Skip to content

[FEATURE] Basic implementation of Arduino's I2S library #5304

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

Merged
merged 107 commits into from
Feb 4, 2022
Merged
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
185b7ef
[FEATURE] Basic implementation of Arduino's I2S library
PilnyTomas Jun 18, 2021
2aabfb7
[MAINTENANCE] Added I2S to CMakeLists
PilnyTomas Jun 18, 2021
ca6f456
[MAINTENANCE] Joined task blocking (i2s event queue + kill command)
PilnyTomas Jun 18, 2021
32043fc
Merge branch 'espressif:master' into arduino_i2s
PilnyTomas Jun 18, 2021
a3309d4
[FEATURE] Added functions to set pins for both Input and Output
PilnyTomas Jun 21, 2021
3ad6d36
[FEATURE] Added new example demonstrating usage of callbacks
PilnyTomas Jun 24, 2021
12d926f
[MAINTENANCE] Minor changes
PilnyTomas Jun 28, 2021
d7eb3f3
[BACKUP] Work in progress on overlaying buffer (crashing)
PilnyTomas Jul 7, 2021
ad2c540
[BUGFIX] Fixed data type which was causing crashes
PilnyTomas Jul 7, 2021
baff65d
[BUGFIX] Fixed usage of new buffer in read function
PilnyTomas Jul 8, 2021
f366160
[BACKUP] Latest experiments with internal buffer
PilnyTomas Jul 23, 2021
370dd9f
Merge branch 'master' into arduino_i2s
PilnyTomas Jul 28, 2021
7a64d97
[BUGFIX] Fixed merging error in CMakeLists
PilnyTomas Jul 28, 2021
ee969b8
Improved quality of playback
PilnyTomas Jul 30, 2021
5b65b5d
Reimplemented input buffer as ring buffer
PilnyTomas Aug 3, 2021
f0ebf2b
Fixed kill semaphore error; added pin getters/setters
PilnyTomas Aug 5, 2021
a86a32b
Returning accidentally removed mutex give
PilnyTomas Aug 5, 2021
97102fe
Increased DMA buffer size for better performance
PilnyTomas Aug 5, 2021
83bb448
Split begin; changed pin setups and duplex/simplex setup
PilnyTomas Aug 13, 2021
5bb5090
Initial implementation of PDM support (untested)
PilnyTomas Aug 18, 2021
1073b60
Merge branch 'master' into arduino_i2s
PilnyTomas Aug 18, 2021
fbfe7c7
Added esp-dsp in CMakeLists.txt to compile in IDF
PilnyTomas Aug 20, 2021
9cb2d3d
Pre-release changes
PilnyTomas Sep 1, 2021
3bdb4e5
Extended SimpleTone example with DAC settings
PilnyTomas Sep 2, 2021
8c8d357
Removed ArduinoSound from CMakeLists
PilnyTomas Sep 2, 2021
adb66dc
[FEATURE] Basic implementation of Arduino's I2S library
PilnyTomas Jun 18, 2021
4577331
[MAINTENANCE] Added I2S to CMakeLists
PilnyTomas Jun 18, 2021
13a988c
[MAINTENANCE] Joined task blocking (i2s event queue + kill command)
PilnyTomas Jun 18, 2021
019490c
[FEATURE] Added functions to set pins for both Input and Output
PilnyTomas Jun 21, 2021
b18cb31
[FEATURE] Added new example demonstrating usage of callbacks
PilnyTomas Jun 24, 2021
d5a66dd
[MAINTENANCE] Minor changes
PilnyTomas Jun 28, 2021
64a3bb2
[BACKUP] Work in progress on overlaying buffer (crashing)
PilnyTomas Jul 7, 2021
992c80a
[BUGFIX] Fixed data type which was causing crashes
PilnyTomas Jul 7, 2021
64bd076
[BUGFIX] Fixed usage of new buffer in read function
PilnyTomas Jul 8, 2021
635dc5a
[BACKUP] Latest experiments with internal buffer
PilnyTomas Jul 23, 2021
d84057b
Improved quality of playback
PilnyTomas Jul 30, 2021
7da54b8
Reimplemented input buffer as ring buffer
PilnyTomas Aug 3, 2021
d5a3a05
Fixed kill semaphore error; added pin getters/setters
PilnyTomas Aug 5, 2021
f95fdb6
Returning accidentally removed mutex give
PilnyTomas Aug 5, 2021
8d99a4d
Increased DMA buffer size for better performance
PilnyTomas Aug 5, 2021
8519d67
Split begin; changed pin setups and duplex/simplex setup
PilnyTomas Aug 13, 2021
b0d45ce
Initial implementation of PDM support (untested)
PilnyTomas Aug 18, 2021
f45e5ba
Added esp-dsp in CMakeLists.txt to compile in IDF
PilnyTomas Aug 20, 2021
cb6da04
Pre-release changes
PilnyTomas Sep 1, 2021
cdf3a7c
Extended SimpleTone example with DAC settings
PilnyTomas Sep 2, 2021
991f54c
Removed ArduinoSound from CMakeLists
PilnyTomas Sep 2, 2021
2270f4c
Merging CMakeLists
PilnyTomas Sep 2, 2021
9fd0042
ESP32-S2 support
PilnyTomas Sep 2, 2021
7b77310
Removed excessive I2S from CMakeLists
PilnyTomas Sep 3, 2021
b3fdeec
Variable pin for ADC
PilnyTomas Sep 20, 2021
cde002f
Fixed data types for sample_rate inconsistent with IDF i2s driver
PilnyTomas Sep 21, 2021
14e2c7f
Fixed #ifdef to #if
PilnyTomas Sep 21, 2021
2645cf4
Fixed forgotten #ifdef to #if
PilnyTomas Sep 21, 2021
545d916
Merge branch 'master' into arduino_i2s
SuGlider Sep 21, 2021
80f49da
Updated Keywords
PilnyTomas Sep 22, 2021
139aef3
GPIO to ADC conversion methods wrapped in ADC support #if
PilnyTomas Sep 22, 2021
1d481e9
Added .skip.esp32c3 files untill C3 is supported
PilnyTomas Sep 22, 2021
ca0887b
All private functions have now underscore preceeding their name
PilnyTomas Sep 22, 2021
2dfab5f
Proposed wrapping functions for thread safety
PilnyTomas Sep 22, 2021
83d5094
Small fix: Added new function as class member
PilnyTomas Sep 23, 2021
28e6947
Applied nesting locks to all public functions
PilnyTomas Sep 23, 2021
a8727ad
Added aditional checks
PilnyTomas Sep 29, 2021
b1e1387
Added thread safety example
PilnyTomas Sep 30, 2021
39372eb
Thread safety example: Added 2 tasks to use more public functions
PilnyTomas Sep 30, 2021
23e65bd
Mono channel support
PilnyTomas Oct 8, 2021
7914492
FullDuplex changed + added example
PilnyTomas Oct 11, 2021
a65dad7
Merge branch 'master' into arduino_i2s
PilnyTomas Oct 13, 2021
f61e30d
Minor changes to FullDuplex example
PilnyTomas Oct 13, 2021
ba155a5
Added support for 8 bps
PilnyTomas Oct 13, 2021
4bc2633
Moved driver install before ringbuffer init
PilnyTomas Oct 13, 2021
ea037b1
BugFix - return was called before mutex release in read
PilnyTomas Oct 13, 2021
0b66402
Changed #if constants for PDM and ADC/DAC
PilnyTomas Oct 14, 2021
660656f
BugFix: forgotten init flag rise for PDM mode during init + #if const…
PilnyTomas Oct 14, 2021
9da5942
bugfix: Changes on the i2s_set_clk and DMA size
pedrominatel Oct 21, 2021
ef1a825
bugfix: Reverted the DMA buffer and fix on the i2s_set_clk for Philli…
pedrominatel Oct 22, 2021
a56be41
Split PDM modes to mono and stereo + renamed ADC mode
PilnyTomas Oct 25, 2021
3f9458c
Modified internal initialization flags and checks
PilnyTomas Oct 25, 2021
d7f6f6e
Merge branch 'master' into arduino_i2s
PilnyTomas Oct 26, 2021
5e4c7a4
Merge branch 'master' into arduino_i2s
PilnyTomas Nov 16, 2021
0e9d34e
Single-sample writes are now blocking (same as Arduino)
PilnyTomas Nov 19, 2021
0e478b9
removed kill sempahore for callback task deletion
PilnyTomas Nov 19, 2021
4cc4e26
added few more checks
PilnyTomas Nov 19, 2021
3dfa490
Removed Callback locks
PilnyTomas Nov 22, 2021
35ec3e4
Implemented peek
PilnyTomas Nov 22, 2021
90232a9
Merge branch 'master' into arduino_i2s
PilnyTomas Nov 22, 2021
5d786e7
Bugfix - check if task exists before deleteing
PilnyTomas Nov 23, 2021
39bfd11
Added draft for unit tests
PilnyTomas Nov 25, 2021
8af5b2a
Merge branch 'arduino_i2s' of github.com:PilnyTomas/arduino-esp32 int…
PilnyTomas Nov 25, 2021
262b18e
Basic UART comm for unit tests
PilnyTomas Nov 26, 2021
0afe17c
Work In Progress on I2S data transfer
PilnyTomas Dec 2, 2021
cd2c8c8
Work In Progress on data fix function
PilnyTomas Dec 8, 2021
395fb08
Fixed WDT
PilnyTomas Jan 4, 2022
6420fad
Removed unsupported examples and unit tests
PilnyTomas Jan 6, 2022
cedff7d
Initial code polish
PilnyTomas Jan 6, 2022
a73a1a6
fixes buffer size - no noise now
SuGlider Jan 6, 2022
29b05a3
Fix free bug for 24 and 32 bps; add warning to unsupported modes
PilnyTomas Jan 6, 2022
5b98d71
Merge branch 'master' into arduino_i2s
PilnyTomas Jan 6, 2022
e1dc00e
Initial documentation of I2S lib
PilnyTomas Jan 18, 2022
e883358
Modifications to I2S doc
PilnyTomas Jan 19, 2022
d02f392
Updates and small fixes - slave mode, pins,...
PilnyTomas Jan 19, 2022
459ed79
Structure review and syntax fixes
pedrominatel Feb 1, 2022
28d6871
Merge branch 'master' into arduino_i2s
pedrominatel Feb 1, 2022
6591f5b
Fix replace() failing (#6224)
s-hadinger Feb 3, 2022
1046f59
Upload to the component registry (#6203)
magicarm22 Feb 3, 2022
bb4d902
add feather esp32 v2 and qtpy c3 board def (#6223)
ladyada Feb 3, 2022
9b066ea
Added dual antenna for WiFi (based on the ESP32-WROOM-DA module) (#6226)
pedrominatel Feb 3, 2022
5a13725
Merge branch 'espressif:master' into arduino_i2s
PilnyTomas Feb 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/upload-idf-component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Push components to https://components.espressif.com
on:
push:
tags:
- v*
jobs:
upload_components:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"

- name: Upload components to the component registry
uses: espressif/github-actions/upload_components@master
with:
name: arduino-esp32
namespace: espressif
api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }}
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -86,6 +86,7 @@ set(LIBRARY_SRCS
libraries/HTTPClient/src/HTTPClient.cpp
libraries/HTTPUpdate/src/HTTPUpdate.cpp
libraries/LittleFS/src/LittleFS.cpp
libraries/I2S/src/I2S.cpp
libraries/NetBIOS/src/NetBIOS.cpp
libraries/Preferences/src/Preferences.cpp
libraries/RainMaker/src/RMaker.cpp
@@ -162,7 +163,6 @@ set(BLE_SRCS
libraries/BLE/src/GeneralUtils.cpp
)


set(includedirs
variants/${IDF_TARGET}/
cores/esp32/
@@ -179,6 +179,7 @@ set(includedirs
libraries/HTTPClient/src
libraries/HTTPUpdate/src
libraries/LittleFS/src
libraries/I2S/src
libraries/NetBIOS/src
libraries/Preferences/src
libraries/RainMaker/src
@@ -234,6 +235,8 @@ function(maybe_add_component component_name)
endif()
endfunction()

maybe_add_component(esp-dsp)

if(IDF_TARGET MATCHES "esp32" AND CONFIG_ESP_RMAKER_TASK_STACK)
maybe_add_component(esp_rainmaker)
maybe_add_component(qrcode)
278 changes: 278 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
@@ -5088,6 +5088,284 @@ adafruit_qtpy_esp32s2.menu.DebugLevel.debug.build.code_debug=4
adafruit_qtpy_esp32s2.menu.DebugLevel.verbose=Verbose
adafruit_qtpy_esp32s2.menu.DebugLevel.verbose.build.code_debug=5

##############################################################

adafruit_qtpy_esp32c3.name=Adafruit QT Py ESP32-C3
adafruit_qtpy_esp32c3.vid.0=0x303a
adafruit_qtpy_esp32c3.pid.0=0x1001

adafruit_qtpy_esp32c3.upload.tool=esptool_py
adafruit_qtpy_esp32c3.upload.maximum_size=1310720
adafruit_qtpy_esp32c3.upload.maximum_data_size=327680
adafruit_qtpy_esp32c3.upload.flags=
adafruit_qtpy_esp32c3.upload.extra_flags=
adafruit_qtpy_esp32c3.upload.use_1200bps_touch=false
adafruit_qtpy_esp32c3.upload.wait_for_upload_port=false

adafruit_qtpy_esp32c3.serial.disableDTR=false
adafruit_qtpy_esp32c3.serial.disableRTS=false

adafruit_qtpy_esp32c3.build.tarch=riscv32
adafruit_qtpy_esp32c3.build.target=esp
adafruit_qtpy_esp32c3.build.mcu=esp32c3
adafruit_qtpy_esp32c3.build.core=esp32
adafruit_qtpy_esp32c3.build.variant=adafruit_qtpy_esp32c3
adafruit_qtpy_esp32c3.build.board=ADAFRUIT_QTPY_ESP32C3
adafruit_qtpy_esp32c3.build.bootloader_addr=0x0

adafruit_qtpy_esp32c3.build.cdc_on_boot=0
adafruit_qtpy_esp32c3.build.f_cpu=160000000L
adafruit_qtpy_esp32c3.build.flash_size=4MB
adafruit_qtpy_esp32c3.build.flash_freq=80m
adafruit_qtpy_esp32c3.build.flash_mode=dout
adafruit_qtpy_esp32c3.build.boot=dout
adafruit_qtpy_esp32c3.build.partitions=default
adafruit_qtpy_esp32c3.build.defines=

adafruit_qtpy_esp32c3.menu.CDCOnBoot.cdc=Enabled
adafruit_qtpy_esp32c3.menu.CDCOnBoot.cdc.build.cdc_on_boot=1
adafruit_qtpy_esp32c3.menu.CDCOnBoot.default=Disabled
adafruit_qtpy_esp32c3.menu.CDCOnBoot.default.build.cdc_on_boot=0

adafruit_qtpy_esp32c3.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
adafruit_qtpy_esp32c3.menu.PartitionScheme.default.build.partitions=default
adafruit_qtpy_esp32c3.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS)
adafruit_qtpy_esp32c3.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
adafruit_qtpy_esp32c3.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
adafruit_qtpy_esp32c3.menu.PartitionScheme.minimal.build.partitions=minimal
adafruit_qtpy_esp32c3.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
adafruit_qtpy_esp32c3.menu.PartitionScheme.no_ota.build.partitions=no_ota
adafruit_qtpy_esp32c3.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
adafruit_qtpy_esp32c3.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS)
adafruit_qtpy_esp32c3.menu.PartitionScheme.noota_3g.build.partitions=noota_3g
adafruit_qtpy_esp32c3.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576
adafruit_qtpy_esp32c3.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS)
adafruit_qtpy_esp32c3.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat
adafruit_qtpy_esp32c3.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152
adafruit_qtpy_esp32c3.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS)
adafruit_qtpy_esp32c3.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat
adafruit_qtpy_esp32c3.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576
adafruit_qtpy_esp32c3.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS)
adafruit_qtpy_esp32c3.menu.PartitionScheme.huge_app.build.partitions=huge_app
adafruit_qtpy_esp32c3.menu.PartitionScheme.huge_app.upload.maximum_size=3145728
adafruit_qtpy_esp32c3.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
adafruit_qtpy_esp32c3.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
adafruit_qtpy_esp32c3.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080

