#include "stm32f4xx_hal.h" #include "stm32f4xx_hal_gpio.h" unsigned int blinkLed = 0; // Interface function to blink the green LED void blinkTheLED() { blinkLed++; } enum { MODE_INACTIVE, MODE_ON, MODE_OFF, MODE_SWITCH, // Just have been off }; void rxLed() { static unsigned long timer = 0; static int mode = MODE_INACTIVE; switch( mode ) { case MODE_INACTIVE: if( blinkLed > 0 ) { blinkLed--; mode = MODE_ON; timer = 1; HAL_GPIO_WritePin(GPIOA,GPIO_PIN_5,(GPIO_PinState)1); } break; case MODE_ON: timer--; if( timer == 0 ) { mode = MODE_OFF; HAL_GPIO_WritePin(GPIOA,GPIO_PIN_5,(GPIO_PinState)0); timer = 1; } break; case MODE_OFF: timer--; if( timer == 0 ) { mode = MODE_INACTIVE; HAL_GPIO_WritePin(GPIOA,GPIO_PIN_5,(GPIO_PinState)0); break; } } } // 10Hz timer interrupt function void led_interrupt(){ rxLed(); }