PAN1080 Peripheral API
Modules | Functions
Timer Interface

Timer Interface. More...

Collaboration diagram for Timer Interface:

Modules

 Timer work mode
 Timer work mode definition.
 
 Timer counting mode
 Timer counting mode definition.
 
 Timer capture mode
 Timer capture edge definition.
 
 Timer counting edge
 Timer counting edge definition.
 
 Timer capture souce
 Timer capture source definition.
 

Functions

__STATIC_INLINE void TIMER_EnableCapture (TIMER_T *timer, TIMER_CapModeDef capMode, TIMER_CapEdgeDef capEdge)
 This API is used to enable timer capture function with specified mode and capture edge. More...
 
__STATIC_INLINE void TIMER_DisableCapture (TIMER_T *timer)
 This API is used to disable the Timer capture function. More...
 
__STATIC_INLINE void TIMER_EnableEventCounter (TIMER_T *timer, TIMER_EvtCntEdgeDef evtCntEdge)
 This function is used to enable the Timer event counter function with specify detection edge. More...
 
__STATIC_INLINE void TIMER_DisableEventCounter (TIMER_T *timer)
 This API is used to disable the Timer event counter function. More...
 
__STATIC_INLINE void TIMER_SetCmpValue (TIMER_T *timer, uint32_t u32Value)
 This function is used to set new Timer compared value. More...
 
__STATIC_INLINE void TIMER_SetPrescaleValue (TIMER_T *timer, uint32_t u32Value)
 This function is used to set new Timer prescale value. More...
 
__STATIC_INLINE void TIMER_SetCountingMode (TIMER_T *timer, TIMER_CntModeDef cntMode)
 This function is used to Set Timer counting mode. More...
 
__STATIC_INLINE bool TIMER_IsActive (TIMER_T *timer)
 This function is used to check if specify Timer is inactive or active. More...
 
__STATIC_INLINE void TIMER_Start (TIMER_T *timer)
 This function is used to start Timer counting. More...
 
__STATIC_INLINE void TIMER_Stop (TIMER_T *timer)
 This function is used to stop Timer counting. More...
 
__STATIC_INLINE void TIMER_Reset (TIMER_T *timer)
 This function is used to reset Timer counting, prescale counter and CNTEN. More...
 
__STATIC_INLINE void TIMER_EnableWakeup (TIMER_T *timer)
 This function is used to enable the Timer wake-up function. More...
 
__STATIC_INLINE void TIMER_DisableWakeup (TIMER_T *timer)
 This function is used to disable the Timer wake-up function. More...
 
__STATIC_INLINE void TIMER_EnableCaptureDebounce (TIMER_T *timer)
 This function is used to enable the capture pin detection de-bounce function. More...
 
__STATIC_INLINE void TIMER_DisableCaptureDebounce (TIMER_T *timer)
 This function is used to disable the capture pin detection de-bounce function. More...
 
__STATIC_INLINE void TIMER_EnableEventCounterDebounce (TIMER_T *timer)
 This function is used to enable the counter pin detection de-bounce function. More...
 
__STATIC_INLINE void TIMER_DisableEventCounterDebounce (TIMER_T *timer)
 This function is used to disable the counter pin detection de-bounce function. More...
 
__STATIC_INLINE void TIMER_EnableInt (TIMER_T *timer)
 This function is used to enable the Timer time-out interrupt function. More...
 
__STATIC_INLINE void TIMER_DisableInt (TIMER_T *timer)
 This function is used to disable the Timer time-out interrupt function. More...
 
__STATIC_INLINE void TIMER_EnableCaptureInt (TIMER_T *timer)
 This function is used to enable the Timer capture trigger interrupt function. More...
 
__STATIC_INLINE void TIMER_DisableCaptureInt (TIMER_T *timer)
 This function is used to disable the Timer capture trigger interrupt function. More...
 
__STATIC_INLINE uint32_t TIMER_GetIntFlag (TIMER_T *timer)
 This function indicates Timer time-out interrupt occurred or not. More...
 
__STATIC_INLINE void TIMER_ClearIntFlag (TIMER_T *timer)
 This function clears the Timer time-out interrupt flag. More...
 
__STATIC_INLINE uint32_t TIMER_GetTFFlag (TIMER_T *timer)
 This function indicates Timer time-out event occurred or not. More...
 
__STATIC_INLINE void TIMER_ClearTFFlag (TIMER_T *timer)
 This function clears the Timer time-out evnet flag. More...
 
