Test Program for LPS331 I2C Library.

Dependencies:   LPS331_I2C mbed

Files at this revision

API Documentation at this revision

Comitter:
nyamfg
Date:
Mon Oct 21 16:41:09 2013 +0000
Parent:
1:b93a693d9047
Commit message:
Added multibyte read test.; Change data rate.

Changed in this revision

LPS331_I2C.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r b93a693d9047 -r 70ce034cfcfc LPS331_I2C.lib
--- a/LPS331_I2C.lib	Sun Oct 20 15:28:04 2013 +0000
+++ b/LPS331_I2C.lib	Mon Oct 21 16:41:09 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/nyamfg/code/LPS331_I2C/#3fd57444bc65
+http://mbed.org/users/nyamfg/code/LPS331_I2C/#b7d3d6e82049
diff -r b93a693d9047 -r 70ce034cfcfc main.cpp
--- a/main.cpp	Sun Oct 20 15:28:04 2013 +0000
+++ b/main.cpp	Mon Oct 21 16:41:09 2013 +0000
@@ -15,7 +15,7 @@
     }
     
     lps331.setResolution(LPS331_I2C_PRESSURE_AVG_512, LPS331_I2C_TEMP_AVG_128);
-    lps331.setDataRate(LPS331_I2C_DATARATE_1HZ);
+    lps331.setDataRate(LPS331_I2C_DATARATE_7HZ);
     lps331.setActive(true);
     
     pc.printf("LPS331 Register map.\r\n");
@@ -28,6 +28,20 @@
         }
         pc.printf("\r\n");
     }
+    
+    pc.printf("LPS331 Register map(multibyte read test).\r\n");
+    
+    for(int i = 0; i < 8; i++) {
+        char data[16];
+        lps331._read_multibyte(i << 4, data, 16);
+        pc.printf("%02x: ", i);
+        for(int j = 0; j < 16; j++) {
+            pc.printf("%02x ", data[j]);
+        }
+        pc.printf("\r\n");
+    }
+    
+    wait(2.0);
                 
     while(true) {
         float pres, temp;
@@ -35,9 +49,9 @@
         pres = lps331.getPressure();
         temp = lps331.getTemperature();
         
-        pc.printf("Pressure = %4.2f hPa, Temp = %2.2f C.\r\n", pres, temp);
+        pc.printf("%f,%f\r\n", pres, temp);
         
-        wait(1);
+        wait(1/7.0);
     }
 
 }