| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

Functions
LTC2990.cpp File Reference
Power Monitors and Coulomb Counters » LTC2990: 14-bit Quad I2C Voltage, Current, and Temperature Monitor

Library for LTC2990: 14-bit Quad I2C Voltage, Current, and Temperature Monitor. More...

## Detailed Description

Library for LTC2990: 14-bit Quad I2C Voltage, Current, and Temperature Monitor.

Definition in file LTC2990.cpp.

Go to the source code of this file.

## Functions
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. More...
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. More...
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 be set. More...
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. More...
int8_t | LTC2990_register_write (uint8_t i2c_address, uint8_t register_address, uint8_t register_data)
| Write one byte to an LTC2990 register. More...
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. More...
float | LTC2990_code_to_single_ended_voltage (int16_t adc_code, float LTC2990_single_ended_lsb)
| Calculates the LTC2990 single-ended input voltages. More...
float | LTC2990_code_to_vcc_voltage (int16_t adc_code, float LTC2990_single_ended_lsb)
| Calculates the LTC2990 Vcc voltage. More...
float | LTC2990_code_to_differential_voltage (int16_t adc_code, float LTC2990_differential_lsb)
| Calculates the LTC2990 differential input voltage. More...
float | LTC2990_temperature (int16_t adc_code, float LTC2990_temperature_lsb, boolean unit)
| Calculates the LTC2990 temperature. More...
float | LTC2990_code_to_diode_voltage (int16_t adc_code, float LTC2990_diode_voltage_lsb)
| Calculates the LTC2990 diode voltage. More...

## Function Documentation

## ◆ LTC2990_adc_read()

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.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.

Parameters

  i2c_address | I2C address of the LTC2990. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet.
  msb_register_address | Address of the LTC2990 MSB register to be read. This is also known as the "command byte". Two sequential 8-bit registers are read, starting with the msb_register_address.
  adc_code | returns 14-bit value read from the ADC
  data_valid | returns the status of the DATA_VALID bit. *data_valid=0 indicates stale data

Definition at line 76 of file LTC2990.cpp.

## ◆ LTC2990_adc_read_new_data()

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 be set.

This function simplifies ADC reads when modes are changing. For example, if V1-V2 changes from temperature mode to differential voltage mode, the data in the register may still correspond to the temperature reading immediately after the mode change. Flushing one reading and waiting for a new reading guarantees fresh data is received. If the timeout is reached without valid data (*data_valid=1) the function exits.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.

Parameters

  i2c_address | I2C address of the LTC2990. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet.
  msb_register_address | Address of the LTC2990 MSB register to be read. This is also known as the "command byte". Two sequential 8-bit registers will be read, starting with the msb_register_address.
  adc_code | returns 14-bit value read from the ADC
  data_valid | returns the status of the DATA_VALID bit. *data_valid=0 indicates stale data
  timeout | maximum timeout in milliseconds. If at any time a NACK is received the function aborts. If the timeout is reached without valid data (*data_valid=1) the function exits.

Definition at line 124 of file LTC2990.cpp.

## ◆ LTC2990_adc_read_timeout()

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.

Similar to LTC2990_adc_read except it repeats until the data_valid bit is set, it fails to receive an I2C acknowledge, or the timeout (in milliseconds) expires. It keeps trying to read from the LTC2990 every millisecond until the data_valid bit is set (indicating new data since the previous time this register was read) or until it fails to receive an I2C acknowledge (indicating an error on the I2C bus).

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.

Parameters

  i2c_address | I2C address of the LTC2990. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet.
  msb_register_address | Address of the LTC2990 MSB register to be read. This is also known as the "command byte". Two sequential 8-bit registers will be read, starting with the msb_register_address.
  adc_code | returns 14-bit value read from the ADC
  data_valid | returns the status of the DATA_VALID bit. *data_valid=0 indicates stale data
  timeout | maximum timeout in milliseconds. If at any time a NACK is received the function aborts.

Definition at line 93 of file LTC2990.cpp.

## ◆ LTC2990_code_to_differential_voltage()

float LTC2990_code_to_differential_voltage | ( | int16_t | adc_code,
|  | float | LTC2990_differential_lsb
| ) |  |

Calculates the LTC2990 differential input voltage.

