paparazzi-commits
[Top][All Lists]
Advanced

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

[paparazzi-commits] [6220] Move meteo sensors that might be useful for n


From: Martin Mueller
Subject: [paparazzi-commits] [6220] Move meteo sensors that might be useful for navigation over to the sensors / folder
Date: Sat, 23 Oct 2010 22:01:00 +0000

Revision: 6220
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=6220
Author:   mmm
Date:     2010-10-23 22:00:57 +0000 (Sat, 23 Oct 2010)
Log Message:
-----------
Move meteo sensors that might be useful for navigation over to the sensors/ 
folder

Modified Paths:
--------------
    paparazzi3/trunk/conf/modules/baro_bmp.xml
    paparazzi3/trunk/conf/modules/baro_scp.xml
    paparazzi3/trunk/conf/modules/baro_scp_i2c.xml
    paparazzi3/trunk/conf/modules/mag_micromag_fw.xml

Added Paths:
-----------
    paparazzi3/trunk/sw/airborne/arch/lpc21/modules/sensors/mag_micromag_fw_hw.c
    paparazzi3/trunk/sw/airborne/arch/lpc21/modules/sensors/mag_micromag_fw_hw.h
    paparazzi3/trunk/sw/airborne/modules/sensors/baro_bmp.c
    paparazzi3/trunk/sw/airborne/modules/sensors/baro_bmp.h
    paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp.c
    paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp.h
    paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp_i2c.c
    paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp_i2c.h
    paparazzi3/trunk/sw/airborne/modules/sensors/mag_micromag_fw.c
    paparazzi3/trunk/sw/airborne/modules/sensors/mag_micromag_fw.h

Removed Paths:
-------------
    paparazzi3/trunk/sw/airborne/arch/lpc21/modules/meteo/micromag_fw_hw.c
    paparazzi3/trunk/sw/airborne/arch/lpc21/modules/meteo/micromag_fw_hw.h
    paparazzi3/trunk/sw/airborne/modules/meteo/baro_bmp.c
    paparazzi3/trunk/sw/airborne/modules/meteo/baro_bmp.h
    paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp.c
    paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp.h
    paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp_i2c.c
    paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp_i2c.h
    paparazzi3/trunk/sw/airborne/modules/meteo/micromag_fw.c
    paparazzi3/trunk/sw/airborne/modules/meteo/micromag_fw.h

Modified: paparazzi3/trunk/conf/modules/baro_bmp.xml
===================================================================
--- paparazzi3/trunk/conf/modules/baro_bmp.xml  2010-10-23 21:28:08 UTC (rev 
6219)
+++ paparazzi3/trunk/conf/modules/baro_bmp.xml  2010-10-23 22:00:57 UTC (rev 
6220)
@@ -1,6 +1,6 @@
 <!DOCTYPE module SYSTEM "module.dtd">
 
-<module name="baro_bmp" dir="meteo">
+<module name="baro_bmp" dir="sensors">
   <header>
     <file name="baro_bmp.h"/>
   </header>

Modified: paparazzi3/trunk/conf/modules/baro_scp.xml
===================================================================
--- paparazzi3/trunk/conf/modules/baro_scp.xml  2010-10-23 21:28:08 UTC (rev 
6219)
+++ paparazzi3/trunk/conf/modules/baro_scp.xml  2010-10-23 22:00:57 UTC (rev 
6220)
@@ -1,6 +1,6 @@
 <!DOCTYPE module SYSTEM "module.dtd">
 
-<module name="baro_scp" dir="meteo">
+<module name="baro_scp" dir="sensors">
   <header>
     <file name="baro_scp.h"/>
   </header>

Modified: paparazzi3/trunk/conf/modules/baro_scp_i2c.xml
===================================================================
--- paparazzi3/trunk/conf/modules/baro_scp_i2c.xml      2010-10-23 21:28:08 UTC 
(rev 6219)
+++ paparazzi3/trunk/conf/modules/baro_scp_i2c.xml      2010-10-23 22:00:57 UTC 
(rev 6220)
@@ -1,6 +1,6 @@
 <!DOCTYPE module SYSTEM "module.dtd">
 
-<module name="baro_scp_i2c" dir="meteo">
+<module name="baro_scp_i2c" dir="sensors">
   <header>
     <file name="baro_scp_i2c.h"/>
   </header>

Modified: paparazzi3/trunk/conf/modules/mag_micromag_fw.xml
===================================================================
--- paparazzi3/trunk/conf/modules/mag_micromag_fw.xml   2010-10-23 21:28:08 UTC 
(rev 6219)
+++ paparazzi3/trunk/conf/modules/mag_micromag_fw.xml   2010-10-23 22:00:57 UTC 
(rev 6220)
@@ -1,16 +1,16 @@
 <!DOCTYPE module SYSTEM "module.dtd">
 
-<module name="mag_micromag_fw" dir="meteo">
+<module name="mag_micromag_fw" dir="sensors">
   <header>
-    <file name="micromag_fw_hw.h"/>
-    <file name="micromag_fw.h"/>
+    <file name="mag_micromag_fw_hw.h"/>
+    <file name="mag_micromag_fw.h"/>
   </header>
   <init fun="micromag_init()"/>
   <periodic fun="micromag_periodic()" freq="60"/>
   <event fun="micromag_event()"/>
   <makefile target="ap">
-    <file_hw name="micromag_fw_hw.c"/>
-    <file name="micromag_fw.c"/>
+    <file_hw name="mag_micromag_fw_hw.c"/>
+    <file name="mag_micromag_fw.c"/>
   </makefile>
 </module>
 

Deleted: paparazzi3/trunk/sw/airborne/arch/lpc21/modules/meteo/micromag_fw_hw.c
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/lpc21/modules/meteo/micromag_fw_hw.c      
2010-10-23 21:28:08 UTC (rev 6219)
+++ paparazzi3/trunk/sw/airborne/arch/lpc21/modules/meteo/micromag_fw_hw.c      
2010-10-23 22:00:57 UTC (rev 6220)
@@ -1,78 +0,0 @@
-/* PNI micromag3 connected on SPI1 */
-/* 
-   Tiny2 (fixed wing)
-   SS    on P0.20 (SSEL)
-   RESET on P0.29 (ADC5)
-   DRDY  on P0.16 ( EINT0 )
-*/
-
-#include "led.h"
-#include "micromag_fw_hw.h"
-#include "meteo/micromag_fw.h"
-
-volatile uint8_t micromag_cur_axe;
-
-static void SSP_ISR(void) __attribute__((naked));
-static void EXTINT_ISR(void) __attribute__((naked));
-
-
-static void SSP_ISR(void) {
- ISR_ENTRY();
-
- MmOnSpiIt();
-
- VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
- ISR_EXIT();
-}
-
-void EXTINT_ISR(void) {
-  ISR_ENTRY();
-//LED_TOGGLE(3); 
-
-  /* no, we won't do anything asynchronously, so just notify */
-  micromag_status = MM_GOT_EOC;
-  /* clear EINT */
-  SetBit(EXTINT,MM_DRDY_EINT);
-//  EXTINT = (1<<MM_DRDY_EINT);
-  VICVectAddr = 0x00000000;    /* clear this interrupt from the VIC */
-  ISR_EXIT();
-}
-
-void micromag_hw_init( void ) {
-  /* setup pins for SSP (SCK, MISO, MOSI, SSEL) */
-  PINSEL1 |= SSP_PINSEL1_SCK  | SSP_PINSEL1_MISO | SSP_PINSEL1_MOSI;
-  
-  /* setup SSP */
-  SSPCR0 = SSPCR0_VAL;;
-  SSPCR1 = SSPCR1_VAL;
-  SSPCPSR = 0x02;
-  
-  /* initialize interrupt vector */
-  VICIntSelect &= ~VIC_BIT( VIC_SPI1 );  /* SPI1 selected as IRQ */
-  VICIntEnable = VIC_BIT( VIC_SPI1 );    /* enable it            */
-  _VIC_CNTL(SSP_VIC_SLOT) = VIC_ENABLE | VIC_SPI1;
-  _VIC_ADDR(SSP_VIC_SLOT) = (uint32_t)SSP_ISR;      /* address of the ISR   */
-
-  MmUnselect();                   /* pin idles high */
-  /* configure SS pin */
-  SetBit(MM_SS_IODIR, MM_SS_PIN); /* pin is output  */
-
-  /* configure RESET pin */
-  SetBit(MM_RESET_IODIR, MM_RESET_PIN); /* pin is output  */
-  MmReset();                            /* pin idles low  */
-
-  /* configure DRDY pin */
-  /* connected pin to EXINT */ 
-  MM_DRDY_PINSEL |= MM_DRDY_PINSEL_VAL << MM_DRDY_PINSEL_BIT;
-  SetBit(EXTMODE, MM_DRDY_EINT); /* EINT is edge trigered */
-  SetBit(EXTPOLAR,MM_DRDY_EINT); /* EINT is trigered on rising edge */
-  SetBit(EXTINT,MM_DRDY_EINT);   /* clear pending EINT */
-  
-  /* initialize interrupt vector */
-  VICIntSelect &= ~VIC_BIT( MM_DRDY_VIC_IT );                       /* select 
EINT as IRQ source */
-  VICIntEnable = VIC_BIT( MM_DRDY_VIC_IT );                         /* enable 
it                 */
-  _VIC_CNTL(MICROMAG_DRDY_VIC_SLOT) = VIC_ENABLE | MM_DRDY_VIC_IT;
-  _VIC_ADDR(MICROMAG_DRDY_VIC_SLOT) = (uint32_t)EXTINT_ISR;         // address 
of the ISR 
-}
-
-

