From 77c3d5e2b669a01a94a9f183c75d69286783d5df Mon Sep 17 00:00:00 2001 From: Arkin Solomon Date: Wed, 2 Apr 2025 11:34:34 -0400 Subject: [PATCH] Allow overriding of default config (#92) --- src/rp2_common/pico_audio_pwm/audio_pwm.c | 12 +++++----- .../pico_audio_pwm/include/pico/audio_pwm.h | 24 +++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/rp2_common/pico_audio_pwm/audio_pwm.c b/src/rp2_common/pico_audio_pwm/audio_pwm.c index 3a58011..d29d756 100644 --- a/src/rp2_common/pico_audio_pwm/audio_pwm.c +++ b/src/rp2_common/pico_audio_pwm/audio_pwm.c @@ -68,8 +68,8 @@ const audio_pwm_channel_config_t default_left_channel_config = { .core = { .base_pin = PICO_AUDIO_PWM_L_PIN, - .pio_sm = 0, - .dma_channel = 0 + .pio_sm = PICO_AUDIO_PWM_L_PIO_SM, + .dma_channel = PICO_AUDIO_PWM_L_DMA_CH }, .pattern = 1, }; @@ -78,8 +78,8 @@ const audio_pwm_channel_config_t default_right_channel_config = { .core = { .base_pin = PICO_AUDIO_PWM_R_PIN, - .pio_sm = 1, - .dma_channel = 1 + .pio_sm = PICO_AUDIO_PWM_R_PIO_SM, + .dma_channel = PICO_AUDIO_PWM_R_DMA_CH, }, .pattern = 1, }; @@ -88,8 +88,8 @@ const audio_pwm_channel_config_t default_mono_channel_config = { .core = { .base_pin = PICO_AUDIO_PWM_MONO_PIN, - .pio_sm = 0, - .dma_channel = 0 + .pio_sm = PICO_AUDIO_PWM_MONO_PIO_SM, + .dma_channel = PICO_AUDIO_PWM_MONO_DMA_CH }, .pattern = 3, }; diff --git a/src/rp2_common/pico_audio_pwm/include/pico/audio_pwm.h b/src/rp2_common/pico_audio_pwm/include/pico/audio_pwm.h index 08d4f2b..decf1ff 100644 --- a/src/rp2_common/pico_audio_pwm/include/pico/audio_pwm.h +++ b/src/rp2_common/pico_audio_pwm/include/pico/audio_pwm.h @@ -84,14 +84,38 @@ extern "C" { #define PICO_AUDIO_PWM_L_PIN 0 #endif +#ifndef PICO_AUDIO_PWM_L_PIO_SM +#define PICO_AUDIO_PWM_L_PIO_SM 0 +#endif + +#ifndef PICO_AUDIO_PWM_L_DMA_CH +#define PICO_AUDIO_PWM_L_DMA_CH 0 +#endif + #ifndef PICO_AUDIO_PWM_R_PIN #define PICO_AUDIO_PWM_R_PIN 1 #endif +#ifndef PICO_AUDIO_PWM_R_PIO_SM +#define PICO_AUDIO_PWM_R_PIO_SM 0 +#endif + +#ifndef PICO_AUDIO_PWM_R_DMA_CH +#define PICO_AUDIO_PWM_R_DMA_CH 1 +#endif + #ifndef PICO_AUDIO_PWM_MONO_PIN #define PICO_AUDIO_PWM_MONO_PIN PICO_AUDIO_PWM_L_PIN #endif +#ifndef PICO_AUDIO_PWM_MONO_PIO_SM +#define PICO_AUDIO_PWM_MONO_PIO_SM PICO_AUDIO_PWM_L_PIO_SM +#endif + +#ifndef PICO_AUDIO_PWM_MONO_DMA_CH +#define PICO_AUDIO_PWM_MONO_DMA_CH PICO_AUDIO_PWM_L_DMA_CH +#endif + #ifndef PIO_AUDIO_PWM_INTERP_SAVE #define PIO_AUDIO_PWM_INTERP_SAVE 1 #endif