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

Function serial_fops_open

components/drivers/serial/dev_serial.c:73–107  ·  view source on GitHub ↗

fops for serial */

Source from the content-addressed store, hash-verified

71
72/* fops for serial */
73static int serial_fops_open(struct dfs_file *fd)
74{
75 rt_err_t ret = 0;
76 rt_uint16_t flags = 0;
77 rt_device_t device;
78
79 device = (rt_device_t)fd->vnode->data;
80 RT_ASSERT(device != RT_NULL);
81
82 switch (fd->flags & O_ACCMODE)
83 {
84 case O_RDONLY:
85 LOG_D("fops open: O_RDONLY!");
86 flags = RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_RDONLY;
87 break;
88 case O_WRONLY:
89 LOG_D("fops open: O_WRONLY!");
90 flags = RT_DEVICE_FLAG_WRONLY;
91 break;
92 case O_RDWR:
93 LOG_D("fops open: O_RDWR!");
94 flags = RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_RDWR;
95 break;
96 default:
97 LOG_E("fops open: unknown mode - %d!", fd->flags & O_ACCMODE);
98 break;
99 }
100
101 if ((fd->flags & O_ACCMODE) != O_WRONLY)
102 rt_device_set_rx_indicate(device, serial_fops_rx_ind);
103 ret = rt_device_open(device, flags);
104 if (ret == RT_EOK) return 0;
105
106 return ret;
107}
108
109static int serial_fops_close(struct dfs_file *fd)
110{

Callers

nothing calls this directly

Calls 2

rt_device_openFunction · 0.85

Tested by

no test coverage detected