aconno acnsensa project for iOS devices with iBeacon packets support.

Dependencies:   LSM9DS1 Si7006A20 aconno_SEGGER_RTT aconno_bsp adc52832_common

Revision:
4:634796e5b8c3
Parent:
3:78ceda8ef565
Child:
5:4807f549aada
--- a/MPL115A1/MPL115A1.cpp	Fri Mar 02 12:37:27 2018 +0000
+++ b/MPL115A1/MPL115A1.cpp	Fri Mar 02 14:32:08 2018 +0000
@@ -1,5 +1,8 @@
 #include "MPL115A1.h"
 
+// These values correspond to the values described here:
+// https://www.nxp.com/docs/en/data-sheet/MPL115A1.pdf
+
 #define a0FracBits  3
 #define b1FracBits  13
 #define b2FracBits  14
@@ -11,7 +14,6 @@
 
 float getA0(uint16_t a0);
 float getB1(uint16_t b1);
-float getC1(uint16_t c1);
 float getC12(uint16_t c12);
 float getPressure();
 
@@ -132,6 +134,7 @@
     wait_ms(1); 
     spi.write(0x8A);        // LSB a0
     a0 |= spi.write(0x00);
+    a0F = getA0(a0);
     wait_ms(1);
     
     spi.write(0x8C);        // MSB b1
@@ -140,6 +143,7 @@
     wait_ms(1);
     spi.write(0x8E);        // LSB b1
     b1 |= spi.write(0x00);
+    b1F = getB1(b1);
     wait_ms(1);
     
     spi.write(0x90);        // MSB b2
@@ -148,6 +152,7 @@
     wait_ms(1);
     spi.write(0x92);        // LSB b2
     b2 |= spi.write(0x00);
+    b2F  = getB2(b2);
     wait_ms(1);
     
     spi.write(0x94);        // MSB c12
@@ -156,6 +161,7 @@
     wait_ms(1);
     spi.write(0x96);        // LSB c12
     c12 |= spi.write(0x00);
+    c12F = getC12(c12);
     wait_ms(1);
     spi.write(0x00);
     cs = 1;
@@ -184,22 +190,8 @@
     spi.write(0x00);
     cs = 1;
     
-    a0F  = getA0(a0);
-    b1F  = getB1(b1);
-    b2F  = getB2(b2);
-    c12F = getC12(c12);
-    
-    /*            
-    float c12x2 = c12F * tadc;
-    float a1F = b1F + c12x2;
-    float a1x1 = a1F * padc;
-    float y1 = a0F + a1x1;
-    float a2x2 = b2F * tadc;
-    pcomp = y1 + a2x2;
-    */
-
     pcomp = a0F + (b1F + c12F * tadc) * padc + b2F * tadc;
-    pressure = pcomp * ((115-50)/(1023.0)) + 52;    // Was + 50
+    pressure = pcomp * ((115-50)/(1023.0)) + 52;
     pressure *= 10;     // Calculate in hPa
     return pressure;
 }