bbqueue
bbqueue copied to clipboard
Use abstract critical sections for thumbv6
This changes the critical sections required for thumbv6 to use the abstraction provided by the critical_section crate. The context here is the RP2040 micocontroller, which is a two core Cortex-M0+ device, so just disabling interrupts on the current core is not sufficient when a bbqueue is used to communicate between cores. However, the HAL provides an implementation of a critical section hooking into the abstraction above to handle this kind of case.
With this change, using bbqueue on single core thumbv6 target (equivalent to the current behavior) looks like:
[dependencies]
bbqueue = { version = "0.5", features = ["thumbv6"] }
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
Or for a RP2040 in multi-core mode:
[dependencies]
bbqueue = { version = "0.5", features = ["thumbv6"] }
rp2040-hal = { version = "0.8.0", features=["critical-section-impl"] }
@ithinuel please feel free to make any breaking changes! I'm open to either using the critical-section crate, or moving to portable-atomic, which can use critical-section as necessary for targets which don't support atomics natively.
Migration to portable-atomic (plus a few other tiny changes) in https://github.com/jamesmunns/bbqueue/pull/103