Code supports writing to the SD card as well as working with the Volckens group smartphone apps for the mbed HRM1017

Dependencies:   ADS1115 BLE_API BME280 Calibration CronoDot EEPROM LSM303 MCP40D17 NCP5623BMUTBG SDFileSystem SI1145 STC3100 mbed nRF51822

Fork of UPAS_BLE_and_USB by Volckens Group Sensors

Revision:
2:e596e685eb39
Parent:
1:37babeb68ab9
Child:
3:2d059d88582b
--- a/main.cpp	Sat May 02 22:35:45 2015 +0000
+++ b/main.cpp	Sun May 03 13:23:35 2015 +0000
@@ -8,7 +8,7 @@
 I2C i2c(p22, p20);
 Adafruit_ADS1115 ads(&i2c);
 MCP40D17 DigPot(&i2c);
-//Serial  pc(USBTX, USBRX);
+Serial  pc(USBTX, USBRX);
 DigitalOut blower(p29, 1);
 
 int omronReading;
@@ -16,31 +16,53 @@
 int vBlowerReading;
 int omronDiff;
 int digital_pot_setpoint = 0x3D; //min = 0x7F, max = 0x00
-
+//char filename[] = "/sd/AMSLOG00.txt";
+    
+//SDFileSystem sd(p12, p13, p15, p14, "sd");
 SDFileSystem sd(SPIS_PSELMOSI, SPIS_PSELMISO, SPIS_PSELSCK, SPIS_PSELSS, "sd"); // I believe this matches Todd's pinout, let me know if this doesn't work. (p12, p13, p15, p14)
-
-
+  
 int main()
 {
+
+    // create a new file
+
+ /* for (uint8_t i = 0; i < 100; i++) {
+      filename[6] = i/10 + '0';
+      filename[7] = i%10 + '0';
+      FILE *fp = fopen(filename, "r");
+      if (fp == NULL) {
+      // only open a new file if it doesn't exist
+      FILE *fp = fopen(filename, "w");
+      fclose(fp);
+      break;  // leave the loop!
+    }
+    
+
+  }
+  */
          
     while(1){
-   
+        
     omronReading = ads.readADC_SingleEnded(0, 0xC583); // read channel 0
-    //pc.printf("Omron Reading: %d\r\n", omronReading); // print reading
+    pc.printf("Omron Reading: %d\r\n", omronReading); // print reading
     vInReading = ads.readADC_SingleEnded(1, 0xD583); // read channel 0
     vBlowerReading = ads.readADC_SingleEnded(2, 0xE783); // read channel 0
     omronDiff = ads.readADC_Differential(0x8583); // differential channel 2-3
-    //Mount the filesystem
-   // sd.mount();
-    //Perform a write test
-    //FILE *fp = fopen("/sd/sdtest.txt", "w");
-    //fprintf(fp, "%d,%d,%d,%d\r\n", omronReading,vInReading, vBlowerReading, omronDiff);
-    //fflush(fp);
-   // fclose(fp);
-     //Unmount the filesystem
-    //sd.unmount();
-    wait(5);
-     DigPot.writeRegister(digital_pot_setpoint);
+ 
+      //Mount the filesystem
+    sd.mount();
+    FILE *fp = fopen("/sd/sdtest.txt", "a");
+    fprintf(fp, "%d,%d,%d,%d\r\n", omronReading,vInReading, vBlowerReading, omronDiff);
+    //fprintf(fp, "wff\r\n");
+    fclose(fp);
+    //Unmount the filesystem
+    sd.unmount();
+   
+      wait(5);
+   
+    DigPot.writeRegister(digital_pot_setpoint);
+   
+    
     }
 }