Skip to content

Commit 2f486c6

Browse files
Add documentation about systick to delay & timers
1 parent 3dd342e commit 2f486c6

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/delay.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
1-
//! Delays
1+
//! API for delays with the systick timer
2+
//!
3+
//! Please be aware of potential overflows.
4+
//! For example, the maximum delay with 48MHz is around 89 seconds
5+
//!
6+
//! Consider using the timers api as a more flexible interface
7+
//!
8+
//! # Example
9+
//!
10+
//! ``` no_run
11+
//! use stm32f0xx_hal as hal;
12+
//!
13+
//! use crate::hal::stm32;
14+
//! use crate::hal::prelude::*;
15+
//! use crate::hal::delay::Delay;
16+
//! use cortex_m::peripheral::Peripherals;
17+
//!
18+
//! let mut p = stm32::Peripherals::take().unwrap();
19+
//! let mut cp = cortex_m::Peripherals::take().unwrap();
20+
//!
21+
//! let clocks = p.RCC.constrain().cfgr.freeze();
22+
//! let mut delay = Delay::new(cp.SYST, clocks);
23+
//! loop {
24+
//! delay.delay_ms(1_000_u16);
25+
//! }
26+
//! ```
227
328
use cast::{u16, u32};
429
use cortex_m::peripheral::syst::SystClkSource;

src/timers.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ impl Timer<SYST> {
7373
}
7474
}
7575

76+
/// Use the systick as a timer
77+
///
78+
/// Be aware that intervals less than 4 Hertz may not function properly
7679
impl CountDown for Timer<SYST> {
7780
type Time = Hertz;
7881

0 commit comments

Comments
 (0)