From 0df118792a96639da51a9857cbb8cd485bb57991 Mon Sep 17 00:00:00 2001 From: Jan Vos Date: Mon, 5 Oct 2026 09:07:29 +0200 Subject: [PATCH 1/3] Allow a different SPI base to be assigned --- src/dmdreader.cpp | 20 ++++++++++---------- src/dmdreader_pins.h | 15 ++++++++------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/dmdreader.cpp b/src/dmdreader.cpp index d65fe7f4..eb2a1905 100644 --- a/src/dmdreader.cpp +++ b/src/dmdreader.cpp @@ -222,20 +222,20 @@ void spi_abort() { } /** - * @brief Notify on pin SPI0_CS that data are ready on SPI + * @brief Notify on pin SPI_CS that data is ready * * The SPI master (the Pico is slave) should start a data transfer when this - * signal is received It toggles pin SPI0_CS to H + * signal is received It toggles pin SPI_CS to H * */ -void start_spi() { digitalWrite(SPI0_CS, HIGH); } +void start_spi() { digitalWrite(DMDREADER_SPI_CS, HIGH); } /** - * @brief Set pin SPI0_CS to L to signal that there is no active SPI data + * @brief Set pin _CS to L to signal that there is no active SPI data * transfer * */ -void finish_spi() { digitalWrite(SPI0_CS, LOW); } +void finish_spi() { digitalWrite(DMDREADER_SPI_CS, LOW); } /** * @brief Cleanly exit SPI by stopping the DMD pio and sending a blank dummy @@ -1555,8 +1555,8 @@ bool dmdreader_init(bool return_on_no_detection) { void dmdreader_spi_init() { // this is used to notify the Pi that data is available - pinMode(SPI0_CS, OUTPUT); - digitalWrite(SPI0_CS, LOW); + pinMode(DMDREADER_SPI_CS, OUTPUT); + digitalWrite(DMDREADER_SPI_CS, LOW); // Set up SPI header h.len = (((target_bytes + 3) / 4) * 4) + sizeof(h) + sizeof(ph); @@ -1567,9 +1567,9 @@ void dmdreader_spi_init() { // initialize SPI slave PIO dmdreader_error_blink(pio_claim_free_sm_and_add_program_for_gpio_range( - &clocked_output_program, &spi_pio, &spi_sm, &spi_offset, SPI_BASE, 4, - true)); - clocked_output_program_init(spi_pio, spi_sm, spi_offset, SPI_BASE); + &clocked_output_program, &spi_pio, &spi_sm, &spi_offset, + DMDREADER_SPI_BASE, 4, true)); + clocked_output_program_init(spi_pio, spi_sm, spi_offset, DMDREADER_SPI_BASE); // DMA for SPI spi_dma_channel = dma_claim_unused_channel(true); diff --git a/src/dmdreader_pins.h b/src/dmdreader_pins.h index e3daf169..a9c473d6 100644 --- a/src/dmdreader_pins.h +++ b/src/dmdreader_pins.h @@ -27,11 +27,12 @@ #endif // SPI Defines -#define SPI0 spi0 -#define SPI_BASE 16 -#define SPI0_MISO SPI_BASE // 16 -#define SPI0_CS (SPI_BASE + 1) // 17 -#define SPI0_SCK (SPI_BASE + 2) // 18 -#define SPI0_MOSI (SPI_BASE + 3) // 19 +#ifndef DMDREADER_SPI_BASE +#define DMDREADER_SPI_BASE 16 // 16 is the default for backwards compatibility +#endif +#define DMDREADER_SPI_MISO SPI_BASE +#define DMDREADER_SPI_CS 17 // Is locked to 17 for all PPUC/DMD revisions +#define DMDREADER_SPI_SCK (DMDREADER_SPI_BASE + 2) +#define DMDREADER_SPI_MOSI (DMDREADER_SPI_BASE + 3) -#endif // DMD_READER_PINS_H +#endif // DMD_READER_PINS_H \ No newline at end of file From 27e238e2da4b0176e8257173c02b9c5a616af4f6 Mon Sep 17 00:00:00 2001 From: Jan Vos Date: Mon, 5 Oct 2026 09:47:45 +0200 Subject: [PATCH 2/3] try 12 real quick --- src/dmdreader_pins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dmdreader_pins.h b/src/dmdreader_pins.h index a9c473d6..1cecdd15 100644 --- a/src/dmdreader_pins.h +++ b/src/dmdreader_pins.h @@ -28,7 +28,7 @@ // SPI Defines #ifndef DMDREADER_SPI_BASE -#define DMDREADER_SPI_BASE 16 // 16 is the default for backwards compatibility +#define DMDREADER_SPI_BASE 12 // 16 is the default for backwards compatibility #endif #define DMDREADER_SPI_MISO SPI_BASE #define DMDREADER_SPI_CS 17 // Is locked to 17 for all PPUC/DMD revisions From 0d75f9d4a87aa1e28949001f239c744c1557eed4 Mon Sep 17 00:00:00 2001 From: Jan Vos Date: Mon, 5 Oct 2026 09:55:52 +0200 Subject: [PATCH 3/3] working, set back to 16. --- src/dmdreader_pins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dmdreader_pins.h b/src/dmdreader_pins.h index 1cecdd15..a9c473d6 100644 --- a/src/dmdreader_pins.h +++ b/src/dmdreader_pins.h @@ -28,7 +28,7 @@ // SPI Defines #ifndef DMDREADER_SPI_BASE -#define DMDREADER_SPI_BASE 12 // 16 is the default for backwards compatibility +#define DMDREADER_SPI_BASE 16 // 16 is the default for backwards compatibility #endif #define DMDREADER_SPI_MISO SPI_BASE #define DMDREADER_SPI_CS 17 // Is locked to 17 for all PPUC/DMD revisions