Skip to content

Commit cd61754

Browse files
committed
Remove redundant cast in UART transmit
Remove unnecessary (uint32_t) casts when writing transmit data for the GD32H7XX USART in lib-gd32/src/gd32_uart.cpp. The two assignments in Gd32UartTransmit and Gd32UartTransmitString now use USART_TDATA_TDATA & *data++, matching the non-H7 branch and reducing redundancy (and potential compiler warnings).
1 parent c9c9e74 commit cd61754

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib-gd32/src/gd32_uart.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ void Gd32UartTransmit(uint32_t usart_periph, const uint8_t* data, uint32_t lengt
309309
while (length-- != 0) {
310310
while (RESET == usart_flag_get(usart_periph, USART_FLAG_TBE));
311311
#if defined(GD32H7XX)
312-
USART_TDATA(usart_periph) = USART_TDATA_TDATA & (uint32_t)*data++;
312+
USART_TDATA(usart_periph) = USART_TDATA_TDATA & *data++;
313313
#else
314314
USART_DATA(usart_periph) = (USART_DATA_DATA & *data++);
315315
#endif
@@ -324,7 +324,7 @@ void Gd32UartTransmitString(uint32_t usart_periph, const char* data) {
324324
while (*data != '\0') {
325325
while (RESET == usart_flag_get(USART0, USART_FLAG_TBE));
326326
#if defined(GD32H7XX)
327-
USART_TDATA(usart_periph) = USART_TDATA_TDATA & (uint32_t)*data++;
327+
USART_TDATA(usart_periph) = USART_TDATA_TDATA & *data++;
328328
#else
329329
USART_DATA(usart_periph) = (USART_DATA_DATA & *data++);
330330
#endif

0 commit comments

Comments
 (0)