Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC24XX_general.cpp
Go to the documentation of this file.
1 /*!
2 LTC24XX General Library: Functions and defines for all SINC4 Delta Sigma ADCs.
3 
4 @verbatim
5 
6 These functions and defines apply to all No Latency Delta Sigmas in the
7 LTC2480 EasyDrive family, LTC2410 differential family, LTC2400 single-ended family,
8 and the LTC2440 High Speed family with selectable speed / resolution.
9 
10 It does not cover the LTC2450 tiny, low cost delta sigma ADC famliy.
11 
12 Please refer to the No Latency Delta Sigma ADC selector guide available at:
13 
14 http://www.linear.com/docs/41341
15 
16 
17 @endverbatim
18 
19 http://www.linear.com/product/LTC2449
20 
21 http://www.linear.com/product/LTC2449#demoboards
22 
23 
24 Copyright 2018(c) Analog Devices, Inc.
25 
26 All rights reserved.
27 
28 Redistribution and use in source and binary forms, with or without
29 modification, are permitted provided that the following conditions are met:
30  - Redistributions of source code must retain the above copyright
31  notice, this list of conditions and the following disclaimer.
32  - Redistributions in binary form must reproduce the above copyright
33  notice, this list of conditions and the following disclaimer in
34  the documentation and/or other materials provided with the
35  distribution.
36  - Neither the name of Analog Devices, Inc. nor the names of its
37  contributors may be used to endorse or promote products derived
38  from this software without specific prior written permission.
39  - The use of this software may or may not infringe the patent rights
40  of one or more patent holders. This license does not release you
41  from the requirement that you obtain separate licenses from these
42  patent holders to use this software.
43  - Use of the software either in source or binary form, must be run
44  on or directly connected to an Analog Devices Inc. component.
45 
46 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
47 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
48 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
49 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
50 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
52 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
53 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
54 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
55 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 */
57 
58 //! @ingroup Analog_to_Digital_Converters
59 //! @{
60 //! @defgroup LTC24XX LTC24XX: All no-latency delta sigma ADCs with SINC4 rejection
61 //! @}
62 
63 /*! @file
64  @ingroup LTC24XX
65  Library for LTC24XX no-latency delta sigma ADCs with SINC4 rejection
66 */
67 
68 #include <stdint.h>
69 #include <Arduino.h>
70 #include "Linduino.h"
71 #include "LT_SPI.h"
72 #include <SPI.h>
73 #include "LTC24XX_general.h"
74 #include "USE_WIRE.h"
75 
76 #ifdef USEWIRE
77 #include "LT_I2C_Wire.h"
78 #else
79 #include "LT_I2C.h"
80 #endif
81 
82 int8_t LTC24XX_EOC_timeout(uint8_t cs, uint16_t miso_timeout)
83 // Checks for EOC with a specified timeout (ms)
84 {
85  uint16_t timer_count = 0; // Timer count for MISO
86  output_low(cs); //! 1) Pull CS low
87  while (1) //! 2) Wait for SDO (MISO) to go low
88  {
89  if (input(MISO) == 0) break; //! 3) If SDO is low, break loop
90  if (timer_count++>miso_timeout) // If timeout, return 1 (failure)
91  {
92  output_high(cs); // Pull CS high
93  return(1);
94  }
95  else
96  delay(1);
97  }
98  output_high(cs); // Pull CS high
99  return(0);
100 }
101 
102 // Reads from LTC24XX ADC that has no configuration word and a 32 bit output word.
103 void LTC24XX_SPI_32bit_data(uint8_t cs, int32_t *adc_code)
104 {
105  LT_union_int32_4bytes data, command; // LTC2449 data and command
106  command.LT_uint32 = 0; // Set to zero, not necessary but avoids
107  // random data in scope shots.
108  output_low(cs); //! 1) Pull CS low
109 
110  spi_transfer_block(cs, command.LT_byte, data.LT_byte, (uint8_t)4); //! 2) Transfer arrays
111 
112  output_high(cs); //! 3) Pull CS high
113  *adc_code = data.LT_int32;
114 }
115 
116 
117 // Reads from a SPI LTC24XX device that has an 8 bit command and a 32 bit output word.
118 void LTC24XX_SPI_8bit_command_32bit_data(uint8_t cs, uint8_t adc_command, int32_t *adc_code)
119 {
120  LT_union_int32_4bytes data, command; // LTC2449 data and command
121  command.LT_byte[3] = adc_command;
122  command.LT_byte[2] = 0;
123  command.LT_byte[1] = 0;
124  command.LT_byte[0] = 0;
125 
126  output_low(cs); //! 1) Pull CS low
127 
128  spi_transfer_block(cs, command.LT_byte, data.LT_byte, (uint8_t)4); //! 2) Transfer arrays
129 
130  output_high(cs); //! 3) Pull CS high
131  *adc_code = data.LT_int32;
132 }
133 
134 
135 // Reads from a SPI LTC24XX device that has a 16 bit command and a 32 bit output word.
136 void LTC24XX_SPI_16bit_command_32bit_data(uint8_t cs, uint8_t adc_command_high, uint8_t adc_command_low, int32_t *adc_code)
137 {
138 
139 
140  LT_union_int32_4bytes data, command; // LTC24XX data and command
141  command.LT_byte[3] = adc_command_high;
142  command.LT_byte[2] = adc_command_low;
143  command.LT_byte[1] = 0;
144  command.LT_byte[0] = 0;
145 
146  output_low(cs); //! 1) Pull CS low
147  spi_transfer_block(cs, command.LT_byte, data.LT_byte, (uint8_t)4); //! 2) Transfer arrays
148  output_high(cs); //! 3) Pull CS high
149  *adc_code = data.LT_int32;
150 }
151 
152 //! Reads from LTC24XX two channel "Ping-Pong" ADC, placing the channel information in the adc_channel parameter
153 //! and returning the 32 bit result with the channel bit cleared so the data format matches the rest of the family
154 //! @return void
155 void LTC24XX_SPI_2ch_ping_pong_32bit_data(uint8_t cs, uint8_t *adc_channel, int32_t *code)
156 {
157  LT_union_int32_4bytes data, command; // ADC data
158 
159  command.LT_int32 = 0x00000000; // This is a "don't care"
160 
161  spi_transfer_block(cs, command.LT_byte , data.LT_byte, (uint8_t)4);
162  if (data.LT_byte[3] & 0x40) // Obtains Channel Number
163  {
164  *adc_channel = 1;
165  }
166  else
167  {
168  *adc_channel = 0;
169  }
170  data.LT_byte[3] &= 0x3F; // Clear channel bit here so code to voltage function doesn't have to.
171  *code = data.LT_int32; // Return data
172 }
173 
174 //! Reads from LTC24XX ADC that has no configuration word and returns a 32 bit result.
175 //! @return void
176 void LTC24XX_SPI_24bit_data(uint8_t cs, int32_t *adc_code)
177 {
178  LT_union_int32_4bytes data, command; // LTC24XX data and command
179  command.LT_int32 = 0;
180 
181  output_low(cs); //! 1) Pull CS low
182  spi_transfer_block(cs, command.LT_byte, data.LT_byte, (uint8_t)3); //! 2) Transfer arrays
183  output_high(cs); //! 3) Pull CS high
184 
185  data.LT_byte[3] = data.LT_byte[2]; // Shift bytes up by one. We read out 24 bits,
186  data.LT_byte[2] = data.LT_byte[1]; // which are loaded into bytes 2,1,0. Need to left-
187  data.LT_byte[1] = data.LT_byte[0]; // justify.
188  data.LT_byte[0] = 0x00;
189 
190  *adc_code = data.LT_int32;
191 }
192 
193 //! Reads from LTC24XX ADC that accepts an 8 bit configuration and returns a 24 bit output word.
194 //! @return void
195 void LTC24XX_SPI_8bit_command_24bit_data(uint8_t cs, uint8_t adc_command, int32_t *adc_code)
196 {
197  LT_union_int32_4bytes data, command; // LTC24XX data and command
198  command.LT_byte[2] = adc_command;
199  command.LT_byte[1] = 0;
200  command.LT_byte[0] = 0;
201 
202  output_low(cs); //! 1) Pull CS low
203  spi_transfer_block(cs, command.LT_byte, data.LT_byte, (uint8_t)3); //! 2) Transfer arrays
204  output_high(cs); //! 3) Pull CS high
205 
206  data.LT_byte[3] = data.LT_byte[2]; // Shift bytes up by one. We read out 24 bits,
207  data.LT_byte[2] = data.LT_byte[1]; // which are loaded into bytes 2,1,0. Need to left-
208  data.LT_byte[1] = data.LT_byte[0]; // justify.
209  data.LT_byte[0] = 0x00;
210 
211  *adc_code = data.LT_int32;
212 }
213 
214 //! Reads from LTC24XX ADC that accepts a 16 bit configuration and returns a 24 bit output word.
215 //! @return void
216 void LTC24XX_SPI_16bit_command_24bit_data(uint8_t cs, uint8_t adc_command_high, uint8_t adc_command_low, int32_t *adc_code)
217 {
218  LT_union_int32_4bytes data, command; // LTC24XX data and command
219  command.LT_byte[2] = adc_command_high;
220  command.LT_byte[1] = adc_command_low;
221  command.LT_byte[0] = 0;
222 
223 
224  output_low(cs); //! 1) Pull CS low
225  spi_transfer_block(cs, command.LT_byte, data.LT_byte, (uint8_t)3); //! 2) Transfer arrays
226  output_high(cs); //! 3) Pull CS high
227 
228  data.LT_byte[3] = data.LT_byte[2]; // Shift bytes up by one. We read out 24 bits,
229  data.LT_byte[2] = data.LT_byte[1]; // which are loaded into bytes 2,1,0. Need to left-
230  data.LT_byte[1] = data.LT_byte[0]; // justify.
231  data.LT_byte[0] = 0x00;
232 
233  *adc_code = data.LT_int32;
234 }
235 
236 //! Reads from LTC24XX two channel "Ping-Pong" ADC, placing the channel information in the adc_channel parameter
237 //! and returning the 24 bit result with the channel bit cleared so the data format matches the rest of the family
238 //! @return void
239 void LTC24XX_SPI_2ch_ping_pong_24bit_data(uint8_t cs, uint8_t *adc_channel, int32_t *code)
240 {
241  LT_union_int32_4bytes data, command; // ADC data
242 
243  command.LT_int32 = 0x00000000; // This is a "don't care"
244 
245  spi_transfer_block(cs, command.LT_byte , data.LT_byte, (uint8_t)3);
246  data.LT_byte[3] = data.LT_byte[2]; // Shift bytes up by one. We read out 24 bits,
247  data.LT_byte[2] = data.LT_byte[1]; // which are loaded into bytes 2,1,0. Need to left-
248  data.LT_byte[1] = data.LT_byte[0]; // justify.
249  data.LT_byte[0] = 0x00;
250 
251  if (data.LT_byte[3] & 0x40) // Obtains Channel Number
252  {
253  *adc_channel = 1;
254  }
255  else
256  {
257  *adc_channel = 0;
258  }
259  data.LT_byte[3] &= 0x3F; // Clear channel bit here so code to voltage function doesn't have to.
260  *code = data.LT_int32; // Return data
261 }
262 
263 
264 //I2C functions
265 
266 //! Reads from LTC24XX ADC that accepts an 8 bit configuration and returns a 24 bit result.
267 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
269 {
270  int8_t ack;
271  uint16_t timer_count = 0; // Timer count to wait for ACK
272  int8_t buf[4];
273  LT_union_int32_4bytes data; // LTC24XX data
274  while (1)
275  {
276  ack = i2c_read_block_data(i2c_address, adc_command, 3, data.LT_byte);
277  if (!ack) break; // !ack indicates success
278  if (timer_count++>eoc_timeout) // If timeout, return 1 (failure)
279  return(1);
280  else
281  delay(1);
282  }
283  data.LT_byte[3] = data.LT_byte[2]; // Shift bytes up by one. We read out 24 bits,
284  data.LT_byte[2] = data.LT_byte[1]; // which are loaded into bytes 2,1,0. Need to left-
285  data.LT_byte[1] = data.LT_byte[0]; // justify.
286  data.LT_byte[0] = 0x00;
287  data.LT_uint32 >>= 2; // Shifts data 2 bits to the right; operating on unsigned member shifts in zeros.
288  data.LT_byte[3] = data.LT_byte[3] & 0x3F; // Clear upper 2 bits JUST IN CASE. Now the data format matches the SPI parts.
289  *adc_code = data.LT_int32;
290  return(ack); // Success
291 }
292 
293 
294 
295 //! Reads from LTC24XX ADC that has no configuration word and returns a 32 bit result.
296 //! Data is formatted to match the SPI devices, with the MSB in the bit 28 position.
297 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
298 int8_t LTC24XX_I2C_32bit_data(uint8_t i2c_address, //!< I2C address of device
299  int32_t *adc_code, //!< 4 byte conversion code read from LTC24XX
300  uint16_t eoc_timeout //!< Timeout (in milliseconds)
301  )
302 {
303  int8_t ack;
304  uint16_t timer_count = 0; // Timer count to wait for ACK
305  int8_t buf[4];
306  LT_union_int32_4bytes data; // LTC24XX data
307  while (1)
308  {
309  ack = i2c_read_block_data(i2c_address, 4, data.LT_byte);
310  if (!ack) break; // !ack indicates success
311  if (timer_count++>eoc_timeout) // If timeout, return 1 (failure)
312  return(1);
313  else
314  delay(1);
315  }
316 
317  data.LT_uint32 >>= 2; // Shifts data 2 bits to the right; operating on unsigned member shifts in zeros.
318  data.LT_byte[3] = data.LT_byte[3] & 0x3F; // Clear upper 2 bits JUST IN CASE. Now the data format matches the SPI parts.
319  *adc_code = data.LT_int32;
320  return(ack); // Success
321 }
322 
323 
324 //! Reads from LTC24XX ADC that accepts an 8 bit configuration and returns a 32 bit result.
325 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
327 {
328  int8_t ack;
329  uint16_t timer_count = 0; // Timer count to wait for ACK
330  int8_t buf[4];
331  LT_union_int32_4bytes data; // LTC24XX data
332  while (1)
333  {
334  ack = i2c_read_block_data(i2c_address, adc_command, 4, data.LT_byte);
335  if (!ack) break; // !ack indicates success
336  if (timer_count++>eoc_timeout) // If timeout, return 1 (failure)
337  return(1);
338  else
339  delay(1);
340  }
341 
342  data.LT_uint32 >>= 2; // Shifts data 2 bits to the right; operating on unsigned member shifts in zeros.
343  data.LT_byte[3] = data.LT_byte[3] & 0x3F; // Clear upper 2 bits JUST IN CASE. Now the data format matches the SPI parts.
344  *adc_code = data.LT_int32;
345  return(ack); // Success
346 }
347 
348 //! Reads from LTC24XX ADC that accepts a 16 bit configuration and returns a 32 bit result.
349 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
350 int8_t LTC24XX_I2C_16bit_command_32bit_data(uint8_t i2c_address,uint8_t adc_command_high,
351  uint8_t adc_command_low,int32_t *adc_code,uint16_t eoc_timeout)
352 {
353  int8_t ack;
354  uint16_t adc_command, timer_count = 0; // Timer count to wait for ACK
355  int8_t buf[4];
356  LT_union_int32_4bytes data; // LTC24XX data
357  adc_command = (adc_command_high << 8) | adc_command_low;
358  while (1)
359  {
360  ack = i2c_two_byte_command_read_block(i2c_address, adc_command, 4, data.LT_byte);
361  if (!ack) break; // !ack indicates success
362  if (timer_count++>eoc_timeout) // If timeout, return 1 (failure)
363  return(1);
364  else
365  delay(1);
366  }
367 
368  data.LT_uint32 >>= 2; // Shifts data 2 bits to the right; operating on unsigned member shifts in zeros.
369  data.LT_byte[3] = data.LT_byte[3] & 0x3F; // Clear upper 2 bits JUST IN CASE. Now the data format matches the SPI parts.
370  *adc_code = data.LT_int32;
371  return(ack); // Success
372 }
373 
374 // Calculates the voltage corresponding to an adc code, given the reference voltage (in volts)
376 {
377  float voltage;
378  adc_code -= 0x20000000; //! 1) Subtract offset
379  voltage=(float) adc_code;
380  voltage = voltage / 268435456.0; //! 2) This calculates the input as a fraction of the reference voltage (dimensionless)
381  voltage = voltage * vref; //! 3) Multiply fraction by Vref to get the actual voltage at the input (in volts)
382  return(voltage);
383 }
384 
385 // Calculates the voltage corresponding to an adc code, given the reference voltage (in volts)
386 // This function handles all differential input parts, including the "single-ended" mode on multichannel
387 // differential parts. Data from I2C parts must be right-shifted by two bit positions such that the MSB
388 // is in bit 28 (the same as the SPI parts.)
390 {
391  float voltage;
392 
393 #ifndef SKIP_EZDRIVE_2X_ZERO_CHECK
394  if (adc_code == 0x00000000)
395  {
396  adc_code = 0x20000000;
397  }
398 #endif
399 
400  adc_code -= 0x20000000; //! 1) Converts offset binary to binary
401  voltage=(float) adc_code;
402  voltage = voltage / 536870912.0; //! 2) This calculates the input as a fraction of the reference voltage (dimensionless)
403  voltage = voltage * vref; //! 3) Multiply fraction by Vref to get the actual voltage at the input (in volts)
404  return(voltage);
405 }
406 
407 // Calculates the voltage corresponding to an adc code, given lsb weight (in volts) and the calibrated
408 // adc offset code (zero code that is subtracted from adc_code). For use with the LTC24XX_cal_voltage() function.
410 {
411  float adc_voltage;
412 
413 #ifndef SKIP_EZDRIVE_2X_ZERO_CHECK
414  if (adc_code == 0x00000000)
415  {
416  adc_code = 0x20000000;
417  }
418 #endif
419 
420  adc_code -= 536870912; //! 1) Converts offset binary to binary
421  adc_voltage=(float)(adc_code+LTC2449_offset_code)*LTC2449_lsb; //! 2) Calculate voltage from ADC code, lsb, offset.
422  return(adc_voltage);
423 }
424 
425 
426 // Calculate the lsb weight and offset code given a full-scale code and a measured zero-code.
427 void LTC24XX_calibrate_voltage(int32_t zero_code, int32_t fs_code, float zero_voltage, float fs_voltage, float *LTC24XX_lsb, int32_t *LTC24XX_offset_code)
428 {
429  zero_code -= 536870912; //! 1) Converts zero code from offset binary to binary
430  fs_code -= 536870912; //! 2) Converts full scale code from offset binary to binary
431 
432  float temp_offset;
433  *LTC24XX_lsb = (fs_voltage-zero_voltage)/((float)(fs_code - zero_code)); //! 3) Calculate the LSB
434 
435  temp_offset = (zero_voltage/ *LTC24XX_lsb) - zero_code; //! 4) Calculate Unipolar offset
436  temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset); //! 5) Round
437  *LTC24XX_offset_code = (int32_t)temp_offset; //! 6) Cast as int32_t
438 }
void LTC24XX_SPI_32bit_data(uint8_t cs, int32_t *adc_code)
Reads from LTC24XX ADC that has no configuration word and returns a 32 bit result.
uint8_t i2c_address
static uint8_t adc_command
Definition: DC2071AA.ino:111
int8_t i2c_read_block_data(uint8_t address, uint8_t command, uint8_t length, uint8_t *values)
Read a block of data, starting at register specified by "command" and ending at (command + length - 1...
Definition: LT_I2C.cpp:244
uint8_t LT_byte[4]
4 bytes (unsigned 8-bit integers) to be converted to a 32-bit signed or unsigned integer ...
Definition: Linduino.h:112
#define output_high(pin)
Set "pin" high.
Definition: Linduino.h:75
Header File for Linduino Libraries and Demo Code.
int8_t LTC24XX_EOC_timeout(uint8_t cs, uint16_t miso_timeout)
Checks for EOC with a specified timeout.
void LTC24XX_SPI_8bit_command_24bit_data(uint8_t cs, uint8_t adc_command, int32_t *adc_code)
Reads from LTC24XX ADC that accepts an 8 bit configuration and returns a 24 bit output word...
uint32_t LT_uint32
32-bit unsigned integer to be converted to four bytes
Definition: Linduino.h:111
int8_t LTC24XX_I2C_8bit_command_24bit_data(uint8_t i2c_address, uint8_t adc_command, int32_t *adc_code, uint16_t eoc_timeout)
Reads from LTC24XX ADC that accepts an 8 bit configuration and returns a 24 bit result.
float LTC24XX_diff_code_to_calibrated_voltage(int32_t adc_code, float LTC2449_lsb, int32_t LTC2449_offset_code)
Calculates the voltage corresponding to an ADC code, given lsb weight (in volts) and the calibrated A...
void LTC24XX_SPI_8bit_command_32bit_data(uint8_t cs, uint8_t adc_command, int32_t *adc_code)
Reads from LTC24XX ADC that accepts an 8 bit configuration and returns a 32 bit result.
static float adc_voltage
Definition: DC2071AA.ino:115
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
LTC24XX General Library: Functions and defines for all SINC4 Delta Sigma ADCs.
int8_t i2c_two_byte_command_read_block(uint8_t address, uint16_t command, uint8_t length, uint8_t *values)
Write a two command bytes, then receive a block of data.
Definition: LT_I2C.cpp:345
void LTC24XX_SPI_16bit_command_32bit_data(uint8_t cs, uint8_t adc_command_high, uint8_t adc_command_low, int32_t *adc_code)
Reads from LTC24XX ADC that accepts a 16 bit configuration and returns a 32 bit result.
void LTC24XX_calibrate_voltage(int32_t zero_code, int32_t fs_code, float zero_voltage, float fs_voltage, float *LTC24XX_lsb, int32_t *LTC24XX_offset_code)
Calculate the lsb weight and offset code given a full-scale code and a measured zero-code.
static uint16_t eoc_timeout
timeout in ms
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
#define output_low(pin)
Set "pin" low.
Definition: Linduino.h:72
int8_t LTC24XX_I2C_16bit_command_32bit_data(uint8_t i2c_address, uint8_t adc_command_high, uint8_t adc_command_low, int32_t *adc_code, uint16_t eoc_timeout)
Reads from LTC24XX ADC that accepts a 16 bit configuration and returns a 32 bit result.
#define input(pin)
Return the state of pin "pin".
Definition: Linduino.h:79
int32_t LT_int32
32-bit signed integer to be converted to four bytes
Definition: Linduino.h:110
void LTC24XX_SPI_2ch_ping_pong_24bit_data(uint8_t cs, uint8_t *adc_channel, int32_t *code)
Reads from LTC24XX two channel "Ping-Pong" ADC, placing the channel information in the adc_channel pa...
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
int8_t LTC24XX_I2C_8bit_command_32bit_data(uint8_t i2c_address, uint8_t adc_command, int32_t *adc_code, uint16_t eoc_timeout)
Reads from LTC24XX ADC that accepts an 8 bit configuration and returns a 32 bit result.
int8_t LTC24XX_I2C_32bit_data(uint8_t i2c_address, int32_t *adc_code, uint16_t eoc_timeout)
Reads from LTC24XX ADC that has no configuration word and returns a 32 bit result.
float LTC24XX_diff_code_to_voltage(int32_t adc_code, float vref)
Calculates the voltage corresponding to an ADC code, given the reference voltage. ...
This union splits one int32_t (32-bit signed integer) or uint32_t (32-bit unsigned integer) four uint...
Definition: Linduino.h:108
void LTC24XX_SPI_2ch_ping_pong_32bit_data(uint8_t cs, uint8_t *adc_channel, int32_t *code)
Reads from LTC24XX two channel "Ping-Pong" ADC, placing the channel information in the adc_channel pa...
static float LTC2449_lsb
The LTC2449 ideal reference voltage.
Definition: DC1410AB.ino:102
void spi_transfer_block(uint8_t cs_pin, uint8_t *tx, uint8_t *rx, uint8_t length)
Reads and sends a byte array.
Definition: LT_SPI.cpp:125
static float voltage
Definition: DC2289AA.ino:71
float LTC24XX_SE_code_to_voltage(int32_t adc_code, float vref)
Calculates the voltage corresponding to an ADC code, given the reference voltage. ...
void LTC24XX_SPI_24bit_data(uint8_t cs, int32_t *adc_code)
Reads from LTC24XX ADC that has no configuration word and returns a 32 bit result.
static int32_t LTC2449_offset_code
Ideal offset for a perfect part.
Definition: DC742A.ino:127
void LTC24XX_SPI_16bit_command_24bit_data(uint8_t cs, uint8_t adc_command_high, uint8_t adc_command_low, int32_t *adc_code)
Reads from LTC24XX ADC that accepts a 16 bit configuration and returns a 24 bit output word...
static uint32_t adc_code
Definition: DC2071AA.ino:113