Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
BMP085/BMP085.h@0:feaa05d35ccf, 2012-03-07 (annotated)
- Committer:
- AlexAllen
- Date:
- Wed Mar 07 20:02:35 2012 +0000
- Revision:
- 0:feaa05d35ccf
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| AlexAllen | 0:feaa05d35ccf | 1 | /* |
| AlexAllen | 0:feaa05d35ccf | 2 | * mbed library to use a Bosch Sensortec BMP085 sensor |
| AlexAllen | 0:feaa05d35ccf | 3 | * Copyright (c) 2010 Hiroshi Suga |
| AlexAllen | 0:feaa05d35ccf | 4 | * Released under the MIT License: http://mbed.org/license/mit |
| AlexAllen | 0:feaa05d35ccf | 5 | */ |
| AlexAllen | 0:feaa05d35ccf | 6 | |
| AlexAllen | 0:feaa05d35ccf | 7 | /** @file BMP085.h |
| AlexAllen | 0:feaa05d35ccf | 8 | * @brief mbed library to use a Bosch Sensortec BMP085 sensor |
| AlexAllen | 0:feaa05d35ccf | 9 | * barometric pressure sensor BMP085 (Bosch Sensortec) |
| AlexAllen | 0:feaa05d35ccf | 10 | * interface: I2C digital |
| AlexAllen | 0:feaa05d35ccf | 11 | */ |
| AlexAllen | 0:feaa05d35ccf | 12 | |
| AlexAllen | 0:feaa05d35ccf | 13 | #ifndef BMP085_H |
| AlexAllen | 0:feaa05d35ccf | 14 | #define BMP085_H |
| AlexAllen | 0:feaa05d35ccf | 15 | |
| AlexAllen | 0:feaa05d35ccf | 16 | #include "mbed.h" |
| AlexAllen | 0:feaa05d35ccf | 17 | |
| AlexAllen | 0:feaa05d35ccf | 18 | /** |
| AlexAllen | 0:feaa05d35ccf | 19 | * @brief over sampling setting |
| AlexAllen | 0:feaa05d35ccf | 20 | */ |
| AlexAllen | 0:feaa05d35ccf | 21 | enum BMP085_oss { |
| AlexAllen | 0:feaa05d35ccf | 22 | BMP085_oss1 = 0, ///< ultra low power (1 time) |
| AlexAllen | 0:feaa05d35ccf | 23 | BMP085_oss2 = 1, ///< standard (2 times) |
| AlexAllen | 0:feaa05d35ccf | 24 | BMP085_oss4 = 2, ///< high resolution (4 times) |
| AlexAllen | 0:feaa05d35ccf | 25 | BMP085_oss8 = 3 ///< ultra high resolution (8 times) |
| AlexAllen | 0:feaa05d35ccf | 26 | }; |
| AlexAllen | 0:feaa05d35ccf | 27 | |
| AlexAllen | 0:feaa05d35ccf | 28 | /** |
| AlexAllen | 0:feaa05d35ccf | 29 | * @brief BMP085 class |
| AlexAllen | 0:feaa05d35ccf | 30 | */ |
| AlexAllen | 0:feaa05d35ccf | 31 | class BMP085 : public Base { |
| AlexAllen | 0:feaa05d35ccf | 32 | public: |
| AlexAllen | 0:feaa05d35ccf | 33 | BMP085(PinName p_sda, PinName p_scl, BMP085_oss p_oss = BMP085_oss1); |
| AlexAllen | 0:feaa05d35ccf | 34 | BMP085(I2C& p_i2c, BMP085_oss p_oss = BMP085_oss1); |
| AlexAllen | 0:feaa05d35ccf | 35 | |
| AlexAllen | 0:feaa05d35ccf | 36 | float get_temperature(); |
| AlexAllen | 0:feaa05d35ccf | 37 | float get_pressure(); |
| AlexAllen | 0:feaa05d35ccf | 38 | void update(); |
| AlexAllen | 0:feaa05d35ccf | 39 | |
| AlexAllen | 0:feaa05d35ccf | 40 | protected: |
| AlexAllen | 0:feaa05d35ccf | 41 | void init(BMP085_oss); |
| AlexAllen | 0:feaa05d35ccf | 42 | unsigned short twi_readshort (int, int); |
| AlexAllen | 0:feaa05d35ccf | 43 | unsigned long twi_readlong (int, int); |
| AlexAllen | 0:feaa05d35ccf | 44 | void twi_writechar (int, int, int); |
| AlexAllen | 0:feaa05d35ccf | 45 | |
| AlexAllen | 0:feaa05d35ccf | 46 | I2C i2c; |
| AlexAllen | 0:feaa05d35ccf | 47 | float temperature; |
| AlexAllen | 0:feaa05d35ccf | 48 | float pressure; |
| AlexAllen | 0:feaa05d35ccf | 49 | |
| AlexAllen | 0:feaa05d35ccf | 50 | private: |
| AlexAllen | 0:feaa05d35ccf | 51 | |
| AlexAllen | 0:feaa05d35ccf | 52 | short ac1, ac2, ac3, b1, b2, mb, mc, md, oss; |
| AlexAllen | 0:feaa05d35ccf | 53 | unsigned short ac4, ac5, ac6; |
| AlexAllen | 0:feaa05d35ccf | 54 | }; |
| AlexAllen | 0:feaa05d35ccf | 55 | |
| AlexAllen | 0:feaa05d35ccf | 56 | #endif |