* @brief Close the serial device. * @param dev The pointer of device driver structure * @return Return the status of the operation. */
| 1149 | * @return Return the status of the operation. |
| 1150 | */ |
| 1151 | static rt_err_t rt_serial_close(struct rt_device *dev) |
| 1152 | { |
| 1153 | struct rt_serial_device *serial; |
| 1154 | |
| 1155 | RT_ASSERT(dev != RT_NULL); |
| 1156 | serial = (struct rt_serial_device *)dev; |
| 1157 | |
| 1158 | /* Disable serial receive mode. */ |
| 1159 | rt_serial_rx_disable(dev, dev->open_flag & (RT_SERIAL_RX_BLOCKING | RT_SERIAL_RX_NON_BLOCKING)); |
| 1160 | /* Disable serial tranmit mode. */ |
| 1161 | rt_serial_tx_disable(dev, dev->open_flag & (RT_SERIAL_TX_BLOCKING | RT_SERIAL_TX_NON_BLOCKING)); |
| 1162 | |
| 1163 | /* Clear the callback function */ |
| 1164 | serial->parent.rx_indicate = RT_NULL; |
| 1165 | serial->parent.tx_complete = RT_NULL; |
| 1166 | |
| 1167 | rt_memset(&serial->rx_notify, RT_NULL, sizeof(struct rt_device_notify)); |
| 1168 | |
| 1169 | /* Call the control() API to close the serial device. disable ignore return value */ |
| 1170 | serial->ops->control(serial, RT_DEVICE_CTRL_CLOSE, RT_NULL); |
| 1171 | dev->flag &= ~RT_DEVICE_FLAG_ACTIVATED; |
| 1172 | |
| 1173 | return RT_EOK; |
| 1174 | } |
| 1175 | |
| 1176 | /** |
| 1177 | * @brief Open the serial device. |
no test coverage detected