Hello Aleks,
Regarding your questions please see my comments below.
In which register the state of the falling or rising edge is reflected?
Unfortunately, there aren't any register that shows if it was either falling or rising edge. However, inside the IRQ handler, you can read the state of the pin, this way you can determine if it was a rising or falling edge. Something like the following:
void EXAMPLE_GPIO_IRQHandler(void)
{
if(GPIO_PinRead(EXAMPLE_SW_GPIO, EXAMPLE_SW_GPIO_PIN))
{
interrupt_flag = 1;
}
else
{
interrupt_flag = 0;
}
GPIO_PortClearInterruptFlags(EXAMPLE_SW_GPIO, 1U << EXAMPLE_SW_GPIO_PIN);
g_InputSignal = true;
#if defined __CORTEX_M && (__CORTEX_M == 4U)
__DSB();
#endif
}
Is it possible to change interrupt settings inside the IRQ function?
Yes, it is possible. To achieve this you need to follow the next procedure.
void EXAMPLE_GPIO_IRQHandler(void)
{
GPIO_PortClearInterruptFlags(EXAMPLE_SW_GPIO, 1U << EXAMPLE_SW_GPIO_PIN);
g_InputSignal = true;
if(change_interrupt)
{
GPIO_PortDisableInterrupts(EXAMPLE_SW_GPIO, 1U << EXAMPLE_SW_GPIO_PIN);
GPIO_PinInit(EXAMPLE_SW_GPIO, EXAMPLE_SW_GPIO_PIN, &sw_reconfig);
GPIO_PortEnableInterrupts(EXAMPLE_SW_GPIO, 1U << EXAMPLE_SW_GPIO_PIN);
change_interrupt = false;
}
#if defined __CORTEX_M && (__CORTEX_M == 4U)
__DSB();
#endif
}
Please consider that keeping the IRQ handlers as short and fast as possible is a good C programming practice. So, it would be good to consider changing the interrupt settings outside the IRQ handler.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------