38 lines
790 B
C
38 lines
790 B
C
/* 底盘固定模组,用步进 */
|
|
#include "main.h"
|
|
#include "bsp/pwm.h"
|
|
#include "motor_step.h"
|
|
#include "bsp/gpio.h"
|
|
#include "cmsis_os2.h"
|
|
|
|
int8_t Motor_Step_Init(MOTOR_STEP_t *motor_step){
|
|
|
|
BSP_PWM_Start(motor_step->param.channel);
|
|
return 0;
|
|
}
|
|
|
|
int8_t Motor_Step_Ctrl(MOTOR_STEP_t *motor_step){
|
|
|
|
/* 控制方向 */
|
|
if(motor_step->param.reverse==true){
|
|
BSP_GPIO_WritePin(BSP_GPIO_DIR_P, true);
|
|
BSP_PWM_SetComp(motor_step->param.channel,0.5);
|
|
}
|
|
|
|
if(motor_step->param.reverse==false){
|
|
BSP_GPIO_WritePin(BSP_GPIO_DIR_P, true);
|
|
|
|
BSP_PWM_SetComp(motor_step->param.channel,0.9);
|
|
// osDelay(100);
|
|
// BSP_PWM_SetComp(motor_step->param.channel,0);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int8_t Motor_Step_Stop(MOTOR_STEP_t *motor_step){
|
|
|
|
BSP_PWM_Stop(motor_step->param.channel) ;
|
|
return 0;
|
|
}
|
|
|