I2C ISR help

christoss15
Posts: 2
Joined: Mon Apr 29, 2019 12:53 pm

I2C ISR help

Postby christoss15 » Mon Apr 29, 2019 12:57 pm

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
i2c_isr.png (51.06 KiB) Viewed 3639 times

ESP_Sprite
Posts: 9766
Joined: Thu Nov 26, 2015 4:08 am

Re: I2C ISR help

Postby ESP_Sprite » Tue Apr 30, 2019 1:41 am

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?

christoss15
Posts: 2
Joined: Mon Apr 29, 2019 12:53 pm

Re: I2C ISR help

Postby christoss15 » Wed May 01, 2019 9:51 am

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

Who is online

Users browsing this forum: MicroController and 121 guests