mirror of
https://github.com/espressif/arduino-esp32
synced 2024-09-21 02:18:29 +00:00
docs(i2s): Fix I2S documentation example (#9916)
* docs(i2s): Fix I2S documentation example * docs(idf): Fix name of Arduino as component link
This commit is contained in:
parent
26db8cba32
commit
1f2ba1f87f
@ -6,6 +6,6 @@ Advanced Utilities
|
||||
:maxdepth: 2
|
||||
|
||||
Library Builder <lib_builder>
|
||||
ESP-IDF as Component <esp-idf_component>
|
||||
Arduino as an ESP-IDF component <esp-idf_component>
|
||||
OTA Web Update <ota_web_update>
|
||||
makeEspArduino <make>
|
||||
|
@ -536,7 +536,7 @@ Sample code
|
||||
#include <ESP_I2S.h>
|
||||
|
||||
const int buff_size = 128;
|
||||
int available, read;
|
||||
int available_bytes, read_bytes;
|
||||
uint8_t buffer[buff_size];
|
||||
I2SClass I2S;
|
||||
|
||||
@ -544,13 +544,13 @@ Sample code
|
||||
I2S.setPins(5, 25, 26, 35, 0); //SCK, WS, SDOUT, SDIN, MCLK
|
||||
I2S.begin(I2S_MODE_STD, 16000, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO);
|
||||
I2S.read();
|
||||
available = I2S.available();
|
||||
if(available < buff_size) {
|
||||
read = I2S.read(buffer, available);
|
||||
available_bytes = I2S.available();
|
||||
if(available_bytes < buff_size) {
|
||||
read_bytes = I2S.read(buffer, available_bytes);
|
||||
} else {
|
||||
read = I2S.read(buffer, buff_size);
|
||||
read_bytes = I2S.read(buffer, buff_size);
|
||||
}
|
||||
I2S.write(buffer, read);
|
||||
I2S.write(buffer, read_bytes);
|
||||
I2S.end();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user