Skip to content

Commit 46ee22d

Browse files
committed
Cast UART0 DMA count to uint16_t
Add an explicit `static_cast<uint16_t>` when computing `sv_rx_count.rx` in `USART0_IRQHandler` to avoid implicit narrowing from `dma_transfer_number_get(...)` and make the intended RX counter type conversion clear.
1 parent 926e8c1 commit 46ee22d

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)