Deleted: paparazzi3/trunk/sw/airborne/arch/lpc21/modules/meteo/micromag_fw_hw.h
===================================================================
--- paparazzi3/trunk/sw/airborne/arch/lpc21/modules/meteo/micromag_fw_hw.h      
2010-10-23 21:28:08 UTC (rev 6219)
+++ paparazzi3/trunk/sw/airborne/arch/lpc21/modules/meteo/micromag_fw_hw.h      
2010-10-23 22:00:57 UTC (rev 6220)
@@ -1,93 +0,0 @@
-#ifndef MICROMAG_FW_HW_H
-#define MICROMAG_FW_HW_H
-
-#include <stdlib.h>  // for abs
-
-#include "std.h"
-#include "LPC21xx.h"
-#include "interrupt_hw.h" 
-
-#include "spi_hw.h"
-#include BOARD_CONFIG
-
-#include "airframe.h"
-
-#define MM_DIVISOR_128  2
-#define MM_DIVISOR_256  3
-#define MM_DIVISOR_512  4
-#define MM_DIVISOR_1024 5
-
-#define MM_DIVISOR MM_DIVISOR_512
-
-
-extern volatile uint8_t micromag_cur_axe;
-
-#define MmSelect() SetBit(MM_SS_IOCLR,MM_SS_PIN)
-#define MmUnselect() SetBit(MM_SS_IOSET,MM_SS_PIN)
-
-#define MmReset() SetBit(MM_RESET_IOCLR,MM_RESET_PIN)
-#define MmSet() SetBit(MM_RESET_IOSET,MM_RESET_PIN)
-
-#define MmOnSpiIt() {                                                  \
-    switch (micromag_status) {                                         \
-    case MM_SENDING_REQ:                                               \
-      {                                                                        
\
-       /* read dummy control byte reply */                             \
-       uint8_t foo __attribute__ ((unused)) = SSPDR;                   \
-       micromag_status = MM_WAITING_EOC;                               \
-       MmUnselect();                                                   \
-       SpiClearRti();                                                  \
-       SpiDisableRti();                                                \
-       SpiDisable();                                                   \
-      }                                                                        
\
-      break;                                                           \
-    case MM_READING_RES:                                               \
-      {                                                                        
\
-       int16_t new_val;                                                \
-       new_val = SSPDR << 8;                                           \
-       new_val += SSPDR;                                               \
-       if (abs(new_val) < 2000)                                        \
-         micromag_values[micromag_cur_axe] = new_val;                  \
-       MmUnselect();                                                   \
-       SpiClearRti();                                                  \
-       SpiDisableRti();                                                \
-       SpiDisable();                                                   \
-       micromag_cur_axe++;                                             \
-       if (micromag_cur_axe > 2) {                                     \
-         micromag_cur_axe = 0;                                         \
-         micromag_status = MM_DATA_AVAILABLE;                          \
-       }                                                               \
-       else                                                            \
-         micromag_status = MM_IDLE;                                    \
-      }                                                                        
\
-      break;                                                           \
-    }                                                                  \
-  }
-
-
-#define MmSendReq() {                                                  \
-    MmSelect();                                                                
\
-    micromag_status = MM_SENDING_REQ;                                  \
-    MmSet();                                                           \
-    SpiClearRti();                                                     \
-    SpiEnableRti();                                                    \
-    MmReset();                                                         \
-    uint8_t control_byte = (micromag_cur_axe+1) << 0 | MM_DIVISOR_1024 << 4; \
-    SSPDR = control_byte;                                              \
-    SpiEnable();                                                       \
-  }
-
-#define MmReadRes() {                                                  \
-    micromag_status = MM_READING_RES;                                  \
-    MmSelect();                                                                
\
-    /* trigger 2 bytes read */                                         \
-    SSPDR = 0;                                                 \
-    SSPDR = 0;                                                 \
-    SpiEnable();                                                       \
-    SpiClearRti();                                                     \
-    SpiEnableRti();                                                    \
-  }
-
-extern void micromag_hw_init( void );
-
-#endif /* MICROMAG_HW_H */

Copied: 
paparazzi3/trunk/sw/airborne/arch/lpc21/modules/sensors/mag_micromag_fw_hw.c 
(from rev 6206, 
paparazzi3/trunk/sw/airborne/arch/lpc21/modules/meteo/micromag_fw_hw.c)
===================================================================
--- 
paparazzi3/trunk/sw/airborne/arch/lpc21/modules/sensors/mag_micromag_fw_hw.c    
                            (rev 0)
+++ 
paparazzi3/trunk/sw/airborne/arch/lpc21/modules/sensors/mag_micromag_fw_hw.c    
    2010-10-23 22:00:57 UTC (rev 6220)
@@ -0,0 +1,78 @@
+/* PNI micromag3 connected on SPI1 */
+/* 
+   Tiny2 (fixed wing)
+   SS    on P0.20 (SSEL)
+   RESET on P0.29 (ADC5)
+   DRDY  on P0.16 ( EINT0 )
+*/
+
+#include "led.h"
+#include "mag_micromag_fw_hw.h"
+#include "sensors/mag_micromag_fw.h"
+
+volatile uint8_t micromag_cur_axe;
+
+static void SSP_ISR(void) __attribute__((naked));
+static void EXTINT_ISR(void) __attribute__((naked));
+
+
+static void SSP_ISR(void) {
+ ISR_ENTRY();
+
+ MmOnSpiIt();
+
+ VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
+ ISR_EXIT();
+}
+
+void EXTINT_ISR(void) {
+  ISR_ENTRY();
+//LED_TOGGLE(3); 
+
+  /* no, we won't do anything asynchronously, so just notify */
+  micromag_status = MM_GOT_EOC;
+  /* clear EINT */
+  SetBit(EXTINT,MM_DRDY_EINT);
+//  EXTINT = (1<<MM_DRDY_EINT);
+  VICVectAddr = 0x00000000;    /* clear this interrupt from the VIC */
+  ISR_EXIT();
+}
+
+void micromag_hw_init( void ) {
+  /* setup pins for SSP (SCK, MISO, MOSI, SSEL) */
+  PINSEL1 |= SSP_PINSEL1_SCK  | SSP_PINSEL1_MISO | SSP_PINSEL1_MOSI;
+  
+  /* setup SSP */
+  SSPCR0 = SSPCR0_VAL;;
+  SSPCR1 = SSPCR1_VAL;
+  SSPCPSR = 0x02;
+  
+  /* initialize interrupt vector */
+  VICIntSelect &= ~VIC_BIT( VIC_SPI1 );  /* SPI1 selected as IRQ */
+  VICIntEnable = VIC_BIT( VIC_SPI1 );    /* enable it            */
+  _VIC_CNTL(SSP_VIC_SLOT) = VIC_ENABLE | VIC_SPI1;
+  _VIC_ADDR(SSP_VIC_SLOT) = (uint32_t)SSP_ISR;      /* address of the ISR   */
+
+  MmUnselect();                   /* pin idles high */
+  /* configure SS pin */
+  SetBit(MM_SS_IODIR, MM_SS_PIN); /* pin is output  */
+
+  /* configure RESET pin */
+  SetBit(MM_RESET_IODIR, MM_RESET_PIN); /* pin is output  */
+  MmReset();                            /* pin idles low  */
+
+  /* configure DRDY pin */
+  /* connected pin to EXINT */ 
+  MM_DRDY_PINSEL |= MM_DRDY_PINSEL_VAL << MM_DRDY_PINSEL_BIT;
+  SetBit(EXTMODE, MM_DRDY_EINT); /* EINT is edge trigered */
+  SetBit(EXTPOLAR,MM_DRDY_EINT); /* EINT is trigered on rising edge */
+  SetBit(EXTINT,MM_DRDY_EINT);   /* clear pending EINT */
+  
+  /* initialize interrupt vector */
+  VICIntSelect &= ~VIC_BIT( MM_DRDY_VIC_IT );                       /* select 
EINT as IRQ source */
+  VICIntEnable = VIC_BIT( MM_DRDY_VIC_IT );                         /* enable 
it                 */
+  _VIC_CNTL(MICROMAG_DRDY_VIC_SLOT) = VIC_ENABLE | MM_DRDY_VIC_IT;
+  _VIC_ADDR(MICROMAG_DRDY_VIC_SLOT) = (uint32_t)EXTINT_ISR;         // address 
of the ISR 
+}
+
+

Copied: 
paparazzi3/trunk/sw/airborne/arch/lpc21/modules/sensors/mag_micromag_fw_hw.h 
(from rev 6206, 
paparazzi3/trunk/sw/airborne/arch/lpc21/modules/meteo/micromag_fw_hw.h)
===================================================================
--- 
paparazzi3/trunk/sw/airborne/arch/lpc21/modules/sensors/mag_micromag_fw_hw.h    
                            (rev 0)
+++ 
paparazzi3/trunk/sw/airborne/arch/lpc21/modules/sensors/mag_micromag_fw_hw.h    
    2010-10-23 22:00:57 UTC (rev 6220)
@@ -0,0 +1,93 @@
+#ifndef MICROMAG_FW_HW_H
+#define MICROMAG_FW_HW_H
+
+#include <stdlib.h>  // for abs
+
+#include "std.h"
+#include "LPC21xx.h"
+#include "interrupt_hw.h" 
+
+#include "spi_hw.h"
+#include BOARD_CONFIG
+
+#include "airframe.h"
+
+#define MM_DIVISOR_128  2
+#define MM_DIVISOR_256  3
+#define MM_DIVISOR_512  4
+#define MM_DIVISOR_1024 5
+
+#define MM_DIVISOR MM_DIVISOR_512
+
+
+extern volatile uint8_t micromag_cur_axe;
+
+#define MmSelect() SetBit(MM_SS_IOCLR,MM_SS_PIN)
+#define MmUnselect() SetBit(MM_SS_IOSET,MM_SS_PIN)
+
+#define MmReset() SetBit(MM_RESET_IOCLR,MM_RESET_PIN)
+#define MmSet() SetBit(MM_RESET_IOSET,MM_RESET_PIN)
+
+#define MmOnSpiIt() {                                                  \
+    switch (micromag_status) {                                         \
+    case MM_SENDING_REQ:                                               \
+      {                                                                        
\
+       /* read dummy control byte reply */                             \
+       uint8_t foo __attribute__ ((unused)) = SSPDR;                   \
+       micromag_status = MM_WAITING_EOC;                               \
+       MmUnselect();                                                   \
+       SpiClearRti();                                                  \
+       SpiDisableRti();                                                \
+       SpiDisable();                                                   \
+      }                                                                        
\
+      break;                                                           \
+    case MM_READING_RES:                                               \
+      {                                                                        
\
+       int16_t new_val;                                                \
+       new_val = SSPDR << 8;                                           \
+       new_val += SSPDR;                                               \
+       if (abs(new_val) < 2000)                                        \
+         micromag_values[micromag_cur_axe] = new_val;                  \
+       MmUnselect();                                                   \
+       SpiClearRti();                                                  \
+       SpiDisableRti();                                                \
+       SpiDisable();                                                   \
+       micromag_cur_axe++;                                             \
+       if (micromag_cur_axe > 2) {                                     \
+         micromag_cur_axe = 0;                                         \
+         micromag_status = MM_DATA_AVAILABLE;                          \
+       }                                                               \
+       else                                                            \
+         micromag_status = MM_IDLE;                                    \
+      }                                                                        
\
+      break;                                                           \
+    }                                                                  \
+  }
+
+
+#define MmSendReq() {                                                  \
+    MmSelect();                                                                
\
+    micromag_status = MM_SENDING_REQ;                                  \
+    MmSet();                                                           \
+    SpiClearRti();                                                     \
+    SpiEnableRti();                                                    \
+    MmReset();                                                         \
+    uint8_t control_byte = (micromag_cur_axe+1) << 0 | MM_DIVISOR_1024 << 4; \
+    SSPDR = control_byte;                                              \
+    SpiEnable();                                                       \
+  }
+
+#define MmReadRes() {                                                  \
+    micromag_status = MM_READING_RES;                                  \
+    MmSelect();                                                                
\
+    /* trigger 2 bytes read */                                         \
+    SSPDR = 0;                                                 \
+    SSPDR = 0;                                                 \
+    SpiEnable();                                                       \
+    SpiClearRti();                                                     \
+    SpiEnableRti();                                                    \
+  }
+
+extern void micromag_hw_init( void );
+
+#endif /* MICROMAG_HW_H */

