3.1.6 PAL_TimerStart Function
C
PAL_Status_t PAL_TimerStart(TimerId_t timerId,
uint32_t timerCount,
TimeoutType_t timeoutType,
void * timerCb,
void *paramCb,
CallbackType_t callbackType)
Summary
Start regular timer
Description
This function starts a regular timer and installs the corresponding callback function handle the timeout event
Precondition
PAL_Init() should have been called before calling this function. PAL_TimerGetId() routine should be called to get the timer Id before starting it
Parameters
Param | Description |
---|---|
timerId | Timer identifier |
timerCount | Timeout in microseconds |
timeoutType | TIMEOUT_RELATIVE or @ref TIMEOUT_ABSOLUTE |
timerCb | Callback handler invoked upon timer expiry |
paramCb | Argument for the callback handler |
callbackType | CALLBACK_SINGLE or @ref CALLBACK_PERIODIC |
Returns
PAL_TMR_INVALID_ID - if the timer identifier is undefined
PAL_INVALID_PARAMETER - if the callback function for this timer is NULL, PAL_TMR_ALREADY_RUNNING - if the timer is already running
PAL_SUCCESS - if timer is started or
PAL_TMR_INVALID_TIMEOUT - if timeout is not within timeout
Example
PAL_Status_t retVal = PAL_FAILURE; TimerId_t appTimer; static void AppTimerCallback(void *paramCb) { //Toggle LED } //Get the Id for the sotware timer instance PAL_TimerGetId(&appTimer); if (PAL_SUCCESS == PAL_TimerStart(appTimer, 5000, TIMEOUT_RELATIVE, (void *)AppTimerCallback, NULL, CALLBACK_SINGLE)) { //Timer Started //ToggleLED }
Remarks
Starting PAL_Timer before getting the Id of timer will lead to unpredicted behaviour