freertos.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * File Name : freertos.c
  5. * Description : Code for freertos applications
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2022 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. #include "RTC.h"
  28. #include "i2c.h"
  29. #include "Tab.h"
  30. /* USER CODE END Includes */
  31. /* Private typedef -----------------------------------------------------------*/
  32. /* USER CODE BEGIN PTD */
  33. /* USER CODE END PTD */
  34. /* Private define ------------------------------------------------------------*/
  35. /* USER CODE BEGIN PD */
  36. /* USER CODE END PD */
  37. /* Private macro -------------------------------------------------------------*/
  38. /* USER CODE BEGIN PM */
  39. /* USER CODE END PM */
  40. /* Private variables ---------------------------------------------------------*/
  41. /* USER CODE BEGIN Variables */
  42. extern Sortie tabSortie[NBLIGNEACTIVE];
  43. extern uint8_t gl_Stop;
  44. extern uint8_t gl_Essai;
  45. /* USER CODE END Variables */
  46. osThreadId PWMHandle;
  47. osThreadId DecodeHandle;
  48. osThreadId LedHandle;
  49. /* Private function prototypes -----------------------------------------------*/
  50. /* USER CODE BEGIN FunctionPrototypes */
  51. /* USER CODE END FunctionPrototypes */
  52. void PWMTask(void const * argument);
  53. void DecodeTask(void const * argument);
  54. void StartTask03(void const * argument);
  55. void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
  56. /* GetIdleTaskMemory prototype (linked to static allocation support) */
  57. void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize );
  58. /* USER CODE BEGIN GET_IDLE_TASK_MEMORY */
  59. static StaticTask_t xIdleTaskTCBBuffer;
  60. static StackType_t xIdleStack[configMINIMAL_STACK_SIZE];
  61. void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )
  62. {
  63. *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer;
  64. *ppxIdleTaskStackBuffer = &xIdleStack[0];
  65. *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
  66. /* place for user code */
  67. }
  68. /* USER CODE END GET_IDLE_TASK_MEMORY */
  69. /**
  70. * @brief FreeRTOS initialization
  71. * @param None
  72. * @retval None
  73. */
  74. void MX_FREERTOS_Init(void) {
  75. /* USER CODE BEGIN Init */
  76. initRTC(&hi2c3);
  77. /* USER CODE END Init */
  78. /* USER CODE BEGIN RTOS_MUTEX */
  79. /* add mutexes, ... */
  80. /* USER CODE END RTOS_MUTEX */
  81. /* USER CODE BEGIN RTOS_SEMAPHORES */
  82. /* add semaphores, ... */
  83. /* USER CODE END RTOS_SEMAPHORES */
  84. /* USER CODE BEGIN RTOS_TIMERS */
  85. /* start timers, add new ones, ... */
  86. /* USER CODE END RTOS_TIMERS */
  87. /* USER CODE BEGIN RTOS_QUEUES */
  88. /* add queues, ... */
  89. /* USER CODE END RTOS_QUEUES */
  90. /* Create the thread(s) */
  91. /* definition and creation of PWM */
  92. osThreadDef(PWM, PWMTask, osPriorityNormal, 0, 128);
  93. PWMHandle = osThreadCreate(osThread(PWM), NULL);
  94. /* definition and creation of Decode */
  95. osThreadDef(Decode, DecodeTask, osPriorityIdle, 0, 128);
  96. DecodeHandle = osThreadCreate(osThread(Decode), NULL);
  97. /* definition and creation of Led */
  98. osThreadDef(Led, StartTask03, osPriorityIdle, 0, 128);
  99. LedHandle = osThreadCreate(osThread(Led), NULL);
  100. /* USER CODE BEGIN RTOS_THREADS */
  101. /* add threads, ... */
  102. /* USER CODE END RTOS_THREADS */
  103. }
  104. /* USER CODE BEGIN Header_PWMTask */
  105. /**
  106. * @brief Function implementing the PWM thread.
  107. * @param argument: Not used
  108. * @retval None
  109. */
  110. /* USER CODE END Header_PWMTask */
  111. void PWMTask(void const * argument)
  112. {
  113. /* USER CODE BEGIN PWMTask */
  114. /* Infinite loop */
  115. for(;;)
  116. {
  117. osDelay(1);
  118. }
  119. /* USER CODE END PWMTask */
  120. }
  121. /* USER CODE BEGIN Header_DecodeTask */
  122. /**
  123. * @brief Function implementing the Decode thread.
  124. * @param argument: Not used
  125. * @retval None
  126. */
  127. /* USER CODE END Header_DecodeTask */
  128. void DecodeTask(void const * argument)
  129. {
  130. /* USER CODE BEGIN DecodeTask */
  131. /* Infinite loop */
  132. for(;;)
  133. {
  134. osDelay(1);
  135. }
  136. /* USER CODE END DecodeTask */
  137. }
  138. /* USER CODE BEGIN Header_StartTask03 */
  139. /**
  140. * @brief Function implementing the Led thread.
  141. * @param argument: Not used
  142. * @retval None
  143. */
  144. /* USER CODE END Header_StartTask03 */
  145. void StartTask03(void const * argument)
  146. {
  147. /* USER CODE BEGIN StartTask03 */
  148. /* Infinite loop */
  149. for(;;)
  150. {
  151. osDelay(1);
  152. }
  153. /* USER CODE END StartTask03 */
  154. }
  155. /* Private application code --------------------------------------------------*/
  156. /* USER CODE BEGIN Application */
  157. /* USER CODE END Application */
  158. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/