|
oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
|
Periodic and one-shot software timer API backed by the active RTOS. More...
Typedefs | |
| typedef struct ove_timer * | ove_timer_t |
| Opaque handle for a software timer object. | |
| typedef void(* | ove_timer_fn) (ove_timer_t timer, void *user_data) |
| Timer expiry callback function prototype. | |
Functions | |
| int | ove_timer_init (ove_timer_t *timer, ove_timer_storage_t *storage, ove_timer_fn callback, void *user_data, uint32_t period_ms, int one_shot) |
| Initialise a software timer using caller-supplied static storage. | |
| void | ove_timer_deinit (ove_timer_t timer) |
| Stop and release resources held by a timer initialised with ove_timer_init(). | |
| int | ove_timer_create (ove_timer_t *timer, ove_timer_fn callback, void *user_data, uint32_t period_ms, int one_shot) |
| Allocate and initialise a software timer from the heap. | |
| void | ove_timer_destroy (ove_timer_t timer) |
| Stop and free a timer allocated with ove_timer_create(). | |
| int | ove_timer_start (ove_timer_t timer) |
| Start (arm) a timer. | |
| int | ove_timer_stop (ove_timer_t timer) |
| Stop a running timer without invoking its callback. | |
| int | ove_timer_reset (ove_timer_t timer) |
| Restart a timer's countdown from the beginning of its period. | |
Periodic and one-shot software timer API backed by the active RTOS.
CONFIG_OVE_TIMER to be defined. When CONFIG_OVE_TIMER is not set, every function is replaced by a static inline stub that returns OVE_ERR_NOT_SUPPORTED.Two allocation strategies are available:
_create() / _destroy() — unified API that works in both heap and zero-heap mode. In zero-heap mode these are macros that generate per-call-site static storage._init() / _deinit() — explicit storage control with caller-supplied buffers. Use when creating objects in loops, arrays, or structs. | typedef void(* ove_timer_fn) (ove_timer_t timer, void *user_data) |
Timer expiry callback function prototype.
Invoked by the RTOS timer service task (or equivalent) when the timer period elapses. Implementations must be non-blocking and short.
| [in] | timer | Handle of the timer that fired. |
| [in] | user_data | Opaque pointer supplied at timer creation time. |
| int ove_timer_init | ( | ove_timer_t * | timer, |
| ove_timer_storage_t * | storage, | ||
| ove_timer_fn | callback, | ||
| void * | user_data, | ||
| uint32_t | period_ms, | ||
| int | one_shot | ||
| ) |
Initialise a software timer using caller-supplied static storage.
Creates a timer in the stopped state. Call ove_timer_start() to arm it.
CONFIG_OVE_TIMER.| [out] | timer | Receives the opaque timer handle on success. |
| [in] | storage | Pointer to statically allocated backend storage. Must remain valid for the lifetime of the timer. |
| [in] | callback | Function invoked when the timer expires. Must not be NULL. |
| [in] | user_data | Opaque pointer forwarded to callback on each expiry. May be NULL. |
| [in] | period_ms | Timer period in milliseconds. Must be > 0. |
| [in] | one_shot | Non-zero to create a one-shot timer (fires once then stops automatically); zero for a periodic timer that reloads automatically. |
| void ove_timer_deinit | ( | ove_timer_t | timer | ) |
Stop and release resources held by a timer initialised with ove_timer_init().
Stops the timer if it is running. The static storage supplied at init time is not freed.
CONFIG_OVE_TIMER.| [in] | timer | Handle returned by ove_timer_init(). |
| int ove_timer_create | ( | ove_timer_t * | timer, |
| ove_timer_fn | callback, | ||
| void * | user_data, | ||
| uint32_t | period_ms, | ||
| int | one_shot | ||
| ) |
Allocate and initialise a software timer from the heap.
Creates a timer in the stopped state. Call ove_timer_start() to arm it.
CONFIG_OVE_TIMER and OVE_HEAP_TIMER (i.e. CONFIG_OVE_ZERO_HEAP must not be set).| [out] | timer | Receives the opaque timer handle on success. |
| [in] | callback | Function invoked when the timer expires. Must not be NULL. |
| [in] | user_data | Opaque pointer forwarded to callback on each expiry. May be NULL. |
| [in] | period_ms | Timer period in milliseconds. Must be > 0. |
| [in] | one_shot | Non-zero to create a one-shot timer; zero for a periodic auto-reloading timer. |
| void ove_timer_destroy | ( | ove_timer_t | timer | ) |
Stop and free a timer allocated with ove_timer_create().
CONFIG_OVE_TIMER and OVE_HEAP_TIMER.| [in] | timer | Handle returned by ove_timer_create(). |
| int ove_timer_start | ( | ove_timer_t | timer | ) |
Start (arm) a timer.
If the timer is already running, it is restarted from the beginning of its period. Has no effect if the timer is in a terminated state.
CONFIG_OVE_TIMER.| [in] | timer | Timer handle to start. |
| int ove_timer_stop | ( | ove_timer_t | timer | ) |
Stop a running timer without invoking its callback.
If the timer is already stopped, this function has no effect.
CONFIG_OVE_TIMER.| [in] | timer | Timer handle to stop. |
| int ove_timer_reset | ( | ove_timer_t | timer | ) |
Restart a timer's countdown from the beginning of its period.
Equivalent to stopping and then starting the timer, but performed atomically with respect to the RTOS timer service. Useful for implementing watchdog-style "kick" patterns.
CONFIG_OVE_TIMER.| [in] | timer | Timer handle to reset. |