Files
paparazzi/sw/airborne/test_adcs.c
T
2007-05-23 12:42:35 +00:00

68 lines
1.3 KiB
C

/*
* Basic program periodically sending the values of the 8 ADCs
*/
#include "interrupt_hw.h"
#include "std.h"
#include "init_hw.h"
#include "sys_time.h"
#include "adc.h"
#include "messages.h"
#include "led.h"
#include "uart.h"
#include "downlink.h"
#define NB_ADC 8
#define ADC_NB_SAMPLES 16
static struct adc_buf buf_adc[NB_ADC];
int main (int argc, char** argv) {
hw_init();
sys_time_init();
led_init();
adc_init();
adc_buf_channel(ADC_0, &buf_adc[0], ADC_NB_SAMPLES);
adc_buf_channel(ADC_1, &buf_adc[1], ADC_NB_SAMPLES);
adc_buf_channel(ADC_2, &buf_adc[2], ADC_NB_SAMPLES);
adc_buf_channel(ADC_3, &buf_adc[3], ADC_NB_SAMPLES);
adc_buf_channel(ADC_4, &buf_adc[4], ADC_NB_SAMPLES);
adc_buf_channel(ADC_5, &buf_adc[5], ADC_NB_SAMPLES);
#ifdef ADC_6
adc_buf_channel(ADC_6, &buf_adc[6], ADC_NB_SAMPLES);
#endif
#ifdef ADC_7
adc_buf_channel(ADC_7, &buf_adc[7], ADC_NB_SAMPLES);
#endif
#if NB_ADC != 8
#error "8 ADCs expected !"
#endif
#ifdef USE_UART0
Uart0Init();
#endif
#ifdef USE_UART1
Uart1Init();
#endif
int_enable();
while(1) {
if (sys_time_periodic()) {
LED_TOGGLE(1);
uint16_t values[NB_ADC];
uint8_t i;
for(i = 0; i < NB_ADC; i++)
values[i] = buf_adc[i].sum / ADC_NB_SAMPLES;
uint8_t id = 42;
DOWNLINK_SEND_ADC(&id, NB_ADC, values);
}
}
return 0;
}