I2C ISR help
Posted: Mon Apr 29, 2019 12:57 pm
by christoss15
Hey! I'm trying to figure out how to setup i2c interrupts with the following function (i2c_isr_register). I am not sure what to put mainly in the arguments, `arg`, `intr_alloc_flags` and `handle`.
- i2c_isr.png (51.06 KiB) Viewed 3636 times
Re: I2C ISR help
Posted: Tue Apr 30, 2019 1:41 am
by ESP_Sprite
It more-or-less explains it in the image you posted... 'arg' is an opaque pointer to something user-defined. The I2C code does nothing with this, but will pass it through to your ISR handler. If you don't need this, just pass NULL. intr_alloc_flags are flags that define what type of interrupt is used for the I2C code. As it says, look in esp_intr_alloc.h for what you can fill in there. If you don't need it, pass 0. 'handle' is a pointer to an interrupt handle structure; it's used to store information about the interrupt. You'll need it if you later want to disable, re-enable or free the interrupt. Again, if you don't need it, use NULL.
Do note that installing an I2C interrupt also means you have to manually control the I2C hardware; you can't use the API then. Are you sure that is what you want?
Re: I2C ISR help
Posted: Wed May 01, 2019 9:51 am
by christoss15
I am trying to get it to work as an I2C slave device and this is the only way I got it working.
Now I am using an interrupt on the falling edge of SDA and checking STL to see if I received the start condition.
What I can't figure out is how to have an I2C ISR that also gives access to read/write bit