Gpio configuration and interrupt selection


In my application during the application’s initialization, I want to configure a specific gpio as an input signal and keep it that way.

Then later when my application is in a certain state(starts performing a specific operation) I then am interested in receiving an interrupt whenever this gpio is asserted (logic level high). At this time I want to retain all the configuration that I had done before and just enable a level high interrupt for this gpio.

Then when the application exits this state I want to disable the interrupts on this gpio.

Is the following flow of code a valid flow?

/// When the application is initializing, I just want to configure the gpio as an input
uIo ioDataRequest = COLIBRI_PIN(79); 

if(!Imx7Gpio_SetConfigString( hGPIO, ioDataRequest, NULL, L"AltFn=5,dir=in,pull=down100k", StoreVolatile)) {
        LOG_ERROR("\nERROR, [%s, %d], Failed to initialize the interrupt gpio", __FUNCTION__, __LINE__ );
        return ERROR_INIT_FAILED;

/// Later when I want the pin to raise and interrupt request, update the pin configuration, by just setting in the interrupt trigger. Is below a valid way of enabling the interrupts on this gpio, since all other configuration was already in place.
if(!Imx7Gpio_SetConfigString( hGPIO, ioDataRequest, NULL, L"irqtrig=high", StoreVolatile)) {
        LOG_ERROR("\nERROR, [%s, %d], Failed to initialize the interrupt gpio", __FUNCTION__, __LINE__ );

//// Once the job with the interrupts is done .. how to disable the interrupt trigger .. the config string parameter irqtrig has no value to disable the interrupts on a gpio

Further, I understand that since I am configuring the gpio for level triggered interrupt, so even after I process the interrupt and call InterruptDone(), the event mapped with this sysIntr would again be set by the underlying system. Is my understanding correct? Is there a way to tell the OS that I want an interrupt again when this pin toggles twice and the pin attains high level again? I want to avoid changing the interrupt level to low and be interrupted when the signal is de-asserted and again change the interrupt trigger level to high to achieve this.

If I configure the gpio to raise an interrupt on the rising edge, I would achieve this. But a level triggered interrupt might help in filtering out any short spikes, which in case of an edge interrupt would set the IST running.


Basically I want to know 2 things, does the library function Imx7Gpio_SetConfigString() work incrementally, when called at different instances within code with different set of parameters to be configured specified. Or does it wipe the previous parameters and set them to some defaults and in addition updates the new parameter specified.

Secondly how do i disable the interrupt triggering for the gpio?

Dear @kapeed

The GpioLib only offers functions to configure how the interrupt gets triggered (high/low level, rising/falling edge).
Turning on/off the interrupt at all is handled in the interrupt library.

To avoid generating interrupt events, you have to turn off the Interrupt by calling Int_InterruptDisable(). Re-enabling is done by calling Int_InterruptInitialize(). The Gpio configuration - including direction and interrupt edge - is not modified by calling the Int_...() functions.

Regards, Andy