AnsweredAssumed Answered

iMX6SX: GPIO_Init() resets IMR of all pins (gpio_imx driver @FreeRTOS)

Question asked by Petr Kubiznak on Jun 25, 2018
Latest reply on Jun 25, 2018 by Petr Kubiznak

I hit on an issue with the gpio_imx driver shipped with the FreeRTOS BSP v1.0.1 (FreeRTOS_BSP_1.0.1_iMX6SX\platform\drivers\src\gpio_imx.c). In the beggining of the GPIO_Init() function, GPIO_IMR and GPIO_EDGE_SEL registers are cleared:

    /* Register reset to default value */
    GPIO_IMR_REG(base) = 0;
    GPIO_EDGE_SEL_REG(base) = 0;

Anyway, the function serves for initialization of a single GPIO pin. When called to reinitialize a pin configuration at runtime, the settings of IMR and EDGE_SEL registers are lost for all pins on that port. I believe this is a bug and the aforementioned code should be masked to only affect a single bit, as follows:

    /* Register reset to default value */
    GPIO_IMR_REG(base) &= ~(1U << pin);
    GPIO_EDGE_SEL_REG(base) &= ~(1U << pin);

Can someone please confirm this is a correct fix? Or would that cause any side effects?