servo/firmware/Lib/motor/motor.c

23 lines
735 B
C
Raw Normal View History

#include "motor.h"
void start_motor_control(TIM_HandleTypeDef *htim, uint32_t channel1, uint32_t channel2, uint32_t channel3)
{
HAL_TIM_PWM_Start(htim, channel1);
HAL_TIM_PWM_Start(htim, channel2);
HAL_TIM_PWM_Start(htim, channel3);
}
void stop_motor_control(TIM_HandleTypeDef *htim, uint32_t channel1, uint32_t channel2, uint32_t channel3)
{
HAL_TIM_PWM_Stop(htim, channel1);
HAL_TIM_PWM_Stop(htim, channel2);
HAL_TIM_PWM_Stop(htim, channel3);
}
void set_pwm(TIM_HandleTypeDef *htim, uint32_t phaseA, uint32_t phaseB, uint32_t phaseC)
{
__HAL_TIM_SET_COMPARE(htim, TIM_CHANNEL_1, phaseA);
__HAL_TIM_SET_COMPARE(htim, TIM_CHANNEL_2, phaseB);
__HAL_TIM_SET_COMPARE(htim, TIM_CHANNEL_3, phaseC);
}