adafruit_qtpy_esp32c3.menu.CPUFreq.160=160MHz (WiFi)
adafruit_qtpy_esp32c3.menu.CPUFreq.160.build.f_cpu=160000000L
adafruit_qtpy_esp32c3.menu.CPUFreq.80=80MHz (WiFi)
adafruit_qtpy_esp32c3.menu.CPUFreq.80.build.f_cpu=80000000L
adafruit_qtpy_esp32c3.menu.CPUFreq.40=40MHz
adafruit_qtpy_esp32c3.menu.CPUFreq.40.build.f_cpu=40000000L
adafruit_qtpy_esp32c3.menu.CPUFreq.20=20MHz
adafruit_qtpy_esp32c3.menu.CPUFreq.20.build.f_cpu=20000000L
adafruit_qtpy_esp32c3.menu.CPUFreq.10=10MHz
adafruit_qtpy_esp32c3.menu.CPUFreq.10.build.f_cpu=10000000L

adafruit_qtpy_esp32c3.menu.FlashMode.dout=DOUT
adafruit_qtpy_esp32c3.menu.FlashMode.dout.build.flash_mode=dout
adafruit_qtpy_esp32c3.menu.FlashMode.dout.build.boot=dout
adafruit_qtpy_esp32c3.menu.FlashMode.qio=QIO
adafruit_qtpy_esp32c3.menu.FlashMode.qio.build.flash_mode=dio
adafruit_qtpy_esp32c3.menu.FlashMode.qio.build.boot=qio
adafruit_qtpy_esp32c3.menu.FlashMode.dio=DIO
adafruit_qtpy_esp32c3.menu.FlashMode.dio.build.flash_mode=dio
adafruit_qtpy_esp32c3.menu.FlashMode.dio.build.boot=dio
adafruit_qtpy_esp32c3.menu.FlashMode.qout=QOUT
adafruit_qtpy_esp32c3.menu.FlashMode.qout.build.flash_mode=dout
adafruit_qtpy_esp32c3.menu.FlashMode.qout.build.boot=qout

