16FXlib
can.cfg.h
Go to the documentation of this file.
1 
2 //*****************************************************************************
3 // Author : Christian Illy
4 // Created : 04.05.2009
5 // Revised : 29.06.2009
6 // Version : 0.1
7 // Target MCU : Fujitsu MB96300 series
8 //
9 // This program is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 //
27 //*****************************************************************************
29 
30 
31 #ifndef CAN_CFG_H_
32 #define CAN_CFG_H_
33 
34 #include "mb96348hs.h"
35 
37 #define CAN_RX_ENABLE PIER10
38 #define CAN_RX_BIT 0
40 
42 #define CAN_BASE CTRLR0
43 #define CAN_BUFFERCOUNT 32
45 
46 
47 
49 #define CANREG(x) (*((CAN_##x##_TYPE*)((uint8_t*)(&(CAN_BASE)) + CAN_##x##_OFFSET)))
50 
51 
52 // TODO: Documentation for registers / bits
53 
54 #define CAN_COER_OFFSET 0xCE
55 #define CAN_COER_TYPE uint8_t
56 #define CAN_COER CANREG(COER)
57 #define CAN_COER_OE 0
58 
59 #define CAN_CTRLR_OFFSET 0x00
60 #define CAN_CTRLR_TYPE uint8_t
61 #define CAN_CTRLR CANREG(CTRLR)
62 #define CAN_CTRLR_INIT 0
63 #define CAN_CTRLR_IE 1
64 #define CAN_CTRLR_SIE 2
65 #define CAN_CTRLR_EIE 3
66 #define CAN_CTRLR_DAR 5
67 #define CAN_CTRLR_CCE 6
68 #define CAN_CTRLR_TEST 7
69 
70 #define CAN_STATR_OFFSET 0x02
71 #define CAN_STATR_TYPE uint8_t
72 #define CAN_STATR CANREG(STATR)
73 #define CAN_STATR_LEC_MASK (0x07)
74 #define CAN_STATR_TXOK 3
75 #define CAN_STATR_RXOK 4
76 #define CAN_STATR_EPASS 5
77 #define CAN_STATR_EWARN 6
78 #define CAN_STATR_BOFF 7
79 
80 #define CAN_ERRCNTH_OFFSET 0x05
81 #define CAN_ERRCNTH_TYPE uint8_t
82 #define CAN_ERRCNTH CANREG(ERRCNTH)
83 #define CAN_ERRCNTH_RP 7
84 #define CAN_ERRCNTH_REC_MASK (0x7f)
85 
86 #define CAN_ERRCNTL_OFFSET 0x04
87 #define CAN_ERRCNTL_TYPE uint8_t
88 #define CAN_ERRCNTL CANREG(ERRCNTL)
89 
90 #define CAN_BTR_OFFSET 0x06
91 #define CAN_BTR_TYPE uint16_t
92 #define CAN_BTR CANREG(BTR)
93 #define CAN_BTR_TSEG2_MASK (0x7000)
94 #define CAN_BTR_TSEG2_SHIFT (12)
95 #define CAN_BTR_TSEG1_MASK (0x0f00)
96 #define CAN_BTR_TSEG1_SHIFT (8)
97 #define CAN_BTR_SJW_MASK (0x00c0)
98 #define CAN_BTR_SJW_SHIFT (6)
99 #define CAN_BTR_BRP_MASK (0x003f)
100 
101 #define CAN_INTR_OFFSET 0x08
102 #define CAN_INTR_TYPE uint16_t
103 #define CAN_INTR CANREG(INTR)
104 #define CAN_INTR_STATUS_VALUE 0x8000
105 
106 #define CAN_TESTR_OFFSET 0x0A
107 #define CAN_TESTR_TYPE uint8_t
108 #define CAN_TESTR CANREG(TESTR)
109 #define CAN_TESTR_RX 7
110 #define CAN_TESTR_TX1 6
111 #define CAN_TESTR_TX0 5
112 #define CAN_TESTR_LBACK 4
113 #define CAN_TESTR_SILENT 3
114 #define CAN_TESTR_BASIC 2
115 
116 #define CAN_BRPER_OFFSET 0x0C
117 #define CAN_BRPER_TYPE uint8_t
118 #define CAN_BRPER CANREG(BRPER)
119 
120 
121 
122 #define CAN_IF1CREQ_OFFSET 0x10
123 #define CAN_IF1CREQ_TYPE uint8_t
124 #define CAN_IF1CREQ CANREG(IF1CREQ)
125 #define CAN_IF1CMSK_OFFSET 0x12
126 #define CAN_IF1CMSK_TYPE uint8_t
127 #define CAN_IF1CMSK CANREG(IF1CMSK)
128 #define CAN_IF1MSK_OFFSET 0x14
129 #define CAN_IF1MSK_TYPE uint32_t
130 #define CAN_IF1MSK CANREG(IF1MSK)
131 #define CAN_IF1ARB_OFFSET 0x18
132 #define CAN_IF1ARB_TYPE uint32_t
133 #define CAN_IF1ARB CANREG(IF1ARB)
134 #define CAN_IF1MCTR_OFFSET 0x1C
135 #define CAN_IF1MCTR_TYPE uint16_t
136 #define CAN_IF1MCTR CANREG(IF1MCTR)
137 #define CAN_IF1DTA_OFFSET 0x1E
138 #define CAN_IF1DTA_TYPE uint32_t
139 #define CAN_IF1DTA CANREG(IF1DTA)
140 #define CAN_IF1DTB_OFFSET 0x22
141 #define CAN_IF1DTB_TYPE uint32_t
142 #define CAN_IF1DTB CANREG(IF1DTB)
143 
144 #define CAN_IF2CREQ_OFFSET 0x40
145 #define CAN_IF2CREQ_TYPE uint8_t
146 #define CAN_IF2CREQ CANREG(IF2CREQ)
147 #define CAN_IF2CMSK_OFFSET 0x42
148 #define CAN_IF2CMSK_TYPE uint8_t
149 #define CAN_IF2CMSK CANREG(IF2CMSK)
150 #define CAN_IF2MSK_OFFSET 0x44
151 #define CAN_IF2MSK_TYPE uint32_t
152 #define CAN_IF2MSK CANREG(IF2MSK)
153 #define CAN_IF2ARB_OFFSET 0x48
154 #define CAN_IF2ARB_TYPE uint32_t
155 #define CAN_IF2ARB CANREG(IF2ARB)
156 #define CAN_IF2MCTR_OFFSET 0x4C
157 #define CAN_IF2MCTR_TYPE uint16_t
158 #define CAN_IF2MCTR CANREG(IF2MCTR)
159 #define CAN_IF2DTA_OFFSET 0x4E
160 #define CAN_IF2DTA_TYPE uint32_t
161 #define CAN_IF2DTA CANREG(IF2DTA)
162 #define CAN_IF2DTB_OFFSET 0x52
163 #define CAN_IF2DTB_TYPE uint32_t
164 #define CAN_IF2DTB CANREG(IF2DTB)
165 
166 #define CAN_IFCREQ_BUSY 15
167 
168 #define CAN_IFCMSK_WRRD 7
169 #define CAN_IFCMSK_MASK 6
170 #define CAN_IFCMSK_ARB 5
171 #define CAN_IFCMSK_CONTROL 4
172 #define CAN_IFCMSK_CIP 3
173 #define CAN_IFCMSK_TXREQ 2
174 #define CAN_IFCMSK_DATAA 1
175 #define CAN_IFCMSK_DATAB 0
176 
177 #define CAN_IFMSK_MXTD 31
178 #define CAN_IFMSK_MDIR 30
179 #define CAN_IFMSK_MSK_MASK (0x1fffffffL)
180 
181 #define CAN_IFARB_MSGVAL 31
182 #define CAN_IFARB_XTD 30
183 #define CAN_IFARB_DIR 29
184 #define CAN_IFARB_ID_MASK (0x1fffffffL)
185 
186 #define CAN_IFMCTR_NEWDAT 15
187 #define CAN_IFMCTR_MSGLST 14
188 #define CAN_IFMCTR_INTPNT 13
189 #define CAN_IFMCTR_UMASK 12
190 #define CAN_IFMCTR_TXIE 11
191 #define CAN_IFMCTR_RXIE 10
192 #define CAN_IFMCTR_RMTEN 9
193 #define CAN_IFMCTR_TXRQST 8
194 #define CAN_IFMCTR_EOB 7
195 #define CAN_IFMCTR_DLC_MASK (0x000f)
196 
197 
198 
199 #define CAN_TREQR_OFFSET 0x80
200 #define CAN_TREQR_TYPE uint32_t
201 #define CAN_TREQR CANREG(TREQR)
202 #define CAN_NEWDT_OFFSET 0x90
203 #define CAN_NEWDT_TYPE uint32_t
204 #define CAN_NEWDT CANREG(NEWDT)
205 #define CAN_INTPND_OFFSET 0xA0
206 #define CAN_INTPND_TYPE uint32_t
207 #define CAN_INTPND CANREG(INTPND)
208 #define CAN_MSGVAL_OFFSET 0xB0
209 #define CAN_MSGVAL_TYPE uint32_t
210 #define CAN_MSGVAL CANREG(MSGVAL)
211 
212 
213 
214 #endif /* CAN_CFG_H_ */
215