Skip to content

Commit 41d7ef5

Browse files
committed
Add basic documentation for delay module
1 parent d96e8c3 commit 41d7ef5

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

src/delay.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,38 @@
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
337
use cast::u32;
438
use cortex_m::peripheral::syst::SystClkSource;

0 commit comments

Comments
 (0)