Imported Upstream version 2.9.0
[debian/cc1111] / device / include / mcs51 / regc515c.h
1 /*---------------------------------------------------------------------------
2    MODULE: regc515c.h
3
4    This file contains definitions for the builtin CAN-Bus Controller of
5    the Siemens c515c controller
6
7    This library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Lesser General Public
9    License as published by the Free Software Foundation; either
10    version 2.1 of the License, or (at your option) any later version.
11
12    This library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Lesser General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with this library; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 ---------------------------------------------------------------------------*/
21
22 #ifndef _REGC515C_H
23 #define _REGC515C_H
24
25 /* define CPU_CLK_10MHZ or CPU_CLK_8MHZ to select the right values for */
26 /* the bit timing registers */
27
28 #define CPU_CLK_10MHZ
29
30 /* address of can controller in xmem */
31 #define CAN_CTRL        0xf700
32
33 /* size of message buffer including 1 dummy byte at end */
34 #define CAN_MSG_SZ      0x10
35
36 /* register offset definitions */
37 #define CR      0
38 #define SR      1
39 #define IR      2
40
41 #define BT_0    4
42 #define BT_1    5
43 #define GMS_0   6
44 #define GMS_1   7
45 #define GME_0   8
46 #define GME_1   9
47 #define GME_2   0xa
48 #define GME_3   0xb
49 #define MSG15MSK_0      0xc
50 #define MSG15MSK_1      0xd
51 #define MSG15MSK_2      0xe
52 #define MSG15MSK_3      0xf
53
54 /* register offsets  in message buffer */
55 #define MCR_0   0
56 #define MCR_1   1
57 #define ARB_0   2
58 #define ARB_1   3
59 #define ARB_2   4
60 #define ARB_3   5
61 #define MCFG    6
62 /* beginning of message data */
63 #define DATA    7
64
65 /* bits in cntr_x registers */
66 #define MSGVAL  0x80
67 #define TXIE    0x20
68 #define RXIE    0x8
69 #define INTPND  0x2
70 #define RMTPND  0x80
71 #define TXRQST  0x20
72 #define MSGLST  0x8
73 #define CPUUPD  0x8
74 #define NEWDAT  0x2
75
76 /* macros for setting and resetting above bits, see Siemens documentation */
77 #define MCR_BIT_SET(p,x) ((p) = (0xff & ~((x) >> 1)))
78 #define MCR_BIT_RES(p,x) ((p) = (0xff & ~(x)))
79
80 /* direction = transmit in mcfg */
81 #define DIR_TRANSMIT    0x8
82
83 /* constants for bit timing registers */
84 /* 8 MHZ */
85 #ifdef CPU_CLK_8MHZ
86 #define BT_0_125K       0x3
87 #define BT_1_125K       0x1c
88 #define BT_0_250K       0x1
89 #define BT_1_250K       0x1c
90 #define BT_0_500K       0x0
91 #define BT_1_500K       0x1c
92 #define BT_0_1M         0x0
93 #define BT_1_1M         0x14
94 #endif
95 /* dito, 10 MHZ */
96 #ifdef CPU_CLK_10MHZ
97 #define BT_0_125K       0x3
98 #define BT_1_125K       0x1c
99 #define BT_0_250K       0x1
100 #define BT_1_250K       0x1c
101 #define BT_0_500K       0x0
102 #define BT_1_500K       0x2f
103 #define BT_0_1M         0x0
104 #define BT_1_1M         0x25
105 #endif
106
107 /* Control register bits */
108
109 #define CINIT   0x1
110 #define IE      0x2
111 #define SIE     0x4
112 #define EIE     0x8
113
114 #define CCE     0x40
115
116 /* status register bits */
117 #define LEC0    0x1
118 #define LEC1    0x2
119 #define LEC2    0x4
120 #define TXOK    0x8
121 #define RXOK    0x10
122 #define WAKE    0x20
123 #define WARN    0x40
124 #define BOFF    0x80
125
126
127 typedef struct can_msg
128 {
129     unsigned char mcr_0;
130     unsigned char mcr_1;
131     unsigned char arb_0;
132     unsigned char arb_1;
133     unsigned char arb_2;
134     unsigned char arb_3;
135     unsigned char mcfg;
136     unsigned char data_bytes[8];
137     unsigned char dummy;
138 } *can_msgp;
139
140 __xdata __at CAN_CTRL struct
141 {
142     unsigned    char    cr;
143     unsigned    char    sr;
144     unsigned    char    ir;
145     unsigned    char    res0;
146     unsigned    char    bt_0;
147     unsigned    char    bt_1;
148     unsigned    char    gms_0;
149     unsigned    char    gms_1;
150     unsigned    char    gme_0;
151     unsigned    char    gme_1;
152     unsigned    char    gme_2;
153     unsigned    char    gme_3;
154     unsigned    char    msg15msk_0;
155     unsigned    char    msg15msk_1;
156     unsigned    char    msg15msk_2;
157     unsigned    char    msg15msk_3;
158     struct      can_msg msgbufs[15];
159 } can_ctrl;
160
161 /* Byte registers in numerical order */
162
163 __sfr __at 0x80 P0;
164 __sfr __at 0x81 SP;
165 __sfr __at 0x82 DPL;
166 __sfr __at 0x83 DPH;
167 __sfr __at 0x86 WDTREL;
168 __sfr __at 0x87 PCON;
169 __sfr __at 0x88 TCON;
170 __sfr __at 0x88 PCON1;
171 __sfr __at 0x89 TMOD;
172 __sfr __at 0x8A TL0;
173 __sfr __at 0x8B TL1;
174 __sfr __at 0x8C TH0;
175 __sfr __at 0x8D TH1;
176 __sfr __at 0x90 P1;
177 __sfr __at 0x91 XPAGE;
178 __sfr __at 0x92 DPSEL;
179 __sfr __at 0x93 SSCCON;
180 __sfr __at 0x94 STB;
181 __sfr __at 0x95 SRB;
182 __sfr __at 0x96 SSCMOD;
183 __sfr __at 0x98 SCON;
184 __sfr __at 0x99 SBUF;
185 __sfr __at 0x9A IEN2;
186 __sfr __at 0xA0 P2;
187 __sfr __at 0xA8 IEN0;
188 __sfr __at 0xA9 IP0;
189 __sfr __at 0xAA SRELL;
190 __sfr __at 0xAB SCF;
191 __sfr __at 0xAC SCIEN;
192 __sfr __at 0xB0 P3;
193 __sfr __at 0xB1 SYSCON;
194 __sfr __at 0xB8 IEN1;
195 __sfr __at 0xB9 IP1;
196 __sfr __at 0xBA SRELH;
197 __sfr __at 0xC0 IRCON;
198 __sfr __at 0xC1 CCEN;
199 __sfr __at 0xC2 CCL1;
200 __sfr __at 0xC3 CCH1;
201 __sfr __at 0xC4 CCL2;
202 __sfr __at 0xC5 CCH2;
203 __sfr __at 0xC6 CCL3;
204 __sfr __at 0xC7 CCH3;
205 __sfr __at 0xC8 T2CON;
206 __sfr __at 0xCA CRCL;
207 __sfr __at 0xCB CRCH;
208 __sfr __at 0xCC TL2;
209 __sfr __at 0xCD TH2;
210 __sfr __at 0xD0 PSW;
211 __sfr __at 0xD8 ADCON0;
212 __sfr __at 0xD9 ADDATH;
213 __sfr __at 0xDA ADDATL;
214 __sfr __at 0xDB P6;
215 __sfr __at 0xDC ADCON1;
216 __sfr __at 0xE0 ACC;
217 __sfr __at 0xE8 P4;
218 __sfr __at 0xF0 B;
219 __sfr __at 0xF8 P5;
220 __sfr __at 0xF8 DIR5;
221 __sfr __at 0xFA P7;
222
223
224 /* defining bits in SFR P0 */
225 __sbit __at 0x80  P0_0;
226 __sbit __at 0x81  P0_1;
227 __sbit __at 0x82  P0_2;
228 __sbit __at 0x83  P0_3;
229 __sbit __at 0x84  P0_4;
230 __sbit __at 0x85  P0_5;
231 __sbit __at 0x86  P0_6;
232 __sbit __at 0x87  P0_7;
233
234
235
236 /* defining bits in SFR PCON1 */
237 __sbit __at 0x88  IT0;
238 __sbit __at 0x89  IE0;
239 __sbit __at 0x8a  IT1;
240 __sbit __at 0x8b  IE1;
241 __sbit __at 0x8c  TR0;
242 __sbit __at 0x8d  TF0;
243 __sbit __at 0x8e  TR1;
244 __sbit __at 0x8f  TF1;
245 __sbit __at 0x8f  EWPD;
246
247
248
249 /* defining bits in SFR P1 */
250 __sbit __at 0x90  P1_0;
251 __sbit __at 0x90  INT3;
252 __sbit __at 0x91  P1_1;
253 __sbit __at 0x91  INT4;
254 __sbit __at 0x92  P1_2;
255 __sbit __at 0x92  INT5;
256 __sbit __at 0x93  P1_3;
257 __sbit __at 0x93  INT6;
258 __sbit __at 0x94  P1_4;
259 __sbit __at 0x94  INT2;
260 __sbit __at 0x95  P1_5;
261 __sbit __at 0x95  T2EX;
262 __sbit __at 0x96  P1_6;
263 __sbit __at 0x96  CLKOUT;
264 __sbit __at 0x97  P1_7;
265 __sbit __at 0x97  T2;
266
267
268
269 /* defining bits in SFR SCON */
270 __sbit __at 0x98  RI;
271 __sbit __at 0x99  TI;
272 __sbit __at 0x9a  RB8;
273 __sbit __at 0x9b  TB8;
274 __sbit __at 0x9c  REN;
275 __sbit __at 0x9d  SM2;
276 __sbit __at 0x9e  SM1;
277 __sbit __at 0x9f  SM0;
278
279
280
281 /* defining bits in SFR P2 */
282 __sbit __at 0xa0  P2_0;
283 __sbit __at 0xa1  P2_1;
284 __sbit __at 0xa2  P2_2;
285 __sbit __at 0xa3  P2_3;
286 __sbit __at 0xa4  P2_4;
287 __sbit __at 0xa5  P2_5;
288 __sbit __at 0xa6  P2_6;
289 __sbit __at 0xa7  P2_7;
290
291
292
293 /* defining bits in SFR IEN0 */
294 __sbit __at 0xa8  EX0;
295 __sbit __at 0xa9  ET0;
296 __sbit __at 0xaa  EX1;
297 __sbit __at 0xab  ET1;
298 __sbit __at 0xac  ES;
299 __sbit __at 0xad  ET2;
300 __sbit __at 0xae  WDT;
301 __sbit __at 0xaf  EA;
302
303
304
305 /* defining bits in SFR P3 */
306 __sbit __at 0xb0  P3_0;
307 __sbit __at 0xb0  RXD;
308 __sbit __at 0xb1  P3_1;
309 __sbit __at 0xb1  TXD;
310 __sbit __at 0xb2  P3_2;
311 __sbit __at 0xb2  INT0;
312 __sbit __at 0xb3  P3_3;
313 __sbit __at 0xb3  INT1;
314 __sbit __at 0xb4  P3_4;
315 __sbit __at 0xb4  T0;
316 __sbit __at 0xb5  P3_5;
317 __sbit __at 0xb5  T1;
318 __sbit __at 0xb6  P3_6;
319 __sbit __at 0xb6  WR;
320 __sbit __at 0xb7  P3_7;
321 __sbit __at 0xb7  RD;
322
323
324
325 /* defining bits in SFR IEN1 */
326 __sbit __at 0xb8  EADC;
327 __sbit __at 0xb9  EX2;
328 __sbit __at 0xba  EX3;
329 __sbit __at 0xbb  EX4;
330 __sbit __at 0xbc  EX5;
331 __sbit __at 0xbd  EX6;
332 __sbit __at 0xbe  SWDT;
333 __sbit __at 0xbf  EXEN2;
334
335
336
337 /* defining bits in SFR IRCON */
338 __sbit __at 0xc0  IADC;
339 __sbit __at 0xc1  IEX2;
340 __sbit __at 0xc2  IEX3;
341 __sbit __at 0xc3  IEX4;
342 __sbit __at 0xc4  IEX5;
343 __sbit __at 0xc5  IEX6;
344 __sbit __at 0xc6  TF2;
345 __sbit __at 0xc7  EXF2;
346
347
348
349 /* defining bits in SFR T2CON */
350 __sbit __at 0xc8  T2I0;
351 __sbit __at 0xc9  T2I1;
352 __sbit __at 0xca  T2CM;
353 __sbit __at 0xcb  T2R0;
354 __sbit __at 0xcc  T2R1;
355 __sbit __at 0xcd  I2FR;
356 __sbit __at 0xce  I3FR;
357 __sbit __at 0xcf  T2PS;
358
359
360
361 /* defining bits in SFR PSW */
362 __sbit __at 0xd0  P;
363 __sbit __at 0xd1  F1;
364 __sbit __at 0xd2  OV;
365 __sbit __at 0xd3  RS0;
366 __sbit __at 0xd4  RS1;
367 __sbit __at 0xd5  F0;
368 __sbit __at 0xd6  AC;
369 __sbit __at 0xd7  CY;
370
371
372
373 /* defining bits in SFR ADCON0 */
374 __sbit __at 0xd8  MX0;
375 __sbit __at 0xd9  MX1;
376 __sbit __at 0xda  MX2;
377 __sbit __at 0xdb  ADM;
378 __sbit __at 0xdc  BSY;
379 __sbit __at 0xdd  ADEX;
380 __sbit __at 0xde  CLK;
381 __sbit __at 0xdf  BD;
382
383
384
385 /* defining bits in SFR ACC */
386 __sbit __at 0xe0  ACC_0;
387 __sbit __at 0xe1  ACC_1;
388 __sbit __at 0xe2  ACC_2;
389 __sbit __at 0xe3  ACC_3;
390 __sbit __at 0xe4  ACC_4;
391 __sbit __at 0xe5  ACC_5;
392 __sbit __at 0xe6  ACC_6;
393 __sbit __at 0xe7  ACC_7;
394
395
396
397 /* defining bits in SFR P4 */
398 __sbit __at 0xe8  P4_0;
399 __sbit __at 0xe8  ADST;
400 __sbit __at 0xe9  P4_1;
401 __sbit __at 0xe9  SCLK;
402 __sbit __at 0xea  P4_2;
403 __sbit __at 0xea  SRI;
404 __sbit __at 0xeb  P4_3;
405 __sbit __at 0xeb  STO;
406 __sbit __at 0xec  P4_4;
407 __sbit __at 0xec  SLS;
408 __sbit __at 0xed  P4_5;
409 __sbit __at 0xed  INT8;
410 __sbit __at 0xee  P4_6;
411 __sbit __at 0xee  TXDC;
412 __sbit __at 0xef  P4_7;
413 __sbit __at 0xef  RXDC;
414
415
416
417 /* defining bits in SFR B */
418 __sbit __at 0xf0  B_0;
419 __sbit __at 0xf1  B_1;
420 __sbit __at 0xf2  B_2;
421 __sbit __at 0xf3  B_3;
422 __sbit __at 0xf4  B_4;
423 __sbit __at 0xf5  B_5;
424 __sbit __at 0xf6  B_6;
425 __sbit __at 0xf7  B_7;
426
427
428
429 /* defining bits in SFR DIR5 */
430 __sbit __at 0xf8  P5_0;
431 __sbit __at 0xf9  P5_1;
432 __sbit __at 0xfa  P5_2;
433 __sbit __at 0xfb  P5_3;
434 __sbit __at 0xfc  P5_4;
435 __sbit __at 0xfd  P5_5;
436 __sbit __at 0xfe  P5_6;
437 __sbit __at 0xff  P5_7;
438 __sbit __at 0xf8  DIR5_0;
439 __sbit __at 0xf9  DIR5_1;
440 __sbit __at 0xfa  DIR5_2;
441 __sbit __at 0xfb  DIR5_3;
442 __sbit __at 0xfc  DIR5_4;
443 __sbit __at 0xfd  DIR5_5;
444 __sbit __at 0xfe  DIR5_6;
445 __sbit __at 0xff  DIR5_7;
446
447 #endif /* _REGC515C_H */
448
449