mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Merged in webbbn/librepilot/LP-540-add-support-for-ms5607-and-ms5637 (pull request #449)
LP-540 Adds support for ms5607 and ms5637 to the ms5611 driver and renames it ms56xx. Approved-by: Lalanne Laurent <f5soh@free.fr> Approved-by: Alessio Morale <alessiomorale@gmail.com> Approved-by: Philippe Renon <philippe_renon@yahoo.fr> Approved-by: Jan NIJS <dr.oblivium@gmail.com> Approved-by: Brian Webb <webbbn@gmail.com>
This commit is contained in:
commit
a542372d5f
@ -84,7 +84,7 @@ SRC += $(PIOSCOMMON)/pios_mpu6000.c
|
||||
SRC += $(PIOSCOMMON)/pios_mpu9250.c
|
||||
SRC += $(PIOSCOMMON)/pios_mpxv.c
|
||||
SRC += $(PIOSCOMMON)/pios_ms4525do.c
|
||||
SRC += $(PIOSCOMMON)/pios_ms5611.c
|
||||
SRC += $(PIOSCOMMON)/pios_ms56xx.c
|
||||
SRC += $(PIOSCOMMON)/pios_bmp280.c
|
||||
SRC += $(PIOSCOMMON)/pios_oplinkrcvr.c
|
||||
SRC += $(PIOSCOMMON)/pios_video.c
|
||||
|
@ -38,9 +38,7 @@
|
||||
# include <pios_mpu6000_config.h>
|
||||
#endif
|
||||
|
||||
#ifdef PIOS_INCLUDE_MS5611
|
||||
# include <pios_ms5611.h>
|
||||
#endif
|
||||
# include <pios_ms56xx.h>
|
||||
|
||||
#ifdef PIOS_INCLUDE_BMP280
|
||||
# include <pios_bmp280.h>
|
||||
@ -190,13 +188,13 @@ void PIOS_BOARD_Sensors_Configure()
|
||||
# endif /* PIOS_INCLUDE_HMC5X83 */
|
||||
|
||||
// internal ms5611 baro
|
||||
#if defined(PIOS_INCLUDE_MS5611)
|
||||
const struct pios_ms5611_cfg *ms5611_cfg = PIOS_BOARD_HW_DEFS_GetMS5611Cfg(pios_board_info_blob.board_rev);
|
||||
if (ms5611_cfg) {
|
||||
PIOS_MS5611_Init(ms5611_cfg, PIOS_I2C_MS5611_INTERNAL_ADAPTER);
|
||||
PIOS_MS5611_Register();
|
||||
#ifdef PIOS_INCLUDE_MS56XX
|
||||
const struct pios_ms56xx_cfg *ms56xx_cfg = PIOS_BOARD_HW_DEFS_GetMS56xxCfg(pios_board_info_blob.board_rev);
|
||||
if (ms56xx_cfg) {
|
||||
PIOS_MS56xx_Init(ms56xx_cfg, PIOS_I2C_MS56XX_INTERNAL_ADAPTER);
|
||||
PIOS_MS56xx_Register();
|
||||
}
|
||||
#endif
|
||||
#endif /* PIOS_INCLUDE_MS56XX */
|
||||
|
||||
#ifdef PIOS_INCLUDE_BMP280
|
||||
const struct pios_bmp280_cfg *bmp280_cfg = PIOS_BOARD_HW_DEFS_GetBMP280Cfg(pios_board_info_blob.board_rev);
|
||||
|
@ -2,13 +2,13 @@
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_MS5611 MS5611 Functions
|
||||
* @addtogroup PIOS_MS56XX MS56XX Functions
|
||||
* @brief Hardware functions to deal with the altitude pressure sensor
|
||||
* @{
|
||||
*
|
||||
* @file pios_ms5611.c
|
||||
* @file pios_ms56xx.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief MS5611 Pressure Sensor Routines
|
||||
* @brief MS56XX Pressure Sensor Routines
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
******************************************************************************/
|
||||
@ -29,44 +29,52 @@
|
||||
*/
|
||||
|
||||
#include "pios.h"
|
||||
#ifdef PIOS_INCLUDE_MS5611
|
||||
#include <pios_ms5611.h>
|
||||
#ifdef PIOS_INCLUDE_MS56XX
|
||||
#include <pios_ms56xx.h>
|
||||
#define POW2(x) (1 << x)
|
||||
|
||||
// Command addresses
|
||||
#define MS56XX_RESET 0x1E
|
||||
#define MS56XX_CALIB_ADDR 0xA2 /* First sample is factory stuff */
|
||||
#define MS56XX_CALIB_LEN 16
|
||||
#define MS56XX_ADC_READ 0x00
|
||||
#define MS56XX_PRES_ADDR 0x40
|
||||
#define MS56XX_TEMP_ADDR 0x50
|
||||
|
||||
// Option to change the interleave between Temp and Pressure conversions
|
||||
// Undef for normal operation
|
||||
#define PIOS_MS5611_SLOW_TEMP_RATE 20
|
||||
#ifndef PIOS_MS5611_SLOW_TEMP_RATE
|
||||
#define PIOS_MS5611_SLOW_TEMP_RATE 1
|
||||
#define PIOS_MS56XX_SLOW_TEMP_RATE 20
|
||||
#ifndef PIOS_MS56XX_SLOW_TEMP_RATE
|
||||
#define PIOS_MS56XX_SLOW_TEMP_RATE 1
|
||||
#endif
|
||||
// Running moving average smoothing factor
|
||||
#define PIOS_MS5611_TEMP_SMOOTHING 10
|
||||
#define PIOS_MS56XX_TEMP_SMOOTHING 10
|
||||
|
||||
#define PIOS_MS5611_INIT_DELAY_US 1000000
|
||||
#define PIOS_MS5611_RESET_DELAY_US 20000
|
||||
#define PIOS_MS56XX_INIT_DELAY_US 1000000
|
||||
#define PIOS_MS56XX_RESET_DELAY_US 20000
|
||||
|
||||
/* Local Types */
|
||||
typedef struct {
|
||||
uint16_t C[6];
|
||||
} MS5611CalibDataTypeDef;
|
||||
} MS56XXCalibDataTypeDef;
|
||||
|
||||
typedef enum {
|
||||
MS5611_CONVERSION_TYPE_None = 0,
|
||||
MS5611_CONVERSION_TYPE_PressureConv,
|
||||
MS5611_CONVERSION_TYPE_TemperatureConv
|
||||
MS56XX_CONVERSION_TYPE_None = 0,
|
||||
MS56XX_CONVERSION_TYPE_PressureConv,
|
||||
MS56XX_CONVERSION_TYPE_TemperatureConv
|
||||
} ConversionTypeTypeDef;
|
||||
|
||||
typedef enum {
|
||||
MS5611_FSM_INIT = 0,
|
||||
MS5611_FSM_CALIBRATION,
|
||||
MS5611_FSM_TEMPERATURE,
|
||||
MS5611_FSM_PRESSURE,
|
||||
MS5611_FSM_CALCULATE,
|
||||
} MS5611_FSM_State;
|
||||
MS56XX_FSM_INIT = 0,
|
||||
MS56XX_FSM_CALIBRATION,
|
||||
MS56XX_FSM_TEMPERATURE,
|
||||
MS56XX_FSM_PRESSURE,
|
||||
MS56XX_FSM_CALCULATE,
|
||||
} MS56XX_FSM_State;
|
||||
|
||||
static ConversionTypeTypeDef CurrentRead = MS5611_CONVERSION_TYPE_None;
|
||||
static ConversionTypeTypeDef CurrentRead = MS56XX_CONVERSION_TYPE_None;
|
||||
|
||||
static MS5611CalibDataTypeDef CalibData;
|
||||
static MS56XXCalibDataTypeDef CalibData;
|
||||
|
||||
static uint8_t temp_press_interleave_count = 1;
|
||||
|
||||
@ -86,61 +94,62 @@ static uint32_t conversionDelayUs;
|
||||
static int64_t compensation_t2;
|
||||
|
||||
// Move into proper driver structure with cfg stored
|
||||
static enum pios_ms56xx_version version;
|
||||
static uint8_t ms56xx_address;
|
||||
static uint32_t oversampling;
|
||||
static const struct pios_ms5611_cfg *dev_cfg;
|
||||
static int32_t i2c_id;
|
||||
static PIOS_SENSORS_1Axis_SensorsWithTemp results;
|
||||
static bool hw_error = false;
|
||||
|
||||
// private functions
|
||||
static int32_t PIOS_MS5611_Read(uint8_t address, uint8_t *buffer, uint8_t len);
|
||||
static int32_t PIOS_MS5611_WriteCommand(uint8_t command, uint32_t delayuS);
|
||||
static uint32_t PIOS_MS5611_GetDelayUs(void);
|
||||
static void PIOS_MS5611_ReadCalibrationData(void);
|
||||
static int32_t PIOS_MS56xx_Read_I2C(uint8_t address, uint8_t *buffer, uint8_t len);
|
||||
static int32_t PIOS_MS56xx_WriteCommand(uint8_t command, uint32_t delayuS);
|
||||
static uint32_t PIOS_MS56xx_GetDelayUs(void);
|
||||
static void PIOS_MS56xx_ReadCalibrationData(void);
|
||||
|
||||
// sensor driver interface
|
||||
bool PIOS_MS5611_driver_Test(uintptr_t context);
|
||||
void PIOS_MS5611_driver_Reset(uintptr_t context);
|
||||
void PIOS_MS5611_driver_get_scale(float *scales, uint8_t size, uintptr_t context);
|
||||
void PIOS_MS5611_driver_fetch(void *, uint8_t size, uintptr_t context);
|
||||
bool PIOS_MS5611_driver_poll(uintptr_t context);
|
||||
bool PIOS_MS56xx_driver_Test(uintptr_t context);
|
||||
void PIOS_MS56xx_driver_Reset(uintptr_t context);
|
||||
void PIOS_MS56xx_driver_get_scale(float *scales, uint8_t size, uintptr_t context);
|
||||
void PIOS_MS56xx_driver_fetch(void *, uint8_t size, uintptr_t context);
|
||||
bool PIOS_MS56xx_driver_poll(uintptr_t context);
|
||||
|
||||
const PIOS_SENSORS_Driver PIOS_MS5611_Driver = {
|
||||
.test = PIOS_MS5611_driver_Test,
|
||||
.poll = PIOS_MS5611_driver_poll,
|
||||
.fetch = PIOS_MS5611_driver_fetch,
|
||||
.reset = PIOS_MS5611_driver_Reset,
|
||||
const PIOS_SENSORS_Driver PIOS_MS56xx_Driver = {
|
||||
.test = PIOS_MS56xx_driver_Test,
|
||||
.poll = PIOS_MS56xx_driver_poll,
|
||||
.fetch = PIOS_MS56xx_driver_fetch,
|
||||
.reset = PIOS_MS56xx_driver_Reset,
|
||||
.get_queue = NULL,
|
||||
.get_scale = PIOS_MS5611_driver_get_scale,
|
||||
.get_scale = PIOS_MS56xx_driver_get_scale,
|
||||
.is_polled = true,
|
||||
};
|
||||
/**
|
||||
* Initialise the MS5611 sensor
|
||||
* Initialise the MS56XX sensor
|
||||
*/
|
||||
void PIOS_MS5611_Init(const struct pios_ms5611_cfg *cfg, int32_t i2c_device)
|
||||
void PIOS_MS56xx_Init(const struct pios_ms56xx_cfg *cfg, int32_t i2c_device)
|
||||
{
|
||||
i2c_id = i2c_device;
|
||||
|
||||
ms56xx_address = cfg->address;
|
||||
version = cfg->version;
|
||||
oversampling = cfg->oversampling;
|
||||
conversionDelayUs = PIOS_MS5611_GetDelayUs();
|
||||
|
||||
dev_cfg = cfg; // Store cfg before enabling interrupt
|
||||
conversionDelayUs = PIOS_MS56xx_GetDelayUs();
|
||||
}
|
||||
/**
|
||||
* Start the ADC conversion
|
||||
* \param[in] PresOrTemp BMP085_PRES_ADDR or BMP085_TEMP_ADDR
|
||||
* \return 0 for success, -1 for failure (conversion completed and not read), -2 if failure occurred
|
||||
*/
|
||||
int32_t PIOS_MS5611_StartADC(ConversionTypeTypeDef Type)
|
||||
int32_t PIOS_MS56xx_StartADC(ConversionTypeTypeDef Type)
|
||||
{
|
||||
/* Start the conversion */
|
||||
|
||||
if (Type == MS5611_CONVERSION_TYPE_TemperatureConv) {
|
||||
if (PIOS_MS5611_WriteCommand(MS5611_TEMP_ADDR + oversampling, conversionDelayUs) != 0) {
|
||||
if (Type == MS56XX_CONVERSION_TYPE_TemperatureConv) {
|
||||
if (PIOS_MS56xx_WriteCommand(MS56XX_TEMP_ADDR + oversampling, conversionDelayUs) != 0) {
|
||||
return -2;
|
||||
}
|
||||
} else if (Type == MS5611_CONVERSION_TYPE_PressureConv) {
|
||||
if (PIOS_MS5611_WriteCommand(MS5611_PRES_ADDR + oversampling, conversionDelayUs) != 0) {
|
||||
} else if (Type == MS56XX_CONVERSION_TYPE_PressureConv) {
|
||||
if (PIOS_MS56xx_WriteCommand(MS56XX_PRES_ADDR + oversampling, conversionDelayUs) != 0) {
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
@ -153,24 +162,27 @@ int32_t PIOS_MS5611_StartADC(ConversionTypeTypeDef Type)
|
||||
/**
|
||||
* @brief Return the delay for the current osr in uS
|
||||
*/
|
||||
static uint32_t PIOS_MS5611_GetDelayUs()
|
||||
static uint32_t PIOS_MS56xx_GetDelayUs()
|
||||
{
|
||||
switch (oversampling) {
|
||||
case MS5611_OSR_256:
|
||||
case MS56XX_OSR_256:
|
||||
return 600;
|
||||
|
||||
case MS5611_OSR_512:
|
||||
case MS56XX_OSR_512:
|
||||
return 1170;
|
||||
|
||||
case MS5611_OSR_1024:
|
||||
case MS56XX_OSR_1024:
|
||||
return 2280;
|
||||
|
||||
case MS5611_OSR_2048:
|
||||
case MS56XX_OSR_2048:
|
||||
return 4540;
|
||||
|
||||
case MS5611_OSR_4096:
|
||||
case MS56XX_OSR_4096:
|
||||
return 9040;
|
||||
|
||||
case MS56XX_OSR_8192:
|
||||
return 18080;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -181,7 +193,7 @@ static uint32_t PIOS_MS5611_GetDelayUs()
|
||||
* Read the ADC conversion value (once ADC conversion has completed)
|
||||
* \return 0 if successfully read the ADC, -1 if conversion time has not elapsed, -2 if failure occurred
|
||||
*/
|
||||
int32_t PIOS_MS5611_ReadADC(void)
|
||||
int32_t PIOS_MS56xx_ReadADC(void)
|
||||
{
|
||||
uint8_t Data[3];
|
||||
|
||||
@ -189,18 +201,18 @@ int32_t PIOS_MS5611_ReadADC(void)
|
||||
Data[1] = 0;
|
||||
Data[2] = 0;
|
||||
|
||||
if (CurrentRead == MS5611_CONVERSION_TYPE_None) {
|
||||
if (CurrentRead == MS56XX_CONVERSION_TYPE_None) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
static int64_t deltaTemp;
|
||||
|
||||
if (PIOS_MS5611_Read(MS5611_ADC_READ, Data, 3) != 0) {
|
||||
if (PIOS_MS56xx_Read_I2C(MS56XX_ADC_READ, Data, 3) != 0) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* Read and store the 16bit result */
|
||||
if (CurrentRead == MS5611_CONVERSION_TYPE_TemperatureConv) {
|
||||
if (CurrentRead == MS56XX_CONVERSION_TYPE_TemperatureConv) {
|
||||
RawTemperature = (Data[0] << 16) | (Data[1] << 8) | Data[2];
|
||||
// Difference between actual and reference temperature
|
||||
// dT = D2 - TREF = D2 - C5 * 2^8
|
||||
@ -209,8 +221,8 @@ int32_t PIOS_MS5611_ReadADC(void)
|
||||
// TEMP = 20°C + dT * TEMPSENS = 2000 + dT * C6 / 2^23
|
||||
Temperature = 2000l + ((deltaTemp * CalibData.C[5]) / POW2(23));
|
||||
if (FilteredTemperature != INT32_MIN) {
|
||||
FilteredTemperature = (FilteredTemperature * (PIOS_MS5611_TEMP_SMOOTHING - 1)
|
||||
+ Temperature) / PIOS_MS5611_TEMP_SMOOTHING;
|
||||
FilteredTemperature = (FilteredTemperature * (PIOS_MS56XX_TEMP_SMOOTHING - 1)
|
||||
+ Temperature) / PIOS_MS56XX_TEMP_SMOOTHING;
|
||||
} else {
|
||||
FilteredTemperature = Temperature;
|
||||
}
|
||||
@ -246,18 +258,26 @@ int32_t PIOS_MS5611_ReadADC(void)
|
||||
Sens2 = 0;
|
||||
}
|
||||
RawPressure = ((Data[0] << 16) | (Data[1] << 8) | Data[2]);
|
||||
// Offset at actual temperature
|
||||
// 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;
|
||||
// Sensitivity at actual temperature
|
||||
// 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;
|
||||
|
||||
// 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;
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Temperature compensated pressure (10…1200mbar with 0.01mbar resolution)
|
||||
// P = D1 * SENS - OFF = (D1 * SENS / 2^21 - OFF) / 2^15
|
||||
Pressure = (((((int64_t)RawPressure) * Sens) / POW2(21)) - Offset) / POW2(15);
|
||||
}
|
||||
|
||||
CurrentRead = MS5611_CONVERSION_TYPE_None;
|
||||
CurrentRead = MS56XX_CONVERSION_TYPE_None;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -265,7 +285,7 @@ int32_t PIOS_MS5611_ReadADC(void)
|
||||
/**
|
||||
* Return the most recently computed temperature in kPa
|
||||
*/
|
||||
static float PIOS_MS5611_GetTemperature(void)
|
||||
static float PIOS_MS56xx_GetTemperature(void)
|
||||
{
|
||||
// Apply the second order low and very low temperature compensation offset
|
||||
return ((float)(FilteredTemperature - compensation_t2)) / 100.0f;
|
||||
@ -274,7 +294,7 @@ static float PIOS_MS5611_GetTemperature(void)
|
||||
/**
|
||||
* Return the most recently computed pressure in Pa
|
||||
*/
|
||||
static float PIOS_MS5611_GetPressure(void)
|
||||
static float PIOS_MS56xx_GetPressure(void)
|
||||
{
|
||||
return (float)Pressure;
|
||||
}
|
||||
@ -287,12 +307,12 @@ static float PIOS_MS5611_GetPressure(void)
|
||||
* \return 0 if operation was successful
|
||||
* \return -1 if error during I2C transfer
|
||||
*/
|
||||
static int32_t PIOS_MS5611_Read(uint8_t address, uint8_t *buffer, uint8_t len)
|
||||
static int32_t PIOS_MS56xx_Read_I2C(uint8_t address, uint8_t *buffer, uint8_t len)
|
||||
{
|
||||
const struct pios_i2c_txn txn_list[] = {
|
||||
{
|
||||
.info = __func__,
|
||||
.addr = MS5611_I2C_ADDR,
|
||||
.addr = ms56xx_address,
|
||||
.rw = PIOS_I2C_TXN_WRITE,
|
||||
.len = 1,
|
||||
.buf = &address,
|
||||
@ -300,7 +320,7 @@ static int32_t PIOS_MS5611_Read(uint8_t address, uint8_t *buffer, uint8_t len)
|
||||
,
|
||||
{
|
||||
.info = __func__,
|
||||
.addr = MS5611_I2C_ADDR,
|
||||
.addr = ms56xx_address,
|
||||
.rw = PIOS_I2C_TXN_READ,
|
||||
.len = len,
|
||||
.buf = buffer,
|
||||
@ -321,18 +341,18 @@ static int32_t PIOS_MS5611_Read(uint8_t address, uint8_t *buffer, uint8_t len)
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes one or more bytes to the MS5611
|
||||
* Writes one or more bytes to the MS56XX
|
||||
* \param[in] address Register address
|
||||
* \param[in] buffer source buffer
|
||||
* \return 0 if operation was successful
|
||||
* \return -1 if error during I2C transfer
|
||||
*/
|
||||
static int32_t PIOS_MS5611_WriteCommand(uint8_t command, uint32_t delayuS)
|
||||
static int32_t PIOS_MS56xx_WriteCommand(uint8_t command, uint32_t delayuS)
|
||||
{
|
||||
const struct pios_i2c_txn txn_list[] = {
|
||||
{
|
||||
.info = __func__,
|
||||
.addr = MS5611_I2C_ADDR,
|
||||
.addr = ms56xx_address,
|
||||
.rw = PIOS_I2C_TXN_WRITE,
|
||||
.len = 1,
|
||||
.buf = &command,
|
||||
@ -356,7 +376,7 @@ static int32_t PIOS_MS5611_WriteCommand(uint8_t command, uint32_t delayuS)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void PIOS_MS5611_ReadCalibrationData()
|
||||
static void PIOS_MS56xx_ReadCalibrationData()
|
||||
{
|
||||
uint8_t data[2];
|
||||
|
||||
@ -364,19 +384,19 @@ static void PIOS_MS5611_ReadCalibrationData()
|
||||
compensation_t2 = 0;
|
||||
/* Calibration parameters */
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (PIOS_MS5611_Read(MS5611_CALIB_ADDR + i * 2, data, 2) != 0) {
|
||||
if (PIOS_MS56xx_Read_I2C(MS56XX_CALIB_ADDR + i * 2, data, 2) != 0) {
|
||||
break;
|
||||
}
|
||||
CalibData.C[i] = (data[0] << 8) | data[1];
|
||||
}
|
||||
}
|
||||
|
||||
static void PIOS_MS5611_Reset()
|
||||
static void PIOS_MS56xx_Reset()
|
||||
{
|
||||
temp_press_interleave_count = 1;
|
||||
hw_error = false;
|
||||
|
||||
PIOS_MS5611_WriteCommand(MS5611_RESET, PIOS_MS5611_RESET_DELAY_US);
|
||||
PIOS_MS56xx_WriteCommand(MS56XX_RESET, PIOS_MS56XX_RESET_DELAY_US);
|
||||
}
|
||||
|
||||
|
||||
@ -384,23 +404,23 @@ static void PIOS_MS5611_Reset()
|
||||
* @brief Run self-test operation.
|
||||
* \return 0 if self-test succeed, -1 if failed
|
||||
*/
|
||||
int32_t PIOS_MS5611_Test()
|
||||
int32_t PIOS_MS56xx_Test()
|
||||
{
|
||||
// TODO: Is there a better way to test this than just checking that pressure/temperature has changed?
|
||||
int32_t cur_value = 0;
|
||||
|
||||
cur_value = Temperature;
|
||||
PIOS_MS5611_StartADC(MS5611_CONVERSION_TYPE_TemperatureConv);
|
||||
PIOS_MS56xx_StartADC(MS56XX_CONVERSION_TYPE_TemperatureConv);
|
||||
PIOS_DELAY_WaitmS(10);
|
||||
PIOS_MS5611_ReadADC();
|
||||
PIOS_MS56xx_ReadADC();
|
||||
if (cur_value == Temperature) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
cur_value = Pressure;
|
||||
PIOS_MS5611_StartADC(MS5611_CONVERSION_TYPE_PressureConv);
|
||||
PIOS_MS56xx_StartADC(MS56XX_CONVERSION_TYPE_PressureConv);
|
||||
PIOS_DELAY_WaitmS(10);
|
||||
PIOS_MS5611_ReadADC();
|
||||
PIOS_MS56xx_ReadADC();
|
||||
if (cur_value == Pressure) {
|
||||
return -1;
|
||||
}
|
||||
@ -410,33 +430,33 @@ int32_t PIOS_MS5611_Test()
|
||||
|
||||
|
||||
/* PIOS sensor driver implementation */
|
||||
void PIOS_MS5611_Register()
|
||||
void PIOS_MS56xx_Register()
|
||||
{
|
||||
PIOS_SENSORS_Register(&PIOS_MS5611_Driver, PIOS_SENSORS_TYPE_1AXIS_BARO, 0);
|
||||
PIOS_SENSORS_Register(&PIOS_MS56xx_Driver, PIOS_SENSORS_TYPE_1AXIS_BARO, 0);
|
||||
}
|
||||
|
||||
bool PIOS_MS5611_driver_Test(__attribute__((unused)) uintptr_t context)
|
||||
bool PIOS_MS56xx_driver_Test(__attribute__((unused)) uintptr_t context)
|
||||
{
|
||||
return true; // !PIOS_MS5611_Test();
|
||||
return true; // !PIOS_MS56xx_Test();
|
||||
}
|
||||
|
||||
void PIOS_MS5611_driver_Reset(__attribute__((unused)) uintptr_t context) {}
|
||||
void PIOS_MS56xx_driver_Reset(__attribute__((unused)) uintptr_t context) {}
|
||||
|
||||
void PIOS_MS5611_driver_get_scale(float *scales, uint8_t size, __attribute__((unused)) uintptr_t context)
|
||||
void PIOS_MS56xx_driver_get_scale(float *scales, uint8_t size, __attribute__((unused)) uintptr_t context)
|
||||
{
|
||||
PIOS_Assert(size > 0);
|
||||
scales[0] = 1;
|
||||
}
|
||||
|
||||
void PIOS_MS5611_driver_fetch(void *data, __attribute__((unused)) uint8_t size, __attribute__((unused)) uintptr_t context)
|
||||
void PIOS_MS56xx_driver_fetch(void *data, __attribute__((unused)) uint8_t size, __attribute__((unused)) uintptr_t context)
|
||||
{
|
||||
PIOS_Assert(data);
|
||||
memcpy(data, (void *)&results, sizeof(PIOS_SENSORS_1Axis_SensorsWithTemp));
|
||||
}
|
||||
|
||||
bool PIOS_MS5611_driver_poll(__attribute__((unused)) uintptr_t context)
|
||||
bool PIOS_MS56xx_driver_poll(__attribute__((unused)) uintptr_t context)
|
||||
{
|
||||
static MS5611_FSM_State next_state = MS5611_FSM_INIT;
|
||||
static MS56XX_FSM_State next_state = MS56XX_FSM_INIT;
|
||||
|
||||
if (PIOS_DELAY_DiffuS(lastCommandTimeRaw) < commandDelayUs) {
|
||||
return false;
|
||||
@ -444,40 +464,40 @@ bool PIOS_MS5611_driver_poll(__attribute__((unused)) uintptr_t context)
|
||||
|
||||
commandDelayUs = 0;
|
||||
|
||||
PIOS_MS5611_ReadADC();
|
||||
PIOS_MS56xx_ReadADC();
|
||||
|
||||
switch (next_state) {
|
||||
case MS5611_FSM_INIT:
|
||||
PIOS_MS5611_Reset();
|
||||
next_state = MS5611_FSM_CALIBRATION;
|
||||
case MS56XX_FSM_INIT:
|
||||
PIOS_MS56xx_Reset();
|
||||
next_state = MS56XX_FSM_CALIBRATION;
|
||||
break;
|
||||
case MS5611_FSM_CALIBRATION:
|
||||
PIOS_MS5611_ReadCalibrationData();
|
||||
/* fall through to MS5611_FSM_TEMPERATURE */
|
||||
case MS56XX_FSM_CALIBRATION:
|
||||
PIOS_MS56xx_ReadCalibrationData();
|
||||
/* fall through to MS56XX_FSM_TEMPERATURE */
|
||||
|
||||
case MS5611_FSM_TEMPERATURE:
|
||||
PIOS_MS5611_StartADC(MS5611_CONVERSION_TYPE_TemperatureConv);
|
||||
next_state = MS5611_FSM_PRESSURE;
|
||||
case MS56XX_FSM_TEMPERATURE:
|
||||
PIOS_MS56xx_StartADC(MS56XX_CONVERSION_TYPE_TemperatureConv);
|
||||
next_state = MS56XX_FSM_PRESSURE;
|
||||
break;
|
||||
|
||||
case MS5611_FSM_PRESSURE:
|
||||
PIOS_MS5611_StartADC(MS5611_CONVERSION_TYPE_PressureConv);
|
||||
next_state = MS5611_FSM_CALCULATE;
|
||||
case MS56XX_FSM_PRESSURE:
|
||||
PIOS_MS56xx_StartADC(MS56XX_CONVERSION_TYPE_PressureConv);
|
||||
next_state = MS56XX_FSM_CALCULATE;
|
||||
break;
|
||||
|
||||
case MS5611_FSM_CALCULATE:
|
||||
case MS56XX_FSM_CALCULATE:
|
||||
temp_press_interleave_count--;
|
||||
if (!temp_press_interleave_count) {
|
||||
temp_press_interleave_count = PIOS_MS5611_SLOW_TEMP_RATE;
|
||||
PIOS_MS5611_StartADC(MS5611_CONVERSION_TYPE_TemperatureConv);
|
||||
next_state = MS5611_FSM_PRESSURE;
|
||||
temp_press_interleave_count = PIOS_MS56XX_SLOW_TEMP_RATE;
|
||||
PIOS_MS56xx_StartADC(MS56XX_CONVERSION_TYPE_TemperatureConv);
|
||||
next_state = MS56XX_FSM_PRESSURE;
|
||||
} else {
|
||||
PIOS_MS5611_StartADC(MS5611_CONVERSION_TYPE_PressureConv);
|
||||
next_state = MS5611_FSM_CALCULATE;
|
||||
PIOS_MS56xx_StartADC(MS56XX_CONVERSION_TYPE_PressureConv);
|
||||
next_state = MS56XX_FSM_CALCULATE;
|
||||
}
|
||||
|
||||
results.temperature = PIOS_MS5611_GetTemperature();
|
||||
results.sample = PIOS_MS5611_GetPressure();
|
||||
results.temperature = PIOS_MS56xx_GetTemperature();
|
||||
results.sample = PIOS_MS56xx_GetPressure();
|
||||
return true;
|
||||
|
||||
default:
|
||||
@ -487,16 +507,25 @@ bool PIOS_MS5611_driver_poll(__attribute__((unused)) uintptr_t context)
|
||||
|
||||
if (hw_error) {
|
||||
lastCommandTimeRaw = PIOS_DELAY_GetRaw();
|
||||
commandDelayUs = (next_state == MS5611_FSM_CALIBRATION) ? PIOS_MS5611_INIT_DELAY_US : 0;
|
||||
CurrentRead = MS5611_CONVERSION_TYPE_None;
|
||||
next_state = MS5611_FSM_INIT;
|
||||
commandDelayUs = (next_state == MS56XX_FSM_CALIBRATION) ? PIOS_MS56XX_INIT_DELAY_US : 0;
|
||||
CurrentRead = MS56XX_CONVERSION_TYPE_None;
|
||||
next_state = MS56XX_FSM_INIT;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Poll the pressure sensor and return the temperature and pressure. */
|
||||
bool PIOS_MS56xx_Read(float *temperature, float *pressure) {
|
||||
if (PIOS_MS56xx_driver_poll(0)) {
|
||||
*temperature = results.temperature;
|
||||
*pressure = results.sample;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif /* PIOS_INCLUDE_MS5611 */
|
||||
#endif /* PIOS_INCLUDE_MS56XX */
|
||||
|
||||
/**
|
||||
* @}
|
@ -44,8 +44,8 @@ const struct pios_hmc5x83_cfg *PIOS_BOARD_HW_DEFS_GetInternalHMC5x83Cfg(uint32_t
|
||||
#ifdef PIOS_INCLUDE_HMC5X83
|
||||
const struct pios_hmc5x83_cfg *PIOS_BOARD_HW_DEFS_GetExternalHMC5x83Cfg(uint32_t board_revision);
|
||||
#endif
|
||||
#ifdef PIOS_INCLUDE_MS5611
|
||||
const struct pios_ms5611_cfg *PIOS_BOARD_HW_DEFS_GetMS5611Cfg(uint32_t board_revision);
|
||||
#ifdef PIOS_INCLUDE_MS56XX
|
||||
const struct pios_ms56xx_cfg *PIOS_BOARD_HW_DEFS_GetMS56xxCfg(uint32_t board_revision);
|
||||
#endif
|
||||
#ifdef PIOS_INCLUDE_BMP280
|
||||
const struct pios_bmp280_cfg *PIOS_BOARD_HW_DEFS_GetBMP280Cfg(uint32_t board_revision);
|
||||
|
@ -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,37 +28,43 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef PIOS_MS5611_H
|
||||
#define PIOS_MS5611_H
|
||||
#include <pios_sensors.h>
|
||||
/* BMP085 Addresses */
|
||||
#define MS5611_I2C_ADDR 0x77
|
||||
#define MS5611_RESET 0x1E
|
||||
#define MS5611_CALIB_ADDR 0xA2 /* First sample is factory stuff */
|
||||
#define MS5611_CALIB_LEN 16
|
||||
#define MS5611_ADC_READ 0x00
|
||||
#define MS5611_PRES_ADDR 0x40
|
||||
#define MS5611_TEMP_ADDR 0x50
|
||||
#define MS5611_ADC_MSB 0xF6
|
||||
#ifndef PIOS_MS56XX_H
|
||||
#define PIOS_MS56XX_H
|
||||
|
||||
struct pios_ms5611_cfg {
|
||||
uint32_t oversampling;
|
||||
#ifdef PIOS_INCLUDE_MS56XX
|
||||
|
||||
#include <pios_sensors.h>
|
||||
|
||||
enum pios_ms56xx_version {
|
||||
MS56XX_VERSION_5607 = 0,
|
||||
MS56XX_VERSION_5611 = 1,
|
||||
MS56XX_VERSION_5637 = 2,
|
||||
};
|
||||
|
||||
enum pios_ms5611_osr {
|
||||
MS5611_OSR_256 = 0,
|
||||
MS5611_OSR_512 = 2,
|
||||
MS5611_OSR_1024 = 4,
|
||||
MS5611_OSR_2048 = 6,
|
||||
MS5611_OSR_4096 = 8,
|
||||
enum pios_ms56xx_osr {
|
||||
MS56XX_OSR_256 = 0,
|
||||
MS56XX_OSR_512 = 2,
|
||||
MS56XX_OSR_1024 = 4,
|
||||
MS56XX_OSR_2048 = 6,
|
||||
MS56XX_OSR_4096 = 8,
|
||||
// Only supported by the ms5637
|
||||
MS56XX_OSR_8192 = 10
|
||||
};
|
||||
|
||||
struct pios_ms56xx_cfg {
|
||||
uint8_t address;
|
||||
enum pios_ms56xx_version version;
|
||||
enum pios_ms56xx_osr oversampling;
|
||||
};
|
||||
|
||||
/* Public Functions */
|
||||
extern void PIOS_MS5611_Init(const struct pios_ms5611_cfg *cfg, int32_t i2c_device);
|
||||
extern const PIOS_SENSORS_Driver PIOS_MS5611_Driver;
|
||||
void PIOS_MS5611_Register();
|
||||
extern void PIOS_MS56xx_Init(const struct pios_ms56xx_cfg *cfg, int32_t i2c_device);
|
||||
extern void PIOS_MS56xx_Register();
|
||||
extern bool PIOS_MS56xx_Read(float *temperature, float *pressure);
|
||||
|
||||
#endif /* PIOS_MS5611_H */
|
||||
#endif /* PIOS_INCLUDE_MS56XX */
|
||||
|
||||
#endif /* PIOS_MS56XX_H */
|
||||
|
||||
/**
|
||||
* @}
|
@ -88,7 +88,7 @@
|
||||
/* #define PIOS_INCLUDE_HMC5X83 */
|
||||
/* #define PIOS_HMC5883_HAS_GPIOS */
|
||||
/* #define PIOS_INCLUDE_BMP085 */
|
||||
/* #define PIOS_INCLUDE_MS5611 */
|
||||
/* #define PIOS_INCLUDE_MS56XX */
|
||||
/* #define PIOS_INCLUDE_MPXV */
|
||||
/* #define PIOS_INCLUDE_ETASV3 */
|
||||
/* #define PIOS_INCLUDE_HCSR04 */
|
||||
|
@ -88,7 +88,7 @@
|
||||
/* #define PIOS_INCLUDE_HMC5X83 */
|
||||
/* #define PIOS_HMC5883_HAS_GPIOS */
|
||||
/* #define PIOS_INCLUDE_BMP085 */
|
||||
/* #define PIOS_INCLUDE_MS5611 */
|
||||
/* #define PIOS_INCLUDE_MS56XX */
|
||||
/* #define PIOS_INCLUDE_MPXV */
|
||||
/* #define PIOS_INCLUDE_ETASV3 */
|
||||
/* #define PIOS_INCLUDE_HCSR04 */
|
||||
|
@ -1425,16 +1425,18 @@ const struct pios_hmc5x83_cfg *PIOS_BOARD_HW_DEFS_GetExternalHMC5x83Cfg(__attrib
|
||||
/**
|
||||
* Configuration for the MS5611 chip
|
||||
*/
|
||||
#if defined(PIOS_INCLUDE_MS5611)
|
||||
#include "pios_ms5611.h"
|
||||
static const struct pios_ms5611_cfg pios_ms5611_cfg = {
|
||||
.oversampling = MS5611_OSR_512,
|
||||
#if defined(PIOS_INCLUDE_MS56XX)
|
||||
#include "pios_ms56xx.h"
|
||||
static const struct pios_ms56xx_cfg pios_ms56xx_cfg = {
|
||||
.address = 0x77,
|
||||
.version = MS56XX_VERSION_5611,
|
||||
.oversampling = MS56XX_OSR_512,
|
||||
};
|
||||
const struct pios_ms5611_cfg *PIOS_BOARD_HW_DEFS_GetMS5611Cfg(__attribute__((unused)) uint32_t board_revision)
|
||||
const struct pios_ms56xx_cfg *PIOS_BOARD_HW_DEFS_GetMS56xxCfg(__attribute__((unused)) uint32_t board_revision)
|
||||
{
|
||||
return &pios_ms5611_cfg;
|
||||
return &pios_ms56xx_cfg;
|
||||
}
|
||||
#endif /* PIOS_INCLUDE_MS5611 */
|
||||
#endif /* PIOS_INCLUDE_MS56XX */
|
||||
|
||||
|
||||
/**
|
||||
|
@ -89,7 +89,7 @@
|
||||
#define PIOS_INCLUDE_HMC5X83_INTERNAL
|
||||
// #define PIOS_HMC5X83_HAS_GPIOS
|
||||
/* #define PIOS_INCLUDE_BMP085 */
|
||||
// #define PIOS_INCLUDE_MS5611
|
||||
/* #define PIOS_INCLUDE_MS56XX */
|
||||
// #define PIOS_INCLUDE_MPXV
|
||||
// #define PIOS_INCLUDE_ETASV3
|
||||
/* #define PIOS_INCLUDE_HCSR04 */
|
||||
|
@ -86,7 +86,7 @@
|
||||
#define PIOS_INCLUDE_HMC5X83_INTERNAL
|
||||
// #define PIOS_HMC5X83_HAS_GPIOS
|
||||
/* #define PIOS_INCLUDE_BMP085 */
|
||||
/* #define PIOS_INCLUDE_MS5611 */
|
||||
/* #define PIOS_INCLUDE_MS56XX */
|
||||
/* #define PIOS_INCLUDE_MPXV */
|
||||
/* #define PIOS_INCLUDE_ETASV3 */
|
||||
/* #define PIOS_INCLUDE_HCSR04 */
|
||||
|
@ -92,7 +92,7 @@
|
||||
/* #define PIOS_MPU9250_MAG */
|
||||
/* #define PIOS_INCLUDE_BMP280 */
|
||||
/* #define PIOS_INCLUDE_BMP085 */
|
||||
/* #define PIOS_INCLUDE_MS5611 */
|
||||
/* #define PIOS_INCLUDE_MS56XX */
|
||||
/* #define PIOS_INCLUDE_MPXV */
|
||||
/* #define PIOS_INCLUDE_ETASV3 */
|
||||
/* #define PIOS_INCLUDE_HCSR04 */
|
||||
|
@ -84,7 +84,7 @@
|
||||
/* #define PIOS_INCLUDE_HMC5X83 */
|
||||
/* #define PIOS_HMC5883_HAS_GPIOS */
|
||||
/* #define PIOS_INCLUDE_BMP085 */
|
||||
/* #define PIOS_INCLUDE_MS5611 */
|
||||
/* #define PIOS_INCLUDE_MS56XX */
|
||||
/* #define PIOS_INCLUDE_MPXV */
|
||||
/* #define PIOS_INCLUDE_ETASV3 */
|
||||
/* #define PIOS_INCLUDE_HCSR04 */
|
||||
|
@ -84,7 +84,7 @@
|
||||
/* #define PIOS_INCLUDE_HMC5X83 */
|
||||
/* #define PIOS_HMC5X83_HAS_GPIOS */
|
||||
#define PIOS_INCLUDE_BMP085
|
||||
/* #define PIOS_INCLUDE_MS5611 */
|
||||
/* #define PIOS_INCLUDE_MS56XX */
|
||||
/* #define PIOS_INCLUDE_MPXV */
|
||||
/* #define PIOS_INCLUDE_ETASV3 */
|
||||
/* #define PIOS_INCLUDE_HCSR04 */
|
||||
|
@ -92,7 +92,7 @@
|
||||
/* #define PIOS_MPU9250_MAG */
|
||||
/* #define PIOS_INCLUDE_BMP280 */
|
||||
/* #define PIOS_INCLUDE_BMP085 */
|
||||
/* #define PIOS_INCLUDE_MS5611 */
|
||||
/* #define PIOS_INCLUDE_MS56XX */
|
||||
/* #define PIOS_INCLUDE_MPXV */
|
||||
/* #define PIOS_INCLUDE_ETASV3 */
|
||||
/* #define PIOS_INCLUDE_HCSR04 */
|
||||
|
@ -1702,16 +1702,18 @@ const struct pios_hmc5x83_cfg *PIOS_BOARD_HW_DEFS_GetExternalHMC5x83Cfg(__attrib
|
||||
/**
|
||||
* Configuration for the MS5611 chip
|
||||
*/
|
||||
#if defined(PIOS_INCLUDE_MS5611)
|
||||
#include "pios_ms5611.h"
|
||||
static const struct pios_ms5611_cfg pios_ms5611_cfg = {
|
||||
.oversampling = MS5611_OSR_4096,
|
||||
#if defined(PIOS_INCLUDE_MS56XX)
|
||||
#include "pios_ms56xx.h"
|
||||
static const struct pios_ms56xx_cfg pios_ms56xx_cfg = {
|
||||
.address = 0x77,
|
||||
.version = MS56XX_VERSION_5611,
|
||||
.oversampling = MS56XX_OSR_4096
|
||||
};
|
||||
const struct pios_ms5611_cfg *PIOS_BOARD_HW_DEFS_GetMS5611Cfg(__attribute__((unused)) uint32_t board_revision)
|
||||
const struct pios_ms56xx_cfg *PIOS_BOARD_HW_DEFS_GetMS56xxCfg(__attribute__((unused)) uint32_t board_revision)
|
||||
{
|
||||
return &pios_ms5611_cfg;
|
||||
return &pios_ms56xx_cfg;
|
||||
}
|
||||
#endif /* PIOS_INCLUDE_MS5611 */
|
||||
#endif /* PIOS_INCLUDE_MS56XX */
|
||||
|
||||
|
||||
/**
|
||||
|
@ -89,7 +89,7 @@
|
||||
#define PIOS_INCLUDE_HMC5X83_INTERNAL
|
||||
#define PIOS_HMC5X83_HAS_GPIOS
|
||||
/* #define PIOS_INCLUDE_BMP085 */
|
||||
#define PIOS_INCLUDE_MS5611
|
||||
#define PIOS_INCLUDE_MS56XX
|
||||
#define PIOS_INCLUDE_MPXV
|
||||
#define PIOS_INCLUDE_ETASV3
|
||||
#define PIOS_INCLUDE_MS4525DO
|
||||
|
@ -127,7 +127,7 @@ extern uint32_t pios_spi_telem_flash_adapter_id;
|
||||
#define PIOS_I2C_MAX_DEVS 3
|
||||
extern uint32_t pios_i2c_mag_pressure_adapter_id;
|
||||
#define PIOS_I2C_HMC5X83_INTERNAL_ADAPTER (pios_i2c_mag_pressure_adapter_id)
|
||||
#define PIOS_I2C_MS5611_INTERNAL_ADAPTER (pios_i2c_mag_pressure_adapter_id)
|
||||
#define PIOS_I2C_MS56XX_INTERNAL_ADAPTER (pios_i2c_mag_pressure_adapter_id)
|
||||
extern uint32_t pios_i2c_flexiport_adapter_id;
|
||||
#define PIOS_I2C_FLEXI_ADAPTER (pios_i2c_flexiport_adapter_id)
|
||||
#define PIOS_I2C_ETASV3_ADAPTER (PIOS_I2C_FLEXI_ADAPTER)
|
||||
|
@ -996,16 +996,18 @@ const struct pios_hmc5x83_cfg *PIOS_BOARD_HW_DEFS_GetExternalHMC5x83Cfg(__attrib
|
||||
/**
|
||||
* Configuration for the MS5611 chip
|
||||
*/
|
||||
#if defined(PIOS_INCLUDE_MS5611)
|
||||
#include "pios_ms5611.h"
|
||||
static const struct pios_ms5611_cfg pios_ms5611_cfg = {
|
||||
.oversampling = MS5611_OSR_4096,
|
||||
#if defined(PIOS_INCLUDE_MS56XX)
|
||||
#include "pios_ms56xx.h"
|
||||
static const struct pios_ms56xx_cfg pios_ms56xx_cfg = {
|
||||
.address = 0x77,
|
||||
.version = MS56XX_VERSION_5611,
|
||||
.oversampling = MS56XX_OSR_4096,
|
||||
};
|
||||
const struct pios_ms5611_cfg *PIOS_BOARD_HW_DEFS_GetMS5611Cfg(__attribute__((unused)) uint32_t board_revision)
|
||||
const struct pios_ms56xx_cfg *PIOS_BOARD_HW_DEFS_GetMS56xxCfg(__attribute__((unused)) uint32_t board_revision)
|
||||
{
|
||||
return &pios_ms5611_cfg;
|
||||
return &pios_ms56xx_cfg;
|
||||
}
|
||||
#endif /* PIOS_INCLUDE_MS5611 */
|
||||
#endif /* PIOS_INCLUDE_MS56XX */
|
||||
|
||||
/**
|
||||
* Configuration for the MPU9250 chip
|
||||
|
@ -88,7 +88,7 @@
|
||||
#define PIOS_INCLUDE_HMC5X83
|
||||
// #define PIOS_HMC5X83_HAS_GPIOS
|
||||
/* #define PIOS_INCLUDE_BMP085 */
|
||||
#define PIOS_INCLUDE_MS5611
|
||||
#define PIOS_INCLUDE_MS56XX
|
||||
#define PIOS_INCLUDE_MPXV
|
||||
#define PIOS_INCLUDE_ETASV3
|
||||
#define PIOS_INCLUDE_MS4525DO
|
||||
|
@ -123,7 +123,7 @@ extern uint32_t pios_spi_gyro_adapter_id;
|
||||
// ------------------------
|
||||
#define PIOS_I2C_MAX_DEVS 3
|
||||
extern uint32_t pios_i2c_eeprom_pressure_adapter_id;
|
||||
#define PIOS_I2C_MS5611_INTERNAL_ADAPTER (pios_i2c_eeprom_pressure_adapter_id)
|
||||
#define PIOS_I2C_MS56XX_INTERNAL_ADAPTER (pios_i2c_eeprom_pressure_adapter_id)
|
||||
extern uint32_t pios_i2c_flexiport_adapter_id;
|
||||
#define PIOS_I2C_FLEXI_ADAPTER (pios_i2c_flexiport_adapter_id)
|
||||
#define PIOS_I2C_ETASV3_ADAPTER (PIOS_I2C_FLEXI_ADAPTER)
|
||||
|
@ -1754,16 +1754,18 @@ const struct pios_hmc5x83_cfg *PIOS_BOARD_HW_DEFS_GetExternalHMC5x83Cfg(__attrib
|
||||
/**
|
||||
* Configuration for the MS5611 chip
|
||||
*/
|
||||
#if defined(PIOS_INCLUDE_MS5611)
|
||||
#include "pios_ms5611.h"
|
||||
static const struct pios_ms5611_cfg pios_ms5611_cfg = {
|
||||
.oversampling = MS5611_OSR_4096,
|
||||
#if defined(PIOS_INCLUDE_MS56XX)
|
||||
#include "pios_ms56xx.h"
|
||||
static const struct pios_ms56xx_cfg pios_ms56xx_cfg = {
|
||||
.address = 0x77,
|
||||
.version = MS56XX_VERSION_5611,
|
||||
.oversampling = MS56XX_OSR_4096,
|
||||
};
|
||||
const struct pios_ms5611_cfg *PIOS_BOARD_HW_DEFS_GetMS5611Cfg(__attribute__((unused)) uint32_t board_revision)
|
||||
const struct pios_ms56xx_cfg *PIOS_BOARD_HW_DEFS_GetMS56xxCfg(__attribute__((unused)) uint32_t board_revision)
|
||||
{
|
||||
return &pios_ms5611_cfg;
|
||||
return &pios_ms56xx_cfg;
|
||||
}
|
||||
#endif /* PIOS_INCLUDE_MS5611 */
|
||||
#endif /* PIOS_INCLUDE_MS56XX */
|
||||
|
||||
/**
|
||||
* Configuration for the BMA180 chip
|
||||
|
@ -86,7 +86,7 @@
|
||||
#define PIOS_INCLUDE_HMC5X83_INTERNAL
|
||||
#define PIOS_HMC5X83_HAS_GPIOS
|
||||
/* #define PIOS_INCLUDE_BMP085 */
|
||||
#define PIOS_INCLUDE_MS5611
|
||||
#define PIOS_INCLUDE_MS56XX
|
||||
#define PIOS_INCLUDE_MPXV
|
||||
#define PIOS_INCLUDE_ETASV3
|
||||
/* #define PIOS_INCLUDE_HCSR04 */
|
||||
|
@ -108,7 +108,7 @@ extern uint32_t pios_spi_accel_id;
|
||||
extern uint32_t pios_i2c_mag_adapter_id;
|
||||
extern uint32_t pios_i2c_pressure_adapter_id;
|
||||
|
||||
#define PIOS_I2C_MS5611_INTERNAL_ADAPTER (pios_i2c_pressure_adapter_id)
|
||||
#define PIOS_I2C_MS56XX_INTERNAL_ADAPTER (pios_i2c_pressure_adapter_id)
|
||||
#define PIOS_I2C_HMC5X83_INTERNAL_ADAPTER (pios_i2c_mag_adapter_id)
|
||||
|
||||
extern uint32_t pios_i2c_flexiport_adapter_id;
|
||||
|
@ -67,7 +67,7 @@
|
||||
// #define PIOS_INCLUDE_MPU6000
|
||||
// #define PIOS_MPU6000_ACCEL
|
||||
// #define PIOS_INCLUDE_L3GD20
|
||||
// #define PIOS_INCLUDE_MS5611
|
||||
// #define PIOS_INCLUDE_MS56XX
|
||||
// #define PIOS_INCLUDE_HCSR04
|
||||
#define PIOS_FLASH_ON_ACCEL /* true for second revo */
|
||||
|
||||
|
@ -1283,16 +1283,18 @@ const struct pios_hmc5x83_cfg *PIOS_BOARD_HW_DEFS_GetExternalHMC5x83Cfg(__attrib
|
||||
/**
|
||||
* Configuration for the MS5611 chip
|
||||
*/
|
||||
#if defined(PIOS_INCLUDE_MS5611)
|
||||
#include "pios_ms5611.h"
|
||||
static const struct pios_ms5611_cfg pios_ms5611_cfg = {
|
||||
.oversampling = MS5611_OSR_4096,
|
||||
#if defined(PIOS_INCLUDE_MS56XX)
|
||||
#include "pios_ms56xx.h"
|
||||
static const struct pios_ms56xx_cfg pios_ms56xx_cfg = {
|
||||
.address = 0x77,
|
||||
.version = MS56XX_VERSION_5611,
|
||||
.oversampling = MS56XX_OSR_4096,
|
||||
};
|
||||
const struct pios_ms5611_cfg *PIOS_BOARD_HW_DEFS_GetMS5611Cfg(__attribute__((unused)) uint32_t board_revision)
|
||||
const struct pios_ms56xx_cfg *PIOS_BOARD_HW_DEFS_GetMS56xxCfg(__attribute__((unused)) uint32_t board_revision)
|
||||
{
|
||||
return &pios_ms5611_cfg;
|
||||
return &pios_ms56xx_cfg;
|
||||
}
|
||||
#endif /* PIOS_INCLUDE_MS5611 */
|
||||
#endif /* PIOS_INCLUDE_MS56xx */
|
||||
|
||||
/**
|
||||
* Configuration for the MPU9250 chip
|
||||
|
@ -88,7 +88,7 @@
|
||||
#define PIOS_INCLUDE_HMC5X83
|
||||
/* Sparky2 5X83s are all external and thus don't have GPIOs #define PIOS_HMC5X83_HAS_GPIOS */
|
||||
/* #define PIOS_INCLUDE_BMP085 */
|
||||
#define PIOS_INCLUDE_MS5611
|
||||
#define PIOS_INCLUDE_MS56XX
|
||||
#define PIOS_INCLUDE_MPXV
|
||||
#define PIOS_INCLUDE_ETASV3
|
||||
#define PIOS_INCLUDE_MS4525DO
|
||||
|
@ -128,7 +128,7 @@ extern uint32_t pios_spi_gyro_adapter_id;
|
||||
// ------------------------
|
||||
#define PIOS_I2C_MAX_DEVS 3
|
||||
extern uint32_t pios_i2c_pressure_adapter_id;
|
||||
#define PIOS_I2C_MS5611_INTERNAL_ADAPTER (pios_i2c_pressure_adapter_id)
|
||||
#define PIOS_I2C_MS56XX_INTERNAL_ADAPTER (pios_i2c_pressure_adapter_id)
|
||||
#define PIOS_I2C_EXTERNAL_ADAPTER (pios_i2c_pressure_adapter_id)
|
||||
extern uint32_t pios_i2c_flexiport_adapter_id;
|
||||
#define PIOS_I2C_FLEXI_ADAPTER (pios_i2c_flexiport_adapter_id)
|
||||
|
@ -152,16 +152,18 @@ const struct pios_hmc5x83_cfg *PIOS_BOARD_HW_DEFS_GetInternalHMC5x83Cfg(__attrib
|
||||
/**
|
||||
* Configuration for the MS5611 chip
|
||||
*/
|
||||
#if defined(PIOS_INCLUDE_MS5611)
|
||||
#include "pios_ms5611.h"
|
||||
static const struct pios_ms5611_cfg pios_ms5611_cfg = {
|
||||
.oversampling = MS5611_OSR_4096,
|
||||
#if defined(PIOS_INCLUDE_MS56XX)
|
||||
#include "pios_ms56xx.h"
|
||||
static const struct pios_ms56xx_cfg pios_ms56xx_cfg = {
|
||||
.address = 0x77,
|
||||
.version = MS56XX_VERSION_5611,
|
||||
.oversampling = MS56XX_OSR_4096,
|
||||
};
|
||||
const struct pios_ms5611_cfg *PIOS_BOARD_HW_DEFS_GetMS5611Cfg(__attribute__((unused)) uint32_t board_revision)
|
||||
const struct pios_ms56xx_cfg *PIOS_BOARD_HW_DEFS_GetMS56xxCfg(__attribute__((unused)) uint32_t board_revision)
|
||||
{
|
||||
return &pios_ms5611_cfg;
|
||||
return &pios_ms56xx_cfg;
|
||||
}
|
||||
#endif /* PIOS_INCLUDE_MS5611 */
|
||||
#endif /* PIOS_INCLUDE_MS56XX */
|
||||
|
||||
|
||||
/**
|
||||
|
@ -89,7 +89,7 @@
|
||||
#define PIOS_INCLUDE_HMC5X83_INTERNAL
|
||||
#define PIOS_HMC5883_HAS_GPIOS
|
||||
/* #define PIOS_INCLUDE_BMP085 */
|
||||
#define PIOS_INCLUDE_MS5611
|
||||
#define PIOS_INCLUDE_MS56XX
|
||||
/* #define PIOS_INCLUDE_MPXV */
|
||||
/* #define PIOS_INCLUDE_ETASV3 */
|
||||
/* #define PIOS_INCLUDE_HCSR04 */
|
||||
|
@ -106,7 +106,7 @@
|
||||
extern uint32_t pios_i2c_id;
|
||||
#define PIOS_I2C_MAIN_ADAPTER (pios_i2c_id)
|
||||
#define PIOS_I2C_ESC_ADAPTER (pios_i2c_id)
|
||||
#define PIOS_I2C_MS5611_INTERNAL_ADAPTER (pios_i2c_id)
|
||||
#define PIOS_I2C_MS56XX_INTERNAL_ADAPTER (pios_i2c_id)
|
||||
#define PIOS_I2C_HMC5X83_INTERNAL_ADAPTER (pios_i2c_id)
|
||||
#define PIOS_I2C_MPU6000_ADAPTER (pios_i2c_id)
|
||||
#define PIOS_I2C_EXTERNAL_ADAPTER (pios_i2c_id)
|
||||
|
@ -92,7 +92,7 @@
|
||||
#define PIOS_MPU9250_MAG
|
||||
#define PIOS_INCLUDE_BMP280
|
||||
/* #define PIOS_INCLUDE_BMP085 */
|
||||
/* #define PIOS_INCLUDE_MS5611 */
|
||||
/* #define PIOS_INCLUDE_MS56XX */
|
||||
/* #define PIOS_INCLUDE_MPXV */
|
||||
/* #define PIOS_INCLUDE_ETASV3 */
|
||||
/* #define PIOS_INCLUDE_HCSR04 */
|
||||
|
@ -92,7 +92,7 @@
|
||||
/* #define PIOS_MPU9250_MAG */
|
||||
/* #define PIOS_INCLUDE_BMP280 */
|
||||
/* #define PIOS_INCLUDE_BMP085 */
|
||||
/* #define PIOS_INCLUDE_MS5611 */
|
||||
/* #define PIOS_INCLUDE_MS56XX */
|
||||
/* #define PIOS_INCLUDE_MPXV */
|
||||
/* #define PIOS_INCLUDE_ETASV3 */
|
||||
/* #define PIOS_INCLUDE_HCSR04 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user