paparazzi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paparazzi-commits] [5932] move sim dir to arch as well, sim compiles ag


From: Felix Ruess
Subject: [paparazzi-commits] [5932] move sim dir to arch as well, sim compiles again
Date: Thu, 23 Sep 2010 12:33:57 +0000

Revision: 5932
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=5932
Author:   flixr
Date:     2010-09-23 12:33:56 +0000 (Thu, 23 Sep 2010)
Log Message:
-----------
move sim dir to arch as well, sim compiles again

Modified Paths:
--------------
    paparazzi3/trunk/conf/Makefile.lpc21
    paparazzi3/trunk/conf/Makefile.sim

Added Paths:
-----------
    paparazzi3/trunk/sw/airborne/arch/sim/adc_hw.c
    paparazzi3/trunk/sw/airborne/arch/sim/adc_hw.h
    paparazzi3/trunk/sw/airborne/arch/sim/baro_MS5534A.h
    paparazzi3/trunk/sw/airborne/arch/sim/gpio.h
    paparazzi3/trunk/sw/airborne/arch/sim/gps_hw.c
    paparazzi3/trunk/sw/airborne/arch/sim/gps_hw.h
    paparazzi3/trunk/sw/airborne/arch/sim/i2c_hw.c
    paparazzi3/trunk/sw/airborne/arch/sim/i2c_hw.h
    paparazzi3/trunk/sw/airborne/arch/sim/init_hw.h
    paparazzi3/trunk/sw/airborne/arch/sim/interrupt_hw.h
    paparazzi3/trunk/sw/airborne/arch/sim/ivy_transport.c
    paparazzi3/trunk/sw/airborne/arch/sim/ivy_transport.h
    paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_gps.c
    paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_hw.c
    paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_hw.h
    paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_ir.c
    paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_transport.c
    paparazzi3/trunk/sw/airborne/arch/sim/led_hw.c
    paparazzi3/trunk/sw/airborne/arch/sim/led_hw.h
    paparazzi3/trunk/sw/airborne/arch/sim/max1167_hw.c
    paparazzi3/trunk/sw/airborne/arch/sim/max1167_hw.h
    paparazzi3/trunk/sw/airborne/arch/sim/micromag_hw.c
    paparazzi3/trunk/sw/airborne/arch/sim/micromag_hw.h
    paparazzi3/trunk/sw/airborne/arch/sim/ppm_hw.c
    paparazzi3/trunk/sw/airborne/arch/sim/ppm_hw.h
    paparazzi3/trunk/sw/airborne/arch/sim/scp1000_hw.c
    paparazzi3/trunk/sw/airborne/arch/sim/scp1000_hw.h
    paparazzi3/trunk/sw/airborne/arch/sim/servos_nil.h
    paparazzi3/trunk/sw/airborne/arch/sim/sim_adc_generic.c
    paparazzi3/trunk/sw/airborne/arch/sim/sim_ap.c
    paparazzi3/trunk/sw/airborne/arch/sim/sim_baro.c
    paparazzi3/trunk/sw/airborne/arch/sim/sim_gps.c
    paparazzi3/trunk/sw/airborne/arch/sim/sim_ir.c
    paparazzi3/trunk/sw/airborne/arch/sim/sim_jsbsim.c
    paparazzi3/trunk/sw/airborne/arch/sim/sim_uart.c
    paparazzi3/trunk/sw/airborne/arch/sim/sim_uart.h
    paparazzi3/trunk/sw/airborne/arch/sim/sim_uart_hw.c
    paparazzi3/trunk/sw/airborne/arch/sim/spi_hw.c
    paparazzi3/trunk/sw/airborne/arch/sim/spi_hw.h
    paparazzi3/trunk/sw/airborne/arch/sim/sys_time_hw.h
    paparazzi3/trunk/sw/airborne/arch/sim/uart_hw.h

Removed Paths:
-------------
    paparazzi3/trunk/sw/airborne/sim/

Modified: paparazzi3/trunk/conf/Makefile.lpc21
===================================================================
--- paparazzi3/trunk/conf/Makefile.lpc21        2010-09-23 12:29:32 UTC (rev 
5931)
+++ paparazzi3/trunk/conf/Makefile.lpc21        2010-09-23 12:33:56 UTC (rev 
5932)
@@ -26,6 +26,7 @@
 # This is the common Makefile for the arm7-target.
 #
 
+# this should not be needed
 #SRC_ARCH = lpc21
 
 # Define programs and commands.

Modified: paparazzi3/trunk/conf/Makefile.sim
===================================================================
--- paparazzi3/trunk/conf/Makefile.sim  2010-09-23 12:29:32 UTC (rev 5931)
+++ paparazzi3/trunk/conf/Makefile.sim  2010-09-23 12:33:56 UTC (rev 5932)
@@ -1,5 +1,5 @@
 # Hey Emacs, this is a -*- makefile -*-
-# 
+#
 #   $Id$
 #   Copyright (C) 2006 Pascal Brisset, Antoine Drouin
 #
@@ -18,14 +18,15 @@
 # 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.  
-# 
+# Boston, MA 02111-1307, USA.
+#
 
 #
 # This is the common Makefile for the sim target.
 #
 
-SRC_ARCH = sim
+# this should not be needed
+#SRC_ARCH = sim
 
 ifneq ($(SIM_TYPE),JSBSIM)
 CC = gcc
@@ -145,8 +146,8 @@
        @echo DEPEND $@
        $(Q)$(CC) -MM -MG $(CFLAGS) $($(TARGET).srcs) | sed 
's|\([^\.]*\.o\)|$(OBJDIR)/\1|' > $@
 
-ifneq ($(MAKECMDGOALS),clean) 
-ifneq ($(MAKECMDGOALS),erase) 
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(MAKECMDGOALS),erase)
 -include $(OBJDIR)/.depend
 endif
 endif

Copied: paparazzi3/trunk/sw/airborne/arch/sim/adc_hw.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/adc_hw.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/adc_hw.c                              
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/adc_hw.c      2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,7 @@
+#include "adc.h"
+
+void adc_buf_channel(uint8_t adc_channel __attribute__ ((unused)), 
+                    struct adc_buf* s __attribute__ ((unused)), 
+                    uint8_t av_nb_sample __attribute__ ((unused))) {}
+
+void adc_init( void ) {}

Copied: paparazzi3/trunk/sw/airborne/arch/sim/adc_hw.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/adc_hw.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/adc_hw.h                              
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/adc_hw.h      2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,8 @@
+#ifndef ADC_HW_H
+#define ADC_HW_H
+
+/* Dummy definitions */
+#define AdcBank1(x) x
+#define AdcBank0(x) x
+
+#endif /* ADC_HW_H */

