main.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include <FreeRTOS.h>
  2. #include <task.h>
  3. #include <timers.h>
  4. #include <stm32f4xx_hal.h>
  5. // STM32F4-Discovery green led - PD12
  6. #define LED_PORT GPIOD
  7. #define LED_PIN GPIO_PIN_12
  8. #define LED_PORT_CLK_ENABLE __HAL_RCC_GPIOD_CLK_ENABLE
  9. static void blinky(void *arg)
  10. {
  11. for(;;)
  12. {
  13. vTaskDelay(500);
  14. HAL_GPIO_TogglePin(LED_PORT, LED_PIN);
  15. }
  16. }
  17. void initGPIO()
  18. {
  19. GPIO_InitTypeDef GPIO_Config;
  20. GPIO_Config.Mode = GPIO_MODE_OUTPUT_PP;
  21. GPIO_Config.Pull = GPIO_NOPULL;
  22. GPIO_Config.Speed = GPIO_SPEED_FREQ_HIGH;
  23. GPIO_Config.Pin = LED_PIN;
  24. LED_PORT_CLK_ENABLE();
  25. HAL_GPIO_Init(LED_PORT, &GPIO_Config);
  26. }
  27. int main(void)
  28. {
  29. SystemInit();
  30. initGPIO();
  31. xTaskCreate(blinky, "blinky", configMINIMAL_STACK_SIZE * 4, NULL, tskIDLE_PRIORITY + 1, NULL);
  32. vTaskStartScheduler();
  33. for (;;);
  34. return 0;
  35. }
  36. void vApplicationTickHook(void)
  37. {
  38. }
  39. void vApplicationIdleHook(void)
  40. {
  41. }
  42. void vApplicationMallocFailedHook(void)
  43. {
  44. taskDISABLE_INTERRUPTS();
  45. for(;;);
  46. }
  47. void vApplicationStackOverflowHook(TaskHandle_t pxTask, char *pcTaskName)
  48. {
  49. (void) pcTaskName;
  50. (void) pxTask;
  51. taskDISABLE_INTERRUPTS();
  52. for(;;);
  53. }