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)
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/>.
29 #include "pg/pg_ids.h"
31 #include "drivers/adc.h"
32 #include "drivers/adc_impl.h"
33 #include "drivers/io.h"
38 PG_REGISTER_WITH_RESET_FN(adcConfig_t
, adcConfig
, PG_ADC_CONFIG
, 0);
40 void pgResetFn_adcConfig(adcConfig_t
*adcConfig
)
42 adcConfig
->device
= ADC_DEV_TO_CFG(adcDeviceByInstance(ADC_INSTANCE
));
43 adcConfig
->dmaopt
[ADCDEV_1
] = ADC1_DMA_OPT
;
44 // These conditionals need to match the ones used in 'src/main/drivers/adc.h'.
46 adcConfig
->dmaopt
[ADCDEV_2
] = ADC2_DMA_OPT
;
49 adcConfig
->dmaopt
[ADCDEV_3
] = ADC3_DMA_OPT
;
52 adcConfig
->dmaopt
[ADCDEV_4
] = ADC4_DMA_OPT
;
55 adcConfig
->dmaopt
[ADCDEV_5
] = ADC5_DMA_OPT
;
59 adcConfig
->vbat
.enabled
= true;
60 adcConfig
->vbat
.ioTag
= IO_TAG(VBAT_ADC_PIN
);
62 #ifdef VBAT_ADC_INSTANCE
63 adcConfig
->vbat
.device
= ADC_DEV_TO_CFG(adcDeviceByInstance(VBAT_ADC_INSTANCE
));
65 adcConfig
->vbat
.device
= adcConfig
->device
;
70 #ifdef EXTERNAL1_ADC_PIN
71 adcConfig
->external1
.enabled
= true;
72 adcConfig
->external1
.ioTag
= IO_TAG(EXTERNAL1_ADC_PIN
);
74 #ifdef EXTERNAL1_ADC_INSTANCE
75 adcConfig
->external1
.device
= ADC_DEV_TO_CFG(adcDeviceByInstance(EXTERNAL1_ADC_INSTANCE
));
77 adcConfig
->external1
.device
= adcConfig
->device
;
82 #ifdef CURRENT_METER_ADC_PIN
83 adcConfig
->current
.enabled
= true;
84 adcConfig
->current
.ioTag
= IO_TAG(CURRENT_METER_ADC_PIN
);
86 #ifdef CURRENT_METER_ADC_INSTANCE
87 adcConfig
->current
.device
= ADC_DEV_TO_CFG(adcDeviceByInstance(CURRENT_METER_ADC_INSTANCE
));
89 adcConfig
->current
.device
= adcConfig
->device
;
95 adcConfig
->rssi
.enabled
= true;
96 adcConfig
->rssi
.ioTag
= IO_TAG(RSSI_ADC_PIN
);
98 #ifdef RSSI_ADC_INSTANCE
99 adcConfig
->rssi
.device
= ADC_DEV_TO_CFG(adcDeviceByInstance(RSSI_ADC_INSTANCE
));
101 adcConfig
->rssi
.device
= adcConfig
->device
;
106 adcConfig
->vrefIntCalibration
= 0;
107 adcConfig
->tempSensorCalibration1
= 0;
108 adcConfig
->tempSensorCalibration2
= 0;