paparazzi-commits
[Top][All Lists]
Advanced

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

[paparazzi-commits] [5790] updated test_itg3200 for new I2C interface


From: antoine drouin
Subject: [paparazzi-commits] [5790] updated test_itg3200 for new I2C interface
Date: Thu, 02 Sep 2010 18:29:44 +0000

Revision: 5790
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=5790
Author:   poine
Date:     2010-09-02 18:29:43 +0000 (Thu, 02 Sep 2010)
Log Message:
-----------
updated test_itg3200 for 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/lisa/test/lisa_test_itg3200.c

Modified: paparazzi3/trunk/conf/airframes/Poine/booz2_a7.xml
===================================================================
--- paparazzi3/trunk/conf/airframes/Poine/booz2_a7.xml  2010-09-02 18:05:09 UTC 
(rev 5789)
+++ paparazzi3/trunk/conf/airframes/Poine/booz2_a7.xml  2010-09-02 18:29:43 UTC 
(rev 5790)
@@ -209,6 +209,7 @@
     <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"/>
+    <target name="test_itg3200"     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 
18:05:09 UTC (rev 5789)
+++ paparazzi3/trunk/conf/autopilot/lisa_l_test_progs.makefile  2010-09-02 
18:29:43 UTC (rev 5790)
@@ -303,4 +303,34 @@
 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
+test_hmc5843.CFLAGS += -DUSE_EXTI9_5_IRQ   # Mag Int on PB5
+
+
+#
+# test ITG3200
+#
+test_itg3200.ARCHDIR = $(ARCHI)
+test_itg3200.TARGET = test_itg3200
+test_itg3200.TARGETDIR = test_itg3200
+test_itg3200.CFLAGS  =  -I$(SRC_LISA) -I$(ARCHI) -I$(SRC_BOOZ) 
-I$(SRC_BOOZ_ARCH) -DPERIPHERALS_AUTO_INIT
+test_itg3200.CFLAGS +=  -DBOARD_CONFIG=$(BOARD_CFG)
+test_itg3200.srcs += lisa/test/lisa_test_itg3200.c \
+                       $(SRC_ARCH)/stm32_exceptions.c   \
+                       $(SRC_ARCH)/stm32_vector_table.c
+
+test_itg3200.CFLAGS += -DUSE_LED
+test_itg3200.srcs += $(SRC_ARCH)/led_hw.c
+
+test_itg3200.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=1
+test_itg3200.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./512.))'
+test_itg3200.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
+
+test_itg3200.CFLAGS += -DUSE_UART2 -DUART2_BAUD=B57600
+test_itg3200.srcs += $(SRC_ARCH)/uart_hw.c
+
+test_itg3200.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport 
-DDOWNLINK_DEVICE=Uart2
+test_itg3200.srcs += downlink.c pprz_transport.c
+
+test_itg3200.CFLAGS += -DUSE_I2C2
+test_itg3200.srcs += i2c.c $(SRC_ARCH)/i2c_hw.c
+test_itg3200.CFLAGS += -DUSE_EXTI15_10_IRQ   # Gyro Int on PC14
\ 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 
18:05:09 UTC (rev 5789)
+++ paparazzi3/trunk/sw/airborne/lisa/test/lisa_test_hmc5843.c  2010-09-02 
18:29:43 UTC (rev 5790)
@@ -45,7 +45,7 @@
 
 //static uint8_t i2c_done = FALSE;
 static struct i2c_transaction i2c_trans;
-#define INITIALISZED 6
+#define INITIALIZED 6
 static uint8_t mag_state = 0;
 static volatile uint8_t mag_ready_for_read = FALSE;
 static uint8_t reading_mag = FALSE;
@@ -118,7 +118,7 @@
     break;
   case 5:
     break;
-  case INITIALISZED:
+  case INITIALIZED:
     //    i2c2_receive(HMC5843_ADDR, 7, &i2c_done);
     //    reading_mag = TRUE;
     break;
@@ -128,14 +128,14 @@
   
   //  if (mag_state  == 4) mag_state=1;
   