Returns
  the differential voltage in volts

Parameters

  adc_code | code read from the ADC (from a function such as LTC2990_adc_read)
  LTC2990_differential_lsb | differential LSB weight. If not calibrated, use LTC2990_DIFFERENTIAL_LSB

Definition at line 200 of file LTC2990.cpp.

## ◆ LTC2990_code_to_diode_voltage()

float LTC2990_code_to_diode_voltage | ( | int16_t | adc_code,
|  | float | LTC2990_diode_voltage_lsb
| ) |  |

Calculates the LTC2990 diode voltage.

Returns
  the diode voltage in volts.

Parameters

  adc_code | code read from the ADC (from a function such as LTC2990_adc_read)
  LTC2990_diode_voltage_lsb | diode voltage LSB weight. If not calibrated, use LTC2990_DIODE_VOLTAGE_LSB

Definition at line 231 of file LTC2990.cpp.

## ◆ LTC2990_code_to_single_ended_voltage()

float LTC2990_code_to_single_ended_voltage | ( | int16_t | adc_code,
|  | float | LTC2990_single_ended_lsb
| ) |  |

Calculates the LTC2990 single-ended input voltages.

Returns
  the single-ended voltage in volts

Parameters

  adc_code | code read from the ADC (from a function such as LTC2990_adc_read)
  LTC2990_single_ended_lsb | single-ended LSB weight. If not calibrated, use LTC2990_SINGLE_ENDED_LSB

Definition at line 170 of file LTC2990.cpp.

## ◆ LTC2990_code_to_vcc_voltage()

float LTC2990_code_to_vcc_voltage | ( | int16_t | adc_code,
|  | float | LTC2990_single_ended_lsb
| ) |  |

Calculates the LTC2990 Vcc voltage.

Returns
  the Vcc voltage in volts

Parameters

  adc_code | code read from the ADC (from a function such as LTC2990_adc_read)
  LTC2990_single_ended_lsb | Vcc LSB weight. If not calibrated, use LTC2990_VCC_LSB

Definition at line 185 of file LTC2990.cpp.

## ◆ LTC2990_register_read()

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.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.

Parameters

  i2c_address | I2C address of the LTC2990. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet.
  register_address | Address of the LTC2990 register to be read. This is also known as the "command byte".
  register_data | returns 8-bit value read from the LTC2990 register.

Definition at line 137 of file LTC2990.cpp.

## ◆ LTC2990_register_set_clear_bits()

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.

bits_to_set will be bitwise OR'd with the register. bits_to_clear will be inverted and bitwise AND'd with the register so that every location with a 1 will result in a 0 in the register.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.

Parameters

  i2c_address | I2C address of the LTC2990. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet.
  register_address | Address of the LTC2990 register to be modified.
  bits_to_set | bits_to_set will be bitwise OR'd with the register.
  bits_to_clear | bits_to_clear will be inverted and bitwise AND'd with the register

Definition at line 157 of file LTC2990.cpp.

## ◆ LTC2990_register_write()

int8_t LTC2990_register_write | ( | uint8_t | i2c_address,
|  | uint8_t | register_address,
|  | uint8_t | register_data
| ) |  |

Write one byte to an LTC2990 register.

Writes to an 8-bit register inside the LTC2990 using the standard I2C repeated start format.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.

Parameters

  i2c_address | I2C address of the LTC2990. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet.
  register_address | Address of the LTC2990 register to be overwritten. This is also known as the "command byte".
  register_data | Value that will be written to the register.

Definition at line 147 of file LTC2990.cpp.

## ◆ LTC2990_temperature()

float LTC2990_temperature | ( | int16_t | adc_code,
|  | float | LTC2990_temperature_lsb,
|  | boolean | unit
| ) |  |

Calculates the LTC2990 temperature.

Returns
  the temperature in degrees Celsius or degrees Kelvin (dependent on mode setting).

Parameters

  adc_code | code read from the ADC (from a function such as LTC2990_adc_read).
  LTC2990_temperature_lsb | temperature LSB weight. If not calibrated, use LTC2990_TEMPERATURE_LSB
  unit | The temperature unit, true for Kelvin, false for Celsius

Definition at line 214 of file LTC2990.cpp.