Copied: paparazzi3/trunk/sw/airborne/arch/sim/baro_MS5534A.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/baro_MS5534A.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/baro_MS5534A.h                        
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/baro_MS5534A.h        2010-09-23 
12:33:56 UTC (rev 5932)
@@ -0,0 +1,59 @@
+/*
+ * $Id$
+ *  
+ * Copyright (C) 2007  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. 
+ *
+ */
+
+/** \file baro_MS5534A.h
+ *  \brief Handling of the MS5534a pressure sensor
+ *
+ */
+
+#ifndef BARO_MS5534A_H
+#define BARO_MS5534A_H
+
+#include "std.h"
+
+#ifdef USE_BARO_MS5534A
+
+extern bool_t spi_message_received;
+extern bool_t baro_MS5534A_available;
+extern uint32_t baro_MS5534A_pressure;
+extern uint16_t baro_MS5534A_temp;
+extern bool_t alt_baro_enabled;
+extern uint32_t baro_MS5534A_ground_pressure;
+extern float baro_MS5534A_r;
+extern float baro_MS5534A_sigma2;
+extern float baro_MS5534A_z;
+
+
+void baro_MS5534A_init(void);
+void baro_MS5534A_reset(void);
+
+/* To be called not faster than 30Hz */
+void baro_MS5534A_send(void);
+
+/* Set baro_MS5534A_available when pressure and temp are readable */
+void baro_MS5534A_event_task( void );
+
+#endif // USE_BARO_MS5534A
+
+#endif // BARO_MS5534A_H

Copied: paparazzi3/trunk/sw/airborne/arch/sim/gpio.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/gpio.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/gpio.h                                
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/gpio.h        2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,7 @@
+#ifndef GPIO_H
+#define GPIO_H
+
+extern bool_t gpio1_status;
+
+#endif /* GPIO_H */
+

Copied: paparazzi3/trunk/sw/airborne/arch/sim/gps_hw.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/gps_hw.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/gps_hw.c                              
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/gps_hw.c      2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,41 @@
+#include "gps.h"
+
+#include "6dof.h"
+
+/* in gps_ubx.c */
+volatile uint8_t gps_msg_received;
+bool_t gps_pos_available;
+uint8_t gps_nb_ovrn;
+
+
+uint8_t gps_mode;
+uint16_t  gps_week;    /* weeks */
+uint32_t  gps_itow;    /* ms */
+int32_t   gps_alt;    /* cm       */
+uint16_t  gps_gspeed;  /* cm/s     */
+int16_t   gps_climb;  /* cm/s     */
+int16_t   gps_course; /* decideg     */
+int32_t gps_utm_east, gps_utm_north;
+uint8_t gps_utm_zone;
+int32_t gps_lat, gps_lon;
+struct svinfo gps_svinfos[GPS_NB_CHANNELS];
+uint8_t gps_nb_channels = 0;
+uint16_t gps_PDOP;
+uint32_t gps_Pacc, gps_Sacc;
+uint8_t gps_numSV;
+uint16_t gps_reset;
+
+
+void parse_gps_msg( void ) {}
+
+void gps_feed_values(double utm_north, double utm_east, double utm_alt, double 
gspeed, double course, double climb) {
+
+  gps_utm_north = utm_north;
+  gps_utm_east = utm_east;
+  gps_alt = utm_alt;
+  gps_gspeed = gspeed;
+  gps_course = course;
+  gps_climb = climb;
+
+  gps_pos_available = TRUE;
+}

Copied: paparazzi3/trunk/sw/airborne/arch/sim/gps_hw.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/gps_hw.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/gps_hw.h                              
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/gps_hw.h      2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,9 @@
+#ifndef GPS_HW_H
+#define GPS_HW_H
+
+#define GpsBuffer() 0
+#define ReadGpsBuffer() {}
+
+void gps_feed_values(double utm_north, double utm_east, double utm_alt, double 
gspeed, double course, double climb);
+
+#endif /* GPS_HW_H */

Copied: paparazzi3/trunk/sw/airborne/arch/sim/i2c_hw.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/i2c_hw.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/i2c_hw.c                              
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/i2c_hw.c      2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,5 @@
+#include "i2c.h"
+
+void i2c_hw_init ( void ) {}
+
+bool_t i2c_submit(struct i2c_periph* p __attribute__ ((unused)), struct 
i2c_transaction* t __attribute__ ((unused))) { return TRUE;}

Copied: paparazzi3/trunk/sw/airborne/arch/sim/i2c_hw.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/i2c_hw.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/i2c_hw.h                              
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/i2c_hw.h      2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,13 @@
+#ifndef I2C_HW_H
+#define I2C_HW_H
+
+#define I2cSendStart() {}
+
+//extern void i2c_hw_init(void);
+#define i2c0_hw_init() {}
+#define i2c1_hw_init() {}
+
+#define I2c0SendStart() {}
+#define I2c1SendStart() {}
+
+#endif /* I2C_HW_H */

Copied: paparazzi3/trunk/sw/airborne/arch/sim/init_hw.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/init_hw.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/init_hw.h                             
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/init_hw.h     2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,6 @@
+#ifndef INIT_HW_H
+#define INIT_HW_H
+
+static inline void hw_init(void) {}
+
+#endif /* INIT_HW_H */

Copied: paparazzi3/trunk/sw/airborne/arch/sim/interrupt_hw.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/interrupt_hw.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/interrupt_hw.h                        
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/interrupt_hw.h        2010-09-23 
12:33:56 UTC (rev 5932)
@@ -0,0 +1,6 @@
+#ifndef INTERRUPT_HW_H
+#define INTERRUPT_HW_H
+
+#define int_enable() {}
+
+#endif /* INTERRUPT_HW_H */

Copied: paparazzi3/trunk/sw/airborne/arch/sim/ivy_transport.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/ivy_transport.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/ivy_transport.c                       
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/ivy_transport.c       2010-09-23 
12:33:56 UTC (rev 5932)
@@ -0,0 +1,2 @@
+char ivy_buf[256];
+char *ivy_p = ivy_buf;

