diff --git a/src/AudioAnalog/AnalogAudioESP32V1.h b/src/AudioAnalog/AnalogAudioESP32V1.h index 69e965afb9..9e9025cd9a 100644 --- a/src/AudioAnalog/AnalogAudioESP32V1.h +++ b/src/AudioAnalog/AnalogAudioESP32V1.h @@ -4,22 +4,12 @@ #if defined(ESP32) && defined(USE_ANALOG) && \ ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) || \ defined(DOXYGEN) + +#include "AudioAnalog/AnalogConfigESP32V1.h" #include "AudioAnalog/AnalogAudioBase.h" #include "AudioTools/AudioStreams.h" #include "AudioTools/AudioStreamsConverter.h" -#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 -#define AUDIO_ADC_OUTPUT_TYPE ADC_DIGI_OUTPUT_FORMAT_TYPE1 -#define AUDIO_ADC_GET_CHANNEL(p_data) ((p_data)->type1.channel) -#define AUDIO_ADC_GET_DATA(p_data) ((p_data)->type1.data) -#else -#define AUDIO_ADC_OUTPUT_TYPE ADC_DIGI_OUTPUT_FORMAT_TYPE2 -#define AUDIO_ADC_GET_CHANNEL(p_data) ((p_data)->type2.channel) -#define AUDIO_ADC_GET_DATA(p_data) ((p_data)->type2.data) -#endif -#define GET_UNIT(x) ((x >> 3) & 0x1) - - namespace audio_tools { diff --git a/src/AudioAnalog/AnalogConfigESP32V1.h b/src/AudioAnalog/AnalogConfigESP32V1.h index 698e67dfc5..68147b1db9 100644 --- a/src/AudioAnalog/AnalogConfigESP32V1.h +++ b/src/AudioAnalog/AnalogConfigESP32V1.h @@ -7,25 +7,36 @@ #include "esp_adc/adc_cali_scheme.h" #if CONFIG_IDF_TARGET_ESP32 -#define ADC_CONV_MODE ADC_CONV_SINGLE_UNIT_1 // ADC2 and Wifi work together -#define ADC_OUTPUT_TYPE ADC_DIGI_OUTPUT_FORMAT_TYPE1 -#define ADC_CHANNELS {ADC_CHANNEL_6, ADC_CHANNEL_7} -#define HAS_ESP32_DAC +# define ADC_CONV_MODE ADC_CONV_SINGLE_UNIT_1 // ADC2 and Wifi work together +# define ADC_OUTPUT_TYPE ADC_DIGI_OUTPUT_FORMAT_TYPE1 +# define ADC_CHANNELS {ADC_CHANNEL_6, ADC_CHANNEL_7} +# define AUDIO_ADC_GET_CHANNEL(p_data) ((p_data)->type1.channel) +# define AUDIO_ADC_GET_DATA(p_data) ((p_data)->type1.data) +# define HAS_ESP32_DAC #elif CONFIG_IDF_TARGET_ESP32S2 -#define ADC_CONV_MODE ADC_CONV_SINGLE_UNIT_1 // ADC2 competes with WiFi and WiFi has priority, ADC_CONV_BOTH_UNIT -#define ADC_OUTPUT_TYPE ADC_DIGI_OUTPUT_FORMAT_TYPE2 -#define ADC_CHANNELS {ADC_CHANNEL_2, ADC_CHANNEL_3} -#define HAS_ESP32_DAC +# define ADC_CONV_MODE ADC_CONV_SINGLE_UNIT_1 // ADC2 competes with WiFi and WiFi has priority, ADC_CONV_BOTH_UNIT +# define ADC_OUTPUT_TYPE ADC_DIGI_OUTPUT_FORMAT_TYPE2 +# define AUDIO_ADC_GET_CHANNEL(p_data) ((p_data)->type2.channel) +# define AUDIO_ADC_GET_DATA(p_data) ((p_data)->type2.data) +# define ADC_CHANNELS {ADC_CHANNEL_2, ADC_CHANNEL_3} +# define HAS_ESP32_DAC #elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6 -#define ADC_CONV_MODE ADC_CONV_ALTER_UNIT //ESP32C3 only supports alter mode -#define ADC_OUTPUT_TYPE ADC_DIGI_OUTPUT_FORMAT_TYPE2 -#define ADC_CHANNELS {ADC_CHANNEL_2, ADC_CHANNEL_3} +# define ADC_CONV_MODE ADC_CONV_ALTER_UNIT //ESP32C3 only supports alter mode +# define ADC_OUTPUT_TYPE ADC_DIGI_OUTPUT_FORMAT_TYPE2 +# define AUDIO_ADC_GET_CHANNEL(p_data) ((p_data)->type2.channel) +# define AUDIO_ADC_GET_DATA(p_data) ((p_data)->type2.data) +# define ADC_CHANNELS {ADC_CHANNEL_2, ADC_CHANNEL_3} #elif CONFIG_IDF_TARGET_ESP32S3 -#define ADC_CONV_MODE ADC_CONV_SINGLE_UNIT_1 // ADC2 competes with WiFi and WiFi has priority -#define ADC_OUTPUT_TYPE ADC_DIGI_OUTPUT_FORMAT_TYPE2 -#define ADC_CHANNELS {ADC_CHANNEL_2, ADC_CHANNEL_3} // These are the I2C SDA and SCL pins on Adafruit ESP32-S3 feather , Channel 4&5 might be better +# define ADC_CONV_MODE ADC_CONV_SINGLE_UNIT_1 // ADC2 competes with WiFi and WiFi has priority +# define ADC_OUTPUT_TYPE ADC_DIGI_OUTPUT_FORMAT_TYPE2 +# define AUDIO_ADC_GET_CHANNEL(p_data) ((p_data)->type2.channel) +# define AUDIO_ADC_GET_DATA(p_data) ((p_data)->type2.data) +# define ADC_CHANNELS {ADC_CHANNEL_2, ADC_CHANNEL_3} // These are the I2C SDA and SCL pins on Adafruit ESP32-S3 feather , Channel 4&5 might be better #endif +#define GET_UNIT(x) ((x >> 3) & 0x1) + + #ifdef HAS_ESP32_DAC # include "driver/dac_continuous.h" #endif