diff --git a/conf/airframes/Poine/booz2_a7.xml b/conf/airframes/Poine/booz2_a7.xml
index 66c1b19224..a739690518 100644
--- a/conf/airframes/Poine/booz2_a7.xml
+++ b/conf/airframes/Poine/booz2_a7.xml
@@ -182,7 +182,7 @@
-->
-
+
+
diff --git a/conf/autopilot/lisa_l_test_progs.makefile b/conf/autopilot/lisa_l_test_progs.makefile
index 78d27924a9..345e5244b3 100644
--- a/conf/autopilot/lisa_l_test_progs.makefile
+++ b/conf/autopilot/lisa_l_test_progs.makefile
@@ -224,7 +224,7 @@ test_adc.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c
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_max1168.c $(SRC_BOOZ_ARCH)/peri
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
diff --git a/sw/airborne/lisa/test/lisa_test_hmc5843.c b/sw/airborne/lisa/test/lisa_test_hmc5843.c
index abb72daac4..bcd1d3993c 100644
--- a/sw/airborne/lisa/test/lisa_test_hmc5843.c
+++ b/sw/airborne/lisa/test/lisa_test_hmc5843.c
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright (C) 2009 Antoine Drouin
+ * Copyright (C) 2010 The Paparazzi Team
*
* This file is part of paparazzi.
*
@@ -43,7 +43,8 @@ static inline void main_event_task( void );
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 @@ static inline void main_periodic_task( void ) {
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 @@ static inline void main_periodic_task( void ) {
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);
diff --git a/sw/airborne/stm32/i2c_hw.c b/sw/airborne/stm32/i2c_hw.c
index d593b7378a..e623e5e342 100644
--- a/sw/airborne/stm32/i2c_hw.c
+++ b/sw/airborne/stm32/i2c_hw.c
@@ -693,8 +693,8 @@ bool_t i2c_submit(struct i2c_periph* p, struct i2c_transaction* t) {
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 @@ bool_t i2c_submit(struct i2c_periph* p, struct i2c_transaction* t) {
if (p->status == I2CIdle)
start_transaction(p);
+ __enable_irq();
+
return TRUE;
}