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 11//! Delays
22use core:: cmp;
3- use cortex_m:: peripheral:: SYST ;
3+ use cortex_m:: peripheral:: { syst :: SystClkSource , SYST } ;
44use fugit:: ExtU32 ;
55use hal:: blocking:: delay:: { DelayMs , DelayUs } ;
66
@@ -20,11 +20,12 @@ pub trait DelayExt<TIM> {
2020
2121impl Delay < SYST > {
2222 /// 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 }
2829 }
2930
3031 pub fn delay ( & mut self , delay : MicroSecond ) {
You can’t perform that action at this time.
0 commit comments