O2S C Library
1.8.2
Provide high-level data-structures and other fundamental tools for C projects
Loading...
Searching...
No Matches
baudrate.c
1
/* ************************************************************************** */
2
/* ____ _ _____ ____ _ _ _ _____ _ _ ____ ____ */
3
/* / ___| / \ | ___| _ \ / \ | \ | | |_ _| || | | _ \/ ___| */
4
/* \___ \ / _ \ | |_ | |_) | / _ \ | \| | | | | || |_| | | \___ \ */
5
/* ___) / ___ \| _| | _ < / ___ \| |\ | | | |__ _| |_| |___) | */
6
/* |____/_/ \_|_| |_| \_/_/ \_|_| \_| |_| |_| |____/|____/ */
7
/* */
8
/* Copyright 2023, SAFRAN T4DS, ALL RIGHTS RESERVED */
9
/* */
10
/* @file baudrate.c */
11
/* @author Antoine GAGNIERE */
12
/* */
13
/* ************************************************************************** */
14
15
#include "
o2s/serial.h
"
16
17
#include <termios.h>
18
19
#include <stdint.h>
20
28
int64_t serial_decode_baudrate(speed_t flag)
29
{
30
switch
(flag)
31
{
32
case
B0:
return
0;
33
case
B50:
return
50;
34
case
B75:
return
75;
35
case
B110:
return
110;
36
case
B134:
return
134;
37
case
B150:
return
150;
38
case
B200:
return
200;
39
case
B300:
return
300;
40
case
B600:
return
600;
41
case
B1200:
return
1200;
42
case
B1800:
return
1800;
43
case
B2400:
return
2400;
44
case
B4800:
return
4800;
45
case
B9600:
return
9600;
46
case
B19200:
return
19200;
47
case
B38400:
return
38400;
48
case
B57600:
return
57600;
49
case
B115200:
return
115200;
50
case
B230400:
return
230400;
51
case
B460800:
return
460800;
52
case
B500000:
return
500000;
53
case
B576000:
return
576000;
54
case
B921600:
return
921600;
55
case
B1000000:
return
1000000;
56
case
B1152000:
return
1152000;
57
case
B1500000:
return
1500000;
58
case
B2000000:
return
2000000;
59
case
B2500000:
return
2500000;
60
case
B3000000:
return
3000000;
61
case
B3500000:
return
3500000;
62
case
B4000000:
return
4000000;
63
}
64
return
-1;
65
}
66
74
speed_t serial_encode_baudrate(int64_t speed_in_bps)
75
{
76
switch
(speed_in_bps)
77
{
78
case
0:
return
B0;
79
case
50:
return
B50;
80
case
75:
return
B75;
81
case
110:
return
B110;
82
case
134:
return
B134;
83
case
150:
return
B150;
84
case
200:
return
B200;
85
case
300:
return
B300;
86
case
600:
return
B600;
87
case
1200:
return
B1200;
88
case
1800:
return
B1800;
89
case
2400:
return
B2400;
90
case
4800:
return
B4800;
91
case
9600:
return
B9600;
92
case
19200:
return
B19200;
93
case
38400:
return
B38400;
94
case
57600:
return
B57600;
95
case
115200:
return
B115200;
96
case
230400:
return
B230400;
97
case
460800:
return
B460800;
98
case
500000:
return
B500000;
99
case
576000:
return
B576000;
100
case
921600:
return
B921600;
101
case
1000000:
return
B1000000;
102
case
1152000:
return
B1152000;
103
case
1500000:
return
B1500000;
104
case
2000000:
return
B2000000;
105
case
2500000:
return
B2500000;
106
case
3000000:
return
B3000000;
107
case
3500000:
return
B3500000;
108
case
4000000:
return
B4000000;
109
}
110
return
0;
111
}
serial.h
Configure and read from serial ports as buffered input streams.
src
serial
baudrate.c
Generated on
for O2S C Library by
1.14.0