|
|
@ -25,7 +25,6 @@ |
|
|
|
/* USER CODE END 0 */ |
|
|
|
/* USER CODE END 0 */ |
|
|
|
|
|
|
|
|
|
|
|
TIM_HandleTypeDef htim2; |
|
|
|
TIM_HandleTypeDef htim2; |
|
|
|
TIM_HandleTypeDef htim3; |
|
|
|
|
|
|
|
TIM_HandleTypeDef htim4; |
|
|
|
TIM_HandleTypeDef htim4; |
|
|
|
|
|
|
|
|
|
|
|
/* TIM2 init function */ |
|
|
|
/* TIM2 init function */ |
|
|
@ -81,60 +80,6 @@ void MX_TIM2_Init(void) |
|
|
|
/* USER CODE END TIM2_Init 2 */ |
|
|
|
/* USER CODE END TIM2_Init 2 */ |
|
|
|
HAL_TIM_MspPostInit(&htim2); |
|
|
|
HAL_TIM_MspPostInit(&htim2); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/* TIM3 init function */ |
|
|
|
|
|
|
|
void MX_TIM3_Init(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE BEGIN TIM3_Init 0 */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END TIM3_Init 0 */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TIM_ClockConfigTypeDef sClockSourceConfig = {0}; |
|
|
|
|
|
|
|
TIM_MasterConfigTypeDef sMasterConfig = {0}; |
|
|
|
|
|
|
|
TIM_OC_InitTypeDef sConfigOC = {0}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE BEGIN TIM3_Init 1 */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END TIM3_Init 1 */ |
|
|
|
|
|
|
|
htim3.Instance = TIM3; |
|
|
|
|
|
|
|
htim3.Init.Prescaler = 2; |
|
|
|
|
|
|
|
htim3.Init.CounterMode = TIM_COUNTERMODE_UP; |
|
|
|
|
|
|
|
htim3.Init.Period = 65535; |
|
|
|
|
|
|
|
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; |
|
|
|
|
|
|
|
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; |
|
|
|
|
|
|
|
if (HAL_TIM_Base_Init(&htim3) != HAL_OK) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Error_Handler(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; |
|
|
|
|
|
|
|
if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Error_Handler(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (HAL_TIM_PWM_Init(&htim3) != HAL_OK) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Error_Handler(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; |
|
|
|
|
|
|
|
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; |
|
|
|
|
|
|
|
if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Error_Handler(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sConfigOC.OCMode = TIM_OCMODE_PWM1; |
|
|
|
|
|
|
|
sConfigOC.Pulse = 0; |
|
|
|
|
|
|
|
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; |
|
|
|
|
|
|
|
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; |
|
|
|
|
|
|
|
if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Error_Handler(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/* USER CODE BEGIN TIM3_Init 2 */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END TIM3_Init 2 */ |
|
|
|
|
|
|
|
HAL_TIM_MspPostInit(&htim3); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
/* TIM4 init function */ |
|
|
|
/* TIM4 init function */ |
|
|
|
void MX_TIM4_Init(void) |
|
|
|
void MX_TIM4_Init(void) |
|
|
@ -195,17 +140,6 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle) |
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END TIM2_MspInit 1 */ |
|
|
|
/* USER CODE END TIM2_MspInit 1 */ |
|
|
|
} |
|
|
|
} |
|
|
|
else if(tim_baseHandle->Instance==TIM3) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
/* USER CODE BEGIN TIM3_MspInit 0 */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END TIM3_MspInit 0 */ |
|
|
|
|
|
|
|
/* TIM3 clock enable */ |
|
|
|
|
|
|
|
__HAL_RCC_TIM3_CLK_ENABLE(); |
|
|
|
|
|
|
|
/* USER CODE BEGIN TIM3_MspInit 1 */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END TIM3_MspInit 1 */ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* tim_encoderHandle) |
|
|
|
void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* tim_encoderHandle) |
|
|
@ -247,6 +181,7 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle) |
|
|
|
/* USER CODE BEGIN TIM2_MspPostInit 0 */ |
|
|
|
/* USER CODE BEGIN TIM2_MspPostInit 0 */ |
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END TIM2_MspPostInit 0 */ |
|
|
|
/* USER CODE END TIM2_MspPostInit 0 */ |
|
|
|
|
|
|
|
|
|
|
|
__HAL_RCC_GPIOA_CLK_ENABLE(); |
|
|
|
__HAL_RCC_GPIOA_CLK_ENABLE(); |
|
|
|
/**TIM2 GPIO Configuration
|
|
|
|
/**TIM2 GPIO Configuration
|
|
|
|
PA15 ------> TIM2_CH1 |
|
|
|
PA15 ------> TIM2_CH1 |
|
|
@ -262,25 +197,6 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle) |
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END TIM2_MspPostInit 1 */ |
|
|
|
/* USER CODE END TIM2_MspPostInit 1 */ |
|
|
|
} |
|
|
|
} |
|
|
|
else if(timHandle->Instance==TIM3) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
/* USER CODE BEGIN TIM3_MspPostInit 0 */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END TIM3_MspPostInit 0 */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__HAL_RCC_GPIOA_CLK_ENABLE(); |
|
|
|
|
|
|
|
/**TIM3 GPIO Configuration
|
|
|
|
|
|
|
|
PA6 ------> TIM3_CH1 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
GPIO_InitStruct.Pin = HEATER_Pin; |
|
|
|
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
|
|
|
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; |
|
|
|
|
|
|
|
HAL_GPIO_Init(HEATER_GPIO_Port, &GPIO_InitStruct); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE BEGIN TIM3_MspPostInit 1 */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END TIM3_MspPostInit 1 */ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -298,17 +214,6 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle) |
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END TIM2_MspDeInit 1 */ |
|
|
|
/* USER CODE END TIM2_MspDeInit 1 */ |
|
|
|
} |
|
|
|
} |
|
|
|
else if(tim_baseHandle->Instance==TIM3) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
/* USER CODE BEGIN TIM3_MspDeInit 0 */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END TIM3_MspDeInit 0 */ |
|
|
|
|
|
|
|
/* Peripheral clock disable */ |
|
|
|
|
|
|
|
__HAL_RCC_TIM3_CLK_DISABLE(); |
|
|
|
|
|
|
|
/* USER CODE BEGIN TIM3_MspDeInit 1 */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* USER CODE END TIM3_MspDeInit 1 */ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* tim_encoderHandle) |
|
|
|
void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* tim_encoderHandle) |
|
|
|