forked from M-Labs/humpback-dds
dds: init
This commit is contained in:
parent
b2d605551a
commit
fe47cafb93
29
src/dds.rs
Normal file
29
src/dds.rs
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user