|
|
|
@ -44,9 +44,10 @@
|
|
|
|
|
/* USER CODE END PM */
|
|
|
|
|
|
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
|
TIM_HandleTypeDef htim2;
|
|
|
|
|
TIM_HandleTypeDef htim2;
|
|
|
|
|
TIM_HandleTypeDef htim6;
|
|
|
|
|
|
|
|
|
|
UART_HandleTypeDef huart1;
|
|
|
|
|
UART_HandleTypeDef huart2;
|
|
|
|
|
|
|
|
|
|
/* USER CODE BEGIN PV */
|
|
|
|
@ -64,6 +65,7 @@ static void MX_GPIO_Init(void);
|
|
|
|
|
static void MX_TIM2_Init(void);
|
|
|
|
|
static void MX_USART2_UART_Init(void);
|
|
|
|
|
static void MX_TIM6_Init(void);
|
|
|
|
|
static void MX_USART1_UART_Init(void);
|
|
|
|
|
/* USER CODE BEGIN PFP */
|
|
|
|
|
|
|
|
|
|
/* USER CODE END PFP */
|
|
|
|
@ -104,6 +106,7 @@ int main(void)
|
|
|
|
|
MX_TIM2_Init();
|
|
|
|
|
MX_USART2_UART_Init();
|
|
|
|
|
MX_TIM6_Init();
|
|
|
|
|
MX_USART1_UART_Init();
|
|
|
|
|
/* USER CODE BEGIN 2 */
|
|
|
|
|
p_uart_init(&huart2);
|
|
|
|
|
|
|
|
|
@ -291,6 +294,41 @@ static void MX_TIM6_Init(void)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief USART1 Initialization Function
|
|
|
|
|
* @param None
|
|
|
|
|
* @retval None
|
|
|
|
|
*/
|
|
|
|
|
static void MX_USART1_UART_Init(void)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/* USER CODE BEGIN USART1_Init 0 */
|
|
|
|
|
|
|
|
|
|
/* USER CODE END USART1_Init 0 */
|
|
|
|
|
|
|
|
|
|
/* USER CODE BEGIN USART1_Init 1 */
|
|
|
|
|
|
|
|
|
|
/* USER CODE END USART1_Init 1 */
|
|
|
|
|
huart1.Instance = USART1;
|
|
|
|
|
huart1.Init.BaudRate = 115200;
|
|
|
|
|
huart1.Init.WordLength = UART_WORDLENGTH_8B;
|
|
|
|
|
huart1.Init.StopBits = UART_STOPBITS_1;
|
|
|
|
|
huart1.Init.Parity = UART_PARITY_NONE;
|
|
|
|
|
huart1.Init.Mode = UART_MODE_TX_RX;
|
|
|
|
|
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
|
|
|
|
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
|
|
|
|
|
huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
|
|
|
|
|
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
|
|
|
|
if (HAL_RS485Ex_Init(&huart1, UART_DE_POLARITY_HIGH, 0, 0) != HAL_OK)
|
|
|
|
|
{
|
|
|
|
|
Error_Handler();
|
|
|
|
|
}
|
|
|
|
|
/* USER CODE BEGIN USART1_Init 2 */
|
|
|
|
|
|
|
|
|
|
/* USER CODE END USART1_Init 2 */
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief USART2 Initialization Function
|
|
|
|
|
* @param None
|
|
|
|
@ -343,9 +381,6 @@ static void MX_GPIO_Init(void)
|
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
|
|
|
HAL_GPIO_WritePin(GPIOA, m1_dir_Pin|m2_dir_Pin|GPIO_PIN_8|GPIO_PIN_9, GPIO_PIN_RESET);
|
|
|
|
|
|
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
|
|
|
HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, GPIO_PIN_RESET);
|
|
|
|
|
|
|
|
|
|
/*Configure GPIO pins : m1_dir_Pin m2_dir_Pin PA8 PA9 */
|
|
|
|
|
GPIO_InitStruct.Pin = m1_dir_Pin|m2_dir_Pin|GPIO_PIN_8|GPIO_PIN_9;
|
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
|
|
@ -353,13 +388,6 @@ static void MX_GPIO_Init(void)
|
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
|
|
/*Configure GPIO pin : LD3_Pin */
|
|
|
|
|
GPIO_InitStruct.Pin = LD3_Pin;
|
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
|
HAL_GPIO_Init(LD3_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* USER CODE BEGIN 4 */
|
|
|
|
|