Exclude a bit more code when USE_ADC is not defined for a target.

This commit is contained in:
Dominic Clifton 2015-01-30 22:43:04 +01:00
parent d21a009d40
commit c85919325c
2 changed files with 17 additions and 1 deletions

View File

@ -18,11 +18,14 @@
#include <stdbool.h>
#include <stdint.h>
#include "build_config.h"
#include "platform.h"
#include "system.h"
#include "adc.h"
#ifdef USE_ADC
adc_config_t adcConfig[ADC_CHANNEL_COUNT];
volatile uint16_t adcValues[ADC_CHANNEL_COUNT];
@ -47,3 +50,10 @@ uint16_t adcGetChannel(uint8_t channel)
return adcValues[adcConfig[channel].dmaIndex];
}
#else
uint16_t adcGetChannel(uint8_t channel)
{
UNUSED(channel);
return 0;
}
#endif

View File

@ -21,6 +21,8 @@
#include <string.h>
#include "build_config.h"
#include "platform.h"
#include "common/maths.h"
@ -59,7 +61,7 @@ bool rxMspInit(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadR
const char rcChannelLetters[] = "AERT12345678abcdefgh";
uint16_t rssi; // range: [0;1023]
uint16_t rssi = 0; // range: [0;1023]
int16_t rcData[MAX_SUPPORTED_RC_CHANNEL_COUNT]; // interval [1000;2000]
@ -377,6 +379,9 @@ void updateRSSIPWM(void)
void updateRSSIADC(uint32_t currentTime)
{
#ifndef USE_ADC
UNUSED(currentTime);
#else
static uint8_t adcRssiSamples[RSSI_ADC_SAMPLE_COUNT];
static uint8_t adcRssiSampleIndex = 0;
static uint32_t rssiUpdateAt = 0;
@ -403,6 +408,7 @@ void updateRSSIADC(uint32_t currentTime)
adcRssiMean = adcRssiMean / RSSI_ADC_SAMPLE_COUNT;
rssi = (uint16_t)((constrain(adcRssiMean, 0, 100) / 100.0f) * 1023.0f);
#endif
}
void updateRSSI(uint32_t currentTime)