diff options
| author | Bernard Xiong <[email protected]> | 2021-05-05 10:48:40 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-05-05 10:48:40 +0800 |
| commit | 00524ccc66bbd93de1a20ca5b8fd10e6d0a4008e (patch) | |
| tree | 8988c7ae4d83359076bdd8e6e2c33179d9e2392c /components | |
| parent | 39aa987fc8190850d7030527c3b3bfb9aa8bc812 (diff) | |
| parent | 141effcae3f50a0096441984bb2bc973da1433ad (diff) | |
Merge pull request #4659 from rtthread-bot/rtt_bot
[update] RT-Thread Robot automatic submission
Diffstat (limited to 'components')
| -rw-r--r-- | components/drivers/serial/serial.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index 32161ad0cb..2736ceed66 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -746,19 +746,24 @@ static rt_err_t rt_serial_close(struct rt_device *dev) { struct rt_serial_rx_fifo* rx_fifo; + /* configure low level device */ + serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void*)RT_DEVICE_FLAG_INT_RX); + dev->open_flag &= ~RT_DEVICE_FLAG_INT_RX; + rx_fifo = (struct rt_serial_rx_fifo*)serial->serial_rx; RT_ASSERT(rx_fifo != RT_NULL); rt_free(rx_fifo); serial->serial_rx = RT_NULL; - dev->open_flag &= ~RT_DEVICE_FLAG_INT_RX; - /* configure low level device */ - serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void*)RT_DEVICE_FLAG_INT_RX); } #ifdef RT_SERIAL_USING_DMA else if (dev->open_flag & RT_DEVICE_FLAG_DMA_RX) { + /* configure low level device */ + serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void *) RT_DEVICE_FLAG_DMA_RX); + dev->open_flag &= ~RT_DEVICE_FLAG_DMA_RX; + if (serial->config.bufsz == 0) { struct rt_serial_rx_dma* rx_dma; @@ -778,10 +783,7 @@ static rt_err_t rt_serial_close(struct rt_device *dev) rt_free(rx_fifo); } serial->serial_rx = RT_NULL; - dev->open_flag &= ~RT_DEVICE_FLAG_DMA_RX; - /* configure low level device */ - serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void *) RT_DEVICE_FLAG_DMA_RX); } #endif /* RT_SERIAL_USING_DMA */ @@ -789,21 +791,26 @@ static rt_err_t rt_serial_close(struct rt_device *dev) { struct rt_serial_tx_fifo* tx_fifo; + serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void*)RT_DEVICE_FLAG_INT_TX); + dev->open_flag &= ~RT_DEVICE_FLAG_INT_TX; + tx_fifo = (struct rt_serial_tx_fifo*)serial->serial_tx; RT_ASSERT(tx_fifo != RT_NULL); rt_free(tx_fifo); serial->serial_tx = RT_NULL; - dev->open_flag &= ~RT_DEVICE_FLAG_INT_TX; /* configure low level device */ - serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void*)RT_DEVICE_FLAG_INT_TX); } #ifdef RT_SERIAL_USING_DMA else if (dev->open_flag & RT_DEVICE_FLAG_DMA_TX) { struct rt_serial_tx_dma* tx_dma; + /* configure low level device */ + serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void *) RT_DEVICE_FLAG_DMA_TX); + dev->open_flag &= ~RT_DEVICE_FLAG_DMA_TX; + tx_dma = (struct rt_serial_tx_dma*)serial->serial_tx; RT_ASSERT(tx_dma != RT_NULL); @@ -811,10 +818,7 @@ static rt_err_t rt_serial_close(struct rt_device *dev) rt_free(tx_dma); serial->serial_tx = RT_NULL; - dev->open_flag &= ~RT_DEVICE_FLAG_DMA_TX; - /* configure low level device */ - serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void *) RT_DEVICE_FLAG_DMA_TX); } #endif /* RT_SERIAL_USING_DMA */ |
