123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 |
- #ifndef BMP085_H
- #define BMP085_H
- #include "hal_barometer.h"
- #include "hal_thermometer.h"
- #define EX_BMP085_VERSION "1.0.1"
- #define EX_BMP085_MAJOR 1
- #define EX_BMP085_MINOR 0
- #define EX_BMP085_PATCH 1
- #define BMP085_BARO_NUMBER_OF_AXES 1U
- #define BMP085_P_RES 0.01
- #define BMP085_THERMO_NUMBER_OF_AXES 1U
- #define BMP085_T_RES 0.1
- #define BMP085_AD_CR 0xF4
- #define BMP085_AD_T_DR_MSB 0xF6
- #define BMP085_AD_T_DR_LSB 0xF7
- #define BMP085_AD_P_DR_MSB 0xF6
- #define BMP085_AD_P_DR_LSB 0xF7
- #define BMP085_AD_P_DR_XLSB 0xF8
- #define BMP085_AD_CC_AC1_MSB 0xAA
- #define BMP085_AD_CC_AC1_LSB 0xAB
- #define BMP085_AD_CC_AC2_MSB 0xAC
- #define BMP085_AD_CC_AC2_LSB 0xAD
- #define BMP085_AD_CC_AC3_MSB 0xAE
- #define BMP085_AD_CC_AC3_LSB 0xAF
- #define BMP085_AD_CC_AC4_MSB 0xB0
- #define BMP085_AD_CC_AC4_LSB 0xB1
- #define BMP085_AD_CC_AC5_MSB 0xB2
- #define BMP085_AD_CC_AC5_LSB 0xB3
- #define BMP085_AD_CC_AC6_MSB 0xB4
- #define BMP085_AD_CC_AC6_LSB 0xB5
- #define BMP085_AD_CC_B1_MSB 0xB6
- #define BMP085_AD_CC_B1_LSB 0xB7
- #define BMP085_AD_CC_B2_MSB 0xB8
- #define BMP085_AD_CC_B2_LSB 0xB9
- #define BMP085_AD_CC_MB_MSB 0xBA
- #define BMP085_AD_CC_MB_LSB 0xBB
- #define BMP085_AD_CC_MC_MSB 0xBC
- #define BMP085_AD_CC_MC_LSB 0xBD
- #define BMP085_AD_CC_MD_MSB 0xBE
- #define BMP085_AD_CC_MD_LSB 0xBF
- #if !defined(BMP085_USE_I2C) || defined(__DOXYGEN__)
- #define BMP085_USE_I2C TRUE
- #endif
- #if !defined(BMP085_USE_ADVANCED) || defined(__DOXYGEN__)
- #define BMP085_USE_ADVANCED TRUE
- #endif
- #if !defined(BMP085_SHARED_I2C) || defined(__DOXYGEN__)
- #define BMP085_SHARED_I2C FALSE
- #endif
- #if !HAL_USE_I2C
- #error "BMP085_USE_I2C requires HAL_USE_I2C"
- #endif
- #if BMP085_SHARED_I2C && !I2C_USE_MUTUAL_EXCLUSION
- #error "BMP085_SHARED_I2C requires I2C_USE_MUTUAL_EXCLUSION"
- #endif
- typedef enum {
- BMP085_BARO_CT_LOW = 0x05,
- BMP085_BARO_CT_STD = 0x18,
- BMP085_BARO_CT_HR = 0x0E,
- BMP085_BARO_CT_LUHR = 0x1A
- } bmp085_baro_ct_t;
- typedef enum {
- BMP085_BARO_MODE_LOW = 0x00,
- BMP085_BARO_MODE_STD = 0x01,
- BMP085_BARO_MODE_HR = 0x02,
- BMP085_BARO_MODE_LUHR = 0x03
- } bmp085_baro_mode_t;
- typedef enum {
- BMP085_BARO_OSS_0 = 0x00,
- BMP085_BARO_OSS_1 = 0x01,
- BMP085_BARO_OSS_2 = 0x02,
- BMP085_BARO_OSS_3 = 0x04
- }bmp085_baro_oss_t;
- typedef struct {
- int16_t ac1;
- int16_t ac2;
- int16_t ac3;
- int16_t b1;
- int16_t b2;
- int16_t mb;
- int16_t mc;
- int16_t md;
- uint16_t ac4;
- uint16_t ac5;
- uint16_t ac6;
- int32_t b5;
- } bmp085_cd_t;
- typedef enum {
- BMP085_THERMO_CT_LOW = 0x05,
- BMP085_THERMO_CT_STD = 0x18,
- BMP085_THERMO_CT_HR = 0x0E,
- BMP085_THERMO_CT_LUHR = 0x1A
- } bmp085_thermo_ct_t;
- typedef enum {
- BMP085_UNINIT = 0,
- BMP085_STOP = 1,
- BMP085_READY = 2
- } bmp085_state_t;
- typedef struct {
- #if BMP085_USE_I2C || defined(__DOXYGEN__)
-
- I2CDriver *i2cp;
-
- const I2CConfig *i2ccfg;
- #endif
-
- float* sensitivity;
-
- float* bias;
-
- float* outputdatarate;
- #if BMP085_USE_ADVANCED || defined(__DOXYGEN__)
-
- bmp085_baro_ct_t bct;
-
- bmp085_baro_mode_t mode;
-
- bmp085_baro_oss_t oss;
-
- bmp085_thermo_ct_t tct;
- #endif
- } BMP085Config;
- typedef struct BMP085Driver BMP085Driver;
- #define _bmp085_baro_methods \
- _base_barometer_methods
- #define _bmp085_thermo_methods \
- _base_thermometer_methods
- struct BMP085BAROVMT {
- _bmp085_baro_methods
- };
- struct BMP085THERMOVMT {
- _bmp085_thermo_methods
- };
- #define _bmp085_data \
- _base_barometer_data \
- _base_thermometer_data \
- \
- bmp085_state_t state; \
- \
- const BMP085Config *config; \
- \
- float barosensitivity[BMP085_BARO_NUMBER_OF_AXES]; \
- \
- int32_t barobias[BMP085_BARO_NUMBER_OF_AXES]; \
- \
- float thermosensitivity[BMP085_THERMO_NUMBER_OF_AXES]; \
- \
- int32_t thermobias[BMP085_THERMO_NUMBER_OF_AXES]; \
- \
- bmp085_cd_t calibrationdata;
- struct BMP085Driver {
-
- const struct BaseSensorVMT *vmt_basesensor;
-
- const struct BaseBarometerVMT *vmt_basebarometer;
-
- const struct BaseThermometerVMT *vmt_basethermometer;
- _bmp085_data;
- };
- #ifdef __cplusplus
- extern "C" {
- #endif
- void bmp085ObjectInit(BMP085Driver *devp);
- void bmp085Start(BMP085Driver *devp, const BMP085Config *config);
- void bmp085Stop(BMP085Driver *devp);
- #ifdef __cplusplus
- }
- #endif
- #endif
|