Deleted: paparazzi3/trunk/sw/airborne/modules/meteo/baro_bmp.c
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/meteo/baro_bmp.c       2010-10-23 
21:28:08 UTC (rev 6219)
+++ paparazzi3/trunk/sw/airborne/modules/meteo/baro_bmp.c       2010-10-23 
22:00:57 UTC (rev 6220)
@@ -1,164 +0,0 @@
-/*
- * $Id: baro_bmp.c $
- *  
- * Copyright (C) 2010 Martin Mueller
- *
- * 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_bmp.c
- *  \brief Bosch BMP085 I2C sensor interface
- *
- *   This reads the values for pressure and temperature from the Bosch BMP085 
sensor through I2C.
- */
-
-
-#include "baro_bmp.h"
-
-#include "sys_time.h"
-#include "i2c.h"
-#include "led.h"
-#include "uart.h"
-#include "messages.h"
-#include "downlink.h"
-
-#ifndef BMP_I2C_DEV
-#define BMP_I2C_DEV i2c0
-#endif
-
-#define BMP085_SLAVE_ADDR 0xEE
-
-struct i2c_transaction bmp_trans;
-
-uint8_t  baro_bmp_status;
-uint32_t baro_bmp_pressure;
-uint16_t baro_bmp_temperature;
-
-int16_t  bmp_ac1, bmp_ac2, bmp_ac3;
-uint16_t bmp_ac4, bmp_ac5, bmp_ac6;
-int16_t  bmp_b1, bmp_b2;
-int16_t  bmp_mb, bmp_mc, bmp_md;
-int32_t  bmp_up, bmp_ut;
-
-void baro_bmp_init( void ) {
-  baro_bmp_status = BARO_BMP_UNINIT;
-  /* read calibration values */
-  bmp_trans.buf[0] = BMP085_EEPROM_AC1;
-  I2CTransceive(BMP_I2C_DEV, bmp_trans, BMP085_SLAVE_ADDR, 1, 22);
-}
-
-void baro_bmp_periodic( void ) {
-  if (baro_bmp_status == BARO_BMP_IDLE) {
-    /* start temp measurement (once) */
-    bmp_trans.buf[0] = BMP085_CTRL_REG;
-    bmp_trans.buf[1] = BMP085_START_TEMP;
-    I2CTransmit(BMP_I2C_DEV, bmp_trans, BMP085_SLAVE_ADDR, 2);
-    baro_bmp_status = BARO_BMP_START_TEMP;
-  }
-  else if (baro_bmp_status == BARO_BMP_START_TEMP) {
-    /* read temp measurement */
-    bmp_trans.buf[0] = BMP085_DAT_MSB;
-    I2CTransceive(BMP_I2C_DEV, bmp_trans, BMP085_SLAVE_ADDR, 1, 2);
-    baro_bmp_status = BARO_BMP_READ_TEMP;
-  }
-  else if (baro_bmp_status == BARO_BMP_START_PRESS) {
-    /* read press measurement */
-    bmp_trans.buf[0] = BMP085_DAT_MSB;
-    I2CTransceive(BMP_I2C_DEV, bmp_trans, BMP085_SLAVE_ADDR, 1, 3);
-    baro_bmp_status = BARO_BMP_READ_PRESS;
-  }
-}
-
-void baro_bmp_event( void ) {
-
-  if (bmp_trans.status == I2CTransSuccess) {
-
-    if (baro_bmp_status == BARO_BMP_UNINIT) {
-      /* get calibration data */
-      bmp_ac1 = (bmp_trans.buf[0] << 8) | bmp_trans.buf[1];
-      bmp_ac2 = (bmp_trans.buf[2] << 8) | bmp_trans.buf[3];
-      bmp_ac3 = (bmp_trans.buf[4] << 8) | bmp_trans.buf[5];
-      bmp_ac4 = (bmp_trans.buf[6] << 8) | bmp_trans.buf[7];
-      bmp_ac5 = (bmp_trans.buf[8] << 8) | bmp_trans.buf[9];
-      bmp_ac6 = (bmp_trans.buf[10] << 8) | bmp_trans.buf[11];
-      bmp_b1  = (bmp_trans.buf[12] << 8) | bmp_trans.buf[13];
-      bmp_b2  = (bmp_trans.buf[14] << 8) | bmp_trans.buf[15];
-      bmp_mb  = (bmp_trans.buf[16] << 8) | bmp_trans.buf[17];
-      bmp_mc  = (bmp_trans.buf[18] << 8) | bmp_trans.buf[19];
-      bmp_md  = (bmp_trans.buf[20] << 8) | bmp_trans.buf[21];
-      baro_bmp_status = BARO_BMP_IDLE;
-    }
-    else if (baro_bmp_status == BARO_BMP_READ_TEMP) {
-      /* get uncompensated temperature */
-      bmp_ut = (bmp_trans.buf[0] << 8) | bmp_trans.buf[1];
-      /* start high res pressure measurement */
-      bmp_trans.buf[0] = BMP085_CTRL_REG;
-      bmp_trans.buf[1] = BMP085_START_P3;
-      I2CTransmit(BMP_I2C_DEV, bmp_trans, BMP085_SLAVE_ADDR, 2);
-      baro_bmp_status = BARO_BMP_START_PRESS;
-    }
-    else if (baro_bmp_status == BARO_BMP_READ_PRESS) {
-      int32_t  bmp_p, bmp_t;
-      int32_t  bmp_x1, bmp_x2, bmp_x3;
-      int32_t  bmp_b3, bmp_b5, bmp_b6;
-      uint32_t bmp_b4, bmp_b7;
-
-      /* get uncompensated pressure, oss=3 */
-      bmp_up = (bmp_trans.buf[0] << 11) | 
-               (bmp_trans.buf[1] << 3)  |
-                bmp_trans.buf[2];
-      /* start temp measurement */
-      bmp_trans.buf[0] = BMP085_CTRL_REG;
-      bmp_trans.buf[1] = BMP085_START_TEMP;
-      I2CTransmit(BMP_I2C_DEV, bmp_trans, BMP085_SLAVE_ADDR, 2);
-      baro_bmp_status = BARO_BMP_START_TEMP;
-
-      /* compensate temperature */
-      bmp_x1 = (bmp_ut - bmp_ac6) * bmp_ac5 / (1<<15);
-      bmp_x2 = bmp_mc * (1<<11) / (bmp_x1 + bmp_md);
-      bmp_b5 = bmp_x1 + bmp_x2;
-      bmp_t  = (bmp_b5 + 8) / (1<<4);
-
-      /* compensate pressure */
-      bmp_b6 = bmp_b5 - 4000;
-      bmp_x1 = (bmp_b2 * (bmp_b6 * bmp_b6 / (1<<12))) / (1<<11);
-      bmp_x2 = bmp_ac2 *bmp_b6 / (1<<11);
-      bmp_x3 = bmp_x1 + bmp_x2;
-      bmp_b3 = (((bmp_ac1 * 4 + bmp_x3) << 3) + 2) / 4;
-      bmp_x1 = bmp_ac3 * bmp_b6 / (1<<13);
-      bmp_x2 = (bmp_b1 * (bmp_b6 * bmp_b6 / (1<<12))) / (1<<16);
-      bmp_x3 = ((bmp_x1 + bmp_x2) +2) / (1<<2);
-      bmp_b4 = bmp_ac4 * (uint32_t)(bmp_x3 + 32768) / (1<<15);
-      bmp_b7 = ((uint32_t)bmp_up - bmp_b3) * (50000>>3);
-      if (bmp_b7 < 0x80000000) 
-        bmp_p = (bmp_b7 * 2) / bmp_b4;
-      else
-        bmp_p = (bmp_b7 * bmp_b4) * 2;
-      bmp_x1 = (bmp_p / (1<<8)) * (bmp_p / (1<<8));
-      bmp_x1 = (bmp_x1 * 3038) / (1<<16);
-      bmp_x2 = (-7357 * bmp_p) / (1<<16);
-      bmp_p = bmp_p + (bmp_x1 + bmp_x2 + 3791) / (1<<4);
-
-      baro_bmp_temperature = bmp_t;
-      baro_bmp_pressure = bmp_p;
-      DOWNLINK_SEND_BMP_STATUS(DefaultChannel, &bmp_p, &bmp_t);
-    }
-  }
-}
-

