mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2025-01-23 09:46:33 +11:00
Feature-gate critical-section-impl
For compatibility with earlier versions, this feature is activated by default. This decision can be revisited later.
This commit is contained in:
parent
b4d0d613e3
commit
c1c5e05989
2 changed files with 9 additions and 1 deletions
|
@ -25,8 +25,10 @@ usb-device = "0.2.9"
|
||||||
vcell = "0.1"
|
vcell = "0.1"
|
||||||
void = { version = "1.0.2", default-features = false }
|
void = { version = "1.0.2", default-features = false }
|
||||||
rand_core = "0.6.3"
|
rand_core = "0.6.3"
|
||||||
|
# Always set the custom-impl feature of legacy critical-section, even if we don't provide our own,
|
||||||
|
# as the default implementation should no longer be used.
|
||||||
critical-section_0_2 = { package = "critical-section", version = "0.2.4", features = ["custom-impl"] }
|
critical-section_0_2 = { package = "critical-section", version = "0.2.4", features = ["custom-impl"] }
|
||||||
critical-section = { version = "1.0.0", features = ["restore-state-u8"] }
|
critical-section = { version = "1.0.0" }
|
||||||
|
|
||||||
futures = { version = "0.3", default-features = false, optional = true }
|
futures = { version = "0.3", default-features = false, optional = true }
|
||||||
chrono = { version = "0.4", default-features = false, optional = true }
|
chrono = { version = "0.4", default-features = false, optional = true }
|
||||||
|
@ -42,11 +44,13 @@ pio-proc = "0.2.0"
|
||||||
dht-sensor = "0.2.1"
|
dht-sensor = "0.2.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
default = ["critical-section-impl"]
|
||||||
rt = ["rp2040-pac/rt"]
|
rt = ["rp2040-pac/rt"]
|
||||||
rom-func-cache = []
|
rom-func-cache = []
|
||||||
disable-intrinsics = []
|
disable-intrinsics = []
|
||||||
rom-v2-intrinsics = []
|
rom-v2-intrinsics = []
|
||||||
rp2040-e5 = [] # USB errata 5: USB device fails to exit RESET state on busy USB bus.
|
rp2040-e5 = [] # USB errata 5: USB device fails to exit RESET state on busy USB bus.
|
||||||
|
critical-section-impl = ["critical-section/restore-state-u8"]
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
# irq example uses cortex-m-rt::interrupt, need rt feature for that
|
# irq example uses cortex-m-rt::interrupt, need rt feature for that
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
use core::sync::atomic::{AtomicU8, Ordering};
|
use core::sync::atomic::{AtomicU8, Ordering};
|
||||||
|
|
||||||
struct RpSpinlockCs;
|
struct RpSpinlockCs;
|
||||||
|
#[cfg(feature = "critical-section-impl")]
|
||||||
critical_section_0_2::custom_impl!(RpSpinlockCs);
|
critical_section_0_2::custom_impl!(RpSpinlockCs);
|
||||||
|
#[cfg(feature = "critical-section-impl")]
|
||||||
critical_section::set_impl!(RpSpinlockCs);
|
critical_section::set_impl!(RpSpinlockCs);
|
||||||
|
|
||||||
/// Marker value to indicate no-one has the lock.
|
/// Marker value to indicate no-one has the lock.
|
||||||
|
@ -22,6 +24,7 @@ static mut LOCK_OWNER: AtomicU8 = AtomicU8::new(LOCK_UNOWNED);
|
||||||
/// The value 2 indicates that we aren't the outermost call, and should not release the spinlock or re-enable interrupts in `release`
|
/// The value 2 indicates that we aren't the outermost call, and should not release the spinlock or re-enable interrupts in `release`
|
||||||
const LOCK_ALREADY_OWNED: u8 = 2;
|
const LOCK_ALREADY_OWNED: u8 = 2;
|
||||||
|
|
||||||
|
#[cfg(feature = "critical-section-impl")]
|
||||||
unsafe impl critical_section_0_2::Impl for RpSpinlockCs {
|
unsafe impl critical_section_0_2::Impl for RpSpinlockCs {
|
||||||
unsafe fn acquire() -> u8 {
|
unsafe fn acquire() -> u8 {
|
||||||
RpSpinlockCs::acquire()
|
RpSpinlockCs::acquire()
|
||||||
|
@ -32,6 +35,7 @@ unsafe impl critical_section_0_2::Impl for RpSpinlockCs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "critical-section-impl")]
|
||||||
unsafe impl critical_section::Impl for RpSpinlockCs {
|
unsafe impl critical_section::Impl for RpSpinlockCs {
|
||||||
unsafe fn acquire() -> u8 {
|
unsafe fn acquire() -> u8 {
|
||||||
RpSpinlockCs::acquire()
|
RpSpinlockCs::acquire()
|
||||||
|
|
Loading…
Add table
Reference in a new issue