Library to communicate with LDC1614

Dependencies:   SHTx

Dependents:   Inductive_Sensor_3

Fork of LDC1101 by Bob Giesberts

Revision:
30:95c53d244f91
Parent:
29:41815fd13822
Child:
31:ab4354a71996
--- a/LDC1614.cpp	Wed Aug 24 07:42:49 2016 +0000
+++ b/LDC1614.cpp	Wed Aug 24 10:31:08 2016 +0000
@@ -1,4 +1,4 @@
-/**
+/** LDC1614 library
 * @file LDC1614.cpp
 * @brief this C++ file contains all required
 * functions to interface with Texas
@@ -8,7 +8,7 @@
 *
 * @date 2016-08-09
 *
-* @example
+* @code
 * Serial pc(USBTX, USBRX);
 * LDC1614 ldc(PTC6, PTC7, PTC5, 16E6, 2, 120E-12);
 * int main(){
@@ -18,11 +18,13 @@
 *       pc.printf("sensor 1: %d | sensor 2: %d\r\n", ldc.get_Data(0), ldc.get_Data(1) );
 *    }
 * }
+* @endcode
 */
 
 #include "LDC1614.h"
 #include "mbed_debug.h"
 
+
 LDC1614::LDC1614(PinName sda, PinName scl, PinName sd, PinName os, float f_CLKIN, int channels, float capacitor) : _i2c(sda, scl), _shutdown_pin(sd), _oscillator(os)
 {
     // settings
@@ -220,7 +222,7 @@
 bool LDC1614::is_error( uint8_t status )
 {
     if( status == 17 ) { status = get_status(); }
-    return ((( status>>ERR_ZC) & 6) == 0);
+    return ((( status>>ERR_ZC ) & 6) == 0);
 }
 
 
@@ -234,21 +236,23 @@
 uint32_t LDC1614::get_Data( uint8_t channel )
 {
     uint16_t data[2];
-    readI2C(data, DATA_MSB_CH0 + channel, 2);
+    readI2C( data, DATA_MSB_CH0 + channel, 2 );
     
     if( ((data[0]>>CHx_ERR_UR) & 1) == 1 ) { debug( "Under-range Error" ); }
     if( ((data[0]>>CHx_ERR_OR) & 1) == 1 ) { debug( "Over-range Error" ); }
     if( ((data[0]>>CHx_ERR_WD) & 1) == 1 ) { debug( "Watchdog Timeout Error" ); }
     if( ((data[0]>>CHx_ERR_AE) & 1) == 1 ) { debug( "Amplitude Error" ); }
     
-    return ( (data[0] & 0x0fff)<<16) | data[1]; // MSB + LSB
+    return ( (data[0] & 0x0fff)<<16 ) | data[1]; // MSB + LSB
 }
 
 
 
+
+
+
 /* REGISTER FUNCTIONS (READ / WRITE)  */
 
-
 void LDC1614::readI2C( uint16_t *data, uint8_t address, uint8_t length )
 {
     // I2C reads per 8-bits, char is 8-bit, combine 8-bit in 16-bit sets