Skip to content

Commit 329303c

Browse files
author
Johannes Draaijer
committed
Allow inline on more small functions
Use PartialEq instead of casting to u8
1 parent cb32e2e commit 329303c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/lptimer.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ pub enum PreScaler {
3333
/// Count modes that are available.
3434
///
3535
/// All ClockSources currently supported require the Internal count mode
36+
#[derive(PartialEq)]
3637
pub enum CountMode {
3738
/// Use an internal clock source (which also includes LSE)
38-
Internal = 0b0,
39-
// External = 0b1,
39+
Internal,
40+
// External,
4041
}
4142

4243
/// All currently supported interrupt events
@@ -184,7 +185,7 @@ macro_rules! hal {
184185
w.enc()
185186
.clear_bit()
186187
.countmode()
187-
.bit(count_mode as u8 > 0)
188+
.bit(count_mode != CountMode::Internal)
188189
.presc()
189190
.bits(prescaler as u8)
190191
.cksel()
@@ -255,19 +256,22 @@ macro_rules! hal {
255256
}
256257

257258
/// Set the compare match field for this LPTIM
259+
#[inline]
258260
pub fn set_compare_match(&mut self, value: u16) {
259261
// This operation is sound as compare_value is a u16, and there are 16 writeable bits
260262
// Additionally, the LPTIM peripheral will always be in the enabled state when this code is called
261263
self.lptim.cmp.write(|w| unsafe { w.bits(value as u32) });
262264
}
263265

264266
/// Get the current counter value for this LPTIM
267+
#[inline]
265268
pub fn get_counter(&mut self) -> u16 {
266269
self.lptim.cnt.read().bits() as u16
267270
}
268271

269272
/// Get the value of the LPTIM_ARR register for this
270273
/// LPTIM
274+
#[inline]
271275
pub fn get_arr(&mut self) -> u16 {
272276
self.lptim.arr.read().bits() as u16
273277
}

0 commit comments

Comments
 (0)