Skip to content

Commit aecadd2

Browse files
committed
Cast UART0 DMA count to uint16_t
Add an explicit `static_cast<uint16_t>` when assigning the computed DMA RX count to `sv_rx_count.rx`, ensuring type-safe conversion from the DMA transfer count expression and avoiding implicit narrowing warnings.
1 parent 96fa09b commit aecadd2

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib-gd32/src/uart0/uart0.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ extern "C" void USART0_IRQHandler() {
5656
if (RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_IDLE)) {
5757
usart_data_receive(USART0);
5858

59-
sv_rx_count.rx = kSizeRxBuffer - (dma_transfer_number_get(USART0_DMAx, USART0_RX_DMA_CHx));
59+
sv_rx_count.rx = static_cast<uint16_t>(kSizeRxBuffer - (dma_transfer_number_get(USART0_DMAx, USART0_RX_DMA_CHx)));
6060
sv_receive_flag = 1;
6161

6262
auto chtl = DMA_CHCTL(USART0_DMAx, USART0_RX_DMA_CHx);

0 commit comments

Comments
 (0)