Hello CircuitDojo Community,
I am struggling with a Zephyr 2.6.0 device tree macro, DEVICE_DT_GET() as I work to port firmware running on a Sparkfun_Thing_Plus_nrf9160 dev’ board to a custom board. I’ve spent several hours today reviewing Zephyr Project documentation on Zephyr’s device driver API and macros. My particular situation is that I have two like sensors on the i2c2 bus peripheral of the 9160’s ARM M33. Here is a snippet from a dts .overlay file that shows the sensors in question:
36 stmicro_sensor: iis2dh@19 {
37 compatible = "st,iis2dh";
38 reg = <0x19>;
39 label = "IIS2DH";
40 };
41 stmicro_sensor_addr_18: iis2dh@18 {
42 compatible = "st,iis2dh";
43 reg = <0x18>;
44 label = "IIS2DH";
45 };
Zephyr macro DEVICE_DT_GET_ANY(st_iis2dh) returns me the first of these sensors, but Zephyr docs say that there’s no guarantee which of a like sensor the “get any” device macro will return. In my present dev tasks I could really benefit from a working macro which returns a device object pointer to the dts node of my choosing.
Is there anyone familiar with these macros, enough so to share a working syntax? I recognize that Zephyr apps often nest two or three such macros to achieve the desired end. I’ve tried a couple of those combos which documentation and sample apps from Nordic nrf sdk seemed to indicate would work. No luck so far. Spinning my wheels with build errors in the intermediate artifacts generated by west build . . .
.
Thanks ahead of time for any insights into this yet cryptic realm of Zephyr and DTS.
- Ted