51 lines
658 B
C

#include "mw_motor.h"
#include "bsp_motor.h"
#include <stdint.h>
void mw_SetMotorSpeed_Left(int8_t Speed)
{
if (Speed >0)
{
bsp_AIN1_ON();
bsp_AIN2_OFF();
PWM_SetCompare3(Speed);
}
else if(Speed==0)
{
bsp_AIN1_ON();
bsp_AIN2_ON();
PWM_SetCompare3(Speed);
}
else
{
bsp_AIN1_OFF();
bsp_AIN2_ON();
PWM_SetCompare3(-Speed);
}
}
void Motor_SetRightSpeed(int8_t Speed)
{
if (Speed >0)
{
bsp_BIN1_ON();
bsp_BIN2_OFF();
PWM_SetCompare3(Speed);
}
else if(Speed==0)
{
bsp_BIN1_ON();
bsp_BIN2_ON();
PWM_SetCompare3(Speed);
}
else
{
bsp_BIN1_OFF();
bsp_BIN2_ON();
PWM_SetCompare3(-Speed);
}
}