Skip to content

Commit

Permalink
Merge pull request #20459 from benpicco/event_periodic_callback_create
Browse files Browse the repository at this point in the history
event_periodic_callback: add event_periodic_callback_create()
  • Loading branch information
mguetschow authored Mar 18, 2024
2 parents 76ef767 + 2bef44b commit 3aaea1a
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion sys/include/event/periodic_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static inline void *event_periodic_callback_get_arg(event_periodic_callback_t *e
/**
* @brief Initialize a periodic callback event
*
* @note: On init the periodic event is to to run forever.
* @note: On init the periodic event is configured to run forever.
*
* @param[in] event event_periodic_callback object to initialize
* @param[in] clock the clock to configure this timer on
Expand Down Expand Up @@ -97,6 +97,28 @@ static inline void event_periodic_callback_start(event_periodic_callback_t *even
event_periodic_start(&event->periodic, interval);
}

/**
* @brief Initialize and start a periodic callback event
*
* This is a convenience function that combines @ref event_periodic_callback_init
* and @ref event_periodic_callback_start
*
* @param[out] event event_periodic_callback object to initialize
* @param[in] clock the clock to configure this timer on
* @param[in] interval period length for the event
* @param[in] queue queue that the timed-out event will be added to
* @param[in] callback callback to set up
* @param[in] arg callback argument to set up
*/
static inline void event_periodic_callback_create(event_periodic_callback_t *event,
ztimer_clock_t *clock, uint32_t interval,
event_queue_t *queue,
void (*callback)(void *), void *arg)
{
event_periodic_callback_init(event, clock, queue, callback, arg);
event_periodic_callback_start(event, interval);
}

/**
* @brief Get the interval in which the periodic callback event repeats
*
Expand Down

0 comments on commit 3aaea1a

Please sign in to comment.