__STATIC_INLINE uint32_t TIMER_GetCaptureIntFlag (TIMER_T *timer)
 This function indicates Timer capture interrupt occurred or not. More...
 
__STATIC_INLINE void TIMER_ClearCaptureIntFlag (TIMER_T *timer)
 This function clears the Timer capture interrupt flag. More...
 
__STATIC_INLINE uint32_t TIMER_GetCaptureFlag (TIMER_T *timer)
 This function indicates Timer capture event occurred or not. More...
 
__STATIC_INLINE void TIMER_ClearCaptureFlag (TIMER_T *timer)
 This function clears the Timer capture event flag. More...
 
__STATIC_INLINE uint32_t TIMER_GetWakeupFlag (TIMER_T *timer)
 This function indicates Timer has waked up system or not. More...
 
__STATIC_INLINE void TIMER_ClearWakeupFlag (TIMER_T *timer)
 This function clears the Timer wakeup interrupt flag. More...
 
__STATIC_INLINE void TIMER_SetCaptureSource (TIMER_T *timer, TIMER_CapSrcDef capSrc)
 This function set the Timer capture source. More...
 
__STATIC_INLINE uint32_t TIMER_GetCaptureData (TIMER_T *timer)
 This function gets the Timer capture data. More...
 
__STATIC_INLINE uint32_t TIMER_GetCounter (TIMER_T *timer)
 This function reports the current timer counter value. More...
 
__STATIC_INLINE void TIMER_SetTmrCounterMode (TIMER_T *timer, uint32_t u32CntMode)
 This function set the timer counter mode. More...
 
uint32_t TIMER_Open (TIMER_T *timer, TIMER_CntModeDef cntMode, uint32_t u32Freq)
 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. More...
 
void TIMER_Close (TIMER_T *timer)
 This API stops Timer counting and disable the Timer interrupt function. More...
 
void TIMER_Delay (TIMER_T *timer, uint32_t u32Usec)
 This API is used to create a delay loop for u32usec micro seconds. More...
 

Detailed Description

Timer Interface.

Function Documentation

◆ TIMER_ClearCaptureFlag()

__STATIC_INLINE void TIMER_ClearCaptureFlag ( TIMER_T *  timer)

This function clears the Timer capture event flag.

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

◆ TIMER_ClearCaptureIntFlag()

__STATIC_INLINE void TIMER_ClearCaptureIntFlag ( TIMER_T *  timer)

This function clears the Timer capture interrupt flag.

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

◆ TIMER_ClearIntFlag()

__STATIC_INLINE void TIMER_ClearIntFlag ( TIMER_T *  timer)

This function clears the Timer time-out interrupt flag.

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

◆ TIMER_ClearTFFlag()

__STATIC_INLINE void TIMER_ClearTFFlag ( TIMER_T *  timer)

This function clears the Timer time-out evnet flag.

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

◆ TIMER_ClearWakeupFlag()

__STATIC_INLINE void TIMER_ClearWakeupFlag ( TIMER_T *  timer)

This function clears the Timer wakeup interrupt flag.

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

◆ TIMER_Close()

void TIMER_Close ( TIMER_T *  timer)

This API stops Timer counting and disable the Timer interrupt function.

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

◆ TIMER_Delay()

void TIMER_Delay ( TIMER_T *  timer,
uint32_t  u32Usec 
)

This API is used to create a delay loop for u32usec micro seconds.

Parameters
[in]timerThe base address of Timer module
[in]u32UsecDelay period in micro seconds with 10 usec every step. Valid values are between 10~1000000 (10 micro second ~ 1 second)
Returns
None
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

◆ TIMER_DisableCapture()

__STATIC_INLINE void TIMER_DisableCapture ( TIMER_T *  timer)

This API is used to disable the Timer capture function.

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

◆ TIMER_DisableCaptureDebounce()

__STATIC_INLINE void TIMER_DisableCaptureDebounce ( TIMER_T *  timer)

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

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

◆ TIMER_DisableCaptureInt()

__STATIC_INLINE void TIMER_DisableCaptureInt ( TIMER_T *  timer)

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

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

◆ TIMER_DisableEventCounter()

__STATIC_INLINE void TIMER_DisableEventCounter ( TIMER_T *  timer)

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

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

◆ TIMER_DisableEventCounterDebounce()

__STATIC_INLINE void TIMER_DisableEventCounterDebounce ( TIMER_T *  timer)

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

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

