From 59a98027cb96f303405175192a5533bbfdc26952 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Mon, 20 Jan 2025 10:04:22 -0800 Subject: [PATCH] Update NeoRp2040PioMonoProgram.h (#873) --- src/internal/methods/Rp2040/NeoRp2040PioMonoProgram.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/internal/methods/Rp2040/NeoRp2040PioMonoProgram.h b/src/internal/methods/Rp2040/NeoRp2040PioMonoProgram.h index 0abe3b6..6ac3fc0 100644 --- a/src/internal/methods/Rp2040/NeoRp2040PioMonoProgram.h +++ b/src/internal/methods/Rp2040/NeoRp2040PioMonoProgram.h @@ -164,12 +164,13 @@ class NeoRp2040PioMonoProgram public: static inline uint add(PIO pio_instance) { - if (s_loadedOffset == c_ProgramNotLoaded) + size_t index = (pio_instance == pio0) ? 0 : 1; + if (s_loadedOffset[index] == c_ProgramNotLoaded) { assert(pio_can_add_program(pio_instance, &T_CADENCE::program)); - s_loadedOffset = pio_add_program(pio_instance, &T_CADENCE::program); + s_loadedOffset[index] = pio_add_program(pio_instance, &T_CADENCE::program); } - return s_loadedOffset; + return s_loadedOffset[index]; } static inline void init(PIO pio_instance, @@ -202,10 +203,10 @@ public: } private: - static uint s_loadedOffset; // singlet instance of loaded program + static uint s_loadedOffset[2]; // singlet instance of loaded program, one for each PIO hardware unit }; template -uint NeoRp2040PioMonoProgram::s_loadedOffset = c_ProgramNotLoaded; +uint NeoRp2040PioMonoProgram::s_loadedOffset[] = {c_ProgramNotLoaded, c_ProgramNotLoaded}; #endif