Skip to content

Commit 8b18522

Browse files
committed
解决_tc_flush可能引起的缓冲区冲突
1 parent 5260e64 commit 8b18522

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

components/drivers/serial/serial.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ static int _get_baudrate(speed_t speed)
882882

883883
static void _tc_flush(struct rt_serial_device *serial, int queue)
884884
{
885+
rt_base_t level;
885886
int ch = -1;
886887
struct rt_serial_rx_fifo *rx_fifo = RT_NULL;
887888
struct rt_device *device = RT_NULL;
@@ -901,10 +902,12 @@ static void _tc_flush(struct rt_serial_device *serial, int queue)
901902
if((device->open_flag & RT_DEVICE_FLAG_INT_RX) || (device->open_flag & RT_DEVICE_FLAG_DMA_RX))
902903
{
903904
RT_ASSERT(RT_NULL != rx_fifo);
905+
level = rt_hw_interrupt_disable();
904906
rt_memset(rx_fifo->buffer, 0, serial->config.bufsz);
905907
rx_fifo->put_index = 0;
906908
rx_fifo->get_index = 0;
907909
rx_fifo->is_full = RT_FALSE;
910+
rt_hw_interrupt_enable(level);
908911
}
909912
else
910913
{

0 commit comments

Comments
 (0)