- com_rslt = p_bme280->BME280_BUS_READ_FUNC(p_bme280->dev_addr,
- BME280_CHIP_ID_REG, &v_data_u8,
- BME280_GEN_READ_WRITE_DATA_LENGTH);
- /* read Chip Id */
+ p_bme280 = bme280;
+
+ while (v_chip_id_read_count > 0) {
+
+ /* read Chip Id */
+ com_rslt = p_bme280->BME280_BUS_READ_FUNC(p_bme280->dev_addr,
+ BME280_CHIP_ID_REG, &v_data_u8,
+ BME280_GEN_READ_WRITE_DATA_LENGTH);
+ /* Check for the correct chip id */
+ if (v_data_u8 == BME280_CHIP_ID)
+ break;
+ v_chip_id_read_count--;
+ /* Delay added concerning the low speed of power up system to
+ facilitate the proper reading of the chip ID */
+ p_bme280->delay_msec(BME280_REGISTER_READ_DELAY);
+ }
+ /*assign chip ID to the global structure*/