app_freertos.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * File Name : app_freertos.c
  5. * Description : Code for freertos applications
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under Ultimate Liberty license
  13. * SLA0044, the "License"; You may not use this file except in compliance with
  14. * the License. You may obtain a copy of the License at:
  15. * www.st.com/SLA0044
  16. *
  17. ******************************************************************************
  18. */
  19. /* USER CODE END Header */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "FreeRTOS.h"
  22. #include "task.h"
  23. #include "main.h"
  24. #include "cmsis_os.h"
  25. /* Private includes ----------------------------------------------------------*/
  26. /* USER CODE BEGIN Includes */
  27. /* USER CODE END Includes */
  28. /* Private typedef -----------------------------------------------------------*/
  29. /* USER CODE BEGIN PTD */
  30. /* USER CODE END PTD */
  31. /* Private define ------------------------------------------------------------*/
  32. /* USER CODE BEGIN PD */
  33. /* USER CODE END PD */
  34. /* Private macro -------------------------------------------------------------*/
  35. /* USER CODE BEGIN PM */
  36. /* USER CODE END PM */
  37. /* Private variables ---------------------------------------------------------*/
  38. /* USER CODE BEGIN Variables */
  39. /* USER CODE END Variables */
  40. /* Definitions for app_main */
  41. osThreadId_t app_mainHandle;
  42. const osThreadAttr_t app_main_attributes = {
  43. .name = "app_main",
  44. .priority = (osPriority_t) osPriorityNormal,
  45. .stack_size = 1024 * 4
  46. };
  47. /* Private function prototypes -----------------------------------------------*/
  48. /* USER CODE BEGIN FunctionPrototypes */
  49. /* USER CODE END FunctionPrototypes */
  50. void app(void *argument);
  51. void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
  52. /* Hook prototypes */
  53. void configureTimerForRunTimeStats(void);
  54. unsigned long getRunTimeCounterValue(void);
  55. void vApplicationIdleHook(void);
  56. void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName);
  57. /* USER CODE BEGIN 1 */
  58. /* Functions needed when configGENERATE_RUN_TIME_STATS is on */
  59. __weak void configureTimerForRunTimeStats(void)
  60. {
  61. }
  62. __weak unsigned long getRunTimeCounterValue(void)
  63. {
  64. return 0;
  65. }
  66. /* USER CODE END 1 */
  67. /* USER CODE BEGIN 2 */
  68. void vApplicationIdleHook( void )
  69. {
  70. /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
  71. to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle
  72. task. It is essential that code added to this hook function never attempts
  73. to block in any way (for example, call xQueueReceive() with a block time
  74. specified, or call vTaskDelay()). If the application makes use of the
  75. vTaskDelete() API function (as this demo application does) then it is also
  76. important that vApplicationIdleHook() is permitted to return to its calling
  77. function, because it is the responsibility of the idle task to clean up
  78. memory allocated by the kernel to any task that has since been deleted. */
  79. }
  80. /* USER CODE END 2 */
  81. /* USER CODE BEGIN 4 */
  82. void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName)
  83. {
  84. /* Run time stack overflow checking is performed if
  85. configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is
  86. called if a stack overflow is detected. */
  87. }
  88. /* USER CODE END 4 */
  89. /* USER CODE BEGIN VPORT_SUPPORT_TICKS_AND_SLEEP */
  90. __weak void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )
  91. {
  92. // Generated when configUSE_TICKLESS_IDLE == 2.
  93. // Function called in tasks.c (in portTASK_FUNCTION).
  94. // TO BE COMPLETED or TO BE REPLACED by a user one, overriding that weak one.
  95. }
  96. /* USER CODE END VPORT_SUPPORT_TICKS_AND_SLEEP */
  97. /**
  98. * @brief FreeRTOS initialization
  99. * @param None
  100. * @retval None
  101. */
  102. void MX_FREERTOS_Init(void) {
  103. /* USER CODE BEGIN Init */
  104. /* USER CODE END Init */
  105. /* USER CODE BEGIN RTOS_MUTEX */
  106. /* add mutexes, ... */
  107. /* USER CODE END RTOS_MUTEX */
  108. /* USER CODE BEGIN RTOS_SEMAPHORES */
  109. /* add semaphores, ... */
  110. /* USER CODE END RTOS_SEMAPHORES */
  111. /* USER CODE BEGIN RTOS_TIMERS */
  112. /* start timers, add new ones, ... */
  113. /* USER CODE END RTOS_TIMERS */
  114. /* USER CODE BEGIN RTOS_QUEUES */
  115. /* add queues, ... */
  116. /* USER CODE END RTOS_QUEUES */
  117. /* Create the thread(s) */
  118. /* creation of app_main */
  119. app_mainHandle = osThreadNew(app, NULL, &app_main_attributes);
  120. /* USER CODE BEGIN RTOS_THREADS */
  121. /* add threads, ... */
  122. /* USER CODE END RTOS_THREADS */
  123. /* USER CODE BEGIN RTOS_EVENTS */
  124. /* add events, ... */
  125. /* USER CODE END RTOS_EVENTS */
  126. }
  127. /* USER CODE BEGIN Header_app */
  128. /**
  129. * @brief Function implementing the app_main thread.
  130. * @param argument: Not used
  131. * @retval None
  132. */
  133. /* USER CODE END Header_app */
  134. __weak void app(void *argument)
  135. {
  136. /* USER CODE BEGIN app */
  137. /* Infinite loop */
  138. for(;;)
  139. {
  140. osDelay(1);
  141. }
  142. /* USER CODE END app */
  143. }
  144. /* Private application code --------------------------------------------------*/
  145. /* USER CODE BEGIN Application */
  146. /* USER CODE END Application */
  147. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/