Skip to content

Commit

Permalink
boards: shields: Adding support for the adafruit can picowbell shield
Browse files Browse the repository at this point in the history
Adding support for the adafruit can picowbell shield for the
raspberry pi picoi. Also added nodelable for spi0 called 'pico_spi'
as well as an GPIO nexus node 'pico_header'

Signed-off-by: Joseph Yates <joeyatessecond@gmail.com>
  • Loading branch information
joeker64 committed Jul 6, 2023
1 parent bbec614 commit 444bed2
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 1 deletion.
35 changes: 35 additions & 0 deletions boards/arm/rpi_pico/rpi_pico-common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,39 @@
aliases {
watchdog0 = &wdt0;
};

pico_header: connector {
compatible = "raspberrypi,pico-header";
#gpio-cells = <2>;
gpio-map-mask = <0xffffffff 0xffffffc0>;
gpio-map-pass-thru = <0 0x3f>;
gpio-map = <0 0 &gpio0 0 0>, /* GP0 */
<1 0 &gpio0 1 0>, /* GP1 */
<2 0 &gpio0 2 0>, /* GP2 */
<3 0 &gpio0 3 0>, /* GP3 */
<4 0 &gpio0 4 0>, /* GP4 */
<5 0 &gpio0 5 0>, /* GP5 */
<6 0 &gpio0 6 0>, /* GP6 */
<7 0 &gpio0 7 0>, /* GP7 */
<8 0 &gpio0 8 0>, /* GP8 */
<9 0 &gpio0 9 0>, /* GP9 */
<10 0 &gpio0 10 0>, /* GP10 */
<11 0 &gpio0 11 0>, /* GP11 */
<12 0 &gpio0 12 0>, /* GP12 */
<13 0 &gpio0 13 0>, /* GP13 */
<14 0 &gpio0 14 0>, /* GP14 */
<15 0 &gpio0 15 0>, /* GP15 */
<16 0 &gpio0 16 0>, /* GP16 */
<17 0 &gpio0 17 0>, /* GP17 */
<18 0 &gpio0 18 0>, /* GP18 */
<19 0 &gpio0 19 0>, /* GP19 */
<20 0 &gpio0 20 0>, /* GP20 */
<21 0 &gpio0 21 0>, /* GP21 */
<22 0 &gpio0 22 0>, /* GP22 */
<26 0 &gpio0 26 0>, /* GP26 */
<27 0 &gpio0 27 0>, /* GP27 */
<28 0 &gpio0 28 0>; /* GP28 */
};
};

