diff options
Diffstat (limited to 'embassy-time/src')
| -rw-r--r-- | embassy-time/src/timer.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs index 07ddf473f..ee2423daf 100644 --- a/embassy-time/src/timer.rs +++ b/embassy-time/src/timer.rs | |||
| @@ -64,6 +64,42 @@ impl Timer { | |||
| 64 | yielded_once: false, | 64 | yielded_once: false, |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| 67 | |||
| 68 | /// Expire after the specified number of ticks. | ||
| 69 | /// | ||
| 70 | /// This method is a convenience wrapper for calling `Timer::after(Duration::from_ticks())`. | ||
| 71 | /// For more details, refer to [`Timer::after()`] and [`Duration::from_ticks()`]. | ||
| 72 | #[inline] | ||
| 73 | pub fn after_ticks(ticks: u64) -> Self { | ||
| 74 | Self::after(Duration::from_ticks(ticks)) | ||
| 75 | } | ||
| 76 | |||
| 77 | /// Expire after the specified number of microseconds. | ||
| 78 | /// | ||
| 79 | /// This method is a convenience wrapper for calling `Timer::after(Duration::from_micros())`. | ||
| 80 | /// For more details, refer to [`Timer::after()`] and [`Duration::from_micros()`]. | ||
| 81 | #[inline] | ||
| 82 | pub fn after_micros(micros: u64) -> Self { | ||
| 83 | Self::after(Duration::from_micros(micros)) | ||
| 84 | } | ||
| 85 | |||
| 86 | /// Expire after the specified number of milliseconds. | ||
| 87 | /// | ||
| 88 | /// This method is a convenience wrapper for calling `Timer::after(Duration::from_millis())`. | ||
| 89 | /// For more details, refer to [`Timer::after`] and [`Duration::from_millis()`]. | ||
| 90 | #[inline] | ||
| 91 | pub fn after_millis(millis: u64) -> Self { | ||
| 92 | Self::after(Duration::from_millis(millis)) | ||
| 93 | } | ||
| 94 | |||
| 95 | /// Expire after the specified number of seconds. | ||
| 96 | /// | ||
| 97 | /// This method is a convenience wrapper for calling `Timer::after(Duration::from_secs())`. | ||
| 98 | /// For more details, refer to [`Timer::after`] and [`Duration::from_secs()`]. | ||
| 99 | #[inline] | ||
| 100 | pub fn after_secs(secs: u64) -> Self { | ||
| 101 | Self::after(Duration::from_secs(secs)) | ||
| 102 | } | ||
| 67 | } | 103 | } |
| 68 | 104 | ||
| 69 | impl Unpin for Timer {} | 105 | impl Unpin for Timer {} |
