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

interrupt not set

Hello,

I have trouble with interrupt.

I use pin 16 to trigger interrupt signals from a sx1261 module.

It has worked well on example code with SDK 14, but for my projet I have to migrate to SDK 15.2. Since migration I am not able to detect interrupts.

I have changed nrf_drv_spi and nrd_drv_gpiote drivers to nrfx drivers.

I think I missed a step while migrating project.

Do you have any idea of something wrong ?

Thank you

this is part of my project related with gpio interrupt:

GpioInit(&SX126x.DIO1,    PIN_LORA_DIO_1,     PIN_INPUT,  PIN_PUSH_PULL, PIN_NO_PULL, 0);

GpioSetInterrupt(&SX126x.DIO1, IRQ_RISING_EDGE, IRQ_HIGH_PRIORITY, dioIrq);


static void gpiote_evt_handler (nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t unused)
{
    if (GpioIrq[pin] != NULL)
    {
        GpioIrq[pin]();
    }
}

void GpioInit (Gpio_t *obj, uint32_t pin, PinModes mode, PinConfigs config, PinTypes type, uint32_t value)
{
    nrf_gpio_pin_pull_t pull_config;

    if (pin >= NRF_NUM_GPIO_PINS)
        return;

    obj->pin = pin;
    obj->pull = type;
    
    if (mode == PIN_INPUT)
    {
        if (type == PIN_NO_PULL)
            pull_config = NRF_GPIO_PIN_NOPULL;
        else if (type == PIN_PULL_UP)
            pull_config = NRF_GPIO_PIN_PULLUP;
        else if (type == PIN_PULL_DOWN)
            pull_config = NRF_GPIO_PIN_PULLDOWN;

        nrf_gpio_cfg_input (obj->pin, pull_config);
    }
    else // mode output
    {
        nrf_gpio_cfg_output (obj->pin);
    }

    // Sets initial output value
    if (mode == PIN_OUTPUT)
    {
        nrf_gpio_pin_write (pin, value);
    }
}

void GpioSetInterrupt (Gpio_t *obj, IrqModes irqMode, IrqPriorities irqPriority, GpioIrqHandler *irqHandler)
{
    uint32_t err_code;

    if (obj->pin >= NRF_NUM_GPIO_PINS)
        return;

    if (irqHandler == NULL)
    {
        return;
    }

    GpioIrq[obj->pin] = irqHandler;

    nrfx_gpiote_in_config_t gpiote_in_config;
    gpiote_in_config.is_watcher  = false;
    gpiote_in_config.hi_accuracy = false;

    // Check if gpiote lib is already initialized
    // Initiliaze it if not
    if (!nrfx_gpiote_is_init())
    {
        err_code = nrfx_gpiote_init();
                APP_ERROR_CHECK(err_code);
    }

    // Configure pin number, polarity and pull configuration
    nrfx_gpiote_pin_t pin = obj->pin;

    if (irqMode == IRQ_RISING_EDGE)
    {
        gpiote_in_config.sense = NRF_GPIOTE_POLARITY_LOTOHI;
    }
    else if (irqMode == IRQ_FALLING_EDGE)
    {
        gpiote_in_config.sense = NRF_GPIOTE_POLARITY_HITOLO;
    }
    else
    {
        gpiote_in_config.sense = NRF_GPIOTE_POLARITY_TOGGLE;
    }

    if (obj->pull == PIN_NO_PULL)
    {
        gpiote_in_config.pull = NRF_GPIO_PIN_NOPULL;
    }
    else if (obj->pull == PIN_PULL_UP)
    {
        gpiote_in_config.pull = NRF_GPIO_PIN_PULLUP;
    }
    else
    {
        gpiote_in_config.pull = NRF_GPIO_PIN_PULLDOWN;
    }

    err_code = nrfx_gpiote_in_init (pin, &gpiote_in_config, gpiote_evt_handler);
    APP_ERROR_CHECK(err_code);

    nrfx_gpiote_in_event_enable(pin, true);
}

Related