From e69ddb3ef2eb6cf5fb3f983ac0f25ca3686d13c3 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov <19325847+AndreySmirnov81@users.noreply.github.com> Date: Fri, 7 Oct 2022 19:47:39 +0300 Subject: [PATCH] Fix `CounterHz` and `Counter` `wait` --- CHANGELOG.md | 4 ++++ src/timer/counter.rs | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7287f32..800a2cbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/timer/counter.rs b/src/timer/counter.rs index 9594962f..3bfdfc5e 100644 --- a/src/timer/counter.rs +++ b/src/timer/counter.rs @@ -33,6 +33,9 @@ impl CounterHz { 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(); @@ -158,6 +161,9 @@ impl Counter { pub fn start(&mut self, timeout: TimerDurationU32) -> Result<(), Error> { // pause self.tim.disable_counter(); + + self.tim.clear_interrupt_flag(Event::Update); + // reset counter self.tim.reset_counter();