mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
Comment out some unused variables in the PIOS_ADC structure for now since they
were consuming lots of memory. Probably should make a simple adc version that just queries the line when needed since we are only using this data at 500 ms. However, the accumulator scheme in place is quite good for averaging over time.
This commit is contained in:
parent
bbb14f5f14
commit
af8d65616e
@ -55,15 +55,6 @@
|
||||
//
|
||||
#define SAMPLE_PERIOD_MS 500
|
||||
|
||||
//#define ENABLE_DEBUG_MSG
|
||||
|
||||
#ifdef ENABLE_DEBUG_MSG
|
||||
#define DEBUG_PORT PIOS_COM_GPS
|
||||
#define DEBUG_MSG(format, ...) PIOS_COM_SendFormattedString(DEBUG_PORT, format, ## __VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_MSG(format, ...)
|
||||
#endif
|
||||
|
||||
// Private types
|
||||
|
||||
// Private variables
|
||||
@ -101,8 +92,8 @@ static void onTimer(UAVObjEvent* ev)
|
||||
FlightBatterySettingsGet(&batterySettings);
|
||||
|
||||
//calculate the battery parameters
|
||||
flightBatteryData.Voltage = ((float)PIOS_ADC_PinGet(1)) * batterySettings.SensorCalibrations[FLIGHTBATTERYSETTINGS_SENSORCALIBRATIONS_VOLTAGEFACTOR]; //in Volts
|
||||
flightBatteryData.Current = ((float)PIOS_ADC_PinGet(0)) * batterySettings.SensorCalibrations[FLIGHTBATTERYSETTINGS_SENSORCALIBRATIONS_CURRENTFACTOR]; //in Amps
|
||||
flightBatteryData.Voltage = ((float)PIOS_ADC_PinGet(0)) * batterySettings.SensorCalibrations[FLIGHTBATTERYSETTINGS_SENSORCALIBRATIONS_VOLTAGEFACTOR]; //in Volts
|
||||
flightBatteryData.Current = ((float)PIOS_ADC_PinGet(1)) * batterySettings.SensorCalibrations[FLIGHTBATTERYSETTINGS_SENSORCALIBRATIONS_CURRENTFACTOR]; //in Amps
|
||||
|
||||
flightBatteryData.ConsumedEnergy += (flightBatteryData.Current * 1000.0 * dT / 3600.0) ;//in mAh
|
||||
|
||||
|
@ -247,7 +247,7 @@ extern uint32_t pios_com_vcp_id;
|
||||
/* which is annoying because this then determines the rate at which we generate buffer turnover events */
|
||||
/* the objective here is to get enough buffer space to support 100Hz averaging rate */
|
||||
#define PIOS_ADC_NUM_CHANNELS 4
|
||||
#define PIOS_ADC_MAX_OVERSAMPLING 10
|
||||
#define PIOS_ADC_MAX_OVERSAMPLING 2
|
||||
#define PIOS_ADC_USE_ADC2 0
|
||||
|
||||
//-------------------------
|
||||
|
@ -76,9 +76,9 @@ struct pios_adc_dev {
|
||||
volatile uint8_t adc_oversample;
|
||||
uint8_t dma_block_size;
|
||||
uint16_t dma_half_buffer_size;
|
||||
int16_t fir_coeffs[PIOS_ADC_MAX_SAMPLES+1] __attribute__ ((aligned(4)));
|
||||
volatile int16_t raw_data_buffer[PIOS_ADC_MAX_SAMPLES] __attribute__ ((aligned(4)));
|
||||
float downsampled_buffer[PIOS_ADC_NUM_CHANNELS] __attribute__ ((aligned(4)));
|
||||
// int16_t fir_coeffs[PIOS_ADC_MAX_SAMPLES+1] __attribute__ ((aligned(4)));
|
||||
// volatile int16_t raw_data_buffer[PIOS_ADC_MAX_SAMPLES] __attribute__ ((aligned(4)));
|
||||
// float downsampled_buffer[PIOS_ADC_NUM_CHANNELS] __attribute__ ((aligned(4)));
|
||||
enum pios_adc_dev_magic magic;
|
||||
};
|
||||
|
||||
@ -108,7 +108,7 @@ struct adc_accumulator {
|
||||
};
|
||||
|
||||
#if defined(PIOS_INCLUDE_ADC)
|
||||
static struct dma_config config[] = PIOS_DMA_PIN_CONFIG;
|
||||
static const struct dma_config config[] = PIOS_DMA_PIN_CONFIG;
|
||||
#define PIOS_ADC_NUM_PINS (sizeof(config) / sizeof(config[0]))
|
||||
|
||||
static struct adc_accumulator accumulator[PIOS_ADC_NUM_PINS];
|
||||
@ -117,8 +117,6 @@ static struct adc_accumulator accumulator[PIOS_ADC_NUM_PINS];
|
||||
static uint16_t adc_raw_buffer[2][PIOS_ADC_MAX_SAMPLES][PIOS_ADC_NUM_PINS];
|
||||
#endif
|
||||
|
||||
#define PIOS_ADC_TIMER TIM3 /* might want this to come from the config */
|
||||
|
||||
#if defined(PIOS_INCLUDE_ADC)
|
||||
static void
|
||||
init_pins(void)
|
||||
@ -176,6 +174,7 @@ init_dma(void)
|
||||
NVIC_Init(&NVICInit);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
init_timer(void)
|
||||
{
|
||||
@ -200,6 +199,7 @@ init_timer(void)
|
||||
TIM_SelectOutputTrigger(PIOS_ADC_TIMER, TIM_TRGOSource_Update);
|
||||
TIM_Cmd(PIOS_ADC_TIMER, ENABLE);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
init_adc(void)
|
||||
@ -432,15 +432,15 @@ void accumulate(uint16_t *buffer, uint32_t count)
|
||||
// XXX should do something with this
|
||||
if (pios_adc_dev->data_queue) {
|
||||
static portBASE_TYPE xHigherPriorityTaskWoken;
|
||||
xQueueSendFromISR(pios_adc_dev->data_queue, pios_adc_dev->downsampled_buffer, &xHigherPriorityTaskWoken);
|
||||
// xQueueSendFromISR(pios_adc_dev->data_queue, pios_adc_dev->downsampled_buffer, &xHigherPriorityTaskWoken);
|
||||
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if(pios_adc_dev->callback_function)
|
||||
pios_adc_dev->callback_function(pios_adc_dev->downsampled_buffer);
|
||||
// if(pios_adc_dev->callback_function)
|
||||
// pios_adc_dev->callback_function(pios_adc_dev->downsampled_buffer);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user