Re: cannot find "__device_[device name]" #api
Bolivar, Marti
Hi Justin,
"Justin Huang via Lists.Zephyrproject.Org" <justin.y.huang=live.com@...> writes: 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 DEVICE_GET(). 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: https://docs.zephyrproject.org/latest/reference/drivers/index.html#single-driver-multiple-instances 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); BR, MartÃ
|
|