Skyward boardcore
|
Driver for STM32 basic timers. More...
#include <BasicTimer.h>
Public Member Functions | |
BasicTimer (TIM_TypeDef *timer) | |
Create a BasicTimer object. Note that this does not resets the timer configuration but automatically enables the timer peripheral clock. | |
~BasicTimer () | |
Disables the peripheral clock. | |
TIM_TypeDef * | getTimer () |
uint8_t | getTimerNumber () |
virtual void | reset () |
Resets the timer configuration to the default state. | |
virtual void | enable () |
virtual void | disable () |
virtual bool | isEnabled () final |
virtual void | enableAutoReloadPreload () final |
The auto reload register is buffered. | |
virtual void | disableAutoReloadPreload () final |
Tha auto reload register is not buffered. | |
virtual void | enableUpdateEventGeneration () final |
When enabled, the UEV is generated by the counter overflow and software UEV generation. | |
virtual void | disableUpdateEventGeneration () final |
The UEV is disabled. | |
virtual void | generateUpdate () final |
Re-initializes the timer counter and generate an update of the registers (the prescaler is cleared too). | |
uint16_t | readCounter () |
void | setCounter (uint16_t counterValue) |
virtual uint16_t | readPrescaler () final |
virtual void | setPrescaler (uint16_t prescalerValue) final |
Updated the prescaler value. | |
virtual int | getFrequency () final |
virtual void | setFrequency (int frequency) final |
Allows to set directly the frequency of the timer's clock. | |
uint16_t | readAutoReloadRegister () |
void | setAutoReloadRegister (uint16_t autoReloadValue) |
virtual void | enableUpdateInterrupt () final |
virtual void | disableUpdateInterrupt () final |
virtual void | enableUpdateDMARequest () final |
virtual void | disableUpdateDMARequest () final |
virtual void | enableOnePulseMode () final |
virtual void | disableOnePulseMode () final |
virtual void | enableUGInterruptAndDMA () final |
virtual void | disableUGInterruptAndDMA () final |
virtual void | setMasterMode (TimerUtils::MasterMode masterMode) |
Static Public Member Functions | |
static void | clearUpdateInterruptFlag (TIM_TypeDef *timer) |
Protected Attributes | |
TIM_TypeDef * | timer |
Driver for STM32 basic timers.
This driver applies to the whole STM32F4xx family.
Basic timers main features are:
TIM6 and TIM7 are basic timers.
You can use any other timer as a basic timer. However TIM9 to TIM 14 can't generate DMA requests.
The main block of the programmable timer is a 16-bit upcounter which is incremented every clock cycle, the clock frequency can be divided by a 16-bit prescaler and the counter resets when it reaches the auto-reload value.
Every time the counter reaches the auto-reload value, an UPDATE EVENT (UEV) is fired and the counter is reset to 0. You can also generate the UEV by software.
The counter is working only when the prescaler is active, thus receiving the clock signal.
The auto-reload register can be preloaded, meaning that there you can use a preload register which acts as a buffer. If enabled, when you change the auto-reload register, its content is transferred into the shadow register (they became active) at each UEV, otherwise the new value takes effect immediately.
You can change on the fly the prescaler value as well as the auto-reload register and the counter.
When the UEV occurs, all the registers are updated and the update flag is set:
The clock source is provided by the internal clock source. For STM32F4s they are:
Definition at line 78 of file BasicTimer.h.
|
inlineexplicit |
Create a BasicTimer object. Note that this does not resets the timer configuration but automatically enables the timer peripheral clock.
Definition at line 207 of file BasicTimer.h.
|
inline |
Disables the peripheral clock.
Definition at line 212 of file BasicTimer.h.
|
inlinestatic |
Definition at line 363 of file BasicTimer.h.
|
inlinevirtual |
Reimplemented in Boardcore::GeneralPurposeTimer< T >, and Boardcore::GeneralPurposeTimer< uint16_t >.
Definition at line 262 of file BasicTimer.h.
|
inlinefinalvirtual |
Tha auto reload register is not buffered.
This means that when you change the auto-reload register, its value is taken into account immediately.
Definition at line 271 of file BasicTimer.h.
|
inlinefinalvirtual |
Definition at line 338 of file BasicTimer.h.
|
inlinefinalvirtual |
Definition at line 345 of file BasicTimer.h.
|
inlinefinalvirtual |
Definition at line 331 of file BasicTimer.h.
|
inlinefinalvirtual |
The UEV is disabled.
However the generateUpdate() function still works.
Definition at line 281 of file BasicTimer.h.
|
inlinefinalvirtual |
Definition at line 321 of file BasicTimer.h.
|
inlinevirtual |
Reimplemented in Boardcore::GeneralPurposeTimer< T >, and Boardcore::GeneralPurposeTimer< uint16_t >.
Definition at line 260 of file BasicTimer.h.
|
inlinefinalvirtual |
The auto reload register is buffered.
This means that the shadow register is used and the auto reload value will became active at the next UEV.
Definition at line 266 of file BasicTimer.h.
|
inlinefinalvirtual |
Definition at line 336 of file BasicTimer.h.
|
inlinefinalvirtual |
Definition at line 340 of file BasicTimer.h.
|
inlinefinalvirtual |
Definition at line 326 of file BasicTimer.h.
|
inlinefinalvirtual |
When enabled, the UEV is generated by the counter overflow and software UEV generation.
Definition at line 276 of file BasicTimer.h.
|
inlinefinalvirtual |
Definition at line 319 of file BasicTimer.h.
|
inlinefinalvirtual |
Re-initializes the timer counter and generate an update of the registers (the prescaler is cleared too).
Definition at line 286 of file BasicTimer.h.
|
inlinefinalvirtual |
Definition at line 302 of file BasicTimer.h.
|
inline |
Definition at line 214 of file BasicTimer.h.
|
inline |
Definition at line 216 of file BasicTimer.h.
|
inlinefinalvirtual |
Definition at line 264 of file BasicTimer.h.
|
inline |
Definition at line 312 of file BasicTimer.h.
|
inline |
Definition at line 288 of file BasicTimer.h.
|
inlinefinalvirtual |
Definition at line 295 of file BasicTimer.h.
|
inlinevirtual |
Resets the timer configuration to the default state.
This means that:
Reimplemented in Boardcore::GeneralPurposeTimer< T >, and Boardcore::GeneralPurposeTimer< uint16_t >.
Definition at line 250 of file BasicTimer.h.
|
inline |
Definition at line 314 of file BasicTimer.h.
|
inline |
Definition at line 290 of file BasicTimer.h.
|
inlinefinalvirtual |
Allows to set directly the frequency of the timer's clock.
frequency | Target frequency for the timer's clock. |
Definition at line 307 of file BasicTimer.h.
|
inlinevirtual |
Reimplemented in Boardcore::GeneralPurposeTimer< T >, and Boardcore::GeneralPurposeTimer< uint16_t >.
Definition at line 350 of file BasicTimer.h.
|
inlinefinalvirtual |
Updated the prescaler value.
Keep in mind that the new prescaler value is taken into account only at the next update event. If you need to change it immediately you need to call generateUpdate() and make sure that UEV generation is enabled (which is by default).
Definition at line 297 of file BasicTimer.h.
|
protected |
Definition at line 204 of file BasicTimer.h.