Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
device.h File Reference
#include <init.h>
#include <linker/sections.h>
#include <pm/device.h>
#include <sys/device_mmio.h>
#include <sys/util.h>
#include <device_extern.h>
#include <syscalls/device.h>

Go to the source code of this file.

Data Structures

struct  device_state
 Runtime device dynamic structure (in RAM) per driver instance. More...
 
struct  device
 Runtime device structure (in ROM) per driver instance. More...
 

Macros

#define DEVICE_HANDLE_SEP   INT16_MIN
 Flag value used in lists of device handles to separate distinct groups. More...
 
#define DEVICE_HANDLE_ENDS   INT16_MAX
 Flag value used in lists of device handles to indicate the end of the list. More...
 
#define DEVICE_HANDLE_NULL   0
 Flag value used to identify an unknown device. More...
 
#define DEVICE_NAME_GET(name)   _CONCAT(__device_, name)
 Expands to the full name of a global device object. More...
 
#define SYS_DEVICE_DEFINE(drv_name, init_fn, pm_control_fn, level, prio)
 Run an initialization function at boot at specified priority, and define device PM control function. More...
 
#define DEVICE_DEFINE(dev_name, drv_name, init_fn, pm_control_fn, data_ptr, cfg_ptr, level, prio, api_ptr)
 Create device object and set it up for boot time initialization, with the option to pm_control. In case of Device Idle Power Management is enabled, make sure the device is in suspended state after initialization. More...
 
#define DEVICE_DT_NAME(node_id)    DT_PROP_OR(node_id, label, DT_NODE_FULL_NAME(node_id))
 Return a string name for a devicetree node. More...
 
#define DEVICE_DT_DEFINE(node_id, init_fn, pm_control_fn, data_ptr, cfg_ptr, level, prio, api_ptr, ...)
 Like DEVICE_DEFINE but taking metadata from a devicetree node. More...
 
#define DEVICE_DT_INST_DEFINE(inst, ...)    DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
 Like DEVICE_DT_DEFINE for an instance of a DT_DRV_COMPAT compatible. More...
 
#define DEVICE_DT_NAME_GET(node_id)   DEVICE_NAME_GET(Z_DEVICE_DT_DEV_NAME(node_id))
 The name of the struct device object for node_id. More...
 
#define DEVICE_DT_GET(node_id)   (&DEVICE_DT_NAME_GET(node_id))
 Obtain a pointer to a device object by node_id. More...
 
#define DEVICE_DT_INST_GET(inst)   DEVICE_DT_GET(DT_DRV_INST(inst))
 Obtain a pointer to a device object for an instance of a DT_DRV_COMPAT compatible. More...
 
#define DEVICE_DT_GET_ANY(compat)
 Obtain a pointer to a device object by devicetree compatible. More...
 
#define DEVICE_DT_GET_ONE(compat)
 Obtain a pointer to a device object by devicetree compatible. More...
 
#define DEVICE_GET(name)   (&DEVICE_NAME_GET(name))
 Obtain a pointer to a device object by name. More...
 
#define DEVICE_DECLARE(name)   static const struct device DEVICE_NAME_GET(name)
 Declare a static device object. More...
 

Typedefs

typedef int16_t device_handle_t
 Type used to represent devices and functions. More...
 
typedef int(* device_visitor_callback_t) (const struct device *dev, void *context)
 Prototype for functions used when iterating over a set of devices. More...
 

Functions

static device_handle_t device_handle_get (const struct device *dev)
 Get the handle for a given device. More...
 
static const struct devicedevice_from_handle (device_handle_t dev_handle)
 Get the device corresponding to a handle. More...
 
static const device_handle_tdevice_required_handles_get (const struct device *dev, size_t *count)
 Get the set of handles for devicetree dependencies of this device. More...
 
static const device_handle_tdevice_supported_handles_get (const struct device *dev, size_t *count)
 Get the set of handles that this device supports. More...
 
int device_required_foreach (const struct device *dev, device_visitor_callback_t visitor_cb, void *context)
 Visit every device that dev directly requires. More...
 
int device_supported_foreach (const struct device *dev, device_visitor_callback_t visitor_cb, void *context)
 Visit every device that dev directly supports. More...
 
const struct devicedevice_get_binding (const char *name)
 Retrieve the device structure for a driver by name. More...
 
int device_usable_check (const struct device *dev)
 Determine whether a device is ready for use. More...
 
static bool device_is_ready (const struct device *dev)
 Verify that a device is ready for use. More...
 

Variables

fix the linker scripts
 

Variable Documentation

◆ scripts

fix the linker scripts