31 lines
590 B
C
31 lines
590 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(STEP_MOTOR *param){
|
|
|
|
BSP_PWM_Start(BSP_PWM_MOTOR_STEP);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int8_t Motor_Step_Ctrl(STEP_MOTOR *param){
|
|
|
|
// if(param->state==1){
|
|
/* 控制方向 */
|
|
BSP_GPIO_WritePin(BSP_GPIO_DIR_P, param->direction);
|
|
osDelay(10); // 方向稳定时间
|
|
// for(int i;i<10000;i++){
|
|
BSP_PWM_SetComp(BSP_PWM_MOTOR_STEP,19999);
|
|
// osDelay(200);
|
|
// BSP_PWM_SetComp(BSP_PWM_STEP_MOTOR,0);
|
|
// osDelay(200);
|
|
// }
|
|
return 0;
|
|
}
|
|
|
|
|