82 *data_valid = (code >> 15) & 0x01;
84 *adc_code = code & 0x7FFF;
100 for (timer_count = 0; timer_count <
timeout; timer_count++)
105 if ((ack) || (((reg_data>>status_bit)&0x1)==1))
111 ack |=
LTC2990_adc_read(i2c_address, msb_register_address, &(*adc_code), &(*data_valid));
128 status_bit = msb_register_address/2-1;
159 uint8_t register_data;
163 register_data = register_data & (~bits_to_clear);
164 register_data = register_data | bits_to_set;
176 adc_code = (adc_code ^ 0x7FFF) + 1;
179 adc_code = (adc_code & 0x3FFF);
180 voltage = ((float) adc_code) * LTC2990_single_ended_lsb *
sign;
191 adc_code = (adc_code ^ 0x7FFF) + 1;
195 voltage = (((float) adc_code) * LTC2990_single_ended_lsb *
sign) + 2.5;
206 adc_code = (adc_code ^ 0x7FFF) + 1;
209 voltage = ((float) adc_code) * LTC2990_differential_lsb *
sign;
217 adc_code = (adc_code & 0x1FFF);
222 adc_code = (adc_code | 0xE000);
225 temperature = ((float) adc_code) * LTC2990_temperature_lsb;
227 return (temperature);
234 adc_code = (adc_code & 0x1FFF);
235 voltage = ((float) adc_code) * LTC2990_diode_voltage_lsb;
int8_t LTC2990_adc_read(uint8_t i2c_address, uint8_t msb_register_address, int16_t *adc_code, int8_t *data_valid)
Reads a 14-bit adc_code from LTC2990.
#define LTC2990_STATUS_REG
Indicates BUSY state and conversion status.
int8_t i2c_read_byte_data(uint8_t address, uint8_t command, uint8_t *value)
Read a byte of data at register specified by "command", store in "value".
float LTC2990_code_to_single_ended_voltage(int16_t adc_code, float LTC2990_single_ended_lsb)
Calculates the LTC2990 single-ended input voltages.
Header File for Linduino Libraries and Demo Code.
int8_t LTC2990_adc_read_new_data(uint8_t i2c_address, uint8_t msb_register_address, int16_t *adc_code, int8_t *data_valid, uint16_t timeout)
Reads new data (even after a mode change) by flushing old data and waiting for the data_valid bit to ...
float LTC2990_code_to_vcc_voltage(int16_t adc_code, float LTC2990_single_ended_lsb)
Calculates the LTC2990 Vcc voltage.
LTC2990: 14-bit ADC Quad I2C voltage, current, and temperature monitor.
int8_t LTC2990_register_set_clear_bits(uint8_t i2c_address, uint8_t register_address, uint8_t bits_to_set, uint8_t bits_to_clear)
Used to set and clear bits in a control register.
int8_t LTC2990_register_write(uint8_t i2c_address, uint8_t register_address, uint8_t register_data)
Write one byte to an LTC2990 register.
int8_t i2c_write_byte_data(uint8_t address, uint8_t command, uint8_t value)
Write a byte of data to register specified by "command".
int8_t LTC2990_register_read(uint8_t i2c_address, uint8_t register_address, uint8_t *register_data)
Reads an 8-bit register from the LTC2990 using the standard repeated start format.
int8_t LTC2990_adc_read_timeout(uint8_t i2c_address, uint8_t msb_register_address, int16_t *adc_code, int8_t *data_valid, uint16_t timeout, uint8_t status_bit)
Reads a 14-bit adc_code from the LTC2990 but enforces a maximum timeout.
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.
float LTC2990_temperature(int16_t adc_code, float LTC2990_temperature_lsb, boolean unit)
Calculates the LTC2990 temperature.
float LTC2990_code_to_differential_voltage(int16_t adc_code, float LTC2990_differential_lsb)
Calculates the LTC2990 differential input voltage.
float LTC2990_code_to_diode_voltage(int16_t adc_code, float LTC2990_diode_voltage_lsb)
Calculates the LTC2990 diode voltage.