diff --git a/src/W800_SDK_v1.00.10/app/app_drivers/i2c/BMP280.c b/src/W800_SDK_v1.00.10/app/app_drivers/i2c/BMP280.c index 2646a20..15643c7 100644 --- a/src/W800_SDK_v1.00.10/app/app_drivers/i2c/BMP280.c +++ b/src/W800_SDK_v1.00.10/app/app_drivers/i2c/BMP280.c @@ -113,6 +113,16 @@ bool BMP280_trigger_measurement(void) return i2c_write_reg(BMP280_I2C_ADDR, BMP280_CTRL_MEAS, data); } +bool BMP280_is_measuring(void) +{ + uint8_t data; + + if(!i2c_read_reg(BMP280_I2C_ADDR, BMP280_STATUS, &data)) return false; + + /* If bit 3 of the status register is 1, then a measurement is ongoing */ + return (data >> 3) & 0x01; +} + float BMP280_get_temperature(void) { int32_t var1, var2; diff --git a/src/W800_SDK_v1.00.10/app/app_drivers/i2c/BMP280.h b/src/W800_SDK_v1.00.10/app/app_drivers/i2c/BMP280.h index 163fb1a..827f3b9 100644 --- a/src/W800_SDK_v1.00.10/app/app_drivers/i2c/BMP280.h +++ b/src/W800_SDK_v1.00.10/app/app_drivers/i2c/BMP280.h @@ -110,6 +110,15 @@ bool BMP280_configure(BMP280_Mode_e mode, BMP280_Oversampling_e temperature_over */ bool BMP280_trigger_measurement(void); +/** + * @brief Checks if the sensor is currently performing a measurement or not. + * This can be useful to check if the measurement is ready after calling @ref BMP280_trigger_measurement. + * + * @return true if the sensor is currently performing a measurement. + * @return false if the sensor is not, this means that the data is ready to be read. + */ +bool BMP280_is_measuring(void); + /** * @brief Returns the previously sampled temperature in °C. *