2021-05-24 00:02:15 +00:00
|
|
|
/*
|
2022-01-02 08:21:47 +00:00
|
|
|
* SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
|
2021-05-24 00:02:15 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2020-12-23 04:29:57 +00:00
|
|
|
|
|
|
|
/* 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.
|
|
|
|
The linker will link constructor (adc2_init_code_calibration) only when any sections inside the same file (adc2_cal_include) is used.
|
|
|
|
Don't put any other code into this file. */
|
|
|
|
|
|
|
|
#include "hal/adc_hal.h"
|
2022-01-02 08:21:47 +00:00
|
|
|
#include "esp_private/adc2_wifi.h"
|
2021-01-18 13:59:18 +00:00
|
|
|
#include "esp_private/adc_cali.h"
|
2020-12-23 04:29:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set initial code to ADC2 after calibration. ADC2 RTC and ADC2 PWDET controller share the initial code.
|
|
|
|
* This API be called in before `app_main()`.
|
|
|
|
*/
|
|
|
|
static __attribute__((constructor)) void adc2_init_code_calibration(void)
|
|
|
|
{
|
2022-03-08 11:26:04 +00:00
|
|
|
const adc_unit_t adc_n = ADC_UNIT_2;
|
2020-12-23 04:29:57 +00:00
|
|
|
const adc_atten_t atten = ADC_ATTEN_DB_11;
|
2022-03-24 09:45:58 +00:00
|
|
|
adc_cal_offset(adc_n, atten);
|
2020-12-23 04:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Don't call `adc2_cal_include` in user code. */
|
|
|
|
void adc2_cal_include(void)
|
|
|
|
{
|
|
|
|
/* When this empty function is called, the `adc2_init_code_calibration` constructor will be linked and executed before the app.*/
|
|
|
|
}
|