while (1)
{
int stan = HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0);
if (stan == GPIO_PIN_SET)
{
// Przycisk wcisniety - zapal diody
HAL_GPIO_WritePin(GPIOD,
GPIO_PIN_12 | GPIO_PIN_13 |
GPIO_PIN_14 | GPIO_PIN_15,
GPIO_PIN_SET);
}
else
{
// Przycisk puszczony - zgas diody
HAL_GPIO_WritePin(GPIOD,
GPIO_PIN_12 | GPIO_PIN_13 |
GPIO_PIN_14 | GPIO_PIN_15,
GPIO_PIN_RESET);
}
if (stan != poprzedniStan)
{
printf("Stan: %d, czas: %lu ms\n",
stan, (unsigned long)HAL_GetTick());
poprzedniStan = stan;
}
}