Skip to content

Commit be49554

Browse files
authored
Add support for Pico (rp2040) boards (#34)
* HyperSPI support for Pico (rp2040) * Adafruit RP2040 Scorpio support (ItsyBitsy uses default build) No support for rp2040 Pimoroni level shifter boards because of missing GPIO SPI pins. * Update README.md * Update hyperspi.cpp * Update README.md * Update README.md
1 parent 2bc11ce commit be49554

File tree

8 files changed

+388
-15
lines changed

8 files changed

+388
-15
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: HyperSPI Pico CI Build
2+
3+
on: [push]
4+
5+
jobs:
6+
7+
#############################
8+
#### HyperSPI for Pico ######
9+
#############################
10+
11+
HyperSpiPico:
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: ./rp2040
16+
steps:
17+
- uses: actions/checkout@v3
18+
with:
19+
submodules: recursive
20+
21+
- name: Install GNU Arm Embedded Toolchain
22+
uses: carlosperate/arm-none-eabi-gcc-action@v1
23+
with:
24+
release: '12.2.Rel1'
25+
26+
- name: Build packages
27+
shell: bash
28+
run: |
29+
mkdir build
30+
cd build
31+
cmake ..
32+
cmake --build . --config Release
33+
34+
- uses: actions/upload-artifact@v3
35+
name: Upload artifacts (commit)
36+
if: (startsWith(github.event.ref, 'refs/tags') != true)
37+
with:
38+
path: |
39+
rp2040/HyperSerialPico/firmware/*.uf2
40+
41+
- uses: actions/upload-artifact@v3
42+
name: Upload artifacts (release)
43+
if: startsWith(github.ref, 'refs/tags/')
44+
with:
45+
name: firmware-release
46+
path: |
47+
rp2040/HyperSerialPico/firmware/*.uf2
48+
49+
- name: Build packages for Adafruit Feather RP2040 Scorpio
50+
shell: bash
51+
run: |
52+
cd build
53+
rm *.*
54+
rm ../HyperSerialPico/firmware/*
55+
echo "Neopixel is using GPIO16(OUTPUT_DATA_PIN) on output 0." > ../HyperSerialPico/firmware/Firmwares_for_Adafruit_Feather_RP2040_Scorpio.txt
56+
cmake -DOVERRIDE_DATA_PIN=16 -DCMAKE_BUILD_TYPE=Release ..
57+
cmake --build .
58+
zip -j ../HyperSerialPico/firmware/Adafruit_Feather_RP2040_Scorpio.zip ../HyperSerialPico/firmware/*
59+
60+
- uses: actions/upload-artifact@v3
61+
name: Upload artifacts (Adafruit_Feather)
62+
if: (startsWith(github.event.ref, 'refs/tags') != true)
63+
with:
64+
path: |
65+
rp2040/HyperSerialPico/firmware/*.zip
66+
67+
- uses: actions/upload-artifact@v3
68+
name: Upload artifacts (release for Adafruit_Feather)
69+
if: startsWith(github.ref, 'refs/tags/')
70+
with:
71+
name: firmware-release
72+
path: |
73+
rp2040/HyperSerialPico/firmware/*.zip
74+
75+
################################
76+
###### Publish Releases ########
77+
################################
78+
79+
publish:
80+
name: Publish Releases
81+
if: startsWith(github.event.ref, 'refs/tags')
82+
needs: [HyperSpiPico]
83+
runs-on: ubuntu-latest
84+
permissions:
85+
contents: write
86+
steps:
87+
# generate environment variables
88+
- name: Generate environment variables from version and tag
89+
run: |
90+
echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
91+
echo "preRelease=false" >> $GITHUB_ENV
92+
93+
# If version contains alpha or beta, mark draft release as pre-release
94+
- name: Mark release as pre-release
95+
if: contains(env.VERSION, 'alpha') || contains(env.VERSION, 'beta')
96+
run: echo "preRelease=true" >> $GITHUB_ENV
97+
98+
- uses: actions/download-artifact@v3
99+
with:
100+
name: firmware-release
101+
102+
# create draft release and upload artifacts
103+
- name: Create draft release
104+
uses: softprops/action-gh-release@v1
105+
with:
106+
name: HyperSPI ${{ env.VERSION }}
107+
tag_name: ${{ env.TAG }}
108+
files: |
109+
*.uf2
110+
*.zip
111+
draft: true
112+
prerelease: ${{ env.preRelease }}
113+
env:
114+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/push-master.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: HyperSPI CI Build
1+
name: HyperSPI ESP32/8266 CI Build
22

33
on: [push]
44

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "rp2040/HyperSerialPico"]
2+
path = rp2040/HyperSerialPico
3+
url = https://github.com/awawa-dev/HyperSerialPico

README.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# HyperSPI
22
SPI bridge for AWA protocol to control a LED strip from HyperHDR.
33
Diagnostic and performance data available at the serial port output [read more](#performancedebug-output).
4-
Rpi acts as a master, ESP8266/ESP32/ESP32-S2 is in slave mode.
4+
Raspberry Pi acts as a master, ESP8266/ESP32/ESP32-S2/rp2040(Raspberry Pi Pico) is in slave mode.
55

6-
| LED strip / Device | ESP8266<br>(limited performance) | ESP32 / ESP32-S2 mini |
7-
|--------------------------------|:-------:|:-----------:|
8-
| SK6812 cold white | yes | yes |
9-
| SK6812 neutral white | yes | yes |
10-
| WS281x | yes | yes |
6+
| LED strip / Device | rp2040 / Pico | ESP8266<br>(limited performance) | ESP32 / ESP32-S2 mini
7+
|--------------------------------|:-------:|:-----------:|:-------:|
8+
| SK6812 cold white | yes | yes | yes |
9+
| SK6812 neutral white | yes | yes | yes |
10+
| WS281x | yes | yes | yes |
1111

1212

1313
# Why this project was created?
@@ -23,9 +23,19 @@ Rpi acts as a master, ESP8266/ESP32/ESP32-S2 is in slave mode.
2323

2424
If you are using an ESP board compatible with the Wemos board (ESP8266 Wemos D1/pro, ESP32 MH-ET Live, ESP32-S2 lolin mini), the SPI connection uses the same pinout location on the ESP board! The pin positions of the LED output may vary. Cables (including ground) should not exceed 15-20cm or it may be necessary to lower the SPI speed.
2525

26+
The photos below use the same home-made adapter throughout, so you can see a repeating pattern and the cable colors should help you locate the correct pins. However, always consult the GPIO diagram for your boards to confirm that you have connected the cables correctly, because if you make a mistake and connect to the 5V GPIO line, it may damage both devices.
27+
28+
As you can also notice, the pinout of the SPI0 interface is identical for the entire Raspberry Pi SBC family: 3, 4, 5, Zero 2W, etc.
29+
2630
<table>
2731
<tr>
28-
<td colspan="2"><p align="center">See how easy it is to connect ESP to Raspberry Pi using SPI</p></td>
32+
<td colspan="2"><p align="center">See how easy it is to connect Raspberry Pi Pico (rp2040) to Raspberry Pi 5 using SPI</p></td>
33+
</tr>
34+
<tr>
35+
<td colspan="2"><img src="https://github.com/awawa-dev/HyperSPI/assets/69086569/7f24f87e-f7e0-43f3-a568-39d0f6beced1"/></td>
36+
</tr>
37+
<tr>
38+
<td colspan="2"><p align="center">or if you prefer ESP32/ESP32-S2/Esp8266</p></td>
2939
</tr>
3040
<tr>
3141
<td><img src="https://github.com/awawa-dev/HyperSPI/assets/69086569/1e500ca3-e93d-4082-af59-b701e6274a29"/></td>
@@ -52,13 +62,16 @@ If you are using an ESP board compatible with the Wemos board (ESP8266 Wemos D1/
5262

5363
## Default pinout (can be changed for esp32 and esp32-s2)
5464

55-
| PINOUT | ESP8266 | ESP32 | ESP32-S2 lolin mini|
56-
|-------------|-----------|-----------|-----------|
57-
| Clock (SCK) | GPIO 14 | GPIO 18 | GPIO 7 |
58-
| Data (MOSI) | GPIO 13 | GPIO 23 | GPIO 11 |
59-
| SPI Chip Select(e.g. CE0) | not used | GPIO 5 | GPIO 12 |
60-
| GROUND | mandatory | mandatory | mandatory |
61-
| LED output | GPIO 2 | GPIO 2 | GPIO 2 |
65+
| PINOUT | ESP8266 | ESP32 | ESP32-S2 lolin mini| Pico (rp2040)
66+
|-------------|-----------|-----------|-----------|-----------|
67+
| Clock (SCK) | GPIO 14 | GPIO 18 | GPIO 7 | GPIO 2 |
68+
| Data (MOSI) | GPIO 13 | GPIO 23 | GPIO 11 | GPIO 4 |
69+
| SPI Chip Select(e.g. CE0) | not used | GPIO 5 | GPIO 12 | GPIO 5 |
70+
| GROUND | mandatory | mandatory | mandatory | mandatory |
71+
| LED output | GPIO 2 | GPIO 2 | GPIO 2 | GPIO 14 |
72+
73+
> [!CAUTION]
74+
> The ground connection between both GPIOs is as important as the other SPI data connections. The ground cable should be of a similar length as them and run directly next to them.
6275
6376
# Flashing the firmware
6477

rp2040/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build
2+
vscode

rp2040/CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
set(CMAKE_SYSTEM_NAME Generic)
2+
# User configuration section starts here
3+
4+
# Some boards, such as the first Adafruit revisions, may have trouble booting properly
5+
# due to bad componets used in the design.
6+
# Turn this setting to ON if your rp2040 is not detected after firmware upload and reset
7+
set(BOOT_WORKAROUND ON)
8+
9+
# Default output data pin for the non-SPI LED strips (only for sk6812/ws2812b)
10+
set(OUTPUT_DATA_PIN 14)
11+
12+
# Use multi-segment, starting index of second led strip or OFF to disable
13+
set(SECOND_SEGMENT_INDEX OFF)
14+
15+
# If multi-segment is used and it's reversed, set this option to ON to enable reversing
16+
set(SECOND_SEGMENT_REVERSED OFF)
17+
18+
# HyperSPI communication interface with Raspberry Pi
19+
set(OUTPUT_SPI_DATA_PIN 4)
20+
set(OUTPUT_SPI_CLOCK_PIN 2)
21+
set(OUTPUT_SPI_CHIP_SELECT 5)
22+
set(OUTPUT_SPI_INTERFACE spi0)
23+
24+
# User configuration section ends here
25+
# Usually you don't need to change anything below this section
26+
cmake_minimum_required(VERSION 3.13)
27+
28+
set(PICO_SDK_PATH ${CMAKE_CURRENT_SOURCE_DIR}/HyperSerialPico/sdk/pico)
29+
set(FREERTOS_KERNEL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/HyperSerialPico/sdk/freertos)
30+
include(${PICO_SDK_PATH}/external/pico_sdk_import.cmake)
31+
include(${FREERTOS_KERNEL_PATH}/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake)
32+
33+
project(HyperSPI_Pico C CXX ASM)
34+
pico_sdk_init()
35+
36+
set(PICO_PROGRAM_MAIN_ENTRY "../hyperspi.cpp")
37+
set(DISABLE_SPI_LEDS ON)
38+
add_definitions(-DSPI_INTERFACE=${OUTPUT_SPI_INTERFACE}
39+
-DSPI_DATA_PIN=${OUTPUT_SPI_DATA_PIN}
40+
-DSPI_CLOCK_PIN=${OUTPUT_SPI_CLOCK_PIN}
41+
-DSPI_CHIP_SELECT=${OUTPUT_SPI_CHIP_SELECT})
42+
add_subdirectory(HyperSerialPico)

rp2040/HyperSerialPico

Submodule HyperSerialPico added at 5bf4754

0 commit comments

Comments
 (0)