[DeviceDriver][Serial] Fix serial open flag lost when device reopen.

This commit is contained in:
armink 2017-11-26 10:19:51 +08:00
parent 3044461ba2
commit 2be6a968d7
1 changed files with 14 additions and 0 deletions

View File

@ -641,6 +641,13 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag)
serial->serial_rx = RT_NULL;
}
}
else
{
if (oflag & RT_DEVICE_FLAG_DMA_RX)
dev->open_flag |= RT_DEVICE_FLAG_DMA_RX;
else if (oflag & RT_DEVICE_FLAG_INT_RX)
dev->open_flag |= RT_DEVICE_FLAG_INT_RX;
}
if (serial->serial_tx == RT_NULL)
{
@ -676,6 +683,13 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag)
serial->serial_tx = RT_NULL;
}
}
else
{
if (oflag & RT_DEVICE_FLAG_DMA_TX)
dev->open_flag |= RT_DEVICE_FLAG_DMA_TX;
else if (oflag & RT_DEVICE_FLAG_INT_TX)
dev->open_flag |= RT_DEVICE_FLAG_INT_TX;
}
/* set stream flag */
dev->open_flag |= stream_flag;