rtc + stepper functioning version
This commit is contained in:
@@ -47,7 +47,9 @@
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
extern void BSP_MotorControl_StepClockHandler(uint8_t deviceId);
|
||||
extern void BSP_MotorControl_FlagInterruptHandler(void);
|
||||
extern void ButtonHandler(void);
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* External functions --------------------------------------------------------*/
|
||||
@@ -194,6 +196,115 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PWM MSP Initialization
|
||||
* @param[in] htim_pwm PWM handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
if(htim_pwm->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_TICK)
|
||||
{
|
||||
/* Peripheral clock enable */
|
||||
__BSP_MOTOR_CONTROL_BOARD_TIMER_TICK_CLCK_ENABLE();
|
||||
|
||||
/* Set Interrupt Group Priority of Timer Interrupt*/
|
||||
HAL_NVIC_SetPriority(BSP_MOTOR_CONTROL_BOARD_TIMER_TICK_IRQn, BSP_MOTOR_CONTROL_BOARD_TIMER_TICK_PRIORITY, 0);
|
||||
|
||||
/* Enable the timer global Interrupt */
|
||||
HAL_NVIC_EnableIRQ(BSP_MOTOR_CONTROL_BOARD_TIMER_TICK_IRQn);
|
||||
}
|
||||
if(htim_pwm->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_VREFA_PWM)
|
||||
{
|
||||
/* Peripheral clock enable */
|
||||
__BSP_MOTOR_CONTROL_BOARD_TIMER_VREFA_PWM_CLCK_ENABLE();
|
||||
|
||||
/* Configure L6208 - VREFA pin -------------------------------------*/
|
||||
GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_VREFA_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
|
||||
GPIO_InitStruct.Alternate = BSP_MOTOR_CONTROL_BOARD_AFx_TIMx_VREFA_PWM;
|
||||
HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_VREFA_PORT, &GPIO_InitStruct);
|
||||
}
|
||||
if(htim_pwm->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_VREFB_PWM)
|
||||
{
|
||||
/* Peripheral clock enable */
|
||||
__BSP_MOTOR_CONTROL_BOARD_TIMER_VREFB_PWM_CLCK_ENABLE();
|
||||
|
||||
/* Configure L6208 - VREFB pin -------------------------------------*/
|
||||
GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_VREFB_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
|
||||
GPIO_InitStruct.Alternate = BSP_MOTOR_CONTROL_BOARD_AFx_TIMx_VREFB_PWM;
|
||||
HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_VREFB_PORT, &GPIO_InitStruct);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PWM MSP De-Initialization
|
||||
* @param[in] htim_pwm PWM handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm)
|
||||
{
|
||||
if(htim_pwm->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_TICK)
|
||||
{
|
||||
/* Peripheral clock disable */
|
||||
__BSP_MOTOR_CONTROL_BOARD_TIMER_TICK_CLCK_DISABLE();
|
||||
}
|
||||
if(htim_pwm->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_VREFA_PWM)
|
||||
{
|
||||
/* Peripheral clock disable */
|
||||
__BSP_MOTOR_CONTROL_BOARD_TIMER_VREFA_PWM_CLCK_DISABLE();
|
||||
/* GPIO Deconfiguration */
|
||||
HAL_GPIO_DeInit(BSP_MOTOR_CONTROL_BOARD_VREFA_PORT, BSP_MOTOR_CONTROL_BOARD_VREFA_PIN);
|
||||
}
|
||||
if(htim_pwm->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_VREFB_PWM)
|
||||
{
|
||||
/* Peripheral clock enable */
|
||||
__BSP_MOTOR_CONTROL_BOARD_TIMER_VREFB_PWM_CLCK_DISABLE();
|
||||
/* GPIO Deconfiguration */
|
||||
HAL_GPIO_DeInit(BSP_MOTOR_CONTROL_BOARD_VREFB_PORT, BSP_MOTOR_CONTROL_BOARD_VREFB_PIN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PWM Callback
|
||||
* @param[in] htim PWM handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
|
||||
{
|
||||
if ((htim->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_TICK)&& (htim->Channel == BSP_MOTOR_CONTROL_BOARD_HAL_ACT_CHAN_TIMER_TICK))
|
||||
{
|
||||
if (BSP_MotorControl_GetDeviceState(0) != INACTIVE)
|
||||
{
|
||||
BSP_MotorControl_StepClockHandler(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief External Line Callback
|
||||
* @param[in] GPIO_Pin pin number
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
||||
{
|
||||
if (GPIO_Pin == BSP_MOTOR_CONTROL_BOARD_EN_AND_FLAG_PIN)
|
||||
{
|
||||
BSP_MotorControl_FlagInterruptHandler();
|
||||
}
|
||||
if (GPIO_Pin == KEY_BUTTON_PIN)
|
||||
{
|
||||
ButtonHandler();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
extern RTC_HandleTypeDef hrtc;
|
||||
extern TIM_HandleTypeDef hTimTick;
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
@@ -213,6 +214,27 @@ void RTC_Alarm_IRQHandler(void)
|
||||
/* USER CODE END RTC_Alarm_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles interrupt for External lines 10 to 15
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void EXTI15_10_IRQHandler(void)
|
||||
{
|
||||
HAL_GPIO_EXTI_IRQHandler(BSP_MOTOR_CONTROL_BOARD_EN_AND_FLAG_PIN);
|
||||
HAL_GPIO_EXTI_IRQHandler(KEY_BUTTON_PIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles TIM4 interrupt request.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void TIM4_IRQHandler(void)
|
||||
{
|
||||
HAL_TIM_IRQHandler(&hTimTick);
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
Reference in New Issue
Block a user