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

Bug in nrfx_gpiote_in_event_enable()

This is a bug report for SDK v15.3.

Once a GPIOTE interrupt is enabled for a pin, nrfx_gpiote_in_event_enable(pin, false) will not disable it.  This appears to be an issue in nrfx_gpiote.c.  Modifying the function as follows resolves the issue:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void nrfx_gpiote_in_event_enable(nrfx_gpiote_pin_t pin, bool int_enable)
{
NRFX_ASSERT(pin < NUMBER_OF_PINS);
NRFX_ASSERT(pin_in_use_by_gpiote(pin));
if (pin_in_use_by_port(pin))
{
uint8_t pin_and_sense = (uint8_t)
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_pin_read(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;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Immediately after posting, I realized that I was misunderstanding the int_enable param.  I should be calling nrfx_gpiote_in_event_disable() instead.