diff options
| author | Tyler <[email protected]> | 2023-09-29 20:02:24 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-09-29 20:02:24 -0600 |
| commit | 2f9b59c5cf21f1e2761a9ccefdfd86f0edea829c (patch) | |
| tree | 8964744b4fb753cf98f6f413464106c4d2a72976 /embassy-time/src/timer.rs | |
| parent | ce91fb2bfc846570ef543a09396c428d70675245 (diff) | |
| parent | 95b3d9eb3b3657de3d7bc9c04f8fb83eae901640 (diff) | |
Merge branch 'main' into issue-1974-add-sai-driver
Diffstat (limited to 'embassy-time/src/timer.rs')
| -rw-r--r-- | embassy-time/src/timer.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs index ad5026e62..07ddf473f 100644 --- a/embassy-time/src/timer.rs +++ b/embassy-time/src/timer.rs | |||
| @@ -133,7 +133,13 @@ impl Ticker { | |||
| 133 | Self { expires_at, duration } | 133 | Self { expires_at, duration } |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | /// Waits for the next tick | 136 | /// Resets the ticker back to its original state. |
| 137 | /// This causes the ticker to go back to zero, even if the current tick isn't over yet. | ||
| 138 | pub fn reset(&mut self) { | ||
| 139 | self.expires_at = Instant::now() + self.duration; | ||
| 140 | } | ||
| 141 | |||
| 142 | /// Waits for the next tick. | ||
| 137 | pub fn next(&mut self) -> impl Future<Output = ()> + '_ { | 143 | pub fn next(&mut self) -> impl Future<Output = ()> + '_ { |
| 138 | poll_fn(|cx| { | 144 | poll_fn(|cx| { |
| 139 | if self.expires_at <= Instant::now() { | 145 | if self.expires_at <= Instant::now() { |
