The Timer APIs provide a set of functions for using the timer module. Functions are provided to configure and control the timer, modify timer/counter values, and manage timer interrupt handling.The Timer consists of two programmable Free Run Counters. Each timer block operates identically. The Free Run Counters can be programmed for 32-bit or 16-bit counter. Any one of the following three timer modes can be selected:

  • Free-running mode: The counter operates continuously and wraps around to its maximum value each time that it reaches zero.
  • Periodic mode: The counter is reloaded from Load Register and operates continuously each time that it reaches zero.
  • One-shot mode: Writing to the Load Register loads the counter with a new value. The counter halts until it is reprogrammed when the counter reaches zero.

 

RSI_TIMERS_SetTimerMode:

Prototype
STATIC INLINE error_t RSI_TIMERS_SetTimerMode(RSI_TIMERS_T *pTIMER, boolean_t mode,uint8_t timerNum)
Input Arguments

pTIMER     : Pointer to the TIMERS instance register area

mode       : in which mode timer run

                  PERIODIC_TIMER

                  ONESHOT_TIMER

timerNum   : Timer number(0 to 3)

Return Value None
Description

return the timer error code

Example Usage
RSI_TIMERS_SetTimerMode(TIMERS, PERIODIC_TIMER, TIMER_0);

 

RSI_TIMERS_SetTimerType:

Prototype

STATIC INLINE error_t RSI_TIMERS_SetTimerType( RSI_TIMERS_T *pTIMER, uint8_t timerType,

                                                                               uint8_t timerNum)

Input Arguments

pTIMER     : Pointer to the TIMERS instance register area

timerType  : timer type

                    MICRO_SEC_MODE

                    _256_MICRO_SEC_MODE

                    COUNTER_DOWN_MODE

timerNum   : Timer number(0 to 3)

Return Value

return the timer error code

Description

This API is used to set the timer type

Example Usage RSI_TIMERS_SetTimerType(TIMERS, MICRO_SEC_MODE, TIMER_0);

 

RSI_TIMERS_MicroSecTimerConfig:

Prototype

STATIC INLINE error_t RSI_TIMERS_MicroSecTimerConfig(RSI_TIMERS_T *pTIMER, uint8_t timerNum,

        uint16_t integer,uint8_t fractional,

        uint8_t mode)

Input Arguments

pTIMER    : Pointer to the TIMERS instance register area

timerNum  : Timer number(0 to 3)

integer     : Integer part of number of clock cycles

                 (per microsecond of the system clock being used)

fractional  : Fractional part of clock cycles per microsecond of the system clock being used

mode        : timer mode

                  MICRO_SEC_MODE

                  _256_MICRO_SEC_MODE

                  COUNTER_DOWN_MODE

Return Value

TIMERS_INVAL_TIMER_MODE   : If timer mode is invalid

TIMERS_INVAL_TIMER_NUM_ERROR  : If timer number is invalid

RSI_OK   : If process is done

Description This API is used to configure timer mode as a 1 micro second or 256 micro second mode
Example Usage
RSI_TIMERS_MicroSecTimerConfig(TIMERS, TIMER_0, 32, 0 ,MICRO_SEC_MODE);

 

RSI_TIMERS_SetMatch:

Prototype
STATIC INLINE error_t RSI_TIMERS_SetMatch( RSI_TIMERS_T *pTIMER, uint8_t timerNum, uint32_t match)
Input Arguments

 pTIMER     : Pointer to the TIMERS instance register area

 timerNum   : Timer number(0 to 3)

 match        : delay time

Return Value

return the timer error code

Description

This API is used to disable the timer interrupt

Example Usage RSI_TIMERS_SetMatch(TIMERS, TIMER_0,1000000);

 

RSI_TIMERS_InterruptEnable:

Prototype
STATIC INLINE error_t RSI_TIMERS_InterruptEnable(RSI_TIMERS_T *pTIMER , uint8_t timerNum)
Input Arguments

pTIMER     : Pointer to the TIMERS instance register area

timerNum   : Timer number(0 to 3)

Return Value

return the timer error code

Description

This API is used to enable the timer interrupt

Example Usage
RSI_TIMERS_InterruptEnable(TIMERS , TIMER_0);

 

RSI_TIMERS_TimerStart:

Prototype
STATIC INLINE error_t  RSI_TIMERS_TimerStart(RSI_TIMERS_T *pTIMER, uint8_t timerNum)
Input Arguments

pTIMER     : Pointer to the TIMERS instance register area

timerNum   : Timer number(0 to 3)

Return Value return the timer error code
Description

This API is used to start the timer

Example Usage
RSI_TIMERS_TimerStart(TIMERS, TIMER_0);

 

RSI_TIMERS_InterruptClear:

Prototype
STATIC INLINE error_t RSI_TIMERS_InterruptClear(RSI_TIMERS_T *pTIMER, uint8_t timerNum)
Input Arguments

pTIMER     : Pointer to the TIMERS instance register area

timerNum   : Timer number(0 to 3)

Return Value return the timer error code
Description

This API is used to clear the timer interrupt

Example Usage
RSI_TIMERS_InterruptClear(TIMERS, TIMER_0);

 

RSI_TIMERS_GetTimerType:

Prototype
STATIC INLINE uint32_t RSI_TIMERS_GetTimerType(RSI_TIMERS_T *pTIMER , uint8_t timerNum)
Input Arguments

pTIMER     : Pointer to the TIMERS instance register area

timerNum   : Timer number(0 to 3)

Return Value

return the type of timer if valid timer else error code

Description

This API is used to get the type of timer

Example Usage
timer_type=RSI_TIMERS_GetTimerType(TIMERS,TIMER_0);

 

RSI_TIMERS_TimerStop:

Prototype
STATIC INLINE error_t RSI_TIMERS_TimerStop(RSI_TIMERS_T *pTIMER, uint8_t timerNum)
Input Arguments

pTIMER     : Pointer to the TIMERS instance register area

timerNum   : Timer number(0 to 3)

Return Value

return the timer error code

Description

This API is used to stop the timer

Example Usage
RSI_TIMERS_TimerStop(TIMERS,TIMER_0);