Library to communicate with LDC1614
Dependents: Inductive_Sensor_3
Fork of LDC1101 by
Diff: LDC1101.h
- Revision:
- 25:ae111662ee03
- Parent:
- 22:8da965ce5af3
- Child:
- 26:1ef9172cd355
--- a/LDC1101.h Mon Jan 25 09:11:05 2016 +0000 +++ b/LDC1101.h Tue Feb 16 15:54:59 2016 +0000 @@ -34,6 +34,15 @@ DIVIDER_4 = 2, \ DIVIDER_8 = 3} DIVIDER; +typedef enum { RPMAX_96 = 0, \ + RPMAX_48 = 1, \ + RPMAX_24 = 2, \ + RPMAX_12 = 3, \ + RPMAX_6 = 4, \ + RPMAX_3 = 5, \ + RPMAX_1 = 6, \ + RPMAX_0 = 7} RPMAX; + typedef enum { RPMIN_96 = 0, \ RPMIN_48 = 1, \ RPMIN_24 = 2, \ @@ -79,6 +88,7 @@ * Also enables shutdown modus **/ void setLHRmode(void); + void setRPmode(void); /** * @brief Settings for RP @@ -90,13 +100,14 @@ * RPMIN < 0.8 x R_p(d = 0mm) * If R_p < 750 Ohm --> increase distance to target **/ - void setRPsettings(bool RPMAX_DIS, RPMIN rpmin); + void setRPsettings(bool RPMAX_DIS, RPMAX rpmax, RPMIN rpmin); /** * @brief Sensor divider (p.26) * Sensor input divider (p.35) * Because f_CLKIN > 4*f_sensor_max is not realisable for higher frequencies, so there is a divider * f_CLKIN > 4 * f_sensor_max / SENSOR_DIV + * this effectively decreases resolution. Preferable use setLHRoffset instead. * @param div * - DIVIDER_1 * - DIVIDER_2 @@ -104,6 +115,15 @@ * - DIVIDER_8 **/ void setDivider(DIVIDER div); + + /** + * @brief Sensor offset (p.26) + * Sensor offset + * The sensor might reach a value > 2^24. To prevent this, set an offset. + * @param offset + * 32 bit value that should be substracted from the current sensor value + **/ + void setLHRoffset( uint32_t offset ); /** * @brief Set the Response Time parameters. Does not apply in LHR mode (p.17) @@ -140,9 +160,10 @@ /** * @brief Set the minimum sensor frequency (so without any target) * @param f_sensor_min - * in MHz + * f_sensor_min in MHz + * value between 0.5 and 8 MHz **/ - void setf_sensorMin(float f_sensor_min); + void set_fsensor_min(float f_sensor_min); /** * @brief Set the value of the external capacitor @@ -165,14 +186,21 @@ * It reads from addresses 0x38, 0x39 & 0x3A. **/ uint32_t get_LHR_Data(void); + uint16_t get_RP_Data(void); + uint16_t get_L_Data(void); + /** + * @brief get the set minimum value for f_sensor (0x04[7:5]) + **/ + float get_fsensor_min(void); /** * @brief get the calculated value for f_sensor **/ - float get_fsensor(void); + float get_fsensor(uint32_t Ldata = 0); /** * @brief get the calculated inductance value **/ - float get_Inductance(void); + float get_Inductance(uint32_t Ldata = 0); + float get_RP( uint16_t RPdata = 0); /** * @brief get the reference frequency (f_CLKIN) **/ @@ -186,6 +214,10 @@ **/ float get_RPmin(void); /** + * @brief get RPmax + **/ + float get_RPmax(void); + /** * @brief get the reference count **/ uint16_t get_Rcount(void) { uint8_t rcount[2]; readSPI(rcount, 0x30, 2); return ((rcount[1] << 8) | rcount[0]); }; @@ -194,6 +226,10 @@ **/ uint8_t get_divider(void); /** + * @brief get LHR_OFFSET + **/ + uint32_t get_LHRoffset(void); + /** * @brief get the capacitance **/ float get_cap(void); @@ -219,8 +255,11 @@ uint16_t _responsetime; // Response Time uint8_t _divider; // divider + uint32_t _LHRoffset; // LHR_OFFSET float _RPmin; // RP_MIN + float _RPmax; // RP_MAX float _fsensor; // f_sensor: the calculated frequency of the sensor + float _f_sensor_min; // f_sensor_min: setting for the lowest expected value for f_sensor float _inductance; // the calculated inductance float _fCLKIN; // f_CLKIN: frequency of external clock: 16MHz float _cap; // capacitor: 120 pF