aboutsummaryrefslogtreecommitdiff
path: root/rtic-monotonics/src/nrf/rtc.rs
diff options
context:
space:
mode:
authorEmil Fresk <emil.fresk@gmail.com>2023-04-02 20:32:10 +0200
committerEmil Fresk <emil.fresk@gmail.com>2023-04-04 21:40:19 +0200
commitaeec8bd41bdf3d57098902407ec320f59365641a (patch)
tree024dbdb94cb5537312c5c34f121257265c165bea /rtic-monotonics/src/nrf/rtc.rs
parenta2f153249f926876e7169016f3dc8e861a9ef065 (diff)
Add setting of priority to interrupts
Diffstat (limited to 'rtic-monotonics/src/nrf/rtc.rs')
-rw-r--r--rtic-monotonics/src/nrf/rtc.rs31
1 files changed, 20 insertions, 11 deletions
diff --git a/rtic-monotonics/src/nrf/rtc.rs b/rtic-monotonics/src/nrf/rtc.rs
index 724c477..03610c0 100644
--- a/rtic-monotonics/src/nrf/rtc.rs
+++ b/rtic-monotonics/src/nrf/rtc.rs
@@ -5,19 +5,22 @@
//! ```
//! use rtic_monotonics::nrf::rtc::*;
//!
-//! # async fn usage() {
-//! # let rtc = unsafe { core::mem::transmute(()) };
-//! // Generate the required token
-//! let token = rtic_monotonics::create_nrf_rtc0_monotonic_token!();
+//! fn init() {
+//! # // This is normally provided by the selected PAC
+//! # let rtc = unsafe { core::mem::transmute(()) };
+//! // Generate the required token
+//! let token = rtic_monotonics::create_nrf_rtc0_monotonic_token!();
//!
-//! // Start the monotonic
-//! Rtc0::start(rtc, token);
+//! // Start the monotonic
+//! Rtc0::start(rtc, token);
+//! }
//!
-//! loop {
-//! // Use the monotonic
-//! Rtc0::delay(100.millis()).await;
+//! async fn usage() {
+//! loop {
+//! // Use the monotonic
+//! Rtc0::delay(100.millis()).await;
+//! }
//! }
-//! # }
//! ```
#[cfg(feature = "nrf52810")]
@@ -106,7 +109,13 @@ macro_rules! make_rtc {
$tq.initialize(Self {});
- unsafe { pac::NVIC::unmask(Interrupt::$rtc) };
+ // SAFETY: We take full ownership of the peripheral and interrupt vector,
+ // plus we are not using any external shared resources so we won't impact
+ // basepri/source masking based critical sections.
+ unsafe {
+ crate::set_monotonic_prio(pac::NVIC_PRIO_BITS, Interrupt::$rtc);
+ pac::NVIC::unmask(Interrupt::$rtc);
+ }
}
/// Used to access the underlying timer queue