Skip to content

Commit 6d2ded4

Browse files
committed
Remove timeout from Tim::new()
1 parent c81015e commit 6d2ded4

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
5757
the newly introduced `InterruptNumber` trait, where the `Interrupt` is held
5858
as an associated const. ([#267])
5959
- Depending on the timer one `Interrupt` or a bundle of `InterruptTypes` is
60-
returned.
60+
returned.
6161
- On the bases of these interrupts, the interrupt controller (NVIC) can
62-
be set to mask or unmask these interrupts.
62+
be set to mask or unmask these interrupts.
6363

6464
[`enumset`]: https://crates.io/crates/enumset
6565

@@ -132,6 +132,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
132132
- `Timer::tim1` and so on are renamed to `Timer::new`
133133
- The implementation of the timers are corrected to better represent the
134134
avaibilities of timers of the hardware.
135+
- `Timer::new` now does not take a timeout value. This means, that the
136+
timer will now not be started automatically and one has to explicitly call
137+
`start()`.
135138

136139
## [v0.7.0] - 2021-06-18
137140

src/timer.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,10 @@ where
104104
TIM: Instance,
105105
{
106106
/// Configures a TIM peripheral as a periodic count down timer
107-
pub fn new<T>(tim: TIM, timeout: T, clocks: Clocks, apb: &mut <TIM as Instance>::APB) -> Self
108-
where
109-
T: Into<Hertz>,
110-
{
107+
pub fn new(tim: TIM, clocks: Clocks, apb: &mut <TIM as Instance>::APB) -> Self {
111108
TIM::enable_clock(apb);
112109

113-
let mut timer = Timer { clocks, tim };
114-
115-
// Should we really start the timer here?
116-
timer.start(timeout);
117-
118-
timer
110+
Timer { clocks, tim }
119111
}
120112

121113
/// Stops the timer

testsuite/tests/timer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ mod tests {
4040
let clocks = rcc.cfgr.freeze(&mut flash.acr);
4141

4242
// Let's use a timer, which is avaliable for every chip
43-
let timer = Timer::new(dp.TIM2, 1.Hz(), clocks, &mut rcc.apb1);
43+
let timer = Timer::new(dp.TIM2, clocks, &mut rcc.apb1);
4444
let mono_timer = MonoTimer::new(cp.DWT, clocks, &mut cp.DCB);
4545

4646
assert!(mono_timer.frequency() == clocks.hclk());
@@ -59,7 +59,7 @@ mod tests {
5959
fn test_stop_and_free(state: &mut State) {
6060
let timer = state.timer.take().unwrap().free();
6161

62-
let timer = Timer::new(timer, 100.Hz(), state.clocks, &mut state.apb1);
62+
let timer = Timer::new(timer, state.clocks, &mut state.apb1);
6363

6464
state.timer = Some(timer);
6565
}

0 commit comments

Comments
 (0)