Align F1 and F3 ADC code.

This commit is contained in:
Dominic Clifton 2014-05-30 15:15:29 +01:00
parent 7e9db61103
commit 3a537d8ef9
4 changed files with 37 additions and 15 deletions

View File

@ -25,6 +25,9 @@ uint16_t adcGetChannel(uint8_t channel)
if (adcConfig[2].enabled) {
debug[2] = adcValues[adcConfig[2].dmaIndex];
}
if (adcConfig[3].enabled) {
debug[3] = adcValues[adcConfig[3].dmaIndex];
}
#endif
return adcValues[adcConfig[channel].dmaIndex];
}

View File

@ -31,6 +31,12 @@ void adcInit(drv_adc_config_t *init)
uint8_t configuredAdcChannels = 0;
memset(&adcConfig, 0, sizeof(adcConfig));
// configure always-present battery index (ADC4)
adcConfig[ADC_BATTERY].adcChannel = ADC_Channel_4;
adcConfig[ADC_BATTERY].dmaIndex = configuredAdcChannels++;
adcConfig[ADC_BATTERY].enabled = true;
adcConfig[ADC_BATTERY].sampleTime = ADC_SampleTime_239Cycles5;
if (init->enableRSSI) {
adcConfig[ADC_RSSI].adcChannel = ADC_Channel_1;
adcConfig[ADC_RSSI].dmaIndex = configuredAdcChannels++;
@ -38,12 +44,14 @@ void adcInit(drv_adc_config_t *init)
adcConfig[ADC_RSSI].sampleTime = ADC_SampleTime_239Cycles5;
}
// configure always-present battery index (ADC4)
adcConfig[ADC_BATTERY].adcChannel = ADC_Channel_4;
adcConfig[ADC_BATTERY].dmaIndex = configuredAdcChannels++;
adcConfig[ADC_BATTERY].enabled = true;
adcConfig[ADC_BATTERY].sampleTime = ADC_SampleTime_239Cycles5;
#ifdef OLIMEXINO
adcConfig[ADC_EXTERNAL1].adcChannel = ADC_Channel_5;
adcConfig[ADC_EXTERNAL1].dmaIndex = configuredAdcChannels++;
adcConfig[ADC_EXTERNAL1].enabled = true;
adcConfig[ADC_EXTERNAL1].sampleTime = ADC_SampleTime_239Cycles5;
#endif
#ifdef NAZE
// optional ADC5 input on rev.5 hardware
if (hse_value == 12000000) {
adcConfig[ADC_EXTERNAL1].adcChannel = ADC_Channel_5;
@ -51,6 +59,7 @@ void adcInit(drv_adc_config_t *init)
adcConfig[ADC_EXTERNAL1].enabled = true;
adcConfig[ADC_EXTERNAL1].sampleTime = ADC_SampleTime_239Cycles5;
}
#endif
if (init->enableCurrentMeter) {
adcConfig[ADC_CURRENT].adcChannel = ADC_Channel_9;
@ -59,6 +68,7 @@ void adcInit(drv_adc_config_t *init)
adcConfig[ADC_CURRENT].sampleTime = ADC_SampleTime_239Cycles5;
}
// ADC driver assumes all the GPIO was already placed in 'AIN' mode
DMA_DeInit(DMA1_Channel1);
dma.DMA_PeripheralBaseAddr = (uint32_t)&ADC1->DR;

View File

@ -31,11 +31,11 @@ void adcInit(drv_adc_config_t *init)
adcChannelCount++;
if (init->enableCurrentMeter) {
adcConfig[ADC_CURRENT].adcChannel = ADC_Channel_7;
adcConfig[ADC_CURRENT].dmaIndex = adcChannelCount;
adcConfig[ADC_CURRENT].sampleTime = ADC_SampleTime_601Cycles5;
adcConfig[ADC_CURRENT].enabled = true;
adcChannelCount++;
adcConfig[ADC_CURRENT].adcChannel = ADC_Channel_7;
adcConfig[ADC_CURRENT].dmaIndex = adcChannelCount;
adcConfig[ADC_CURRENT].sampleTime = ADC_SampleTime_601Cycles5;
adcConfig[ADC_CURRENT].enabled = true;
adcChannelCount++;
}
if (init->enableRSSI) {
@ -46,6 +46,12 @@ void adcInit(drv_adc_config_t *init)
adcChannelCount++;
}
adcConfig[ADC_EXTERNAL1].adcChannel = ADC_Channel_9;
adcConfig[ADC_EXTERNAL1].dmaIndex = adcChannelCount;
adcConfig[ADC_EXTERNAL1].sampleTime = ADC_SampleTime_601Cycles5;
adcConfig[ADC_EXTERNAL1].enabled = true;
adcChannelCount++;
DMA_DeInit(DMA1_Channel1);
DMA_StructInit(&DMA_InitStructure);

View File

@ -65,16 +65,19 @@
#ifdef OLIMEXINO
// OLIMEXINO
#ifdef OLIMEXINO_UNCUT_LED2_E_JUMPER
// LED2 is using one of the pwm pins (PWM2), so we must not use PWM2. @See pwmInit()
//#define OLIMEXINO_UNCUT_LED1_E_JUMPER
//#define OLIMEXINO_UNCUT_LED2_E_JUMPER
#ifdef OLIMEXINO_UNCUT_LED1_E_JUMPER
#define LED0_GPIO GPIOA
#define LED0_PIN Pin_1 // D3, PA1/USART2_RTS/ADC1/TIM2_CH3 - "LED2" on silkscreen, Yellow
#define LED0_PIN Pin_5 // D13, PA5/SPI1_SCK/ADC5 - "LED1" on silkscreen, Green
#define LED0
#endif
#ifdef OLIMEXINO_UNCUT_LED1_E_JUMPER
#ifdef OLIMEXINO_UNCUT_LED2_E_JUMPER
// "LED2" is using one of the PWM pins (CH2/PWM2), so we must not use PWM2 unless the jumper is cut. @See pwmInit()
#define LED1_GPIO GPIOA
#define LED1_PIN Pin_5 // D13, PA5/SPI1_SCK/ADC5 - "LED1" on silkscreen, Green
#define LED1_PIN Pin_1 // D3, PA1/USART2_RTS/ADC1/TIM2_CH3 - "LED2" on silkscreen, Yellow
#define LED1
#endif