M480 BSP V3.05.005
The Board Support Package for M480 Series
Macros | Functions

Macros

#define TIMER_SET_CMP_VALUE(timer, u32Value)
 Set Timer Compared Value. More...
 
#define TIMER_SET_PRESCALE_VALUE(timer, u32Value)
 Set Timer Prescale Value. More...
 
#define TIMER_IS_ACTIVE(timer)
 Check specify Timer Status. More...
 
#define TIMER_SELECT_TOUT_PIN(timer, u32ToutSel)
 Select Toggle-output Pin. More...
 
#define TIMER_SET_OPMODE(timer, u32OpMode)
 Select Timer operating mode. 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_StartCapture (TIMER_T *timer)
 Start Timer Capture Function. More...
 
__STATIC_INLINE void TIMER_StopCapture (TIMER_T *timer)
 Stop Timer Capture 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...
 
void TIMER_EnableFreqCounter (TIMER_T *timer, uint32_t u32DropCount, uint32_t u32Timeout, uint32_t u32EnableInt)
 This function is used to enable the Timer frequency counter function. More...
 
void TIMER_DisableFreqCounter (TIMER_T *timer)
 This function is used to disable the Timer frequency counter function. More...
 
void TIMER_SetTriggerSource (TIMER_T *timer, uint32_t u32Src)
 This function is used to select the interrupt source used to trigger other modules. More...
 
void TIMER_SetTriggerTarget (TIMER_T *timer, uint32_t u32Mask)
 This function is used to set modules trigger by timer interrupt. More...
 
int32_t TIMER_ResetCounter (TIMER_T *timer)
 Reset Counter. More...
 

Detailed Description

Macro Definition Documentation

◆ TIMER_IS_ACTIVE

#define TIMER_IS_ACTIVE (   timer)

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 109 of file timer.h.

◆ TIMER_SELECT_TOUT_PIN

#define TIMER_SELECT_TOUT_PIN (   timer,
  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 TMx or TMx_EXT pin.

Definition at line 124 of file timer.h.

◆ TIMER_SET_CMP_VALUE

#define TIMER_SET_CMP_VALUE (   timer,
  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 82 of file timer.h.

◆ TIMER_SET_OPMODE

#define TIMER_SET_OPMODE (   timer,
  u32OpMode 
)

Select Timer operating mode.

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

Definition at line 139 of file timer.h.

◆ TIMER_SET_PRESCALE_VALUE

#define TIMER_SET_PRESCALE_VALUE (   timer,
  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 96 of file timer.h.

Function Documentation

◆ TIMER_ClearCaptureIntFlag()

__STATIC_INLINE void TIMER_ClearCaptureIntFlag ( TIMER_T timer)

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 416 of file timer.h.

◆ TIMER_ClearIntFlag()

__STATIC_INLINE void TIMER_ClearIntFlag ( TIMER_T timer)

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 387 of file timer.h.

◆ TIMER_ClearWakeupFlag()

__STATIC_INLINE void TIMER_ClearWakeupFlag ( TIMER_T timer)

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 445 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
Delay success or not
Return values
0Success, target delay time reached
TIMER_TIMEOUT_ERRDelay function execute failed due to timer stop working

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 94 of file timer.c.

◆ 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 210 of file timer.c.

◆ TIMER_DisableCaptureDebounce()

__STATIC_INLINE void TIMER_DisableCaptureDebounce ( TIMER_T timer)

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 274 of file timer.h.

◆ TIMER_DisableCaptureInt()

__STATIC_INLINE void TIMER_DisableCaptureInt ( TIMER_T timer)

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 358 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 244 of file timer.c.

◆ TIMER_DisableEventCounterDebounce()

__STATIC_INLINE void TIMER_DisableEventCounterDebounce ( TIMER_T timer)

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 302 of file timer.h.

◆ TIMER_DisableFreqCounter()

void TIMER_DisableFreqCounter ( TIMER_T timer)

This function is used to disable the Timer frequency counter function.

Parameters
[in]timerThe base address of Timer module
Returns
None

Definition at line 335 of file timer.c.

◆ TIMER_DisableInt()

__STATIC_INLINE void TIMER_DisableInt ( TIMER_T timer)

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 330 of file timer.h.

◆ TIMER_DisableWakeup()

__STATIC_INLINE void TIMER_DisableWakeup ( TIMER_T timer)

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 218 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 195 of file timer.c.

◆ TIMER_EnableCaptureDebounce()

__STATIC_INLINE void TIMER_EnableCaptureDebounce ( TIMER_T timer)

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 260 of file timer.h.

