mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
refactor(esp_adc): reformat code with astyle_py
This commit is contained in:
parent
366bb1f99a
commit
b774bd1457
@ -18,7 +18,6 @@
|
||||
|
||||
const __attribute__((unused)) static char *TAG = "adc_cali";
|
||||
|
||||
|
||||
esp_err_t adc_cali_check_scheme(adc_cali_scheme_ver_t *scheme_mask)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(scheme_mask, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer");
|
||||
|
@ -178,7 +178,6 @@ static void calc_first_step_coefficients(const adc_calib_info_t *parsed_data, ca
|
||||
ESP_LOGV(TAG, "Calib V1, Cal Voltage = %" PRId32 ", Digi out = %" PRId32 ", Coef_a = %" PRId32, parsed_data->ref_data.ver1.voltage, parsed_data->ref_data.ver1.digi, ctx->chars_first_step.coeff_a);
|
||||
}
|
||||
|
||||
|
||||
static int32_t get_reading_error(uint64_t v_cali_1, const cali_chars_second_step_t *param)
|
||||
{
|
||||
if (v_cali_1 == 0 || param->term_num == 0) {
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "hal/adc_hal_common.h"
|
||||
#include "soc/adc_periph.h"
|
||||
|
||||
|
||||
static const char *TAG = "adc_common";
|
||||
static portMUX_TYPE s_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
extern portMUX_TYPE rtc_spinlock;
|
||||
|
@ -106,7 +106,6 @@ struct adc_continuous_ctx_t {
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2016-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -20,7 +20,6 @@
|
||||
static const char *TAG = "adc_filter";
|
||||
static portMUX_TYPE s_filter_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
|
||||
#if SOC_ADC_DIG_IIR_FILTER_UNIT_BINDED
|
||||
static atomic_bool s_adc_filter_claimed[SOC_ADC_DIGI_IIR_FILTER_NUM] = {ATOMIC_VAR_INIT(false),
|
||||
#if (SOC_ADC_DIGI_IIR_FILTER_NUM >= 2)
|
||||
@ -87,7 +86,6 @@ static esp_err_t s_adc_filter_free(adc_iir_filter_t *filter_ctx)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
esp_err_t adc_new_continuous_iir_filter(adc_continuous_handle_t handle, const adc_continuous_iir_filter_config_t *config, adc_iir_filter_handle_t *ret_hdl)
|
||||
{
|
||||
esp_err_t ret = ESP_FAIL;
|
||||
|
@ -28,7 +28,6 @@ typedef struct adc_monitor_platform_t {
|
||||
// Global context of adc monitor, other member will be lazy loaded
|
||||
static adc_monitor_platform_t s_adc_monitor_platform = {.monitor_spinlock = portMUX_INITIALIZER_UNLOCKED};
|
||||
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
// Monitor unit index need equal to ADC unit index on ESP32S2
|
||||
static atomic_bool s_adc_monitor_claimed[SOC_ADC_DIGI_MONITOR_NUM] = {};
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -25,18 +25,15 @@
|
||||
#include "hal/adc_ll.h"
|
||||
#include "soc/adc_periph.h"
|
||||
|
||||
|
||||
#if CONFIG_ADC_ONESHOT_CTRL_FUNC_IN_IRAM
|
||||
#define ADC_MEM_ALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)
|
||||
#else
|
||||
#define ADC_MEM_ALLOC_CAPS MALLOC_CAP_DEFAULT
|
||||
#endif
|
||||
|
||||
|
||||
extern portMUX_TYPE rtc_spinlock;
|
||||
static const char *TAG = "adc_oneshot";
|
||||
|
||||
|
||||
typedef struct adc_oneshot_unit_ctx_t {
|
||||
adc_oneshot_hal_ctx_t hal;
|
||||
uint32_t unit_id;
|
||||
@ -49,7 +46,6 @@ typedef struct adc_oneshot_ctx_t {
|
||||
int apb_periph_ref_cnts; //For the chips that ADC oneshot mode using APB_SARADC periph
|
||||
} adc_oneshot_ctx_t;
|
||||
|
||||
|
||||
static adc_oneshot_ctx_t s_ctx; //ADC oneshot mode context
|
||||
static atomic_bool s_adc_unit_claimed[SOC_ADC_PERIPH_NUM] = {ATOMIC_VAR_INIT(false),
|
||||
#if (SOC_ADC_PERIPH_NUM >= 2)
|
||||
@ -57,12 +53,10 @@ ATOMIC_VAR_INIT(false)
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
static bool s_adc_unit_claim(adc_unit_t unit);
|
||||
static bool s_adc_unit_free(adc_unit_t unit);
|
||||
static esp_err_t s_adc_io_init(adc_unit_t unit, adc_channel_t channel);
|
||||
|
||||
|
||||
esp_err_t adc_oneshot_io_to_channel(int io_num, adc_unit_t * const unit_id, adc_channel_t * const channel)
|
||||
{
|
||||
return adc_io_to_channel(io_num, unit_id, channel);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -85,13 +85,17 @@ static const uint32_t adc2_vref_atten_offset[4] = {63, 66, 89, 128};
|
||||
|
||||
//20 Point lookup tables, covering ADC readings from 2880 to 4096, step size of 64
|
||||
static const uint32_t lut_adc1_low[LUT_POINTS] = {2240, 2297, 2352, 2405, 2457, 2512, 2564, 2616, 2664, 2709,
|
||||
2754, 2795, 2832, 2868, 2903, 2937, 2969, 3000, 3030, 3060};
|
||||
2754, 2795, 2832, 2868, 2903, 2937, 2969, 3000, 3030, 3060
|
||||
};
|
||||
static const uint32_t lut_adc1_high[LUT_POINTS] = {2667, 2706, 2745, 2780, 2813, 2844, 2873, 2901, 2928, 2956,
|
||||
2982, 3006, 3032, 3059, 3084, 3110, 3135, 3160, 3184, 3209};
|
||||
2982, 3006, 3032, 3059, 3084, 3110, 3135, 3160, 3184, 3209
|
||||
};
|
||||
static const uint32_t lut_adc2_low[LUT_POINTS] = {2238, 2293, 2347, 2399, 2451, 2507, 2561, 2613, 2662, 2710,
|
||||
2754, 2792, 2831, 2869, 2904, 2937, 2968, 2999, 3029, 3059};
|
||||
2754, 2792, 2831, 2869, 2904, 2937, 2968, 2999, 3029, 3059
|
||||
};
|
||||
static const uint32_t lut_adc2_high[LUT_POINTS] = {2657, 2698, 2738, 2774, 2807, 2838, 2867, 2894, 2921, 2946,
|
||||
2971, 2996, 3020, 3043, 3067, 3092, 3116, 3139, 3162, 3185};
|
||||
2971, 2996, 3020, 3043, 3067, 3092, 3116, 3139, 3162, 3185
|
||||
};
|
||||
|
||||
/* ----------------------- EFuse Access Functions --------------------------- */
|
||||
static bool check_efuse_vref(void)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -20,7 +20,6 @@
|
||||
|
||||
const static char LOG_TAG[] = "ADC_CALI";
|
||||
|
||||
|
||||
/* ------------------------ Characterization Constants ---------------------- */
|
||||
|
||||
// coeff_a is actually a float number
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -81,7 +81,6 @@ typedef struct {
|
||||
} ref_data;
|
||||
} adc_calib_info_t;
|
||||
|
||||
|
||||
//To get the reference point (Dout, Vin)
|
||||
static esp_err_t get_reference_point(int version_num, adc_unit_t adc_num, adc_atten_t atten, adc_calib_info_t *calib_info)
|
||||
{
|
||||
|
@ -46,7 +46,6 @@ esp_err_t esp_adc_cal_get_voltage(adc_channel_t channel,
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#if ESP_ADC_CAL_CURVE_FITTING_SUPPORTED
|
||||
/*------------------------------------------------------------------------------
|
||||
* Private API
|
||||
|
@ -44,7 +44,6 @@ int32_t esp_adc_cal_get_reading_error(const esp_adc_error_calc_param_t *param, u
|
||||
|
||||
#endif //#if ESP_ADC_CAL_CURVE_FITTING_SUPPORTED
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -44,7 +44,6 @@ typedef struct {
|
||||
} esp_adc_cal_characteristics_t;
|
||||
#endif //#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -88,17 +88,20 @@ static const uint32_t adc2_vref_atten_offset[4] = {63, 66, 89, 128};
|
||||
|
||||
//20 Point lookup tables, covering ADC readings from 2880 to 4096, step size of 64
|
||||
static const uint32_t lut_adc1_low[LUT_POINTS] = {2240, 2297, 2352, 2405, 2457, 2512, 2564, 2616, 2664, 2709,
|
||||
2754, 2795, 2832, 2868, 2903, 2937, 2969, 3000, 3030, 3060};
|
||||
2754, 2795, 2832, 2868, 2903, 2937, 2969, 3000, 3030, 3060
|
||||
};
|
||||
static const uint32_t lut_adc1_high[LUT_POINTS] = {2667, 2706, 2745, 2780, 2813, 2844, 2873, 2901, 2928, 2956,
|
||||
2982, 3006, 3032, 3059, 3084, 3110, 3135, 3160, 3184, 3209};
|
||||
2982, 3006, 3032, 3059, 3084, 3110, 3135, 3160, 3184, 3209
|
||||
};
|
||||
static const uint32_t lut_adc2_low[LUT_POINTS] = {2238, 2293, 2347, 2399, 2451, 2507, 2561, 2613, 2662, 2710,
|
||||
2754, 2792, 2831, 2869, 2904, 2937, 2968, 2999, 3029, 3059};
|
||||
2754, 2792, 2831, 2869, 2904, 2937, 2968, 2999, 3029, 3059
|
||||
};
|
||||
static const uint32_t lut_adc2_high[LUT_POINTS] = {2657, 2698, 2738, 2774, 2807, 2838, 2867, 2894, 2921, 2946,
|
||||
2971, 2996, 3020, 3043, 3067, 3092, 3116, 3139, 3162, 3185};
|
||||
2971, 2996, 3020, 3043, 3067, 3092, 3116, 3139, 3162, 3185
|
||||
};
|
||||
|
||||
const __attribute__((unused)) static char *TAG = "adc_cali";
|
||||
|
||||
|
||||
/* ----------------------- EFuse Access Functions --------------------------- */
|
||||
static bool check_efuse_vref(void);
|
||||
static bool check_efuse_tp(void);
|
||||
@ -107,7 +110,6 @@ static uint32_t read_efuse_vref(void);
|
||||
static uint32_t read_efuse_tp_low(adc_unit_t unit_id);
|
||||
static uint32_t read_efuse_tp_high(adc_unit_t unit_id);
|
||||
|
||||
|
||||
/* ----------------------- Characterization Functions ----------------------- */
|
||||
static void characterize_using_two_point(adc_unit_t unit_id,
|
||||
adc_atten_t atten,
|
||||
@ -121,7 +123,6 @@ static void characterize_using_vref(adc_unit_t unit_id,
|
||||
uint32_t *coeff_a,
|
||||
uint32_t *coeff_b);
|
||||
|
||||
|
||||
/* ------------------------ Conversion Functions --------------------------- */
|
||||
static uint32_t calculate_voltage_linear(uint32_t adc_reading, uint32_t coeff_a, uint32_t coeff_b);
|
||||
//Only call when ADC reading is above threshold
|
||||
@ -133,11 +134,9 @@ static inline uint32_t interpolate_two_points(uint32_t y1, uint32_t y2, uint32_t
|
||||
return ((y1 * x_step) + (y2 * x) - (y1 * x) + (x_step / 2)) / x_step;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------ Interface Functions --------------------------- */
|
||||
static esp_err_t cali_raw_to_voltage(void *arg, int raw, int *voltage);
|
||||
|
||||
|
||||
/* ------------------------ Context Structure--------------------------- */
|
||||
typedef struct {
|
||||
adc_unit_t unit_id; ///< ADC unit
|
||||
@ -151,7 +150,6 @@ typedef struct {
|
||||
adc_cali_line_fitting_efuse_val_t efuse_val; ///< Type of calibration value used in characterization
|
||||
} cali_chars_line_fitting_t;
|
||||
|
||||
|
||||
/* ------------------------- Public API ------------------------------------- */
|
||||
esp_err_t adc_cali_create_scheme_line_fitting(const adc_cali_line_fitting_config_t *config, adc_cali_handle_t *ret_handle)
|
||||
{
|
||||
@ -350,7 +348,6 @@ static uint32_t read_efuse_tp_high(adc_unit_t unit_id)
|
||||
return ret; //Reading of ADC at 850mV
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------- Characterization Functions ----------------------- */
|
||||
static void characterize_using_two_point(adc_unit_t unit_id,
|
||||
adc_atten_t atten,
|
||||
@ -400,7 +397,6 @@ static void characterize_using_vref(adc_unit_t unit_id,
|
||||
*coeff_b = atten_offsets[atten];
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------ Conversion Functions --------------------------- */
|
||||
static uint32_t calculate_voltage_linear(uint32_t adc_reading, uint32_t coeff_a, uint32_t coeff_b)
|
||||
{
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "esp_adc/adc_cali_scheme.h"
|
||||
#include "adc_cali_interface.h"
|
||||
|
||||
|
||||
/**
|
||||
* This file contains Line Fitting Calibration Scheme for ESP32C2.
|
||||
*
|
||||
@ -30,7 +29,6 @@
|
||||
* 5. Only build this file, when `ADC_CALI_SCHEME_LINE_FITTING_V2_SUPPORTED == true`
|
||||
*/
|
||||
|
||||
|
||||
// coeff_a is actually a float number
|
||||
// it is scaled to put them into uint32_t so that the headers do not have to be changed
|
||||
static const int coeff_a_scaling = 65536;
|
||||
@ -43,7 +41,6 @@ typedef struct {
|
||||
uint32_t coeff_b; ///< Offset of ADC-Voltage characteristics
|
||||
} cali_chars_line_fitting_t;
|
||||
|
||||
|
||||
/* ------------------------ Interface Functions --------------------------- */
|
||||
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);
|
||||
@ -107,7 +104,6 @@ esp_err_t adc_cali_delete_scheme_line_fitting(adc_cali_handle_t handle)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------ Interface Functions --------------------------- */
|
||||
static esp_err_t cali_raw_to_voltage(void *arg, int raw, int *voltage)
|
||||
{
|
||||
|
@ -62,7 +62,6 @@ const static int32_t adc1_error_sign[COEFF_VERSION_NUM][COEFF_GROUP_NUM][TERM_MA
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
void curve_fitting_get_second_step_coeff(const adc_cali_curve_fitting_config_t *config, cali_chars_second_step_t *ctx)
|
||||
{
|
||||
uint32_t adc_calib_ver = esp_efuse_rtc_calib_get_ver();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -27,7 +27,6 @@ const __attribute__((unused)) static char *TAG = "adc_cali";
|
||||
static const int coeff_a_scaling = 65536;
|
||||
static const int coeff_b_scaling = 1024;
|
||||
|
||||
|
||||
/* -------------------- Characterization Helper Data Types ------------------ */
|
||||
typedef struct {
|
||||
int adc_calib_high;
|
||||
@ -49,7 +48,6 @@ typedef struct {
|
||||
} efuse_data;
|
||||
} adc_calib_parsed_info_t;
|
||||
|
||||
|
||||
/* ------------------------ Context Structure--------------------------- */
|
||||
typedef struct {
|
||||
adc_unit_t unit_id; ///< ADC unit
|
||||
@ -58,7 +56,6 @@ typedef struct {
|
||||
uint32_t coeff_b; ///< Offset of ADC-Voltage curve
|
||||
} cali_chars_line_fitting_t;
|
||||
|
||||
|
||||
/* ----------------------- Characterization Functions ----------------------- */
|
||||
static bool prepare_calib_data_for(adc_unit_t unit_id, adc_atten_t atten, adc_calib_parsed_info_t *parsed_data_storage);
|
||||
/**
|
||||
@ -82,11 +79,9 @@ static void characterize_using_two_point(adc_unit_t unit_id,
|
||||
* */
|
||||
static bool calculate_characterization_coefficients(const adc_calib_parsed_info_t *parsed_data, cali_chars_line_fitting_t *ctx);
|
||||
|
||||
|
||||
/* ------------------------ Interface Functions --------------------------- */
|
||||
static esp_err_t cali_raw_to_voltage(void *arg, int raw, int *voltage);
|
||||
|
||||
|
||||
/* ------------------------- Public API ------------------------------------- */
|
||||
esp_err_t adc_cali_create_scheme_line_fitting(const adc_cali_line_fitting_config_t *config, adc_cali_handle_t *ret_handle)
|
||||
{
|
||||
@ -142,7 +137,6 @@ esp_err_t adc_cali_delete_scheme_line_fitting(adc_cali_handle_t handle)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------ Interface Functions --------------------------- */
|
||||
static esp_err_t cali_raw_to_voltage(void *arg, int raw, int *voltage)
|
||||
{
|
||||
@ -154,7 +148,6 @@ static esp_err_t cali_raw_to_voltage(void *arg, int raw, int *voltage)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------- Characterization Functions ----------------------- */
|
||||
static bool prepare_calib_data_for(adc_unit_t unit_id, adc_atten_t atten, adc_calib_parsed_info_t *parsed_data_storage)
|
||||
{
|
||||
|
@ -53,7 +53,6 @@ esp_err_t adc_cali_check_scheme(adc_cali_scheme_ver_t *scheme_mask);
|
||||
*/
|
||||
esp_err_t adc_cali_raw_to_voltage(adc_cali_handle_t handle, int raw, int *voltage);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -15,7 +15,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
|
||||
/*---------------------------------------------------------------
|
||||
Curve Fitting Calibration Scheme
|
||||
@ -56,7 +55,6 @@ esp_err_t adc_cali_create_scheme_curve_fitting(const adc_cali_curve_fitting_conf
|
||||
esp_err_t adc_cali_delete_scheme_curve_fitting(adc_cali_handle_t handle);
|
||||
#endif // #if ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED
|
||||
|
||||
|
||||
#if ADC_CALI_SCHEME_LINE_FITTING_SUPPORTED
|
||||
/*---------------------------------------------------------------
|
||||
Line Fitting Calibration Scheme
|
||||
|
@ -16,7 +16,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Driver Backgrounds
|
||||
*
|
||||
@ -239,7 +238,6 @@ esp_err_t adc_continuous_io_to_channel(int io_num, adc_unit_t * const unit_id, a
|
||||
*/
|
||||
esp_err_t adc_continuous_channel_to_io(adc_unit_t unit_id, adc_channel_t channel, int * const io_num);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -31,7 +31,6 @@ typedef struct {
|
||||
adc_digi_iir_filter_coeff_t coeff; ///< ADC filter coefficient
|
||||
} adc_continuous_iir_filter_config_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief New an ADC continuous mode IIR filter
|
||||
*
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "adc_continuous.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -48,7 +47,6 @@ typedef struct {
|
||||
adc_monitor_evt_cb_t on_below_low_thresh; /*!< adc_monitor low value interrupt callback */
|
||||
} adc_monitor_evt_cbs_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Allocate an ADC continuous mode monitor (and configure it into an initial state)
|
||||
*
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "hal/adc_types.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -33,7 +32,6 @@ void adc_apb_periph_claim(void);
|
||||
*/
|
||||
void adc_apb_periph_free(void);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
ADC IOs
|
||||
---------------------------------------------------------------*/
|
||||
@ -64,7 +62,6 @@ esp_err_t adc_io_to_channel(int io_num, adc_unit_t * const unit_id, adc_channel_
|
||||
*/
|
||||
esp_err_t adc_channel_to_io(adc_unit_t unit_id, adc_channel_t channel, int * const io_num);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
ADC Oneshot Read API ISR Version
|
||||
---------------------------------------------------------------*/
|
||||
@ -89,7 +86,6 @@ typedef struct adc_oneshot_unit_ctx_t *adc_oneshot_unit_handle_t;
|
||||
*/
|
||||
esp_err_t adc_oneshot_read_isr(adc_oneshot_unit_handle_t handle, adc_channel_t chan, int *out_raw);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -11,7 +11,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct adc_cali_scheme_t adc_cali_scheme_t;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,6 @@ static const char *TAG_CH[2][10] = {{"ADC1_CH4", "ADC1_CH5"}, {"ADC2_CH0"}};
|
||||
static const char *TAG_CH[2][10] = {{"ADC1_CH2", "ADC1_CH3"}, {"ADC2_CH0"}};
|
||||
#endif
|
||||
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
ADC Oneshot High / Low test
|
||||
---------------------------------------------------------------*/
|
||||
@ -95,7 +94,6 @@ TEST_CASE("ADC oneshot high/low test", "[adc_oneshot]")
|
||||
TEST_ASSERT_INT_WITHIN(ADC_TEST_LOW_THRESH, ADC_TEST_LOW_VAL, adc_raw[1][0]);
|
||||
#endif //#if ADC_TEST_ONESHOT_HIGH_LOW_TEST_ADC2
|
||||
|
||||
|
||||
test_adc_set_io_level(ADC_UNIT_1, ADC1_TEST_CHAN0, 1);
|
||||
TEST_ESP_OK(adc_oneshot_read(adc1_handle, ADC1_TEST_CHAN0, &adc_raw[0][0]));
|
||||
ESP_LOGI(TAG_CH[0][0], "raw data: %d", adc_raw[0][0]);
|
||||
@ -113,15 +111,12 @@ TEST_CASE("ADC oneshot high/low test", "[adc_oneshot]")
|
||||
TEST_ASSERT_INT_WITHIN(ADC_TEST_HIGH_THRESH, ADC_TEST_HIGH_VAL, adc_raw[1][0]);
|
||||
#endif //#if ADC_TEST_ONESHOT_HIGH_LOW_TEST_ADC2
|
||||
|
||||
|
||||
TEST_ESP_OK(adc_oneshot_del_unit(adc1_handle));
|
||||
#if ADC_TEST_ONESHOT_HIGH_LOW_TEST_ADC2
|
||||
TEST_ESP_OK(adc_oneshot_del_unit(adc2_handle));
|
||||
#endif //#if ADC_TEST_ONESHOT_HIGH_LOW_TEST_ADC2
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if SOC_ADC_CALIBRATION_V1_SUPPORTED
|
||||
/*---------------------------------------------------------------
|
||||
ADC Oneshot with Light Sleep
|
||||
@ -267,14 +262,14 @@ TEST_CASE("test ADC2 Single Read with Light Sleep", "[adc][manul][ignore]")
|
||||
|
||||
#endif //#if SOC_ADC_CALIBRATION_V1_SUPPORTED
|
||||
|
||||
|
||||
#if SOC_ADC_MONITOR_SUPPORTED && CONFIG_SOC_ADC_DMA_SUPPORTED
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
#define TEST_ADC_FORMATE_TYPE ADC_DIGI_OUTPUT_FORMAT_TYPE1
|
||||
#else
|
||||
#define TEST_ADC_FORMATE_TYPE ADC_DIGI_OUTPUT_FORMAT_TYPE2
|
||||
#endif
|
||||
bool IRAM_ATTR test_high_cb(adc_monitor_handle_t monitor_handle, const adc_monitor_evt_data_t *event_data, void *user_data){
|
||||
bool IRAM_ATTR test_high_cb(adc_monitor_handle_t monitor_handle, const adc_monitor_evt_data_t *event_data, void *user_data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
TEST_CASE("ADC continuous monitor init_deinit", "[adc]")
|
||||
@ -366,7 +361,6 @@ TEST_CASE("ADC continuous monitor init_deinit", "[adc]")
|
||||
TEST_ESP_OK(adc_continuous_deinit(handle));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NOTE: To run this special feature test case, you need wire ADC channel pin you want to monit
|
||||
* to a wave output pin defined below.
|
||||
@ -386,11 +380,13 @@ TEST_CASE("ADC continuous monitor init_deinit", "[adc]")
|
||||
#define TEST_WAVE_OUT_PIN GPIO_NUM_2 //GPIO_2
|
||||
static uint32_t m1h_cnt, m1l_cnt;
|
||||
|
||||
bool IRAM_ATTR m1h_cb(adc_monitor_handle_t monitor_handle, const adc_monitor_evt_data_t *event_data, void *user_data){
|
||||
bool IRAM_ATTR m1h_cb(adc_monitor_handle_t monitor_handle, const adc_monitor_evt_data_t *event_data, void *user_data)
|
||||
{
|
||||
m1h_cnt ++;
|
||||
return false;
|
||||
}
|
||||
bool IRAM_ATTR m1l_cb(adc_monitor_handle_t monitor_handle, const adc_monitor_evt_data_t *event_data, void *user_data){
|
||||
bool IRAM_ATTR m1l_cb(adc_monitor_handle_t monitor_handle, const adc_monitor_evt_data_t *event_data, void *user_data)
|
||||
{
|
||||
m1l_cnt ++;
|
||||
return false;
|
||||
}
|
||||
@ -451,8 +447,7 @@ TEST_CASE("ADC continuous monitor functionary", "[adc][manual][ignore]")
|
||||
TEST_ESP_OK(adc_continuous_monitor_enable(monitor_handle));
|
||||
TEST_ESP_OK(adc_continuous_start(handle));
|
||||
|
||||
for (uint8_t i=0; i<8; i++)
|
||||
{
|
||||
for (uint8_t i = 0; i < 8; i++) {
|
||||
vTaskDelay(1000);
|
||||
|
||||
// check monitor cb
|
||||
|
@ -59,13 +59,11 @@ static bool IRAM_ATTR s_alarm_callback(gptimer_handle_t timer, const gptimer_ala
|
||||
TEST_ASSERT_INT_WITHIN(ADC_TEST_LOW_THRESH, ADC_TEST_LOW_VAL, adc_raw);
|
||||
}
|
||||
|
||||
|
||||
// check the count value at alarm event
|
||||
vTaskNotifyGiveFromISR(test_ctx->task_handle, &high_task_wakeup);
|
||||
return high_task_wakeup == pdTRUE;
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("ADC oneshot fast work with ISR", "[adc_oneshot]")
|
||||
{
|
||||
static test_adc_isr_ctx_t isr_test_ctx = {};
|
||||
@ -114,7 +112,6 @@ TEST_CASE("ADC oneshot fast work with ISR", "[adc_oneshot]")
|
||||
TEST_ASSERT_NOT_EQUAL(0, ulTaskNotifyTake(pdFALSE, pdMS_TO_TICKS(1000)));
|
||||
TEST_ESP_OK(gptimer_stop(timer));
|
||||
|
||||
|
||||
//ADC IO tile high
|
||||
test_adc_set_io_level(ADC_UNIT_1, ADC1_TEST_CHAN0, 1);
|
||||
isr_test_ctx.level = 1;
|
||||
@ -144,7 +141,6 @@ TEST_CASE("ADC oneshot fast work with ISR", "[adc_oneshot]")
|
||||
|
||||
#define ADC_FRAME_TEST_SIZE 8192
|
||||
|
||||
|
||||
static bool IRAM_ATTR NOINLINE_ATTR s_conv_done_cb_frame_size_test(adc_continuous_handle_t handle, const adc_continuous_evt_data_t *edata, void *user_data)
|
||||
{
|
||||
test_adc_isr_ctx_t *test_ctx = (test_adc_isr_ctx_t *)user_data;
|
||||
@ -215,7 +211,6 @@ TEST_CASE("ADC continuous big conv_frame_size test", "[adc_continuous]")
|
||||
free(result);
|
||||
}
|
||||
|
||||
|
||||
#define ADC_FLUSH_TEST_SIZE 64
|
||||
|
||||
TEST_CASE("ADC continuous flush internal pool", "[adc_continuous][mannual][ignore]")
|
||||
|
@ -43,7 +43,6 @@ extern void spi_flash_enable_interrupts_caches_and_other_cpu(void);
|
||||
__attribute__((unused))
|
||||
static void s_test_cache_disable_period_us(test_adc_iram_ctx_t *ctx, uint32_t period_us);
|
||||
|
||||
|
||||
#if CONFIG_ADC_ONESHOT_CTRL_FUNC_IN_IRAM && CONFIG_GPTIMER_ISR_IRAM_SAFE
|
||||
/*---------------------------------------------------------------
|
||||
ADC oneshot work with cache safe ISR
|
||||
@ -143,7 +142,6 @@ TEST_CASE("ADC oneshot fast work with ISR and Flash", "[adc_oneshot]")
|
||||
}
|
||||
#endif //#if CONFIG_ADC_ONESHOT_CTRL_FUNC_IN_IRAM && CONFIG_GPTIMER_ISR_IRAM_SAFE
|
||||
|
||||
|
||||
#if CONFIG_ADC_CONTINUOUS_ISR_IRAM_SAFE || CONFIG_GDMA_ISR_IRAM_SAFE
|
||||
#include "esp_adc/adc_continuous.h"
|
||||
/*---------------------------------------------------------------
|
||||
@ -181,7 +179,6 @@ static bool IRAM_ATTR NOINLINE_ATTR s_conv_done_cb(adc_continuous_handle_t handl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,6 @@ static float s_print_summary(bool figure)
|
||||
#define ADC_TEST_PKG_SIZE 512
|
||||
#define ADC_TEST_CNT 4096
|
||||
|
||||
|
||||
static bool IRAM_ATTR s_conv_done_cb(adc_continuous_handle_t handle, const adc_continuous_evt_data_t *edata, void *user_data)
|
||||
{
|
||||
BaseType_t mustYield = pdFALSE;
|
||||
@ -389,7 +388,6 @@ TEST_CASE("ADC1 oneshot std_deviation performance", "[adc_oneshot][performance]"
|
||||
#define RECORD_TIME_END(p_time) do{__t2 = esp_cpu_get_cycle_count(); *p_time = (__t2-__t1);}while(0)
|
||||
#define GET_US_BY_CCOUNT(t) ((double)t/CPU_FREQ_MHZ)
|
||||
|
||||
|
||||
//ADC Channels
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#define ADC1_CALI_SPEED_TEST_CHAN0 ADC_CHANNEL_6
|
||||
@ -401,7 +399,6 @@ TEST_CASE("ADC1 oneshot std_deviation performance", "[adc_oneshot][performance]"
|
||||
|
||||
#define TIMES_PER_ATTEN 10
|
||||
|
||||
|
||||
static IRAM_ATTR NOINLINE_ATTR uint32_t get_cali_time_in_ccount(adc_cali_handle_t cali_handle, int adc_raw)
|
||||
{
|
||||
uint32_t time;
|
||||
|
@ -35,7 +35,6 @@ adc_digi_iir_filter_coeff_t g_test_filter_coeff[TEST_FILTER_COEFF_NUMS] = {
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
ADC Calibration
|
||||
---------------------------------------------------------------*/
|
||||
@ -90,7 +89,6 @@ void test_adc_calibration_deinit(adc_cali_handle_t handle)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
ADC GPIO
|
||||
---------------------------------------------------------------*/
|
||||
@ -116,7 +114,6 @@ void test_adc_set_io_level(adc_unit_t unit, adc_channel_t channel, bool level)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void test_adc_set_io_middle(adc_unit_t unit, adc_channel_t channel)
|
||||
{
|
||||
TEST_ASSERT(channel < SOC_ADC_CHANNEL_NUM(unit) && "invalid channel");
|
||||
|
@ -88,7 +88,6 @@ extern "C" {
|
||||
#define ADC_TEST_HIGH_THRESH 200
|
||||
#endif
|
||||
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
ADC Attenuation
|
||||
---------------------------------------------------------------*/
|
||||
@ -133,7 +132,6 @@ bool test_adc_calibration_init(adc_unit_t unit, adc_channel_t channel, adc_atten
|
||||
*/
|
||||
void test_adc_calibration_deinit(adc_cali_handle_t handle);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
ADC GPIO
|
||||
---------------------------------------------------------------*/
|
||||
|
@ -52,7 +52,6 @@ components_not_formatted_temporary:
|
||||
- "/components/cxx/"
|
||||
- "/components/driver/"
|
||||
- "/components/efuse/"
|
||||
- "/components/esp_adc/"
|
||||
- "/components/esp_app_format/"
|
||||
- "/components/esp_bootloader_format/"
|
||||
- "/components/esp_coex/"
|
||||
|
Loading…
Reference in New Issue
Block a user