|
2
|
1 //========================================================================== |
|
|
2 // |
|
|
3 // io/serial/common/haldiag.c |
|
|
4 // |
|
|
5 // Serial I/O interface module using HAL I/O routines |
|
|
6 // |
|
|
7 //========================================================================== |
|
|
8 //####COPYRIGHTBEGIN#### |
|
|
9 // |
|
|
10 // ------------------------------------------- |
|
|
11 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
12 // Version 1.0 (the "License"); you may not use this file except in |
|
|
13 // compliance with the License. You may obtain a copy of the License at |
|
|
14 // http://sourceware.cygnus.com/ecos |
|
|
15 // |
|
|
16 // Software distributed under the License is distributed on an "AS IS" |
|
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
18 // License for the specific language governing rights and limitations under |
|
|
19 // the License. |
|
|
20 // |
|
|
21 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
22 // September 30, 1998. |
|
|
23 // |
|
|
24 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
|
25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
|
26 // ------------------------------------------- |
|
|
27 // |
|
|
28 //####COPYRIGHTEND#### |
|
|
29 //========================================================================== |
|
|
30 //#####DESCRIPTIONBEGIN#### |
|
|
31 // |
|
|
32 // Author(s): gthomas |
|
|
33 // Contributors: gthomas |
|
|
34 // Date: 1999-02-04 |
|
|
35 // Purpose: HAL/diag serial driver |
|
|
36 // Description: |
|
|
37 // |
|
|
38 //####DESCRIPTIONEND#### |
|
|
39 // |
|
|
40 //========================================================================== |
|
|
41 |
|
|
42 #include <pkgconf/io.h> |
|
|
43 #include <pkgconf/io_serial.h> |
|
|
44 #ifdef CYGPKG_IO_SERIAL_HALDIAG |
|
|
45 #include <cyg/io/io.h> |
|
|
46 #include <cyg/io/devtab.h> |
|
|
47 #include <cyg/io/serial.h> |
|
|
48 #include <cyg/infra/diag.h> |
|
|
49 #include <cyg/hal/hal_diag.h> |
|
|
50 |
|
|
51 static bool haldiag_init(struct cyg_devtab_entry *tab); |
|
|
52 static bool haldiag_putc(serial_channel *chan, unsigned char c); |
|
|
53 static unsigned char haldiag_getc(serial_channel *chan); |
|
|
54 static bool haldiag_set_config(serial_channel *chan, cyg_serial_info_t *config); |
|
|
55 |
|
|
56 static SERIAL_FUNS(haldiag_funs, |
|
|
57 haldiag_putc, |
|
|
58 haldiag_getc, |
|
|
59 haldiag_set_config, |
|
|
60 0, // start xmit - not used |
|
|
61 0 // stop xmit - not used |
|
|
62 ); |
|
|
63 |
|
|
64 static int _no_data; |
|
|
65 SERIAL_CHANNEL(haldiag_channel0, |
|
|
66 haldiag_funs, |
|
|
67 _no_data, |
|
|
68 CYG_SERIAL_BAUD_DEFAULT, |
|
|
69 CYG_SERIAL_STOP_DEFAULT, |
|
|
70 CYG_SERIAL_PARITY_DEFAULT, |
|
|
71 CYG_SERIAL_WORD_LENGTH_DEFAULT, |
|
|
72 CYG_SERIAL_FLAGS_DEFAULT |
|
|
73 ); |
|
|
74 DEVTAB_ENTRY(haldiag_io0, |
|
|
75 "/dev/haldiag", |
|
|
76 0, // Does not depend on a lower level interface |
|
|
77 &serial_devio, |
|
|
78 haldiag_init, |
|
|
79 0, // No initialization/lookup needed |
|
|
80 &haldiag_channel0); |
|
|
81 |
|
|
82 static void |
|
|
83 haldiag_config_port(serial_channel *chan) |
|
|
84 { |
|
|
85 } |
|
|
86 |
|
|
87 static bool |
|
|
88 haldiag_init(struct cyg_devtab_entry *tab) |
|
|
89 { |
|
|
90 serial_channel *chan = (serial_channel *)tab->priv; |
|
|
91 #ifdef CYGDBG_IO_INIT |
|
|
92 diag_printf("HAL/diag SERIAL init\n"); |
|
|
93 #endif |
|
|
94 haldiag_config_port(chan); |
|
|
95 return true; |
|
|
96 } |
|
|
97 |
|
|
98 // Return 'true' if character is sent to device |
|
|
99 static bool |
|
|
100 haldiag_putc(serial_channel *chan, unsigned char c) |
|
|
101 { |
|
|
102 HAL_DIAG_WRITE_CHAR(c); |
|
|
103 return true; |
|
|
104 } |
|
|
105 |
|
|
106 static unsigned char |
|
|
107 haldiag_getc(serial_channel *chan) |
|
|
108 { |
|
|
109 unsigned char c; |
|
|
110 HAL_DIAG_READ_CHAR(c); |
|
|
111 return c; |
|
|
112 } |
|
|
113 |
|
|
114 static bool |
|
|
115 haldiag_set_config(serial_channel *chan, cyg_serial_info_t *config) |
|
|
116 { |
|
|
117 diag_printf("%s\n", __FUNCTION__); |
|
|
118 return true; |
|
|
119 } |
|
|
120 #endif // CYGPKG_IO_SERIAL_HALDIAG |