removed reg515.h
[fw/sdcc] / device / include / canc515c.h
1 /*****************************************************************************
2 |*
3 |*  MODULE:            canc515c.h
4 |*
5 |*    This file contains definitions for the builtin CAN-Bus Controller of
6 |*    the Siemens c515c controller
7 |*
8 ****************************************************************************/
9
10 #ifndef _CANC515C_H
11 #define _CANC515C_H
12
13 /* define CPU_CLK_10MHZ or CPU_CLK_8MHZ to select the right values for */
14 /* the bit timing registers */
15
16 #define CPU_CLK_10MHZ
17
18 /* address of can controller in xmem */
19 #define CAN_CTRL        0xf700
20
21 /* size of message buffer including 1 dummy byte at end */
22 #define CAN_MSG_SZ      0x10
23
24 /* register offset definitions */
25 #define CR      0
26 #define SR      1
27 #define IR      2
28
29 #define BT_0    4
30 #define BT_1    5
31 #define GMS_0   6
32 #define GMS_1   7
33 #define GME_0   8
34 #define GME_1   9
35 #define GME_2   0xa
36 #define GME_3   0xb
37 #define MSG15MSK_0      0xc
38 #define MSG15MSK_1      0xd
39 #define MSG15MSK_2      0xe
40 #define MSG15MSK_3      0xf
41
42 /* register offsets  in message buffer */
43 #define MCR_0   0
44 #define MCR_1   1
45 #define ARB_0   2
46 #define ARB_1   3
47 #define ARB_2   4
48 #define ARB_3   5
49 #define MCFG    6
50 /* beginning of message data */
51 #define DATA    7
52
53 /* bits in cntr_x registers */
54 #define MSGVAL  0x80
55 #define TXIE    0x20
56 #define RXIE    0x8
57 #define INTPND  0x2
58 #define RMTPND  0x80
59 #define TXRQST  0x20
60 #define MSGLST  0x8
61 #define CPUUPD  0x8
62 #define NEWDAT  0x2
63
64 /* macros for setting and resetting above bits, see Siemens documentation */
65 #define MCR_BIT_SET(p,x) ((p) = (0xff & ~((x) >> 1)))
66 #define MCR_BIT_RES(p,x) ((p) = (0xff & ~(x)))
67
68 /* direction = transmit in mcfg */
69 #define DIR_TRANSMIT    0x8
70
71 /* constants for bit timing registers */
72 /* 8 MHZ */
73 #ifdef CPU_CLK_8MHZ
74 #define BT_0_125K       0x3
75 #define BT_1_125K       0x1c
76 #define BT_0_250K       0x1
77 #define BT_1_250K       0x1c
78 #define BT_0_500K       0x0
79 #define BT_1_500K       0x1c
80 #define BT_0_1M         0x0
81 #define BT_1_1M         0x14
82 #endif
83 /* dito, 10 MHZ */
84 #ifdef CPU_CLK_10MHZ
85 #define BT_0_125K       0x3
86 #define BT_1_125K       0x1c
87 #define BT_0_250K       0x1
88 #define BT_1_250K       0x1c
89 #define BT_0_500K       0x0
90 #define BT_1_500K       0x2f
91 #define BT_0_1M         0x0
92 #define BT_1_1M         0x25
93 #endif
94
95 /* Control register bits */
96
97 #define CINIT   0x1
98 #define IE      0x2
99 #define SIE     0x4
100 #define EIE     0x8
101
102 #define CCE     0x40
103
104 /* status register bits */
105 #define LEC0    0x1
106 #define LEC1    0x2
107 #define LEC2    0x4
108 #define TXOK    0x8
109 #define RXOK    0x10
110 #define WAKE    0x20
111 #define WARN    0x40
112 #define BOFF    0x80
113
114
115 typedef struct can_msg
116 {
117     unsigned char mcr_0;
118     unsigned char mcr_1;
119     unsigned char arb_0;
120     unsigned char arb_1;
121     unsigned char arb_2;
122     unsigned char arb_3;
123     unsigned char mcfg;
124     unsigned char data_bytes[8];
125     unsigned char dummy;
126 } *can_msgp;
127
128 xdata at CAN_CTRL struct
129 {
130     unsigned    char    cr;
131     unsigned    char    sr;
132     unsigned    char    ir;
133     unsigned    char    res0;
134     unsigned    char    bt_0;
135     unsigned    char    bt_1;
136     unsigned    char    gms_0;
137     unsigned    char    gme_1;
138     unsigned    char    gme_0;
139     unsigned    char    gme_1;
140     unsigned    char    gme_2;
141     unsigned    char    gme_3;
142     unsigned    char    msg15msk_0;
143     unsigned    char    msg15msk_1;
144     unsigned    char    msg15msk_2;
145     unsigned    char    msg15msk_3;
146     struct      can_msg msgbufs[15];
147 } can_ctrl;
148
149 #endif /* _CANC515C */