diff --git a/conf/firmwares/lisa_test_progs.makefile b/conf/firmwares/lisa_test_progs.makefile index 39f5a9ffec..453e636f83 100644 --- a/conf/firmwares/lisa_test_progs.makefile +++ b/conf/firmwares/lisa_test_progs.makefile @@ -179,7 +179,7 @@ test_baro.srcs += $(COMMON_TELEMETRY_SRCS) test_baro.CFLAGS += -I$(SRC_LISA) -I$(SRC_BOARD) test_baro.srcs += $(SRC_BOARD)/test_baro.c -test_baro.srcs += $(SRC_BOARD)/baro_board.c +test_baro.srcs += $(SRC_BOARD)/baro_board_i2c.c test_baro.CFLAGS += -DUSE_I2C2 test_baro.srcs += mcu_periph/i2c.c $(SRC_ARCH)/mcu_periph/i2c_arch.c diff --git a/sw/airborne/boards/lisa_m/baro_board.c b/sw/airborne/boards/lisa_m/baro_board.c index 8cd38d2452..1ba5652ddb 100644 --- a/sw/airborne/boards/lisa_m/baro_board.c +++ b/sw/airborne/boards/lisa_m/baro_board.c @@ -1,6 +1,6 @@ -/** +/** * Generic barometer interface, assuming the barometer is read through Aspirin IMU directly - * + * * Edit by: Michal Podhradsky, michal.podhradsky@aggiemail.usu.edu * Utah State University, http://aggieair.usu.edu/ */ @@ -19,6 +19,6 @@ void baro_init(void) { void baro_periodic(void) {} void baro_event(void (*b_abs_handler)(void), void (*b_diff_handler)(void)){ - b_abs_handler(); - b_diff_handler(); + b_abs_handler(); + b_diff_handler(); } diff --git a/sw/airborne/boards/lisa_m/baro_board.h b/sw/airborne/boards/lisa_m/baro_board.h index 9bee9aa82b..4498eef51b 100644 --- a/sw/airborne/boards/lisa_m/baro_board.h +++ b/sw/airborne/boards/lisa_m/baro_board.h @@ -1,6 +1,6 @@ -/** +/** * Generic barometer interface, assuming the barometer is read through Aspirin IMU directly - * + * * Edit by: Michal Podhradsky, michal.podhradsky@aggiemail.usu.edu * Utah State University, http://aggieair.usu.edu/ */ diff --git a/sw/airborne/boards/lisa_m/baro_board_i2c.c b/sw/airborne/boards/lisa_m/baro_board_i2c.c index afe7d6532e..40e4b5cbbf 100644 --- a/sw/airborne/boards/lisa_m/baro_board_i2c.c +++ b/sw/airborne/boards/lisa_m/baro_board_i2c.c @@ -1,6 +1,6 @@ -/** +/** * Measurement Specialties (Intersema) MS5611-01BA pressure/temperature sensor interface for I2C - * + * * Edit by: Michal Podhradsky, michal.podhradsky@aggiemail.usu.edu * Utah State University, http://aggieair.usu.edu/ */ @@ -89,7 +89,7 @@ void baro_periodic(void) { ms5611_status = MS5611_ADC_D2; ms5611_trans.buf[0] = MS5611_ADC_READ; I2CTransceive(MS5611_I2C_DEV, ms5611_trans, MS5611_SLAVE_ADDR, 1, 3); - } + } else if (ms5611_status == MS5611_UNINIT) { /* reset sensor */ ms5611_status = MS5611_RESET; @@ -100,7 +100,7 @@ void baro_periodic(void) { /* start getting prom data */ ms5611_status = MS5611_PROM; ms5611_trans.buf[0] = MS5611_PROM_READ | (prom_cnt << 1); - I2CTransceive(MS5611_I2C_DEV, ms5611_trans, MS5611_SLAVE_ADDR, 1, 2); + I2CTransceive(MS5611_I2C_DEV, ms5611_trans, MS5611_SLAVE_ADDR, 1, 2); } } } diff --git a/sw/airborne/boards/lisa_m/baro_board_spi.c b/sw/airborne/boards/lisa_m/baro_board_spi.c index 66bb809361..cb6f813e12 100644 --- a/sw/airborne/boards/lisa_m/baro_board_spi.c +++ b/sw/airborne/boards/lisa_m/baro_board_spi.c @@ -1,6 +1,6 @@ -/** +/** * Measurement Specialties (Intersema) MS5611-01BA pressure/temperature sensor interface for I2C - * + * * Edit by: Michal Podhradsky, michal.podhradsky@aggiemail.usu.edu * Utah State University, http://aggieair.usu.edu/ */ @@ -56,9 +56,9 @@ static int8_t baro_ms5611_crc(uint16_t* prom) { } static void trans_cb_ms5611( struct spi_transaction *trans ) { - #ifdef ROTORCRAFT_BARO_LED - RunOnceEvery(10,LED_TOGGLE(ROTORCRAFT_BARO_LED)); - #endif +#ifdef ROTORCRAFT_BARO_LED + RunOnceEvery(10,LED_TOGGLE(ROTORCRAFT_BARO_LED)); +#endif } void baro_init(void) { @@ -112,7 +112,7 @@ void baro_periodic(void) { ms5611_status = MS5611_ADC_D2; ms5611_trans.output_buf[0] = MS5611_ADC_READ; spi_submit(&(MS5611_SPI_DEV), &ms5611_trans); - } + } else if (ms5611_status == MS5611_UNINIT) { /* reset sensor */ ms5611_status = MS5611_RESET; @@ -123,7 +123,7 @@ void baro_periodic(void) { /* start getting prom data */ ms5611_status = MS5611_PROM; ms5611_trans.output_buf[0] = MS5611_PROM_READ | (prom_cnt << 1); - spi_submit(&(MS5611_SPI_DEV), &ms5611_trans); + spi_submit(&(MS5611_SPI_DEV), &ms5611_trans); } } } @@ -143,7 +143,7 @@ void baro_event(void (*b_abs_handler)(void), void (*b_diff_handler)(void)){ if (prom_cnt < PROM_NB) {//8 bytes at PROM /* get next prom data */ ms5611_trans.output_buf[0] = MS5611_PROM_READ | (prom_cnt << 1); - spi_submit(&(MS5611_SPI_DEV), &ms5611_trans); + spi_submit(&(MS5611_SPI_DEV), &ms5611_trans); } else { /* done reading prom */ @@ -168,7 +168,7 @@ void baro_event(void (*b_abs_handler)(void), void (*b_diff_handler)(void)){ /* start D2 conversion */ ms5611_status = MS5611_CONV_D2; ms5611_trans.output_buf[0] = MS5611_START_CONV_D2; - spi_submit(&(MS5611_SPI_DEV), &ms5611_trans); + spi_submit(&(MS5611_SPI_DEV), &ms5611_trans); break; case MS5611_ADC_D2: { diff --git a/sw/airborne/boards/lisa_m/test_baro.c b/sw/airborne/boards/lisa_m/test_baro.c index 9c888b2e42..1a63ad6274 100644 --- a/sw/airborne/boards/lisa_m/test_baro.c +++ b/sw/airborne/boards/lisa_m/test_baro.c @@ -30,6 +30,7 @@ #include "mcu.h" #include "mcu_periph/sys_time.h" #include "mcu_periph/uart.h" +#include "mcu_periph/i2c.h" #include "led.h" #include "subsystems/datalink/downlink.h"