I'm currently working on a project that uses the MLX90640 IR sensor. By default, this device has an I2C address of 0x33, but it can be set up with one of 127 different I2C addresses.
This is how I have the device tree set up:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
&i2c0 {
compatible = "nordic,nrf-twim";
status = "okay";
pinctrl-0 = <&i2c0_default>;
pinctrl-1 = <&i2c0_sleep>;
pinctrl-names = "default", "sleep";
clock-frequency = <I2C_BITRATE_STANDARD>;
mlx90640: mlx90640@33 {
compatible = "mlx90640";
reg = <0x33>;
label = "MLX90640";
};
What I'm trying to understand is, if I go in and change the I2C address of the device, what happens to the device pointer I have that is linked to the device tree entry?
Fullscreen
1
2
#define I2C0_NODE DT_NODELABEL(mlx90640)
static const struct i2c_dt_spec mlx90640_i2c = I2C_DT_SPEC_GET(I2C0_NODE);
All of the Zephyr I2C API's require referencing the device pointer, but if I change the I2C address, I'm guessing this will no longer be valid. So I'm not sure how I reference the device once I've changed the I2C address.
Anyone done this before and can help me work out how to get it functioning?
Regards,
Mike