adafruit_qtpy_esp32c3.menu.FlashFreq.80=80MHz
adafruit_qtpy_esp32c3.menu.FlashFreq.80.build.flash_freq=80m
adafruit_qtpy_esp32c3.menu.FlashFreq.40=40MHz
adafruit_qtpy_esp32c3.menu.FlashFreq.40.build.flash_freq=40m

adafruit_qtpy_esp32c3.menu.FlashSize.4M=4MB (32Mb)
adafruit_qtpy_esp32c3.menu.FlashSize.4M.build.flash_size=4MB
adafruit_qtpy_esp32c3.menu.FlashSize.2M=2MB (16Mb)
adafruit_qtpy_esp32c3.menu.FlashSize.2M.build.flash_size=2MB
adafruit_qtpy_esp32c3.menu.FlashSize.2M.build.partitions=minimal

adafruit_qtpy_esp32c3.menu.UploadSpeed.115200=115200
adafruit_qtpy_esp32c3.menu.UploadSpeed.115200.upload.speed=115200
adafruit_qtpy_esp32c3.menu.UploadSpeed.921600=921600
adafruit_qtpy_esp32c3.menu.UploadSpeed.921600.upload.speed=921600
adafruit_qtpy_esp32c3.menu.UploadSpeed.921600=921600
adafruit_qtpy_esp32c3.menu.UploadSpeed.921600.upload.speed=921600
adafruit_qtpy_esp32c3.menu.UploadSpeed.115200=115200
adafruit_qtpy_esp32c3.menu.UploadSpeed.115200.upload.speed=115200
adafruit_qtpy_esp32c3.menu.UploadSpeed.256000.windows=256000
adafruit_qtpy_esp32c3.menu.UploadSpeed.256000.upload.speed=256000
adafruit_qtpy_esp32c3.menu.UploadSpeed.230400.windows.upload.speed=256000
adafruit_qtpy_esp32c3.menu.UploadSpeed.230400=230400
adafruit_qtpy_esp32c3.menu.UploadSpeed.230400.upload.speed=230400
adafruit_qtpy_esp32c3.menu.UploadSpeed.460800.linux=460800
adafruit_qtpy_esp32c3.menu.UploadSpeed.460800.macosx=460800
adafruit_qtpy_esp32c3.menu.UploadSpeed.460800.upload.speed=460800
adafruit_qtpy_esp32c3.menu.UploadSpeed.512000.windows=512000
adafruit_qtpy_esp32c3.menu.UploadSpeed.512000.upload.speed=512000

adafruit_qtpy_esp32c3.menu.DebugLevel.none=None
adafruit_qtpy_esp32c3.menu.DebugLevel.none.build.code_debug=0
adafruit_qtpy_esp32c3.menu.DebugLevel.error=Error
adafruit_qtpy_esp32c3.menu.DebugLevel.error.build.code_debug=1
adafruit_qtpy_esp32c3.menu.DebugLevel.warn=Warn
adafruit_qtpy_esp32c3.menu.DebugLevel.warn.build.code_debug=2
adafruit_qtpy_esp32c3.menu.DebugLevel.info=Info
adafruit_qtpy_esp32c3.menu.DebugLevel.info.build.code_debug=3
adafruit_qtpy_esp32c3.menu.DebugLevel.debug=Debug
adafruit_qtpy_esp32c3.menu.DebugLevel.debug.build.code_debug=4
adafruit_qtpy_esp32c3.menu.DebugLevel.verbose=Verbose
adafruit_qtpy_esp32c3.menu.DebugLevel.verbose.build.code_debug=5


adafruit_qtpy_esp32_pico.name=Adafruit QT Py ESP32 Pico

adafruit_qtpy_esp32_pico.upload.tool=esptool_py
adafruit_qtpy_esp32_pico.upload.maximum_size=1310720
adafruit_qtpy_esp32_pico.upload.maximum_data_size=327680
adafruit_qtpy_esp32_pico.upload.flags=
adafruit_qtpy_esp32_pico.upload.extra_flags=

adafruit_qtpy_esp32_pico.serial.disableDTR=true
adafruit_qtpy_esp32_pico.serial.disableRTS=true

adafruit_qtpy_esp32_pico.build.tarch=xtensa
adafruit_qtpy_esp32_pico.build.bootloader_addr=0x1000
adafruit_qtpy_esp32_pico.build.target=esp32
adafruit_qtpy_esp32_pico.build.mcu=esp32
adafruit_qtpy_esp32_pico.build.core=esp32
adafruit_qtpy_esp32_pico.build.variant=adafruit_qtpy_esp32
adafruit_qtpy_esp32_pico.build.board=ADAFRUIT_QTPY_ESP32_PICO

