Skip to content

Commit

Permalink
icm42699: Only clear interrupt status when setting trigger
Browse files Browse the repository at this point in the history
Always clearing the interrupt status register was causing issues for
the sensor shell when interrupts were enabled but trying to read
one-off samples.

Signed-off-by: Yuval Peress <peress@google.com>
  • Loading branch information
yperess committed May 16, 2023
1 parent ba3167a commit 1689e90
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/sensor/icm42688/icm42688_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,11 @@ static void icm42688_gpio_callback(const struct device *dev, struct gpio_callbac
static void icm42688_thread_cb(const struct device *dev)
{
struct icm42688_dev_data *data = dev->data;
const struct icm42688_dev_cfg *cfg = dev->config;

icm42688_lock(dev);

if (data->data_ready_handler != NULL) {
data->data_ready_handler(dev, data->data_ready_trigger);
} else {
uint8_t status;

icm42688_spi_read(&cfg->spi, REG_INT_STATUS, &status, 1);
}

icm42688_unlock(dev);
Expand Down Expand Up @@ -81,6 +76,7 @@ int icm42688_trigger_set(const struct device *dev, const struct sensor_trigger *
{
struct icm42688_dev_data *data = dev->data;
const struct icm42688_dev_cfg *cfg = dev->config;
uint8_t status;
int res = 0;

if (trig == NULL || handler == NULL) {
Expand All @@ -94,6 +90,10 @@ int icm42688_trigger_set(const struct device *dev, const struct sensor_trigger *
case SENSOR_TRIG_DATA_READY:
data->data_ready_handler = handler;
data->data_ready_trigger = trig;

icm42688_lock(dev);
icm42688_spi_read(&cfg->spi, REG_INT_STATUS, &status, 1);
icm42688_unlock(dev);
break;
default:
res = -ENOTSUP;
Expand Down

0 comments on commit 1689e90

Please sign in to comment.