mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
61 lines
1.6 KiB
C
61 lines
1.6 KiB
C
/*
|
|
* This file is part of Cleanflight.
|
|
*
|
|
* Cleanflight is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Cleanflight is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include "platform.h"
|
|
|
|
#ifdef USE_ADC
|
|
|
|
#include "config/parameter_group.h"
|
|
#include "config/parameter_group_ids.h"
|
|
|
|
#include "drivers/adc_impl.h"
|
|
#include "drivers/io.h"
|
|
|
|
#include "pg/adc.h"
|
|
|
|
|
|
PG_REGISTER_WITH_RESET_FN(adcConfig_t, adcConfig, PG_ADC_CONFIG, 0);
|
|
|
|
void pgResetFn_adcConfig(adcConfig_t *adcConfig)
|
|
{
|
|
adcConfig->device = ADC_DEV_TO_CFG(adcDeviceByInstance(ADC_INSTANCE));
|
|
|
|
#ifdef VBAT_ADC_PIN
|
|
adcConfig->vbat.enabled = true;
|
|
adcConfig->vbat.ioTag = IO_TAG(VBAT_ADC_PIN);
|
|
#endif
|
|
|
|
#ifdef EXTERNAL1_ADC_PIN
|
|
adcConfig->external1.enabled = true;
|
|
adcConfig->external1.ioTag = IO_TAG(EXTERNAL1_ADC_PIN);
|
|
#endif
|
|
|
|
#ifdef CURRENT_METER_ADC_PIN
|
|
adcConfig->current.enabled = true;
|
|
adcConfig->current.ioTag = IO_TAG(CURRENT_METER_ADC_PIN);
|
|
#endif
|
|
|
|
#ifdef RSSI_ADC_PIN
|
|
adcConfig->rssi.enabled = true;
|
|
adcConfig->rssi.ioTag = IO_TAG(RSSI_ADC_PIN);
|
|
#endif
|
|
|
|
}
|
|
#endif // USE_ADC
|