12#ifndef ZEPHYR_INCLUDE_DRIVERS_MBOX_H_
13#define ZEPHYR_INCLUDE_DRIVERS_MBOX_H_
128#define MBOX_DT_SPEC_GET(node_id, name) \
130 .dev = DEVICE_DT_GET(DT_MBOX_CTLR_BY_NAME(node_id, name)), \
131 .channel_id = DT_MBOX_CHANNEL_BY_NAME(node_id, name), \
142#define MBOX_DT_SPEC_INST_GET(inst, name) \
143 MBOX_DT_SPEC_GET(DT_DRV_INST(inst), name)
284static inline int z_impl_mbox_send(
const struct device *dev,
290 if (api->
send == NULL) {
294 return api->
send(dev, channel_id, msg);
381static inline int z_impl_mbox_mtu_get(
const struct device *dev)
433static inline int z_impl_mbox_set_enabled(
const struct device *dev,
473static inline uint32_t z_impl_mbox_max_channels_get(
const struct device *dev)
502#include <zephyr/syscalls/mbox.h>
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1425
bool device_is_ready(const struct device *dev)
Verify that a device is ready for use.
int(* mbox_send_t)(const struct device *dev, mbox_channel_id_t channel_id, const struct mbox_msg *msg)
Callback API to send MBOX messages.
Definition mbox.h:179
int(* mbox_set_enabled_t)(const struct device *dev, mbox_channel_id_t channel_id, bool enabled)
Callback API upon enablement of interrupts.
Definition mbox.h:219
uint32_t(* mbox_max_channels_get_t)(const struct device *dev)
Callback API to get maximum number of channels.
Definition mbox.h:230
int(* mbox_register_callback_t)(const struct device *dev, mbox_channel_id_t channel_id, mbox_callback_t cb, void *user_data)
Callback API upon registration.
Definition mbox.h:205
void(* mbox_callback_t)(const struct device *dev, mbox_channel_id_t channel_id, void *user_data, struct mbox_msg *data)
Callback API for incoming MBOX messages.
Definition mbox.h:165
int(* mbox_mtu_get_t)(const struct device *dev)
Callback API to get maximum data size.
Definition mbox.h:191
static int mbox_set_enabled_dt(const struct mbox_dt_spec *spec, bool enabled)
Enable (disable) interrupts and callbacks for inbound channels from a struct mbox_dt_spec.
Definition mbox.h:455
int mbox_mtu_get(const struct device *dev)
Return the maximum number of bytes possible in an outbound message.
static int mbox_send_dt(const struct mbox_dt_spec *spec, const struct mbox_msg *msg)
Try to send a message over the MBOX device from a struct mbox_dt_spec.
Definition mbox.h:305
static int mbox_mtu_get_dt(const struct mbox_dt_spec *spec)
Return the maximum number of bytes possible in an outbound message from struct mbox_dt_spec.
Definition mbox.h:400
static int mbox_register_callback_dt(const struct mbox_dt_spec *spec, mbox_callback_t cb, void *user_data)
Register a callback function on a channel for incoming messages from a struct mbox_dt_spec.
Definition mbox.h:352
int mbox_set_enabled(const struct device *dev, mbox_channel_id_t channel_id, bool enabled)
Enable (disable) interrupts and callbacks for inbound channels.
static bool mbox_is_ready_dt(const struct mbox_dt_spec *spec)
Validate if MBOX device instance from a struct mbox_dt_spec is ready.
Definition mbox.h:257
static int mbox_register_callback(const struct device *dev, mbox_channel_id_t channel_id, mbox_callback_t cb, void *user_data)
Register a callback function on a channel for incoming messages.
Definition mbox.h:327
static int mbox_max_channels_get_dt(const struct mbox_dt_spec *spec)
Return the maximum number of channels from a struct mbox_dt_spec.
Definition mbox.h:491
uint32_t mbox_channel_id_t
Type for MBOX channel identifiers.
Definition mbox.h:82
uint32_t mbox_max_channels_get(const struct device *dev)
Return the maximum number of channels.
int mbox_send(const struct device *dev, mbox_channel_id_t channel_id, const struct mbox_msg *msg)
Try to send a message over the MBOX device.
#define ENOSYS
Function not implemented.
Definition errno.h:82
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
<span class="mlabel">Driver Operations</span> MBOX driver operations
Definition mbox.h:235
mbox_send_t send
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition mbox.h:237
mbox_mtu_get_t mtu_get
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition mbox.h:241
mbox_max_channels_get_t max_channels_get
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition mbox.h:243
mbox_register_callback_t register_callback
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition mbox.h:239
mbox_set_enabled_t set_enabled
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition mbox.h:245
MBOX specification from DT.
Definition mbox.h:93
const struct device * dev
MBOX device pointer.
Definition mbox.h:95
mbox_channel_id_t channel_id
Channel ID.
Definition mbox.h:97
Message struct (to hold data and its size).
Definition mbox.h:85
size_t size
Size of the data.
Definition mbox.h:89
const void * data
Pointer to the data sent in the message.
Definition mbox.h:87