Re: cannot find "__device_[device name]" #api
"Justin Huang via Lists.Zephyrproject.Org"
Hi,DEVICE_GET() might not be the right thing here. Are you trying to get a
pointer to your device from the device driver C file itself, or from
some other file?
If you're trying to get a pointer to your device from some application
source code, you should probably be using device_get_binding() instead of
If (and only if) the DEVICE_GET() line is in the same file as the above
DEVICE_INIT(), then it should work properly when paired with
DEVICE_DECLARE(), as shown with example code in this documentation page:
However, note that DEVICE_INIT allocates a static struct device, so you
can't use DEVICE_GET() to access that device from another file.
If you're trying to get a pointer to your struct device from another
C file, you need to use something like this instead:
struct device *mydev = device_get_binding(CONFIG_MYDEV_NAME);