SK
Size: a a a
SK
l
ED
l
ED
SK
ED
SK
IN
SK
l
SK
ED
volatile uint8_t my_button_state;
...
void TIMx_InterruptHandler(void)
{
static uint32_t my_button_counter=0;
TIMx->SR = ...;
if (GPIOx->IDR & MY_BUTTON_BITMASK)
{
my_button_counter++;
}
else
{
if (my_button_counter > SHORT_PRESS_DURATION)
{
my_button_state=MY_BUTTON_SHORT_PRESS;
my_button_counter = 0;
}
if (my_button_counter > LONG_PRESS_DURATION)
{
my_button_state = MY_BUTTON_LONG_PRESS;
my_button_counter = 0;
}
}
}
IN
ED
IN
ED
ED
IN