1 /*---------------------------------------------------------------------------
2 regc515c.h - This file contains definitions for the builtin CAN-Bus
3 Controller of the Siemens c515c controller
5 Copyright (C) 2005, Maarten Brock, sourceforge.brock@dse.nl
7 This library is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
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
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this library; see the file COPYING. If not, write to the
19 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
22 As a special exception, if you link this library with other files,
23 some of which are compiled with SDCC, to produce an executable,
24 this library does not by itself cause the resulting executable to
25 be covered by the GNU General Public License. This exception does
26 not however invalidate any other reasons why the executable file
27 might be covered by the GNU General Public License.
28 -------------------------------------------------------------------------*/
35 /* define CPU_CLK_10MHZ or CPU_CLK_8MHZ to select the right values for */
36 /* the bit timing registers */
40 /* address of can controller in xmem */
41 #define CAN_CTRL 0xf700
43 /* size of message buffer including 1 dummy byte at end */
44 #define CAN_MSG_SZ 0x10
46 /* register offset definitions */
59 #define MSG15MSK_0 0xc
60 #define MSG15MSK_1 0xd
61 #define MSG15MSK_2 0xe
62 #define MSG15MSK_3 0xf
64 /* register offsets in message buffer */
72 /* beginning of message data */
75 /* bits in cntr_x registers */
86 /* macros for setting and resetting above bits, see Siemens documentation */
87 #define MCR_BIT_SET(p,x) ((p) = (0xff & ~((x) >> 1)))
88 #define MCR_BIT_RES(p,x) ((p) = (0xff & ~(x)))
90 /* direction = transmit in mcfg */
91 #define DIR_TRANSMIT 0x8
93 /* constants for bit timing registers */
97 #define BT_1_125K 0x1c
99 #define BT_1_250K 0x1c
100 #define BT_0_500K 0x0
101 #define BT_1_500K 0x1c
107 #define BT_0_125K 0x3
108 #define BT_1_125K 0x1c
109 #define BT_0_250K 0x1
110 #define BT_1_250K 0x1c
111 #define BT_0_500K 0x0
112 #define BT_1_500K 0x2f
117 /* Control register bits */
126 /* status register bits */
137 typedef struct can_msg
146 unsigned char data_bytes
[8];
150 __xdata __at CAN_CTRL
struct
164 unsigned char msg15msk_0
;
165 unsigned char msg15msk_1
;
166 unsigned char msg15msk_2
;
167 unsigned char msg15msk_3
;
168 struct can_msg msgbufs
[15];
171 /* Byte registers in numerical order */
234 /* defining bits in SFR P0 */
246 /* defining bits in SFR PCON1 */
259 /* defining bits in SFR P1 */
273 SBIT(CLKOUT
, 0x90, 6);
279 /* defining bits in SFR SCON */
291 /* defining bits in SFR P2 */
303 /* defining bits in SFR IEN0 */
315 /* defining bits in SFR P3 */
335 /* defining bits in SFR IEN1 */
343 SBIT(EXEN2
, 0xb8, 7);
347 /* defining bits in SFR IRCON */
359 /* defining bits in SFR T2CON */
371 /* defining bits in SFR PSW */
383 /* defining bits in SFR ADCON0 */
395 /* defining bits in SFR ACC */
396 SBIT(ACC_0
, 0xe0, 0);
397 SBIT(ACC_1
, 0xe0, 1);
398 SBIT(ACC_2
, 0xe0, 2);
399 SBIT(ACC_3
, 0xe0, 3);
400 SBIT(ACC_4
, 0xe0, 4);
401 SBIT(ACC_5
, 0xe0, 5);
402 SBIT(ACC_6
, 0xe0, 6);
403 SBIT(ACC_7
, 0xe0, 7);
407 /* defining bits in SFR P4 */
427 /* defining bits in SFR B */
439 /* defining bits in SFR DIR5 */
448 SBIT(DIR5_0
, 0xf8, 0);
449 SBIT(DIR5_1
, 0xf8, 1);
450 SBIT(DIR5_2
, 0xf8, 2);
451 SBIT(DIR5_3
, 0xf8, 3);
452 SBIT(DIR5_4
, 0xf8, 4);
453 SBIT(DIR5_5
, 0xf8, 5);
454 SBIT(DIR5_6
, 0xf8, 6);
455 SBIT(DIR5_7
, 0xf8, 7);
457 #endif /* _REGC515C_H */