Refactor shell task creation

- Removed the shell task handle from app.c as it is no longer needed.
- Moved the shell task creation to shell_port.c with updated parameters.
- Ensured the shell task is created with appropriate stack size and priority.
This commit is contained in:
xushenghao 2025-09-10 00:41:42 +08:00
parent c3b9daba20
commit 9f37c7d763
3 changed files with 2544 additions and 2550 deletions

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,6 @@
#include "shell_port.h" #include "shell_port.h"
static TaskHandle_t business_task_handle = NULL; static TaskHandle_t business_task_handle = NULL;
static TaskHandle_t shell_task_handle = NULL;
void business_task(void *pvParameters) void business_task(void *pvParameters)
{ {
@ -29,12 +28,4 @@ void app_init(void)
(void *)NULL, // 任务入口函数参数 (void *)NULL, // 任务入口函数参数
(UBaseType_t)1, // 任务优先级 (UBaseType_t)1, // 任务优先级
(TaskHandle_t *)&business_task_handle); // 任务句柄 (TaskHandle_t *)&business_task_handle); // 任务句柄
extern Shell shell;
xTaskCreate((TaskFunction_t)shellTask, // 任务入口函数
(const char *)"shell_task", // 任务名字
(uint16_t)1024, // 任务栈大小
(void *)&shell, // 任务入口函数参数(传递 shell 对象指针)
(UBaseType_t)1, // 任务优先级
(TaskHandle_t *)&shell_task_handle); // 任务句柄
} }

View File

@ -108,10 +108,13 @@ void userShellInit(void)
// 启动串口中断接收 // 启动串口中断接收
HAL_UART_Receive_IT(&huart1, &shell_uart_rx_temp, 1); HAL_UART_Receive_IT(&huart1, &shell_uart_rx_temp, 1);
// if (xTaskCreate(shellTask, "shell", 256, &shell, 5, NULL) != pdPASS)
// { xTaskCreate((TaskFunction_t)shellTask, // 任务入口函数
//// logError("shell task creat failed"); (const char *)"shell_task", // 任务名字
// } (uint16_t)1024, // 任务栈大小
(void *)&shell, // 任务入口函数参数(传递 shell 对象指针)
(UBaseType_t)1, // 任务优先级
NULL); // 任务句柄
} }
// 串口接收完成回调(在 usart.c 里实现也可) // 串口接收完成回调(在 usart.c 里实现也可)