Hello igorpadykov
I found where the error was, there is a bug in the SDK concerning the "gpio_set_interrupt_mask()" function in the source file "gpio.c" in the directory "…\iMX6_Platform_SDK\sdk\drivers\gpio\src".
the bugged function is as follows:
------------------------------------------------------
int32_t gpio_set_interrupt_mask(int32_t port, int32_t pin, int32_t mask)
{
if ((port > HW_GPIO_INSTANCE_COUNT) || (port < 1))
{
debug_printf("Invalid GPIO Instance GPIO_PORT%d parameter. GPIO_PORT1~GPIO_PORT%d is allowed.\n",
port, HW_GPIO_INSTANCE_COUNT);
return INVALID_PARAMETER;
}
if ((pin > 31) || (pin < 0))
{
debug_printf("Invalid GPIO Pin %d parameter. Pin 0~31 is allowed.\n", pin);
return INVALID_PARAMETER;
}
uint32_t value = HW_GPIO_IMR_RD(port);
if (mask == GPIO_IMR_MASKED) <<<< (2) also the if conditions are swapped
value &= ~(1 << pin);
else
value |= 1 << pin;
HW_GPIO_GDIR_WR(port, value); <<<< (1) Here is the main bug; it writes to the register GDIR instead of IMR
return 0; //SUCCESS;
}
And the corrected function should be as follows:
-------------------------------------------------------------------
int32_t gpio_set_interrupt_mask(int32_t port, int32_t pin, int32_t mask)
{
if ((port > HW_GPIO_INSTANCE_COUNT) || (port < 1))
{
debug_printf("Invalid GPIO Instance GPIO_PORT%d parameter. GPIO_PORT1~GPIO_PORT%d is allowed.\n",
port, HW_GPIO_INSTANCE_COUNT);
return INVALID_PARAMETER;
}
if ((pin > 31) || (pin < 0))
{
debug_printf("Invalid GPIO Pin %d parameter. Pin 0~31 is allowed.\n", pin);
return INVALID_PARAMETER;
}
uint32_t value = HW_GPIO_IMR_RD(port);
if (mask == GPIO_IMR_MASKED)
value |= 1 << pin;
else
value &= ~(1 << pin);
HW_GPIO_IMR_WR(port, value);
return 0; //SUCCESS;
}
Regards,
Abdelrahman