le_timer.h File Reference

Go to the source code of this file.

Typedefs

typedef struct le_timer * le_timer_Ref_t
 
typedef void(* le_timer_ExpiryHandler_t) (le_timer_Ref_t timerRef)
 

Functions

le_timer_Ref_t le_timer_Create (const char *nameStr)
 
void le_timer_Delete (le_timer_Ref_t timerRef)
 
le_result_t le_timer_SetHandler (le_timer_Ref_t timerRef, le_timer_ExpiryHandler_t handlerFunc)
 
le_result_t le_timer_SetInterval (le_timer_Ref_t timerRef, le_clk_Time_t interval)
 
le_clk_Time_t le_timer_GetInterval (le_timer_Ref_t timerRef)
 
le_result_t le_timer_SetMsInterval (le_timer_Ref_t timerRef, uint32_t interval)
 
uint32_t le_timer_GetMsInterval (le_timer_Ref_t timerRef)
 
le_result_t le_timer_SetRepeat (le_timer_Ref_t timerRef, uint32_t repeatCount)
 
le_result_t le_timer_SetWakeup (le_timer_Ref_t timerRef, bool wakeupEnabled)
 
le_result_t le_timer_SetContextPtr (le_timer_Ref_t timerRef, void *contextPtr)
 
void * le_timer_GetContextPtr (le_timer_Ref_t timerRef)
 
uint32_t le_timer_GetExpiryCount (le_timer_Ref_t timerRef)
 
le_clk_Time_t le_timer_GetTimeRemaining (le_timer_Ref_t timerRef)
 
uint32_t le_timer_GetMsTimeRemaining (le_timer_Ref_t timerRef)
 
le_result_t le_timer_Start (le_timer_Ref_t timerRef)
 
le_result_t le_timer_Stop (le_timer_Ref_t timerRef)
 
void le_timer_Restart (le_timer_Ref_t timerRef)
 
bool le_timer_IsRunning (le_timer_Ref_t timerRef)
 

Detailed Description

Legato Timer API include file.

Typedef Documentation

◆ le_timer_ExpiryHandler_t

typedef void(* le_timer_ExpiryHandler_t) (le_timer_Ref_t timerRef)

Prototype for timer expiry handler function.

Parameters
timerRefTimer that has expired

◆ le_timer_Ref_t

typedef struct le_timer* le_timer_Ref_t

Timer object. Created by le_timer_Create().

Function Documentation

◆ le_timer_Create()

le_timer_Ref_t le_timer_Create ( const char *  nameStr)

Create the timer object.

Parameters
[in]nameStrName of the timer.
Returns
A reference to the timer object.

◆ le_timer_Delete()

void le_timer_Delete ( le_timer_Ref_t  timerRef)

Delete the timer object.

Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRefDelete this timer object

◆ le_timer_GetContextPtr()

void* le_timer_GetContextPtr ( le_timer_Ref_t  timerRef)

Get context pointer for the timer.

This can be used when the timer expires to retrieve data that was previously set.

Returns
Context pointer, which could be NULL if it was not set.
Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRefGet context pointer for this timer object

◆ le_timer_GetExpiryCount()

uint32_t le_timer_GetExpiryCount ( le_timer_Ref_t  timerRef)

Get the expiry count of a timer.

The count is returned for currently running and idle timers. The expiry count is reset every time the timer is (re)started.

Returns
Expiry count, or zero if the timer has never expired.
Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRefGet expiry count for this timer object

◆ le_timer_GetInterval()

le_clk_Time_t le_timer_GetInterval ( le_timer_Ref_t  timerRef)

Get the timer interval.

Returns
The timer interval. If it hasn't been set yet, {0, 0} will be returned.
Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRefTimer object.

◆ le_timer_GetMsInterval()

uint32_t le_timer_GetMsInterval ( le_timer_Ref_t  timerRef)

Get the timer interval in milliseconds.

Returns
The timer interval (ms). If it hasn't been set yet, 0 will be returned.
Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRefTimer object.

◆ le_timer_GetMsTimeRemaining()

uint32_t le_timer_GetMsTimeRemaining ( le_timer_Ref_t  timerRef)

Get the time remaining (in milliseconds) until the next scheduled expiry.

Returns
Time remaining (in milliseconds). 0 if the timer is stopped or if it has reached its expiry time.
Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRefGet expiry count for this timer object

