85 uint16_t timer_count = 0;
89 if (
input(MISO) == 0)
break;
90 if (timer_count++>miso_timeout)
141 command.
LT_byte[3] = adc_command_high;
142 command.
LT_byte[2] = adc_command_low;
219 command.
LT_byte[2] = adc_command_high;
220 command.
LT_byte[1] = adc_command_low;
271 uint16_t timer_count = 0;
278 if (timer_count++>eoc_timeout)
304 uint16_t timer_count = 0;
311 if (timer_count++>eoc_timeout)
329 uint16_t timer_count = 0;
336 if (timer_count++>eoc_timeout)
357 adc_command = (adc_command_high << 8) | adc_command_low;
362 if (timer_count++>eoc_timeout)
378 adc_code -= 0x20000000;
379 voltage=(float) adc_code;
380 voltage = voltage / 268435456.0;
381 voltage = voltage *
vref;
393 #ifndef SKIP_EZDRIVE_2X_ZERO_CHECK 394 if (adc_code == 0x00000000)
396 adc_code = 0x20000000;
400 adc_code -= 0x20000000;
401 voltage=(float) adc_code;
402 voltage = voltage / 536870912.0;
403 voltage = voltage *
vref;
413 #ifndef SKIP_EZDRIVE_2X_ZERO_CHECK 414 if (adc_code == 0x00000000)
416 adc_code = 0x20000000;
420 adc_code -= 536870912;
421 adc_voltage=(float)(adc_code+LTC2449_offset_code)*
LTC2449_lsb;
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)
429 zero_code -= 536870912;
430 fs_code -= 536870912;
433 *LTC24XX_lsb = (fs_voltage-zero_voltage)/((
float)(fs_code - zero_code));
435 temp_offset = (zero_voltage/ *LTC24XX_lsb) - zero_code;
436 temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset);
437 *LTC24XX_offset_code = (int32_t)temp_offset;
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.
static uint8_t adc_command
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...
uint8_t LT_byte[4]
4 bytes (unsigned 8-bit integers) to be converted to a 32-bit signed or unsigned integer ...
#define output_high(pin)
Set "pin" high.
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
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.
union LT_union_int32_4bytes data
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.
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's hardware I2C port.
#define output_low(pin)
Set "pin" low.
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".
int32_t LT_int32
32-bit signed integer to be converted to four bytes
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's hardware SPI port.
LT_I2C: Routines to communicate with ATmega328P'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...
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.
void spi_transfer_block(uint8_t cs_pin, uint8_t *tx, uint8_t *rx, uint8_t length)
Reads and sends a byte array.
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.
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...