summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorchenjh <[email protected]>2021-06-17 10:32:17 +0800
committerchenjh <[email protected]>2021-06-18 14:54:37 +0800
commit0613cf8ca2aa8df16fe3b67e648b67fa33890414 (patch)
treea37dc8618a632329b1793161456145f53896ce1e /components
parent5ac5d92cbb6b00f50c9f91c2f7de038419453398 (diff)
[serial] 解决serial_close未清除回调接口的问题
Diffstat (limited to 'components')
-rw-r--r--components/drivers/serial/serial_v2.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/components/drivers/serial/serial_v2.c b/components/drivers/serial/serial_v2.c
index 8670a99aa8..d6ae508cab 100644
--- a/components/drivers/serial/serial_v2.c
+++ b/components/drivers/serial/serial_v2.c
@@ -939,6 +939,10 @@ static rt_err_t rt_serial_close(struct rt_device *dev)
rt_serial_tx_disable(dev, dev->open_flag &
(RT_SERIAL_TX_BLOCKING | RT_SERIAL_TX_NON_BLOCKING));
+ /* Clear the callback function */
+ serial->parent.rx_indicate = RT_NULL;
+ serial->parent.tx_complete = RT_NULL;
+
/* Call the control() API to close the serial device */
serial->ops->control(serial, RT_DEVICE_CTRL_CLOSE, RT_NULL);
dev->flag &= ~RT_DEVICE_FLAG_ACTIVATED;