diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-07-24 21:52:36 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-24 21:52:36 +0000 |
| commit | 4e9d38fef0b64e000ea8d2e04e34ec656028c44e (patch) | |
| tree | a16ecba1950b7dc40e477df800d8c63b7f90ca4b /embassy-stm32/src | |
| parent | 915513753aea689f73d1300acc069ac985be3a0b (diff) | |
| parent | 4301016f155fd26a3934fb9e7bd2920107a32910 (diff) | |
Merge pull request #4305 from annie444/main
Add helper methods for the low-power interrupt timer.
Diffstat (limited to 'embassy-stm32/src')
| -rw-r--r-- | embassy-stm32/src/lptim/timer/mod.rs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/embassy-stm32/src/lptim/timer/mod.rs b/embassy-stm32/src/lptim/timer/mod.rs index a629be62b..648da5940 100644 --- a/embassy-stm32/src/lptim/timer/mod.rs +++ b/embassy-stm32/src/lptim/timer/mod.rs | |||
| @@ -115,6 +115,31 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 115 | .ccmr(0) | 115 | .ccmr(0) |
| 116 | .modify(|w| w.set_ccsel(channel.index(), direction.into())); | 116 | .modify(|w| w.set_ccsel(channel.index(), direction.into())); |
| 117 | } | 117 | } |
| 118 | |||
| 119 | /// Enable the timer interrupt. | ||
| 120 | pub fn enable_interrupt(&self) { | ||
| 121 | T::regs().dier().modify(|w| w.set_arrmie(true)); | ||
| 122 | } | ||
| 123 | |||
| 124 | /// Disable the timer interrupt. | ||
| 125 | pub fn disable_interrupt(&self) { | ||
| 126 | T::regs().dier().modify(|w| w.set_arrmie(false)); | ||
| 127 | } | ||
| 128 | |||
| 129 | /// Check if the timer interrupt is enabled. | ||
| 130 | pub fn is_interrupt_enabled(&self) -> bool { | ||
| 131 | T::regs().dier().read().arrmie() | ||
| 132 | } | ||
| 133 | |||
| 134 | /// Check if the timer interrupt is pending. | ||
| 135 | pub fn is_interrupt_pending(&self) -> bool { | ||
| 136 | T::regs().isr().read().arrm() | ||
| 137 | } | ||
| 138 | |||
| 139 | /// Clear the timer interrupt. | ||
| 140 | pub fn clear_interrupt(&self) { | ||
| 141 | T::regs().icr().write(|w| w.set_arrmcf(true)); | ||
| 142 | } | ||
| 118 | } | 143 | } |
| 119 | 144 | ||
| 120 | #[cfg(not(any(lptim_v2a, lptim_v2b)))] | 145 | #[cfg(not(any(lptim_v2a, lptim_v2b)))] |
| @@ -128,4 +153,29 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 128 | pub fn get_compare_value(&self) -> u16 { | 153 | pub fn get_compare_value(&self) -> u16 { |
| 129 | T::regs().cmp().read().cmp() | 154 | T::regs().cmp().read().cmp() |
| 130 | } | 155 | } |
| 156 | |||
| 157 | /// Enable the timer interrupt. | ||
| 158 | pub fn enable_interrupt(&self) { | ||
| 159 | T::regs().ier().modify(|w| w.set_arrmie(true)); | ||
| 160 | } | ||
| 161 | |||
| 162 | /// Disable the timer interrupt. | ||
| 163 | pub fn disable_interrupt(&self) { | ||
| 164 | T::regs().ier().modify(|w| w.set_arrmie(false)); | ||
| 165 | } | ||
| 166 | |||
| 167 | /// Check if the timer interrupt is enabled. | ||
| 168 | pub fn is_interrupt_enabled(&self) -> bool { | ||
| 169 | T::regs().ier().read().arrmie() | ||
| 170 | } | ||
| 171 | |||
| 172 | /// Check if the timer interrupt is pending. | ||
| 173 | pub fn is_interrupt_pending(&self) -> bool { | ||
| 174 | T::regs().isr().read().arrm() | ||
| 175 | } | ||
| 176 | |||
| 177 | /// Clear the timer interrupt. | ||
| 178 | pub fn clear_interrupt(&self) { | ||
| 179 | T::regs().icr().write(|w| w.set_arrmcf(true)); | ||
| 180 | } | ||
| 131 | } | 181 | } |
