forked from M-Labs/humpback-dds
30 lines
499 B
Rust
30 lines
499 B
Rust
|
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)
|
||
|
}
|
||
|
}
|