From fe47cafb9316ace9f66fcc5aa2bedf30092a747f Mon Sep 17 00:00:00 2001 From: occheung Date: Wed, 12 Aug 2020 15:31:06 +0800 Subject: [PATCH] dds: init --- src/dds.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/dds.rs diff --git a/src/dds.rs b/src/dds.rs new file mode 100644 index 0000000..476dd71 --- /dev/null +++ b/src/dds.rs @@ -0,0 +1,29 @@ +use embedded_hal::blocking::spi::Transfer; +use cortex_m_semihosting::hprintln; +use crate::Error; + +pub struct DDS { + spi: SPI, +} + +impl DDS +where + SPI: Transfer +{ + pub fn new(spi: SPI) -> Self { + DDS { + spi + } + } +} + +impl Transfer for ConfigRegister +where + SPI: Transfer +{ + type Error = Error; + + fn transfer<'w>(&mut self, words: &'w mut [u8]) -> Result<&'w [u8], Self::Error> { + self.spi.transfer(words).map_err(Error::SPI) + } +}