I have a custom board with an I2C connected sensor ADXL345. I have to do GPI/O initialization to select the I2C. This works because I can read the ADXL with custom I2C commands. But the sensor driver doesn't work. Here is what I get on the console (very first message before the kernel boots):
[00:00:00.875,915] <err> ADXL345: Read PART ID failed: 0xfffffffb (0)
I know that it is a software error because I get the following messages from a direct I2C read:
[00:00:00.876,708] <inf> adxl344: Call to 'i2c_reg_read_byte_dt': address = 0x00, chip_id = 0xE6
which is the correct I2C.
Here is my board definition file:
&i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
pinctrl-0 = <&i2c0_default>;
pinctrl-1 = <&i2c0_sleep>;
pinctrl-names = "default", "sleep";
adxl344: adxl344@53 {
compatible = "adi,adxl345";
status = "okay";
reg = < 0x53 >;
};
};
This is my board pre-initialization:
static int board_nrf52840dongle_nrf52840_init(void)
{
nrf_gpio_cfg_output(NRF_GPIO_PIN_MAP(0, 5));
nrf_gpio_cfg_output(NRF_GPIO_PIN_MAP(0, 27));
nrf_gpio_pin_set(NRF_GPIO_PIN_MAP(0, 5));
nrf_gpio_pin_clear(NRF_GPIO_PIN_MAP(0, 27));
return 0;
}
SYS_INIT(board_nrf52840dongle_nrf52840_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
What am I doing wrong?