LIS3DH inertial wakeup


I would like to implement the inertial wakeup (6.3.3) from AN3308 of LIS3DH accelerometer but the lis3dh driver has very limited functionality. I need to change the values in CTRL_REG1-5 but the function lis3dh_write_reg is only available in the drivers/lis3dh/lis3dh.c file and I can’t use it in my code. I can’t find any other way of writing to those registers.

How can I achive that?


I think what you want to do can be achived with the function lis2dh12_cfg_threshold_event() followed by a lis2dh12_wait_event().

The latter function will block, the CPU can now switch to a lower power mode (even deep sleep if you configure it). It will configure the interrupt pin so that it wakes the CPU when the even occurs.

Alternatively you can also do so manually with pm_set(0) in another thread (if you want to enter the deepest possible sleep state, usually wake-up will trigger a CPU reset)

1 Like

Thanks! Yes, definitely, I’m looking for that but for the lis3dh module. I feel like the lis3dh driver is missing functinality.

Ah sorry I misread your post. Indeed the driver for lis3dh lacks interrupt support. Then the path forward would be to implement a similar API as lis2dh does instead of exposing raw registers to the application.

I’m not sure how similar lis2dh and lis3dh are but there is a good chance that some code can be re-used. Maybe they could even be supported by a single driver. Linux manages to do so.

1 Like

Thanks. I will try to implement some code to make it work for me. I don’t think that I’m capable of writing a good driver, yet.

If you add the functionality to lis3dh just open a pull request on Github, we’ll then help you to get it into a state where it can be integrated upstream :slight_smile:

1 Like