Remove need to specify ADC Channel (only 1 per pin).

This commit is contained in:
blckmn 2016-06-19 21:45:03 +10:00 committed by blckmn
parent 7e6fb8db65
commit 71353066b8
37 changed files with 160 additions and 294 deletions

View File

@ -33,6 +33,14 @@
adc_config_t adcConfig[ADC_CHANNEL_COUNT]; adc_config_t adcConfig[ADC_CHANNEL_COUNT];
volatile uint16_t adcValues[ADC_CHANNEL_COUNT]; volatile uint16_t adcValues[ADC_CHANNEL_COUNT];
uint8_t adcChannelByPin(ioTag_t pin)
{
for (uint8_t i = 0; i < ARRAYLEN(adcPinMap); i++) {
if (pin == adcPinMap[i].pin)
return adcPinMap[i].channel;
}
return 0;
}
uint16_t adcGetChannel(uint8_t channel) uint16_t adcGetChannel(uint8_t channel)
{ {

View File

@ -17,27 +17,52 @@
#pragma once #pragma once
#include "io.h"
#include "rcc.h" #include "rcc.h"
#if defined(STM32F4)
#define ADC_PIN_MAP_COUNT 16
#elif defined(STM32F3)
#define ADC_PIN_MAP_COUNT 39
#else
#define ADC_PIN_MAP_COUNT 10
#endif
typedef enum ADCDevice { typedef enum ADCDevice {
ADCINVALID = -1, ADCINVALID = -1,
ADCDEV_1 = 0, ADCDEV_1 = 0,
#if defined(STM32F3)
ADCDEV_2,
ADCDEV_MAX = ADCDEV_2,
#elif defined(STM32F4)
ADCDEV_2, ADCDEV_2,
ADCDEV_3, ADCDEV_3,
ADCDEV_MAX = ADCDEV_3, ADCDEV_MAX = ADCDEV_3,
#else
ADCDEV_MAX = ADCDEV_1,
#endif
} ADCDevice; } ADCDevice;
typedef struct adcPinMap_s {
ioTag_t pin;
uint8_t channel;
} adcPinMap_t;
typedef struct adcDevice_s { typedef struct adcDevice_s {
ADC_TypeDef* ADCx; ADC_TypeDef* ADCx;
rccPeriphTag_t rccADC; rccPeriphTag_t rccADC;
rccPeriphTag_t rccDMA; rccPeriphTag_t rccDMA;
#if defined(STM32F4) #if defined(STM32F4)
DMA_Stream_TypeDef* DMAy_Streamx; DMA_Stream_TypeDef* DMAy_Streamx;
uint32_t channel;
#else #else
DMA_Channel_TypeDef* DMAy_Channelx; DMA_Channel_TypeDef* DMAy_Channelx;
#endif #endif
} adcDevice_t; } adcDevice_t;
extern const adcDevice_t adcHardware[]; extern const adcDevice_t adcHardware[];
extern const adcPinMap_t adcPinMap[ADC_PIN_MAP_COUNT];
extern adc_config_t adcConfig[ADC_CHANNEL_COUNT]; extern adc_config_t adcConfig[ADC_CHANNEL_COUNT];
extern volatile uint16_t adcValues[ADC_CHANNEL_COUNT]; extern volatile uint16_t adcValues[ADC_CHANNEL_COUNT];
uint8_t adcChannelByPin(ioTag_t pin);

View File

@ -54,6 +54,19 @@ ADCDevice adcDeviceByInstance(ADC_TypeDef *instance)
return ADCINVALID; return ADCINVALID;
} }
const adcPinMap_t adcPinMap[] = {
{ .pin = DEFIO_TAG_E__PA0, .channel = ADC_Channel_0 }, // ADC12
{ .pin = DEFIO_TAG_E__PA1, .channel = ADC_Channel_1 }, // ADC12
{ .pin = DEFIO_TAG_E__PA2, .channel = ADC_Channel_2 }, // ADC12
{ .pin = DEFIO_TAG_E__PA3, .channel = ADC_Channel_3 }, // ADC12
{ .pin = DEFIO_TAG_E__PA4, .channel = ADC_Channel_4 }, // ADC12
{ .pin = DEFIO_TAG_E__PA5, .channel = ADC_Channel_5 }, // ADC12
{ .pin = DEFIO_TAG_E__PA6, .channel = ADC_Channel_6 }, // ADC12
{ .pin = DEFIO_TAG_E__PA7, .channel = ADC_Channel_7 }, // ADC12
{ .pin = DEFIO_TAG_E__PB0, .channel = ADC_Channel_8 }, // ADC12
{ .pin = DEFIO_TAG_E__PB1, .channel = ADC_Channel_9 }, // ADC12
};
// Driver for STM32F103CB onboard ADC // Driver for STM32F103CB onboard ADC
// //
// Naze32 // Naze32
@ -80,7 +93,7 @@ void adcInit(drv_adc_config_t *init)
if (init->enableVBat) { if (init->enableVBat) {
IOInit(IOGetByTag(IO_TAG(VBAT_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC); IOInit(IOGetByTag(IO_TAG(VBAT_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC);
IOConfigGPIO(IOGetByTag(IO_TAG(VBAT_ADC_PIN)), IO_CONFIG(GPIO_Mode_AIN, 0)); IOConfigGPIO(IOGetByTag(IO_TAG(VBAT_ADC_PIN)), IO_CONFIG(GPIO_Mode_AIN, 0));
adcConfig[ADC_BATTERY].adcChannel = VBAT_ADC_CHANNEL; adcConfig[ADC_BATTERY].adcChannel = adcChannelByPin(IO_TAG(VBAT_ADC_PIN));
adcConfig[ADC_BATTERY].dmaIndex = configuredAdcChannels++; adcConfig[ADC_BATTERY].dmaIndex = configuredAdcChannels++;
adcConfig[ADC_BATTERY].enabled = true; adcConfig[ADC_BATTERY].enabled = true;
adcConfig[ADC_BATTERY].sampleTime = ADC_SampleTime_239Cycles5; adcConfig[ADC_BATTERY].sampleTime = ADC_SampleTime_239Cycles5;
@ -91,7 +104,7 @@ void adcInit(drv_adc_config_t *init)
if (init->enableRSSI) { if (init->enableRSSI) {
IOInit(IOGetByTag(IO_TAG(RSSI_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC); IOInit(IOGetByTag(IO_TAG(RSSI_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC);
IOConfigGPIO(IOGetByTag(IO_TAG(RSSI_ADC_PIN)), IO_CONFIG(GPIO_Mode_AIN, 0)); IOConfigGPIO(IOGetByTag(IO_TAG(RSSI_ADC_PIN)), IO_CONFIG(GPIO_Mode_AIN, 0));
adcConfig[ADC_RSSI].adcChannel = RSSI_ADC_CHANNEL; adcConfig[ADC_RSSI].adcChannel = adcChannelByPin(IO_TAG(RSSI_ADC_PIN));
adcConfig[ADC_RSSI].dmaIndex = configuredAdcChannels++; adcConfig[ADC_RSSI].dmaIndex = configuredAdcChannels++;
adcConfig[ADC_RSSI].enabled = true; adcConfig[ADC_RSSI].enabled = true;
adcConfig[ADC_RSSI].sampleTime = ADC_SampleTime_239Cycles5; adcConfig[ADC_RSSI].sampleTime = ADC_SampleTime_239Cycles5;
@ -102,7 +115,7 @@ void adcInit(drv_adc_config_t *init)
if (init->enableExternal1) { if (init->enableExternal1) {
IOInit(IOGetByTag(IO_TAG(EXTERNAL1_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC); IOInit(IOGetByTag(IO_TAG(EXTERNAL1_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC);
IOConfigGPIO(IOGetByTag(IO_TAG(EXTERNAL1_ADC_PIN)), IO_CONFIG(GPIO_Mode_AIN, 0)); IOConfigGPIO(IOGetByTag(IO_TAG(EXTERNAL1_ADC_PIN)), IO_CONFIG(GPIO_Mode_AIN, 0));
adcConfig[ADC_EXTERNAL1].adcChannel = EXTERNAL1_ADC_CHANNEL; adcConfig[ADC_EXTERNAL1].adcChannel = adcChannelByPin(IO_TAG(EXTERNAL1_ADC_PIN));
adcConfig[ADC_EXTERNAL1].dmaIndex = configuredAdcChannels++; adcConfig[ADC_EXTERNAL1].dmaIndex = configuredAdcChannels++;
adcConfig[ADC_EXTERNAL1].enabled = true; adcConfig[ADC_EXTERNAL1].enabled = true;
adcConfig[ADC_EXTERNAL1].sampleTime = ADC_SampleTime_239Cycles5; adcConfig[ADC_EXTERNAL1].sampleTime = ADC_SampleTime_239Cycles5;
@ -113,7 +126,7 @@ void adcInit(drv_adc_config_t *init)
if (init->enableCurrentMeter) { if (init->enableCurrentMeter) {
IOInit(IOGetByTag(IO_TAG(CURRENT_METER_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC); IOInit(IOGetByTag(IO_TAG(CURRENT_METER_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC);
IOConfigGPIO(IOGetByTag(IO_TAG(CURRENT_METER_ADC_PIN)), IO_CONFIG(GPIO_Mode_AIN, 0)); IOConfigGPIO(IOGetByTag(IO_TAG(CURRENT_METER_ADC_PIN)), IO_CONFIG(GPIO_Mode_AIN, 0));
adcConfig[ADC_CURRENT].adcChannel = CURRENT_METER_ADC_CHANNEL; adcConfig[ADC_CURRENT].adcChannel = adcChannelByPin(IO_TAG(CURRENT_METER_ADC_PIN));
adcConfig[ADC_CURRENT].dmaIndex = configuredAdcChannels++; adcConfig[ADC_CURRENT].dmaIndex = configuredAdcChannels++;
adcConfig[ADC_CURRENT].enabled = true; adcConfig[ADC_CURRENT].enabled = true;
adcConfig[ADC_CURRENT].sampleTime = ADC_SampleTime_239Cycles5; adcConfig[ADC_CURRENT].sampleTime = ADC_SampleTime_239Cycles5;

View File

@ -41,6 +41,48 @@ const adcDevice_t adcHardware[] = {
{ .ADCx = ADC2, .rccADC = RCC_AHB(ADC12), .rccDMA = RCC_AHB(DMA2), .DMAy_Channelx = DMA2_Channel1 } { .ADCx = ADC2, .rccADC = RCC_AHB(ADC12), .rccDMA = RCC_AHB(DMA2), .DMAy_Channelx = DMA2_Channel1 }
}; };
const adcPinMap_t adcPinMap[] = {
{ .pin = DEFIO_TAG_E__PA0, .channel = ADC_Channel_1 }, // ADC1
{ .pin = DEFIO_TAG_E__PA1, .channel = ADC_Channel_2 }, // ADC1
{ .pin = DEFIO_TAG_E__PA2, .channel = ADC_Channel_3 }, // ADC1
{ .pin = DEFIO_TAG_E__PA3, .channel = ADC_Channel_4 }, // ADC1
{ .pin = DEFIO_TAG_E__PA4, .channel = ADC_Channel_1 }, // ADC2
{ .pin = DEFIO_TAG_E__PA5, .channel = ADC_Channel_2 }, // ADC2
{ .pin = DEFIO_TAG_E__PA6, .channel = ADC_Channel_3 }, // ADC2
{ .pin = DEFIO_TAG_E__PA7, .channel = ADC_Channel_4 }, // ADC2
{ .pin = DEFIO_TAG_E__PB0, .channel = ADC_Channel_12 }, // ADC3
{ .pin = DEFIO_TAG_E__PB1, .channel = ADC_Channel_1 }, // ADC3
{ .pin = DEFIO_TAG_E__PB2, .channel = ADC_Channel_12 }, // ADC2
{ .pin = DEFIO_TAG_E__PB12, .channel = ADC_Channel_3 }, // ADC4
{ .pin = DEFIO_TAG_E__PB13, .channel = ADC_Channel_5 }, // ADC3
{ .pin = DEFIO_TAG_E__PB14, .channel = ADC_Channel_4 }, // ADC4
{ .pin = DEFIO_TAG_E__PB15, .channel = ADC_Channel_5 }, // ADC4
{ .pin = DEFIO_TAG_E__PC0, .channel = ADC_Channel_6 }, // ADC12
{ .pin = DEFIO_TAG_E__PC1, .channel = ADC_Channel_7 }, // ADC12
{ .pin = DEFIO_TAG_E__PC2, .channel = ADC_Channel_8 }, // ADC12
{ .pin = DEFIO_TAG_E__PC3, .channel = ADC_Channel_9 }, // ADC12
{ .pin = DEFIO_TAG_E__PC4, .channel = ADC_Channel_5 }, // ADC2
{ .pin = DEFIO_TAG_E__PC5, .channel = ADC_Channel_11 }, // ADC2
{ .pin = DEFIO_TAG_E__PD8, .channel = ADC_Channel_12 }, // ADC4
{ .pin = DEFIO_TAG_E__PD9, .channel = ADC_Channel_13 }, // ADC4
{ .pin = DEFIO_TAG_E__PD10, .channel = ADC_Channel_7 }, // ADC34
{ .pin = DEFIO_TAG_E__PD11, .channel = ADC_Channel_8 }, // ADC34
{ .pin = DEFIO_TAG_E__PD12, .channel = ADC_Channel_9 }, // ADC34
{ .pin = DEFIO_TAG_E__PD13, .channel = ADC_Channel_10 }, // ADC34
{ .pin = DEFIO_TAG_E__PD14, .channel = ADC_Channel_11 }, // ADC34
{ .pin = DEFIO_TAG_E__PE7, .channel = ADC_Channel_13 }, // ADC3
{ .pin = DEFIO_TAG_E__PE8, .channel = ADC_Channel_6 }, // ADC34
{ .pin = DEFIO_TAG_E__PE9, .channel = ADC_Channel_2 }, // ADC3
{ .pin = DEFIO_TAG_E__PE10, .channel = ADC_Channel_14 }, // ADC3
{ .pin = DEFIO_TAG_E__PE11, .channel = ADC_Channel_15 }, // ADC3
{ .pin = DEFIO_TAG_E__PE12, .channel = ADC_Channel_16 }, // ADC3
{ .pin = DEFIO_TAG_E__PE13, .channel = ADC_Channel_3 }, // ADC3
{ .pin = DEFIO_TAG_E__PE14, .channel = ADC_Channel_1 }, // ADC4
{ .pin = DEFIO_TAG_E__PE15, .channel = ADC_Channel_2 }, // ADC4
{ .pin = DEFIO_TAG_E__PF2, .channel = ADC_Channel_10 }, // ADC12
{ .pin = DEFIO_TAG_E__PF4, .channel = ADC_Channel_5 }, // ADC1
};
ADCDevice adcDeviceByInstance(ADC_TypeDef *instance) ADCDevice adcDeviceByInstance(ADC_TypeDef *instance)
{ {
if (instance == ADC1) if (instance == ADC1)
@ -68,7 +110,7 @@ void adcInit(drv_adc_config_t *init)
IOInit(IOGetByTag(IO_TAG(VBAT_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC); IOInit(IOGetByTag(IO_TAG(VBAT_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC);
IOConfigGPIO(IOGetByTag(IO_TAG(VBAT_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL)); IOConfigGPIO(IOGetByTag(IO_TAG(VBAT_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL));
adcConfig[ADC_BATTERY].adcChannel = VBAT_ADC_CHANNEL; adcConfig[ADC_BATTERY].adcChannel = adcChannelByPin(IO_TAG(VBAT_ADC_PIN));
adcConfig[ADC_BATTERY].dmaIndex = adcChannelCount; adcConfig[ADC_BATTERY].dmaIndex = adcChannelCount;
adcConfig[ADC_BATTERY].sampleTime = ADC_SampleTime_601Cycles5; adcConfig[ADC_BATTERY].sampleTime = ADC_SampleTime_601Cycles5;
adcConfig[ADC_BATTERY].enabled = true; adcConfig[ADC_BATTERY].enabled = true;
@ -81,7 +123,7 @@ void adcInit(drv_adc_config_t *init)
IOInit(IOGetByTag(IO_TAG(RSSI_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC); IOInit(IOGetByTag(IO_TAG(RSSI_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC);
IOConfigGPIO(IOGetByTag(IO_TAG(RSSI_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL)); IOConfigGPIO(IOGetByTag(IO_TAG(RSSI_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL));
adcConfig[ADC_RSSI].adcChannel = RSSI_ADC_CHANNEL; adcConfig[ADC_RSSI].adcChannel = adcChannelByPin(IO_TAG(RSSI_ADC_PIN));
adcConfig[ADC_RSSI].dmaIndex = adcChannelCount; adcConfig[ADC_RSSI].dmaIndex = adcChannelCount;
adcConfig[ADC_RSSI].sampleTime = ADC_SampleTime_601Cycles5; adcConfig[ADC_RSSI].sampleTime = ADC_SampleTime_601Cycles5;
adcConfig[ADC_RSSI].enabled = true; adcConfig[ADC_RSSI].enabled = true;
@ -94,7 +136,7 @@ void adcInit(drv_adc_config_t *init)
IOInit(IOGetByTag(IO_TAG(CURRENT_METER_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC); IOInit(IOGetByTag(IO_TAG(CURRENT_METER_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC);
IOConfigGPIO(IOGetByTag(IO_TAG(CURRENT_METER_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL)); IOConfigGPIO(IOGetByTag(IO_TAG(CURRENT_METER_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL));
adcConfig[ADC_CURRENT].adcChannel = CURRENT_METER_ADC_CHANNEL; adcConfig[ADC_CURRENT].adcChannel = adcChannelByPin(IO_TAG(CURRENT_METER_ADC_PIN));
adcConfig[ADC_CURRENT].dmaIndex = adcChannelCount; adcConfig[ADC_CURRENT].dmaIndex = adcChannelCount;
adcConfig[ADC_CURRENT].sampleTime = ADC_SampleTime_601Cycles5; adcConfig[ADC_CURRENT].sampleTime = ADC_SampleTime_601Cycles5;
adcConfig[ADC_CURRENT].enabled = true; adcConfig[ADC_CURRENT].enabled = true;
@ -107,7 +149,7 @@ void adcInit(drv_adc_config_t *init)
IOInit(IOGetByTag(IO_TAG(EXTERNAL1_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC); IOInit(IOGetByTag(IO_TAG(EXTERNAL1_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC);
IOConfigGPIO(IOGetByTag(IO_TAG(EXTERNAL1_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL)); IOConfigGPIO(IOGetByTag(IO_TAG(EXTERNAL1_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL));
adcConfig[ADC_EXTERNAL1].adcChannel = EXTERNAL1_ADC_CHANNEL; adcConfig[ADC_EXTERNAL1].adcChannel = adcChannelByPin(IO_TAG(EXTERNAL1_ADC_PIN));
adcConfig[ADC_EXTERNAL1].dmaIndex = adcChannelCount; adcConfig[ADC_EXTERNAL1].dmaIndex = adcChannelCount;
adcConfig[ADC_EXTERNAL1].sampleTime = ADC_SampleTime_601Cycles5; adcConfig[ADC_EXTERNAL1].sampleTime = ADC_SampleTime_601Cycles5;
adcConfig[ADC_EXTERNAL1].enabled = true; adcConfig[ADC_EXTERNAL1].enabled = true;

View File

@ -23,6 +23,7 @@
#include "system.h" #include "system.h"
#include "io.h" #include "io.h"
#include "io_impl.h"
#include "rcc.h" #include "rcc.h"
#include "sensors/sensors.h" // FIXME dependency into the main code #include "sensors/sensors.h" // FIXME dependency into the main code
@ -38,8 +39,38 @@
#endif #endif
const adcDevice_t adcHardware[] = { const adcDevice_t adcHardware[] = {
{ .ADCx = ADC1, .rccADC = RCC_APB2(ADC1), .rccDMA = RCC_AHB1(DMA2), .DMAy_Streamx = DMA2_Stream4 }, { .ADCx = ADC1, .rccADC = RCC_APB2(ADC1), .rccDMA = RCC_AHB1(DMA2), .DMAy_Streamx = DMA2_Stream4, .channel = DMA_Channel_0 },
//{ .ADCx = ADC2, .rccADC = RCC_APB2(ADC2), .rccDMA = RCC_AHB1(DMA2), .DMAy_Streamx = DMA2_Stream1 } //{ .ADCx = ADC2, .rccADC = RCC_APB2(ADC2), .rccDMA = RCC_AHB1(DMA2), .DMAy_Streamx = DMA2_Stream1, .channel = DMA_Channel_0 }
};
/* note these could be packed up for saving space */
const adcPinMap_t adcPinMap[] = {
/*
{ .pin = DEFIO_TAG_E__PF3, .channel = ADC_Channel_9 },
{ .pin = DEFIO_TAG_E__PF4, .channel = ADC_Channel_14 },
{ .pin = DEFIO_TAG_E__PF5, .channel = ADC_Channel_15 },
{ .pin = DEFIO_TAG_E__PF6, .channel = ADC_Channel_4 },
{ .pin = DEFIO_TAG_E__PF7, .channel = ADC_Channel_5 },
{ .pin = DEFIO_TAG_E__PF8, .channel = ADC_Channel_6 },
{ .pin = DEFIO_TAG_E__PF9, .channel = ADC_Channel_7 },
{ .pin = DEFIO_TAG_E__PF10, .channel = ADC_Channel_8 },
*/
{ .pin = DEFIO_TAG_E__PC0, .channel = ADC_Channel_10 },
{ .pin = DEFIO_TAG_E__PC1, .channel = ADC_Channel_11 },
{ .pin = DEFIO_TAG_E__PC2, .channel = ADC_Channel_12 },
{ .pin = DEFIO_TAG_E__PC3, .channel = ADC_Channel_13 },
{ .pin = DEFIO_TAG_E__PC4, .channel = ADC_Channel_14 },
{ .pin = DEFIO_TAG_E__PC5, .channel = ADC_Channel_15 },
{ .pin = DEFIO_TAG_E__PB0, .channel = ADC_Channel_8 },
{ .pin = DEFIO_TAG_E__PB1, .channel = ADC_Channel_9 },
{ .pin = DEFIO_TAG_E__PA0, .channel = ADC_Channel_0 },
{ .pin = DEFIO_TAG_E__PA1, .channel = ADC_Channel_1 },
{ .pin = DEFIO_TAG_E__PA2, .channel = ADC_Channel_2 },
{ .pin = DEFIO_TAG_E__PA3, .channel = ADC_Channel_3 },
{ .pin = DEFIO_TAG_E__PA4, .channel = ADC_Channel_4 },
{ .pin = DEFIO_TAG_E__PA5, .channel = ADC_Channel_5 },
{ .pin = DEFIO_TAG_E__PA6, .channel = ADC_Channel_6 },
{ .pin = DEFIO_TAG_E__PA7, .channel = ADC_Channel_7 },
}; };
ADCDevice adcDeviceByInstance(ADC_TypeDef *instance) ADCDevice adcDeviceByInstance(ADC_TypeDef *instance)
@ -47,11 +78,12 @@ ADCDevice adcDeviceByInstance(ADC_TypeDef *instance)
if (instance == ADC1) if (instance == ADC1)
return ADCDEV_1; return ADCDEV_1;
/* /*
if (instance == ADC2) if (instance == ADC2) // TODO add ADC2 and 3
return ADCDEV_2; return ADCDEV_2;
*/ */
return ADCINVALID; return ADCINVALID;
} }
void adcInit(drv_adc_config_t *init) void adcInit(drv_adc_config_t *init)
{ {
ADC_InitTypeDef ADC_InitStructure; ADC_InitTypeDef ADC_InitStructure;
@ -70,7 +102,7 @@ void adcInit(drv_adc_config_t *init)
if (init->enableVBat) { if (init->enableVBat) {
IOInit(IOGetByTag(IO_TAG(VBAT_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC); IOInit(IOGetByTag(IO_TAG(VBAT_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC);
IOConfigGPIO(IOGetByTag(IO_TAG(VBAT_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL)); IOConfigGPIO(IOGetByTag(IO_TAG(VBAT_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL));
adcConfig[ADC_BATTERY].adcChannel = VBAT_ADC_CHANNEL; adcConfig[ADC_BATTERY].adcChannel = adcChannelByPin(IO_TAG(VBAT_ADC_PIN)); //VBAT_ADC_CHANNEL;
adcConfig[ADC_BATTERY].dmaIndex = configuredAdcChannels++; adcConfig[ADC_BATTERY].dmaIndex = configuredAdcChannels++;
adcConfig[ADC_BATTERY].enabled = true; adcConfig[ADC_BATTERY].enabled = true;
adcConfig[ADC_BATTERY].sampleTime = ADC_SampleTime_480Cycles; adcConfig[ADC_BATTERY].sampleTime = ADC_SampleTime_480Cycles;
@ -81,7 +113,7 @@ void adcInit(drv_adc_config_t *init)
if (init->enableExternal1) { if (init->enableExternal1) {
IOInit(IOGetByTag(IO_TAG(EXTERNAL1_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC); IOInit(IOGetByTag(IO_TAG(EXTERNAL1_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC);
IOConfigGPIO(IOGetByTag(IO_TAG(EXTERNAL1_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL)); IOConfigGPIO(IOGetByTag(IO_TAG(EXTERNAL1_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL));
adcConfig[ADC_EXTERNAL1].adcChannel = EXTERNAL1_ADC_CHANNEL; adcConfig[ADC_EXTERNAL1].adcChannel = adcChannelByPin(IO_TAG(EXTERNAL1_ADC_PIN)); //EXTERNAL1_ADC_CHANNEL;
adcConfig[ADC_EXTERNAL1].dmaIndex = configuredAdcChannels++; adcConfig[ADC_EXTERNAL1].dmaIndex = configuredAdcChannels++;
adcConfig[ADC_EXTERNAL1].enabled = true; adcConfig[ADC_EXTERNAL1].enabled = true;
adcConfig[ADC_EXTERNAL1].sampleTime = ADC_SampleTime_480Cycles; adcConfig[ADC_EXTERNAL1].sampleTime = ADC_SampleTime_480Cycles;
@ -92,7 +124,7 @@ void adcInit(drv_adc_config_t *init)
if (init->enableRSSI) { if (init->enableRSSI) {
IOInit(IOGetByTag(IO_TAG(RSSI_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC); IOInit(IOGetByTag(IO_TAG(RSSI_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC);
IOConfigGPIO(IOGetByTag(IO_TAG(RSSI_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL)); IOConfigGPIO(IOGetByTag(IO_TAG(RSSI_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL));
adcConfig[ADC_RSSI].adcChannel = RSSI_ADC_CHANNEL; adcConfig[ADC_RSSI].adcChannel = adcChannelByPin(IO_TAG(RSSI_ADC_PIN)); //RSSI_ADC_CHANNEL;
adcConfig[ADC_RSSI].dmaIndex = configuredAdcChannels++; adcConfig[ADC_RSSI].dmaIndex = configuredAdcChannels++;
adcConfig[ADC_RSSI].enabled = true; adcConfig[ADC_RSSI].enabled = true;
adcConfig[ADC_RSSI].sampleTime = ADC_SampleTime_480Cycles; adcConfig[ADC_RSSI].sampleTime = ADC_SampleTime_480Cycles;
@ -103,7 +135,7 @@ void adcInit(drv_adc_config_t *init)
if (init->enableCurrentMeter) { if (init->enableCurrentMeter) {
IOInit(IOGetByTag(IO_TAG(CURRENT_METER_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC); IOInit(IOGetByTag(IO_TAG(CURRENT_METER_ADC_PIN)), OWNER_SYSTEM, RESOURCE_ADC);
IOConfigGPIO(IOGetByTag(IO_TAG(CURRENT_METER_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL)); IOConfigGPIO(IOGetByTag(IO_TAG(CURRENT_METER_ADC_PIN)), IO_CONFIG(GPIO_Mode_AN, 0, GPIO_OType_OD, GPIO_PuPd_NOPULL));
adcConfig[ADC_CURRENT].adcChannel = CURRENT_METER_ADC_CHANNEL; adcConfig[ADC_CURRENT].adcChannel = adcChannelByPin(IO_TAG(CURRENT_METER_ADC_PIN)); //CURRENT_METER_ADC_CHANNEL;
adcConfig[ADC_CURRENT].dmaIndex = configuredAdcChannels++; adcConfig[ADC_CURRENT].dmaIndex = configuredAdcChannels++;
adcConfig[ADC_CURRENT].enabled = true; adcConfig[ADC_CURRENT].enabled = true;
adcConfig[ADC_CURRENT].sampleTime = ADC_SampleTime_480Cycles; adcConfig[ADC_CURRENT].sampleTime = ADC_SampleTime_480Cycles;
@ -125,7 +157,7 @@ void adcInit(drv_adc_config_t *init)
DMA_StructInit(&DMA_InitStructure); DMA_StructInit(&DMA_InitStructure);
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&adc.ADCx->DR; DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&adc.ADCx->DR;
DMA_InitStructure.DMA_Channel = DMA_Channel_0; DMA_InitStructure.DMA_Channel = adc.channel;
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)adcValues; DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)adcValues;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMA_InitStructure.DMA_BufferSize = configuredAdcChannels; DMA_InitStructure.DMA_BufferSize = configuredAdcChannels;

View File

@ -23,7 +23,9 @@ typedef enum {
OWNER_FLASH, OWNER_FLASH,
OWNER_USB, OWNER_USB,
OWNER_BEEPER, OWNER_BEEPER,
OWNER_OSD OWNER_OSD,
OWNER_BARO,
OWNER_TOTAL_COUNT
} resourceOwner_t; } resourceOwner_t;
// Currently TIMER should be shared resource (softserial dualtimer and timerqueue needs to allocate timer channel, but pin can be used for other function) // Currently TIMER should be shared resource (softserial dualtimer and timerqueue needs to allocate timer channel, but pin can be used for other function)

View File

@ -47,9 +47,10 @@ typedef uint32_t timCCER_t;
typedef uint32_t timSR_t; typedef uint32_t timSR_t;
typedef uint32_t timCNT_t; typedef uint32_t timCNT_t;
#else #else
# error "Unknown CPU defined" #error "Unknown CPU defined"
#endif #endif
// use different types from capture and overflow - multiple overflow handlers are implemented as linked list // use different types from capture and overflow - multiple overflow handlers are implemented as linked list
struct timerCCHandlerRec_s; struct timerCCHandlerRec_s;
struct timerOvrHandlerRec_s; struct timerOvrHandlerRec_s;

View File

@ -3038,7 +3038,7 @@ void cliProcess(void)
} }
} }
const char * const ownerNames[] = { const char * const ownerNames[OWNER_TOTAL_COUNT] = {
"FREE", "FREE",
"PWM IN", "PWM IN",
"PPM IN", "PPM IN",
@ -3060,6 +3060,8 @@ const char * const ownerNames[] = {
"FLASH", "FLASH",
"USB", "USB",
"BEEPER", "BEEPER",
"OSD",
"BARO",
}; };
static void cliResource(char *cmdline) static void cliResource(char *cmdline)

View File

@ -118,13 +118,8 @@
#define USE_ADC #define USE_ADC
#define ADC_INSTANCE ADC2 #define ADC_INSTANCE ADC2
#define ADC_DMA_CHANNEL DMA2_Channel1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
//#define BOARD_HAS_VOLTAGE_DIVIDER //#define BOARD_HAS_VOLTAGE_DIVIDER
#define VBAT_ADC_PIN PA4 #define VBAT_ADC_PIN PA4
#define VBAT_ADC_CHANNEL ADC_Channel_1
// alternative defaults for AlienFlight F3 target // alternative defaults for AlienFlight F3 target
#define ALIENFLIGHT #define ALIENFLIGHT

View File

@ -152,18 +152,10 @@
#define USE_ADC #define USE_ADC
//#define BOARD_HAS_VOLTAGE_DIVIDER //#define BOARD_HAS_VOLTAGE_DIVIDER
#define VBAT_ADC_PIN PC0 #define VBAT_ADC_PIN PC0
#define VBAT_ADC_CHANNEL ADC_Channel_1
#define CURRENT_METER_ADC_PIN PC1 #define CURRENT_METER_ADC_PIN PC1
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_0
#define RSSI_ADC_PIN PC4 #define RSSI_ADC_PIN PC4
#define RSSI_ADC_CHANNEL ADC_Channel_4
#define EXTERNAL1_ADC_GPIO_PIN PC5 #define EXTERNAL1_ADC_GPIO_PIN PC5
#define EXTERNAL1_ADC_CHANNEL ADC_Channel_5
// LED strip configuration using RC5 pin. // LED strip configuration using RC5 pin.
//#define LED_STRIP //#define LED_STRIP

View File

@ -138,7 +138,6 @@
#define USE_ADC #define USE_ADC
#define VBAT_ADC_PIN PC3 #define VBAT_ADC_PIN PC3
#define VBAT_ADC_CHANNEL ADC_Channel_13
#define DEFAULT_RX_FEATURE FEATURE_RX_PPM #define DEFAULT_RX_FEATURE FEATURE_RX_PPM
#define USE_SERIAL_4WAY_BLHELI_INTERFACE #define USE_SERIAL_4WAY_BLHELI_INTERFACE

View File

@ -92,15 +92,9 @@
#define I2C_DEVICE (I2CDEV_2) // Flex port - SCL/PB10, SDA/PB11 #define I2C_DEVICE (I2CDEV_2) // Flex port - SCL/PB10, SDA/PB11
#define USE_ADC #define USE_ADC
#define CURRENT_METER_ADC_PIN PB1 #define CURRENT_METER_ADC_PIN PB1
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_9
#define VBAT_ADC_PIN PA0 #define VBAT_ADC_PIN PA0
#define VBAT_ADC_CHANNEL ADC_Channel_0
#define RSSI_ADC_PIN PB0 #define RSSI_ADC_PIN PB0
#define RSSI_ADC_CHANNEL ADC_Channel_8
#define LED_STRIP #define LED_STRIP
#define LED_STRIP_TIMER TIM3 #define LED_STRIP_TIMER TIM3

View File

@ -101,22 +101,11 @@
#define I2C_DEVICE (I2CDEV_1) #define I2C_DEVICE (I2CDEV_1)
#define USE_ADC #define USE_ADC
#define ADC_INSTANCE ADC1 #define ADC_INSTANCE ADC1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA1
#define ADC_DMA_CHANNEL DMA1_Channel1
#define VBAT_ADC_PIN PC0 #define VBAT_ADC_PIN PC0
#define VBAT_ADC_CHANNEL ADC_Channel_6
#define CURRENT_METER_ADC_PIN PC1 #define CURRENT_METER_ADC_PIN PC1
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_7
#define RSSI_ADC_PIN PC2 #define RSSI_ADC_PIN PC2
#define RSSI_ADC_CHANNEL ADC_Channel_8
#define EXTERNAL1_ADC_PIN PC3 #define EXTERNAL1_ADC_PIN PC3
#define EXTERNAL1_ADC_CHANNEL ADC_Channel_9
// IO - assuming 303 in 64pin package, TODO // IO - assuming 303 in 64pin package, TODO
#define TARGET_IO_PORTA 0xffff #define TARGET_IO_PORTA 0xffff

View File

@ -103,16 +103,8 @@
#define USE_I2C #define USE_I2C
#define I2C_DEVICE (I2CDEV_2) #define I2C_DEVICE (I2CDEV_2)
#define I2C2_SCL_GPIO GPIOA #define I2C2_SCL_PIN PA9
#define I2C2_SCL_GPIO_AF GPIO_AF_4 #define I2C2_SDA_PIN PA10
#define I2C2_SCL_PIN GPIO_Pin_9
#define I2C2_SCL_PIN_SOURCE GPIO_PinSource9
#define I2C2_SCL_CLK_SOURCE RCC_AHBPeriph_GPIOA
#define I2C2_SDA_GPIO GPIOA
#define I2C2_SDA_GPIO_AF GPIO_AF_4
#define I2C2_SDA_PIN GPIO_Pin_10
#define I2C2_SDA_PIN_SOURCE GPIO_PinSource10
#define I2C2_SDA_CLK_SOURCE RCC_AHBPeriph_GPIOA
#define USE_BST #define USE_BST
#define BST_DEVICE (BSTDEV_1) #define BST_DEVICE (BSTDEV_1)
@ -120,28 +112,17 @@
#define BST_CRC_POLYNOM 0xD5 #define BST_CRC_POLYNOM 0xD5
#define USE_ADC #define USE_ADC
#define ADC_INSTANCE ADC1 #define ADC_INSTANCE ADC1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA1
#define ADC_DMA_CHANNEL DMA1_Channel1
#define BOARD_HAS_VOLTAGE_DIVIDER #define BOARD_HAS_VOLTAGE_DIVIDER
#define VBAT_ADC_PIN PC0 #define VBAT_ADC_PIN PC0
#define VBAT_ADC_CHANNEL ADC_Channel_6
#define CURRENT_METER_ADC_PIN PC1 #define CURRENT_METER_ADC_PIN PC1
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_7
#define RSSI_ADC_PIN PC2 #define RSSI_ADC_PIN PC2
#define RSSI_ADC_CHANNEL ADC_Channel_8
#define EXTERNAL1_ADC_PIN PC3 #define EXTERNAL1_ADC_PIN PC3
#define EXTERNAL1_ADC_CHANNEL ADC_Channel_9
#define LED_STRIP #define LED_STRIP
#define USE_COLIBTI_RACE_LED_DEFAULT_CONFIG #define USE_COLIBTI_RACE_LED_DEFAULT_CONFIG
#define LED_STRIP_TIMER TIM16 #define LED_STRIP_TIMER TIM16
#define WS2811_GPIO GPIOA #define WS2811_GPIO GPIOA
#define WS2811_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOA #define WS2811_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOA

View File

@ -34,44 +34,29 @@
#define BEEPER_INVERTED #define BEEPER_INVERTED
// tqfp48 pin 3 // tqfp48 pin 3
#define MPU6500_CS_GPIO_CLK_PERIPHERAL RCC_AHBPeriph_GPIOC
#define MPU6500_CS_GPIO GPIOC
#define MPU6500_CS_PIN PC14 #define MPU6500_CS_PIN PC14
#define MPU6500_SPI_INSTANCE SPI1 #define MPU6500_SPI_INSTANCE SPI1
// tqfp48 pin 25 // tqfp48 pin 25
#define BMP280_CS_GPIO_CLK_PERIPHERAL RCC_AHBPeriph_GPIOB #define BMP280_CS_PIN PB12
#define BMP280_CS_GPIO GPIOB
#define BMP280_CS_PIN GPIO_Pin_12
#define BMP280_SPI_INSTANCE SPI2 #define BMP280_SPI_INSTANCE SPI2
#define USE_SPI #define USE_SPI
#define USE_SPI_DEVICE_1 #define USE_SPI_DEVICE_1
#define USE_SPI_DEVICE_2 #define USE_SPI_DEVICE_2
#define SPI1_GPIO GPIOB
#define SPI1_GPIO_PERIPHERAL RCC_AHBPeriph_GPIOB
// tqfp48 pin 39 // tqfp48 pin 39
#define SPI1_SCK_PIN PB3 #define SPI1_SCK_PIN PB3
#define SPI1_SCK_PIN_SOURCE GPIO_PinSource3
// tqfp48 pin 40 // tqfp48 pin 40
#define SPI1_MISO_PIN PB4 #define SPI1_MISO_PIN PB4
#define SPI1_MISO_PIN_SOURCE GPIO_PinSource4
// tqfp48 pin 41 // tqfp48 pin 41
#define SPI1_MOSI_PIN PB5 #define SPI1_MOSI_PIN PB5
#define SPI1_MOSI_PIN_SOURCE GPIO_PinSource5
#define SPI2_GPIO GPIOB
#define SPI2_GPIO_PERIPHERAL RCC_AHBPeriph_GPIOB
// tqfp48 pin 26 // tqfp48 pin 26
#define SPI2_SCK_PIN PB13 #define SPI2_SCK_PIN PB13
#define SPI2_SCK_PIN_SOURCE GPIO_PinSource13
// tqfp48 pin 27 // tqfp48 pin 27
#define SPI2_MISO_PIN PB14 #define SPI2_MISO_PIN PB14
#define SPI2_MISO_PIN_SOURCE GPIO_PinSource14
// tqfp48 pin 28 // tqfp48 pin 28
#define SPI2_MOSI_PIN PB15 #define SPI2_MOSI_PIN PB15
#define SPI2_MOSI_PIN_SOURCE GPIO_PinSource15
#define USE_FLASHFS #define USE_FLASHFS
#define USE_FLASH_M25P16 #define USE_FLASH_M25P16
@ -139,18 +124,9 @@
#define USE_ADC #define USE_ADC
#define BOARD_HAS_VOLTAGE_DIVIDER #define BOARD_HAS_VOLTAGE_DIVIDER
#define ADC_INSTANCE ADC2 #define ADC_INSTANCE ADC2
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
#define ADC_DMA_CHANNEL DMA2_Channel1
// tqfp48 pin 14
#define VBAT_ADC_PIN PA4 #define VBAT_ADC_PIN PA4
#define VBAT_ADC_CHANNEL ADC_Channel_1
// tqfp48 pin 15
#define CURRENT_METER_ADC_PIN PA5 #define CURRENT_METER_ADC_PIN PA5
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_2
// mpu_int definition in sensors/initialisation.c // mpu_int definition in sensors/initialisation.c
#define USE_EXTI #define USE_EXTI

View File

@ -97,18 +97,10 @@
// #define SOFT_I2C_PB67 // #define SOFT_I2C_PB67
#define USE_ADC #define USE_ADC
#define CURRENT_METER_ADC_PIN PB1 #define CURRENT_METER_ADC_PIN PB1
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_9
#define VBAT_ADC_PIN PA4 #define VBAT_ADC_PIN PA4
#define VBAT_ADC_CHANNEL ADC_Channel_4
#define RSSI_ADC_PIN PA1 #define RSSI_ADC_PIN PA1
#define RSSI_ADC_CHANNEL ADC_Channel_1
#define EXTERNAL1_ADC_PIN PA5 #define EXTERNAL1_ADC_PIN PA5
#define EXTERNAL1_ADC_CHANNEL ADC_Channel_5
//#define LED_STRIP //#define LED_STRIP
#define LED_STRIP_TIMER TIM3 #define LED_STRIP_TIMER TIM3

View File

@ -150,22 +150,13 @@
#define USE_ADC #define USE_ADC
#define BOARD_HAS_VOLTAGE_DIVIDER #define BOARD_HAS_VOLTAGE_DIVIDER
#define ADC_INSTANCE ADC1 #define ADC_INSTANCE ADC1
#define ADC_DMA_CHANNEL DMA1_Channel1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA1
#define VBAT_ADC_PIN PA0 #define VBAT_ADC_PIN PA0
#define VBAT_ADC_CHANNEL ADC_Channel_1
#define RSSI_ADC_PIN PA1 #define RSSI_ADC_PIN PA1
#define RSSI_ADC_CHANNEL ADC_Channel_2
#define CURRENT_METER_ADC_PIN PA2 #define CURRENT_METER_ADC_PIN PA2
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_3
#define LED_STRIP #define LED_STRIP
#define LED_STRIP_TIMER TIM1 #define LED_STRIP_TIMER TIM1
#define USE_LED_STRIP_ON_DMA1_CHANNEL2 #define USE_LED_STRIP_ON_DMA1_CHANNEL2
#define WS2811_GPIO GPIOA #define WS2811_GPIO GPIOA

View File

@ -144,15 +144,9 @@
#define USE_ADC #define USE_ADC
#define BOARD_HAS_VOLTAGE_DIVIDER #define BOARD_HAS_VOLTAGE_DIVIDER
#define VBAT_ADC_PIN PC1
#define VBAT_ADC_PIN PC1 #define RSSI_ADC_GPIO_PIN PC2
#define VBAT_ADC_CHANNEL ADC_Channel_11
#define RSSI_ADC_GPIO_PIN PC2
#define RSSI_ADC_CHANNEL ADC_Channel_12
#define CURRENT_METER_ADC_PIN PC3 #define CURRENT_METER_ADC_PIN PC3
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_13
#define DEFAULT_RX_FEATURE FEATURE_RX_PPM #define DEFAULT_RX_FEATURE FEATURE_RX_PPM

View File

@ -85,20 +85,10 @@
#define USE_ADC #define USE_ADC
#define BOARD_HAS_VOLTAGE_DIVIDER #define BOARD_HAS_VOLTAGE_DIVIDER
#define ADC_INSTANCE ADC2 #define ADC_INSTANCE ADC2
#define ADC_DMA_CHANNEL DMA2_Channel1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
#define VBAT_ADC_PIN PA4 #define VBAT_ADC_PIN PA4
#define VBAT_ADC_CHANNEL ADC_Channel_1
#define CURRENT_METER_ADC_PIN PA5 #define CURRENT_METER_ADC_PIN PA5
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_2
#define RSSI_ADC_PIN PB2 #define RSSI_ADC_PIN PB2
#define RSSI_ADC_CHANNEL ADC_Channel_12
#define SPEKTRUM_BIND #define SPEKTRUM_BIND
// USART3, // USART3,

View File

@ -72,20 +72,11 @@
#define USE_I2C #define USE_I2C
#define I2C_DEVICE (I2CDEV_1) // PB6/SCL, PB7/SDA #define I2C_DEVICE (I2CDEV_1) // PB6/SCL, PB7/SDA
//#define USE_ADC
#define ADC_INSTANCE ADC2 #define ADC_INSTANCE ADC2
#define ADC_DMA_CHANNEL DMA2_Channel1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
#define VBAT_ADC_PIN PA4 #define VBAT_ADC_PIN PA4
#define VBAT_ADC_CHANNEL ADC_Channel_1
#define CURRENT_METER_ADC_PIN PA5 #define CURRENT_METER_ADC_PIN PA5
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_2
#define RSSI_ADC_PIN PB2 #define RSSI_ADC_PIN PB2
#define RSSI_ADC_CHANNEL ADC_Channel_12
#define SPEKTRUM_BIND #define SPEKTRUM_BIND

View File

@ -88,23 +88,11 @@
#define I2C_DEVICE (I2CDEV_2) #define I2C_DEVICE (I2CDEV_2)
#define USE_ADC #define USE_ADC
#define ADC_INSTANCE ADC1 #define ADC_INSTANCE ADC1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA1
#define ADC_DMA_CHANNEL DMA1_Channel1
#define VBAT_ADC_PIN PC0 #define VBAT_ADC_PIN PC0
#define VBAT_ADC_CHANNEL ADC_Channel_6
#define CURRENT_METER_ADC_PIN PC1 #define CURRENT_METER_ADC_PIN PC1
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_7
#define RSSI_ADC_PIN PC2 #define RSSI_ADC_PIN PC2
#define RSSI_ADC_CHANNEL ADC_Channel_8
#define EXTERNAL1_ADC_PIN PC3 #define EXTERNAL1_ADC_PIN PC3
#define EXTERNAL1_ADC_CHANNEL ADC_Channel_9
#define LED_STRIP #define LED_STRIP
#define LED_STRIP_TIMER TIM16 #define LED_STRIP_TIMER TIM16

View File

@ -119,19 +119,10 @@
#define USE_ADC #define USE_ADC
#define BOARD_HAS_VOLTAGE_DIVIDER #define BOARD_HAS_VOLTAGE_DIVIDER
#define ADC_INSTANCE ADC2 #define ADC_INSTANCE ADC2
#define ADC_DMA_CHANNEL DMA2_Channel1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
#define VBAT_ADC_PIN PA5 #define VBAT_ADC_PIN PA5
#define VBAT_ADC_CHANNEL ADC_Channel_2
//#define CURRENT_METER_ADC_PIN PA5 //#define CURRENT_METER_ADC_PIN PA5
//#define CURRENT_METER_ADC_CHANNEL ADC_Channel_2
#define RSSI_ADC_PIN PB2 #define RSSI_ADC_PIN PB2
#define RSSI_ADC_CHANNEL ADC_Channel_12
#define LED_STRIP #define LED_STRIP
#if 1 #if 1

View File

@ -147,18 +147,10 @@
// #define SOFT_I2C_PB67 // #define SOFT_I2C_PB67
#define USE_ADC #define USE_ADC
#define CURRENT_METER_ADC_PIN PB1 #define CURRENT_METER_ADC_PIN PB1
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_9
#define VBAT_ADC_PIN PA4 #define VBAT_ADC_PIN PA4
#define VBAT_ADC_CHANNEL ADC_Channel_4
#define RSSI_ADC_PIN PA1 #define RSSI_ADC_PIN PA1
#define RSSI_ADC_CHANNEL ADC_Channel_1
#define EXTERNAL1_ADC_PIN PA5 #define EXTERNAL1_ADC_PIN PA5
#define EXTERNAL1_ADC_CHANNEL ADC_Channel_5
#define LED_STRIP #define LED_STRIP

View File

@ -83,18 +83,10 @@
// #define SOFT_I2C_PB67 // #define SOFT_I2C_PB67
#define USE_ADC #define USE_ADC
#define CURRENT_METER_ADC_PIN PB1 #define CURRENT_METER_ADC_PIN PB1
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_9
#define VBAT_ADC_PIN PA4 #define VBAT_ADC_PIN PA4
#define VBAT_ADC_CHANNEL ADC_Channel_4
#define RSSI_ADC_PIN PA1 #define RSSI_ADC_PIN PA1
#define RSSI_ADC_CHANNEL ADC_Channel_1
#define EXTERNAL1_ADC_PIN PA5 #define EXTERNAL1_ADC_PIN PA5
#define EXTERNAL1_ADC_CHANNEL ADC_Channel_5
//#define LED_STRIP //#define LED_STRIP
//#define LED_STRIP_TIMER TIM3 //#define LED_STRIP_TIMER TIM3

View File

@ -159,19 +159,11 @@
#define USE_ADC #define USE_ADC
#define BOARD_HAS_VOLTAGE_DIVIDER #define BOARD_HAS_VOLTAGE_DIVIDER
#define ADC_INSTANCE ADC2 #define ADC_INSTANCE ADC2
#define ADC_DMA_CHANNEL DMA2_Channel1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
#define VBAT_ADC_PIN PA4 #define VBAT_ADC_PIN PA4
#define VBAT_ADC_CHANNEL ADC_Channel_1
#define CURRENT_METER_ADC_PIN PA5 #define CURRENT_METER_ADC_PIN PA5
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_2
#define RSSI_ADC_PIN PB2 #define RSSI_ADC_PIN PB2
#define RSSI_ADC_CHANNEL ADC_Channel_12
#define LED_STRIP #define LED_STRIP
#define LED_STRIP_TIMER TIM1 #define LED_STRIP_TIMER TIM1

View File

@ -87,19 +87,10 @@
#define USE_ADC #define USE_ADC
#define BOARD_HAS_VOLTAGE_DIVIDER #define BOARD_HAS_VOLTAGE_DIVIDER
#define ADC_INSTANCE ADC2 #define ADC_INSTANCE ADC2
#define ADC_DMA_CHANNEL DMA2_Channel1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
#define CURRENT_METER_ADC_PIN PA2 #define CURRENT_METER_ADC_PIN PA2
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_3
#define VBAT_ADC_PIN PA5 #define VBAT_ADC_PIN PA5
#define VBAT_ADC_CHANNEL ADC_Channel_2
#define RSSI_ADC_PIN PB2 #define RSSI_ADC_PIN PB2
#define RSSI_ADC_CHANNEL ADC_Channel_12
#define LED_STRIP #define LED_STRIP
#if 1 #if 1

View File

@ -38,22 +38,17 @@
#define USE_SPI_DEVICE_2 #define USE_SPI_DEVICE_2
#define PORT103R_SPI_INSTANCE SPI2 #define PORT103R_SPI_INSTANCE SPI2
#define PORT103R_SPI_CS_GPIO GPIOB
#define PORT103R_SPI_CS_PIN PB12 #define PORT103R_SPI_CS_PIN PB12
// We either have this 16mbit flash chip on SPI or the MPU6500 acc/gyro depending on board revision: // We either have this 16mbit flash chip on SPI or the MPU6500 acc/gyro depending on board revision:
#define M25P16_CS_GPIO PORT103R_SPI_CS_GPIO
#define M25P16_CS_PIN PORT103R_SPI_CS_PIN #define M25P16_CS_PIN PORT103R_SPI_CS_PIN
#define M25P16_SPI_INSTANCE PORT103R_SPI_INSTANCE #define M25P16_SPI_INSTANCE PORT103R_SPI_INSTANCE
#define MPU6000_CS_GPIO PORT103R_SPI_CS_GPIO
#define MPU6000_CS_PIN PORT103R_SPI_CS_PIN #define MPU6000_CS_PIN PORT103R_SPI_CS_PIN
#define MPU6000_SPI_INSTANCE PORT103R_SPI_INSTANCE #define MPU6000_SPI_INSTANCE PORT103R_SPI_INSTANCE
#define MPU6500_CS_GPIO PORT103R_SPI_CS_GPIO
#define MPU6500_CS_PIN PORT103R_SPI_CS_PIN #define MPU6500_CS_PIN PORT103R_SPI_CS_PIN
#define MPU6500_SPI_INSTANCE PORT103R_SPI_INSTANCE #define MPU6500_SPI_INSTANCE PORT103R_SPI_INSTANCE
#define MPU6500_CS_GPIO_CLK_PERIPHERAL RCC_APB2Periph_GPIOB
#define GYRO #define GYRO
#define USE_FAKE_GYRO #define USE_FAKE_GYRO
@ -115,18 +110,10 @@
// #define SOFT_I2C_PB67 // #define SOFT_I2C_PB67
#define USE_ADC #define USE_ADC
#define CURRENT_METER_ADC_PIN PB1 #define CURRENT_METER_ADC_PIN PB1
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_9
#define VBAT_ADC_PIN PA4 #define VBAT_ADC_PIN PA4
#define VBAT_ADC_CHANNEL ADC_Channel_4
#define RSSI_ADC_PIN PA1 #define RSSI_ADC_PIN PA1
#define RSSI_ADC_CHANNEL ADC_Channel_1
#define EXTERNAL1_ADC_PIN PA5 #define EXTERNAL1_ADC_PIN PA5
#define EXTERNAL1_ADC_CHANNEL ADC_Channel_5
//#define LED_STRIP //#define LED_STRIP
//#define LED_STRIP_TIMER TIM3 //#define LED_STRIP_TIMER TIM3

View File

@ -32,11 +32,11 @@
#define USBD_SERIALNUMBER_STRING "0x8020000" #define USBD_SERIALNUMBER_STRING "0x8020000"
#endif #endif
#define LED0 PB5 #define LED0 PB5
#define LED1 PB4 #define LED1 PB4
#define BEEPER PB4 #define BEEPER PB4
#define INVERTER PC0 // PC0 used as inverter select GPIO #define INVERTER PC0 // PC0 used as inverter select GPIO
#define INVERTER_USART USART1 #define INVERTER_USART USART1
#define MPU6000_CS_PIN PA4 #define MPU6000_CS_PIN PA4
#define MPU6000_SPI_INSTANCE SPI1 #define MPU6000_SPI_INSTANCE SPI1
@ -110,14 +110,10 @@
#define USE_ADC #define USE_ADC
#define CURRENT_METER_ADC_PIN PC1 #define CURRENT_METER_ADC_PIN PC1
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_11
#define VBAT_ADC_PIN PC2 #define VBAT_ADC_PIN PC2
#define VBAT_ADC_CHANNEL ADC_Channel_12
#define RSSI_ADC_GPIO_PIN PA0 #define RSSI_ADC_GPIO_PIN PA0
#define RSSI_ADC_CHANNEL ADC_Channel_0
#define SENSORS_SET (SENSOR_ACC) #define SENSORS_SET (SENSOR_ACC)
//#define LED_STRIP //#define LED_STRIP

View File

@ -87,18 +87,9 @@
#define I2C_DEVICE (I2CDEV_3) #define I2C_DEVICE (I2CDEV_3)
#define USE_ADC #define USE_ADC
//FLEXI-IO 6
#define CURRENT_METER_ADC_PIN PA7 #define CURRENT_METER_ADC_PIN PA7
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_7
//FLEXI-IO 7
#define VBAT_ADC_PIN PA6 #define VBAT_ADC_PIN PA6
#define VBAT_ADC_CHANNEL ADC_Channel_6
//FLEXI-IO 8
#define RSSI_ADC_PIN PA5 #define RSSI_ADC_PIN PA5
#define RSSI_ADC_CHANNEL ADC_Channel_5
//#define SENSORS_SET (SENSOR_ACC|SENSOR_MAG) //#define SENSORS_SET (SENSOR_ACC|SENSOR_MAG)

View File

@ -106,20 +106,10 @@
#define USE_ADC #define USE_ADC
#define BOARD_HAS_VOLTAGE_DIVIDER #define BOARD_HAS_VOLTAGE_DIVIDER
#define ADC_INSTANCE ADC2 #define ADC_INSTANCE ADC2
#define ADC_DMA_CHANNEL DMA2_Channel1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
#define VBAT_ADC_PIN PA4 #define VBAT_ADC_PIN PA4
#define VBAT_ADC_CHANNEL ADC_Channel_1
#define CURRENT_METER_ADC_PIN PA5 #define CURRENT_METER_ADC_PIN PA5
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_2
#define RSSI_ADC_PIN PB2 #define RSSI_ADC_PIN PB2
#define RSSI_ADC_CHANNEL ADC_Channel_12
#define LED_STRIP #define LED_STRIP
#define LED_STRIP_TIMER TIM1 #define LED_STRIP_TIMER TIM1

View File

@ -94,11 +94,7 @@
#define BOARD_HAS_VOLTAGE_DIVIDER #define BOARD_HAS_VOLTAGE_DIVIDER
#define ADC_INSTANCE ADC2 #define ADC_INSTANCE ADC2
#define ADC_DMA_CHANNEL DMA2_Channel1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
#define VBAT_ADC_PIN PB2 #define VBAT_ADC_PIN PB2
#define VBAT_ADC_CHANNEL ADC_Channel_12
#define LED_STRIP #define LED_STRIP
#define LED_STRIP_TIMER TIM1 #define LED_STRIP_TIMER TIM1

View File

@ -140,11 +140,7 @@
#define BOARD_HAS_VOLTAGE_DIVIDER #define BOARD_HAS_VOLTAGE_DIVIDER
#define ADC_INSTANCE ADC1 #define ADC_INSTANCE ADC1
#define ADC_DMA_CHANNEL DMA1_Channel1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA1
#define VBAT_ADC_PIN PA0 #define VBAT_ADC_PIN PA0
#define VBAT_ADC_CHANNEL ADC_Channel_1
//#define USE_QUAD_MIXER_ONLY //#define USE_QUAD_MIXER_ONLY
#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT #define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT

View File

@ -88,16 +88,9 @@
#define I2C_DEVICE (I2CDEV_2) // SDA (PA10/AF4), SCL (PA9/AF4) #define I2C_DEVICE (I2CDEV_2) // SDA (PA10/AF4), SCL (PA9/AF4)
#define USE_ADC #define USE_ADC
#define ADC_INSTANCE ADC2 #define ADC_INSTANCE ADC2
#define ADC_DMA_CHANNEL DMA2_Channel1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
#define VBAT_ADC_PIN PA4 #define VBAT_ADC_PIN PA4
#define VBAT_ADC_CHANNEL ADC_Channel_1
#define CURRENT_METER_ADC_PIN PA7 #define CURRENT_METER_ADC_PIN PA7
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_4
#define DEFAULT_RX_FEATURE FEATURE_RX_PPM #define DEFAULT_RX_FEATURE FEATURE_RX_PPM

View File

@ -114,20 +114,10 @@
#define USE_ADC #define USE_ADC
#define BOARD_HAS_VOLTAGE_DIVIDER #define BOARD_HAS_VOLTAGE_DIVIDER
#define ADC_INSTANCE ADC2 #define ADC_INSTANCE ADC2
#define ADC_DMA_CHANNEL DMA2_Channel1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
#define VBAT_ADC_PIN PA4 #define VBAT_ADC_PIN PA4
#define VBAT_ADC_CHANNEL ADC_Channel_1
#define CURRENT_METER_ADC_PIN PA5 #define CURRENT_METER_ADC_PIN PA5
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_2
#define RSSI_ADC_PIN PB2 #define RSSI_ADC_PIN PB2
#define RSSI_ADC_CHANNEL ADC_Channel_12
#define LED_STRIP #define LED_STRIP
#define LED_STRIP_TIMER TIM1 #define LED_STRIP_TIMER TIM1

View File

@ -136,19 +136,10 @@
#define USE_ADC #define USE_ADC
#define BOARD_HAS_VOLTAGE_DIVIDER #define BOARD_HAS_VOLTAGE_DIVIDER
#define ADC_INSTANCE ADC2 #define ADC_INSTANCE ADC2
#define ADC_DMA_CHANNEL DMA2_Channel1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
#define VBAT_ADC_PIN PA4 #define VBAT_ADC_PIN PA4
#define VBAT_ADC_CHANNEL ADC_Channel_1
#define CURRENT_METER_ADC_PIN PA5 #define CURRENT_METER_ADC_PIN PA5
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_2
#define RSSI_ADC_PIN PB2 #define RSSI_ADC_PIN PB2
#define RSSI_ADC_CHANNEL ADC_Channel_12
#define LED_STRIP #define LED_STRIP
#define LED_STRIP_TIMER TIM1 #define LED_STRIP_TIMER TIM1

View File

@ -145,17 +145,9 @@
#define ADC_INSTANCE ADC2 #define ADC_INSTANCE ADC2
#define ADC_DMA_CHANNEL DMA2_Channel1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA2
#define VBAT_ADC_PIN PA4 #define VBAT_ADC_PIN PA4
#define VBAT_ADC_CHANNEL ADC_Channel_1
#define CURRENT_METER_ADC_PIN PA5 #define CURRENT_METER_ADC_PIN PA5
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_2
#define RSSI_ADC_PIN PB2 #define RSSI_ADC_PIN PB2
#define RSSI_ADC_CHANNEL ADC_Channel_12
#define LED_STRIP #define LED_STRIP
#define LED_STRIP_TIMER TIM1 #define LED_STRIP_TIMER TIM1

View File

@ -139,22 +139,11 @@
#define I2C_DEVICE (I2CDEV_1) #define I2C_DEVICE (I2CDEV_1)
#define USE_ADC #define USE_ADC
#define ADC_INSTANCE ADC1 #define ADC_INSTANCE ADC1
#define ADC_AHB_PERIPHERAL RCC_AHBPeriph_DMA1
#define ADC_DMA_CHANNEL DMA1_Channel1
#define VBAT_ADC_PIN PC0 #define VBAT_ADC_PIN PC0
#define VBAT_ADC_CHANNEL ADC_Channel_6
#define CURRENT_METER_ADC_PIN PC1 #define CURRENT_METER_ADC_PIN PC1
#define CURRENT_METER_ADC_CHANNEL ADC_Channel_7
#define RSSI_ADC_PIN PC2 #define RSSI_ADC_PIN PC2
#define RSSI_ADC_CHANNEL ADC_Channel_8
#define EXTERNAL1_ADC_PIN PC3 #define EXTERNAL1_ADC_PIN PC3
#define EXTERNAL1_ADC_CHANNEL ADC_Channel_9
#define LED_STRIP #define LED_STRIP
#define LED_STRIP_TIMER TIM16 #define LED_STRIP_TIMER TIM16