10000 mimxrt: Add a I2S section to the Quickref. · micropython/micropython@41cb752 · GitHub
[go: up one dir, main page]

Skip to content

Commit 41cb752

Browse files
committed
mimxrt: Add a I2S section to the Quickref.
1 parent df51b6a commit 41cb752

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

docs/mimxrt/quickref.rst

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,86 @@ has the same methods as software SPI above::
364364
i2c = I2C(0, 400_000)
365365
i2c.writeto(0x76, b"Hello World")
366366

367+
I2S bus
368+
-------
369+
370+
See :ref:`machine.I2S <machine.I2S>`. Example using a Teensy 4.1 board with a simple
371+
external Codec like UDA1334.::
372+
373+
from machine import I2S, Pin
374+
i2s = I2S(2, sck=Pin(26), ws=Pin(27), sd=Pin(7),
375+
mode=I2S.TX, bts=16,format=I2S.STEREO,
376+
rate=44100,ibuf=40000)
377+
i2s.write(buf) # write buffer of audio samples to I2S device
378+
379+
380+
Example for using I2S with a MIMXRT10xx_DEV board::
381+
382+
from machine import I2S, I2C, Pin
383+
import wm8960
384+
385+
i2c=I2C(0)
386+
387+
wm=wm8960.WM8960(i2c, sample_rate=SAMPLE_RATE_IN_HZ,
388+
adc_sync=wm8960.sync_dac,
389+
swap=wm8960.swap_input)
390+
391+
i2s = I2S(1, sck=Pin("SCK_TX"), ws=Pin("WS_TX"), sd=Pin("SD_RX"),
392+
mck=Pin("MCK),mode=I2S.RX, bts=16,format=I2S.MONO,
393+
rate=32000,ibuf=10000)
394+
i2s.readinto(buf) # fill buffer with audio samples from I2S device
395+
396+
In this example, the input channels are swapped in the WM8960 driver, since the
397+
on-board microphone is connected to the right channel, but Mono audio is taken
398+
from the left channel. Note, that the sck and ws pins are connected to the TX signals
399+
of the I2S bus. That is intentional, since at the MW8960 codec these signals are
400+
shared for RX and TX.
401+
402+
Example using the Teensy audio shield::
403+
404+
from machine import I2C, I2S, Pin
405+
from sgtl5000 import CODEC
406+
i2s = I2S(1, sck=Pin(21), ws=Pin(20), sd=Pin(7), mck=Pin(23),
407+
mode=I2S.TX, bits=16,rate=44100,format=I2S.STEREO,
408+
ibuf=40000,
409+
)
410+
411+
# configure the SGTL5000 codec
412+
i2c = I2C(0, freq=400000)
413+
codec = CODEC(0x0A, i2c)
414+
codec.mute_dac(False)
415+
codec.dac_volume(0.9, 0.9)
416+
codec.headphone_select(0)
417+
codec.mute_headphone(False)
418+
codec.volume(0.7, 0.7)
419+
420+
i2s.write(buf) # write buffer of audio samples to I2S device
421+
422+
The SGTL5000 codec used by the Teensy Audio shiel uses the RX signals for both RX and TX.
423+
Note that the codec is initialize after the I2S device. That is essential since MCK
424+
is needed for it's I2C operation and is provided by the I2S controller.
425+
426+
MIMXRT boards may have 1 or 2 I2S buses available at the board connectors.
427+
At MIMXRT1010 devices the bus numbers as 1 and 3.
428+
429+
Pin assignments for a few MIMXRT boards:
430+
431+
============== == ===== ======== ======= ======= ======== ======= =======
432+
Board ID MCK SCK_TX WS_TX SD_TX SCK_RX WS_RX SD_RX
433+
============== == ===== ======== ======= ======= ======== ======= =======
434+
Teensy 4.0 1 23 26 27 7 21 20 8
435+
Teensy 4.0 2 33 4 3 2 - - 5
436+
Teensy 4.1 1 23 26 27 7 21 20 8
437+
Teensy 4.1 2 33 4 3 2 - - 5
438+
Seeed Arch MIX 1 J4_09 J4_14 J4_15 J14_13 J4_11 J4_10 J4_10
439+
Olimex RT1010 1 D8 D6 D7 D4 D1 D2 D3
440+
Olimex RT1010 3 - D10 D9 D11 - - -
441+
MIMXRT_DEV 1 "MCK" "SCK_TX" "WS_TX" "SD_TX" "SCK_RX" "WS_RX" "SD_RX"
442+
============== == ===== ======== ======= ======= ======== ======= =======
443+
444+
Symbolic pin names are provided for the MIMXRT_10xx_DEV boards. These are provided
445+
for the other boards as well.
446+
367447
Real time clock (RTC)
368448
---------------------
369449

0 commit comments

Comments
 (0)
0