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"
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
));
42 adcConfig
->dmaopt
[ADCDEV_1
] = ADC1_DMA_OPT
;
43 // These conditionals need to match the ones used in 'src/main/drivers/adc.h'.
45 adcConfig
->dmaopt
[ADCDEV_2
] = ADC2_DMA_OPT
;
48 adcConfig
->dmaopt
[ADCDEV_3
] = ADC3_DMA_OPT
;
51 adcConfig
->dmaopt
[ADCDEV_4
] = ADC4_DMA_OPT
;
54 adcConfig
->dmaopt
[ADCDEV_5
] = ADC5_DMA_OPT
;
58 adcConfig
->vbat
.enabled
= true;
59 adcConfig
->vbat
.ioTag
= IO_TAG(ADC_VBAT_PIN
);
61 #ifdef ADC_VBAT_INSTANCE
62 adcConfig
->vbat
.device
= ADC_DEV_TO_CFG(adcDeviceByInstance(ADC_VBAT_INSTANCE
));
64 adcConfig
->vbat
.device
= adcConfig
->device
;
69 #ifdef ADC_EXTERNAL1_PIN
70 adcConfig
->external1
.enabled
= true;
71 adcConfig
->external1
.ioTag
= IO_TAG(ADC_EXTERNAL1_PIN
);
73 #ifdef ADC_EXTERNAL1_INSTANCE
74 adcConfig
->external1
.device
= ADC_DEV_TO_CFG(adcDeviceByInstance(ADC_EXTERNAL1_INSTANCE
));
76 adcConfig
->external1
.device
= adcConfig
->device
;
82 adcConfig
->current
.enabled
= true;
83 adcConfig
->current
.ioTag
= IO_TAG(ADC_CURR_PIN
);
85 #ifdef ADC_CURR_INSTANCE
86 adcConfig
->current
.device
= ADC_DEV_TO_CFG(adcDeviceByInstance(ADC_CURR_INSTANCE
));
88 adcConfig
->current
.device
= adcConfig
->device
;
94 adcConfig
->rssi
.enabled
= true;
95 adcConfig
->rssi
.ioTag
= IO_TAG(ADC_RSSI_PIN
);
97 #ifdef ADC_RSSI_INSTANCE
98 adcConfig
->rssi
.device
= ADC_DEV_TO_CFG(adcDeviceByInstance(ADC_RSSI_INSTANCE
));
100 adcConfig
->rssi
.device
= adcConfig
->device
;
105 adcConfig
->vrefIntCalibration
= 0;
106 adcConfig
->tempSensorCalibration1
= 0;
107 adcConfig
->tempSensorCalibration2
= 0;