diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-08-18 22:17:46 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-08-18 22:17:46 +0200 |
| commit | c0fb534a00165a008f47556d12abd58b6510a82c (patch) | |
| tree | b011d3387025dddb2afd3859f8bd8607440a5347 | |
| parent | 2b5d1c068fe87fdc119e2a3fab3d4996f7c30f5f (diff) | |
| parent | 066abfe4c661046222ea4a059d795065f1ad0479 (diff) | |
Merge pull request #364 from embassy-rs/nrf-time-irq-prio
nrf/time: allow configuring the rtc irq prio
| -rw-r--r-- | embassy-nrf/src/lib.rs | 4 | ||||
| -rw-r--r-- | 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 { | |||
| 99 | pub hfclk_source: HfclkSource, | 99 | pub hfclk_source: HfclkSource, |
| 100 | pub lfclk_source: LfclkSource, | 100 | pub lfclk_source: LfclkSource, |
| 101 | pub gpiote_interrupt_priority: crate::interrupt::Priority, | 101 | pub gpiote_interrupt_priority: crate::interrupt::Priority, |
| 102 | pub time_interrupt_priority: crate::interrupt::Priority, | ||
| 102 | } | 103 | } |
| 103 | 104 | ||
| 104 | impl Default for Config { | 105 | impl Default for Config { |
| @@ -110,6 +111,7 @@ pub mod config { | |||
| 110 | hfclk_source: HfclkSource::Internal, | 111 | hfclk_source: HfclkSource::Internal, |
| 111 | lfclk_source: LfclkSource::InternalRC, | 112 | lfclk_source: LfclkSource::InternalRC, |
| 112 | gpiote_interrupt_priority: crate::interrupt::Priority::P0, | 113 | gpiote_interrupt_priority: crate::interrupt::Priority::P0, |
| 114 | time_interrupt_priority: crate::interrupt::Priority::P0, | ||
| 113 | } | 115 | } |
| 114 | } | 116 | } |
| 115 | } | 117 | } |
| @@ -165,7 +167,7 @@ pub fn init(config: config::Config) -> Peripherals { | |||
| 165 | gpiote::init(config.gpiote_interrupt_priority); | 167 | gpiote::init(config.gpiote_interrupt_priority); |
| 166 | 168 | ||
| 167 | // init RTC time driver | 169 | // init RTC time driver |
| 168 | time_driver::init(); | 170 | time_driver::init(config.time_interrupt_priority); |
| 169 | 171 | ||
| 170 | peripherals | 172 | peripherals |
| 171 | } | 173 | } |
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 { | |||
| 98 | }; | 98 | }; |
| 99 | 99 | ||
| 100 | impl State { | 100 | impl State { |
| 101 | fn init(&'static self) { | 101 | fn init(&'static self, irq_prio: crate::interrupt::Priority) { |
| 102 | let r = rtc(); | 102 | let r = rtc(); |
| 103 | r.cc[3].write(|w| unsafe { w.bits(0x800000) }); | 103 | r.cc[3].write(|w| unsafe { w.bits(0x800000) }); |
| 104 | 104 | ||
| @@ -114,7 +114,9 @@ impl State { | |||
| 114 | // Wait for clear | 114 | // Wait for clear |
| 115 | while r.counter.read().bits() != 0 {} | 115 | while r.counter.read().bits() != 0 {} |
| 116 | 116 | ||
| 117 | unsafe { interrupt::RTC1::steal() }.enable(); | 117 | let irq = unsafe { interrupt::RTC1::steal() }; |
| 118 | irq.set_priority(irq_prio); | ||
| 119 | irq.enable(); | ||
| 118 | } | 120 | } |
| 119 | 121 | ||
| 120 | fn on_interrupt(&self) { | 122 | fn on_interrupt(&self) { |
| @@ -287,6 +289,6 @@ fn RTC1() { | |||
| 287 | STATE.on_interrupt() | 289 | STATE.on_interrupt() |
| 288 | } | 290 | } |
| 289 | 291 | ||
| 290 | pub(crate) fn init() { | 292 | pub(crate) fn init(irq_prio: crate::interrupt::Priority) { |
| 291 | STATE.init() | 293 | STATE.init(irq_prio) |
| 292 | } | 294 | } |
