Configurable ADC internal sensor calibration values
[betaflight.git] / src / main / pg / adc.c
blob493929b9ee10007732361c75e29fe87b3beef9ef
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #include <stdbool.h>
22 #include <stdint.h>
24 #include "platform.h"
26 #ifdef USE_ADC
28 #include "pg/pg.h"
29 #include "pg/pg_ids.h"
31 #include "drivers/adc_impl.h"
32 #include "drivers/io.h"
34 #include "pg/adc.h"
37 PG_REGISTER_WITH_RESET_FN(adcConfig_t, adcConfig, PG_ADC_CONFIG, 0);
39 void pgResetFn_adcConfig(adcConfig_t *adcConfig)
41 adcConfig->device = ADC_DEV_TO_CFG(adcDeviceByInstance(ADC_INSTANCE));
43 #ifdef VBAT_ADC_PIN
44 adcConfig->vbat.enabled = true;
45 adcConfig->vbat.ioTag = IO_TAG(VBAT_ADC_PIN);
46 #endif
48 #ifdef EXTERNAL1_ADC_PIN
49 adcConfig->external1.enabled = true;
50 adcConfig->external1.ioTag = IO_TAG(EXTERNAL1_ADC_PIN);
51 #endif
53 #ifdef CURRENT_METER_ADC_PIN
54 adcConfig->current.enabled = true;
55 adcConfig->current.ioTag = IO_TAG(CURRENT_METER_ADC_PIN);
56 #endif
58 #ifdef RSSI_ADC_PIN
59 adcConfig->rssi.enabled = true;
60 adcConfig->rssi.ioTag = IO_TAG(RSSI_ADC_PIN);
61 #endif
63 adcConfig->vrefIntCalibration = 0;
64 adcConfig->tempSensorCalibration1 = 0;
65 adcConfig->tempSensorCalibration2 = 0;
67 #endif // USE_ADC