Skip to content

Commit 69e0930

Browse files
committed
It all works!!! I think- need to make sure I copied the code oever right.
1 parent e287791 commit 69e0930

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

libraries/I2S/src/pio_i2s.pio

+6-9
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,15 @@ lastbit: ; Last bit toggles WCLK to mark frame boundary
141141
; to be 32 (as per the TDM specs)
142142
; +----- WCLK
143143
; |+---- BCLK
144-
mov x, y side 0b01 [1]
144+
mov x, y side 0b00 [1]
145145
bitloop:
146-
in pins, 1 side 0b00 ; Sample input on falling edge
147-
out pins, 1 side 0b00 ; Output changes on falling edge
148-
jmp x-- bitloop side 0b01 [1]
146+
out pins, 1 side 0b11 ; Output changes on falling edge
147+
in pins, 1 side 0b11 ; Sample input on falling edge
148+
jmp x-- bitloop side 0b00 [1]
149149

150150
lastbit: ; Last bit toggles WCLK to mark frame boundary
151-
in pins, 1 side 0b10
152-
out pins, 1 side 0b10
151+
in pins, 1 side 0b01
152+
out pins, 1 side 0b01
153153
; Loop back to the beginning
154154

155155
.program pio_tdm_inout_swap
@@ -529,9 +529,6 @@ static inline void pio_tdm_inout_program_init(PIO pio, uint sm, uint offset, uin
529529
pio_sm_exec(pio, sm, pio_encode_set(pio_y, bits * channels - 2));
530530
}
531531

532-
// Initialize input shift register
533-
pio_sm_exec(pio, sm, pio_encode_in(pio_pins, 32)); // Shift in first TDM frame
534-
535532
// Need to make OSR believe there's nothing left to shift out
536533
pio_sm_exec(pio, sm, pio_encode_out(pio_osr, 32));
537534
}

libraries/I2S/src/pio_i2s.pio.h

+7-9
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,12 @@ static inline pio_sm_config pio_tdm_in_swap_program_get_default_config(uint offs
267267

268268
static const uint16_t pio_tdm_inout_program_instructions[] = {
269269
// .wrap_target
270-
0xa922, // 0: mov x, y side 1 [1]
271-
0x4001, // 1: in pins, 1 side 0
272-
0x6001, // 2: out pins, 1 side 0
273-
0x0941, // 3: jmp x--, 1 side 1 [1]
274-
0x5001, // 4: in pins, 1 side 2
275-
0x7001, // 5: out pins, 1 side 2
270+
0xa122, // 0: mov x, y side 0 [1]
271+
0x7801, // 1: out pins, 1 side 3
272+
0x5801, // 2: in pins, 1 side 3
273+
0x0141, // 3: jmp x--, 1 side 0 [1]
274+
0x4801, // 4: in pins, 1 side 1
275+
0x6801, // 5: out pins, 1 side 1
276276
// .wrap
277277
};
278278

@@ -737,10 +737,8 @@ static inline void pio_tdm_inout_program_init(PIO pio, uint sm, uint offset, uin
737737
pio_sm_exec(pio, sm, pio_encode_pull(false, false));
738738
pio_sm_exec(pio, sm, pio_encode_mov(pio_y, pio_osr));
739739
} else {
740-
pio_sm_exec(pio, sm, pio_encode_set(pio_y, bits * channels - 1));
740+
pio_sm_exec(pio, sm, pio_encode_set(pio_y, bits * channels - 2));
741741
}
742-
// Initialize input shift register
743-
pio_sm_exec(pio, sm, pio_encode_in(pio_pins, 32)); // Shift in first TDM frame
744742
// Need to make OSR believe there's nothing left to shift out
745743
pio_sm_exec(pio, sm, pio_encode_out(pio_osr, 32));
746744
}

0 commit comments

Comments
 (0)