Deleted: paparazzi3/trunk/sw/airborne/modules/meteo/baro_bmp.h
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/meteo/baro_bmp.h       2010-10-23 
21:28:08 UTC (rev 6219)
+++ paparazzi3/trunk/sw/airborne/modules/meteo/baro_bmp.h       2010-10-23 
22:00:57 UTC (rev 6220)
@@ -1,45 +0,0 @@
-#ifndef BARO_BMP_H
-#define BARO_BMP_H
-
-#include "std.h"
-
-#define BMP085_EEPROM_AC1   0xAA
-#define BMP085_EEPROM_AC2   0xAC
-#define BMP085_EEPROM_AC3   0xAE
-#define BMP085_EEPROM_AC4   0xB0
-#define BMP085_EEPROM_AC5   0xB2
-#define BMP085_EEPROM_AC6   0xB4
-#define BMP085_EEPROM_B1    0xB6
-#define BMP085_EEPROM_B2    0xB8
-#define BMP085_EEPROM_MB    0xBA
-#define BMP085_EEPROM_MC    0xBC
-#define BMP085_EEPROM_MD    0xBE
-
-#define BMP085_CTRL_REG     0xF4
-
-#define BMP085_START_TEMP   0x2E
-#define BMP085_START_P0     0x34
-#define BMP085_START_P1     0x74
-#define BMP085_START_P2     0xB4
-#define BMP085_START_P3     0xF4
-
-#define BMP085_DAT_MSB      0xF6
-#define BMP085_DAT_LSB      0xF7
-#define BMP085_DAT_XLSB     0xF8
-                               
-#define BARO_BMP_UNINIT       0
-#define BARO_BMP_IDLE         1
-#define BARO_BMP_START_TEMP   2
-#define BARO_BMP_READ_TEMP    3
-#define BARO_BMP_START_PRESS  4
-#define BARO_BMP_READ_PRESS   5
-
-extern uint8_t  baro_bmp_status;
-extern uint32_t baro_bmp_pressure;
-extern uint16_t baro_bmp_temperature;
-
-void baro_bmp_init(void);
-void baro_bmp_periodic(void);
-void baro_bmp_event(void);
-
-#endif

Deleted: paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp.c
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp.c       2010-10-23 
21:28:08 UTC (rev 6219)
+++ paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp.c       2010-10-23 
22:00:57 UTC (rev 6220)
@@ -1,178 +0,0 @@
-#include "std.h"
-#include "init_hw.h"
-#include "sys_time.h"
-#include "led.h"
-#include "interrupt_hw.h"
-
-#include "uart.h"
-#include "messages.h"
-#include "downlink.h"
-
-#include "spi_hw.h"
-
-#include "baro_scp.h"
-
-#define STA_UNINIT       0
-#define STA_INITIALISING 1
-#define STA_IDLE         2
-
-uint8_t  baro_scp_status;
-uint32_t baro_scp_pressure;
-uint16_t baro_scp_temperature;
-bool_t baro_scp_available;
-
-static void baro_scp_start_high_res_measurement(void);
-static void baro_scp_read(void);
-static void EXTINT_ISR(void) __attribute__((naked));
-static void SPI1_ISR(void) __attribute__((naked));
-
-void baro_scp_periodic(void) {
-  if (baro_scp_status == STA_UNINIT && cpu_time_sec > 1) {
-    baro_scp_start_high_res_measurement();
-    baro_scp_status = STA_INITIALISING;
-  }
-}
-
-/* ssp input clock 468.75kHz, clock that divided by SCR+1 */
-#define SSP_CLOCK 468750
-
-/* SSPCR0 settings */
-#define SSP_DDS  0x07 << 0  /* data size         : 8 bits        */
-#define SSP_FRF  0x00 << 4  /* frame format      : SPI           */
-#define SSP_CPOL 0x00 << 6  /* clock polarity    : data captured on first 
clock transition */  
-#define SSP_CPHA 0x00 << 7  /* clock phase       : SCK idles low */
-#define SSP_SCR  0x0F << 8  /* serial clock rate : divide by 16  */
-
-/* SSPCR1 settings */
-#define SSP_LBM  0x00 << 0  /* loopback mode     : disabled                  */
-#define SSP_SSE  0x00 << 1  /* SSP enable        : disabled                  */
-#define SSP_MS   0x00 << 2  /* master slave mode : master                    */
-#define SSP_SOD  0x00 << 3  /* slave output disable : don't care when master */
-
-#define SS_PIN   20
-#define SS_IODIR IO0DIR
-#define SS_IOSET IO0SET
-#define SS_IOCLR IO0CLR
-
-#define ScpSelect()   SetBit(SS_IOCLR,SS_PIN)
-#define ScpUnselect() SetBit(SS_IOSET,SS_PIN)
-
-void baro_scp_init( void ) {
-  /* setup pins for SSP (SCK, MISO, MOSI) */
-  PINSEL1 |= 2 << 2 | 2 << 4 | 2 << 6;
-  
-  /* setup SSP */
-  SSPCR0 = SSP_DDS | SSP_FRF | SSP_CPOL | SSP_CPHA | SSP_SCR;
-  SSPCR1 = SSP_LBM | SSP_MS | SSP_SOD;
-  /* set prescaler for SSP clock */
-  SSPCPSR = PCLK/SSP_CLOCK;
-
-  /* initialize interrupt vector */
-  VICIntSelect &= ~VIC_BIT(VIC_SPI1);   // SPI1 selected as IRQ
-  VICIntEnable = VIC_BIT(VIC_SPI1);     // SPI1 interrupt enabled
-  VICVectCntl7 = VIC_ENABLE | VIC_SPI1;
-  VICVectAddr7 = (uint32_t)SPI1_ISR;    // address of the ISR 
-  
-  /* configure SS pin */
-  SetBit(SS_IODIR, SS_PIN); /* pin is output  */
-  ScpUnselect();            /* pin idles high */
-
-  /* configure DRDY pin */
-  /* connected pin to EXINT */ 
-  SPI1_DRDY_PINSEL |= SPI1_DRDY_PINSEL_VAL << SPI1_DRDY_PINSEL_BIT;
-  SetBit(EXTMODE, SPI1_DRDY_EINT); /* EINT is edge trigered */
-  SetBit(EXTPOLAR,SPI1_DRDY_EINT); /* EINT is trigered on rising edge */
-  SetBit(EXTINT,SPI1_DRDY_EINT);   /* clear pending EINT */
-  
-  /* initialize interrupt vector */
-  VICIntSelect &= ~VIC_BIT( SPI1_DRDY_VIC_IT );  /* select EINT as IRQ source 
*/
-  VICIntEnable = VIC_BIT( SPI1_DRDY_VIC_IT );    /* enable it */
-  VICVectCntl11 = VIC_ENABLE | SPI1_DRDY_VIC_IT;
-  VICVectAddr11 = (uint32_t)EXTINT_ISR;         // address of the ISR 
-  
-  baro_scp_status = STA_UNINIT;
-}
-
-void SPI1_ISR(void) {
-  ISR_ENTRY();
-
-  if (baro_scp_status == STA_INITIALISING) {
-    uint8_t foo1 = SSPDR;
-    uint8_t foo2 = SSPDR;
-    baro_scp_status = STA_IDLE;
-    foo1=foo2;
-  }
-  else if (baro_scp_status == STA_IDLE) {
-  
-    uint8_t foo0 = SSPDR;
-    baro_scp_temperature = SSPDR<<8;
-    baro_scp_temperature += SSPDR;
-    if (baro_scp_temperature & 0x2000) {
-      baro_scp_temperature |= 0xC000;
-    }
-    baro_scp_temperature *= 5;
-
-    uint8_t foo1 = SSPDR;
-    uint32_t datard8 = SSPDR<<16;
-    uint8_t foo2 = SSPDR;
-    baro_scp_pressure = SSPDR<<8;
-    baro_scp_pressure += SSPDR;
-    baro_scp_pressure += datard8;
-    baro_scp_pressure *= 25;
-    baro_scp_available = TRUE;
-    foo1=foo2;
-    foo0=foo2;
-  }
-
-  ScpUnselect();
-  SpiClearRti();
-  SpiDisable();
-
-  VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
-  ISR_EXIT();
-}
-
-void EXTINT_ISR(void) {
-  ISR_ENTRY();
-  baro_scp_read();
-
-  SetBit(EXTINT,SPI1_DRDY_EINT); /* clear EINT2 */
-  VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
-  ISR_EXIT();
-}
-
-/* write 0x0A to 0x03 */
-static void baro_scp_start_high_res_measurement(void) {
-  uint8_t cmd  = 0x03<<2|0x02;
-  uint8_t data = 0x0A;
-  ScpSelect();
-  SSPDR = cmd;
-  SSPDR = data;
-  SpiEnableRti();
-  SpiEnable();
-}
-
-/* read 0x21 (TEMP), 0x1F (MSB) and 0x20 (LSB) */
-static void baro_scp_read(void) {
-  uint8_t cmd0 = 0x21 << 2;
-  uint8_t cmd1 = 0x1F << 2;
-  uint8_t cmd2 = 0x20 << 2;
-  ScpSelect(); 
-  SSPDR = cmd0;
-  SSPDR = 0;
-  SSPDR = 0;
-  SSPDR = cmd1;
-  SSPDR = 0;
-  SSPDR = cmd2;
-  SSPDR = 0;
-  SSPDR = 0;
-  SpiEnable();
-}
-
-void baro_scp_event( void ) {
-  if (baro_scp_available == TRUE) {
-    DOWNLINK_SEND_SCP_STATUS(DefaultChannel, &baro_scp_pressure, 
&baro_scp_temperature);
-    baro_scp_available = FALSE;
-  }
-}
-

Deleted: paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp.h
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp.h       2010-10-23 
21:28:08 UTC (rev 6219)
+++ paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp.h       2010-10-23 
22:00:57 UTC (rev 6220)
@@ -1,22 +0,0 @@
-#ifndef BARO_SCP_H
-#define BARO_SCP_H
-
-#include "std.h"
-
-#ifdef STM32
-#error LPC21_only
-#endif
-
-#define STA_UNINIT       0
-#define STA_INITIALISING 1
-#define STA_IDLE         2
-
-extern uint8_t  baro_scp_status;
-extern uint32_t baro_scp_pressure;
-extern uint16_t baro_scp_temperature;
-extern bool_t baro_scp_available;
-
-void baro_scp_init(void);
-void baro_scp_periodic(void);
-
-#endif

