Add documentation about systick to delay & timers

This commit is contained in:
David Sawatzke 2018-12-20 21:30:49 +01:00
parent 3dd342e536
commit 2f486c62c6
2 changed files with 29 additions and 1 deletions

View File

@ -1,4 +1,29 @@
//! Delays
//! API for delays with the systick timer
//!
//! Please be aware of potential overflows.
//! For example, the maximum delay with 48MHz is around 89 seconds
//!
//! Consider using the timers api as a more flexible interface
//!
//! # Example
//!
//! ``` no_run
//! use stm32f0xx_hal as hal;
//!
//! use crate::hal::stm32;
//! use crate::hal::prelude::*;
//! use crate::hal::delay::Delay;
//! use cortex_m::peripheral::Peripherals;
//!
//! let mut p = stm32::Peripherals::take().unwrap();
//! let mut cp = cortex_m::Peripherals::take().unwrap();
//!
//! let clocks = p.RCC.constrain().cfgr.freeze();
//! let mut delay = Delay::new(cp.SYST, clocks);
//! loop {
//! delay.delay_ms(1_000_u16);
//! }
//! ```
use cast::{u16, u32};
use cortex_m::peripheral::syst::SystClkSource;

View File

@ -73,6 +73,9 @@ impl Timer<SYST> {
}
}
/// Use the systick as a timer
///
/// Be aware that intervals less than 4 Hertz may not function properly
impl CountDown for Timer<SYST> {
type Time = Hertz;