Library to communicate with LDC1614

Dependencies:   SHTx

Dependents:   Inductive_Sensor_3

Fork of LDC1101 by Bob Giesberts

Revision:
26:1ef9172cd355
Parent:
25:ae111662ee03
Child:
27:05dd145c7997
--- a/LDC1101.cpp	Tue Feb 16 15:54:59 2016 +0000
+++ b/LDC1101.cpp	Wed Mar 30 12:00:10 2016 +0000
@@ -30,7 +30,62 @@
     init();
 }
 
-void LDC1101::func_mode(LDC_MODE mode) { writeSPI((uint8_t *)(&mode), 0x0B); wait_ms(0.8); }
+LDC1101::~LDC1101()
+{
+    // THERE IS A LEAK HERE!!!
+    // _sd_enable is connected to both the SD card and the LDC1101
+    // this line should put 0.0 V on the SD card and the LDC1101
+    // but in reality there still is 0.8 V on both the SD card and the LDC1101
+    
+    
+    // For all SPI communication pinouts:
+    // 1) Create a new handle to access the pinout
+    // 2) Set it to 0 V
+    // 3) delete and remove the class
+    
+    // SPI communication with the SD card --> THIS SHOULD BE PART OF THE SDFileSystem CLASS!!!
+    DigitalOut *sdP2 = new DigitalOut(PTD4);
+        sdP2->write(0);
+        delete sdP2;
+        sdP2 = NULL;// SPI: cs
+    DigitalOut *sdP3 = new DigitalOut(PTD6);
+        sdP3->write(0);
+        delete sdP3;
+        sdP3 = NULL;// SPI: mosi
+    DigitalOut *sdP5 = new DigitalOut(PTD5);
+        sdP5->write(0);
+        delete sdP5;
+        sdP5 = NULL;// SPI: sck
+    DigitalOut *sdP7 = new DigitalOut(PTD7);
+        sdP7->write(0);
+        delete sdP7;
+        sdP7 = NULL;// SPI: miso
+    
+    // SPI communication with the LDC1101    
+    DigitalOut *senP2 = new DigitalOut(PTC7);
+        senP2->write(0);
+        delete senP2;
+        senP2 = NULL; // SPI: miso
+    DigitalOut *senP3 = new DigitalOut(PTC5);
+        senP3->write(0);
+        delete senP3;
+        senP3 = NULL; // SPI: sck
+    DigitalOut *senP4 = new DigitalOut(PTC6);
+        senP4->write(0);
+        delete senP4;
+        senP4 = NULL; // SPI: mosi
+    DigitalOut *senP5 = new DigitalOut(PTC4);
+        senP5->write(0);
+        delete senP5;
+        senP5 = NULL; // SPI: cs
+}
+
+
+void LDC1101::func_mode(LDC_MODE mode)
+{ 
+    writeSPI((uint8_t *)(&mode), 0x0B);
+    wait_ms(0.8);
+}
 
 void LDC1101::sleep(void)
 { 
@@ -38,6 +93,7 @@
     func_mode( LDC_MODE_SHUTDOWN );
     suicide( this );
 }
+
 void LDC1101::wakeup(void) { 
     /* start toggling the clock input on the CLKIN pin */ 
     init();