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