Skip to content

Commit 22026e9

Browse files
bors[bot]burrbull
andauthored
Merge #442
442: delay-u8 r=therealprof a=burrbull Co-authored-by: Andrey Zgarbul <[email protected]>
2 parents 8ab1f8f + e5a6421 commit 22026e9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2626

2727
### Added
2828

29+
- Missing `DelayMs<u8>` / `DelayUs<u8>` impls for fugit::Delay
2930
- Aliases for peripheral wrappers [#434]
3031
- `WithPwm` trait implemented for timers with channels (internals) [#425]
3132
- `Pwm` struct with `split` method and implementation of embedded-hal::Pwm (similar to f1xx-hal) [#425]

src/fugit/hal_02.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ impl<TIM: Instance, const FREQ: u32> DelayMs<u16> for Delay<TIM, FREQ> {
3131
}
3232
}
3333

34+
impl<TIM: Instance, const FREQ: u32> DelayUs<u8> for Delay<TIM, FREQ> {
35+
/// Sleep for `us` microseconds
36+
fn delay_us(&mut self, us: u8) {
37+
self.delay((us as u32).micros()).unwrap()
38+
}
39+
}
40+
impl<TIM: Instance, const FREQ: u32> DelayMs<u8> for Delay<TIM, FREQ> {
41+
/// Sleep for `ms` milliseconds
42+
fn delay_ms(&mut self, ms: u8) {
43+
self.delay((ms as u32).millis()).unwrap()
44+
}
45+
}
46+
3447
use embedded_hal::timer::{Cancel, CountDown, Periodic};
3548

3649
impl<TIM: Instance, const FREQ: u32> Periodic for Counter<TIM, FREQ> {}

0 commit comments

Comments
 (0)