Separated ADC parameter group code into separate files
This commit is contained in:
parent
a0f6d10b72
commit
725f0dfa26
|
@ -61,6 +61,7 @@ COMMON_SRC = \
|
|||
io/statusindicator.c \
|
||||
io/transponder_ir.c \
|
||||
msp/msp_serial.c \
|
||||
pg/adc.c \
|
||||
scheduler/scheduler.c \
|
||||
sensors/battery.c \
|
||||
sensors/current.c \
|
||||
|
|
|
@ -61,7 +61,7 @@ typedef enum {
|
|||
ADC_CHANNEL_COUNT
|
||||
} AdcChannel;
|
||||
|
||||
typedef struct adc_config_s {
|
||||
typedef struct adcOperatingConfig_s {
|
||||
ioTag_t tag;
|
||||
uint8_t adcChannel; // ADC1_INxx channel number
|
||||
uint8_t dmaIndex; // index into DMA buffer in case of sparse channels
|
||||
|
@ -69,20 +69,8 @@ typedef struct adc_config_s {
|
|||
uint8_t sampleTime;
|
||||
} adcOperatingConfig_t;
|
||||
|
||||
typedef struct adcChannelConfig_t {
|
||||
bool enabled;
|
||||
ioTag_t ioTag;
|
||||
} adcChannelConfig_t;
|
||||
|
||||
typedef struct adcConfig_s {
|
||||
adcChannelConfig_t vbat;
|
||||
adcChannelConfig_t rssi;
|
||||
adcChannelConfig_t current;
|
||||
adcChannelConfig_t external1;
|
||||
int8_t device; // ADCDevice
|
||||
} adcConfig_t;
|
||||
|
||||
void adcInit(const adcConfig_t *config);
|
||||
struct adcConfig_s;
|
||||
void adcInit(const struct adcConfig_s *config);
|
||||
uint16_t adcGetChannel(uint8_t channel);
|
||||
|
||||
#ifndef SITL
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "drivers/adc.h"
|
||||
#include "drivers/io_types.h"
|
||||
#include "rcc_types.h"
|
||||
#include "drivers/rcc_types.h"
|
||||
|
||||
#if defined(STM32F4) || defined(STM32F7)
|
||||
#define ADC_TAG_MAP_COUNT 16
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
#include "rcc.h"
|
||||
#include "dma.h"
|
||||
|
||||
#include "pg/adc.h"
|
||||
|
||||
|
||||
const adcDevice_t adcHardware[] = {
|
||||
{ .ADCx = ADC1, .rccADC = RCC_APB2(ADC1), .DMAy_Channelx = DMA1_Channel1 }
|
||||
};
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
|
||||
#include "common/utils.h"
|
||||
|
||||
#include "pg/adc.h"
|
||||
|
||||
|
||||
const adcDevice_t adcHardware[] = {
|
||||
{ .ADCx = ADC1, .rccADC = RCC_AHB(ADC12), .DMAy_Channelx = DMA1_Channel1 },
|
||||
#ifdef ADC24_DMA_REMAP
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
#include "adc.h"
|
||||
#include "adc_impl.h"
|
||||
|
||||
#include "pg/adc.h"
|
||||
|
||||
|
||||
const adcDevice_t adcHardware[] = {
|
||||
{ .ADCx = ADC1, .rccADC = RCC_APB2(ADC1), .DMAy_Streamx = ADC1_DMA_STREAM, .channel = DMA_Channel_0 },
|
||||
#if !defined(STM32F411xE)
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
#include "adc.h"
|
||||
#include "adc_impl.h"
|
||||
|
||||
#include "pg/adc.h"
|
||||
|
||||
|
||||
#ifndef ADC_INSTANCE
|
||||
#define ADC_INSTANCE ADC1
|
||||
#endif
|
||||
|
|
|
@ -145,9 +145,6 @@ PG_RESET_TEMPLATE(systemConfig_t, systemConfig,
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef USE_ADC
|
||||
PG_REGISTER_WITH_RESET_FN(adcConfig_t, adcConfig, PG_ADC_CONFIG, 0);
|
||||
#endif
|
||||
#ifdef USE_PWM
|
||||
PG_REGISTER_WITH_RESET_FN(pwmConfig_t, pwmConfig, PG_PWM_CONFIG, 0);
|
||||
#endif
|
||||
|
@ -180,35 +177,6 @@ PG_RESET_TEMPLATE(sdcardConfig_t, sdcardConfig,
|
|||
// no template required since defaults are zero
|
||||
PG_REGISTER(vcdProfile_t, vcdProfile, PG_VCD_CONFIG, 0);
|
||||
|
||||
#ifdef USE_ADC
|
||||
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
|
||||
|
||||
|
||||
#if defined(USE_PWM) || defined(USE_PPM)
|
||||
void pgResetFn_ppmConfig(ppmConfig_t *ppmConfig)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#include "config/parameter_group.h"
|
||||
|
||||
#include "drivers/adc.h"
|
||||
#include "drivers/flash.h"
|
||||
#include "drivers/rx_pwm.h"
|
||||
#include "drivers/sdcard.h"
|
||||
|
@ -84,7 +83,6 @@ typedef struct systemConfig_s {
|
|||
|
||||
PG_DECLARE(pilotConfig_t, pilotConfig);
|
||||
PG_DECLARE(systemConfig_t, systemConfig);
|
||||
PG_DECLARE(adcConfig_t, adcConfig);
|
||||
PG_DECLARE(beeperDevConfig_t, beeperDevConfig);
|
||||
PG_DECLARE(flashConfig_t, flashConfig);
|
||||
PG_DECLARE(ppmConfig_t, ppmConfig);
|
||||
|
|
|
@ -80,6 +80,8 @@
|
|||
|
||||
#include "msp/msp_serial.h"
|
||||
|
||||
#include "pg/adc.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
#include "rx/rx_spi.h"
|
||||
#include "rx/spektrum.h"
|
||||
|
|
|
@ -116,6 +116,8 @@ extern uint8_t __config_end;
|
|||
#include "io/vtx_control.h"
|
||||
#include "io/vtx.h"
|
||||
|
||||
#include "pg/adc.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
#include "rx/spektrum.h"
|
||||
#include "../rx/cc2500_frsky_common.h"
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "config/parameter_group.h"
|
||||
#include "config/parameter_group_ids.h"
|
||||
|
||||
#include "drivers/adc.h"
|
||||
#include "drivers/bus_i2c.h"
|
||||
#include "drivers/bus_spi.h"
|
||||
#include "drivers/light_led.h"
|
||||
|
@ -64,6 +65,8 @@
|
|||
#include "io/vtx_control.h"
|
||||
#include "io/vtx_rtc6705.h"
|
||||
|
||||
#include "pg/adc.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
#include "rx/cc2500_frsky_common.h"
|
||||
#include "rx/spektrum.h"
|
||||
|
|
|
@ -77,6 +77,8 @@
|
|||
|
||||
#include "osd_slave/osd_slave_init.h"
|
||||
|
||||
#include "pg/adc.h"
|
||||
|
||||
#include "scheduler/scheduler.h"
|
||||
|
||||
#include "sensors/acceleration.h"
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* 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
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "config/parameter_group.h"
|
||||
#include "drivers/io_types.h"
|
||||
|
||||
typedef struct adcChannelConfig_t {
|
||||
bool enabled;
|
||||
ioTag_t ioTag;
|
||||
} adcChannelConfig_t;
|
||||
|
||||
typedef struct adcConfig_s {
|
||||
adcChannelConfig_t vbat;
|
||||
adcChannelConfig_t rssi;
|
||||
adcChannelConfig_t current;
|
||||
adcChannelConfig_t external1;
|
||||
int8_t device; // ADCDevice
|
||||
} adcConfig_t;
|
||||
|
||||
PG_DECLARE(adcConfig_t, adcConfig);
|
|
@ -30,6 +30,7 @@
|
|||
#include "common/maths.h"
|
||||
#include "common/utils.h"
|
||||
|
||||
#include "drivers/adc.h"
|
||||
#include "drivers/cc2500.h"
|
||||
#include "drivers/io.h"
|
||||
#include "drivers/system.h"
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "sensors/acceleration.h"
|
||||
#include "sensors/gyro.h"
|
||||
|
||||
#include "pg/adc.h"
|
||||
|
||||
#include "hardware_revision.h"
|
||||
|
||||
// alternative defaults settings for BlueJayF4 targets
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "blackbox/blackbox.h"
|
||||
#include "fc/config.h"
|
||||
#include "flight/pid.h"
|
||||
#include "pg/adc.h"
|
||||
#include "telemetry/telemetry.h"
|
||||
|
||||
#include "hardware_revision.h"
|
||||
|
|
Loading…
Reference in New Issue