Skip to content

Commit

Permalink
Adafruit RP2040 Scorpio support (ItsyBitsy uses default build)
Browse files Browse the repository at this point in the history
No support for rp2040 Pimoroni level shifter boards because of missing GPIO SPI pins.
  • Loading branch information
awawa-dev committed Dec 6, 2023
1 parent 641ffe1 commit f906e08
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 74 deletions.
85 changes: 25 additions & 60 deletions .github/workflows/push-master-pico.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,66 +46,31 @@ jobs:
path: |
rp2040/HyperSerialPico/firmware/*.uf2
# - name: Build packages for Adafruit Feather RP2040 Scorpio (release-only)
# if: startsWith(github.ref, 'refs/tags/')
# shell: bash
# run: |
# cd build
# rm *.*
# rm ../HyperSerialPico/firmware/*
# echo "Neopixel is using GPIO16(OUTPUT_DATA_PIN) on output 0." > ../firmware/Firmwares_for_Adafruit_Feather_RP2040_Scorpio.txt
# cmake -DOVERRIDE_BOOT_WORKAROUND=ON -DOVERRIDE_DATA_PIN=16 -DCMAKE_BUILD_TYPE=Release ..
# cmake --build .
# zip -j ../HyperSerialPico/firmware/Adafruit_Feather_RP2040_Scorpio.zip ../firmware/*

# - uses: actions/upload-artifact@v3
# name: Upload artifacts (release Adafruit_Feather)
# if: startsWith(github.ref, 'refs/tags/')
# with:
# name: firmware-release
# path: |
# rp2040/HyperSerialPico/firmware/*.zip

# - name: Build packages for Adafruit ItsyBitsy RP2040 (release-only)
# if: startsWith(github.ref, 'refs/tags/')
# shell: bash
# run: |
# cd build
# rm *.*
# rm ../HyperSerialPico/firmware/*
# echo "Neopixel is using GPIO14(OUTPUT_DATA_PIN) on output 5." > ../firmware/Firmwares_for_Adafruit_ItsyBitsy_2040.txt
# cmake -DOVERRIDE_BOOT_WORKAROUND=ON -DOVERRIDE_DATA_PIN=14 -DCMAKE_BUILD_TYPE=Release ..
# cmake --build .
# rm ../firmware/*_Spi.uf2
# zip -j ../HyperSerialPico/firmware/Adafruit_ItsyBitsy_2040.zip ../firmware/*

# - uses: actions/upload-artifact@v3
# name: Upload artifacts (release Adafruit_ItsyBitsy)
# if: startsWith(github.ref, 'refs/tags/')
# with:
# name: firmware-release
# path: |
# rp2040/HyperSerialPico/firmware/*.zip

# - name: Build packages for Pimoroni Plasma 2040 (release-only)
# if: startsWith(github.ref, 'refs/tags/')
# shell: bash
# run: |
# cd build
# rm *.*
# rm ../HyperSerialPico/firmware/*
# echo "Neopixel is using GPIO15(OUTPUT_DATA_PIN) on output DA." > ../firmware/Firmwares_for_Pimoroni_Plasma_2040.txt
# cmake -DOVERRIDE_DATA_PIN=15 -DCMAKE_BUILD_TYPE=Release ..
# cmake --build .
# zip -j ../HyperSerialPico/firmware/Pimoroni_Plasma_2040.zip ../firmware/*

# - uses: actions/upload-artifact@v3
# name: Upload artifacts (release Pimoroni_Plasma)
# if: startsWith(github.ref, 'refs/tags/')
# with:
# name: firmware-release
# path: |
# rp2040/HyperSerialPico/firmware/*.zip
- name: Build packages for Adafruit Feather RP2040 Scorpio
shell: bash
run: |
cd build
rm *.*
rm ../HyperSerialPico/firmware/*
echo "Neopixel is using GPIO16(OUTPUT_DATA_PIN) on output 0." > ../HyperSerialPico/firmware/Firmwares_for_Adafruit_Feather_RP2040_Scorpio.txt
cmake -DOVERRIDE_DATA_PIN=16 -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
zip -j ../HyperSerialPico/firmware/Adafruit_Feather_RP2040_Scorpio.zip ../HyperSerialPico/firmware/*
- uses: actions/upload-artifact@v3
name: Upload artifacts (Adafruit_Feather)
if: (startsWith(github.event.ref, 'refs/tags') != true)
with:
path: |
rp2040/HyperSerialPico/firmware/*.zip
- uses: actions/upload-artifact@v3
name: Upload artifacts (release for Adafruit_Feather)
if: startsWith(github.ref, 'refs/tags/')
with:
name: firmware-release
path: |
rp2040/HyperSerialPico/firmware/*.zip
################################
###### Publish Releases ########
Expand Down
4 changes: 2 additions & 2 deletions rp2040/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(CMAKE_SYSTEM_NAME Generic)
# Some boards, such as the first Adafruit revisions, may have trouble booting properly
# due to bad componets used in the design.
# Turn this setting to ON if your rp2040 is not detected after firmware upload and reset
set(BOOT_WORKAROUND OFF)
set(BOOT_WORKAROUND ON)

# Default output data pin for the non-SPI LED strips (only for sk6812/ws2812b)
set(OUTPUT_DATA_PIN 14)
Expand All @@ -30,7 +30,7 @@ set(FREERTOS_KERNEL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/HyperSerialPico/sdk/freerto
include(${PICO_SDK_PATH}/external/pico_sdk_import.cmake)
include(${FREERTOS_KERNEL_PATH}/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake)

project(HyperSPI C CXX ASM)
project(HyperSPI_Pico C CXX ASM)
pico_sdk_init()

set(PICO_PROGRAM_MAIN_ENTRY "../hyperspi.cpp")
Expand Down
16 changes: 4 additions & 12 deletions rp2040/hyperspi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ static uint initSpi(uint baudrate, spi_inst_t* _spi, uint32_t spiMosipin, uint32

static void core0( void *pvParameters )
{
bool regroupNeeded = false;
uint dmaChannelNumber = initSpi(SPI_SPEED, SPI_INTERFACE, SPI_DATA_PIN, SPI_CLOCK_PIN, SPI_CHIP_SELECT);

while(true)
Expand All @@ -166,20 +165,13 @@ static void core0( void *pvParameters )

if (frameState.getRegroup())
{
if (regroupNeeded)
{
dma_channel_unclaim(dmaChannelNumber);
spi_deinit(SPI_INTERFACE);
dmaChannelNumber = initSpi(SPI_SPEED, SPI_INTERFACE, SPI_DATA_PIN, SPI_CLOCK_PIN, SPI_CHIP_SELECT);
}
regroupNeeded = false;
dma_channel_unclaim(dmaChannelNumber);
spi_deinit(SPI_INTERFACE);
dmaChannelNumber = initSpi(SPI_SPEED, SPI_INTERFACE, SPI_DATA_PIN, SPI_CLOCK_PIN, SPI_CHIP_SELECT);
frameState.setRegroup(false);
}
else
regroupNeeded = true;


//printf("%i %i %i %i %i %i %i %i\n",spiBuffer[0],spiBuffer[1],spiBuffer[2],spiBuffer[3],spiBuffer[4],spiBuffer[5],spiBuffer[6],spiBuffer[7],spiBuffer[8]);
//printf("%i %i %i %i %i %i %i %i %i %i %i\n",spiBuffer[0],spiBuffer[1],spiBuffer[2],spiBuffer[3],spiBuffer[4],spiBuffer[5],spiBuffer[6],spiBuffer[7],spiBuffer[8],spiBuffer[9],spiBuffer[10]);
int remains = SPI_FRAME_SIZE;
int wanted, received;
do
Expand Down

0 comments on commit f906e08

Please sign in to comment.