Jump to main content

##

# 1.2.11.4.6 SYS_TIME_DelayUS Function

## C

    SYS_TIME_RESULT SYS_TIME_DelayUS ( uint32_t us, SYS_TIME_HANDLE* handle )

## Summary

This function is used to generate a delay of a given number of microseconds.

## 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
--- | ---
us | The desired number of microseconds 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, either because the requested delay is zero, or the passed handle is invalid or there is not enough room to queue in the request in the SYS Time's internal queue.

## Example

    SYS_TIME_HANDLE timer = SYS_TIME_HANDLE_INVALID;

    if (SYS_TIME_DelayUS(50, &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 microseconds 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 1 msec and the requested delay is 1500 usec, a delay of 2 msec will be generated.

Delay values of 0 will return SYS_TIME_ERROR.

Will return SYS_TIME_ERROR if timer handle pointer is NULL.