mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
refactor(esp_adc): reformat code with astyle_py
This commit is contained in:
@@ -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);
|
||||
/**
|
||||
@@ -71,22 +68,20 @@ static bool prepare_calib_data_for(adc_unit_t unit_id, adc_atten_t atten, adc_ca
|
||||
*
|
||||
*/
|
||||
static void characterize_using_two_point(adc_unit_t unit_id,
|
||||
adc_atten_t atten,
|
||||
uint32_t high,
|
||||
uint32_t low,
|
||||
uint32_t *coeff_a,
|
||||
uint32_t *coeff_b);
|
||||
adc_atten_t atten,
|
||||
uint32_t high,
|
||||
uint32_t low,
|
||||
uint32_t *coeff_a,
|
||||
uint32_t *coeff_b);
|
||||
/*
|
||||
* Estimate the (assumed) linear relationship btwn the measured raw value and the voltage
|
||||
* with the previously done measurement when the chip was manufactured.
|
||||
* */
|
||||
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)
|
||||
{
|
||||
@@ -213,11 +206,11 @@ static bool prepare_calib_data_for(adc_unit_t unit_id, adc_atten_t atten, adc_ca
|
||||
*
|
||||
*/
|
||||
static void characterize_using_two_point(adc_unit_t unit_id,
|
||||
adc_atten_t atten,
|
||||
uint32_t high,
|
||||
uint32_t low,
|
||||
uint32_t *coeff_a,
|
||||
uint32_t *coeff_b)
|
||||
adc_atten_t atten,
|
||||
uint32_t high,
|
||||
uint32_t low,
|
||||
uint32_t *coeff_a,
|
||||
uint32_t *coeff_b)
|
||||
{
|
||||
// once we have recovered the reference high(Dhigh) and low(Dlow) readings, we can calculate a and b from
|
||||
// the measured high and low readings
|
||||
@@ -244,7 +237,7 @@ static bool calculate_characterization_coefficients(const adc_calib_parsed_info_
|
||||
case 2:
|
||||
ESP_LOGD(TAG, "Calib V2, volt%dmV", parsed_data->efuse_data.ver2.adc_calib_high);
|
||||
ctx->coeff_a = coeff_a_scaling * parsed_data->efuse_data.ver2.adc_calib_high_voltage /
|
||||
parsed_data->efuse_data.ver2.adc_calib_high;
|
||||
parsed_data->efuse_data.ver2.adc_calib_high;
|
||||
ctx->coeff_b = 0;
|
||||
break;
|
||||
default:
|
||||
|
Reference in New Issue
Block a user