Skip to content

better document the SYST API #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/peripheral/syst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ const SYST_CALIB_NOREF: u32 = 1 << 31;
impl SYST {
/// Clears current value to 0
///
/// After calling `clear_current()`, the next call to `has_wrapped()`
/// will return `false`.
/// After calling `clear_current()`, the next call to `has_wrapped()` will return `false`.
pub fn clear_current(&mut self) {
unsafe { self.cvr.write(0) }
}
Expand All @@ -56,6 +55,17 @@ impl SYST {
}

/// Enables counter
///
/// *NOTE* The reference manual indicates that:
///
/// "The SysTick counter reload and current value are undefined at reset, the correct
/// initialization sequence for the SysTick counter is:
///
/// - Program reload value
/// - Clear current value
/// - Program Control and Status register"
///
/// The sequence translates to `self.set_reload(x); self.clear_current(); self.enable_counter()`
pub fn enable_counter(&mut self) {
unsafe { self.csr.modify(|v| v | SYST_CSR_ENABLE) }
}
Expand Down Expand Up @@ -153,6 +163,8 @@ impl SYST {
/// Sets reload value
///
/// Valid values are between `1` and `0x00ffffff`.
///
/// *NOTE* To make the timer wrap every `N` ticks set the reload value to `N - 1`
pub fn set_reload(&mut self, value: u32) {
unsafe { self.rvr.write(value) }
}
Expand Down