79 uint8_t
LTC2373_build_command(uint8_t sequencer_bit, uint8_t ch_designate, uint8_t range_select, uint8_t gain_compression)
82 adc_command = sequencer_bit | ch_designate | range_select | gain_compression;
140 config = (adc_command >> 1) & 0x03;
145 voltage = (float)adc_code;
146 voltage = voltage / (pow(2,32)-1);
147 voltage = voltage *
vref;
151 if ((adc_code>>31) == 1)
153 adc_code = (adc_code ^ 0xFFFFFFFF)+1;
157 voltage = (float)adc_code;
158 voltage = voltage / (pow(2,31)-1);
159 voltage = sign * voltage * vref/2;
163 voltage = (float)adc_code;
164 voltage = voltage / (pow(2,32)-1);
165 voltage = sign * voltage *
vref;
169 if ((adc_code>>31) == 1)
171 adc_code = (adc_code ^ 0xFFFFFFFF)+1;
175 voltage = (float)adc_code;
176 voltage = voltage / (pow(2,31)-1);
177 voltage = sign * voltage *
vref;
uint8_t LTC2373_build_command(uint8_t sequencer_bit, uint8_t ch_designate, uint8_t range_select, uint8_t gain_compression)
static uint8_t adc_command
uint8_t LT_byte[4]
4 bytes (unsigned 8-bit integers) to be converted to a 32-bit signed or unsigned integer ...
void LTC2373_configure(uint8_t cs, uint32_t adc_configure)
Configures the LTC2373.
LTC2373: 16/18-bit 1Msps 8 channel SAR ADC LTC2372: 16/18-bit 500ksps 8 channel SAR ADC LTC2374: 16 b...
Header File for Linduino Libraries and Demo Code.
uint32_t LT_uint32
32-bit unsigned integer to be converted to four bytes
union LT_union_int32_4bytes data
int32_t LT_int32
32-bit signed integer to be converted to four bytes
void LTC2373_read(uint8_t cs, uint8_t adc_command, uint32_t *ptr_adc_code)
Reads the LTC2373 and returns 32-bit data.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
This union splits one int32_t (32-bit signed integer) or uint32_t (32-bit unsigned integer) four uint...
void spi_transfer_block(uint8_t cs_pin, uint8_t *tx, uint8_t *rx, uint8_t length)
Reads and sends a byte array.
float LTC2373_code_to_voltage(uint8_t adc_command, uint32_t adc_code, float vref)
Calculates the LTC2373 input voltage given the binary data and lsb weight.