humpback-dds/src/dds.rs

30 lines
499 B
Rust
Raw Normal View History

2020-08-12 15:31:06 +08:00
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)
}
}