Testé pour projet BTS SN

Dependencies:   MPL115A1 mbed

Fork of MPL115A1_HelloWorld by Christian Dupaty

Revision:
1:3bdc0f29c3ae
Parent:
0:b03929952ce3
--- a/main.cpp	Thu Nov 07 14:12:03 2013 +0000
+++ b/main.cpp	Sat Apr 30 17:07:31 2016 +0000
@@ -1,23 +1,15 @@
-#include "mbed.h"
-#include "mpl115a1.h"
-Serial pc(USBTX,USBRX);
-int main() {
-// Chip must be deselected
-    cs = 1;
- 
-    // Setup the spi for 8 bit data, high steady state clock,
-    // second edge capture, with a 8MHz clock rate
-    spi.format(8,0);
-    spi.frequency(8000000);
-//Chip selscted
-cs=0;
-    while(1) {
-        float pressure_pKa = 0;
-        sdn=1;
-        wait(0.02);
-        pressure_pKa = calculatePressurekPa();
-        pc.printf("Pressure=%d",pressure_pKa);
-        sdn=0;
-        wait(5);
-    }
-}
+#include "mbed.h"
+ #include "MPL115A1.h"
+ 
+SPI spi(SPI_MOSI,SPI_MISO,SPI_SCK);
+MPL115A1 bar(spi, SPI_CS);
+ 
+Serial pc(USBTX, USBRX);
+ 
+int main() {
+    while(1) {
+        wait(10);
+        pc.printf("Pressure is %f\n", bar.readPressure());  // en kPa
+        pc.printf("Temperature is %f\n", bar.readTemperature()); // en degC... temperature non compense
+    }
+}
\ No newline at end of file