M471M/R1/S BSP V3.01.000
The Board Support Package for M4521
Macros | Functions
Collaboration diagram for TIMER Exported Functions:

Macros

#define TIMER_SET_CMP_VALUE(timer, u32Value)   ((timer)->CMP = (u32Value))
 Set Timer Compared Value. More...
 
#define TIMER_SET_PRESCALE_VALUE(timer, u32Value)   ((timer)->CTL = ((timer)->CTL & ~TIMER_CTL_PSC_Msk) | (u32Value))
 Set Timer Prescale Value. More...
 
#define TIMER_IS_ACTIVE(timer)   (((timer)->CTL & TIMER_CTL_ACTSTS_Msk)? 1 : 0)
 Check specify Timer Status. More...
 
#define TIMER_SELECT_TOUT_PIN(timer, u32ToutSel)   ((timer)->CTL = ((timer)->CTL & ~TIMER_CTL_TGLPINSEL_Msk) | (u32ToutSel))
 Select Toggle-output Pin. More...
 

Functions

static __INLINE void TIMER_Start (TIMER_T *timer)
 Start Timer Counting. More...
 
static __INLINE void TIMER_Stop (TIMER_T *timer)
 Stop Timer Counting. More...
 
static __INLINE void TIMER_EnableWakeup (TIMER_T *timer)
 Enable Timer Interrupt Wake-up Function. More...
 
static __INLINE void TIMER_DisableWakeup (TIMER_T *timer)
 Disable Timer Wake-up Function. More...
 
static __INLINE void TIMER_EnableCaptureDebounce (TIMER_T *timer)
 Enable Capture Pin De-bounce. More...
 
static __INLINE void TIMER_DisableCaptureDebounce (TIMER_T *timer)
 Disable Capture Pin De-bounce. More...
 
static __INLINE void TIMER_EnableEventCounterDebounce (TIMER_T *timer)
 Enable Counter Pin De-bounce. More...
 
static __INLINE void TIMER_DisableEventCounterDebounce (TIMER_T *timer)
 Disable Counter Pin De-bounce. More...
 
static __INLINE void TIMER_EnableInt (TIMER_T *timer)
 Enable Timer Time-out Interrupt. More...
 
static __INLINE void TIMER_DisableInt (TIMER_T *timer)
 Disable Timer Time-out Interrupt. More...
 
static __INLINE void TIMER_EnableCaptureInt (TIMER_T *timer)
 Enable Capture Trigger Interrupt. More...
 
static __INLINE void TIMER_DisableCaptureInt (TIMER_T *timer)
 Disable Capture Trigger Interrupt. More...
 
static __INLINE uint32_t TIMER_GetIntFlag (TIMER_T *timer)
 Get Timer Time-out Interrupt Flag. More...
 
static __INLINE void TIMER_ClearIntFlag (TIMER_T *timer)
 Clear Timer Time-out Interrupt Flag. More...
 
static __INLINE uint32_t TIMER_GetCaptureIntFlag (TIMER_T *timer)
 Get Timer Capture Interrupt Flag. More...
 
static __INLINE void TIMER_ClearCaptureIntFlag (TIMER_T *timer)
 Clear Timer Capture Interrupt Flag. More...
 
static __INLINE uint32_t TIMER_GetWakeupFlag (TIMER_T *timer)
 Get Timer Wake-up Flag. More...
 
static __INLINE void TIMER_ClearWakeupFlag (TIMER_T *timer)
 Clear Timer Wake-up Flag. More...
 
static __INLINE uint32_t TIMER_GetCaptureData (TIMER_T *timer)
 Get Capture value. More...
 
static __INLINE uint32_t TIMER_GetCounter (TIMER_T *timer)
 Get Counter value. More...
 
uint32_t TIMER_Open (TIMER_T *timer, uint32_t u32Mode, uint32_t u32Freq)
 Open Timer with Operate Mode and Frequency. More...
 
void TIMER_Close (TIMER_T *timer)
 Stop Timer Counting. More...
 
