82 *data_valid = (code >> 15) & 0x01;
84 *adc_code = code & 0x7FFF;
99 for (timer_count = 0; timer_count <
timeout; timer_count++)
119 if ((ack) || (((reg_data>>status_bit)&0x1)==1))
127 ack |=
LTC2991_adc_read(i2c_address, msb_register_address, &(*adc_code), &(*data_valid));
130 Serial.println(
"Data not valid");
131 Serial.println(*data_valid);
146 ack |=
LTC2991_adc_read_timeout(i2c_address, msb_register_address, &(*adc_code), &(*data_valid), timeout, ((msb_register_address/2) - 0x05));
147 ack |=
LTC2991_adc_read_timeout(i2c_address, msb_register_address, &(*adc_code), &(*data_valid), timeout, ((msb_register_address/2) - 0x05));
175 uint8_t register_data;
179 register_data = register_data & (~bits_to_clear);
180 register_data = register_data | bits_to_set;
192 adc_code = (adc_code ^ 0x7FFF) + 1;
195 adc_code = (adc_code & 0x3FFF);
196 voltage = ((float) adc_code) * LTC2991_single_ended_lsb *
sign;
207 adc_code = (adc_code ^ 0x7FFF) + 1;
211 voltage = (((float) adc_code) * LTC2991_single_ended_lsb *
sign) + 2.5;
222 adc_code = (adc_code ^ 0x7FFF) + 1;
225 voltage = ((float) adc_code) * LTC2991_differential_lsb *
sign;
233 adc_code = (adc_code & 0x1FFF);
238 adc_code = (adc_code | 0xE000);
241 temperature = ((float) adc_code) * LTC2991_temperature_lsb;
243 return (temperature);
250 adc_code = (adc_code & 0x1FFF);
251 voltage = ((float) adc_code) * LTC2991_diode_voltage_lsb;
int8_t LTC2991_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 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".
int8_t LTC2991_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 LTC2991 but enforces a maximum timeout.
float LTC2991_code_to_vcc_voltage(int16_t adc_code, float LTC2991_single_ended_lsb)
Calculates the LTC2991 Vcc voltage.
Header File for Linduino Libraries and Demo Code.
int8_t LTC2991_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 LTC2991.
float LTC2991_code_to_diode_voltage(int16_t adc_code, float LTC2991_diode_voltage_lsb)
Calcultates the LTC2991 diode voltage.
int8_t LTC2991_register_write(uint8_t i2c_address, uint8_t register_address, uint8_t register_data)
Write one byte to an LTC2991 register.
float LTC2991_code_to_differential_voltage(int16_t adc_code, float LTC2991_differential_lsb)
Calculates the LTC2991 differential input voltage.
float LTC2991_code_to_single_ended_voltage(int16_t adc_code, float LTC2991_single_ended_lsb)
Calculates the LTC2991 single-ended input voltages.
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".
#define LTC2991_STATUS_LOW_REG
Data_Valid Bits(V1 Through V8)
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.
int8_t LTC2991_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 ...
int8_t LTC2991_register_read(uint8_t i2c_address, uint8_t register_address, uint8_t *register_data)
Reads an 8-bit register from the LTC2991 using the standard repeated start format.
float LTC2991_temperature(int16_t adc_code, float LTC2991_temperature_lsb, boolean unit)
Calculates the LTC2991 temperature.
LTC2991: 14-bit ADC octal I2C voltage, current, and temperature monitor.
#define LTC2991_STATUS_HIGH_REG
Data_valid bits.