From 8b18522cfd3f321d52d389c7658a2992d6ea1d2c Mon Sep 17 00:00:00 2001 From: MLW <2544047213@qq.com> Date: Sun, 3 Mar 2019 14:12:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=5Ftc=5Fflush=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=BC=95=E8=B5=B7=E7=9A=84=E7=BC=93=E5=86=B2=E5=8C=BA?= =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drivers/serial/serial.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index a03e4a719e..094c403656 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -882,6 +882,7 @@ static int _get_baudrate(speed_t speed) static void _tc_flush(struct rt_serial_device *serial, int queue) { + rt_base_t level; int ch = -1; struct rt_serial_rx_fifo *rx_fifo = RT_NULL; struct rt_device *device = RT_NULL; @@ -901,10 +902,12 @@ static void _tc_flush(struct rt_serial_device *serial, int queue) if((device->open_flag & RT_DEVICE_FLAG_INT_RX) || (device->open_flag & RT_DEVICE_FLAG_DMA_RX)) { RT_ASSERT(RT_NULL != rx_fifo); + level = rt_hw_interrupt_disable(); rt_memset(rx_fifo->buffer, 0, serial->config.bufsz); rx_fifo->put_index = 0; rx_fifo->get_index = 0; rx_fifo->is_full = RT_FALSE; + rt_hw_interrupt_enable(level); } else {