From 6f604a81372e254031678ef873c2e586698933ea Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Tue, 12 Mar 2024 11:06:37 +0100 Subject: [PATCH 1/2] event_periodic_callback: add event_periodic_callback_create() --- sys/include/event/periodic_callback.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sys/include/event/periodic_callback.h b/sys/include/event/periodic_callback.h index dac03c5ca584..6cb03acaf478 100644 --- a/sys/include/event/periodic_callback.h +++ b/sys/include/event/periodic_callback.h @@ -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 * From 2bef44bd6b9ef946b8078aa8a69369bc1d42892b Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Tue, 12 Mar 2024 18:35:42 +0100 Subject: [PATCH 2/2] event_periodic_callback: fix typo --- sys/include/event/periodic_callback.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/include/event/periodic_callback.h b/sys/include/event/periodic_callback.h index 6cb03acaf478..26ff293f9f74 100644 --- a/sys/include/event/periodic_callback.h +++ b/sys/include/event/periodic_callback.h @@ -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