1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:12:57 +01:00

drivers/ccs811: fix the data ready check

When the measurement results are read from the `ALG_RESULT_DATA` register set including the STATUS register, the `DATA_RDY` flag in the STATUS register is already cleared during reading. Therefore it is not possible to check this flag after the `ALG_RESULT_DATA` has been read. Therefore the function `ccs811_read_iaq` always returned `CCS811_ERROR_NO_NEW_DATA` although the data were valid either after checking for new data with the function `ccs811_data_ready` or after triggering the Data Ready interrupt.
This commit is contained in:
Gunar Schorcht 2021-12-04 13:42:20 +01:00
parent 97f7b67b49
commit 27265095cd
2 changed files with 1 additions and 13 deletions

View File

@ -300,15 +300,6 @@ int ccs811_read_iaq(const ccs811_t *dev,
return _error_code(dev, data[CCS811_ALG_DATA_ERROR_ID]);
}
/*
* check whether new data are ready to read; if not, latest values read
* from sensor are used and error code CCS811_ERROR_NO_NEW_DATA is returned
*/
if (!(data[CCS811_ALG_DATA_STATUS] & CCS811_STATUS_DATA_RDY)) {
DEBUG_DEV("no new data", dev);
res = -CCS811_ERROR_NO_NEW_DATA;
}
/* if *iaq* is not NULL return IAQ sensor values */
if (iaq_tvoc) {
*iaq_tvoc = data[CCS811_ALG_DATA_TVOC_HB] << 8;

View File

@ -144,8 +144,7 @@ int ccs811_init (ccs811_t *dev, const ccs811_params_t *params);
*
* @note
* - If the function is called and no new data are available, the function
* returns the results of the last measurement and the error code
* #CCS811_ERROR_NO_NEW_DATA.
* returns the results of the last measurement.
* - The data-ready status function #ccs811_data_ready or the data-ready
* interrupt (#CCS811_INT_DATA_READY) can be used to determine whether
* new data are available.
@ -160,8 +159,6 @@ int ccs811_init (ccs811_t *dev, const ccs811_params_t *params);
* @param[out] raw_v Voltage across the sensor measured (0..1023 = 1.65 V)
*
* @retval CCS811_OK on success and new data are returned
* @retval CCS811_ERROR_NO_NEW_DATA when no new data are available and last
* measurement results are returned.
* @retval CCS811_ERROR_* otherwise, see #ccs811_error_codes_t.
*/
int ccs811_read_iaq (const ccs811_t *dev,