#include <stdbool.h> #include <stdint.h> #include "boards.h" #include "nrf_delay.h" #include "nrf_gpio.h" #include "nrf.h" #include "nrf_drv_gpiote.h" #include "app_error.h" #include "nrf_drv_timer.h" #include "app_timer.h" #include "app_button.h" #include "nrf_drv_ppi.h" #define PIN_IN BSP_BUTTON_3 #define PIN_IN_1 BSP_BUTTON_2 #define PIN_OUT BSP_LED_3 #define PIN_OUT_1 BSP_LED_2 //void Tarama_Basla(void) //{ // nrf_gpio_cfg_output(PIN_OUT); // nrf_gpio_cfg_input(PIN_IN, NRF_GPIO_PIN_PULLUP); // for(;;) // { // if(nrf_gpio_pin_read(PIN_IN)) // nrf_gpio_pin_clear(PIN_OUT); // else // nrf_gpio_pin_set(PIN_OUT); // } //} /*******************************************************************************************////// void button_event_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action){ if(action == NRF_GPIOTE_POLARITY_TOGGLE && pin == PIN_IN){ nrf_gpio_pin_toggle(PIN_OUT); } } void Tarama_Basla(void) { nrf_gpio_cfg_output(PIN_OUT); nrf_gpio_pin_set(PIN_OUT); //Initialize GPIOTE driver nrf_drv_gpiote_init(); //Configure button with pullup and event on both high and low transition nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false); config.pull = NRF_GPIO_PIN_PULLUP; nrf_drv_gpiote_in_init(PIN_IN, &config, button_event_handler); //Assign button config to a GPIOTE channel //and assigning the interrupt handler nrf_drv_gpiote_in_event_enable(PIN_IN, true); //Enable event and interrupt for(;;)__WFE(); //CPU sleep while waiting for event }
Here is my code. I did it one button but i must add 4 button. How to use multiple pins for interrupt?