Skip to content

Commit

Permalink
Swap PDM CLK and DAT pin defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepmistry committed May 19, 2021
1 parent 00b9ba7 commit 50897fe
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
8 changes: 4 additions & 4 deletions examples/hello_pdm_microphone/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions examples/usb_microphone/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/include/pico/pdm_microphone.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/pdm_microphone.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/pdm_microphone.pio
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 50897fe

Please sign in to comment.