diff --git a/firmware/Pre-flight.md b/firmware/Pre-flight.md index a837bae..a03e5c7 100644 --- a/firmware/Pre-flight.md +++ b/firmware/Pre-flight.md @@ -7,6 +7,7 @@ - `APRS_ENABLE` is set if APRS is to be used on the flight - `APRS_USE_GEOFENCE` is set - `TELEMETRY_USE_GEOFENCE` is set + - Check the correct barometer is defined, for instance `BAROMETER_TYPE_MS5607` is set. - `DEBUG_USE_INTWATCHDOG` can be disabled during flight. This saves some power - Check interrupts are regular enough to kick the hardware watchdog under all conditions. diff --git a/firmware/inc/hw_config.h b/firmware/inc/hw_config.h index fc9b517..6e56401 100644 --- a/firmware/inc/hw_config.h +++ b/firmware/inc/hw_config.h @@ -135,6 +135,7 @@ */ #define BAROMETER_TYPE_BMP180 0 #define BAROMETER_TYPE_MS5607 1 +#define BAROMETER_TYPE_MS5611 0 /** * Battery ADC diff --git a/firmware/inc/ms5607.h b/firmware/inc/ms5607.h deleted file mode 100644 index fa4801c..0000000 --- a/firmware/inc/ms5607.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * MS5607 - * Copyright (C) 2015 Richard Meadows - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef MS5607_H -#define MS5607_H - -#include "samd20.h" - -/** - * Barometer data structure - */ -struct barometer { - double temperature; - double pressure; - int valid; // 1 = valid, 0 = invalid -}; - -struct barometer* get_barometer(void); -void ms5607_init(void); - -#endif /* MS5607_H */ diff --git a/firmware/src/ms5607.c b/firmware/src/ms5607.c index 44b32f3..f755f4b 100644 --- a/firmware/src/ms5607.c +++ b/firmware/src/ms5607.c @@ -28,7 +28,7 @@ #include "samd20.h" #include "hw_config.h" -#if BAROMETER_TYPE_MS5607 +#if (BAROMETER_TYPE_MS5607 || BAROMETER_TYPE_MS5611) #include "barometer.h" #include "i2c_bb.h" @@ -284,7 +284,11 @@ struct barometer* get_barometer(void) double P = (((D1 * SENS) / (1<<21)) - OFF) / (1<<15); barometer.temperature = (double)TEMP / 100; /* degC */ +#if BAROMETER_TYPE_MS5611 barometer.pressure = P/2; /* Pa. DIVIDE BY 2 FOR MS5611 ONLY */ +#else + barometer.pressure = P; +#endif barometer.valid = 1; } else { /* Barometer not initialised correctly */