bugfix(i2s): Updated ESP32-S2 ADC DAC support

* Delete the relevant codes of ADC DAC of ESP32-S2.
This commit is contained in:
xiongyu
2020-02-20 16:00:48 +08:00
parent 3ad5138dd8
commit b3ae9fa978
11 changed files with 96 additions and 87 deletions

View File

@@ -2,6 +2,6 @@
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
set(SUPPORTED_TARGETS esp32 esp32s2beta)
set(SUPPORTED_TARGETS esp32)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(i2s-adc-dac)

View File

@@ -9,9 +9,7 @@
#include "driver/i2s.h"
#include "driver/adc.h"
#include "audio_example_file.h"
#ifdef CONFIG_IDF_TARGET_ESP32
#include "esp_adc_cal.h"
#endif
static const char* TAG = "ad/da";
#define V_REF 1100
@@ -272,17 +270,11 @@ void adc_read_task(void* arg)
{
adc1_config_width(ADC_WIDTH_12Bit);
adc1_config_channel_atten(ADC1_TEST_CHANNEL, ADC_ATTEN_11db);
#ifdef CONFIG_IDF_TARGET_ESP32
esp_adc_cal_characteristics_t characteristics;
esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_12, V_REF, &characteristics);
#endif
while(1) {
uint32_t voltage;
#ifdef CONFIG_IDF_TARGET_ESP32
esp_adc_cal_get_voltage(ADC1_TEST_CHANNEL, &characteristics, &voltage);
#else
voltage = adc1_get_raw(ADC1_TEST_CHANNEL) * (3300.0 / 4095); // At 11 dB attenuation the maximum voltage is limited by VDD_A(3300 mV), not the full scale voltage.
#endif
ESP_LOGI(TAG, "%d mV", voltage);
vTaskDelay(200 / portTICK_RATE_MS);
}