/**
* @brief Starts or Stops the stepper motor
* @param NewState: This parameter can be ENABLE or DISABLE.
* @retval : None
*/
void Stepper_Start(FunctionalState NewState)
{
if(NewState == ENABLE)
{
/* Set the C.09 pin */
GPIO_SetBits(GPIOC, GPIO_Pin_9);
}
else
{
/* Reset the C.09 pin */
GPIO_ResetBits(GPIOC, GPIO_Pin_9);
}
}
/**
* @brief Disables the initialization of the driver to its default reset value
* @param None
* @retval : None
*/
void Stepper_ResetDisable(void)
{
/* Set the C.05pin */
GPIO_SetBits(GPIOC, GPIO_Pin_5);
}
/**
* @brief Selects the direction of the rotation
* @param Stepper_RotationDirection: Specifies the rotation direction
* This parameter can be one of the following values:
* @arg Stepper_RotationDirection_CW : sets clockwise direction
* @arg Stepper_RotationDirection_CCW: sets counterclockwise direction
*
* @retval : None
*/
void Stepper_SetRotationDirection(uint16_t Stepper_RotationDirection)
{
if(Stepper_RotationDirection == Stepper_RotationDirection_CW )
{
/* Set the C.06 pin */
GPIO_SetBits(GPIOC, GPIO_Pin_6);
}
else
{
/* Reset the C.06 pin */
GPIO_ResetBits(GPIOC, GPIO_Pin_6);
}
}
/**
* @brief Selects the step mode
* @param Stepper_Mode: Specifies the Step Mode
* This parameter can be one of the following values:
* @param Stepper_Full : Sets FULL STEP Mode
* @param Stepper_Half : Sets HALF STEP Mode
*
* @retval : None
*/
void Stepper_SelectMode(uint16_t Stepper_Mode)
{
if(Stepper_Mode == Stepper_Full)
{
/* Reset the C.07 pin */
GPIO_ResetBits(GPIOC, GPIO_Pin_7);
}
else
{
/* Set the C.07 pin */
GPIO_SetBits(GPIOC, GPIO_Pin_7);
}
}
/**
* @brief Selects the decay mode
* @param StepperControlMode: Specifies the Decay Mode
* This parameter can be one of the following values:
* @param Stepper_ControlFast : Sets FAST DECAY Mode
* @param Stepper_ControlSlow : Sets SLOW DECAY Mode
*
* @retval : None
*/
void Stepper_SetControlMode(uint16_t Stepper_ControlMode)
{
if(Stepper_ControlMode == Stepper_ControlFast)
{
/* Reset the C.08 pin */
GPIO_ResetBits(GPIOC, GPIO_Pin_8);
}
else
{
/* Set the C.08 pin */
GPIO_SetBits(GPIOC, GPIO_Pin_8);
}
}
/**
* @brief Activates or Desactivates the driver
* @param NewState: This parameter can be ENABLE or DISABLE.
* @retval : None
*/
void Stepper_Cmd(FunctionalState NewState)
{
if(NewState == ENABLE)
{
/* TIM2 clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
/* GPIOA clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
/* GPIOC clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
/* Enable DMA1 clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);