diff --git a/firmware/src/board/delay.rs b/firmware/src/board/delay.rs index e0d7305..0201681 100644 --- a/firmware/src/board/delay.rs +++ b/firmware/src/board/delay.rs @@ -11,9 +11,9 @@ pub struct Delay { } impl Delay { - pub fn new() -> Self { - let mut cp = unsafe { tm4c129x::CorePeripherals::steal() }; - let mut syst = cp.SYST; + /// unsafe: must only be used once to avoid concurrent use of systick + pub unsafe fn new() -> Self { + let mut syst = CorePeripherals::steal().SYST; // PIOSC syst.set_clock_source(SystClkSource::External); syst.disable_interrupt(); diff --git a/firmware/src/board/softspi.rs b/firmware/src/board/softspi.rs index f5bd286..d222634 100644 --- a/firmware/src/board/softspi.rs +++ b/firmware/src/board/softspi.rs @@ -137,6 +137,7 @@ impl<'d, SCK: OutputPin, MOSI: OutputPin, MISO: InputPin, D: FnMut()> SyncSoftSp } impl<'d, SCK: OutputPin, MOSI: OutputPin, MISO: InputPin, D: FnMut()> Transfer for SyncSoftSpi<'d, SCK, MOSI, MISO, D> { + // TODO: proper type type Error = (); fn transfer<'w>(&mut self, words: &'w mut [u8]) -> Result<&'w [u8], Self::Error> { for b in words.iter_mut() { diff --git a/firmware/src/main.rs b/firmware/src/main.rs index deb0bbf..d0aa4b2 100644 --- a/firmware/src/main.rs +++ b/firmware/src/main.rs @@ -53,6 +53,7 @@ mod ethmac; static ADC_IRQ_COUNT: Mutex> = Mutex::new(Cell::new(0)); +// TODO: remove fn get_time_ms() -> u64 { let adc_irq_count = cortex_m::interrupt::free(|cs| { ADC_IRQ_COUNT.borrow(cs).get() @@ -115,8 +116,8 @@ fn main() -> ! { | | |_| "#); - let mut delay = board::delay::Delay::new(); - // SCK + let mut delay = unsafe { board::delay::Delay::new() }; + // CSn let pb4 = board::gpio::PB4.into_output(); // SCLK let pb5 = board::gpio::PB5.into_output();