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