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

Using more than 4 buttons with GPIOTE interrupts

Hi,

I am using GPIOTE interrupts to detect button presses. It works fine but there are only four channels in GPIOTE->EVENTS_IN[] and each channel can only be assigned to one pin. How should I do if I want to implement more than 4 buttons?

Basically I set up GPIOTE like this:

  pinInput(pin); // make sure the pin is set as input
  NRF_GPIOTE->CONFIG[channel] = (static_cast<uint32_t>(transitionMode) << GPIOTE_CONFIG_POLARITY_Pos) |
      (pin << GPIOTE_CONFIG_PSEL_Pos) |
      (GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos);
  NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_IN0_Set << channel; // @warning: we should use bitfields instead
  NRF_GPIOTE->EVENTS_IN[channel] = 0;

and in the GPIOTE_IRQHandler I check which channel has been interrupted and send an appropriate callback.

I do not use any sd by the way.

Thanks!

Parents Reply Children
Related