Sample program for LPS331_SPI library.

Dependencies:   LPS331_SPI mbed

Files at this revision

API Documentation at this revision

Comitter:
ohtsuka
Date:
Thu Jul 28 10:39:28 2016 +0000
Child:
1:a289840e583b
Commit message:
1st commit.

Changed in this revision

LPS331_SPI.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPS331_SPI.lib	Thu Jul 28 10:39:28 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/nyamfg/code/LPS331_I2C/#b74daa677551
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jul 28 10:39:28 2016 +0000
@@ -0,0 +1,40 @@
+/*
+ *  Sample program for LPS331_SPI library.
+ *
+ *  Copyright(c) -2016 Toru OHTSUKA, 
+ *  Released under the MIT License: http://mbed.org/license/mit
+ *
+ *  revision 1.0    07-Jul-2016     1st release.
+ */
+
+#include "mbed.h"
+#include "LPS331_SPI.h"
+
+DigitalOut myled(LED1);
+
+LPS331_SPI press(dp2, dp1, dp6, dp26);
+
+int main() {
+    char whoami;
+    
+    whoami = press.whoami();
+    printf("WHO_AM_I REG. = 0x%X, ", whoami);
+    if(press.isLPS331()) {
+        printf("This sensor is LPS331.\n\n");
+    } else if(press.isLPS25H()) {
+        printf("This sensor is LPS25H.\n\n");
+    } else {
+        printf("Unknown sensor.\n\n");
+    }
+    
+    press.quickStart();
+    while(1) {
+        float pressure;
+        pressure = press.getPressure();
+        printf("pressrue = %f\n", pressure);
+
+        myled = !myled;
+        wait(0.2);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jul 28 10:39:28 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/f9eeca106725
\ No newline at end of file