Rivian Irvine Team
/
TCTF_Control_Main
Control Code with I/O and ADC working
Diff: LTC2487/LTC2487.cpp
- Revision:
- 16:82d941b1ef21
- Parent:
- 14:69cd53434783
- Child:
- 20:cdeed4dad690
--- a/LTC2487/LTC2487.cpp Mon Jun 11 21:10:14 2018 +0000 +++ b/LTC2487/LTC2487.cpp Wed Jun 20 00:30:48 2018 +0000 @@ -37,9 +37,8 @@ addrI2C = address; } -float LTC2487::readOutput(int chnl){ +float LTC2487::writePort(int chnl){ char ADC_channel[1]; - char ADC_data_rx[3]; char ADC_config[1]; ADC_config[0] = 0b10001000;//0x82; //0b10000010 char cmd[2]; @@ -64,12 +63,13 @@ cmd[1] = ADC_config[0]; i2c.write((addrI2C<<1)|(I2C_WRITE), cmd, 2); - //must wait, otherwise breaks...*/ - wait(0.08); +} + +float LTC2487::read(){ + char ADC_data_rx[3]; + //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); - //must wait, otherwise breaks... - wait(0.08); //Stitch together 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