Copied: paparazzi3/trunk/sw/airborne/arch/sim/ivy_transport.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/ivy_transport.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/ivy_transport.h                       
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/ivy_transport.h       2010-09-23 
12:33:56 UTC (rev 5932)
@@ -0,0 +1,48 @@
+#include <stdio.h>
+#include <Ivy/ivy.h>
+
+extern char ivy_buf[];
+extern char* ivy_p;
+
+#define IvyTransportCheckFreeSpace(_) TRUE
+
+#define IvyTransportSizeOf(x) (x)
+
+#define IvyTransportHeader(len) ivy_p=ivy_buf;
+
+#define IvyTransportTrailer() { *ivy_p = '\0'; IvySendMsg("%s",ivy_buf); }
+
+#define IvyTransportPutUint8(x) { ivy_p += sprintf(ivy_p, "%u ", x); }
+#define IvyTransportPutNamedUint8(_name, _x) { ivy_p += sprintf(ivy_p, "%s ", 
_name); }
+
+#define Space() ivy_p += sprintf(ivy_p, " ");
+#define Comma() ivy_p += sprintf(ivy_p, ",");
+
+#define IvyTransportPutUintByAddr(x) ivy_p += sprintf(ivy_p, "%u", *x);
+#define IvyTransportPutUint8ByAddr(x) IvyTransportPutUintByAddr(x) Space()
+#define IvyTransportPutUint16ByAddr(x) IvyTransportPutUintByAddr(x) Space()
+#define IvyTransportPutUint32ByAddr(x) IvyTransportPutUintByAddr(x) Space()
+
+#define IvyTransportPutIntByAddr(x) ivy_p += sprintf(ivy_p, "%d", *x);
+#define IvyTransportPutInt8ByAddr(x) IvyTransportPutIntByAddr(x) Space()
+#define IvyTransportPutInt16ByAddr(x) IvyTransportPutIntByAddr(x) Space()
+#define IvyTransportPutInt32ByAddr(x) IvyTransportPutIntByAddr(x) Space()
+
+#define IvyTransportPutOneFloatByAddr(x) ivy_p += sprintf(ivy_p, "%f", *x);
+#define IvyTransportPutFloatByAddr(x) IvyTransportPutOneFloatByAddr(x) Space()
+#define IvyTransportPutDoubleByAddr(x) IvyTransportPutOneFloatByAddr(x) Space()
+
+#define IvyTransportPutArray(_put, _n, _x) { \
+  int __i; \
+  for(__i = 0; __i < _n; __i++) { \
+    _put(&_x[__i]); \
+    Comma(); \
+  } \
+}
+
+#define IvyTransportPutUint8Array(_n, _x) 
IvyTransportPutArray(IvyTransportPutUintByAddr, _n, _x)
+#define IvyTransportPutInt16Array(_n, _x) 
IvyTransportPutArray(IvyTransportPutIntByAddr, _n, _x)
+#define IvyTransportPutUint16Array(_n, _x) 
IvyTransportPutArray(IvyTransportPutUintByAddr, _n, _x)
+#define IvyTransportPutUint32Array(_n, _x) 
IvyTransportPutArray(IvyTransportPutUintByAddr, _n, _x)
+#define IvyTransportPutFloatArray(_n, _x) 
IvyTransportPutArray(IvyTransportPutOneFloatByAddr, _n, _x)
+#define IvyTransportPutDoubleArray(_n, _x) IvyTransportPutFloatArray(_n, _x) 

Copied: paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_gps.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/jsbsim_gps.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_gps.c                          
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_gps.c  2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,80 @@
+/* OCaml binding to link the simulator to autopilot functions. */
+
+#include <assert.h>
+#include <math.h>
+#include <inttypes.h>
+
+/** From airborne/autopilot/ */
+#include "airframe.h"
+#include "flight_plan.h"
+#include "autopilot.h"
+#include "gps.h"
+#include "estimator.h"
+#include "latlong.h"
+#include "common_nav.h"
+
+uint8_t gps_mode;
+uint16_t  gps_week;    /* weeks */
+uint32_t  gps_itow;     /* ms */
+int32_t   gps_alt;      /* cm       */
+uint16_t  gps_gspeed;   /* cm/s     */
+int16_t   gps_climb;    /* cm/s     */
+int16_t   gps_course;   /* decideg     */
+int32_t gps_utm_east, gps_utm_north;
+uint8_t gps_utm_zone;
+int32_t gps_lat, gps_lon;
+struct svinfo gps_svinfos[GPS_NB_CHANNELS];
+uint8_t gps_nb_channels = 0;
+uint16_t gps_PDOP;
+uint32_t gps_Pacc, gps_Sacc;
+uint8_t gps_numSV;
+uint16_t gps_reset;
+
+
+void sim_use_gps_pos(double lat, double lon, double alt, double course, double 
gspeed, double climb, double time) {
+    
+  gps_mode = 3; // Mode 3D
+  gps_course = DegOfRad(course) * 10.;
+  gps_alt = alt * 100.;
+  gps_gspeed = gspeed * 100.;
+  gps_climb = climb * 100.;
+  gps_week = 0; // FIXME
+  gps_itow = time * 1000.;
+
+  gps_lat = DegOfRad(lat)*1e7;
+  gps_lon = DegOfRad(lon)*1e7;
+  latlong_utm_of(lat, lon, nav_utm_zone0);
+  gps_utm_east = latlong_utm_x * 100;
+  gps_utm_north = latlong_utm_y * 100;
+  gps_utm_zone = nav_utm_zone0;
+
+}
+
+/** Space vehicle info simulation */
+void sim_update_sv(void) {
+
+  gps_nb_channels=7;
+  int i;
+  static int time;
+  time++;
+  for(i = 0; i < gps_nb_channels; i++) {
+    gps_svinfos[i].svid = 7 + i;
+    gps_svinfos[i].elev = (cos(((100*i)+time)/100.) + 1) * 45;
+    gps_svinfos[i].azim = (time/gps_nb_channels + 50 * i) % 360;
+    gps_svinfos[i].cno = 40 + sin((time+i*10)/100.) * 10.;
+    gps_svinfos[i].flags = ((time/10) % (i+1) == 0 ? 0x00 : 0x01);
+    gps_svinfos[i].qi = (int)((time / 1000.) + i) % 8;
+  }
+  gps_PDOP = gps_Sacc = gps_Pacc = 500+200*sin(time/100.);
+  gps_numSV = 7;
+      
+  gps_verbose_downlink = !launch;
+  UseGpsPosNoSend(estimator_update_state_gps);
+  gps_downlink();
+
+}
+
+void ubxsend_cfg_rst(uint16_t a __attribute__ ((unused)), uint8_t b 
__attribute__ ((unused))) {
+  return;
+}
+