◆ TIMER_DisableInt()

__STATIC_INLINE void TIMER_DisableInt ( TIMER_T *  timer)

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

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

◆ TIMER_DisableWakeup()

__STATIC_INLINE void TIMER_DisableWakeup ( TIMER_T *  timer)

This function is used to disable the Timer wake-up function.

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

◆ TIMER_EnableCapture()

__STATIC_INLINE void TIMER_EnableCapture ( TIMER_T *  timer,
TIMER_CapModeDef  capMode,
TIMER_CapEdgeDef  capEdge 
)

This API is used to enable timer capture function with specified mode and capture edge.

Parameters
[in]timerThe base address of Timer module
[in]capModeTimer capture mode. Could be
[in]capEdgeTimer capture edge. Possible values are
Returns
None
Note
Timer frequency should be configured separately by using TIMER_Open API, or program registers directly

◆ TIMER_EnableCaptureDebounce()

__STATIC_INLINE void TIMER_EnableCaptureDebounce ( TIMER_T *  timer)

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

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

◆ TIMER_EnableCaptureInt()

__STATIC_INLINE void TIMER_EnableCaptureInt ( TIMER_T *  timer)

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

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

◆ TIMER_EnableEventCounter()

__STATIC_INLINE void TIMER_EnableEventCounter ( TIMER_T *  timer,
TIMER_EvtCntEdgeDef  evtCntEdge 
)

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

Parameters
[in]timerThe base address of Timer module
[in]evtCntEdgeDetection edge of counter pin. Could be ether
Returns
None
Note
Timer compare value should be configured separately by using TIMER_SetCmpValue function or program registers directly

◆ TIMER_EnableEventCounterDebounce()

__STATIC_INLINE void TIMER_EnableEventCounterDebounce ( TIMER_T *  timer)

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

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

◆ TIMER_EnableInt()

__STATIC_INLINE void TIMER_EnableInt ( TIMER_T *  timer)

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

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

◆ TIMER_EnableWakeup()

__STATIC_INLINE void TIMER_EnableWakeup ( TIMER_T *  timer)

This function is used to enable the Timer wake-up function.

Parameters
[in]timerThe base address of Timer module
Returns
None
Note
To wake the system from power down mode, timer clock source must be ether LXT or LIRC

◆ TIMER_GetCaptureData()

__STATIC_INLINE uint32_t TIMER_GetCaptureData ( TIMER_T *  timer)

This function gets the Timer capture data.

Parameters
[in]timerThe base address of Timer module
Returns
Timer capture data value

◆ TIMER_GetCaptureFlag()

__STATIC_INLINE uint32_t TIMER_GetCaptureFlag ( TIMER_T *  timer)

This function indicates Timer capture event occurred or not.

Parameters
[in]timerThe base address of Timer module
Returns
Timer capture event occurred or not
Return values
0Timer capture event did not occur
1Timer capture event occurred

◆ TIMER_GetCaptureIntFlag()

__STATIC_INLINE uint32_t TIMER_GetCaptureIntFlag ( TIMER_T *  timer)

This function indicates Timer capture interrupt occurred or not.

Parameters
[in]timerThe base address of Timer module
Returns
Timer capture interrupt occurred or not
Return values
0Timer capture interrupt did not occur
1Timer capture interrupt occurred

◆ TIMER_GetCounter()

__STATIC_INLINE uint32_t TIMER_GetCounter ( TIMER_T *  timer)

This function reports the current timer counter value.

Parameters
[in]timerThe base address of Timer module
Returns
Timer counter value

◆ TIMER_GetIntFlag()

__STATIC_INLINE uint32_t TIMER_GetIntFlag ( TIMER_T *  timer)

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

Parameters
[in]timerThe base address of Timer module
Returns
Timer time-out interrupt occurred or not
Return values
0Timer time-out interrupt did not occur
1Timer time-out interrupt occurred

◆ TIMER_GetTFFlag()

__STATIC_INLINE uint32_t TIMER_GetTFFlag ( TIMER_T *  timer)

This function indicates Timer time-out event occurred or not.

Parameters
[in]timerThe base address of Timer module
Returns
Timer time-out event occurred or not
Return values
0Timer time-out event did not occur
1Timer time-out event occurred

◆ TIMER_GetWakeupFlag()

__STATIC_INLINE uint32_t TIMER_GetWakeupFlag ( TIMER_T *  timer)

This function indicates Timer has waked up system or not.

