Digital Pressure Sensor

Committer:
mcm
Date:
Tue Sep 11 11:35:00 2018 +0000
Revision:
3:60816c745222
Parent:
2:3a52d110213a
The driver was completed and tested ( NUCLEO-L152RE ), it works as expected

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mcm 1:d001f2e0ad2c 1 /**
mcm 1:d001f2e0ad2c 2 * @brief BMP180.h
mcm 1:d001f2e0ad2c 3 * @details Digital Pressure Sensor.
mcm 1:d001f2e0ad2c 4 * Header file.
mcm 1:d001f2e0ad2c 5 *
mcm 1:d001f2e0ad2c 6 *
mcm 1:d001f2e0ad2c 7 * @return N/A
mcm 1:d001f2e0ad2c 8 *
mcm 1:d001f2e0ad2c 9 * @author Manuel Caballero
mcm 1:d001f2e0ad2c 10 * @date 11/September/2018
mcm 1:d001f2e0ad2c 11 * @version 11/September/2018 The ORIGIN
mcm 1:d001f2e0ad2c 12 * @pre N/A
mcm 1:d001f2e0ad2c 13 * @warning N/A
mcm 1:d001f2e0ad2c 14 * @pre This code belongs to Nimbus Centre ( http://www.nimbus.cit.ie ).
mcm 1:d001f2e0ad2c 15 */
mcm 1:d001f2e0ad2c 16 #ifndef BMP180_H_
mcm 1:d001f2e0ad2c 17 #define BMP180_H_
mcm 1:d001f2e0ad2c 18
mcm 1:d001f2e0ad2c 19 #include "mbed.h"
mcm 1:d001f2e0ad2c 20
mcm 1:d001f2e0ad2c 21
mcm 1:d001f2e0ad2c 22 /**
mcm 1:d001f2e0ad2c 23 Example:
mcm 1:d001f2e0ad2c 24
mcm 1:d001f2e0ad2c 25 @code
mcm 3:60816c745222 26 #include "mbed.h"
mcm 3:60816c745222 27 #include "BMP180.h"
mcm 1:d001f2e0ad2c 28
mcm 3:60816c745222 29 BMP180 myBMP180 ( I2C_SDA, I2C_SCL, BMP180::BMP180_ADDRESS, 400000 );
mcm 3:60816c745222 30 Serial pc ( USBTX, USBRX ); // tx, rx
mcm 3:60816c745222 31
mcm 3:60816c745222 32 DigitalOut myled ( LED1 );
mcm 3:60816c745222 33 Ticker newAction;
mcm 3:60816c745222 34
mcm 3:60816c745222 35
mcm 3:60816c745222 36 // @brief Constants.
mcm 3:60816c745222 37 //
mcm 3:60816c745222 38
mcm 3:60816c745222 39
mcm 3:60816c745222 40 // @brief Variables.
mcm 3:60816c745222 41 //
mcm 3:60816c745222 42 volatile uint32_t myState; // State that indicates when to perform an ADC sample
mcm 3:60816c745222 43
mcm 3:60816c745222 44
mcm 3:60816c745222 45 //
mcm 3:60816c745222 46 // @brief FUNCTION PROTOTYPES
mcm 3:60816c745222 47 //
mcm 3:60816c745222 48 void changeDATA ( void );
mcm 3:60816c745222 49
mcm 3:60816c745222 50
mcm 3:60816c745222 51 // @brief FUNCTION FOR APPLICATION MAIN ENTRY.
mcm 3:60816c745222 52 //
mcm 3:60816c745222 53 int main()
mcm 3:60816c745222 54 {
mcm 3:60816c745222 55 uint32_t aux;
mcm 3:60816c745222 56 BMP180::BMP180_chip_id_data_t myBMP180_ChipID;
mcm 3:60816c745222 57 BMP180::BMP180_temperature_data_t myBMP180_TemperatureData;
mcm 3:60816c745222 58 BMP180::BMP180_pressure_data_t myBMP180_PressureData;
mcm 3:60816c745222 59 BMP180::BMP180_calibration_data_t myBMP180_Calibration_Data;
mcm 3:60816c745222 60 BMP180::BMP180_uncompensated_data_t myBMP180_Uncompensated_Data;
mcm 3:60816c745222 61
mcm 3:60816c745222 62 pc.baud ( 115200 );
mcm 3:60816c745222 63
mcm 3:60816c745222 64
mcm 3:60816c745222 65 myled = 1;
mcm 3:60816c745222 66 wait(3);
mcm 3:60816c745222 67 myled = 0;
mcm 3:60816c745222 68
mcm 3:60816c745222 69 // Get the chip-id
mcm 3:60816c745222 70 aux = myBMP180.BMP180_GetID ( &myBMP180_ChipID );
mcm 3:60816c745222 71 pc.printf( "Chip-ID: %d\r\n", myBMP180_ChipID.id );
mcm 3:60816c745222 72
mcm 3:60816c745222 73 // Get calibration data
mcm 3:60816c745222 74 aux = myBMP180.BMP180_Get_Cal_Param ( &myBMP180_Calibration_Data );
mcm 3:60816c745222 75 pc.printf( "AC1: %d, AC2: %d, AC3: %d, AC4: %d, AC5: %d, AC6: %d, B1: %d, B2: %d, MB: %d, MC: %d, MD: %d\r\n", myBMP180_Calibration_Data.ac1, myBMP180_Calibration_Data.ac2,
mcm 3:60816c745222 76 myBMP180_Calibration_Data.ac3, myBMP180_Calibration_Data.ac4, myBMP180_Calibration_Data.ac5, myBMP180_Calibration_Data.ac6, myBMP180_Calibration_Data.b1, myBMP180_Calibration_Data.b2,
mcm 3:60816c745222 77 myBMP180_Calibration_Data.mb, myBMP180_Calibration_Data.mc, myBMP180_Calibration_Data.md );
mcm 3:60816c745222 78
mcm 3:60816c745222 79
mcm 3:60816c745222 80
mcm 3:60816c745222 81 myState = 0UL; // Reset the variable
mcm 3:60816c745222 82 newAction.attach( &changeDATA, 2 ); // the address of the function to be attached ( changeDATA ) and the interval ( 2s )
mcm 3:60816c745222 83
mcm 3:60816c745222 84 // Let the callbacks take care of everything
mcm 3:60816c745222 85 while(1) {
mcm 3:60816c745222 86 sleep();
mcm 3:60816c745222 87
mcm 3:60816c745222 88 if ( myState == 1UL ) {
mcm 3:60816c745222 89 myled = 1U;
mcm 3:60816c745222 90
mcm 3:60816c745222 91 // Get uncompensated temperature
mcm 3:60816c745222 92 aux = myBMP180.BMP180_Get_UT ( &myBMP180_Uncompensated_Data );
mcm 3:60816c745222 93
mcm 3:60816c745222 94 // Get uncompensated pressure, Resolution: Standard
mcm 3:60816c745222 95 aux = myBMP180.BMP180_Get_UP ( BMP180::PRESSURE_STANDARD_MODE, &myBMP180_Uncompensated_Data );
mcm 3:60816c745222 96
mcm 3:60816c745222 97 // Calculate the true temperature
mcm 3:60816c745222 98 myBMP180_TemperatureData = myBMP180.BMP180_Get_Temperature ( myBMP180_Calibration_Data, myBMP180_Uncompensated_Data );
mcm 3:60816c745222 99
mcm 3:60816c745222 100 // Calculate the true pressure
mcm 3:60816c745222 101 myBMP180_PressureData = myBMP180.BMP180_Get_CalPressure ( myBMP180_Calibration_Data, myBMP180_TemperatureData, BMP180::PRESSURE_STANDARD_MODE, myBMP180_Uncompensated_Data );
mcm 3:60816c745222 102
mcm 3:60816c745222 103 // Transmit result through the UART
mcm 3:60816c745222 104 pc.printf ( "Temperature: %0.1f C | Pressure: %ld Pa\r\n", ( 0.1f * myBMP180_TemperatureData.temp ), myBMP180_PressureData.press );
mcm 3:60816c745222 105
mcm 3:60816c745222 106
mcm 3:60816c745222 107 // Reset the variables
mcm 3:60816c745222 108 myState = 0UL;
mcm 3:60816c745222 109 myled = 0U;
mcm 3:60816c745222 110 }
mcm 3:60816c745222 111 }
mcm 3:60816c745222 112 }
mcm 3:60816c745222 113
mcm 3:60816c745222 114
mcm 3:60816c745222 115 //
mcm 3:60816c745222 116 // @brief changeDATA ( void )
mcm 3:60816c745222 117 //
mcm 3:60816c745222 118 // @details It changes myState variable
mcm 3:60816c745222 119 //
mcm 3:60816c745222 120 // @param[in] N/A
mcm 3:60816c745222 121 //
mcm 3:60816c745222 122 // @param[out] N/A.
mcm 3:60816c745222 123 //
mcm 3:60816c745222 124 //
mcm 3:60816c745222 125 // @return N/A..
mcm 3:60816c745222 126 //
mcm 3:60816c745222 127 //
mcm 3:60816c745222 128 // @author Manuel Caballero
mcm 3:60816c745222 129 // @date 11/September/2018
mcm 3:60816c745222 130 // @version 11/September/2018 The ORIGIN
mcm 3:60816c745222 131 // @pre N/A
mcm 3:60816c745222 132 // @warning N/A.
mcm 3:60816c745222 133 //
mcm 3:60816c745222 134 void changeDATA ( void )
mcm 3:60816c745222 135 {
mcm 3:60816c745222 136 myState = 1UL;
mcm 3:60816c745222 137 }
mcm 1:d001f2e0ad2c 138 @endcode
mcm 1:d001f2e0ad2c 139 */
mcm 1:d001f2e0ad2c 140
mcm 1:d001f2e0ad2c 141
mcm 1:d001f2e0ad2c 142 /*!
mcm 2:3a52d110213a 143 Library for the BMP180 Digital Pressure Sensor.
mcm 1:d001f2e0ad2c 144 */
mcm 1:d001f2e0ad2c 145 class BMP180
mcm 1:d001f2e0ad2c 146 {
mcm 1:d001f2e0ad2c 147 public:
mcm 1:d001f2e0ad2c 148 /**
mcm 1:d001f2e0ad2c 149 * @brief DEFAULT ADDRESS
mcm 1:d001f2e0ad2c 150 */
mcm 1:d001f2e0ad2c 151 typedef enum {
mcm 1:d001f2e0ad2c 152 BMP180_ADDRESS = ( 0b1110111 << 1U ) /*!< BMP180 I2C Address */
mcm 1:d001f2e0ad2c 153 } BMP180_address_t;
mcm 1:d001f2e0ad2c 154
mcm 1:d001f2e0ad2c 155
mcm 1:d001f2e0ad2c 156
mcm 1:d001f2e0ad2c 157 /**
mcm 1:d001f2e0ad2c 158 * @brief CALIBRATION COEFFICIENTS
mcm 1:d001f2e0ad2c 159 */
mcm 1:d001f2e0ad2c 160 typedef enum {
mcm 1:d001f2e0ad2c 161 BMP180_AC1_MSB = 0xAA, /*!< MSB AC1 coefficient */
mcm 1:d001f2e0ad2c 162 BMP180_AC1_LSB = 0xAB, /*!< LSB AC1 coefficient */
mcm 1:d001f2e0ad2c 163 BMP180_AC2_MSB = 0xAC, /*!< MSB AC2 coefficient */
mcm 1:d001f2e0ad2c 164 BMP180_AC2_LSB = 0xAD, /*!< LSB AC2 coefficient */
mcm 1:d001f2e0ad2c 165 BMP180_AC3_MSB = 0xAE, /*!< MSB AC3 coefficient */
mcm 1:d001f2e0ad2c 166 BMP180_AC3_LSB = 0xAF, /*!< LSB AC3 coefficient */
mcm 1:d001f2e0ad2c 167 BMP180_AC4_MSB = 0xB0, /*!< MSB AC4 coefficient */
mcm 1:d001f2e0ad2c 168 BMP180_AC4_LSB = 0xB1, /*!< LSB AC4 coefficient */
mcm 1:d001f2e0ad2c 169 BMP180_AC5_MSB = 0xB2, /*!< MSB AC5 coefficient */
mcm 1:d001f2e0ad2c 170 BMP180_AC5_LSB = 0xB3, /*!< LSB AC5 coefficient */
mcm 1:d001f2e0ad2c 171 BMP180_AC6_MSB = 0xB4, /*!< MSB AC6 coefficient */
mcm 1:d001f2e0ad2c 172 BMP180_AC6_LSB = 0xB5, /*!< LSB AC6 coefficient */
mcm 1:d001f2e0ad2c 173 BMP180_B1_MSB = 0xB6, /*!< MSB B1 coefficient */
mcm 1:d001f2e0ad2c 174 BMP180_B1_LSB = 0xB7, /*!< LSB B1 coefficient */
mcm 1:d001f2e0ad2c 175 BMP180_B2_MSB = 0xB8, /*!< MSB B2 coefficient */
mcm 1:d001f2e0ad2c 176 BMP180_B2_LSB = 0xB9, /*!< LSB B2 coefficient */
mcm 1:d001f2e0ad2c 177 BMP180_MB_MSB = 0xBA, /*!< MSB MB coefficient */
mcm 1:d001f2e0ad2c 178 BMP180_MB_LSB = 0xBB, /*!< LSB MB coefficient */
mcm 1:d001f2e0ad2c 179 BMP180_MC_MSB = 0xBC, /*!< MSB MC coefficient */
mcm 1:d001f2e0ad2c 180 BMP180_MC_LSB = 0xBD, /*!< LSB MC coefficient */
mcm 1:d001f2e0ad2c 181 BMP180_MD_MSB = 0xBE, /*!< MSB MD coefficient */
mcm 1:d001f2e0ad2c 182 BMP180_MD_LSB = 0xBF /*!< LSB MD coefficient */
mcm 1:d001f2e0ad2c 183 } BMP180_calibration_coefficients_t;
mcm 1:d001f2e0ad2c 184
mcm 1:d001f2e0ad2c 185
mcm 1:d001f2e0ad2c 186
mcm 1:d001f2e0ad2c 187 /**
mcm 1:d001f2e0ad2c 188 * @brief REGISTERS MAP
mcm 1:d001f2e0ad2c 189 */
mcm 1:d001f2e0ad2c 190 typedef enum {
mcm 1:d001f2e0ad2c 191 BMP180_OUT_XLSB = 0xF8, /*!< ADC OUT XLSB | Reset: 0x00 */
mcm 1:d001f2e0ad2c 192 BMP180_OUT_LSB = 0xF7, /*!< ADC OUT MSB | Reset: 0x00 */
mcm 1:d001f2e0ad2c 193 BMP180_OUT_MSB = 0xF6, /*!< ADC OUT LSB | Reset: 0x80 */
mcm 1:d001f2e0ad2c 194 BMP180_CTRL_MEAS = 0xF4, /*!< Measurement control ( Control register ) | Reset: 0x00 */
mcm 1:d001f2e0ad2c 195 BMP180_SOFT = 0xE0, /*!< Software reset | Reset: 0x00 */
mcm 1:d001f2e0ad2c 196 BMP180_ID = 0xD0 /*!< Chip-ID | Reset: 0x55 */
mcm 1:d001f2e0ad2c 197 } BMP180_registers_map_t;
mcm 1:d001f2e0ad2c 198
mcm 1:d001f2e0ad2c 199
mcm 1:d001f2e0ad2c 200
mcm 1:d001f2e0ad2c 201 /* MEASUREMENT CONTROL */
mcm 1:d001f2e0ad2c 202 /**
mcm 1:d001f2e0ad2c 203 * @brief START OF CONVERSION ( SCO, BIT<5> )
mcm 1:d001f2e0ad2c 204 */
mcm 1:d001f2e0ad2c 205 /*
mcm 1:d001f2e0ad2c 206 NOTE: The value of this bit stays '1' during conversion and is reset to '0' after conversion is complete ( data registers
mcm 1:d001f2e0ad2c 207 are filled ).
mcm 1:d001f2e0ad2c 208 */
mcm 1:d001f2e0ad2c 209 typedef enum {
mcm 1:d001f2e0ad2c 210 CTRL_MEAS_SCO_MASK = ( 1U << 5U ), /*!< SCO Mask */
mcm 1:d001f2e0ad2c 211 CTRL_MEAS_SCO_CONVERSION_IN_PROGRESS = ( 1U << 5U ), /*!< SCO conversion in progress */
mcm 1:d001f2e0ad2c 212 CTRL_MEAS_SCO_CONVERSION_COMPLETED = ( 0U << 5U ) /*!< SCO conversion is complete */
mcm 1:d001f2e0ad2c 213 } BMP180_sco_t;
mcm 1:d001f2e0ad2c 214
mcm 1:d001f2e0ad2c 215
mcm 1:d001f2e0ad2c 216
mcm 1:d001f2e0ad2c 217 /**
mcm 1:d001f2e0ad2c 218 * @brief CONTROLS THE OVERSAMPLING RATIO OF THE PRESSURE MEASUREMENT ( OSS, BIT<7:6> )
mcm 1:d001f2e0ad2c 219 */
mcm 1:d001f2e0ad2c 220 typedef enum {
mcm 1:d001f2e0ad2c 221 CTRL_MEAS_OSS_MASK = ( 0b11 << 6U ), /*!< OSS Mask */
mcm 1:d001f2e0ad2c 222 CTRL_MEAS_OSS_OVERSAMPLING_SINGLE = ( 0b00 << 6U ), /*!< OSS oversampling ratio: single */
mcm 1:d001f2e0ad2c 223 CTRL_MEAS_OSS_OVERSAMPLING_2_TIMES = ( 0b01 << 6U ), /*!< OSS oversampling ratio: 2 times */
mcm 1:d001f2e0ad2c 224 CTRL_MEAS_OSS_OVERSAMPLING_4_TIMES = ( 0b10 << 6U ), /*!< OSS oversampling ratio: 4 times */
mcm 1:d001f2e0ad2c 225 CTRL_MEAS_OSS_OVERSAMPLING_8_TIMES = ( 0b11 << 6U ) /*!< OSS oversampling ratio: 8 times */
mcm 1:d001f2e0ad2c 226 } BMP180_oss_t;
mcm 1:d001f2e0ad2c 227
mcm 1:d001f2e0ad2c 228
mcm 1:d001f2e0ad2c 229
mcm 1:d001f2e0ad2c 230 /* SOFT RESET */
mcm 1:d001f2e0ad2c 231 /**
mcm 1:d001f2e0ad2c 232 * @brief SOFT RESET
mcm 1:d001f2e0ad2c 233 */
mcm 1:d001f2e0ad2c 234 typedef enum {
mcm 1:d001f2e0ad2c 235 SOFT_SOFT_RESET = 0xB6 /*!< It will perform the same sequence as power on reset */
mcm 1:d001f2e0ad2c 236 } BMP180_soft_reset_t;
mcm 1:d001f2e0ad2c 237
mcm 1:d001f2e0ad2c 238
mcm 1:d001f2e0ad2c 239
mcm 1:d001f2e0ad2c 240 /* ID */
mcm 1:d001f2e0ad2c 241 /**
mcm 1:d001f2e0ad2c 242 * @brief CHIP-ID
mcm 1:d001f2e0ad2c 243 */
mcm 1:d001f2e0ad2c 244 typedef enum {
mcm 1:d001f2e0ad2c 245 ID_CHIP_ID = 0x55 /*!< Fixed value */
mcm 1:d001f2e0ad2c 246 } BMP180_chip_id_t;
mcm 1:d001f2e0ad2c 247
mcm 1:d001f2e0ad2c 248
mcm 1:d001f2e0ad2c 249
mcm 1:d001f2e0ad2c 250 /*
mcm 1:d001f2e0ad2c 251 AUXILIAR REGISTERS
mcm 1:d001f2e0ad2c 252
mcm 1:d001f2e0ad2c 253 NOTE: These definitions are for better understanding in order to use the driver
mcm 1:d001f2e0ad2c 254 */
mcm 1:d001f2e0ad2c 255 /**
mcm 1:d001f2e0ad2c 256 * @brief COMMANDS
mcm 1:d001f2e0ad2c 257 */
mcm 1:d001f2e0ad2c 258 typedef enum {
mcm 1:d001f2e0ad2c 259 BMP180_TRIGGER_TEMPERATURE = 0x2E, /*!< It triggers a new temperature measurement */
mcm 1:d001f2e0ad2c 260 BMP180_TRIGGER_PRESSURE = 0x34 /*!< It triggers a new pressure measurement */
mcm 1:d001f2e0ad2c 261 } BMP180_commands_t;
mcm 1:d001f2e0ad2c 262
mcm 1:d001f2e0ad2c 263
mcm 1:d001f2e0ad2c 264
mcm 1:d001f2e0ad2c 265 /**
mcm 1:d001f2e0ad2c 266 * @brief PRESSURE
mcm 1:d001f2e0ad2c 267 */
mcm 1:d001f2e0ad2c 268 typedef enum {
mcm 1:d001f2e0ad2c 269 PRESSURE_ULTRA_LOW_POWER_MODE = CTRL_MEAS_OSS_OVERSAMPLING_SINGLE, /*!< OSS oversampling ratio: single */
mcm 1:d001f2e0ad2c 270 PRESSURE_STANDARD_MODE = CTRL_MEAS_OSS_OVERSAMPLING_2_TIMES, /*!< OSS oversampling ratio: 2 times */
mcm 1:d001f2e0ad2c 271 PRESSURE_HIGH_RESOLUTION_MODE = CTRL_MEAS_OSS_OVERSAMPLING_4_TIMES, /*!< OSS oversampling ratio: 4 times */
mcm 1:d001f2e0ad2c 272 PRESSURE_ULTRA_HIGH_RES_MODE = CTRL_MEAS_OSS_OVERSAMPLING_8_TIMES /*!< OSS oversampling ratio: 8 times */
mcm 1:d001f2e0ad2c 273 } BMP180_pressure_resolution_t;
mcm 1:d001f2e0ad2c 274
mcm 1:d001f2e0ad2c 275
mcm 1:d001f2e0ad2c 276
mcm 1:d001f2e0ad2c 277
mcm 1:d001f2e0ad2c 278
mcm 1:d001f2e0ad2c 279 #ifndef BMP180_VECTOR_STRUCT_H
mcm 1:d001f2e0ad2c 280 #define BMP180_VECTOR_STRUCT_H
mcm 1:d001f2e0ad2c 281 /* Calibration data */
mcm 1:d001f2e0ad2c 282 typedef struct {
mcm 1:d001f2e0ad2c 283 int16_t ac1;
mcm 1:d001f2e0ad2c 284 int16_t ac2;
mcm 1:d001f2e0ad2c 285 int16_t ac3;
mcm 1:d001f2e0ad2c 286 uint16_t ac4;
mcm 1:d001f2e0ad2c 287 uint16_t ac5;
mcm 1:d001f2e0ad2c 288 uint16_t ac6;
mcm 1:d001f2e0ad2c 289
mcm 1:d001f2e0ad2c 290 int16_t b1;
mcm 1:d001f2e0ad2c 291 int16_t b2;
mcm 1:d001f2e0ad2c 292
mcm 1:d001f2e0ad2c 293 int16_t mb;
mcm 1:d001f2e0ad2c 294 int16_t mc;
mcm 1:d001f2e0ad2c 295 int16_t md;
mcm 1:d001f2e0ad2c 296 } BMP180_calibration_data_t;
mcm 1:d001f2e0ad2c 297
mcm 1:d001f2e0ad2c 298
mcm 1:d001f2e0ad2c 299 /* Uncompensated data */
mcm 1:d001f2e0ad2c 300 typedef struct {
mcm 1:d001f2e0ad2c 301 int32_t ut;
mcm 1:d001f2e0ad2c 302 int32_t up;
mcm 1:d001f2e0ad2c 303 } BMP180_uncompensated_data_t;
mcm 1:d001f2e0ad2c 304
mcm 1:d001f2e0ad2c 305
mcm 1:d001f2e0ad2c 306 /* Data */
mcm 1:d001f2e0ad2c 307 typedef struct {
mcm 1:d001f2e0ad2c 308 int32_t b5;
mcm 1:d001f2e0ad2c 309
mcm 1:d001f2e0ad2c 310 int32_t temp;
mcm 1:d001f2e0ad2c 311 } BMP180_temperature_data_t;
mcm 1:d001f2e0ad2c 312
mcm 1:d001f2e0ad2c 313 typedef struct {
mcm 1:d001f2e0ad2c 314 int32_t press;
mcm 1:d001f2e0ad2c 315 } BMP180_pressure_data_t;
mcm 1:d001f2e0ad2c 316
mcm 1:d001f2e0ad2c 317 typedef struct {
mcm 1:d001f2e0ad2c 318 uint8_t id;
mcm 1:d001f2e0ad2c 319 } BMP180_chip_id_data_t;
mcm 1:d001f2e0ad2c 320 #endif
mcm 1:d001f2e0ad2c 321
mcm 1:d001f2e0ad2c 322
mcm 1:d001f2e0ad2c 323 /**
mcm 1:d001f2e0ad2c 324 * @brief INTERNAL CONSTANTS
mcm 1:d001f2e0ad2c 325 */
mcm 1:d001f2e0ad2c 326 typedef enum {
mcm 1:d001f2e0ad2c 327 BMP180_SUCCESS = 0,
mcm 1:d001f2e0ad2c 328 BMP180_FAILURE = 1,
mcm 1:d001f2e0ad2c 329 I2C_SUCCESS = 0 /*!< I2C communication was fine */
mcm 1:d001f2e0ad2c 330 } BMP180_status_t;
mcm 1:d001f2e0ad2c 331
mcm 1:d001f2e0ad2c 332
mcm 1:d001f2e0ad2c 333
mcm 1:d001f2e0ad2c 334
mcm 1:d001f2e0ad2c 335 /** Create an BMP180 object connected to the specified I2C pins.
mcm 1:d001f2e0ad2c 336 *
mcm 1:d001f2e0ad2c 337 * @param sda I2C data pin
mcm 1:d001f2e0ad2c 338 * @param scl I2C clock pin
mcm 1:d001f2e0ad2c 339 * @param addr I2C slave address
mcm 1:d001f2e0ad2c 340 * @param freq I2C frequency in Hz.
mcm 1:d001f2e0ad2c 341 */
mcm 1:d001f2e0ad2c 342 BMP180 ( PinName sda, PinName scl, uint32_t addr, uint32_t freq );
mcm 1:d001f2e0ad2c 343
mcm 1:d001f2e0ad2c 344 /** Delete BMP180 object.
mcm 1:d001f2e0ad2c 345 */
mcm 1:d001f2e0ad2c 346 ~BMP180();
mcm 1:d001f2e0ad2c 347
mcm 1:d001f2e0ad2c 348 /** It performs a soft reset.
mcm 1:d001f2e0ad2c 349 */
mcm 1:d001f2e0ad2c 350 BMP180_status_t BMP180_SoftReset ( void );
mcm 1:d001f2e0ad2c 351
mcm 1:d001f2e0ad2c 352 /** It gets the chip-ID.
mcm 1:d001f2e0ad2c 353 */
mcm 1:d001f2e0ad2c 354 BMP180_status_t BMP180_GetID ( BMP180_chip_id_data_t* myID );
mcm 1:d001f2e0ad2c 355
mcm 1:d001f2e0ad2c 356 /** It reads the calibration data.
mcm 1:d001f2e0ad2c 357 */
mcm 1:d001f2e0ad2c 358 BMP180_status_t BMP180_Get_Cal_Param ( BMP180_calibration_data_t* myCalibrationData );
mcm 1:d001f2e0ad2c 359
mcm 1:d001f2e0ad2c 360 /** It reads uncompensated temperature value.
mcm 1:d001f2e0ad2c 361 */
mcm 1:d001f2e0ad2c 362 BMP180_status_t BMP180_Get_UT ( BMP180_uncompensated_data_t* myUT );
mcm 1:d001f2e0ad2c 363
mcm 1:d001f2e0ad2c 364 /** It reads uncompensated pressure value.
mcm 1:d001f2e0ad2c 365 */
mcm 1:d001f2e0ad2c 366 BMP180_status_t BMP180_Get_UP ( BMP180_pressure_resolution_t myPressureResolutionMode, BMP180_uncompensated_data_t* myUP );
mcm 1:d001f2e0ad2c 367
mcm 1:d001f2e0ad2c 368 /** It calculates true temperature.
mcm 1:d001f2e0ad2c 369 */
mcm 1:d001f2e0ad2c 370 BMP180_temperature_data_t BMP180_Get_Temperature ( BMP180_calibration_data_t myCalibrationData, BMP180_uncompensated_data_t myUT );
mcm 1:d001f2e0ad2c 371
mcm 1:d001f2e0ad2c 372 /** It calculates true pressure.
mcm 1:d001f2e0ad2c 373 */
mcm 1:d001f2e0ad2c 374 BMP180_pressure_data_t BMP180_Get_CalPressure ( BMP180_calibration_data_t myCalibrationData, BMP180_temperature_data_t myB5, BMP180_pressure_resolution_t myPressureResolutionMode, BMP180_uncompensated_data_t myUP );
mcm 1:d001f2e0ad2c 375
mcm 1:d001f2e0ad2c 376
mcm 1:d001f2e0ad2c 377 private:
mcm 1:d001f2e0ad2c 378 I2C _i2c;
mcm 1:d001f2e0ad2c 379 uint32_t _BMP180_Addr;
mcm 1:d001f2e0ad2c 380 };
mcm 1:d001f2e0ad2c 381
mcm 1:d001f2e0ad2c 382 #endif /* BMP180_H */