Lucas Lim / Mbed 2 deprecated HSP_Temperature_Barometer_CS3237

Dependencies:   mbed

Committer:
lucaslwl
Date:
Mon Aug 26 08:11:41 2019 +0000
Revision:
22:5c07298d3383
add library folder

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lucaslwl 22:5c07298d3383 1 /*******************************************************************************
lucaslwl 22:5c07298d3383 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
lucaslwl 22:5c07298d3383 3 *
lucaslwl 22:5c07298d3383 4 * Permission is hereby granted, free of charge, to any person obtaining a
lucaslwl 22:5c07298d3383 5 * copy of this software and associated documentation files (the "Software"),
lucaslwl 22:5c07298d3383 6 * to deal in the Software without restriction, including without limitation
lucaslwl 22:5c07298d3383 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
lucaslwl 22:5c07298d3383 8 * and/or sell copies of the Software, and to permit persons to whom the
lucaslwl 22:5c07298d3383 9 * Software is furnished to do so, subject to the following conditions:
lucaslwl 22:5c07298d3383 10 *
lucaslwl 22:5c07298d3383 11 * The above copyright notice and this permission notice shall be included
lucaslwl 22:5c07298d3383 12 * in all copies or substantial portions of the Software.
lucaslwl 22:5c07298d3383 13 *
lucaslwl 22:5c07298d3383 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
lucaslwl 22:5c07298d3383 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
lucaslwl 22:5c07298d3383 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
lucaslwl 22:5c07298d3383 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
lucaslwl 22:5c07298d3383 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
lucaslwl 22:5c07298d3383 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
lucaslwl 22:5c07298d3383 20 * OTHER DEALINGS IN THE SOFTWARE.
lucaslwl 22:5c07298d3383 21 *
lucaslwl 22:5c07298d3383 22 * Except as contained in this notice, the name of Maxim Integrated
lucaslwl 22:5c07298d3383 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
lucaslwl 22:5c07298d3383 24 * Products, Inc. Branding Policy.
lucaslwl 22:5c07298d3383 25 *
lucaslwl 22:5c07298d3383 26 * The mere transfer of this software does not imply any licenses
lucaslwl 22:5c07298d3383 27 * of trade secrets, proprietary technology, copyrights, patents,
lucaslwl 22:5c07298d3383 28 * trademarks, maskwork rights, or any other form of intellectual
lucaslwl 22:5c07298d3383 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
lucaslwl 22:5c07298d3383 30 * ownership rights.
lucaslwl 22:5c07298d3383 31 *******************************************************************************/
lucaslwl 22:5c07298d3383 32 /**
lucaslwl 22:5c07298d3383 33 * Bosch BMP280 Digital Pressure Sensor
lucaslwl 22:5c07298d3383 34 *
lucaslwl 22:5c07298d3383 35 */
lucaslwl 22:5c07298d3383 36
lucaslwl 22:5c07298d3383 37 #ifndef BMP280_H_
lucaslwl 22:5c07298d3383 38 #define BMP280_H_
lucaslwl 22:5c07298d3383 39
lucaslwl 22:5c07298d3383 40 #include "mbed.h"
lucaslwl 22:5c07298d3383 41
lucaslwl 22:5c07298d3383 42 /**
lucaslwl 22:5c07298d3383 43 * @brief Bosch BMP280 Digital Pressure Sensor
lucaslwl 22:5c07298d3383 44 */
lucaslwl 22:5c07298d3383 45 class BMP280 {
lucaslwl 22:5c07298d3383 46
lucaslwl 22:5c07298d3383 47 public:
lucaslwl 22:5c07298d3383 48
lucaslwl 22:5c07298d3383 49 typedef enum { ///< BMP280 Register addresses
lucaslwl 22:5c07298d3383 50
lucaslwl 22:5c07298d3383 51 BMP280_READID = 0x58,
lucaslwl 22:5c07298d3383 52 BMP280_TEMP_XLSB = 0xFC,
lucaslwl 22:5c07298d3383 53 BMP280_TEMP_LSB = 0xFB,
lucaslwl 22:5c07298d3383 54 BMP280_TEMP_MSB = 0xFA,
lucaslwl 22:5c07298d3383 55 BMP280_PRESS_XLSB = 0xF9,
lucaslwl 22:5c07298d3383 56 BMP280_PRESS_LSB = 0xF8,
lucaslwl 22:5c07298d3383 57 BMP280_PRESS_MSB = 0xF7,
lucaslwl 22:5c07298d3383 58 BMP280_CONFIG = 0xF5,
lucaslwl 22:5c07298d3383 59 BMP280_CTRL_MEAS = 0xF4,
lucaslwl 22:5c07298d3383 60 BMP280_STATUS = 0xF3,
lucaslwl 22:5c07298d3383 61 BMP280_RESET = 0xE0,
lucaslwl 22:5c07298d3383 62 BMP280_ID = 0xD0,
lucaslwl 22:5c07298d3383 63 ///< calib25-calib00: 0xA1-0x88
lucaslwl 22:5c07298d3383 64 BMP280_CALIB25 = 0xA1, ///< Beginning address
lucaslwl 22:5c07298d3383 65 BMP280_CALIB00 = 0x88, ///< Ending address
lucaslwl 22:5c07298d3383 66
lucaslwl 22:5c07298d3383 67 BMP280_REGISTER_CHIPID = 0xD0,
lucaslwl 22:5c07298d3383 68 BMP280_REGISTER_VERSION = 0xD1,
lucaslwl 22:5c07298d3383 69 BMP280_REGISTER_SOFTRESET = 0xE0,
lucaslwl 22:5c07298d3383 70 BMP280_REGISTER_CAL26 = 0xE1, // R calibration stored in 0xE1-0xF0
lucaslwl 22:5c07298d3383 71 BMP280_REGISTER_CONTROL = 0xF4,
lucaslwl 22:5c07298d3383 72 BMP280_REGISTER_CONFIG = 0xF5,
lucaslwl 22:5c07298d3383 73 BMP280_REGISTER_PRESSUREDATA = 0xF7,
lucaslwl 22:5c07298d3383 74 BMP280_REGISTER_TEMPDATA = 0xFA,
lucaslwl 22:5c07298d3383 75
lucaslwl 22:5c07298d3383 76 } BMP280_REG_map_t;
lucaslwl 22:5c07298d3383 77
lucaslwl 22:5c07298d3383 78
lucaslwl 22:5c07298d3383 79 /**
lucaslwl 22:5c07298d3383 80 * @brief BMP280 constructor.
lucaslwl 22:5c07298d3383 81 * @param sda mbed pin to use for SDA line of I2C interface.
lucaslwl 22:5c07298d3383 82 * @param scl mbed pin to use for SCL line of I2C interface.
lucaslwl 22:5c07298d3383 83 * @param slaveAddress Slave Address of the device.
lucaslwl 22:5c07298d3383 84 */
lucaslwl 22:5c07298d3383 85 BMP280(PinName sda, PinName scl, int slaveAddress);
lucaslwl 22:5c07298d3383 86
lucaslwl 22:5c07298d3383 87 /**
lucaslwl 22:5c07298d3383 88 * @brief BMP280 constructor.
lucaslwl 22:5c07298d3383 89 * @param i2c I2C object to use.
lucaslwl 22:5c07298d3383 90 * @param slaveAddress Slave Address of the device.
lucaslwl 22:5c07298d3383 91 */
lucaslwl 22:5c07298d3383 92 BMP280(I2C *i2c, int slaveAddress);
lucaslwl 22:5c07298d3383 93
lucaslwl 22:5c07298d3383 94 char loggingEnabled;
lucaslwl 22:5c07298d3383 95 char loggingSampleRate;
lucaslwl 22:5c07298d3383 96
lucaslwl 22:5c07298d3383 97 /**
lucaslwl 22:5c07298d3383 98 * @brief Write a device register
lucaslwl 22:5c07298d3383 99 */
lucaslwl 22:5c07298d3383 100 int writeReg(char reg, char value);
lucaslwl 22:5c07298d3383 101 /**
lucaslwl 22:5c07298d3383 102 * @brief Read a device register
lucaslwl 22:5c07298d3383 103 */
lucaslwl 22:5c07298d3383 104 int readReg(char reg, char *value);
lucaslwl 22:5c07298d3383 105
lucaslwl 22:5c07298d3383 106 ///< @brief CONFIG_REG (0xF5)
lucaslwl 22:5c07298d3383 107 typedef union bmp280_config_reg {
lucaslwl 22:5c07298d3383 108 char all;
lucaslwl 22:5c07298d3383 109 struct {
lucaslwl 22:5c07298d3383 110 char spi3w_en : 1;
lucaslwl 22:5c07298d3383 111 char reserved : 1;
lucaslwl 22:5c07298d3383 112 char filter : 3;
lucaslwl 22:5c07298d3383 113 char t_sb : 3;
lucaslwl 22:5c07298d3383 114 } bit;
lucaslwl 22:5c07298d3383 115 } bmp280_config_t;
lucaslwl 22:5c07298d3383 116
lucaslwl 22:5c07298d3383 117 ///< @brief CTRL_MEAS (0xF4)
lucaslwl 22:5c07298d3383 118 typedef union bmp280_ctrl_meas {
lucaslwl 22:5c07298d3383 119 char all;
lucaslwl 22:5c07298d3383 120 struct {
lucaslwl 22:5c07298d3383 121 char mode : 2;
lucaslwl 22:5c07298d3383 122 char osrs_p : 3;
lucaslwl 22:5c07298d3383 123 char osrs_t : 3;
lucaslwl 22:5c07298d3383 124 } bit;
lucaslwl 22:5c07298d3383 125 } bmp280_ctrl_meas_t;
lucaslwl 22:5c07298d3383 126
lucaslwl 22:5c07298d3383 127 ///< @brief STATUS (0xF3)
lucaslwl 22:5c07298d3383 128 typedef union bmp280_status {
lucaslwl 22:5c07298d3383 129 char all;
lucaslwl 22:5c07298d3383 130 struct {
lucaslwl 22:5c07298d3383 131 char im_update : 1;
lucaslwl 22:5c07298d3383 132 char reserved1 : 2;
lucaslwl 22:5c07298d3383 133 char measuring : 1;
lucaslwl 22:5c07298d3383 134 char reserved2 : 4;
lucaslwl 22:5c07298d3383 135 } bit;
lucaslwl 22:5c07298d3383 136 } bmp280_status_t;
lucaslwl 22:5c07298d3383 137
lucaslwl 22:5c07298d3383 138
lucaslwl 22:5c07298d3383 139 ///< @brief RESET (0xE0)
lucaslwl 22:5c07298d3383 140 char bmp280_reset;
lucaslwl 22:5c07298d3383 141
lucaslwl 22:5c07298d3383 142 ///< @brief ID (0xD0)
lucaslwl 22:5c07298d3383 143 char bmp280_id;
lucaslwl 22:5c07298d3383 144
lucaslwl 22:5c07298d3383 145 typedef enum {
lucaslwl 22:5c07298d3383 146 SKIPPED_P = 0,
lucaslwl 22:5c07298d3383 147 OVERSAMPLING_X1_P = 1,
lucaslwl 22:5c07298d3383 148 OVERSAMPLING_X2_P = 2,
lucaslwl 22:5c07298d3383 149 OVERSAMPLING_X4_P = 3,
lucaslwl 22:5c07298d3383 150 OVERSAMPLING_X8_P = 4,
lucaslwl 22:5c07298d3383 151 OVERSAMPLING_X16_P = 5
lucaslwl 22:5c07298d3383 152 } bmp280_osrs_P_t;
lucaslwl 22:5c07298d3383 153
lucaslwl 22:5c07298d3383 154 typedef enum {
lucaslwl 22:5c07298d3383 155 SKIPPED_T = 0,
lucaslwl 22:5c07298d3383 156 OVERSAMPLING_X1_T = 1,
lucaslwl 22:5c07298d3383 157 OVERSAMPLING_X2_T = 2,
lucaslwl 22:5c07298d3383 158 OVERSAMPLING_X4_T = 3,
lucaslwl 22:5c07298d3383 159 OVERSAMPLING_X8_T = 4,
lucaslwl 22:5c07298d3383 160 OVERSAMPLING_X16_T = 5
lucaslwl 22:5c07298d3383 161 } bmp280_osrs_T_t;
lucaslwl 22:5c07298d3383 162
lucaslwl 22:5c07298d3383 163 typedef enum {
lucaslwl 22:5c07298d3383 164 FILT_OFF = 1,
lucaslwl 22:5c07298d3383 165 FILT_2 = 2,
lucaslwl 22:5c07298d3383 166 FILT_3 = 4,
lucaslwl 22:5c07298d3383 167 FILT_4 = 8,
lucaslwl 22:5c07298d3383 168 FILT_5 = 16
lucaslwl 22:5c07298d3383 169 } bmp280_FILT_t;
lucaslwl 22:5c07298d3383 170
lucaslwl 22:5c07298d3383 171 typedef enum {
lucaslwl 22:5c07298d3383 172 SLEEP_MODE = 0,
lucaslwl 22:5c07298d3383 173 FORCED_MODE = 1,
lucaslwl 22:5c07298d3383 174 NORMAL_MODE = 3
lucaslwl 22:5c07298d3383 175 } bmp280_MODE_t;
lucaslwl 22:5c07298d3383 176
lucaslwl 22:5c07298d3383 177 typedef enum {
lucaslwl 22:5c07298d3383 178 T_0_5 = 0,
lucaslwl 22:5c07298d3383 179 T_62_5 = 1,
lucaslwl 22:5c07298d3383 180 T_125 = 2,
lucaslwl 22:5c07298d3383 181 T_250 = 3,
lucaslwl 22:5c07298d3383 182 T_500 = 4,
lucaslwl 22:5c07298d3383 183 T_1000 = 5,
lucaslwl 22:5c07298d3383 184 T_2000 = 6,
lucaslwl 22:5c07298d3383 185 T_4000 = 7
lucaslwl 22:5c07298d3383 186 } bmp280_TSB_t;
lucaslwl 22:5c07298d3383 187
lucaslwl 22:5c07298d3383 188 ///< @brief calib25... calib00 (0xA1...0x88)
lucaslwl 22:5c07298d3383 189 char bmp280_Calib[26];
lucaslwl 22:5c07298d3383 190
lucaslwl 22:5c07298d3383 191 uint16_t dig_T1; ///< Unique temp coeffs. read from the chip
lucaslwl 22:5c07298d3383 192 int16_t dig_T2;
lucaslwl 22:5c07298d3383 193 int16_t dig_T3;
lucaslwl 22:5c07298d3383 194
lucaslwl 22:5c07298d3383 195 uint16_t dig_P1; ///< Unique Press. coeffs. read from the chip
lucaslwl 22:5c07298d3383 196 int16_t dig_P2;
lucaslwl 22:5c07298d3383 197 int16_t dig_P3;
lucaslwl 22:5c07298d3383 198 int16_t dig_P4;
lucaslwl 22:5c07298d3383 199 int16_t dig_P5;
lucaslwl 22:5c07298d3383 200 int16_t dig_P6;
lucaslwl 22:5c07298d3383 201 int16_t dig_P7;
lucaslwl 22:5c07298d3383 202 int16_t dig_P8;
lucaslwl 22:5c07298d3383 203 int16_t dig_P9;
lucaslwl 22:5c07298d3383 204
lucaslwl 22:5c07298d3383 205 int32_t t_fine; ///< This is calculated int the temperature to be used by the
lucaslwl 22:5c07298d3383 206 ///< pressure
lucaslwl 22:5c07298d3383 207
lucaslwl 22:5c07298d3383 208 int32_t bmp280_rawPress;
lucaslwl 22:5c07298d3383 209 int32_t bmp280_rawTemp;
lucaslwl 22:5c07298d3383 210
lucaslwl 22:5c07298d3383 211 float Temp_degC;
lucaslwl 22:5c07298d3383 212 float Press_Pa;
lucaslwl 22:5c07298d3383 213
lucaslwl 22:5c07298d3383 214 /**
lucaslwl 22:5c07298d3383 215 * @brief BMP280 constructor.
lucaslwl 22:5c07298d3383 216 * @param sda mbed pin to use for SDA line of I2C interface.
lucaslwl 22:5c07298d3383 217 * @param scl mbed pin to use for SCL line of I2C interface.
lucaslwl 22:5c07298d3383 218 */
lucaslwl 22:5c07298d3383 219 BMP280(PinName sda, PinName scl);
lucaslwl 22:5c07298d3383 220
lucaslwl 22:5c07298d3383 221 /**
lucaslwl 22:5c07298d3383 222 * @brief BMP280 constructor.
lucaslwl 22:5c07298d3383 223 * @param i2c I2C object to use.
lucaslwl 22:5c07298d3383 224 */
lucaslwl 22:5c07298d3383 225 BMP280(I2C *i2c);
lucaslwl 22:5c07298d3383 226
lucaslwl 22:5c07298d3383 227 /**
lucaslwl 22:5c07298d3383 228 * @brief BMP280 destructor.
lucaslwl 22:5c07298d3383 229 */
lucaslwl 22:5c07298d3383 230 ~BMP280(void);
lucaslwl 22:5c07298d3383 231
lucaslwl 22:5c07298d3383 232 // Function Prototypes
lucaslwl 22:5c07298d3383 233
lucaslwl 22:5c07298d3383 234 /**
lucaslwl 22:5c07298d3383 235 * @brief This initializes the BMP280
lucaslwl 22:5c07298d3383 236 * @brief The BMP280 has 2 modes. FORCED mode and NORMAL mode. FORCED Mode gives more
lucaslwl 22:5c07298d3383 237 * @brief control to the processor as the processor sends out the Mode to initiate a conversion
lucaslwl 22:5c07298d3383 238 * @brief and a data is sent out then. NORMAL mode is initialized once and it just runs and sends
lucaslwl 22:5c07298d3383 239 * @brief out data at a programmed timed interval. (In this example the main() will set this to Normal
lucaslwl 22:5c07298d3383 240 * @brief function)
lucaslwl 22:5c07298d3383 241 * @param Osrs_p- Pressure oversampling
lucaslwl 22:5c07298d3383 242 * @param Osrs_t- Temperature oversampling
lucaslwl 22:5c07298d3383 243 * @param Filter- Filter Settings
lucaslwl 22:5c07298d3383 244 * @param Mode- Power Modes
lucaslwl 22:5c07298d3383 245 * @param T_sb- Standby time (used with Normal mode)
lucaslwl 22:5c07298d3383 246 * @param dig_T1, dig_T2, dig_T3- Coeffs used for temp conversion - GLOBAL variables (output)
lucaslwl 22:5c07298d3383 247 * @param dig_P1, .... , dig_P9- Coeffs used for press conversion - GLOBAL variables (output)
lucaslwl 22:5c07298d3383 248 * @returns 0-if no error. A non-zero value indicates an error.
lucaslwl 22:5c07298d3383 249 */
lucaslwl 22:5c07298d3383 250 int init(bmp280_osrs_P_t Osrs_p, bmp280_osrs_T_t Osrs_t, bmp280_FILT_t Filter,
lucaslwl 22:5c07298d3383 251 bmp280_MODE_t Mode, bmp280_TSB_t T_sb);
lucaslwl 22:5c07298d3383 252
lucaslwl 22:5c07298d3383 253 /**
lucaslwl 22:5c07298d3383 254 * @brief The BMP280 has 2 modes. FORCED mode and NORMAL mode. FORCED Mode
lucaslwl 22:5c07298d3383 255 * gives more
lucaslwl 22:5c07298d3383 256 * @brief control to the processor as the processor sends out the Mode to
lucaslwl 22:5c07298d3383 257 * initiate a conversion
lucaslwl 22:5c07298d3383 258 * @brief and a data is sent out then. NORMAL mode is initialized once and it
lucaslwl 22:5c07298d3383 259 * just runs and sends
lucaslwl 22:5c07298d3383 260 * @brief out data at a programmed timed interval. (In this example the
lucaslwl 22:5c07298d3383 261 * main() will set this to Normal
lucaslwl 22:5c07298d3383 262 * @brief function)
lucaslwl 22:5c07298d3383 263 * @param *Temp_degC - Pointer to temperature (result in deg C)
lucaslwl 22:5c07298d3383 264 * @param *Press_Pa - Pointer to pressure (resul in Pascal)
lucaslwl 22:5c07298d3383 265 * @returns 0-if no error. A non-zero value indicates an error.
lucaslwl 22:5c07298d3383 266 */
lucaslwl 22:5c07298d3383 267 int ReadCompData(float *Temp_degC, float *Press_Pa);
lucaslwl 22:5c07298d3383 268
lucaslwl 22:5c07298d3383 269 /**
lucaslwl 22:5c07298d3383 270 * @brief This function allows writing to a register.
lucaslwl 22:5c07298d3383 271 * @param reg- Address of the register to write to
lucaslwl 22:5c07298d3383 272 * @param value- Data written to the register
lucaslwl 22:5c07298d3383 273 * @returns 0-if no error. A non-zero value indicates an error.
lucaslwl 22:5c07298d3383 274 */
lucaslwl 22:5c07298d3383 275 int reg_write(BMP280_REG_map_t reg, char value);
lucaslwl 22:5c07298d3383 276
lucaslwl 22:5c07298d3383 277 /**
lucaslwl 22:5c07298d3383 278 * @brief This function allows writing to a register.
lucaslwl 22:5c07298d3383 279 * @params reg- Address of the register to read from (input)
lucaslwl 22:5c07298d3383 280 * @params *value- Pointer to the value read from the register (output)
lucaslwl 22:5c07298d3383 281 * @returns 0-if no error. A non-zero value indicates an error.
lucaslwl 22:5c07298d3383 282 */
lucaslwl 22:5c07298d3383 283 int reg_read(BMP280_REG_map_t reg, char *value, char number);
lucaslwl 22:5c07298d3383 284
lucaslwl 22:5c07298d3383 285 /**
lucaslwl 22:5c07298d3383 286 * @brief Performs a soft reset on the BMP280
lucaslwl 22:5c07298d3383 287 * @param none
lucaslwl 22:5c07298d3383 288 * @returns none
lucaslwl 22:5c07298d3383 289 */
lucaslwl 22:5c07298d3383 290 void Reset(void);
lucaslwl 22:5c07298d3383 291
lucaslwl 22:5c07298d3383 292 /**
lucaslwl 22:5c07298d3383 293 * @brief Detects if the BMP280 is present
lucaslwl 22:5c07298d3383 294 * @param none
lucaslwl 22:5c07298d3383 295 * @returns 1 for found, 0 for not found, -1 for comm error
lucaslwl 22:5c07298d3383 296 */
lucaslwl 22:5c07298d3383 297 int Detect(void);
lucaslwl 22:5c07298d3383 298
lucaslwl 22:5c07298d3383 299 /**
lucaslwl 22:5c07298d3383 300 * @brief Performs calculations on the raw temperature data to convert to
lucaslwl 22:5c07298d3383 301 * @brief temperature in deg C, based on Bosch's algorithm
lucaslwl 22:5c07298d3383 302 * @param Raw Temp ADC value, Global dig_T1, dig_T2, dig_T3
lucaslwl 22:5c07298d3383 303 * @returns The Temperature in deg C
lucaslwl 22:5c07298d3383 304 */
lucaslwl 22:5c07298d3383 305 float compensate_T_float(int32_t adc_T); // returned value Deg C.
lucaslwl 22:5c07298d3383 306
lucaslwl 22:5c07298d3383 307 /**
lucaslwl 22:5c07298d3383 308 * @brief Performs calculations on the raw pressure data to convert to
lucaslwl 22:5c07298d3383 309 * @brief pressure in Pascal, based on Bosch's algorithm
lucaslwl 22:5c07298d3383 310 * @param adc_P Raw Press ADC value, Global dig_P1, dig_P2,..., dig_P9
lucaslwl 22:5c07298d3383 311 * @returns The Pressure in Pascals
lucaslwl 22:5c07298d3383 312 */
lucaslwl 22:5c07298d3383 313 float compensate_P_float(int32_t adc_P); // returned value Pascal.
lucaslwl 22:5c07298d3383 314
lucaslwl 22:5c07298d3383 315 /**
lucaslwl 22:5c07298d3383 316 * @brief Puts the BMP280 in low power Sleep mode
lucaslwl 22:5c07298d3383 317 * @param none
lucaslwl 22:5c07298d3383 318 * @returns 0 if no errors, -1 if error.
lucaslwl 22:5c07298d3383 319 */
lucaslwl 22:5c07298d3383 320 int Sleep(void);
lucaslwl 22:5c07298d3383 321
lucaslwl 22:5c07298d3383 322 /**
lucaslwl 22:5c07298d3383 323 * @brief This reads the raw BMP280 data
lucaslwl 22:5c07298d3383 324 * @param *bmp280_rawData- array of raw output data
lucaslwl 22:5c07298d3383 325 * @returns 0-if no error. A non-zero value indicates an error.
lucaslwl 22:5c07298d3383 326 *
lucaslwl 22:5c07298d3383 327 */
lucaslwl 22:5c07298d3383 328 int ReadCompDataRaw(char *bmp280_rawData);
lucaslwl 22:5c07298d3383 329 /**
lucaslwl 22:5c07298d3383 330 * @brief This reads the raw BMP280 data uses the Bosch algorithm to get the
lucaslwl 22:5c07298d3383 331 * data
lucaslwl 22:5c07298d3383 332 * @brief in float, then the float gets converted to an String
lucaslwl 22:5c07298d3383 333 * @param *bmp280_rawData- array of raw output data
lucaslwl 22:5c07298d3383 334 * @returns 0-if no error. A non-zero value indicates an error.
lucaslwl 22:5c07298d3383 335 *
lucaslwl 22:5c07298d3383 336 */
lucaslwl 22:5c07298d3383 337 int ReadCompDataRaw2(char *bmp280_rawData);
lucaslwl 22:5c07298d3383 338 /**
lucaslwl 22:5c07298d3383 339 * @brief This converts the raw BMP280 data to couble based on Bosch's
lucaslwl 22:5c07298d3383 340 * algorithm
lucaslwl 22:5c07298d3383 341 * @param *bmp280_rawData- array of raw input data
lucaslwl 22:5c07298d3383 342 * @param *Temp_degC- pointer to output, Temp value in deg C
lucaslwl 22:5c07298d3383 343 * @param *Press_Pa- pointer to output, Press value in Pascals
lucaslwl 22:5c07298d3383 344 * @returns 0-if no error. A non-zero value indicates an error.
lucaslwl 22:5c07298d3383 345 *
lucaslwl 22:5c07298d3383 346 */
lucaslwl 22:5c07298d3383 347 void ToFloat(char *bmp280_rawData, float *Temp_degC, float *Press_Pa);
lucaslwl 22:5c07298d3383 348 /**
lucaslwl 22:5c07298d3383 349 * @brief converts to Farenhite from Centigrade
lucaslwl 22:5c07298d3383 350 * @param temperature in Centigrade
lucaslwl 22:5c07298d3383 351 * @returns temperature value in Farenhite
lucaslwl 22:5c07298d3383 352 */
lucaslwl 22:5c07298d3383 353 float ToFahrenheit(float temperature);
lucaslwl 22:5c07298d3383 354
lucaslwl 22:5c07298d3383 355 /**
lucaslwl 22:5c07298d3383 356 * @brief Reads a unique ID from the register
lucaslwl 22:5c07298d3383 357 * @param none
lucaslwl 22:5c07298d3383 358 * @returns The correct id value which is 0x58
lucaslwl 22:5c07298d3383 359 */
lucaslwl 22:5c07298d3383 360 int ReadId(void);
lucaslwl 22:5c07298d3383 361
lucaslwl 22:5c07298d3383 362 private:
lucaslwl 22:5c07298d3383 363 /**
lucaslwl 22:5c07298d3383 364 * @brief I2C pointer
lucaslwl 22:5c07298d3383 365 */
lucaslwl 22:5c07298d3383 366 I2C *i2c;
lucaslwl 22:5c07298d3383 367 /**
lucaslwl 22:5c07298d3383 368 * @brief Is this object the owner of the I2C object
lucaslwl 22:5c07298d3383 369 */
lucaslwl 22:5c07298d3383 370 bool isOwner;
lucaslwl 22:5c07298d3383 371 /**
lucaslwl 22:5c07298d3383 372 * @brief Device slave address
lucaslwl 22:5c07298d3383 373 */
lucaslwl 22:5c07298d3383 374 int slaveAddress;
lucaslwl 22:5c07298d3383 375 };
lucaslwl 22:5c07298d3383 376
lucaslwl 22:5c07298d3383 377 #endif // BMP280_H_
lucaslwl 22:5c07298d3383 378