Merge pull request #364 from embassy-rs/nrf-time-irq-prio

nrf/time: allow configuring the rtc irq prio
This commit is contained in:
Dario Nieuwenhuis 2021-08-18 22:17:46 +02:00 committed by GitHub
commit c0fb534a00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -99,6 +99,7 @@ pub mod config {
pub hfclk_source: HfclkSource, pub hfclk_source: HfclkSource,
pub lfclk_source: LfclkSource, pub lfclk_source: LfclkSource,
pub gpiote_interrupt_priority: crate::interrupt::Priority, pub gpiote_interrupt_priority: crate::interrupt::Priority,
pub time_interrupt_priority: crate::interrupt::Priority,
} }
impl Default for Config { impl Default for Config {
@ -110,6 +111,7 @@ pub mod config {
hfclk_source: HfclkSource::Internal, hfclk_source: HfclkSource::Internal,
lfclk_source: LfclkSource::InternalRC, lfclk_source: LfclkSource::InternalRC,
gpiote_interrupt_priority: crate::interrupt::Priority::P0, 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); gpiote::init(config.gpiote_interrupt_priority);
// init RTC time driver // init RTC time driver
time_driver::init(); time_driver::init(config.time_interrupt_priority);
peripherals peripherals
} }

View File

@ -98,7 +98,7 @@ static STATE: State = State {
}; };
impl State { impl State {
fn init(&'static self) { fn init(&'static self, irq_prio: crate::interrupt::Priority) {
let r = rtc(); let r = rtc();
r.cc[3].write(|w| unsafe { w.bits(0x800000) }); r.cc[3].write(|w| unsafe { w.bits(0x800000) });
@ -114,7 +114,9 @@ impl State {
// Wait for clear // Wait for clear
while r.counter.read().bits() != 0 {} 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) { fn on_interrupt(&self) {
@ -287,6 +289,6 @@ fn RTC1() {
STATE.on_interrupt() STATE.on_interrupt()
} }
pub(crate) fn init() { pub(crate) fn init(irq_prio: crate::interrupt::Priority) {
STATE.init() STATE.init(irq_prio)
} }