High resolution barometer and altimeter using i2c mode
Fork of ms5611 by
Diff: ms5611.h
- Revision:
- 7:90ee2168baa7
- Parent:
- 6:41c370fa1f7b
- Child:
- 8:461f68bc94f2
diff -r 41c370fa1f7b -r 90ee2168baa7 ms5611.h --- a/ms5611.h Mon Jun 24 19:11:28 2013 +0000 +++ b/ms5611.h Mon Dec 22 23:38:34 2014 +0000 @@ -41,7 +41,10 @@ * #include "mbed.h" * #include "ms5611.h" * - * ms5611 ms(p9, p10); // i2c pins used + * //ms5611 ms(p9, p10); // i2c pins used + * ms5611 ms(p9, p10, ms5611::CSBpin_0); // NEW!! with rev 7. User can set polarity of CSB pin + * //ms5611 ms(p9, p10, ms5611::CSBpin_1); + * * Serial pc(USBTX, USBRX); // local terminal interface * * @@ -74,7 +77,7 @@ //_____ M A C R O S -#define MS5611_ADDR_W 0xEE // Module address write mode +#define MS5611_ADDR_W 0xEE // Module address write mode (CSBpin = 0); #define MS5611_ADDR_R 0xEF // Module address read mode #define MS5611_CMD_RESET 0x1E // ADC reset command #define MS5611_CMD_ADC_READ 0x00 // ADC read command @@ -96,11 +99,27 @@ class ms5611 { public: + enum CSBpolarity { + CSBpin_0, //CSB pin is grounded, I2C address is 0xEE and 0xEF + CSBpin_1, //CSB pin is tied to Vdd, I2C address is 0xEC and 0xED + }; /** Create a MS5611 object using the specified I2C object - * - * @param constructor, - the I2C object to communicate with + * - User fixed I2C address 0xEE, CSB pin = 0 + * - This is the default legacy constructor + * @param sda - mbed I2C interface pin + * @param scl - mbed I2C interface pin */ ms5611(PinName sda, PinName scl); + /** Create a MS5611 object using the specified I2C object + * - User defined use of the CSB pin + * - CSB pin = 0, user set I2C address to 0xEE + * - CSB pin = 1, user set I2C address to 0xEC + * @param sda - mbed I2C interface pin + * @param scl - mbed I2C interface pin + * @param ms5611::CSBpin_0 - CSB pin tied to ground + * @param ms5611::CSBpin_1 - CSB pin tied to VDD + */ + ms5611(PinName sda, PinName scl, CSBpolarity CSBpin); /** Initialize the MS5611 and set up the coefficients * First - reset the MS5611 * Second - load coefficient values from the MS5611 PROM @@ -150,6 +169,8 @@ float getSeaLevelBaroM(float known_alt); private: + char _i2cWAddr; + char _i2cRAddr; int m_i2c_start(bool readMode); void m_i2c_stop(void); unsigned char m_i2c_write(unsigned char data);