aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src/timer.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-05-11 03:04:59 +0200
committerDario Nieuwenhuis <[email protected]>2021-05-17 00:57:20 +0200
commitbd9589d0ce71a2aa41c9fdf439d6de6349a09d83 (patch)
treebed94fa0d977604b1f9cbcb09d27b44791aca404 /embassy-nrf/src/timer.rs
parentcd4111736c0384b1ef957df7f6aa51e3727c29b2 (diff)
nrf: add support for nrf52805, nrf52811, nrf52820
Diffstat (limited to 'embassy-nrf/src/timer.rs')
-rw-r--r--embassy-nrf/src/timer.rs34
1 files changed, 14 insertions, 20 deletions
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs
index d74e3cfad..69d620b48 100644
--- a/embassy-nrf/src/timer.rs
+++ b/embassy-nrf/src/timer.rs
@@ -1,8 +1,10 @@
1#![macro_use]
2
1use embassy::interrupt::Interrupt; 3use embassy::interrupt::Interrupt;
2 4
3use crate::{interrupt, pac, peripherals}; 5use crate::pac;
4 6
5mod sealed { 7pub(crate) mod sealed {
6 use super::*; 8 use super::*;
7 9
8 pub trait Instance { 10 pub trait Instance {
@@ -16,28 +18,20 @@ pub trait Instance: sealed::Instance + 'static {
16} 18}
17pub trait ExtendedInstance: Instance + sealed::ExtendedInstance {} 19pub trait ExtendedInstance: Instance + sealed::ExtendedInstance {}
18 20
19macro_rules! impl_instance { 21macro_rules! impl_timer {
20 ($type:ident, $irq:ident) => { 22 ($type:ident, $pac_type:ident, $irq:ident) => {
21 impl sealed::Instance for peripherals::$type { 23 impl crate::timer::sealed::Instance for peripherals::$type {
22 fn regs(&self) -> &pac::timer0::RegisterBlock { 24 fn regs(&self) -> &pac::timer0::RegisterBlock {
23 unsafe { &*(pac::$type::ptr() as *const pac::timer0::RegisterBlock) } 25 unsafe { &*(pac::$pac_type::ptr() as *const pac::timer0::RegisterBlock) }
24 } 26 }
25 } 27 }
26 impl Instance for peripherals::$type { 28 impl crate::timer::Instance for peripherals::$type {
27 type Interrupt = interrupt::$irq; 29 type Interrupt = crate::interrupt::$irq;
28 } 30 }
29 }; 31 };
30 ($type:ident, $irq:ident, extended) => { 32 ($type:ident, $pac_type:ident, $irq:ident, extended) => {
31 impl_instance!($type, $irq); 33 impl_timer!($type, $pac_type, $irq);
32 impl sealed::ExtendedInstance for peripherals::$type {} 34 impl crate::timer::sealed::ExtendedInstance for peripherals::$type {}
33 impl ExtendedInstance for peripherals::$type {} 35 impl crate::timer::ExtendedInstance for peripherals::$type {}
34 }; 36 };
35} 37}
36
37impl_instance!(TIMER0, TIMER0);
38impl_instance!(TIMER1, TIMER1);
39impl_instance!(TIMER2, TIMER2);
40#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
41impl_instance!(TIMER3, TIMER3, extended);
42#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
43impl_instance!(TIMER4, TIMER4, extended);