Skip to content

Commit bc31511

Browse files
committed
Auto merge of #75 - japaric:syst, r=japaric
better document the SYST API closes #59
2 parents ca3d4ef + f0919f2 commit bc31511

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/peripheral/syst.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ const SYST_CALIB_NOREF: u32 = 1 << 31;
3939
impl SYST {
4040
/// Clears current value to 0
4141
///
42-
/// After calling `clear_current()`, the next call to `has_wrapped()`
43-
/// will return `false`.
42+
/// After calling `clear_current()`, the next call to `has_wrapped()` will return `false`.
4443
pub fn clear_current(&mut self) {
4544
unsafe { self.cvr.write(0) }
4645
}
@@ -56,6 +55,17 @@ impl SYST {
5655
}
5756

5857
/// Enables counter
58+
///
59+
/// *NOTE* The reference manual indicates that:
60+
///
61+
/// "The SysTick counter reload and current value are undefined at reset, the correct
62+
/// initialization sequence for the SysTick counter is:
63+
///
64+
/// - Program reload value
65+
/// - Clear current value
66+
/// - Program Control and Status register"
67+
///
68+
/// The sequence translates to `self.set_reload(x); self.clear_current(); self.enable_counter()`
5969
pub fn enable_counter(&mut self) {
6070
unsafe { self.csr.modify(|v| v | SYST_CSR_ENABLE) }
6171
}
@@ -153,6 +163,8 @@ impl SYST {
153163
/// Sets reload value
154164
///
155165
/// Valid values are between `1` and `0x00ffffff`.
166+
///
167+
/// *NOTE* To make the timer wrap every `N` ticks set the reload value to `N - 1`
156168
pub fn set_reload(&mut self, value: u32) {
157169
unsafe { self.rvr.write(value) }
158170
}

0 commit comments

Comments
 (0)