Re: Problem running samples/sensor/sht3xd #sensor #driver


Bolivar, Marti
 

Hi again Ilkka,

"ilkka.virtanen via lists.zephyrproject.org"
<ilkka.virtanen=sensoan.com@lists.zephyrproject.org> writes:

Thank you Marti for the reply.

The problem was indeed in the connection between the nRF52840DK and the external sensor. I watched your video, it was very good and informative.
I'm glad; thanks!

As I learned that the device will be initialized before execution is in application code, I realize we will have a problem with the driver in our own product. Our own board will have a sht31 sensor but it is behind a TCA9548A I2C switch, which means a device tree configuration like this:
&i2c0 {
tca9548a@71 ( TCA9548A@71 ) {
sht3xd@44 {
};
};
};

Can I stack the drivers like this?
Yes, you can, you just need to make sure the initialization priorities
are managed correctly so the init functions run in the following order:

i2c0 -> tca9548a -> sht3xd

You can control the initialization priorities with Kconfig options, but
the defaults should be OK for your use case.

See CONFIG_I2C_INIT_PRIORITY and CONFIG_SENSOR_INIT_PRIORITY
respectively for i2c0 and sht3xd.

If yes, to be able to use the available device drivers for the sensors
that are behind the I2C switch, I will need to implement the tca9548a
functionality to a device driver to make this work. Do you know are
there any example to use as a starting point?
I recently reviewed a TCA9546A driver, which seems similar to your
TCA9548A.

https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/i2c/i2c_tca9546a.c

https://docs.zephyrproject.org/latest/reference/devicetree/bindings/i2c/ti%2Ctca9546a.html#dtbinding-ti-tca9546a

If the differences are superficial you may be able to extend the driver
to support "TCA954xA", i.e. both devices.

You may wish to contact the driver author if you want to collaborate.


Thanks again,
Ilkka
HTH,
Marti

Join users@lists.zephyrproject.org to automatically receive all group messages.