Skip to content

#[init()] functions should provide a CriticalSection  #32

Closed
@BryanKadzban

Description

@BryanKadzban

In my program's #[init()] function (using rtfm-0.5) I have to reconfigure a bunch of GPIO pins from the stm32f0xx_hal crate in order to pass them to HAL constructors like Spi::spi1() and I2c::i2c1(). Each of those GPIO-configuration calls requires a CriticalSection. OK, I can run the call inside a cortex_m::interrupt::free() callback ... but the RTFM framework already disables interrupts before it calls the init() function, so the read-PRIMASK, cpsid, and test-old-PRIMASK-and-branch sequences from cortex_m::interrupt::free are unnecessary inside init(). But I can't express that (unless I unsafely create a CriticalSection of my own at the top of init()).

It would be nice if init::Context contained a CriticalSection so I could pass a reference to it into the HAL crate's gpioa::PA0::into_alternate_af4() function (or whichever one I need to call).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions