drivers: sensor: Make apds9960 polling wait
sensor_fetch for apds9960 will now block until a valid sample is ready Signed-off-by: Thomas Lang <thomaslang2003@me.com>
This commit is contained in:
parent
999b8f85c6
commit
f38beeafba
@ -83,6 +83,24 @@ static int apds9960_sample_fetch(const struct device *dev,
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_APDS9960_FETCH_MODE_POLL
|
||||
#ifdef CONFIG_APDS9960_ENABLE_ALS
|
||||
while (!(tmp & APDS9960_STATUS_AINT)) {
|
||||
k_sleep(K_MSEC(APDS9960_DEFAULT_WAIT_TIME));
|
||||
if (i2c_reg_read_byte_dt(&config->i2c, APDS9960_STATUS_REG, &tmp)) {
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
#else
|
||||
while (!(tmp & APDS9960_STATUS_PINT)) {
|
||||
k_sleep(K_MSEC(APDS9960_DEFAULT_WAIT_TIME));
|
||||
if (i2c_reg_read_byte_dt(&config->i2c, APDS9960_STATUS_REG, &tmp)) {
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
LOG_DBG("status: 0x%x", tmp);
|
||||
if (tmp & APDS9960_STATUS_PINT) {
|
||||
if (i2c_reg_read_byte_dt(&config->i2c,
|
||||
|
||||
@ -212,6 +212,9 @@
|
||||
#define APDS9960_DEFAULT_GPULSE 0xC9
|
||||
#define APDS9960_DEFAULT_GCONF3 0
|
||||
|
||||
/* Polling Wait Times (ms) */
|
||||
#define APDS9960_DEFAULT_WAIT_TIME 2.78
|
||||
|
||||
struct apds9960_config {
|
||||
struct i2c_dt_spec i2c;
|
||||
#ifdef CONFIG_APDS9960_FETCH_MODE_INTERRUPT
|
||||
|
||||
Loading…
Reference in New Issue
Block a user