TIMER - Timer/Counter
Description
Timer/Counter (TIMER) Peripheral API.
The timer module consists of three main parts:
- General timer configuration and enable control.
- Compare/capture control.
- Dead time insertion control (may not be available for all timers).
Data Structures |
|
struct | TIMER_Init_TypeDef |
TIMER initialization structure.
|
|
struct | TIMER_InitCC_TypeDef |
TIMER compare/capture initialization structure.
|
|
struct | TIMER_InitDTI_TypeDef |
TIMER Dead Time Insertion (DTI) initialization structure.
|
|
Functions |
|
bool | TIMER_Valid (const TIMER_TypeDef *ref) |
Validate TIMER register block pointer.
|
|
bool | TIMER_SupportsDTI (const TIMER_TypeDef *ref) |
Check if TIMER is valid and supports Dead Timer Insertion (DTI).
|
|
uint32_t | TIMER_MaxCount (const TIMER_TypeDef *ref) |
Get the Max count of the timer.
|
|
uint32_t | TIMER_CaptureGet (TIMER_TypeDef *timer, unsigned int ch) |
Get compare/capture value for compare/capture channel.
|
|
uint32_t | TIMER_CaptureBufGet (TIMER_TypeDef *timer, unsigned int ch) |
Get buffered compare/capture value for compare/capture channel.
|
|
void | TIMER_CompareBufSet (TIMER_TypeDef *timer, unsigned int ch, uint32_t val) |
Set compare value buffer for compare/capture channel when operating in compare or PWM mode.
|
|
void | TIMER_CompareSet (TIMER_TypeDef *timer, unsigned int ch, uint32_t val) |
Set compare value for compare/capture channel when operating in compare or PWM mode.
|
|
uint32_t | TIMER_CounterGet (TIMER_TypeDef *timer) |
Get TIMER counter value.
|
|
void | TIMER_CounterSet (TIMER_TypeDef *timer, uint32_t val) |
Set TIMER counter value.
|
|
void | TIMER_Enable (TIMER_TypeDef *timer, bool enable) |
Start/stop TIMER.
|
|
void | TIMER_Init (TIMER_TypeDef *timer, const TIMER_Init_TypeDef *init) |
Initialize TIMER.
|
|
void | TIMER_InitCC (TIMER_TypeDef *timer, unsigned int ch, const TIMER_InitCC_TypeDef *init) |
Initialize the TIMER compare/capture channel.
|
|
void | TIMER_InitDTI (TIMER_TypeDef *timer, const TIMER_InitDTI_TypeDef *init) |
Initialize the TIMER DTI unit.
|
|
void | TIMER_EnableDTI (TIMER_TypeDef *timer, bool enable) |
Enable or disable DTI unit.
|
|
uint32_t | TIMER_GetDTIFault (TIMER_TypeDef *timer) |
Get DTI fault source flags status.
|
|
void | TIMER_ClearDTIFault (TIMER_TypeDef *timer, uint32_t flags) |
Clear DTI fault source flags.
|
|
void | TIMER_IntClear (TIMER_TypeDef *timer, uint32_t flags) |
Clear one or more pending TIMER interrupts.
|
|
void | TIMER_IntDisable (TIMER_TypeDef *timer, uint32_t flags) |
Disable one or more TIMER interrupts.
|
|
void | TIMER_IntEnable (TIMER_TypeDef *timer, uint32_t flags) |
Enable one or more TIMER interrupts.
|
|
uint32_t | TIMER_IntGet (TIMER_TypeDef *timer) |
Get pending TIMER interrupt flags.
|
|
uint32_t | TIMER_IntGetEnabled (TIMER_TypeDef *timer) |
Get enabled and pending TIMER interrupt flags.
|
|
void | TIMER_IntSet (TIMER_TypeDef *timer, uint32_t flags) |
Set one or more pending TIMER interrupts from SW.
|
|
void | TIMER_Lock (TIMER_TypeDef *timer) |
Lock some of the TIMER registers in order to protect them from being modified.
|
|
void | TIMER_Reset (TIMER_TypeDef *timer) |
Reset the TIMER to the same state that it was in after a hardware reset.
|
|
void | TIMER_TopBufSet (TIMER_TypeDef *timer, uint32_t val) |
Set top value buffer for timer.
|
|
uint32_t | TIMER_TopGet (TIMER_TypeDef *timer) |
Get top value setting for timer.
|
|
void | TIMER_TopSet (TIMER_TypeDef *timer, uint32_t val) |
Set top value for timer.
|
|
void | TIMER_Unlock (TIMER_TypeDef *timer) |
Unlock TIMER to enable writing to locked registers again.
|
|
Macros |
|
#define | TIMER_INIT_DEFAULT |
Default configuration for TIMER initialization structure.
|
|
#define | TIMER_INITCC_DEFAULT |
Default configuration for TIMER compare/capture initialization structure.
|
|
#define | TIMER_INITDTI_DEFAULT |
Default configuration for TIMER DTI initialization structure.
|
|
Typedefs |
|
typedef uint8_t | TIMER_PRSSEL_TypeDef |
Peripheral Reflex System signal.
|
|
Enumerations |
|
enum |
TIMER_CCMode_TypeDef
{
timerCCModeOff = _TIMER_CC_CTRL_MODE_OFF, timerCCModeCapture = _TIMER_CC_CTRL_MODE_INPUTCAPTURE, timerCCModeCompare = _TIMER_CC_CTRL_MODE_OUTPUTCOMPARE, timerCCModePWM = _TIMER_CC_CTRL_MODE_PWM } |
Timer compare/capture mode.
|
|
enum |
TIMER_ClkSel_TypeDef
{
timerClkSelHFPerClk = _TIMER_CTRL_CLKSEL_PRESCHFPERCLK, timerClkSelCC1 = _TIMER_CTRL_CLKSEL_CC1, timerClkSelCascade = _TIMER_CTRL_CLKSEL_TIMEROUF } |
Clock select.
|
|
enum |
TIMER_Edge_TypeDef
{
timerEdgeRising = _TIMER_CC_CTRL_ICEDGE_RISING, timerEdgeFalling = _TIMER_CC_CTRL_ICEDGE_FALLING, timerEdgeBoth = _TIMER_CC_CTRL_ICEDGE_BOTH, timerEdgeNone = _TIMER_CC_CTRL_ICEDGE_NONE } |
Input capture edge select.
|
|
enum |
TIMER_Event_TypeDef
{
timerEventEveryEdge = _TIMER_CC_CTRL_ICEVCTRL_EVERYEDGE, timerEventEvery2ndEdge = _TIMER_CC_CTRL_ICEVCTRL_EVERYSECONDEDGE, timerEventRising = _TIMER_CC_CTRL_ICEVCTRL_RISING, timerEventFalling = _TIMER_CC_CTRL_ICEVCTRL_FALLING } |
Input capture event control.
|
|
enum |
TIMER_InputAction_TypeDef
{
timerInputActionNone = _TIMER_CTRL_FALLA_NONE, timerInputActionStart = _TIMER_CTRL_FALLA_START, timerInputActionStop = _TIMER_CTRL_FALLA_STOP, timerInputActionReloadStart = _TIMER_CTRL_FALLA_RELOADSTART } |
Input edge action.
|
|
enum |
TIMER_Mode_TypeDef
{
timerModeUp = _TIMER_CTRL_MODE_UP, timerModeDown = _TIMER_CTRL_MODE_DOWN, timerModeUpDown = _TIMER_CTRL_MODE_UPDOWN, timerModeQDec = _TIMER_CTRL_MODE_QDEC } |
Timer mode.
|
|
enum |
TIMER_OutputAction_TypeDef
{
timerOutputActionNone = _TIMER_CC_CTRL_CUFOA_NONE, timerOutputActionToggle = _TIMER_CC_CTRL_CUFOA_TOGGLE, timerOutputActionClear = _TIMER_CC_CTRL_CUFOA_CLEAR, timerOutputActionSet = _TIMER_CC_CTRL_CUFOA_SET } |
Compare/capture output action.
|
|
enum |
TIMER_Prescale_TypeDef
{
timerPrescale1 = _TIMER_CTRL_PRESC_DIV1, timerPrescale2 = _TIMER_CTRL_PRESC_DIV2, timerPrescale4 = _TIMER_CTRL_PRESC_DIV4, timerPrescale8 = _TIMER_CTRL_PRESC_DIV8, timerPrescale16 = _TIMER_CTRL_PRESC_DIV16, timerPrescale32 = _TIMER_CTRL_PRESC_DIV32, timerPrescale64 = _TIMER_CTRL_PRESC_DIV64, timerPrescale128 = _TIMER_CTRL_PRESC_DIV128, timerPrescale256 = _TIMER_CTRL_PRESC_DIV256, timerPrescale512 = _TIMER_CTRL_PRESC_DIV512, timerPrescale1024 = _TIMER_CTRL_PRESC_DIV1024 } |
Prescaler.
|
|
enum |
TIMER_DtiFaultAction_TypeDef
{
timerDtiFaultActionNone = _TIMER_DTFC_DTFA_NONE, timerDtiFaultActionInactive = _TIMER_DTFC_DTFA_INACTIVE, timerDtiFaultActionClear = _TIMER_DTFC_DTFA_CLEAR, timerDtiFaultActionTristate = _TIMER_DTFC_DTFA_TRISTATE } |
DT (Dead Time) Fault Actions.
|
|
enum |
TIMER_PrsOutput_t
{
timerPrsOutputPulse = 0, timerPrsOutputLevel = 1, timerPrsOutputDefault = timerPrsOutputPulse } |
PRS Output configuration.
|
|
Function Documentation
◆ TIMER_Valid()
|
inline |
Validate TIMER register block pointer.
- Parameters
-
[in] ref
Pointer to TIMER peripheral register block.
- Returns
- True if ref points to a valid timer, false otherwise.
◆ TIMER_SupportsDTI()
|
inline |
Check if TIMER is valid and supports Dead Timer Insertion (DTI).
- Parameters
-
[in] ref
Pointer to TIMER peripheral register block.
- Returns
- True if ref points to a valid timer that supports DTI, false otherwise.
◆ TIMER_MaxCount()
|
inline |
Get the Max count of the timer.
- Parameters
-
[in] ref
Pointer to TIMER peripheral register block.
- Returns
- The max count value of the timer. This is 0xFFFF for 16 bit timers and 0xFFFFFFFF for 32 bit timers.
◆ TIMER_CaptureGet()
|
inline |
Get compare/capture value for compare/capture channel.
- Parameters
-
[in] timer
Pointer to TIMER peripheral register block. [in] ch
Compare/capture channel to access.
- Returns
- Current capture value.
◆ TIMER_CaptureBufGet()
|
inline |
Get buffered compare/capture value for compare/capture channel.
- Parameters
-
[in] timer
Pointer to TIMER peripheral register block. [in] ch
Compare/capture channel to access.
- Returns
- Current buffered capture value.
◆ TIMER_CompareBufSet()
|
inline |