int32_t TIMER_Delay (TIMER_T *timer, uint32_t u32Usec)
 Create a specify Delay Time. More...
 
void TIMER_EnableCapture (TIMER_T *timer, uint32_t u32CapMode, uint32_t u32Edge)
 Enable Timer Capture Function. More...
 
void TIMER_DisableCapture (TIMER_T *timer)
 Disable Timer Capture Function. More...
 
void TIMER_EnableEventCounter (TIMER_T *timer, uint32_t u32Edge)
 Enable Timer Counter Function. More...
 
void TIMER_DisableEventCounter (TIMER_T *timer)
 Disable Timer Counter Function. More...
 
uint32_t TIMER_GetModuleClock (TIMER_T *timer)
 Get Timer Clock Frequency. More...
 

Detailed Description

Macro Definition Documentation

◆ TIMER_IS_ACTIVE

#define TIMER_IS_ACTIVE (   timer)    (((timer)->CTL & TIMER_CTL_ACTSTS_Msk)? 1 : 0)

Check specify Timer Status.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Return values
0Timer 24-bit up counter is inactive
1Timer 24-bit up counter is active

This macro is used to check if specify Timer counter is inactive or active.

Definition at line 92 of file timer.h.

◆ TIMER_SELECT_TOUT_PIN

#define TIMER_SELECT_TOUT_PIN (   timer,
  u32ToutSel 
)    ((timer)->CTL = ((timer)->CTL & ~TIMER_CTL_TGLPINSEL_Msk) | (u32ToutSel))

Select Toggle-output Pin.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
[in]u32ToutSelToggle-output pin selection, valid values are:
Returns
None

This macro is used to select timer toggle-output pin is output on Tx or Tx_EXT pin.

Definition at line 106 of file timer.h.

◆ TIMER_SET_CMP_VALUE

#define TIMER_SET_CMP_VALUE (   timer,
  u32Value 
)    ((timer)->CMP = (u32Value))

Set Timer Compared Value.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
[in]u32ValueTimer compare value. Valid values are between 2 to 0xFFFFFF.
Returns
None

This macro is used to set timer compared value to adjust timer time-out interval.

Note
1. Never write 0x0 or 0x1 in this field, or the core will run into unknown state.
  1. If update timer compared value in continuous counting mode, timer counter value will keep counting continuously.
    But if timer is operating at other modes, the timer up counter will restart counting and start from 0.

Definition at line 67 of file timer.h.

◆ TIMER_SET_PRESCALE_VALUE

#define TIMER_SET_PRESCALE_VALUE (   timer,
  u32Value 
)    ((timer)->CTL = ((timer)->CTL & ~TIMER_CTL_PSC_Msk) | (u32Value))

Set Timer Prescale Value.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
[in]u32ValueTimer prescale value. Valid values are between 0 to 0xFF.
Returns
None

This macro is used to set timer prescale value and timer source clock will be divided by (prescale + 1)
before it is fed into timer.

Definition at line 80 of file timer.h.

Function Documentation

◆ TIMER_ClearCaptureIntFlag()

static __INLINE void TIMER_ClearCaptureIntFlag ( TIMER_T timer)
static

Clear Timer Capture Interrupt Flag.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This function clears timer capture trigger interrupt flag to 0.

Definition at line 331 of file timer.h.

◆ TIMER_ClearIntFlag()

static __INLINE void TIMER_ClearIntFlag ( TIMER_T timer)
static

Clear Timer Time-out Interrupt Flag.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This function clears timer time-out interrupt flag to 0.

Definition at line 302 of file timer.h.

◆ TIMER_ClearWakeupFlag()

static __INLINE void TIMER_ClearWakeupFlag ( TIMER_T timer)
static

Clear Timer Wake-up Flag.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This function clears the timer wake-up system flag to 0.

Definition at line 360 of file timer.h.

◆ TIMER_Close()

void TIMER_Close ( TIMER_T timer)

Stop Timer Counting.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This API stops timer counting and disable all timer interrupt function.

Definition at line 74 of file timer.c.

◆ TIMER_Delay()

