77 * Date Author Notes
88 * 2021-08-20 BruceOu first implementation
99 * 2025-07-11 Wangshun adapt to GD32VV553H
10+ * 2026-01-22 HaitaoZhang adapt to GD32VW553H UART1/2
1011 */
1112
1213#include "drv_usart.h"
@@ -45,6 +46,7 @@ void USART0_IRQHandler(void)
4546#if defined(BSP_USING_UART1 )
4647struct rt_serial_device serial1 ;
4748
49+ #if defined (SOC_SERIES_GD32VF103V )
4850void USART1_IRQHandler (void )
4951{
5052 /* enter interrupt */
@@ -55,12 +57,27 @@ void USART1_IRQHandler(void)
5557 /* leave interrupt */
5658 rt_interrupt_leave ();
5759}
60+ #elif defined (SOC_SERIES_GD32VW55x )
61+ void UART1_IRQHandler (void )
62+ {
63+ /* enter interrupt */
64+ rt_interrupt_enter ();
65+
66+ GD32_UART_IRQHandler (& serial1 );
67+
68+ /* leave interrupt */
69+ rt_interrupt_leave ();
70+ }
71+ #else
72+ #error "Uart1 ISR name not compatible with current MCU series"
73+ #endif
5874
5975#endif /* BSP_USING_UART1 */
6076
6177#if defined(BSP_USING_UART2 )
6278struct rt_serial_device serial2 ;
6379
80+ #if defined (SOC_SERIES_GD32VF103V )
6481void USART2_IRQHandler (void )
6582{
6683 /* enter interrupt */
@@ -71,6 +88,20 @@ void USART2_IRQHandler(void)
7188 /* leave interrupt */
7289 rt_interrupt_leave ();
7390}
91+ #elif defined (SOC_SERIES_GD32VW55x )
92+ void UART2_IRQHandler (void )
93+ {
94+ /* enter interrupt */
95+ rt_interrupt_enter ();
96+
97+ GD32_UART_IRQHandler (& serial2 );
98+
99+ /* leave interrupt */
100+ rt_interrupt_leave ();
101+ }
102+ #else
103+ #error "Uart2 ISR name not compatible with current MCU series"
104+ #endif
74105
75106#endif /* BSP_USING_UART2 */
76107
@@ -161,30 +192,55 @@ static const struct gd32_uart uart_obj[] = {
161192 RCU_USART0 , RCU_GPIOB , RCU_GPIOA , /* periph clock, tx gpio clock, rt gpio clock */
162193 GPIOB , GPIO_PIN_15 , /* tx port, tx pin */
163194 GPIOA , GPIO_PIN_8 , /* rx port, rx pin */
195+ #if defined (SOC_SERIES_GD32VW55x )
196+ GPIO_AF_8 , GPIO_AF_2 ,
197+ #endif
164198 & serial0 ,
165199 "uart0" ,
166200 },
167201 #endif
168202
169203 #ifdef BSP_USING_UART1
170204 {
205+ #if defined (SOC_SERIES_GD32VF103V )
171206 USART1 , /* uart peripheral index */
172207 USART1_IRQn , /* uart iqrn */
173208 RCU_USART1 , RCU_GPIOA , RCU_GPIOA , /* periph clock, tx gpio clock, rt gpio clock */
174209 GPIOA , GPIO_PIN_2 , /* tx port, tx pin */
175210 GPIOA , GPIO_PIN_3 , /* rx port, rx pin */
211+ #elif defined (SOC_SERIES_GD32VW55x )
212+ UART1 , /* uart peripheral index */
213+ UART1_IRQn , /* uart iqrn */
214+ RCU_UART1 , RCU_GPIOA , RCU_GPIOA , /* periph clock, tx gpio clock, rt gpio clock */
215+ GPIOA , GPIO_PIN_2 , /* tx port, tx pin */
216+ GPIOA , GPIO_PIN_3 , /* rx port, rx pin */
217+ GPIO_AF_7 , GPIO_AF_7 ,
218+ #else
219+ #error "UART1 peripheral config incompatible with current MCU series"
220+ #endif
176221 & serial1 ,
177222 "uart1" ,
178223 },
179224 #endif
180225
181226 #ifdef BSP_USING_UART2
182227 {
228+ #if defined (SOC_SERIES_GD32VF103V )
183229 USART2 , /* uart peripheral index */
184230 USART2_IRQn , /* uart iqrn */
185231 RCU_USART2 , RCU_GPIOB , RCU_GPIOB , /* periph clock, tx gpio clock, rt gpio clock */
186232 GPIOB , GPIO_PIN_10 , /* tx port, tx pin */
187233 GPIOB , GPIO_PIN_11 , /* rx port, rx pin */
234+ #elif defined (SOC_SERIES_GD32VW55x )
235+ UART2 , /* uart peripheral index */
236+ UART2_IRQn , /* uart iqrn */
237+ RCU_UART2 , RCU_GPIOA , RCU_GPIOA , /* periph clock, tx gpio clock, rt gpio clock */
238+ GPIOA , GPIO_PIN_6 , /* tx port, tx pin */
239+ GPIOA , GPIO_PIN_7 , /* rx port, rx pin */
240+ GPIO_AF_10 , GPIO_AF_8 ,
241+ #else
242+ #error "UART2 peripheral config incompatible with current MCU series"
243+ #endif
188244 & serial2 ,
189245 "uart2" ,
190246 },
@@ -233,17 +289,19 @@ void gd32_uart_gpio_init(struct gd32_uart *uart)
233289 rcu_periph_clock_enable (uart -> per_clk );
234290
235291 /* connect port */
236- #if defined SOC_SERIES_GD32VF103V
292+ #if defined ( SOC_SERIES_GD32VF103V )
237293 gpio_init (uart -> tx_port , GPIO_MODE_AF_PP , GPIO_OSPEED_50MHZ , uart -> tx_pin );
238294 gpio_init (uart -> rx_port , GPIO_MODE_IN_FLOATING , GPIO_OSPEED_50MHZ , uart -> rx_pin );
239- #else
240- gpio_af_set (uart -> tx_port , GPIO_AF_8 , uart -> tx_pin );
295+ #elif defined ( SOC_SERIES_GD32VW55x )
296+ gpio_af_set (uart -> tx_port , uart -> tx_alt , uart -> tx_pin );
241297 gpio_mode_set (uart -> tx_port , GPIO_MODE_AF , GPIO_PUPD_PULLUP , uart -> tx_pin );
242298 gpio_output_options_set (uart -> tx_port , GPIO_OTYPE_PP , GPIO_OSPEED_25MHZ , uart -> tx_pin );
243299
244- gpio_af_set (uart -> rx_port , GPIO_AF_2 , uart -> rx_pin );
300+ gpio_af_set (uart -> rx_port , uart -> rx_alt , uart -> rx_pin );
245301 gpio_mode_set (uart -> rx_port , GPIO_MODE_AF , GPIO_PUPD_PULLUP , uart -> rx_pin );
246302 gpio_output_options_set (uart -> rx_port , GPIO_OTYPE_PP , GPIO_OSPEED_25MHZ , uart -> rx_pin );
303+ #else
304+ #error "Uart GPIO config incompatible with current MCU series"
247305#endif
248306}
249307
@@ -328,7 +386,7 @@ static rt_err_t gd32_uart_control(struct rt_serial_device *serial, int cmd, void
328386
329387 break ;
330388 case RT_DEVICE_CTRL_SET_INT :
331- #ifdef SOC_SERIES_GD32VF103V
389+ #if defined ( SOC_SERIES_GD32VF103V )
332390 eclic_set_nlbits (ECLIC_GROUP_LEVEL3_PRIO1 );
333391#endif /* SOC_SERIES_GD32VF103V */
334392 /* enable rx irq */
0 commit comments