mcp2515_defines.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 OTA keys S.A.
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
22 #ifndef MCP2515_DEFINES_H
23 #define MCP2515_DEFINES_H
24 
25 #include <stdint.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
35 #define MCP2515_RXF0SIDH 0x00
36 #define MCP2515_RXF0SIDL 0x01
37 #define MCP2515_RXF0EID8 0x02
38 #define MCP2515_RXF0EID0 0x03
39 
40 #define MCP2515_RXF1SIDH 0x04
41 #define MCP2515_RXF1SIDL 0x05
42 #define MCP2515_RXF1EID8 0x06
43 #define MCP2515_RXF1EID0 0x07
44 
45 #define MCP2515_RXF2SIDH 0x08
46 #define MCP2515_RXF2SIDL 0x09
47 #define MCP2515_RXF2EID8 0x0A
48 #define MCP2515_RXF2EID0 0x0B
49 
50 #define MCP2515_BFPCTRL 0x0C
51 #define MCP2515_TXRTSCTRL 0x0D
52 #define MCP2515_CANSTAT 0x0E
53 #define MCP2515_CANCTRL 0x0F
54 
55 #define MCP2515_RXF3SIDH 0x10
56 #define MCP2515_RXF3SIDL 0x11
57 #define MCP2515_RXF3EID8 0x12
58 #define MCP2515_RXF3EID0 0x13
59 
60 #define MCP2515_RXF4SIDH 0x14
61 #define MCP2515_RXF4SIDL 0x15
62 #define MCP2515_RXF4EID8 0x16
63 #define MCP2515_RXF4EID0 0x17
64 
65 #define MCP2515_RXF5SIDH 0x18
66 #define MCP2515_RXF5SIDL 0x19
67 #define MCP2515_RXF5EID8 0x1A
68 #define MCP2515_RXF5EID0 0x1B
69 
70 #define MCP2515_TEC 0x1C
71 #define MCP2515_REC 0x1D
72 
73 #define MCP2515_RXM0SIDH 0x20
74 #define MCP2515_RXM0SIDL 0x21
75 #define MCP2515_RXM0EID8 0x22
76 #define MCP2515_RXM0EID0 0x23
77 
78 #define MCP2515_RXM1SIDH 0x24
79 #define MCP2515_RXM1SIDL 0x25
80 #define MCP2515_RXM1EID8 0x26
81 #define MCP2515_RXM1EID0 0x27
82 
83 #define MCP2515_CNF3 0x28
84 #define MCP2515_CNF2 0x29
85 #define MCP2515_CNF1 0x2A
86 #define MCP2515_CANINTE 0x2B
87 
88 #define MCP2515_CANINTF 0x2C
89 #define MCP2515_EFLG 0x2D
90 
91 #define MCP2515_TXB0CTRL 0x30
92 #define MCP2515_TXB0SIDH 0x31
93 #define MCP2515_TXB0SIDL 0x32
94 #define MCP2515_TXB0EID8 0x33
95 #define MCP2515_TXB0EID0 0x34
96 #define MCP2515_TXB0DLC 0x35
97 #define MCP2515_TXB0D0 0x36
98 #define MCP2515_TXB0D1 0x37
99 #define MCP2515_TXB0D2 0x38
100 #define MCP2515_TXB0D3 0x39
101 #define MCP2515_TXB0D4 0x3A
102 #define MCP2515_TXB0D5 0x3B
103 #define MCP2515_TXB0D6 0x3C
104 #define MCP2515_TXB0D7 0x3D
105 
106 #define MCP2515_TXB1CTRL 0x40
107 #define MCP2515_TXB1SIDH 0x41
108 #define MCP2515_TXB1SIDL 0x42
109 #define MCP2515_TXB1EID8 0x43
110 #define MCP2515_TXB1EID0 0x44
111 #define MCP2515_TXB1DLC 0x45
112 #define MCP2515_TXB1D0 0x46
113 #define MCP2515_TXB1D1 0x47
114 #define MCP2515_TXB1D2 0x48
115 #define MCP2515_TXB1D3 0x49
116 #define MCP2515_TXB1D4 0x4A
117 #define MCP2515_TXB1D5 0x4B
118 #define MCP2515_TXB1D6 0x4C
119 #define MCP2515_TXB1D7 0x4D
120 
121 #define MCP2515_TXB2CTRL 0x50
122 #define MCP2515_TXB2SIDH 0x51
123 #define MCP2515_TXB2SIDL 0x52
124 #define MCP2515_TXB2EID8 0x53
125 #define MCP2515_TXB2EID0 0x54
126 #define MCP2515_TXB2DLC 0x55
127 #define MCP2515_TXB2D0 0x56
128 #define MCP2515_TXB2D1 0x57
129 #define MCP2515_TXB2D2 0x58
130 #define MCP2515_TXB2D3 0x59
131 #define MCP2515_TXB2D4 0x5A
132 #define MCP2515_TXB2D5 0x5B
133 #define MCP2515_TXB2D6 0x5C
134 #define MCP2515_TXB2D7 0x5D
135 
136 #define MCP2515_RXB0CTRL 0x60
137 #define MCP2515_RXB0SIDH 0x61
138 #define MCP2515_RXB0SIDL 0x62
139 #define MCP2515_RXB0EID8 0x63
140 #define MCP2515_RXB0EID0 0x64
141 #define MCP2515_RXB0DLC 0x65
142 #define MCP2515_RXB0D0 0x66
143 #define MCP2515_RXB0D1 0x67
144 #define MCP2515_RXB0D2 0x68
145 #define MCP2515_RXB0D3 0x69
146 #define MCP2515_RXB0D4 0x6A
147 #define MCP2515_RXB0D5 0x6B
148 #define MCP2515_RXB0D6 0x6C
149 #define MCP2515_RXB0D7 0x6D
150 
151 #define MCP2515_RXB1CTRL 0x70
152 #define MCP2515_RXB1SIDH 0x71
153 #define MCP2515_RXB1SIDL 0x72
154 #define MCP2515_RXB1EID8 0x73
155 #define MCP2515_RXB1EID0 0x74
156 #define MCP2515_RXB1DLC 0x75
157 #define MCP2515_RXB1D0 0x76
158 #define MCP2515_RXB1D1 0x77
159 #define MCP2515_RXB1D2 0x78
160 #define MCP2515_RXB1D3 0x79
161 #define MCP2515_RXB1D4 0x7A
162 #define MCP2515_RXB1D5 0x7B
163 #define MCP2515_RXB1D6 0x7C
164 #define MCP2515_RXB1D7 0x7D
165 
171 #define MCP2515_BFPCTRL_B0BFM 0x01
172 #define MCP2515_BFPCTRL_B1BFM 0x02
173 #define MCP2515_BFPCTRL_B0BFE 0x04
174 #define MCP2515_BFPCTRL_B1BFE 0x08
175 
176 #define MCP2515_BFPCTRL_B0BFS 0x10
177 #define MCP2515_BFPCTRL_B1BFS 0x20
178 
179 #define MCP2515_TXRTSCTRL_B0RTSM 0x01
180 #define MCP2515_TXRTSCTRL_B1RTSM 0x02
181 #define MCP2515_TXRTSCTRL_B2RTSM 0x04
182 #define MCP2515_TXRTSCTRL_B0RTS 0x08
183 #define MCP2515_TXRTSCTRL_B1RTS 0x10
184 #define MCP2515_TXRTSCTRL_B2RTS 0x20
185 
186 #define MCP2515_CANSTAT_ICOD0 0x02
187 #define MCP2515_CANSTAT_ICOD1 0x04
188 #define MCP2515_CANSTAT_ICOD2 0x08
189 #define MCP2515_CANSTAT_OPMOD0 0x20
190 #define MCP2515_CANSTAT_OPMOD1 0x40
191 #define MCP2515_CANSTAT_OPMOD2 0x80
192 
193 #define MCP2515_CANSTAT_ICOD_MASK 0x0E
194 
195 #define MCP2515_CANSTAT_OPMOD_MASK 0xE0
196 #define MCP2515_CANSTAT_OPMOD_CONFIGURATION MCP2515_CANSTAT_OPMOD2
197 #define MCP2515_CANSTAT_OPMOD_NORMAL 0x00
198 #define MCP2515_CANSTAT_OPMOD_SLEEP MCP2515_CANSTAT_OPMOD0
199 #define MCP2515_CANSTAT_OPMOD_LOOPBACK MCP2515_CANSTAT_OPMOD1
200 #define MCP2515_CANSTAT_OPMOD_LISTEN_ONLY (MCP2515_CANSTAT_OPMOD1 | \
201  MCP2515_CANSTAT_OPMOD0)
202 
203 #define MCP2515_CANCTRL_CLKPRE0 0x01
204 #define MCP2515_CANCTRL_CLKPRE1 0x02
205 #define MCP2515_CANCTRL_CLKEN 0x04
206 #define MCP2515_CANCTRL_OSM 0x08
207 #define MCP2515_CANCTRL_ABAT 0x10
208 #define MCP2515_CANCTRL_REQOP0 0x20
209 #define MCP2515_CANCTRL_REQOP1 0x40
210 #define MCP2515_CANCTRL_REQOP2 0x80
211 
212 #define MCP2515_CANCTRL_CLKPRE_MASK (MCP2515_CANCTRL_CLKPRE1 | \
213  MCP2515_CANCTRL_CLKPRE0)
214 
215 #define MCP2515_CANCTRL_REQOP_MASK 0xE0
216 #define MCP2515_CANCTRL_REQOP_CONFIGURATION MCP2515_CANCTRL_REQOP2
217 #define MCP2515_CANCTRL_REQOP_NORMAL 0x00
218 #define MCP2515_CANCTRL_REQOP_SLEEP MCP2515_CANCTRL_REQOP0
219 #define MCP2515_CANCTRL_REQOP_LOOPBACK MCP2515_CANCTRL_REQOP1
220 #define MCP2515_CANCTRL_REQOP_LISTEN_ONLY (MCP2515_CANCTRL_REQOP1 | \
221  MCP2515_CANCTRL_REQOP0)
222 
223 #define MCP2515_CNF3_PHSEG20 0x01
224 #define MCP2515_CNF3_PHSEG21 0x02
225 #define MCP2515_CNF3_PHSEG22 0x04
226 #define MCP2515_CNF3_WAKFIL 0x40
227 #define MCP2515_CNF3_SOF 0x80
228 
229 #define MCP2515_CNF3_PHSEG_MASK 0x07
230 
231 #define MCP2515_CNF2_PRSEG0 0x01
232 #define MCP2515_CNF2_PRSEG1 0x02
233 #define MCP2515_CNF2_PRSEG2 0x04
234 #define MCP2515_CNF2_PHSEG10 0x08
235 #define MCP2515_CNF2_PHSEG11 0x10
236 #define MCP2515_CNF2_PHSEG12 0x20
237 #define MCP2515_CNF2_SAM 0x40
238 #define MCP2515_CNF2_BTLMODE 0x80
239 
240 #define MCP2515_CNF2_PRSEG_MASK 0x07
241 #define MCP2515_CNF2_PHSEG_MASK 0x38
242 
243 #define MCP2515_CNF1_BRP0 0x01
244 #define MCP2515_CNF1_BRP1 0x02
245 #define MCP2515_CNF1_BRP2 0x04
246 #define MCP2515_CNF1_BRP3 0x08
247 #define MCP2515_CNF1_BRP4 0x10
248 #define MCP2515_CNF1_BRP5 0x20
249 #define MCP2515_CNF1_SJW0 0x40
250 #define MCP2515_CNF1_SJW1 0x80
251 
252 #define MCP2515_CNF1_BRP_MASK 0x3F
253 #define MCP2515_CNF1_SJW_MASK 0xC0
254 
255 #define MCP2515_CANINTE_RX0IE 0x01
256 #define MCP2515_CANINTE_RX1IE 0x02
257 #define MCP2515_CANINTE_TX0IE 0x04
258 #define MCP2515_CANINTE_TX1IE 0x08
259 #define MCP2515_CANINTE_TX2IE 0x10
260 #define MCP2515_CANINTE_ERRIE 0x20
261 #define MCP2515_CANINTE_WAKIE 0x40
262 #define MCP2515_CANINTE_MERRE 0x80
263 
264 #define MCP2515_CANINTF_RX0IF 0x01
265 #define MCP2515_CANINTF_RX1IF 0x02
266 #define MCP2515_CANINTF_TX0IF 0x04
267 #define MCP2515_CANINTF_TX1IF 0x08
268 #define MCP2515_CANINTF_TX2IF 0x10
269 #define MCP2515_CANINTF_ERRIF 0x20
270 #define MCP2515_CANINTF_WAKIF 0x40
271 #define MCP2515_CANINTF_MERRF 0x80
272 
278 #define MCP2515_EFLG_EWARN 0x01
279 #define MCP2515_EFLG_RXWAR 0x02
280 #define MCP2515_EFLG_TXWAR 0x04
281 #define MCP2515_EFLG_RXEP 0x08
282 #define MCP2515_EFLG_TXEP 0x10
283 #define MCP2515_EFLG_TXBO 0x20
284 #define MCP2515_EFLG_RX0OVR 0x40
285 #define MCP2515_EFLG_RX1OVR 0x80
286 
292 #define MCP2515_TXBCTRL_TXP0 0x01
293 #define MCP2515_TXBCTRL_TXP1 0x02
294 #define MCP2515_TXBCTRL_TXREQ 0x08
295 #define MCP2515_TXBCTRL_TXERR 0x10
296 #define MCP2515_TXBCTRL_MLOA 0x20
297 #define MCP2515_TXBCTRL_ABTF 0x40
298 
299 #define MCP2515_RXB0CTRL_FILHIT0 0x01
300 #define MCP2515_RXB0CTRL_BUKT1 0x02
301 #define MCP2515_RXB0CTRL_BUKT 0x04
302 #define MCP2515_RXB0CTRL_RXRTR 0x08
303 #define MCP2515_RXB0CTRL_RXM0 0x20
304 #define MCP2515_RXB0CTRL_RXM1 0x40
305 #define MCP2515_RXB0CTRL_MODE_RECV_STD_OR_EXT 0x00
306 #define MCP2515_RXB0CTRL_MODE_RECV_STD MCP2515_RXB0CTRL_RXM0
307 #define MCP2515_RXB0CTRL_MODE_RECV_EXT MCP2515_RXB0CTRL_RXM1
308 #define MCP2515_RXB0CTRL_MODE_RECV_ALL (MCP2515_RXB0CTRL_RXM1 | \
309  MCP2515_RXB0CTRL_RXM0)
310 
311 #define MCP2515_RXB1CTRL_FILHIT0 0x01
312 #define MCP2515_RXB1CTRL_FILHIT1 0x02
313 #define MCP2515_RXB1CTRL_FILHIT2 0x04
314 #define MCP2515_RXB1CTRL_RXRTR 0x08
315 #define MCP2515_RXB1CTRL_RXM0 0x20
316 #define MCP2515_RXB1CTRL_RXM1 0x40
317 #define MCP2515_RXB1CTRL_MODE_RECV_STD_OR_EXT 0x00
318 #define MCP2515_RXB1CTRL_MODE_RECV_STD MCP2515_RXB1CTRL_RXM0
319 #define MCP2515_RXB1CTRL_MODE_RECV_EXT MCP2515_RXB1CTRL_RXM1
320 #define MCP2515_RXB1CTRL_MODE_RECV_ALL (MCP2515_RXB1CTRL_RXM1 | \
321  MCP2515_RXB1CTRL_RXM0)
322 
328 #define MCP2515_SPI_RESET 0xC0
329 #define MCP2515_SPI_READ 0x03
330 #define MCP2515_SPI_READ_RXBUF 0x90
331 #define MCP2515_SPI_WRITE 0x02
332 #define MCP2515_SPI_LOAD_TXBUF 0x40
333 #define MCP2515_SPI_RTS 0x80
334 #define MCP2515_SPI_READ_STATUS 0xA0
335 #define MCP2515_SPI_RX_STATUS 0xB0
336 #define MCP2515_SPI_BITMOD 0x05
337 
343 #define MCP2515_RXBUF_RXB0SIDH 0x00
344 #define MCP2515_RXBUF_RXB0D0 0x02
345 #define MCP2515_RXBUF_RXB1SIDH 0x04
346 #define MCP2515_RXBUF_RXB1D0 0x06
347 
353 #define MCP2515_TXBUF_TXB0SIDH 0x00
354 #define MCP2515_TXBUF_TXB0D0 0x01
355 #define MCP2515_TXBUF_TXB1SIDH 0x02
356 #define MCP2515_TXBUF_TXB1D0 0x03
357 #define MCP2515_TXBUF_TXB2SIDH 0x04
358 #define MCP2515_TXBUF_TXB2D0 0x05
359 
365 #define MCP2515_OPTION_ROLLOVER 1
366 #define MCP2515_OPTION_ONESHOT 2
367 #define MCP2515_OPTION_ABORT 3
368 #define MCP2515_OPTION_CLOCKOUT 4
369 #define MCP2515_OPTION_LOOPBACK 5
370 #define MCP2515_OPTION_LISTEN_ONLY 6
371 #define MCP2515_OPTION_SLEEP 7
372 #define MCP2515_OPTION_MULTISAMPLE 8
373 #define MCP2515_OPTION_SOFOUT 9
374 #define MCP2515_OPTION_WAKE_GLITCH_FILTER 10
375 #define MCP2515_OPTION_WAKE 11
376 
382 #define MCP2515_IRQ_FLAGGED 0x80
383 #define MCP2515_IRQ_HANDLED 0x40
384 #define MCP2515_IRQ_RX 0x01
385 #define MCP2515_IRQ_TX 0x02
386 #define MCP2515_IRQ_ERROR 0x04
387 #define MCP2515_IRQ_WAKEUP 0x08
388 
394 #define MCP2515_RX_IDE 0x08
395 
397 #ifdef __cplusplus
398 }
399 #endif
400 
401 #endif /* MCP2515_DEFINES_H */
402