Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Inductive_Sensor_3
Fork of LDC1101 by
Revision 5:98d4fd07734a, committed 2015-05-26
- Comitter:
- hamid567
- Date:
- Tue May 26 14:34:05 2015 +0000
- Parent:
- 4:62ebb87678f8
- Child:
- 6:5b6ad98d6436
- Commit message:
- Set mode to standby before writing registers. Counter 1..0 not changing ?
Changed in this revision
| LDC1000.cpp | Show annotated file Show diff for this revision Revisions of this file |
| LDC1000.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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);
--- a/LDC1000.h Tue May 19 14:10:01 2015 +0000
+++ b/LDC1000.h Tue May 26 14:34:05 2015 +0000
@@ -32,6 +32,8 @@
typedef enum { LDC_MODE_STANDBY = 0, LDC_MODE_ACTIVE = 1} LDC_MODE;
+typedef enum { WAKE_UP = 1, COMPARATOR = 2 , ACTIVE = 4} LDC_INTB;
+
/**
* Class for the LDC1000.
@@ -51,6 +53,7 @@
* @param mode choose from LDC_MODE_ACTIVE or LDC_MODE STANDBY
**/
void mode(LDC_MODE mode){writeSPI((uint8_t *)(&mode), 0x0B);};
+ void setINTB(LDC_INTB setINTB){writeSPI((uint8_t *)(&setINTB), 0x0A);};
/**
* @brief get the calculated inductance value
**/
@@ -70,6 +73,10 @@
* This is needed for the calculation of the inductance.
**/
uint32_t readRawL(void){_raw_l = readRawCounts(); return _raw_l;};
+
+ // EXTRA test Read INTB register
+ uint32_t readINTBregister(void){INTB = readINTB(); return INTB;};
+
/**
* @brief Set the Response Time parameters.
* @param responsetime
@@ -97,7 +104,9 @@
private:
void readSPI(uint8_t *data, uint8_t address, uint8_t num_bytes = 1);
void writeSPI(uint8_t *data, uint8_t address, uint8_t num_bytes = 1);
+ void writeSPIregister(uint8_t reg, uint8_t value){writeSPI(&value,reg);};
uint32_t readRawCounts(void);
+ uint32_t readINTB(void); // EXTRA UNTB Read register
LDC_RESPONSE _responsetime;
LDC_AMPLITUDE _amplitude;
float _fsensor;
@@ -105,6 +114,7 @@
float _frequency; //frequency of external clock
float cap;
uint32_t _raw_l;
+ uint32_t INTB; // extra: read register INTB
SPI _spiport;
DigitalOut _cs_pin;
FastPWM _clock;
