curve_fitting_coefficients.h 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdint.h>
  8. #define COEFF_GROUP_NUM 4
  9. #define TERM_MAX 5
  10. /**
  11. * @note Error Calculation
  12. * Coefficients for calculating the reading voltage error.
  13. * Four sets of coefficients for atten0 ~ atten3 respectively.
  14. *
  15. * For each item, first element is the Coefficient, second element is the Multiple. (Coefficient / Multiple) is the real coefficient.
  16. *
  17. * @note {0,0} stands for unused item
  18. * @note In case of the overflow, these coeffcients are recorded as Absolute Value
  19. * @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);
  20. * @note Above formula is rewritten from the original documentation, please note that the coefficients are re-ordered.
  21. * @note ADC1 and ADC2 use same coeffients
  22. */
  23. extern const uint64_t adc1_error_coef_atten[COEFF_GROUP_NUM][TERM_MAX][2];
  24. extern const uint64_t adc2_error_coef_atten[COEFF_GROUP_NUM][TERM_MAX][2];
  25. /**
  26. * Term sign
  27. */
  28. extern const int32_t adc1_error_sign[COEFF_GROUP_NUM][TERM_MAX];
  29. extern const int32_t adc2_error_sign[COEFF_GROUP_NUM][TERM_MAX];