diff options
| author | shufps <[email protected]> | 2024-01-14 22:31:19 +0100 |
|---|---|---|
| committer | shufps <[email protected]> | 2024-01-15 08:11:22 +0100 |
| commit | 4e2361c024187d2ddba8596b05f013ad8a52a28c (patch) | |
| tree | 420d5e41609bcaf930d2e3e121ce83ef1798b161 /embassy-stm32/src/time_driver.rs | |
| parent | 131ef00658903420fb08e4666c01d93c3b5fd943 (diff) | |
adds timer-driver for tim21 and tim22 (on L0)
Diffstat (limited to 'embassy-stm32/src/time_driver.rs')
| -rw-r--r-- | embassy-stm32/src/time_driver.rs | 24 |
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)))] |
| 32 | const ALARM_COUNT: usize = 3; | 32 | const 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))] |
| 35 | const ALARM_COUNT: usize = 1; | 35 | const ALARM_COUNT: usize = 1; |
| 36 | 36 | ||
| 37 | #[cfg(time_driver_tim2)] | 37 | #[cfg(time_driver_tim2)] |
| @@ -50,6 +50,10 @@ type T = peripherals::TIM11; | |||
| 50 | type T = peripherals::TIM12; | 50 | type T = peripherals::TIM12; |
| 51 | #[cfg(time_driver_tim15)] | 51 | #[cfg(time_driver_tim15)] |
| 52 | type T = peripherals::TIM15; | 52 | type T = peripherals::TIM15; |
| 53 | #[cfg(time_driver_tim21)] | ||
| 54 | type T = peripherals::TIM21; | ||
| 55 | #[cfg(time_driver_tim22)] | ||
| 56 | type T = peripherals::TIM22; | ||
| 53 | 57 | ||
| 54 | foreach_interrupt! { | 58 | foreach_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 |
