Hello, we need to first enable GPIOTE+IRQ. Then after 1st IRQ we want to keep only GPIOTE and disable IRQ. We do not want to disable GPIOTE (because it works with PPI), but only to disable IRQ.
We tried to call first: nrf_drv_gpiote_in_event_enable(pin, true)
and then in ISR we tried to call nrf_drv_gpiote_in_event_enable(pin, false)
in order to disable IRQ, but it would not work.
I propose to fix the SDK function and add:
else{ nrf_gpiote_int_disable(1 << channel);}
so it would look like:
void nrf_drv_gpiote_in_event_enable(nrf_drv_gpiote_pin_t pin, bool int_enable)
{
ASSERT(pin < NUMBER_OF_PINS);
ASSERT(pin_in_use_by_gpiote(pin));
if (pin_in_use_by_port(pin))
{
uint8_t pin_and_sense = m_cb.port_handlers_pins[channel_port_get(pin) - GPIOTE_CH_NUM];
nrf_gpiote_polarity_t polarity = (nrf_gpiote_polarity_t)(pin_and_sense >> SENSE_FIELD_POS);
nrf_gpio_pin_sense_t sense;
if (polarity == NRF_GPIOTE_POLARITY_TOGGLE)
{
/* read current pin state and set for next sense to oposit */
sense = (nrf_gpio_pins_read() & (1 << pin)) ?
NRF_GPIO_PIN_SENSE_LOW : NRF_GPIO_PIN_SENSE_HIGH;
}
else
{
sense = (polarity == NRF_GPIOTE_POLARITY_LOTOHI) ?
NRF_GPIO_PIN_SENSE_HIGH : NRF_GPIO_PIN_SENSE_LOW;
}
nrf_gpio_cfg_sense_set(pin,sense);
}
else if (pin_in_use_by_te(pin))
{
int32_t channel = (int32_t)channel_port_get(pin);
nrf_gpiote_events_t event = TE_IDX_TO_EVENT_ADDR(channel);
nrf_gpiote_event_enable(channel);
nrf_gpiote_event_clear(event);
if (int_enable)
{
nrf_drv_gpiote_evt_handler_t handler = channel_handler_get(channel_port_get(pin));
// Enable the interrupt only if event handler was provided.
if (handler)
{
nrf_gpiote_int_enable(1 << channel);
}
}else{
nrf_gpiote_int_disable(1 << channel);
}
}
}
Also I believe that current description of function is not correct. In documentation is written:
int_enable: True to enable the interrupt. Always valid for a high-accuracy pin.
But in fact interrupt is always enabled for PORT event. Thus when high-accuracy = False