rp-rs / rp2040-pac

A Rust PAC for the RP2040 Microcontroller
142 stars 28 forks source link

Use critical section instead of disabling interrupts #72

Closed tana closed 1 year ago

tana commented 1 year ago

This PR replaces an interruption-free section inside Peripherals::take() with more generic critical section using critical_section crate.

Critical sections implemented with just disabling interrupts are unsound on multicore environments, because other core can still modify data. critical_section crate can mitigate this problem because it can be implemented in multicore-safe way, as in rp2040-hal.

Also, it improves compatibility with newer, unreleased version of cortex-m which has different signature of interrupt::free.

tana commented 1 year ago

This PR is closed because this problem is already addressed in svd2rust. Sorry for the inconvenience.

tana commented 1 year ago

This PR is closed because this problem is already addressed in svd2rust. Sorry for the inconvenience.