From 3fcef59348353fb505692a56af5d18101a8b551d Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Fri, 18 Sep 2026 16:50:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E6=9C=BA=E5=8F=AA=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/paint_robot_new/paint_robot_new_motors.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/project/paint_robot_new/paint_robot_new_motors.c b/project/paint_robot_new/paint_robot_new_motors.c index 985d6b6..0a1689a 100644 --- a/project/paint_robot_new/paint_robot_new_motors.c +++ b/project/paint_robot_new/paint_robot_new_motors.c @@ -46,6 +46,7 @@ static uint32_t g_uiMotorModuleID = 0; static int g_aiMotorSpeed[MOTOR_INSTANCE_MAX] = {0}; static int g_isMotorInit = -1; // -1表示还在等待遥控器初始化完毕,0表示可以进行电机初始化,1表示电机初始化完毕,运行电机主循环 static int g_iLastVehicleMove = 0; +static int g_iInitOnce = 0; // 防止重复初始化标志 /*----------------------------------------------* * 常量定义 * @@ -195,7 +196,7 @@ void MotorTask(void *argument) // 处理消息 MsgCenter_ProcessWait(g_uiMotorModuleID, 2); - if (0 == g_isMotorInit) + if (0 == g_isMotorInit && 0 == g_iInitOnce) { HAL_GPIO_WritePin(OUT_0_GPIO_Port, OUT_0_Pin, 0); // 初始化FDCAN1,使用雷赛电机的回调 @@ -243,6 +244,7 @@ void MotorTask(void *argument) MotorMgr_SpeedModeInit(g_apstMotors[0]); MotorMgr_SpeedModeInit(g_apstMotors[1]); g_isMotorInit = 1; + g_iInitOnce = 1; } else if (g_isMotorInit > 0) {