mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 22:17:01 +08:00
[boards] move generic baro_ms5611_x driver to subsystem/sensors
- use this for krooz as well - don't call the differential pressure handler, only absolute available there - lisa_m: if using bmp, store temp in baro_board struct instead of abusing differential pressure
This commit is contained in:
@@ -174,12 +174,12 @@ LISA_M_BARO ?= BARO_BOARD_BMP085
|
||||
ap.CFLAGS += -DUSE_SPI2 -DUSE_SPI_SLAVE3
|
||||
ap.srcs += peripherals/ms5611.c
|
||||
ap.srcs += peripherals/ms5611_spi.c
|
||||
ap.srcs += $(SRC_BOARD)/baro_ms5611_spi.c
|
||||
ap.srcs += subsystems/sensors/baro_ms5611_spi.c
|
||||
else ifeq ($(LISA_M_BARO), BARO_MS5611_I2C)
|
||||
ap.CFLAGS += -DUSE_I2C2
|
||||
ap.srcs += peripherals/ms5611.c
|
||||
ap.srcs += peripherals/ms5611_i2c.c
|
||||
ap.srcs += $(SRC_BOARD)/baro_ms5611_i2c.c
|
||||
ap.srcs += subsystems/sensors/baro_ms5611_i2c.c
|
||||
else ifeq ($(LISA_M_BARO), BARO_BOARD_BMP085)
|
||||
ap.srcs += $(SRC_BOARD)/baro_board.c
|
||||
ap.CFLAGS += -DUSE_I2C2
|
||||
@@ -195,12 +195,12 @@ LIA_BARO ?= BARO_MS5611_SPI
|
||||
ap.CFLAGS += -DUSE_SPI2 -DUSE_SPI_SLAVE3
|
||||
ap.srcs += peripherals/ms5611.c
|
||||
ap.srcs += peripherals/ms5611_spi.c
|
||||
ap.srcs += boards/lisa_m/baro_ms5611_spi.c
|
||||
ap.srcs += subsystems/sensors/baro_ms5611_spi.c
|
||||
else ifeq ($(LIA_BARO), BARO_MS5611_I2C)
|
||||
ap.CFLAGS += -DUSE_I2C2
|
||||
ap.srcs += peripherals/ms5611.c
|
||||
ap.srcs += peripherals/ms5611_i2c.c
|
||||
ap.srcs += boards/lisa_m/baro_ms5611_i2c.c
|
||||
ap.srcs += subsystems/sensors/baro_ms5611_i2c.c
|
||||
endif
|
||||
ap.CFLAGS += -D$(LIA_BARO)
|
||||
|
||||
@@ -214,7 +214,10 @@ ap.srcs += $(SRC_BOARD)/baro_board.c
|
||||
|
||||
# krooz baro
|
||||
else ifeq ($(BOARD), krooz)
|
||||
ap.srcs += $(SRC_BOARD)/baro_board.c
|
||||
ap.CFLAGS += -DMS5611_I2C_DEV=i2c0
|
||||
ap.srcs += peripherals/ms5611.c
|
||||
ap.srcs += peripherals/ms5611_i2c.c
|
||||
ap.srcs += subsystems/sensors/baro_ms5611_i2c.c
|
||||
|
||||
# apogee baro
|
||||
else ifeq ($(BOARD), apogee)
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
|
||||
#include "subsystems/sensors/baro.h"
|
||||
#include "baro_board.h"
|
||||
|
||||
struct Baro baro;
|
||||
|
||||
void baro_init(void) {
|
||||
baro_ms5611_init();
|
||||
}
|
||||
|
||||
void baro_periodic(void) {
|
||||
static uint8_t cnt;
|
||||
switch(cnt) {
|
||||
case 0:
|
||||
baro_ms5611_periodic();
|
||||
cnt++;
|
||||
break;
|
||||
case 1:
|
||||
baro_ms5611_d1();
|
||||
cnt++;
|
||||
break;
|
||||
case 2:
|
||||
baro_ms5611_d2();
|
||||
cnt = 0;
|
||||
break;
|
||||
default:
|
||||
cnt = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,14 @@
|
||||
|
||||
/*
|
||||
* board specific fonctions for the KroozSD board
|
||||
* board specific interface for the KroozSD board
|
||||
*
|
||||
* It uses the subsystems/sensors/baro_ms5611_i2c.c driver
|
||||
*/
|
||||
|
||||
#ifndef BOARDS_KROOZ_BARO_H
|
||||
#define BOARDS_KROOZ_BARO_H
|
||||
|
||||
#include "std.h"
|
||||
#include "mcu_periph/i2c.h"
|
||||
#include "modules/sensors/baro_ms5611_i2c.h"
|
||||
#include "math/pprz_algebra_int.h"
|
||||
|
||||
//#include "led.h"
|
||||
|
||||
static inline void baro_event(void (*b_abs_handler)(void), void (*b_diff_handler)(void))
|
||||
{
|
||||
baro_ms5611_event();
|
||||
if(baro_ms5611_valid) {
|
||||
baro.status = BS_RUNNING;
|
||||
baro.absolute = (int32_t)baroms;
|
||||
b_abs_handler();
|
||||
baro_ms5611_valid = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
#define BaroEvent(_b_abs_handler, _b_diff_handler) baro_event(_b_abs_handler,_b_diff_handler)
|
||||
extern void baro_event(void (*b_abs_handler)(void));
|
||||
#define BaroEvent(_b_abs_handler, _b_diff_handler) baro_event(_b_abs_handler)
|
||||
|
||||
#endif /* BOARDS_KROOZ_SD_BARO_H */
|
||||
|
||||
@@ -167,7 +167,7 @@ static int32_t baro_apply_calibration(int32_t raw)
|
||||
return p + ((x1 + x2 + 3791) >> 4);
|
||||
}
|
||||
|
||||
void baro_event(void (*b_abs_handler)(void), void (*b_diff_handler)(void))
|
||||
void baro_event(void (*b_abs_handler)(void))
|
||||
{
|
||||
if (baro_board.status == LBS_READING &&
|
||||
baro_trans.status != I2CTransPending && baro_trans.status != I2CTransRunning) {
|
||||
@@ -183,13 +183,11 @@ void baro_event(void (*b_abs_handler)(void), void (*b_diff_handler)(void))
|
||||
baro_trans.status != I2CTransPending && baro_trans.status != I2CTransRunning) {
|
||||
baro_board.status = LBS_REQUEST;
|
||||
if (baro_trans.status == I2CTransSuccess) {
|
||||
// abuse differential to store temp in 0.1C for now
|
||||
int32_t tmp = (baro_trans.buf[0] << 8) | baro_trans.buf[1];
|
||||
int32_t x1 = ((tmp - calibration.ac6) * calibration.ac5) >> 15;
|
||||
int32_t x2 = (calibration.mc << 11) / (x1 + calibration.md);
|
||||
calibration.b5 = x1 + x2;
|
||||
baro.differential = (calibration.b5 + 8) >> 4;
|
||||
b_diff_handler();
|
||||
baro_board.temp = (calibration.b5 + 8) >> 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ enum LisaBaroStatus {
|
||||
|
||||
struct BaroBoard {
|
||||
enum LisaBaroStatus status;
|
||||
int32_t temp; ///< temperature in 0.1C
|
||||
};
|
||||
|
||||
struct bmp085_baro_calibration {
|
||||
@@ -60,8 +61,8 @@ extern void baro_board_send_config(void);
|
||||
|
||||
#endif // !BARO_MS5611_xx
|
||||
|
||||
extern void baro_event(void (*b_abs_handler)(void), void (*b_diff_handler)(void));
|
||||
extern void baro_event(void (*b_abs_handler)(void));
|
||||
|
||||
#define BaroEvent(_b_abs_handler, _b_diff_handler) baro_event(_b_abs_handler,_b_diff_handler)
|
||||
#define BaroEvent(_b_abs_handler, _b_diff_handler) baro_event(_b_abs_handler)
|
||||
|
||||
#endif /* BOARDS_LISA_M_BARO_H */
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@
|
||||
/**
|
||||
* @file boards/lisa_m/baro_ms5611_i2c.c
|
||||
*
|
||||
* Driver for MS5611 baro on LisaM/Aspirin2.1 via I2C.
|
||||
* Driver for MS5611 baro via I2C.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -94,7 +94,7 @@ void baro_periodic(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void baro_event(void (*b_abs_handler)(void), void (*b_diff_handler)(void)){
|
||||
void baro_event(void (*b_abs_handler)(void)){
|
||||
if (sys_time.nb_sec > 1) {
|
||||
ms5611_i2c_event(&baro_ms5611);
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ void baro_periodic(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void baro_event(void (*b_abs_handler)(void), void (*b_diff_handler)(void)){
|
||||
void baro_event(void (*b_abs_handler)(void)){
|
||||
if (sys_time.nb_sec > 1) {
|
||||
ms5611_spi_event(&baro_ms5611);
|
||||
|
||||
Reference in New Issue
Block a user