Merge pull request '1、修改电机驱动PWM源为TIMER4 U;启用缓启动缓停止。' (#4) from Motor_Test into 算法控制

Reviewed-on: http://192.168.2.47:8418/GXJT/HC32F460/pulls/4
This commit is contained in:
cui635
2025-09-15 16:24:39 +08:00
7 changed files with 366 additions and 73 deletions
+40 -2
View File
@@ -7,6 +7,7 @@
#include "Debug.h"
#include "main.h"
#include "bsp.h"
#include "dc_motor.h"
#if (USE_DEBUG != 0)
#define DEBUG_CMD_CNT 8
@@ -213,6 +214,7 @@ void DebugCmdHelp(int argc, char *argv[])
DBG_LOG("Debug Cmd:\r\n\
disp task on/off -->Open the task display.\r\n\
help\
dcmotor\
");
}
@@ -265,13 +267,49 @@ void DebugCmdHelp(int argc, char *argv[])
// TimeSync(num);
//}
extern uint8_t KeyASta;
extern uint8_t KeyBSta;
extern uint8_t RunSta;
void MotorSwitch(int argc, char *argv[])
{
// 如果参数个数小于2,则返回
if(argc < 2)
return;
// 如果第一个参数为?,则打印帮助信息
if(strcmp(argv[1], "?") == 0)
{
DBG_LOG("DCMotor Cmd:\r\n\
motor F/R/S -->Turn the motor on or off.\r\n");
return;
}
// 如果第一个参数为on,则开启SonarWork
if(strcmp(argv[1], "R") == 0)
{
KeyASta = true;
Motor_Control(MOTOR_CMD_REVERSE);
DBG_LOG("Motor FORWARD\r\n");
}
// 如果第一个参数为off,则关闭SonarWork
else if(strcmp(argv[1], "F") == 0)
{
KeyBSta = true;
Motor_Control(MOTOR_CMD_FORWARD);
DBG_LOG("Motor REVERSE\r\n");
}
else if(strcmp(argv[1], "S") == 0)
{
KeyASta = false;
KeyBSta = false;
Motor_Control(MOTOR_CMD_STOP);
DBG_LOG("Motor OFF\r\n");
}
}
const DBGFunType DebugFun[DEBUG_CMD_CNT] = {
"help", DebugCmdHelp,
// "TimeSync", (void*)TimeSync,
// "SetTime", SetTime,
"motor", MotorSwitch,
};
#endif