Hi there,
so I have a simple problem, I am trying to controll the LED with a button. I want it to flash when the button is set, and darken when it's on reset. I've used the TogglePin function, and it doesn't work. It changes the LED state and leaves it as it is. I've tried removing the else statement cauze I thought it might be enough for one if to be written - but when i did, it crashes. I mean it works but once it lights up, the communication between button and LED breaks and clicking the button doesn't change the LED's state. I have to mention that it is supposed to be controlled by ISR. Any advices what do I do?
void ToggleDiode()
{
if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_5) == GPIO_PIN_RESET)
{
HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_7);
}
else
{
HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_7);
}
}
void handleButtonInterrupt(void)
{
ToggleDiode();
}