HI ALL
I am using SDK15.3.0 to familiarize myself with GPIOTE functions,But I have encountered some problems.
First ,I registered 4 GPIOTE pins on the DK board,and I need 4 GPIOTE pins to trigger at the same time.
But the problem is that when I press one of the GPOTEs and then press another one, it can't be triggered.
Because my power supply is a battery, I have to pay attention to power consumption.So I can't set config.hi_accuracy to true
static void btn_init(void)
{
uint8_t BUTTON_NUM = 4;
uint8_t LED_NUM = 3;
uint8_t Button[BUTTON_NUM];
uint8_t LED[LED_NUM];
ret_code_t err_code;
err_code = nrf_drv_gpiote_init();
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(true);
nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
in_config.pull = NRF_GPIO_PIN_PULLUP; //Start valtage is high
in_config.hi_accuracy = false; //true = pin event; false = port event
in_config.sense = NRF_GPIOTE_POLARITY_HITOLO;
for(uint8_t i = 0 ; i < BUTTON_NUM ; i++)
{
err_code = nrf_drv_gpiote_in_init((13+i),&in_config,input_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable((13+i),true);
}
for(uint8_t i = 0 ; i < LED_NUM ; i++)
{
err_code = nrf_drv_gpiote_out_init((17+i),&out_config);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_out_task_enable((17+i));
}
}
Second,The problem of triggering Handler multiple times when I press the button.I don't know how to prevent multiple triggers.
void input_handler(nrf_drv_gpiote_pin_t pin,nrf_gpiote_polarity_t action)
{
if(pin == 13)
{
SEGGER_RTT_printf(0, "bsp_event_handler2 -> BSP_EVENT_KEY_1\r\n");
}else if(pin == 14)
{
SEGGER_RTT_printf(0, "bsp_event_handler2 -> BSP_EVENT_KEY_2\r\n");
}else if(pin == 15)
{
SEGGER_RTT_printf(0, "bsp_event_handler2 -> BSP_EVENT_KEY_3\r\n");
}else if(pin == 16)
{
SEGGER_RTT_printf(0, "bsp_event_handler2 -> BSP_EVENT_KEY_4\r\n");
}
}
This is my first time to ask here, please help me thank you all.