Skip to content

Commit e159537

Browse files
authored
Merge pull request #214 from datdenkikniet/lp_timers
Restart continuous mode after disabling and enabling the peripheral
2 parents ca71955 + de8f383 commit e159537

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/lptimer.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ macro_rules! hal {
129129
self.lptim.cr.modify(|_, w| w.enable().bit(enabled));
130130
}
131131

132+
#[inline(always)]
133+
fn start_continuous_mode(&mut self) {
134+
self.lptim.cr.modify(|_, w| w.cntstrt().set_bit());
135+
}
136+
132137
/// Consume the LPTIM and produce a LowPowerTimer that encapsulates
133138
/// said LPTIM.
134139
///
@@ -197,7 +202,7 @@ macro_rules! hal {
197202
instance.enable();
198203

199204
// Write compare, arr, and continous mode start register _after_ enabling lptim
200-
instance.lptim.cr.modify(|_, w| w.cntstrt().set_bit());
205+
instance.start_continuous_mode();
201206

202207
// This operation is sound as arr_value is a u16, and there are 16 writeable bits
203208
instance
@@ -219,6 +224,7 @@ macro_rules! hal {
219224
Event::AutoReloadMatch => w.arrmie().set_bit(),
220225
});
221226
self.enable();
227+
self.start_continuous_mode();
222228
}
223229

224230
/// Disable interrupts for the specified event
@@ -230,6 +236,7 @@ macro_rules! hal {
230236
Event::AutoReloadMatch => w.arrmie().clear_bit(),
231237
});
232238
self.enable();
239+
self.start_continuous_mode();
233240
}
234241

235242
/// Check if the specified event has been triggered for this LowPowerTimer.

0 commit comments

Comments
 (0)