summaryrefslogtreecommitdiff
path: root/nrf-softdevice-defmt-rtt
diff options
context:
space:
mode:
authorDario Nieuwenhuis <dirbaio@dirbaio.net>2021-05-10 00:12:22 +0200
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2021-05-10 00:24:02 +0200
commit7e0bf163f35dca8a1daba11429035a7780f5f4b7 (patch)
tree93bace85158e5c2da5e6e19800c3a2dcacd711c1 /nrf-softdevice-defmt-rtt
parent963b2f871556dac53d2d9b4e25cff282e5d90b61 (diff)
downloadnrf-softdevice-7e0bf163f35dca8a1daba11429035a7780f5f4b7.zip
Replace `interrupts` mod with `critical-section` crate
Diffstat (limited to 'nrf-softdevice-defmt-rtt')
-rw-r--r--nrf-softdevice-defmt-rtt/Cargo.toml1
-rw-r--r--nrf-softdevice-defmt-rtt/src/lib.rs7
2 files changed, 4 insertions, 4 deletions
diff --git a/nrf-softdevice-defmt-rtt/Cargo.toml b/nrf-softdevice-defmt-rtt/Cargo.toml
index d4b4be3..611a713 100644
--- a/nrf-softdevice-defmt-rtt/Cargo.toml
+++ b/nrf-softdevice-defmt-rtt/Cargo.toml
@@ -14,3 +14,4 @@ version = "0.1.0"
defmt = { version = "0.2.0" }
nrf-softdevice = { path = "../nrf-softdevice", version = "0.1.0" }
cortex-m = "0.6.4"
+critical-section = { version = "0.1.0" }
diff --git a/nrf-softdevice-defmt-rtt/src/lib.rs b/nrf-softdevice-defmt-rtt/src/lib.rs
index 3889677..0d2cf95 100644
--- a/nrf-softdevice-defmt-rtt/src/lib.rs
+++ b/nrf-softdevice-defmt-rtt/src/lib.rs
@@ -16,7 +16,6 @@ use core::{
ptr::NonNull,
sync::atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering},
};
-use nrf_softdevice::interrupt;
// TODO make configurable
// NOTE use a power of 2 for best performance
@@ -36,7 +35,7 @@ static INTERRUPTS_TOKEN: AtomicU8 = AtomicU8::new(0);
unsafe impl defmt::Logger for Logger {
fn acquire() -> Option<NonNull<dyn defmt::Write>> {
- let token = unsafe { interrupt::disable_all() };
+ let token = unsafe { critical_section::acquire() };
if !TAKEN.load(Ordering::Relaxed) {
// no need for CAS because interrupts are disabled
TAKEN.store(true, Ordering::Relaxed);
@@ -45,14 +44,14 @@ unsafe impl defmt::Logger for Logger {
Some(NonNull::from(&Logger as &dyn defmt::Write))
} else {
- unsafe { interrupt::enable_all(token) };
+ unsafe { critical_section::release(token) };
None
}
}
unsafe fn release(_: NonNull<dyn defmt::Write>) {
TAKEN.store(false, Ordering::Relaxed);
- interrupt::enable_all(INTERRUPTS_TOKEN.load(Ordering::Relaxed));
+ critical_section::release(INTERRUPTS_TOKEN.load(Ordering::Relaxed));
}
}