1 /* 2 * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #pragma once 8 9 #include "esp_err.h" 10 #include "esp_bit_defs.h" 11 #include "hal/adc_types.h" 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 /** 18 * @brief ADC calibration handle 19 */ 20 typedef struct adc_cali_scheme_t *adc_cali_handle_t; 21 22 /** 23 * @brief ADC calibration scheme 24 */ 25 typedef enum { 26 ADC_CALI_SCHEME_VER_LINE_FITTING = BIT(0), ///< Line fitting scheme 27 ADC_CALI_SCHEME_VER_CURVE_FITTING = BIT(1), ///< Curve fitting scheme 28 } adc_cali_scheme_ver_t; 29 30 /** 31 * @brief Check the supported ADC calibration scheme 32 * 33 * @param[out] scheme_mask Supported ADC calibration scheme(s) 34 * 35 * @return 36 * - ESP_OK: On success 37 * - ESP_ERR_INVALID_ARG: Invalid argument 38 * - ESP_ERR_NOT_SUPPORTED: No supported calibration scheme 39 */ 40 esp_err_t adc_cali_check_scheme(adc_cali_scheme_ver_t *scheme_mask); 41 42 /** 43 * @brief Convert ADC raw data to calibrated voltage 44 * 45 * @param[in] handle ADC calibration handle 46 * @param[in] raw ADC raw data 47 * @param[out] voltage Calibrated ADC voltage (in mV) 48 * 49 * @return 50 * - ESP_OK: On success 51 * - ESP_ERR_INVALID_ARG: Invalid argument 52 * - ESP_ERR_INVALID_STATE: Invalid state, scheme didn't registered 53 */ 54 esp_err_t adc_cali_raw_to_voltage(adc_cali_handle_t handle, int raw, int *voltage); 55 56 57 #ifdef __cplusplus 58 } 59 #endif 60