adafruit_qtpy_esp32_pico.build.f_cpu=240000000L
adafruit_qtpy_esp32_pico.build.flash_size=8MB
adafruit_qtpy_esp32_pico.build.flash_freq=80m
adafruit_qtpy_esp32_pico.build.flash_mode=dio
adafruit_qtpy_esp32_pico.build.boot=dio
adafruit_qtpy_esp32_pico.build.partitions=default
adafruit_qtpy_esp32_pico.build.defines=

adafruit_qtpy_esp32_pico.menu.PartitionScheme.default=Default
adafruit_qtpy_esp32_pico.menu.PartitionScheme.default.build.partitions=default
adafruit_qtpy_esp32_pico.menu.PartitionScheme.no_ota=No OTA (Large APP)
adafruit_qtpy_esp32_pico.menu.PartitionScheme.no_ota.build.partitions=no_ota
adafruit_qtpy_esp32_pico.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
adafruit_qtpy_esp32_pico.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
adafruit_qtpy_esp32_pico.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
adafruit_qtpy_esp32_pico.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080

adafruit_qtpy_esp32_pico.menu.UploadSpeed.921600=921600
adafruit_qtpy_esp32_pico.menu.UploadSpeed.921600.upload.speed=921600
adafruit_qtpy_esp32_pico.menu.UploadSpeed.115200=115200
adafruit_qtpy_esp32_pico.menu.UploadSpeed.115200.upload.speed=115200
adafruit_qtpy_esp32_pico.menu.UploadSpeed.256000.windows=256000
adafruit_qtpy_esp32_pico.menu.UploadSpeed.256000.upload.speed=256000
adafruit_qtpy_esp32_pico.menu.UploadSpeed.230400.windows.upload.speed=256000
adafruit_qtpy_esp32_pico.menu.UploadSpeed.230400=230400
adafruit_qtpy_esp32_pico.menu.UploadSpeed.230400.upload.speed=230400
adafruit_qtpy_esp32_pico.menu.UploadSpeed.460800.linux=460800
adafruit_qtpy_esp32_pico.menu.UploadSpeed.460800.macosx=460800
adafruit_qtpy_esp32_pico.menu.UploadSpeed.460800.upload.speed=460800
adafruit_qtpy_esp32_pico.menu.UploadSpeed.512000.windows=512000
adafruit_qtpy_esp32_pico.menu.UploadSpeed.512000.upload.speed=512000

adafruit_qtpy_esp32_pico.menu.PSRAM.enabled=Enabled
adafruit_qtpy_esp32_pico.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-strategy=memw
adafruit_qtpy_esp32_pico.menu.PSRAM.enabled.build.extra_libs=
adafruit_qtpy_esp32_pico.menu.PSRAM.disabled=Disabled
adafruit_qtpy_esp32_pico.menu.PSRAM.disabled.build.defines=
adafruit_qtpy_esp32_pico.menu.PSRAM.disabled.build.extra_libs=

adafruit_qtpy_esp32_pico.menu.DebugLevel.none=None
adafruit_qtpy_esp32_pico.menu.DebugLevel.none.build.code_debug=0
adafruit_qtpy_esp32_pico.menu.DebugLevel.error=Error
adafruit_qtpy_esp32_pico.menu.DebugLevel.error.build.code_debug=1
adafruit_qtpy_esp32_pico.menu.DebugLevel.warn=Warn
adafruit_qtpy_esp32_pico.menu.DebugLevel.warn.build.code_debug=2
adafruit_qtpy_esp32_pico.menu.DebugLevel.info=Info
adafruit_qtpy_esp32_pico.menu.DebugLevel.info.build.code_debug=3
adafruit_qtpy_esp32_pico.menu.DebugLevel.debug=Debug
adafruit_qtpy_esp32_pico.menu.DebugLevel.debug.build.code_debug=4
adafruit_qtpy_esp32_pico.menu.DebugLevel.verbose=Verbose
adafruit_qtpy_esp32_pico.menu.DebugLevel.verbose.build.code_debug=5



adafruit_feather_esp32_v2.name=Adafruit Feather ESP32 V2

adafruit_feather_esp32_v2.upload.tool=esptool_py
adafruit_feather_esp32_v2.upload.maximum_size=1310720
adafruit_feather_esp32_v2.upload.maximum_data_size=327680
adafruit_feather_esp32_v2.upload.flags=
adafruit_feather_esp32_v2.upload.extra_flags=

adafruit_feather_esp32_v2.serial.disableDTR=true
adafruit_feather_esp32_v2.serial.disableRTS=true

adafruit_feather_esp32_v2.build.tarch=xtensa
adafruit_feather_esp32_v2.build.bootloader_addr=0x1000
adafruit_feather_esp32_v2.build.target=esp32
adafruit_feather_esp32_v2.build.mcu=esp32
adafruit_feather_esp32_v2.build.core=esp32
adafruit_feather_esp32_v2.build.variant=adafruit_feather_esp32_v2
adafruit_feather_esp32_v2.build.board=ADAFRUIT_FEATHER_ESP32_V2

adafruit_feather_esp32_v2.build.f_cpu=240000000L
adafruit_feather_esp32_v2.build.flash_size=8MB
adafruit_feather_esp32_v2.build.flash_freq=80m
adafruit_feather_esp32_v2.build.flash_mode=dio
adafruit_feather_esp32_v2.build.boot=dio
adafruit_feather_esp32_v2.build.partitions=default
adafruit_feather_esp32_v2.build.defines=

adafruit_feather_esp32_v2.menu.PartitionScheme.default=Default
adafruit_feather_esp32_v2.menu.PartitionScheme.default.build.partitions=default
adafruit_feather_esp32_v2.menu.PartitionScheme.no_ota=No OTA (Large APP)
adafruit_feather_esp32_v2.menu.PartitionScheme.no_ota.build.partitions=no_ota
adafruit_feather_esp32_v2.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
adafruit_feather_esp32_v2.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (Large APPS with OTA)
adafruit_feather_esp32_v2.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
adafruit_feather_esp32_v2.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080

adafruit_feather_esp32_v2.menu.UploadSpeed.921600=921600
adafruit_feather_esp32_v2.menu.UploadSpeed.921600.upload.speed=921600
adafruit_feather_esp32_v2.menu.UploadSpeed.115200=115200
adafruit_feather_esp32_v2.menu.UploadSpeed.115200.upload.speed=115200
adafruit_feather_esp32_v2.menu.UploadSpeed.256000.windows=256000
adafruit_feather_esp32_v2.menu.UploadSpeed.256000.upload.speed=256000
adafruit_feather_esp32_v2.menu.UploadSpeed.230400.windows.upload.speed=256000
adafruit_feather_esp32_v2.menu.UploadSpeed.230400=230400
adafruit_feather_esp32_v2.menu.UploadSpeed.230400.upload.speed=230400
adafruit_feather_esp32_v2.menu.UploadSpeed.460800.linux=460800
adafruit_feather_esp32_v2.menu.UploadSpeed.460800.macosx=460800
adafruit_feather_esp32_v2.menu.UploadSpeed.460800.upload.speed=460800
adafruit_feather_esp32_v2.menu.UploadSpeed.512000.windows=512000
adafruit_feather_esp32_v2.menu.UploadSpeed.512000.upload.speed=512000

adafruit_feather_esp32_v2.menu.PSRAM.enabled=Enabled
adafruit_feather_esp32_v2.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-strategy=memw
adafruit_feather_esp32_v2.menu.PSRAM.enabled.build.extra_libs=
adafruit_feather_esp32_v2.menu.PSRAM.disabled=Disabled
adafruit_feather_esp32_v2.menu.PSRAM.disabled.build.defines=
adafruit_feather_esp32_v2.menu.PSRAM.disabled.build.extra_libs=

