paparazzi-commits
[Top][All Lists]
Advanced

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

[paparazzi-commits] [6096] Port HMC5843 to new i2c format, enable i2c fo


From: Allen Ibara
Subject: [paparazzi-commits] [6096] Port HMC5843 to new i2c format, enable i2c for test_imu_b2
Date: Wed, 06 Oct 2010 23:45:54 +0000

Revision: 6096
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=6096
Author:   aibara
Date:     2010-10-06 23:45:54 +0000 (Wed, 06 Oct 2010)
Log Message:
-----------
Port HMC5843 to new i2c format, enable i2c for test_imu_b2

Modified Paths:
--------------
    paparazzi3/trunk/conf/autopilot/lisa_l_test_progs.makefile
    paparazzi3/trunk/sw/airborne/booz/peripherals/booz_hmc5843.c
    paparazzi3/trunk/sw/airborne/booz/peripherals/booz_hmc5843.h

Modified: paparazzi3/trunk/conf/autopilot/lisa_l_test_progs.makefile
===================================================================
--- paparazzi3/trunk/conf/autopilot/lisa_l_test_progs.makefile  2010-10-06 
23:33:26 UTC (rev 6095)
+++ paparazzi3/trunk/conf/autopilot/lisa_l_test_progs.makefile  2010-10-06 
23:45:54 UTC (rev 6096)
@@ -360,7 +360,9 @@
 test_imu_b2_2.CFLAGS += -DUSE_SPI2 -DUSE_DMA1_C4_IRQ -DUSE_EXTI2_IRQ 
-DUSE_SPI2_IRQ
 test_imu_b2_2.srcs += $(SRC_FIRMWARE)/imu/imu_b2.c 
$(SRC_FIRMWARE)/imu/arch/$(ARCH)/imu_b2_arch.c
 test_imu_b2_2.srcs += $(SRC_BOOZ)/peripherals/booz_max1168.c 
$(SRC_BOOZ_ARCH)/peripherals/booz_max1168_arch.c
-test_imu_b2_2.srcs += $(SRC_BOOZ)/peripherals/booz_hmc5843.c # 
$(SRC_BOOZ_ARCH)/peripherals/booz_hmc5843.c
+test_imu_b2_2.CFLAGS += -DUSE_I2C2
+test_imu_b2_2.srcs += i2c.c $(SRC_ARCH)/i2c_hw.c
+test_imu_b2_2.srcs += $(SRC_BOOZ)/peripherals/booz_hmc5843.c
 
 
 

Modified: paparazzi3/trunk/sw/airborne/booz/peripherals/booz_hmc5843.c
===================================================================
--- paparazzi3/trunk/sw/airborne/booz/peripherals/booz_hmc5843.c        
2010-10-06 23:33:26 UTC (rev 6095)
+++ paparazzi3/trunk/sw/airborne/booz/peripherals/booz_hmc5843.c        
2010-10-06 23:45:54 UTC (rev 6096)
@@ -3,36 +3,49 @@
 #include "i2c.h"
 
 struct Hmc5843 hmc5843;
+static struct i2c_transaction hmc5843_i2c_trans;
 
 void hmc5843_init(void) {
   hmc5843.status = HMC5843_UNINITIALIZED1;
   hmc5843.i2c_done = TRUE;
+
+       hmc5843_i2c_trans.status = I2CTransSuccess;
+       hmc5843_i2c_trans.slave_addr = HMC5843_ADDR;
+       hmc5843_i2c_trans.stop_after_transmit = TRUE;
 }
 
 void hmc5843_periodic(void) {
   
-  if (!hmc5843.i2c_done) return;
+  if (hmc5843_i2c_trans.status != I2CTransSuccess) return;
   switch (hmc5843.status) {
   case HMC5843_UNINITIALIZED1:
-    i2c2.buf[0] = HMC5843_REG_CFGA;  // set to rate to 50Hz
-    i2c2.buf[1] = 0x00 | (0x06 << 2);
-    i2c2_transmit(HMC5843_ADDR, 2, &hmc5843.i2c_done);
+    hmc5843_i2c_trans.buf[0] = HMC5843_REG_CFGA;  // set to rate to 50Hz
+    hmc5843_i2c_trans.buf[1] = 0x00 | (0x06 << 2);
+    hmc5843_i2c_trans.type = I2CTransTx;
+    hmc5843_i2c_trans.len_w = 2;
+    i2c_submit(&i2c2, &hmc5843_i2c_trans);
     hmc5843.status = HMC5843_UNINITIALIZED2;
     break;
   case HMC5843_UNINITIALIZED2:
-    i2c2.buf[0] = HMC5843_REG_CFGB;  // set to gain to 1 Gauss
-    i2c2.buf[1] = 0x01<<5;
-    i2c2_transmit(HMC5843_ADDR, 2, &hmc5843.i2c_done);
+    hmc5843_i2c_trans.buf[0] = HMC5843_REG_CFGB;  // set to gain to 1 Gauss
+    hmc5843_i2c_trans.buf[1] = 0x01<<5;
+    hmc5843_i2c_trans.type = I2CTransTx;
+    hmc5843_i2c_trans.len_w = 2;
+    i2c_submit(&i2c2, &hmc5843_i2c_trans);
     hmc5843.status = HMC5843_UNINITIALIZED3;
     break;
   case HMC5843_UNINITIALIZED3:
-    i2c2.buf[0] = HMC5843_REG_MODE;  // set to continuous mode
-    i2c2.buf[1] = 0x00;
-    i2c2_transmit(HMC5843_ADDR, 2, &hmc5843.i2c_done);
+    hmc5843_i2c_trans.buf[0] = HMC5843_REG_MODE;  // set to continuous mode
+    hmc5843_i2c_trans.buf[1] = 0x00;
+    hmc5843_i2c_trans.type = I2CTransTx;
+    hmc5843_i2c_trans.len_w = 2;
+    i2c_submit(&i2c2, &hmc5843_i2c_trans);
     hmc5843.status = HMC5843_IDLE;
     break;
   case HMC5843_IDLE:
-    i2c2_receive(HMC5843_ADDR, 6, &hmc5843.i2c_done);
+    hmc5843_i2c_trans.type = I2CTransRx;
+    hmc5843_i2c_trans.len_w = 6;
+    i2c_submit(&i2c2, &hmc5843_i2c_trans);
     hmc5843.status = HMC5843_READING;
     break;
   default:

Modified: paparazzi3/trunk/sw/airborne/booz/peripherals/booz_hmc5843.h
===================================================================
--- paparazzi3/trunk/sw/airborne/booz/peripherals/booz_hmc5843.h        
2010-10-06 23:33:26 UTC (rev 6095)
+++ paparazzi3/trunk/sw/airborne/booz/peripherals/booz_hmc5843.h        
2010-10-06 23:45:54 UTC (rev 6096)
@@ -69,7 +69,7 @@
 #include <string.h>
 
 #define MagEvent(_m_handler) {                                         \
-    if (hmc5843.status == HMC5843_READING && hmc5843.i2c_done) {       \
+    if (hmc5843.status == HMC5843_READING && hmc5843_i2c_trans.status == 
I2CTransSuccess) {    \
       memcpy(hmc5843.data.buf, (const void*)i2c2.buf, 6);              \
       _m_handler();                                                    \
       hmc5843.status = HMC5843_IDLE;                                   \




reply via email to

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