adc2_init_cal.c 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /* This file is used to get `adc2_init_code_calibration` executed before the APP when the ADC2 is used by Wi-Fi or other drivers.
  7. The linker will link constructor (adc2_init_code_calibration) only when any sections inside the same file (adc2_cal_include) is used.
  8. Don't put any other code into this file. */
  9. #include "adc2_wifi_private.h"
  10. #include "hal/adc_hal.h"
  11. #include "esp_private/adc_cali.h"
  12. /**
  13. * @brief Set initial code to ADC2 after calibration. ADC2 RTC and ADC2 PWDET controller share the initial code.
  14. * This API be called in before `app_main()`.
  15. */
  16. static __attribute__((constructor)) void adc2_init_code_calibration(void)
  17. {
  18. const adc_ll_num_t adc_n = ADC_NUM_2;
  19. const adc_atten_t atten = ADC_ATTEN_DB_11;
  20. const adc_channel_t channel = 0;
  21. adc_cal_offset(adc_n, channel, atten);
  22. }
  23. /** Don't call `adc2_cal_include` in user code. */
  24. void adc2_cal_include(void)
  25. {
  26. /* When this empty function is called, the `adc2_init_code_calibration` constructor will be linked and executed before the app.*/
  27. }