aboutsummaryrefslogtreecommitdiff
path: root/embassy-time/src/timer.rs
diff options
context:
space:
mode:
authorFrostie314159 <[email protected]>2023-08-29 08:29:38 +0200
committerFrostie314159 <[email protected]>2023-08-29 08:29:38 +0200
commit70662ec4ba1d0ba9edd9d6b7a781c19dec938616 (patch)
treea4f914609fa2ebb06fd57a9947de71250eca8877 /embassy-time/src/timer.rs
parent0568738f77d090d5d326abadd366a66aa4088ccd (diff)
embassy-time: Introduced reset function for Ticker
Diffstat (limited to 'embassy-time/src/timer.rs')
-rw-r--r--embassy-time/src/timer.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs
index ad5026e62..8996aefbc 100644
--- a/embassy-time/src/timer.rs
+++ b/embassy-time/src/timer.rs
@@ -133,7 +133,14 @@ 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 ///
138 /// This causes the ticker to go back to zero, even if the current tick isn't over yet.
139 pub fn reset(&mut self) {
140 self.expires_at = Instant::now() + self.duration;
141 }
142
143 /// Waits for the next tick.
137 pub fn next(&mut self) -> impl Future<Output = ()> + '_ { 144 pub fn next(&mut self) -> impl Future<Output = ()> + '_ {
138 poll_fn(|cx| { 145 poll_fn(|cx| {
139 if self.expires_at <= Instant::now() { 146 if self.expires_at <= Instant::now() {