diff --git a/ports/psoc6/modules/machine/machine_i2s.c b/ports/psoc6/modules/machine/machine_i2s.c index 2cb0dd18079f5..f8fc802567801 100644 --- a/ports/psoc6/modules/machine/machine_i2s.c +++ b/ports/psoc6/modules/machine/machine_i2s.c @@ -172,12 +172,12 @@ STATIC void machine_i2s_init_helper(machine_i2s_obj_t *self, size_t n_pos_args, if (result != CY_RSLT_SUCCESS) { mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("I2S tx initialisation failed with return code %lx !"), result); } - } else { // Rx is master + } else { // Rx is slave cyhal_i2s_pins_t rx_pins = { .sck = self->sck, .ws = self->ws, .data = self->sd, .mclk = NC }; cyhal_i2s_config_t rx_config = { .is_tx_slave = false, - .is_rx_slave = false, + .is_rx_slave = true, .mclk_hz = 0, .channel_length = 32, .word_length = self->bits, diff --git a/tests/psoc6/dut/i2s.py b/tests/psoc6/dut/i2s.py new file mode 100644 index 0000000000000..0517b08c008d1 --- /dev/null +++ b/tests/psoc6/dut/i2s.py @@ -0,0 +1,47 @@ +#### SoftI2C +import os +from machine import I2S +import time +import array + +# Allocate pin based on board +machine = os.uname().machine +if "CY8CPROTO-062-4343W" in machine: + sck_tx_pin = "P13_1" + ws_tx_pin = "P13_2" + sd_tx_pin = "P13_3" + sck_rx_pin = "P5_4" + ws_rx_pin = "P5_5" + sd_rx_pin = "P5_6" + +audio_out = I2S( + 0, + sck=sck_tx_pin, + ws=ws_tx_pin, + sd=sd_tx_pin, + mode=I2S.TX, + bits=16, + format=I2S.STEREO, + rate=8000, + ibuf=20000, +) +audio_in = I2S( + 1, + sck=sck_rx_pin, + ws=ws_rx_pin, + sd=sd_rx_pin, + mode=I2S.RX, + bits=16, + format=I2S.STEREO, + rate=8000, + ibuf=20000, +) +buf = bytearray(10) +buf = b"\x01\x00\x17\x15\x16\x44" +print("tx Buffer") +print(buf) +num_written = audio_out.write(buf) +buf1 = bytearray(10) +num_read = audio_in.readinto(buf1) +print("Rx Buffer") +print(buf1) diff --git a/tests/psoc6/dut/i2s.py.exp b/tests/psoc6/dut/i2s.py.exp new file mode 100644 index 0000000000000..53f057b52ccf3 --- /dev/null +++ b/tests/psoc6/dut/i2s.py.exp @@ -0,0 +1,4 @@ +tx Buffer +b'\x01\x00\x17\x15\x16D' +Rx Buffer +bytearray(b'\x00\x00\x00\x00\x01\x00\x17\x15\x16D')