freertos.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. /* Private includes ----------------------------------------------------------*/
  24. /* USER CODE BEGIN Includes */
  25. /* USER CODE END Includes */
  26. /* Private typedef -----------------------------------------------------------*/
  27. /* USER CODE BEGIN PTD */
  28. /* USER CODE END PTD */
  29. /* Private define ------------------------------------------------------------*/
  30. /* USER CODE BEGIN PD */
  31. /* USER CODE END PD */
  32. /* Private macro -------------------------------------------------------------*/
  33. /* USER CODE BEGIN PM */
  34. /* USER CODE END PM */
  35. /* Private variables ---------------------------------------------------------*/
  36. /* USER CODE BEGIN Variables */
  37. /* USER CODE END Variables */
  38. /* Private function prototypes -----------------------------------------------*/
  39. /* USER CODE BEGIN FunctionPrototypes */
  40. /* USER CODE END FunctionPrototypes */
  41. /* GetIdleTaskMemory prototype (linked to static allocation support) */
  42. void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize );
  43. /* Hook prototypes */
  44. void vApplicationIdleHook(void);
  45. void vApplicationMallocFailedHook(void);
  46. /* USER CODE BEGIN 2 */
  47. __weak void vApplicationIdleHook( void )
  48. {
  49. /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
  50. to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle
  51. task. It is essential that code added to this hook function never attempts
  52. to block in any way (for example, call xQueueReceive() with a block time
  53. specified, or call vTaskDelay()). If the application makes use of the
  54. vTaskDelete() API function (as this demo application does) then it is also
  55. important that vApplicationIdleHook() is permitted to return to its calling
  56. function, because it is the responsibility of the idle task to clean up
  57. memory allocated by the kernel to any task that has since been deleted. */
  58. }
  59. /* USER CODE END 2 */
  60. /* USER CODE BEGIN 5 */
  61. __weak void vApplicationMallocFailedHook(void)
  62. {
  63. /* vApplicationMallocFailedHook() will only be called if
  64. configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
  65. function that will get called if a call to pvPortMalloc() fails.
  66. pvPortMalloc() is called internally by the kernel whenever a task, queue,
  67. timer or semaphore is created. It is also called by various parts of the
  68. demo application. If heap_1.c or heap_2.c are used, then the size of the
  69. heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
  70. FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
  71. to query the size of free heap space that remains (although it does not
  72. provide information on how the remaining heap might be fragmented). */
  73. }
  74. /* USER CODE END 5 */
  75. /* USER CODE BEGIN GET_IDLE_TASK_MEMORY */
  76. static StaticTask_t xIdleTaskTCBBuffer;
  77. static StackType_t xIdleStack[configMINIMAL_STACK_SIZE];
  78. void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )
  79. {
  80. *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer;
  81. *ppxIdleTaskStackBuffer = &xIdleStack[0];
  82. *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
  83. /* place for user code */
  84. }
  85. /* USER CODE END GET_IDLE_TASK_MEMORY */
  86. /* Private application code --------------------------------------------------*/
  87. /* USER CODE BEGIN Application */
  88. /* USER CODE END Application */