Lab 7

Dependencies:   MPL3115A2 mbed

Fork of AltTest2 by CPS_Lab*

Revision:
2:126622942102
Parent:
1:03565a1413e6
Child:
3:93ba3e6cdaf3
--- a/main.cpp	Thu Mar 01 18:18:19 2018 +0000
+++ b/main.cpp	Fri Mar 02 01:07:57 2018 +0000
@@ -19,6 +19,8 @@
     int num_regs = length;  //redundant, but it helps me think
     uint8_t valArray[num_regs];  //the array of register values we'll be returning
     
+    pressure_sensor.readRegs(start, valArray, num_regs - 1);    //populates valArray with register values, one per element, starting at i
+
     if(length == 0)
         length = 45;
     int i = start, end = start + length;     
@@ -30,9 +32,9 @@
         return(-1);
     if (end > 46)
         return(-1);
+        
     for( i = start; i <= end; i++) {
         char name[25];
-        pressure_sensor.readRegs(i, valArray, num_regs - 1);
         switch (i) {
                 case 0x00:
                     strcpy(name,"MPL_STATUS");
@@ -187,7 +189,7 @@
 
 
 int main() {
-    int return_val, start, length;
+    int start, length;
     while (1){
         printf("Enter start: \n\r");
         scanf("%d", &start);
@@ -195,6 +197,7 @@
         scanf("%d", &length);
         printf("Printing registers: \n\r");
         MPL3115A2_reg_print(start, length);
+        wait_ms(500);
     }
-    return (0);        
+    //no return; while(1) never exited       
 } 
\ No newline at end of file