adafruit_feather_esp32_v2.menu.DebugLevel.none=None
adafruit_feather_esp32_v2.menu.DebugLevel.none.build.code_debug=0
adafruit_feather_esp32_v2.menu.DebugLevel.error=Error
adafruit_feather_esp32_v2.menu.DebugLevel.error.build.code_debug=1
adafruit_feather_esp32_v2.menu.DebugLevel.warn=Warn
adafruit_feather_esp32_v2.menu.DebugLevel.warn.build.code_debug=2
adafruit_feather_esp32_v2.menu.DebugLevel.info=Info
adafruit_feather_esp32_v2.menu.DebugLevel.info.build.code_debug=3
adafruit_feather_esp32_v2.menu.DebugLevel.debug=Debug
adafruit_feather_esp32_v2.menu.DebugLevel.debug.build.code_debug=4
adafruit_feather_esp32_v2.menu.DebugLevel.verbose=Verbose
adafruit_feather_esp32_v2.menu.DebugLevel.verbose.build.code_debug=5



##############################################################

nodemcu-32s.name=NodeMCU-32S
3 changes: 2 additions & 1 deletion cores/esp32/WString.cpp
Original file line number Diff line number Diff line change
@@ -774,9 +774,10 @@ void String::replace(const String& find, const String& replace) {
}
if(size == len())
return;
if(size > capacity() && !changeBuffer(size))
if(size > capacity() && !changeBuffer(size)) {
log_w("String.Replace() Insufficient space to replace string");
return;
}
int index = len() - 1;
while(index >= 0 && (index = lastIndexOf(find, index)) >= 0) {
readFrom = wbuffer() + index + find.len();
566 changes: 566 additions & 0 deletions docs/source/api/i2s.rst

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/source/libraries.rst
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ Currently, the Arduino ESP32 supports the following peripherals with Arduino API
+---------------+---------------+---------------+---------------+-------------------------------+
| I2C | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| I2S | No | No | No | WIP |
| I2S | Yes | No | No | WIP |
+---------------+---------------+---------------+---------------+-------------------------------+
| LEDC | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
@@ -74,5 +74,5 @@ The Arduino ESP32 offers some unique APIs, described in this section:
.. toctree::
:maxdepth: 1
:glob:

api/*
20 changes: 20 additions & 0 deletions idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
description: "Arduino core for ESP32, ESP32-S and ESP32-C series of SoCs"
url: "https://github.com/espressif/arduino-esp32"
targets:
- esp32
- esp32s2
- esp32c3
tags:
- arduino
files:
include:
- "cores/**/*"
- "variants/esp32/**/*"
- "variants/esp32s2/**/*"
- "variants/esp32s3/**/*"
- "variants/esp32c3/**/*"
- "libraries/**/*"
- "CMakeLists.txt"
- "Kconfig.projbuild"
exclude:
- "**/*"
Empty file.
86 changes: 86 additions & 0 deletions libraries/I2S/examples/ADCPlotter/ADCPlotter.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
This example is only for ESP devices.
This example demonstrates usage of integrated Digital to Analog Converter (DAC)
You can display sound wave from audio device, or just measure voltage.
To display audio prepare circuit found in following link or drafted as ASCII art
https://forum.arduino.cc/index.php?topic=567581.0
(!) Note that unlike in the link we are connecting the supply line to 3.3V (not 5V)
because ADC can measure only up to around 3V. Anything above 3V will be very inaccurate.
^ +3.3V
|
_
| |10k
|_|
| | |10uF
GPIO34-------------*------------| |----------- line in
(Default ADC pin) | +| |
|
_
| |10k
|_|
|
|
V GND
Connect hot wire of your audio to Line in and GNd wire of audio cable to common ground (GND)
Second option to measure voltage on trimmer / potentiometer has following connection
^ +3.3V
|
_
| |
GPIO34----------->| |
(Default ADC pin) |_|
|
|
_
| | optional resistor
|_|
|
|
V GND
Optional resistor will decrease read value.
Steps to run:
1. Select target board:
Tools -> Board -> ESP32 Arduino -> your board
2. Upload sketch
Press upload button (arrow in top left corner)
When you see in console line like this: "Connecting........_____.....__"
On your board press and hold Boot button and press EN button shortly. Now you can release both buttons.
You should see lines like this: "Writing at 0x00010000... (12 %)" with rising percentage on each line.
If this fails, try the board buttons right after pressing upload button, or reconnect the USB cable.
3. Open plotter
Tools -> Serial Plotter
Enjoy
Created by Tomas Pilny
on 17th June 2021
*/

#include <I2S.h>

void setup() {
// Open serial communications and wait for port to open:
// A baud rate of 115200 is used instead of 9600 for a faster data rate
// on non-native USB ports
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

// start I2S at 8 kHz with 32-bits per sample
if (!I2S.begin(ADC_DAC_MODE, 8000, 16)) {
Serial.println("Failed to initialize I2S!");
while (1); // do nothing
}
}

void loop() {
// read a sample
int sample = I2S.read();
Serial.println(sample);
}
Empty file.
59 changes: 59 additions & 0 deletions libraries/I2S/examples/FullDuplex/FullDuplex.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
This example is only for ESP
This example demonstrates simultaneous usage of microphone and speaker using single I2S module.
The application transfers data from input to output
Circuit:
* ESP32
* GND connected GND
* VIN connected 5V
* SCK 5
* FS 25
* DIN 35
* DOUT 26
* I2S microphone
* I2S decoder + headphones / speaker
created 8 October 2021
by Tomas Pilny
*/

#include <I2S.h>
const long sampleRate = 16000;
const int bitsPerSample = 32;
uint8_t *buffer;

void setup() {
Serial.begin(115200);
//I2S.setAllPins(5, 25, 35, 26); // you can change default pins; order of pins = (CLK, WS, IN, OUT)
if(!I2S.setDuplex()){
Serial.println("ERROR - could not set duplex");
while(true){
vTaskDelay(10); // Cannot continue
}
}
if (!I2S.begin(I2S_PHILIPS_MODE, sampleRate, bitsPerSample)) {
Serial.println("Failed to initialize I2S!");
while(true){
vTaskDelay(10); // Cannot continue
}
}
buffer = (uint8_t*) malloc(I2S.getBufferSize() * (bitsPerSample / 8));
if(buffer == NULL){
Serial.println("Failed to allocate buffer!");
while(true){
vTaskDelay(10); // Cannot continue
}
}
Serial.println("Setup done");
}

void loop() {
//I2S.write(I2S.read()); // primitive implementation sample-by-sample

// Buffer based implementation
I2S.read(buffer, I2S.getBufferSize() * (bitsPerSample / 8));
I2S.write(buffer, I2S.getBufferSize() * (bitsPerSample / 8));

//optimistic_yield(1000); // yield if last yield occurred before <parameter> CPU clock cycles ago
}
Empty file.
44 changes: 44 additions & 0 deletions libraries/I2S/examples/InputSerialPlotter/InputSerialPlotter.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
This example reads audio data from an Invensense's ICS43432 I2S microphone
breakout board, and prints out the samples to the Serial console. The
Serial Plotter built into the Arduino IDE can be used to plot the audio
data (Tools -> Serial Plotter)
Circuit:
* Arduino/Genuino Zero, MKR family and Nano 33 IoT
* ICS43432:
* GND connected GND
* 3.3V connected to 3.3V (Zero, Nano, ESP32), VCC (MKR)
* WS connected to pin 0 (Zero) or 3 (MKR), A2 (Nano) or 25 (ESP32)
* CLK connected to pin 1 (Zero) or 2 (MKR), A3 (Nano) or 5 (ESP32)
* SD connected to pin 9 (Zero) or A6 (MKR), 4 (Nano) or 26 (ESP32)
created 17 November 2016
by Sandeep Mistry
*/

#include <I2S.h>

void setup() {
// Open serial communications and wait for port to open:
// A baud rate of 115200 is used instead of 9600 for a faster data rate
// on non-native USB ports
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

// start I2S at 8 kHz with 32-bits per sample
if (!I2S.begin(I2S_PHILIPS_MODE, 8000, 32)) {
Serial.println("Failed to initialize I2S!");
while (1); // do nothing
}
}

void loop() {
// read a sample
int sample = I2S.read();

if (sample && sample != -1 && sample != 1) {
Serial.println(sample);
}
}
Empty file.
79 changes: 79 additions & 0 deletions libraries/I2S/examples/SimpleTone/SimpleTone.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
This example generates a square wave based tone at a specified frequency
and sample rate. Then outputs the data using the I2S interface to a
MAX08357 I2S Amp Breakout board.
I2S Circuit:
* Arduino/Genuino Zero, MKR family and Nano 33 IoT
* MAX08357:
* GND connected GND
* VIN connected 5V
* LRC connected to pin 0 (Zero) or 3 (MKR), A2 (Nano) or 25 (ESP32)
* BCLK connected to pin 1 (Zero) or 2 (MKR), A3 (Nano) or 5 (ESP32)
* DIN connected to pin 9 (Zero) or A6 (MKR), 4 (Nano) or 26 (ESP32)
DAC Circuit:
* ESP32 or ESP32-S2
* Audio amplifier
- Note:
- ESP32 has DAC on GPIO pins 25 and 26.
- ESP32-S2 has DAC on GPIO pins 17 and 18.
- Connect speaker(s) or headphones.
created 17 November 2016
by Sandeep Mistry
For ESP extended
Tomas Pilny
2nd September 2021
*/

#include <I2S.h>
const int frequency = 440; // frequency of square wave in Hz
const int amplitude = 500; // amplitude of square wave
const int sampleRate = 8000; // sample rate in Hz
const int bps = 16;

const int halfWavelength = (sampleRate / frequency); // half wavelength of square wave

short sample = amplitude; // current sample value
int count = 0;

i2s_mode_t mode = I2S_PHILIPS_MODE; // I2S decoder is needed
// i2s_mode_t mode = ADC_DAC_MODE; // Audio amplifier is needed

// Mono channel input
// This is ESP specific implementation -
// samples will be automatically copied to both channels inside I2S driver
// If you want to have true mono output use I2S_PHILIPS_MODE and interlay
// second channel with 0-value samples.
// The order of channels is RIGH followed by LEFT
//i2s_mode_t mode = I2S_RIGHT_JUSTIFIED_MODE; // I2S decoder is needed

void setup() {
Serial.begin(115200);
Serial.println("I2S simple tone");

// start I2S at the sample rate with 16-bits per sample
if (!I2S.begin(mode, sampleRate, bps)) {
Serial.println("Failed to initialize I2S!");
while (1); // do nothing
}
}

void loop() {
if (count % halfWavelength == 0 ) {
// invert the sample every half wavelength count multiple to generate square wave
sample = -1 * sample;
}

if(mode == I2S_PHILIPS_MODE || mode == ADC_DAC_MODE){ // write the same sample twice, once for Right and once for Left channel
I2S.write(sample); // Right channel
I2S.write(sample); // Left channel
}else if(mode == I2S_RIGHT_JUSTIFIED_MODE || mode == I2S_LEFT_JUSTIFIED_MODE){
// write the same only once - it will be automatically copied to the other channel
I2S.write(sample);
}

// increment the counter for the next sample
count++;
}
61 changes: 61 additions & 0 deletions libraries/I2S/keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#######################################
# Syntax Coloring Map I2S
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################

I2S KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
#######################################
I2SClass KEYWORD2
begin KEYWORD2
end KEYWORD2

onReceive KEYWORD2
onTransmit KEYWORD2

setSckPin KEYWORD2
setFsPin KEYWORD2
setDataInPin KEYWORD2
setDataOutPin KEYWORD2
setAllPins KEYWORD2

getSckPin KEYWORD2
getFsPin KEYWORD2
getDataPin KEYWORD2
getDataInPin KEYWORD2
getDataOutPin KEYWORD2

setDuplex KEYWORD2
setSimplex KEYWORD2
isDuplex KEYWORD2

setBufferSize KEYWORD2
getBufferSize KEYWORD2

write KEYWORD2
availableForWrite KEYWORD2

read KEYWORD2
available KEYWORD2

gpioToAdcUnit KEYWORD2
gpioToAdcChannel KEYWORD2

#######################################
# Constants (LITERAL1)
#######################################
I2S_PHILIPS_MODE LITERAL1
I2S_RIGHT_JUSTIFIED_MODE LITERAL1
I2S_LEFT_JUSTIFIED_MODE LITERAL1
I2S_ADC_DAC LITERAL1
I2S_PDM LITERAL1

PIN_I2S_SCK LITERAL1
PIN_I2S_FS LITERAL1
PIN_I2S_SD LITERAL1
PIN_I2S_SD_OUT LITERAL1
9 changes: 9 additions & 0 deletions libraries/I2S/library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name=I2S
version=1.0
author=Tomas Pilny
maintainer=Tomas Pilny <tomas.pilny@espressif.com>
sentence=Enables the communication with devices that use the Inter-IC Sound (I2S) Bus. Specific implementation for ESP.
paragraph=
category=Communication
url=http://www.arduino.cc/en/Reference/I2S
architectures=esp32
1,209 changes: 1,209 additions & 0 deletions libraries/I2S/src/I2S.cpp

Large diffs are not rendered by default.

195 changes: 195 additions & 0 deletions libraries/I2S/src/I2S.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
/*
Copyright (c) 2016 Arduino LLC. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef _I2S_H_INCLUDED
#define _I2S_H_INCLUDED

#include <Arduino.h>
#include "freertos/ringbuf.h"

namespace esp_i2s {
#include "driver/i2s.h" // ESP specific i2s driver
}

// Default pins
#ifndef PIN_I2S_SCK
#define PIN_I2S_SCK 14
#endif

#ifndef PIN_I2S_FS
#if CONFIG_IDF_TARGET_ESP32S2
#define PIN_I2S_FS 27
#else
#define PIN_I2S_FS 25
#endif
#endif

#ifndef PIN_I2S_SD
#define PIN_I2S_SD 26
#endif

#ifndef PIN_I2S_SD_OUT
#define PIN_I2S_SD_OUT 26
#endif

#ifndef PIN_I2S_SD_IN
#define PIN_I2S_SD_IN 35 // Pin 35 is only input!
#endif

typedef enum {
I2S_PHILIPS_MODE,
I2S_RIGHT_JUSTIFIED_MODE,
I2S_LEFT_JUSTIFIED_MODE,
ADC_DAC_MODE,
PDM_STEREO_MODE,
PDM_MONO_MODE
} i2s_mode_t;

class I2SClass : public Stream
{
public:
// The device index and pins must map to the "COM" pads in Table 6-1 of the datasheet
I2SClass(uint8_t deviceIndex, uint8_t clockGenerator, uint8_t sdPin, uint8_t sckPin, uint8_t fsPin);

// Init in MASTER mode: the SCK and FS pins are driven as outputs using the sample rate
int begin(int mode, int sampleRate, int bitsPerSample);

// Init in SLAVE mode: the SCK and FS pins are inputs, other side controls sample rate
int begin(int mode, int bitsPerSample);

// change pin setup and mode (default is Half Duplex)
// Can be called only on initialized object (after begin)
int setSckPin(int sckPin);
int setFsPin(int fsPin);
int setDataPin(int sdPin); // shared data pin for simplex
int setDataOutPin(int outSdPin);
int setDataInPin(int inSdPin);

int setAllPins();
int setAllPins(int sckPin, int fsPin, int sdPin, int outSdPin, int inSdPin);

int getSckPin();
int getFsPin();
int getDataPin();
int getDataOutPin();
int getDataInPin();

int setDuplex();
int setSimplex();
int isDuplex();

void end();

// from Stream
virtual int available();
virtual int read();
virtual int peek();
virtual void flush();

// from Print
virtual size_t write(uint8_t);
virtual size_t write(const uint8_t *buffer, size_t size);

virtual int availableForWrite();

int read(void* buffer, size_t size);

//size_t write(int);
size_t write(int32_t);
size_t write(const void *buffer, size_t size);
size_t write_blocking(const void *buffer, size_t size);
size_t write_nonblocking(const void *buffer, size_t size);

void onTransmit(void(*)(void));
void onReceive(void(*)(void));

int setBufferSize(int bufferSize);
int getBufferSize();
private:
#if (SOC_I2S_SUPPORTS_ADC && SOC_I2S_SUPPORTS_DAC)
int _gpioToAdcUnit(gpio_num_t gpio_num, esp_i2s::adc_unit_t* adc_unit);
int _gpioToAdcChannel(gpio_num_t gpio_num, esp_i2s::adc_channel_t* adc_channel);
#endif
int begin(int mode, int sampleRate, int bitsPerSample, bool driveClock);

int _enableTransmitter();
int _enableReceiver();
void _onTransferComplete();

int _createCallbackTask();

static void onDmaTransferComplete(void*);
int _installDriver();
void _uninstallDriver();
void _setSckPin(int sckPin);
void _setFsPin(int fsPin);
void _setDataPin(int sdPin);
void _setDataOutPin(int outSdPin);
void _setDataInPin(int inSdPin);
int _applyPinSetting();

private:
typedef enum {
I2S_STATE_IDLE,
I2S_STATE_TRANSMITTER,
I2S_STATE_RECEIVER,
I2S_STATE_DUPLEX
} i2s_state_t;

int _deviceIndex;
int _sdPin;
int _inSdPin;
int _outSdPin;
int _sckPin;
int _fsPin;

i2s_state_t _state;
int _bitsPerSample;
uint32_t _sampleRate;
int _mode;

uint16_t _buffer_byte_size;

bool _driverInstalled; // Is IDF I2S driver installed?
bool _initialized; // Is everything initialized (callback task, I2S driver, ring buffers)?
TaskHandle_t _callbackTaskHandle;
QueueHandle_t _i2sEventQueue;
SemaphoreHandle_t _i2s_general_mutex;
RingbufHandle_t _input_ring_buffer;
RingbufHandle_t _output_ring_buffer;
int _i2s_dma_buffer_size;
bool _driveClock;
uint32_t _peek_buff;
bool _peek_buff_valid;

void _tx_done_routine(uint8_t* prev_item);
void _rx_done_routine();

uint16_t _nesting_counter;
void _take_if_not_holding();
void _give_if_top_call();
void _post_read_data_fix(void *input, size_t *size);
void _fix_and_write(void *output, size_t size, size_t *bytes_written = NULL, size_t *actual_bytes_written = NULL);

void (*_onTransmit)(void);
void (*_onReceive)(void);
};

extern I2SClass I2S;

#endif
88 changes: 88 additions & 0 deletions libraries/WiFi/src/WiFiGeneric.cpp
Original file line number Diff line number Diff line change
@@ -1192,6 +1192,94 @@ bool WiFiGenericClass::initiateFTM(uint8_t frm_count, uint16_t burst_period, uin
return true;
}

/**
* Configure Dual antenna.
* @param gpio_ant1 Configure the GPIO number for the antenna 1 connected to the RF switch (default GPIO2 on ESP32-WROOM-DA)
* @param gpio_ant2 Configure the GPIO number for the antenna 2 connected to the RF switch (default GPIO25 on ESP32-WROOM-DA)
* @param rx_mode Set the RX antenna mode. See wifi_rx_ant_t for the options.
* @param tx_mode Set the TX antenna mode. See wifi_tx_ant_t for the options.
* @return true on success
*/
bool WiFiGenericClass::setDualAntennaConfig(uint8_t gpio_ant1, uint8_t gpio_ant2, wifi_rx_ant_t rx_mode, wifi_tx_ant_t tx_mode) {

wifi_ant_gpio_config_t wifi_ant_io;

if (ESP_OK != esp_wifi_get_ant_gpio(&wifi_ant_io)) {
log_e("Failed to get antenna configuration");
return false;
}

wifi_ant_io.gpio_cfg[0].gpio_num = gpio_ant1;
wifi_ant_io.gpio_cfg[0].gpio_select = 1;
wifi_ant_io.gpio_cfg[1].gpio_num = gpio_ant2;
wifi_ant_io.gpio_cfg[1].gpio_select = 1;

if (ESP_OK != esp_wifi_set_ant_gpio(&wifi_ant_io)) {
log_e("Failed to set antenna GPIO configuration");
return false;
}

// Set antenna default configuration
wifi_ant_config_t ant_config = {
.rx_ant_mode = WIFI_ANT_MODE_AUTO,
.tx_ant_mode = WIFI_ANT_MODE_AUTO,
.enabled_ant0 = 0,
.enabled_ant1 = 1,
};

switch (rx_mode)
{
case WIFI_RX_ANT0:
ant_config.rx_ant_mode = WIFI_ANT_MODE_ANT0;
break;
case WIFI_RX_ANT1:
ant_config.rx_ant_mode = WIFI_ANT_MODE_ANT1;
break;
case WIFI_RX_ANT_AUTO:
log_i("TX Antenna will be automatically selected");
ant_config.rx_ant_default = WIFI_ANT_ANT0;
ant_config.rx_ant_mode = WIFI_ANT_MODE_AUTO;
// Force TX for AUTO if RX is AUTO
ant_config.tx_ant_mode = WIFI_ANT_MODE_AUTO;
goto set_ant;
break;
default:
log_e("Invalid default antenna! Falling back to AUTO");
ant_config.rx_ant_mode = WIFI_ANT_MODE_AUTO;
break;
}

switch (tx_mode)
{
case WIFI_TX_ANT0:
ant_config.tx_ant_mode = WIFI_ANT_MODE_ANT0;
break;
case WIFI_TX_ANT1:
ant_config.tx_ant_mode = WIFI_ANT_MODE_ANT1;
break;
case WIFI_TX_ANT_AUTO:
log_i("RX Antenna will be automatically selected");
ant_config.rx_ant_default = WIFI_ANT_ANT0;
ant_config.tx_ant_mode = WIFI_ANT_MODE_AUTO;
// Force RX for AUTO if RX is AUTO
ant_config.rx_ant_mode = WIFI_ANT_MODE_AUTO;
break;
default:
log_e("Invalid default antenna! Falling back to AUTO");
ant_config.rx_ant_default = WIFI_ANT_ANT0;
ant_config.tx_ant_mode = WIFI_ANT_MODE_AUTO;
break;
}

set_ant:
if (ESP_OK != esp_wifi_set_ant(&ant_config)) {
log_e("Failed to set antenna configuration");
return false;
}

return true;
}

// -----------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------ Generic Network function ---------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------
14 changes: 14 additions & 0 deletions libraries/WiFi/src/WiFiGeneric.h
Original file line number Diff line number Diff line change
@@ -139,6 +139,18 @@ static const int WIFI_SCAN_DONE_BIT= BIT12;
static const int WIFI_DNS_IDLE_BIT = BIT13;
static const int WIFI_DNS_DONE_BIT = BIT14;

typedef enum {
WIFI_RX_ANT0 = 0,
WIFI_RX_ANT1,
WIFI_RX_ANT_AUTO
} wifi_rx_ant_t;

typedef enum {
WIFI_TX_ANT0 = 0,
WIFI_TX_ANT1,
WIFI_TX_ANT_AUTO
} wifi_tx_ant_t;

class WiFiGenericClass
{
public:
@@ -174,6 +186,8 @@ class WiFiGenericClass

bool initiateFTM(uint8_t frm_count=16, uint16_t burst_period=2, uint8_t channel=1, const uint8_t * mac=NULL);

bool setDualAntennaConfig(uint8_t gpio_ant1, uint8_t gpio_ant2, wifi_rx_ant_t rx_mode, wifi_tx_ant_t tx_mode);

static const char * getHostname();
static bool setHostname(const char * hostname);
static bool hostname(const String& aHostname) { return setHostname(aHostname.c_str()); }
73 changes: 73 additions & 0 deletions variants/adafruit_feather_esp32_v2/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <stdint.h>

#define EXTERNAL_NUM_INTERRUPTS 16
#define NUM_DIGITAL_PINS 40
#define NUM_ANALOG_INPUTS 16

#define analogInputToDigitalPin(p) (((p)<20)?(esp32_adc2gpio[(p)]):-1)
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
#define digitalPinHasPWM(p) (p < 34)

static const uint8_t LED_BUILTIN = 13;
#define BUILTIN_LED LED_BUILTIN // backward compatibility
#define LED_BUILTIN LED_BUILTIN

static const uint8_t TX = 7;
static const uint8_t RX = 8;
static const uint8_t TX1 = 7;
static const uint8_t RX1 = 8;

static const uint8_t SDA = 22;
static const uint8_t SCL = 20;

static const uint8_t SS = 33;
static const uint8_t MOSI = 19;
static const uint8_t MISO = 21;
static const uint8_t SCK = 5;

// mapping to match other feathers and also in order
static const uint8_t A0 = 26;
static const uint8_t A1 = 25;
static const uint8_t A2 = 34;
static const uint8_t A3 = 39;
static const uint8_t A4 = 36;
static const uint8_t A5 = 4;
static const uint8_t A6 = 14;
static const uint8_t A7 = 32;
static const uint8_t A8 = 15;
static const uint8_t A9 = 33;
static const uint8_t A10 = 27;
static const uint8_t A11 = 12;
static const uint8_t A12 = 13;

// vbat measure
static const uint8_t BATT_MONITOR = 35;
static const uint8_t A13 = 35;

// internal switch
static const uint8_t BUTTON = 38;

// Neopixel
static const uint8_t NEOPIXEL_PIN = 0;

// Neopixel & I2C power
static const uint8_t NEOPIXEL_I2C_POWER = 2;

static const uint8_t T0 = 4;
static const uint8_t T1 = 0;
static const uint8_t T2 = 2;
static const uint8_t T3 = 15;
static const uint8_t T4 = 13;
static const uint8_t T5 = 12;
static const uint8_t T6 = 14;
static const uint8_t T7 = 27;
static const uint8_t T8 = 33;
static const uint8_t T9 = 32;

static const uint8_t DAC1 = 25;
static const uint8_t DAC2 = 26;

#endif /* Pins_Arduino_h */
40 changes: 40 additions & 0 deletions variants/adafruit_feather_esp32_v2/variant.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2021 Ha Thach (tinyusb.org) for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/


#include "esp32-hal-gpio.h"
#include "pins_arduino.h"

extern "C" {

// Initialize variant/board, called before setup()
void initVariant(void)
{
// This board has a power control pin, and we must set it to output and high
// in order to enable the NeoPixels & I2C
pinMode(NEOPIXEL_I2C_POWER, OUTPUT);
digitalWrite(NEOPIXEL_I2C_POWER, HIGH);
}

}
1 change: 1 addition & 0 deletions variants/adafruit_feather_esp32s2/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@
#define NEOPIXEL_POWER 21 // power pin
#define NEOPIXEL_POWER_ON HIGH // power pin state when on
#define I2C_POWER 7 // I2C power pin
#define PIN_I2C_POWER 7 // I2C power pin

static const uint8_t SDA = 3;
static const uint8_t SCL = 4;
8 changes: 4 additions & 4 deletions variants/adafruit_qtpy_esp32/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -11,14 +11,14 @@
#define digitalPinToInterrupt(p) (((p)<40)?(p):-1)
#define digitalPinHasPWM(p) (p < 34)

static const uint8_t NEOPIXEL = 5;
static const uint8_t PIN_NEOPIXEL = 5;
static const uint8_t NEOPIXEL_POWER = 8;

static const uint8_t TX = 32;
static const uint8_t RX = 7;

static const uint8_t TX1 = 32;
static const uint8_t RX1 = 7;
#define TX1 32
#define RX1 7

static const uint8_t SDA = 25;
static const uint8_t SCL = 33;
@@ -43,7 +43,7 @@ static const uint8_t A8 = 14;
static const uint8_t A9 = 12;
static const uint8_t A10 = 13;

static const uint8_t SWITCH = 0;
static const uint8_t BUTTON = 0;

static const uint8_t T0 = 4;
static const uint8_t T3 = 15;
40 changes: 40 additions & 0 deletions variants/adafruit_qtpy_esp32/variant.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2021 Ha Thach (tinyusb.org) for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/


#include "esp32-hal-gpio.h"
#include "pins_arduino.h"

extern "C" {

// Initialize variant/board, called before setup()
void initVariant(void)
{
// This board has a power control pin, and we must set it to output and high
// in order to enable the NeoPixels.
pinMode(NEOPIXEL_POWER, OUTPUT);
digitalWrite(NEOPIXEL_POWER, HIGH);
}

}
34 changes: 34 additions & 0 deletions variants/adafruit_qtpy_esp32c3/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <stdint.h>

#define EXTERNAL_NUM_INTERRUPTS 22
#define NUM_DIGITAL_PINS 22
#define NUM_ANALOG_INPUTS 6

#define analogInputToDigitalPin(p) (((p)<NUM_ANALOG_INPUTS)?(esp32_adc2gpio[(p)]):-1)
#define digitalPinToInterrupt(p) (((p)<NUM_DIGITAL_PINS)?(p):-1)
#define digitalPinHasPWM(p) (p < EXTERNAL_NUM_INTERRUPTS)

static const uint8_t SWITCH = 9;
static const uint8_t NEOPIXEL_PIN = 2;

static const uint8_t TX = 21;
static const uint8_t RX = 20;

static const uint8_t SDA = 5;
static const uint8_t SCL = 6;

static const uint8_t SS = 6;
static const uint8_t MOSI = 7;
static const uint8_t MISO = 8;
static const uint8_t SCK = 10;

static const uint8_t A0 = 4;
static const uint8_t A1 = 3;
static const uint8_t A2 = 1;
static const uint8_t A3 = 0;
static const uint8_t A4 = 5;

#endif /* Pins_Arduino_h */
3 changes: 1 addition & 2 deletions variants/feather_esp32/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -45,14 +45,13 @@ static const uint8_t A11 = 12;
static const uint8_t A12 = 13;

// vbat measure
static const uint8_t BATT_MONITOR = 35;
static const uint8_t A13 = 35;
//static const uint8_t Ax = 0; // not used/available
//static const uint8_t Ax = 2; // not used/available


static const uint8_t T0 = 4;
static const uint8_t T1 = 0;
static const uint8_t T2 = 2;
static const uint8_t T3 = 15;
static const uint8_t T4 = 13;
static const uint8_t T5 = 12;