113 voltage = (float)adc_code;
114 voltage = voltage / (pow(2,16)-1);
119 if ((adc_code & 0x8000) == 0x8000)
121 adc_code = (adc_code ^ 0xFFFF)+1;
124 voltage = sign*(float)adc_code;
125 voltage = voltage / (pow(2,15)-1);
127 voltage = voltage *
vref;
int8_t LTC2309_read(uint8_t i2c_address, uint8_t adc_command, uint16_t *ptr_adc_code)
Reads 12-bit code from LTC2309, programs channel and mode for next conversion.
static uint8_t adc_command
static uint8_t uni_bipolar
Default set for unipolar mode.
Header File for Linduino Libraries and Demo Code.
#define LTC2309_UNIPOLAR_MODE
union LT_union_int32_4bytes data
uint16_t LT_uint16
16-bit unsigned integer to be converted to two bytes
LTC2309: 8-channel, 12-Bit SAR ADC with I2C interface LTC2301: 1-Channel, 12-Bit ADCs with I2C Compat...
int8_t i2c_read_word_data(uint8_t address, uint8_t command, uint16_t *value)
Read a 16-bit word of data from register specified by "command".
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
This union splits one int16_t (16-bit signed integer) or uint16_t (16-bit unsigned integer) into two ...
uint8_t LT_byte[2]
2 bytes (unsigned 8-bit integers) to be converted to a 16-bit signed or unsigned integer ...
float LTC2309_code_to_voltage(uint16_t adc_code, float vref, uint8_t uni_bipolar)
Calculates the LTC2309 input voltage.