Changeset 22 for trunk/fw_g473rct/Core/Src/usart.c
- Timestamp:
- Aug 29, 2025, 6:15:42 PM (24 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/fw_g473rct/Core/Src/usart.c
r20 r22 27 27 UART_HandleTypeDef huart1; 28 28 UART_HandleTypeDef huart2; 29 DMA_HandleTypeDef hdma_usart2_rx; 29 30 30 31 /* USART1 init function */ … … 86 87 huart2.Instance = USART2; 87 88 huart2.Init.BaudRate = 115200; 88 huart2.Init.WordLength = UART_WORDLENGTH_ 8B;89 huart2.Init.WordLength = UART_WORDLENGTH_9B; 89 90 huart2.Init.StopBits = UART_STOPBITS_1; 90 huart2.Init.Parity = UART_PARITY_ NONE;91 huart2.Init.Parity = UART_PARITY_EVEN; 91 92 huart2.Init.Mode = UART_MODE_TX_RX; 92 93 huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; … … 94 95 huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; 95 96 huart2.Init.ClockPrescaler = UART_PRESCALER_DIV1; 96 huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; 97 huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_SWAP_INIT; 98 huart2.AdvancedInit.Swap = UART_ADVFEATURE_SWAP_ENABLE; 97 99 if (HAL_UART_Init(&huart2) != HAL_OK) 98 100 { … … 152 154 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 153 155 156 /* USART1 interrupt Init */ 157 HAL_NVIC_SetPriority(USART1_IRQn, 0, 0); 158 HAL_NVIC_EnableIRQ(USART1_IRQn); 154 159 /* USER CODE BEGIN USART1_MspInit 1 */ 155 160 … … 186 191 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 187 192 193 /* USART2 DMA Init */ 194 /* USART2_RX Init */ 195 hdma_usart2_rx.Instance = DMA1_Channel6; 196 hdma_usart2_rx.Init.Request = DMA_REQUEST_USART2_RX; 197 hdma_usart2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; 198 hdma_usart2_rx.Init.PeriphInc = DMA_PINC_DISABLE; 199 hdma_usart2_rx.Init.MemInc = DMA_MINC_ENABLE; 200 hdma_usart2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; 201 hdma_usart2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; 202 hdma_usart2_rx.Init.Mode = DMA_NORMAL; 203 hdma_usart2_rx.Init.Priority = DMA_PRIORITY_LOW; 204 if (HAL_DMA_Init(&hdma_usart2_rx) != HAL_OK) 205 { 206 Error_Handler(); 207 } 208 209 __HAL_LINKDMA(uartHandle,hdmarx,hdma_usart2_rx); 210 211 /* USART2 interrupt Init */ 212 HAL_NVIC_SetPriority(USART2_IRQn, 0, 0); 213 HAL_NVIC_EnableIRQ(USART2_IRQn); 188 214 /* USER CODE BEGIN USART2_MspInit 1 */ 189 215 … … 209 235 HAL_GPIO_DeInit(GPIOC, GPIO_PIN_4|GPIO_PIN_5); 210 236 237 /* USART1 interrupt Deinit */ 238 HAL_NVIC_DisableIRQ(USART1_IRQn); 211 239 /* USER CODE BEGIN USART1_MspDeInit 1 */ 212 240 … … 227 255 HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3); 228 256 257 /* USART2 DMA DeInit */ 258 HAL_DMA_DeInit(uartHandle->hdmarx); 259 260 /* USART2 interrupt Deinit */ 261 HAL_NVIC_DisableIRQ(USART2_IRQn); 229 262 /* USER CODE BEGIN USART2_MspDeInit 1 */ 230 263
Note: See TracChangeset
for help on using the changeset viewer.