int32_t TIMER_Delay ( TIMER_T timer,
uint32_t  u32Usec 
)

Create a specify Delay Time.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
[in]u32UsecDelay period in micro seconds. Valid values are between 100~1000000 (100 micro second ~ 1 second).
Returns
None

This API is used to create a delay loop for u32usec micro seconds by using timer one-shot mode.

Note
This API overwrites the register setting of the timer used to count the delay time.
This API use polling mode. So there is no need to enable interrupt for the timer module used to generate delay.

Definition at line 92 of file timer.c.

Here is the call graph for this function:

◆ TIMER_DisableCapture()

void TIMER_DisableCapture ( TIMER_T timer)

Disable Timer Capture Function.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This API is used to disable the timer capture function.

Definition at line 209 of file timer.c.

◆ TIMER_DisableCaptureDebounce()

static __INLINE void TIMER_DisableCaptureDebounce ( TIMER_T timer)
static

Disable Capture Pin De-bounce.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This function is used to disable the detect de-bounce function of capture pin.

Definition at line 189 of file timer.h.

◆ TIMER_DisableCaptureInt()

static __INLINE void TIMER_DisableCaptureInt ( TIMER_T timer)
static

Disable Capture Trigger Interrupt.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This function is used to disable the timer capture trigger interrupt function.

Definition at line 273 of file timer.h.

◆ TIMER_DisableEventCounter()

void TIMER_DisableEventCounter ( TIMER_T timer)

Disable Timer Counter Function.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This API is used to disable the timer event counter function.

Definition at line 243 of file timer.c.

◆ TIMER_DisableEventCounterDebounce()

static __INLINE void TIMER_DisableEventCounterDebounce ( TIMER_T timer)
static

Disable Counter Pin De-bounce.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This function is used to disable the detect de-bounce function of counter pin.

Definition at line 217 of file timer.h.

◆ TIMER_DisableInt()

static __INLINE void TIMER_DisableInt ( TIMER_T timer)
static

Disable Timer Time-out Interrupt.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This function is used to disable the timer time-out interrupt function.

Definition at line 245 of file timer.h.

◆ TIMER_DisableWakeup()

static __INLINE void TIMER_DisableWakeup ( TIMER_T timer)
static

Disable Timer Wake-up Function.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This function is used to disable the timer interrupt wake-up function.

Definition at line 161 of file timer.h.

◆ TIMER_EnableCapture()

void TIMER_EnableCapture ( TIMER_T timer,
uint32_t  u32CapMode,
uint32_t  u32Edge 
)

Enable Timer Capture Function.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
[in]u32CapModeTimer capture mode. Could be
[in]u32EdgeTimer capture trigger edge. Possible values are
Returns
None

This API is used to enable timer capture function with specify capture trigger edge
to get current counter value or reset counter value to 0.

Note
Timer frequency should be configured separately by using TIMER_Open API, or program registers directly.

Definition at line 193 of file timer.c.

◆ TIMER_EnableCaptureDebounce()

static __INLINE void TIMER_EnableCaptureDebounce ( TIMER_T timer)
static

Enable Capture Pin De-bounce.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This function is used to enable the detect de-bounce function of capture pin.

Definition at line 175 of file timer.h.

◆ TIMER_EnableCaptureInt()

static __INLINE void TIMER_EnableCaptureInt ( TIMER_T timer)
static

Enable Capture Trigger Interrupt.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This function is used to enable the timer capture trigger interrupt function.

Definition at line 259 of file timer.h.

◆ TIMER_EnableEventCounter()

void TIMER_EnableEventCounter ( TIMER_T timer,
uint32_t  u32Edge 
)

Enable Timer Counter Function.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
[in]u32EdgeDetection edge of counter pin. Could be ether
Returns
None

This function is used to enable the timer counter function with specify detection edge.

Note
Timer compare value should be configured separately by using TIMER_SET_CMP_VALUE macro or program registers directly.
While using event counter function, TIMER_TOGGLE_MODE cannot set as timer operation mode.

Definition at line 228 of file timer.c.

