diff --git a/README.md b/README.md index 5a4a2de..1faa28e 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ Capture audio from a microphone on your Raspberry Pi Pico or any RP2040 based bo | 3.3V | VCC | | GND | GND | | GND | SEL | -| GPIO 2 | CLK | -| GPIO 3 | DAT | +| GPIO 2 | DAT | +| GPIO 3 | CLK | GPIO pins are configurable in examples or API. diff --git a/examples/hello_pdm_microphone/main.c b/examples/hello_pdm_microphone/main.c index e94ea78..4618049 100644 --- a/examples/hello_pdm_microphone/main.c +++ b/examples/hello_pdm_microphone/main.c @@ -17,11 +17,11 @@ // configuration const struct pdm_microphone_config config = { - // GPIO pin for the PDM CLK signal - .gpio_clk = 2, - // GPIO pin for the PDM DAT signal - .gpio_data = 3, + .gpio_data = 2, + + // GPIO pin for the PDM CLK signal + .gpio_clk = 3, // PIO instance to use .pio = pio0, diff --git a/examples/usb_microphone/main.c b/examples/usb_microphone/main.c index e8d5925..9323110 100644 --- a/examples/usb_microphone/main.c +++ b/examples/usb_microphone/main.c @@ -18,8 +18,8 @@ // configuration const struct pdm_microphone_config config = { - .gpio_clk = 2, - .gpio_data = 3, + .gpio_data = 2, + .gpio_clk = 3, .pio = pio0, .pio_sm = 0, .sample_rate = SAMPLE_RATE, diff --git a/src/include/pico/pdm_microphone.h b/src/include/pico/pdm_microphone.h index f75aba9..150c0c6 100644 --- a/src/include/pico/pdm_microphone.h +++ b/src/include/pico/pdm_microphone.h @@ -13,8 +13,8 @@ typedef void (*pdm_samples_ready_handler_t)(void); struct pdm_microphone_config { - uint gpio_clk; uint gpio_data; + uint gpio_clk; PIO pio; uint pio_sm; uint sample_rate; diff --git a/src/pdm_microphone.c b/src/pdm_microphone.c index a65749b..d5edb96 100644 --- a/src/pdm_microphone.c +++ b/src/pdm_microphone.c @@ -71,8 +71,8 @@ int pdm_microphone_init(const struct pdm_microphone_config* config) { config->pio_sm, pio_sm_offset, clk_div, - config->gpio_clk, - config->gpio_data + config->gpio_data, + config->gpio_clk ); dma_channel_config dma_channel_cfg = dma_channel_get_default_config(pdm_mic.dma_channel); diff --git a/src/pdm_microphone.pio b/src/pdm_microphone.pio index 0103984..2a93df3 100644 --- a/src/pdm_microphone.pio +++ b/src/pdm_microphone.pio @@ -14,7 +14,7 @@ % c-sdk { -static inline void pdm_microphone_data_init(PIO pio, uint sm, uint offset, float clk_div, uint clk_pin, uint data_pin) { +static inline void pdm_microphone_data_init(PIO pio, uint sm, uint offset, float clk_div, uint data_pin, uint clk_pin) { pio_sm_set_consecutive_pindirs(pio, sm, data_pin, 1, false); pio_sm_set_consecutive_pindirs(pio, sm, clk_pin, 1, true);