File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- //! Delays
1+ //! Delay providers
2+ //!
3+ //! There are currently two delay providers. In general you should prefer to use
4+ //! [Delay](Delay), however if you do not have access to `SYST` you can use
5+ //! [DelayFromCountDownTimer](DelayFromCountDownTimer) with any timer that
6+ //! implements the [CountDown](embedded_hal::timer::CountDown) trait. This can be
7+ //! useful if you're using [RTIC](https://rtic.rs)'s schedule API, which occupies
8+ //! the `SYST` peripheral.
9+ //!
10+ //! # Examples
11+ //!
12+ //! ## Delay
13+ //!
14+ //! ```no_run
15+ //! let mut delay = Delay::new(core.SYST, device.clocks);
16+ //!
17+ //! delay.delay_ms(500);
18+ //!
19+ //! // Release SYST from the delay
20+ //! let syst = delay.free();
21+ //! ```
22+ //!
23+ //! ## DelayFromCountDownTimer
24+ //!
25+ //! ```no_run
26+ //! let timer2 = device
27+ //! .TIM2
28+ //! .timer(100.ms(), device.peripheral.TIM2, &mut device.clocks);
29+ //! let mut delay = DelayFromCountDownTimer::new(timer2);
30+ //!
31+ //! delay.delay_ms(500);
32+ //!
33+ //! // Release the timer from the delay
34+ //! let timer2 = delay.free();
35+ //! ```
236
337use cast:: u32;
438use cortex_m:: peripheral:: syst:: SystClkSource ;
You can’t perform that action at this time.
0 commit comments