mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-05 23:49:00 +08:00
Make adc_generic a module.
This commit is contained in:
@@ -10,15 +10,6 @@
|
|||||||
<airframe name="Funjet mm 1">
|
<airframe name="Funjet mm 1">
|
||||||
|
|
||||||
<firmware name="fixedwing">
|
<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">
|
<target name="ap" board="tiny_2.11">
|
||||||
<define name="AGR_CLIMB"/>
|
<define name="AGR_CLIMB"/>
|
||||||
<define name="LOITER_TRIM"/>
|
<define name="LOITER_TRIM"/>
|
||||||
@@ -26,10 +17,19 @@
|
|||||||
<define name="WIND_INFO"/>
|
<define name="WIND_INFO"/>
|
||||||
<define name="WIND_INFO_RET"/>
|
<define name="WIND_INFO_RET"/>
|
||||||
<define name="USE_I2C0"/>
|
<define name="USE_I2C0"/>
|
||||||
<define name="SPI_MASTER"/>
|
<define name="SENSOR_SYNC_SEND"/>
|
||||||
<define name="USE_MICROMAG_FW"/>
|
<define name="ADC_CHANNEL_GENERIC1" value="ADC_3"/>
|
||||||
<define name="MICROMAG_DRDY_VIC_SLOT" value="12"/>
|
<define name="ADC_CHANNEL_GENERIC2" value="ADC_4"/>
|
||||||
<define name="SSP_VIC_SLOT" value="11"/>
|
<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>
|
</target>
|
||||||
|
|
||||||
<!-- RC -->
|
<!-- RC -->
|
||||||
@@ -49,7 +49,6 @@
|
|||||||
<subsystem name="navigation"/>
|
<subsystem name="navigation"/>
|
||||||
<!-- Interfaces -->
|
<!-- Interfaces -->
|
||||||
<subsystem name="i2c"/>
|
<subsystem name="i2c"/>
|
||||||
<subsystem name="spi"/>
|
|
||||||
</firmware>
|
</firmware>
|
||||||
|
|
||||||
<firmware name="setup">
|
<firmware name="setup">
|
||||||
@@ -61,8 +60,12 @@
|
|||||||
|
|
||||||
<!-- modules -->
|
<!-- modules -->
|
||||||
<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="dust_gp2y.xml"/>
|
||||||
<!--load name="adc_generic.xml"/>
|
|
||||||
<load name="alt_srf08.xml"/>
|
<load name="alt_srf08.xml"/>
|
||||||
<load name="mag_micromag_fw.xml"/>
|
<load name="mag_micromag_fw.xml"/>
|
||||||
<load name="baro_bmp.xml"/>
|
<load name="baro_bmp.xml"/>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|
||||||
@@ -67,10 +67,6 @@
|
|||||||
#include "led.h"
|
#include "led.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_ADC_GENERIC
|
|
||||||
#include "adc_generic.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined USE_I2C0 || USE_I2C1
|
#if defined USE_I2C0 || USE_I2C1
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -87,10 +83,6 @@
|
|||||||
#include "usb_serial.h"
|
#include "usb_serial.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_BARO_ETS
|
|
||||||
#include "baro_ets.h"
|
|
||||||
#endif // USE_BARO_ETS
|
|
||||||
|
|
||||||
#if ! defined CATASTROPHIC_BAT_LEVEL && defined LOW_BATTERY
|
#if ! defined CATASTROPHIC_BAT_LEVEL && defined LOW_BATTERY
|
||||||
#warning "LOW_BATTERY deprecated. Renamed into CATASTROPHIC_BAT_LEVEL (in airframe file)"
|
#warning "LOW_BATTERY deprecated. Renamed into CATASTROPHIC_BAT_LEVEL (in airframe file)"
|
||||||
#define CATASTROPHIC_BAT_LEVEL LOW_BATTERY
|
#define CATASTROPHIC_BAT_LEVEL LOW_BATTERY
|
||||||
@@ -446,13 +438,6 @@ void periodic_task_ap( void ) {
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_ADC_GENERIC
|
|
||||||
case 6:
|
|
||||||
adc_generic_periodic();
|
|
||||||
DOWNLINK_SEND_ADC_GENERIC(DefaultChannel, &adc_generic_val1, &adc_generic_val2);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* default: */
|
/* default: */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,10 +528,6 @@ void init_ap( void ) {
|
|||||||
i2c1_init();
|
i2c1_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_ADC_GENERIC
|
|
||||||
adc_generic_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************* Links initialization ***************/
|
/************* Links initialization ***************/
|
||||||
#if defined USE_SPI
|
#if defined USE_SPI
|
||||||
spi_init();
|
spi_init();
|
||||||
@@ -673,15 +654,6 @@ void event_task_ap( void ) {
|
|||||||
}
|
}
|
||||||
#endif
|
#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) {
|
if (inter_mcu_received_fbw) {
|
||||||
/* receive radio control task from fbw */
|
/* receive radio control task from fbw */
|
||||||
inter_mcu_received_fbw = FALSE;
|
inter_mcu_received_fbw = FALSE;
|
||||||
|
|||||||
@@ -1,10 +1,21 @@
|
|||||||
#include "adc_generic.h"
|
#include "adc_generic.h"
|
||||||
#include "adc.h"
|
#include "adc.h"
|
||||||
|
#include "uart.h"
|
||||||
|
#include "messages.h"
|
||||||
|
#include "downlink.h"
|
||||||
#include BOARD_CONFIG
|
#include BOARD_CONFIG
|
||||||
|
|
||||||
#ifdef USE_ADC_GENERIC
|
|
||||||
uint16_t adc_generic_val1;
|
uint16_t adc_generic_val1;
|
||||||
uint16_t adc_generic_val2;
|
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
|
#endif
|
||||||
|
|
||||||
#ifdef ADC_CHANNEL_GENERIC1
|
#ifdef ADC_CHANNEL_GENERIC1
|
||||||
@@ -31,4 +42,7 @@ void adc_generic_periodic( void ) {
|
|||||||
#ifdef ADC_CHANNEL_GENERIC2
|
#ifdef ADC_CHANNEL_GENERIC2
|
||||||
adc_generic_val2 = buf_generic2.sum / buf_generic2.av_nb_sample;
|
adc_generic_val2 = buf_generic2.sum / buf_generic2.av_nb_sample;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DOWNLINK_SEND_ADC_GENERIC(DefaultChannel, &adc_generic_val1, &adc_generic_val2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user