Skip to content

Commit

Permalink
Merge #449
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bors[bot] and AndreySmirnov81 authored Oct 7, 2022
2 parents cafbac1 + e69ddb3 commit 5f0a53f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Allow `Serial` release after splitting.
- `Spi::is_busy()`

### Fixed

- `CounterHz` and `Counter` do not `wait` properly after the second and subsequent `start`.

## [v0.9.0] - 2022-03-02

### Added
Expand Down
6 changes: 6 additions & 0 deletions src/timer/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ impl<TIM: Instance> CounterHz<TIM> {
pub fn start(&mut self, timeout: Hertz) -> Result<(), Error> {
// pause
self.tim.disable_counter();

self.tim.clear_interrupt_flag(Event::Update);

// reset counter
self.tim.reset_counter();

Expand Down Expand Up @@ -158,6 +161,9 @@ impl<TIM: Instance, const FREQ: u32> Counter<TIM, FREQ> {
pub fn start(&mut self, timeout: TimerDurationU32<FREQ>) -> Result<(), Error> {
// pause
self.tim.disable_counter();

self.tim.clear_interrupt_flag(Event::Update);

// reset counter
self.tim.reset_counter();

Expand Down

0 comments on commit 5f0a53f

Please sign in to comment.