Skip to content

Commit

Permalink
tests/psoc6/hw_ext/i2s.py: WIP i2s evaluation.
Browse files Browse the repository at this point in the history
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
  • Loading branch information
jaenrig-ifx committed Mar 25, 2024
1 parent a52aea7 commit ab1249e
Showing 1 changed file with 55 additions and 23 deletions.
78 changes: 55 additions & 23 deletions tests/psoc6/hw_ext/i2s.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@
print("SKIP")
raise SystemExit

sample_num = 3600
max_num = 0x80
sample = bytearray(
[0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF]
)
buf = bytearray([0] * sample_num)
j = 0
for i in range(sample_num):
if i >= (j + 1) * max_num:
j = j + 1
buf[i] = sample[j % len(sample)]


# for i in range(sample_num/max_num - 1):
# print(binascii.hexlify(buf[i*max_num: (i + 1)*max_num]))

audio_out = I2S(
0,
Expand All @@ -38,30 +53,47 @@
mode=I2S.TX,
bits=32,
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=32,
format=I2S.STEREO,
rate=8000,
rate=22050,
ibuf=20000,
)
buf = bytearray([0] * 64)
for i in range(64):
buf[i] = i
# audio_in = I2S(
# 1,
# sck=sck_rx_pin,
# ws=ws_rx_pin,
# sd=sd_rx_pin,
# mode=I2S.RX,
# bits=32,
# format=I2S.STEREO,
# rate=8000,
# ibuf=20000,
# )

tx_done = False


def tx_complete_irq(obj):
global tx_done
tx_done = True
# print("tx completed")


# buf = b"\x01\x00\x17\x15\x16\x44"
print("tx Buffer")
print(buf)
# print("tx Buffer")
# print(buf)
audio_out.irq(tx_complete_irq)
num_written = audio_out.write(buf)
buf1 = bytearray(64)
num_read = audio_in.readinto(buf1)
print("Rx Buffer")
print(buf1)
audio_out.stop()
audio_in.stop()

while not tx_done:
pass

print("tx completed")

# print(num_written)
# buf1 = bytearray(64)
# num_read = audio_in.readinto(buf1)
# print("Rx Buffer")
# print(buf1)
# audio_out.stop()
# audio_in.stop()
# time.sleep(5)
# audio_out.deinit()

0 comments on commit ab1249e

Please sign in to comment.