Parameters
[in]timerThe base address of Timer module
Returns
Timer has waked up system or not
Return values
0Timer did not wake up system
1Timer wake up system

◆ TIMER_IsActive()

__STATIC_INLINE bool TIMER_IsActive ( TIMER_T *  timer)

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

Parameters
[in]timerThe base address of Timer module
Returns
timer is activate or inactivate
Return values
0Timer 24-bit up counter is inactive
1Timer 24-bit up counter is active

◆ TIMER_Open()

uint32_t TIMER_Open ( TIMER_T *  timer,
TIMER_CntModeDef  cntMode,
uint32_t  u32Freq 
)

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.

Parameters
[in]timerThe base address of Timer module
[in]cntModeOperation mode. Possible options are
[in]u32FreqTimer Target working frequency
Returns
Real Timer working frequency
Note
After calling this API, Timer is NOT running yet. But could start timer running be calling TIMER_Start macro or program registers directly

◆ TIMER_Reset()

__STATIC_INLINE void TIMER_Reset ( TIMER_T *  timer)

This function is used to reset Timer counting, prescale counter and CNTEN.

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

◆ TIMER_SetCaptureSource()

__STATIC_INLINE void TIMER_SetCaptureSource ( TIMER_T *  timer,
TIMER_CapSrcDef  capSrc 
)

This function set the Timer capture source.

Parameters
[in]timerThe base address of Timer module
[in]capSrcThe capture source for timer capture functions TIMER_CAPTURE_SOURCE_EXT_PIN TIMER_CAPTURE_SOURCE_32K_OUTPUT
Returns
None

◆ TIMER_SetCmpValue()

__STATIC_INLINE void TIMER_SetCmpValue ( TIMER_T *  timer,
uint32_t  u32Value 
)

This function is used to set new Timer compared value.

Parameters
[in]timerThe base address of Timer module
[in]u32ValueTimer compare value. Valid values are between 2 to 0xFFFFFF
Returns
None

◆ TIMER_SetCountingMode()

__STATIC_INLINE void TIMER_SetCountingMode ( TIMER_T *  timer,
TIMER_CntModeDef  cntMode 
)

This function is used to Set Timer counting mode.

Parameters
[in]timerThe base address of Timer module
[in]cntModeOperation mode. Possible options are
Returns
None

◆ TIMER_SetPrescaleValue()

__STATIC_INLINE void TIMER_SetPrescaleValue ( TIMER_T *  timer,
uint32_t  u32Value 
)

This function is used to set new Timer prescale value.

Parameters
[in]timerThe base address of Timer module
[in]u32ValueTimer prescale value. Valid values are between 0 to 0xFF
Returns
None
Note
Clock input is divided by (prescale + 1) before it is fed into timer

◆ TIMER_SetTmrCounterMode()

__STATIC_INLINE void TIMER_SetTmrCounterMode ( TIMER_T *  timer,
uint32_t  u32CntMode 
)

This function set the timer counter mode.

Parameters
[in]timerThe base address of Timer module
[in]u32CntModecount mode select, TIMER_CntModeDef
Returns
Timer counter value

◆ TIMER_Start()

__STATIC_INLINE void TIMER_Start ( TIMER_T *  timer)

This function is used to start Timer counting.

Parameters
[in]timerThe base address of Timer module
Returns
None
TIMER_Open(TIMER0, TIMER_PERIODIC_MODE, 16000000);
TIMER_SetCmpValue(TIMER0, 32000);
TIMER_Start(TIMER0);
@ TIMER_PERIODIC_MODE
Definition: pan_timer.h:36
__STATIC_INLINE void TIMER_Start(TIMER_T *timer)
This function is used to start Timer counting.
Definition: pan_timer.h:211
__STATIC_INLINE void TIMER_EnableInt(TIMER_T *timer)
This function is used to enable the Timer time-out interrupt function.
Definition: pan_timer.h:304
__STATIC_INLINE void TIMER_SetCmpValue(TIMER_T *timer, uint32_t u32Value)
This function is used to set new Timer compared value.
Definition: pan_timer.h:152
uint32_t TIMER_Open(TIMER_T *timer, TIMER_CntModeDef cntMode, uint32_t u32Freq)
This API is used to configure timer to operate in specified mode and frequency. If timer cannot work ...

◆ TIMER_Stop()

__STATIC_INLINE void TIMER_Stop ( TIMER_T *  timer)

This function is used to stop Timer counting.

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