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

Function serial_cfg_from_args

components/drivers/serial/serial_dm.c:91–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91struct serial_configure serial_cfg_from_args(char *_str)
92{
93 char *str = _str;
94 struct serial_configure cfg = RT_SERIAL_CONFIG_DEFAULT;
95
96 /* Format baudrate/parity/bits/flow (BBBBPNF), Default is 115200n8 */
97 if (str && *str)
98 {
99 rt_uint32_t baudrate = 0;
100
101 /* BBBB is the speed */
102 while (*str && (*str >= '0' && *str <= '9'))
103 {
104 baudrate *= 10;
105 baudrate += *str - '0';
106 ++str;
107 }
108
109 if (baudrate)
110 {
111 cfg.baud_rate = baudrate;
112 }
113
114 /* P is parity (n/o/e) */
115 switch (*str)
116 {
117 case 'n':
118 cfg.parity = PARITY_NONE;
119 break;
120 case 'o':
121 cfg.parity = PARITY_ODD;
122 break;
123 case 'e':
124 cfg.parity = PARITY_EVEN;
125 break;
126 default:
127 --str;
128 break;
129 }
130 ++str;
131
132 /* N is number of bits */
133 if (*str && (*str >= '0' && *str <= '9'))
134 {
135 cfg.data_bits = *str - '0';
136 ++str;
137 }
138
139 /* F is flow ontrol ('r' for RTS) */
140 if (*str)
141 {
142 cfg.flowcontrol = (*str == 'r' ? RT_SERIAL_FLOWCONTROL_CTSRTS : RT_SERIAL_FLOWCONTROL_NONE);
143 ++str;
144 }
145
146 #ifdef RT_USING_OFW
147 if (*str == '\0')
148 {

Callers 2

rt_ofw_console_setupFunction · 0.85
serial8250_configFunction · 0.85

Calls 2

rt_strcmpFunction · 0.85
rt_memsetFunction · 0.85

Tested by

no test coverage detected