Copied: paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_hw.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/jsbsim_hw.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_hw.c                           
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_hw.c   2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,35 @@
+/* Definitions and declarations required to compile autopilot code on a
+   i386 architecture */
+
+#include "jsbsim_hw.h"
+
+#include <stdio.h>
+#include <assert.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <string.h>
+
+
+/* Dummy definitions to replace the ones from the files not compiled in the 
simulator */
+//uint8_t ir_estim_mode;
+//uint8_t vertical_mode;
+//uint8_t inflight_calib_mode;
+//bool_t rc_event_1, rc_event_2;
+uint8_t gps_nb_ovrn, modem_nb_ovrn, link_fbw_fbw_nb_err, link_fbw_nb_err;
+//float alt_roll_pgain;
+//float roll_rate_pgain;
+//bool_t gpio1_status;
+uint16_t adc_generic_val1;
+uint16_t adc_generic_val2;
+uint16_t ppm_pulses[ PPM_NB_PULSES ];
+volatile bool_t ppm_valid;
+
+uint8_t ac_id;
+
+void update_bat(double bat) {
+  fbw_vsupply_decivolt = (int) (bat * 10.);
+}
+
+void adc_generic_init( void ) {}
+void adc_generic_periodic( void ) {}

Copied: paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_hw.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/jsbsim_hw.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_hw.h                           
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_hw.h   2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,68 @@
+/*
+ *  
+ * Copyright (C) 2009 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. 
+ *
+ */
+
+/** \file jsbsim_hw.h
+ */
+
+#ifndef JSBSIM_HW_H
+#define JSBSIM_HW_H
+
+#include <inttypes.h>
+#include "std.h"
+#include "inter_mcu.h"
+#include "autopilot.h"
+#include "estimator.h"
+#include "gps.h"
+#include "traffic_info.h"
+#include "flight_plan.h"
+#include "airframe.h"
+#include "settings.h"
+#include "nav.h"
+#include "fw_h_ctl.h"
+#include "fw_v_ctl.h"
+#include "infrared.h"
+#include "commands.h"
+#include "main_ap.h"
+#include "ap_downlink.h"
+#include "sim_uart.h"
+#include "latlong.h"
+#include "datalink.h"
+#include "adc_generic.h"
+#include "ppm.h"
+
+
+void sim_use_gps_pos(double lat, double lon, double alt, double course, double 
gspeed, double climb, double time);
+void sim_update_sv(void);
+
+void set_ir(double roll, double pitch);
+
+void update_bat(double bat);
+
+void parse_dl_ping(char* argv[]);
+void parse_dl_acinfo(char* argv[]);
+void parse_dl_setting(char* argv[]);
+void parse_dl_get_setting(char* argv[]);
+void parse_dl_block(char* argv[]);
+void parse_dl_move_wp(char* argv[]);
+
+#endif

Copied: paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_ir.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/jsbsim_ir.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_ir.c                           
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_ir.c   2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,35 @@
+/** 
+ *  \brief Regroup functions to simulate autopilot/infrared.c
+ *
+ * Infrared soft simulation.
+ */
+
+
+#include "jsbsim_hw.h"
+#include <math.h>
+
+#ifndef JSBSIM_IR_ROLL_NEUTRAL
+#define JSBSIM_IR_ROLL_NEUTRAL 0.
+#endif
+#ifndef JSBSIM_IR_PITCH_NEUTRAL
+#define JSBSIM_IR_PITCH_NEUTRAL 0.
+#endif
+
+void set_ir(double roll, double pitch) {
+
+  double ir_contrast = 150; //FIXME
+  double roll_sensor = roll + JSBSIM_IR_ROLL_NEUTRAL; // ir_roll_neutral;
+  double pitch_sensor = pitch + JSBSIM_IR_PITCH_NEUTRAL; // ir_pitch_neutral;
+#ifdef INFRARED
+  ir_roll = sin(roll_sensor) * ir_contrast;
+  ir_pitch = sin(pitch_sensor) * ir_contrast;
+  ir_top = cos(roll_sensor) * cos(pitch_sensor) * ir_contrast;
+#endif
+
+}
+
+
+void ir_gain_calib(void) {}
+
+/** Required by infrared.c:ir_init() */
+void adc_buf_channel(uint8_t adc_channel __attribute__ ((unused)), struct 
adc_buf* s __attribute__ ((unused)), uint8_t av_nb_sample __attribute__ 
((unused))) {}

Copied: paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_transport.c (from rev 
5930, paparazzi3/trunk/sw/airborne/sim/jsbsim_transport.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_transport.c                    
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/jsbsim_transport.c    2010-09-23 
12:33:56 UTC (rev 5932)
@@ -0,0 +1,61 @@
+/* Datalink parsing functions */
+
+#include "jsbsim_hw.h"
+
+#include <stdlib.h>
+
+#define MOfCm(_x) (((float)(_x))/100.)
+
+void parse_dl_ping(char* argv[] __attribute__ ((unused))) {
+  DOWNLINK_SEND_PONG(DefaultChannel);
+}
+
+void parse_dl_acinfo(char* argv[] __attribute__ ((unused))) {
+#ifdef TRAFFIC_INFO
+  uint8_t id = atoi(argv[8]);
+  float ux = MOfCm(atoi(argv[2]));
+  float uy = MOfCm(atoi(argv[3]));
+  float a = MOfCm(atoi(argv[4]));
+  float c = RadOfDeg(((float)atoi(argv[1]))/ 10.);
+  float s = MOfCm(atoi(argv[6]));
+  float cl = MOfCm(atoi(argv[7]));
+  uint32_t t = atoi(argv[5]);
+  SetAcInfo(id, ux, uy, c, a, s, cl, t);
+#endif
+}
+
+void parse_dl_setting(char* argv[]) {
+  uint8_t index = atoi(argv[2]);
+  float value = atof(argv[3]);
+  DlSetting(index, value);
+  DOWNLINK_SEND_DL_VALUE(DefaultChannel,&index, &value);
+}
+
+void parse_dl_get_setting(char* argv[]) {
+  uint8_t index = atoi(argv[2]);
+  float value = settings_get_value(index);
+  DOWNLINK_SEND_DL_VALUE(DefaultChannel,&index, &value);
+}
+
+void parse_dl_block(char* argv[]) {
+  int block = atoi(argv[1]);
+  nav_goto_block(block);
+}
+
+void parse_dl_move_wp(char* argv[]) {
+  uint8_t wp_id = atoi(argv[1]);
+  float a = MOfCm(atoi(argv[5]));
+
+  /* Computes from (lat, long) in the referenced UTM zone */
+  float lat = RadOfDeg((float)(atoi(argv[3]) / 1e7));
+  float lon = RadOfDeg((float)(atoi(argv[4]) / 1e7));
+  latlong_utm_of(lat, lon, nav_utm_zone0);
+  nav_move_waypoint(wp_id, latlong_utm_x, latlong_utm_y, a);
+
+  /* Waypoint range is limited. Computes the UTM pos back from the relative
+     coordinates */
+  latlong_utm_x = waypoints[wp_id].x + nav_utm_east0;
+  latlong_utm_y = waypoints[wp_id].y + nav_utm_north0;
+  DOWNLINK_SEND_WP_MOVED(DefaultChannel,&wp_id, &latlong_utm_x, 
&latlong_utm_y, &a, &nav_utm_zone0);
+}
+

Copied: paparazzi3/trunk/sw/airborne/arch/sim/led_hw.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/led_hw.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/led_hw.c                              
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/led_hw.c      2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,8 @@
+#include "led_hw.h"
+
+value * leds_closure = 0;
+
+value register_leds_cb(value cb_name) {
+  leds_closure = caml_named_value(String_val(cb_name));
+  return Val_unit;
+}

Copied: paparazzi3/trunk/sw/airborne/arch/sim/led_hw.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/led_hw.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/led_hw.h                              
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/led_hw.h      2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include <caml/mlvalues.h>
+#include <caml/memory.h>
+#include <caml/callback.h>
+
+extern value * leds_closure;
+
+#define LED_INIT(i) { }
+#define LED_ON(i) { if (leds_closure) callback2(*leds_closure, Val_int(i), 
Val_int(1)); }
+#define LED_OFF(i) { if (leds_closure) callback2(*leds_closure, Val_int(i), 
Val_int(0)); }
+#define LED_TOGGLE(i) { if (leds_closure) callback2(*leds_closure, Val_int(i), 
Val_int(2)); }
+ 

