aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Tran <[email protected]>2025-09-21 23:01:03 -0500
committerMatthew Tran <[email protected]>2025-09-21 23:01:03 -0500
commitc692a97b654adc50f997852a360ce3277cb73db4 (patch)
treee9f409e584214c8c3e903fffa9735546a41bbccd
parent539837a7485381f83ef078595a4e248a0ea11436 (diff)
nrf: impl Drop for Timer
-rw-r--r--embassy-nrf/src/timer.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs
index de2875765..b6a77bd2e 100644
--- a/embassy-nrf/src/timer.rs
+++ b/embassy-nrf/src/timer.rs
@@ -104,7 +104,7 @@ impl<'d, T: Instance> Timer<'d, T> {
104 Self::new_inner(timer, true) 104 Self::new_inner(timer, true)
105 } 105 }
106 106
107 fn new_inner(timer: Peri<'d, T>, _is_counter: bool) -> Self { 107 fn new_inner(timer: Peri<'d, T>, is_counter: bool) -> Self {
108 let regs = T::regs(); 108 let regs = T::regs();
109 109
110 let this = Self { _p: timer }; 110 let this = Self { _p: timer };
@@ -114,7 +114,7 @@ impl<'d, T: Instance> Timer<'d, T> {
114 this.stop(); 114 this.stop();
115 115
116 regs.mode().write(|w| { 116 regs.mode().write(|w| {
117 w.set_mode(match _is_counter { 117 w.set_mode(match is_counter {
118 #[cfg(not(feature = "_nrf51"))] 118 #[cfg(not(feature = "_nrf51"))]
119 true => vals::Mode::LOW_POWER_COUNTER, 119 true => vals::Mode::LOW_POWER_COUNTER,
120 #[cfg(feature = "_nrf51")] 120 #[cfg(feature = "_nrf51")]
@@ -218,6 +218,12 @@ impl<'d, T: Instance> Timer<'d, T> {
218 } 218 }
219} 219}
220 220
221impl<'d, T: Instance> Drop for Timer<'d, T> {
222 fn drop(&mut self) {
223 self.stop();
224 }
225}
226
221/// A representation of a timer's Capture/Compare (CC) register. 227/// A representation of a timer's Capture/Compare (CC) register.
222/// 228///
223/// A CC register holds a 32-bit value. 229/// A CC register holds a 32-bit value.