Brody Kellish / ltc2991_lib

Dependents:   ece495_firmware

Fork of ltc2991_test by Logan Rooper

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LTC2991.h Source File

LTC2991.h

Go to the documentation of this file.
00001 /*!
00002 LTC2991: 14-bit ADC octal I2C voltage, current, and temperature monitor.
00003 
00004 @verbatim
00005 
00006 The LTC2991 is used to monitor system temperatures, voltages and currents.
00007 Through the I2C serial interface, the eight monitors can individually measure
00008 supply voltages and can be paired for differential measurements of current sense
00009 resistors or temperature sensing transistors. Additional measurements include
00010 internal temperature and internal VCC. The internal 10ppm reference minimizes
00011 the number of supporting components and area required. Selectable address and
00012 configurable functionality give the LTC2991 flexibility to be incorporated in
00013 various systems needing temperature, voltage or current data. The LTC2991 fits
00014 well in systems needing submillivolt voltage resolution, 1% current measurement
00015 and 1 degree Celsius temperature accuracy or any combination of the three.
00016 
00017 I2C DATA FORMAT (MSB FIRST);
00018 
00019 Data Out:
00020 Byte #1                                     Byte #2                    Byte #3
00021 
00022 START  SA6 SA5 SA4 SA3 SA2 SA1 SA0 W SACK   X X X X C3 C2 C1 C0 SACK   D7 D6 D5 D4 D3 D2 D1 D0 SACK STOP
00023 
00024 Data In:
00025 Byte #1                                     Byte #2                                  Byte #3
00026 
00027 START  SA6 SA5 SA4 SA3 SA2 SA1 SA0 W SACK   X X X X C3 C2 C1 C0 SACK   REPEAT START  SA6 SA5 SA4 SA3 SA2 SA1 SA0 R SACK
00028 
00029 Byte #4                              Byte #5
00030 MSB                                  LSB
00031 D15 D14 D13 D12 D11 D10 D9 D8 MACK   D7 D6 D5 D4 D3 D2 D1 D0 MNACK STOP
00032 
00033 START        : I2C Start
00034 REPEAT Start : I2C Repeat Start
00035 STOP         : I2C Stop
00036 SACK         : I2C Slave Generated Acknowledge (Active Low)
00037 MACK         : I2C Master Generated Acknowledge (Active Low)
00038 MNACK        : I2C Master Generated Not Acknowledge
00039 SAx  : I2C Address
00040 W    : I2C Write (0)
00041 R    : I2C Read  (1)
00042 Cx   : Command Code
00043 Dx   : Data Bits
00044 X    : Don't care
00045 
00046 
00047 Example Code:
00048 
00049 Read single-ended voltage from V1.
00050 
00051     // Enable Single-Ended Mode
00052     ack |= LTC2991_register_set_clear_bits(LTC2991_I2C_ADDRESS, LTC2991_CONTROL_V1234_REG, 0x00, LTC2991_V1_V2_DIFFERENTIAL_ENABLE | LTC2991_V1_V2_TEMP_ENABLE);
00053 
00054     // Flush one ADC reading in case it is stale.  Then, take a new fresh reading.
00055     ack |= LTC2991_adc_read_new_data(LTC2991_I2C_ADDRESS, LTC2991_V1_MSB_REG, &code, &data_valid, LTC2991_TIMEOUT);
00056 
00057     voltage = LTC2991_code_to_single_ended_voltage(code, LTC2991_SINGLE_ENDED_lsb); // Converts code to voltage from single-ended lsb
00058 
00059 Read current from V3-V4.
00060 
00061     resistor = 1; // R_sense across V3-V4 in ohms
00062 
00063     // Enable Differential Mode
00064     ack |= LTC2991_register_set_clear_bits(LTC2991_I2C_ADDRESS, LTC2991_CONTROL_V1234_REG, LTC2991_V3_V4_DIFFERENTIAL_ENABLE, LTC2991_V3_V4_TEMP_ENABLE);
00065 
00066     // Flush one ADC reading in case it is stale.  Then, take a new fresh reading.
00067     ack |= LTC2991_adc_read_new_data(LTC2991_I2C_ADDRESS, LTC2991_V4_MSB_REG, &code, &data_valid, LTC2991_TIMEOUT);
00068 
00069     voltage = LTC2991_code_to_differential_voltage(code, LTC2991_DIFFERENTIAL_lsb); // Converts code to voltage from differential lsb
00070     current = voltage / resistor; // Calculates current
00071 
00072 Read temperature from diode connected to V7-V8.
00073 
00074     // Enable temperature mode.
00075     ack |= LTC2991_register_set_clear_bits(LTC2991_I2C_ADDRESS, LTC2991_CONTROL_V5678_REG, LTC2991_V7_V8_TEMP_ENABLE, 0x00);
00076 
00077     // Flush one ADC reading in case it is stale.  Then, take a new fresh reading.
00078     ack |= LTC2991_adc_read_new_data(LTC2991_I2C_ADDRESS, LTC2991_V7_MSB_REG, &adc_code, &data_valid, LTC2991_TIMEOUT);
00079 
00080     // Converts code to temperature from adc code and temperature lsb
00081     temperature = LTC2991_temperature(adc_code, LTC2991_TEMPERATURE_lsb);
00082 
00083 @endverbatim
00084 
00085 http://www.linear.com/product/LTC2991
00086 
00087 http://www.linear.com/product/LTC2991#demoboards
00088 
00089 REVISION HISTORY
00090 $Revision: 3659 $
00091 $Date: 2015-07-01 10:19:20 -0700 (Wed, 01 Jul 2015) $
00092 
00093 Copyright (c) 2013, Linear Technology Corp.(LTC)
00094 All rights reserved.
00095 
00096 Redistribution and use in source and binary forms, with or without
00097 modification, are permitted provided that the following conditions are met:
00098 
00099 1. Redistributions of source code must retain the above copyright notice, this
00100    list of conditions and the following disclaimer.
00101 2. Redistributions in binary form must reproduce the above copyright notice,
00102    this list of conditions and the following disclaimer in the documentation
00103    and/or other materials provided with the distribution.
00104 
00105 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00106 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00107 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00108 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
00109 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00110 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00111 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00112 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00113 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00114 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00115 
00116 The views and conclusions contained in the software and documentation are those
00117 of the authors and should not be interpreted as representing official policies,
00118 either expressed or implied, of Linear Technology Corp.
00119 
00120 The Linear Technology Linduino is not affiliated with the official Arduino team.
00121 However, the Linduino is only possible because of the Arduino team's commitment
00122 to the open-source community.  Please, visit http://www.arduino.cc and
00123 http://store.arduino.cc , and consider a purchase that will help fund their
00124 ongoing work.
00125 
00126 */
00127 /*! @file
00128     @ingroup LTC2991
00129     Library Header File for LTC2991: 14-bit Octal I2C Voltage, Current, and Temperature Monitor
00130 */
00131 
00132 #ifndef LTC2991_H
00133 #define LTC2991_H
00134 
00135 typedef bool boolean;
00136 //#include <Wire.h>
00137 
00138 // Calibration Variables
00139 //! Typical single-ended LSB weight in volts
00140 const float LTC2991_SINGLE_ENDED_lsb = 3.05176E-04;
00141 //! Typical differential LSB weight in volts
00142 const float LTC2991_DIFFERENTIAL_lsb = 1.90735E-05;
00143 //! Typical VCC LSB weight in volts
00144 const float LTC2991_VCC_lsb = 3.05176E-04;
00145 //! Typical temperature LSB weight in degrees Celsius (and Kelvin).
00146 //! Used for internal temperature as well as remote diode temperature measurements.
00147 const float LTC2991_TEMPERATURE_lsb = 0.0625;
00148 //! Typical remote diode LSB weight in volts.
00149 //! Used to readback diode voltage when in temperature measurement mode.
00150 const float LTC2991_DIODE_VOLTAGE_lsb = 3.815E-05;
00151 
00152 /*! @name I2C_Addresses
00153 @{ */
00154 
00155 //! I2C address of the LTC2991.
00156 //! Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet.
00157 //! Uncomment LTC2991_I2C_ADDRESS to match demo board configuration.
00158 //  Address assignment
00159 // LTC2991 I2C Address                //  AD2       AD1       AD0
00160  #define LTC2991_I2C_ADDRESS 0x48      //  Low       Low       Low
00161 // #define LTC2991_I2C_ADDRESS 0x49    //  Low       Low       High
00162 // #define LTC2991_I2C_ADDRESS 0x4A    //  Low       High      Low
00163 // #define LTC2991_I2C_ADDRESS 0x4B    //  Low       High      High
00164 // #define LTC2991_I2C_ADDRESS 0x4C    //  High      Low       Low
00165 // #define LTC2991_I2C_ADDRESS 0x4D    //  High      Low       High
00166 // #define LTC2991_I2C_ADDRESS 0x4E    //  High      High      Low
00167 //#define LTC2991_I2C_ADDRESS 0x4F    //  High      High      High
00168 
00169 //! LTC2991 Global I2C Address.
00170 #define LTC2991_I2C_GLOBAL_ADDRESS 0x77  //  Global Address
00171 
00172 /*! @} */
00173 /*! @name REGISTERS
00174 @{ */
00175 
00176 #define LTC2991_STATUS_LOW_REG              0x00    //!< Data_Valid Bits(V1 Through V8)
00177 #define LTC2991_STATUS_HIGH_REG             0x01    //!< Data_valid bits
00178 #define LTC2991_CHANNEL_ENABLE_REG          0x01    //!< Channel Enable, Vcc, T_internal Conversion Status, Trigger
00179 #define LTC2991_CONTROL_V1234_REG           0x06    //!< V1, V2, V3, and V4 Control Register
00180 #define LTC2991_CONTROL_V5678_REG           0x07    //!< V5, V6, V7, AND V8 Control Register
00181 #define LTC2991_CONTROL_PWM_Tinternal_REG   0x08    //!< PWM Threshold and T_internal Control Register
00182 #define LTC2991_PWM_THRESHOLD_MSB_REG       0x09    //!< PWM Threshold
00183 #define LTC2991_V1_MSB_REG                  0x0A    //!< V1, or T_R1 T MSB
00184 #define LTC2991_V1_LSB_REG                  0x0B    //!< V1, or T_R1 T LSB
00185 #define LTC2991_V2_MSB_REG                  0x0C    //!< V2, V1-V2, or T_R2 Voltage MSB
00186 #define LTC2991_V2_LSB_REG                  0x0D    //!< V2, V1-V2, or T_R2 Voltage LSB
00187 #define LTC2991_V3_MSB_REG                  0x0E    //!< V3, or T_R2 T MSB
00188 #define LTC2991_V3_LSB_REG                  0x0F    //!< V3, or T_R2 T LSB
00189 #define LTC2991_V4_MSB_REG                  0x10    //!< V4, V3-V4, or T_R2 Voltage MSB
00190 #define LTC2991_V4_LSB_REG                  0x11    //!< V4, V3-V4, or T_R2 Voltage LSB
00191 #define LTC2991_V5_MSB_REG                  0x12    //!< V5, or T_R3 T MSB
00192 #define LTC2991_V5_LSB_REG                  0x13    //!< V5, or T_R3 T LSB
00193 #define LTC2991_V6_MSB_REG                  0x14    //!< V6, V5-V6, or T_R3 Voltage MSB
00194 #define LTC2991_V6_LSB_REG                  0x15    //!< V6, V5-V6, or T_R3 Voltage LSB
00195 #define LTC2991_V7_MSB_REG                  0x16    //!< V7, or T_R4 T MSB
00196 #define LTC2991_V7_LSB_REG                  0x17    //!< V7, or T_R4 T LSB
00197 #define LTC2991_V8_MSB_REG                  0x18    //!< V8, V7-V8, or T_R4 Voltage MSB
00198 #define LTC2991_V8_LSB_REG                  0x19    //!< V8, V7-V8, or T_R4 Voltage LSB
00199 #define LTC2991_T_Internal_MSB_REG          0x1A    //!< T_Internal MSB
00200 #define LTC2991_T_Internal_LSB_REG          0x1B    //!< T_Internal LSB
00201 #define LTC2991_Vcc_MSB_REG                 0x1C    //!< Vcc MSB
00202 #define LTC2991_Vcc_LSB_REG                 0x1D    //!< Vcc LSB
00203 
00204 /*! @} */
00205 /*! @name LTC2991_CHANNEL_ENABLE_REG SETTINGS
00206     Bitwise OR settings, and write to LTC2991_CHANNEL_ENABLE_REG to configure settings.
00207     Bitwise AND with value read from LTC2991_CHANNEL_ENABLE_REG to determine present setting.
00208 @{ */
00209 
00210 #define LTC2991_V7_V8_TR4_ENABLE              0x80  //!< Enable V7-V8 measurements, including TR4 temperature
00211 #define LTC2991_V5_V6_TR3_ENABLE              0x40  //!< Enable V5-V6 measurements, including TR3 temperature
00212 #define LTC2991_V3_V4_TR2_ENABLE              0x20  //!< Enable V3-V4 measurements, including TR2 temperature
00213 #define LTC2991_V1_V2_TR1_ENABLE              0x10  //!< Enable V1-V2 measurements, including TR1 temperature
00214 #define LTC2991_VCC_TINTERNAL_ENABLE          0x08  //!< Enable Vcc internal voltage measurement
00215 #define LTC2991_ENABLE_ALL_CHANNELS           0xF8  //!< Use to enable all LTC2991 channels.  Equivalent to bitwise OR'ing all channel enables.
00216 #define LTC2991_BUSY                          0x04  //!< LTC2991 Busy Bit
00217 
00218 /*! @} */
00219 /*! @name LTC2991_CONTROL_V1234_REG SETTINGS
00220     Bitwise OR settings, and write to LTC2991_CONTROL_V1234_REG to configure settings.
00221     Bitwise AND with value read from LTC2991_CONTROL_V1234_REG to determine present setting.
00222 @{ */
00223 
00224 #define LTC2991_V3_V4_FILTER_ENABLE           0x80 //!< Enable filters on V3-V4
00225 #define LTC2991_V3_V4_KELVIN_ENABLE           0x40 //!< Enable V3-V4 for Kelvin. Otherwise, Celsius.
00226 #define LTC2991_V3_V4_TEMP_ENABLE             0x20 //!< Enable V3-V4 temperature mode.
00227 #define LTC2991_V3_V4_DIFFERENTIAL_ENABLE     0x10 //!< Enable V3-V4 differential mode.  Otherwise, single-ended.
00228 #define LTC2991_V1_V2_FILTER_ENABLE           0x08 //!< Enable filters on V1-V2
00229 #define LTC2991_V1_V2_KELVIN_ENABLE           0x04 //!< Enable V1-V2 for Kelvin. Otherwise, Celsius.
00230 #define LTC2991_V1_V2_TEMP_ENABLE             0x02 //!< Enable V1-V2 temperature mode.
00231 #define LTC2991_V1_V2_DIFFERENTIAL_ENABLE     0x01 //!< Enable V1-V2 differential mode.  Otherwise, single-ended.
00232 
00233 /*! @} */
00234 /*! @name LTC2991_CONTROL_V5678_REG SETTINGS
00235     Bitwise OR settings, and write to LTC2991_CONTROL_V5678_REG to configure settings.
00236     Bitwise AND with value read from LTC2991_CONTROL_V5678_REG to determine present setting.
00237 @{ */
00238 
00239 #define LTC2991_V7_V8_FILTER_ENABLE           0x80 //!< Enable filters on V7-V8
00240 #define LTC2991_V7_V8_KELVIN_ENABLE           0x40 //!< Enable V7-V8 for Kelvin. Otherwise, Celsius.
00241 #define LTC2991_V7_V8_TEMP_ENABLE             0x20 //!< Enable V7-V8 temperature mode.
00242 #define LTC2991_V7_V8_DIFFERENTIAL_ENABLE     0x10 //!< Enable V7-V8 differential mode.  Otherwise, single-ended.
00243 #define LTC2991_V5_V6_FILTER_ENABLE           0x08 //!< Enable filters on V5-V6
00244 #define LTC2991_V5_V6_KELVIN_ENABLE           0x04 //!< Enable V5-V6 for Kelvin. Otherwise, Celsius.
00245 #define LTC2991_V5_V6_TEMP_ENABLE             0x02 //!< Enable V5-V6 temperature mode.
00246 #define LTC2991_V5_V6_DIFFERENTIAL_ENABLE     0x01 //!< Enable V5-V6 differential mode.  Otherwise, single-ended.
00247 
00248 /*! @} */
00249 /*! @name LTC2991_CONTROL_PWM_Tinternal_REG SETTINGS
00250     Bitwise OR settings, and write to LTC2991_CONTROL_PWM_Tinternal_REG to configure settings.
00251     Bitwise AND with value read from LTC2991_CONTROL_PWM_Tinternal_REG to determine present setting.
00252 @{ */
00253 
00254 #define LTC2991_PWM_0                         0x80 //!< PWM threshold Least Significant Bit
00255 #define LTC2991_PWM_INVERT                    0x40 //!< Invert PWM
00256 #define LTC2991_PWM_ENABLE                    0x20 //!< Enable PWM
00257 #define LTC2991_REPEAT_MODE                   0x10 //!< Enable Repeated Aquisition Mode
00258 #define LTC2991_INT_FILTER_ENABLE             0x08 //!< Enable Internal Temperature Filter
00259 #define LTC2991_INT_KELVIN_ENABLE             0x04 //!< Enable internal temperature for Kelvin. Otherwise, Celsius.
00260 /*!@} */
00261 
00262 #include "LT_I2C.h "
00263 
00264 
00265 class LTC2991 {
00266 
00267 private:
00268     LT_I2C *lti2c;
00269 
00270 
00271 public:
00272 LTC2991();
00273 LTC2991(PinName i2c_scl_, PinName i2c_sda_);
00274 
00275 //! Reads a 14-bit adc_code from LTC2991.
00276 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
00277 int8_t LTC2991_adc_read(uint8_t i2c_address,    //!< I2C address of the LTC2991. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet.
00278                         uint8_t msb_register_address,        /*!< Address of the LTC2991 MSB register to be read. This is also known as the "command byte".
00279                                                      Two sequential 8-bit registers are read, starting with the msb_register_address.*/
00280                         int16_t *adc_code,      //!< returns 14-bit value read from the adc
00281                         int8_t *data_valid      //!< returns the status of the DATA_VALID bit. *data_valid=0 indicates stale data
00282                        );
00283 
00284 //! Reads a 14-bit adc_code from the LTC2991 but enforces a maximum timeout.
00285 //! 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)
00286 //! expires. It keeps trying to read from the LTC2991 every millisecond until the data_valid bit is set (indicating new data since the previous
00287 //! time this register was read) or until it fails to receive an I2C acknowledge (indicating an error on the I2C bus).
00288 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
00289 int8_t LTC2991_adc_read_timeout(uint8_t i2c_address,    //!< I2C address of the LTC2991. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet.
00290                                 uint8_t msb_register_address,        /*!< Address of the LTC2991 MSB register to be read. This is also known as the "command byte".
00291                                                              Two sequential 8-bit registers will be read, starting with the msb_register_address.*/
00292                                 int16_t *adc_code,      //!< returns 14-bit value read from the adc
00293                                 int8_t *data_valid,     //!< returns the status of the DATA_VALID bit. *data_valid=0 indicates stale data
00294                                 uint16_t timeout,        //!< maximum timeout in millisceonds. If at any time a NACK is received the function aborts.
00295                                 uint8_t status_bit        //!<                     If the timeout is reached without valid data (*data_valid=1) the function exits.*/
00296                                );
00297 
00298 //! Reads new data (even after a mode change) by flushing old data and waiting for the data_valid bit to be set.
00299 //! This function simplifies adc reads when modes are changing.  For example, if V1-V2 changes from temperature mode
00300 //! to differential voltage mode, the data in the register may still correspond to the temperature reading immediately
00301 //! after the mode change.  Flushing one reading and waiting for a new reading guarantees fresh data is received.
00302 //! If the timeout is reached without valid data (*data_valid=1) the function exits.
00303 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
00304 int8_t LTC2991_adc_read_new_data(uint8_t i2c_address,   //!< I2C address of the LTC2991. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet.
00305                                  uint8_t msb_register_address,       /*!< Address of the LTC2991 MSB register to be read. This is also known as the "command byte".
00306                                                              Two sequential 8-bit registers will be read, starting with the msb_register_address.*/
00307                                  int16_t *adc_code,     //!< returns 14-bit value read from the adc
00308                                  int8_t *data_valid,    //!< returns the status of the DATA_VALID bit. *data_valid=0 indicates stale data
00309                                  uint16_t timeout       /*!< maximum timeout in millisceonds. If at any time a NACK is received the function aborts.
00310                                                              If the timeout is reached without valid data (*data_valid=1) the function exits.*/
00311                                 );
00312 
00313 //! Reads an 8-bit register from the LTC2991 using the standard repeated start format.
00314 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
00315 int8_t LTC2991_register_read(uint8_t i2c_address,       //!< I2C address of the LTC2991. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet.
00316                              uint8_t register_address,  //!< Address of the LTC2991 register to be read. This is also known as the "command byte".
00317                              uint8_t *register_data     //!< returns 8-bit value read from the LTC2991 register.
00318                             );
00319 
00320 //! Write one byte to an LTC2991 register.
00321 //! Writes to an 8-bit register inside the LTC2991 using the standard I2C repeated start format.
00322 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
00323 int8_t LTC2991_register_write(uint8_t i2c_address,      //!< I2C address of the LTC2991. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet.
00324                               uint8_t register_address, //!< Address of the LTC2991 register to be overwritten.  This is also known as the "command byte".
00325                               uint8_t register_data     //!< Value that will be written to the register.
00326                              );
00327 
00328 
00329 //! Used to set and clear bits in a control register.  bits_to_set will be bitwise OR'd with the register.
00330 //! 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.
00331 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
00332 int8_t LTC2991_register_set_clear_bits(uint8_t i2c_address,         //!< I2C address of the LTC2991. Configured by tying the ADR0, ADR1, and ADR2 pins high or low. See Table 1 of datasheet.
00333                                        uint8_t register_address,    //!< Address of the LTC2991 register to be modified.
00334                                        uint8_t bits_to_set,         //!< bits_to_set will be bitwise OR'd with the register.
00335                                        uint8_t bits_to_clear        //!< bits_to_clear will be inverted and bitwise AND'd with the register
00336                                       );
00337 
00338 //! Calculates the LTC2991 single-ended input voltages
00339 //! @return the single-ended voCalculatesltage in volts
00340 float LTC2991_code_to_single_ended_voltage(int16_t adc_code,                //!< code read from the adc (from a function such as LTC2991_adc_read)
00341     float LTC2991_single_ended_lsb   //!< single-ended LSB weight. If not calibrated, use LTC2991_SINGLE_ENDED_LSB
00342                                           );
00343 
00344 //! Calculates the LTC2991 Vcc voltage
00345 //! @return the Vcc voltage in volts
00346 float LTC2991_code_to_vcc_voltage(int16_t adc_code,                 //!< code read from the adc (from a function such as LTC2991_adc_read)
00347                                   float LTC2991_single_ended_lsb    //!< Vcc LSB weight. If not calibrated, use LTC2991_VCC_LSB
00348                                  );
00349 
00350 //! Calculates the LTC2991 differential input voltage.
00351 //! @return the differential voltage in volts
00352 float LTC2991_code_to_differential_voltage(int16_t adc_code,                //!< code read from the adc (from a function such as LTC2991_adc_read)
00353     float LTC2991_differential_lsb   //!< differential LSB weight. If not calibrated, use LTC2991_DIFFERENTIAL_LSB
00354                                           );
00355 
00356 //! Calculates the LTC2991 temperature
00357 //! @return the temperature in degrees Celsius or degrees Kevlin (dependent on mode setting).
00358 float LTC2991_temperature(int16_t adc_code,                 //!< code read from the adc (from a function such as LTC2991_adc_read).
00359                           float LTC2991_temperature_lsb,     //!< temperature LSB weight. If not calibrated, use LTC2991_TEMPERATURE_LSB
00360                           boolean unit                     //!< The temperature unit, true for Kelvin, false for Celsius
00361                          );
00362 
00363 //! Calcultates the LTC2991 diode voltage
00364 //! @return the diode voltage in volts.
00365 float LTC2991_code_to_diode_voltage(int16_t adc_code,               //!< code read from the adc (from a function such as LTC2991_adc_read)
00366                                     float LTC2991_diode_voltage_lsb //!< diode voltage LSB weight. If not calibrated, use LTC2991_DIODE_VOLTAGE_LSB
00367                                    );
00368 };
00369 #endif  // LTC2991_H