Library to work with the LDC1000 from Texas Instruments

Dependencies:   FastPWM

Dependents:   LDC1000_test

LDC1000

This library was written to interface to Texas Instruments' LDC1000 in order to perform inductance measurement. This libary needs a SPI peripheral on your mbed device to talk to the LDC1000.

Clock

The LDC1000 needs a high speed clock for its internal frequency counter. In order to provide this clock, the FastPWM library is used. This may change the behaviour of other PWM channels, please be aware of that, and read the FastPWM documentation to understand the implications.

Unsupported

Not supported (yet):

  1. Setting the RpMAX and RpMIN values
  2. Setting the interrupt pin functionality
Revision:
1:a88df80e7664
Parent:
0:90873b4e8330
Child:
2:44b76f6f19d5
--- a/LDC1000.cpp	Sun Apr 05 18:19:12 2015 +0000
+++ b/LDC1000.cpp	Wed Apr 29 14:57:22 2015 +0000
@@ -17,9 +17,11 @@
     _spiport.format(8,3);
     _spiport.frequency(1E6);
     _cs_pin.write(1);
+    wait_us(100);
+    mode(LDC_MODE_ACTIVE);
+    wait_us(10);
     setFrequency(f_external);
     setResponseTime(LDC_RESPONSE_384);
-    mode(LDC_MODE_ACTIVE);
 }
 
 void LDC1000::setOutputPower(LDC_AMPLITUDE amplitude)
@@ -33,6 +35,8 @@
 
 }
 
+
+
 void LDC1000::setResponseTime(LDC_RESPONSE responsetime)
 {
     uint8_t buffer;
@@ -46,6 +50,7 @@
 void LDC1000::setFrequency(float frequency)
 {
     _frequency = frequency;
+    _clock.write(0.5);
     _clock.period(1.0/frequency);
 }
 
@@ -75,7 +80,7 @@
     _spiport.write(address | 0x80); //read flag 
     for(int i=0; i < num_bytes ; i++)
     {
-        _spiport.write(data[i]);
+        data[i] = _spiport.write(0xFF);
     }
     _cs_pin.write(1);
 }
@@ -86,7 +91,7 @@
     _spiport.write(address); 
     for(int i=0; i < num_bytes ; i++)
     {
-        *data = _spiport.write(0xFF);
+        _spiport.write(data[i]);
     }
     _cs_pin.write(1);
 }
\ No newline at end of file