diff --git a/conf/airframes/Poine/booz2_a7.xml b/conf/airframes/Poine/booz2_a7.xml index a739690518..adf9b53139 100644 --- a/conf/airframes/Poine/booz2_a7.xml +++ b/conf/airframes/Poine/booz2_a7.xml @@ -209,6 +209,7 @@ + diff --git a/conf/autopilot/lisa_l_test_progs.makefile b/conf/autopilot/lisa_l_test_progs.makefile index 345e5244b3..c93f295316 100644 --- a/conf/autopilot/lisa_l_test_progs.makefile +++ b/conf/autopilot/lisa_l_test_progs.makefile @@ -303,4 +303,34 @@ 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 +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 diff --git a/sw/airborne/lisa/test/lisa_test_hmc5843.c b/sw/airborne/lisa/test/lisa_test_hmc5843.c index bcd1d3993c..4333cf475d 100644 --- a/sw/airborne/lisa/test/lisa_test_hmc5843.c +++ b/sw/airborne/lisa/test/lisa_test_hmc5843.c @@ -45,7 +45,7 @@ static inline void main_init_hw(void); //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 @@ static inline void main_periodic_task( void ) { break; case 5: break; - case INITIALISZED: + case INITIALIZED: // i2c2_receive(HMC5843_ADDR, 7, &i2c_done); // reading_mag = TRUE; break; @@ -128,14 +128,14 @@ static inline void main_periodic_task( void ) { // 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 @@ void exti9_5_irq_handler(void) { 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; } diff --git a/sw/airborne/lisa/test/lisa_test_itg3200.c b/sw/airborne/lisa/test/lisa_test_itg3200.c index 327f73c6cc..7415391a3d 100644 --- a/sw/airborne/lisa/test/lisa_test_itg3200.c +++ b/sw/airborne/lisa/test/lisa_test_itg3200.c @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2009 Antoine Drouin + * Copyright (C) 2010 The Paparazzi Team * * This file is part of paparazzi. * @@ -43,8 +43,8 @@ static inline void main_event_task( void ); 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 @@ static inline void main_periodic_task( void ) { 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 @@ static inline void main_periodic_task( void ) { } // 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_periodic_task( void ) { 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 @@ static inline void main_event_task( void ) { 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 @@ void exti15_10_irq_handler(void) { // DEBUG_S4_TOGGLE(); - if (gyro_state == INITIALISZED) gyro_ready_for_read = TRUE; + if (gyro_state == INITIALIZED) gyro_ready_for_read = TRUE; // DEBUG_S4_OFF();