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