Skip to content

Commit

Permalink
Merge pull request #287 from rosflight/fix_rosflight_59
Browse files Browse the repository at this point in the history
Fix rosflight 59
  • Loading branch information
dpkoch authored Feb 27, 2018
2 parents 4ccb0c6 + 187bfc1 commit be5cf40
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions boards/naze/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ BREEZY_SRC = drv_gpio.c \
drv_ms4525.c \
drv_mb1242.c \
drv_ms5611.c \
drv_bmp280.c \
drv_hmc5883l.c \
startup_stm32f10x_md_gcc.S

Expand Down
22 changes: 17 additions & 5 deletions boards/naze/naze32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,16 @@ void Naze32::sensors_init()
while(millis() < 50);

i2cWrite(0,0,0);
ms5611_init();
if (bmp280_init())
baro_type = BARO_BMP280;
else if (ms5611_init())
baro_type = BARO_MS5611;

hmc5883lInit(_board_revision);
mb1242_init();
ms4525_init();


// IMU
uint16_t acc1G;
mpu6050_init(true, &acc1G, &_gyro_scale, _board_revision);
Expand Down Expand Up @@ -183,14 +188,21 @@ bool Naze32::mag_check(void)

void Naze32::baro_read(float *pressure, float *temperature)
{
ms5611_async_update();
ms5611_async_read(pressure, temperature);
if (baro_type == BARO_BMP280)
{
bmp280_async_update();
bmp280_async_read(pressure, temperature);
}
else if (baro_type == BARO_MS5611)
{
ms5611_async_update();
ms5611_async_read(pressure, temperature);
}
}

bool Naze32::baro_check()
{
ms5611_async_update();
return ms5611_present();
return baro_type != BARO_NONE;
}

bool Naze32::diff_pressure_check(void)
Expand Down
8 changes: 8 additions & 0 deletions boards/naze/naze32.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ class Naze32 : public Board
};
uint8_t sonar_type = SONAR_NONE;

enum
{
BARO_NONE,
BARO_BMP280,
BARO_MS5611
};
uint8_t baro_type = BARO_NONE;



public:
Expand Down

0 comments on commit be5cf40

Please sign in to comment.