arduino-audio-tools
Loading...
Searching...
No Matches
esp32.h
Go to the documentation of this file.
1#pragma once
2
3# ifdef ARDUINO
4# include "esp32-hal-log.h"
5# endif
6
7//-------ESP32---------
8#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32)
9// the regular ESP32
10# define ESP32_CORE
11#endif
12#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32S2)
13# define ESP32S2
14# define ESP32X
15#endif
16#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32S3)
17# define ESP32S3
18# define ESP32X
19# define USE_TDM
20# define USE_PDM
21# define USE_PDM_RX
22#endif
23#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32S31)
24# define ESP32S31
25# define ESP32S3
26# define ESP32X
27# define USE_TDM
28# define USE_PDM
29# define USE_PDM_RX
30#endif
31#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32C3)
32# define ESP32C3
33# define ESP32X
34# define USE_INT24_FROM_INT
35# define USE_TDM
36# define USE_PDM
37#endif
38#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32C5)
39# define ESP32C5
40# define ESP32X
41# define USE_TDM
42# define USE_PDM
43#endif
44#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32C6)
45# define ESP32C6
46# define ESP32X
47# define USE_TDM
48# define USE_PDM
49#endif
50#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32P4)
51# define ESP32P4
52# define ESP32X
53# define USE_TDM
54# define USE_PDM
55# define USE_PDM_RX
56#endif
57#if defined(ESP32) && defined(CONFIG_IDF_TARGET_ESP32H2)
58# define ESP32H2
59#endif
60
61//-------I2S Version -----------------------------------------------
62#ifndef USE_LEGACY_I2S
63# define USE_LEGACY_I2S (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0))
64#endif
65
66
67//-------Config for ESP32 families ---------
68#if defined(ESP32)
69# define USE_PSRAM
70# define USE_STRTOD
71# define USE_INITIALIZER_LIST
72// We need to use accept instead of available
73# if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
74# define USE_SERVER_ACCEPT true
75# endif
76# if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
77# define USE_CONCURRENCY
78// Print has been fixed
79# define USE_PRINT_FLUSH true
80# else
81# define USE_PRINT_FLUSH false
82# endif
83# define USE_SD_SUPPORTS_SPI
84//# define USE_ESP32_LOGGER true
85# if !defined(ARDUINO)
86# define USE_IDF_LOGGER
87# endif
88# if !defined(I2S_USE_APLL)
89# define I2S_USE_APLL false
90# endif
91// use ESP_DSP library for ouput mixing
92//# define USE_ESP32_DSP
93#endif
94
95// ----- Regular ESP32 -----
96#if defined(ESP32_CORE)
97
98#if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0 , 0)
99# define USE_INT24_FROM_INT
100# define USE_PDM
101#endif
102
103#define USE_ANALOG
104#define USE_I2S
105#define USE_PDM_RX
106
107#ifdef ARDUINO
108# define USE_WIFI
109# define USE_WIFI_CLIENT_SECURE
110# define USE_URL_ARDUINO
111# define USE_AUDIO_SERVER
112# define USE_TOUCH_READ
113#endif
114
115#define USE_PWM
116#define USE_TIMER
117#define USE_TYPETRAITS
118#define USE_STREAM_WRITE_OVERRIDE
119#define USE_STREAM_READ_OVERRIDE
120#define USE_EXT_BUTTON_LOGIC
121// support for psram -> set to true
122#define USE_ALLOCATOR true
123#define HAS_IOSTRAM
124#define USE_TASK false
125
126#define PWM_FREQENCY 30000
127#define PIN_PWM_START 12
128#define PIN_I2S_BCK 14
129#define PIN_I2S_WS 15
130#define PIN_I2S_DATA_IN 32
131#define PIN_I2S_DATA_OUT 22
132#define PIN_I2S_MCK -1
133// Default Setting: The mute pin can be switched actovated by setting it to a gpio (e.g 23). Or you could drive the LED by assigning LED_BUILTIN
134#define PIN_I2S_MUTE -1
135#define SOFT_MUTE_VALUE 0
136#define PIN_CS SS
137#define PIN_ADC1 34
138
139#define I2S_AUTO_CLEAR true
140
141// URLStream
142#define URL_STREAM_CORE 0
143#define URL_STREAM_PRIORITY 2
144#define URL_STREAM_BUFFER_COUNT 10
145#define STACK_SIZE 30000
146#define URL_CLIENT_TIMEOUT 60000;
147#define URL_HANDSHAKE_TIMEOUT 120000
148
149// // Default LED
150// #ifndef LED_BUILTIN
151// # define LED_BUILTIN 13 // pin number is specific to your esp32 board
152// #endif
153
154// support for old idf releases
155#if ESP_IDF_VERSION_MAJOR < 4 && !defined(I2S_COMM_FORMAT_STAND_I2S)
156# define I2S_COMM_FORMAT_STAND_I2S (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB)
157# define I2S_COMM_FORMAT_STAND_MSB (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_LSB)
158# define I2S_COMM_FORMAT_STAND_PCM_LONG (I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_LONG)
159# define I2S_COMM_FORMAT_STAND_PCM_SHORT (I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_SHORT)
160
161typedef int eps32_i2s_sample_rate_type;
162#else
163typedef uint32_t eps32_i2s_sample_rate_type;
164#endif
165
166#endif
167
168//-------ESP32C3, ESP32S3, ESP32S2---------
169
170#if defined(ESP32X)
171# if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0 , 0)
172# define USE_INT24_FROM_INT
173# define USE_ANALOG
174# endif
175
176#define USE_PWM
177#define USE_URL_ARDUINO
178#define USE_WIFI
179#define USE_WIFI_CLIENT_SECURE
180#define USE_I2S
181#define USE_AUDIO_SERVER
182#define USE_TYPETRAITS
183#define USE_TIMER
184#define USE_STREAM_WRITE_OVERRIDE
185#define USE_STREAM_READ_OVERRIDE
186// support for psram -> set to true
187#define USE_ALLOCATOR true
188
189#define PWM_FREQENCY 30000
190#define PIN_PWM_START 1
191#define PIN_I2S_MCK -1
192#define PIN_I2S_BCK 6
193#define PIN_I2S_WS 7
194#define PIN_I2S_DATA_OUT 8
195#define PIN_I2S_DATA_IN 9
196// Default Setting: The mute pin can be switched actovated by setting it to a gpio (e.g 5). Or you could drive the LED by assigning LED_BUILTIN
197#define PIN_I2S_MUTE -1
198#define SOFT_MUTE_VALUE 0
199#define PIN_CS SS
200#define PIN_ADC1 21
201
202#define I2S_AUTO_CLEAR true
203
204// URLStream
205//#define USE_ESP8266_AUDIO
206#define URL_STREAM_CORE 0
207#define URL_STREAM_PRIORITY 2
208#define URL_STREAM_BUFFER_COUNT 10
209#define STACK_SIZE 30000
210#define URL_CLIENT_TIMEOUT 60000;
211#define URL_HANDSHAKE_TIMEOUT 120000
212
213// // Default LED
214// #ifndef LED_BUILTIN
215// # define LED_BUILTIN 13 // pin number is specific to your esp32 board
216// #endif
217
218typedef uint32_t eps32_i2s_sample_rate_type;
219
220#endif
221
222//-------ESP32H2---------
223
224#if defined(ESP32H2)
225#include "esp32-hal-log.h"
226#if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0 , 0)
227# define USE_INT24_FROM_INT
228# define USE_ANALOG
229#endif
230
231#define ESP32H2
232#define USE_TDM
233#define USE_PWM
234#define USE_I2S
235#define USE_PDM
236#define USE_TYPETRAITS
237#define USE_TIMER
238#define USE_STREAM_WRITE_OVERRIDE
239#define USE_STREAM_READ_OVERRIDE
240// support for psram -> set to true
241#define USE_ALLOCATOR true
242//#define USE_INITIALIZER_LIST
243
244#define PWM_FREQENCY 30000
245#define PIN_PWM_START 1
246#define PIN_I2S_MCK -1
247#define PIN_I2S_BCK 6
248#define PIN_I2S_WS 7
249#define PIN_I2S_DATA_OUT 8
250#define PIN_I2S_DATA_IN 9
251// Default Setting: The mute pin can be switched actovated by setting it to a gpio (e.g 5). Or you could drive the LED by assigning LED_BUILTIN
252#define PIN_I2S_MUTE -1
253#define SOFT_MUTE_VALUE 0
254#define PIN_CS SS
255#define PIN_ADC1 21
256#define I2S_AUTO_CLEAR true
257
258typedef uint32_t eps32_i2s_sample_rate_type;
259
260#endif