ir adc and i2c are available as modules and subsystems

This commit is contained in:
Gautier Hattenberger
2010-12-29 12:23:09 +01:00
parent 267ee33b0e
commit 28e26cb7c5
12 changed files with 134 additions and 19 deletions
@@ -33,6 +33,7 @@ ap.CFLAGS += -DADC_CHANNEL_IR_NB_SAMPLES=$(ADC_IR_NB_SAMPLES)
$(TARGET).CFLAGS += -DUSE_INFRARED
$(TARGET).srcs += subsystems/sensors/infrared.c
$(TARGET).srcs += subsystems/sensors/infrared_adc.c
sim.srcs += $(SRC_ARCH)/sim_ir.c
jsbsim.srcs += $(SRC_ARCH)/jsbsim_ir.c
@@ -0,0 +1,8 @@
# attitude via IR I2C sensors
$(TARGET).CFLAGS += -DUSE_INFRARED_I2C
$(TARGET).srcs += subsystems/sensors/infrared.c
$(TARGET).srcs += subsystems/sensors/infrared_i2c.c
sim.srcs += $(SRC_ARCH)/sim_ir.c
jsbsim.srcs += $(SRC_ARCH)/jsbsim_ir.c
+20
View File
@@ -0,0 +1,20 @@
<!DOCTYPE module SYSTEM "module.dtd">
<!-- @define IR_ADC_READ_ONLY for read only module -->
<module name="ir_adc" dir="sensors">
<header>
<file name="infrared_adc.h"/>
</header>
<init fun="infrared_adc_init()"/>
<periodic fun="infrared_adc_update()" freq="60."/>
<makefile>
<define name="USE_INFRARED_TELEMETRY"/>
<file name="infrared.c" dir="subsystems/sensors"/>
<file name="infrared_adc.c" dir="subsystems/sensors"/>
</makefile>
<makefile target="sim">
<file_arch name="sim_ir.c" dir="."/>
</makefile>
</module>
+5 -6
View File
@@ -1,4 +1,5 @@
<!DOCTYPE module SYSTEM "module.dtd">
<!-- @define IR_I2C_READ_ONLY for read only module -->
<module name="ir_i2c" dir="sensors">
<header>
@@ -9,14 +10,12 @@
<!--periodic fun="infrared_i2cDownlink()" freq="1."/-->
<event fun="infrared_i2cEvent()"/>
<makefile>
<define name="USE_INFRARED_I2C"/>
<raw>ap.srcs += subsystems/sensors/infrared.c</raw>
<raw>ap.srcs += subsystems/sensors/infrared_i2c.c</raw>
<raw>sim.srcs += subsystems/sensors/infrared.c</raw>
<raw>sim.srcs += subsystems/sensors/infrared_i2c.c</raw>
<define name="USE_INFRARED_TELEMETRY"/>
<file name="infrared.c" dir="subsystems/sensors"/>
<file name="infrared_i2c.c" dir="subsystems/sensors"/>
</makefile>
<makefile target="sim">
<raw>sim.srcs += $(SRC_ARCH)/sim_ir.c</raw>
<file_arch name="sim_ir.c" dir="."/>
</makefile>
</module>
+4 -2
View File
@@ -60,8 +60,10 @@ value CDATA #IMPLIED
type CDATA #IMPLIED>
<!ATTLIST file
name CDATA #REQUIRED>
name CDATA #REQUIRED
dir CDATA #IMPLIED>
<!ATTLIST file_arch
name CDATA #REQUIRED>
name CDATA #REQUIRED
dir CDATA #IMPLIED>
+1 -1
View File
@@ -115,7 +115,7 @@
#define PERIODIC_SEND_SETTINGS(_chan) {}
#endif
#if defined USE_INFRARED || USE_INFRARED_I2C
#if defined USE_INFRARED || USE_INFRARED_TELEMETRY
#define PERIODIC_SEND_IR_SENSORS(_chan) DOWNLINK_SEND_IR_SENSORS(_chan, &infrared.value.ir1, &infrared.value.ir2, &infrared.pitch, &infrared.roll, &infrared.top);
#else
#define PERIODIC_SEND_IR_SENSORS(_chan) ;
+2 -1
View File
@@ -21,7 +21,8 @@ value set_ir(value roll __attribute__ ((unused)),
value top __attribute__ ((unused)),
value air_speed
) {
#if defined USE_INFRARED || USE_INFRARED_I2C
// INFRARED_TELEMETRY : Stupid hack to use with modules
#if defined USE_INFRARED || USE_INFRARED_TELEMETRY
infrared.roll = Int_val(roll);
infrared.pitch = Int_val(front);
infrared.top = Int_val(top);
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2010 ENAC
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
/*
* Wrapper for adc infrared sensor module
*/
#ifndef INFRARED_ADC_H
#define INFRARED_ADC_H
#include "subsystems/sensors/infrared_adc.h"
#endif // INFRARED_ADC_H
+17 -6
View File
@@ -31,7 +31,7 @@
#include <stdlib.h>
#include "subsystems/sensors/infrared.h"
#include "subsystems/sensors/infrared_adc.h"
#include "mcu_periph/adc.h"
#include BOARD_CONFIG
@@ -53,10 +53,22 @@ static struct adc_buf buf_ir3;
struct Infrared_raw ir_adc;
// Standard infrared implementation
void infrared_init(void) {
infrared_adc_init();
}
void infrared_update(void) {
infrared_adc_update();
}
/* No event with adc ir */
void infrared_event(void) {}
/** \brief Initialisation of \a ir */
/** Initialize \a adc_buf_channel
*/
void infrared_init(void) {
void infrared_adc_init(void) {
#if ! (defined SITL || defined HITL)
adc_buf_channel(ADC_CHANNEL_IR1, &buf_ir1, ADC_CHANNEL_IR_NB_SAMPLES);
adc_buf_channel(ADC_CHANNEL_IR2, &buf_ir2, ADC_CHANNEL_IR_NB_SAMPLES);
@@ -76,18 +88,17 @@ void infrared_init(void) {
/** \brief Update \a ir_roll and ir_pitch from ADCs or from simulator
* message in HITL and SITL modes
*/
void infrared_update(void) {
void infrared_adc_update(void) {
#if ! (defined SITL || defined HITL)
ir_adc.ir1 = (int32_t)(buf_ir1.sum/buf_ir1.av_nb_sample) - IR_ADC_IR1_NEUTRAL;
ir_adc.ir2 = (int32_t)(buf_ir2.sum/buf_ir2.av_nb_sample) - IR_ADC_IR2_NEUTRAL;
#ifdef ADC_CHANNEL_IR_TOP
ir_adc.ir3 = (int32_t)(buf_ir3.sum/buf_ir3.av_nb_sample) - IR_ADC_TOP_NEUTRAL;
#endif // IR_TOP
#ifndef IR_ADC_READ_ONLY
UpdateIRValue(ir_adc);
#endif
#endif /* !SITL && !HITL */
/** #else ir_roll set by simulator in sim_ir.c */
}
/* No event with adc ir */
void infrared_event(void) {}
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2010 ENAC
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
/*
* Driver for adc infrared sensor
*/
#ifndef SUBSYSTEMS_SENSORS_INFRARED_ADC_H
#define SUBSYSTEMS_SENSORS_INFRARED_ADC_H
#include "std.h"
#include "subsystems/sensors/infrared.h"
void infrared_adc_init();
void infrared_adc_update();
#endif // SUBSYSTEMS_SENSORS_INFRARED_ADC_H
@@ -70,7 +70,6 @@ struct i2c_transaction irh_trans, irv_trans;
// Standard infrared implementation
void infrared_init(void) {
infrared_i2c_init();
infrared_struct_init();
}
void infrared_update(void) {
@@ -92,6 +91,8 @@ void infrared_i2c_init( void ) {
ir_i2c_conf_ver_done = FALSE;
irh_trans.status = I2CTransDone;
irv_trans.status = I2CTransDone;
infrared_struct_init();
}
void infrared_i2c_update( void ) {
+4 -2
View File
@@ -137,10 +137,12 @@ let dump_module_section = fun xml f ->
) targets
| "file" ->
let name = Xml.attrib field "name" in
List.iter (fun target -> fprintf f "%s.srcs += $(%s)/%s\n" target dir_name name) targets
let dir_name = ExtXml.attrib_or_default field "dir" ("$("^dir_name^")") in
List.iter (fun target -> fprintf f "%s.srcs += %s/%s\n" target dir_name name) targets
| "file_arch" ->
let name = Xml.attrib field "name" in
List.iter (fun target -> fprintf f "%s.srcs += arch/$(ARCH)/$(%s)/%s\n" target dir_name name) targets
let dir_name = ExtXml.attrib_or_default field "dir" ("$("^dir_name^")") in
List.iter (fun target -> fprintf f "%s.srcs += arch/$(ARCH)/%s/%s\n" target dir_name name) targets
| "raw" ->
begin match Xml.children field with
[Xml.PCData s] -> fprintf f "%s\n" s