Make adc_generic a module.

This commit is contained in:
Martin Mueller
2010-10-28 20:24:58 +00:00
parent d9f9b9f5a3
commit 4596785e07
5 changed files with 54 additions and 44 deletions
+18 -15
View File
@@ -10,15 +10,6 @@
<airframe name="Funjet mm 1">
<firmware name="fixedwing">
<target name="sim" board="pc">
<define name="AGR_CLIMB"/>
<define name="LOITER_TRIM"/>
<define name="ALT_KALMAN"/>
<define name="WIND_INFO"/>
<define name="WIND_INFO_RET"/>
<define name="USE_I2C0"/>
</target>
<target name="ap" board="tiny_2.11">
<define name="AGR_CLIMB"/>
<define name="LOITER_TRIM"/>
@@ -26,10 +17,19 @@
<define name="WIND_INFO"/>
<define name="WIND_INFO_RET"/>
<define name="USE_I2C0"/>
<define name="SPI_MASTER"/>
<define name="USE_MICROMAG_FW"/>
<define name="MICROMAG_DRDY_VIC_SLOT" value="12"/>
<define name="SSP_VIC_SLOT" value="11"/>
<define name="SENSOR_SYNC_SEND"/>
<define name="ADC_CHANNEL_GENERIC1" value="ADC_3"/>
<define name="ADC_CHANNEL_GENERIC2" value="ADC_4"/>
<define name="USE_ADC_3"/>
<define name="USE_ADC_4"/>
</target>
<target name="sim" board="pc">
<define name="AGR_CLIMB"/>
<define name="LOITER_TRIM"/>
<define name="ALT_KALMAN"/>
<define name="WIND_INFO"/>
<define name="WIND_INFO_RET"/>
</target>
<!-- RC -->
@@ -49,7 +49,6 @@
<subsystem name="navigation"/>
<!-- Interfaces -->
<subsystem name="i2c"/>
<subsystem name="spi"/>
</firmware>
<firmware name="setup">
@@ -61,8 +60,12 @@
<!-- modules -->
<modules>
<load name="adc_generic.xml"/>
<!--load name="windturbine.xml"/>
<load name="trig_test.xml"/>
<load name="temp_temod.xml"/>
<load name="airspeed_ets.xml"/>
<load name="dust_gp2y.xml"/>
<!--load name="adc_generic.xml"/>
<load name="alt_srf08.xml"/>
<load name="mag_micromag_fw.xml"/>
<load name="baro_bmp.xml"/>
+21
View File
@@ -0,0 +1,21 @@
<!DOCTYPE module SYSTEM "module.dtd">
<!--
Generic ADC module
@param ADC_CHANNEL_GENERIC1 on which ADC input 1 is measured
@param ADC_CHANNEL_GENERIC2 on which ADC input 2 is measured
-->
<module name="adc_generic" dir="adcs">
<header>
<file name="adc_generic.h"/>
</header>
<init fun="adc_generic_init()"/>
<periodic fun="adc_generic_periodic()" freq="4"/>
<makefile target="ap">
<file name="adc_generic.c"/>
<flag name="USE_$(ADC_CHANNEL_GENERIC1)"/>
<flag name="USE_$(ADC_CHANNEL_GENERIC2)"/>
</makefile>
</module>
-28
View File
@@ -67,10 +67,6 @@
#include "led.h"
#endif
#ifdef USE_ADC_GENERIC
#include "adc_generic.h"
#endif
#if defined USE_I2C0 || USE_I2C1
#include "i2c.h"
#endif
@@ -87,10 +83,6 @@
#include "usb_serial.h"
#endif
#ifdef USE_BARO_ETS
#include "baro_ets.h"
#endif // USE_BARO_ETS
#if ! defined CATASTROPHIC_BAT_LEVEL && defined LOW_BATTERY
#warning "LOW_BATTERY deprecated. Renamed into CATASTROPHIC_BAT_LEVEL (in airframe file)"
#define CATASTROPHIC_BAT_LEVEL LOW_BATTERY
@@ -446,13 +438,6 @@ void periodic_task_ap( void ) {
break;
#endif
#ifdef USE_ADC_GENERIC
case 6:
adc_generic_periodic();
DOWNLINK_SEND_ADC_GENERIC(DefaultChannel, &adc_generic_val1, &adc_generic_val2);
break;
#endif
/* default: */
}
@@ -543,10 +528,6 @@ void init_ap( void ) {
i2c1_init();
#endif
#ifdef USE_ADC_GENERIC
adc_generic_init();
#endif
/************* Links initialization ***************/
#if defined USE_SPI
spi_init();
@@ -673,15 +654,6 @@ void event_task_ap( void ) {
}
#endif
#if defined(USE_BARO_ETS)
if (baro_ets_updated) {
baro_ets_updated = FALSE;
if (baro_ets_valid) {
EstimatorSetAlt(baro_ets_altitude);
}
}
#endif
if (inter_mcu_received_fbw) {
/* receive radio control task from fbw */
inter_mcu_received_fbw = FALSE;
@@ -1,10 +1,21 @@
#include "adc_generic.h"
#include "adc.h"
#include "uart.h"
#include "messages.h"
#include "downlink.h"
#include BOARD_CONFIG
#ifdef USE_ADC_GENERIC
uint16_t adc_generic_val1;
uint16_t adc_generic_val2;
#ifndef ADC_CHANNEL_GENERIC1
#ifndef ADC_CHANNEL_GENERIC2
#error "at least one ADC_CHANNEL_GENERIC1/2 needs to be defined to use the generic_adc module"
#endif
#endif
#ifndef ADC_CHANNEL_GENERIC_NB_SAMPLES
#define ADC_CHANNEL_GENERIC_NB_SAMPLES DEFAULT_AV_NB_SAMPLE
#endif
#ifdef ADC_CHANNEL_GENERIC1
@@ -31,4 +42,7 @@ void adc_generic_periodic( void ) {
#ifdef ADC_CHANNEL_GENERIC2
adc_generic_val2 = buf_generic2.sum / buf_generic2.av_nb_sample;
#endif
DOWNLINK_SEND_ADC_GENERIC(DefaultChannel, &adc_generic_val1, &adc_generic_val2);
}