This commit is contained in:
2025-09-15 15:15:26 +08:00
parent 7dc8f7c6d7
commit f296a8eb48
5 changed files with 165 additions and 130 deletions
@@ -335,10 +335,21 @@ void Motor_SetDirection(uint8_t dir) {
}
uint8_t KeyASta;
uint8_t KeyBSta;
uint8_t RunSta;
// 电机控制接口
void Motor_Control(MotorCommand cmd) {
g_motorCmd = cmd;
if(cmd == MOTOR_CMD_REVERSE)
KeyASta =true;
else if(cmd == MOTOR_CMD_FORWARD)
KeyBSta = true;
else
{
KeyASta = false;
KeyBSta = false;
}
}
// 获取电机当前方向
@@ -388,9 +399,7 @@ void Dcmotor1msRoutine(void)
uint8_t KeyASta;
uint8_t KeyBSta;
uint8_t RunSta;
void DcmotorLoopHandler(void)
{
@@ -418,7 +427,7 @@ void DcmotorLoopHandler(void)
{
RunSta = true;
Timer61B_Init();
g_motorSpeed = 8000;
g_motorSpeed = 9500;
Timer6_SetGeneralCmpValue(M4_TMR61, Timer6GenCompareA, g_motorSpeed);
Timer6_SetGeneralCmpValue(M4_TMR61, Timer6GenCompareC, g_motorSpeed);
Timer6_StartCount(M4_TMR61);
@@ -430,7 +439,7 @@ void DcmotorLoopHandler(void)
{
RunSta = true;
Timer61A_Init();
g_motorSpeed = 8000;
g_motorSpeed = 9500;
Timer6_SetGeneralCmpValue(M4_TMR61, Timer6GenCompareA, g_motorSpeed);
Timer6_SetGeneralCmpValue(M4_TMR61, Timer6GenCompareC, g_motorSpeed);
Timer6_StartCount(M4_TMR61);