mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
adc_calib: support calibration v2 on esp32c6
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../curve_fitting_coefficients.h"
|
||||
|
||||
/**
|
||||
* @note Error Calculation
|
||||
@@ -14,12 +15,12 @@
|
||||
* For each item, first element is the Coefficient, second element is the Multiple. (Coefficient / Multiple) is the real coefficient.
|
||||
*
|
||||
* @note {0,0} stands for unused item
|
||||
* @note In case of the overflow, these coeffcients are recorded as Absolute Value
|
||||
* @note In case of the overflow, these coefficients are recorded as Absolute Value
|
||||
* @note For atten0 ~ 2, error = (K0 * X^0) + (K1 * X^1) + (K2 * X^2); For atten3, error = (K0 * X^0) + (K1 * X^1) + (K2 * X^2) + (K3 * X^3) + (K4 * X^4);
|
||||
* @note Above formula is rewritten from the original documentation, please note that the coefficients are re-ordered.
|
||||
* @note ADC1 and ADC2 use same coeffients
|
||||
* @note ADC1 and ADC2 use same coefficients
|
||||
*/
|
||||
const uint64_t adc1_error_coef_atten[4][5][2] = {
|
||||
const static uint64_t adc1_error_coef_atten[COEFF_GROUP_NUM][TERM_MAX][2] = {
|
||||
{{225966470500043, 1e15}, {7265418501948, 1e16}, {109410402681, 1e16}, {0, 0}, {0, 0}}, //atten0
|
||||
{{4229623392600516, 1e16}, {731527490903, 1e16}, {88166562521, 1e16}, {0, 0}, {0, 0}}, //atten1
|
||||
{{1017859239236435, 1e15}, {97159265299153, 1e16}, {149794028038, 1e16}, {0, 0}, {0, 0}}, //atten2
|
||||
@@ -28,9 +29,18 @@ const uint64_t adc1_error_coef_atten[4][5][2] = {
|
||||
/**
|
||||
* Term sign
|
||||
*/
|
||||
const int32_t adc1_error_sign[4][5] = {
|
||||
const static int32_t adc1_error_sign[COEFF_GROUP_NUM][TERM_MAX] = {
|
||||
{-1, -1, 1, 0, 0}, //atten0
|
||||
{ 1, -1, 1, 0, 0}, //atten1
|
||||
{-1, -1, 1, 0, 0}, //atten2
|
||||
{-1, -1, 1, -1, 1} //atten3
|
||||
};
|
||||
|
||||
void curve_fitting_get_second_step_coeff(const adc_cali_curve_fitting_config_t *config, cali_chars_second_step_t *ctx)
|
||||
{
|
||||
ctx->term_num = (config->atten == 3) ? 5 : 3;
|
||||
// On esp32c3, ADC1 and ADC2 share the second step coefficients
|
||||
// And if the target only has 1 ADC peripheral, just use the ADC1 directly
|
||||
ctx->coeff = &adc1_error_coef_atten;
|
||||
ctx->sign = &adc1_error_sign;
|
||||
}
|
||||
|
Reference in New Issue
Block a user