单片机解密DRV8825步进电机驱动芯片
单片机解密DRV8825步进电机驱动芯片的驱动程序,使用GD32E230控制。可以根据使用的MUC自行修改。
/*******************************************************************************
** 函数名称:STEP_MOTOR_RESET()
** 功能描述:步进电机复位函数
** 输 入:无
** 输 出:无
** 全局变量:
********************************************************************************/
void STEP_MOTOR_RESET(uint8_t NewState)
{
printf("\r\n STEPMOTOR_RESET!");
if(NewState)
{
GPIO_BC(GPIOB) = GPIO_PIN_3;
delay_1ms(5);
GPIO_BC(GPIOB) = GPIO_PIN_3;
delay_1ms(5);
}
else GPIO_BOP(GPIOB) = GPIO_PIN_3;
delay_1ms(100);
}
/*******************************************************************************
** 函数名称:STEP_MOTOR_DIR_F()
** 功能描述:步进电机旋转方向设置
** 输 入:Stepper_RotationDirection
** 输 出:无
** 全局变量:
** 调用模块:
********************************************************************************/
void STEP_MOTOR_DIR_F(uint8_t Stepper_RotationDirection)
{
switch (Stepper_RotationDirection)
{
case Stepper_Direction_CW:gpio_bit_set(GPIOA,GPIO_PIN_3);printf("\r\n STEPMOTOR_Direction_CW!");break ;
case Stepper_Direction_CCW:gpio_bit_reset(GPIOA,GPIO_PIN_3);printf("\r\n STEPMOTOR_Direction_CCW!");break ;
}
delay_1ms(3);
}

芯片解密