diff --git a/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp b/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp index 4bab63a..00cea79 100644 --- a/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp +++ b/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp @@ -386,7 +386,7 @@ int32_t StepMotorCtrlModule::exec_move_to_zero_task() { xreach_zero = true; _motor_stop(-1); - while (!m_stepM1->isStoped()) { // 等待电机停止 + while (!m_stepM1->isStoped() && !m_thread.getExitFlag()) { // 等待电机停止 _motor_stop(-1); vTaskDelay(10); } @@ -417,6 +417,9 @@ int32_t StepMotorCtrlModule::exec_move_to_zero_task() { if (m_thread.getExitFlag()) break; if (!m_Xgpio->getState()) { _motor_stop(-1); + while (!m_stepM1->isStoped() && !m_thread.getExitFlag()) { // 等待电机停止 + vTaskDelay(1); + } break; } vTaskDelay(1); @@ -432,6 +435,7 @@ int32_t StepMotorCtrlModule::exec_move_to_zero_task() { return err::kxymotor_x_find_zero_edge_fail; } } + if (m_thread.getExitFlag()) { ZLOGI(TAG, "break move to zero thread exit"); return 0;