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