annotate libserial-newlnx/baudtab.c @ 254:6984b76f3def

beginning of libserial-newlnx: copy of libserial-orig
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 22 Sep 2017 00:09:37 +0000
parents
children ab8410d06ca7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
254
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module contains the table of baud rates supported
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * by this implementation of FreeCalypso libserial.
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdlib.h>
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <string.h>
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <strings.h>
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <termios.h>
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "baudrate.h"
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 struct baudrate baud_rate_table[] = {
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 /* the first listed rate will be our default */
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 {"115200", B115200, 0},
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 {"57600", B57600, 1},
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 {"38400", B38400, 2},
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 {"19200", B19200, 4},
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 /*
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 * Non-standard high baud rates remapped by CP2102 EEPROM programming
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 * or by a hacky patch to the ftdi_sio Linux kernel driver to work
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 * with FTDI adapters.
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 */
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 {"812500", B921600, -1},
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 {"406250", B460800, -1},
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 {"203125", B230400, -1},
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 /* table search terminator */
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 {NULL, B0, -1},
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 };
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 struct baudrate *
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 find_baudrate_by_name(srch_name)
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 char *srch_name;
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 {
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 struct baudrate *br;
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 for (br = baud_rate_table; br->name; br++)
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 if (!strcmp(br->name, srch_name))
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 break;
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 if (br->name)
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 return(br);
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 else {
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 fprintf(stderr, "error: baud rate \"%s\" not known\n",
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 srch_name);
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 return(NULL);
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 }
6984b76f3def beginning of libserial-newlnx: copy of libserial-orig
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 }