'__device_dts_ord___BUS_ORD' undeclared here (not in a function); did you mean '__device_dts_ord_94'? #46523
Unanswered
vinay34892
asked this question in
Q&A
Replies: 1 comment
-
Please see https://docs.zephyrproject.org/latest/kernel/drivers/index.html#c.DEVICE_DT_GET |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When I try to debug the my project this error occurs. Please let me know what kind of errors are these.
/*
*/
#ifndef ZEPHYR_INCLUDE_DEVICE_H_
#define ZEPHYR_INCLUDE_DEVICE_H_
/**
/
/*
/
/*
*/
#include <init.h>
#include <linker/sections.h>
#include <sys/device_mmio.h>
#include <sys/util.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
*/
typedef int16_t device_handle_t;
/** @brief Flag value used in lists of device handles to separate
*/
#define DEVICE_HANDLE_SEP INT16_MIN
/** @brief Flag value used in lists of device handles to indicate the
*/
#define DEVICE_HANDLE_ENDS INT16_MAX
/** @brief Flag value used to identify an unknown device. */
#define DEVICE_HANDLE_NULL 0
#define Z_DEVICE_MAX_NAME_LEN 48
/**
*/
#define DEVICE_NAME_GET(name) _CONCAT(_device, name)
/**
*/
#define SYS_DEVICE_DEFINE(drv_name, init_fn, level, prio)
__DEPRECATED_MACRO SYS_INIT(init_fn, level, prio)
/* Node paths can exceed the maximum size supported by device_get_binding() in user mode,
*/
#define Z_DEVICE_DT_DEV_NAME(node_id) CONCAT(dts_ord, DT_DEP_ORD(node_id))
/* Synthesize a unique name for the device state associated with
*/
#define Z_DEVICE_STATE_NAME(dev_name) _CONCAT(_devstate, dev_name)
/**
*/
#define Z_DEVICE_STATE_DEFINE(node_id, dev_name)
static struct device_state Z_DEVICE_STATE_NAME(dev_name)
attribute((section(".z_devstate")));
/**
*/
#define DEVICE_DEFINE(dev_name, drv_name, init_fn, pm_device,
data_ptr, cfg_ptr, level, prio, api_ptr)
Z_DEVICE_STATE_DEFINE(DT_INVALID_NODE, dev_name)
Z_DEVICE_DEFINE(DT_INVALID_NODE, dev_name, drv_name, init_fn,
pm_device,
data_ptr, cfg_ptr, level, prio, api_ptr,
&Z_DEVICE_STATE_NAME(dev_name))
/**
*/
#define DEVICE_DT_NAME(node_id)
DT_PROP_OR(node_id, label, DT_NODE_FULL_NAME(node_id))
/**
*/
#define DEVICE_DT_DEFINE(node_id, init_fn, pm_device,
data_ptr, cfg_ptr, level, prio,
api_ptr, ...)
Z_DEVICE_STATE_DEFINE(node_id, Z_DEVICE_DT_DEV_NAME(node_id))
Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_NAME(node_id),
DEVICE_DT_NAME(node_id), init_fn,
pm_device,
data_ptr, cfg_ptr, level, prio,
api_ptr,
&Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_NAME(node_id)),
VA_ARGS)
/**
*/
#define DEVICE_DT_INST_DEFINE(inst, ...)
DEVICE_DT_DEFINE(DT_DRV_INST(inst), VA_ARGS)
/**
*/
#define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_NAME(node_id))
/**
*/
#define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
/** @def DEVICE_DT_INST_GET
*
*/
#define DEVICE_DT_INST_GET(inst) DEVICE_DT_GET(DT_DRV_INST(inst))
/**
*/
#define DEVICE_DT_GET_ANY(compat)
COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(compat),
(DEVICE_DT_GET(DT_COMPAT_GET_ANY_STATUS_OKAY(compat))),
(NULL))
/**
*/
#define DEVICE_DT_GET_ONE(compat)
COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(compat),
(DEVICE_DT_GET(DT_COMPAT_GET_ANY_STATUS_OKAY(compat))),
(ZERO_OR_COMPILE_ERROR(0)))
/**
*/
#define DEVICE_DT_GET_OR_NULL(node_id)
COND_CODE_1(DT_NODE_HAS_STATUS(node_id, okay),
(DEVICE_DT_GET(node_id)), (NULL))
/**
*/
#define DEVICE_GET(name) (&DEVICE_NAME_GET(name))
/** @def DEVICE_DECLARE
*
*/
#define DEVICE_DECLARE(name) static const struct device DEVICE_NAME_GET(name)
/**
@brief Runtime device dynamic structure (in RAM) per driver instance
Fields in this are expected to be default-initialized to zero. The
kernel driver infrastructure and driver access functions are
responsible for ensuring that any non-zero initialization is done
before they are accessed.
/
struct device_state {
/* Non-negative result of initializing the device.
*
UINT8_MAX
if the value exceeds*/
unsigned int init_res : 8;
/** Indicates the device initialization function has been
*/
bool initialized : 1;
};
struct pm_device;
/**
/
struct device {
/* Name of the device instance /
const char name;
/ Address of device instance config information /
const void config;
/ Address of the API structure exposed by the device instance /
const void api;
/ Address of the common device state /
struct device_state * const state;
/* Address of the device instance private data /
void * const data;
/* optional pointer to handles associated with the device.
*
/
const device_handle_t const handles;
#ifdef CONFIG_PM_DEVICE
/ Reference to the device PM resources. */
struct pm_device * const pm;
#endif
};
/**
@brief Get the handle for a given device
@param dev the device for which a handle is desired.
@return the handle for the device, or DEVICE_HANDLE_NULL if the
device does not have an associated handle.
*/
static inline device_handle_t
device_handle_get(const struct device *dev)
{
device_handle_t ret = DEVICE_HANDLE_NULL;
extern const struct device __device_start[];
/* TODO: If/when devices can be constructed that are not part of the
*/
if (dev != NULL) {
ret = 1 + (device_handle_t)(dev - __device_start);
}
return ret;
}
/**
@brief Get the device corresponding to a handle.
@param dev_handle the device handle
@return the device that has that handle, or a null pointer if @p
dev_handle does not identify a device.
*/
static inline const struct device *
device_from_handle(device_handle_t dev_handle)
{
extern const struct device __device_start[];
extern const struct device __device_end[];
const struct device *dev = NULL;
size_t numdev = __device_end - __device_start;
if ((dev_handle > 0) && ((size_t)dev_handle <= numdev)) {
dev = &__device_start[dev_handle - 1];
}
return dev;
}
/**
*/
typedef int (*device_visitor_callback_t)(const struct device *dev, void *context);
/**
@brief Get the device handles for devicetree dependencies of this device.
This function returns a pointer to an array of device handles. The
length of the array is stored in the @p count parameter.
The array contains a handle for each device that @p dev requires
directly, as determined from the devicetree. This does not include
transitive dependencies; you must recursively determine those.
@param dev the device for which dependencies are desired.
@param count pointer to where this function should store the length
of the returned array. No value is stored if the call returns a
null pointer. The value may be set to zero if the device has no
devicetree dependencies.
@return a pointer to a sequence of @p *count device handles, or a null
pointer if @p dev does not have any dependency data.
*/
static inline const device_handle_t *
device_required_handles_get(const struct device *dev,
size_t *count)
{
const device_handle_t *rv = dev->handles;
if (rv != NULL) {
size_t i = 0;
}
return rv;
}
/**
@brief Get the set of handles that this device supports.
This function returns a pointer to an array of device handles. The
length of the array is stored in the @p count parameter.
The array contains a handle for each device that @p dev "supports"
-- that is, devices that require @p dev directly -- as determined
from the devicetree. This does not include transitive dependencies;
you must recursively determine those.
@param dev the device for which supports are desired.
@param count pointer to where this function should store the length
of the returned array. No value is stored if the call returns a
null pointer. The value may be set to zero if nothing in the
devicetree depends on @p dev.
@return a pointer to a sequence of @p *count device handles, or a null
pointer if @p dev does not have any dependency data.
*/
static inline const device_handle_t *
device_supported_handles_get(const struct device *dev,
size_t *count)
{
const device_handle_t *rv = dev->handles;
size_t region = 0;
size_t i = 0;
if (rv != NULL) {
/* Fast forward to supporting devices */
while (region != 2) {
if (rv == DEVICE_HANDLE_SEP) {
region++;
}
rv++;
}
/ Count supporting devices */
while (rv[i] != DEVICE_HANDLE_ENDS) {
++i;
}
*count = i;
}
return rv;
}
/**
*/
int device_required_foreach(const struct device *dev,
device_visitor_callback_t visitor_cb,
void *context);
/**
*/
int device_supported_foreach(const struct device *dev,
device_visitor_callback_t visitor_cb,
void *context);
/**
*/
__syscall const struct device *device_get_binding(const char *name);
/** @brief Get access to the static array of static devices.
*
*/
size_t z_device_get_all_static(const struct device * *devices);
/** @brief Determine whether a device has been successfully initialized.
*
*/
bool z_device_ready(const struct device *dev);
/** @brief Determine whether a device is ready for use
*
device_usable_check()
, without the*/
static inline int z_device_usable_check(const struct device *dev)
{
return z_device_ready(dev) ? 0 : -ENODEV;
}
/** @brief Determine whether a device is ready for use.
*
*/
__syscall int device_usable_check(const struct device *dev);
static inline int z_impl_device_usable_check(const struct device *dev)
{
return z_device_usable_check(dev);
}
/** @brief Verify that a device is ready for use.
*
*/
static inline bool device_is_ready(const struct device *dev)
{
return device_usable_check(dev) == 0;
}
/**
*/
/* Synthesize the name of the object that holds device ordinal and
*/
#define Z_DEVICE_HANDLE_NAME(node_id, dev_name)
_CONCAT(_devicehdl,
COND_CODE_1(DT_NODE_EXISTS(node_id),
(node_id),
(dev_name)))
#define Z_DEVICE_EXTRA_HANDLES(...)
FOR_EACH_NONEMPTY_TERM(IDENTITY, (,), VA_ARGS)
/*
*/
#define Z_DEVICE_STATE_DEFINE(node_id, dev_name)
static struct device_state Z_DEVICE_STATE_NAME(dev_name)
attribute((section(".z_devstate")));
/* Construct objects that are referenced from struct device. These
*/
#define Z_DEVICE_DEFINE_PRE(node_id, dev_name, ...)
Z_DEVICE_DEFINE_HANDLES(node_id, dev_name, VA_ARGS)
/* Initial build provides a record that associates the device object
gen_handles.py
must be updated.*/
BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts");
#define Z_DEVICE_DEFINE_HANDLES(node_id, dev_name, ...)
extern const device_handle_t
Z_DEVICE_HANDLE_NAME(node_id, dev_name)[];
const device_handle_t
__aligned(sizeof(device_handle_t))
attribute((weak,
section(".__device_handles_pass1")))
Z_DEVICE_HANDLE_NAME(node_id, dev_name)[] = {
COND_CODE_1(DT_NODE_EXISTS(node_id), (
DT_DEP_ORD(node_id),
DT_REQUIRES_DEP_ORDS(node_id)
), (
DEVICE_HANDLE_NULL,
))
DEVICE_HANDLE_SEP,
Z_DEVICE_EXTRA_HANDLES(VA_ARGS)
DEVICE_HANDLE_SEP,
COND_CODE_1(DT_NODE_EXISTS(node_id),
(DT_SUPPORTS_DEP_ORDS(node_id)), ())
};
#define Z_DEVICE_DEFINE_INIT(node_id, dev_name)
.handles = Z_DEVICE_HANDLE_NAME(node_id, dev_name),
/* Like DEVICE_DEFINE but takes a node_id AND a dev_name, and trailing
*/
#define Z_DEVICE_DEFINE(node_id, dev_name, drv_name, init_fn, pm_device,
data_ptr, cfg_ptr, level, prio, api_ptr, state_ptr, ...)
Z_DEVICE_DEFINE_PRE(node_id, dev_name, VA_ARGS)
COND_CODE_1(DT_NODE_EXISTS(node_id), (), (static))
const Z_DECL_ALIGN(struct device)
DEVICE_NAME_GET(dev_name) _used
attribute((section(".z_device" #level STRINGIFY(prio)"_"))) = {
.name = drv_name,
.config = (cfg_ptr),
.api = (api_ptr),
.state = (state_ptr),
.data = (data_ptr),
COND_CODE_1(CONFIG_PM_DEVICE, (.pm = pm_device,), ())
Z_DEVICE_DEFINE_INIT(node_id, dev_name)
};
BUILD_ASSERT(sizeof(Z_STRINGIFY(drv_name)) <= Z_DEVICE_MAX_NAME_LEN,
Z_STRINGIFY(DEVICE_NAME_GET(drv_name)) " too long");
Z_INIT_ENTRY_DEFINE(DEVICE_NAME_GET(dev_name), init_fn,
(&DEVICE_NAME_GET(dev_name)), level, prio)
#ifdef __cplusplus
}
#endif
/* device_extern is generated based on devicetree nodes */
#include <device_extern.h>
#include <syscalls/device.h>
#endif /* ZEPHYR_INCLUDE_DEVICE_H_ */
Beta Was this translation helpful? Give feedback.
All reactions