@@ -251,6 +251,7 @@ void USART6_IRQHandler(void)
251251void HAL_UART_MspInit (UART_HandleTypeDef * uartHandle )
252252{
253253 GPIO_InitTypeDef GPIO_InitStruct ;
254+ #ifdef BSP_USING_UART1
254255 if (uartHandle -> Instance == USART1 )
255256 {
256257 /* USART1 clock enable */
@@ -267,7 +268,9 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
267268 GPIO_InitStruct .Alternate = GPIO_AF7_USART1 ;
268269 HAL_GPIO_Init (GPIOA , & GPIO_InitStruct );
269270 }
270- else if (uartHandle -> Instance == USART2 )
271+ #endif /* BSP_USING_UART1 */
272+ #ifdef BSP_USING_UART2
273+ if (uartHandle -> Instance == USART2 )
271274 {
272275 /* USART2 clock enable */
273276 __HAL_RCC_USART2_CLK_ENABLE ();
@@ -283,7 +286,9 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
283286 GPIO_InitStruct .Alternate = GPIO_AF7_USART2 ;
284287 HAL_GPIO_Init (GPIOA , & GPIO_InitStruct );
285288 }
286- else if (uartHandle -> Instance == USART3 )
289+ #endif /* BSP_USING_UART2 */
290+ #ifdef BSP_USING_UART3
291+ if (uartHandle -> Instance == USART3 )
287292 {
288293 /* USART3 clock enable */
289294 __HAL_RCC_USART3_CLK_ENABLE ();
@@ -299,7 +304,9 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
299304 GPIO_InitStruct .Alternate = GPIO_AF7_USART3 ;
300305 HAL_GPIO_Init (GPIOB , & GPIO_InitStruct );
301306 }
302- else if (uartHandle -> Instance == USART6 )
307+ #endif /* BSP_USING_UART3 */
308+ #ifdef BSP_USING_UART6
309+ if (uartHandle -> Instance == USART6 )
303310 {
304311 /* USART6 clock enable */
305312 __HAL_RCC_USART6_CLK_ENABLE ();
@@ -315,10 +322,12 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
315322 GPIO_InitStruct .Alternate = GPIO_AF8_USART6 ;
316323 HAL_GPIO_Init (GPIOC , & GPIO_InitStruct );
317324 }
325+ #endif /* BSP_USING_UART6 */
318326}
319327
320328void HAL_UART_MspDeInit (UART_HandleTypeDef * uartHandle )
321329{
330+ #ifdef BSP_USING_UART1
322331 if (uartHandle -> Instance == USART1 )
323332 {
324333 /* Peripheral clock disable */
@@ -329,7 +338,9 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle)
329338 */
330339 HAL_GPIO_DeInit (GPIOA , GPIO_PIN_9 | GPIO_PIN_10 );
331340 }
332- else if (uartHandle -> Instance == USART2 )
341+ #endif /* BSP_USING_UART1 */
342+ #ifdef BSP_USING_UART2
343+ if (uartHandle -> Instance == USART2 )
333344 {
334345 /* Peripheral clock disable */
335346 __HAL_RCC_USART2_CLK_DISABLE ();
@@ -339,7 +350,9 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle)
339350 */
340351 HAL_GPIO_DeInit (GPIOA , GPIO_PIN_2 | GPIO_PIN_3 );
341352 }
342- else if (uartHandle -> Instance == USART3 )
353+ #endif /* BSP_USING_UART2 */
354+ #ifdef BSP_USING_UART3
355+ if (uartHandle -> Instance == USART3 )
343356 {
344357 /* Peripheral clock disable */
345358 __HAL_RCC_USART3_CLK_DISABLE ();
@@ -349,7 +362,9 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle)
349362 */
350363 HAL_GPIO_DeInit (GPIOB , GPIO_PIN_10 | GPIO_PIN_11 );
351364 }
352- else if (uartHandle -> Instance == USART6 )
365+ #endif /* BSP_USING_UART3 */
366+ #ifdef BSP_USING_UART6
367+ if (uartHandle -> Instance == USART6 )
353368 {
354369 /* Peripheral clock disable */
355370 __HAL_RCC_USART6_CLK_DISABLE ();
@@ -359,6 +374,7 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle)
359374 */
360375 HAL_GPIO_DeInit (GPIOC , GPIO_PIN_6 | GPIO_PIN_7 );
361376 }
377+ #endif /* BSP_USING_UART6 */
362378}
363379
364380int hw_usart_init (void )
0 commit comments