From 066abfe4c661046222ea4a059d795065f1ad0479 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 18 Aug 2021 22:12:36 +0200 Subject: [PATCH] nrf/time: allow configuring the rtc irq prio --- embassy-nrf/src/lib.rs | 4 +++- embassy-nrf/src/time_driver.rs | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index e846746b8..0de4b4390 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs @@ -99,6 +99,7 @@ pub mod config { pub hfclk_source: HfclkSource, pub lfclk_source: LfclkSource, pub gpiote_interrupt_priority: crate::interrupt::Priority, + pub time_interrupt_priority: crate::interrupt::Priority, } impl Default for Config { @@ -110,6 +111,7 @@ pub mod config { hfclk_source: HfclkSource::Internal, lfclk_source: LfclkSource::InternalRC, gpiote_interrupt_priority: crate::interrupt::Priority::P0, + time_interrupt_priority: crate::interrupt::Priority::P0, } } } @@ -165,7 +167,7 @@ pub fn init(config: config::Config) -> Peripherals { gpiote::init(config.gpiote_interrupt_priority); // init RTC time driver - time_driver::init(); + time_driver::init(config.time_interrupt_priority); peripherals } diff --git a/embassy-nrf/src/time_driver.rs b/embassy-nrf/src/time_driver.rs index f3d07e98d..30461633a 100644 --- a/embassy-nrf/src/time_driver.rs +++ b/embassy-nrf/src/time_driver.rs @@ -98,7 +98,7 @@ static STATE: State = State { }; impl State { - fn init(&'static self) { + fn init(&'static self, irq_prio: crate::interrupt::Priority) { let r = rtc(); r.cc[3].write(|w| unsafe { w.bits(0x800000) }); @@ -114,7 +114,9 @@ impl State { // Wait for clear while r.counter.read().bits() != 0 {} - unsafe { interrupt::RTC1::steal() }.enable(); + let irq = unsafe { interrupt::RTC1::steal() }; + irq.set_priority(irq_prio); + irq.enable(); } fn on_interrupt(&self) { @@ -287,6 +289,6 @@ fn RTC1() { STATE.on_interrupt() } -pub(crate) fn init() { - STATE.init() +pub(crate) fn init(irq_prio: crate::interrupt::Priority) { + STATE.init(irq_prio) }