diff --git a/Core/Inc/FreeRTOSConfig.h b/Core/Inc/FreeRTOSConfig.h index 8457b6d..a9a3a57 100644 --- a/Core/Inc/FreeRTOSConfig.h +++ b/Core/Inc/FreeRTOSConfig.h @@ -69,7 +69,9 @@ #define configUSE_16_BIT_TICKS 0 #define configUSE_MUTEXES 1 #define configQUEUE_REGISTRY_SIZE 8 +#define configCHECK_FOR_STACK_OVERFLOW 1 #define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_MALLOC_FAILED_HOOK 1 #define configUSE_COUNTING_SEMAPHORES 1 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 #define configRECORD_STACK_HIGH_ADDRESS 1 @@ -83,6 +85,12 @@ #define configUSE_CO_ROUTINES 0 #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) +/* Software timer definitions. */ +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY ( 2 ) +#define configTIMER_QUEUE_LENGTH 10 +#define configTIMER_TASK_STACK_DEPTH 1024 + /* The following flag must be enabled only when using newlib */ #define configUSE_NEWLIB_REENTRANT 1 diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c index 677d3be..afdb21d 100644 --- a/Core/Src/freertos.c +++ b/Core/Src/freertos.c @@ -61,6 +61,38 @@ void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */ /* GetIdleTaskMemory prototype (linked to static allocation support) */ void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); +/* GetTimerTaskMemory prototype (linked to static allocation support) */ +void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ); + +/* Hook prototypes */ +void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName); +void vApplicationMallocFailedHook(void); + +/* USER CODE BEGIN 4 */ +__weak void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName) +{ + /* Run time stack overflow checking is performed if + configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is + called if a stack overflow is detected. */ +} +/* USER CODE END 4 */ + +/* USER CODE BEGIN 5 */ +__weak void vApplicationMallocFailedHook(void) +{ + /* vApplicationMallocFailedHook() will only be called if + configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook + function that will get called if a call to pvPortMalloc() fails. + pvPortMalloc() is called internally by the kernel whenever a task, queue, + timer or semaphore is created. It is also called by various parts of the + demo application. If heap_1.c or heap_2.c are used, then the size of the + heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in + FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used + to query the size of free heap space that remains (although it does not + provide information on how the remaining heap might be fragmented). */ +} +/* USER CODE END 5 */ + /* USER CODE BEGIN GET_IDLE_TASK_MEMORY */ static StaticTask_t xIdleTaskTCBBuffer; static StackType_t xIdleStack[configMINIMAL_STACK_SIZE]; @@ -74,6 +106,19 @@ void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackTy } /* USER CODE END GET_IDLE_TASK_MEMORY */ +/* USER CODE BEGIN GET_TIMER_TASK_MEMORY */ +static StaticTask_t xTimerTaskTCBBuffer; +static StackType_t xTimerStack[configTIMER_TASK_STACK_DEPTH]; + +void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ) +{ + *ppxTimerTaskTCBBuffer = &xTimerTaskTCBBuffer; + *ppxTimerTaskStackBuffer = &xTimerStack[0]; + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; + /* place for user code */ +} +/* USER CODE END GET_TIMER_TASK_MEMORY */ + /** * @brief FreeRTOS initialization * @param None diff --git a/Core/Src/main.c b/Core/Src/main.c index 713e70c..c3d43c8 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -228,8 +228,10 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ +extern void SysMgr_on_Error_Handler(); /* User can add his own implementation to report the HAL error return state */ __disable_irq(); + SysMgr_on_Error_Handler(); while (1) { } @@ -247,8 +249,10 @@ void Error_Handler(void) void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ +extern void SysMgr_on_assert_failed(uint8_t* file, uint32_t line) ; /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ + SysMgr_on_assert_failed(file, line); /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */ diff --git a/Core/Src/stm32f4xx_it.c b/Core/Src/stm32f4xx_it.c index f95b454..83dd03d 100644 --- a/Core/Src/stm32f4xx_it.c +++ b/Core/Src/stm32f4xx_it.c @@ -64,7 +64,11 @@ extern UART_HandleTypeDef huart3; extern TIM_HandleTypeDef htim11; /* USER CODE BEGIN EV */ - +void SysMgr_on_NMI_Handler(void); +void SysMgr_on_HardFault_Handler(void); +void SysMgr_on_MemManage_Handler(void); +void SysMgr_on_BusFault_Handler(void); +void SysMgr_on_UsageFault_Handler(void); /* USER CODE END EV */ /******************************************************************************/ @@ -76,7 +80,7 @@ extern TIM_HandleTypeDef htim11; void NMI_Handler(void) { /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - + SysMgr_on_NMI_Handler(); /* USER CODE END NonMaskableInt_IRQn 0 */ /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ while (1) @@ -91,7 +95,7 @@ void NMI_Handler(void) void HardFault_Handler(void) { /* USER CODE BEGIN HardFault_IRQn 0 */ - + SysMgr_on_HardFault_Handler(); /* USER CODE END HardFault_IRQn 0 */ while (1) { @@ -106,7 +110,7 @@ void HardFault_Handler(void) void MemManage_Handler(void) { /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - + SysMgr_on_MemManage_Handler(); /* USER CODE END MemoryManagement_IRQn 0 */ while (1) { @@ -121,7 +125,7 @@ void MemManage_Handler(void) void BusFault_Handler(void) { /* USER CODE BEGIN BusFault_IRQn 0 */ - + SysMgr_on_BusFault_Handler(); /* USER CODE END BusFault_IRQn 0 */ while (1) { @@ -136,7 +140,7 @@ void BusFault_Handler(void) void UsageFault_Handler(void) { /* USER CODE BEGIN UsageFault_IRQn 0 */ - + SysMgr_on_UsageFault_Handler(); /* USER CODE END UsageFault_IRQn 0 */ while (1) { diff --git a/dbdb_liquid_path_control_v2.ioc b/dbdb_liquid_path_control_v2.ioc index 34095b8..1774ac1 100644 --- a/dbdb_liquid_path_control_v2.ioc +++ b/dbdb_liquid_path_control_v2.ioc @@ -39,15 +39,18 @@ Dma.USART3_TX.1.Priority=DMA_PRIORITY_LOW Dma.USART3_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode FREERTOS.FootprintOK=true FREERTOS.INCLUDE_uxTaskGetStackHighWaterMark=1 -FREERTOS.IPParameters=Tasks01,FootprintOK,configUSE_NEWLIB_REENTRANT,configUSE_RECURSIVE_MUTEXES,configUSE_COUNTING_SEMAPHORES,configRECORD_STACK_HIGH_ADDRESS,configENABLE_FPU,configTOTAL_HEAP_SIZE,configMINIMAL_STACK_SIZE,INCLUDE_uxTaskGetStackHighWaterMark +FREERTOS.IPParameters=Tasks01,FootprintOK,configUSE_NEWLIB_REENTRANT,configUSE_RECURSIVE_MUTEXES,configUSE_COUNTING_SEMAPHORES,configRECORD_STACK_HIGH_ADDRESS,configENABLE_FPU,configTOTAL_HEAP_SIZE,configMINIMAL_STACK_SIZE,INCLUDE_uxTaskGetStackHighWaterMark,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,configUSE_TIMERS FREERTOS.Tasks01=defaultTask,-3,1024,StartDefaultTask,As weak,NULL,Dynamic,NULL,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=1 FREERTOS.configENABLE_FPU=1 FREERTOS.configMINIMAL_STACK_SIZE=512 FREERTOS.configRECORD_STACK_HIGH_ADDRESS=1 FREERTOS.configTOTAL_HEAP_SIZE=30000 FREERTOS.configUSE_COUNTING_SEMAPHORES=1 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 FREERTOS.configUSE_NEWLIB_REENTRANT=1 FREERTOS.configUSE_RECURSIVE_MUTEXES=1 +FREERTOS.configUSE_TIMERS=1 File.Version=6 GPIO.groupedBy=Group By Peripherals KeepUserPlacement=false