1.. _mcp2515_shield:
2
3Microchip MCP2515 CAN bus shields
4#################################
5
6Zephyr supports a couple of different shields carrying the Microchip `MCP2515`_
7Stand-Alone CAN Controller with SPI Interface.
8
9DFRobot CAN BUS Shield V2.0
10***************************
11
12Overview
13--------
14
15The DFRobot CAN BUS shield supports the Microchip MCP2515 stand-alone CAN
16controller and JTA1050 high speed CAN transceiver. The shield has an Arduino
17Uno R3 compatible hardware interface.
18
19.. figure:: dfrobot_can_bus_v2_0.jpg
20   :align: center
21   :alt: DFRobot_CAN_BUS_V2_0_SHIELD
22
23Hardware
24--------
25
26- MCP2515
27
28        - Stand-Alone CAN 2.0B Controller
29        - Up to 1Mb/s baud rate
30        - Standard and extended data and remote frames
31        - 3x Tx Buffers
32        - 2x Rx Buffers
33        - 6x 29-bit Filters
34        - 2x 29-bit Masks
35        - Interrupt output
36        - One shot mode
37        - High speed SPI interface (10 MHz)
38
39- TJA1050
40
41        - Fully compatible with the “ISO 11898” standard
42        - High speed (up to 1 Mbaud)
43
44- Connectivity
45
46        - Industrial standard DB9 terminal (CAN)
47        - Screw terminals (CAN)
48        - Integrated MicroSD socket for data storage (SPI)
49        - Arduino Uno R3 compatible (SPI)
50
51+-------+-----------------------+---------------------------+
52| Name  | Function              | Usage                     |
53+=======+=======================+===========================+
54| A0    | None                  |                           |
55+-------+-----------------------+---------------------------+
56| A1    | None                  |                           |
57+-------+-----------------------+---------------------------+
58| A2    | None                  |                           |
59+-------+-----------------------+---------------------------+
60| A3    | None                  |                           |
61+-------+-----------------------+---------------------------+
62| A4    | None                  |                           |
63+-------+-----------------------+---------------------------+
64| A5    | None                  |                           |
65+-------+-----------------------+---------------------------+
66| D0    | RX                    | Ext. header only          |
67+-------+-----------------------+---------------------------+
68| D1    | TX                    | Ext. header only          |
69+-------+-----------------------+---------------------------+
70| D2    | GPIO_ACTIVE_LOW       | MCP2515 - INT             |
71+-------+-----------------------+---------------------------+
72| D3    | None                  |                           |
73+-------+-----------------------+---------------------------+
74| D4    | SPI-CS                | MicroSD                   |
75+-------+-----------------------+---------------------------+
76| D5    | None                  |                           |
77+-------+-----------------------+---------------------------+
78| D6    | None                  |                           |
79+-------+-----------------------+---------------------------+
80| D7    | None                  |                           |
81+-------+-----------------------+---------------------------+
82| D8    | None                  |                           |
83+-------+-----------------------+---------------------------+
84| D9    | None                  |                           |
85+-------+-----------------------+---------------------------+
86| D10   | SPI-CS                | MCP2515                   |
87+-------+-----------------------+---------------------------+
88| D11   | SPI-MOSI              | MCP2515 / MicroSD         |
89+-------+-----------------------+---------------------------+
90| D12   | SPI-MISO              | MCP2515 / MicroSD         |
91+-------+-----------------------+---------------------------+
92| D13   | SPI-CLK               | MCP2515 / MicroSD         |
93+-------+-----------------------+---------------------------+
94| D14   | I2C-SDA               | Ext. header only          |
95+-------+-----------------------+---------------------------+
96| D15   | I2C_SCL               | Ext. header only          |
97+-------+-----------------------+---------------------------+
98
99
100- Power Supply
101
102        - 3.3V ~ 5V
103
104- Components
105
106        - Power switch
107        - Power LED
108        - RX0BF LED
109        - RX1BF LED
110
111For more information about the DFRobot CAN-BUS V2.0 shield:
112
113- `DFRobot Website`_
114- `DFRobot CAN BUS Shield V2.0 schematic`_
115- `MCP2515 Datasheet`_
116- `TJA1050 Datasheet`_
117
118Keyestudio CAN-BUS Shield (KS0411)
119**********************************
120
121Overview
122--------
123
124The Keyestudio CAN BUS shield supports the Microchip MCP2515 stand-alone CAN
125controller and MCP2551 high speed CAN transceiver. The shield has an Arduino
126Uno R3 compatible hardware interface.
127
128.. figure:: keyestudio_can_bus_ks0411.jpg
129   :align: center
130   :alt: Keyestudio CAN-BUS Shield (KS0411)
131
132   Keyestudio CAN-BUS Shield (KS0411) (Credit: Keyestudio)
133
134Hardware
135--------
136
137- MCP2515
138
139        - Stand-Alone CAN 2.0B Controller
140        - Up to 1Mb/s baud rate
141        - Standard and extended data and remote frames
142        - 3x Tx Buffers
143        - 2x Rx Buffers
144        - 6x 29-bit Filters
145        - 2x 29-bit Masks
146        - Interrupt output
147        - One shot mode
148        - High speed SPI interface (10 MHz)
149
150- MCP2551
151
152        - Fully compatible with the “ISO 11898” standard
153        - High speed (up to 1 Mbaud)
154
155- Connectivity
156
157        - Industrial standard DB9 terminal (CAN)
158        - Pin headers (CAN)
159        - Integrated MicroSD socket for data storage (SPI)
160        - Arduino Uno R3 compatible (SPI)
161
162+-------+-----------------------+---------------------------+
163| Name  | Function              | Usage                     |
164+=======+=======================+===========================+
165| A0    | None                  |                           |
166+-------+-----------------------+---------------------------+
167| A1    | None                  |                           |
168+-------+-----------------------+---------------------------+
169| A2    | None                  |                           |
170+-------+-----------------------+---------------------------+
171| A3    | None                  |                           |
172+-------+-----------------------+---------------------------+
173| A4    | None                  |                           |
174+-------+-----------------------+---------------------------+
175| A5    | None                  |                           |
176+-------+-----------------------+---------------------------+
177| D0    | RX                    | Ext. header only          |
178+-------+-----------------------+---------------------------+
179| D1    | TX                    | Ext. header only          |
180+-------+-----------------------+---------------------------+
181| D2    | None                  |                           |
182+-------+-----------------------+---------------------------+
183| D3    | None                  |                           |
184+-------+-----------------------+---------------------------+
185| D4    | None                  |                           |
186+-------+-----------------------+---------------------------+
187| D5    | None                  |                           |
188+-------+-----------------------+---------------------------+
189| D6    | None                  |                           |
190+-------+-----------------------+---------------------------+
191| D7    | None                  |                           |
192+-------+-----------------------+---------------------------+
193| D8    | GPIO_ACTIVE_LOW       | MCP2515 - INT             |
194+-------+-----------------------+---------------------------+
195| D9    | SPI-CS                | MicroSD                   |
196+-------+-----------------------+---------------------------+
197| D10   | SPI-CS                | MCP2515                   |
198+-------+-----------------------+---------------------------+
199| D11   | SPI-MOSI              | MCP2515 / MicroSD         |
200+-------+-----------------------+---------------------------+
201| D12   | SPI-MISO              | MCP2515 / MicroSD         |
202+-------+-----------------------+---------------------------+
203| D13   | SPI-CLK               | MCP2515 / MicroSD         |
204+-------+-----------------------+---------------------------+
205| D14   | I2C-SDA               | Ext. header only          |
206+-------+-----------------------+---------------------------+
207| D15   | I2C_SCL               | Ext. header only          |
208+-------+-----------------------+---------------------------+
209
210
211- Power Supply
212
213        - 5.0VDC
214
215For more information about the Keyestudio CAN-BUS shield:
216
217- `Keyestudio Website`_
218- `Keyestudio Wiki`_
219- `MCP2515 Datasheet`_
220- `MCP2551 Datasheet`_
221
222Adafruit PiCowbell CAN Bus Shield for Pico
223******************************************
224
225Overview
226--------
227
228The Adafruit PiCowbell CAN Bus Shield uses the Microchip MCP2515 controller
229with an TJA1051/3 transceiver. This shield is built for the Raspberry Pi Pico
230and uses the SPI interface. It also contains a Qwiic connector to add support
231for a sensor.
232
233.. figure:: adafruit_can_picowbell.jpg
234   :align: center
235   :alt: Adafruit PiCowbell CAN Bus Shield
236
237   Adafruit PiCowbell CAN Bus Shield
238
239Hardware
240--------
241
242- MCP2515
243
244        - Stand-Alone CAN 2.0B Controller
245        - Up to 1Mb/s baud rate
246        - Standard and extended data and remote frames
247        - 3x Tx Buffers
248        - 2x Rx Buffers
249        - 6x 29-bit Filters
250        - 2x 29-bit Masks
251        - Interrupt output
252        - One shot mode
253        - High speed SPI interface (10 MHz)
254
255- TJA1051
256
257        - Fully compatible with the “ISO 11898-2:2016”, "SAE J2284-1" & "SAE J2284-5"  standards
258        - Supports CAN FD
259        - Fast data rates (up to 5 Mbit/s)
260
261- Connectivity
262
263        - Terminal Block - 3-pin 3.5mm (CAN)
264        - Raspberry Pi Pico compatible (SPI)
265
266+-------+-----------------------+---------------------------+
267| Name  | Function              | Usage                     |
268+=======+=======================+===========================+
269| GP0   | None                  |                           |
270+-------+-----------------------+---------------------------+
271| GP1   | None                  |                           |
272+-------+-----------------------+---------------------------+
273| GP2   | None                  |                           |
274+-------+-----------------------+---------------------------+
275| GP3   | None                  |                           |
276+-------+-----------------------+---------------------------+
277| GP4   | None                  |                           |
278+-------+-----------------------+---------------------------+
279| GP5   | None                  |                           |
280+-------+-----------------------+---------------------------+
281| GP6   | None                  |                           |
282+-------+-----------------------+---------------------------+
283| GP7   | None                  |                           |
284+-------+-----------------------+---------------------------+
285| GP8   | None                  |                           |
286+-------+-----------------------+---------------------------+
287| GP9   | None                  |                           |
288+-------+-----------------------+---------------------------+
289| GP10  | None                  |                           |
290+-------+-----------------------+---------------------------+
291| GP11  | None                  |                           |
292+-------+-----------------------+---------------------------+
293| GP12  | None                  |                           |
294+-------+-----------------------+---------------------------+
295| GP13  | None                  |                           |
296+-------+-----------------------+---------------------------+
297| GP14  | None                  |                           |
298+-------+-----------------------+---------------------------+
299| GP15  | None                  |                           |
300+-------+-----------------------+---------------------------+
301| GP16  | SPI-MISO              | MCP2515                   |
302+-------+-----------------------+---------------------------+
303| GP17  | None                  |                           |
304+-------+-----------------------+---------------------------+
305| GP18  | SPI-SCK               | MCP2515                   |
306+-------+-----------------------+---------------------------+
307| GP19  | SPI-MOSI              | MCP2515                   |
308+-------+-----------------------+---------------------------+
309| GP20  | SPI-CS                | MCP2515                   |
310+-------+-----------------------+---------------------------+
311| GP21  | GPIO_ACTIVE_LOW       | MCP2515 - INT             |
312+-------+-----------------------+---------------------------+
313| GP22  | None                  |                           |
314+-------+-----------------------+---------------------------+
315| GP23  | None                  |                           |
316+-------+-----------------------+---------------------------+
317| GP24  | None                  |                           |
318+-------+-----------------------+---------------------------+
319| GP25  | None                  |                           |
320+-------+-----------------------+---------------------------+
321| GP26  | None                  |                           |
322+-------+-----------------------+---------------------------+
323| GP27  | None                  |                           |
324+-------+-----------------------+---------------------------+
325| GP28  | None                  |                           |
326+-------+-----------------------+---------------------------+
327
328
329- Power Supply
330
331        - 3.3V ~ 5V
332
333For more information about the Adafruit PiCowbell CAN Bus shield:
334
335- `Adafruit Website`_
336- `MCP2515 Datasheet`_
337- `TJA1051 Datasheet`_
338
339Programming
340***********
341
342Set ``--shield dfrobot_can_bus_v2_0`` or ``--shield keyestudio_can_bus_ks0411``
343or ``--shield adafruit_can_picowbell`` when you invoke ``west build`` or ``cmake`` in your Zephyr application. For
344example:
345
346.. zephyr-app-commands::
347   :zephyr-app: samples/drivers/can/counter
348   :tool: all
349   :board: nrf52dk/nrf52832
350   :shield: dfrobot_can_bus_v2_0
351   :goals: build flash
352
353.. zephyr-app-commands::
354   :zephyr-app: samples/drivers/can/counter
355   :tool: all
356   :board: nrf52840dk/nrf52840
357   :shield: keyestudio_can_bus_ks0411
358   :goals: build flash
359
360.. zephyr-app-commands::
361   :zephyr-app: samples/drivers/can/counter
362   :tool: all
363   :board: rpi_pico
364   :shield: adafruit_can_picowbell
365   :goals: build
366
367.. _DFRobot Website:
368   https://www.dfrobot.com/product-1444.html
369
370.. _DFRobot CAN BUS Shield V2.0 schematic:
371   https://github.com/DFRobot/DFRobot_MCP2515/blob/master/resources/doc/DFR0370%20CAN%20BUS%20sheild(V2.0).pdf
372
373.. _MCP2515:
374   https://www.microchip.com/en-us/product/MCP2515
375
376.. _Keyestudio Website:
377   https://www.keyestudio.com/2019new-keyestudio-can-bus-shield-mcp2551-chip-with-sd-socket-for-arduino-uno-r3-p0543.html
378
379.. _Keyestudio Wiki:
380   https://wiki.keyestudio.com/KS0411_keyestudio_CAN-BUS_Shield
381
382.. _MCP2515 Datasheet:
383   http://ww1.microchip.com/downloads/en/DeviceDoc/MCP2515-Stand-Alone-CAN-Controller-with-SPI-20001801J.pdf
384
385.. _TJA1050 Datasheet:
386   https://www.nxp.com/docs/en/data-sheet/TJA1050.pdf
387
388.. _MCP2551 Datasheet:
389   https://ww1.microchip.com/downloads/en/DeviceDoc/20001667G.pdf
390
391.. _Adafruit Website:
392   https://www.adafruit.com/product/5728#technical-details
393
394.. _TJA1051 Datasheet:
395   https://www.nxp.com/docs/en/data-sheet/TJA1051.pdf
396