FreeCalypso > hg > freecalypso-reveng
annotate fluid-mnf/serial.c @ 357:ebb9377cf52c
fluid-mnf/machine.c: read operation time report message
changed to match the reality of the number being in ms, not s
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 13 Mar 2020 20:56:47 +0000 |
parents | 37b5f94de802 |
children | 49fe64a5e207 |
rev | line source |
---|---|
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * FLUID (Flash Loader Utility Independent of Device) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * Copyright Texas Instruments, 2001. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * Mads Meisner-Jensen, mmj@ti.com. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * Serial/UART driver |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 * |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * $Id: serial.c 1.23 Fri, 18 Oct 2002 08:53:12 +0200 mmj $ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
11 * This serial interface handling architecture has been majorly redesigned |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
12 * by Mychaela N. Falconia for the present fluid-mnf Linux port. |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
13 * |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
14 * Because FLUID supports Calypso high baud rates of 203125, 406250 and 812500 |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
15 * bps, as well as D-Sample XXO (eXternal Xtal Oscillator) baud rates of |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
16 * 230400, 460800 and 912600 bps, the present fluid-mnf port had to be made |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
17 * quite Linux-specific, using the same raw ioctl approach as is used in |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
18 * freecalypso-tools/libserial-linux. |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
19 * |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include "fluid.h" |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 #include "serial.h" |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #include "trace.h" |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
26 #include <sys/types.h> |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
27 #include <sys/file.h> |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
28 #include <sys/time.h> |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
29 #include <sys/ioctl.h> |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
30 #include <asm/ioctls.h> |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
31 #include <asm/termbits.h> |
344
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
32 #include <sys/errno.h> |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 #include <stdio.h> |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
34 #include <stdlib.h> |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
35 #include <string.h> |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
36 #include <unistd.h> |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 |
344
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
38 extern int errno; |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
39 |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 /****************************************************************************** |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
42 * Linux Driver |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
45 static int target_fd; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
46 static struct termios2 target_termios; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
47 |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
48 static void fill_termios(int bps) |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
49 { |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
50 int termios_baud_code; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
52 switch (bps) { |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
53 case 9600: |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
54 termios_baud_code = B9600; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
55 break; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
56 case 19200: |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
57 termios_baud_code = B19200; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
58 break; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
59 case 38400: |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
60 termios_baud_code = B38400; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
61 break; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
62 case 57600: |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
63 termios_baud_code = B57600; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
64 break; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
65 case 115200: |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
66 termios_baud_code = B115200; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
67 break; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
68 case 230400: |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
69 termios_baud_code = B230400; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
70 break; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
71 case 460800: |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
72 termios_baud_code = B460800; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
73 break; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
74 case 921600: |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
75 termios_baud_code = B921600; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
76 break; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
77 default: |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
78 termios_baud_code = BOTHER; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
79 } |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
80 target_termios.c_iflag = IGNBRK; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
81 target_termios.c_oflag = 0; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
82 target_termios.c_cflag = termios_baud_code | CLOCAL|HUPCL|CREAD|CS8; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
83 target_termios.c_lflag = 0; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
84 target_termios.c_cc[VMIN] = 1; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
85 target_termios.c_cc[VTIME] = 0; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
86 target_termios.c_ispeed = bps; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
87 target_termios.c_ospeed = bps; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
88 } |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 |
348
37b5f94de802
fluid-mnf: sensible target tty specification
Mychaela Falconia <falcon@freecalypso.org>
parents:
344
diff
changeset
|
90 int serial_init(char *ttyport, int bps) |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 { |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
92 static int zero = 0; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 |
348
37b5f94de802
fluid-mnf: sensible target tty specification
Mychaela Falconia <falcon@freecalypso.org>
parents:
344
diff
changeset
|
94 if (!ttyport) { |
37b5f94de802
fluid-mnf: sensible target tty specification
Mychaela Falconia <falcon@freecalypso.org>
parents:
344
diff
changeset
|
95 ttyport = getenv("FLUID_PORT"); |
37b5f94de802
fluid-mnf: sensible target tty specification
Mychaela Falconia <falcon@freecalypso.org>
parents:
344
diff
changeset
|
96 if (!ttyport) { |
37b5f94de802
fluid-mnf: sensible target tty specification
Mychaela Falconia <falcon@freecalypso.org>
parents:
344
diff
changeset
|
97 fprintf(stderr, |
37b5f94de802
fluid-mnf: sensible target tty specification
Mychaela Falconia <falcon@freecalypso.org>
parents:
344
diff
changeset
|
98 "fluid-mnf error: target tty port must be specified with -p or FLUID_PORT=\n"); |
37b5f94de802
fluid-mnf: sensible target tty specification
Mychaela Falconia <falcon@freecalypso.org>
parents:
344
diff
changeset
|
99 exit(-E_BADARG); |
37b5f94de802
fluid-mnf: sensible target tty specification
Mychaela Falconia <falcon@freecalypso.org>
parents:
344
diff
changeset
|
100 } |
37b5f94de802
fluid-mnf: sensible target tty specification
Mychaela Falconia <falcon@freecalypso.org>
parents:
344
diff
changeset
|
101 } |
37b5f94de802
fluid-mnf: sensible target tty specification
Mychaela Falconia <falcon@freecalypso.org>
parents:
344
diff
changeset
|
102 |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
103 target_fd = open(ttyport, O_RDWR|O_NONBLOCK); |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
104 if (target_fd < 0) |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
105 return E_OS + E_UART_INIT; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
106 ioctl(target_fd, TIOCEXCL); |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
107 fill_termios(bps); |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
108 if (ioctl(target_fd, TCSETSF2, &target_termios) < 0) |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
109 return E_OS + E_UART_INIT; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
110 ioctl(target_fd, FIONBIO, &zero); |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
112 if (arg_uart_level_convert) { |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
113 /* |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
114 * Powering TI's serial level converter |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
115 * with DTR = +12V and RTS = -12V |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
116 */ |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
117 serial_dtr(1); |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
118 serial_rts(0); |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
119 } |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
121 serial_reset(); |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
122 return 0; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 int serial_is_baudrate(int bps) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 int i; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 const struct rate_s { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 int bps; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 int baudrate; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 } rates[] = { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 { 9600, 9600 }, { 9, 9600 }, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 { 14400, 14400 }, { 14, 14400 }, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 { 19200, 19200 }, { 19, 19200 }, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 { 38400, 38400 }, { 38, 38400 }, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 { 57600, 57600 }, { 57, 57600 }, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 { 115200, 115200 }, { 115, 115200 }, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 { 203125, 203125 }, { 203, 203125 }, // 13MHz clock |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 { 230400, 230400 }, { 230, 230400 }, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 { 406250, 406250 }, { 406, 406250 }, // 13MHz clock |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 { 460800, 460800 }, { 460, 460800 }, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 { 812500, 812500 }, { 812, 812500 }, // 13MHz clock |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 { 921600, 921600 }, { 921, 921600 }, |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 { 0, 0 } // terminator |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 }; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 for (i = 0; i < sizeof(rates) / sizeof(struct rate_s) - 1; i++) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 if (rates[i].bps == bps) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 break; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 tr(TrTargetDrv, "serial_is_baudrate(%d) %d\n", bps, rates[i].baudrate); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 return rates[i].baudrate; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 int serial_baudrate_set(int bps) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 bps = serial_is_baudrate(bps); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 if (bps == 0) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 return E_OS + E_UART_PARAM; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
162 fill_termios(bps); |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
163 if (ioctl(target_fd, TCSETSF2, &target_termios) < 0) |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 return E_OS + E_UART_PARAM; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 return bps; |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 int serial_baudrate_get(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 { |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
171 return target_termios.c_ospeed; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 void serial_exit(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 serial_reset(); |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
177 close(target_fd); |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 // Clear buffers and transactions. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 void serial_reset(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 { |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
183 ioctl(target_fd, TCFLSH, TCIOFLUSH); |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 // Return the number of milli-seconds it takes to transfer <n> bytes. |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 int serial_transfer_time(int size) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 return 1000 * 10 * size / serial_baudrate_get(); |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 /*************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 * Send |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 ***************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 int serial_send(char *buf, int size) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 { |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
199 int cc; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
201 cc = write(target_fd, buf, size); |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
202 if (cc < 0) |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
203 cc = E_OS + E_UART_DRV_SEND; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
204 return cc; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 /*************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 * Receive |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 ***************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 void serial_recv_reset(void) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 { |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
214 ioctl(target_fd, TCFLSH, TCIFLUSH); |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
217 int serial_recv(char *buf, int size, int timeout) |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 { |
344
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
219 fd_set fds; |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
220 struct timeval tv; |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
221 int cc; |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
222 |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
223 for (;;) { |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
224 FD_ZERO(&fds); |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
225 FD_SET(target_fd, &fds); |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
226 tv.tv_sec = timeout / 1000; |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
227 tv.tv_usec = (timeout % 1000) * 1000; |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
228 cc = select(target_fd+1, &fds, NULL, NULL, &tv); |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
229 if (cc < 0) { |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
230 if (errno == EINTR) |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
231 continue; |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
232 return E_OS + E_UART_DRV_RECV; |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
233 } |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
234 break; |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
235 } |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
236 if (cc == 0) |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
237 return cc; |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
238 cc = read(target_fd, buf, size); |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
239 if (cc <= 0) |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
240 cc = E_OS + E_UART_DRV_RECV; |
2bd27d940023
fluid-mnf/serial.c: serial_recv() implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
343
diff
changeset
|
241 return cc; |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 /****************************************************************************** |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 * Control of Delta cable special outputs |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 ******************************************************************************/ |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 void serial_rts(char state) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 { |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
251 int rts_arg = TIOCM_RTS; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
252 |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 if (state) |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
254 ioctl(target_fd, TIOCMBIS, &rts_arg); |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 else |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
256 ioctl(target_fd, TIOCMBIC, &rts_arg); |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 void serial_dtr(char state) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 { |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
261 int dtr_arg = TIOCM_DTR; |
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
262 |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 if (state) |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
264 ioctl(target_fd, TIOCMBIS, &dtr_arg); |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 else |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
266 ioctl(target_fd, TIOCMBIC, &dtr_arg); |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 } |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 void serial_break(char state) |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 { |
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 if (state) |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
272 ioctl(target_fd, TIOCSBRK); |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 else |
342
6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
Mychaela Falconia <falcon@freecalypso.org>
parents:
311
diff
changeset
|
274 ioctl(target_fd, TIOCCBRK); |
311
9cecc930d78f
fluid-mnf: original source from TI,
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 } |