Library to work with the LDC1000 from Texas Instruments
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):
- Setting the RpMAX and RpMIN values
- Setting the interrupt pin functionality
Diff: LDC1000.cpp
- Revision:
- 5:98d4fd07734a
- Parent:
- 4:62ebb87678f8
- Child:
- 6:5b6ad98d6436
diff -r 62ebb87678f8 -r 98d4fd07734a LDC1000.cpp --- a/LDC1000.cpp Tue May 19 14:10:01 2015 +0000 +++ b/LDC1000.cpp Tue May 26 14:34:05 2015 +0000 @@ -18,11 +18,30 @@ _spiport.frequency(1E6); _cs_pin.write(1); wait_us(100); - mode(LDC_MODE_ACTIVE); + mode(LDC_MODE_STANDBY); + setFrequency(f_external); + wait(0.1); + setOutputPower(LDC_AMPLITUDE_4V); wait_us(10); - setFrequency(f_external); setResponseTime(LDC_RESPONSE_384); setWatchdog(5000); + +// Write comando's like in EVM start log: + /* writeSPIregister(0x0B,0x00); + writeSPIregister(0x01,0x0E); + writeSPIregister(0x02,0x3C); + writeSPIregister(0x03,0x15); + writeSPIregister(0x04,0x17); + writeSPIregister(0x05,0x00); + writeSPIregister(0x06,0x50); + writeSPIregister(0x07,0x14); + writeSPIregister(0x08,0xC0); + writeSPIregister(0x09,0x12); + writeSPIregister(0x0A,0x04); +// writeSPIregister(0x0C,0x01); + writeSPIregister(0x0B,0x01);*/ + + mode(LDC_MODE_ACTIVE); } void LDC1000::setOutputPower(LDC_AMPLITUDE amplitude) @@ -50,7 +69,7 @@ _responsetime = responsetime; readSPI(&buffer, 0x04); buffer &= 0xF8; //clear responsetime bits - buffer |= responsetime & 0xF8; + buffer |= responsetime & 0x07; writeSPI(&buffer,0x04); } @@ -81,6 +100,8 @@ return val.value; } + + void LDC1000::readSPI(uint8_t *data, uint8_t address, uint8_t num_bytes) { _cs_pin.write(0);