Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
|
Shared device API . More...
Data Structures | |
struct | shared_device_dt_spec |
Container for shared device information specified in devicetree. More... | |
struct | shared_device_api |
Macros | |
#define | SHARED_DEVICE_DT_SPEC_GET_BY_IDX(node_id, prop, idx) |
Static initializer for a shared_device_dt_spec . | |
#define | SHARED_DEVICE_DT_SPEC_GET_BY_IDX_OR(node_id, prop, idx, default_value) |
Like SHARED_DEVICE_DT_SPEC_GET_BY_IDX(), with a fallback to a default value. | |
#define | SHARED_DEVICE_DT_SPEC_GET(node_id, prop) |
Equivalent to SHARED_DEVICE_DT_SPEC_GET_BY_IDX(node_id, prop, 0). | |
#define | SHARED_DEVICE_DT_SPEC_GET_OR(node_id, prop, default_value) |
Equivalent to SHARED_DEVICE_DT_SPEC_GET_BY_IDX_OR(node_id, prop, 0, default_value). | |
#define | SHARED_DEVICE_DT_SPEC_INST_GET_BY_IDX(inst, prop, idx) |
Static initializer for a shared_device_dt_spec from a DT_DRV_COMPAT instance's shared device property at an index. | |
#define | SHARED_DEVICE_DT_SPEC_INST_GET_BY_IDX_OR(inst, prop, idx, default_value) |
Static initializer for a shared_device_dt_spec from a DT_DRV_COMPAT instance's shared device property at an index, with fallback. | |
#define | SHARED_DEVICE_DT_SPEC_INST_GET(inst, prop) |
Equivalent to SHARED_DEVICE_DT_SPEC_INST_GET_BY_IDX(inst, prop, 0). | |
#define | SHARED_DEVICE_DT_SPEC_INST_GET_OR(inst, prop, default_value) |
Equivalent to SHARED_DEVICE_DT_SPEC_INST_GET_BY_IDX_OR(inst, prop, 0, default_value). | |
Functions | |
static bool | shared_device_is_ready_dt (const struct shared_device_dt_spec *spec) |
Validate that the shared device is ready. | |
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. | |
static int | shared_device_request_dt (const struct shared_device_dt_spec *spec) |
Request a shared device from a shared_device_dt_spec . | |
static int | shared_device_release (const struct device *dev, uint8_t state_priority) |
Release a previous request for a given state. | |
static int | shared_device_release_dt (const struct shared_device_dt_spec *spec) |
Release a shared device from a shared_device_dt_spec . | |
Shared device API .
#define SHARED_DEVICE_DT_SPEC_GET | ( | node_id, | |
prop ) |
#include <infuse/shared/device.h>
Equivalent to SHARED_DEVICE_DT_SPEC_GET_BY_IDX(node_id, prop, 0).
node_id | devicetree node identifier |
prop | lowercase-and-underscores property name |
#define SHARED_DEVICE_DT_SPEC_GET_BY_IDX | ( | node_id, | |
prop, | |||
idx ) |
#include <infuse/shared/device.h>
Static initializer for a shared_device_dt_spec
.
Example devicetree fragment:
n: node { rf-switch = <&ant_switch 0 100>, <&ant_switch 1 50>; }
Example usage:
const struct shared_device_dt_spec spec = GPIO_DT_SPEC_GET_BY_IDX(DT_NODELABEL(n), rf-switch, 1); // Initializes 'spec' to: // { // .shared = DEVICE_DT_GET(DT_NODELABEL(ant_switch)), // .state = 1, // .priority = 50 // }
The 'shared' field must still be checked for readiness, e.g. using device_is_ready(). It is an error to use this macro unless the node exists, has the given property, and that property specifies a shared device, requested state, and state priority as shown above.
node_id | devicetree node identifier |
prop | lowercase-and-underscores property name |
idx | logical index into "prop" |
#define SHARED_DEVICE_DT_SPEC_GET_BY_IDX_OR | ( | node_id, | |
prop, | |||
idx, | |||
default_value ) |
#include <infuse/shared/device.h>
Like SHARED_DEVICE_DT_SPEC_GET_BY_IDX(), with a fallback to a default value.
If the devicetree node identifier 'node_id' refers to a node with a property 'prop', this expands to SHARED_DEVICE_DT_SPEC_GET_BY_IDX(node_id, prop, idx)
. The default_value
parameter is not expanded in this case.
Otherwise, this expands to default_value
.
node_id | devicetree node identifier |
prop | lowercase-and-underscores property name |
idx | logical index into "prop" |
default_value | fallback value to expand to |
#define SHARED_DEVICE_DT_SPEC_GET_OR | ( | node_id, | |
prop, | |||
default_value ) |
#include <infuse/shared/device.h>
Equivalent to SHARED_DEVICE_DT_SPEC_GET_BY_IDX_OR(node_id, prop, 0, default_value).
node_id | devicetree node identifier |
prop | lowercase-and-underscores property name |
default_value | fallback value to expand to |
#define SHARED_DEVICE_DT_SPEC_INST_GET | ( | inst, | |
prop ) |
#include <infuse/shared/device.h>
Equivalent to SHARED_DEVICE_DT_SPEC_INST_GET_BY_IDX(inst, prop, 0).
inst | DT_DRV_COMPAT instance number |
prop | lowercase-and-underscores property name |
#define SHARED_DEVICE_DT_SPEC_INST_GET_BY_IDX | ( | inst, | |
prop, | |||
idx ) |
#include <infuse/shared/device.h>
Static initializer for a shared_device_dt_spec
from a DT_DRV_COMPAT instance's shared device property at an index.
inst | DT_DRV_COMPAT instance number |
prop | lowercase-and-underscores property name |
idx | logical index into "prop" |
#define SHARED_DEVICE_DT_SPEC_INST_GET_BY_IDX_OR | ( | inst, | |
prop, | |||
idx, | |||
default_value ) |
#include <infuse/shared/device.h>
Static initializer for a shared_device_dt_spec
from a DT_DRV_COMPAT instance's shared device property at an index, with fallback.
inst | DT_DRV_COMPAT instance number |
prop | lowercase-and-underscores property name |
idx | logical index into "prop" |
default_value | fallback value to expand to |
#define SHARED_DEVICE_DT_SPEC_INST_GET_OR | ( | inst, | |
prop, | |||
default_value ) |
#include <infuse/shared/device.h>
Equivalent to SHARED_DEVICE_DT_SPEC_INST_GET_BY_IDX_OR(inst, prop, 0, default_value).
inst | DT_DRV_COMPAT instance number |
prop | lowercase-and-underscores property name |
default_value | fallback value to expand to |
|
inlinestatic |
#include <infuse/shared/device.h>
Validate that the shared device is ready.
spec | Shared device specification from devicetree |
true | if the shared device is ready for use. |
false | if the shared device is not ready for use. |
|
inlinestatic |
#include <infuse/shared/device.h>
Release a previous request for a given state.
dev | Switch to release |
state_priority | Priority of the request provided to shared_device_request |
0 | request has been released |
-EINVAL | no request was previously received |
|
inlinestatic |
#include <infuse/shared/device.h>
Release a shared device from a shared_device_dt_spec
.
This is equivalent to:
shared_device_release(spec->shared, spec->priority);
spec | Shared device specification from devicetree |
|
inlinestatic |
#include <infuse/shared/device.h>
Request a device to be in a given state.
The state with the highest requested priority is the one active. The behaviour when no state is selected is implementation-defined.
dev | Shared device to request to be in a certain state |
state_priority | Priority of the request, each state must have a single associated priority |
state | State that is being requested for a device |
0 | request has been submitted |
-EALREADY | a request for the given state already exists |
-EINVAL | state is invalid for this device |
|
inlinestatic |
#include <infuse/shared/device.h>
Request a shared device from a shared_device_dt_spec
.
This is equivalent to:
shared_device_request(spec->shared, spec->priority, spec->state);
spec | Shared device specification from devicetree |