From 21b0b3e515f2f6a7f884ae25d0b7368602003eaa Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 26 Jan 2025 11:01:20 -0600 Subject: [PATCH] sdk 1.5 compat --- src/sdk_compat.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/sdk_compat.h b/src/sdk_compat.h index 935dce2..6459501 100644 --- a/src/sdk_compat.h +++ b/src/sdk_compat.h @@ -6,6 +6,16 @@ static __always_inline void pio_sm_set_jmp_pin(PIO pio, uint sm, uint jmp_pin) { (pio->sm[sm].execctrl & ~PIO_SM0_EXECCTRL_JMP_PIN_BITS) | (jmp_pin << PIO_SM0_EXECCTRL_JMP_PIN_LSB); } + +static_assert(PIO1_BASE - PIO0_BASE == (1u << 20), "hardware layout mismatch"); +#define PIO_INSTANCE(instance) ((pio_hw_t *)(PIO0_BASE + (instance) * (1u << 20))) +static __always_inline PIO pio_get_instance(uint instance) { + return PIO_INSTANCE(instance); +} + +#define NUM_PIO_IRQS (2u) +#define PIO_IRQ_NUM(pio, irqn) (PIO0_IRQ_0 + NUM_PIO_IRQS * PIO_NUM(pio) + (irqn)) + #endif #if PICO_SDK_VERSION_MAJOR < 2 || (PICO_SDK_VERSION_MAJOR == 2 && PICO_SDK_VERSION_MINOR < 1)