2025-05-04 9:41 AM
Hi, I am using STM32CubeMX to configure STM32CubeIDE project. I have Nucleo-U385RG-Q with MEMS X-Nucleo-IKS01A3. I am trying to read pressure sensor LPS22HH. According the X-Nucleo documentation the I2C default addresses for LPS22HH are: BA and B8. But the C code for the sensor defines BA and B8.
Using the STM32CubeIDE project generated by STM32CubeMX I am not able to read sensor ID. The following code gives me an error.
In the code I first define:
stmdev_ctx_t dev_ctx;
dev_ctx.write_reg = platform_write;
dev_ctx.read_reg = platform_read;
dev_ctx.mdelay = platform_delay;
dev_ctx.handle = &SENSOR_BUS;
Then use it:
whoamI = 0;
lps22hh_device_id_get(&dev_ctx, &whoamI);
In STM32CubeMX i configured PINs PB6 and PB7 for I2C1. The sensor files "lps22hh_reg.*" I got from GitHub.
Can someone please point me to the right direction. Thank you in advance.