Skip to content

Commit 0ba94d6

Browse files
aviscontiioannisg
authored andcommitted
driver/sensor: lis3mdl: Fix DRDY interrupt
The LIS3MDL sensor provides two different pins for handling interrupts: the DRDY, that triggers new data sample availability, and INT, that goes off when data sample exceeds a given threshold. The driver handled data ready triggers only, which does not require sensor configuration at all. Moreover a dummy read is required when the data ready is configured to re-trigger a new interrupt. Signed-off-by: Armando Visconti <[email protected]>
1 parent 36b92fb commit 0ba94d6

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

drivers/sensor/lis3mdl/lis3mdl_trigger.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ int lis3mdl_trigger_set(struct device *dev,
2020
sensor_trigger_handler_t handler)
2121
{
2222
struct lis3mdl_data *drv_data = dev->driver_data;
23+
s16_t buf[3];
2324

2425
__ASSERT_NO_MSG(trig->type == SENSOR_TRIG_DATA_READY);
2526

27+
/* dummy read: re-trigger interrupt */
28+
i2c_burst_read(drv_data->i2c, DT_INST_0_ST_LIS3MDL_MAGN_BASE_ADDRESS,
29+
LIS3MDL_REG_SAMPLE_START, (u8_t *)buf, 6);
30+
2631
gpio_pin_interrupt_configure(drv_data->gpio,
2732
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN,
2833
GPIO_INT_DISABLE);
@@ -133,13 +138,6 @@ int lis3mdl_init_interrupt(struct device *dev)
133138
return -EIO;
134139
}
135140

136-
/* enable interrupt */
137-
if (i2c_reg_write_byte(drv_data->i2c, DT_INST_0_ST_LIS3MDL_MAGN_BASE_ADDRESS,
138-
LIS3MDL_REG_INT_CFG, LIS3MDL_INT_XYZ_EN) < 0) {
139-
LOG_DBG("Could not enable interrupt.");
140-
return -EIO;
141-
}
142-
143141
#if defined(CONFIG_LIS3MDL_TRIGGER_OWN_THREAD)
144142
k_sem_init(&drv_data->gpio_sem, 0, UINT_MAX);
145143

0 commit comments

Comments
 (0)