Hello Nordic Team,
I am currently developing applications for a custom board based on the nRF52840 microcontroller using the nRF Connect SDK (NCS) v2.5.0 and Zephyr RTOS. As part of the project, I am interfacing the LIS2DUX12 sensor. However, I have encountered some challenges due to the absence of LIS2DUX12 sensor driver configurations in NCS v2.5.0, which are available in NCS v2.7.0.
To work around this, I manually integrated the `lis2dux12_reg.c` and `lis2dux12_reg.h` files into my project to enable basic communication with the sensor. However, I am facing an issue during initialization:
When I power on the device, the sensor fails to wake up from deep power-down mode, and I see the following logs:
[00:00:00.336,273] <inf> SI7210: Found Si7210-B-03 S/N 000a2598, at I2C address 0x32 *** Booting nRF Connect SDK v2.5.0 *** [00:00:00.405,273] <err> i2c_nrfx_twi: Error 0x0BAE0001 occurred for message 0 [00:00:00.405,303] <inf> lis_sensor: Error: Failed to wakeup sensor from deep power down mode.
However, when I reset the device after this error occurs, the sensor initializes successfully, and I see the following logs:
[00:00:00.286,132] <inf> SI7210: Found Si7210-B-03 S/N 000a2598, at I2C address 0x32 *** Booting nRF Connect SDK v2.5.0 *** [00:00:00.382,751] <inf> lis_sensor: LIS2DUX12 detected (WHO_AM_I = 0x47) [00:00:00.386,657] <inf> lis_sensor: LIS2DUX12 initialized successfully
Below is the initialization function I am using for the LIS2DUX12 sensor:
void lis2dux12_init(void) { uint8_t who_am_i; int ret; lis_ctx.write_reg = lis2dux12_i2c_write; lis_ctx.read_reg = lis2dux12_i2c_read; lis_ctx.handle = NULL; k_msleep(50); // Stabilize the sensor /* Perform the I²C-specific power-up sequence */ ret = lis2dux12_exit_deep_power_down(&lis_ctx); if (ret != 0) { LOG_INF("Error: Failed to wakeup sensor from deep power down mode.\n"); return; } k_busy_wait(25000); /* Read WHO_AM_I Register */ ret = lis2dux12_device_id_get(&lis_ctx, &who_am_i); if (ret < 0) { LOG_ERR("Not able to read who_am_i id"); return ret; } if (ret != 0 || who_am_i != LIS2DUX12_ID) { LOG_ERR("Failed to detect LIS2DUX12 (WHO_AM_I = 0x%02X)", who_am_i); return; } /* Reset device */ ret = lis2dux12_init_set(&lis_ctx, LIS2DUX12_RESET); if (ret < 0) { return ret; } k_busy_wait(100); LOG_INF("LIS2DUX12 detected (WHO_AM_I = 0x%02X)", who_am_i); /* Configure Sensor */ ret = lis2dux12_init_set(&lis_ctx, LIS2DUX12_SENSOR_ONLY_ON); if (ret != 0) { LOG_ERR("Failed to configure LIS2DUX12"); return; } lis2dux12_md_t mode = { .odr = LIS2DUX12_1Hz6_ULP, .fs = LIS2DUX12_4g, .bw = LIS2DUX12_ODR_div_4, }; ret = lis2dux12_mode_set(&lis_ctx, &mode); if (ret != 0) { LOG_INF("Error: Failed to configure LIS2DUX12 mode.\n"); return; } LOG_INF("LIS2DUX12 initialized successfully\n"); }
Note: '[00:00:00.286,132] <inf> SI7210: Found Si7210-B-03 S/N 000a2598, at I2C address 0x32'
This line is due to Hall Effect I2C Sensor. This is also one of the sensor in custom board
I would like to know if there are any recommendations or best practices for ensuring compatibility of the LIS2DUX12 sensor in NCS v2.5.0, especially regarding its initialization sequence.
Additionally, if the LIS2DUX12 sensor driver configurations from NCS v2.7.0 can be backported to NCS v2.5.0, I would appreciate any guidance or steps for doing so.
Thank you for your assistance!
Best regards,
Anmol