summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2020-03-26 22:04:45 +0800
committerGitHub <[email protected]>2020-03-26 22:04:45 +0800
commitc1a3de7b8a6fdc279ddaa5c83d169bb8ab1cdf53 (patch)
tree9601df7f71da25f8019e7e573c20b7f75a05ad6b /components
parent130550d5a61a3f167e5300708a99b236986288db (diff)
parente5c1183350966cd242093c626f2f2c3944122498 (diff)
Merge pull request #3478 from SummerLife/optimize_uart
[stm32/driver] optimize uart driver
Diffstat (limited to 'components')
-rw-r--r--components/drivers/serial/serial.c14
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;
}