Copied: paparazzi3/trunk/sw/airborne/arch/sim/max1167_hw.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/max1167_hw.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/max1167_hw.c                          
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/max1167_hw.c  2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,45 @@
+/*
+ * $Id$
+ *  
+ * Copyright (C) 2008  Antoine Drouin
+ *
+ * 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. 
+ *
+ */
+
+#include "max1167.h"
+
+#include "booz_imu.h"
+
+void max1167_hw_init( void ) {}
+
+void max1167_read( void ) {}
+
+void max1167_hw_feed_value(VEC* gyro, VEC* accel) {
+
+  max1167_values[0] = gyro->ve[AXIS_P];
+  max1167_values[1] = gyro->ve[AXIS_Q];
+  max1167_values[2] = gyro->ve[AXIS_R];
+
+  buf_ax.sum =  accel->ve[AXIS_X];
+  buf_ay.sum =  accel->ve[AXIS_Y];
+  buf_az.sum =  accel->ve[AXIS_Z];
+
+  max1167_status = STA_MAX1167_DATA_AVAILABLE;
+
+}

Copied: paparazzi3/trunk/sw/airborne/arch/sim/max1167_hw.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/max1167_hw.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/max1167_hw.h                          
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/max1167_hw.h  2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,37 @@
+/*
+ * $Id$
+ *  
+ * Copyright (C) 2008  Antoine Drouin
+ *
+ * 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. 
+ *
+ */
+
+#ifndef MAX1167_HW_H
+#define MAX1167_HW_H
+
+/*
+  Simulated max1167 external ADC
+*/
+
+#include "std.h"
+#include <matrix.h>
+
+extern void max1167_hw_feed_value(VEC* gyro, VEC* accel);
+
+#endif /* MAX1167_WH */

Copied: paparazzi3/trunk/sw/airborne/arch/sim/micromag_hw.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/micromag_hw.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/micromag_hw.c                         
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/micromag_hw.c 2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,43 @@
+/*
+ * $Id$
+ *  
+ * Copyright (C) 2008  Antoine Drouin
+ *
+ * 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. 
+ *
+ */
+
+/*
+ * Simulator hardware implementation of the PNI micromag magnetometer
+ */
+
+#include "micromag.h"
+
+#include "6dof.h"
+
+void micromag_hw_init( void ) {}
+
+void micromag_read( void ) {}
+
+void micromag_hw_feed_value(VEC* mag) {
+  micromag_values[0] =  mag->ve[AXIS_X];
+  micromag_values[1] =  mag->ve[AXIS_Y];
+  micromag_values[2] =  mag->ve[AXIS_Z];
+  micromag_status = MM_DATA_AVAILABLE;
+}
+

Copied: paparazzi3/trunk/sw/airborne/arch/sim/micromag_hw.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/micromag_hw.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/micromag_hw.h                         
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/micromag_hw.h 2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,37 @@
+/*
+ * $Id$
+ *  
+ * Copyright (C) 2008  Antoine Drouin
+ *
+ * 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. 
+ *
+ */
+
+/*
+ * Simulator hardware implementation of the PNI micromag magnetometer
+ */
+
+#ifndef MICROMAG_HW_H
+#define MICROMAG_HW_H
+
+#include <matrix.h>
+
+extern void micromag_hw_feed_value(VEC* mag);
+
+
+#endif /* MICROMAG_HW_H */

Copied: paparazzi3/trunk/sw/airborne/arch/sim/ppm_hw.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/ppm_hw.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/ppm_hw.c                              
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/ppm_hw.c      2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,28 @@
+#include <inttypes.h>
+#include <caml/mlvalues.h>
+#include "ppm.h"
+
+#ifdef RADIO_CONTROL
+uint16_t ppm_pulses[ PPM_NB_PULSES ];
+volatile bool_t ppm_valid;
+
+
+value update_rc_channel(value c, value v) {
+  ppm_pulses[Int_val(c)] = Double_val(v);
+  return Val_unit;
+}
+
+value send_ppm(value unit) {
+  ppm_valid = TRUE;
+  return unit;
+}
+#else // RADIO_CONTROL
+value update_rc_channel(value c __attribute__ ((unused)), value v 
__attribute__ ((unused))) {
+  return Val_unit;
+}
+
+value send_ppm(value unit) {
+  return unit;
+}
+
+#endif // RADIO_CONTROL

Copied: paparazzi3/trunk/sw/airborne/arch/sim/ppm_hw.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/ppm_hw.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/ppm_hw.h                              
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/ppm_hw.h      2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,6 @@
+#ifndef PPM_HW_H
+#define PPM_HW_H
+
+static inline void ppm_init( void ) {}
+
+#endif /* PPM_HW_H */

Copied: paparazzi3/trunk/sw/airborne/arch/sim/scp1000_hw.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/scp1000_hw.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/scp1000_hw.c                          
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/scp1000_hw.c  2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,36 @@
+/*
+ * $Id$
+ *  
+ * Copyright (C) 2008  Antoine Drouin
+ *
+ * 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. 
+ *
+ */
+
+/*
+  hw implementation of scp1000 for sitl simulator
+*/
+
+#include "scp1000.h"
+
+void scp1000_hw_init(void) {}
+
+void scp1000_hw_feed_value(double value) {
+  scp1000_pressure = value;
+  scp1000_status = SCP1000_STA_DATA_AVAILABLE;
+}

