I would like to make a timer to check the GPIO status.
The current code is like below:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Detect the event
void charge_event_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
if(action == GPIOTE_CONFIG_POLARITY_HiToLo && pin == TYPE_C)
{
nrf_gpio_pin_set(LED_2);
}
if(action == GPIOTE_CONFIG_POLARITY_LoToHi && pin == TYPE_C)
{
nrf_gpio_pin_clear(LED_2);
}
}
void charge_init(void)
{
uint32_t err_code;
//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;
I already checked that timer function is worked by implant the specific event into the charge_event_handler as below:
charge_event_handler(TYPE_C,GPIOTE_CONFIG_POLARITY_LoToHi );
But not sure how to make it switch from different event.
Or there is any smart way to make it?