Version 3.0: Switching to newer LDC1614 which is placed on the same PCB.

Dependencies:   Bob DS1825 LDC1614 LDC1101 SDFileSystem mbed

Fork of Inductive_Sensor by Bob Giesberts

Revision:
1:22c272515015
Parent:
0:e81b68888268
Child:
2:1a203732fc95
--- a/main.cpp	Thu Dec 10 15:13:45 2015 +0000
+++ b/main.cpp	Sat Dec 12 11:26:35 2015 +0000
@@ -1,5 +1,6 @@
 #include "mbed.h"
 #include "LDC1101.h"
+#include "SDFileSystem.h"
 #include <iostream>
 using namespace std;
 
@@ -27,23 +28,44 @@
     flash(5);
     
 
-    pc.printf("Contact maken met LDC1101...\n");
-    // mosi = PTC6           (PTD2)
-    // miso = PTC7           (PTD3)
-    // sck  = PTC5           (PTD1)
-    // cs   = PTC4           (PTB0)
-    // capacitor = 120E-12   (100E-12)
-    // f_external = 6.5E6    (6000000) 
-    // clock_out = PTA18?    (PTA13)
-    LDC1101 ldc(PTC6, PTC7, PTC5, PTC4, 120E-12, 6500000);
+    // --- Connection to LDC1101
+    pc.printf("Contact maken met LDC1101...");
+    LDC1101 ldc(PTC6, PTC7, PTC5, PTC4, 120E-12, 6000000);  // mosi, miso, sck, cs, capacitor, f_CLKIN
+    pc.printf("success!\n");
+
 
+    // --- Connection to SD card
+    // Enable PTC3
+    DigitalOut sd_pin(PTC3);
+    sd_pin = 1;
+    // Load SD card
+    SDFileSystem SD(PTD6, PTD7, PTD5, PTD4, "sd");  // mosi, miso, sclk, cs, sd_name
+    // something with card detect?
+    // if(PTE0 == 1)
+    mkdir("/sd/mydir", 0777);
+    FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
+    if(fp == NULL) {
+        error("ERROR: Could not open file for write\n");
+    }
+    fprintf(fp, "Start writing the SD card!\r\n");
+    fclose(fp); 
 
     while(1)
     {
+        // feedback with LEDs
         flash(1);
         
+        // Feedback in putty
         pc.printf("%4.0f",ldc.get_raw_l());
         pc.printf(", %f \r\n", 1000000*ldc.getInductance());
+        
+        // Store in SD_card
+        fprintf(fp, "Doet het!\r\n");
+        
         wait_ms(250);
     }
+    
+    // On exit
+    fclose(fp);
+    
 }