1.2.11.4.18 SYS_TIME_TimerReload Function
C
SYS_TIME_RESULT SYS_TIME_TimerReload ( SYS_TIME_HANDLE handle, uint32_t count, uint32_t period, SYS_TIME_CALLBACK callback, uintptr_t context, SYS_TIME_CALLBACK_TYPE type );
Summary
Reloads (or reinitializes) the software timer instance.
Description
This function reloads the initial values for an already created/allocated instance of a software timer, even if it is currently running.
Precondition
The SYS_TIME_Initialize must have been called and a valid handle to the software timer to be reloaded must be available.
Parameters
Param | Description |
---|---|
handle | Handle to a software timer instance. |
count | The new value of the counter. |
period | The new period value. |
callback | The new callback function pointer. For single shot timers, the callback must be specified. For periodic timers, if the callback pointer is given as NULL, no callback will occur, but SYS_TIME_TimerPeriodHasExpired can still be polled to determine if the period has expired for a periodic timer. |
context | The new caller-defined value that's passed (unmodified) back to the client as a parameter of callback function. |
type | Type of callback requested. If type is SYS_TIME_SINGLE, the Callback function will be called once when the time period expires. If type is SYS_TIME_PERIODIC Callback function will be called repeatedly, every time the time period expires until the timer object is stopped or deleted. |
Returns
SYS_TIME_SUCCESS - If the call succeeded.
SYS_TIME_ERROR - If the call failed (and the timer was not modified).
Example
Given an implementation of the following function prototype:
void MyNewCallback ( uintptr_t context);
The following example updates a software timer instance.
//myNewData is the user-defined data that will be passed back in the registered callback function. if (SYS_TIME_TimerReload(timer, 0, SYS_TIME_MSToCount(500), &MyNewCallback, (uintptr_t)&myNewData, SYS_TIME_PERIODIC) != SYS_TIME_SUCCESS ) { // Handle error }
Remarks
This function facilitates changing multiple timer parameters quickly and atomically.