33 lines
785 B
C
33 lines
785 B
C
/* 底盘固定模组,用步进 */
|
|
#include "main.h"
|
|
#include "step_motor.h"
|
|
#include "bsp/gpio.h"
|
|
#include "cmsis_os2.h"
|
|
|
|
|
|
|
|
int8_t Step_Motor_Ctrl(STEP_MOTOR *param){
|
|
|
|
// if(param->state==1){
|
|
/* 控制方向 */
|
|
BSP_GPIO_WritePin(BSP_GPIO_DIR_P, param->direction);
|
|
osDelay(10); // 方向稳定时间
|
|
// for(int i;i >= param->pulse;i++){
|
|
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_1, 1);
|
|
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_2, 0);
|
|
// BSP_GPIO_WritePin(BSP_GPIO_PUL_P,true);
|
|
// BSP_GPIO_WritePin(BSP_GPIO_PUL_N,false);
|
|
osDelay(param->time);
|
|
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_1, 1);
|
|
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_2, 0);
|
|
// BSP_GPIO_WritePin(BSP_GPIO_PUL_P,true);
|
|
// BSP_GPIO_WritePin(BSP_GPIO_PUL_N,false);
|
|
osDelay(param->time);
|
|
// }
|
|
// param->state=1;
|
|
//}
|
|
return 0;
|
|
}
|
|
|
|
|