diff options
| author | SummerGift <[email protected]> | 2020-03-23 15:35:27 +0800 |
|---|---|---|
| committer | SummerGift <[email protected]> | 2020-03-23 15:44:54 +0800 |
| commit | e5c1183350966cd242093c626f2f2c3944122498 (patch) | |
| tree | d6f0b384a0e867312e546536e6ebb7287c93cd55 /components/drivers | |
| parent | 5ddb0d51c022f9b10028143de740fa5becf3739f (diff) | |
[optimize] stm32 uart driver
Diffstat (limited to 'components/drivers')
| -rw-r--r-- | components/drivers/serial/serial.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index d1c04dec6f..7dd2918b9b 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -733,6 +733,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_INT_RX; + /* configure low level device */ serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void*)RT_DEVICE_FLAG_INT_RX); } @@ -754,10 +755,11 @@ static rt_err_t rt_serial_close(struct rt_device *dev) rt_free(rx_fifo); } - /* configure low level device */ - serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void *) RT_DEVICE_FLAG_DMA_RX); 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 */ @@ -771,6 +773,7 @@ static rt_err_t rt_serial_close(struct rt_device *dev) 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); } @@ -785,7 +788,14 @@ 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); } + + serial->ops->control(serial, RT_DEVICE_CTRL_CLOSE, RT_NULL); + dev->flag &= ~RT_DEVICE_FLAG_ACTIVATED; + #endif /* RT_SERIAL_USING_DMA */ return RT_EOK; } |
