Handling interrupts from i2c devices

boron
Tags: #<Tag:0x00007fe22be7b638>

#1

I’m a little puzzled about what the recommended process is to handle interrupts from an i2c device. I have an accelerometer that generates an interrupt, so far so good. To disable the interrupt one has to read one of the registers (over i2c), and obviously to get the info about the interrupt one has to read other registers. But using i2c from within an interrupt handler seems to be a great recipe for lock-up (understandably).
I don’t want to just set a flag and wait for the next loop() iteration, that’s too slow because the loop() does some slow things. So do I need to create a separate high-priority thread and enable that in the interrupt handler? But then how about conflicts between i2c accesses in that thread and in the main thread / loop()?
Is there some sample code somewhere for recommended approaches? (Would be nice not to have to reinvent the wheel from scratch…)