Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
DC1496BB.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC14968B-B Demonstration Board.
3 LTC2942: Battery Gas Gauge with Temperature, Voltage Measurement
4 
5 Linear Technology DC14968B-A Demonstration Board.
6 LTC2941: Battery Gas Gauge with I2C Interface
7 
8 @verbatim
9 
10  Setup:
11  Apply a voltage source to the V_BATT terminal and a load at the V_CHRG/LD terminal.
12  Refer to the Demo Manual Guide for a detailed setup description. Ensure that JP1 is
13  set to AL# position.
14 
15  Explanation of Commands:
16 
17  1 - Automatic Mode - Scans Voltage, Temperature and charge every 60ms.
18  Scanning interval has been increased to 1s for ease of reading on the Serial Prompt.
19  Displays an alert if it is set in the status register at the time of scan.
20 
21  2 - Manual Voltage Mode - Provides a SnapShot of the Voltage, and Accumulated Charge.
22  After the initial SnapShot, the part goes into sleep mode where it only counts charge.
23  Displays an alert if it is set in the status register at the time of scan.
24 
25  3 - Manual Temperature Mode - Provides a SnapShot of the Temperature, and Accumulated Charge.
26  After the initial SnapShot, the part goes into sleep mode where it only counts charge.
27  Displays an alert if it is set in the status register at the time of scan.
28 
29  4 - Sleep Mode - The ADC portion of the LTC2942 is shutdown. In this mode only charge is accumulated.
30 
31  5 - Shutdown Mode - The LTC2942 goes into low power mode.
32 
33  6 - Settings - Allows user to set alert thresholds, set prescalar, set AL#/CC# pin mode and change the temperature and charge units.
34 
35 NOTES
36  Setup:
37  Set the terminal baud rate to 115200 and select the newline terminator.
38  Requires a power supply.
39  Refer to demo manual DC1812A-A.
40  For use with LTC2941 ignore calls to temperature and voltage as these are not present in LTC2941.
41  All of the functionality of LTC2941 is supported except Control Register B[7:6]
42 
43 USER INPUT DATA FORMAT:
44  decimal : 1024
45  hex : 0x400
46  octal : 02000 (leading 0 "zero")
47  binary : B10000000000
48  float : 1024.0
49 
50 @endverbatim
51 
52 http://www.linear.com/product/LTC2942
53 http://www.linear.com/product/LTC2941
54 
55 http://www.linear.com/product/LTC2942#demoboards
56 http://www.linear.com/product/LTC2941#demoboards
57 
58 
59 Copyright 2018(c) Analog Devices, Inc.
60 
61 All rights reserved.
62 
63 Redistribution and use in source and binary forms, with or without
64 modification, are permitted provided that the following conditions are met:
65  - Redistributions of source code must retain the above copyright
66  notice, this list of conditions and the following disclaimer.
67  - Redistributions in binary form must reproduce the above copyright
68  notice, this list of conditions and the following disclaimer in
69  the documentation and/or other materials provided with the
70  distribution.
71  - Neither the name of Analog Devices, Inc. nor the names of its
72  contributors may be used to endorse or promote products derived
73  from this software without specific prior written permission.
74  - The use of this software may or may not infringe the patent rights
75  of one or more patent holders. This license does not release you
76  from the requirement that you obtain separate licenses from these
77  patent holders to use this software.
78  - Use of the software either in source or binary form, must be run
79  on or directly connected to an Analog Devices Inc. component.
80 
81 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
82 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
83 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
84 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
85 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
86 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
87 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
88 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
89 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
90 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
91  */
92 
93 /*! @file
94  @ingroup LTC2942
95 */
96 
97 #include <Arduino.h>
98 #include <stdint.h>
99 #include "Linduino.h"
100 #include "LT_I2C.h"
101 #include "UserInterface.h"
102 #include "QuikEval_EEPROM.h"
103 #include "LTC2942.h"
104 #include <Wire.h>
105 
106 
107 // Function Declaration
108 void print_title(); // Print the title block
109 void print_prompt(); // Print the Prompt
110 void store_alert_settings(); // Store the alert settings to the EEPROM
111 int8_t restore_alert_settings(); // Read the alert settings from EEPROM
112 
113 
114 #define AUTOMATIC_MODE_DISPLAY_DELAY 1000 //!< The delay between readings in automatic mode
115 #define SCAN_MODE_DISPLAY_DELAY 10000 //!< The delay between readings in scan mode
116 const float resistor = .100; //!< resistor value on demo board
117 
118 // Error string
119 const char ack_error[] = "Error: No Acknowledge. Check I2C Address."; //!< Error message
120 
121 
122 
123 // Global variables
124 static int8_t demo_board_connected; //!< Set to 1 if the board is connected
125 static uint8_t alert_code = 0; //!< Value stored or read from ALERT register. Shared between loop() and restore_alert_settings()
126 
127 //! Initialize Linduino
128 void setup()
129 {
130  char demo_name[] = "DC1496"; //! Demo Board Name stored in QuikEval EEPROM
131 
132  quikeval_I2C_init(); //! Configure the EEPROM I2C port for 100kHz
133  quikeval_I2C_connect(); //! Connects to main I2C port
134  Serial.begin(115200); //! Initialize the serial port to the PC
135  print_title();
138  {
139  print_prompt();
140  }
141  else
142  {
143  demo_board_connected = true;
144  Serial.println("Did not read ID String, attempting to proceed anyway...\nPlease ensure I2C lines of Linduino are connected to the LTC device");
145  print_prompt();
146  }
147 
148 
149 }
150 
151 
152 //! Repeats Linduino loop
153 void loop()
154 {
155  int8_t ack = 0; //! I2C acknowledge indicator
156  static uint8_t user_command; //! The user input command
157  static uint8_t mAh_or_Coulombs = 0;
158  static uint8_t celcius_or_kelvin = 0;
159  static uint16_t prescalar_mode = LTC2942_PRESCALAR_M_128;
160  static uint16_t prescalarValue = 128;
161  static uint16_t alcc_mode = LTC2942_ALERT_MODE;
162 
163  if (demo_board_connected) //! Do nothing if the demo board is not connected
164  {
165  if (Serial.available()) //! Do nothing if serial is not available
166  {
167  user_command = read_int(); //! Read user input command
168  if (user_command != 'm')
169  Serial.println(user_command);
170  Serial.println();
171  ack = 0;
172  switch (user_command) //! Prints the appropriate submenu
173  {
174  case 1:
175  ack |= menu_1_automatic_mode(mAh_or_Coulombs, celcius_or_kelvin, prescalar_mode, prescalarValue, alcc_mode); //! Automatic Mode
176  break;
177  case 2:
178  ack |= menu_2_manual_voltage_mode(mAh_or_Coulombs, celcius_or_kelvin, prescalar_mode, prescalarValue, alcc_mode); //! Manual Voltage Mode
179  break;
180  case 3:
181  ack |= menu_3_manual_temperature_mode(mAh_or_Coulombs, celcius_or_kelvin, prescalar_mode, prescalarValue, alcc_mode); //! Manual Temperature Mode
182  break;
183  case 4:
184  ack |= menu_4_sleep_mode(mAh_or_Coulombs, prescalar_mode, prescalarValue, alcc_mode); //! Sleep Mode
185  break;
186  case 5:
187  ack |= menu_5_shutdown_mode(); //! Shutdown Mode
188  break;
189  case 6:
190  ack |= menu_6_settings(&mAh_or_Coulombs, &celcius_or_kelvin, &prescalar_mode, &prescalarValue, &alcc_mode); //! Settings Mode
191  break;
192  }
193  if (ack != 0) //! If ack is not recieved print an error.
194  Serial.println(ack_error);
195  Serial.print(F("*************************"));
196  print_prompt();
197  }
198  }
199 }
200 
201 // Function Definitions
202 //! Print the title block
204 {
205  Serial.println(F("\n*****************************************************************"));
206  Serial.print(F("* DC1496B-B Demonstration Program *\n"));
207  Serial.print(F("* *\n"));
208  Serial.print(F("* This program communicates with the LTC2942 Coulomb Counter *\n"));
209  Serial.print(F("* found on the DC1496B-B demo board. *\n"));
210  Serial.print(F("* Set the baud rate to 115200 and select the newline terminator.*\n"));
211  Serial.print(F("* *\n"));
212  Serial.print(F("*****************************************************************\n"));
213 }
214 
215 //! Print the Prompt
217 {
218  Serial.print(F("\n1-Automatic Mode\n"));
219  Serial.print(F("2-Manual Voltage Mode\n"));
220  Serial.print(F("3-Manual Temperature Mode\n"));
221  Serial.print(F("4-Sleep Mode\n"));
222  Serial.print(F("5-Shutdown Mode\n"));
223  Serial.print(F("6-Settings\n"));
224  Serial.print(F("Enter a command: "));
225 }
226 
227 //! Automatic Mode.
228 int8_t menu_1_automatic_mode(int8_t mAh_or_Coulombs, int8_t celcius_or_kelvin ,uint16_t prescalar_mode, uint16_t prescalarValue, uint16_t alcc_mode)
229 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
230 {
231  int8_t LTC2942_mode;
232  int8_t ack = 0;
233  LTC2942_mode = LTC2942_AUTOMATIC_MODE|prescalar_mode|alcc_mode ; //! Set the control register of the LTC2942 to automatic mode as well as set prescalar and AL#/CC# pin values.
234  Serial.println();
235  ack |= LTC2942_write(LTC2942_I2C_ADDRESS, LTC2942_CONTROL_REG, LTC2942_mode); //! Writes the set mode to the LTC2942 control register
236  if (ack)
237  {
238  Serial.println(F("could not configure LTC2942"));
239  return(ack);
240  }
241  do
242  {
243  Serial.print(F("*************************\n\n"));
244 
245  uint8_t status_code, hightemp_code, lowtemp_code;
246  uint16_t charge_code, current_code, voltage_code, temperature_code;
247 
248  ack |= LTC2942_read_16_bits(LTC2942_I2C_ADDRESS, LTC2942_ACCUM_CHARGE_MSB_REG, &charge_code); //! Read MSB and LSB Accumulated Charge Registers for 16 bit charge code
249  ack |= LTC2942_read_16_bits(LTC2942_I2C_ADDRESS, LTC2942_VOLTAGE_MSB_REG, &voltage_code); //! Read MSB and LSB Voltage Registers for 16 bit voltage code
250  ack |= LTC2942_read_16_bits(LTC2942_I2C_ADDRESS, LTC2942_TEMPERATURE_MSB_REG, &temperature_code); //! Read MSB and LSB Temperature Registers for 16 bit temperature code
251  ack |= LTC2942_read(LTC2942_I2C_ADDRESS, LTC2942_STATUS_REG, &status_code); //! Read Status Register for 8 bit status code
252 
253  Serial.print(F("CHARGE: "));
254  Serial.println(charge_code,HEX);
255  Serial.print(F("VOLTAGE: "));
256  Serial.println(voltage_code, HEX);
257  Serial.print(F("TEMPERATURE: "));
258  Serial.println(temperature_code,HEX);
259 
260  float charge, voltage, temperature;
261  if (mAh_or_Coulombs)
262  {
263  charge = LTC2942_code_to_coulombs(charge_code, resistor, prescalarValue); //! Convert charge code to Coulombs if Coulomb units are desired.
264  Serial.print("Coulombs: ");
265  Serial.print(charge, 4);
266  Serial.print(F(" C\n"));
267  }
268  else
269  {
270  charge = LTC2942_code_to_mAh(charge_code, resistor, prescalarValue); //! Convert charge code to mAh if mAh units are desired.
271  Serial.print("mAh: ");
272  Serial.print(charge, 4);
273  Serial.print(F(" mAh\n"));
274  }
275 
276 
277  voltage = LTC2942_code_to_voltage(voltage_code); //! Convert voltage code to Volts
278 
279 
280  Serial.print(F("Voltage "));
281  Serial.print(voltage, 4);
282  Serial.print(F(" V\n"));
283 
284 
285  if (celcius_or_kelvin)
286  {
287  temperature = LTC2942_code_to_kelvin_temperature(temperature_code); //! Convert temperature code to kelvin
288  Serial.print(F("Temperature "));
289  Serial.print(temperature, 4);
290  Serial.print(F(" K\n"));
291  }
292  else
293  {
294  temperature = LTC2942_code_to_celcius_temperature(temperature_code); //! Convert temperature code to celcius
295  Serial.print(F("Temperature "));
296  Serial.print(temperature, 4);
297  Serial.print(F(" C\n"));
298  }
299 
300  checkAlerts(status_code); //! Check status code for Alerts. If an Alert has been set, print out appropriate message in the Serial Prompt.
301 
302  Serial.print(F("m-Main Menu\n\n"));
303 
304  Serial.flush();
305  delay(AUTOMATIC_MODE_DISPLAY_DELAY); //! Delay for 1s before next polling
306  }
307  while (!Serial.available() && !(ack)); //! if Serial is not available and an NACK has not been recieved, keep polling the registers.
308  read_int(); // clears the Serial.available
309  return(ack);
310 }
311 
312 
313 //! Manual Voltage Mode
314 int8_t menu_2_manual_voltage_mode(int8_t mAh_or_Coulombs ,int8_t celcius_or_kelvin ,uint16_t prescalar_mode, uint16_t prescalarValue, uint16_t alcc_mode)
315 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
316 {
317  int8_t LTC2942_mode;
318  int8_t ack = 0;
319  LTC2942_mode = LTC2942_MANUAL_VOLTAGE|prescalar_mode|alcc_mode ; //! Set the control mode of the LTC2942 to manual mode as well as set prescalar and AL#/CC# pin values.
320  Serial.println();
321  ack |= LTC2942_write(LTC2942_I2C_ADDRESS, LTC2942_CONTROL_REG, LTC2942_mode); //! Writes the set mode to the LTC2942 control register
322 
323  int staleData = 0; //! Stale Data Check variable. When set to 1 it indicates that stale data is being read from the voltage, current and temperature registers.
324 
325  do
326  {
327  Serial.print(F("*************************\n\n"));
328 
329  uint8_t status_code;
330  uint16_t charge_code, voltage_code;
331 
332 
333  ack |= LTC2942_read_16_bits(LTC2942_I2C_ADDRESS, LTC2942_ACCUM_CHARGE_MSB_REG, &charge_code); //! Read MSB and LSB Accumulated Charge Registers for 16 bit charge code
334  ack |= LTC2942_read_16_bits(LTC2942_I2C_ADDRESS, LTC2942_VOLTAGE_MSB_REG, &voltage_code); //! Read MSB and LSB Voltage Registers for 16 bit voltage code
335  ack |= LTC2942_read(LTC2942_I2C_ADDRESS, LTC2942_STATUS_REG, &status_code); //! Read Status Registers for 8 bit status code
336 
337 
338  float charge, voltage, temperature;
339  if (mAh_or_Coulombs)
340  {
341  charge = LTC2942_code_to_coulombs(charge_code, resistor, prescalarValue); //! Convert charge code to Coulombs if Coulomb units are desired.
342  Serial.print("Coulombs: ");
343  Serial.print(charge, 4);
344  Serial.print(F(" C\n"));
345  }
346  else
347  {
348  charge = LTC2942_code_to_mAh(charge_code, resistor, prescalarValue); //! Convert charge code to mAh if mAh units are desired.
349  Serial.print("mAh: ");
350  Serial.print(charge, 4);
351  Serial.print(F(" mAh\n"));
352  }
353 
354 
355  voltage = LTC2942_code_to_voltage(voltage_code); //! Convert voltage code to Volts
356 
357 
358  Serial.print(F("Voltage "));
359  Serial.print(voltage, 4);
360  Serial.print(F(" V"));
361  if (staleData) Serial.print(F(" ***** Stale Data ******\n")); //! If Stale data is inside the register after initial snapshot, Print Stale Data message.
362  else Serial.println("");
363 
364 
365  if (staleData) Serial.print(F(" ***** Stale Data ******\n"));
366  else Serial.println("");
367 
368 
369  checkAlerts(status_code); //! Check status code for Alerts. If an Alert has been set, print out appropriate message in the Serial Prompt
370 
371 
372  Serial.print(F("m-Main Menu\n\n"));
373 
374  staleData = 1;
375  Serial.flush();
377  }
378  while (!Serial.available() && !(ack));
379  read_int(); // clears the Serial.available
380  return(ack);
381 }
382 
383 //! Manual Voltage Mode
384 int8_t menu_3_manual_temperature_mode(int8_t mAh_or_Coulombs ,int8_t celcius_or_kelvin ,uint16_t prescalar_mode, uint16_t prescalarValue, uint16_t alcc_mode)
385 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
386 {
387  int8_t LTC2942_mode;
388  int8_t ack = 0;
389  LTC2942_mode = LTC2942_MANUAL_TEMPERATURE|prescalar_mode|alcc_mode ; //! Set the control mode of the LTC2942 to manual mode as well as set prescalar and AL#/CC# pin values.
390  Serial.println();
391  ack |= LTC2942_write(LTC2942_I2C_ADDRESS, LTC2942_CONTROL_REG, LTC2942_mode); //! Writes the set mode to the LTC2942 control register
392 
393  int staleData = 0; //! Stale Data Check variable. When set to 1 it indicates that stale data is being read from the voltage, current and temperature registers.
394 
395  do
396  {
397  Serial.print(F("*************************\n\n"));
398 
399  uint8_t status_code;
400  uint16_t charge_code, temperature_code;
401 
402 
403  ack |= LTC2942_read_16_bits(LTC2942_I2C_ADDRESS, LTC2942_ACCUM_CHARGE_MSB_REG, &charge_code); //! Read MSB and LSB Accumulated Charge Registers for 16 bit charge code
404  ack |= LTC2942_read_16_bits(LTC2942_I2C_ADDRESS, LTC2942_TEMPERATURE_MSB_REG, &temperature_code); //! Read MSB and LSB Temperature Registers for 16 bit temperature code
405  ack |= LTC2942_read(LTC2942_I2C_ADDRESS, LTC2942_STATUS_REG, &status_code); //! Read Status Registers for 8 bit status code
406 
407 
408  float charge, temperature;
409  if (mAh_or_Coulombs)
410  {
411  charge = LTC2942_code_to_coulombs(charge_code, resistor, prescalarValue); //! Convert charge code to Coulombs if Coulomb units are desired.
412  Serial.print("Coulombs: ");
413  Serial.print(charge, 4);
414  Serial.print(F(" C\n"));
415  }
416  else
417  {
418  charge = LTC2942_code_to_mAh(charge_code, resistor, prescalarValue); //! Convert charge code to mAh if mAh units are desired.
419  Serial.print("mAh: ");
420  Serial.print(charge, 4);
421  Serial.print(F(" mAh\n"));
422  }
423 
424 
425 
426 
427  if (celcius_or_kelvin)
428  {
429  temperature = LTC2942_code_to_kelvin_temperature(temperature_code); //! Convert temperature code to Kelvin if Kelvin units are desired.
430  Serial.print(F("Temperature "));
431  Serial.print(temperature, 4);
432  Serial.print(F(" K"));
433  }
434  else
435  {
436  temperature = LTC2942_code_to_celcius_temperature(temperature_code); //! Convert temperature code to Celcius if Celcius units are desired.
437  Serial.print(F("Temperature "));
438  Serial.print(temperature, 4);
439  Serial.print(F(" C"));
440  }
441  if (staleData) Serial.print(F(" ***** Stale Data ******\n"));
442  else Serial.println("");
443 
444 
445  checkAlerts(status_code); //! Check status code for Alerts. If an Alert has been set, print out appropriate message in the Serial Prompt
446 
447 
448  Serial.print(F("m-Main Menu\n\n"));
449 
450  staleData = 1;
451  Serial.flush();
453  }
454  while (!Serial.available() && !(ack));
455  read_int(); // clears the Serial.available
456  return(ack);
457 }
458 
459 //! Sleep Mode
460 int8_t menu_4_sleep_mode(int8_t mAh_or_Coulombs ,uint16_t prescalar_mode, uint16_t prescalarValue, uint16_t alcc_mode)
461 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
462 {
463  int8_t LTC2942_mode;
464  int8_t ack = 0;
465  LTC2942_mode = LTC2942_SLEEP_MODE|prescalar_mode|alcc_mode ; //! Set the control mode of the LTC2942 to sleep mode as well as set prescalar and AL#/CC# pin values.
466  Serial.println();
467  ack |= LTC2942_write(LTC2942_I2C_ADDRESS, LTC2942_CONTROL_REG, LTC2942_mode); //! Writes the set mode to the LTC2942 control register
468 
469 
470  do
471  {
472  Serial.print(F("*************************\n\n"));
473  delay(100);
474  uint8_t status_code;
475  uint16_t charge_code;
476 
477 
478  ack |= LTC2942_read_16_bits(LTC2942_I2C_ADDRESS, LTC2942_ACCUM_CHARGE_MSB_REG, &charge_code); //! Read MSB and LSB Accumulated Charge Registers for 16 bit charge code
479  ack |= LTC2942_read(LTC2942_I2C_ADDRESS, LTC2942_STATUS_REG, &status_code); //! Read Status Registers for 8 bit status code
480 
481 
482  float charge;
483  if (mAh_or_Coulombs)
484  {
485  charge = LTC2942_code_to_coulombs(charge_code, resistor, prescalarValue); //! Convert charge code to Coulombs if Coulomb units are desired.
486  Serial.print("Coulombs: ");
487  Serial.print(charge, 4);
488  Serial.print(F(" C\n"));
489  }
490  else
491  {
492  charge = LTC2942_code_to_mAh(charge_code, resistor, prescalarValue); //! Convert charge code to mAh if mAh units are desired.
493  Serial.print("mAh: ");
494  Serial.print(charge, 4);
495  Serial.print(F(" mAh\n"));
496  }
497 
498 
499  Serial.print(F("Voltage "));
500  Serial.print(F(" ADC Sleep...\n"));
501 
502  Serial.print(F("Temperature "));
503  Serial.print(F(" ADC Sleep...\n"));
504 
505  Serial.print(F("m-Main Menu\n\n"));
506 
507  checkAlerts(status_code);
508 
509  Serial.flush();
511  }
512  while (!Serial.available() && !(ack));
513  read_int(); // clears the Serial.available
514  return(ack);
515 }
516 
517 //! Shutdown Mode
519 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
520 {
521  int8_t ack = 0;
522  ack |= LTC2942_write(LTC2942_I2C_ADDRESS, LTC2942_CONTROL_REG, LTC2942_SHUTDOWN_MODE); //! Sets the LTC2942 into shutdown mode
523  Serial.print("LTC2942 Has Been ShutDown\n");
524  return(ack);
525 }
526 //! Settings Menu
527 int8_t menu_6_settings(uint8_t *mAh_or_Coulombs, uint8_t *celcius_or_kelvin, uint16_t *prescalar_mode, uint16_t *prescalarValue, uint16_t *alcc_mode)
528 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
529 {
530  int8_t ack = 0;
531  int8_t user_command;
532  do
533  {
534  Serial.print(F("*************************\n\n"));
535  Serial.print(F("1-Set Alert Thresholds\n"));
536  Serial.print(F("2-Set Prescalar Value\n"));
537  Serial.print(F("3-Set AL#/CC# Pin State\n"));
538  Serial.print(F("4-Set Units\n"));
539  Serial.print(F("m-Main Menu\n\n"));
540  Serial.print(F("Enter a command: "));
541 
542  user_command = read_int();
543  if (user_command == 'm')
544  Serial.println("m");
545  else
546  Serial.println(user_command);
547  Serial.println();
548  switch (user_command)
549  {
550  case 1:
551  ack |= menu_6_settings_menu_1_set_alert_thresholds(); //! Settings Menu to set Alert Thresholds
552  break;
553 
554  case 2:
555  ack |= menu_6_settings_menu_2_set_prescalar_values(prescalar_mode, prescalarValue); //! Settings Menu to set Prescalar Values
556  break;
557 
558  case 3:
559  ack |= menu_6_alert_menu_3_set_allcc_state(alcc_mode); //! Settings Menu to set AL#/CC# mode
560  break;
561 
562  case 4:
563  ack |= menu_6_alert_menu_4_set_units(mAh_or_Coulombs, celcius_or_kelvin); //! Settings Menu to set Temperature and Charge Units
564  break;
565 
566  default:
567  if (user_command != 'm')
568  Serial.println("Incorrect Option");
569  break;
570  }
571  }
572  while (!((user_command == 'm') || (ack)));
573  return(ack);
574 
575 }
576 
577 //! Alert Threshold Menu
579 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
580 {
581  int8_t ack = 0;
582  int8_t user_command;
583  do
584  {
585  Serial.print(F("*************************\n\n"));
586  Serial.print(F("1-Set Charge Thresholds\n"));
587  Serial.print(F("2-Set Voltage Thresholds\n"));
588  Serial.print(F("3-Set Temperature Thresholds\n"));
589  Serial.print(F("m-Main Menu\n\n"));
590  Serial.print(F("Enter a command: "));
591 
592  user_command = read_int();
593  if (user_command == 'm')
594  Serial.println("m");
595  else
596  Serial.println(user_command);
597  Serial.println();
598  switch (user_command)
599  {
600  case 1:
601  ack |= menu_6_alert_menu_1_set_charge_thresholds(); //! Set Max and Min Charge Thresholds. The ACR charge lsb size changes with respect to the prescalar and sense resistor value. Due to this variability, for the purpose of this demo enter values in hexadecimal.
602  break;
603  case 2:
604  ack |= menu_6_alert_menu_2_set_voltage_thresholds(); //! Set Max and Min Voltage Thresholds. Enter Values in Volts
605  break;
606  case 3:
607  ack |= menu_6_alert_menu_3_set_temperature_thresholds(); //! Set Max and Min Temperature Thresholds. Enter Values in Celcius.
608  break;
609  default:
610  if (user_command != 'm')
611  Serial.println("Incorrect Option");
612  break;
613  }
614  }
615  while (!((user_command == 'm') || (ack)));
616  return(ack);
617 
618 }
619 //! Set Charge Threshold Function
621 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
622 {
623  int8_t ack = 0;
624  Serial.print(F("Enter RAW Max Charge Threshold:"));
625 
626  uint16_t max_charge_threshold;
627  max_charge_threshold = read_int(); //! Read user entered value
628  Serial.println(max_charge_threshold);
629 
630  ack |= LTC2942_write_16_bits(LTC2942_I2C_ADDRESS, LTC2942_CHARGE_THRESH_HIGH_MSB_REG, max_charge_threshold); //! write user entered value to HIGH threshold register
631 
632  Serial.print(F("Enter RAW Min Charge Threshold:"));
633 
634  float min_charge_threshold;
635  min_charge_threshold = read_int(); //! Read user entered value
636  Serial.println(min_charge_threshold);
637 
638  ack |= LTC2942_write_16_bits(LTC2942_I2C_ADDRESS, LTC2942_CHARGE_THRESH_LOW_MSB_REG, min_charge_threshold); //! write user entered value to HIGH threshold register
639  return(ack);
640 
641 }
642 
643 //! Set Voltage Thresholds
645 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
646 {
647  int8_t ack = 0;
648  Serial.print(F("Enter Max Voltage Threshold:"));
649 
650  float max_voltage_threshold;
651  max_voltage_threshold = read_float(); //! Read user entered value
652  Serial.print(max_voltage_threshold, 3);
653  Serial.println("V");
654 
655  uint16_t max_voltage_threshold_code_16 =max_voltage_threshold*(0xFFFF)/(LTC2942_FULLSCALE_VOLTAGE);
656  uint8_t max_voltage_threshold_code = max_voltage_threshold_code_16>>8; //! Convert user entered voltage into adc code.
657 
658  ack |= LTC2942_write(LTC2942_I2C_ADDRESS, LTC2942_VOLTAGE_THRESH_HIGH_REG, max_voltage_threshold_code); //! Write adc code to HIGH threshold register
659 
660  Serial.print(F("Enter Min Voltage Threshold:"));
661 
662  float min_voltage_threshold;
663  min_voltage_threshold = read_float(); //! Read user entered value
664  Serial.println(min_voltage_threshold, 3);
665  Serial.println("V");
666 
667  uint16_t min_voltage_threshold_code_16 =(min_voltage_threshold*(0xFFFF)/(LTC2942_FULLSCALE_VOLTAGE));
668  uint8_t min_voltage_threshold_code = min_voltage_threshold_code_16>>8; //! Convert user entered voltage into adc code.
669 
670  ack |= LTC2942_write(LTC2942_I2C_ADDRESS, LTC2942_VOLTAGE_THRESH_LOW_REG, min_voltage_threshold_code); //! Write adc code to LOW threshold register
671  return(ack);
672 }
673 
674 //! Set Temperature Thresholds
676 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
677 {
678  int8_t ack = 0;
679  Serial.print(F("Enter Max Temperature Threshold in Celcius:"));
680 
681  float max_temperature_threshold;
682  max_temperature_threshold = read_float(); //! Read user entered value
683  Serial.print(max_temperature_threshold, 2);
684  Serial.println("C");
685 
686  uint16_t max_temperature_threshold_code_16 =((max_temperature_threshold + 273.15)*(0xFFFF)/(LTC2942_FULLSCALE_TEMPERATURE));
687  uint8_t max_temperature_threshold_code = max_temperature_threshold_code_16>>8; //! Convert user entered temperature into adc code.
688 
689 
690  ack |= LTC2942_write(LTC2942_I2C_ADDRESS, LTC2942_TEMPERATURE_THRESH_HIGH_REG, max_temperature_threshold_code); //! Write adc code to HIGH threshold register
691 
692  Serial.print(F("Enter Min Temperature Threshold in Celcius:"));
693 
694  float min_temperature_threshold;
695  min_temperature_threshold = read_float(); //! Read user entered value
696  Serial.print(min_temperature_threshold, 2);
697  Serial.println("C");
698  uint16_t min_temperature_threshold_code_16 = ((min_temperature_threshold + 273.15)*(0xFFFF)/(LTC2942_FULLSCALE_TEMPERATURE));
699  uint8_t min_temperature_threshold_code = min_temperature_threshold_code_16>>8; //! Convert user entered temperature into adc code.
700 
701  ack |= LTC2942_write_16_bits(LTC2942_I2C_ADDRESS, LTC2942_TEMPERATURE_THRESH_LOW_REG, min_temperature_threshold_code); //! Write adc code to LOW threshold register
702  return(ack);
703 
704 }
705 
706 //! Prescalar Menu
707 int8_t menu_6_settings_menu_2_set_prescalar_values(uint16_t *prescalar_mode, uint16_t *prescalarValue)
708 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
709 {
710  int8_t ack = 0;
711  int8_t user_command;
712  do
713  {
714  Serial.print(F("*************************\n\n"));
715  Serial.print(F("1-Set Prescalar M = 1\n"));
716  Serial.print(F("2-Set Prescalar M = 2\n"));
717  Serial.print(F("3-Set Prescalar M = 4\n"));
718  Serial.print(F("4-Set Prescalar M = 8\n"));
719  Serial.print(F("5-Set Prescalar M = 16\n"));
720  Serial.print(F("6-Set Prescalar M = 32\n"));
721  Serial.print(F("7-Set Prescalar M = 64\n"));
722  Serial.print(F("8-Set Prescalar M = 128\n"));
723  Serial.print(F("m-Main Menu\n\n"));
724  Serial.print(F("Enter a command: "));
725 
726  user_command = read_int();
727  if (user_command == 'm')
728  Serial.println("m");
729  else
730  Serial.println(user_command);
731  Serial.println();
732  switch (user_command)
733  {
734  case 1:
735  *prescalar_mode = LTC2942_PRESCALAR_M_1; //! Set Prescalar Value M = 1
736  *prescalarValue = 1;
737  Serial.println(F("\nPrescalar Set to 1\n"));
738  break;
739  case 2:
740  *prescalar_mode = LTC2942_PRESCALAR_M_2; //! Set Prescalar Value M = 2
741  *prescalarValue = 2;
742  Serial.println(F("\nPrescalar Set to 2\n"));
743  break;
744  case 3:
745  *prescalar_mode = LTC2942_PRESCALAR_M_4; //! Set Prescalar Value M = 4
746  *prescalarValue = 4;
747  Serial.println(F("\nPrescalar Set to 4\n"));
748  break;
749  case 4:
750  *prescalar_mode = LTC2942_PRESCALAR_M_8; //! Set Prescalar Value M = 8
751  *prescalarValue = 8;
752  Serial.println(F("\nPrescalar Set to 8\n"));
753  break;
754  case 5:
755  *prescalar_mode = LTC2942_PRESCALAR_M_16; //! Set Prescalar Value M = 16
756  *prescalarValue = 16;
757  Serial.println(F("\nPrescalar Set to 16\n"));
758  break;
759  case 6:
760  *prescalar_mode = LTC2942_PRESCALAR_M_32; //! Set Prescalar Value M = 32
761  *prescalarValue = 32;
762  \
763  Serial.println(F("\nPrescalar Set to 32\n"));
764  break;
765  case 7:
766  *prescalar_mode = LTC2942_PRESCALAR_M_64; //! Set Prescalar Value M = 64
767  *prescalarValue = 64;
768  Serial.println(F("\nPrescalar Set to 64\n"));
769  break;
770  case 8:
771  *prescalar_mode = LTC2942_PRESCALAR_M_128; //! Set Prescalar Value M = 128
772  *prescalarValue =128;
773  Serial.println(F("\nPrescalar Set to 128\n"));
774  default:
775  if (user_command != 'm')
776  Serial.println("Incorrect Option");
777  break;
778  }
779  }
780  while (!((user_command == 'm') || (ack)));
781  return(ack);
782 }
783 
784 //! AL#/CC# Pin Mode Menu
785 uint8_t menu_6_alert_menu_3_set_allcc_state(uint16_t *alcc_mode)
786 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
787 {
788  int8_t ack = 0;
789  int8_t user_command;
790  do
791  {
792  Serial.print(F("*************************\n\n"));
793  Serial.print(F("1-Enable Alert Mode\n"));
794  Serial.print(F("2-Enable Charge Complete Mode\n"));
795  Serial.print(F("3-Disable AL#/CC# Pin\n"));
796  Serial.print(F("m-Main Menu\n\n"));
797  Serial.print(F("Enter a command: "));
798 
799  user_command = read_int();
800  if (user_command == 'm')
801  Serial.println("m");
802  else
803  Serial.println(user_command);
804  Serial.println();
805  switch (user_command)
806  {
807  case 1:
808  *alcc_mode = LTC2942_ALERT_MODE; //! Set AL#/CC# mode to Alert Mode
809  Serial.println(F("\nAlert Mode Enabled\n"));
810  break;
811  case 2:
812  *alcc_mode = LTC2942_CHARGE_COMPLETE_MODE; //! Set AL#/CC# mode to Charge Complete Mode
813  Serial.println(F("\nCharge Mode Enabled\n"));
814  break;
815  case 3:
816  *alcc_mode = LTC2942_DISABLE_ALCC_PIN; //! Disable AL#/CC# pin.
817  Serial.println(F("\nAL#/CC# Pin Disabled\n"));
818  break;
819  default:
820  if (user_command != 'm')
821  Serial.println("Incorrect Option");
822  break;
823  }
824  }
825  while (!((user_command == 'm') || (ack)));
826  return(ack);
827 }
828 
829 //! Set Charge and Temperature Units Menu
830 uint8_t menu_6_alert_menu_4_set_units(uint8_t *mAh_or_Coulombs, uint8_t *celcius_or_kelvin)
831 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
832 {
833  int8_t ack = 0;
834  int8_t user_command;
835  do
836  {
837  Serial.print(F("*************************\n\n"));
838  Serial.print(F("1-Set Charge Units to mAh\n"));
839  Serial.print(F("2-Set Charge Units to Coulombs\n"));
840  Serial.print(F("3-Set Temperature Units to Celsius\n"));
841  Serial.print(F("4-Set Temperature Units to Kelvin\n"));
842  Serial.print(F("m-Main Menu\n\n"));
843  Serial.print(F("Enter a command: "));
844 
845  user_command = read_int();
846  if (user_command == 'm')
847  Serial.println("m");
848  else
849  Serial.println(user_command);
850  Serial.println();
851  switch (user_command)
852  {
853  case 1:
854  *mAh_or_Coulombs = 0;
855  Serial.println(F("\nCharge Units Set to mAh\n"));
856  break;
857  case 2:
858  *mAh_or_Coulombs = 1;
859  Serial.println(F("\nCharge Units Set to Coulombs\n"));
860  break;
861  case 3:
862  *celcius_or_kelvin = 0;
863  Serial.println(F("\nTemperature Units Set to Celcius\n"));
864  break;
865  case 4:
866  *celcius_or_kelvin = 1;
867  Serial.println(F("\nTemperature Units Set to Kelvin\n"));
868  break;
869  default:
870  if (user_command != 'm')
871  Serial.println("Incorrect Option");
872  break;
873  }
874 
875  }
876  while (!((user_command == 'm') || (ack)));
877  return(ack);
878 
879 }
880 
881 //! Checks to see if a bit in a certain position is set.
882 bool isBitSet(uint8_t value, uint8_t position)
883 //! @return Returns the state of a bit at "position" in a byte. 1 = Set, 0 = Not Set
884 {
885  return((1<<position)&value);
886 }
887 //! Check Alerts Function - Checks to see if an alert has been set in the status register. If an alert has been set, it prints out the appropriate message.
888 void checkAlerts(uint8_t status_code)
889 //! @return
890 {
891 
892  if (isBitSet(status_code,5))
893  {
894  Serial.print(F("\n***********************\n"));
895  Serial.print(F("Alert: "));
896  Serial.print(F("Charge Over/Under Flow Alert\n"));
897  Serial.print(F("***********************\n"));
898  }
899  if (isBitSet(status_code,4))
900  {
901  Serial.print(F("\n***********************\n"));
902  Serial.print(F("Alert: "));
903  Serial.print(F("Temperature Alert\n"));
904  Serial.print(F("***********************\n"));
905  }
906  if (isBitSet(status_code,3))
907  {
908  Serial.print(F("\n***********************\n"));
909  Serial.print(F("Alert: "));
910  Serial.print(F("Charge High Alert\n"));
911  Serial.print(F("***********************\n"));
912  }
913  if (isBitSet(status_code,2))
914  {
915  Serial.print(F("\n***********************\n"));
916  Serial.print(F("Alert: "));
917  Serial.print(F("Charge Low Alert\n"));
918  Serial.print(F("***********************\n"));
919  }
920  if (isBitSet(status_code,1))
921  {
922  Serial.print(F("\n***********************\n"));
923  Serial.print(F("Alert: "));
924  Serial.print(F("Voltage Alert\n"));
925  Serial.print(F("***********************\n"));
926  }
927  if (isBitSet(status_code,0))
928  {
929  Serial.print(F("\n***********************\n"));
930  Serial.print(F("Alert: "));
931  Serial.print(F("UVLO Alert\n"));
932  Serial.print(F("***********************\n"));
933  }
934 }
935 
static int8_t menu_4_sleep_mode(int8_t mAh_or_Coulombs, uint16_t prescalar_mode, uint16_t prescalarValue, uint16_t alcc_mode)
Sleep Mode.
Definition: DC1496BB.ino:460
float LTC2942_code_to_voltage(uint16_t adc_code)
Calculate the LTC2942 SENSE+ voltage.
Definition: LTC2942.cpp:131
#define LTC2942_PRESCALAR_M_32
Definition: LTC2942.h:215
#define LTC2942_PRESCALAR_M_2
Definition: LTC2942.h:211
#define LTC2942_SLEEP_MODE
Definition: LTC2942.h:208
unsigned char user_command
LTC2942: Battery Gas Gauge with Temperature, Voltage Measurement.
const float LTC2942_FULLSCALE_TEMPERATURE
Definition: LTC2942.h:243
#define LTC2942_PRESCALAR_M_1
Definition: LTC2942.h:210
#define LTC2942_MANUAL_TEMPERATURE
Definition: LTC2942.h:207
#define LTC2942_TEMPERATURE_THRESH_LOW_REG
Definition: LTC2942.h:178
const float resistor
resistor value on demo board
Definition: DC1496BB.ino:116
static void store_alert_settings()
int8_t LTC2942_read_16_bits(uint8_t i2c_address, uint8_t adc_command, uint16_t *adc_code)
Reads a 16-bit adc_code from LTC2942.
Definition: LTC2942.cpp:103
Header File for Linduino Libraries and Demo Code.
#define LTC2942_I2C_ADDRESS
Definition: LTC2942.h:133
#define LTC2942_SHUTDOWN_MODE
Definition: LTC2942.h:223
#define LTC2942_VOLTAGE_THRESH_HIGH_REG
Definition: LTC2942.h:173
#define LTC2942_TEMPERATURE_MSB_REG
Definition: LTC2942.h:175
#define LTC2942_PRESCALAR_M_8
Definition: LTC2942.h:213
static int8_t menu_3_manual_temperature_mode(int8_t mAh_or_Coulombs, int8_t celcius_or_kelvin, uint16_t prescalar_mode, uint16_t prescalarValue, uint16_t alcc_mode)
Manual Voltage Mode.
Definition: DC1496BB.ino:384
static void print_prompt()
Print the Prompt.
Definition: DC1496BB.ino:216
#define LTC2942_STATUS_REG
Definition: LTC2942.h:163
int8_t LTC2942_write(uint8_t i2c_address, uint8_t adc_command, uint8_t code)
Write an 8-bit code to the LTC2942.
Definition: LTC2942.cpp:71
int8_t LTC2942_write_16_bits(uint8_t i2c_address, uint8_t adc_command, uint16_t code)
Write a 16-bit code to the LTC2942.
Definition: LTC2942.cpp:82
#define LTC2942_PRESCALAR_M_4
Definition: LTC2942.h:212
const float LTC2942_FULLSCALE_VOLTAGE
Definition: LTC2942.h:242
#define LTC2942_PRESCALAR_M_64
Definition: LTC2942.h:216
static int8_t menu_6_alert_menu_1_set_charge_thresholds()
Set Charge Threshold Function.
Definition: DC1496BB.ino:620
static uint8_t alert_code
Value stored or read from ALERT register.
Definition: DC1496BB.ino:125
#define LTC2942_MANUAL_VOLTAGE
Definition: LTC2942.h:206
static uint8_t menu_6_alert_menu_3_set_allcc_state(uint16_t *alcc_mode)
AL#/CC# Pin Mode Menu.
Definition: DC1496BB.ino:785
#define LTC2942_PRESCALAR_M_16
Definition: LTC2942.h:214
#define LTC2942_ACCUM_CHARGE_MSB_REG
Definition: LTC2942.h:165
float LTC2942_code_to_coulombs(uint16_t adc_code, float resistor, uint16_t prescalar)
Calculate the LTC2942 charge in Coulombs.
Definition: LTC2942.cpp:114
bool isBitSet(uint8_t value, uint8_t position)
Checks to see if a bit in a certain position is set.
Definition: DC1496BB.ino:882
static int8_t menu_6_settings_menu_2_set_prescalar_values(uint16_t *prescalar_mode, uint16_t *prescalarValue)
Prescalar Menu.
Definition: DC1496BB.ino:707
static int8_t menu_5_shutdown_mode()
Shutdown Mode.
Definition: DC1496BB.ino:518
QuikEval EEPROM Library.
static int8_t menu_2_manual_voltage_mode(int8_t mAh_or_Coulombs, int8_t celcius_or_kelvin, uint16_t prescalar_mode, uint16_t prescalarValue, uint16_t alcc_mode)
Manual Voltage Mode.
Definition: DC1496BB.ino:314
static int8_t menu_6_settings(uint8_t *mAh_or_Coulombs, uint8_t *celcius_or_kelvin, uint16_t *prescalar_mode, uint16_t *prescalarValue, uint16_t *alcc_mode)
Settings Menu.
Definition: DC1496BB.ino:527
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
#define LTC2942_CHARGE_COMPLETE_MODE
Definition: LTC2942.h:220
static void checkAlerts(uint8_t status_code)
Check Alerts Function - Checks to see if an alert has been set in the status register. If an alert has been set, it prints out the appropriate message.
Definition: DC1496BB.ino:888
#define LTC2942_DISABLE_ALCC_PIN
Definition: LTC2942.h:221
static void loop()
Repeats Linduino loop.
Definition: DC1496BB.ino:153
static uint8_t menu_6_alert_menu_4_set_units(uint8_t *mAh_or_Coulombs, uint8_t *celcius_or_kelvin)
Set Charge and Temperature Units Menu.
Definition: DC1496BB.ino:830
static int8_t menu_1_automatic_mode(int8_t mAh_or_Coulombs, int8_t celcius_or_kelvin, uint16_t prescalar_mode, uint16_t prescalarValue, uint16_t alcc_mode)
Automatic Mode.
Definition: DC1496BB.ino:228
#define LTC2942_VOLTAGE_THRESH_LOW_REG
Definition: LTC2942.h:174
static int8_t menu_6_alert_menu_3_set_temperature_thresholds()
Set Temperature Thresholds.
Definition: DC1496BB.ino:675
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
static void print_title()
Print the title block.
Definition: DC1496BB.ino:203
#define LTC2942_TEMPERATURE_THRESH_HIGH_REG
Definition: LTC2942.h:177
static int8_t menu_6_settings_menu_1_set_alert_thresholds()
Alert Threshold Menu.
Definition: DC1496BB.ino:578
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
static int8_t menu_6_alert_menu_2_set_voltage_thresholds()
Set Voltage Thresholds.
Definition: DC1496BB.ino:644
#define AUTOMATIC_MODE_DISPLAY_DELAY
The delay between readings in automatic mode.
Definition: DC1496BB.ino:114
int32_t read_int()
#define LTC2942_PRESCALAR_M_128
Definition: LTC2942.h:217
float read_float()
#define LTC2942_AUTOMATIC_MODE
Definition: LTC2942.h:205
#define LTC2942_VOLTAGE_MSB_REG
Definition: LTC2942.h:171
#define LTC2942_CHARGE_THRESH_LOW_MSB_REG
Definition: LTC2942.h:169
#define LTC2942_CONTROL_REG
Definition: LTC2942.h:164
float LTC2942_code_to_mAh(uint16_t adc_code, float resistor, uint16_t prescalar)
Calculate the LTC2942 charge in mAh.
Definition: LTC2942.cpp:123
static int8_t demo_board_connected
Set to 1 if the board is connected.
Definition: DC1496BB.ino:124
static void setup()
Initialize Linduino.
Definition: DC1496BB.ino:128
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
Definition: LT_I2C.cpp:401
static float voltage
Definition: DC2289AA.ino:71
static int8_t restore_alert_settings()
float LTC2942_code_to_celcius_temperature(uint16_t adc_code)
Calculate the LTC2942 temperature.
Definition: LTC2942.cpp:148
const char ack_error[]
Error message.
Definition: DC1496BB.ino:119
int8_t LTC2942_read(uint8_t i2c_address, uint8_t adc_command, uint8_t *adc_code)
Reads an 8-bit adc_code from LTC2942.
Definition: LTC2942.cpp:92
float LTC2942_code_to_kelvin_temperature(uint16_t adc_code)
Calculate the LTC2942 temperature.
Definition: LTC2942.cpp:140
#define LTC2942_CHARGE_THRESH_HIGH_MSB_REG
Definition: LTC2942.h:167
#define LTC2942_ALERT_MODE
Definition: LTC2942.h:219