Skip to content

Commit 5f0a53f

Browse files
Merge #449
449: Bugfix: `CounterHz` and `Counter` `wait` r=burrbull a=AndreySmirnov81 `CounterHz` and `Counter` do not `wait` properly after the second and subsequent `start`. Co-authored-by: Andrey Smirnov <19325847+AndreySmirnov81@users.noreply.github.com>
2 parents cafbac1 + e69ddb3 commit 5f0a53f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2929
- Allow `Serial` release after splitting.
3030
- `Spi::is_busy()`
3131

32+
### Fixed
33+
34+
- `CounterHz` and `Counter` do not `wait` properly after the second and subsequent `start`.
35+
3236
## [v0.9.0] - 2022-03-02
3337

3438
### Added

src/timer/counter.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ impl<TIM: Instance> CounterHz<TIM> {
3333
pub fn start(&mut self, timeout: Hertz) -> Result<(), Error> {
3434
// pause
3535
self.tim.disable_counter();
36+
37+
self.tim.clear_interrupt_flag(Event::Update);
38+
3639
// reset counter
3740
self.tim.reset_counter();
3841

@@ -158,6 +161,9 @@ impl<TIM: Instance, const FREQ: u32> Counter<TIM, FREQ> {
158161
pub fn start(&mut self, timeout: TimerDurationU32<FREQ>) -> Result<(), Error> {
159162
// pause
160163
self.tim.disable_counter();
164+
165+
self.tim.clear_interrupt_flag(Event::Update);
166+
161167
// reset counter
162168
self.tim.reset_counter();
163169

0 commit comments

Comments
 (0)