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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

Jump to solution
1,469 Views
kubiznak_petr
Contributor V

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?

Labels (2)
0 Kudos
Reply
1 Solution
1,309 Views
igorpadykov
NXP Employee
NXP Employee

Hi Petr

fix seems as quite sensible, I do not think it would cause any side effects.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
Reply
2 Replies
1,310 Views
igorpadykov
NXP Employee
NXP Employee

Hi Petr

fix seems as quite sensible, I do not think it would cause any side effects.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
1,309 Views
kubiznak_petr
Contributor V

Great, thank you Igor.

0 Kudos
Reply