I'm trying to add more buttons to the nRF51 DK.
But I get an error.
I have found the NUMBER_OF_GPIO_TE define.
#define NUMBER_OF_GPIO_TE 4
How can I handle more buttons? I need at least 12 buttons. And my App must be able to wake up by pressing any one of them.
I found a solution in another question. I can do it like this:
void GPIOTE_IRQHandler(void)
{
// If PORT event has been called, clear event and do stuff
if (NRF_GPIOTE->EVENTS_PORT)
{
uint32_t gpio_state = NRF_GPIO->IN;
NRF_GPIOTE->EVENTS_PORT = 0;
// Look at gpio_state to detect what buttons was pressed. Write code to
// use scheduler to transfer execution from the interrupt context to the main context
}
}
static void buttons_init(void)
{
nrf_gpio_cfg_sense_input(PIN_BUTTON_X, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
nrf_gpio_cfg_sense_input(PIN_BUTTON_Y, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Msk;
NVIC_EnableIRQ(GPIOTE_IRQn);
}
I have tried this code in my application and it detects button presses and a bit in NRF_GPIOTE->EVENTS_PORT corresponding to the port number is set to zero.
I tried to find NRF_GPIOTE->EVENTS_PORT in the reference manual. I can't find any information about that register???