Control Code with I/O and ADC working

Dependencies:   MODSERIAL mbed

Revision:
1:0182b86f9bd4
Parent:
0:a28a1035c31b
Child:
2:bd118a724f03
--- a/LTC2487/LTC2487.cpp	Mon Jan 22 20:11:52 2018 +0000
+++ b/LTC2487/LTC2487.cpp	Mon Feb 05 06:41:23 2018 +0000
@@ -2,6 +2,8 @@
 #include "LTC2487.h"
 #include "MODSERIAL.h"
 
+MODSERIAL pc3(USBTX, USBRX);
+
 namespace {
     const uint8_t I2C_WRITE  = 0x00;
     const uint8_t I2C_READ   = 0x01;
@@ -51,18 +53,18 @@
     //send message to select channel
     i2c.write((addrI2C<<1)|(I2C_WRITE), ADC_channel, 1);
     //must wait, otherwise breaks...
-    wait(0.3);
+    wait(0.2);
     //send configuration (1 gain, autocalibration
     i2c.write((addrI2C<<1)|(I2C_WRITE), ADC_config, 1);
     //must wait, otherwise breaks...
-    wait(0.3);
+    wait(0.2);
     //Read data from selected channel --> 24bits --> 23bit=SIGN 22bit=MSB 21-7bits=DATA 5-0bits=JUNK
     i2c.read((addrI2C<<1)|(I2C_READ), ADC_data_rx, 3); 
     //Stich togethor the bytes into a 24bit value
     unsigned long data = (ADC_data_rx[0] << 16) | (ADC_data_rx[1] << 8)| ADC_data_rx[2];
     //Delete SIGN bit and MSB bit and remove 6 JUNK bits
-    unsigned long ADC_Result = (data&0x3fffff)>>6;    
-    
+    unsigned long ADC_Result = (data&0x3fffff)>>6;  
+        
     return float(float(ADC_Result));
 
 }