mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-09-27 20:30:29 +00:00
nrf: impl Drop for Timer
This commit is contained in:
parent
539837a748
commit
c692a97b65
@ -104,7 +104,7 @@ impl<'d, T: Instance> Timer<'d, T> {
|
|||||||
Self::new_inner(timer, true)
|
Self::new_inner(timer, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_inner(timer: Peri<'d, T>, _is_counter: bool) -> Self {
|
fn new_inner(timer: Peri<'d, T>, is_counter: bool) -> Self {
|
||||||
let regs = T::regs();
|
let regs = T::regs();
|
||||||
|
|
||||||
let this = Self { _p: timer };
|
let this = Self { _p: timer };
|
||||||
@ -114,7 +114,7 @@ impl<'d, T: Instance> Timer<'d, T> {
|
|||||||
this.stop();
|
this.stop();
|
||||||
|
|
||||||
regs.mode().write(|w| {
|
regs.mode().write(|w| {
|
||||||
w.set_mode(match _is_counter {
|
w.set_mode(match is_counter {
|
||||||
#[cfg(not(feature = "_nrf51"))]
|
#[cfg(not(feature = "_nrf51"))]
|
||||||
true => vals::Mode::LOW_POWER_COUNTER,
|
true => vals::Mode::LOW_POWER_COUNTER,
|
||||||
#[cfg(feature = "_nrf51")]
|
#[cfg(feature = "_nrf51")]
|
||||||
@ -218,6 +218,12 @@ impl<'d, T: Instance> Timer<'d, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'d, T: Instance> Drop for Timer<'d, T> {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
self.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A representation of a timer's Capture/Compare (CC) register.
|
/// A representation of a timer's Capture/Compare (CC) register.
|
||||||
///
|
///
|
||||||
/// A CC register holds a 32-bit value.
|
/// A CC register holds a 32-bit value.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user