1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

sys/event: add event_periodic_start_now()

This commit is contained in:
Fabian Hüßler 2024-10-14 21:17:38 +02:00
parent 2b682585a7
commit 90473c62f0
2 changed files with 22 additions and 1 deletions

View File

@ -25,7 +25,6 @@
static bool _event_periodic_callback(void *arg)
{
event_periodic_t *event_periodic = (event_periodic_t *)arg;
event_post(event_periodic->queue, event_periodic->event);
if (event_periodic->count && --event_periodic->count == 0) {

View File

@ -72,6 +72,28 @@ typedef struct {
void event_periodic_init(event_periodic_t *event_periodic, ztimer_clock_t *clock,
event_queue_t *queue, event_t *event);
/**
* @brief Starts a periodic timeout without delay for the first occurrence
*
* This will make the event as configured in @p event_periodic be triggered
* at every interval ticks (based on event_periodic->clock).
*
* @note: the used event_periodic struct must stay valid until after the timeout
* event has been processed!
*
* @note: this function does not touch the current count value.
*
* @note: the periodic event will start without delay.
*
* @param[in] event_periodic event_timout context object to use
* @param[in] interval period length for the event
*/
static inline void event_periodic_start_now(event_periodic_t *event_periodic, uint32_t interval)
{
event_periodic->timer.interval = interval;
ztimer_periodic_start_now(&event_periodic->timer);
}
/**
* @brief Starts a periodic timeout
*