◆ le_timer_GetTimeRemaining()

le_clk_Time_t le_timer_GetTimeRemaining ( le_timer_Ref_t  timerRef)

Get the time remaining until the next scheduled expiry.

Returns
Time remaining. {0, 0} if the timer is stopped or if it has reached its expiry time.
Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRefGet expiry count for this timer object

◆ le_timer_IsRunning()

bool le_timer_IsRunning ( le_timer_Ref_t  timerRef)

Is the timer currently running?

Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRefIs this timer object currently running?

◆ le_timer_Restart()

void le_timer_Restart ( le_timer_Ref_t  timerRef)

Re-start the timer.

Start the given timer. If the timer is currently running, it will be stopped and then started. If the timer is not currently running, it will be started.

Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRef(Re)start this timer object.

◆ le_timer_SetContextPtr()

le_result_t le_timer_SetContextPtr ( le_timer_Ref_t  timerRef,
void *  contextPtr 
)

Set context pointer for the timer.

This can be used to pass data to the timer when it expires.

Returns
  • LE_OK on success
  • LE_BUSY if the timer is currently running
Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRefSet context pointer for this timer object
[in]contextPtrContext Pointer.

◆ le_timer_SetHandler()

le_result_t le_timer_SetHandler ( le_timer_Ref_t  timerRef,
le_timer_ExpiryHandler_t  handlerFunc 
)

Set the timer expiry handler function.

If the handler is NULL, then the previous handler will be removed.

Returns
  • LE_OK on success
  • LE_BUSY if the timer is currently running
Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRefSet expiry handler for this timer object.
[in]handlerFuncHandler function to call on expiry.

◆ le_timer_SetInterval()

le_result_t le_timer_SetInterval ( le_timer_Ref_t  timerRef,
le_clk_Time_t  interval 
)

Set the timer interval.

Timer will expire after the interval has elapsed since it was last started or restarted.

If the timer is running when the interval is changed and the new interval is shorter than the period of time since the timer last (re)started, the timer will expire immediately.

Returns
  • LE_OK on success
Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRefSet interval for this timer object.
[in]intervalTimer interval.

◆ le_timer_SetMsInterval()

le_result_t le_timer_SetMsInterval ( le_timer_Ref_t  timerRef,
uint32_t  interval 
)

Set the timer interval using milliseconds.

Timer will expire after the interval has elapsed since it was last started or restarted.

If the timer is running when the interval is changed and the new interval is shorter than the period of time since the timer last (re)started, the timer will expire immediately.

Returns
  • LE_OK on success
Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRefSet interval for this timer object.
[in]intervalTimer interval in milliseconds.

◆ le_timer_SetRepeat()

le_result_t le_timer_SetRepeat ( le_timer_Ref_t  timerRef,
uint32_t  repeatCount 
)

Set how many times the timer will repeat.

Timer will repeat the given number of times. A value of 0 means repeat indefinitely. The default is 1, so that a one-shot timer is the default.

Returns
  • LE_OK on success
  • LE_BUSY if the timer is currently running
Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRefSet repeat count for this timer object
[in]repeatCountNumber of times the timer will repeat (0 = forever).

◆ le_timer_SetWakeup()

le_result_t le_timer_SetWakeup ( le_timer_Ref_t  timerRef,
bool  wakeupEnabled 
)

Configure if timer expiry will wake up a suspended system.

Returns
  • LE_OK on success
  • LE_BUSY if the timer is currently running
Note
The default timer expiry behaviour will wake up the system. If an invalid timer object is given, the process exits.
Parameters
[in]timerRefDisable system wake up for this timer object
[in]wakeupEnabledFlag to determine timer will wakeup or not

◆ le_timer_Start()

le_result_t le_timer_Start ( le_timer_Ref_t  timerRef)

Start the timer.

Start the given timer. The timer must not be currently running.

Returns
  • LE_OK on success
  • LE_BUSY if the timer is already running
Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRefStart this timer object.

◆ le_timer_Stop()

le_result_t le_timer_Stop ( le_timer_Ref_t  timerRef)

Stop the timer.

Stop the given timer. The timer must be running.

Returns
  • LE_OK on success
  • LE_FAULT if the timer is not currently running
Note
If an invalid timer object is given, the process exits.
Parameters
[in]timerRefStop this timer object.