I can't read register WhoAmI from LIS2DW12 with I2C
Hi,
I've bought a ST MKI179V1 board to interface via I2C with a Nucelo-L433RC . Furthermore, I'm using ST oficial drivers to MEMS sensors. The problem is when I try to read the register it always return 0. I've already made a lot of tests and I can't discover the problem. For me it looks to be so simple but I'm not makinng this work.
I let you my schematic:

And my simplified code:
- Field definitions;
static uint8_t whoamI;
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len);- Read Function:
static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len) {
HAL_I2C_Mem_Read(handle, LIS2DW12_I2C_ADD_L, reg, I2C_MEMADD_SIZE_16BIT,
bufp, len, 1000);
return 0;
}- Main Function;
int main(void){
stmdev_ctx_t dev_ctx;
dev_ctx.write_reg = platform_write;
dev_ctx.read_reg = platform_read;
dev_ctx.handle = &hi2c1;
MX_I2C1_Init();
...
lis2dw12_device_id_get(&dev_ctx, &whoamI);
if (whoamI != LIS2DW12_ID){
// Device not found
}
...
}Furthermore when I use HAL_I2C_IsDeviceReady it seems to identify the device.
if(HAL_I2C_IsDeviceReady(&hi2c1, LIS2DW12_I2C_ADD_L,1,1000) == HAL_OK){
// It enters here correctly
debugPrintln(&huart2, "Device Is Ready");
}It proves that the device is correctly connected.
I would appreciate any help.
Best Regards
