Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/dmdreader.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: dmdreader
on:
push:
pull_request:

defaults:
run:
shell: bash

jobs:
version:
name: Detect version
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: version
run: |
TAG=`cat version.txt`
echo "${TAG}"
echo "tag=${TAG}" >> $GITHUB_OUTPUT
- name: Check git tag
if: startsWith(github.ref, 'refs/tags/v')
run: |
GIT_TAG="${GITHUB_REF#refs/tags/}"
EXPECTED_TAG="v${{ steps.version.outputs.tag }}"
if [[ "${GIT_TAG}" != "${EXPECTED_TAG}" ]]; then
echo "Error: Git tag (${GIT_TAG}) does not match version from version.txt (v${{ steps.version.outputs.tag }})"
exit 1
fi

build:
name: Build dmdreader
runs-on: ${{ matrix.os }}
needs: [ version ]
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
platform: linux
arch: x64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Checkout pico-sdk
uses: actions/checkout@v4
with:
repository: raspberrypi/pico-sdk
path: pico-sdk
ref: 2.1.1
fetch-depth: 1
- if: (matrix.platform == 'linux' && matrix.arch == 'x64')
run: sudo apt install gdb-multiarch cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib cmake
- if: (!(matrix.platform == 'linux' && matrix.arch == 'aarch64'))
run: scripts/compile.sh
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dmdreader-${{ needs.version.outputs.tag }}
path: |
dmdreader.elf
dmdreader.uf2
version.txt

