dds: init

This commit is contained in:
occheung 2020-08-12 15:31:06 +08:00
parent b2d605551a
commit fe47cafb93
1 changed files with 29 additions and 0 deletions

29
src/dds.rs Normal file
View File

@ -0,0 +1,29 @@
use embedded_hal::blocking::spi::Transfer;
use cortex_m_semihosting::hprintln;
use crate::Error;
pub struct DDS<SPI> {
spi: SPI,
}
impl<SPI, E> DDS<SPI>
where
SPI: Transfer<u8, Error= E>
{
pub fn new(spi: SPI) -> Self {
DDS {
spi
}
}
}
impl<SPI, E> Transfer<u8> for ConfigRegister<SPI>
where
SPI: Transfer<u8, Error = E>
{
type Error = Error<E>;
fn transfer<'w>(&mut self, words: &'w mut [u8]) -> Result<&'w [u8], Self::Error> {
self.spi.transfer(words).map_err(Error::SPI)
}
}