modified to work with juston I2CX library for Nordic BLE, see http://developer.mbed.org/questions/5107/Arch-BLE-I2C-working/#answer5383 esp. the answer by Joris Aerts
Dependents: Seed_Barometer_Sensor_custom_I2C_lib
Fork of BMP085 by
BMP085.h@0:6245372b9179, 2010-10-14 (annotated)
- Committer:
- okini3939
- Date:
- Thu Oct 14 11:28:45 2010 +0000
- Revision:
- 0:6245372b9179
- Child:
- 1:80e4c62baf09
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okini3939 | 0:6245372b9179 | 1 | /* |
okini3939 | 0:6245372b9179 | 2 | * mbed library to use a Bosch Sensortec BMP085 sensor |
okini3939 | 0:6245372b9179 | 3 | * Copyright (c) 2010 Hiroshi Suga |
okini3939 | 0:6245372b9179 | 4 | * Released under the MIT License: http://mbed.org/license/mit |
okini3939 | 0:6245372b9179 | 5 | */ |
okini3939 | 0:6245372b9179 | 6 | |
okini3939 | 0:6245372b9179 | 7 | #ifndef BMP085_H |
okini3939 | 0:6245372b9179 | 8 | #define BMP085_H |
okini3939 | 0:6245372b9179 | 9 | |
okini3939 | 0:6245372b9179 | 10 | #include "mbed.h" |
okini3939 | 0:6245372b9179 | 11 | |
okini3939 | 0:6245372b9179 | 12 | enum BMP085_oss { |
okini3939 | 0:6245372b9179 | 13 | BMP085_oss1 = 0, |
okini3939 | 0:6245372b9179 | 14 | BMP085_oss2 = 1, |
okini3939 | 0:6245372b9179 | 15 | BMP085_oss4 = 2, |
okini3939 | 0:6245372b9179 | 16 | BMP085_oss8 = 3 |
okini3939 | 0:6245372b9179 | 17 | }; |
okini3939 | 0:6245372b9179 | 18 | |
okini3939 | 0:6245372b9179 | 19 | class BMP085 : public Base { |
okini3939 | 0:6245372b9179 | 20 | public: |
okini3939 | 0:6245372b9179 | 21 | BMP085(PinName p_sda, PinName p_scl, BMP085_oss p_oss = BMP085_oss1); |
okini3939 | 0:6245372b9179 | 22 | BMP085(I2C& p_i2c, BMP085_oss p_oss = BMP085_oss1); |
okini3939 | 0:6245372b9179 | 23 | |
okini3939 | 0:6245372b9179 | 24 | float get_temperature(); |
okini3939 | 0:6245372b9179 | 25 | float get_pressure(); |
okini3939 | 0:6245372b9179 | 26 | void update(); |
okini3939 | 0:6245372b9179 | 27 | |
okini3939 | 0:6245372b9179 | 28 | protected: |
okini3939 | 0:6245372b9179 | 29 | void init(BMP085_oss); |
okini3939 | 0:6245372b9179 | 30 | unsigned short twi_readshort (int, int); |
okini3939 | 0:6245372b9179 | 31 | unsigned long twi_readlong (int, int); |
okini3939 | 0:6245372b9179 | 32 | void twi_writechar (int, int, int); |
okini3939 | 0:6245372b9179 | 33 | |
okini3939 | 0:6245372b9179 | 34 | I2C i2c; |
okini3939 | 0:6245372b9179 | 35 | float temperature; |
okini3939 | 0:6245372b9179 | 36 | float pressure; |
okini3939 | 0:6245372b9179 | 37 | |
okini3939 | 0:6245372b9179 | 38 | private: |
okini3939 | 0:6245372b9179 | 39 | |
okini3939 | 0:6245372b9179 | 40 | short ac1, ac2, ac3, b1, b2, mb, mc, md, oss; |
okini3939 | 0:6245372b9179 | 41 | unsigned short ac4, ac5, ac6; |
okini3939 | 0:6245372b9179 | 42 | }; |
okini3939 | 0:6245372b9179 | 43 | |
okini3939 | 0:6245372b9179 | 44 | #endif |