File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -15,18 +15,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
15
15
- Update existing ADC example according to ADC API changes
16
16
- Add new ADC example to read ambient temperature using ADC1 CH16
17
17
- Add ` listen ` and ` unlisten ` to ` serial::Tx ` and ` serial::Rx ` .
18
+ - Add ` count ` and ` reset ` methods to timer
18
19
19
20
20
21
### Breaking changes
21
22
22
23
- Replace gpio traits with digital::v2
23
24
- Bump ` stm32f1 ` dependency (` 0.8.0 ` )
24
- - ADC now requires the clock configuration for intialisation
25
+ - ADC now requires the clock configuration for initialisation
25
26
- ` disable_jtag ` now transforms PA15, PB3 and PB4 to forbid their use without desactivating JTAG
26
27
27
28
### Changed
28
29
29
30
- Fix hclk miscalculation
31
+ - Starting the timer does not generate interrupt requests anymore
30
32
31
33
## [ v0.3.0] - 2019-04-27
32
34
Original file line number Diff line number Diff line change @@ -160,6 +160,21 @@ macro_rules! hal {
160
160
self . stop( ) ;
161
161
self . tim
162
162
}
163
+
164
+ /// Returns the current counter value
165
+ pub fn count( & self ) -> u16 {
166
+ self . tim. cnt. read( ) . cnt( ) . bits( )
167
+ }
168
+
169
+ /// Resets the counter and generates an update event
170
+ pub fn reset( & mut self ) {
171
+ // Sets the URS bit to prevent an interrupt from being triggered by
172
+ // the UG bit.
173
+ self . tim. cr1. modify( |_, w| w. urs( ) . set_bit( ) ) ;
174
+
175
+ self . tim. egr. write( |w| w. ug( ) . set_bit( ) ) ;
176
+ self . tim. cr1. modify( |_, w| w. urs( ) . clear_bit( ) ) ;
177
+ }
163
178
}
164
179
165
180
impl CountDown for Timer <$TIMX> {
@@ -184,11 +199,7 @@ macro_rules! hal {
184
199
self . tim. arr. write( |w| w. arr( ) . bits( arr) ) ;
185
200
186
201
// Trigger an update event to load the prescaler value to the clock
187
- self . tim. egr. write( |w| w. ug( ) . set_bit( ) ) ;
188
- // The above line raises an update event which will indicate
189
- // that the timer is already finished. Since this is not the case,
190
- // it should be cleared
191
- self . clear_update_interrupt_flag( ) ;
202
+ self . reset( ) ;
192
203
193
204
// start counter
194
205
self . tim. cr1. modify( |_, w| w. cen( ) . set_bit( ) ) ;
You can’t perform that action at this time.
0 commit comments