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 | |
| parent | ce91fb2bfc846570ef543a09396c428d70675245 (diff) | |
| parent | 95b3d9eb3b3657de3d7bc9c04f8fb83eae901640 (diff) | |
Merge branch 'main' into issue-1974-add-sai-driver
Diffstat (limited to 'embassy-time')
| -rw-r--r-- | embassy-time/CHANGELOG.md | 11 | ||||
| -rw-r--r-- | embassy-time/Cargo.toml | 64 | ||||
| -rw-r--r-- | embassy-time/gen_tick.py | 4 | ||||
| -rw-r--r-- | embassy-time/src/fmt.rs | 45 | ||||
| -rw-r--r-- | embassy-time/src/instant.rs | 2 | ||||
| -rw-r--r-- | embassy-time/src/tick.rs | 186 | ||||
| -rw-r--r-- | embassy-time/src/timer.rs | 8 |
7 files changed, 310 insertions, 10 deletions
diff --git a/embassy-time/CHANGELOG.md b/embassy-time/CHANGELOG.md index 26640d930..e3b38455c 100644 --- a/embassy-time/CHANGELOG.md +++ b/embassy-time/CHANGELOG.md | |||
| @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file. | |||
| 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
| 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
| 7 | 7 | ||
| 8 | ## 0.1.4 - ??? | ||
| 9 | |||
| 10 | - Added more tick rates | ||
| 11 | |||
| 12 | ## 0.1.3 - 2023-08-28 | ||
| 13 | |||
| 14 | - Update `embedded-hal-async` to `1.0.0-rc.1` | ||
| 15 | - Update `embedded-hal v1` to `1.0.0-rc.1` | ||
| 16 | |||
| 8 | ## 0.1.2 - 2023-07-05 | 17 | ## 0.1.2 - 2023-07-05 |
| 9 | 18 | ||
| 10 | - Update `embedded-hal-async` to `0.2.0-alpha.2`. | 19 | - Update `embedded-hal-async` to `0.2.0-alpha.2`. |
| @@ -26,4 +35,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 26 | 35 | ||
| 27 | ## 0.1.0 - 2022-08-26 | 36 | ## 0.1.0 - 2022-08-26 |
| 28 | 37 | ||
| 29 | - First release \ No newline at end of file | 38 | - First release |
diff --git a/embassy-time/Cargo.toml b/embassy-time/Cargo.toml index 00d31d30f..8f034a9de 100644 --- a/embassy-time/Cargo.toml +++ b/embassy-time/Cargo.toml | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-time" | 2 | name = "embassy-time" |
| 3 | version = "0.1.2" | 3 | version = "0.1.4" |
| 4 | edition = "2021" | 4 | edition = "2021" |
| 5 | description = "Instant and Duration for embedded no-std systems, with async timer support" | 5 | description = "Instant and Duration for embedded no-std systems, with async timer support" |
| 6 | repository = "https://github.com/embassy-rs/embassy" | 6 | repository = "https://github.com/embassy-rs/embassy" |
| @@ -145,6 +145,68 @@ tick-hz-384_000_000 = [] | |||
| 145 | tick-hz-512_000_000 = [] | 145 | tick-hz-512_000_000 = [] |
| 146 | tick-hz-576_000_000 = [] | 146 | tick-hz-576_000_000 = [] |
| 147 | tick-hz-768_000_000 = [] | 147 | tick-hz-768_000_000 = [] |
| 148 | tick-hz-20_000_000 = [] | ||
| 149 | tick-hz-30_000_000 = [] | ||
| 150 | tick-hz-40_000_000 = [] | ||
| 151 | tick-hz-50_000_000 = [] | ||
| 152 | tick-hz-60_000_000 = [] | ||
| 153 | tick-hz-70_000_000 = [] | ||
| 154 | tick-hz-80_000_000 = [] | ||
| 155 | tick-hz-90_000_000 = [] | ||
| 156 | tick-hz-110_000_000 = [] | ||
| 157 | tick-hz-120_000_000 = [] | ||
| 158 | tick-hz-130_000_000 = [] | ||
| 159 | tick-hz-140_000_000 = [] | ||
| 160 | tick-hz-150_000_000 = [] | ||
| 161 | tick-hz-160_000_000 = [] | ||
| 162 | tick-hz-170_000_000 = [] | ||
| 163 | tick-hz-180_000_000 = [] | ||
| 164 | tick-hz-190_000_000 = [] | ||
| 165 | tick-hz-200_000_000 = [] | ||
| 166 | tick-hz-210_000_000 = [] | ||
| 167 | tick-hz-220_000_000 = [] | ||
| 168 | tick-hz-230_000_000 = [] | ||
| 169 | tick-hz-240_000_000 = [] | ||
| 170 | tick-hz-250_000_000 = [] | ||
| 171 | tick-hz-260_000_000 = [] | ||
| 172 | tick-hz-270_000_000 = [] | ||
| 173 | tick-hz-280_000_000 = [] | ||
| 174 | tick-hz-290_000_000 = [] | ||
| 175 | tick-hz-300_000_000 = [] | ||
| 176 | tick-hz-320_000_000 = [] | ||
| 177 | tick-hz-340_000_000 = [] | ||
| 178 | tick-hz-360_000_000 = [] | ||
| 179 | tick-hz-380_000_000 = [] | ||
| 180 | tick-hz-400_000_000 = [] | ||
| 181 | tick-hz-420_000_000 = [] | ||
| 182 | tick-hz-440_000_000 = [] | ||
| 183 | tick-hz-460_000_000 = [] | ||
| 184 | tick-hz-480_000_000 = [] | ||
| 185 | tick-hz-500_000_000 = [] | ||
| 186 | tick-hz-520_000_000 = [] | ||
| 187 | tick-hz-540_000_000 = [] | ||
| 188 | tick-hz-560_000_000 = [] | ||
| 189 | tick-hz-580_000_000 = [] | ||
| 190 | tick-hz-600_000_000 = [] | ||
| 191 | tick-hz-620_000_000 = [] | ||
| 192 | tick-hz-640_000_000 = [] | ||
| 193 | tick-hz-660_000_000 = [] | ||
| 194 | tick-hz-680_000_000 = [] | ||
| 195 | tick-hz-700_000_000 = [] | ||
| 196 | tick-hz-720_000_000 = [] | ||
| 197 | tick-hz-740_000_000 = [] | ||
| 198 | tick-hz-760_000_000 = [] | ||
| 199 | tick-hz-780_000_000 = [] | ||
| 200 | tick-hz-800_000_000 = [] | ||
| 201 | tick-hz-820_000_000 = [] | ||
| 202 | tick-hz-840_000_000 = [] | ||
| 203 | tick-hz-860_000_000 = [] | ||
| 204 | tick-hz-880_000_000 = [] | ||
| 205 | tick-hz-900_000_000 = [] | ||
| 206 | tick-hz-920_000_000 = [] | ||
| 207 | tick-hz-940_000_000 = [] | ||
| 208 | tick-hz-960_000_000 = [] | ||
| 209 | tick-hz-980_000_000 = [] | ||
| 148 | # END TICKS | 210 | # END TICKS |
| 149 | 211 | ||
| 150 | [dependencies] | 212 | [dependencies] |
diff --git a/embassy-time/gen_tick.py b/embassy-time/gen_tick.py index 15e65187b..67a4c79c8 100644 --- a/embassy-time/gen_tick.py +++ b/embassy-time/gen_tick.py | |||
| @@ -17,6 +17,10 @@ for i in range(1, 10): | |||
| 17 | ticks.append(2**i * 1000000) | 17 | ticks.append(2**i * 1000000) |
| 18 | ticks.append(2**i * 9 // 8 * 1000000) | 18 | ticks.append(2**i * 9 // 8 * 1000000) |
| 19 | ticks.append(2**i * 3 // 2 * 1000000) | 19 | ticks.append(2**i * 3 // 2 * 1000000) |
| 20 | for i in range(1, 30): | ||
| 21 | ticks.append(10 * i * 1_000_000) | ||
| 22 | for i in range(15, 50): | ||
| 23 | ticks.append(20 * i * 1_000_000) | ||
| 20 | 24 | ||
| 21 | seen = set() | 25 | seen = set() |
| 22 | ticks = [x for x in ticks if not (x in seen or seen.add(x))] | 26 | ticks = [x for x in ticks if not (x in seen or seen.add(x))] |
diff --git a/embassy-time/src/fmt.rs b/embassy-time/src/fmt.rs index 066970813..78e583c1c 100644 --- a/embassy-time/src/fmt.rs +++ b/embassy-time/src/fmt.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | #![allow(unused_macros)] | 2 | #![allow(unused_macros)] |
| 3 | 3 | ||
| 4 | use core::fmt::{Debug, Display, LowerHex}; | ||
| 5 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | 6 | #[cfg(all(feature = "defmt", feature = "log"))] |
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | 7 | compile_error!("You may not enable both `defmt` and `log` features."); |
| 6 | 8 | ||
| @@ -81,14 +83,17 @@ macro_rules! todo { | |||
| 81 | }; | 83 | }; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| 86 | #[cfg(not(feature = "defmt"))] | ||
| 84 | macro_rules! unreachable { | 87 | macro_rules! unreachable { |
| 85 | ($($x:tt)*) => { | 88 | ($($x:tt)*) => { |
| 86 | { | 89 | ::core::unreachable!($($x)*) |
| 87 | #[cfg(not(feature = "defmt"))] | 90 | }; |
| 88 | ::core::unreachable!($($x)*); | 91 | } |
| 89 | #[cfg(feature = "defmt")] | 92 | |
| 90 | ::defmt::unreachable!($($x)*); | 93 | #[cfg(feature = "defmt")] |
| 91 | } | 94 | macro_rules! unreachable { |
| 95 | ($($x:tt)*) => { | ||
| 96 | ::defmt::unreachable!($($x)*) | ||
| 92 | }; | 97 | }; |
| 93 | } | 98 | } |
| 94 | 99 | ||
| @@ -223,3 +228,31 @@ impl<T, E> Try for Result<T, E> { | |||
| 223 | self | 228 | self |
| 224 | } | 229 | } |
| 225 | } | 230 | } |
| 231 | |||
| 232 | #[allow(unused)] | ||
| 233 | pub(crate) struct Bytes<'a>(pub &'a [u8]); | ||
| 234 | |||
| 235 | impl<'a> Debug for Bytes<'a> { | ||
| 236 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 237 | write!(f, "{:#02x?}", self.0) | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | impl<'a> Display for Bytes<'a> { | ||
| 242 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 243 | write!(f, "{:#02x?}", self.0) | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | impl<'a> LowerHex for Bytes<'a> { | ||
| 248 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 249 | write!(f, "{:#02x?}", self.0) | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 253 | #[cfg(feature = "defmt")] | ||
| 254 | impl<'a> defmt::Format for Bytes<'a> { | ||
| 255 | fn format(&self, fmt: defmt::Formatter) { | ||
| 256 | defmt::write!(fmt, "{:02x}", self.0) | ||
| 257 | } | ||
| 258 | } | ||
diff --git a/embassy-time/src/instant.rs b/embassy-time/src/instant.rs index 44f226f62..5571cdd15 100644 --- a/embassy-time/src/instant.rs +++ b/embassy-time/src/instant.rs | |||
| @@ -71,7 +71,7 @@ impl Instant { | |||
| 71 | /// Panics on over/underflow. | 71 | /// Panics on over/underflow. |
| 72 | pub fn duration_since(&self, earlier: Instant) -> Duration { | 72 | pub fn duration_since(&self, earlier: Instant) -> Duration { |
| 73 | Duration { | 73 | Duration { |
| 74 | ticks: self.ticks.checked_sub(earlier.ticks).unwrap(), | 74 | ticks: unwrap!(self.ticks.checked_sub(earlier.ticks)), |
| 75 | } | 75 | } |
| 76 | } | 76 | } |
| 77 | 77 | ||
diff --git a/embassy-time/src/tick.rs b/embassy-time/src/tick.rs index 608bc44f1..be544181a 100644 --- a/embassy-time/src/tick.rs +++ b/embassy-time/src/tick.rs | |||
| @@ -156,6 +156,130 @@ pub const TICK_HZ: u64 = 512_000_000; | |||
| 156 | pub const TICK_HZ: u64 = 576_000_000; | 156 | pub const TICK_HZ: u64 = 576_000_000; |
| 157 | #[cfg(feature = "tick-hz-768_000_000")] | 157 | #[cfg(feature = "tick-hz-768_000_000")] |
| 158 | pub const TICK_HZ: u64 = 768_000_000; | 158 | pub const TICK_HZ: u64 = 768_000_000; |
| 159 | #[cfg(feature = "tick-hz-20_000_000")] | ||
| 160 | pub const TICK_HZ: u64 = 20_000_000; | ||
| 161 | #[cfg(feature = "tick-hz-30_000_000")] | ||
| 162 | pub const TICK_HZ: u64 = 30_000_000; | ||
| 163 | #[cfg(feature = "tick-hz-40_000_000")] | ||
| 164 | pub const TICK_HZ: u64 = 40_000_000; | ||
| 165 | #[cfg(feature = "tick-hz-50_000_000")] | ||
| 166 | pub const TICK_HZ: u64 = 50_000_000; | ||
| 167 | #[cfg(feature = "tick-hz-60_000_000")] | ||
| 168 | pub const TICK_HZ: u64 = 60_000_000; | ||
| 169 | #[cfg(feature = "tick-hz-70_000_000")] | ||
| 170 | pub const TICK_HZ: u64 = 70_000_000; | ||
| 171 | #[cfg(feature = "tick-hz-80_000_000")] | ||
| 172 | pub const TICK_HZ: u64 = 80_000_000; | ||
| 173 | #[cfg(feature = "tick-hz-90_000_000")] | ||
| 174 | pub const TICK_HZ: u64 = 90_000_000; | ||
| 175 | #[cfg(feature = "tick-hz-110_000_000")] | ||
| 176 | pub const TICK_HZ: u64 = 110_000_000; | ||
| 177 | #[cfg(feature = "tick-hz-120_000_000")] | ||
| 178 | pub const TICK_HZ: u64 = 120_000_000; | ||
| 179 | #[cfg(feature = "tick-hz-130_000_000")] | ||
| 180 | pub const TICK_HZ: u64 = 130_000_000; | ||
| 181 | #[cfg(feature = "tick-hz-140_000_000")] | ||
| 182 | pub const TICK_HZ: u64 = 140_000_000; | ||
| 183 | #[cfg(feature = "tick-hz-150_000_000")] | ||
| 184 | pub const TICK_HZ: u64 = 150_000_000; | ||
| 185 | #[cfg(feature = "tick-hz-160_000_000")] | ||
| 186 | pub const TICK_HZ: u64 = 160_000_000; | ||
| 187 | #[cfg(feature = "tick-hz-170_000_000")] | ||
| 188 | pub const TICK_HZ: u64 = 170_000_000; | ||
| 189 | #[cfg(feature = "tick-hz-180_000_000")] | ||
| 190 | pub const TICK_HZ: u64 = 180_000_000; | ||
| 191 | #[cfg(feature = "tick-hz-190_000_000")] | ||
| 192 | pub const TICK_HZ: u64 = 190_000_000; | ||
| 193 | #[cfg(feature = "tick-hz-200_000_000")] | ||
| 194 | pub const TICK_HZ: u64 = 200_000_000; | ||
| 195 | #[cfg(feature = "tick-hz-210_000_000")] | ||
| 196 | pub const TICK_HZ: u64 = 210_000_000; | ||
| 197 | #[cfg(feature = "tick-hz-220_000_000")] | ||
| 198 | pub const TICK_HZ: u64 = 220_000_000; | ||
| 199 | #[cfg(feature = "tick-hz-230_000_000")] | ||
| 200 | pub const TICK_HZ: u64 = 230_000_000; | ||
| 201 | #[cfg(feature = "tick-hz-240_000_000")] | ||
| 202 | pub const TICK_HZ: u64 = 240_000_000; | ||
| 203 | #[cfg(feature = "tick-hz-250_000_000")] | ||
| 204 | pub const TICK_HZ: u64 = 250_000_000; | ||
| 205 | #[cfg(feature = "tick-hz-260_000_000")] | ||
| 206 | pub const TICK_HZ: u64 = 260_000_000; | ||
| 207 | #[cfg(feature = "tick-hz-270_000_000")] | ||
| 208 | pub const TICK_HZ: u64 = 270_000_000; | ||
| 209 | #[cfg(feature = "tick-hz-280_000_000")] | ||
| 210 | pub const TICK_HZ: u64 = 280_000_000; | ||
| 211 | #[cfg(feature = "tick-hz-290_000_000")] | ||
| 212 | pub const TICK_HZ: u64 = 290_000_000; | ||
| 213 | #[cfg(feature = "tick-hz-300_000_000")] | ||
| 214 | pub const TICK_HZ: u64 = 300_000_000; | ||
| 215 | #[cfg(feature = "tick-hz-320_000_000")] | ||
| 216 | pub const TICK_HZ: u64 = 320_000_000; | ||
| 217 | #[cfg(feature = "tick-hz-340_000_000")] | ||
| 218 | pub const TICK_HZ: u64 = 340_000_000; | ||
| 219 | #[cfg(feature = "tick-hz-360_000_000")] | ||
| 220 | pub const TICK_HZ: u64 = 360_000_000; | ||
| 221 | #[cfg(feature = "tick-hz-380_000_000")] | ||
| 222 | pub const TICK_HZ: u64 = 380_000_000; | ||
| 223 | #[cfg(feature = "tick-hz-400_000_000")] | ||
| 224 | pub const TICK_HZ: u64 = 400_000_000; | ||
| 225 | #[cfg(feature = "tick-hz-420_000_000")] | ||
| 226 | pub const TICK_HZ: u64 = 420_000_000; | ||
| 227 | #[cfg(feature = "tick-hz-440_000_000")] | ||
| 228 | pub const TICK_HZ: u64 = 440_000_000; | ||
| 229 | #[cfg(feature = "tick-hz-460_000_000")] | ||
| 230 | pub const TICK_HZ: u64 = 460_000_000; | ||
| 231 | #[cfg(feature = "tick-hz-480_000_000")] | ||
| 232 | pub const TICK_HZ: u64 = 480_000_000; | ||
| 233 | #[cfg(feature = "tick-hz-500_000_000")] | ||
| 234 | pub const TICK_HZ: u64 = 500_000_000; | ||
| 235 | #[cfg(feature = "tick-hz-520_000_000")] | ||
| 236 | pub const TICK_HZ: u64 = 520_000_000; | ||
| 237 | #[cfg(feature = "tick-hz-540_000_000")] | ||
| 238 | pub const TICK_HZ: u64 = 540_000_000; | ||
| 239 | #[cfg(feature = "tick-hz-560_000_000")] | ||
| 240 | pub const TICK_HZ: u64 = 560_000_000; | ||
| 241 | #[cfg(feature = "tick-hz-580_000_000")] | ||
| 242 | pub const TICK_HZ: u64 = 580_000_000; | ||
| 243 | #[cfg(feature = "tick-hz-600_000_000")] | ||
| 244 | pub const TICK_HZ: u64 = 600_000_000; | ||
| 245 | #[cfg(feature = "tick-hz-620_000_000")] | ||
| 246 | pub const TICK_HZ: u64 = 620_000_000; | ||
| 247 | #[cfg(feature = "tick-hz-640_000_000")] | ||
| 248 | pub const TICK_HZ: u64 = 640_000_000; | ||
| 249 | #[cfg(feature = "tick-hz-660_000_000")] | ||
| 250 | pub const TICK_HZ: u64 = 660_000_000; | ||
| 251 | #[cfg(feature = "tick-hz-680_000_000")] | ||
| 252 | pub const TICK_HZ: u64 = 680_000_000; | ||
| 253 | #[cfg(feature = "tick-hz-700_000_000")] | ||
| 254 | pub const TICK_HZ: u64 = 700_000_000; | ||
| 255 | #[cfg(feature = "tick-hz-720_000_000")] | ||
| 256 | pub const TICK_HZ: u64 = 720_000_000; | ||
| 257 | #[cfg(feature = "tick-hz-740_000_000")] | ||
| 258 | pub const TICK_HZ: u64 = 740_000_000; | ||
| 259 | #[cfg(feature = "tick-hz-760_000_000")] | ||
| 260 | pub const TICK_HZ: u64 = 760_000_000; | ||
| 261 | #[cfg(feature = "tick-hz-780_000_000")] | ||
| 262 | pub const TICK_HZ: u64 = 780_000_000; | ||
| 263 | #[cfg(feature = "tick-hz-800_000_000")] | ||
| 264 | pub const TICK_HZ: u64 = 800_000_000; | ||
| 265 | #[cfg(feature = "tick-hz-820_000_000")] | ||
| 266 | pub const TICK_HZ: u64 = 820_000_000; | ||
| 267 | #[cfg(feature = "tick-hz-840_000_000")] | ||
| 268 | pub const TICK_HZ: u64 = 840_000_000; | ||
| 269 | #[cfg(feature = "tick-hz-860_000_000")] | ||
| 270 | pub const TICK_HZ: u64 = 860_000_000; | ||
| 271 | #[cfg(feature = "tick-hz-880_000_000")] | ||
| 272 | pub const TICK_HZ: u64 = 880_000_000; | ||
| 273 | #[cfg(feature = "tick-hz-900_000_000")] | ||
| 274 | pub const TICK_HZ: u64 = 900_000_000; | ||
| 275 | #[cfg(feature = "tick-hz-920_000_000")] | ||
| 276 | pub const TICK_HZ: u64 = 920_000_000; | ||
| 277 | #[cfg(feature = "tick-hz-940_000_000")] | ||
| 278 | pub const TICK_HZ: u64 = 940_000_000; | ||
| 279 | #[cfg(feature = "tick-hz-960_000_000")] | ||
| 280 | pub const TICK_HZ: u64 = 960_000_000; | ||
| 281 | #[cfg(feature = "tick-hz-980_000_000")] | ||
| 282 | pub const TICK_HZ: u64 = 980_000_000; | ||
| 159 | #[cfg(not(any( | 283 | #[cfg(not(any( |
| 160 | feature = "tick-hz-1", | 284 | feature = "tick-hz-1", |
| 161 | feature = "tick-hz-10", | 285 | feature = "tick-hz-10", |
| @@ -235,5 +359,67 @@ pub const TICK_HZ: u64 = 768_000_000; | |||
| 235 | feature = "tick-hz-512_000_000", | 359 | feature = "tick-hz-512_000_000", |
| 236 | feature = "tick-hz-576_000_000", | 360 | feature = "tick-hz-576_000_000", |
| 237 | feature = "tick-hz-768_000_000", | 361 | feature = "tick-hz-768_000_000", |
| 362 | feature = "tick-hz-20_000_000", | ||
| 363 | feature = "tick-hz-30_000_000", | ||
| 364 | feature = "tick-hz-40_000_000", | ||
| 365 | feature = "tick-hz-50_000_000", | ||
| 366 | feature = "tick-hz-60_000_000", | ||
| 367 | feature = "tick-hz-70_000_000", | ||
| 368 | feature = "tick-hz-80_000_000", | ||
| 369 | feature = "tick-hz-90_000_000", | ||
| 370 | feature = "tick-hz-110_000_000", | ||
| 371 | feature = "tick-hz-120_000_000", | ||
| 372 | feature = "tick-hz-130_000_000", | ||
| 373 | feature = "tick-hz-140_000_000", | ||
| 374 | feature = "tick-hz-150_000_000", | ||
| 375 | feature = "tick-hz-160_000_000", | ||
| 376 | feature = "tick-hz-170_000_000", | ||
| 377 | feature = "tick-hz-180_000_000", | ||
| 378 | feature = "tick-hz-190_000_000", | ||
| 379 | feature = "tick-hz-200_000_000", | ||
| 380 | feature = "tick-hz-210_000_000", | ||
| 381 | feature = "tick-hz-220_000_000", | ||
| 382 | feature = "tick-hz-230_000_000", | ||
| 383 | feature = "tick-hz-240_000_000", | ||
| 384 | feature = "tick-hz-250_000_000", | ||
| 385 | feature = "tick-hz-260_000_000", | ||
| 386 | feature = "tick-hz-270_000_000", | ||
| 387 | feature = "tick-hz-280_000_000", | ||
| 388 | feature = "tick-hz-290_000_000", | ||
| 389 | feature = "tick-hz-300_000_000", | ||
| 390 | feature = "tick-hz-320_000_000", | ||
| 391 | feature = "tick-hz-340_000_000", | ||
| 392 | feature = "tick-hz-360_000_000", | ||
| 393 | feature = "tick-hz-380_000_000", | ||
| 394 | feature = "tick-hz-400_000_000", | ||
| 395 | feature = "tick-hz-420_000_000", | ||
| 396 | feature = "tick-hz-440_000_000", | ||
| 397 | feature = "tick-hz-460_000_000", | ||
| 398 | feature = "tick-hz-480_000_000", | ||
| 399 | feature = "tick-hz-500_000_000", | ||
| 400 | feature = "tick-hz-520_000_000", | ||
| 401 | feature = "tick-hz-540_000_000", | ||
| 402 | feature = "tick-hz-560_000_000", | ||
| 403 | feature = "tick-hz-580_000_000", | ||
| 404 | feature = "tick-hz-600_000_000", | ||
| 405 | feature = "tick-hz-620_000_000", | ||
| 406 | feature = "tick-hz-640_000_000", | ||
| 407 | feature = "tick-hz-660_000_000", | ||
| 408 | feature = "tick-hz-680_000_000", | ||
| 409 | feature = "tick-hz-700_000_000", | ||
| 410 | feature = "tick-hz-720_000_000", | ||
| 411 | feature = "tick-hz-740_000_000", | ||
| 412 | feature = "tick-hz-760_000_000", | ||
| 413 | feature = "tick-hz-780_000_000", | ||
| 414 | feature = "tick-hz-800_000_000", | ||
| 415 | feature = "tick-hz-820_000_000", | ||
| 416 | feature = "tick-hz-840_000_000", | ||
| 417 | feature = "tick-hz-860_000_000", | ||
| 418 | feature = "tick-hz-880_000_000", | ||
| 419 | feature = "tick-hz-900_000_000", | ||
| 420 | feature = "tick-hz-920_000_000", | ||
| 421 | feature = "tick-hz-940_000_000", | ||
| 422 | feature = "tick-hz-960_000_000", | ||
| 423 | feature = "tick-hz-980_000_000", | ||
| 238 | )))] | 424 | )))] |
| 239 | pub const TICK_HZ: u64 = 1_000_000; | 425 | pub const TICK_HZ: u64 = 1_000_000; |
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() { |
