forked from M-Labs/humpback-dds
urukul: very bad constructor
This commit is contained in:
parent
69761c4517
commit
49594dfb3b
58
src/lib.rs
58
src/lib.rs
@ -1,7 +1,13 @@
|
||||
#![no_std]
|
||||
extern crate embedded_hal;
|
||||
|
||||
use core::cell;
|
||||
use embedded_hal::{
|
||||
digital::v2::OutputPin,
|
||||
blocking::spi::Transfer,
|
||||
};
|
||||
use core::{
|
||||
cell,
|
||||
marker::PhantomData,
|
||||
};
|
||||
|
||||
use cortex_m;
|
||||
use cortex_m_semihosting::hprintln;
|
||||
@ -10,13 +16,23 @@ use cortex_m_semihosting::hprintln;
|
||||
pub mod bitmask_macro;
|
||||
|
||||
pub mod spi_slave;
|
||||
use crate::spi_slave::Parts;
|
||||
// use crate::spi_slave::{
|
||||
// Parts,
|
||||
// SPISlave,
|
||||
// };
|
||||
|
||||
pub mod cpld;
|
||||
use crate::cpld::CPLD;
|
||||
|
||||
pub mod config_register;
|
||||
use crate::config_register::ConfigRegister;
|
||||
|
||||
pub mod attenuator;
|
||||
use crate::attenuator::Attenuator;
|
||||
|
||||
pub mod dds;
|
||||
use crate::dds::DDS;
|
||||
|
||||
pub mod scpi;
|
||||
|
||||
/*
|
||||
@ -31,3 +47,39 @@ pub enum Error<E> {
|
||||
IOUpdateError,
|
||||
DDSError,
|
||||
}
|
||||
|
||||
/*
|
||||
* Struct for Urukul master device
|
||||
*/
|
||||
pub struct Urukul<SPI> {
|
||||
config_register: ConfigRegister<SPI>,
|
||||
attenuator: Attenuator<SPI>,
|
||||
dds: [DDS<SPI>; 4],
|
||||
}
|
||||
|
||||
impl<SPI, E> Urukul<SPI>
|
||||
where
|
||||
SPI: Transfer<u8, Error = E>,
|
||||
{
|
||||
/*
|
||||
* Master constructor for the entire Urukul device
|
||||
*/
|
||||
pub fn new(spi1: SPI, spi2: SPI, spi3: SPI, spi4: SPI, spi5: SPI, spi6: SPI, spi7: SPI, f_ref_clks: [u64; 4]) -> Self {
|
||||
// Construct cpld and get parts
|
||||
// let switch = CPLD::new(spi, chip_select, io_update);
|
||||
// let parts = switch.split();
|
||||
|
||||
// Construct Urukul
|
||||
Urukul {
|
||||
config_register: ConfigRegister::new(spi1),
|
||||
attenuator: Attenuator::new(spi2),
|
||||
dds: [
|
||||
DDS::new(spi4, f_ref_clks[1]),
|
||||
DDS::new(spi5, f_ref_clks[1]),
|
||||
DDS::new(spi6, f_ref_clks[2]),
|
||||
DDS::new(spi7, f_ref_clks[3]),
|
||||
],
|
||||
// _phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user