Skip to content

Commit ae16616

Browse files
authored
Merge pull request #35 from lthiery/add-reset-to-timer-api
add reset api to Timer
2 parents 4a86684 + cb1e993 commit ae16616

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/timer.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ macro_rules! timers {
135135
self.tim.cr1.modify(|_, w| w.cen().clear_bit());
136136
self.tim
137137
}
138+
139+
/// Reset counter
140+
pub fn reset(&mut self) {
141+
// pause
142+
self.tim.cr1.modify(|_, w| w.cen().clear_bit());
143+
// reset counter
144+
self.tim.cnt.reset();
145+
// continue
146+
self.tim.cr1.modify(|_, w| w.cen().set_bit());
147+
}
138148
}
139149

140150
impl CountDown for Timer<$TIM> {

0 commit comments

Comments
 (0)