Re: user_data with gpio_callback #api

Hadrien KOHL <hadrien.kohl@...>

The callback receives a pointer to your gpio_callback struct. 

If the gpio_callback is within your own struct user_data you can use the CONTAINER_OF() macro to get a pointer to the user_data.

Something like this:

void isr_your_gpio_handler(struct device *dev, struct gpio_callback *CB) {
  struct user_data *data = CONTAINER_OF(cb, struct user_data,field_name_of_gpio_callback);


On Wed, Sep 18, 2019, 00:10 <leonardomt@...> wrote:
Hello Zephyr developers,

What are my options if I want an interrupt / gpio_init_callback to invoke a member function?
Is there a way to pass user_data with a gpio_callback?


Join to automatically receive all group messages.