bool Putz01HandleButtons (void) { int i = 1; static uint32_t tickEvent = EVENT_INTERVAL; while (Buttons_GetState()) { if (i) puts ("Putz01HandleButtons() Looping\r"); i = 0; } if (HAL_GetTick() > tickEvent) { static bool onOff = false; LED_SetOut(onOff ? 2 : 1); onOff = !onOff; tickEvent = HAL_GetTick() + EVENT_INTERVAL; } return true; }
/** \fn int32_t LED_Initialize (void) \brief Initialize LEDs \returns - \b 0: function succeeded - \b -1: function failed */ int32_t LED_Initialize (void) { RCC->AHBENR |= (1UL << 19); /* Enable GPIOC clock */ /* Configure LED pins as push-pull outputs, No pull-up, pull-down */ GPIOC->MODER &= ~((3UL << 2*8) | (3UL << 2*9)); GPIOC->MODER |= ((1UL << 2*8) | (1UL << 2*9)); GPIOC->OTYPER &= ~((1UL << 8) | (1UL << 9)); GPIOC->OSPEEDR &= ~((3UL << 2*8) | (3UL << 2*9)); GPIOC->OSPEEDR |= ((1UL << 2*8) | (1UL << 2*9)); GPIOC->PUPDR &= ~((3UL << 2*8) | (3UL << 2*9)); LED_SetOut (0); return (0); }