Skip to content

Commit 36e43aa

Browse files
committed
Rename set_arr to set_autoreload (to match with set_compare_match) and make it public
1 parent 242741b commit 36e43aa

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/lptimer.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,6 @@ macro_rules! hal {
134134
self.lptim.cr.modify(|_, w| w.cntstrt().set_bit());
135135
}
136136

137-
/// Set auto reload register
138-
/// has to be used _after_ enabling of lptim
139-
#[inline(always)]
140-
fn set_arr(&mut self, arr_value: u16) {
141-
// clear autoreload register OK interrupt flag
142-
self.lptim.icr.write(|w| w.arrokcf().set_bit());
143-
144-
// Write autoreload value
145-
// This operation is sound as arr_value is a u16, and there are 16 writeable bits
146-
self.lptim
147-
.arr
148-
.write(|w| unsafe { w.bits(arr_value as u32) });
149-
150-
// wait for autoreload write ok interrupt to be signalled (RM0394 Rev 4, sec. 30.7.1, Bit 4)
151-
while self.lptim.isr.read().arrok().bit_is_clear() {}
152-
}
153-
154137
/// Consume the LPTIM and produce a LowPowerTimer that encapsulates
155138
/// said LPTIM.
156139
///
@@ -219,7 +202,7 @@ macro_rules! hal {
219202
instance.enable();
220203

221204
instance.start_continuous_mode();
222-
instance.set_arr(arr_value);
205+
instance.set_autoreload(arr_value);
223206
instance.set_compare_match(compare_value);
224207
instance
225208
}
@@ -284,6 +267,23 @@ macro_rules! hal {
284267
while self.lptim.isr.read().cmpok().bit_is_clear() {}
285268
}
286269

270+
/// Set auto reload register
271+
/// has to be used _after_ enabling of lptim
272+
#[inline(always)]
273+
pub fn set_autoreload(&mut self, arr_value: u16) {
274+
// clear autoreload register OK interrupt flag
275+
self.lptim.icr.write(|w| w.arrokcf().set_bit());
276+
277+
// Write autoreload value
278+
// This operation is sound as arr_value is a u16, and there are 16 writeable bits
279+
self.lptim
280+
.arr
281+
.write(|w| unsafe { w.bits(arr_value as u32) });
282+
283+
// wait for autoreload write ok interrupt to be signalled (RM0394 Rev 4, sec. 30.7.1, Bit 4)
284+
while self.lptim.isr.read().arrok().bit_is_clear() {}
285+
}
286+
287287
/// Get the current counter value for this LowPowerTimer
288288
#[inline]
289289
pub fn get_counter(&self) -> u16 {

0 commit comments

Comments
 (0)