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.
|
| typedef void(* | timer_callback_t) (struct mmosal_timer *timer) |
| | Function type definition for timer callbacks. More...
|
| |
◆ timer_callback_t
| typedef void(* timer_callback_t) (struct mmosal_timer *timer) |
Function type definition for timer callbacks.
- Parameters
-
| timer | The timer that triggered the callback. |
Definition at line 760 of file mmosal.h.
◆ mmosal_is_timer_active()
| bool mmosal_is_timer_active |
( |
struct mmosal_timer * |
timer | ) |
|
Queries the timer to determine if it running.
- Parameters
-
| timer | The 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
-
| timer | The timer to assign the new period. |
| new_period | Period 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
-
| name | The name of the timer. |
| timer_period_ms | The period of the timer in milliseconds. |
| auto_reload | If true then the timer will automatically be reloaded when it expires. |
| arg | Void pointer that can be used to store a value for the timer callback. Pass NULL if unused. |
| callback | Callback 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
-
| timer | The 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
-
| timer | The 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
-
- 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
-
- Returns
true if the timer was stopped successfully, else false.