esp-idf-lib
esp-idf-lib copied to clipboard
Problem with nested structs in BME680-Driver / I²C-init
The issue
I try to use the BME680-driver on an ESP32C6 with VSC on Linux with newest ESP-IDF (v5.1.2). Unfortunately the controller went in an error by init the sensor. After a debug session I realized, that there is a wrong variable initialization.
the definitions in bme680.h:
/**
* BME680 sensor device data structure type
*/
typedef struct
{
i2c_dev_t i2c_dev; //!< I2C device descriptor
bool meas_started; //!< Indicates whether measurement started
uint8_t meas_status; //!< Last sensor status (for internal use only)
bme680_settings_t settings; //!< Sensor settings
bme680_calib_data_t calib_data; //!< Calibration data of the sensor
} bme680_t;
//Test-Dev without the first struct
typedef struct
{
bool meas_started; //!< Indicates whether measurement started
uint8_t meas_status; //!< Last sensor status (for internal use only)
bme680_settings_t settings; //!< Sensor settings
bme680_calib_data_t calib_data; //!< Calibration data of the sensor
} bme680t1;
typedef struct
{
i2c_dev_t i2c_dev0; //!< I2C device descriptor
} bme680_t_1;
the definitions in i2cdev.h:
/**
* I2C device descriptor
*/
typedef struct
{
i2c_port_t port; //!< I2C port number
i2c_config_t cfg; //!< I2C driver configuration
uint8_t addr; //!< Unshifted address
SemaphoreHandle_t mutex; //!< Device mutex
uint32_t timeout_ticks; /*!< HW I2C bus timeout (stretch time), in ticks. 80MHz APB clock
ticks for ESP-IDF, CPU ticks for ESP8266.
When this value is 0, I2CDEV_MAX_STRETCH_TIME will be used */
} i2c_dev_t;
typedef struct
{
i2c_port_t port; //!< I2C port number
i2c_config_t cfg; //!< I2C driver configuration
uint8_t addr; //!< Unshifted address
SemaphoreHandle_t mutex; //!< Device mutex
uint32_t timeout_ticks; /*!< HW I2C bus timeout (stretch time), in ticks. 80MHz APB clock
ticks for ESP-IDF, CPU ticks for ESP8266.
When this value is 0, I2CDEV_MAX_STRETCH_TIME will be used */
} i2c_dev_t_stek;
the declarations:
bme680_t sensor;
bme680t1 sensor2;
bme680_t_1 sensor1;
i2c_dev_t i2c_dev;
i2c_dev_t_stek i2c_dev1;
The variables (breakpoint after the declarations) are shown in the picture.
What you see: The nested structs are absolutely wrong - and I don't know how and why. The compiler(?) uses the wrong struct definitions. And...after a nested struct the the definition in the typedef stops.
What is going wrong here?
Which SDK are you using?
esp-idf
Which version of SDK are you using?
v5.1.2
Which build target have you used?
- [ ] esp32
- [ ] esp32s2
- [ ] esp32s3
- [ ] esp32c2
- [ ] esp8266
- [X] other
Component causing the issue
BME680, I2CDEV
Anything in the logs that might be useful for us?
No response
Additional information or context
No response
Confirmation
- [X] This report is not a question nor a request for drivers.