103 voltage = (float)adc_code;
104 voltage = voltage / (pow(2,16)-1);
108 if ((adc_code & 0x8000) == 0x8000)
110 adc_code = (adc_code ^ 0xFFFF)+1;
113 voltage = sign*(float)adc_code;
114 voltage = voltage / (pow(2,15)-1);
117 voltage = voltage *
vref;
static uint8_t adc_command
static uint8_t uni_bipolar
Default set for unipolar mode.
Header File for Linduino Libraries and Demo Code.
static uint8_t range_low_high
Default set for high range mode.
void spi_transfer_word(uint8_t cs_pin, uint16_t tx, uint16_t *rx)
Reads and sends a word.
void LTC1859_read(uint8_t cs, uint8_t adc_command, uint16_t *adc_code)
Reads the ADC and returns 16-bit data.
LTC1859: 16-bit 8-channel 100ksps ADC.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
#define LTC1859_UNIPOLAR_MODE
uint8_t LTC1859_build_command(uint8_t ch_designate, uint8_t uni_bipolar, uint8_t range_low_high)
Builds the ADC command and returns an 8 bit command.
float LTC1859_code_to_voltage(uint16_t adc_code, float vref, uint8_t range_low_high, uint8_t uni_bipolar)
Calculates the LTC1859 input's unipolar voltage given the binary data and lsb weight.
#define LTC1859_LOW_RANGE_MODE