Deleted: paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp_i2c.c
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp_i2c.c   2010-10-23 
21:28:08 UTC (rev 6219)
+++ paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp_i2c.c   2010-10-23 
22:00:57 UTC (rev 6220)
@@ -1,102 +0,0 @@
-
-/** \file baro_scp_i2c.c
- *  \brief VTI SCP1000 I2C sensor interface
- *
- *   This reads the values for pressure and temperature from the VTI SCP1000 
sensor through I2C.
- */
-
-
-#include "baro_scp_i2c.h"
-
-#include "sys_time.h"
-#include "i2c.h"
-#include "led.h"
-#include "uart.h"
-#include "messages.h"
-#include "downlink.h"
-
-uint8_t  baro_scp_status;
-uint32_t baro_scp_pressure;
-uint16_t baro_scp_temperature;
-
-struct i2c_transaction scp_trans;
-
-#ifndef SCP_I2C_DEV
-#define SCP_I2C_DEV i2c0
-#endif
-
-#define SCP1000_SLAVE_ADDR 0x22
-
-static void baro_scp_start_high_res_measurement(void) {
-  /* switch to high resolution */
-  scp_trans.buf[0] = SCP1000_OPERATION;
-  scp_trans.buf[1] = SCP1000_HIGH_RES;
-  I2CTransmit(SCP_I2C_DEV, scp_trans, SCP1000_SLAVE_ADDR, 2);
-}
-
-void baro_scp_init( void ) {
-  baro_scp_status = BARO_SCP_UNINIT;
-}
-
-void baro_scp_periodic( void ) {
-
-  if (baro_scp_status == BARO_SCP_UNINIT && cpu_time_sec > 1) {
-
-    baro_scp_start_high_res_measurement();
-    baro_scp_status = BARO_SCP_IDLE;
-  } else if (baro_scp_status == BARO_SCP_IDLE) {
-
-    /* init: start two byte temperature */
-    scp_trans.buf[0] = SCP1000_TEMPOUT;
-    baro_scp_status = BARO_SCP_RD_TEMP;
-    I2CTransceive(SCP_I2C_DEV, scp_trans, SCP1000_SLAVE_ADDR, 1, 2);
-  }
-}
-
-void baro_scp_event( void ) {
-
-  if (scp_trans.status == I2CTransSuccess) {
-
-    if (baro_scp_status == BARO_SCP_RD_TEMP) {
-
-      /* read two byte temperature */
-      baro_scp_temperature  = scp_trans.buf[0] << 8;
-      baro_scp_temperature |= scp_trans.buf[1];
-      if (baro_scp_temperature & 0x2000) {
-        baro_scp_temperature |= 0xC000;
-      }
-      baro_scp_temperature *= 5;
-
-      /* start one byte msb pressure */
-      scp_trans.buf[0] = SCP1000_DATARD8;
-      baro_scp_status = BARO_SCP_RD_PRESS_0;
-      I2CTransceive(SCP_I2C_DEV, scp_trans, SCP1000_SLAVE_ADDR, 1, 1);
-    }
-
-    else if (baro_scp_status == BARO_SCP_RD_PRESS_0) {
-
-      /* read one byte pressure */
-      baro_scp_pressure = scp_trans.buf[0] << 16;
-
-      /* start two byte lsb pressure */
-      scp_trans.buf[0] = SCP1000_DATARD16;
-      baro_scp_status = BARO_SCP_RD_PRESS_1;
-      I2CTransceive(SCP_I2C_DEV, scp_trans, SCP1000_SLAVE_ADDR, 1, 2);
-    }
-
-    else if (baro_scp_status == BARO_SCP_RD_PRESS_1) {
-
-      /* read two byte pressure */
-      baro_scp_pressure |= scp_trans.buf[0] << 8;
-      baro_scp_pressure |= scp_trans.buf[1];
-      baro_scp_pressure *= 25;
-
-      DOWNLINK_SEND_SCP_STATUS(DefaultChannel, &baro_scp_pressure, 
&baro_scp_temperature);
-
-      baro_scp_status = BARO_SCP_IDLE;
-    }
-
-    else baro_scp_status = BARO_SCP_IDLE;
-  }
-}
-

Deleted: paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp_i2c.h
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp_i2c.h   2010-10-23 
21:28:08 UTC (rev 6219)
+++ paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp_i2c.h   2010-10-23 
22:00:57 UTC (rev 6220)
@@ -1,31 +0,0 @@
-#ifndef BARO_SCP_H
-#define BARO_SCP_H
-
-#include "std.h"
-
-#define SCP1000_OPERATION      0x03
-
-#define SCP1000_HIGH_SPEED  0x09
-#define SCP1000_HIGH_RES    0x0A
-#define SCP1000_ULT_LOW_PW  0x0B
-#define SCP1000_LOW_PW      0x0C
-
-#define SCP1000_DATARD8     0x7F
-#define SCP1000_DATARD16    0x80
-#define SCP1000_TEMPOUT     0x81
-
-#define BARO_SCP_UNINIT     0
-#define BARO_SCP_IDLE       1
-#define BARO_SCP_RD_TEMP    2
-#define BARO_SCP_RD_PRESS_0 3
-#define BARO_SCP_RD_PRESS_1 4
-
-extern uint8_t  baro_scp_status;
-extern uint32_t baro_scp_pressure;
-extern uint16_t baro_scp_temperature;
-
-void baro_scp_init(void);
-void baro_scp_periodic(void);
-void baro_scp_event(void);
-
-#endif

Deleted: paparazzi3/trunk/sw/airborne/modules/meteo/micromag_fw.c
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/meteo/micromag_fw.c    2010-10-23 
21:28:08 UTC (rev 6219)
+++ paparazzi3/trunk/sw/airborne/modules/meteo/micromag_fw.c    2010-10-23 
22:00:57 UTC (rev 6220)
@@ -1,71 +0,0 @@
-#include "micromag_fw.h"
-#include "meteo/micromag_fw_hw.h"
-#include "led.h"
-#include "uart.h"
-#include "messages.h"
-#include "downlink.h"
-
-volatile uint8_t micromag_status;
-volatile int16_t micromag_values[MM_NB_AXIS];
-
-
-void micromag_periodic( void ) {
-
-  static uint8_t cnt = 0;
-
-  if (micromag_status == MM_IDLE) {
-    //    uint8_t * tab = &cnt;
-    //    DOWNLINK_SEND_DEBUG(1,tab);
-    cnt = 0;
-    MmSendReq();
-  }
-  else if (micromag_status ==  MM_GOT_EOC) {
-    MmReadRes();
-  }
-  else if (micromag_status == MM_WAITING_EOC) {
-    cnt++;
-    if (cnt > 50) {cnt = 0; micromag_status = MM_IDLE;}
-  }
-}
-
-void micromag_event( void ) {
-
-  int32_t mx=micromag_values[0];
-  int32_t my=micromag_values[1];
-  int32_t mz=micromag_values[2];
-
-  if (micromag_status == MM_DATA_AVAILABLE) {
-    DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel,
-                &mx,
-                &my,
-                &mz );
-    micromag_status = MM_IDLE;
-  }
-}
-
-void micromag_init( void ) {
-
-  micromag_hw_init();
-  
-  uint8_t i;
-  for (i=0; i<MM_NB_AXIS; i++)
-    micromag_values[i] = 0;
-  micromag_status = MM_IDLE;
-}
-
-void micromag_reset() {
-  micromag_status = MM_IDLE;
-}
-
-void micromag_read() {
-  if (micromag_status == MM_IDLE) {
-    MmSendReq();
-  }
-  else if (micromag_status ==  MM_GOT_EOC) {
-    MmReadRes();
-  }
-  else if (micromag_status ==  MM_DATA_AVAILABLE) {
-    micromag_status = MM_IDLE;
-  }
-}
-

Deleted: paparazzi3/trunk/sw/airborne/modules/meteo/micromag_fw.h
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/meteo/micromag_fw.h    2010-10-23 
21:28:08 UTC (rev 6219)
+++ paparazzi3/trunk/sw/airborne/modules/meteo/micromag_fw.h    2010-10-23 
22:00:57 UTC (rev 6220)
@@ -1,64 +0,0 @@
-#ifndef MICROMAG_FW_H
-#define MICROMAG_FW_H
-
-
-#include "std.h"
-#define MM_NB_AXIS 3
-
-extern void micromag_init( void );
-extern void micromag_read( void );
-
-extern void micromag_reset( void);
-extern void micromag_periodic( void );
-extern void micromag_event( void );
-
-#define MM_IDLE            0
-#define MM_BUSY            1
-#define MM_SENDING_REQ     2
-#define MM_WAITING_EOC     3
-#define MM_GOT_EOC         4
-#define MM_READING_RES     5
-#define MM_DATA_AVAILABLE  6
-
-/* ssp input clock 468.75kHz, clock that divided by SCR+1 */
-#define SSP_CLOCK 468750
-
-/* SSPCR0 settings */
-#define SSP_DDS  0x07 << 0  /* data size         : 8 bits        */
-#define SSP_FRF  0x00 << 4  /* frame format      : SPI           */
-#define SSP_CPOL 0x00 << 6  /* clock polarity    : data captured on first 
clock transition */  
-#define SSP_CPHA 0x00 << 7  /* clock phase       : SCK idles low */
-#define SSP_SCR  0x0F << 8  /* serial clock rate : divide by 16  */
-
-/* SSPCR1 settings */
-#define SSP_LBM  0x00 << 0  /* loopback mode     : disabled                  */
-#define SSP_SSE  0x00 << 1  /* SSP enable        : disabled                  */
-#define SSP_MS   0x00 << 2  /* master slave mode : master                    */
-#define SSP_SOD  0x00 << 3  /* slave output disable : don't care when master */
-
-#define SS_PIN   20
-#define SS_IODIR IO0DIR
-#define SS_IOSET IO0SET
-#define SS_IOCLR IO0CLR
-
-#define SSPCR0_VAL (SSP_DDS |  SSP_FRF | SSP_CPOL | SSP_CPHA | SSP_SCR )
-#define SSPCR1_VAL (SSP_LBM |  SSP_SSE | SSP_MS | SSP_SOD )
-
-#define SSP_PINSEL1_SCK  (2<<2)
-#define SSP_PINSEL1_MISO (2<<4)
-#define SSP_PINSEL1_MOSI (2<<6)
-
-#define SSP_Enable()     SetBit(SSPCR1, SSE);
-#define SSP_Disable()    ClearBit(SSPCR1, SSE);
-#define SSP_EnableRxi()  SetBit(SSPIMSC, RXIM)
-#define SSP_DisableRxi() ClearBit(SSPIMSC, RXIM)
-#define SSP_EnableTxi()  SetBit(SSPIMSC, TXIM)
-#define SSP_DisableTxi() ClearBit(SSPIMSC, TXIM)
-#define SSP_EnableRti()  SetBit(SSPIMSC, RTIM);
-#define SSP_DisableRti() ClearBit(SSPIMSC, RTIM);
-#define SSP_ClearRti()   SetBit(SSPICR, RTIC);
-
-extern volatile uint8_t micromag_status;
-extern volatile int16_t micromag_values[MM_NB_AXIS];
-
-#endif /* MICROMAG_H */

