Hello world for bm1383glv on mbed classic. Sets up treshold interrupts and makes measurements. Depends on rohm-sensor-hal and rohm-bm1383-glv.

Dependencies:   mbed rohm-bm1383-glv rohm-sensor-hal

Hello world for mbed classic + Rohm BM1383 glv barometer sensor.

Files at this revision

API Documentation at this revision

Comitter:
MikkoZ
Date:
Tue Apr 12 13:13:41 2016 +0000
Parent:
0:9fb407c1232e
Commit message:
Refactored main program

Changed in this revision

main_classic.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 9fb407c1232e -r 6f7979f79aa4 main_classic.cpp
--- a/main_classic.cpp	Tue Apr 12 12:56:38 2016 +0000
+++ b/main_classic.cpp	Tue Apr 12 13:13:41 2016 +0000
@@ -40,7 +40,7 @@
   }
  
     
-void use_treshold_interrupts_to_find_treshold_matching_current_pressure(){
+void bm1383_init_and_setup(){
     pc.printf("\nBM1383 library test program.\n\r");
     I2CCommonBegin();
 
@@ -56,36 +56,35 @@
     //bm1383_disable_interrupt_pullup();  //Pullup doesn't work on Japan-shield? Int line stays low(triggered).
     bm1383_enable_treshold_interrupts();
     bm1383_clear_interrupt();
-    
-    while(1) {
-        float pressure;
-        static uint16_t treshold = 1000;
-      
-        pc.printf("\nStart meas. - ");
-    
-        bm1383_set_high_treshold(treshold);
-        pc.printf("Treshold: %d \n\r", treshold);
-    
-        bm1383_start_measurement_oneshot();
+}
     
-        wait(0.5);
-        //waitActiveLowInterrupt(INTPIN);
-        printTreshodRegStatus();
-        
-        pressure = bm1383_read_pressure();
-        pc.printf("Pressure: %f\n\r", pressure);
-    
-        pc.printf("Clear int command\n\r");
-        bm1383_clear_interrupt();
-        //waitActiveLowInterruptClear(INTPIN);
-    
-        treshold = treshold + 1000;    
-    
-    }
+void bm1383_read_previous_measurement_and_start_new_one(){
+    float pressure;
+    static uint16_t treshold = 0;
+
+    //waitActiveLowInterrupt(INTPIN);
+
+    pressure = bm1383_read_pressure();
+    pc.printf("Pressure: %f\n\r", pressure);
+
+    printTreshodRegStatus();
+    pc.printf("Clear int command\n\r");
+    pc.printf("\r\n");
+    bm1383_clear_interrupt();
+    //waitActiveLowInterruptClear(INTPIN);
+
+    treshold = treshold + 1000;    
+    pc.printf("Treshold: %d \n\r", treshold);
+    pc.printf("Start meas. - ");
+    bm1383_set_high_treshold(treshold);
+    bm1383_start_measurement_oneshot();
 }
 
 
 int main() {
-    use_treshold_interrupts_to_find_treshold_matching_current_pressure();
+    while(1){
+        bm1383_read_previous_measurement_and_start_new_one();
+        wait(0.5);
+        }
     }