1.5.4.4.5 SRV_TIME_MANAGEMENT_CbRegisterUS Function

C

SYS_TIME_HANDLE SRV_TIME_MANAGEMENT_CbRegisterUS ( SYS_TIME_CALLBACK callback,
    uintptr_t context, uint32_t us, SYS_TIME_CALLBACK_TYPE type );

Summary

Registers a function with the time system service to be called back when the requested number of microseconds have expired (either once or repeatedly).

Description

This routine registers a function in SYS_TIME to be called back when the requested delay (specified in microseconds) has completed. The caller must identify if the timer should call the function once or repeatedly every time the given delay period expires.

Precondition

None.

Parameters

Param Description
callback

Pointer to the function to be called.

context A client-defined value that is passed to the callback function.
us Time period in microseconds.
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, the callback function will be called repeatedly, every time the time period expires until the timer object is stopped or deleted.

Returns

SYS_TIME_HANDLE - A valid timer object handle if the call succeeds.

SYS_TIME_HANDLE_INVALID if it fails.

Example

void MyCallback ( uintptr_t context);

SYS_TIME_HANDLE handle = SRV_TIME_MANAGEMENT_CbRegisterUS(MyCallback, (uintptr_t)0, 500, SYS_TIME_PERIODIC);
if (handle != SYS_TIME_HANDLE_INVALID)
{
}

Remarks

This service will give a callback after the requested number of microseconds or longer have elapsed, 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.