post-build:
runs-on: ubuntu-latest
needs: [ version, build ]
name: Release
steps:
- uses: actions/download-artifact@v4
- name: Package
if: startsWith(github.ref, 'refs/tags/v')
run: zip dmdreader-${{ needs.version.outputs.tag }}

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
draft: true
files: |
dmdreader-${{ needs.version.outputs.tag }}.zip
39 changes: 22 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
src/build
src/CMakeCache.txt
src/CopyOfCMakeCache.txt
src/Makefile
src/cmake_install.cmake
src/elf2uf2/
src/generated/
src/pico-sdk/
src/pioasm/
src/CMakeFiles
src/*.pio.h
src/*.bin
src/*.dis
src/*.elf
src/*.elf.map
src/*.uf2
src/*.hex
build
CMakeCache.txt
CopyOfCMakeCache.txt
CMakeDoxyfile.in
CMakeDoxygenDefaults.cmake
_deps/
picotool/
pico_flash_region.ld
Makefile
cmake_install.cmake
elf2uf2/
generated/
pico-sdk/
pioasm/
CMakeFiles
*.pio.h
*.bin
*.dis
*.elf
*.elf.map
*.uf2
*.hex
**/core
*.pyc
**/out/**
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 19 additions & 12 deletions src/CMakeLists.txt → CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ cmake_minimum_required(VERSION 3.13)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

file(READ version.txt VERSION_STRING)
string(STRIP "${VERSION_STRING}" VERSION_STRING)

# Initialise pico_sdk from installed location
# (note this can come from environment, CMake cache etc)
set(PICO_SDK_PATH "/home/$ENV{USER}/pico-sdk")
set(PICO_SDK_PATH "pico-sdk")

# Pull in Raspberry Pi Pico SDK (must be before project)
include(pico_sdk_import.cmake)
Expand All @@ -16,19 +19,23 @@ include(${PICO_SDK_PATH}/tools/CMakeLists.txt)
project(dmdreader C CXX ASM)

# Initialise the Raspberry Pi Pico SDK
pico_sdk_init()
pico_sdk_init()

# Add executable. Default name is the project name, version 0.2.0
add_executable(${PROJECT_NAME}
src/dmdreader.c
src/crc32.c
)

# Add executable. Default name is the project name, version 0.1
add_executable(${PROJECT_NAME} dmdreader.c crc32.c)
pico_set_program_name(${PROJECT_NAME} "dmdreader")
pico_set_program_version(${PROJECT_NAME} "0.1")

pico_generate_pio_header(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/spi_slave_sender.pio)
pico_generate_pio_header(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/dmd_counter.pio)
pico_generate_pio_header(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/dmd_interface_wpc.pio)
pico_generate_pio_header(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/dmd_interface_whitestar.pio)
pico_generate_pio_header(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/dmd_interface_spike.pio)
pico_generate_pio_header(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/dmd_interface_sam.pio)
pico_set_program_version(${PROJECT_NAME} "${VERSION_STRING}")

pico_generate_pio_header(${PROJECT_NAME} src/spi_slave_sender.pio)
pico_generate_pio_header(${PROJECT_NAME} src/dmd_counter.pio)
pico_generate_pio_header(${PROJECT_NAME} src/dmd_interface_wpc.pio)
pico_generate_pio_header(${PROJECT_NAME} src/dmd_interface_whitestar.pio)
pico_generate_pio_header(${PROJECT_NAME} src/dmd_interface_spike.pio)
pico_generate_pio_header(${PROJECT_NAME} src/dmd_interface_sam.pio)

# Add the standard library to the build
target_link_libraries(${PROJECT_NAME} pico_stdlib)
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions scripts/install-software
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/sh

# Installs additional software for development
sudo apt-get -y install gdb-multiarch cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib openocd cmake
sudo apt -y install gdb-multiarch cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib openocd cmake

cd
git clone https://github.com/raspberrypi/pico-sdk

File renamed without changes.
File renamed without changes.
118 changes: 47 additions & 71 deletions src/dmd_interface_wpc.pio
Original file line number Diff line number Diff line change
@@ -1,82 +1,61 @@
.define PUBLIC dmd_reader_interrupt 0
.define de 0
.define rdata 1
.define rclk 2
.define collat 3
.define dotclk 4
.define sdata 5
.define DE 0
.define RDATA 1
.define RCLK 2
.define COLLAT 3
.define DOTCLK 4
.define SDATA 5
.define PLANE_START 4


.program dmd_reader_wpc

; Send using an external clock on the SPI interface
; - IN pin 0 is the DATA pin

; initialize y with 12288 = number of pixels (128x32) * number of planes
set x, 3
in x, 2
in null, 12
mov y, isr
set x, 31 ; load 31, 5 bits is max allowed (0b11111)
in x, 5 ; shift in 5 bits, isr is 31 now
set x, 31 ; load 31, 5 bits is max allowed (0b11111)
in x, 5 ; shift in 5 bits, isr is 1023 now
set x, 3 ; load 3
in x, 2 ; shift in 2 bits, isr is 4095 now (128x32 - 1)
mov y, isr ; copy 4095 to y

.wrap_target

mov x, y ; load number of pixels
mov isr, null ; reset shift counter

irq clear 4
wait irq 4

dotloop:
wait 0 gpio 4 ; falling edge
in null 1 ; add a 0 to the output as WPC is 2bit/px
wait 1 gpio 4 ; raising edge
in pins 1 ; read pin data

jmp x-- dotloop

mov x, y ; load number of pixels per plane (128x32 - 1)
mov isr, null ; reset shift counter

irq clear PLANE_START
wait irq PLANE_START

plane_loop:
wait 0 gpio DOTCLK ; no DOTCLK period or faling edge of the previous
in null 1 ; add a 0 to the output as WPC is 2bit/px
wait 1 gpio DOTCLK ; raising edge
in pins 1 ; read 1 bit pin data
jmp x-- plane_loop
.wrap

.program dmd_framedetect_wpc

.program dmd_framedetect_wpc
.wrap_target
; synchronize on the first line
wait 0 gpio rdata
wait 1 gpio rdata
set x, 31

lineloop:
wait 1 gpio rclk
wait 0 gpio rclk
jmp x-- lineloop

; delay by 1 pixel
wait 0 gpio 4
wait 1 gpio 4

irq 4

wait 0 gpio RDATA
wait 1 gpio RDATA
wait 1 gpio DE
wait 0 gpio DOTCLK
nop [31]
irq PLANE_START
.wrap


% c-sdk {
static inline void dmd_reader_wpc_program_init(PIO pio, uint sm, uint offset) {

uint8_t datapin = 5;
pio_sm_config c = dmd_reader_wpc_program_get_default_config(offset);

// Set the IN base pin to the provided `pin` parameter. This is the data pin, we don't use any other
sm_config_set_in_pins(&c, datapin);

// Set the pin direction at the PIO
pio_sm_set_consecutive_pindirs(pio, sm, 0, 6, false);
// Set the IN pin, we don't use any other
sm_config_set_in_pins(&c, 5); // SDATA

// Connect these GPIOs to this PIO block
pio_gpio_init(pio, 0);
pio_gpio_init(pio, 1);
pio_gpio_init(pio, 2);
pio_gpio_init(pio, 3);
pio_gpio_init(pio, 4);
pio_gpio_init(pio, 5);
pio_gpio_init(pio, 4); // DOTCLK
pio_gpio_init(pio, 5); // SDATA

// Set the pin direction at the PIO
pio_sm_set_consecutive_pindirs(pio, sm, 4, 2, false); // DOTCLK, SDATA

// Shifting to left matches the customary MSB-first ordering of SPI.
sm_config_set_in_shift(
Expand All @@ -96,19 +75,16 @@ static inline void dmd_reader_wpc_program_init(PIO pio, uint sm, uint offset) {

% c-sdk {
static inline void dmd_framedetect_wpc_program_init(PIO pio, uint sm, uint offset) {

pio_sm_config c = dmd_framedetect_wpc_program_get_default_config(offset);

// Set the pin direction at the PIO
pio_sm_set_consecutive_pindirs(pio, sm, 0, 6, false);

// Connect these GPIOs to this PIO block
pio_gpio_init(pio, 0);
pio_gpio_init(pio, 1);
pio_gpio_init(pio, 2);
pio_gpio_init(pio, 3);
pio_gpio_init(pio, 4);
pio_gpio_init(pio, 5);
pio_gpio_init(pio, 0); // DE
pio_gpio_init(pio, 1); // RDATA
pio_gpio_init(pio, 4); // DOTCLK

// Set the pin direction at the PIO
pio_sm_set_consecutive_pindirs(pio, sm, 0, 2, false); // DE, RDATA
pio_sm_set_consecutive_pindirs(pio, sm, 4, 1, false); // DOTCLK

// Load our configuration, do not yet start the program
pio_sm_init(pio, sm, offset, &c);
Expand Down
Loading