aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar homunkulus <homunkulus@gmx.com> 2018-01-15 16:44:18 +0000
committerGravatar homunkulus <homunkulus@gmx.com> 2018-01-15 16:44:18 +0000
commitbc31511494082273b90def2c3348f591ecb5b103 (patch)
tree9ed893b138df2782f62a0df8447acaea8bf4f319
parentca3d4ef29b8cab72106587908c459da8328a74ea (diff)
parentf0919f2b029d7a4c1d7cfc71fa252daba90eaf17 (diff)
downloadcortex-m-bc31511494082273b90def2c3348f591ecb5b103.tar.gz
cortex-m-bc31511494082273b90def2c3348f591ecb5b103.tar.zst
cortex-m-bc31511494082273b90def2c3348f591ecb5b103.zip
Auto merge of #75 - japaric:syst, r=japaric
better document the SYST API closes #59
-rw-r--r--src/peripheral/syst.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/peripheral/syst.rs b/src/peripheral/syst.rs
index e02275d..ddffcde 100644
--- a/src/peripheral/syst.rs
+++ b/src/peripheral/syst.rs
@@ -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) }
}
@@ -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) }
}
@@ -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) }
}