You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
6.4 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * File Name : freertos.c
  5. * Description : Code for freertos applications
  6. ******************************************************************************
  7. * This notice applies to any and all portions of this file
  8. * that are not between comment pairs USER CODE BEGIN and
  9. * USER CODE END. Other portions of this file, whether
  10. * inserted by the user or by software development tools
  11. * are owned by their respective copyright owners.
  12. *
  13. * Copyright (c) 2019 STMicroelectronics International N.V.
  14. * All rights reserved.
  15. *
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted, provided that the following conditions are met:
  18. *
  19. * 1. Redistribution of source code must retain the above copyright notice,
  20. * this list of conditions and the following disclaimer.
  21. * 2. Redistributions in binary form must reproduce the above copyright notice,
  22. * this list of conditions and the following disclaimer in the documentation
  23. * and/or other materials provided with the distribution.
  24. * 3. Neither the name of STMicroelectronics nor the names of other
  25. * contributors to this software may be used to endorse or promote products
  26. * derived from this software without specific written permission.
  27. * 4. This software, including modifications and/or derivative works of this
  28. * software, must execute solely and exclusively on microcontroller or
  29. * microprocessor devices manufactured by or for STMicroelectronics.
  30. * 5. Redistribution and use of this software other than as permitted under
  31. * this license is void and will automatically terminate your rights under
  32. * this license.
  33. *
  34. * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
  35. * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
  36. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  37. * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
  38. * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
  39. * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  40. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  42. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  43. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  44. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  45. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  46. *
  47. ******************************************************************************
  48. */
  49. /* USER CODE END Header */
  50. /* Includes ------------------------------------------------------------------*/
  51. #include "FreeRTOS.h"
  52. #include "task.h"
  53. #include "main.h"
  54. #include "cmsis_os.h"
  55. /* Private includes ----------------------------------------------------------*/
  56. /* USER CODE BEGIN Includes */
  57. /* USER CODE END Includes */
  58. /* Private typedef -----------------------------------------------------------*/
  59. /* USER CODE BEGIN PTD */
  60. /* USER CODE END PTD */
  61. /* Private define ------------------------------------------------------------*/
  62. /* USER CODE BEGIN PD */
  63. /* USER CODE END PD */
  64. /* Private macro -------------------------------------------------------------*/
  65. /* USER CODE BEGIN PM */
  66. /* USER CODE END PM */
  67. /* Private variables ---------------------------------------------------------*/
  68. /* USER CODE BEGIN Variables */
  69. osThreadId mainTaskHandle;
  70. /* USER CODE END Variables */
  71. osThreadId defaultTaskHandle;
  72. /* Private function prototypes -----------------------------------------------*/
  73. /* USER CODE BEGIN FunctionPrototypes */
  74. void StartMainTask(void const * argument);
  75. /* USER CODE END FunctionPrototypes */
  76. void StartDefaultTask(void const * argument);
  77. extern void MX_LWIP_Init(void);
  78. void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
  79. /* GetIdleTaskMemory prototype (linked to static allocation support) */
  80. void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize );
  81. /* USER CODE BEGIN GET_IDLE_TASK_MEMORY */
  82. static StaticTask_t xIdleTaskTCBBuffer;
  83. static StackType_t xIdleStack[configMINIMAL_STACK_SIZE];
  84. void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )
  85. {
  86. *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer;
  87. *ppxIdleTaskStackBuffer = &xIdleStack[0];
  88. *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
  89. /* place for user code */
  90. }
  91. /* USER CODE END GET_IDLE_TASK_MEMORY */
  92. /**
  93. * @brief FreeRTOS initialization
  94. * @param None
  95. * @retval None
  96. */
  97. void MX_FREERTOS_Init(void) {
  98. /* USER CODE BEGIN Init */
  99. /* USER CODE END Init */
  100. /* USER CODE BEGIN RTOS_MUTEX */
  101. /* add mutexes, ... */
  102. /* USER CODE END RTOS_MUTEX */
  103. /* USER CODE BEGIN RTOS_SEMAPHORES */
  104. /* add semaphores, ... */
  105. /* USER CODE END RTOS_SEMAPHORES */
  106. /* USER CODE BEGIN RTOS_TIMERS */
  107. /* start timers, add new ones, ... */
  108. /* USER CODE END RTOS_TIMERS */
  109. /* USER CODE BEGIN RTOS_QUEUES */
  110. /* add queues, ... */
  111. /* USER CODE END RTOS_QUEUES */
  112. /* Create the thread(s) */
  113. /* definition and creation of defaultTask */
  114. osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
  115. defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
  116. /* USER CODE BEGIN RTOS_THREADS */
  117. /* add threads, ... */
  118. /* USER CODE END RTOS_THREADS */
  119. }
  120. /* USER CODE BEGIN Header_StartDefaultTask */
  121. /**
  122. * @brief Function implementing the defaultTask thread.
  123. * @param argument: Not used
  124. * @retval None
  125. */
  126. /* USER CODE END Header_StartDefaultTask */
  127. void StartDefaultTask(void const * argument)
  128. {
  129. /* init code for LWIP */
  130. MX_LWIP_Init();
  131. /* USER CODE BEGIN StartDefaultTask */
  132. osThreadDef(mainTask, StartMainTask, osPriorityNormal, 0, 1024);
  133. mainTaskHandle = osThreadCreate(osThread(mainTask), NULL);
  134. /* Infinite loop */
  135. for(;;)
  136. {
  137. osDelay(1);
  138. }
  139. /* USER CODE END StartDefaultTask */
  140. }
  141. /* Private application code --------------------------------------------------*/
  142. /* USER CODE BEGIN Application */
  143. void StartMainTask(void const * argument)
  144. {
  145. extern void user_main();
  146. user_main();
  147. }
  148. /* USER CODE END Application */