paparazzi-commits
[Top][All Lists]
Advanced

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

[paparazzi-commits] [5789] converted hmc5843 test program to new i2c int


From: antoine drouin
Subject: [paparazzi-commits] [5789] converted hmc5843 test program to new i2c interface
Date: Thu, 02 Sep 2010 18:05:09 +0000

Revision: 5789
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=5789
Author:   poine
Date:     2010-09-02 18:05:09 +0000 (Thu, 02 Sep 2010)
Log Message:
-----------
converted hmc5843 test program to new i2c interface

Modified Paths:
--------------
    paparazzi3/trunk/conf/airframes/Poine/booz2_a7.xml
    paparazzi3/trunk/conf/autopilot/lisa_l_test_progs.makefile
    paparazzi3/trunk/sw/airborne/lisa/test/lisa_test_hmc5843.c
    paparazzi3/trunk/sw/airborne/stm32/i2c_hw.c

Modified: paparazzi3/trunk/conf/airframes/Poine/booz2_a7.xml
===================================================================
--- paparazzi3/trunk/conf/airframes/Poine/booz2_a7.xml  2010-09-02 17:35:44 UTC 
(rev 5788)
+++ paparazzi3/trunk/conf/airframes/Poine/booz2_a7.xml  2010-09-02 18:05:09 UTC 
(rev 5789)
@@ -182,7 +182,7 @@
 -->
  
   <firmware name="rotorcraft">
-    <target name="ap" board="lisa_l_1.1">
+    <target name="ap" board="lisa_l_1.0">
 <!--      <define name="BOOZ_START_DELAY" value="1"/> -->
       <subsystem name="radio_control" type="spektrum">
         <param name="RADIO_CONTROL_SPEKTRUM_MODEL" 
@@ -208,6 +208,7 @@
     <target name="test_rc_spektrum" board="lisa_l_1.0"/>
     <target name="test_rc_ppm"      board="lisa_l_1.0"/>
     <target name="test_adc"         board="lisa_l_1.0"/>
+    <target name="test_hmc5843"     board="lisa_l_1.0"/>
   </firmware>
 
   <firmware name="lisa_passthrough">

Modified: paparazzi3/trunk/conf/autopilot/lisa_l_test_progs.makefile
===================================================================
--- paparazzi3/trunk/conf/autopilot/lisa_l_test_progs.makefile  2010-09-02 
17:35:44 UTC (rev 5788)
+++ paparazzi3/trunk/conf/autopilot/lisa_l_test_progs.makefile  2010-09-02 
18:05:09 UTC (rev 5789)
@@ -224,7 +224,7 @@
 
 test_adc.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
 test_adc.srcs   += $(SRC_ARCH)/uart_hw.c
-test_adc.CFLAGS += -DDATALINK=PPRZ -DPPRZ_UART=Uart2
+test_adc.CFLAGS += -DDATALINK=PPRZ -DPPRZ_UART=$(MODEM_PORT)
 
 test_adc.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport 
-DDOWNLINK_DEVICE=$(MODEM_PORT) 
 test_adc.srcs   += downlink.c pprz_transport.c
@@ -277,3 +277,30 @@
 test_imu_b2.srcs += $(SRC_BOOZ)/peripherals/booz_ms2001.c  
$(SRC_BOOZ_ARCH)/peripherals/booz_ms2001_arch.c
 
 
+#
+# test hmc5843
+#
+test_hmc5843.ARCHDIR = $(ARCHI)
+test_hmc5843.TARGET = test_hmc5843
+test_hmc5843.TARGETDIR = test_hmc5843
+test_hmc5843.CFLAGS = -I$(SRC_LISA) -I$(ARCHI) -Ibooz -DPERIPHERALS_AUTO_INIT
+test_hmc5843.CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
+test_hmc5843.srcs = lisa/test/lisa_test_hmc5843.c         \
+                    $(SRC_ARCH)/stm32_exceptions.c   \
+                    $(SRC_ARCH)/stm32_vector_table.c
+test_hmc5843.CFLAGS += -DUSE_LED
+test_hmc5843.srcs += $(SRC_ARCH)/led_hw.c
+test_hmc5843.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=$(SYS_TIME_LED)
+test_hmc5843.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC(1./512.)'
+test_hmc5843.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+
+test_hmc5843.CFLAGS += -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
+test_hmc5843.srcs += $(SRC_ARCH)/uart_hw.c
+
+test_hmc5843.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport 
-DDOWNLINK_DEVICE=$(MODEM_PORT) 
+test_hmc5843.srcs += downlink.c pprz_transport.c
+
+test_hmc5843.CFLAGS += -DUSE_I2C2
+test_hmc5843.srcs += i2c.c $(SRC_ARCH)/i2c_hw.c
+test_hmc5843.CFLAGS += -DIMU_OVERRIDE_CHANNELS
+test_hmc5843.CFLAGS += -DUSE_EXTI9_5_IRQ   # Mag Int on PB5
\ No newline at end of file

Modified: paparazzi3/trunk/sw/airborne/lisa/test/lisa_test_hmc5843.c
===================================================================
--- paparazzi3/trunk/sw/airborne/lisa/test/lisa_test_hmc5843.c  2010-09-02 
17:35:44 UTC (rev 5788)
+++ paparazzi3/trunk/sw/airborne/lisa/test/lisa_test_hmc5843.c  2010-09-02 
18:05:09 UTC (rev 5789)
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *  
- * Copyright (C) 2009 Antoine Drouin <address@hidden>
+ * Copyright (C) 2010 The Paparazzi Team
  *
  * This file is part of paparazzi.
  *