Copied: paparazzi3/trunk/sw/airborne/modules/sensors/baro_bmp.c (from rev 6206, 
paparazzi3/trunk/sw/airborne/modules/meteo/baro_bmp.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/sensors/baro_bmp.c                     
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/sensors/baro_bmp.c     2010-10-23 
22:00:57 UTC (rev 6220)
@@ -0,0 +1,164 @@
+/*
+ * $Id: baro_bmp.c $
+ *  
+ * Copyright (C) 2010 Martin Mueller
+ *
+ * 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_bmp.c
+ *  \brief Bosch BMP085 I2C sensor interface
+ *
+ *   This reads the values for pressure and temperature from the Bosch BMP085 
sensor through I2C.
+ */
+
+
+#include "baro_bmp.h"
+
+#include "sys_time.h"
+#include "i2c.h"
+#include "led.h"
+#include "uart.h"
+#include "messages.h"
+#include "downlink.h"
+
+#ifndef BMP_I2C_DEV
+#define BMP_I2C_DEV i2c0
+#endif
+
+#define BMP085_SLAVE_ADDR 0xEE
+
+struct i2c_transaction bmp_trans;
+
+uint8_t  baro_bmp_status;
+uint32_t baro_bmp_pressure;
+uint16_t baro_bmp_temperature;
+
+int16_t  bmp_ac1, bmp_ac2, bmp_ac3;
+uint16_t bmp_ac4, bmp_ac5, bmp_ac6;
+int16_t  bmp_b1, bmp_b2;
+int16_t  bmp_mb, bmp_mc, bmp_md;
+int32_t  bmp_up, bmp_ut;
+
+void baro_bmp_init( void ) {
+  baro_bmp_status = BARO_BMP_UNINIT;
+  /* read calibration values */
+  bmp_trans.buf[0] = BMP085_EEPROM_AC1;
+  I2CTransceive(BMP_I2C_DEV, bmp_trans, BMP085_SLAVE_ADDR, 1, 22);
+}
+
+void baro_bmp_periodic( void ) {
+  if (baro_bmp_status == BARO_BMP_IDLE) {
+    /* start temp measurement (once) */
+    bmp_trans.buf[0] = BMP085_CTRL_REG;
+    bmp_trans.buf[1] = BMP085_START_TEMP;
+    I2CTransmit(BMP_I2C_DEV, bmp_trans, BMP085_SLAVE_ADDR, 2);
+    baro_bmp_status = BARO_BMP_START_TEMP;
+  }
+  else if (baro_bmp_status == BARO_BMP_START_TEMP) {
+    /* read temp measurement */
+    bmp_trans.buf[0] = BMP085_DAT_MSB;
+    I2CTransceive(BMP_I2C_DEV, bmp_trans, BMP085_SLAVE_ADDR, 1, 2);
+    baro_bmp_status = BARO_BMP_READ_TEMP;
+  }
+  else if (baro_bmp_status == BARO_BMP_START_PRESS) {
+    /* read press measurement */
+    bmp_trans.buf[0] = BMP085_DAT_MSB;
+    I2CTransceive(BMP_I2C_DEV, bmp_trans, BMP085_SLAVE_ADDR, 1, 3);
+    baro_bmp_status = BARO_BMP_READ_PRESS;
+  }
+}
+
+void baro_bmp_event( void ) {
+
+  if (bmp_trans.status == I2CTransSuccess) {
+
+    if (baro_bmp_status == BARO_BMP_UNINIT) {
+      /* get calibration data */
+      bmp_ac1 = (bmp_trans.buf[0] << 8) | bmp_trans.buf[1];
+      bmp_ac2 = (bmp_trans.buf[2] << 8) | bmp_trans.buf[3];
+      bmp_ac3 = (bmp_trans.buf[4] << 8) | bmp_trans.buf[5];
+      bmp_ac4 = (bmp_trans.buf[6] << 8) | bmp_trans.buf[7];
+      bmp_ac5 = (bmp_trans.buf[8] << 8) | bmp_trans.buf[9];
+      bmp_ac6 = (bmp_trans.buf[10] << 8) | bmp_trans.buf[11];
+      bmp_b1  = (bmp_trans.buf[12] << 8) | bmp_trans.buf[13];
+      bmp_b2  = (bmp_trans.buf[14] << 8) | bmp_trans.buf[15];
+      bmp_mb  = (bmp_trans.buf[16] << 8) | bmp_trans.buf[17];
+      bmp_mc  = (bmp_trans.buf[18] << 8) | bmp_trans.buf[19];
+      bmp_md  = (bmp_trans.buf[20] << 8) | bmp_trans.buf[21];
+      baro_bmp_status = BARO_BMP_IDLE;
+    }
+    else if (baro_bmp_status == BARO_BMP_READ_TEMP) {
+      /* get uncompensated temperature */
+      bmp_ut = (bmp_trans.buf[0] << 8) | bmp_trans.buf[1];
+      /* start high res pressure measurement */
+      bmp_trans.buf[0] = BMP085_CTRL_REG;
+      bmp_trans.buf[1] = BMP085_START_P3;
+      I2CTransmit(BMP_I2C_DEV, bmp_trans, BMP085_SLAVE_ADDR, 2);
+      baro_bmp_status = BARO_BMP_START_PRESS;
+    }
+    else if (baro_bmp_status == BARO_BMP_READ_PRESS) {
+      int32_t  bmp_p, bmp_t;
+      int32_t  bmp_x1, bmp_x2, bmp_x3;
+      int32_t  bmp_b3, bmp_b5, bmp_b6;
+      uint32_t bmp_b4, bmp_b7;
+
+      /* get uncompensated pressure, oss=3 */
+      bmp_up = (bmp_trans.buf[0] << 11) | 
+               (bmp_trans.buf[1] << 3)  |
+                bmp_trans.buf[2];
+      /* start temp measurement */
+      bmp_trans.buf[0] = BMP085_CTRL_REG;
+      bmp_trans.buf[1] = BMP085_START_TEMP;
+      I2CTransmit(BMP_I2C_DEV, bmp_trans, BMP085_SLAVE_ADDR, 2);
+      baro_bmp_status = BARO_BMP_START_TEMP;
+
+      /* compensate temperature */
+      bmp_x1 = (bmp_ut - bmp_ac6) * bmp_ac5 / (1<<15);
+      bmp_x2 = bmp_mc * (1<<11) / (bmp_x1 + bmp_md);
+      bmp_b5 = bmp_x1 + bmp_x2;
+      bmp_t  = (bmp_b5 + 8) / (1<<4);
+
+      /* compensate pressure */
+      bmp_b6 = bmp_b5 - 4000;
+      bmp_x1 = (bmp_b2 * (bmp_b6 * bmp_b6 / (1<<12))) / (1<<11);
+      bmp_x2 = bmp_ac2 *bmp_b6 / (1<<11);
+      bmp_x3 = bmp_x1 + bmp_x2;
+      bmp_b3 = (((bmp_ac1 * 4 + bmp_x3) << 3) + 2) / 4;
+      bmp_x1 = bmp_ac3 * bmp_b6 / (1<<13);
+      bmp_x2 = (bmp_b1 * (bmp_b6 * bmp_b6 / (1<<12))) / (1<<16);
+      bmp_x3 = ((bmp_x1 + bmp_x2) +2) / (1<<2);
+      bmp_b4 = bmp_ac4 * (uint32_t)(bmp_x3 + 32768) / (1<<15);
+      bmp_b7 = ((uint32_t)bmp_up - bmp_b3) * (50000>>3);
+      if (bmp_b7 < 0x80000000) 
+        bmp_p = (bmp_b7 * 2) / bmp_b4;
+      else
+        bmp_p = (bmp_b7 * bmp_b4) * 2;
+      bmp_x1 = (bmp_p / (1<<8)) * (bmp_p / (1<<8));
+      bmp_x1 = (bmp_x1 * 3038) / (1<<16);
+      bmp_x2 = (-7357 * bmp_p) / (1<<16);
+      bmp_p = bmp_p + (bmp_x1 + bmp_x2 + 3791) / (1<<4);
+
+      baro_bmp_temperature = bmp_t;
+      baro_bmp_pressure = bmp_p;
+      DOWNLINK_SEND_BMP_STATUS(DefaultChannel, &bmp_p, &bmp_t);
+    }
+  }
+}
+

Copied: paparazzi3/trunk/sw/airborne/modules/sensors/baro_bmp.h (from rev 6206, 
paparazzi3/trunk/sw/airborne/modules/meteo/baro_bmp.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/sensors/baro_bmp.h                     
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/sensors/baro_bmp.h     2010-10-23 
22:00:57 UTC (rev 6220)
@@ -0,0 +1,45 @@
+#ifndef BARO_BMP_H
+#define BARO_BMP_H
+
+#include "std.h"
+
+#define BMP085_EEPROM_AC1   0xAA
+#define BMP085_EEPROM_AC2   0xAC
+#define BMP085_EEPROM_AC3   0xAE
+#define BMP085_EEPROM_AC4   0xB0
+#define BMP085_EEPROM_AC5   0xB2
+#define BMP085_EEPROM_AC6   0xB4
+#define BMP085_EEPROM_B1    0xB6
+#define BMP085_EEPROM_B2    0xB8
+#define BMP085_EEPROM_MB    0xBA
+#define BMP085_EEPROM_MC    0xBC
+#define BMP085_EEPROM_MD    0xBE
+
+#define BMP085_CTRL_REG     0xF4
+
+#define BMP085_START_TEMP   0x2E
+#define BMP085_START_P0     0x34
+#define BMP085_START_P1     0x74
+#define BMP085_START_P2     0xB4
+#define BMP085_START_P3     0xF4
+
+#define BMP085_DAT_MSB      0xF6
+#define BMP085_DAT_LSB      0xF7
+#define BMP085_DAT_XLSB     0xF8
+                               
+#define BARO_BMP_UNINIT       0
+#define BARO_BMP_IDLE         1
+#define BARO_BMP_START_TEMP   2
+#define BARO_BMP_READ_TEMP    3
+#define BARO_BMP_START_PRESS  4
+#define BARO_BMP_READ_PRESS   5
+
+extern uint8_t  baro_bmp_status;
+extern uint32_t baro_bmp_pressure;
+extern uint16_t baro_bmp_temperature;
+
+void baro_bmp_init(void);
+void baro_bmp_periodic(void);
+void baro_bmp_event(void);
+
+#endif

Copied: paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp.c (from rev 6206, 
paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp.c                     
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp.c     2010-10-23 
22:00:57 UTC (rev 6220)
@@ -0,0 +1,178 @@
+#include "std.h"
+#include "init_hw.h"
+#include "sys_time.h"
+#include "led.h"
+#include "interrupt_hw.h"
+
+#include "uart.h"
+#include "messages.h"
+#include "downlink.h"
+
+#include "spi_hw.h"
+
+#include "baro_scp.h"
+
+#define STA_UNINIT       0
+#define STA_INITIALISING 1
+#define STA_IDLE         2
+
+uint8_t  baro_scp_status;
+uint32_t baro_scp_pressure;
+uint16_t baro_scp_temperature;
+bool_t baro_scp_available;
+
+static void baro_scp_start_high_res_measurement(void);
+static void baro_scp_read(void);
+static void EXTINT_ISR(void) __attribute__((naked));
+static void SPI1_ISR(void) __attribute__((naked));
+
+void baro_scp_periodic(void) {
+  if (baro_scp_status == STA_UNINIT && cpu_time_sec > 1) {
+    baro_scp_start_high_res_measurement();
+    baro_scp_status = STA_INITIALISING;
+  }
+}
+
+/* ssp input clock 468.75kHz, clock that divided by SCR+1 */
+#define SSP_CLOCK 468750
+
+/* SSPCR0 settings */
+#define SSP_DDS  0x07 << 0  /* data size         : 8 bits        */
+#define SSP_FRF  0x00 << 4  /* frame format      : SPI           */
+#define SSP_CPOL 0x00 << 6  /* clock polarity    : data captured on first 
clock transition */  
+#define SSP_CPHA 0x00 << 7  /* clock phase       : SCK idles low */
+#define SSP_SCR  0x0F << 8  /* serial clock rate : divide by 16  */
+
+/* SSPCR1 settings */
+#define SSP_LBM  0x00 << 0  /* loopback mode     : disabled                  */
+#define SSP_SSE  0x00 << 1  /* SSP enable        : disabled                  */
+#define SSP_MS   0x00 << 2  /* master slave mode : master                    */
+#define SSP_SOD  0x00 << 3  /* slave output disable : don't care when master */
+
+#define SS_PIN   20
+#define SS_IODIR IO0DIR
+#define SS_IOSET IO0SET
+#define SS_IOCLR IO0CLR
+
+#define ScpSelect()   SetBit(SS_IOCLR,SS_PIN)
+#define ScpUnselect() SetBit(SS_IOSET,SS_PIN)
+
+void baro_scp_init( void ) {
+  /* setup pins for SSP (SCK, MISO, MOSI) */
+  PINSEL1 |= 2 << 2 | 2 << 4 | 2 << 6;
+  
+  /* setup SSP */
+  SSPCR0 = SSP_DDS | SSP_FRF | SSP_CPOL | SSP_CPHA | SSP_SCR;
+  SSPCR1 = SSP_LBM | SSP_MS | SSP_SOD;
+  /* set prescaler for SSP clock */
+  SSPCPSR = PCLK/SSP_CLOCK;
+
+  /* initialize interrupt vector */
+  VICIntSelect &= ~VIC_BIT(VIC_SPI1);   // SPI1 selected as IRQ
+  VICIntEnable = VIC_BIT(VIC_SPI1);     // SPI1 interrupt enabled
+  VICVectCntl7 = VIC_ENABLE | VIC_SPI1;
+  VICVectAddr7 = (uint32_t)SPI1_ISR;    // address of the ISR 
+  
+  /* configure SS pin */
+  SetBit(SS_IODIR, SS_PIN); /* pin is output  */
+  ScpUnselect();            /* pin idles high */
+
+  /* configure DRDY pin */
+  /* connected pin to EXINT */ 
+  SPI1_DRDY_PINSEL |= SPI1_DRDY_PINSEL_VAL << SPI1_DRDY_PINSEL_BIT;
+  SetBit(EXTMODE, SPI1_DRDY_EINT); /* EINT is edge trigered */
+  SetBit(EXTPOLAR,SPI1_DRDY_EINT); /* EINT is trigered on rising edge */
+  SetBit(EXTINT,SPI1_DRDY_EINT);   /* clear pending EINT */
+  
+  /* initialize interrupt vector */
+  VICIntSelect &= ~VIC_BIT( SPI1_DRDY_VIC_IT );  /* select EINT as IRQ source 
*/
+  VICIntEnable = VIC_BIT( SPI1_DRDY_VIC_IT );    /* enable it */
+  VICVectCntl11 = VIC_ENABLE | SPI1_DRDY_VIC_IT;
+  VICVectAddr11 = (uint32_t)EXTINT_ISR;         // address of the ISR 
+  
+  baro_scp_status = STA_UNINIT;
+}
+
+void SPI1_ISR(void) {
+  ISR_ENTRY();
+
+  if (baro_scp_status == STA_INITIALISING) {
+    uint8_t foo1 = SSPDR;
+    uint8_t foo2 = SSPDR;
+    baro_scp_status = STA_IDLE;
+    foo1=foo2;
+  }
+  else if (baro_scp_status == STA_IDLE) {
+  
+    uint8_t foo0 = SSPDR;
+    baro_scp_temperature = SSPDR<<8;
+    baro_scp_temperature += SSPDR;
+    if (baro_scp_temperature & 0x2000) {
+      baro_scp_temperature |= 0xC000;
+    }
+    baro_scp_temperature *= 5;
+
+    uint8_t foo1 = SSPDR;
+    uint32_t datard8 = SSPDR<<16;
+    uint8_t foo2 = SSPDR;
+    baro_scp_pressure = SSPDR<<8;
+    baro_scp_pressure += SSPDR;
+    baro_scp_pressure += datard8;
+    baro_scp_pressure *= 25;
+    baro_scp_available = TRUE;
+    foo1=foo2;
+    foo0=foo2;
+  }
+
+  ScpUnselect();
+  SpiClearRti();
+  SpiDisable();
+
+  VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
+  ISR_EXIT();
+}
+
+void EXTINT_ISR(void) {
+  ISR_ENTRY();
+  baro_scp_read();
+
+  SetBit(EXTINT,SPI1_DRDY_EINT); /* clear EINT2 */
+  VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
+  ISR_EXIT();
+}
+
+/* write 0x0A to 0x03 */
+static void baro_scp_start_high_res_measurement(void) {
+  uint8_t cmd  = 0x03<<2|0x02;
+  uint8_t data = 0x0A;
+  ScpSelect();
+  SSPDR = cmd;
+  SSPDR = data;
+  SpiEnableRti();
+  SpiEnable();
+}
+
+/* read 0x21 (TEMP), 0x1F (MSB) and 0x20 (LSB) */
+static void baro_scp_read(void) {
+  uint8_t cmd0 = 0x21 << 2;
+  uint8_t cmd1 = 0x1F << 2;
+  uint8_t cmd2 = 0x20 << 2;
+  ScpSelect(); 
+  SSPDR = cmd0;
+  SSPDR = 0;
+  SSPDR = 0;
+  SSPDR = cmd1;
+  SSPDR = 0;
+  SSPDR = cmd2;
+  SSPDR = 0;
+  SSPDR = 0;
+  SpiEnable();
+}
+
+void baro_scp_event( void ) {
+  if (baro_scp_available == TRUE) {
+    DOWNLINK_SEND_SCP_STATUS(DefaultChannel, &baro_scp_pressure, 
&baro_scp_temperature);
+    baro_scp_available = FALSE;
+  }
+}
+

Copied: paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp.h (from rev 6206, 
paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp.h                     
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp.h     2010-10-23 
22:00:57 UTC (rev 6220)
@@ -0,0 +1,23 @@
+#ifndef BARO_SCP_H
+#define BARO_SCP_H
+
+#include "std.h"
+
+#ifdef STM32
+#error LPC21_only
+#endif
+
+#define STA_UNINIT       0
+#define STA_INITIALISING 1
+#define STA_IDLE         2
+
+extern uint8_t  baro_scp_status;
+extern uint32_t baro_scp_pressure;
+extern uint16_t baro_scp_temperature;
+extern bool_t baro_scp_available;
+
+void baro_scp_init(void);
+void baro_scp_periodic(void);
+void baro_scp_event(void);
+
+#endif

Copied: paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp_i2c.c (from rev 
6206, paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp_i2c.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp_i2c.c                 
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp_i2c.c 2010-10-23 
22:00:57 UTC (rev 6220)
@@ -0,0 +1,102 @@
+
+/** \file baro_scp_i2c.c
+ *  \brief VTI SCP1000 I2C sensor interface
+ *
+ *   This reads the values for pressure and temperature from the VTI SCP1000 
sensor through I2C.
+ */
+
+
+#include "baro_scp_i2c.h"
+
+#include "sys_time.h"
+#include "i2c.h"
+#include "led.h"
+#include "uart.h"
+#include "messages.h"
+#include "downlink.h"
+
+uint8_t  baro_scp_status;
+uint32_t baro_scp_pressure;
+uint16_t baro_scp_temperature;
+
+struct i2c_transaction scp_trans;
+
+#ifndef SCP_I2C_DEV
+#define SCP_I2C_DEV i2c0
+#endif
+
+#define SCP1000_SLAVE_ADDR 0x22
+
+static void baro_scp_start_high_res_measurement(void) {
+  /* switch to high resolution */
+  scp_trans.buf[0] = SCP1000_OPERATION;
+  scp_trans.buf[1] = SCP1000_HIGH_RES;
+  I2CTransmit(SCP_I2C_DEV, scp_trans, SCP1000_SLAVE_ADDR, 2);
+}
+
+void baro_scp_init( void ) {
+  baro_scp_status = BARO_SCP_UNINIT;
+}
+
+void baro_scp_periodic( void ) {
+
+  if (baro_scp_status == BARO_SCP_UNINIT && cpu_time_sec > 1) {
+
+    baro_scp_start_high_res_measurement();
+    baro_scp_status = BARO_SCP_IDLE;
+  } else if (baro_scp_status == BARO_SCP_IDLE) {
+
+    /* init: start two byte temperature */
+    scp_trans.buf[0] = SCP1000_TEMPOUT;
+    baro_scp_status = BARO_SCP_RD_TEMP;
+    I2CTransceive(SCP_I2C_DEV, scp_trans, SCP1000_SLAVE_ADDR, 1, 2);
+  }
+}
+
+void baro_scp_event( void ) {
+
+  if (scp_trans.status == I2CTransSuccess) {
+
+    if (baro_scp_status == BARO_SCP_RD_TEMP) {
+
+      /* read two byte temperature */
+      baro_scp_temperature  = scp_trans.buf[0] << 8;
+      baro_scp_temperature |= scp_trans.buf[1];
+      if (baro_scp_temperature & 0x2000) {
+        baro_scp_temperature |= 0xC000;
+      }
+      baro_scp_temperature *= 5;
+
+      /* start one byte msb pressure */
+      scp_trans.buf[0] = SCP1000_DATARD8;
+      baro_scp_status = BARO_SCP_RD_PRESS_0;
+      I2CTransceive(SCP_I2C_DEV, scp_trans, SCP1000_SLAVE_ADDR, 1, 1);
+    }
+
+    else if (baro_scp_status == BARO_SCP_RD_PRESS_0) {
+
+      /* read one byte pressure */
+      baro_scp_pressure = scp_trans.buf[0] << 16;
+
+      /* start two byte lsb pressure */
+      scp_trans.buf[0] = SCP1000_DATARD16;
+      baro_scp_status = BARO_SCP_RD_PRESS_1;
+      I2CTransceive(SCP_I2C_DEV, scp_trans, SCP1000_SLAVE_ADDR, 1, 2);
+    }
+
+    else if (baro_scp_status == BARO_SCP_RD_PRESS_1) {
+
+      /* read two byte pressure */
+      baro_scp_pressure |= scp_trans.buf[0] << 8;
+      baro_scp_pressure |= scp_trans.buf[1];
+      baro_scp_pressure *= 25;
+
+      DOWNLINK_SEND_SCP_STATUS(DefaultChannel, &baro_scp_pressure, 
&baro_scp_temperature);
+
+      baro_scp_status = BARO_SCP_IDLE;
+    }
+
+    else baro_scp_status = BARO_SCP_IDLE;
+  }
+}
+

Copied: paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp_i2c.h (from rev 
6206, paparazzi3/trunk/sw/airborne/modules/meteo/baro_scp_i2c.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp_i2c.h                 
        (rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/sensors/baro_scp_i2c.h 2010-10-23 
22:00:57 UTC (rev 6220)
@@ -0,0 +1,31 @@
+#ifndef BARO_SCP_H
+#define BARO_SCP_H
+
+#include "std.h"
+
+#define SCP1000_OPERATION      0x03
+
+#define SCP1000_HIGH_SPEED  0x09
+#define SCP1000_HIGH_RES    0x0A
+#define SCP1000_ULT_LOW_PW  0x0B
+#define SCP1000_LOW_PW      0x0C
+
+#define SCP1000_DATARD8     0x7F
+#define SCP1000_DATARD16    0x80
+#define SCP1000_TEMPOUT     0x81
+
+#define BARO_SCP_UNINIT     0
+#define BARO_SCP_IDLE       1
+#define BARO_SCP_RD_TEMP    2
+#define BARO_SCP_RD_PRESS_0 3
+#define BARO_SCP_RD_PRESS_1 4
+
+extern uint8_t  baro_scp_status;
+extern uint32_t baro_scp_pressure;
+extern uint16_t baro_scp_temperature;
+
+void baro_scp_init(void);
+void baro_scp_periodic(void);
+void baro_scp_event(void);
+
+#endif

Copied: paparazzi3/trunk/sw/airborne/modules/sensors/mag_micromag_fw.c (from 
rev 6206, paparazzi3/trunk/sw/airborne/modules/meteo/micromag_fw.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/sensors/mag_micromag_fw.c              
                (rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/sensors/mag_micromag_fw.c      
2010-10-23 22:00:57 UTC (rev 6220)
@@ -0,0 +1,71 @@
+#include "mag_micromag_fw.h"
+#include "sensors/mag_micromag_fw_hw.h"
+#include "led.h"
+#include "uart.h"
+#include "messages.h"
+#include "downlink.h"
+
+volatile uint8_t micromag_status;
+volatile int16_t micromag_values[MM_NB_AXIS];
+
+
+void micromag_periodic( void ) {
+
+  static uint8_t cnt = 0;
+
+  if (micromag_status == MM_IDLE) {
+    //    uint8_t * tab = &cnt;
+    //    DOWNLINK_SEND_DEBUG(1,tab);
+    cnt = 0;
+    MmSendReq();
+  }
+  else if (micromag_status ==  MM_GOT_EOC) {
+    MmReadRes();
+  }
+  else if (micromag_status == MM_WAITING_EOC) {
+    cnt++;
+    if (cnt > 50) {cnt = 0; micromag_status = MM_IDLE;}
+  }
+}
+
+void micromag_event( void ) {
+
+  int32_t mx=micromag_values[0];
+  int32_t my=micromag_values[1];
+  int32_t mz=micromag_values[2];
+
+  if (micromag_status == MM_DATA_AVAILABLE) {
+    DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel,
+                &mx,
+                &my,
+                &mz );
+    micromag_status = MM_IDLE;
+  }
+}
+
+void micromag_init( void ) {
+
+  micromag_hw_init();
+  
+  uint8_t i;
+  for (i=0; i<MM_NB_AXIS; i++)
+    micromag_values[i] = 0;
+  micromag_status = MM_IDLE;
+}
+
+void micromag_reset() {
+  micromag_status = MM_IDLE;
+}
+
+void micromag_read() {
+  if (micromag_status == MM_IDLE) {
+    MmSendReq();
+  }
+  else if (micromag_status ==  MM_GOT_EOC) {
+    MmReadRes();
+  }
+  else if (micromag_status ==  MM_DATA_AVAILABLE) {
+    micromag_status = MM_IDLE;
+  }
+}
+

Copied: paparazzi3/trunk/sw/airborne/modules/sensors/mag_micromag_fw.h (from 
rev 6206, paparazzi3/trunk/sw/airborne/modules/meteo/micromag_fw.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/sensors/mag_micromag_fw.h              
                (rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/sensors/mag_micromag_fw.h      
2010-10-23 22:00:57 UTC (rev 6220)
@@ -0,0 +1,64 @@
+#ifndef MICROMAG_FW_H
+#define MICROMAG_FW_H
+
+
+#include "std.h"
+#define MM_NB_AXIS 3
+
+extern void micromag_init( void );
+extern void micromag_read( void );
+
+extern void micromag_reset( void);
+extern void micromag_periodic( void );
+extern void micromag_event( void );
+
+#define MM_IDLE            0
+#define MM_BUSY            1
+#define MM_SENDING_REQ     2
+#define MM_WAITING_EOC     3
+#define MM_GOT_EOC         4
+#define MM_READING_RES     5
+#define MM_DATA_AVAILABLE  6
+
+/* ssp input clock 468.75kHz, clock that divided by SCR+1 */
+#define SSP_CLOCK 468750
+
+/* SSPCR0 settings */
+#define SSP_DDS  0x07 << 0  /* data size         : 8 bits        */
+#define SSP_FRF  0x00 << 4  /* frame format      : SPI           */
+#define SSP_CPOL 0x00 << 6  /* clock polarity    : data captured on first 
clock transition */  
+#define SSP_CPHA 0x00 << 7  /* clock phase       : SCK idles low */
+#define SSP_SCR  0x0F << 8  /* serial clock rate : divide by 16  */
+
+/* SSPCR1 settings */
+#define SSP_LBM  0x00 << 0  /* loopback mode     : disabled                  */
+#define SSP_SSE  0x00 << 1  /* SSP enable        : disabled                  */
+#define SSP_MS   0x00 << 2  /* master slave mode : master                    */
+#define SSP_SOD  0x00 << 3  /* slave output disable : don't care when master */
+
+#define SS_PIN   20
+#define SS_IODIR IO0DIR
+#define SS_IOSET IO0SET
+#define SS_IOCLR IO0CLR
+
+#define SSPCR0_VAL (SSP_DDS |  SSP_FRF | SSP_CPOL | SSP_CPHA | SSP_SCR )
+#define SSPCR1_VAL (SSP_LBM |  SSP_SSE | SSP_MS | SSP_SOD )
+
+#define SSP_PINSEL1_SCK  (2<<2)
+#define SSP_PINSEL1_MISO (2<<4)
+#define SSP_PINSEL1_MOSI (2<<6)
+
+#define SSP_Enable()     SetBit(SSPCR1, SSE);
+#define SSP_Disable()    ClearBit(SSPCR1, SSE);
+#define SSP_EnableRxi()  SetBit(SSPIMSC, RXIM)
+#define SSP_DisableRxi() ClearBit(SSPIMSC, RXIM)
+#define SSP_EnableTxi()  SetBit(SSPIMSC, TXIM)
+#define SSP_DisableTxi() ClearBit(SSPIMSC, TXIM)
+#define SSP_EnableRti()  SetBit(SSPIMSC, RTIM);
+#define SSP_DisableRti() ClearBit(SSPIMSC, RTIM);
+#define SSP_ClearRti()   SetBit(SSPICR, RTIC);
+
+extern volatile uint8_t micromag_status;
+extern volatile int16_t micromag_values[MM_NB_AXIS];
+
+#endif /* MICROMAG_H */




reply via email to

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