1
- //! Delays
1
+ /// System timer (SysTick) as a delay provider
2
2
3
3
use cast:: u32;
4
4
use cortex_m:: peripheral:: syst:: SystClkSource ;
@@ -8,17 +8,16 @@ use crate::rcc::Clocks;
8
8
use embedded_hal:: blocking:: delay:: { DelayMs , DelayUs } ;
9
9
10
10
/// System timer (SysTick) as a delay provider
11
- pub struct Delay {
11
+ pub struct SystickDelay {
12
12
clocks : Clocks ,
13
13
syst : SYST ,
14
14
}
15
15
16
- impl Delay {
16
+ impl SystickDelay {
17
17
/// Configures the system timer (SysTick) as a delay provider
18
18
pub fn new ( mut syst : SYST , clocks : Clocks ) -> Self {
19
19
syst. set_clock_source ( SystClkSource :: External ) ;
20
-
21
- Delay { clocks, syst }
20
+ Self { syst, clocks }
22
21
}
23
22
24
23
#[ deprecated( since = "0.10.0" , note = "Please use release instead" ) ]
@@ -32,25 +31,25 @@ impl Delay {
32
31
}
33
32
}
34
33
35
- impl DelayMs < u32 > for Delay {
34
+ impl DelayMs < u32 > for SystickDelay {
36
35
fn delay_ms ( & mut self , ms : u32 ) {
37
36
self . delay_us ( ms * 1_000 ) ;
38
37
}
39
38
}
40
39
41
- impl DelayMs < u16 > for Delay {
40
+ impl DelayMs < u16 > for SystickDelay {
42
41
fn delay_ms ( & mut self , ms : u16 ) {
43
42
self . delay_ms ( u32 ( ms) ) ;
44
43
}
45
44
}
46
45
47
- impl DelayMs < u8 > for Delay {
46
+ impl DelayMs < u8 > for SystickDelay {
48
47
fn delay_ms ( & mut self , ms : u8 ) {
49
48
self . delay_ms ( u32 ( ms) ) ;
50
49
}
51
50
}
52
51
53
- impl DelayUs < u32 > for Delay {
52
+ impl DelayUs < u32 > for SystickDelay {
54
53
fn delay_us ( & mut self , us : u32 ) {
55
54
// The SysTick Reload Value register supports values between 1 and 0x00FFFFFF.
56
55
const MAX_RVR : u32 = 0x00FF_FFFF ;
@@ -78,13 +77,13 @@ impl DelayUs<u32> for Delay {
78
77
}
79
78
}
80
79
81
- impl DelayUs < u16 > for Delay {
80
+ impl DelayUs < u16 > for SystickDelay {
82
81
fn delay_us ( & mut self , us : u16 ) {
83
82
self . delay_us ( u32 ( us) )
84
83
}
85
84
}
86
85
87
- impl DelayUs < u8 > for Delay {
86
+ impl DelayUs < u8 > for SystickDelay {
88
87
fn delay_us ( & mut self , us : u8 ) {
89
88
self . delay_us ( u32 ( us) )
90
89
}
0 commit comments