Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
zbus.h File Reference
#include <string.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/iterable_sections.h>

Go to the source code of this file.

Data Structures

struct  zbus_channel_data
 Type used to represent a channel mutable data. More...
 
struct  zbus_channel
 Type used to represent a channel. More...
 
struct  zbus_observer_data
 
struct  zbus_observer
 Type used to represent an observer. More...
 

Macros

#define ZBUS_CHAN_ADD_OBS_WITH_MASK(_chan, _obs, _masked, _prio)
 Add a static channel observervation.
 
#define ZBUS_CHAN_ADD_OBS(_chan, _obs, _prio)   ZBUS_CHAN_ADD_OBS_WITH_MASK(_chan, _obs, false, _prio)
 Add a static channel observervation.
 
#define ZBUS_OBS_DECLARE(...)   FOR_EACH_NONEMPTY_TERM(_ZBUS_OBS_EXTERN, (;), __VA_ARGS__)
 This macro list the observers to be used in a file.
 
#define ZBUS_CHAN_DECLARE(...)   FOR_EACH(_ZBUS_CHAN_EXTERN, (;), __VA_ARGS__)
 This macro list the channels to be used in a file.
 
#define ZBUS_OBSERVERS_EMPTY
 This macro indicates the channel has no observers.
 
#define ZBUS_OBSERVERS(...)   __VA_ARGS__
 This macro indicates the channel has listed observers.
 
#define ZBUS_CHAN_DEFINE(_name, _type, _validator, _user_data, _observers, _init_val)
 Zbus channel definition.
 
#define ZBUS_MSG_INIT(_val, ...)
 Initialize a message.
 
#define ZBUS_SUBSCRIBER_DEFINE_WITH_ENABLE(_name, _queue_size, _enable)
 Define and initialize a subscriber.
 
#define ZBUS_SUBSCRIBER_DEFINE(_name, _queue_size)    ZBUS_SUBSCRIBER_DEFINE_WITH_ENABLE(_name, _queue_size, true)
 Define and initialize a subscriber.
 
#define ZBUS_LISTENER_DEFINE_WITH_ENABLE(_name, _cb, _enable)
 Define and initialize a listener.
 
#define ZBUS_LISTENER_DEFINE(_name, _cb)   ZBUS_LISTENER_DEFINE_WITH_ENABLE(_name, _cb, true)
 Define and initialize a listener.
 
#define ZBUS_MSG_SUBSCRIBER_DEFINE_WITH_ENABLE(_name, _enable)
 Define and initialize a message subscriber.
 
#define ZBUS_MSG_SUBSCRIBER_DEFINE(_name)   ZBUS_MSG_SUBSCRIBER_DEFINE_WITH_ENABLE(_name, true)
 Define and initialize an enabled message subscriber.
 

Enumerations

enum  zbus_observer_type { ZBUS_OBSERVER_LISTENER_TYPE , ZBUS_OBSERVER_SUBSCRIBER_TYPE , ZBUS_OBSERVER_MSG_SUBSCRIBER_TYPE }
 Type used to represent an observer type. More...
 

Functions

int zbus_chan_pub (const struct zbus_channel *chan, const void *msg, k_timeout_t timeout)
 Publish to a channel.
 
int zbus_chan_read (const struct zbus_channel *chan, void *msg, k_timeout_t timeout)
 Read a channel.
 
int zbus_chan_claim (const struct zbus_channel *chan, k_timeout_t timeout)
 Claim a channel.
 
int zbus_chan_finish (const struct zbus_channel *chan)
 Finish a channel claim.
 
int zbus_chan_notify (const struct zbus_channel *chan, k_timeout_t timeout)
 Force a channel notification.
 
static const char * zbus_chan_name (const struct zbus_channel *chan)
 Get the channel's name.
 
static void * zbus_chan_msg (const struct zbus_channel *chan)
 Get the reference for a channel message directly.
 
static const void * zbus_chan_const_msg (const struct zbus_channel *chan)
 Get a constant reference for a channel message directly.
 
static uint16_t zbus_chan_msg_size (const struct zbus_channel *chan)
 Get the channel's message size.
 
static void * zbus_chan_user_data (const struct zbus_channel *chan)
 Get the channel's user data.
 
int zbus_chan_add_obs (const struct zbus_channel *chan, const struct zbus_observer *obs, k_timeout_t timeout)
 Add an observer to a channel.
 
int zbus_chan_rm_obs (const struct zbus_channel *chan, const struct zbus_observer *obs, k_timeout_t timeout)
 Remove an observer from a channel.
 
int zbus_obs_set_enable (struct zbus_observer *obs, bool enabled)
 Change the observer state.
 
static int zbus_obs_is_enabled (struct zbus_observer *obs, bool *enable)
 Get the observer state.
 
int zbus_obs_set_chan_notification_mask (const struct zbus_observer *obs, const struct zbus_channel *chan, bool masked)
 Mask notifications from a channel to an observer.
 
int zbus_obs_is_chan_notification_masked (const struct zbus_observer *obs, const struct zbus_channel *chan, bool *masked)
 Get the notifications masking state from a channel to an observer.
 
static const char * zbus_obs_name (const struct zbus_observer *obs)
 Get the observer's name.
 
int zbus_obs_attach_to_thread (const struct zbus_observer *obs)
 Set the observer thread priority by attaching it to a thread.
 
int zbus_obs_detach_from_thread (const struct zbus_observer *obs)
 Clear the observer thread priority by detaching it from a thread.
 
int zbus_sub_wait (const struct zbus_observer *sub, const struct zbus_channel **chan, k_timeout_t timeout)
 Wait for a channel notification.
 
int zbus_sub_wait_msg (const struct zbus_observer *sub, const struct zbus_channel **chan, void *msg, k_timeout_t timeout)
 Wait for a channel message.
 
bool zbus_iterate_over_channels (bool(*iterator_func)(const struct zbus_channel *chan))
 Iterate over channels.
 
bool zbus_iterate_over_channels_with_user_data (bool(*iterator_func)(const struct zbus_channel *chan, void *user_data), void *user_data)
 Iterate over channels with user data.
 
bool zbus_iterate_over_observers (bool(*iterator_func)(const struct zbus_observer *obs))
 Iterate over observers.
 
bool zbus_iterate_over_observers_with_user_data (bool(*iterator_func)(const struct zbus_observer *obs, void *user_data), void *user_data)
 Iterate over observers with user data.