Skip to content

Commit 844170a

Browse files
dbrgnburrbull
authored andcommitted
Move SYST Delay to separate module
1 parent f1d18b4 commit 844170a

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/delay/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//! Delays
2+
3+
mod syst;
4+
5+
pub use syst::SystickDelay as Delay;

src/delay.rs renamed to src/delay/syst.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Delays
1+
/// System timer (SysTick) as a delay provider
22
33
use cast::u32;
44
use cortex_m::peripheral::syst::SystClkSource;
@@ -8,17 +8,16 @@ use crate::rcc::Clocks;
88
use embedded_hal::blocking::delay::{DelayMs, DelayUs};
99

1010
/// System timer (SysTick) as a delay provider
11-
pub struct Delay {
11+
pub struct SystickDelay {
1212
clocks: Clocks,
1313
syst: SYST,
1414
}
1515

16-
impl Delay {
16+
impl SystickDelay {
1717
/// Configures the system timer (SysTick) as a delay provider
1818
pub fn new(mut syst: SYST, clocks: Clocks) -> Self {
1919
syst.set_clock_source(SystClkSource::External);
20-
21-
Delay { clocks, syst }
20+
Self { syst, clocks }
2221
}
2322

2423
#[deprecated(since = "0.10.0", note = "Please use release instead")]
@@ -32,25 +31,25 @@ impl Delay {
3231
}
3332
}
3433

35-
impl DelayMs<u32> for Delay {
34+
impl DelayMs<u32> for SystickDelay {
3635
fn delay_ms(&mut self, ms: u32) {
3736
self.delay_us(ms * 1_000);
3837
}
3938
}
4039

41-
impl DelayMs<u16> for Delay {
40+
impl DelayMs<u16> for SystickDelay {
4241
fn delay_ms(&mut self, ms: u16) {
4342
self.delay_ms(u32(ms));
4443
}
4544
}
4645

47-
impl DelayMs<u8> for Delay {
46+
impl DelayMs<u8> for SystickDelay {
4847
fn delay_ms(&mut self, ms: u8) {
4948
self.delay_ms(u32(ms));
5049
}
5150
}
5251

53-
impl DelayUs<u32> for Delay {
52+
impl DelayUs<u32> for SystickDelay {
5453
fn delay_us(&mut self, us: u32) {
5554
// The SysTick Reload Value register supports values between 1 and 0x00FFFFFF.
5655
const MAX_RVR: u32 = 0x00FF_FFFF;
@@ -78,13 +77,13 @@ impl DelayUs<u32> for Delay {
7877
}
7978
}
8079

81-
impl DelayUs<u16> for Delay {
80+
impl DelayUs<u16> for SystickDelay {
8281
fn delay_us(&mut self, us: u16) {
8382
self.delay_us(u32(us))
8483
}
8584
}
8685

87-
impl DelayUs<u8> for Delay {
86+
impl DelayUs<u8> for SystickDelay {
8887
fn delay_us(&mut self, us: u8) {
8988
self.delay_us(u32(us))
9089
}

0 commit comments

Comments
 (0)