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

GPiote_handler doubly defined

HI, I am new to embedded system and just start to learn NRF52 DK. currently I want to configure a pin of nrf52 as interrupt. so i created new GPIOTE_Handler function . however, it seems the function is multiply defined with a same function in drv_gpiote.c. after delete the function in drv_gpiote.c, the button function can't work properly. so i tried to merge the two GPIOTE_handler, but failed.

void GPIOTE_INIT(void){
nrf_gpio_cfg_input(31, GPIO_PIN_CNF_PULL_Pullup);  //configure pin0.31 as gpio interrupt
NVIC_EnableIRQ(GPIOTE_IRQn);
NRF_GPIOTE->CONFIG[0] = (GPIOTE_CONFIG_POLARITY_HiToLo << GPIOTE_CONFIG_POLARITY_Pos)
                        | (31 << GPIOTE_CONFIG_PSEL_Pos)
                        | (GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos);
NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_IN0_Set << GPIOTE_INTENSET_IN0_Pos;  
  	}

my GPIOTE_IRQHandler.

void GPIOTE_IRQHandler(void){
    if ((NRF_GPIOTE->EVENTS_IN[0] == 1) && (NRF_GPIOTE->INTENSET & GPIOTE_INTENSET_IN0_Msk))
		{
			  NRF_GPIOTE->EVENTS_IN[0] = 0;
			  DRDY = 1;
		}
							}

is anyone able to teach me to merge them. Thank you very much

  • You need to change 31 to your button pin, both in nrf_gpio_cfg_input(..) and NRF_GPIOTE->CONFIG[0].

    I would however recommend to use the driver instead. We have a button library in the SDK that also implements button debouncing (do a quick google search to see what this is) which is good to have. Here is an example of how to use the button library for two buttons (code after the EDIT).

Related