1 // Copyright 2018 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "sdkconfig.h"
16 
17 #ifdef CONFIG_VFS_SUPPORT_TERMIOS
18 
19 #include <sys/termios.h>
20 #include <sys/errno.h>
21 
cfgetispeed(const struct termios * p)22 speed_t cfgetispeed(const struct termios *p)
23 {
24     return p ? p->c_ispeed : B0;
25 }
26 
cfgetospeed(const struct termios * p)27 speed_t cfgetospeed(const struct termios *p)
28 {
29     return p ? p->c_ospeed : B0;
30 }
31 
cfsetispeed(struct termios * p,speed_t sp)32 int cfsetispeed(struct termios *p, speed_t sp)
33 {
34     if (p) {
35         p->c_ispeed = sp;
36         return 0;
37     } else {
38         errno = EINVAL;
39         return -1;
40     }
41 }
42 
cfsetospeed(struct termios * p,speed_t sp)43 int cfsetospeed(struct termios *p, speed_t sp)
44 {
45     if (p) {
46         p->c_ospeed = sp;
47         return 0;
48     } else {
49         errno = EINVAL;
50         return -1;
51     }
52 }
53 
54 #endif // CONFIG_VFS_SUPPORT_TERMIOS
55