|
1 | 1 | //! # Inter-IC Sound (I2S) |
2 | 2 | //! |
3 | 3 | //! ## Overview |
| 4 | +//! |
4 | 5 | //! I2S (Inter-IC Sound) is a synchronous serial communication protocol usually |
5 | 6 | //! used for transmitting audio data between two digital audio devices. |
6 | 7 | //! Espressif devices may contain more than one I2S peripheral(s). These |
7 | 8 | //! peripherals can be configured to input and output sample data via the I2S |
8 | 9 | //! driver. |
9 | 10 | //! |
10 | | -//! |
11 | 11 | //! ## Configuration |
| 12 | +//! |
12 | 13 | //! I2S supports different data formats, including varying data and channel |
13 | 14 | //! widths, different standards, such as the Philips standard and configurable |
14 | 15 | //! pin mappings for I2S clock (BCLK), word select (WS), and data input/output |
|
18 | 19 | //! supports various configurations, such as different data formats, standards |
19 | 20 | //! (e.g., Philips) and pin configurations. It relies on other peripheral |
20 | 21 | //! modules, such as |
21 | | -//! - `GPIO` |
22 | | -//! - `DMA` |
23 | | -//! - `system` (to configure and enable the I2S peripheral) |
| 22 | +//! - `GPIO` |
| 23 | +//! - `DMA` |
| 24 | +//! - `system` (to configure and enable the I2S peripheral) |
| 25 | +//! |
| 26 | +//! ## Example |
24 | 27 | //! |
25 | | -//! ## Examples |
26 | 28 | //! ### Initialization |
| 29 | +//! |
27 | 30 | //! ```rust, no_run |
28 | 31 | #![doc = crate::before_snippet!()] |
29 | 32 | //! # use esp_hal::i2s::I2s; |
30 | 33 | //! # use esp_hal::i2s::Standard; |
31 | 34 | //! # use esp_hal::i2s::DataFormat; |
| 35 | +//! # use esp_hal::i2s::I2sReadDma; |
32 | 36 | //! # use esp_hal::gpio::Io; |
33 | 37 | //! # use esp_hal::dma_buffers; |
34 | 38 | //! # use esp_hal::dma::{Dma, DmaPriority}; |
35 | | -//! # use crate::esp_hal::prelude::_fugit_RateExtU32; |
36 | | -//! # use crate::esp_hal::peripherals::Peripherals; |
37 | | -//! # use crate::esp_hal::i2s::I2sReadDma; |
38 | | -//! # use core::ptr::addr_of_mut; |
39 | | -//! # let io = Io::new(peripherals.GPIO, peripherals.IO_MUX); |
40 | | -//! let dma = Dma::new(peripherals.DMA); |
| 39 | +//! let system = esp_hal::init(CpuClock::boot_default()); |
| 40 | +//! # let io = Io::new(system.peripherals.GPIO, system.peripherals.IO_MUX); |
| 41 | +//! let dma = Dma::new(system.peripherals.DMA); |
41 | 42 | #![cfg_attr(any(esp32, esp32s2), doc = "let dma_channel = dma.i2s0channel;")] |
42 | 43 | #![cfg_attr(not(any(esp32, esp32s2)), doc = "let dma_channel = dma.channel0;")] |
43 | 44 | //! let (_, tx_descriptors, mut rx_buffer, rx_descriptors) = |
44 | 45 | //! dma_buffers!(0, 4 * 4092); |
45 | 46 | //! |
46 | 47 | //! let i2s = I2s::new( |
47 | | -//! peripherals.I2S0, |
| 48 | +//! system.peripherals.I2S0, |
48 | 49 | //! Standard::Philips, |
49 | 50 | //! DataFormat::Data16Channel16, |
50 | 51 | //! 44100.Hz(), |
|
54 | 55 | //! ), |
55 | 56 | //! tx_descriptors, |
56 | 57 | //! rx_descriptors, |
57 | | -//! &clocks, |
| 58 | +//! &system.clocks, |
58 | 59 | //! ); |
59 | 60 | #![cfg_attr(not(esp32), doc = "let i2s = i2s.with_mclk(io.pins.gpio0);")] |
60 | 61 | //! let mut i2s_rx = i2s.i2s_rx |
|
0 commit comments