Skip to content

Commit

Permalink
test/psoc6: I2S Test.
Browse files Browse the repository at this point in the history
Signed-off-by: IFX-Anusha <Anusha.TR@infineon.com>

ports/psoc6: Fix formatting.

Signed-off-by: IFX-Anusha <Anusha.TR@infineon.com>

ports/psoc6: Fix formatting.

Signed-off-by: IFX-Anusha <Anusha.TR@infineon.com>

 tests/psoc6: format fix.

Signed-off-by: IFX-Anusha <Anusha.TR@infineon.com>
  • Loading branch information
IFX-Anusha committed Nov 21, 2023
1 parent 917fab4 commit 85e971b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ports/psoc6/modules/machine/machine_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
47 changes: 47 additions & 0 deletions tests/psoc6/dut/i2s.py
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 4 additions & 0 deletions tests/psoc6/dut/i2s.py.exp
Original file line number Diff line number Diff line change
@@ -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')

0 comments on commit 85e971b

Please sign in to comment.