Closed kowyo closed 1 month ago
XIAOESP32S3
USB connected to Mac
v3.0.1
Arduino IDE
macOS 14.5
80Mhz
yes
115200
@lucasssvaz @me-no-dev I ran the example code in https://docs.espressif.com/projects/arduino-esp32/en/latest/api/i2s.html?highlight=i2s and the output reported error
#include <ESP_I2S.h> const int buff_size = 128; int available, read; uint8_t buffer[buff_size]; I2SClass I2S; void setup() { 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); } else { read = I2S.read(buffer, buff_size); } I2S.write(buffer, read); I2S.end(); } void loop() {}
/Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino:4:16: error: 'int read' redeclared as different kind of entity 4 | int available, read; | ^~~~ In file included from /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp32-arduino-libs/idf-release_v5.1-442a798083/esp32s3/include/newlib/platform_include/sys/unistd.h:11, from /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp-xs3/2302/xtensa-esp32s3-elf/sys-include/unistd.h:4, from /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp32-arduino-libs/idf-release_v5.1-442a798083/esp32s3/include/lwip/port/include/lwipopts.h:14, from /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp32-arduino-libs/idf-release_v5.1-442a798083/esp32s3/include/lwip/lwip/src/include/lwip/opt.h:51, from /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp32-arduino-libs/idf-release_v5.1-442a798083/esp32s3/include/lwip/lwip/src/include/lwip/ip_addr.h:40, from /Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/cores/esp32/IPAddress.h:25, from /Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/cores/esp32/Arduino.h:196, from /private/var/folders/6r/s6_mxzqs2nq3vp6jb2hh8xpr0000gn/T/arduino/sketches/A17C809F49E99F211DA5F2057498F7E6/sketch/firmware.ino.cpp:1: /Users/kowyo/Library/Arduino15/packages/esp32/tools/esp-xs3/2302/xtensa-esp32s3-elf/sys-include/sys/unistd.h:189:25: note: previous declaration 'int read(int, void*, size_t)' 189 | _READ_WRITE_RETURN_TYPE read (int __fd, void *__buf, size_t __nbyte); | ^~~~ /Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino: In function 'void setup()': /Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino:14:20: error: no matching function for call to 'I2SClass::read(uint8_t [128], int&)' 14 | read = I2S.read(buffer, available); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~ In file included from /Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino:1: /Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/ESP_I2S/src/ESP_I2S.h:81:7: note: candidate: 'virtual int I2SClass::read()' 81 | int read(); | ^~~~ /Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/ESP_I2S/src/ESP_I2S.h:81:7: note: candidate expects 0 arguments, 2 provided /Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino:16:20: error: no matching function for call to 'I2SClass::read(uint8_t [128], const int&)' 16 | read = I2S.read(buffer, buff_size); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~ /Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/ESP_I2S/src/ESP_I2S.h:81:7: note: candidate: 'virtual int I2SClass::read()' 81 | int read(); | ^~~~ /Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/ESP_I2S/src/ESP_I2S.h:81:7: note: candidate expects 0 arguments, 2 provided /Users/kowyo/Library/CloudStorage/OneDrive-Personal/Projects/OpenGlass/firmware/firmware.ino:18:21: error: invalid conversion from 'int (*)(int, void*, size_t)' {aka 'int (*)(int, void*, unsigned int)'} to 'size_t' {aka 'unsigned int'} [-fpermissive] 18 | I2S.write(buffer, read); | ^~~~ | | | int (*)(int, void*, size_t) {aka int (*)(int, void*, unsigned int)} /Users/kowyo/Library/Arduino15/packages/esp32/hardware/esp32/3.0.1/libraries/ESP_I2S/src/ESP_I2S.h:65:40: note: initializing argument 2 of 'size_t I2SClass::write(uint8_t*, size_t)' 65 | size_t write(uint8_t *buffer, size_t size); | ~~~~~~~^~~~ exit status 1 Compilation error: 'int read' redeclared as different kind of entity
No response
I'll update the example but for now you can just rename the read variable to byte_read and available to bytes_available and it should work fine
read
byte_read
available
bytes_available
Board
XIAOESP32S3
Device Description
Hardware Configuration
USB connected to Mac
Version
v3.0.1
IDE Name
Arduino IDE
Operating System
macOS 14.5
Flash frequency
80Mhz
PSRAM enabled
yes
Upload speed
115200
Description
@lucasssvaz @me-no-dev I ran the example code in https://docs.espressif.com/projects/arduino-esp32/en/latest/api/i2s.html?highlight=i2s and the output reported error
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide