1 /* 2 * Copyright (c) 2006-2018, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2017/08/30 Bernard The first version 9 */ 10 #ifndef TERMIOS_H__ 11 #define TERMIOS_H__ 12 13 #include <rtthread.h> 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 typedef unsigned char cc_t; 20 typedef unsigned int speed_t; 21 typedef unsigned int tcflag_t; 22 23 #define NCCS 32 24 25 struct termios { 26 tcflag_t c_iflag; 27 tcflag_t c_oflag; 28 tcflag_t c_cflag; 29 tcflag_t c_lflag; 30 cc_t c_line; 31 cc_t c_cc[NCCS]; 32 speed_t __c_ispeed; 33 speed_t __c_ospeed; 34 }; 35 36 #define VINTR 0 37 #define VQUIT 1 38 #define VERASE 2 39 #define VKILL 3 40 #define VEOF 4 41 #define VTIME 5 42 #define VMIN 6 43 #define VSWTC 7 44 #define VSTART 8 45 #define VSTOP 9 46 #define VSUSP 10 47 #define VEOL 11 48 #define VREPRINT 12 49 #define VDISCARD 13 50 #define VWERASE 14 51 #define VLNEXT 15 52 #define VEOL2 16 53 54 #define IGNBRK 0000001 55 #define BRKINT 0000002 56 #define IGNPAR 0000004 57 #define PARMRK 0000010 58 #define INPCK 0000020 59 #define ISTRIP 0000040 60 #define INLCR 0000100 61 #define IGNCR 0000200 62 #define ICRNL 0000400 63 #define IUCLC 0001000 64 #define IXON 0002000 65 #define IXANY 0004000 66 #define IXOFF 0010000 67 #define IMAXBEL 0020000 68 #define IUTF8 0040000 69 70 #define OPOST 0000001 71 #define OLCUC 0000002 72 #define ONLCR 0000004 73 #define OCRNL 0000010 74 #define ONOCR 0000020 75 #define ONLRET 0000040 76 #define OFILL 0000100 77 #define OFDEL 0000200 78 #define NLDLY 0000400 79 #define NL0 0000000 80 #define NL1 0000400 81 #define CRDLY 0003000 82 #define CR0 0000000 83 #define CR1 0001000 84 #define CR2 0002000 85 #define CR3 0003000 86 #define TABDLY 0014000 87 #define TAB0 0000000 88 #define TAB1 0004000 89 #define TAB2 0010000 90 #define TAB3 0014000 91 #define BSDLY 0020000 92 #define BS0 0000000 93 #define BS1 0020000 94 #define FFDLY 0100000 95 #define FF0 0000000 96 #define FF1 0100000 97 98 #define VTDLY 0040000 99 #define VT0 0000000 100 #define VT1 0040000 101 102 #define B0 0000000 103 #define B50 0000001 104 #define B75 0000002 105 #define B110 0000003 106 #define B134 0000004 107 #define B150 0000005 108 #define B200 0000006 109 #define B300 0000007 110 #define B600 0000010 111 #define B1200 0000011 112 #define B1800 0000012 113 #define B2400 0000013 114 #define B4800 0000014 115 #define B9600 0000015 116 #define B19200 0000016 117 #define B38400 0000017 118 119 #define B57600 0010001 120 #define B115200 0010002 121 #define B230400 0010003 122 #define B460800 0010004 123 #define B500000 0010005 124 #define B576000 0010006 125 #define B921600 0010007 126 #define B1000000 0010010 127 #define B1152000 0010011 128 #define B1500000 0010012 129 #define B2000000 0010013 130 #define B2500000 0010014 131 #define B3000000 0010015 132 #define B3500000 0010016 133 #define B4000000 0010017 134 135 #define CSIZE 0000060 136 #define CS5 0000000 137 #define CS6 0000020 138 #define CS7 0000040 139 #define CS8 0000060 140 #define CSTOPB 0000100 141 #define CREAD 0000200 142 #define PARENB 0000400 143 #define PARODD 0001000 144 #define HUPCL 0002000 145 #define CLOCAL 0004000 146 147 #define ISIG 0000001 148 #define ICANON 0000002 149 #define ECHO 0000010 150 #define ECHOE 0000020 151 #define ECHOK 0000040 152 #define ECHONL 0000100 153 #define NOFLSH 0000200 154 #define TOSTOP 0000400 155 #define IEXTEN 0100000 156 157 #define TCOOFF 0 158 #define TCOON 1 159 #define TCIOFF 2 160 #define TCION 3 161 162 #define TCIFLUSH 0 163 #define TCOFLUSH 1 164 #define TCIOFLUSH 2 165 166 #define TCSANOW 0 167 #define TCSADRAIN 1 168 #define TCSAFLUSH 2 169 170 #define EXTA 0000016 171 #define EXTB 0000017 172 #define CBAUD 0010017 173 #define CBAUDEX 0010000 174 #define CIBAUD 002003600000 175 #define CMSPAR 010000000000 176 #define CRTSCTS 020000000000 177 178 #define XCASE 0000004 179 #define ECHOCTL 0001000 180 #define ECHOPRT 0002000 181 #define ECHOKE 0004000 182 #define FLUSHO 0010000 183 #define PENDIN 0040000 184 #define EXTPROC 0200000 185 186 #define XTABS 0014000 187 188 speed_t cfgetospeed (const struct termios *); 189 speed_t cfgetispeed (const struct termios *); 190 int cfsetospeed (struct termios *, speed_t); 191 int cfsetispeed (struct termios *, speed_t); 192 193 int tcgetattr (int, struct termios *); 194 int tcsetattr (int, int, const struct termios *); 195 196 int tcsendbreak (int, int); 197 int tcdrain (int); 198 int tcflush (int, int); 199 int tcflow (int, int); 200 201 pid_t tcgetsid (int); 202 203 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 204 void cfmakeraw(struct termios *); 205 int cfsetspeed(struct termios *, speed_t); 206 #endif 207 208 #ifdef __cplusplus 209 } 210 #endif 211 212 #endif 213