Copied: paparazzi3/trunk/sw/airborne/arch/sim/scp1000_hw.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/scp1000_hw.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/scp1000_hw.h                          
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/scp1000_hw.h  2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,32 @@
+/*
+ * $Id$
+ *  
+ * Copyright (C) 2008  Antoine Drouin
+ *
+ * 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. 
+ *
+ */
+
+#ifndef SCP1000_HW_H
+#define SCP1000_HW_H
+
+#include <matrix.h>
+
+extern void scp1000_hw_feed_value(double value);
+
+#endif /* SCP1000_HW_H */

Copied: paparazzi3/trunk/sw/airborne/arch/sim/servos_nil.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/servos_nil.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/servos_nil.h                          
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/servos_nil.h  2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,9 @@
+#ifndef SERVOS_NIL_H
+#define SERVOS_NIL_H
+
+#define SERVOS_TICS_OF_USEC(s) SYS_TICS_OF_USEC(s)
+#define ChopServo(x,a,b) Chop(x, a, b)
+#define Actuator(i) actuators[i]
+#define ActuatorsCommit() {}
+
+#endif /* SERVOS_NIL_H */

Copied: paparazzi3/trunk/sw/airborne/arch/sim/sim_adc_generic.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/sim_adc_generic.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/sim_adc_generic.c                     
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/sim_adc_generic.c     2010-09-23 
12:33:56 UTC (rev 5932)
@@ -0,0 +1,16 @@
+#include <caml/mlvalues.h>
+#include "adc_generic.h"
+
+uint16_t adc_generic_val1;
+uint16_t adc_generic_val2;
+
+void adc_generic_init( void ) {
+}
+
+void adc_generic_periodic( void ) {
+}
+
+value update_adc1(value adc1) {
+  adc_generic_val1 = Int_val(adc1);
+  return Val_unit;
+}

Copied: paparazzi3/trunk/sw/airborne/arch/sim/sim_ap.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/sim_ap.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/sim_ap.c                              
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/sim_ap.c      2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,119 @@
+/* Definitions and declarations required to compile autopilot code on a
+   i386 architecture. Bindings for OCaml. */
+
+#include <stdio.h>
+#include <assert.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <string.h>
+#include "std.h"
+#include "inter_mcu.h"
+#include "autopilot.h"
+#include "estimator.h"
+#include "gps.h"
+#include "traffic_info.h"
+#include "flight_plan.h"
+#include "settings.h"
+#include "nav.h"
+#include "fw_h_ctl.h"
+#include "fw_v_ctl.h"
+#include "infrared.h"
+#include "commands.h"
+#include "main_ap.h"
+#include "ap_downlink.h"
+#include "sim_uart.h"
+#include "latlong.h"
+#include "datalink.h"
+
+#include <caml/mlvalues.h>
+#include <caml/memory.h>
+
+
+/* Dummy definitions to replace the ones from the files not compiled in the
+   simulator */
+uint8_t ir_estim_mode;
+uint8_t vertical_mode;
+uint8_t inflight_calib_mode;
+bool_t rc_event_1, rc_event_2;
+bool_t launch;
+uint8_t gps_nb_ovrn, modem_nb_ovrn, link_fbw_fbw_nb_err, link_fbw_nb_err;
+float alt_roll_pgain;
+float roll_rate_pgain;
+bool_t gpio1_status;
+uint16_t datalink_time = 0;
+
+
+
+uint8_t ac_id;
+
+value sim_periodic_task(value unit) {
+  periodic_task_ap();
+  periodic_task_fbw();
+  event_task_ap();
+  event_task_fbw();
+  return unit;
+}
+
+
+float ftimeofday(void) {
+  struct timeval t;
+  struct timezone z;
+  gettimeofday(&t, &z);
+  return (t.tv_sec + t.tv_usec/1e6);
+}
+
+value sim_init(value unit) {
+  init_fbw();
+  init_ap();
+#ifdef SIM_UART
+  /* open named pipe */
+  char link_pipe_name[128];
+#ifdef SIM_XBEE
+  sprintf(link_pipe_name, "/tmp/pprz_xbee");
+#else
+  sprintf(link_pipe_name, "/tmp/pprz_link_%d", AC_ID);
+#endif
+  struct stat st;
+  if (stat(link_pipe_name, &st)) {
+    if (mkfifo(link_pipe_name, 0644) == -1) {
+      perror("make pipe");
+      exit (10);
+    }
+  }    
+  if ( !(pipe_stream = fopen(link_pipe_name, "w")) ) {
+    perror("open pipe");
+    exit (10);
+  }
+#endif
+
+  return unit;
+}
+
+value update_bat(value bat) {
+  fbw_vsupply_decivolt = Int_val(bat);  
+  return Val_unit;
+}
+
+
+value get_commands(value val_commands) {
+  int i;
+
+  for(i=0; i < COMMANDS_NB; i++)
+    Store_field(val_commands, i, Val_int(commands[i]));
+
+  return Val_int(commands[COMMAND_THROTTLE]);
+}
+
+value set_datalink_message(value s) {
+  int n = string_length(s);
+  char *ss = String_val(s);
+  assert(n <= MSG_SIZE);
+
+  int i;
+  for(i = 0; i < n; i++) 
+    dl_buffer[i] = ss[i];
+
+  dl_parse_msg();
+  return Val_unit;
+}

Copied: paparazzi3/trunk/sw/airborne/arch/sim/sim_baro.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/sim_baro.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/sim_baro.c                            
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/sim_baro.c    2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,37 @@
+#include <stdlib.h>
+#include "estimator.h"
+#include "nav.h"
+#include "gps.h"
+#include "baro_MS5534A.h"
+
+bool_t alt_baro_enabled;
+bool_t spi_message_received;
+bool_t baro_MS5534A_available;
+uint32_t baro_MS5534A_pressure;
+uint32_t baro_MS5534A_ground_pressure;
+uint16_t baro_MS5534A_temp;
+float baro_MS5534A_r;
+float baro_MS5534A_sigma2;
+float baro_MS5534A_z;
+
+void baro_MS5534A_init(void) {
+  baro_MS5534A_ground_pressure = 100000;
+
+  baro_MS5534A_r = 10.;
+  baro_MS5534A_sigma2 = 1;
+}
+
+// void baro_MS5534A_reset(void);
+
+void baro_MS5534A_send(void) {
+  static bool_t even = FALSE;
+  even = !even;
+
+  spi_message_received = even;
+}
+
+void baro_MS5534A_event_task( void ) {
+  baro_MS5534A_pressure = baro_MS5534A_ground_pressure - 
(gps_alt/100.-ground_alt) / 0.08 + ((10.*random()) / RAND_MAX);
+  baro_MS5534A_temp = 10 + estimator_z;
+  baro_MS5534A_available = TRUE;
+}

