Merge pull request #364 from embassy-rs/nrf-time-irq-prio
nrf/time: allow configuring the rtc irq prio
This commit is contained in:
commit
c0fb534a00
2 changed files with 9 additions and 5 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue