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 <armando.visconti@st.com>
This commit is contained in:
Armando Visconti 2020-02-18 11:42:02 +01:00 committed by Ioannis Glaropoulos
commit 0ba94d6d78

View file

@ -20,9 +20,14 @@ int lis3mdl_trigger_set(struct device *dev,
sensor_trigger_handler_t handler)
{
struct lis3mdl_data *drv_data = dev->driver_data;
s16_t buf[3];
__ASSERT_NO_MSG(trig->type == SENSOR_TRIG_DATA_READY);
/* dummy read: re-trigger interrupt */
i2c_burst_read(drv_data->i2c, DT_INST_0_ST_LIS3MDL_MAGN_BASE_ADDRESS,
LIS3MDL_REG_SAMPLE_START, (u8_t *)buf, 6);
gpio_pin_interrupt_configure(drv_data->gpio,
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN,
GPIO_INT_DISABLE);
@ -133,13 +138,6 @@ int lis3mdl_init_interrupt(struct device *dev)
return -EIO;
}
/* enable interrupt */
if (i2c_reg_write_byte(drv_data->i2c, DT_INST_0_ST_LIS3MDL_MAGN_BASE_ADDRESS,
LIS3MDL_REG_INT_CFG, LIS3MDL_INT_XYZ_EN) < 0) {
LOG_DBG("Could not enable interrupt.");
return -EIO;
}
#if defined(CONFIG_LIS3MDL_TRIGGER_OWN_THREAD)
k_sem_init(&drv_data->gpio_sem, 0, UINT_MAX);