mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 13:55:40 +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:
@@ -172,17 +172,17 @@ LISA_M_BARO ?= BARO_BOARD_BMP085
|
|||||||
ifeq ($(LISA_M_BARO), BARO_MS5611_SPI)
|
ifeq ($(LISA_M_BARO), BARO_MS5611_SPI)
|
||||||
include $(CFG_SHARED)/spi_master.makefile
|
include $(CFG_SHARED)/spi_master.makefile
|
||||||
ap.CFLAGS += -DUSE_SPI2 -DUSE_SPI_SLAVE3
|
ap.CFLAGS += -DUSE_SPI2 -DUSE_SPI_SLAVE3
|
||||||
ap.srcs += peripherals/ms5611.c
|
ap.srcs += peripherals/ms5611.c
|
||||||
ap.srcs += peripherals/ms5611_spi.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)
|
else ifeq ($(LISA_M_BARO), BARO_MS5611_I2C)
|
||||||
ap.CFLAGS += -DUSE_I2C2
|
ap.CFLAGS += -DUSE_I2C2
|
||||||
ap.srcs += peripherals/ms5611.c
|
ap.srcs += peripherals/ms5611.c
|
||||||
ap.srcs += peripherals/ms5611_i2c.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)
|
else ifeq ($(LISA_M_BARO), BARO_BOARD_BMP085)
|
||||||
ap.srcs += $(SRC_BOARD)/baro_board.c
|
ap.srcs += $(SRC_BOARD)/baro_board.c
|
||||||
ap.CFLAGS += -DUSE_I2C2
|
ap.CFLAGS += -DUSE_I2C2
|
||||||
endif
|
endif
|
||||||
ap.CFLAGS += -D$(LISA_M_BARO)
|
ap.CFLAGS += -D$(LISA_M_BARO)
|
||||||
|
|
||||||
@@ -193,14 +193,14 @@ LIA_BARO ?= BARO_MS5611_SPI
|
|||||||
ifeq ($(LIA_BARO), BARO_MS5611_SPI)
|
ifeq ($(LIA_BARO), BARO_MS5611_SPI)
|
||||||
include $(CFG_SHARED)/spi_master.makefile
|
include $(CFG_SHARED)/spi_master.makefile
|
||||||
ap.CFLAGS += -DUSE_SPI2 -DUSE_SPI_SLAVE3
|
ap.CFLAGS += -DUSE_SPI2 -DUSE_SPI_SLAVE3
|
||||||
ap.srcs += peripherals/ms5611.c
|
ap.srcs += peripherals/ms5611.c
|
||||||
ap.srcs += peripherals/ms5611_spi.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)
|
else ifeq ($(LIA_BARO), BARO_MS5611_I2C)
|
||||||
ap.CFLAGS += -DUSE_I2C2
|
ap.CFLAGS += -DUSE_I2C2
|
||||||
ap.srcs += peripherals/ms5611.c
|
ap.srcs += peripherals/ms5611.c
|
||||||
ap.srcs += peripherals/ms5611_i2c.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
|
endif
|
||||||
ap.CFLAGS += -D$(LIA_BARO)
|
ap.CFLAGS += -D$(LIA_BARO)
|
||||||
|
|
||||||
@@ -214,7 +214,10 @@ ap.srcs += $(SRC_BOARD)/baro_board.c
|
|||||||
|
|
||||||
# krooz baro
|
# krooz baro
|
||||||
else ifeq ($(BOARD), krooz)
|
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
|
# apogee baro
|
||||||
else ifeq ($(BOARD), apogee)
|
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
|
#ifndef BOARDS_KROOZ_BARO_H
|
||||||
#define BOARDS_KROOZ_BARO_H
|
#define BOARDS_KROOZ_BARO_H
|
||||||
|
|
||||||
#include "std.h"
|
extern void baro_event(void (*b_abs_handler)(void));
|
||||||
#include "mcu_periph/i2c.h"
|
#define BaroEvent(_b_abs_handler, _b_diff_handler) baro_event(_b_abs_handler)
|
||||||
#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)
|
|
||||||
|
|
||||||
#endif /* BOARDS_KROOZ_SD_BARO_H */
|
#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);
|
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 &&
|
if (baro_board.status == LBS_READING &&
|
||||||
baro_trans.status != I2CTransPending && baro_trans.status != I2CTransRunning) {
|
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_trans.status != I2CTransPending && baro_trans.status != I2CTransRunning) {
|
||||||
baro_board.status = LBS_REQUEST;
|
baro_board.status = LBS_REQUEST;
|
||||||
if (baro_trans.status == I2CTransSuccess) {
|
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 tmp = (baro_trans.buf[0] << 8) | baro_trans.buf[1];
|
||||||
int32_t x1 = ((tmp - calibration.ac6) * calibration.ac5) >> 15;
|
int32_t x1 = ((tmp - calibration.ac6) * calibration.ac5) >> 15;
|
||||||
int32_t x2 = (calibration.mc << 11) / (x1 + calibration.md);
|
int32_t x2 = (calibration.mc << 11) / (x1 + calibration.md);
|
||||||
calibration.b5 = x1 + x2;
|
calibration.b5 = x1 + x2;
|
||||||
baro.differential = (calibration.b5 + 8) >> 4;
|
baro_board.temp = (calibration.b5 + 8) >> 4;
|
||||||
b_diff_handler();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ enum LisaBaroStatus {
|
|||||||
|
|
||||||
struct BaroBoard {
|
struct BaroBoard {
|
||||||
enum LisaBaroStatus status;
|
enum LisaBaroStatus status;
|
||||||
|
int32_t temp; ///< temperature in 0.1C
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bmp085_baro_calibration {
|
struct bmp085_baro_calibration {
|
||||||
@@ -60,8 +61,8 @@ extern void baro_board_send_config(void);
|
|||||||
|
|
||||||
#endif // !BARO_MS5611_xx
|
#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 */
|
#endif /* BOARDS_LISA_M_BARO_H */
|
||||||
|
|||||||
+2
-2
@@ -23,7 +23,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file boards/lisa_m/baro_ms5611_i2c.c
|
* @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) {
|
if (sys_time.nb_sec > 1) {
|
||||||
ms5611_i2c_event(&baro_ms5611);
|
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) {
|
if (sys_time.nb_sec > 1) {
|
||||||
ms5611_spi_event(&baro_ms5611);
|
ms5611_spi_event(&baro_ms5611);
|
||||||
|
|
||||||
Reference in New Issue
Block a user