Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main i2s merge #105

Merged
merged 10 commits into from
Nov 21, 2023
4 changes: 3 additions & 1 deletion docs/psoc6/feature_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ Table :ref:`configuration details <table_mpy_configuration>` below lists specifi
+-----------------+----------------------------------------------------------------------------------------------------------------------+
| machine.Timer | mode = Timer.PERIODIC is not supported |
+-----------------+----------------------------------------------------------------------------------------------------------------------+
| machine.SPI | Option ``MICROPY_PY_MACHINE_SPI``, ``MICROPY_PY_MACHINE_SPI_MSB`` , ``MICROPY_PY_MACHINE_SPI_MSB`` enabled. |
| machine.SPI | Option ``MICROPY_PY_MACHINE_SPI``, ``MICROPY_PY_MACHINE_SPI_MSB`` , ``MICROPY_PY_MACHINE_SPI_MSB`` enabled. |
+-----------------+----------------------------------------------------------------------------------------------------------------------+
| machine.I2S | Non Blocking Mode & asyncio mode is not supported |
+-----------------+----------------------------------------------------------------------------------------------------------------------+
| psoc6 | Option to enable the external instead of the internal flash: ``MICROPY_ENABLE_EXT_QSPI_FLASH``. |
| | |
Expand Down
36 changes: 36 additions & 0 deletions docs/psoc6/quickref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -530,3 +530,39 @@ To use the APIs:
adc = adcBlock.connect(0, "P10_0") # connect channel 0 to pin P10_0
val = adc.read_uv() # read an analog value in micro volts

I2S bus
-------

See :ref:`machine.I2S <machine.I2S>`.

PSoC6 implements additional method which is explained below.

Methods
^^^^^^^
.. method:: I2S.stop()

This method is to stop either the transmission or reception. This function should be called by user once the readinto or
write is done.

::

from machine import I2S, Pin
import array
buf=bytearray(10) #Initilase buffer with required values for transmission & as empty buffer for reception

audio_out = I2S(0, sck="P13_1", ws="P13_2", sd="P13_3", mode=I2S.TX, bits=16, format=I2S.STEREO, rate=22050, ibuf=20000) #create I2S object
num_written = audio_out.write(buf) # write buffer of audio samples to I2S device


audio_in = I2S(1, sck="P5_4", ws="P5_5", sd="P5_6", mode=I2S.RX, bits=16, format=I2S.STEREO, rate=22050, ibuf=20000) # create I2S object
num_read = audio_in.readinto(buf)# fill buffer with audio samples from I2S device
audio_out.stop() # stop transmission
audio_in.stop() # stop reception

PSoc6 supports two I2S Bus. So id could be either 0 or 1. Please note that if both instances are running together then the sample rate should
be either 8/16/32/48 or 22.05/44.01. Both the set of frequencies can't work together(For eg eg. 8 & 22.01 will cause error)
Supported sample rates are 8KHz, 16KHz, 32KHz, 48KHz, 22.05KHz, 44.1KHz.
PSoC6 supports only STEREO Mode.

.. note:: I2S Blocking mode is only supported

1 change: 1 addition & 0 deletions ports/psoc6/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ MOD_SRC_C += $(addprefix modules/,\
machine/machine_timer.c \
machine/machine_adc.c \
machine/machine_adcblock.c \
machine/machine_i2s.c\
\
psoc6/modpsoc6.c \
psoc6/psoc6_fatfs.c \
Expand Down
Loading
Loading