diff --git a/flashloader/Cargo.toml b/flashloader/Cargo.toml index 15ffcf1..92a9a99 100644 --- a/flashloader/Cargo.toml +++ b/flashloader/Cargo.toml @@ -15,6 +15,7 @@ rtt-log = "0.3" log = "0.4" crc = "3" rtic-sync = "1" +static_cell = "2" [dependencies.satrs] version = "0.2" diff --git a/flashloader/src/main.rs b/flashloader/src/main.rs index 3be9cc6..4b28bcf 100644 --- a/flashloader/src/main.rs +++ b/flashloader/src/main.rs @@ -52,11 +52,11 @@ impl WdtInterface for OptWdt { } } -use once_cell::sync::Lazy; use ringbuf::{ traits::{Consumer, Observer, Producer, SplitRef}, CachingCons, StaticProd, StaticRb, }; +use static_cell::StaticCell; // Larger buffer for TC to be able to hold the possibly large memory write packets. const BUF_RB_SIZE_TC: usize = 2048; @@ -66,16 +66,12 @@ const BUF_RB_SIZE_TM: usize = 512; const SIZES_RB_SIZE_TM: usize = 16; // Ring buffers to handling variable sized telemetry -static mut BUF_RB_TM: Lazy> = - Lazy::new(StaticRb::::default); -static mut SIZES_RB_TM: Lazy> = - Lazy::new(StaticRb::::default); +static BUF_RB_TM: StaticCell> = StaticCell::new(); +static SIZES_RB_TM: StaticCell> = StaticCell::new(); // Ring buffers to handling variable sized telecommands -static mut BUF_RB_TC: Lazy> = - Lazy::new(StaticRb::::default); -static mut SIZES_RB_TC: Lazy> = - Lazy::new(StaticRb::::default); +static BUF_RB_TC: StaticCell> = StaticCell::new(); +static SIZES_RB_TC: StaticCell> = StaticCell::new(); pub struct DataProducer { pub buf_prod: StaticProd<'static, u8, BUF_SIZE>, @@ -166,6 +162,7 @@ mod app { .xtal_n_clk_with_src_freq(Hertz::from_raw(EXTCLK_FREQ)) .freeze(&mut cx.device.sysconfig) .unwrap(); + enable_and_init_irq_router(&mut cx.device.sysconfig, &cx.device.irq_router); setup_edac(&mut cx.device.sysconfig); @@ -184,11 +181,19 @@ mod app { let verif_reporter = VerificationReportCreator::new(0).unwrap(); - let (buf_prod_tm, buf_cons_tm) = unsafe { BUF_RB_TM.split_ref() }; - let (sizes_prod_tm, sizes_cons_tm) = unsafe { SIZES_RB_TM.split_ref() }; + let (buf_prod_tm, buf_cons_tm) = BUF_RB_TM + .init(StaticRb::::default()) + .split_ref(); + let (sizes_prod_tm, sizes_cons_tm) = SIZES_RB_TM + .init(StaticRb::::default()) + .split_ref(); - let (buf_prod_tc, buf_cons_tc) = unsafe { BUF_RB_TC.split_ref() }; - let (sizes_prod_tc, sizes_cons_tc) = unsafe { SIZES_RB_TC.split_ref() }; + let (buf_prod_tc, buf_cons_tc) = BUF_RB_TC + .init(StaticRb::::default()) + .split_ref(); + let (sizes_prod_tc, sizes_cons_tc) = SIZES_RB_TC + .init(StaticRb::::default()) + .split_ref(); Mono::start(cx.core.SYST, clocks.sysclk().raw()); CLOCKS.set(clocks).unwrap(); diff --git a/va416xx-hal/src/gpio/pin.rs b/va416xx-hal/src/gpio/pin.rs index 209190c..b28f629 100644 --- a/va416xx-hal/src/gpio/pin.rs +++ b/va416xx-hal/src/gpio/pin.rs @@ -321,7 +321,6 @@ macro_rules! pin_id { //================================================================================================== /// A type-level GPIO pin, parameterized by [`PinId`] and [`PinMode`] types - pub struct Pin { pub(in crate::gpio) regs: Registers, mode: PhantomData, diff --git a/va416xx-hal/src/uart.rs b/va416xx-hal/src/uart.rs index 822597d..ca97991 100644 --- a/va416xx-hal/src/uart.rs +++ b/va416xx-hal/src/uart.rs @@ -305,17 +305,17 @@ impl IrqResultMaxSizeOrTimeout { #[inline] pub fn overflow_error(&self) -> bool { - self.errors.map_or(false, |e| e.overflow) + self.errors.is_some_and(|e| e.overflow) } #[inline] pub fn framing_error(&self) -> bool { - self.errors.map_or(false, |e| e.framing) + self.errors.is_some_and(|e| e.framing) } #[inline] pub fn parity_error(&self) -> bool { - self.errors.map_or(false, |e| e.parity) + self.errors.is_some_and(|e| e.parity) } #[inline]