periodic_callback.h File Reference

Provides functionality to trigger periodic event callbacks. More...

Detailed Description

Provides functionality to trigger periodic event callbacks.

This provides convenience functions to trigger periodic event callbacks executed by the event thread.

Event Periodic Callback API

Author
Benjamin Valentin benja.nosp@m.min..nosp@m.valen.nosp@m.tin@.nosp@m.ml-pa.nosp@m..com

Definition in file periodic_callback.h.

#include "event/callback.h"
#include "event/periodic.h"
+ Include dependency graph for periodic_callback.h:

Go to the source code of this file.

Data Structures

struct  event_periodic_callback_t
 Periodic Callback Event structure. More...
 
static void * event_periodic_callback_get_arg (event_periodic_callback_t *event)
 Get user context from Periodic Callback Event. More...
 
static void event_periodic_callback_init (event_periodic_callback_t *event, ztimer_clock_t *clock, event_queue_t *queue, void(*callback)(void *), void *arg)
 Initialize a periodic callback event. More...
 
static void event_periodic_callback_start (event_periodic_callback_t *event, uint32_t interval)
 Starts a periodic callback event. More...
 
static void event_periodic_callback_set_count (event_periodic_callback_t *event, uint32_t count)
 Set the amount of times the periodic callback event should repeat itself. More...
 
static void event_periodic_callback_stop (event_periodic_callback_t *event)
 Stop a periodic callback event. More...
 

Function Documentation

◆ event_periodic_callback_get_arg()

static void* event_periodic_callback_get_arg ( event_periodic_callback_t event)
inlinestatic

Get user context from Periodic Callback Event.

Parameters
[in]eventevent_periodic_callback object to initialize
Returns
User supplied argument to the event

Definition at line 49 of file periodic_callback.h.

◆ event_periodic_callback_init()

static void event_periodic_callback_init ( event_periodic_callback_t event,
ztimer_clock_t clock,
event_queue_t queue,
void(*)(void *)  callback,
void *  arg 
)
inlinestatic

Initialize a periodic callback event.

Note
: On init the periodic event is to to run forever.
Parameters
[in]eventevent_periodic_callback object to initialize
[in]clockthe clock to configure this timer on
[in]queuequeue that the timed-out event will be added to
[in]callbackcallback to set up
[in]argcallback argument to set up

Definition at line 65 of file periodic_callback.h.

◆ event_periodic_callback_set_count()

static void event_periodic_callback_set_count ( event_periodic_callback_t event,
uint32_t  count 
)
inlinestatic

Set the amount of times the periodic callback event should repeat itself.

Parameters
[in]eventevent_periodic_callback context object to use
[in]counttimes the event should repeat itself, EVENT_PERIODIC_FOREVER to run for ever.

Definition at line 107 of file periodic_callback.h.

◆ event_periodic_callback_start()

static void event_periodic_callback_start ( event_periodic_callback_t event,
uint32_t  interval 
)
inlinestatic

Starts a periodic callback event.

If the event is already started, it's interval will be updated and it will be scheduled with the new interval.

This will make the event as configured in event 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!
: this function does not touch the current count value.
Parameters
[in]eventevent_periodic_callback context object to use
[in]intervalperiod length for the event

Definition at line 94 of file periodic_callback.h.

◆ event_periodic_callback_stop()

static void event_periodic_callback_stop ( event_periodic_callback_t event)
inlinestatic

Stop a periodic callback event.

Calling this function will cancel the timeout by removing its underlying timer. If the timer has already fired before calling this function, the connected event will be put already into the given event queue and this function does not have any effect.

Note
Calling this function does not touch event_periodic->count, if the periodic event was not set to run for ever and did run until expiration, then count will be != 0 after this function is called.
Parameters
[in]eventevent_periodic_callback context object to use

Definition at line 127 of file periodic_callback.h.