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_CLIENT_TIMEOUT 60000;
152#define URL_HANDSHAKE_TIMEOUT 120000
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_CLIENT_TIMEOUT 60000;
216#define URL_HANDSHAKE_TIMEOUT 120000
217
218// // Default LED
219// #ifndef LED_BUILTIN
220// # define LED_BUILTIN 13 // pin number is specific to your esp32 board
221// #endif
222
223typedef uint32_t eps32_i2s_sample_rate_type;
224
225#endif
226
227//-------ESP32H2---------
228
229#if defined(ESP32H2)
230#include "esp32-hal-log.h"
231#if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0 , 0)
232# define USE_INT24_FROM_INT
233# define USE_ANALOG
234#endif
235
236#define ESP32H2
237#define USE_TDM
238#define USE_PWM
239#define USE_I2S
240#define USE_PDM
241#define USE_TYPETRAITS
242#define USE_TIMER
243#define USE_STREAM_WRITE_OVERRIDE
244#define USE_STREAM_READ_OVERRIDE
245// support for psram -> set to true
246#define USE_ALLOCATOR true
247//#define USE_INITIALIZER_LIST
248
249#define PWM_FREQENCY 30000
250#define PIN_PWM_START 1
251#define PIN_I2S_MCK -1
252#define PIN_I2S_BCK 6
253#define PIN_I2S_WS 7
254#define PIN_I2S_DATA_OUT 8
255#define PIN_I2S_DATA_IN 9
256// 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
257#define PIN_I2S_MUTE -1
258#define SOFT_MUTE_VALUE 0
259#define PIN_CS SS
260#define PIN_ADC1 21
261#define I2S_AUTO_CLEAR true
262
263typedef uint32_t eps32_i2s_sample_rate_type;
264
265#endif