High resolution barometer and altimeter using i2c mode. Adapted to FreeIMU interface

Dependents:   FreeIMU FreeIMU_external_magnetometer FreeIMU

Fork of ms5611 by Kevin Braun

Revision:
8:f3660f819e54
Parent:
7:8545a1d1d1e4
--- a/MS561101BA.h	Sat Nov 02 17:23:33 2013 +0000
+++ b/MS561101BA.h	Sat Nov 09 08:51:15 2013 +0000
@@ -37,7 +37,7 @@
 // registers of the device
 #define MS561101BA_D1 0x40
 #define MS561101BA_D2 0x50
-#define MS561101BA_RESET 0x1E
+//#define MS561101BA_RESET 0x1E
 
 // D1 and D2 result size (bytes)
 #define MS561101BA_D1D2_SIZE 3
@@ -54,30 +54,39 @@
 #define MS561101BA_PROM_REG_COUNT 6 // number of registers in the PROM
 #define MS561101BA_PROM_REG_SIZE 2 // size in bytes of a prom registry.
 
-#define I2C_SDA p28
-#define I2C_SCL p27
-
 class MS561101BA {
   public:
     MS561101BA();
-    MS561101BA(I2C _i2c);
     void init(uint8_t addr);
-    float getPressure(uint8_t OSR);
-    float getTemperature(uint8_t OSR);
-    int32_t getDeltaTemp(uint8_t OSR);
-    uint32_t rawPressure(uint8_t OSR);
-    uint32_t rawTemperature(uint8_t OSR);
+    float getPressure();
+    float getTemperature();
+    int32_t getDeltaTemp();
+    void start_sampling(uint8_t OSR);
+    int rawTemperature();
+    int rawPressure();
     int readPROM();
     void reset();
     uint32_t lastPresConv, lastTempConv;
-  private:
-    I2C i2c;
+    
+    MODI2C i2c;
+    
+    static void samplingthread_stub(void const *p);
+    void samplingthread();
+    Thread _thread;
+    volatile uint32_t conversion;
+    uint8_t _OSR;
+    Semaphore sem;
+    char cobuf[3];
+
     Timer t;
-    void startConversion(uint8_t command);
-    uint32_t getConversion(uint8_t command);
+    void startConversion(char *command);
+    void getConversion();
     uint8_t _addr;
     uint16_t _Cal[MS561101BA_PROM_REG_COUNT];
     uint32_t pressCache, tempCache;
+    
+    char zero;
+    char MS561101BA_RESET;
 };
 
 #endif // MS561101BA_h
\ No newline at end of file