Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC2945.h
Go to the documentation of this file.
1 /*!
2  LTC2945: 12-Bit Wide Range Power Monitor
3 
4 @verbatim
5 
6 The LTC2945 is a rail-to-rail system monitor that measures current, voltage, and
7 power. It features an operating range of 2.7V to 80V and includes a shunt
8 regulator for supplies above 80V to allow flexibility in the selection of input
9 supply. The current measurement range of 0V to 80V is independent of the input
10 supply. An onboard 0.75% accurate 12-bit ADC measures load current, input
11 voltage and an auxiliary external voltage. A 24-bit power value is generated by
12 digitally multiplying the measured 12-bit load current and input voltage data.
13 Minimum and maximum values are stored and an overrange alert with programmable
14 thresholds minimizes the need for software polling. Data is reported via a
15 standard I2C interface. Shutdown mode reduces power consumption to 20uA.
16 standard I2C interface. Shutdown mode reduces power consumption to 20uA.
17 
18 I2C DATA FORMAT (MSB FIRST):
19 
20 Data Out:
21 Byte #1 Byte #2 Byte #3
22 
23 START SA6 SA5 SA4 SA3 SA2 SA1 SA0 W SACK X X C5 C4 C3 C2 C1 C0 SACK D7 D6 D5 D4 D3 D2 D1 D0 SACK STOP
24 
25 Data In:
26 Byte #1 Byte #2 Byte #3
27 
28 START SA6 SA5 SA4 SA3 SA2 SA1 SA0 W SACK X X C5 C4 C3 C2 C1 C0 SACK Repeat Start SA6 SA5 SA4 SA3 SA2 SA1 SA0 R SACK
29 
30 Byte #4 Byte #5
31 MSB LSB
32 D15 D14 D13 D12 D11 D10 D9 D8 MACK D7 D6 D5 D4 D3 D2 D1 D0 MNACK STOP
33 
34 START : I2C Start
35 Repeat Start: I2c Repeat Start
36 STOP : I2C Stop
37 SAx : I2C Address
38 SACK : I2C Slave Generated Acknowledge (Active Low)
39 MACK : I2C Master Generated Acknowledge (Active Low)
40 MNACK : I2c Master Generated Not Acknowledge
41 W : I2C Write (0)
42 R : I2C Read (1)
43 Cx : Command Code
44 Dx : Data Bits
45 X : Don't care
46 
47 
48 
49 Example Code:
50 
51 Read power, current, and voltage.
52 
53  adc_command = LTC2945_SENSE_MONITOR | LTC2945_CONTINUOUS_MODE; // Builds commands to set LTC2945 to continuous mode
54  ack |= LTC2945_write(LTC2945_I2C_ADDRESS, LTC2945_CONTROL_REG, adc_command); // Sets the LTC2945 to continuous mode
55 
56  resistor = .02; // Resistor Value On Demo Board
57 
58  ack |= LTC2945_read_24_bits(LTC2945_I2C_ADDRESS, LTC2945_POWER_MSB2_REG, &power_code); // Reads the ADC registers that contains V^2
59  power = LTC2945_code_to_power(power_code, resistor, LTC2945_Power_lsb); // Calculates power from power code, resistor value and power lsb
60 
61  ack |= LTC2945_read_12_bits(LTC2945_I2C_ADDRESS, LTC2945_DELTA_SENSE_MSB_REG, &current_code); // Reads the voltage code across sense resistor
62  current = LTC2945_code_to_current(current_code, resistor, LTC2945_DELTA_SENSE_lsb); // Calculates current from current code, resistor value and current lsb
63 
64  ack |= LTC2945_read_12_bits(LTC2945_I2C_ADDRESS, LTC2945_VIN_MSB_REG, &VIN_code); // Reads VIN voltage code
65  VIN = LTC2945_VIN_code_to_voltage(VIN_code, LTC2945_VIN_lsb); // Calculates VIN voltage from VIN code and lsb
66 
67 
68 @endverbatim
69 
70 http://www.linear.com/product/LTC2945
71 
72 http://www.linear.com/product/ltc2945#demoboards
73 
74 
75 Copyright 2018(c) Analog Devices, Inc.
76 
77 All rights reserved.
78 
79 Redistribution and use in source and binary forms, with or without
80 modification, are permitted provided that the following conditions are met:
81  - Redistributions of source code must retain the above copyright
82  notice, this list of conditions and the following disclaimer.
83  - Redistributions in binary form must reproduce the above copyright
84  notice, this list of conditions and the following disclaimer in
85  the documentation and/or other materials provided with the
86  distribution.
87  - Neither the name of Analog Devices, Inc. nor the names of its
88  contributors may be used to endorse or promote products derived
89  from this software without specific prior written permission.
90  - The use of this software may or may not infringe the patent rights
91  of one or more patent holders. This license does not release you
92  from the requirement that you obtain separate licenses from these
93  patent holders to use this software.
94  - Use of the software either in source or binary form, must be run
95  on or directly connected to an Analog Devices Inc. component.
96 
97 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
98 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
99 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
100 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
101 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
102 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
103 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
104 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
105 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
106 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
107 */
108 
109 /*! @file
110  @ingroup LTC2945
111  Header for LTC2945: 12-bit Wide Range Power Monitor
112 */
113 
114 #ifndef LTC2945_H
115 #define LTC2945_H
116 
117 #include <Wire.h>
118 
119 //! Use table to select address
120 /*!
121 | LTC2945 I2C Address Assignment | Value | AD1 | AD2 |
122 | :-------------------------------- | :---: | :------: | :------: |
123 | LTC2945_I2C_ADDRESS | 0x67 | High | Low |
124 | LTC2945_I2C_ADDRESS | 0x68 | Float | High |
125 | LTC2945_I2C_ADDRESS | 0x69 | High | High |
126 | LTC2945_I2C_ADDRESS | 0x6A | Float | Float |
127 | LTC2945_I2C_ADDRESS | 0x6B | Float | Low |
128 | LTC2945_I2C_ADDRESS | 0x6C | Low | High |
129 | LTC2945_I2C_ADDRESS | 0x6D | High | Float |
130 | LTC2945_I2C_ADDRESS | 0x6E | Low | Float |
131 | LTC2945_I2C_ADDRESS | 0x6F | Low | Low |
132 | | | | |
133 | LTC2945_I2C_MASS_WRITE | 0xCC | X | X |
134 | LTC2945_I2C_ALERT_RESPONSE | 0x19 | X | X |
135 */
136 /*! @name LTC2945 I2C Address Assignments
137 @{ */
138 
139 // Address Choices:
140 // To choose an address, comment out all options except the
141 // configuration on the demo board.
142 
143 // Address assignment
144 // LTC2945 I2C Address // AD1 AD0
145 // #define LTC2945_I2C_ADDRESS 0x67 // High Low
146 // #define LTC2945_I2C_ADDRESS 0x68 // Float High
147 // #define LTC2945_I2C_ADDRESS 0x69 // High High
148 // #define LTC2945_I2C_ADDRESS 0x6A // Float Float
149 // #define LTC2945_I2C_ADDRESS 0x6B // Float Low
150 // #define LTC2945_I2C_ADDRESS 0x6C // Low High
151 // #define LTC2945_I2C_ADDRESS 0x6D // High Float
152 // #define LTC2945_I2C_ADDRESS 0x6E // Low Float
153 #define LTC2945_I2C_ADDRESS 0x6F // Low Low
154 
155 #define LTC2945_I2C_MASS_WRITE 0xCC
156 #define LTC2945_I2C_ALERT_RESPONSE 0x19
157 //! @}
158 
159 
160 /*!
161 | Name | Value |
162 | :------------------------------------------------ | :---: |
163 | LTC2945_CONTROL_REG | 0x00 |
164 | LTC2945_ALERT_REG | 0x01 |
165 | LTC2945_STATUS_REG | 0x02 |
166 | LTC2945_FAULT_REG | 0x03 |
167 | LTC2945_FAULT_CoR_REG | 0x04 |
168 | LTC2945_POWER_MSB2_REG | 0x05 |
169 | LTC2945_POWER_MSB1_REG | 0x06 |
170 | LTC2945_POWER_LSB_REG | 0x07 |
171 | LTC2945_MAX_POWER_MSB2_REG | 0x08 |
172 | LTC2945_MAX_POWER_MSB1_REG | 0x09 |
173 | LTC2945_MAX_POWER_LSB_REG | 0x0A |
174 | LTC2945_MIN_POWER_MSB2_REG | 0x0B |
175 | LTC2945_MIN_POWER_MSB1_REG | 0x0C |
176 | LTC2945_MIN_POWER_LSB_REG | 0x0D |
177 | LTC2945_MAX_POWER_THRESHOLD_MSB2_REG | 0x0E |
178 | LTC2945_MAX_POWER_THRESHOLD_MSB1_REG | 0x0F |
179 | LTC2945_MAX_POWER_THRESHOLD_LSB_REG | 0x10 |
180 | LTC2945_MIN_POWER_THRESHOLD_MSB2_REG | 0x11 |
181 | LTC2945_MIN_POWER_THRESHOLD_MSB1_REG | 0x12 |
182 | LTC2945_MIN_POWER_THRESHOLD_LSB_REG | 0x13 |
183 | LTC2945_DELTA_SENSE_MSB_REG | 0x14 |
184 | LTC2945_DELTA_SENSE_LSB_REG | 0x15 |
185 | LTC2945_MAX_DELTA_SENSE_MSB_REG | 0x16 |
186 | LTC2945_MAX_DELTA_SENSE_LSB_REG | 0x17 |
187 | LTC2945_MIN_DELTA_SENSE_MSB_REG | 0x18 |
188 | LTC2945_MIN_DELTA_SENSE_LSB_REG | 0x19 |
189 | LTC2945_MAX_DELTA_SENSE_THRESHOLD_MSB_REG | 0x1A |
190 | LTC2945_MAX_DELTA_SENSE_THRESHOLD_LSB_REG | 0x1B |
191 | LTC2945_MIN_DELTA_SENSE_THRESHOLD_MSB_REG | 0x1C |
192 | LTC2945_MIN_DELTA_SENSE_THRESHOLD_LSB_REG | 0x1D |
193 | LTC2945_VIN_MSB_REG | 0x1E |
194 | LTC2945_VIN_LSB_REG | 0x1F |
195 | LTC2945_MAX_VIN_MSB_REG | 0x20 |
196 | LTC2945_MAX_VIN_LSB_REG | 0x21 |
197 | LTC2945_MIN_VIN_MSB_REG | 0x22 |
198 | LTC2945_MIN_VIN_LSB_REG | 0x23 |
199 | LTC2945_MAX_VIN_THRESHOLD_MSB_REG | 0x24 |
200 | LTC2945_MAX_VIN_THRESHOLD_LSB_REG | 0x25 |
201 | LTC2945_MIN_VIN_THRESHOLD_MSB_REG | 0x26 |
202 | LTC2945_MIN_VIN_THRESHOLD_LSB_REG | 0x27 |
203 | LTC2945_ADIN_MSB_REG | 0x28 |
204 | LTC2945_ADIN_LSB_REG_REG | 0x29 |
205 | LTC2945_MAX_ADIN_MSB_REG | 0x2A |
206 | LTC2945_MAX_ADIN_LSB_REG | 0x2B |
207 | LTC2945_MIN_ADIN_MSB_REG | 0x2C |
208 | LTC2945_MIN_ADIN_LSB_REG | 0x2D |
209 | LTC2945_MAX_ADIN_THRESHOLD_MSB_REG | 0x2E |
210 | LTC2945_MAX_ADIN_THRESHOLD_LSB_REG | 0x2F |
211 | LTC2945_MIN_ADIN_THRESHOLD_MSB_REG | 0x30 |
212 | LTC2945_MIN_ADIN_THRESHOLD_LSB_REG | 0x31 |
213 */
214 
215 
216 
217 /*! @name Registers
218 @{ */
219 // Registers
220 
221 #define LTC2945_CONTROL_REG 0x00
222 #define LTC2945_ALERT_REG 0x01
223 #define LTC2945_STATUS_REG 0x02
224 #define LTC2945_FAULT_REG 0x03
225 #define LTC2945_FAULT_CoR_REG 0x04
226 
227 #define LTC2945_POWER_MSB2_REG 0x05
228 #define LTC2945_POWER_MSB1_REG 0x06
229 #define LTC2945_POWER_LSB_REG 0x07
230 #define LTC2945_MAX_POWER_MSB2_REG 0x08
231 #define LTC2945_MAX_POWER_MSB1_REG 0x09
232 #define LTC2945_MAX_POWER_LSB_REG 0x0A
233 #define LTC2945_MIN_POWER_MSB2_REG 0x0B
234 #define LTC2945_MIN_POWER_MSB1_REG 0x0C
235 #define LTC2945_MIN_POWER_LSB_REG 0x0D
236 #define LTC2945_MAX_POWER_THRESHOLD_MSB2_REG 0x0E
237 #define LTC2945_MAX_POWER_THRESHOLD_MSB1_REG 0x0F
238 #define LTC2945_MAX_POWER_THRESHOLD_LSB_REG 0x10
239 #define LTC2945_MIN_POWER_THRESHOLD_MSB2_REG 0x11
240 #define LTC2945_MIN_POWER_THRESHOLD_MSB1_REG 0x12
241 #define LTC2945_MIN_POWER_THRESHOLD_LSB_REG 0x13
242 
243 #define LTC2945_DELTA_SENSE_MSB_REG 0x14
244 #define LTC2945_DELTA_SENSE_LSB_REG 0x15
245 #define LTC2945_MAX_DELTA_SENSE_MSB_REG 0x16
246 #define LTC2945_MAX_DELTA_SENSE_LSB_REG 0x17
247 #define LTC2945_MIN_DELTA_SENSE_MSB_REG 0x18
248 #define LTC2945_MIN_DELTA_SENSE_LSB_REG 0x19
249 #define LTC2945_MAX_DELTA_SENSE_THRESHOLD_MSB_REG 0x1A
250 #define LTC2945_MAX_DELTA_SENSE_THRESHOLD_LSB_REG 0x1B
251 #define LTC2945_MIN_DELTA_SENSE_THRESHOLD_MSB_REG 0x1C
252 #define LTC2945_MIN_DELTA_SENSE_THRESHOLD_LSB_REG 0x1D
253 
254 #define LTC2945_VIN_MSB_REG 0x1E
255 #define LTC2945_VIN_LSB_REG 0x1F
256 #define LTC2945_MAX_VIN_MSB_REG 0x20
257 #define LTC2945_MAX_VIN_LSB_REG 0x21
258 #define LTC2945_MIN_VIN_MSB_REG 0x22
259 #define LTC2945_MIN_VIN_LSB_REG 0x23
260 #define LTC2945_MAX_VIN_THRESHOLD_MSB_REG 0x24
261 #define LTC2945_MAX_VIN_THRESHOLD_LSB_REG 0x25
262 #define LTC2945_MIN_VIN_THRESHOLD_MSB_REG 0x26
263 #define LTC2945_MIN_VIN_THRESHOLD_LSB_REG 0x27
264 
265 #define LTC2945_ADIN_MSB_REG 0x28
266 #define LTC2945_ADIN_LSB_REG_REG 0x29
267 #define LTC2945_MAX_ADIN_MSB_REG 0x2A
268 #define LTC2945_MAX_ADIN_LSB_REG 0x2B
269 #define LTC2945_MIN_ADIN_MSB_REG 0x2C
270 #define LTC2945_MIN_ADIN_LSB_REG 0x2D
271 #define LTC2945_MAX_ADIN_THRESHOLD_MSB_REG 0x2E
272 #define LTC2945_MAX_ADIN_THRESHOLD_LSB_REG 0x2F
273 #define LTC2945_MIN_ADIN_THRESHOLD_MSB_REG 0x30
274 #define LTC2945_MIN_ADIN_THRESHOLD_LSB_REG 0x31
275 //! @}
276 
277 /*!
278 | Snapshot Selection Command | Value |
279 | :-------------------------------------------- | :---: |
280 | LTC2945_DELTA_SENSE_SNAPSHOT | 0x80 |
281 | LTC2945_VIN_SNAPSHOT | 0xA0 |
282 | LTC2945_ADIN_SNAPSHOT | 0xC0 |
283 */
284 
285 /*! @name Selection Command
286 @{ */
287 // Snapshot Selection Command
288 #define LTC2945_DELTA_SENSE_SNAPSHOT 0x80
289 #define LTC2945_VIN_SNAPSHOT 0xA0
290 #define LTC2945_ADIN_SNAPSHOT 0xC0
291 //! @}
292 
293 /*!
294 | Command Codes | Value |
295 | :-------------------------------------------- | :-------: |
296 | LTC2945_CONTINUOUS_MODE | 0x00 |
297 | LTC2945_SHUTDOWN_MODE | 0x02 |
298 | LTC2945_TEST_MODE | 0x10 |
299 | LTC2945_RESET_ALL_FAULTS | 0x00 |
300 | LTC2945_SENSE_MULTIPLIER | 0x01 |
301 | LTC2945_SENSE_MONITOR | 0x04 |
302 | LTC2945_MAX_POWER_MSB2_RESET | 0x00 |
303 | LTC2945_MIN_POWER_MSB2_RESET | 0xFF |
304 | LTC2945_MAX_DELTA_SENSE_MSB_RESET | 0x00 |
305 | LTC2945_MIN_DELTA_SENSE_MSB_RESET | 0xFF |
306 | LTC2945_MAX_VIN_MSB_RESET | 0x00 |
307 | LTC2945_MIN_VIN_MSB_RESET | 0xFF |
308 | LTC2945_MAX_ADIN_MSB_RESET | 0x00 |
309 | LTC2945_MIN_ADIN_MSB_RESET | 0xFF |
310 | LTC2945_ENABLE_MAX_POWER_ALERT | 0x80 |
311 | LTC2945_ENABLE_MIN_POWER_ALERT | 0x40 |
312 | LTC2945_DISABLE_MAX_POWER_ALERT | 0x7F |
313 | LTC2945_DISABLE_MIN_POWER_ALERT | 0xBF |
314 | LTC2945_ENABLE_MAX_DELTA_SENSE_ALERT | 0x20 |
315 | LTC2945_ENABLE_MIN_DELTA_SENSE_ALERT | 0x10 |
316 | LTC2945_DISABLE_MAX_DELTA_SENSE_ALERT | 0xDF |
317 | LTC2945_DISABLE_MIN_DELTA_SENSE_ALERT | 0xEF |
318 | LTC2945_ENABLE_MAX_VIN_ALERT | 0x08 |
319 | LTC2945_ENABLE_MIN_VIN_ALERT | 0x04 |
320 | LTC2945_DISABLE_MAX_VIN_ALERT | 0xF7 |
321 | LTC2945_DISABLE_MIN_VIN_ALERT | 0xFB |
322 | LTC2945_ENABLE_MAX_ADIN_ALERT | 0x02 |
323 | LTC2945_ENABLE_MIN_ADIN_ALERT | 0x01 |
324 | LTC2945_DISABLE_MAX_ADIN_ALERT | 0xFD |
325 | LTC2945_DISABLE_MIN_ADIN_ALERT | 0xFE |
326 */
327 /*! @name Command Codes
328 @{ */
329 // Command Codes
330 #define LTC2945_CONTINUOUS_MODE 0x00
331 #define LTC2945_SHUTDOWN_MODE 0x02
332 #define LTC2945_TEST_MODE 0x10
333 #define LTC2945_RESET_ALL_FAULTS 0x00
334 #define LTC2945_SENSE_MULTIPLIER 0x01
335 #define LTC2945_SENSE_MONITOR 0x04
336 
337 #define LTC2945_MAX_POWER_MSB2_RESET 0x00
338 #define LTC2945_MIN_POWER_MSB2_RESET 0xFF
339 #define LTC2945_MAX_DELTA_SENSE_MSB_RESET 0x00
340 #define LTC2945_MIN_DELTA_SENSE_MSB_RESET 0xFF
341 #define LTC2945_MAX_VIN_MSB_RESET 0x00
342 #define LTC2945_MIN_VIN_MSB_RESET 0xFF
343 #define LTC2945_MAX_ADIN_MSB_RESET 0x00
344 #define LTC2945_MIN_ADIN_MSB_RESET 0xFF
345 
346 #define LTC2945_ENABLE_MAX_POWER_ALERT 0x80
347 #define LTC2945_ENABLE_MIN_POWER_ALERT 0x40
348 #define LTC2945_DISABLE_MAX_POWER_ALERT 0x7F
349 #define LTC2945_DISABLE_MIN_POWER_ALERT 0xBF
350 
351 #define LTC2945_ENABLE_MAX_DELTA_SENSE_ALERT 0x20
352 #define LTC2945_ENABLE_MIN_DELTA_SENSE_ALERT 0x10
353 #define LTC2945_DISABLE_MAX_DELTA_SENSE_ALERT 0xDF
354 #define LTC2945_DISABLE_MIN_DELTA_SENSE_ALERT 0xEF
355 
356 #define LTC2945_ENABLE_MAX_VIN_ALERT 0x08
357 #define LTC2945_ENABLE_MIN_VIN_ALERT 0x04
358 #define LTC2945_DISABLE_MAX_VIN_ALERT 0xF7
359 #define LTC2945_DISABLE_MIN_VIN_ALERT 0xFB
360 
361 #define LTC2945_ENABLE_MAX_ADIN_ALERT 0x02
362 #define LTC2945_ENABLE_MIN_ADIN_ALERT 0x01
363 #define LTC2945_DISABLE_MAX_ADIN_ALERT 0xFD
364 #define LTC2945_DISABLE_MIN_ADIN_ALERT 0xFE
365 //! @}
366 
367 //! Write an 8-bit code to the LTC2945.
368 //! @return The function returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
369 int8_t LTC2945_write(uint8_t i2c_address, //!< Register address for the LTC2945
370  uint8_t adc_command, //!< The "command byte" for the LTC2945
371  uint8_t code //!< Value that will be written to the register.
372  );
373 //! Write a 16-bit code to the LTC2945.
374 //! @return The function returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
375 int8_t LTC2945_write_16_bits(uint8_t i2c_address, //!< Register address for the LTC2945
376  uint8_t adc_command, //!< The "command byte" for the LTC2945
377  uint16_t code //!< Value that will be written to the register.
378  );
379 
380 //! Write a 24-bit code to the LTC2945.
381 //! @return The function returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
382 int8_t LTC2945_write_24_bits(uint8_t i2c_address, //!< Register address for the LTC2945
383  uint8_t adc_command, //!< The "command byte" for the LTC2945
384  int32_t code //!< Value that will be written to the register.
385  );
386 //! Reads an 8-bit adc_code from LTC2945
387 //! @return The function returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
388 int8_t LTC2945_read(uint8_t i2c_address, //!< Register address for the LTC2945
389  uint8_t adc_command, //!< The "command byte" for the LTC2945
390  uint8_t *adc_code //!< Value that will be read from the register.
391  );
392 //! Reads a 12-bit adc_code from LTC2945
393 //! @return The function returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
394 int8_t LTC2945_read_12_bits(uint8_t i2c_address, //!< Register address for the LTC2945
395  uint8_t adc_command, //!< The "command byte" for the LTC2945
396  uint16_t *adc_code //!< Value that will be read from the register.
397  );
398 //! Reads a 16-bit adc_code from LTC2945
399 //! @return The function returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
400 int8_t LTC2945_read_16_bits(uint8_t i2c_address, //!< Register address for the LTC2945
401  uint8_t adc_command, //!< The "command byte" for the LTC2945
402  uint16_t *adc_code //!< Value that will be read from the register.
403  );
404 //! Reads a 24-bit adc_code from LTC2945
405 //! @return The function returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
406 int8_t LTC2945_read_24_bits(uint8_t i2c_address, //!< Register address for the LTC2945
407  uint8_t adc_command, //!< The "command byte" for the LTC2945
408  int32_t *adc_code //!< Value that will be read from the register.
409  );
410 //! Calculate the LTC2945 VIN voltage
411 //! @return Returns the VIN Voltage in Volts
412 float LTC2945_VIN_code_to_voltage(uint16_t adc_code, //!< The ADC value
413  float LTC2945_VIN_lsb //!< VIN lsb weight
414  );
415 //! Calculate the LTC2945 ADIN voltage
416 //! @return Returns the ADIN Voltage in Volts
417 float LTC2945_ADIN_code_to_voltage(uint16_t adc_code, //!< The ADC value
418  float LTC2945_ADIN_lsb //!< ADIN lsb weight
419  );
420 //! Calculate the LTC2945 current with a sense resistor
421 //! @return The LTC2945 current
422 float LTC2945_code_to_current(uint16_t adc_code, //!< The ADC value
423  float resistor, //!< The resistor value
424  float LTC2945_DELTA_SENSE_lsb //!< Delta sense lsb weight
425  );
426 //! Calculate the LTC2945 power
427 //! @return The LTC2945 power
428 float LTC2945_code_to_power(int32_t adc_code, //!< The ADC value
429  float resistor, //!< The resistor value
430  float LTC2945_Power_lsb //!< Power lsb weight
431  );
432 //! Calculate the LTC2945 power with the ADIN
433 //! @return The LTC2945 power with the ADIN
434 float LTC2945_code_to_ADIN_power(int32_t adc_code, //!< The ADC value
435  float resistor, //!< The resistor value
436  float LTC2945_ADIN_DELTA_SENSE_lsb //!< Power lsb weight
437  );
438 #endif // LTC2945_H
float LTC2945_VIN_code_to_voltage(uint16_t adc_code, float LTC2945_VIN_lsb)
Calculate the LTC2945 VIN voltage.
Definition: LTC2945.cpp:162
uint8_t i2c_address
static uint8_t adc_command
Definition: DC2071AA.ino:111
int8_t LTC2945_read_12_bits(uint8_t i2c_address, uint8_t adc_command, uint16_t *adc_code)
Reads a 12-bit adc_code from LTC2945.
Definition: LTC2945.cpp:123
const float resistor
resistor value on demo board
Definition: DC1496BB.ino:116
int8_t LTC2945_write_24_bits(uint8_t i2c_address, uint8_t adc_command, int32_t code)
Write a 24-bit code to the LTC2945.
Definition: LTC2945.cpp:98
const float LTC2945_ADIN_lsb
Typical ADIN lsb weight in volts.
Definition: DC1697A.ino:112
int8_t LTC2945_write(uint8_t i2c_address, uint8_t adc_command, uint8_t code)
Write an 8-bit code to the LTC2945.
Definition: LTC2945.cpp:76
int8_t LTC2945_read(uint8_t i2c_address, uint8_t adc_command, uint8_t *adc_code)
Reads an 8-bit adc_code from LTC2945.
Definition: LTC2945.cpp:112
float LTC2945_code_to_current(uint16_t adc_code, float resistor, float LTC2945_DELTA_SENSE_lsb)
Calculate the LTC2945 current with a sense resistor.
Definition: LTC2945.cpp:180
int8_t LTC2945_read_16_bits(uint8_t i2c_address, uint8_t adc_command, uint16_t *adc_code)
Reads a 16-bit adc_code from LTC2945.
Definition: LTC2945.cpp:137
const float LTC2945_Power_lsb
Typical POWER lsb weight in V^2.
Definition: DC1697A.ino:115
float LTC2945_ADIN_code_to_voltage(uint16_t adc_code, float LTC2945_ADIN_lsb)
Calculate the LTC2945 ADIN voltage.
Definition: LTC2945.cpp:171
const float LTC2945_ADIN_DELTA_SENSE_lsb
Typical sense lsb weight in V^2 *ADIN_lsb * DELTA_SENSE_lsb.
Definition: DC1697A.ino:116
const float LTC2945_VIN_lsb
Typical VIN lsb weight in volts.
Definition: DC1697A.ino:114
float LTC2945_code_to_ADIN_power(int32_t adc_code, float resistor, float LTC2945_ADIN_DELTA_SENSE_lsb)
Calculate the LTC2945 power with the ADIN.
Definition: LTC2945.cpp:200
const float LTC2945_DELTA_SENSE_lsb
Typical Delta lsb weight in volts.
Definition: DC1697A.ino:113
float LTC2945_code_to_power(int32_t adc_code, float resistor, float LTC2945_Power_lsb)
Calculate the LTC2945 power.
Definition: LTC2945.cpp:190
static uint32_t adc_code
Definition: DC2071AA.ino:113
int8_t LTC2945_read_24_bits(uint8_t i2c_address, uint8_t adc_command, int32_t *adc_code)
Reads a 24-bit adc_code from LTC2945.
Definition: LTC2945.cpp:148
int8_t LTC2945_write_16_bits(uint8_t i2c_address, uint8_t adc_command, uint16_t code)
Write a 16-bit code to the LTC2945.
Definition: LTC2945.cpp:88