Description
Currently (since rtic-rs/rfcs#32) the init::Context
contains a bare_metal
critical section token to indicate that the initialization routine runs with interrupts disabled. This causes issues when trying to use RTIC with the STM32F0 HAL and an updated cortex-m
crate, which has moved away from using bare_metal
to instead use critical_section
in rust-embedded/cortex-m#447.
With stm32-rs/stm32f0xx-hal#180, the STM32F0 HAL is going to be usable with more recent cortex-m
versions, but this will instead introduce an incompatibility with RTIC which will require users to work around this incompatibility with a bit of unsafe
:
#[init]
fn init(mut cx: init::Context) -> (Shared, Local) {
let cs = unsafe { critical_section::CriticalSection::new() };
// ...
}
This isn't a show-stopper but given that critical_section::CriticalSection
already seems to be used elsewhere in RTIC, and that STM32F0 seems to be the origin of the bare_metal
CS to begin with, it seems reasonable to move that CS to critical_section
as well.