Re: device_get_binding() returns NULL on all but one vl53l0x
toggle quoted messageShow quoted text
Indeed this dynamic behavior is not implemented.
As you can see in vl53lx driver, vl53l0x_init make use of DT_INST_FOO(0, bar) macros.
Which means only the information from instance 0 are used.
This being said, enabling dynamic support should not be that complicated.
A lot of zephyr drivers support instantiation and could be used as example.
Here are the steps:
- Add a config struct to the driver init to store all the instance init data from device tree
- rework the vl53l0x_init function to be instance agnostic by using this config struct
- Instantiate the driver DEVICE_AND_API_INIT thanks to DT_INST_FOREACH_STATUS_OKAY(FOO) macro
DT_INST_FOREACH_STATUS_OKAY(FOO) will loop through all dt enabled instances of your sensor
and call FOO(i) for each instance.
You'll find doc and examples of use of this macro throughout the tree.
On Wed, 2 Dec 2020 at 14:56, Matthias Wenzel <mw@...> wrote: