File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 1
1
//! Delays
2
2
use core:: cmp;
3
- use cortex_m:: peripheral:: SYST ;
3
+ use cortex_m:: peripheral:: { syst :: SystClkSource , SYST } ;
4
4
use fugit:: ExtU32 ;
5
5
use hal:: blocking:: delay:: { DelayMs , DelayUs } ;
6
6
@@ -20,11 +20,12 @@ pub trait DelayExt<TIM> {
20
20
21
21
impl Delay < SYST > {
22
22
/// Configures the system timer (SysTick) as a delay provider
23
- pub fn syst ( syst : SYST , rcc : & Rcc ) -> Self {
24
- Delay {
25
- tim : syst,
26
- clk : rcc. clocks . core_clk ,
27
- }
23
+ pub fn syst ( mut syst : SYST , rcc : & Rcc ) -> Self {
24
+ let clk = match syst. get_clock_source ( ) {
25
+ SystClkSource :: Core => rcc. clocks . ahb_clk ,
26
+ SystClkSource :: External => rcc. clocks . core_clk ,
27
+ } ;
28
+ Delay { tim : syst, clk }
28
29
}
29
30
30
31
pub fn delay ( & mut self , delay : MicroSecond ) {
You can’t perform that action at this time.
0 commit comments