| | |
| | | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
| | | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
| | | |
| | | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) |
| | | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_ACR_LATENCY) != HAL_OK) |
| | | { |
| | | Error_Handler(); |
| | | } |
| | |
| | | LL_USART_Enable(USART2); |
| | | } |
| | | |
| | | /* USART3 init function */ |
| | | void MX_USART3_UART_Init(void) |
| | | { |
| | | |
| | | |
| | | LL_USART_InitTypeDef USART_InitStruct = {0}; |
| | | LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; |
| | | |
| | | /* Peripheral clock enable */ |
| | | LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART3); |
| | | LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB); |
| | | |
| | | /**USART3 GPIO Configuration |
| | | PB5 ------> USART3_DE |
| | | PB3 ------> USART3_TX |
| | | PB4 ------> USART3_RX |
| | | */ |
| | | GPIO_InitStruct.Pin = LL_GPIO_PIN_10|LL_GPIO_PIN_11; |
| | | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; |
| | | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; |
| | | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; |
| | | GPIO_InitStruct.Pull = LL_GPIO_PULL_UP; |
| | | GPIO_InitStruct.Alternate = LL_GPIO_AF_4; |
| | | LL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| | | |
| | | |
| | | /* USART3 interrupt Init */ |
| | | NVIC_SetPriority(USART3_6_IRQn, 0); |
| | | NVIC_EnableIRQ(USART3_6_IRQn); |
| | | |
| | | USART_InitStruct.BaudRate = 230400; |
| | | USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B; |
| | | USART_InitStruct.StopBits = LL_USART_STOPBITS_1; |
| | | USART_InitStruct.Parity = LL_USART_PARITY_NONE; |
| | | USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX; |
| | | USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE; |
| | | USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_8; |
| | | LL_USART_Init(USART3, &USART_InitStruct); |
| | | |
| | | /* |
| | | LL_USART_EnableDEMode(USART3); |
| | | LL_USART_SetDESignalPolarity(USART3, LL_USART_DE_POLARITY_LOW); |
| | | // LL_USART_SetDESignalPolarity(USART3, LL_USART_DE_POLARITY_HIGH); |
| | | LL_USART_SetDEAssertionTime(USART3, 3); |
| | | LL_USART_SetDEDeassertionTime(USART3, 3); |
| | | LL_USART_EnableOneBitSamp(USART3); |
| | | // LL_USART_EnableAutoBaudRate(USART3); |
| | | // LL_USART_SetAutoBaudRateMode(USART3, LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE); |
| | | */ |
| | | LL_USART_DisableOverrunDetect(USART3); |
| | | LL_USART_ConfigAsyncMode(USART3); |
| | | LL_USART_Enable(USART3); |
| | | } |
| | | |
| | | |
| | | /* USART5 init function */ |
| | | void MX_USART5_UART_Init(void) |
| | |
| | | NVIC_SetPriority(USART3_6_IRQn, 0); |
| | | NVIC_EnableIRQ(USART3_6_IRQn); |
| | | |
| | | USART_InitStruct.BaudRate = 57600; |
| | | USART_InitStruct.BaudRate = 230400; |
| | | USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B; |
| | | USART_InitStruct.StopBits = LL_USART_STOPBITS_1; |
| | | USART_InitStruct.Parity = LL_USART_PARITY_NONE; |