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