1.2.11.4.7 SYS_TIME_DelayMS Function
C
SYS_TIME_RESULT SYS_TIME_DelayMS ( uint32_t ms, SYS_TIME_HANDLE* handle )
Summary
This function is used to generate a delay of a given number of milliseconds.
Description
The function will internally create a single shot timer which will be auto deleted when the application calls SYS_TIME_DelayIsComplete routine and the delay has expired. The function will return immediately, requiring the caller to use SYS_TIME_DelayIsComplete routine to check the delay timer's status.
Precondition
The SYS_TIME_Initialize function must have been called before calling this function.
Parameters
Param | Description |
---|---|
ms | The desired number of milliseconds to delay. |
handle | Address of the variable to receive the timer handle value. |
Returns
SYS_TIME_SUCCESS - If the call succeeded.
SYS_TIME_ERROR - If the call failed.
Example
SYS_TIME_HANDLE timer = SYS_TIME_HANDLE_INVALID;
if (SYS_TIME_DelayMS(100, &timer) != SYS_TIME_SUCCESS)
{
// Handle error
}
else if(SYS_TIME_DelayIsComplete(timer) != true)
{
// Wait till the delay has not expired
while (SYS_TIME_DelayIsComplete(timer) == false);
}
Remarks
Will delay the requested number of milliseconds or longer depending on system performance. In tick-based mode, the requested delay will be ceiled to the next timer tick. For example, if the timer tick is set to 700 usec and the requested delay is 2 msec, a delay of 2.1 ms will be generated.
Delay values of 0 will return SYS_TIME_ERROR.
Will return SYS_TIME_ERROR if the timer handle pointer is NULL.