Merge branch 'bugfix/fix_wrong_adc_attenuation_name_v5.2' into 'release/v5.2'

fix(adc): rename ADC_ATTEN_DB_11 to ADC_ATTEN_DB_12 (v5.2)

See merge request espressif/esp-idf!26966
This commit is contained in:
morris 2023-11-08 14:50:30 +08:00
commit 02cacc6e05
33 changed files with 68 additions and 67 deletions

View File

@ -56,7 +56,7 @@ esp_pm_lock_handle_t adc_digi_arbiter_lock = NULL;
ESP32 Depricated ADC APIs and functions ESP32 Depricated ADC APIs and functions
---------------------------------------------------------------*/ ---------------------------------------------------------------*/
#define DIG_ADC_OUTPUT_FORMAT_DEFUALT (ADC_DIGI_FORMAT_12BIT) #define DIG_ADC_OUTPUT_FORMAT_DEFUALT (ADC_DIGI_FORMAT_12BIT)
#define DIG_ADC_ATTEN_DEFUALT (ADC_ATTEN_DB_11) #define DIG_ADC_ATTEN_DEFUALT (ADC_ATTEN_DB_12)
#define DIG_ADC_BIT_WIDTH_DEFUALT (3) //3 for ADC_WIDTH_BIT_12 #define DIG_ADC_BIT_WIDTH_DEFUALT (3) //3 for ADC_WIDTH_BIT_12
/** /**

View File

@ -802,7 +802,7 @@ int adc1_get_raw(adc1_channel_t channel)
esp_err_t adc2_config_channel_atten(adc2_channel_t channel, adc_atten_t atten) esp_err_t adc2_config_channel_atten(adc2_channel_t channel, adc_atten_t atten)
{ {
ESP_RETURN_ON_FALSE(channel < SOC_ADC_CHANNEL_NUM(ADC_UNIT_2), ESP_ERR_INVALID_ARG, ADC_TAG, "ADC2 channel error"); ESP_RETURN_ON_FALSE(channel < SOC_ADC_CHANNEL_NUM(ADC_UNIT_2), ESP_ERR_INVALID_ARG, ADC_TAG, "ADC2 channel error");
ESP_RETURN_ON_FALSE((atten <= ADC_ATTEN_DB_11), ESP_ERR_INVALID_ARG, ADC_TAG, "ADC2 Atten Err"); ESP_RETURN_ON_FALSE((atten <= ADC_ATTEN_DB_12), ESP_ERR_INVALID_ARG, ADC_TAG, "ADC2 Atten Err");
esp_err_t ret = ESP_OK; esp_err_t ret = ESP_OK;
s_atten2_single[channel] = atten; s_atten2_single[channel] = atten;

View File

@ -33,7 +33,7 @@
#define ADC_TEST_WIDTH ADC_BITWIDTH_13 #define ADC_TEST_WIDTH ADC_BITWIDTH_13
#endif #endif
#define ADC_TEST_ATTEN ADC_ATTEN_DB_11 #define ADC_TEST_ATTEN ADC_ATTEN_DB_12
TEST_CASE("DAC_API_basic_logic_test", "[dac]") TEST_CASE("DAC_API_basic_logic_test", "[dac]")
{ {

View File

@ -28,7 +28,7 @@ static const char *TAG = "test_dac";
#elif defined CONFIG_IDF_TARGET_ESP32S2 #elif defined CONFIG_IDF_TARGET_ESP32S2
#define ADC_TEST_WIDTH ADC_WIDTH_BIT_13 //ESP32S2 only support 13 bit width #define ADC_TEST_WIDTH ADC_WIDTH_BIT_13 //ESP32S2 only support 13 bit width
#endif #endif
#define ADC_TEST_ATTEN ADC_ATTEN_DB_11 #define ADC_TEST_ATTEN ADC_ATTEN_DB_12
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32
#define ADC_TEST_CHANNEL_NUM ADC2_CHANNEL_8 // GPIO25 #define ADC_TEST_CHANNEL_NUM ADC2_CHANNEL_8 // GPIO25
@ -174,8 +174,8 @@ TEST_CASE("esp32s2_adc2-dac_with_adc2_calibration", "[dac_legacy]")
subtest_adc_dac(1250, &chars); subtest_adc_dac(1250, &chars);
printf("Test 11dB atten...\n"); printf("Test 11dB atten...\n");
adc2_config_channel_atten((adc2_channel_t)ADC_TEST_CHANNEL_NUM, ADC_ATTEN_DB_11); adc2_config_channel_atten((adc2_channel_t)ADC_TEST_CHANNEL_NUM, ADC_ATTEN_DB_12);
esp_adc_cal_characterize(ADC_UNIT_2, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_13, 0, &chars); esp_adc_cal_characterize(ADC_UNIT_2, ADC_ATTEN_DB_12, ADC_WIDTH_BIT_13, 0, &chars);
printf("a %"PRIu32", b %"PRIu32"\n", chars.coeff_a, chars.coeff_b); printf("a %"PRIu32", b %"PRIu32"\n", chars.coeff_a, chars.coeff_b);
subtest_adc_dac(1500, &chars); subtest_adc_dac(1500, &chars);
subtest_adc_dac(2500, &chars); subtest_adc_dac(2500, &chars);

View File

@ -114,7 +114,7 @@ TEST_CASE("I2S_adc_test", "[i2s_legacy]")
i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL); i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
// init ADC pad // init ADC pad
i2s_set_adc_mode(ADC_UNIT_1, ADC1_CHANNEL_4); i2s_set_adc_mode(ADC_UNIT_1, ADC1_CHANNEL_4);
// enable adc sampling, ADC_WIDTH_BIT_12, ADC_ATTEN_DB_11 hard-coded in adc_i2s_mode_init // enable adc sampling, ADC_WIDTH_BIT_12, ADC_ATTEN_DB_12 hard-coded in adc_i2s_mode_init
i2s_adc_enable(I2S_NUM_0); i2s_adc_enable(I2S_NUM_0);
// init read buffer // init read buffer
uint16_t *i2sReadBuffer = (uint16_t *)calloc(1024, sizeof(uint16_t)); uint16_t *i2sReadBuffer = (uint16_t *)calloc(1024, sizeof(uint16_t));

View File

@ -110,10 +110,10 @@ TEST_CASE("Legacy ADC oneshot high/low test", "[legacy_adc_oneshot]")
int adc_raw = 0; int adc_raw = 0;
//ADC1 config //ADC1 config
TEST_ESP_OK(adc1_config_width(ADC_WIDTH_BIT_DEFAULT)); TEST_ESP_OK(adc1_config_width(ADC_WIDTH_BIT_DEFAULT));
TEST_ESP_OK(adc1_config_channel_atten(ADC1_TEST_CHAN0, ADC_ATTEN_DB_11)); TEST_ESP_OK(adc1_config_channel_atten(ADC1_TEST_CHAN0, ADC_ATTEN_DB_12));
#if ADC_TEST_ADC2 #if ADC_TEST_ADC2
//ADC2 config //ADC2 config
TEST_ESP_OK(adc2_config_channel_atten(ADC2_TEST_CHAN0, ADC_ATTEN_DB_11)); TEST_ESP_OK(adc2_config_channel_atten(ADC2_TEST_CHAN0, ADC_ATTEN_DB_12));
#endif #endif
test_adc_set_io_level(ADC_UNIT_1, (adc1_channel_t)ADC1_TEST_CHAN0, 0); test_adc_set_io_level(ADC_UNIT_1, (adc1_channel_t)ADC1_TEST_CHAN0, 0);

View File

@ -28,12 +28,12 @@ uint32_t esp_efuse_rtc_calib_get_init_code(int version, uint32_t adc_unit, int a
{ {
assert((version >= ESP_EFUSE_ADC_CALIB_VER_MIN) && assert((version >= ESP_EFUSE_ADC_CALIB_VER_MIN) &&
(version <= ESP_EFUSE_ADC_CALIB_VER_MAX)); (version <= ESP_EFUSE_ADC_CALIB_VER_MAX));
assert(atten <= ADC_ATTEN_DB_11); assert(atten <= ADC_ATTEN_DB_12);
(void) adc_unit; (void) adc_unit;
if (atten == ADC_ATTEN_DB_2_5 || atten == ADC_ATTEN_DB_6) { if (atten == ADC_ATTEN_DB_2_5 || atten == ADC_ATTEN_DB_6) {
/** /**
* - ESP32C2 only supports HW calibration on ADC_ATTEN_DB_0 and ADC_ATTEN_DB_11 * - ESP32C2 only supports HW calibration on ADC_ATTEN_DB_0 and ADC_ATTEN_DB_12
* - For other attenuation, we just return default value, which is 0. * - For other attenuation, we just return default value, which is 0.
*/ */
return 0; return 0;
@ -56,7 +56,7 @@ uint32_t esp_efuse_rtc_calib_get_init_code(int version, uint32_t adc_unit, int a
if (atten == ADC_ATTEN_DB_0) { if (atten == ADC_ATTEN_DB_0) {
init_code = adc_icode_diff_atten0 + 2160; init_code = adc_icode_diff_atten0 + 2160;
} else { } else {
//ADC_ATTEN_DB_11 //ADC_ATTEN_DB_12
init_code = adc_icode_diff_atten3 + adc_icode_diff_atten0 + 2160; init_code = adc_icode_diff_atten3 + adc_icode_diff_atten0 + 2160;
} }
@ -76,7 +76,7 @@ esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, in
if (atten == ADC_ATTEN_DB_2_5 || atten == ADC_ATTEN_DB_6) { if (atten == ADC_ATTEN_DB_2_5 || atten == ADC_ATTEN_DB_6) {
/** /**
* - ESP32C2 only supports SW calibration on ADC_ATTEN_DB_0 and ADC_ATTEN_DB_11 * - ESP32C2 only supports SW calibration on ADC_ATTEN_DB_0 and ADC_ATTEN_DB_12
* - For other attenuation, we need to return an error, informing upper layer SW calibration driver * - For other attenuation, we need to return an error, informing upper layer SW calibration driver
* to deal with the error. * to deal with the error.
*/ */
@ -101,7 +101,7 @@ esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, in
*out_digi = adc_vol_diff_atten0 + 1540; *out_digi = adc_vol_diff_atten0 + 1540;
*out_vol_mv = 400; *out_vol_mv = 400;
} else { } else {
//ADC_ATTEN_DB_11 //ADC_ATTEN_DB_12
*out_digi = adc_vol_diff_atten0 + 1540 - adc_vol_diff_atten3 - 123; *out_digi = adc_vol_diff_atten0 + 1540 - adc_vol_diff_atten3 - 123;
*out_vol_mv = 1370; *out_vol_mv = 1370;
} }

View File

@ -316,7 +316,7 @@ esp_adc_cal_value_t esp_adc_cal_characterize(adc_unit_t adc_num,
chars->bit_width = bit_width; chars->bit_width = bit_width;
chars->vref = (EFUSE_VREF_ENABLED && efuse_vref_present) ? read_efuse_vref() : default_vref; chars->vref = (EFUSE_VREF_ENABLED && efuse_vref_present) ? read_efuse_vref() : default_vref;
//Initialize fields for lookup table if necessary //Initialize fields for lookup table if necessary
if (LUT_ENABLED && atten == ADC_ATTEN_DB_11) { if (LUT_ENABLED && atten == ADC_ATTEN_DB_12) {
chars->low_curve = (adc_num == ADC_UNIT_1) ? lut_adc1_low : lut_adc2_low; chars->low_curve = (adc_num == ADC_UNIT_1) ? lut_adc1_low : lut_adc2_low;
chars->high_curve = (adc_num == ADC_UNIT_1) ? lut_adc1_high : lut_adc2_high; chars->high_curve = (adc_num == ADC_UNIT_1) ? lut_adc1_high : lut_adc2_high;
} else { } else {
@ -336,8 +336,8 @@ uint32_t esp_adc_cal_raw_to_voltage(uint32_t adc_reading, const esp_adc_cal_char
adc_reading = ADC_12_BIT_RES - 1; //Set to 12bit res max adc_reading = ADC_12_BIT_RES - 1; //Set to 12bit res max
} }
if (LUT_ENABLED && (chars->atten == ADC_ATTEN_DB_11) && (adc_reading >= LUT_LOW_THRESH)) { //Check if in non-linear region if (LUT_ENABLED && (chars->atten == ADC_ATTEN_DB_12) && (adc_reading >= LUT_LOW_THRESH)) { //Check if in non-linear region
//Use lookup table to get voltage in non linear portion of ADC_ATTEN_DB_11 //Use lookup table to get voltage in non linear portion of ADC_ATTEN_DB_12
uint32_t lut_voltage = calculate_voltage_lut(adc_reading, chars->vref, chars->low_curve, chars->high_curve); uint32_t lut_voltage = calculate_voltage_lut(adc_reading, chars->vref, chars->low_curve, chars->high_curve);
if (adc_reading <= LUT_HIGH_THRESH) { //If ADC is transitioning from linear region to non-linear region if (adc_reading <= LUT_HIGH_THRESH) { //If ADC is transitioning from linear region to non-linear region
//Linearly interpolate between linear voltage and lut voltage //Linearly interpolate between linear voltage and lut voltage

View File

@ -75,7 +75,7 @@ static bool prepare_calib_data_for(adc_unit_t adc_num, adc_atten_t atten, adc_ca
case ADC_ATTEN_DB_6: case ADC_ATTEN_DB_6:
parsed_data_storage->efuse_data.ver2.adc_calib_high_voltage = 1000; parsed_data_storage->efuse_data.ver2.adc_calib_high_voltage = 1000;
break; break;
case ADC_ATTEN_DB_11: case ADC_ATTEN_DB_12:
parsed_data_storage->efuse_data.ver2.adc_calib_high_voltage = 2000; parsed_data_storage->efuse_data.ver2.adc_calib_high_voltage = 2000;
break; break;
default: default:

View File

@ -190,7 +190,7 @@ esp_err_t adc_cali_create_scheme_line_fitting(const adc_cali_line_fitting_config
chars->atten = config->atten; chars->atten = config->atten;
chars->bitwidth = (config->bitwidth == ADC_BITWIDTH_DEFAULT) ? ADC_BITWIDTH_12 : config->bitwidth; chars->bitwidth = (config->bitwidth == ADC_BITWIDTH_DEFAULT) ? ADC_BITWIDTH_12 : config->bitwidth;
//Initialize fields for lookup table if necessary //Initialize fields for lookup table if necessary
if (LUT_ENABLED && config->atten == ADC_ATTEN_DB_11) { if (LUT_ENABLED && config->atten == ADC_ATTEN_DB_12) {
chars->low_curve = (config->unit_id == ADC_UNIT_1) ? lut_adc1_low : lut_adc2_low; chars->low_curve = (config->unit_id == ADC_UNIT_1) ? lut_adc1_low : lut_adc2_low;
chars->high_curve = (config->unit_id == ADC_UNIT_1) ? lut_adc1_high : lut_adc2_high; chars->high_curve = (config->unit_id == ADC_UNIT_1) ? lut_adc1_high : lut_adc2_high;
} else { } else {
@ -251,8 +251,8 @@ static esp_err_t cali_raw_to_voltage(void *arg, int raw, int *voltage)
raw = ADC_12_BIT_RES - 1; //Set to 12bit res max raw = ADC_12_BIT_RES - 1; //Set to 12bit res max
} }
if (LUT_ENABLED && (ctx->atten == ADC_ATTEN_DB_11) && (raw >= LUT_LOW_THRESH)) { //Check if in non-linear region if (LUT_ENABLED && (ctx->atten == ADC_ATTEN_DB_12) && (raw >= LUT_LOW_THRESH)) { //Check if in non-linear region
//Use lookup table to get voltage in non linear portion of ADC_ATTEN_DB_11 //Use lookup table to get voltage in non linear portion of ADC_ATTEN_DB_12
uint32_t lut_voltage = calculate_voltage_lut(raw, ctx->vref, ctx->low_curve, ctx->high_curve); uint32_t lut_voltage = calculate_voltage_lut(raw, ctx->vref, ctx->low_curve, ctx->high_curve);
if (raw <= LUT_HIGH_THRESH) { //If ADC is transitioning from linear region to non-linear region if (raw <= LUT_HIGH_THRESH) { //If ADC is transitioning from linear region to non-linear region
//Linearly interpolate between linear voltage and lut voltage //Linearly interpolate between linear voltage and lut voltage

View File

@ -118,7 +118,7 @@ static esp_err_t cali_raw_to_voltage(void *arg, int raw, int *voltage)
static esp_err_t check_valid(const adc_cali_line_fitting_config_t *config) static esp_err_t check_valid(const adc_cali_line_fitting_config_t *config)
{ {
ESP_RETURN_ON_FALSE(config->unit_id < SOC_ADC_PERIPH_NUM, ESP_ERR_INVALID_ARG, TAG, "invalid ADC unit"); ESP_RETURN_ON_FALSE(config->unit_id < SOC_ADC_PERIPH_NUM, ESP_ERR_INVALID_ARG, TAG, "invalid ADC unit");
ESP_RETURN_ON_FALSE((config->atten == ADC_ATTEN_DB_0 || config->atten == ADC_ATTEN_DB_11), ESP_ERR_NOT_SUPPORTED, TAG, "only ADC_ATTEN_DB_0 and ADC_ATTEN_DB_11 are supported"); ESP_RETURN_ON_FALSE((config->atten == ADC_ATTEN_DB_0 || config->atten == ADC_ATTEN_DB_12), ESP_ERR_NOT_SUPPORTED, TAG, "only ADC_ATTEN_DB_0 and ADC_ATTEN_DB_12 are supported");
if (config->atten == ADC_ATTEN_DB_0) { if (config->atten == ADC_ATTEN_DB_0) {
ESP_LOGW(TAG, "Experimental: ADC Atten 0 calibration can now only used for inputs lower than 950mV. Calibration Scheme may get updated, DON'T USE FOR MASS PRODUCTION!"); ESP_LOGW(TAG, "Experimental: ADC Atten 0 calibration can now only used for inputs lower than 950mV. Calibration Scheme may get updated, DON'T USE FOR MASS PRODUCTION!");
} }

View File

@ -177,7 +177,7 @@ static bool prepare_calib_data_for(adc_unit_t unit_id, adc_atten_t atten, adc_ca
case ADC_ATTEN_DB_6: case ADC_ATTEN_DB_6:
parsed_data_storage->efuse_data.ver2.adc_calib_high_voltage = 1000; parsed_data_storage->efuse_data.ver2.adc_calib_high_voltage = 1000;
break; break;
case ADC_ATTEN_DB_11: case ADC_ATTEN_DB_12:
parsed_data_storage->efuse_data.ver2.adc_calib_high_voltage = 2000; parsed_data_storage->efuse_data.ver2.adc_calib_high_voltage = 2000;
break; break;
default: default:

View File

@ -65,7 +65,7 @@ TEST_CASE("ADC oneshot high/low test", "[adc_oneshot]")
//-------------ADC1 TEST Channel 0 Config---------------// //-------------ADC1 TEST Channel 0 Config---------------//
adc_oneshot_chan_cfg_t config = { adc_oneshot_chan_cfg_t config = {
.bitwidth = ADC_BITWIDTH_DEFAULT, .bitwidth = ADC_BITWIDTH_DEFAULT,
.atten = ADC_ATTEN_DB_11, .atten = ADC_ATTEN_DB_12,
}; };
TEST_ESP_OK(adc_oneshot_config_channel(adc1_handle, ADC1_TEST_CHAN0, &config)); TEST_ESP_OK(adc_oneshot_config_channel(adc1_handle, ADC1_TEST_CHAN0, &config));
@ -283,7 +283,7 @@ TEST_CASE("ADC continuous monitor init_deinit", "[adc]")
adc_digi_pattern_config_t adc_pattern[SOC_ADC_PATT_LEN_MAX] = {0}; adc_digi_pattern_config_t adc_pattern[SOC_ADC_PATT_LEN_MAX] = {0};
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
adc_pattern[i].atten = ADC_ATTEN_DB_11; adc_pattern[i].atten = ADC_ATTEN_DB_12;
adc_pattern[i].channel = i; adc_pattern[i].channel = i;
adc_pattern[i].unit = ADC_UNIT_1; adc_pattern[i].unit = ADC_UNIT_1;
adc_pattern[i].bit_width = SOC_ADC_DIGI_MAX_BITWIDTH; adc_pattern[i].bit_width = SOC_ADC_DIGI_MAX_BITWIDTH;
@ -401,7 +401,7 @@ TEST_CASE("ADC continuous monitor functionary", "[adc][manual][ignore]")
adc_digi_pattern_config_t adc_pattern[SOC_ADC_PATT_LEN_MAX] = {0}; adc_digi_pattern_config_t adc_pattern[SOC_ADC_PATT_LEN_MAX] = {0};
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
adc_pattern[i].atten = ADC_ATTEN_DB_11; adc_pattern[i].atten = ADC_ATTEN_DB_12;
adc_pattern[i].channel = TEST_ADC_CHANNEL; adc_pattern[i].channel = TEST_ADC_CHANNEL;
adc_pattern[i].unit = ADC_UNIT_1; adc_pattern[i].unit = ADC_UNIT_1;
adc_pattern[i].bit_width = SOC_ADC_DIGI_MAX_BITWIDTH; adc_pattern[i].bit_width = SOC_ADC_DIGI_MAX_BITWIDTH;

View File

@ -80,7 +80,7 @@ TEST_CASE("ADC oneshot fast work with ISR", "[adc_oneshot]")
//-------------ADC1 TEST Channel 0 Config---------------// //-------------ADC1 TEST Channel 0 Config---------------//
adc_oneshot_chan_cfg_t config = { adc_oneshot_chan_cfg_t config = {
.bitwidth = ADC_BITWIDTH_DEFAULT, .bitwidth = ADC_BITWIDTH_DEFAULT,
.atten = ADC_ATTEN_DB_11, .atten = ADC_ATTEN_DB_12,
}; };
TEST_ESP_OK(adc_oneshot_config_channel(isr_test_ctx.oneshot_handle, ADC1_TEST_CHAN0, &config)); TEST_ESP_OK(adc_oneshot_config_channel(isr_test_ctx.oneshot_handle, ADC1_TEST_CHAN0, &config));
@ -171,7 +171,7 @@ TEST_CASE("ADC continuous big conv_frame_size test", "[adc_continuous]")
.format = ADC_DRIVER_TEST_OUTPUT_TYPE, .format = ADC_DRIVER_TEST_OUTPUT_TYPE,
}; };
adc_digi_pattern_config_t adc_pattern[SOC_ADC_PATT_LEN_MAX] = {0}; adc_digi_pattern_config_t adc_pattern[SOC_ADC_PATT_LEN_MAX] = {0};
adc_pattern[0].atten = ADC_ATTEN_DB_11; adc_pattern[0].atten = ADC_ATTEN_DB_12;
adc_pattern[0].channel = ADC1_TEST_CHAN0; adc_pattern[0].channel = ADC1_TEST_CHAN0;
adc_pattern[0].unit = ADC_UNIT_1; adc_pattern[0].unit = ADC_UNIT_1;
adc_pattern[0].bit_width = SOC_ADC_DIGI_MAX_BITWIDTH; adc_pattern[0].bit_width = SOC_ADC_DIGI_MAX_BITWIDTH;
@ -229,7 +229,7 @@ TEST_CASE("ADC continuous flush internal pool", "[adc_continuous][mannual][ignor
.format = ADC_DRIVER_TEST_OUTPUT_TYPE, .format = ADC_DRIVER_TEST_OUTPUT_TYPE,
}; };
adc_digi_pattern_config_t adc_pattern[SOC_ADC_PATT_LEN_MAX] = {0}; adc_digi_pattern_config_t adc_pattern[SOC_ADC_PATT_LEN_MAX] = {0};
adc_pattern[0].atten = ADC_ATTEN_DB_11; adc_pattern[0].atten = ADC_ATTEN_DB_12;
adc_pattern[0].channel = ADC1_TEST_CHAN0; adc_pattern[0].channel = ADC1_TEST_CHAN0;
adc_pattern[0].unit = ADC_UNIT_1; adc_pattern[0].unit = ADC_UNIT_1;
adc_pattern[0].bit_width = SOC_ADC_DIGI_MAX_BITWIDTH; adc_pattern[0].bit_width = SOC_ADC_DIGI_MAX_BITWIDTH;

View File

@ -84,7 +84,7 @@ TEST_CASE("ADC oneshot fast work with ISR and Flash", "[adc_oneshot]")
//-------------ADC1 TEST Channel 0 Config---------------// //-------------ADC1 TEST Channel 0 Config---------------//
adc_oneshot_chan_cfg_t config = { adc_oneshot_chan_cfg_t config = {
.bitwidth = ADC_BITWIDTH_DEFAULT, .bitwidth = ADC_BITWIDTH_DEFAULT,
.atten = ADC_ATTEN_DB_11, .atten = ADC_ATTEN_DB_12,
}; };
TEST_ESP_OK(adc_oneshot_config_channel(oneshot_handle, ADC1_TEST_CHAN0, &config)); TEST_ESP_OK(adc_oneshot_config_channel(oneshot_handle, ADC1_TEST_CHAN0, &config));

View File

@ -269,29 +269,29 @@ TEST_CASE("ADC1 continuous raw average and std_deviation", "[adc_continuous][man
TEST_CASE("ADC1 continuous std deviation performance, no filter", "[adc_continuous][performance]") TEST_CASE("ADC1 continuous std deviation performance, no filter", "[adc_continuous][performance]")
{ {
float std = test_adc_continuous_std(ADC_ATTEN_DB_11, false, 0, true); float std = test_adc_continuous_std(ADC_ATTEN_DB_12, false, 0, true);
TEST_PERFORMANCE_LESS_THAN(ADC_CONTINUOUS_STD_ATTEN3_NO_FILTER, "%.2f", std); TEST_PERFORMANCE_LESS_THAN(ADC_CONTINUOUS_STD_ATTEN3_NO_FILTER, "%.2f", std);
} }
#if SOC_ADC_DIG_IIR_FILTER_SUPPORTED #if SOC_ADC_DIG_IIR_FILTER_SUPPORTED
TEST_CASE("ADC1 continuous std deviation performance, with filter", "[adc_continuous][performance]") TEST_CASE("ADC1 continuous std deviation performance, with filter", "[adc_continuous][performance]")
{ {
float std = test_adc_continuous_std(ADC_ATTEN_DB_11, false, 0, true); float std = test_adc_continuous_std(ADC_ATTEN_DB_12, false, 0, true);
TEST_PERFORMANCE_LESS_THAN(ADC_CONTINUOUS_STD_ATTEN3_NO_FILTER, "%.2f", std); TEST_PERFORMANCE_LESS_THAN(ADC_CONTINUOUS_STD_ATTEN3_NO_FILTER, "%.2f", std);
std = test_adc_continuous_std(ADC_ATTEN_DB_11, true, ADC_DIGI_IIR_FILTER_COEFF_2, true); std = test_adc_continuous_std(ADC_ATTEN_DB_12, true, ADC_DIGI_IIR_FILTER_COEFF_2, true);
TEST_PERFORMANCE_LESS_THAN(ADC_CONTINUOUS_STD_ATTEN3_FILTER_2, "%.2f", std); TEST_PERFORMANCE_LESS_THAN(ADC_CONTINUOUS_STD_ATTEN3_FILTER_2, "%.2f", std);
std = test_adc_continuous_std(ADC_ATTEN_DB_11, true, ADC_DIGI_IIR_FILTER_COEFF_4, true); std = test_adc_continuous_std(ADC_ATTEN_DB_12, true, ADC_DIGI_IIR_FILTER_COEFF_4, true);
TEST_PERFORMANCE_LESS_THAN(ADC_CONTINUOUS_STD_ATTEN3_FILTER_4, "%.2f", std); TEST_PERFORMANCE_LESS_THAN(ADC_CONTINUOUS_STD_ATTEN3_FILTER_4, "%.2f", std);
std = test_adc_continuous_std(ADC_ATTEN_DB_11, true, ADC_DIGI_IIR_FILTER_COEFF_8, true); std = test_adc_continuous_std(ADC_ATTEN_DB_12, true, ADC_DIGI_IIR_FILTER_COEFF_8, true);
TEST_PERFORMANCE_LESS_THAN(ADC_CONTINUOUS_STD_ATTEN3_FILTER_8, "%.2f", std); TEST_PERFORMANCE_LESS_THAN(ADC_CONTINUOUS_STD_ATTEN3_FILTER_8, "%.2f", std);
std = test_adc_continuous_std(ADC_ATTEN_DB_11, true, ADC_DIGI_IIR_FILTER_COEFF_16, true); std = test_adc_continuous_std(ADC_ATTEN_DB_12, true, ADC_DIGI_IIR_FILTER_COEFF_16, true);
TEST_PERFORMANCE_LESS_THAN(ADC_CONTINUOUS_STD_ATTEN3_FILTER_16, "%.2f", std); TEST_PERFORMANCE_LESS_THAN(ADC_CONTINUOUS_STD_ATTEN3_FILTER_16, "%.2f", std);
std = test_adc_continuous_std(ADC_ATTEN_DB_11, true, ADC_DIGI_IIR_FILTER_COEFF_64, true); std = test_adc_continuous_std(ADC_ATTEN_DB_12, true, ADC_DIGI_IIR_FILTER_COEFF_64, true);
TEST_PERFORMANCE_LESS_THAN(ADC_CONTINUOUS_STD_ATTEN3_FILTER_64, "%.2f", std); TEST_PERFORMANCE_LESS_THAN(ADC_CONTINUOUS_STD_ATTEN3_FILTER_64, "%.2f", std);
} }
#endif //#if SOC_ADC_DIG_IIR_FILTER_SUPPORTED #endif //#if SOC_ADC_DIG_IIR_FILTER_SUPPORTED
@ -375,7 +375,7 @@ TEST_CASE("ADC1 oneshot raw average and std_deviation", "[adc_oneshot][manual]")
TEST_CASE("ADC1 oneshot std_deviation performance", "[adc_oneshot][performance]") TEST_CASE("ADC1 oneshot std_deviation performance", "[adc_oneshot][performance]")
{ {
float std = test_adc_oneshot_std(ADC_ATTEN_DB_11, true); float std = test_adc_oneshot_std(ADC_ATTEN_DB_12, true);
TEST_PERFORMANCE_LESS_THAN(ADC_ONESHOT_STD_ATTEN3, "%.2f", std); TEST_PERFORMANCE_LESS_THAN(ADC_ONESHOT_STD_ATTEN3, "%.2f", std);
} }
/*--------------------------------------------------------------- /*---------------------------------------------------------------

View File

@ -170,7 +170,7 @@ __attribute__((unused)) static void adc_work_with_wifi(adc_unit_t unit_id, adc_c
//-------------ADC TEST Channel Config---------------// //-------------ADC TEST Channel Config---------------//
adc_oneshot_chan_cfg_t config = { adc_oneshot_chan_cfg_t config = {
.bitwidth = ADC_BITWIDTH_DEFAULT, .bitwidth = ADC_BITWIDTH_DEFAULT,
.atten = ADC_ATTEN_DB_11, .atten = ADC_ATTEN_DB_12,
}; };
TEST_ESP_OK(adc_oneshot_config_channel(adc_handle, channel, &config)); TEST_ESP_OK(adc_oneshot_config_channel(adc_handle, channel, &config));

View File

@ -20,9 +20,9 @@ __attribute__((unused)) static const char *TAG = "TEST_ADC";
ADC Attenuation ADC Attenuation
---------------------------------------------------------------*/ ---------------------------------------------------------------*/
#if CONFIG_IDF_TARGET_ESP32C2 #if CONFIG_IDF_TARGET_ESP32C2
adc_atten_t g_test_atten[TEST_ATTEN_NUMS] = {ADC_ATTEN_DB_0, ADC_ATTEN_DB_11}; adc_atten_t g_test_atten[TEST_ATTEN_NUMS] = {ADC_ATTEN_DB_0, ADC_ATTEN_DB_12};
#else #else
adc_atten_t g_test_atten[TEST_ATTEN_NUMS] = {ADC_ATTEN_DB_0, ADC_ATTEN_DB_2_5, ADC_ATTEN_DB_6, ADC_ATTEN_DB_11}; adc_atten_t g_test_atten[TEST_ATTEN_NUMS] = {ADC_ATTEN_DB_0, ADC_ATTEN_DB_2_5, ADC_ATTEN_DB_6, ADC_ATTEN_DB_12};
#endif #endif
#if SOC_ADC_DIG_IIR_FILTER_SUPPORTED #if SOC_ADC_DIG_IIR_FILTER_SUPPORTED

View File

@ -22,9 +22,9 @@ extern portMUX_TYPE rtc_spinlock;
static __attribute__((constructor)) void adc2_init_code_calibration(void) static __attribute__((constructor)) void adc2_init_code_calibration(void)
{ {
adc_hal_calibration_init(ADC_UNIT_2); adc_hal_calibration_init(ADC_UNIT_2);
adc_calc_hw_calibration_code(ADC_UNIT_2, ADC_ATTEN_DB_11); adc_calc_hw_calibration_code(ADC_UNIT_2, ADC_ATTEN_DB_12);
portENTER_CRITICAL(&rtc_spinlock); portENTER_CRITICAL(&rtc_spinlock);
adc_set_hw_calibration_code(ADC_UNIT_2, ADC_ATTEN_DB_11); adc_set_hw_calibration_code(ADC_UNIT_2, ADC_ATTEN_DB_12);
portEXIT_CRITICAL(&rtc_spinlock); portEXIT_CRITICAL(&rtc_spinlock);
} }

View File

@ -22,9 +22,9 @@ extern portMUX_TYPE rtc_spinlock;
static __attribute__((constructor)) void adc2_init_code_calibration(void) static __attribute__((constructor)) void adc2_init_code_calibration(void)
{ {
adc_hal_calibration_init(ADC_UNIT_2); adc_hal_calibration_init(ADC_UNIT_2);
adc_calc_hw_calibration_code(ADC_UNIT_2, ADC_ATTEN_DB_11); adc_calc_hw_calibration_code(ADC_UNIT_2, ADC_ATTEN_DB_12);
portENTER_CRITICAL(&rtc_spinlock); portENTER_CRITICAL(&rtc_spinlock);
adc_set_hw_calibration_code(ADC_UNIT_2, ADC_ATTEN_DB_11); adc_set_hw_calibration_code(ADC_UNIT_2, ADC_ATTEN_DB_12);
portEXIT_CRITICAL(&rtc_spinlock); portEXIT_CRITICAL(&rtc_spinlock);
} }

View File

@ -848,19 +848,19 @@ static inline void adc_ll_rtc_set_arbiter_stable_cycle(uint32_t cycle)
* - 0dB attenuation (ADC_ATTEN_DB_0) gives full-scale voltage 1.1V * - 0dB attenuation (ADC_ATTEN_DB_0) gives full-scale voltage 1.1V
* - 2.5dB attenuation (ADC_ATTEN_DB_2_5) gives full-scale voltage 1.5V * - 2.5dB attenuation (ADC_ATTEN_DB_2_5) gives full-scale voltage 1.5V
* - 6dB attenuation (ADC_ATTEN_DB_6) gives full-scale voltage 2.2V * - 6dB attenuation (ADC_ATTEN_DB_6) gives full-scale voltage 2.2V
* - 11dB attenuation (ADC_ATTEN_DB_11) gives full-scale voltage 3.9V (see note below) * - 12dB attenuation (ADC_ATTEN_DB_12) gives full-scale voltage 3.9V (see note below)
* *
* @note The full-scale voltage is the voltage corresponding to a maximum reading (depending on ADC1 configured * @note The full-scale voltage is the voltage corresponding to a maximum reading (depending on ADC1 configured
* bit width, this value is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits.) * bit width, this value is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits.)
* *
* @note At 11dB attenuation the maximum voltage is limited by VDD_A, not the full scale voltage. * @note At 12dB attenuation the maximum voltage is limited by VDD_A, not the full scale voltage.
* *
* Due to ADC characteristics, most accurate results are obtained within the following approximate voltage ranges: * Due to ADC characteristics, most accurate results are obtained within the following approximate voltage ranges:
* *
* - 0dB attenuation (ADC_ATTEN_DB_0) between 100 and 950mV * - 0dB attenuation (ADC_ATTEN_DB_0) between 100 and 950mV
* - 2.5dB attenuation (ADC_ATTEN_DB_2_5) between 100 and 1250mV * - 2.5dB attenuation (ADC_ATTEN_DB_2_5) between 100 and 1250mV
* - 6dB attenuation (ADC_ATTEN_DB_6) between 150 to 1750mV * - 6dB attenuation (ADC_ATTEN_DB_6) between 150 to 1750mV
* - 11dB attenuation (ADC_ATTEN_DB_11) between 150 to 2450mV * - 12dB attenuation (ADC_ATTEN_DB_12) between 150 to 2450mV
* *
* For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges. * For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges.
* *

View File

@ -1108,19 +1108,19 @@ static inline void adc_ll_rtc_set_arbiter_stable_cycle(uint32_t cycle)
* - 0dB attenuation (ADC_ATTEN_DB_0) gives full-scale voltage 1.1V * - 0dB attenuation (ADC_ATTEN_DB_0) gives full-scale voltage 1.1V
* - 2.5dB attenuation (ADC_ATTEN_DB_2_5) gives full-scale voltage 1.5V * - 2.5dB attenuation (ADC_ATTEN_DB_2_5) gives full-scale voltage 1.5V
* - 6dB attenuation (ADC_ATTEN_DB_6) gives full-scale voltage 2.2V * - 6dB attenuation (ADC_ATTEN_DB_6) gives full-scale voltage 2.2V
* - 11dB attenuation (ADC_ATTEN_DB_11) gives full-scale voltage 3.9V (see note below) * - 12dB attenuation (ADC_ATTEN_DB_12) gives full-scale voltage 3.9V (see note below)
* *
* @note The full-scale voltage is the voltage corresponding to a maximum reading (depending on ADC1 configured * @note The full-scale voltage is the voltage corresponding to a maximum reading (depending on ADC1 configured
* bit width, this value is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits.) * bit width, this value is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits.)
* *
* @note At 11dB attenuation the maximum voltage is limited by VDD_A, not the full scale voltage. * @note At 12dB attenuation the maximum voltage is limited by VDD_A, not the full scale voltage.
* *
* Due to ADC characteristics, most accurate results are obtained within the following approximate voltage ranges: * Due to ADC characteristics, most accurate results are obtained within the following approximate voltage ranges:
* *
* - 0dB attenuation (ADC_ATTEN_DB_0) between 100 and 950mV * - 0dB attenuation (ADC_ATTEN_DB_0) between 100 and 950mV
* - 2.5dB attenuation (ADC_ATTEN_DB_2_5) between 100 and 1250mV * - 2.5dB attenuation (ADC_ATTEN_DB_2_5) between 100 and 1250mV
* - 6dB attenuation (ADC_ATTEN_DB_6) between 150 to 1750mV * - 6dB attenuation (ADC_ATTEN_DB_6) between 150 to 1750mV
* - 11dB attenuation (ADC_ATTEN_DB_11) between 150 to 2450mV * - 12dB attenuation (ADC_ATTEN_DB_12) between 150 to 2450mV
* *
* For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges. * For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges.
* *

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -45,9 +45,10 @@ typedef enum {
*/ */
typedef enum { typedef enum {
ADC_ATTEN_DB_0 = 0, ///<No input attenuation, ADC can measure up to approx. ADC_ATTEN_DB_0 = 0, ///<No input attenuation, ADC can measure up to approx.
ADC_ATTEN_DB_2_5 = 1, ///<The input voltage of ADC will be attenuated extending the range of measurement by about 2.5 dB (1.33 x) ADC_ATTEN_DB_2_5 = 1, ///<The input voltage of ADC will be attenuated extending the range of measurement by about 2.5 dB
ADC_ATTEN_DB_6 = 2, ///<The input voltage of ADC will be attenuated extending the range of measurement by about 6 dB (2 x) ADC_ATTEN_DB_6 = 2, ///<The input voltage of ADC will be attenuated extending the range of measurement by about 6 dB
ADC_ATTEN_DB_11 = 3, ///<The input voltage of ADC will be attenuated extending the range of measurement by about 11 dB (3.55 x) ADC_ATTEN_DB_12 = 3, ///<The input voltage of ADC will be attenuated extending the range of measurement by about 12 dB
ADC_ATTEN_DB_11 __attribute__((deprecated)) = ADC_ATTEN_DB_12, ///<This is deprecated, it behaves the same as `ADC_ATTEN_DB_12`
} adc_atten_t; } adc_atten_t;
typedef enum { typedef enum {

View File

@ -152,7 +152,7 @@ After setting up the calibration characteristics, you can call :cpp:func:`adc_ca
.. note:: .. note::
ADC calibration is only supported under :c:macro:`ADC_ATTEN_DB_0` and :c:macro:`ADC_ATTEN_DB_11`. Under :c:macro:`ADC_ATTEN_DB_0`, the attenuation of ADC is set to 0 dB, and input voltage higher than 950 mV is not supported. Under :c:macro:`ADC_ATTEN_DB_11`, the attenuation of ADC is set to 11 dB, and input voltage higher than 2800 mV is not supported. ADC calibration is only supported under :c:macro:`ADC_ATTEN_DB_0` and :c:macro:`ADC_ATTEN_DB_12`. Under :c:macro:`ADC_ATTEN_DB_0`, the attenuation of ADC is set to 0 dB, and input voltage higher than 950 mV is not supported. Under :c:macro:`ADC_ATTEN_DB_12`, the attenuation of ADC is set to 11 dB, and input voltage higher than 2800 mV is not supported.
Get Voltage Get Voltage
~~~~~~~~~~~ ~~~~~~~~~~~
@ -182,7 +182,7 @@ Other functions that take the :cpp:type:`adc_cali_handle_t` as the first positio
- :ref:`CONFIG_ADC_CAL_EFUSE_TP_ENABLE` - disable this to decrease the code size, if the calibration eFuse value is not set to :cpp:type:`ADC_CALI_LINE_FITTING_EFUSE_VAL_EFUSE_TP`. - :ref:`CONFIG_ADC_CAL_EFUSE_TP_ENABLE` - disable this to decrease the code size, if the calibration eFuse value is not set to :cpp:type:`ADC_CALI_LINE_FITTING_EFUSE_VAL_EFUSE_TP`.
- :ref:`CONFIG_ADC_CAL_EFUSE_VREF_ENABLE` - disable this to decrease the code size, if the calibration eFuse value is not set to :cpp:type:`ADC_CALI_LINE_FITTING_EFUSE_VAL_EFUSE_VREF`. - :ref:`CONFIG_ADC_CAL_EFUSE_VREF_ENABLE` - disable this to decrease the code size, if the calibration eFuse value is not set to :cpp:type:`ADC_CALI_LINE_FITTING_EFUSE_VAL_EFUSE_VREF`.
- :ref:`CONFIG_ADC_CAL_LUT_ENABLE` - disable this to decrease the code size, if you do not calibrate the ADC raw results under :c:macro:`ADC_ATTEN_DB_11`. - :ref:`CONFIG_ADC_CAL_LUT_ENABLE` - disable this to decrease the code size, if you do not calibrate the ADC raw results under :c:macro:`ADC_ATTEN_DB_12`.
.. _adc-minimize-noise: .. _adc-minimize-noise:

View File

@ -105,7 +105,7 @@ Configure Two ADC Channels
adc_oneshot_chan_cfg_t config = { adc_oneshot_chan_cfg_t config = {
.bitwidth = ADC_BITWIDTH_DEFAULT, .bitwidth = ADC_BITWIDTH_DEFAULT,
.atten = ADC_ATTEN_DB_11, .atten = ADC_ATTEN_DB_12,
}; };
ESP_ERROR_CHECK(adc_oneshot_config_channel(adc1_handle, EXAMPLE_ADC1_CHAN0, &config)); ESP_ERROR_CHECK(adc_oneshot_config_channel(adc1_handle, EXAMPLE_ADC1_CHAN0, &config));
ESP_ERROR_CHECK(adc_oneshot_config_channel(adc1_handle, EXAMPLE_ADC1_CHAN1, &config)); ESP_ERROR_CHECK(adc_oneshot_config_channel(adc1_handle, EXAMPLE_ADC1_CHAN1, &config));

View File

@ -152,7 +152,7 @@ ADC 校准驱动程序会提供 ADC 校准方案。对于驱动程序来说,
.. note:: .. note::
ADC 校准仅在 :c:macro:`ADC_ATTEN_DB_0`:c:macro:`ADC_ATTEN_DB_11` 时支持。在 :c:macro:`ADC_ATTEN_DB_0`ADC 的衰减程度设置为 0 dB仅支持低于 950 mV 的输入电压;在 :c:macro:`ADC_ATTEN_DB_11` 时ADC 的衰减程度设置为 11 dB仅支持低于 2800 mV 的输入电压。 ADC 校准仅在 :c:macro:`ADC_ATTEN_DB_0`:c:macro:`ADC_ATTEN_DB_12` 时支持。在 :c:macro:`ADC_ATTEN_DB_0`ADC 的衰减程度设置为 0 dB仅支持低于 950 mV 的输入电压;在 :c:macro:`ADC_ATTEN_DB_12` 时ADC 的衰减程度设置为 12 dB仅支持低于 2800 mV 的输入电压。
获取电压 获取电压
~~~~~~~~~~~ ~~~~~~~~~~~
@ -182,7 +182,7 @@ ADC 校准驱动程序会提供 ADC 校准方案。对于驱动程序来说,
- :ref:`CONFIG_ADC_CAL_EFUSE_TP_ENABLE` - 如果校准相关的 eFuse 值没有配置为 :cpp:type:`ADC_CALI_LINE_FITTING_EFUSE_VAL_EFUSE_TP`,则可以禁用该选项,减小代码大小。 - :ref:`CONFIG_ADC_CAL_EFUSE_TP_ENABLE` - 如果校准相关的 eFuse 值没有配置为 :cpp:type:`ADC_CALI_LINE_FITTING_EFUSE_VAL_EFUSE_TP`,则可以禁用该选项,减小代码大小。
- :ref:`CONFIG_ADC_CAL_EFUSE_VREF_ENABLE` - 如果校准相关的 eFuse 值没有配置为 :cpp:type:`ADC_CALI_LINE_FITTING_EFUSE_VAL_EFUSE_VREF`,则可以禁用该选项,减小代码大小。 - :ref:`CONFIG_ADC_CAL_EFUSE_VREF_ENABLE` - 如果校准相关的 eFuse 值没有配置为 :cpp:type:`ADC_CALI_LINE_FITTING_EFUSE_VAL_EFUSE_VREF`,则可以禁用该选项,减小代码大小。
- :ref:`CONFIG_ADC_CAL_LUT_ENABLE` - 如果校准 ADC 原始结果时,衰减没有设置成 :c:macro:`ADC_ATTEN_DB_11`,则可以禁用该选项,减小代码大小。 - :ref:`CONFIG_ADC_CAL_LUT_ENABLE` - 如果校准 ADC 原始结果时,衰减没有设置成 :c:macro:`ADC_ATTEN_DB_12`,则可以禁用该选项,减小代码大小。
.. _adc-minimize-noise: .. _adc-minimize-noise:

View File

@ -105,7 +105,7 @@ ADC 单次转换模式驱动基于 {IDF_TARGET_NAME} SAR ADC 模块实现,不
adc_oneshot_chan_cfg_t config = { adc_oneshot_chan_cfg_t config = {
.bitwidth = ADC_BITWIDTH_DEFAULT, .bitwidth = ADC_BITWIDTH_DEFAULT,
.atten = ADC_ATTEN_DB_11, .atten = ADC_ATTEN_DB_12,
}; };
ESP_ERROR_CHECK(adc_oneshot_config_channel(adc1_handle, EXAMPLE_ADC1_CHAN0, &config)); ESP_ERROR_CHECK(adc_oneshot_config_channel(adc1_handle, EXAMPLE_ADC1_CHAN0, &config));
ESP_ERROR_CHECK(adc_oneshot_config_channel(adc1_handle, EXAMPLE_ADC1_CHAN1, &config)); ESP_ERROR_CHECK(adc_oneshot_config_channel(adc1_handle, EXAMPLE_ADC1_CHAN1, &config));

View File

@ -45,7 +45,7 @@ const static char *TAG = "EXAMPLE";
#endif #endif
#endif //#if EXAMPLE_USE_ADC2 #endif //#if EXAMPLE_USE_ADC2
#define EXAMPLE_ADC_ATTEN ADC_ATTEN_DB_11 #define EXAMPLE_ADC_ATTEN ADC_ATTEN_DB_12
static int adc_raw[2][10]; static int adc_raw[2][10];
static int voltage[2][10]; static int voltage[2][10];

View File

@ -38,7 +38,7 @@
#endif #endif
#define EXAMPLE_DAC_CHAN0_IO DAC_CHAN0_GPIO_NUM // DAC channel 0 io number #define EXAMPLE_DAC_CHAN0_IO DAC_CHAN0_GPIO_NUM // DAC channel 0 io number
#define EXAMPLE_DAC_CHAN1_IO DAC_CHAN1_GPIO_NUM // DAC channel 1 io number #define EXAMPLE_DAC_CHAN1_IO DAC_CHAN1_GPIO_NUM // DAC channel 1 io number
#define EXAMPLE_ADC_ATTEN ADC_ATTEN_DB_11 #define EXAMPLE_ADC_ATTEN ADC_ATTEN_DB_12
_Static_assert(EXAMPLE_DAC_AMPLITUDE < 256, "The DAC accuracy is 8 bit-width, doesn't support the amplitude beyond 255"); _Static_assert(EXAMPLE_DAC_AMPLITUDE < 256, "The DAC accuracy is 8 bit-width, doesn't support the amplitude beyond 255");

View File

@ -19,7 +19,7 @@
#define EXAMPLE_DAC_CHAN1_ADC_CHAN ADC_CHANNEL_7 // GPIO18, same as DAC channel 1 #define EXAMPLE_DAC_CHAN1_ADC_CHAN ADC_CHANNEL_7 // GPIO18, same as DAC channel 1
#define EXAMPLE_ADC_WIDTH ADC_WIDTH_BIT_13 #define EXAMPLE_ADC_WIDTH ADC_WIDTH_BIT_13
#endif #endif
#define EXAMPLE_ADC_ATTEN ADC_ATTEN_DB_11 #define EXAMPLE_ADC_ATTEN ADC_ATTEN_DB_12
static void adc_monitor_task(void *args) static void adc_monitor_task(void *args)
{ {

View File

@ -19,7 +19,7 @@
#define EXAMPLE_DAC_CHAN1_ADC_CHAN ADC_CHANNEL_7 // GPIO18, same as DAC channel 1 #define EXAMPLE_DAC_CHAN1_ADC_CHAN ADC_CHANNEL_7 // GPIO18, same as DAC channel 1
#define EXAMPLE_ADC_WIDTH ADC_WIDTH_BIT_13 #define EXAMPLE_ADC_WIDTH ADC_WIDTH_BIT_13
#endif #endif
#define EXAMPLE_ADC_ATTEN ADC_ATTEN_DB_11 #define EXAMPLE_ADC_ATTEN ADC_ATTEN_DB_12
static void adc_monitor_task(void *args) static void adc_monitor_task(void *args)
{ {

View File

@ -8,7 +8,7 @@
/* Ints are used here to be able to include the file in assembly as well */ /* Ints are used here to be able to include the file in assembly as well */
#define EXAMPLE_ADC_CHANNEL 6 // ADC_CHANNEL_6, GPIO34 on ESP32, GPIO7 on ESP32-S3 #define EXAMPLE_ADC_CHANNEL 6 // ADC_CHANNEL_6, GPIO34 on ESP32, GPIO7 on ESP32-S3
#define EXAMPLE_ADC_UNIT 0 // ADC_UNIT_1 #define EXAMPLE_ADC_UNIT 0 // ADC_UNIT_1
#define EXAMPLE_ADC_ATTEN 3 // ADC_ATTEN_DB_11 #define EXAMPLE_ADC_ATTEN 3 // ADC_ATTEN_DB_12
#define EXAMPLE_ADC_WIDTH 0 // ADC_BITWIDTH_DEFAULT #define EXAMPLE_ADC_WIDTH 0 // ADC_BITWIDTH_DEFAULT
/* Set low and high thresholds, approx. 1.35V - 1.75V*/ /* Set low and high thresholds, approx. 1.35V - 1.75V*/

View File

@ -9,7 +9,7 @@
#define EXAMPLE_ADC_CHANNEL ADC_CHANNEL_0 #define EXAMPLE_ADC_CHANNEL ADC_CHANNEL_0
#define EXAMPLE_ADC_UNIT ADC_UNIT_1 #define EXAMPLE_ADC_UNIT ADC_UNIT_1
#define EXAMPLE_ADC_ATTEN ADC_ATTEN_DB_11 #define EXAMPLE_ADC_ATTEN ADC_ATTEN_DB_12
#define EXAMPLE_ADC_WIDTH ADC_BITWIDTH_DEFAULT #define EXAMPLE_ADC_WIDTH ADC_BITWIDTH_DEFAULT
/* Set high threshold, approx. 1.75V*/ /* Set high threshold, approx. 1.75V*/