diff options
| author | Karun Koppula <[email protected]> | 2024-04-02 15:51:50 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-04-02 15:51:50 -0400 |
| commit | 9344f55ff3107917ce1b765bc4fa57965ec86ca6 (patch) | |
| tree | 4ca4936f84d4ad9ecf85a0129159b6d6d20c53cd /embassy-time | |
| parent | 2caea89b6ab9859470ccf6c7d7414c01251bbecd (diff) | |
| parent | 990f2717673de5e6de6be6a9fb001bc0c8d34745 (diff) | |
Merge branch 'main' into karun/main_octospi_implementation
Diffstat (limited to 'embassy-time')
| -rw-r--r-- | embassy-time/src/fmt.rs | 3 | ||||
| -rw-r--r-- | embassy-time/src/timer.rs | 14 |
2 files changed, 14 insertions, 3 deletions
diff --git a/embassy-time/src/fmt.rs b/embassy-time/src/fmt.rs index 78e583c1c..2ac42c557 100644 --- a/embassy-time/src/fmt.rs +++ b/embassy-time/src/fmt.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | 4 | use core::fmt::{Debug, Display, LowerHex}; |
| 5 | 5 | ||
| @@ -229,7 +229,6 @@ impl<T, E> Try for Result<T, E> { | |||
| 229 | } | 229 | } |
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | 232 | pub(crate) struct Bytes<'a>(pub &'a [u8]); |
| 234 | 233 | ||
| 235 | impl<'a> Debug for Bytes<'a> { | 234 | impl<'a> Debug for Bytes<'a> { |
diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs index daa4c1699..757c3ff00 100644 --- a/embassy-time/src/timer.rs +++ b/embassy-time/src/timer.rs | |||
| @@ -190,8 +190,20 @@ impl Ticker { | |||
| 190 | self.expires_at = Instant::now() + self.duration; | 190 | self.expires_at = Instant::now() + self.duration; |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | /// Reset the ticker at the deadline. | ||
| 194 | /// If the deadline is in the past, the ticker will fire instantly. | ||
| 195 | pub fn reset_at(&mut self, deadline: Instant) { | ||
| 196 | self.expires_at = deadline + self.duration; | ||
| 197 | } | ||
| 198 | |||
| 199 | /// Resets the ticker, after the specified duration has passed. | ||
| 200 | /// If the specified duration is zero, the next tick will be after the duration of the ticker. | ||
| 201 | pub fn reset_after(&mut self, after: Duration) { | ||
| 202 | self.expires_at = Instant::now() + after + self.duration; | ||
| 203 | } | ||
| 204 | |||
| 193 | /// Waits for the next tick. | 205 | /// Waits for the next tick. |
| 194 | pub fn next(&mut self) -> impl Future<Output = ()> + '_ { | 206 | pub fn next(&mut self) -> impl Future<Output = ()> + Send + Sync + '_ { |
| 195 | poll_fn(|cx| { | 207 | poll_fn(|cx| { |
| 196 | if self.expires_at <= Instant::now() { | 208 | if self.expires_at <= Instant::now() { |
| 197 | let dur = self.duration; | 209 | let dur = self.duration; |
