This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

APP_GPIOTE_INIT

It's not clear to me from the documentation what a 'user' with regards to the APP_GPIOTE_MAX_USERS define used when calling the APP_GPIOTE_INIT macro.

If I would like to configure all 4 push buttons on the DK51 to trigger different events do I need to call APP_GPIOTE_INIT(4)?

Parents
  • To simply put it MAX_USERS equals number of times your app have to use app_gpiote_user_register(including other modules which might use app_gpiote)

    one user can listen to more than one pins (buttons), it just need to tell how many pins it need to sense like below

    gpiote_pin_low_high_mask = ((1 << BUTTON1_PIN) | (1 << BUTTON3_PIN));
    gpiote_pin_high_low_mask = (1 << BUTTON1_PIN);
    
    (void)app_gpiote_user_register(&m_gpiote_uid,
                                   gpiote_pin_low_high_mask,
                                   gpiote_pin_high_low_mask,
                                   gpiote_uart_event_handler);
    

    quote from the header file app_gpiote.h @warning If multiple users registers for the same pins the behavior for those pins are undefined.

Reply
  • To simply put it MAX_USERS equals number of times your app have to use app_gpiote_user_register(including other modules which might use app_gpiote)

    one user can listen to more than one pins (buttons), it just need to tell how many pins it need to sense like below

    gpiote_pin_low_high_mask = ((1 << BUTTON1_PIN) | (1 << BUTTON3_PIN));
    gpiote_pin_high_low_mask = (1 << BUTTON1_PIN);
    
    (void)app_gpiote_user_register(&m_gpiote_uid,
                                   gpiote_pin_low_high_mask,
                                   gpiote_pin_high_low_mask,
                                   gpiote_uart_event_handler);
    

    quote from the header file app_gpiote.h @warning If multiple users registers for the same pins the behavior for those pins are undefined.

Children
No Data
Related