MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_serial_tx_disable

Function rt_serial_tx_disable

components/drivers/serial/dev_serial_v2.c:1079–1119  ·  view source on GitHub ↗

* @brief Disable serial tranmit mode. * @param dev The pointer of device driver structure * @param rx_oflag The flag of that the serial port opens. * @return Return the status of the operation. */

Source from the content-addressed store, hash-verified

1077 * @return Return the status of the operation.
1078 */
1079static rt_err_t rt_serial_tx_disable(struct rt_device *dev,
1080 rt_uint16_t tx_oflag)
1081{
1082 struct rt_serial_device *serial;
1083 struct rt_serial_tx_fifo *tx_fifo;
1084
1085 RT_ASSERT(dev != RT_NULL);
1086 serial = (struct rt_serial_device *)dev;
1087
1088#ifndef RT_USING_DEVICE_OPS
1089 dev->write = RT_NULL;
1090#endif
1091
1092 if (serial->serial_tx == RT_NULL) return RT_EOK;
1093
1094 tx_fifo = (struct rt_serial_tx_fifo *)serial->serial_tx;
1095 RT_ASSERT(tx_fifo != RT_NULL);
1096
1097 if (tx_oflag == RT_SERIAL_TX_NON_BLOCKING)
1098 {
1099 dev->open_flag &= ~RT_SERIAL_TX_NON_BLOCKING;
1100 /* disable ignore return value */
1101 serial->ops->control(serial,
1102 RT_DEVICE_CTRL_CLR_INT,
1103 (void *)RT_SERIAL_TX_NON_BLOCKING);
1104 }
1105 else
1106 {
1107 rt_completion_done(&tx_fifo->tx_cpt);
1108 dev->open_flag &= ~RT_SERIAL_TX_BLOCKING;
1109 /* disable ignore return value */
1110 serial->ops->control(serial,
1111 RT_DEVICE_CTRL_CLR_INT,
1112 (void *)RT_SERIAL_TX_BLOCKING);
1113 }
1114
1115
1116 rt_free(tx_fifo);
1117 serial->serial_tx = RT_NULL;
1118 return RT_EOK;
1119}
1120
1121/**
1122 * @brief Initialize the serial device.

Callers 1

rt_serial_closeFunction · 0.85

Calls 2

rt_completion_doneFunction · 0.85
rt_freeFunction · 0.85

Tested by

no test coverage detected