cancel
Showing results for 
Search instead for 
Did you mean: 

Can someone provide a INTERRUPT BASED driver for LIS2DW12?

CPeng.1
Associate

Hi community:

There is this driver provided on ST webpage for LIS2DW12:

https://www.st.com/content/st_com/en/products/embedded-software/mems-and-sensors-software/drivers-for-mems/c-driver-mems.html

leading to:

https://github.com/STMicroelectronics/STMems_Standard_C_drivers/tree/master/lis2dw12_STdC

The driver provided here does polling, but I need an interrupt based driver.

Can someone provide an INTERRUPT BASED driver?

Thanks!

1 REPLY 1
Eleon BORLINI
ST Employee

Hi @CPeng.1​ , but you can take inspiration from, for example, this other driver lsm6ds3_read_data_interrupt.c. You have to route first the DRDY signal on INT1 pin:

/* Enable interrupt generation on DRDY INT1 pin */
  lis2dw12_pin_int1_route_get(&dev_ctx, &int_1_reg);
  int_1_reg.int1_drdy_xl = PROPERTY_ENABLE; // INT1_DRDY bit in CTRL4_INT1_PAD_CTRL (23h) register
  lis2dw12_pin_int1_route_set(&dev_ctx, &int_1_reg);

and then manage the dataout read triggering the application processor with that interrupt signal

static int32_t platform_read_int_pin(void)
{
  return HAL_GPIO_ReadPin(LIS2DW12_INT1_GPIO_PORT, LIS2DW12_INT1_PIN);
  /* Please uncomment next line if interrupt configured on INT2 pin */
  //return HAL_GPIO_ReadPin(LSM6DS3_INT2_GPIO_PORT, LSM6DS3_INT2_PIN);
}

Regards