Copied: paparazzi3/trunk/sw/airborne/arch/sim/sim_gps.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/sim_gps.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/sim_gps.c                             
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/sim_gps.c     2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,94 @@
+/* OCaml binding to link the simulator to autopilot functions. */
+
+#include <assert.h>
+#include <math.h>
+#include <inttypes.h>
+
+/** From airborne/autopilot/ */
+#include "airframe.h"
+#include "flight_plan.h"
+#include "autopilot.h"
+#include "gps.h"
+#include "estimator.h"
+#include "latlong.h"
+#include "common_nav.h"
+
+#include <caml/mlvalues.h>
+
+uint8_t gps_mode;
+uint16_t  gps_week;    /* weeks */
+uint32_t  gps_itow;    /* ms */
+int32_t   gps_alt;    /* cm       */
+uint16_t  gps_gspeed;  /* cm/s     */
+int16_t   gps_climb;  /* cm/s     */
+int16_t   gps_course; /* decideg     */
+int32_t gps_utm_east, gps_utm_north;
+uint8_t gps_utm_zone;
+int32_t gps_lat, gps_lon;
+struct svinfo gps_svinfos[GPS_NB_CHANNELS];
+uint8_t gps_nb_channels = 0;
+uint16_t gps_PDOP;
+uint32_t gps_Pacc, gps_Sacc;
+uint8_t gps_numSV;
+uint16_t gps_reset;
+
+
+value sim_use_gps_pos(value x, value y, value z, value c, value a, value s, 
value cl, value t, value m, value lat, value lon) {
+  gps_mode = (Bool_val(m) ? 3 : 0);
+  gps_course = DegOfRad(Double_val(c)) * 10.;
+  gps_alt = Double_val(a) * 100.;
+  gps_gspeed = Double_val(s) * 100.;
+  gps_climb = Double_val(cl) * 100.;
+  gps_week = 0; // FIXME
+  gps_itow = Double_val(t) * 1000.;
+
+#ifdef GPS_USE_LATLONG
+  gps_lat = DegOfRad(Double_val(lat))*1e7;
+  gps_lon = DegOfRad(Double_val(lon))*1e7;
+  latlong_utm_of(RadOfDeg(gps_lat/1e7), RadOfDeg(gps_lon/1e7), nav_utm_zone0);
+  gps_utm_east = latlong_utm_x * 100;
+  gps_utm_north = latlong_utm_y * 100;
+  gps_utm_zone = nav_utm_zone0;
+  x = y = z; /* Just to get rid of the "unused arg" warning */
+#else // GPS_USE_LATLONG
+  gps_utm_east = Int_val(x);
+  gps_utm_north = Int_val(y);
+  gps_utm_zone = Int_val(z);
+  lat = lon; /* Just to get rid of the "unused arg" warning */
+#endif // GPS_USE_LATLONG
+
+
+  /** Space vehicle info simulation */
+  gps_nb_channels=7;
+  int i;
+  static int time;
+  time++;
+  for(i = 0; i < gps_nb_channels; i++) {
+    gps_svinfos[i].svid = 7 + i;
+    gps_svinfos[i].elev = (cos(((100*i)+time)/100.) + 1) * 45;
+    gps_svinfos[i].azim = (time/gps_nb_channels + 50 * i) % 360;
+    gps_svinfos[i].cno = 40 + sin((time+i*10)/100.) * 10.;
+    gps_svinfos[i].flags = ((time/10) % (i+1) == 0 ? 0x00 : 0x01);
+    gps_svinfos[i].qi = (int)((time / 1000.) + i) % 8;
+  }
+  gps_PDOP = gps_Sacc = gps_Pacc = 500+200*sin(time/100.);
+  gps_numSV = 7;
+      
+  gps_verbose_downlink = !launch;
+  UseGpsPosNoSend(estimator_update_state_gps);
+  gps_downlink();
+
+
+  return Val_unit;
+}
+
+/* Second binding required because number of args > 5 */
+value sim_use_gps_pos_bytecode(value *a, int argn) {
+  assert(argn == 11);
+  return sim_use_gps_pos(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7], a[8],a[9], 
a[10]);
+}
+
+void ubxsend_cfg_rst(uint16_t a __attribute__ ((unused)), uint8_t b 
__attribute__ ((unused))) {
+  return;
+}
+

Copied: paparazzi3/trunk/sw/airborne/arch/sim/sim_ir.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/sim_ir.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/sim_ir.c                              
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/sim_ir.c      2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,37 @@
+/** \file sim_ir.c
+ *  \brief Regroup functions to simulate autopilot/infrared.c
+ *
+ * Infrared soft simulation. OCaml binding.
+ */
+
+
+#include <inttypes.h>
+#include "infrared.h"
+#include "airframe.h"
+
+#include <caml/mlvalues.h>
+
+float sim_air_speed;
+
+void ir_gain_calib(void) {
+}
+
+value set_ir(value roll __attribute__ ((unused)),
+            value front __attribute__ ((unused)),
+             value top __attribute__ ((unused)),
+            value air_speed
+            ) {
+#if defined  INFRARED || INFRARED_I2C
+  ir_roll = Int_val(roll);
+  ir_pitch = Int_val(front);
+  ir_top = Int_val(top);
+#endif
+  sim_air_speed = Double_val(air_speed);
+  return Val_unit;
+}
+
+/** Required by infrared.c:ir_init() */
+void adc_buf_channel(void* a __attribute__ ((unused)),
+                    void* b __attribute__ ((unused)),
+                    void* c __attribute__ ((unused))) {
+}

