未验证 提交 aa7166df 编写于 作者: B Bernard Xiong 提交者: GitHub

Merge pull request #2376 from loogg/mlw-fs

 解决_tc_flush可能引起的缓冲区冲突
......@@ -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
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册