9#ifndef INFUSE_SDK_INCLUDE_INFUSE_SHARED_DEVICE_H_
10#define INFUSE_SDK_INCLUDE_INFUSE_SHARED_DEVICE_H_
15#include <zephyr/device.h>
78#define SHARED_DEVICE_DT_SPEC_GET_BY_IDX(node_id, prop, idx) \
80 .shared = DEVICE_DT_GET(DT_PHANDLE_BY_IDX(node_id, prop, idx)), \
81 .state = DT_PHA_BY_IDX(node_id, prop, idx, state), \
82 .priority = DT_PHA_BY_IDX(node_id, prop, idx, priority), \
102#define SHARED_DEVICE_DT_SPEC_GET_BY_IDX_OR(node_id, prop, idx, default_value) \
103 COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \
104 (SHARED_DEVICE_DT_SPEC_GET_BY_IDX(node_id, prop, idx)), (default_value))
114#define SHARED_DEVICE_DT_SPEC_GET(node_id, prop) SHARED_DEVICE_DT_SPEC_GET_BY_IDX(node_id, prop, 0)
126#define SHARED_DEVICE_DT_SPEC_GET_OR(node_id, prop, default_value) \
127 SHARED_DEVICE_DT_SPEC_GET_BY_IDX_OR(node_id, prop, 0, default_value)
139#define SHARED_DEVICE_DT_SPEC_INST_GET_BY_IDX(inst, prop, idx) \
140 SHARED_DEVICE_DT_SPEC_GET_BY_IDX(DT_DRV_INST(inst), prop, idx)
153#define SHARED_DEVICE_DT_SPEC_INST_GET_BY_IDX_OR(inst, prop, idx, default_value) \
154 SHARED_DEVICE_DT_SPEC_GET_BY_IDX_OR(DT_DRV_INST(inst), prop, idx, default_value)
164#define SHARED_DEVICE_DT_SPEC_INST_GET(inst, prop) \
165 SHARED_DEVICE_DT_SPEC_INST_GET_BY_IDX(inst, prop, 0)
177#define SHARED_DEVICE_DT_SPEC_INST_GET_OR(inst, prop, default_value) \
178 SHARED_DEVICE_DT_SPEC_INST_GET_BY_IDX_OR(inst, prop, 0, default_value)
181 int (*
request)(
const struct device *dev, uint8_t state_priority, uint8_t state);
182 int (*
release)(
const struct device *dev, uint8_t state_priority);
195 if (spec->
shared == NULL) {
198 return device_is_ready(spec->
shared);
220 return api->
request(dev, state_priority, state);
236 if (spec->
shared == NULL) {
255 return api->
release(dev, state_priority);
271 if (spec->
shared == NULL) {
static bool shared_device_is_ready_dt(const struct shared_device_dt_spec *spec)
Validate that the shared device is ready.
Definition device.h:193
static int shared_device_release_dt(const struct shared_device_dt_spec *spec)
Release a shared device from a shared_device_dt_spec.
Definition device.h:269
static int shared_device_request(const struct device *dev, uint8_t state_priority, uint8_t state)
Request a device to be in a given state.
Definition device.h:215
static int shared_device_request_dt(const struct shared_device_dt_spec *spec)
Request a shared device from a shared_device_dt_spec.
Definition device.h:234
static int shared_device_release(const struct device *dev, uint8_t state_priority)
Release a previous request for a given state.
Definition device.h:251
int(* release)(const struct device *dev, uint8_t state_priority)
Definition device.h:182
int(* request)(const struct device *dev, uint8_t state_priority, uint8_t state)
Definition device.h:181
Container for shared device information specified in devicetree.
Definition device.h:38
const struct device * shared
Definition device.h:40
uint8_t priority
Definition device.h:44
uint8_t state
Definition device.h:42