Library to communicate with LDC1614
Dependents: Inductive_Sensor_3
Fork of LDC1101 by
Diff: LDC1614.h
- Revision:
- 34:b03d7bb9010c
- Parent:
- 32:9712c9bdaf44
- Child:
- 35:00c9c01f0c0f
diff -r 2f4c791f37b2 -r b03d7bb9010c LDC1614.h --- a/LDC1614.h Sun Sep 11 15:08:43 2016 +0000 +++ b/LDC1614.h Wed Sep 21 14:25:20 2016 +0000 @@ -2,6 +2,7 @@ #define _LDC1614_H_ #include "mbed.h" +#include "mbed_debug.h" #include "register_values.h" #include "i2c.hpp" @@ -33,11 +34,11 @@ * @param sda I2C SDA pin connected to LDC1614 * @param scl I2C SCL pin connected to LDC1614 * @param sd Shutdown pin connected to LDC1614 - * @param f_CLKIN f_CLKIN (Hz) + * @param f_CLKIN f_CLKIN (MHz) * @param sensors number of sensors - * @param capacitor Used capacitor on all connected sensors + * @param capacitor Used capacitor (pF) on all connected sensors **/ - LDC1614(PinName sda, PinName scl, PinName sd, float f_CLKIN, int sensors, float capacitor); + LDC1614(PinName sda, PinName scl, PinName sd, uint8_t f_CLKIN, int sensors, uint8_t capacitor); ~LDC1614(); /** @@ -93,9 +94,10 @@ /** * @brief clock divider * Sensor divider (p.14) - * f_REF = f_CLKIN / REF_DIVIDER - * f_IN = f_SENSOR / IN_DIVIDER - * Ideally f_REF > 4*f_IN + * f_REF = f_CLKIN / CHx_REF_DIVIDER + * f_IN = f_SENSOR / CHx_FIN_DIVIDER + * f_REF > 4*f_IN + * if f_SENSOR >= 8.75 MHz, then CHx_FIN_DIVIDER >= 2 (p.10) * @param channel the channel (CH0, CH1, CH2, CH3) * @param divIN CHx_FIN_DIVIDER (4bit: 1 - 15) * @param divREF CHx_FREF_DIVIDER (8 bit: 1 - 255) @@ -199,7 +201,9 @@ /// @brief get the reference frequency (f_CLKIN) float get_fCLKIN(void); /// @brief get the reference count - uint16_t get_Rcount( uint8_t channel ); + uint16_t get_ReferenceCount( uint8_t channel ); + /// @brief get the reference count + uint8_t get_DriveCurrent( uint8_t channel ); /// @brief get the divider uint8_t get_dividerIN(void); /// @brief get the divider @@ -229,10 +233,10 @@ * if omitted, get_status() will be used to get a value **/ bool is_error( uint8_t status = 17 ); - uint8_t what_error( uint8_t channel ); + uint8_t get_error( uint8_t channel ); - uint16_t get_ID( void ); + uint16_t get_device_ID( void ); uint16_t get_manufacturer_ID( void ); private: @@ -253,11 +257,12 @@ uint8_t _DriveCurrent; // CHx_IDRIVE float _fsensor; // f_sensor (Hz): the calculated frequency of the sensor - float _fCLKIN; // f_CLKIN (Hz): frequency of external clock: 16MHz + uint8_t _fCLKIN; // f_CLKIN (MHz): frequency of external clock: 40MHz float _inductance; // the calculated inductance - float _cap; // capacitor (F): 120 pF + uint8_t _cap; // capacitor (pF): 120 pF + uint8_t error[]; SHTx::I2C _i2c; DigitalOut _shutdown_pin;