Copied: paparazzi3/trunk/sw/airborne/arch/sim/sim_jsbsim.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/sim_jsbsim.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/sim_jsbsim.c                          
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/sim_jsbsim.c  2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,69 @@
+/* Definitions and declarations required to compile autopilot code on a
+   i386 architecture */
+
+#include <stdio.h>
+#include <assert.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <string.h>
+#include "std.h"
+#include "inter_mcu.h"
+#include "autopilot.h"
+#include "estimator.h"
+#include "gps.h"
+#include "traffic_info.h"
+#include "flight_plan.h"
+#include "settings.h"
+#include "nav.h"
+#include "fw_h_ctl.h"
+#include "fw_v_ctl.h"
+#include "infrared.h"
+#include "commands.h"
+#include "main_ap.h"
+#include "ap_downlink.h"
+#include "sim_uart.h"
+#include "latlong.h"
+#include "datalink.h"
+#include "adc_generic.h"
+#include "ppm.h"
+
+
+/* Dummy definitions to replace the ones from the files not compiled in the
+   simulator */
+uint8_t ir_estim_mode;
+uint8_t vertical_mode;
+uint8_t inflight_calib_mode;
+bool_t rc_event_1, rc_event_2;
+uint8_t gps_mode;
+uint16_t  gps_week;    /* weeks */
+uint32_t  gps_itow;    /* ms */
+int32_t   gps_alt;    /* cm       */
+uint16_t  gps_gspeed;  /* cm/s     */
+int16_t   gps_climb;  /* cm/s     */
+int16_t   gps_course; /* decideg     */
+int32_t gps_utm_east, gps_utm_north;
+uint8_t gps_utm_zone;
+int32_t gps_lat, gps_lon;
+struct svinfo gps_svinfos[GPS_NB_CHANNELS];
+uint8_t gps_nb_channels = 0;
+uint16_t gps_PDOP;
+uint32_t gps_Pacc, gps_Sacc;
+uint8_t gps_numSV;
+uint16_t gps_reset;
+uint8_t gps_nb_ovrn, modem_nb_ovrn, link_fbw_fbw_nb_err, link_fbw_nb_err;
+float alt_roll_pgain;
+float roll_rate_pgain;
+bool_t gpio1_status;
+uint16_t adc_generic_val1;
+uint16_t adc_generic_val2;
+uint16_t ppm_pulses[ PPM_NB_PULSES ];
+volatile bool_t ppm_valid;
+
+uint8_t ac_id;
+
+void ir_gain_calib(void) {}
+void adc_buf_channel(uint8_t adc_channel __attribute__ ((unused)), struct 
adc_buf* s __attribute__ ((unused)), uint8_t av_nb_sample __attribute__ 
((unused))) {}
+void ubxsend_cfg_rst(uint16_t bbr __attribute__ ((unused)), uint8_t reset_mode 
__attribute__ ((unused))) {}
+void adc_generic_init( void ) {}
+void adc_generic_periodic( void ) {}

Copied: paparazzi3/trunk/sw/airborne/arch/sim/sim_uart.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/sim_uart.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/sim_uart.c                            
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/sim_uart.c    2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,3 @@
+#include "sim_uart.h"
+
+FILE* pipe_stream;

Copied: paparazzi3/trunk/sw/airborne/arch/sim/sim_uart.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/sim_uart.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/sim_uart.h                            
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/sim_uart.h    2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,14 @@
+/** \file sim_uart.h
+ * \brief Simulation of uart transmission on an Unix pipe
+ */
+
+#include <stdio.h>
+
+extern FILE* pipe_stream;
+
+#define SimUartCheckFreeSpace(_) TRUE
+
+#define SimUartTransmit(_x) fputc(_x, pipe_stream)
+#define SimUartPrintString(_s) fputs(_s, pipe_stream)
+#define SimUartSendMessage() fflush(pipe_stream);
+#define SimUartPrintHex16(c) _PrintHex16(SimUartTransmit, c)

Copied: paparazzi3/trunk/sw/airborne/arch/sim/sim_uart_hw.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/sim_uart_hw.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/sim_uart_hw.c                         
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/sim_uart_hw.c 2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,5 @@
+#include "uart_hw.h"
+
+char stdinout_buffer[STDINOUT_BUFFER_SIZE];
+uint8_t stdinout_rx_insert_idx = 0;
+uint8_t stdinout_rx_extract_idx = 0;

Copied: paparazzi3/trunk/sw/airborne/arch/sim/spi_hw.c (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/spi_hw.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/spi_hw.c                              
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/spi_hw.c      2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,3 @@
+#include "spi.h"
+
+void spi_init( void ) {}

Copied: paparazzi3/trunk/sw/airborne/arch/sim/sys_time_hw.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/sys_time_hw.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/sys_time_hw.h                         
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/sys_time_hw.h 2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,27 @@
+#ifndef SYS_TIME_HW_H
+#define SYS_TIME_HW_H
+
+#include <unistd.h>
+
+#define SYS_TICS_OF_SEC(x) (x)
+#define SIGNED_SYS_TICS_OF_SEC(x) (x)
+
+#define SEC_OF_SYS_TICS(st) (st)
+#define MSEC_OF_SYS_TICS(st) (st)
+#define USEC_OF_SYS_TICS(st) (st)
+
+#define SysTimeChronoStart() { }
+#define SysTimeChronoStop() { }
+#define SysTimeChronoStartDisableIRQ() { }
+#define SysTimeChronoStopEnableIRQAndSendUS(_tag) { }
+
+#define SysTimeTimerStart(_t) { }
+#define SysTimeTimer(_t) (_t)
+#define SysTimeTimerStop(_t) { }
+
+static inline void sys_time_init( void ) {}
+
+#define sys_time_periodic() TRUE
+#define sys_time_usleep(x) usleep(x)
+
+#endif /* SYS_TIME_HW_H */

Copied: paparazzi3/trunk/sw/airborne/arch/sim/uart_hw.h (from rev 5930, 
paparazzi3/trunk/sw/airborne/sim/uart_hw.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/sim/uart_hw.h                             
(rev 0)
+++ paparazzi3/trunk/sw/airborne/arch/sim/uart_hw.h     2010-09-23 12:33:56 UTC 
(rev 5932)
@@ -0,0 +1,40 @@
+#include <stdbool.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <sys/select.h>
+#include <unistd.h>
+#include <assert.h>
+
+#define STDINOUT_BUFFER_SIZE 256
+#define FD_STDIN 0
+
+extern char stdinout_buffer[STDINOUT_BUFFER_SIZE];
+extern uint8_t stdinout_rx_insert_idx;
+extern uint8_t stdinout_rx_extract_idx;
+
+
+static inline bool StdInOutChAvailable(void) {
+  struct timeval tv;
+  fd_set fds;
+  tv.tv_sec = 0;
+  tv.tv_usec = 0;
+  FD_ZERO(&fds);
+  FD_SET(FD_STDIN, &fds);
+  select(1, &fds, NULL, NULL, &tv);
+  if (FD_ISSET(FD_STDIN, &fds)) {
+    char tmp_buf[STDINOUT_BUFFER_SIZE];
+    uint8_t n = read(FD_STDIN, tmp_buf, STDINOUT_BUFFER_SIZE);
+    unsigned int i;
+    for(i = 0; i < n; i++) {
+      stdinout_buffer[stdinout_rx_insert_idx] = tmp_buf[i];
+      stdinout_rx_insert_idx++; /* Auto overflow */
+    }
+  }
+  return (stdinout_rx_insert_idx != stdinout_rx_extract_idx);
+}
+
+#define StdInOutTransmit(_char) putchar(_char)
+#define StdInOutGetch() ({ \
+  assert(stdinout_rx_insert_idx != stdinout_rx_extract_idx); \
+  stdinout_buffer[stdinout_rx_extract_idx++]; \
+})




reply via email to

[Prev in Thread] Current Thread [Next in Thread]