1 |
30 |
unneback |
/* canbus.h
|
2 |
|
|
*
|
3 |
|
|
* This include file contains all canbus IO definitions
|
4 |
|
|
*
|
5 |
|
|
* Written by Jay Monkman (jmonkman@frasca.com)
|
6 |
|
|
*
|
7 |
|
|
* COPYRIGHT (c) 1998
|
8 |
|
|
* Frasca International, Inc.
|
9 |
|
|
*
|
10 |
|
|
* The license and distribution terms for this file may be
|
11 |
|
|
* found in the file LICENSE in this distribution or at
|
12 |
|
|
* http://www.OARcorp.com/rtems/license.html.
|
13 |
|
|
*
|
14 |
|
|
* $Id:
|
15 |
|
|
*/
|
16 |
|
|
|
17 |
|
|
#ifndef __CANBUS_H_
|
18 |
|
|
#define __CANBUS_H_
|
19 |
|
|
|
20 |
|
|
#include <rtems.h>
|
21 |
|
|
|
22 |
|
|
typedef struct i82527_msg_t_ {
|
23 |
|
|
rtems_unsigned8 ctrl0 __attribute__ ((packed)); /* Control 0 register */
|
24 |
|
|
rtems_unsigned8 ctrl1 __attribute__ ((packed)); /* Control 1 register */
|
25 |
|
|
rtems_unsigned32 arb __attribute__ ((packed)); /* Arbitration reg */
|
26 |
|
|
rtems_unsigned8 cfg __attribute__ ((packed)); /* Message config reg */
|
27 |
|
|
rtems_unsigned8 data[8] __attribute__ ((packed)); /* Actual message */
|
28 |
|
|
} i82527_msg_t;
|
29 |
|
|
|
30 |
|
|
typedef struct i82527_t_ {
|
31 |
|
|
rtems_unsigned8 ctrl __attribute__ ((packed)); /* Control register */
|
32 |
|
|
rtems_unsigned8 status __attribute__ ((packed)); /* Status register */
|
33 |
|
|
rtems_unsigned8 cir __attribute__ ((packed)); /* CPU interface reg */
|
34 |
|
|
rtems_unsigned8 _res0 __attribute__ ((packed));
|
35 |
|
|
rtems_unsigned16 hsr __attribute__ ((packed)); /* High speed read */
|
36 |
|
|
rtems_unsigned16 gms __attribute__ ((packed)); /* Global Mask - std */
|
37 |
|
|
rtems_unsigned32 gml __attribute__ ((packed)); /* Global Mask - long */
|
38 |
|
|
rtems_unsigned32 mlm __attribute__ ((packed)); /* Mask last message */
|
39 |
|
|
i82527_msg_t msg1 __attribute__ ((packed)); /* Message 1 */
|
40 |
|
|
rtems_unsigned8 clkout __attribute__ ((packed)); /* CLKOUT register */
|
41 |
|
|
i82527_msg_t msg2 __attribute__ ((packed)); /* Message 2 */
|
42 |
|
|
rtems_unsigned8 bcr __attribute__ ((packed)); /* Bus config register */
|
43 |
|
|
i82527_msg_t msg3 __attribute__ ((packed)); /* Message 3 */
|
44 |
|
|
rtems_unsigned8 btr0 __attribute__ ((packed)); /* Bit timing reg 0 */
|
45 |
|
|
i82527_msg_t msg4 __attribute__ ((packed)); /* Message 4 */
|
46 |
|
|
rtems_unsigned8 btr1 __attribute__ ((packed)); /* Bit timing reg 1 */
|
47 |
|
|
i82527_msg_t msg5 __attribute__ ((packed)); /* Message 5 */
|
48 |
|
|
rtems_unsigned8 intr __attribute__ ((packed)); /* Interrupt register */
|
49 |
|
|
i82527_msg_t msg6 __attribute__ ((packed)); /* Message 6 */
|
50 |
|
|
rtems_unsigned8 _res1 __attribute__ ((packed));
|
51 |
|
|
i82527_msg_t msg7 __attribute__ ((packed)); /* Message 7 */
|
52 |
|
|
rtems_unsigned8 _res2 __attribute__ ((packed));
|
53 |
|
|
i82527_msg_t msg8 __attribute__ ((packed)); /* Message 8 */
|
54 |
|
|
rtems_unsigned8 _res3 __attribute__ ((packed));
|
55 |
|
|
i82527_msg_t msg9 __attribute__ ((packed)); /* Message 9 */
|
56 |
|
|
rtems_unsigned8 p1conf __attribute__ ((packed)); /* Port 1 config */
|
57 |
|
|
i82527_msg_t msg10 __attribute__ ((packed)); /* Message 10 */
|
58 |
|
|
rtems_unsigned8 p2conf __attribute__ ((packed)); /* Port 2 config */
|
59 |
|
|
i82527_msg_t msg11 __attribute__ ((packed)); /* Message 11 */
|
60 |
|
|
rtems_unsigned8 p1in __attribute__ ((packed)); /* Port 1 in */
|
61 |
|
|
i82527_msg_t msg12 __attribute__ ((packed)); /* Message 12 */
|
62 |
|
|
rtems_unsigned8 p2in __attribute__ ((packed)); /* Port 2 in */
|
63 |
|
|
i82527_msg_t msg13 __attribute__ ((packed)); /* Message 13 */
|
64 |
|
|
rtems_unsigned8 p1out __attribute__ ((packed)); /* Port 1 out */
|
65 |
|
|
i82527_msg_t msg14 __attribute__ ((packed)); /* Message 14 */
|
66 |
|
|
rtems_unsigned8 p2out __attribute__ ((packed)); /* Port 2 out */
|
67 |
|
|
i82527_msg_t msg15 __attribute__ ((packed)); /* Message 15 */
|
68 |
|
|
rtems_unsigned8 sra __attribute__ ((packed)); /* Serial reset address */
|
69 |
|
|
} i82527_t;
|
70 |
|
|
|
71 |
|
|
#define I82527_CTRL_CCE (1<<6)
|
72 |
|
|
#define I82527_CTRL_EIE (1<<3)
|
73 |
|
|
#define I82527_CTRL_SIE (1<<2)
|
74 |
|
|
#define I82527_CTRL_IE (1<<1)
|
75 |
|
|
#define I82527_CTRL_INIT (1)
|
76 |
|
|
#define I82527_STATUS_BOFF (1<<7)
|
77 |
|
|
#define I82527_STATUS_WARN (1<<6)
|
78 |
|
|
#define I82527_STATUS_WAKE (1<<5)
|
79 |
|
|
#define I82527_STATUS_RXOK (1<<4)
|
80 |
|
|
#define I82527_STATUS_TXOK (1<<3)
|
81 |
|
|
#define I82527_STATUS_LEC (7)
|
82 |
|
|
#define I82527_STATUS_LEC_NONE 0
|
83 |
|
|
#define I82527_STATUS_LEC_STUFF 1
|
84 |
|
|
#define I82527_STATUS_LEC_FORM 2
|
85 |
|
|
#define I82527_STATUS_LEC_ACK 3
|
86 |
|
|
#define I82527_STATUS_LEC_BIT1 4
|
87 |
|
|
#define I82527_STATUS_LEC_BIT0 5
|
88 |
|
|
#define I82527_STATUS_LEC_CRC 6
|
89 |
|
|
#define I82527_CIR_RSTSTAT (1<<7)
|
90 |
|
|
#define I82527_CIR_DSC (1<<6)
|
91 |
|
|
#define I82527_CIR_DMC (1<<5)
|
92 |
|
|
#define I82527_CIR_PWD (1<<4)
|
93 |
|
|
#define I82527_CIR_SLEEP (1<<3)
|
94 |
|
|
#define I82527_CIR_MUX (1<<2)
|
95 |
|
|
#define I82527_CIR_CEN (1)
|
96 |
|
|
#define I82527_CLKOUT_SL1 (1<<5)
|
97 |
|
|
#define I82527_CLKOUT_SLO (1<<4)
|
98 |
|
|
#define I82527_BCR_COBY (1<<6)
|
99 |
|
|
#define I82527_BCR_POL (1<<5)
|
100 |
|
|
#define I82527_DCT1 (1<<3)
|
101 |
|
|
#define I82527_DCR1 (1<<1)
|
102 |
|
|
#define I82527_DCR0 (1)
|
103 |
|
|
#define I82527_BTR1_SPL (1<<7)
|
104 |
|
|
#define I82527_MSG_CTRL_MSGVAL (2<<6)
|
105 |
|
|
#define I82527_MSG_CTRL_MSGVAL_NC (3<<6)
|
106 |
|
|
#define I82527_MSG_CTRL_MSGVAL_SET (2<<6)
|
107 |
|
|
#define I82527_MSG_CTRL_MSGVAL_CLR (1<<6)
|
108 |
|
|
#define I82527_MSG_CTRL_TXIE (2<<4)
|
109 |
|
|
#define I82527_MSG_CTRL_TXIE_NC (3<<4)
|
110 |
|
|
#define I82527_MSG_CTRL_TXIE_SET (2<<4)
|
111 |
|
|
#define I82527_MSG_CTRL_TXIE_CLR (1<<4)
|
112 |
|
|
#define I82527_MSG_CTRL_RXIE (2<<2)
|
113 |
|
|
#define I82527_MSG_CTRL_RXIE_NC (3<<2)
|
114 |
|
|
#define I82527_MSG_CTRL_RXIE_SET (2<<2)
|
115 |
|
|
#define I82527_MSG_CTRL_RXIE_CLR (1<<2)
|
116 |
|
|
#define I82527_MSG_CTRL_INTPND (2)
|
117 |
|
|
#define I82527_MSG_CTRL_INTPND_NC (3)
|
118 |
|
|
#define I82527_MSG_CTRL_INTPND_SET (2)
|
119 |
|
|
#define I82527_MSG_CTRL_INTPND_CLR (1)
|
120 |
|
|
#define I82527_MSG_CTRL_RMTPND (2<<6)
|
121 |
|
|
#define I82527_MSG_CTRL_RMTPND_NC (3<<6)
|
122 |
|
|
#define I82527_MSG_CTRL_RMTPND_SET (2<<6)
|
123 |
|
|
#define I82527_MSG_CTRL_RMTPND_CLR (1<<6)
|
124 |
|
|
#define I82527_MSG_CTRL_TXRQ (2<<4)
|
125 |
|
|
#define I82527_MSG_CTRL_TXRQ_NC (3<<4)
|
126 |
|
|
#define I82527_MSG_CTRL_TXRQ_SET (2<<4)
|
127 |
|
|
#define I82527_MSG_CTRL_TXRQ_CLR (1<<4)
|
128 |
|
|
#define I82527_MSG_CTRL_MSGLST (2<<2)
|
129 |
|
|
#define I82527_MSG_CTRL_MSGLST_NC (3<<2)
|
130 |
|
|
#define I82527_MSG_CTRL_MSGLST_SET (2<<2)
|
131 |
|
|
#define I82527_MSG_CTRL_MSGLST_CLR (1<<2)
|
132 |
|
|
#define I82527_MSG_CTRL_CPUUPD (2<<2)
|
133 |
|
|
#define I82527_MSG_CTRL_CPUUPD_NC (3<<2)
|
134 |
|
|
#define I82527_MSG_CTRL_CPUUPD_SET (2<<2)
|
135 |
|
|
#define I82527_MSG_CTRL_CPUUPD_CLR (1<<2)
|
136 |
|
|
#define I82527_MSG_CTRL_NEWDAT (2)
|
137 |
|
|
#define I82527_MSG_CTRL_NEWDAT_NC (3)
|
138 |
|
|
#define I82527_MSG_CTRL_NEWDAT_SET (2)
|
139 |
|
|
#define I82527_MSG_CTRL_NEWDAT_CLR (1)
|
140 |
|
|
#define I82527_MSG_CFG_DIR (1<<3)
|
141 |
|
|
#define I82527_MSG_CFG_XTD (1<<2)
|
142 |
|
|
|
143 |
|
|
extern i82527_t canbus0;
|
144 |
|
|
extern i82527_t canbus1;
|
145 |
|
|
extern i82527_t canbus2;
|
146 |
|
|
|
147 |
|
|
|
148 |
|
|
rtems_device_driver canbus_initialize(rtems_device_major_number,
|
149 |
|
|
rtems_device_minor_number,
|
150 |
|
|
void *);
|
151 |
|
|
rtems_device_driver canbus_open(rtems_device_major_number,
|
152 |
|
|
rtems_device_minor_number,
|
153 |
|
|
void *);
|
154 |
|
|
rtems_device_driver canbus_close(rtems_device_major_number,
|
155 |
|
|
rtems_device_minor_number,
|
156 |
|
|
void *);
|
157 |
|
|
rtems_device_driver canbus_read(rtems_device_major_number,
|
158 |
|
|
rtems_device_minor_number,
|
159 |
|
|
void *);
|
160 |
|
|
rtems_device_driver canbus_write(rtems_device_major_number,
|
161 |
|
|
rtems_device_minor_number,
|
162 |
|
|
void *);
|
163 |
|
|
rtems_device_driver canbus_control(rtems_device_major_number,
|
164 |
|
|
rtems_device_minor_number,
|
165 |
|
|
void *);
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
#define CANBUS_DRIVER_TABLE_ENTRY \
|
169 |
|
|
{ canbus_initialize, canbus_open, canbus_close, \
|
170 |
|
|
canbus_read, canbus_write, canbus_control }
|
171 |
|
|
|
172 |
|
|
#endif /* __CANBUS_H_ */
|