Morse Micro IoT SDK  2.9.7

Detailed Description

Provides support for RTOS timers.

Note
The timer service must have a priority higher than MMOSAL_TASK_PRI_HIGH. This is because tasks may yield to allow the timer service to execute. In some RTOS implementations if there are no other tasks at a higher or equal priority to the task that calls mmosal_task_yield() then the RTOS scheduler will simply select the task that called mmosal_task_yield() to run again.

Typedefs

typedef void(* timer_callback_t) (struct mmosal_timer *timer)
 Function type definition for timer callbacks. More...
 

Functions

struct mmosal_timer * mmosal_timer_create (const char *name, uint32_t timer_period_ms, bool auto_reload, void *arg, timer_callback_t callback)
 Create a new timer. More...
 
void mmosal_timer_delete (struct mmosal_timer *timer)
 Delete a timer. More...
 
bool mmosal_timer_start (struct mmosal_timer *timer)
 Start a timer. More...
 
bool mmosal_timer_stop (struct mmosal_timer *timer)
 Stop a timer. More...
 
bool mmosal_timer_change_period (struct mmosal_timer *timer, uint32_t new_period)
 Change timer period. More...
 
void * mmosal_timer_get_arg (struct mmosal_timer *timer)
 Get the opaque argument associated with a given timer. More...
 
bool mmosal_is_timer_active (struct mmosal_timer *timer)
 Queries the timer to determine if it running. More...
 

Typedef Documentation

◆ timer_callback_t

typedef void(* timer_callback_t) (struct mmosal_timer *timer)

Function type definition for timer callbacks.

Parameters
timerThe timer that triggered the callback.

Definition at line 760 of file mmosal.h.

Function Documentation

◆ mmosal_is_timer_active()

bool mmosal_is_timer_active ( struct mmosal_timer *  timer)

Queries the timer to determine if it running.

Parameters
timerThe timer to retrieve the argument from.
Returns
true if the timer is running, else false.

◆ mmosal_timer_change_period()

bool mmosal_timer_change_period ( struct mmosal_timer *  timer,
uint32_t  new_period 
)

Change timer period.

Warning
May not be invoked from an ISR.
Parameters
timerThe timer to assign the new period.
new_periodPeriod to assign to the timer.
Returns
true if the timer period was stopped change, else false.

◆ mmosal_timer_create()

struct mmosal_timer * mmosal_timer_create ( const char *  name,
uint32_t  timer_period_ms,
bool  auto_reload,
void *  arg,
timer_callback_t  callback 
)

Create a new timer.

Parameters
nameThe name of the timer.
timer_period_msThe period of the timer in milliseconds.
auto_reloadIf true then the timer will automatically be reloaded when it expires.
argVoid pointer that can be used to store a value for the timer callback. Pass NULL if unused.
callbackCallback to be triggered when the timer expires.
Returns
an opaque handle to the timer, or NULL on failure.
Warning
Ensure that the timer callback function does not block or cause the calling task to be placed in a blocked state.

◆ mmosal_timer_delete()

void mmosal_timer_delete ( struct mmosal_timer *  timer)

Delete a timer.

Parameters
timerThe timer to delete.

◆ mmosal_timer_get_arg()

void * mmosal_timer_get_arg ( struct mmosal_timer *  timer)

Get the opaque argument associated with a given timer.

Parameters
timerThe timer to retrieve the argument from.
Returns
void pointer to the argument.

◆ mmosal_timer_start()

bool mmosal_timer_start ( struct mmosal_timer *  timer)

Start a timer.

Parameters
timerThe timer to start.
Returns
true if the timer was started successfully, else false.

◆ mmosal_timer_stop()

bool mmosal_timer_stop ( struct mmosal_timer *  timer)

Stop a timer.

Parameters
timerThe timer to stop.
Returns
true if the timer was stopped successfully, else false.