FreeCalypso > hg > freecalypso-tools
annotate libserial-posix/baudtab.c @ 999:30fad2b3afd2
doc/Flash-write-protection: document flash lock-state retrieval
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 04 Dec 2023 20:40:50 +0000 |
parents | 0a6184443821 |
children |
rev | line source |
---|---|
248
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module contains the table of baud rates supported |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * by this implementation of FreeCalypso libserial. |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <strings.h> |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <termios.h> |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "baudrate.h" |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 struct baudrate baud_rate_table[] = { |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 /* the first listed rate will be our default */ |
654
39b39b546824
libserial-orig: same xram_records baudtab addition as in libserial-newlnx
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
15 {"115200", B115200, 0, 100}, |
39b39b546824
libserial-orig: same xram_records baudtab addition as in libserial-newlnx
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
16 {"57600", B57600, 1, 100}, |
39b39b546824
libserial-orig: same xram_records baudtab addition as in libserial-newlnx
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
17 {"38400", B38400, 2, 100}, |
39b39b546824
libserial-orig: same xram_records baudtab addition as in libserial-newlnx
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
18 {"19200", B19200, 4, 50}, |
248
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 /* |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 * Non-standard high baud rates remapped by CP2102 EEPROM programming |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 * or by a hacky patch to the ftdi_sio Linux kernel driver to work |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 * with FTDI adapters. |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 */ |
654
39b39b546824
libserial-orig: same xram_records baudtab addition as in libserial-newlnx
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
24 {"812500", B921600, -1, 1000}, |
39b39b546824
libserial-orig: same xram_records baudtab addition as in libserial-newlnx
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
25 {"406250", B460800, -1, 500}, |
39b39b546824
libserial-orig: same xram_records baudtab addition as in libserial-newlnx
Mychaela Falconia <falcon@freecalypso.org>
parents:
248
diff
changeset
|
26 {"203125", B230400, -1, 250}, |
248
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 /* table search terminator */ |
662
0a6184443821
libserial-posix/baudtab.c: cosmetic bugfix
Mychaela Falconia <falcon@freecalypso.org>
parents:
661
diff
changeset
|
28 {NULL, B0, -1, 0}, |
248
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 }; |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 struct baudrate * |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 find_baudrate_by_name(srch_name) |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 char *srch_name; |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 { |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 struct baudrate *br; |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 for (br = baud_rate_table; br->name; br++) |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 if (!strcmp(br->name, srch_name)) |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 break; |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 if (br->name) |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 return(br); |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 else { |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 fprintf(stderr, "error: baud rate \"%s\" not known\n", |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 srch_name); |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 return(NULL); |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 } |
cb1ba53a1106
beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } |