提交 0613cf8c 编写于 作者: C chenjh

[serial] 解决serial_close未清除回调接口的问题

上级 5ac5d92c
......@@ -28,7 +28,7 @@ int rt_hw_usart_init(void);
#else
#define UART_SET_TDR(__HANDLE__, __DATA__) ((__HANDLE__)->Instance->DR = (__DATA__))
#define UART_GET_RDR(__HANDLE__) (return (__HANDLE__)->Instance->DR & 0xFF))
#define UART_GET_RDR(__HANDLE__) ((__HANDLE__)->Instance->DR & 0xFF)
#endif
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册