From 00ad2af94d754ac4bae5f8ba0177837e2bbe99cc Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Wed, 23 Sep 2026 09:48:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=AD=E8=A8=80=E6=89=93?= =?UTF-8?q?=E5=8D=B0=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=90=8E=E5=81=9C=E8=BD=A6?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=B8=AD=E5=86=8D=E6=8C=89=E5=BC=80=E6=9E=AA?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E5=96=B7=E6=9E=AA=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E5=90=8E=E6=97=A0=E6=B3=95=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bspMCU/bsp_pin.c | 5 ++-- project/paint_robot_new/paint_robot_new.c | 32 +++++++++-------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/bspMCU/bsp_pin.c b/bspMCU/bsp_pin.c index 204a522..39cc2ac 100644 --- a/bspMCU/bsp_pin.c +++ b/bspMCU/bsp_pin.c @@ -50,11 +50,12 @@ void delay_us(int nus) void hard_fault_handler_c(unsigned int *hardfault_args) { + unsigned int stacked_lr = hardfault_args[5]; unsigned int stacked_pc = hardfault_args[6]; // 程序计数器 unsigned int stacked_psr = hardfault_args[7]; // 状态寄存器 uint32_t sp = (uint32_t)hardfault_args; // 打印寄存器现场 - log_a("====== HardFault Detected ======\nPC = 0x%08X, PSR= 0x%08X\nHFSR = 0x%08X\tCFSR = 0x%08X\nBFAR = 0x%08X\tMMFAR= 0x%08X\nsp = 0x%08X\n", - stacked_pc, stacked_psr, SCB->HFSR, SCB->CFSR, SCB->BFAR, SCB->MMFAR, sp); + log_a("====== HardFault Detected ======\nPSR= 0x%08X\nPC = 0x%08X, LR = 0x%08X\nHFSR = 0x%08X\tCFSR = 0x%08X\nBFAR = 0x%08X\tMMFAR= 0x%08X\nsp = 0x%08X\n", + stacked_psr, stacked_pc, stacked_lr, SCB->HFSR, SCB->CFSR, SCB->BFAR, SCB->MMFAR, sp); } diff --git a/project/paint_robot_new/paint_robot_new.c b/project/paint_robot_new/paint_robot_new.c index e6d3ada..99f4fad 100644 --- a/project/paint_robot_new/paint_robot_new.c +++ b/project/paint_robot_new/paint_robot_new.c @@ -50,7 +50,7 @@ static PV_struct_define g_stPV; static IV_struct_define g_stIV; static int g_Is_All_Button_Reset = 0; // 1表示按钮正常工作,0表示需要复位 static int g_ichangLineState = 0; // 换道状态,0表示起始状态,1表示第一次旋转完成,2表示计时行走 完成 -static int g_bNotTable = 0; +static int g_iRobot_Move_State = 0; // 机器人状态0表示默认,1表示调用TIMER_CMD_STRAIGHT_DRIVE static int g_iLeft_Compensation = 0; static int g_iRight_Compensation = 0; @@ -498,7 +498,7 @@ static void Move_Halt_AngleError(void) void MK32_Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode) { - if (0 == g_bNotTable) g_bNotTable = 1; + g_iRobot_Move_State = 0; // 急停 if (_pstMK32->CH8_SE == -1000 && _pstMK32->CH9_SF == -1000) { @@ -562,22 +562,6 @@ void MK32_Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode) MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_PAINTGUN, &g_stAngleError_Ctl.m_iPaintState, sizeof(int)); } } - else if(_iMode == 2 || _iMode == 3) - { - if (_pstMK32->CH13_S2 != g_iS2LastValue) - { - if(g_stIV.CurrentSpeed != 0) - { - g_stAngleError_Ctl.m_iPaintState = 0; - MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_PAINTGUN, &g_stAngleError_Ctl.m_iPaintState, sizeof(int)); - } - else - { - //log_w("cannot open paint with 0 move speed !"); - } - } - } - g_iS2LastValue = _pstMK32->CH13_S2; } int aiMotorSpeed[2] = {0}; //0索引表示左,1索引表示右,多轮时到对应motor的MOTOR_CMD_SET_SPEED命令自行处理 @@ -595,6 +579,8 @@ void MK32_Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode) } else if (_iMode == 2 || _iMode == 3) { + g_iRobot_Move_State = 1; + Robot_Paint_SP(); if (0 == g_stAngleError_Ctl.m_iAnglelock) { BHBF_straight_drive_Cmd stCmd = { @@ -621,6 +607,8 @@ void MK32_Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode) } else if (_iMode == 2 || _iMode == 3) { + g_iRobot_Move_State = 1; + Robot_Paint_SP(); if (0 == g_stAngleError_Ctl.m_iAnglelock) { BHBF_straight_drive_Cmd stCmd = { @@ -666,6 +654,8 @@ void MK32_Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode) } else if (_iMode == 2 || _iMode == 3) { + g_iRobot_Move_State = 1; + Robot_Paint_SP(); if (0 == g_stAngleError_Ctl.m_iAnglelock) { BHBF_straight_drive_Cmd stCmd = { @@ -691,6 +681,8 @@ void MK32_Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode) } else if (_iMode == 2 || _iMode == 3) { + g_iRobot_Move_State = 1; + Robot_Paint_SP(); if (0 == g_stAngleError_Ctl.m_iAnglelock) { BHBF_straight_drive_Cmd stCmd = { @@ -931,8 +923,8 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) lua_print("PV Info\n"); lua_print("{%d, %d, %d, %d, %d, %ld}\n", g_stPV.RunMode, g_stPV.RobotSpeed, g_stPV.LaneChangeDistance, (int)g_stPV.Vertical_Calibration, g_stPV.IV_IsRestart_Notified, (long long)g_stPV.TimeStamp); - lua_print("\niPaint = %d\ng_stAngleError_Ctl.m_iPaintState = %d\ng_stAngleError_Ctl.m_iAnglelock = %d\ng_stAngleError_Ctl.m_ipaintOffCount = %d\ng_Is_All_Button_Reset = %d\ng_bNotTable = %d\n", - g_iPaint, g_stAngleError_Ctl.m_iPaintState, g_stAngleError_Ctl.m_iAnglelock, g_stAngleError_Ctl.m_ipaintOffCount, g_Is_All_Button_Reset, g_bNotTable); + lua_print("\niPaint = %d\ng_stAngleError_Ctl.m_iPaintState = %d\ng_stAngleError_Ctl.m_iAnglelock = %d\ng_stAngleError_Ctl.m_ipaintOffCount = %d\ng_Is_All_Button_Reset = %d\n", + g_iPaint, g_stAngleError_Ctl.m_iPaintState, g_stAngleError_Ctl.m_iAnglelock, g_stAngleError_Ctl.m_ipaintOffCount, g_Is_All_Button_Reset); break; } default: