High resolution barometer and altimeter using i2c mode
Fork of ms5611 by
Diff: ms5611.h
- Revision:
- 11:e0417b67a4b5
- Parent:
- 8:461f68bc94f2
- Child:
- 12:af100556f99e
diff -r 44e5b491a88c -r e0417b67a4b5 ms5611.h --- a/ms5611.h Tue Dec 01 17:23:12 2015 +0000 +++ b/ms5611.h Thu Dec 03 19:47:10 2015 +0000 @@ -3,12 +3,8 @@ #include "mbed.h" -#if(defined(TARGET_KL25Z) )//|| defined(TARGET_K64F)) - - #define MS5611i2cLOWLEVEL 1 //if the use of low-level I2C routines is needed - #warning "MS5611 using low level I2C routines" - -#endif +//#define MS5611i2cLOWLEVEL 1 //if the use of low-level I2C routines is needed +//#warning "MS5611 using low level I2C routines" #define SEA_PRESS 1013.25 //default sea level pressure level in mb #define KNOWNALT 327.0 //default known altitude, 5200 Franklin Dr., 94588 @@ -175,20 +171,23 @@ float getSeaLevelBaroM(float known_alt); private: - char _i2cWAddr; - char _i2cRAddr; +#if not defined MS5611i2cLOWLEVEL + char cobuf[3]; +#endif + uint8_t _i2cWAddr; + uint8_t _i2cRAddr; int m_i2c_start(bool readMode); - void m_i2c_stop(void); - unsigned char m_i2c_write(unsigned char data); - unsigned char m_i2c_readAck(void); - unsigned char m_i2c_readNak(void); - void m_i2c_send(char cmd); + void m_i2c_stop(); + uint8_t m_i2c_write(uint8_t data); + uint8_t m_i2c_readAck(); + uint8_t m_i2c_readNak(); + void m_i2c_send(uint8_t cmd); void loadCoefs(); - unsigned long cmd_adc(char cmd); - unsigned int cmd_prom(char coef_num); - unsigned char crc4(unsigned n_prom[]); + uint64_t cmd_adc(uint8_t cmd); + uint32_t cmd_prom(uint8_t coef_num); + uint8_t crc4(uint32_t n_prom[]); void calcPT(); - unsigned int PTbuffer[8]; // calibration coefficients + uint32_t PTbuffer[8]; // calibration coefficients protected: I2C _i2c;