-  if (mag_state  < INITIALISZED) mag_state++;
+  if (mag_state  < INITIALIZED) mag_state++;
   
 }
 
 
 static inline void main_event_task( void ) {
 
-  if (mag_state == INITIALISZED && mag_ready_for_read && 
i2c_trans.status==I2CTransSuccess) {
+  if (mag_state == INITIALIZED && mag_ready_for_read && 
i2c_trans.status==I2CTransSuccess) {
     /* read mag */
     i2c_trans.type = I2CTransRx;
     i2c_trans.slave_addr = HMC5843_ADDR;
@@ -210,5 +210,5 @@
   if(EXTI_GetITStatus(EXTI_Line5) != RESET)
     EXTI_ClearITPendingBit(EXTI_Line5);
 
-  if (mag_state == INITIALISZED) mag_ready_for_read = TRUE;
+  if (mag_state == INITIALIZED) mag_ready_for_read = TRUE;
 }

Modified: paparazzi3/trunk/sw/airborne/lisa/test/lisa_test_itg3200.c
===================================================================
--- paparazzi3/trunk/sw/airborne/lisa/test/lisa_test_itg3200.c  2010-09-02 
18:05:09 UTC (rev 5789)
+++ paparazzi3/trunk/sw/airborne/lisa/test/lisa_test_itg3200.c  2010-09-02 
18:29:43 UTC (rev 5790)
@@ -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,8 +43,8 @@
 
 static inline void main_init_hw(void);
 
-static uint8_t i2c_done = FALSE;
-#define INITIALISZED 6
+static struct i2c_transaction i2c_trans;
+#define INITIALIZED 6
 static uint8_t gyro_state = 0;
 static volatile uint8_t gyro_ready_for_read = FALSE;
 static uint8_t reading_gyro = FALSE;
@@ -92,34 +92,50 @@
   switch (gyro_state) {
 
   case 1:
-    i2c2.buf[0] = ITG3200_REG_TEMP_OUT_H;
-    i2c2_transmit(ITG3200_ADDR,1, &i2c_done);
+    /* dummy one byte write for testing */
+    i2c_trans.type = I2CTransTx;
+    i2c_trans.slave_addr = ITG3200_ADDR;
+    i2c_trans.buf[0] = ITG3200_REG_TEMP_OUT_H;
+    i2c_trans.len_w = 1;
+    i2c_submit(&i2c2,&i2c_trans);
     break;
   case 2:
     /* set gyro range to 2000deg/s and low pass at 256Hz */
-    i2c2.buf[0] = ITG3200_REG_DLPF_FS;
-    i2c2.buf[1] = (0x03<<3);
-    i2c2_transmit(ITG3200_ADDR, 2, &i2c_done);
+    i2c_trans.type = I2CTransTx;
+    i2c_trans.slave_addr = ITG3200_ADDR;
+    i2c_trans.buf[0] = ITG3200_REG_DLPF_FS;
+    i2c_trans.buf[1] = (0x03<<3);
+    i2c_trans.len_w = 2;
+    i2c_submit(&i2c2,&i2c_trans);
     break;
   case 3:
     /* set sample rate to 533Hz */
-    i2c2.buf[0] = ITG3200_REG_SMPLRT_DIV;
-    i2c2.buf[1] = 0x0E;
-    i2c2_transmit(ITG3200_ADDR, 2, &i2c_done);
+    i2c_trans.type = I2CTransTx;
+    i2c_trans.slave_addr = ITG3200_ADDR;
+    i2c_trans.buf[0] = ITG3200_REG_SMPLRT_DIV;
+    i2c_trans.buf[1] = 0x0E;
+    i2c_trans.len_w = 2;
+    i2c_submit(&i2c2,&i2c_trans);
     break;
   case 4:
     /* switch to gyroX clock */
-    i2c2.buf[0] = ITG3200_REG_PWR_MGM;
-    i2c2.buf[1] = 0x01;
-    i2c2_transmit(ITG3200_ADDR, 2, &i2c_done);
+    i2c_trans.type = I2CTransTx;
+    i2c_trans.slave_addr = ITG3200_ADDR;
+    i2c_trans.buf[0] = ITG3200_REG_PWR_MGM;
+    i2c_trans.buf[1] = 0x01;
+    i2c_trans.len_w = 2;
+    i2c_submit(&i2c2,&i2c_trans);
     break;
   case 5:
     /* enable interrupt on data ready, idle hight */
-    i2c2.buf[0] = ITG3200_REG_INT_CFG;
-    i2c2.buf[1] = (0x01 | 0x01<<7);
-    i2c2_transmit(ITG3200_ADDR, 2, &i2c_done);
+    i2c_trans.type = I2CTransTx;
+    i2c_trans.slave_addr = ITG3200_ADDR;
+    i2c_trans.buf[0] = ITG3200_REG_INT_CFG;
+    i2c_trans.buf[1] = (0x01 | 0x01<<7);
+    i2c_trans.len_w = 2;
+    i2c_submit(&i2c2,&i2c_trans);
     break;
-  case INITIALISZED:
+  case INITIALIZED:
     /* reads 8 bytes from address 0x1b */
     //    i2c2.buf[0] = ITG3200_REG_TEMP_OUT_H;
     //    i2c2_transceive(ITG3200_ADDR,1, 8, &i2c_done);
@@ -129,7 +145,7 @@
   }
 
   //  if (gyro_state == 1) gyro_state = 0;
-  if (gyro_state  < INITIALISZED) gyro_state++;
+  if (gyro_state  < INITIALIZED) gyro_state++;
 
 }
 
@@ -140,36 +156,41 @@
 
 static inline void main_event_task( void ) {
 
-  if (gyro_state == INITIALISZED && gyro_ready_for_read && i2c_done) {
+  if (gyro_state == INITIALIZED && gyro_ready_for_read && 
+      ( i2c_trans.status==I2CTransSuccess || 
i2c_trans.status==I2CTransFailed)) {
     /* reads 8 bytes from address 0x1b */
-    i2c2.buf[0] = ITG3200_REG_TEMP_OUT_H;
-    i2c2_transceive(ITG3200_ADDR,1, 8, &i2c_done);
+    i2c_trans.type = I2CTransTxRx;
+    i2c_trans.buf[0] = ITG3200_REG_TEMP_OUT_H;
+    i2c_trans.len_w = 1;
+    i2c_trans.len_r = 8;
+    i2c_submit(&i2c2,&i2c_trans);
     //   i2c2.buf[0] = ITG3200_REG_GYRO_XOUT_H;
     //    i2c2_transceive(ITG3200_ADDR,1, 6, &i2c_done);
     gyro_ready_for_read = FALSE;
     reading_gyro = TRUE;
   }
 
-  if (reading_gyro && i2c_done) {
+  if (reading_gyro && 
+      (i2c_trans.status==I2CTransSuccess || i2c_trans.status==I2CTransFailed)) 
{
     //    DEBUG_S5_ON();
     reading_gyro = FALSE;
     int16_t tgp, tgq, tgr;
-
-    int16_t ttemp = i2c2.buf[0]<<8 | i2c2.buf[1];
+    
+    int16_t ttemp = i2c_trans.buf[0]<<8 | i2c_trans.buf[1];
 #if 1
-    tgp = i2c2.buf[2]<<8 | i2c2.buf[3];
-    tgq = i2c2.buf[4]<<8 | i2c2.buf[5];
-    tgr = i2c2.buf[6]<<8 | i2c2.buf[7];
+    tgp = i2c_trans.buf[2]<<8 | i2c_trans.buf[3];
+    tgq = i2c_trans.buf[4]<<8 | i2c_trans.buf[5];
+    tgr = i2c_trans.buf[6]<<8 | i2c_trans.buf[7];
 #endif
 #if 0
-    tgp = __REVSH(*(int16_t*)(i2c2.buf+2));
-    tgq = __REVSH(*(int16_t*)(i2c2.buf+4));
-    tgr = __REVSH(*(int16_t*)(i2c2.buf+6));
+    tgp = __REVSH(*(int16_t*)(i2c_trans.buf+2));
+    tgq = __REVSH(*(int16_t*)(i2c_trans.buf+4));
+    tgr = __REVSH(*(int16_t*)(i2c_trans.buf+6));
 #endif
 #if 0
-    MyByteSwap16(*(int16_t*)(i2c2.buf+2), tgp);
-    MyByteSwap16(*(int16_t*)(i2c2.buf+4), tgq);
-    MyByteSwap16(*(int16_t*)(i2c2.buf+6), tgr);
+    MyByteSwap16(*(int16_t*)(i2c_trans.buf+2), tgp);
+    MyByteSwap16(*(int16_t*)(i2c_trans.buf+4), tgq);
+    MyByteSwap16(*(int16_t*)(i2c_trans.buf+6), tgr);
 #endif
     struct Int32Rates g;
     RATES_ASSIGN(g, tgp, tgq, tgr);
@@ -178,7 +199,7 @@
       DOWNLINK_SEND_IMU_GYRO_RAW(DefaultChannel, &g.p, &g.q, &g.r);
       
       uint8_t tmp[8];
-      memcpy(tmp, i2c2.buf, 8);
+      memcpy(tmp, i2c_trans.buf, 8);
       DOWNLINK_SEND_DEBUG(DefaultChannel, 8, tmp);
 
 
@@ -242,7 +263,7 @@
 
   //  DEBUG_S4_TOGGLE();
 
-  if (gyro_state == INITIALISZED) gyro_ready_for_read = TRUE;
+  if (gyro_state == INITIALIZED) gyro_ready_for_read = TRUE;
 
   //  DEBUG_S4_OFF();
 




reply via email to

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