Mercurial > ecos-v3_0-branch
annotate packages/devs/can/loop/current/src/loop_can.c @ 2863:7d8c61e6225c default tip
* Added execute permissions to files missed in conversion from CVS
| author | alexs |
|---|---|
| date | Thu, 26 Mar 2009 20:39:18 +0000 |
| parents | 3caad2060bd3 |
| children |
| rev | line source |
|---|---|
|
2830
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
1 //========================================================================== |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
2 // |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
3 // loop_can.c |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
4 // |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
5 // Loopback CAN device driver |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
6 // |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
7 //========================================================================== |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
8 // ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
9 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
10 // This file is part of eCos, the Embedded Configurable Operating System. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
12 // |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
13 // eCos is free software; you can redistribute it and/or modify it under |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
14 // the terms of the GNU General Public License as published by the Free |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
15 // Software Foundation; either version 2 or (at your option) any later |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
16 // version. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
17 // |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
18 // eCos is distributed in the hope that it will be useful, but WITHOUT |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
21 // for more details. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
22 // |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
23 // You should have received a copy of the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
24 // along with eCos; if not, write to the Free Software Foundation, Inc., |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
26 // |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
27 // As a special exception, if other files instantiate templates or use |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
28 // macros or inline functions from this file, or you compile this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
29 // and link it with other works to produce a work based on this file, |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
30 // this file does not by itself cause the resulting work to be covered by |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
31 // the GNU General Public License. However the source code for this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
32 // must still be made available in accordance with section (3) of the GNU |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
33 // General Public License v2. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
34 // |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
35 // This exception does not invalidate any other reasons why a work based |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
36 // on this file might be covered by the GNU General Public License. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
37 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2424
diff
changeset
|
38 // ####ECOSGPLCOPYRIGHTEND#### |
|
2830
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
39 //========================================================================== |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
40 //#####DESCRIPTIONBEGIN#### |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
41 // |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
42 // Author(s): Uwe Kindler |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
43 // Contributors: Uwe Kindler |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
44 // Date: 2005-07-10 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
45 // Purpose: Loopback CAN device driver |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
46 // Description: This device driver implements a pair of CAN lines that are |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
47 // connected back-to-back. Data output to one will appear as |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
48 // input on the other. This process in part driven by an alarm |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
49 // object which provides a degree of separation between the two |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
50 // channels. |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
51 // |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
52 //####DESCRIPTIONEND#### |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
53 // |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
54 //========================================================================== |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
55 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
56 #include <pkgconf/hal.h> |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
57 #include <pkgconf/io_can.h> |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
58 #include <pkgconf/devs_can_loop.h> |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
59 #include <cyg/hal/hal_io.h> |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
60 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
61 #include <cyg/io/io.h> |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
62 #include <cyg/io/devtab.h> |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
63 #include <cyg/io/can.h> |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
64 #include <cyg/hal/hal_intr.h> |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
65 #include <cyg/kernel/kapi.h> |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
66 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
67 #ifdef CYGPKG_DEVS_CAN_LOOP |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
68 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
69 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
70 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
71 extern void diag_printf(const char *fmt, ...); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
72 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
73 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
74 // Forward definitions |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
75 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
76 static bool loop_can_init(struct cyg_devtab_entry *devtab_entry); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
77 static bool loop_can_putmsg(can_channel *priv, cyg_can_message *pmsg, void *pdata); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
78 static Cyg_ErrNo loop_can_lookup(struct cyg_devtab_entry **tab, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
79 struct cyg_devtab_entry *sub_tab, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
80 const char *name); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
81 static bool loop_can_getevent(can_channel *priv, cyg_can_event *pevent, void *pdata); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
82 static Cyg_ErrNo loop_can_set_config(can_channel *chan, cyg_uint32 key, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
83 const void *xbuf, cyg_uint32 *len); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
84 static Cyg_ErrNo loop_can_get_config(can_channel *chan, cyg_uint32 key, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
85 const void* buf, cyg_uint32* len); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
86 static void loop_can_start_xmit(can_channel *chan); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
87 static void loop_can_stop_xmit(can_channel *chan); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
88 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
89 static void alarm_handler(cyg_handle_t alarm, cyg_addrword_t data); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
90 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
91 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
92 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
93 // Alarm object for feeding data back into CAN channels |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
94 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
95 static cyg_alarm alarm_obj; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
96 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
97 static cyg_handle_t alarm_handle; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
98 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
99 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
100 // Transfer FIFOs |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
101 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
102 #define FIFO_SIZE 33 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
103 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
104 struct fifo |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
105 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
106 cyg_bool tx_enable; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
107 volatile int head; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
108 volatile int tail; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
109 volatile int num; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
110 volatile cyg_can_event buf[FIFO_SIZE+1]; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
111 }; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
112 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
113 static struct fifo fifo0 = { false, 0, 0, 0 }; // from CAN0 to CAN1 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
114 static struct fifo fifo1 = { false, 0, 0, 0 }; // from CAN1 to CAN0 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
115 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
116 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
117 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
118 #define BUFSIZE 128 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
119 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
120 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
121 // Info for each serial device controlled |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
122 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
123 typedef struct loop_can_info { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
124 struct fifo *write_fifo; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
125 struct fifo *read_fifo; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
126 } loop_can_info; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
127 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
128 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
129 // Callback functions exported by this driver |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
130 CAN_LOWLEVEL_FUNS(loop_can_lowlevel_funs, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
131 loop_can_putmsg, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
132 loop_can_getevent, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
133 loop_can_get_config, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
134 loop_can_set_config, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
135 loop_can_start_xmit, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
136 loop_can_stop_xmit |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
137 ); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
138 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
139 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
140 // Hardware info for each serial line |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
141 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
142 #ifdef CYGPKG_DEVS_CAN_LOOP_CAN0 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
143 static loop_can_info loop_can_info0 = { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
144 &fifo0, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
145 &fifo1 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
146 }; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
147 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
148 static cyg_can_message loop_can_txbuf0[CYGNUM_DEVS_CAN_LOOP_CAN0_QUEUESIZE_TX]; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
149 static cyg_can_event loop_can_rxbuf0[CYGNUM_DEVS_CAN_LOOP_CAN0_QUEUESIZE_RX]; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
150 #endif // CYGPKG_IO_SERIAL_LOOP_SERIAL0 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
151 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
152 #ifdef CYGPKG_DEVS_CAN_LOOP_CAN1 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
153 static loop_can_info loop_can_info1 = { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
154 &fifo1, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
155 &fifo0 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
156 }; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
157 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
158 static cyg_can_message loop_can_txbuf1[CYGNUM_DEVS_CAN_LOOP_CAN1_QUEUESIZE_TX]; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
159 static cyg_can_event loop_can_rxbuf1[CYGNUM_DEVS_CAN_LOOP_CAN1_QUEUESIZE_RX]; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
160 #endif // CYGPKG_IO_SERIAL_LOOP_SERIAL1 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
161 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
162 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
163 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
164 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
165 // Channel descriptions: |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
166 // |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
167 #ifdef CYGPKG_DEVS_CAN_LOOP_CAN0 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
168 CAN_CHANNEL_USING_INTERRUPTS(loop_can0_chan, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
169 loop_can_lowlevel_funs, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
170 loop_can_info0, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
171 CYG_CAN_BAUD_RATE(CYGNUM_DEVS_CAN_LOOP_CAN0_KBAUD), |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
172 loop_can_txbuf0, CYGNUM_DEVS_CAN_LOOP_CAN0_QUEUESIZE_TX, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
173 loop_can_rxbuf0, CYGNUM_DEVS_CAN_LOOP_CAN0_QUEUESIZE_RX |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
174 ); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
175 #endif // CYGPKG_DEVS_CAN_LOOP_CAN1 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
176 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
177 #ifdef CYGPKG_DEVS_CAN_LOOP_CAN1 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
178 CAN_CHANNEL_USING_INTERRUPTS(loop_can1_chan, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
179 loop_can_lowlevel_funs, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
180 loop_can_info1, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
181 CYG_CAN_BAUD_RATE(CYGNUM_DEVS_CAN_LOOP_CAN1_KBAUD), |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
182 loop_can_txbuf1, CYGNUM_DEVS_CAN_LOOP_CAN1_QUEUESIZE_TX, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
183 loop_can_rxbuf1, CYGNUM_DEVS_CAN_LOOP_CAN1_QUEUESIZE_RX |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
184 ); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
185 #endif // CYGPKG_DEVS_CAN_LOOP_CAN1 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
186 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
187 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
188 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
189 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
190 // And finally, the device table entries: |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
191 // |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
192 #ifdef CYGPKG_DEVS_CAN_LOOP_CAN0 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
193 DEVTAB_ENTRY(loop_can_io0, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
194 CYGDAT_DEVS_CAN_LOOP_CAN0_NAME, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
195 0, // Does not depend on a lower level interface |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
196 &cyg_io_can_devio, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
197 loop_can_init, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
198 loop_can_lookup, // CAN driver may need initializing |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
199 &loop_can0_chan |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
200 ); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
201 #endif // CYGPKG_DEVS_CAN_LOOP_CAN0 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
202 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
203 #ifdef CYGPKG_DEVS_CAN_LOOP_CAN1 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
204 DEVTAB_ENTRY(loop_can_io1, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
205 CYGDAT_DEVS_CAN_LOOP_CAN1_NAME, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
206 0, // Does not depend on a lower level interface |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
207 &cyg_io_can_devio, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
208 loop_can_init, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
209 loop_can_lookup, // CAN driver may need initializing |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
210 &loop_can1_chan |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
211 ); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
212 #endif // CYGPKG_DEVS_CAN_LOOP_CAN1 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
213 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
214 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
215 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
216 static bool |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
217 loop_can_config_channel(can_channel *chan, cyg_can_info_t *new_config, bool init) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
218 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
219 if (new_config != &chan->config) { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
220 chan->config = *new_config; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
221 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
222 return true; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
223 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
224 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
225 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
226 // Function to initialize the device. Called at bootstrap time. |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
227 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
228 bool loop_can_init(struct cyg_devtab_entry *tab) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
229 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
230 can_channel *chan = (can_channel *)tab->priv; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
231 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
232 (chan->callbacks->can_init)(chan); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
233 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
234 // Set up alarm for feeding data back into channels |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
235 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
236 cyg_alarm_create( cyg_real_time_clock(), |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
237 alarm_handler, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
238 0, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
239 &alarm_handle, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
240 &alarm_obj); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
241 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
242 cyg_alarm_initialize( alarm_handle, 1, 1 ); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
243 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
244 loop_can_config_channel(chan, &chan->config, true); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
245 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
246 return true; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
247 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
248 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
249 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
250 // This routine is called when the device is "looked" up (i.e. attached) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
251 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
252 static Cyg_ErrNo |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
253 loop_can_lookup(struct cyg_devtab_entry **tab, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
254 struct cyg_devtab_entry *sub_tab, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
255 const char *name) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
256 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
257 can_channel *chan = (can_channel *)(*tab)->priv; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
258 (chan->callbacks->can_init)(chan); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
259 return ENOERR; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
260 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
261 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
262 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
263 // Return 'true' if message is sent to device |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
264 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
265 bool |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
266 loop_can_putmsg(can_channel *chan, cyg_can_message *pmsg, void *pdata) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
267 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
268 loop_can_info *loop_chan = (loop_can_info *)chan->dev_priv; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
269 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
270 struct fifo *fwr = loop_chan->write_fifo; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
271 #ifdef CYGOPT_IO_CAN_TX_EVENT_SUPPORT |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
272 struct fifo *frd = loop_chan->read_fifo; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
273 #endif |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
274 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
275 if( fwr->num == FIFO_SIZE ) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
276 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
277 return false; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
278 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
279 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
280 fwr->buf[fwr->tail].msg = *pmsg; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
281 fwr->buf[fwr->tail].flags = CYGNUM_CAN_EVENT_RX; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
282 fwr->num++; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
283 fwr->tail = (fwr->tail + 1) % FIFO_SIZE; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
284 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
285 #ifdef CYGOPT_IO_CAN_TX_EVENT_SUPPORT |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
286 // |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
287 // if TX events are supported we insert a TX event into read fifo |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
288 // |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
289 if( frd->num < FIFO_SIZE ) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
290 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
291 frd->buf[frd->tail].msg = *pmsg; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
292 frd->buf[frd->tail].flags = CYGNUM_CAN_EVENT_TX; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
293 frd->num++; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
294 frd->tail = (frd->tail + 1) % FIFO_SIZE; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
295 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
296 #endif |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
297 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
298 return true; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
299 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
300 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
301 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
302 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
303 bool loop_can_getevent(can_channel *chan, cyg_can_event *pevent, void *pdata) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
304 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
305 loop_can_info *loop_chan = (loop_can_info *)chan->dev_priv; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
306 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
307 struct fifo *frd = loop_chan->read_fifo; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
308 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
309 while( frd->num == 0 ) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
310 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
311 continue; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
312 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
313 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
314 *pevent = frd->buf[frd->head]; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
315 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
316 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
317 #ifdef CYGOPT_IO_CAN_SUPPORT_TIMESTAMP |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
318 // |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
319 // if timestamps are supported then we store a actual timestamp into |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
320 // CAN event |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
321 // |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
322 pevent->timestamp = cyg_current_time(); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
323 #endif // CYGOPT_IO_CAN_SUPPORT_TIMESTAMP |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
324 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
325 frd->num--; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
326 frd->head = (frd->head + 1) % FIFO_SIZE; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
327 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
328 return true; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
329 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
330 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
331 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
332 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
333 static Cyg_ErrNo |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
334 loop_can_set_config(can_channel *chan, cyg_uint32 key, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
335 const void *xbuf, cyg_uint32 *len) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
336 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
337 return ENOERR; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
338 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
339 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
340 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
341 // Query device configuration |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
342 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
343 static Cyg_ErrNo |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
344 loop_can_get_config(can_channel *chan, cyg_uint32 key, |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
345 const void* buf, cyg_uint32* len) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
346 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
347 return ENOERR; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
348 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
349 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
350 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
351 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
352 // Enable the transmitter on the device |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
353 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
354 static void |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
355 loop_can_start_xmit(can_channel *chan) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
356 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
357 loop_can_info *loop_chan = (loop_can_info *)chan->dev_priv; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
358 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
359 loop_chan->write_fifo->tx_enable = true; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
360 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
361 (chan->callbacks->xmt_msg)(chan, 0); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
362 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
363 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
364 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
365 // Disable the transmitter on the device |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
366 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
367 static void |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
368 loop_can_stop_xmit(can_channel *chan) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
369 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
370 loop_can_info *loop_chan = (loop_can_info *)chan->dev_priv; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
371 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
372 loop_chan->write_fifo->tx_enable = false; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
373 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
374 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
375 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
376 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
377 static void alarm_handler(cyg_handle_t alarm, cyg_addrword_t data) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
378 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
379 can_channel *chan0 = &loop_can0_chan; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
380 can_channel *chan1 = &loop_can1_chan; |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
381 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
382 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
383 while(fifo0.num ) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
384 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
385 (chan1->callbacks->rcv_event)(chan1, 0); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
386 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
387 if(fifo0.tx_enable ) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
388 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
389 (chan0->callbacks->xmt_msg)(chan0, 0); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
390 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
391 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
392 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
393 while(fifo1.num ) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
394 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
395 (chan0->callbacks->rcv_event)(chan0, 0); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
396 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
397 if(fifo1.tx_enable ) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
398 { |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
399 (chan1->callbacks->xmt_msg)(chan1, 0); |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
400 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
401 } // while( fifo1.num ) |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
402 } |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
403 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
404 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
405 #endif // CYGPKG_IO_CAN_LOOP |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
406 |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
407 //------------------------------------------------------------------------- |
|
3caad2060bd3
Strip erroneous CR chars from text files in the eCos repository.
jld
parents:
2729
diff
changeset
|
408 // EOF loop_can.c |
