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

Function rt_serial_rx_disable

components/drivers/serial/dev_serial_v2.c:1031–1071  ·  view source on GitHub ↗

* @brief Disable serial receive 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

1029 * @return Return the status of the operation.
1030 */
1031static rt_err_t rt_serial_rx_disable(struct rt_device *dev,
1032 rt_uint16_t rx_oflag)
1033{
1034 struct rt_serial_device *serial;
1035 struct rt_serial_rx_fifo *rx_fifo;
1036
1037 RT_ASSERT(dev != RT_NULL);
1038 serial = (struct rt_serial_device *)dev;
1039
1040#ifndef RT_USING_DEVICE_OPS
1041 dev->read = RT_NULL;
1042#endif
1043
1044 if (serial->serial_rx == RT_NULL) return RT_EOK;
1045
1046 rx_fifo = (struct rt_serial_rx_fifo *)serial->serial_rx;
1047 RT_ASSERT(rx_fifo != RT_NULL);
1048
1049 if (rx_oflag == RT_SERIAL_RX_NON_BLOCKING)
1050 {
1051 dev->open_flag &= ~RT_SERIAL_RX_NON_BLOCKING;
1052 /* disable ignore return value */
1053 serial->ops->control(serial,
1054 RT_DEVICE_CTRL_CLR_INT,
1055 (void *)RT_SERIAL_RX_NON_BLOCKING);
1056 }
1057 else
1058 {
1059 rt_completion_done(&rx_fifo->rx_cpt);
1060 dev->open_flag &= ~RT_SERIAL_RX_BLOCKING;
1061 /* disable ignore return value */
1062 serial->ops->control(serial,
1063 RT_DEVICE_CTRL_CLR_INT,
1064 (void *)RT_SERIAL_RX_BLOCKING);
1065 }
1066
1067 rt_free(rx_fifo);
1068 serial->serial_rx = RT_NULL;
1069
1070 return RT_EOK;
1071}
1072
1073/**
1074 * @brief Disable serial tranmit mode.

Callers 1

rt_serial_closeFunction · 0.85

Calls 2

rt_completion_doneFunction · 0.85
rt_freeFunction · 0.85

Tested by

no test coverage detected