◆ TIMER_EnableEventCounterDebounce()

static __INLINE void TIMER_EnableEventCounterDebounce ( TIMER_T timer)
static

Enable Counter Pin De-bounce.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This function is used to enable the detect de-bounce function of counter pin.

Definition at line 203 of file timer.h.

◆ TIMER_EnableInt()

static __INLINE void TIMER_EnableInt ( TIMER_T timer)
static

Enable Timer Time-out Interrupt.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This function is used to enable the timer time-out interrupt function.

Definition at line 231 of file timer.h.

◆ TIMER_EnableWakeup()

static __INLINE void TIMER_EnableWakeup ( TIMER_T timer)
static

Enable Timer Interrupt Wake-up Function.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This function is used to enable the timer interrupt wake-up function and interrupt source could be time-out interrupt,
counter event interrupt or capture trigger interrupt.

Note
To wake the system from Power-down mode, timer clock source must be ether LXT or LIRC.

Definition at line 147 of file timer.h.

◆ TIMER_GetCaptureData()

static __INLINE uint32_t TIMER_GetCaptureData ( TIMER_T timer)
static

Get Capture value.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
24-bit Capture Value

This function reports the current 24-bit timer capture value.

Definition at line 374 of file timer.h.

◆ TIMER_GetCaptureIntFlag()

static __INLINE uint32_t TIMER_GetCaptureIntFlag ( TIMER_T timer)
static

Get Timer Capture Interrupt Flag.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Return values
0Timer capture interrupt did not occur
1Timer capture interrupt occurred

This function indicates timer capture trigger interrupt occurred or not.

Definition at line 317 of file timer.h.

◆ TIMER_GetCounter()

static __INLINE uint32_t TIMER_GetCounter ( TIMER_T timer)
static

Get Counter value.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
24-bit Counter Value

This function reports the current 24-bit timer counter value.

Definition at line 388 of file timer.h.

◆ TIMER_GetIntFlag()

static __INLINE uint32_t TIMER_GetIntFlag ( TIMER_T timer)
static

Get Timer Time-out Interrupt Flag.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Return values
0Timer time-out interrupt did not occur
1Timer time-out interrupt occurred

This function indicates timer time-out interrupt occurred or not.

Definition at line 288 of file timer.h.

◆ TIMER_GetModuleClock()

uint32_t TIMER_GetModuleClock ( TIMER_T timer)

Get Timer Clock Frequency.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
Timer clock frequency

This API is used to get the timer clock frequency.

Note
This API cannot return correct clock rate if timer source is from external clock input.

Definition at line 258 of file timer.c.

Here is the caller graph for this function:

◆ TIMER_GetWakeupFlag()

static __INLINE uint32_t TIMER_GetWakeupFlag ( TIMER_T timer)
static

Get Timer Wake-up Flag.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Return values
0Timer does not cause CPU wake-up
1Timer interrupt event cause CPU wake-up

This function indicates timer interrupt event has waked up system or not.

Definition at line 346 of file timer.h.

◆ TIMER_Open()

uint32_t TIMER_Open ( TIMER_T timer,
uint32_t  u32Mode,
uint32_t  u32Freq 
)

Open Timer with Operate Mode and Frequency.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
[in]u32ModeOperation mode. Possible options are
[in]u32FreqTarget working frequency
Returns
Real timer working frequency

This API is used to configure timer to operate in specified mode and frequency. If timer cannot work in target frequency, a closest frequency will be chose and returned.

Note
After calling this API, Timer is NOT running yet. But could start timer running be calling TIMER_Start macro or program registers directly.

Definition at line 41 of file timer.c.

Here is the call graph for this function:

◆ TIMER_Start()

static __INLINE void TIMER_Start ( TIMER_T timer)
static

Start Timer Counting.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This function is used to start Timer counting.

Definition at line 117 of file timer.h.

◆ TIMER_Stop()

static __INLINE void TIMER_Stop ( TIMER_T timer)
static

Stop Timer Counting.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
None

This function is used to stop/suspend Timer counting.

Definition at line 131 of file timer.h.