&flash0 {
Expand Down Expand Up @@ -110,3 +143,5 @@ zephyr_udc0: &usbd {
regulator-always-on;
regulator-allowed-modes = <REGULATOR_RPI_PICO_MODE_NORMAL>;
};

pico_spi: &spi0 {};
3 changes: 3 additions & 0 deletions boards/shields/mcp2515/Kconfig.shield
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ config SHIELD_DFROBOT_CAN_BUS_V2_0

config SHIELD_KEYESTUDIO_CAN_BUS_KS0411
def_bool $(shields_list_contains,keyestudio_can_bus_ks0411)

config SHIELD_ADAFRUIT_CAN_PICOWBELL
def_bool $(shields_list_contains,adafruit_can_picowbell)
32 changes: 32 additions & 0 deletions boards/shields/mcp2515/adafruit_can_picowbell.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2023 Joseph Yates
*
* SPDX-License-Identifier: Apache-2.0
*/

&pico_spi {
status = "okay";
cs-gpios = <&pico_header 20 GPIO_ACTIVE_LOW>;

mcp2515_adafruit_can_picowbell: can@0 {
compatible = "microchip,mcp2515";
spi-max-frequency = <1000000>;
int-gpios = <&pico_header 21 GPIO_ACTIVE_LOW>;
status = "okay";
reg = <0x0>;
osc-freq = <16000000>;
bus-speed = <125000>;
sjw = <1>;
sample-point = <875>;

can-transceiver {
max-bitrate = <1000000>;
};
};
};

/ {
chosen {
zephyr,canbus = &mcp2515_adafruit_can_picowbell;
};
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
132 changes: 131 additions & 1 deletion boards/shields/mcp2515/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,128 @@ For more information about the Keyestudio CAN-BUS shield:
- `MCP2515 Datasheet`_
- `MCP2551 Datasheet`_

Adafruit PiCowbell CAN Bus Shield for Pico
******************************************

Overview
--------

The Adafruit PiCowbell CAN Bus Shield uses the Microchip MCP2515 controller
with an TJA1051/3 transceiver. This shield is built for the Raspberry Pi Pico
and uses the SPI interface. It also contains a Qwiic connector to add support
for a sensor.

.. figure:: adafruit_can_picowbell.jpg
:align: center
:alt: Adafruit PiCowbell CAN Bus Shield

Adafruit PiCowbell CAN Bus Shield

Hardware
--------

- MCP2515

- Stand-Alone CAN 2.0B Controller
- Up to 1Mb/s baud rate
- Standard and extended data and remote frames
- 3x Tx Buffers
- 2x Rx Buffers
- 6x 29-bit Filters
- 2x 29-bit Masks
- Interrupt output
- One shot mode
- High speed SPI interface (10 MHz)

- TJA1051

- Fully compatible with the “ISO 11898-2:2016”, "SAE J2284-1" & "SAE J2284-5" standards
- Supports CAN FD
- Fast data rates (up to 5 Mbit/s)

- Connectivity

- Terminal Block - 3-pin 3.5mm (CAN)
- Raspberry Pi Pico compatible (SPI)

+-------+-----------------------+---------------------------+
| Name | Function | Usage |
+=======+=======================+===========================+
| GP0 | None | |
+-------+-----------------------+---------------------------+
| GP1 | None | |
+-------+-----------------------+---------------------------+
| GP2 | None | |
+-------+-----------------------+---------------------------+
| GP3 | None | |
+-------+-----------------------+---------------------------+
| GP4 | None | |
+-------+-----------------------+---------------------------+
| GP5 | None | |
+-------+-----------------------+---------------------------+
| GP6 | None | |
+-------+-----------------------+---------------------------+
| GP7 | None | |
+-------+-----------------------+---------------------------+
| GP8 | None | |
+-------+-----------------------+---------------------------+
| GP9 | None | |
+-------+-----------------------+---------------------------+
| GP10 | None | |
+-------+-----------------------+---------------------------+
| GP11 | None | |
+-------+-----------------------+---------------------------+
| GP12 | None | |
+-------+-----------------------+---------------------------+
| GP13 | None | |
+-------+-----------------------+---------------------------+
| GP14 | None | |
+-------+-----------------------+---------------------------+
| GP15 | None | |
+-------+-----------------------+---------------------------+
| GP16 | SPI-MISO | MCP2515 |
+-------+-----------------------+---------------------------+
| GP17 | None | |
+-------+-----------------------+---------------------------+
| GP18 | SPI-SCK | MCP2515 |
+-------+-----------------------+---------------------------+
| GP19 | SPI-MOSI | MCP2515 |
+-------+-----------------------+---------------------------+
| GP20 | SPI-CS | MCP2515 |
+-------+-----------------------+---------------------------+
| GP21 | GPIO_ACTIVE_LOW | MCP2515 - INT |
+-------+-----------------------+---------------------------+
| GP22 | None | |
+-------+-----------------------+---------------------------+
| GP23 | None | |
+-------+-----------------------+---------------------------+
| GP24 | None | |
+-------+-----------------------+---------------------------+
| GP25 | None | |
+-------+-----------------------+---------------------------+
| GP26 | None | |
+-------+-----------------------+---------------------------+
| GP27 | None | |
+-------+-----------------------+---------------------------+
| GP28 | None | |
+-------+-----------------------+---------------------------+


- Power Supply

- 3.3V ~ 5V

For more information about the Adafruit PiCowbell CAN Bus shield:

- `Adafruit Website`_
- `MCP2515 Datasheet`_
- `TJA1051 Datasheet`_

Programming
***********

Set ``-DSHIELD=dfrobot_can_bus_v2_0`` or ``-DSHIELD=keyestudio_can_bus_ks0411``
when you invoke ``west build`` or ``cmake`` in your Zephyr application. For
or ``-DSHIELD=adafruit_can_picowbell`` when you invoke ``west build`` or ``cmake`` in your Zephyr application. For
example:

.. zephyr-app-commands::
Expand All @@ -240,6 +357,13 @@ example:
:shield: keyestudio_can_bus_ks0411
:goals: build flash

.. zephyr-app-commands::
:zephyr-app: samples/drivers/can/counter
:tool: all
:board: rpi_pico
:shield: adafruit_can_picowbell
:goals: build

.. _DFRobot Website:
https://www.dfrobot.com/product-1444.html

Expand All @@ -263,3 +387,9 @@ example:

.. _MCP2551 Datasheet:
https://ww1.microchip.com/downloads/en/DeviceDoc/20001667G.pdf

.. _Adafruit Website:
https://www.adafruit.com/product/5728#technical-details

.. _TJA1051 Datasheet:
https://www.nxp.com/docs/en/data-sheet/TJA1051.pdf
34 changes: 34 additions & 0 deletions dts/bindings/gpio/raspberrypi,pico-header.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2023, Joseph Yates
# SPDX-License-Identifier: Apache-2.0

description: |
GPIO pins exposed on Raspberry Pi Pico headers.
The Raspberry Pi Pico layout provides 2 columns of 20 pins headers
This binding provides a nexus mapping for the default 26 pins as depicted below:
0 GPIO0/UART0_TX VBUS -
1 GPIO1/UART0_RX VSYS -
- GND GND -
2 GPIO2 3V3_EN -
3 GPIO3 3V3_OUT -
4 GPIO4/I2C0_SDA ADC_VREF -
5 GPIO5/I2C0_SCL GPIO28/ADC2 28
- GND GND -
6 GPIO6 GPIO27/ADC1 27
7 GPIO7 GPIO26/ADC0 26
8 GPIO8 RUN -
9 GPIO9 GPIO22 22
- GND GND -
10 GPIO10 GPIO21 21
11 GPIO11 GPIO20 20
12 GPIO12 GPIO19/SPI0_TX 19
13 GPIO13 GPIO18/SPI0_SCK 18
- GND GND -
14 GPIO14 GPIO17/SPI0_CSn 17
15 GPIO15 GPIO16/SPI0_RX 16
compatible: "raspberrypi,pico-header"

include: [gpio-nexus.yaml, base.yaml]

0 comments on commit 444bed2

Please sign in to comment.