91 voltage = (float)adc_code;
92 voltage = voltage / (pow(2,16)-1);
97 if ((adc_code & 0x8000) == 0x8000)
99 adc_code = (adc_code ^ 0xFFFF)+1;
102 voltage = sign*(float)adc_code;
103 voltage = voltage / (pow(2,15)-1);
105 voltage = voltage *
vref;
void LTC2308_read(uint8_t cs, uint8_t adc_command, uint16_t *adc_code)
Reads the ADC and returns 16-bit data.
static uint8_t adc_command
static uint8_t uni_bipolar
Default set for unipolar mode.
Header File for Linduino Libraries and Demo Code.
#define LTC2308_UNIPOLAR_MODE
void spi_transfer_word(uint8_t cs_pin, uint16_t tx, uint16_t *rx)
Reads and sends a word.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
float LTC2308_code_to_voltage(uint16_t adc_code, float vref, uint8_t uni_bipolar)
Calculates the LTC2308 input's unipolar voltage given the binary data and lsb weight.
LTC2308: 16-bit 8-channel 100ksps ADC.