@@ -43,7 +43,8 @@
 
 static inline void main_init_hw(void);
 
-static uint8_t i2c_done = FALSE;
+//static uint8_t i2c_done = FALSE;
+static struct i2c_transaction i2c_trans;
 #define INITIALISZED 6
 static uint8_t mag_state = 0;
 static volatile uint8_t mag_ready_for_read = FALSE;
@@ -92,19 +93,28 @@
   
   switch (mag_state) {
   case 2:
-    i2c2.buf[0] = HMC5843_REG_CFGA;  // set to rate to 50Hz
-    i2c2.buf[1] = 0x00 | (0x06 << 2);
-    i2c2_transmit(HMC5843_ADDR, 2, &i2c_done);
+    i2c_trans.type = I2CTransTx;
+    i2c_trans.slave_addr = HMC5843_ADDR;
+    i2c_trans.buf[0] = HMC5843_REG_CFGA;  // set to rate to 50Hz
+    i2c_trans.buf[1] = 0x00 | (0x06 << 2);
+    i2c_trans.len_w = 2;
+    i2c_submit(&i2c2,&i2c_trans);
     break;
   case 3:
-    i2c2.buf[0] = HMC5843_REG_CFGB;  // set to gain to 1 Gauss
-    i2c2.buf[1] = 0x01<<5;
-    i2c2_transmit(HMC5843_ADDR, 2, &i2c_done);
+    i2c_trans.type = I2CTransTx;
+    i2c_trans.slave_addr = HMC5843_ADDR;
+    i2c_trans.buf[0] = HMC5843_REG_CFGB;  // set to gain to 1 Gauss
+    i2c_trans.buf[1] = 0x01<<5;
+    i2c_trans.len_w = 2;
+    i2c_submit(&i2c2,&i2c_trans);
     break;
   case 4:
-    i2c2.buf[0] = HMC5843_REG_MODE;  // set to continuous mode
-    i2c2.buf[1] = 0x00;
-    i2c2_transmit(HMC5843_ADDR, 2, &i2c_done);
+    i2c_trans.type = I2CTransTx;
+    i2c_trans.slave_addr = HMC5843_ADDR;
+    i2c_trans.buf[0] = HMC5843_REG_MODE;  // set to continuous mode
+    i2c_trans.buf[1] = 0x00;
+    i2c_trans.len_w = 2;
+    i2c_submit(&i2c2,&i2c_trans);
     break;
   case 5:
     break;
@@ -115,29 +125,32 @@
   default:
     break;
   }
-
+  
   //  if (mag_state  == 4) mag_state=1;
-
+  
   if (mag_state  < INITIALISZED) mag_state++;
-
+  
 }
 
 
 static inline void main_event_task( void ) {
 
-  if (mag_state == INITIALISZED && mag_ready_for_read && i2c_done) {
+  if (mag_state == INITIALISZED && mag_ready_for_read && 
i2c_trans.status==I2CTransSuccess) {
     /* read mag */
-    i2c2_receive(HMC5843_ADDR, 7, &i2c_done);
+    i2c_trans.type = I2CTransRx;
+    i2c_trans.slave_addr = HMC5843_ADDR;
+    i2c_trans.len_r = 7;
+    i2c_submit(&i2c2,&i2c_trans);
     reading_mag = TRUE;
     mag_ready_for_read = FALSE;
   }
 
-  if (reading_mag && i2c_done) {
-    RunOnceEvery(10, 
+  if (reading_mag && i2c_trans.status==I2CTransSuccess) {
+    RunOnceEvery(10,
     {
-      int16_t mx   = i2c2.buf[0]<<8 | i2c2.buf[1];
-      int16_t my   = i2c2.buf[2]<<8 | i2c2.buf[3];
-      int16_t mz   = i2c2.buf[4]<<8 | i2c2.buf[5];
+      int16_t mx   = i2c_trans.buf[0]<<8 | i2c_trans.buf[1];
+      int16_t my   = i2c_trans.buf[2]<<8 | i2c_trans.buf[3];
+      int16_t mz   = i2c_trans.buf[4]<<8 | i2c_trans.buf[5];
       struct Int32Vect3 m;
       VECT3_ASSIGN(m, mx, my, mz);
       DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel, &m.x, &m.y, &m.z);

Modified: paparazzi3/trunk/sw/airborne/stm32/i2c_hw.c
===================================================================
--- paparazzi3/trunk/sw/airborne/stm32/i2c_hw.c 2010-09-02 17:35:44 UTC (rev 
5788)
+++ paparazzi3/trunk/sw/airborne/stm32/i2c_hw.c 2010-09-02 18:05:09 UTC (rev 
5789)
@@ -693,8 +693,8 @@
 
   t->status = I2CTransPending;
   
-  // FIXME : disable IRQ
 
+  __disable_irq();
   /* put transacation in queue */
   p->trans[p->trans_insert_idx] = t;
   p->trans_insert_idx = temp;
@@ -703,6 +703,8 @@
   if (p->status == I2CIdle)
     start_transaction(p);
   
+  __enable_irq();
+
   return TRUE;
 }
 




reply via email to

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