◆ TIMER_EnableCaptureInt()

__STATIC_INLINE void TIMER_EnableCaptureInt ( TIMER_T timer)

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 344 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 229 of file timer.c.

◆ TIMER_EnableEventCounterDebounce()

__STATIC_INLINE void TIMER_EnableEventCounterDebounce ( TIMER_T timer)

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 288 of file timer.h.

◆ TIMER_EnableFreqCounter()

void TIMER_EnableFreqCounter ( TIMER_T timer,
uint32_t  u32DropCount,
uint32_t  u32Timeout,
uint32_t  u32EnableInt 
)

This function is used to enable the Timer frequency counter function.

Parameters
[in]timerThe base address of Timer module. Can be TIMER0 or TIMER2
[in]u32DropCountThis parameter has no effect in M480 series BSP
[in]u32TimeoutThis parameter has no effect in M480 series BSP
[in]u32EnableIntEnable interrupt assertion after capture complete or not. Valid values are TRUE and FALSE
Returns
None

This function is used to calculate input event frequency. After enable this function, a pair of timers, TIMER0 and TIMER1, or TIMER2 and TIMER3 will be configured for this function. The mode used to calculate input event frequency is mentioned as "Inter Timer Trigger Mode" in Technical Reference Manual

Definition at line 315 of file timer.c.

◆ TIMER_EnableInt()

__STATIC_INLINE void TIMER_EnableInt ( TIMER_T timer)

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 316 of file timer.h.

◆ TIMER_EnableWakeup()

__STATIC_INLINE void TIMER_EnableWakeup ( TIMER_T timer)

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 204 of file timer.h.

◆ TIMER_GetCaptureData()

__STATIC_INLINE uint32_t TIMER_GetCaptureData ( TIMER_T timer)

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 459 of file timer.h.

◆ TIMER_GetCaptureIntFlag()

__STATIC_INLINE uint32_t TIMER_GetCaptureIntFlag ( TIMER_T timer)

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 402 of file timer.h.

◆ TIMER_GetCounter()

__STATIC_INLINE uint32_t TIMER_GetCounter ( TIMER_T timer)

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 473 of file timer.h.

◆ TIMER_GetIntFlag()

__STATIC_INLINE uint32_t TIMER_GetIntFlag ( TIMER_T timer)

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 373 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 259 of file timer.c.

◆ TIMER_GetWakeupFlag()

__STATIC_INLINE uint32_t TIMER_GetWakeupFlag ( TIMER_T timer)

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 431 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.

◆ TIMER_ResetCounter()

int32_t TIMER_ResetCounter ( TIMER_T timer)

Reset Counter.

Parameters
[in]timerThe pointer of the specified Timer module. It could be TIMER0, TIMER1, TIMER2, TIMER3.
Returns
Reset success or not
Return values
0Timer reset success
TIMER_TIMEOUT_ERRTimer reset failed

This function is used to reset current counter value and internal prescale counter value.

Definition at line 380 of file timer.c.

◆ TIMER_SetTriggerSource()

void TIMER_SetTriggerSource ( TIMER_T timer,
uint32_t  u32Src 
)

This function is used to select the interrupt source used to trigger other modules.

Parameters
[in]timerThe base address of Timer module
[in]u32SrcSelects the interrupt source to trigger other modules. Could be:
Returns
None

Definition at line 349 of file timer.c.

◆ TIMER_SetTriggerTarget()

void TIMER_SetTriggerTarget ( TIMER_T timer,
uint32_t  u32Mask 
)

This function is used to set modules trigger by timer interrupt.

Parameters
[in]timerThe base address of Timer module
[in]u32MaskThe mask of modules (EPWM, EADC, DAC and PDMA) trigger by timer. Is the combination of
Returns
None

Definition at line 364 of file timer.c.

◆ TIMER_Start()

__STATIC_INLINE void TIMER_Start ( TIMER_T timer)

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 174 of file timer.h.

◆ TIMER_StartCapture()

__STATIC_INLINE void TIMER_StartCapture ( TIMER_T timer)

Start Timer Capture Function.

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 capture function.

Definition at line 232 of file timer.h.

◆ TIMER_Stop()

__STATIC_INLINE void TIMER_Stop ( 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 function is used to stop/suspend Timer counting.

Definition at line 188 of file timer.h.

◆ TIMER_StopCapture()

__STATIC_INLINE void TIMER_StopCapture ( TIMER_T timer)

Stop Timer Capture Function.

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

This function is used to stop Timer capture function.

Definition at line 246 of file timer.h.