修复了servo类型定义错误

This commit is contained in:
NeoZng 2023-01-01 12:48:45 +08:00
parent 7e36f6a0cf
commit c2f8b5c8c3
2 changed files with 8 additions and 9 deletions

View File

@ -42,6 +42,7 @@ USARTInstance *USARTRegister(USART_Init_Config_s *init_config)
instance->module_callback = init_config->module_callback;
usart_instance[idx++] = instance;
USARTServiceInit(instance);
return instance;
}

View File

@ -83,32 +83,30 @@ void Servo_Motor_Type_Select(ServoInstance *Servo_Motor, int16_t mode)
void Servo_Motor_Control()
{
static ServoInstance *Servo_Motor;
static Servo_Type_e Servo_type;
for (size_t i = 0; i < servo_idx; i++)
{
if (servo_motor_instance[i])
{
Servo_Motor = servo_motor_instance[i];
Servo_type = Servo_Motor->Servo_type;
switch (Servo_type)
switch (Servo_Motor->Servo_type)
{
case Servo180:
if (Servo_Motor->Servo_type == Start_mode)
if (Servo_Motor->Servo_Angle_Type == Start_mode)
compare_value[i] = 0.5 * 20000 / 20 + Servo_Motor->Servo_Angle.Init_angle * 20000 / 20 / 90;
if (Servo_Motor->Servo_type == Final_mode)
if (Servo_Motor->Servo_Angle_Type == Final_mode)
compare_value[i] = 0.5 * 20000 / 20 + Servo_Motor->Servo_Angle.Final_angle * 20000 / 20 / 90;
if (Servo_Motor->Servo_type == Free_Angle_mode)
if (Servo_Motor->Servo_Angle_Type == Free_Angle_mode)
compare_value[i] = 0.5 * 20000 / 20 + Servo_Motor->Servo_Angle.free_angle * 20000 / 20 / 90;
__HAL_TIM_SET_COMPARE(Servo_Motor->htim, Servo_Motor->Channel, compare_value[i]);
break;
case Servo270:
if (Servo_Motor->Servo_type == Start_mode)
if (Servo_Motor->Servo_Angle_Type == Start_mode)
compare_value[i] = 0.5 * 20000 / 20 + Servo_Motor->Servo_Angle.Init_angle * 20000 / 20 / 135;
if (Servo_Motor->Servo_type == Final_mode)
if (Servo_Motor->Servo_Angle_Type == Final_mode)
compare_value[i] = 0.5 * 20000 / 20 + Servo_Motor->Servo_Angle.Final_angle * 20000 / 20 / 135;
if (Servo_Motor->Servo_type == Free_Angle_mode)
if (Servo_Motor->Servo_Angle_Type == Free_Angle_mode)
compare_value[i] = 0.5 * 20000 / 20 + Servo_Motor->Servo_Angle.free_angle * 20000 / 20 / 135;
__HAL_TIM_SET_COMPARE(Servo_Motor->htim, Servo_Motor->Channel, compare_value[i]);
break;