mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 06:23:53 +01:00
drivers/stmpe811: ensure fifo is not empty before reading touch position
This commit is contained in:
parent
caead7bb75
commit
37b096562a
@ -194,6 +194,13 @@ int stmpe811_read_touch_position(stmpe811_t *dev, stmpe811_touch_position_t *pos
|
||||
/* Acquire I2C device */
|
||||
i2c_acquire(STMPE811_DEV_I2C);
|
||||
|
||||
/* Ensure there's a least one position measured in the FIFO */
|
||||
uint8_t fifo_size = 0;
|
||||
do {
|
||||
i2c_read_reg(STMPE811_DEV_I2C, STMPE811_DEV_ADDR,
|
||||
STMPE811_FIFO_SIZE, &fifo_size, 0);
|
||||
} while (!fifo_size);
|
||||
|
||||
uint8_t xyz[4];
|
||||
uint32_t xyz_ul;
|
||||
|
||||
@ -203,7 +210,6 @@ int stmpe811_read_touch_position(stmpe811_t *dev, stmpe811_touch_position_t *pos
|
||||
i2c_release(STMPE811_DEV_I2C);
|
||||
return -STMPE811_ERR_I2C;
|
||||
}
|
||||
_reset_fifo(dev);
|
||||
|
||||
/* Release I2C device */
|
||||
i2c_release(STMPE811_DEV_I2C);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user