Library to communicate with LDC1614

Dependencies:   SHTx

Dependents:   Inductive_Sensor_3

Fork of LDC1101 by Bob Giesberts

Revision:
29:41815fd13822
Parent:
28:76a2fc42f888
Child:
30:95c53d244f91
--- a/LDC1614.h	Tue Aug 23 08:25:40 2016 +0000
+++ b/LDC1614.h	Wed Aug 24 07:42:49 2016 +0000
@@ -18,12 +18,13 @@
 #define PI 3.14
 #endif
 
+
+/*
 int min(int a, int b)       { return (a<b) ? a : b; }
 float min(float a, float b) { return (a<b) ? a : b; }
 int max(int a, int b)       { return (a>b) ? a : b; }
 float max(float a, float b) { return (a>b) ? a : b; }
-
-
+*/
 
 
 typedef enum {  LDC_MODE_ACTIVE   = 0, \
@@ -68,7 +69,23 @@
                 DRIVE_CURRENT_CH2   = 0x20, \
                 DRIVE_CURRENT_CH3   = 0x21} ADDR;
 
-typedef enum {  UR_ERR2OUT          = 15, \
+typedef enum {  CHx_ERR_UR          = 15, \
+                CHx_ERR_OR          = 14, \
+                CHx_ERR_WD          = 13, \
+                CHx_ERR_AE          = 12, \
+                ERR_CHAN            = 14, \
+                ERR_UR              = 13, \
+                ERR_OR              = 12, \
+                ERR_WD              = 11, \
+                ERR_AHE             = 10, \
+                ERR_ALE             =  9, \
+                ERR_ZC              =  8, \
+                DRDY                =  6, \
+                CH0_UNREADCONV      =  3, \
+                CH1_UNREADCONV      =  2, \
+                CH2_UNREADCONV      =  1, \
+                CH3_UNREADCONV      =  0, \
+                UR_ERR2OUT          = 15, \
                 OR_ERR2OUT          = 14, \
                 WD_ERR2OUT          = 13, \
                 AH_ERR2OUT          = 12, \
@@ -106,7 +123,7 @@
         /**
         * @brief Create a new Class to interface to an LDC1614
         **/
-        LDC1614(PinName sda, PinName scl, PinName sd, float f_CLKIN, int sensors, float capacitor);
+        LDC1614(PinName sda, PinName scl, PinName sd, PinName os, float f_CLKIN, int sensors, float capacitor);
         ~LDC1614();
         
         /**
@@ -119,7 +136,7 @@
         **/
         void func_mode(LDC_MODE mode);
         /**
-        * @brief Set LDC1614 to lowest power setting
+        * @brief Put the LDC in configuration modus
         **/
         void sleep(void);
         /**
@@ -127,6 +144,10 @@
         **/
         void wakeup(void);
         /**
+        * @brief Put the LDC in its lowest power modus
+        **/
+        void shutdown(void);
+        /**
         * @brief initial configurations
         **/
         void init(void);
@@ -236,6 +257,7 @@
         void set( ADDR addr, SETTING setting, uint8_t value );
         
 
+        uint8_t get( ADDR addr, SETTING setting, uint8_t mask = 1 );
 
         
 
@@ -335,7 +357,15 @@
         * returns true when data is ready for all sensors
         * returns false if not
         **/
-        bool is_ready(void);
+        bool is_ready( uint8_t status = 17 );
+        
+        /**
+        * @brief is there an error?
+        * returns true when there is an error
+        * returns false if not
+        **/
+        bool is_error( uint8_t status = 17 );
+        
 
         
     private:
@@ -354,8 +384,6 @@
         uint16_t _Rcount;       // CHx_RCOUNT
         uint16_t _SettleCount;  // CHx_SETTLECOUNT
         uint8_t _DriveCurrent;  // CHx_IDRIVE
-       
-       
         
         float _fsensor;         // f_sensor: the calculated frequency of the sensor
         float _fCLKIN;          // f_CLKIN: frequency of external clock: 16MHz
@@ -366,6 +394,7 @@
         
         I2C _i2c;
         DigitalOut _shutdown_pin;
+        DigitalOut _oscillator;
 
 };