freertos.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * File Name : freertos.c
  5. * Description : Code for freertos applications
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2024 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* USER CODE END Header */
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "FreeRTOS.h"
  21. #include "task.h"
  22. #include "main.h"
  23. #include "cmsis_os.h"
  24. /* Private includes ----------------------------------------------------------*/
  25. /* USER CODE BEGIN Includes */
  26. #define LED_STATE_GPIO_Port GPIOC
  27. #define LED_STATE_Pin GPIO_PIN_13
  28. /* USER CODE END Includes */
  29. /* Private typedef -----------------------------------------------------------*/
  30. /* USER CODE BEGIN PTD */
  31. /* USER CODE END PTD */
  32. /* Private define ------------------------------------------------------------*/
  33. /* USER CODE BEGIN PD */
  34. /* USER CODE END PD */
  35. /* Private macro -------------------------------------------------------------*/
  36. /* USER CODE BEGIN PM */
  37. /* USER CODE END PM */
  38. /* Private variables ---------------------------------------------------------*/
  39. /* USER CODE BEGIN Variables */
  40. /* USER CODE END Variables */
  41. /* Definitions for defaultTask */
  42. osThreadId_t defaultTaskHandle;
  43. const osThreadAttr_t defaultTask_attributes = {
  44. .name = "defaultTask",
  45. .stack_size = 128 * 4,
  46. .priority = (osPriority_t) osPriorityNormal,
  47. };
  48. /* Private function prototypes -----------------------------------------------*/
  49. /* USER CODE BEGIN FunctionPrototypes */
  50. /* USER CODE END FunctionPrototypes */
  51. void StartDefaultTask(void *argument);
  52. void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
  53. /**
  54. * @brief FreeRTOS initialization
  55. * @param None
  56. * @retval None
  57. */
  58. void MX_FREERTOS_Init(void) {
  59. /* USER CODE BEGIN Init */
  60. /* USER CODE END Init */
  61. /* USER CODE BEGIN RTOS_MUTEX */
  62. /* add mutexes, ... */
  63. /* USER CODE END RTOS_MUTEX */
  64. /* USER CODE BEGIN RTOS_SEMAPHORES */
  65. /* add semaphores, ... */
  66. /* USER CODE END RTOS_SEMAPHORES */
  67. /* USER CODE BEGIN RTOS_TIMERS */
  68. /* start timers, add new ones, ... */
  69. /* USER CODE END RTOS_TIMERS */
  70. /* USER CODE BEGIN RTOS_QUEUES */
  71. /* add queues, ... */
  72. /* USER CODE END RTOS_QUEUES */
  73. /* Create the thread(s) */
  74. /* creation of defaultTask */
  75. defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
  76. /* USER CODE BEGIN RTOS_THREADS */
  77. /* add threads, ... */
  78. /* USER CODE END RTOS_THREADS */
  79. /* USER CODE BEGIN RTOS_EVENTS */
  80. /* add events, ... */
  81. /* USER CODE END RTOS_EVENTS */
  82. }
  83. /* USER CODE BEGIN Header_StartDefaultTask */
  84. /**
  85. * @brief Function implementing the defaultTask thread.
  86. * @param argument: Not used
  87. * @retval None
  88. */
  89. /* USER CODE END Header_StartDefaultTask */
  90. void StartDefaultTask(void *argument)
  91. {
  92. /* USER CODE BEGIN StartDefaultTask */
  93. /* Infinite loop */
  94. for (;;)
  95. {
  96. HAL_GPIO_TogglePin(LED_STATE_GPIO_Port, LED_STATE_Pin);
  97. osDelay(500);
  98. }
  99. /* USER CODE END StartDefaultTask */
  100. }
  101. /* Private application code --------------------------------------------------*/
  102. /* USER CODE BEGIN Application */
  103. /* USER CODE END Application */