1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

LP-540 Changes all reference to ms5611 in ms56xx.h to ms56xx, and combines if statements in pressure compensation equations.

This commit is contained in:
Brian Webb 2017-07-02 09:55:19 -07:00
parent 4ee7249b4a
commit b75637e6f2
2 changed files with 11 additions and 14 deletions

View File

@ -258,19 +258,16 @@ int32_t PIOS_MS56xx_ReadADC(void)
Sens2 = 0;
}
RawPressure = ((Data[0] << 16) | (Data[1] << 8) | Data[2]);
// Offset at actual temperature
// Offset and sensitivity at actual temperature
if (version == MS56XX_VERSION_5611) {
// OFF = OFFT1 + TCO * dT = C2 * 2^16 + (C4 * dT) / 2^7
Offset = ((int64_t)CalibData.C[1]) * POW2(16) + (((int64_t)CalibData.C[3]) * deltaTemp) / POW2(7) - Offset2;
} else {
// OFF = OFFT1 + TCO * dT = C2 * 2^17 + (C4 * dT) / 2^6
Offset = ((int64_t)CalibData.C[1]) * POW2(17) + (((int64_t)CalibData.C[3]) * deltaTemp) / POW2(6) - Offset2;
}
// Sensitivity at actual temperature
if (version == MS56XX_VERSION_5611) {
// SENS = SENST1 + TCS * dT = C1 * 2^15 + (C3 * dT) / 2^8
Sens = ((int64_t)CalibData.C[0]) * POW2(15) + (((int64_t)CalibData.C[2]) * deltaTemp) / POW2(8) - Sens2;
} else {
// OFF = OFFT1 + TCO * dT = C2 * 2^17 + (C4 * dT) / 2^6
Offset = ((int64_t)CalibData.C[1]) * POW2(17) + (((int64_t)CalibData.C[3]) * deltaTemp) / POW2(6) - Offset2;
// SENS = SENST1 + TCS * dT = C1 * 2^16 + (C3 * dT) / 2^7
Sens = ((int64_t)CalibData.C[0]) * POW2(16) + (((int64_t)CalibData.C[2]) * deltaTemp) / POW2(7) - Sens2;
}

View File

@ -2,13 +2,13 @@
******************************************************************************
* @addtogroup PIOS PIOS Core hardware abstraction layer
* @{
* @addtogroup PIOS_MS5611 MS5611 Functions
* @addtogroup PIOS_MS5611 MS56XX Functions
* @brief Hardware functions to deal with the altitude pressure sensor
* @{
*
* @file pios_ms5611.h
* @file pios_ms56xx.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @brief MS5611 functions header.
* @brief MS56XX functions header.
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
@ -28,8 +28,8 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PIOS_MS5611_H
#define PIOS_MS5611_H
#ifndef PIOS_MS56XX_H
#define PIOS_MS56XX_H
#ifdef PIOS_INCLUDE_MS56XX
@ -41,7 +41,7 @@ enum pios_ms56xx_version {
MS56XX_VERSION_5637 = 2,
};
enum pios_ms5611_osr {
enum pios_ms56xx_osr {
MS56XX_OSR_256 = 0,
MS56XX_OSR_512 = 2,
MS56XX_OSR_1024 = 4,
@ -54,7 +54,7 @@ enum pios_ms5611_osr {
struct pios_ms56xx_cfg {
uint8_t address;
enum pios_ms56xx_version version;
enum pios_ms5611_osr oversampling;
enum pios_ms56xx_osr oversampling;
};
/* Public Functions */