Update drv_usart.c

This commit is contained in:
周传福 2019-05-19 22:26:56 +08:00 committed by GitHub
parent 24f38acf52
commit 81ff374aed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -359,20 +359,20 @@ static void dma_isr(struct rt_serial_device *serial)
uart = (struct stm32_uart *) serial->parent.user_data; uart = (struct stm32_uart *) serial->parent.user_data;
RT_ASSERT(uart != RT_NULL); RT_ASSERT(uart != RT_NULL);
if ((__HAL_DMA_GET_IT_SOURCE(&(uart->dma.handle), DMA_IT_TC) != RESET) || if ((__HAL_DMA_GET_IT_SOURCE(&(uart->dma_rx.handle), DMA_IT_TC) != RESET) ||
(__HAL_DMA_GET_IT_SOURCE(&(uart->dma.handle), DMA_IT_HT) != RESET)) (__HAL_DMA_GET_IT_SOURCE(&(uart->dma_rx.handle), DMA_IT_HT) != RESET))
{ {
level = rt_hw_interrupt_disable(); level = rt_hw_interrupt_disable();
recv_total_index = serial->config.bufsz - __HAL_DMA_GET_COUNTER(&(uart->dma.handle)); recv_total_index = serial->config.bufsz - __HAL_DMA_GET_COUNTER(&(uart->dma_rx.handle));
if (recv_total_index == 0) if (recv_total_index == 0)
{ {
recv_len = serial->config.bufsz - uart->dma.last_index; recv_len = serial->config.bufsz - uart->dma_rx.last_index;
} }
else else
{ {
recv_len = recv_total_index - uart->dma.last_index; recv_len = recv_total_index - uart->dma_rx.last_index;
} }
uart->dma.last_index = recv_total_index; uart->dma_rx.last_index = recv_total_index;
rt_hw_interrupt_enable(level); rt_hw_interrupt_enable(level);
if (recv_len) if (recv_len)