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: