解决_tc_flush可能引起的缓冲区冲突

This commit is contained in:
MLW 2019-03-03 14:12:01 +08:00
parent 5260e647cb
commit 8b18522cfd
1 changed files with 3 additions and 0 deletions

View File

@ -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
{