aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src
diff options
context:
space:
mode:
authorshufps <[email protected]>2024-01-14 22:31:19 +0100
committershufps <[email protected]>2024-01-15 08:11:22 +0100
commit4e2361c024187d2ddba8596b05f013ad8a52a28c (patch)
tree420d5e41609bcaf930d2e3e121ce83ef1798b161 /embassy-stm32/src
parent131ef00658903420fb08e4666c01d93c3b5fd943 (diff)
adds timer-driver for tim21 and tim22 (on L0)
Diffstat (limited to 'embassy-stm32/src')
-rw-r--r--embassy-stm32/src/time_driver.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs
index 0dbadce0c..d613394ef 100644
--- a/embassy-stm32/src/time_driver.rs
+++ b/embassy-stm32/src/time_driver.rs
@@ -28,10 +28,10 @@ use crate::{interrupt, peripherals};
28// available after reserving CC1 for regular time keeping. For example, TIM2 has four CC registers: 28// available after reserving CC1 for regular time keeping. For example, TIM2 has four CC registers:
29// CC1, CC2, CC3, and CC4, so it can provide ALARM_COUNT = 3. 29// CC1, CC2, CC3, and CC4, so it can provide ALARM_COUNT = 3.
30 30
31#[cfg(not(any(time_driver_tim12, time_driver_tim15)))] 31#[cfg(not(any(time_driver_tim12, time_driver_tim15, time_driver_tim21, time_driver_tim22)))]
32const ALARM_COUNT: usize = 3; 32const ALARM_COUNT: usize = 3;
33 33
34#[cfg(any(time_driver_tim12, time_driver_tim15))] 34#[cfg(any(time_driver_tim12, time_driver_tim15, time_driver_tim21, time_driver_tim22))]
35const ALARM_COUNT: usize = 1; 35const ALARM_COUNT: usize = 1;
36 36
37#[cfg(time_driver_tim2)] 37#[cfg(time_driver_tim2)]
@@ -50,6 +50,10 @@ type T = peripherals::TIM11;
50type T = peripherals::TIM12; 50type T = peripherals::TIM12;
51#[cfg(time_driver_tim15)] 51#[cfg(time_driver_tim15)]
52type T = peripherals::TIM15; 52type T = peripherals::TIM15;
53#[cfg(time_driver_tim21)]
54type T = peripherals::TIM21;
55#[cfg(time_driver_tim22)]
56type T = peripherals::TIM22;
53 57
54foreach_interrupt! { 58foreach_interrupt! {
55 (TIM2, timer, $block:ident, UP, $irq:ident) => { 59 (TIM2, timer, $block:ident, UP, $irq:ident) => {
@@ -116,6 +120,22 @@ foreach_interrupt! {
116 DRIVER.on_interrupt() 120 DRIVER.on_interrupt()
117 } 121 }
118 }; 122 };
123 (TIM21, timer, $block:ident, UP, $irq:ident) => {
124 #[cfg(time_driver_tim21)]
125 #[cfg(feature = "rt")]
126 #[interrupt]
127 fn $irq() {
128 DRIVER.on_interrupt()
129 }
130 };
131 (TIM22, timer, $block:ident, UP, $irq:ident) => {
132 #[cfg(time_driver_tim22)]
133 #[cfg(feature = "rt")]
134 #[interrupt]
135 fn $irq() {
136 DRIVER.on_interrupt()
137 }
138 };
119} 139}
120 140
121// Clock timekeeping works with something we call "periods", which are time intervals 141// Clock timekeeping works with something we call "periods", which are time intervals