![]() |
Linduino
1.3.0
Linear Technology Arduino-Compatible Demonstration Board
|
Library for LTC2991: 14-bit Octal I2C Voltage, Current, and Temperature Monitor. More...
Library for LTC2991: 14-bit Octal I2C Voltage, Current, and Temperature Monitor.
Definition in file LTC2991.cpp.
Go to the source code of this file.
Functions | |
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. More... | |
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. More... | |
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 be set. More... | |
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. More... | |
int8_t | LTC2991_register_write (uint8_t i2c_address, uint8_t register_address, uint8_t register_data) |
Write one byte to an LTC2991 register. More... | |
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. More... | |
float | LTC2991_code_to_single_ended_voltage (int16_t adc_code, float LTC2991_single_ended_lsb) |
Calculates the LTC2991 single-ended input voltages. More... | |
float | LTC2991_code_to_vcc_voltage (int16_t adc_code, float LTC2991_single_ended_lsb) |
Calculates the LTC2991 Vcc voltage. More... | |
float | LTC2991_code_to_differential_voltage (int16_t adc_code, float LTC2991_differential_lsb) |
Calculates the LTC2991 differential input voltage. More... | |
float | LTC2991_temperature (int16_t adc_code, float LTC2991_temperature_lsb, boolean unit) |
Calculates the LTC2991 temperature. More... | |
float | LTC2991_code_to_diode_voltage (int16_t adc_code, float LTC2991_diode_voltage_lsb) |
Calcultates the LTC2991 diode voltage. More... | |
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.
i2c_address | I2C address of the LTC2991. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet. |
msb_register_address | Address of the LTC2991 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 LTC2991.cpp.
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 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.
i2c_address | I2C address of the LTC2991. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet. |
msb_register_address | Address of the LTC2991 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 millisceonds. 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 142 of file LTC2991.cpp.
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.
Similar to LTC2991_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 LTC2991 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).
i2c_address | I2C address of the LTC2991. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet. |
msb_register_address | Address of the LTC2991 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 millisceonds. If at any time a NACK is received the function aborts. |
status_bit | If the timeout is reached without valid data (data_valid=1) the function exits./ |
Definition at line 93 of file LTC2991.cpp.
float LTC2991_code_to_differential_voltage | ( | int16_t | adc_code, |
float | LTC2991_differential_lsb | ||
) |
Calculates the LTC2991 differential input voltage.
adc_code | code read from the adc (from a function such as LTC2991_adc_read) |
LTC2991_differential_lsb | differential LSB weight. If not calibrated, use LTC2991_DIFFERENTIAL_LSB |
Definition at line 216 of file LTC2991.cpp.
float LTC2991_code_to_diode_voltage | ( | int16_t | adc_code, |
float | LTC2991_diode_voltage_lsb | ||
) |
Calcultates the LTC2991 diode voltage.
adc_code | code read from the adc (from a function such as LTC2991_adc_read) |
LTC2991_diode_voltage_lsb | diode voltage LSB weight. If not calibrated, use LTC2991_DIODE_VOLTAGE_LSB |
Definition at line 247 of file LTC2991.cpp.
float LTC2991_code_to_single_ended_voltage | ( | int16_t | adc_code, |
float | LTC2991_single_ended_lsb | ||
) |
Calculates the LTC2991 single-ended input voltages.
adc_code | code read from the adc (from a function such as LTC2991_adc_read) |
LTC2991_single_ended_lsb | single-ended LSB weight. If not calibrated, use LTC2991_SINGLE_ENDED_LSB |
Definition at line 186 of file LTC2991.cpp.
float LTC2991_code_to_vcc_voltage | ( | int16_t | adc_code, |
float | LTC2991_single_ended_lsb | ||
) |
Calculates the LTC2991 Vcc voltage.
adc_code | code read from the adc (from a function such as LTC2991_adc_read) |
LTC2991_single_ended_lsb | Vcc LSB weight. If not calibrated, use LTC2991_VCC_LSB |
Definition at line 201 of file LTC2991.cpp.
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.
i2c_address | I2C address of the LTC2991. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet. |
register_address | Address of the LTC2991 register to be read. This is also known as the "command byte". |
register_data | returns 8-bit value read from the LTC2991 register. |
Definition at line 153 of file LTC2991.cpp.
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.
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.
i2c_address | I2C address of the LTC2991. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet. |
register_address | Address of the LTC2991 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 173 of file LTC2991.cpp.
int8_t LTC2991_register_write | ( | uint8_t | i2c_address, |
uint8_t | register_address, | ||
uint8_t | register_data | ||
) |
Write one byte to an LTC2991 register.
Writes to an 8-bit register inside the LTC2991 using the standard I2C repeated start format.
i2c_address | I2C address of the LTC2991. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet. |
register_address | Address of the LTC2991 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 163 of file LTC2991.cpp.
float LTC2991_temperature | ( | int16_t | adc_code, |
float | LTC2991_temperature_lsb, | ||
boolean | unit | ||
) |
Calculates the LTC2991 temperature.
adc_code | code read from the adc (from a function such as LTC2991_adc_read). |
LTC2991_temperature_lsb | temperature LSB weight. If not calibrated, use LTC2991_TEMPERATURE_LSB |
unit | The temperature unit, true for Kelvin, false for Celsius |
Definition at line 230 of file LTC2991.cpp.