| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DC985A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC985A Demonstration Board.
3 LTC4245: Hot Swap Controller with I2C Compatible Monitoring
4
5 @verbatim
6
7 NOTES
8 Setup:
9 Set the terminal baud rate to 115200 and select the newline terminator. Provide
10 the board with an external power supply of 12 V. Ensure all jumpers on the
11 demo board are installed in their default positions from the factory. Refer to
12 Demo Manual DC985A.
13
14 This program has options to measure voltage at ADIN pin (input voltage), SOURCE
15 VOLTAGE (output voltage), and SENSE CURRENT (current through sense resisitor).
16 There are also options to read and manipulate CONTROL register, ALERT register,
17 and FAULT register.
18
19 Mass write option can be achieved using Device Address = 0xBE. Refer to datasheet
20 LTC4245.
21
22 USER INPUT DATA FORMAT:
23 decimal : 1024
24 hex : 0x400
25 octal : 02000 (leading 0 "zero")
26 binary : B10000000000
27 float : 1024.0
28
29 @endverbatim
30
31 http://www.linear.com/product/LTC4245
32
33 http://www.linear.com/product/LTC4245#demoboards
34
35
36 Copyright 2018(c) Analog Devices, Inc.
37
38 All rights reserved.
39
40 Redistribution and use in source and binary forms, with or without
41 modification, are permitted provided that the following conditions are met:
42 - Redistributions of source code must retain the above copyright
43 notice, this list of conditions and the following disclaimer.
44 - Redistributions in binary form must reproduce the above copyright
45 notice, this list of conditions and the following disclaimer in
46 the documentation and/or other materials provided with the
47 distribution.
48 - Neither the name of Analog Devices, Inc. nor the names of its
49 contributors may be used to endorse or promote products derived
50 from this software without specific prior written permission.
51 - The use of this software may or may not infringe the patent rights
52 of one or more patent holders. This license does not release you
53 from the requirement that you obtain separate licenses from these
54 patent holders to use this software.
55 - Use of the software either in source or binary form, must be run
56 on or directly connected to an Analog Devices Inc. component.
57
58 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
59 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
60 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
61 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
62 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
63 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
64 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
65 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
66 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
67 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68 */
69
70 /*! @file
71 @ingroup LTC4245
72 */
73
74 // Headerfiles
75 #include <Arduino.h>
76 #include <stdint.h>
77 #include "Linduino.h"
78 #include "LT_I2C.h"
79 #include "LT_SPI.h"
80 #include "UserInterface.h"
81 #include "QuikEval_EEPROM.h"
82 #include <Wire.h>
83 #include <SPI.h>
84 #include "LTC4245.h"
85
86 // Function Declarations
87 void print_title();
88 void print_prompt();
89 int8_t main_menu_1_continuous_mode();
90 int8_t main_menu_2_read_and_clear_faults();
91 int8_t main_menu_3_send_ARA();
92 int8_t main_menu_4_manage_alerts();
93 int8_t main_menu_5_settings();
94 int8_t main_menu_6_read_all_registers();
95
96 //! Initialize Linduino
97 void setup()
98 {
99 char demo_name[] = "DC985"; // Demo Board Name stored in QuikEval EEPROM
100 quikeval_I2C_init(); // Enable the I2C port
101 quikeval_I2C_connect();
102 Serial.begin(115200); // Initialize the serial port to the PC
103 print_title();
104 discover_DC985A(demo_name);
105 print_prompt();
106 }
107
108 //! Repeats Linduino loop
109 void loop()
110 {
111 if (1)
112 {
113 int8_t ack = 0; // I2C acknowledge indicator
114 static uint8_t user_command; // The user input command
115 if (Serial.available()) //! Do nothing if serial is not available
116 {
117 user_command = read_int(); //! Read user input command
118 if (user_command != 'm')
119 Serial.println(user_command);
120 Serial.println();
121 ack = 0;
122
123 switch (user_command) //! Prints the appropriate submenu
124 {
125 case 1:
126 ack |= main_menu_1_continuous_mode(); // continous mode
127 break;
128 case 2:
129 ack |= main_menu_2_read_and_clear_faults(); // read and clear faults
130 break;
131 case 3:
132 ack |= main_menu_3_send_ARA();// read address of alert
133 break;
134 case 4:
135 ack |= main_menu_4_manage_alerts(); // manage alerts
136 break;
137 case 5:
138 ack |= main_menu_5_settings(); // settings
139 break;
140 case 6:
141 ack |= main_menu_6_read_all_registers();
142 break;
143 default:
144 Serial.println("Incorrect Option");
145 break;
146 }
147
148 print_prompt();
149 }
150 }
151 }
152
153 //! Read the ID string from the EEPROM and determine if the correct board is connected.
154 //! Returns 1 if successful, 0 if not successful
155 uint8_t discover_DC985A(char *demo_name)
156 {
157 Serial.print(F("\nChecking EEPROM contents..."));
158 read_quikeval_id_string(&ui_buffer[0]);
159 ui_buffer[48] = 0;
160 Serial.println(ui_buffer);
161
162 if (!strcmp(demo_board.name, demo_name))
163 {
164 Serial.print("Demo Board Name: ");
165 Serial.println(demo_board.name);
166 Serial.print("Product Name: ");
167 Serial.println(demo_board.product_name);
168 if (demo_board.option)
169 {
170 Serial.print("Demo Board Option: ");
171 Serial.println(demo_board.option);
172 }
173 Serial.println(F("Demo board connected"));
174 Serial.println(F("\n\n\t\t\t\tPress Enter to Continue..."));
175 read_int();
176 return 1;
177 }
178 else
179 {
180 Serial.print("Demo board ");
181 Serial.print(demo_name);
182 Serial.print(" not found, \nfound ");
183 Serial.print(demo_board.name);
184 Serial.println(" instead. \nConnect the correct demo board, then press the reset button.");
185 return 0;
186 }
187 }
188
189 //! Print the title block
190 void print_title()
191 {
192 Serial.println(F("\n*****************************************************************"));
193 Serial.print(F("* DC874A Demonstration Program *\n"));
194 Serial.print(F("* *\n"));
195 Serial.print(F("* This program demonstrates how to send and receive data from *\n"));
196 Serial.print(F("* LTC4245 Hot Swap Controller with I2C Compatible Monitoring *\n"));
197 Serial.print(F("* Set the baud rate to 115200 and select the newline terminator.*\n"));
198 Serial.print(F("* *\n"));
199 Serial.print(F("*****************************************************************\n"));
200 }
201
202 //! Print the main menu
203 void print_prompt()
204 {
205 Serial.print(F("\n\nMain Menu\n"));
206 Serial.print(F(" 1. Read current and voltage on continous mode\n"));
207 Serial.print(F(" 2. Read and clear faults\n"));
208 Serial.print(F(" 3. Request for alert response address (ARA)\n"));
209 Serial.print(F(" 4. Manage alerts\n"));
210 Serial.print(F(" 5. Settings\n"));
211 Serial.print(F(" 6. Read all registers\n\n"));
212 Serial.print(F("Enter a command: "));
213 }
214
215 //! Function to read Rsense current, ADIN voltage and ADIN2 voltage in continous mode
216 int8_t main_menu_1_continuous_mode()
217 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
218 {
219 int8_t choice;
220 int8_t ack = 0;
221 float sense_voltage, vin_voltage, vout_voltage;
222 uint8_t sense_code, vin_code, vout_code;
223 // Set voltage divider ratio to 1, for no resistor divider circuit.
224 float vin_full_scale_12V = 14.025;
225 float vin_full_scale_5V = 5.61;
226 float vin_full_scale_3_3V = 3.825;
227 float vin_full_scale_NEG12V = -14.025;
228
229 float sense_full_scale_12V = (63.75/1000);
230 float sense_full_scale_5V = (31.875/1000);
231 float sense_full_scale_3_3V = (31.875/1000);
232 float sense_full_scale_NEG12V = (-63.75/1000);
233
234 float vout_full_scale_12V = 14.025;
235 float vout_full_scale_5V = 5.61;
236 float vout_full_scale_3_3V = 3.825;
237 float vout_full_scale_NEG12V = -14.025;
238
239 float SENSE_RESISTOR_12V = 0.008;
240 float SENSE_RESISTOR_5V = 0.0035;
241 float SENSE_RESISTOR_3_3V = 0.0025;
242 float SENSE_RESISTOR_NEG12V = 0.004;
243
244 Serial.println(F("1. Read in continous mode"));
245 Serial.print(F("2. Read in snapshot mode"));
246 choice = read_int();
247
248 if (choice == 1)
249 {
250 do
251 {
252 Serial.print(F("********** Press Enter to Exit ***********\n\n"));
253 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_12VIN_REG, &vin_code);
254 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_12VSENSE_REG, &sense_code);
255 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_12VOUT_REG, &vout_code);
256
257 vin_voltage = LTC4245_code_to_voltage(vin_code, vin_full_scale_12V);
258 sense_voltage = LTC4245_code_to_voltage(sense_code, sense_full_scale_12V);
259 vout_voltage = LTC4245_code_to_voltage(vout_code, vout_full_scale_12V);
260
261 Serial.print(F("VIN: "));
262 Serial.println(vin_voltage);
263 Serial.print(F("SENSE VOLTAGE CODE: "));
264 Serial.println(sense_code);
265 Serial.print(F("SENSE CURRENT CALCULATED: "));
266 Serial.println((sense_voltage / SENSE_RESISTOR_12V), 4);
267 Serial.print(F("VOUT: "));
268 Serial.println(vout_voltage);
269 Serial.print("\n");
270
271
272 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_5VIN_REG, &vin_code);
273 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_5VSENSE_REG, &sense_code);
274 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_5VOUT_REG, &vout_code);
275
276 vin_voltage = LTC4245_code_to_voltage(vin_code, vin_full_scale_5V);
277 sense_voltage = LTC4245_code_to_voltage(sense_code, sense_full_scale_5V);
278 vout_voltage = LTC4245_code_to_voltage(vout_code, vout_full_scale_5V);
279
280 Serial.print(F("VIN: "));
281 Serial.println(vin_voltage);
282 Serial.print(F("SENSE VOLTAGE CODE: "));
283 Serial.println(sense_code);
284 Serial.print(F("SENSE CURRENT CALCULATED: "));
285 Serial.println((sense_voltage / SENSE_RESISTOR_5V), 4);
286 Serial.print(F("VOUT: "));
287 Serial.println(vout_voltage);
288 Serial.print("\n");
289
290
291 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_3_3VIN_REG, &vin_code);
292 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_3_3VSENSE_REG, &sense_code);
293 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_3_3VOUT_REG, &vout_code);
294
295 vin_voltage = LTC4245_code_to_voltage(vin_code, vin_full_scale_3_3V);
296 sense_voltage = LTC4245_code_to_voltage(sense_code, sense_full_scale_3_3V);
297 vout_voltage = LTC4245_code_to_voltage(vout_code, vout_full_scale_3_3V);
298
299 Serial.print(F("VIN: "));
300 Serial.println(vin_voltage);
301 Serial.print(F("SENSE VOLTAGE CODE: "));
302 Serial.println(sense_code);
303 Serial.print(F("SENSE CURRENT CALCULATED: "));
304 Serial.println((sense_voltage / SENSE_RESISTOR_3_3V), 4);
305 Serial.print(F("VOUT: "));
306 Serial.println(vout_voltage);
307 Serial.print("\n");
308
309
310 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_VEEIN_REG, &vin_code);
311 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_VEESENSE_REG, &sense_code);
312 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_VEEOUT_REG, &vout_code);
313
314 vin_voltage = LTC4245_code_to_voltage(vin_code, vin_full_scale_NEG12V);
315 sense_voltage = LTC4245_code_to_voltage(sense_code, sense_full_scale_NEG12V);
316 vout_voltage = LTC4245_code_to_voltage(vout_code, vout_full_scale_NEG12V);
317
318 Serial.print(F("VIN: "));
319 Serial.println(vin_voltage);
320 Serial.print(F("SENSE VOLTAGE CODE: "));
321 Serial.println(sense_code);
322 Serial.print(F("SENSE CURRENT CALCULATED: "));
323 Serial.println((sense_voltage / SENSE_RESISTOR_NEG12V), 4);
324 Serial.print(F("VOUT: "));
325 Serial.println(vout_voltage);
326 Serial.print("\n");
327 delay(2000);
328 }
329 while (Serial.available()==false && ack== 0);
330 if (Serial.available())
331 read_int(); // clears the Serial.available()
332 }
333
334 return (ack);
335 }
336
337
338 //! Function to read and clear fault register
339 int8_t main_menu_2_read_and_clear_faults()
340 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
341 {
342 int8_t ack = 0;
343
344 uint8_t faults;
345 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_FAULT1_REG, &faults);
346 if (faults != 0)
347 {
348 Serial.println(F("Faults Detected :"));
349 if (faults & LTC4245_NEG12V_OVERCURRENT_FAULT)
350 Serial.println(F(" Overcurrent Fault Occurred on –12V Supply"));
351 if (faults & LTC4245_3_3V_OVERCURRENT_FAULT)
352 Serial.println(F(" Overcurrent Fault Occurred on 3.3V Supply"));
353 if (faults & LTC4245_5V_OVERCURRENT_FAULT)
354 Serial.println(F(" Overcurrent Fault Occurred on 5V Supply"));
355 if (faults & LTC4245_12V_OVERCURRENT_FAULT)
356 Serial.println(F(" Overcurrent Fault Occurred on 12V Supply"));
357 if (faults & LTC4245_NEG12V_UNDERVOLTAGE_FAULT)
358 Serial.println(F(" Undervoltage Fault Occurred on –12V Supply"));
359 if (faults & LTC4245_3_3V_UNDERVOLTAGE_FAULT)
360 Serial.println(F(" Undervoltage Fault Occurred on 3.3V Supply"));
361 if (faults & LTC4245_5V_UNDERVOLTAGE_FAULT)
362 Serial.println(F(" Undervoltage Fault Occurred on 5V Supply"));
363 if (faults & LTC4245_12V_UNDERVOLTAGE_FAULT)
364 Serial.println(F(" Undervoltage Fault Occurred on 12V Supply"));
365 }
366 faults = 0;
367 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_FAULT2_REG, &faults);
368 if (faults != 0)
369 {
370 if (faults & LTC4245_GPIO1_STATE_CHANGE)
371 Serial.println(F(" GPIO1 Pin Changed State"));
372 if (faults & LTC4245_BD_SEL_STATE_CHANGE)
373 Serial.println(F(" BD_SEL# Pin Changed State"));
374 if (faults & LTC4245_FET_SHORT_FAULT)
375 Serial.println(F(" FET Short Detected on at Least One Supply"));
376 if (faults & LTC4245_PGI_FAULT)
377 Serial.println(F(" PGI Fault Occurred"));
378 if (faults & LTC4245_NEG12V_POWER_BAD_FAULT)
379 Serial.println(F(" –12V Power Bad When VEEOUT Went High"));
380 if (faults & LTC4245_3_3V_POWER_BAD_FAULT)
381 Serial.println(F(" 3.3V Power Bad When 3VOUT Went Low"));
382 if (faults & LTC4245_5V_POWER_BAD_FAULT)
383 Serial.println(F(" 5V Power Bad When 5VOUT Went Low"));
384 if (faults & LTC4245_12V_POWER_BAD_FAULT)
385 Serial.println(F(" 12V Power Bad When 12VOUT Went Low"));
386 }
387 ack |= LTC4245_write(LTC4245_I2C_ADDRESS, LTC4245_FAULT1_REG, 0x00);
388 ack |= LTC4245_write(LTC4245_I2C_ADDRESS, LTC4245_FAULT2_REG, 0x00);
389 Serial.print(F("\nALL FAULTS CLEARED \n\n"));
390
391 return (ack);
392 }
393
394 //! Function to send alert response (0001100) and read back the address of device that pulled ALERT pin low.
395 int8_t main_menu_3_send_ARA()
396 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
397 {
398 int8_t ack = 0;
399 uint8_t address;
400 ack |= LTC4245_ARA(LTC4245_I2C_ALERT_RESPONSE, &address);// send ARA
401 Serial.print(F(" ALERT RESPONSE ADDRESS : 0x"));
402 Serial.println(address,HEX);
403 if (address == 0xFF && ack == 1)
404 {
405 ack = 0;
406 Serial.print(F(" NO RESPONSE\n\n"));
407 }
408 return(ack);
409 }
410
411 //! Function to update alert register bits
412 int8_t main_menu_4_manage_alerts()
413 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
414 {
415 int8_t ack = 0;
416 uint8_t alert_settings = 0;
417 int8_t user_command;
418 do
419 {
420 Serial.println(F("GPIO1 STATE CHANGE ALERT"));
421 Serial.println(F(" 1. Enable"));
422 Serial.println(F(" 2. Disable"));
423 Serial.print(F("Enter a command: "));
424 user_command = read_int();
425 if (user_command == 'm')
426 Serial.println("m");
427 else
428 Serial.println(user_command);
429 Serial.println();
430 if (user_command == 1)
431 alert_settings |= LTC4245_GPIO1_STATE_CHANGE_ENABLE;
432 else if (user_command ==2)
433 alert_settings &= LTC4245_GPIO1_STATE_CHANGE_DISABLE;
434 else if (user_command != 'm')
435 Serial.println("Incorrect Option\n");
436 else
437 return(ack);
438
439 Serial.println(F("BD_SEL# STATE CHANGE ALERT"));
440 Serial.println(F(" 1. Enable"));
441 Serial.println(F(" 2. Disable"));
442 Serial.print(F("Enter a command: "));
443 user_command = read_int();
444 if (user_command == 'm')
445 Serial.println("m");
446 else
447 Serial.println(user_command);
448 Serial.println();
449 if (user_command == 1)
450 alert_settings |= LTC4245_BD_SEL_STATE_CHANGE_ENABLE;
451 else if (user_command ==2)
452 alert_settings &= LTC4245_BD_SEL_STATE_CHANGE_DISABLE;
453 else if (user_command != 'm')
454 Serial.println("Incorrect Option\n");
455 else
456 return(ack);
457
458 Serial.println(F("FET SHORT ALERT"));
459 Serial.println(F(" 1. Enable"));
460 Serial.println(F(" 2. Disable"));
461 Serial.print(F("Enter a command: "));
462 user_command = read_int();
463 if (user_command == 'm')
464 Serial.println("m");
465 else
466 Serial.println(user_command);
467 Serial.println();
468 if (user_command == 1)
469 alert_settings |= LTC4245_FET_SHORT_ENABLE;
470 else if (user_command ==2)
471 alert_settings &= LTC4245_FET_SHORT_DISABLE;
472 else if (user_command != 'm')
473 Serial.println("Incorrect Option\n");
474 else
475 return(ack);
476
477 Serial.println(F("PGI FAULT ALERT"));
478 Serial.println(F(" 1. Enable"));
479 Serial.println(F(" 2. Disable"));
480 Serial.print(F("Enter a command: "));
481 user_command = read_int();
482 if (user_command == 'm')
483 Serial.println("m");
484 else
485 Serial.println(user_command);
486 Serial.println();
487 if (user_command == 1)
488 alert_settings |= LTC4245_PGI_FAULT_ENABLE;
489 else if (user_command ==2)
490 alert_settings &= LTC4245_PGI_FAULT_DISABLE;
491 else if (user_command != 'm')
492 Serial.println("Incorrect Option\n");
493 else
494 return(ack);
495
496 Serial.println(F("ALERT# Pin Open-Drain Output State"));
497 Serial.println(F(" 1. Pulls Low"));
498 Serial.println(F(" 2. High Impedance"));
499 Serial.print(F("Enter a command: "));
500 user_command = read_int();
501 if (user_command == 'm')
502 Serial.println("m");
503 else
504 Serial.println(user_command);
505 Serial.println();
506 if (user_command == 1)
507 alert_settings |= LTC4245_ALERT_PRESENT_ENABLE;
508 else if (user_command ==2)
509 alert_settings &= LTC4245_ALERT_PRESENT_DISABLE;
510 else if (user_command != 'm')
511 Serial.println("Incorrect Option\n");
512 else
513 return(ack);
514
515 Serial.println(F("POWER BAD ALERT"));
516 Serial.println(F(" 1. Enable"));
517 Serial.println(F(" 2. Disable"));
518 Serial.print(F("Enter a command: "));
519 user_command = read_int();
520 if (user_command == 'm')
521 Serial.println("m");
522 else
523 Serial.println(user_command);
524 Serial.println();
525 if (user_command == 1)
526 alert_settings |= LTC4245_POWER_BAD_ENABLE;
527 else if (user_command ==2)
528 alert_settings &= LTC4245_POWER_BAD_DISABLE;
529 else if (user_command != 'm')
530 Serial.println("Incorrect Option\n");
531 else
532 return(ack);
533
534 Serial.println(F("OVERCURRENT ALERT"));
535 Serial.println(F(" 1. Enable"));
536 Serial.println(F(" 2. Disable"));
537 Serial.print(F("Enter a command: "));
538 user_command = read_int();
539 if (user_command == 'm')
540 Serial.println("m");
541 else
542 Serial.println(user_command);
543 Serial.println();
544 if (user_command == 1)
545 alert_settings |= LTC4245_OVERCURRENT_ENABLE;
546 else if (user_command ==2)
547 alert_settings &= LTC4245_OVERCURRENT_DISABLE;
548 else if (user_command != 'm')
549 Serial.println("Incorrect Option\n");
550 else
551 return(ack);
552
553 Serial.println(F("UNDERVOLTAGE ALERT"));
554 Serial.println(F(" 1. Enable"));
555 Serial.println(F(" 2. Disable"));
556 Serial.print(F("Enter a command: "));
557 user_command = read_int();
558 if (user_command == 'm')
559 Serial.println("m");
560 else
561 Serial.println(user_command);
562 Serial.println();
563 if (user_command == 1)
564 alert_settings |= LTC4245_UNDERVOLTAGE_ENABLE;
565 else if (user_command ==2)
566 alert_settings &= LTC4245_UNDERVOLTAGE_DISABLE;
567 else if (user_command != 'm')
568 Serial.println("Incorrect Option\n");
569 else
570 return(ack);
571
572 ack |= LTC4245_write(LTC4245_I2C_ADDRESS, LTC4245_ALERT_REG, alert_settings);
573 Serial.print(F("\n ALERTS UPDATED\n\n"));
574 Serial.println(F(" m. Main Menu"));
575 Serial.println(F(" 1. Repeat"));
576 Serial.print(F("Enter a command: "));
577 user_command = read_int();
578 if (user_command == 'm')
579 Serial.println("m");
580 else
581 Serial.println(user_command);
582 Serial.println();
583 }
584 while (!((user_command == 'm') || (ack)));
585 return(ack);
586 }
587
588 //! Function to update control register bits
589 int8_t main_menu_5_settings()
590 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
591 {
592 int8_t ack = 0;
593 uint8_t settings =0;
594 int8_t user_command;
595 do
596 {
597 Serial.println(F("ADC Free Running Operation to Allow On-Demand Measurement and Writes to ADC Registers"));
598 Serial.println(F(" 1. ADC Free Running"));
599 Serial.println(F(" 2. Halt ADC Free Running"));
600 Serial.print(F("Enter a command: "));
601 user_command = read_int();
602 if (user_command == 'm')
603 Serial.println("m");
604 else
605 Serial.println(user_command);
606 Serial.println();
607 if (user_command == 1)
608 settings |= LTC4245_ADC_FREE_RUN_ENABLE;
609 else if (user_command ==2)
610 settings &= LTC4245_ADC_FREE_RUN_DISABLE;
611 else if (user_command != 'm')
612 Serial.println("Incorrect Option\n");
613 else
614 return(ack);
615
616 Serial.println(F("Turn-On in a Set Sequence"));
617 Serial.println(F(" 1. Sequencing Enabled"));
618 Serial.println(F(" 2. Sequencing Disabled"));
619 Serial.print(F("Enter a command: "));
620 user_command = read_int();
621 if (user_command == 'm')
622 Serial.println("m");
623 else
624 Serial.println(user_command);
625 Serial.println();
626 if (user_command == 1)
627 settings |= LTC4245_SEQUENCING_ENABLE;
628 else if (user_command ==2)
629 settings &= LTC4245_SEQUENCING_DISABLE;
630 else if (user_command != 'm')
631 Serial.println("Incorrect Option\n");
632 else
633 return(ack);
634
635 Serial.println(F("MASS WRITE"));
636 Serial.println(F(" 1. Enable"));
637 Serial.println(F(" 2. Disable"));
638 Serial.print(F("Enter a command: "));
639 user_command = read_int();
640 if (user_command == 'm')
641 Serial.println("m");
642 else
643 Serial.println(user_command);
644 Serial.println();
645 if (user_command == 1)
646 settings |= LTC4245_MASS_WRITE_ENABLE;
647 else if (user_command ==2)
648 settings &= LTC4245_MASS_WRITE_DISABLE;
649 else if (user_command != 'm')
650 Serial.println("Incorrect Option\n");
651 else
652 return(ack);
653
654 Serial.println(F("PGI Fault Autoretry"));
655 Serial.println(F(" 1. ON"));
656 Serial.println(F(" 2. OFF"));
657 Serial.print(F("Enter a command: "));
658 user_command = read_int();
659 if (user_command == 'm')
660 Serial.println("m");
661 else
662 Serial.println(user_command);
663 Serial.println();
664 if (user_command == 1)
665 settings |= LTC4245_PGI_FAULT_AUTO_RETRY_ENABLE;
666 else if (user_command ==2)
667 settings &= LTC4245_PGI_FAULT_AUTO_RETRY_DISABLE;
668 else if (user_command != 'm')
669 Serial.println("Incorrect Option\n");
670 else
671 return(ack);
672
673 Serial.println(F(" PGI Pin"));
674 Serial.println(F(" 1. PGI Pin Enabled"));
675 Serial.println(F(" 2. PGI Pin Disabled"));
676 Serial.print(F("Enter a command: "));
677 user_command = read_int();
678 if (user_command == 'm')
679 Serial.println("m");
680 else
681 Serial.println(user_command);
682 Serial.println();
683 if (user_command == 1)
684 settings |= LTC4245_PGI_ENABLE;
685 else if (user_command ==2)
686 settings &= LTC4245_PGI_DISABLE;
687 else if (user_command != 'm')
688 Serial.println("Incorrect Option\n");
689 else
690 return(ack);
691
692 Serial.println(F("OVERCURRENT AUTO RETRY"));
693 Serial.println(F(" 1. Enable"));
694 Serial.println(F(" 2. Disable"));
695 Serial.print(F("Enter a command: "));
696 user_command = read_int();
697 if (user_command == 'm')
698 Serial.println("m");
699 else
700 Serial.println(user_command);
701 Serial.println();
702 if (user_command == 1)
703 settings |= LTC4245_OVERCURRENT_AUTO_RETRY_ENABLE;
704 else if (user_command ==2)
705 settings &= LTC4245_OVERCURRENT_AUTO_RETRY_DISABLE;
706 else if (user_command != 'm')
707 Serial.println("Incorrect Option\n");
708 else
709 return(ack);
710
711 Serial.println(F("UNDERVOLTAGE AUTO RETRY"));
712 Serial.println(F(" 1. Enable"));
713 Serial.println(F(" 2. Disable"));
714 Serial.print(F("Enter a command: "));
715 user_command = read_int();
716 if (user_command == 'm')
717 Serial.println("m");
718 else
719 Serial.println(user_command);
720 Serial.println();
721 if (user_command == 1)
722 settings |= LTC4245_UNDERVOLTAGE_AUTO_RETRY_ENABLE;
723 else if (user_command ==2)
724 settings &= LTC4245_UNDERVOLTAGE_AUTO_RETRY_DISABLE;
725 else if (user_command != 'm')
726 Serial.println("Incorrect Option\n");
727 else
728 return(ack);
729
730 ack |= LTC4245_write(LTC4245_I2C_ADDRESS, LTC4245_CONTROL_REG, settings);
731 Serial.print(F("\nSETTINGS UPDATED\n\n"));
732 Serial.println(F(" m. Main Menu"));
733 Serial.println(F(" 1. Repeat"));
734 Serial.print(F("Enter a command: "));
735 user_command = read_int();
736 if (user_command == 'm')
737 Serial.println("m");
738 else
739 Serial.println(user_command);
740 Serial.println();
741 }
742 while (!((user_command == 'm') || (ack)));
743 return(ack);
744 }
745
746 //! Function to read all registers.
747 int8_t main_menu_6_read_all_registers()
748 //! @return Returns the state of the acknowledge bit after the I2C address read. 0=acknowledge, 1=no acknowledge.
749 {
750 int8_t ack = 0;
751 uint8_t register_val;
752 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_STATUS_REG, &register_val);
753 Serial.print(" STATUS REGISTER : 0b");
754 Serial.println(register_val, BIN);
755 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_ALERT_REG, &register_val);
756 Serial.print(" ALERT REGISTER : 0b");
757 Serial.println(register_val, BIN);
758 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_CONTROL_REG, &register_val);
759 Serial.print(" CONTROL REGISTER : 0b");
760 Serial.println(register_val, BIN);
761 ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_ON_REG, &register_val);
762 Serial.print(" ON REGISTER : 0b");
763 Serial.println(register_val, BIN);
764 Serial.println();
765 return ack;
766 }
demo_board
struct demo_board_type demo_board
Instantiate demo board structure.
Definition: QuikEval_EEPROM.cpp:71
LTC4245_12V_UNDERVOLTAGE_FAULT
#define LTC4245_12V_UNDERVOLTAGE_FAULT
Definition: LTC4245.h:196
demo_board_type::option
char option
Demo Circuit option (A)
Definition: QuikEval_EEPROM.h:72
LTC4245_OVERCURRENT_ENABLE
#define LTC4245_OVERCURRENT_ENABLE
Definition: LTC4245.h:153
LTC4245_ON_REG
#define LTC4245_ON_REG
Definition: LTC4245.h:110
setup
static void setup()
Initialize Linduino.
Definition: DC985A.ino:97
user_command
unsigned char user_command
Definition: Serial_EEPROM_Test.ino:75
LTC4245_OVERCURRENT_AUTO_RETRY_ENABLE
#define LTC4245_OVERCURRENT_AUTO_RETRY_ENABLE
Definition: LTC4245.h:177
LTC4245_I2C_ALERT_RESPONSE
#define LTC4245_I2C_ALERT_RESPONSE
Definition: LTC4245.h:100
LTC4245_CONTROL_REG
#define LTC4245_CONTROL_REG
Definition: LTC4245.h:109
LTC4245_3_3VIN_REG
#define LTC4245_3_3VIN_REG
Definition: LTC4245.h:126
LTC4245_NEG12V_POWER_BAD_FAULT
#define LTC4245_NEG12V_POWER_BAD_FAULT
Definition: LTC4245.h:202
LTC4245_ALERT_PRESENT_DISABLE
#define LTC4245_ALERT_PRESENT_DISABLE
Definition: LTC4245.h:150
main_menu_4_manage_alerts
static int8_t main_menu_4_manage_alerts()
Function to update alert register bits.
Definition: DC985A.ino:412
LTC4245_code_to_voltage
float LTC4245_code_to_voltage(uint8_t register_code, float full_scale_voltage)
Calculates voltage from register code data.
Definition: LTC4245.cpp:73
LTC4245_ALERT_PRESENT_ENABLE
#define LTC4245_ALERT_PRESENT_ENABLE
Definition: LTC4245.h:149
LTC4245_ADC_FREE_RUN_DISABLE
#define LTC4245_ADC_FREE_RUN_DISABLE
Definition: LTC4245.h:162
LTC4245_PGI_FAULT_AUTO_RETRY_ENABLE
#define LTC4245_PGI_FAULT_AUTO_RETRY_ENABLE
Definition: LTC4245.h:171
demo_board_type::name
char name[15]
Demo Circuit number (DC1678)
Definition: QuikEval_EEPROM.h:71
LTC4245_OVERCURRENT_DISABLE
#define LTC4245_OVERCURRENT_DISABLE
Definition: LTC4245.h:154
LTC4245_MASS_WRITE_ENABLE
#define LTC4245_MASS_WRITE_ENABLE
Definition: LTC4245.h:168
LTC4245_FET_SHORT_DISABLE
#define LTC4245_FET_SHORT_DISABLE
Definition: LTC4245.h:146
LTC4245_UNDERVOLTAGE_AUTO_RETRY_ENABLE
#define LTC4245_UNDERVOLTAGE_AUTO_RETRY_ENABLE
Definition: LTC4245.h:180
main_menu_1_continuous_mode
static int8_t main_menu_1_continuous_mode()
Function to read Rsense current, ADIN voltage and ADIN2 voltage in continous mode.
Definition: DC985A.ino:216
LTC4245_MASS_WRITE_DISABLE
#define LTC4245_MASS_WRITE_DISABLE
Definition: LTC4245.h:169
LTC4245_VEEOUT_REG
#define LTC4245_VEEOUT_REG
Definition: LTC4245.h:131
Linduino.h
Header File for Linduino Libraries and Demo Code.
LTC4245_GPIO1_STATE_CHANGE_DISABLE
#define LTC4245_GPIO1_STATE_CHANGE_DISABLE
Definition: LTC4245.h:142
LTC4245_12V_POWER_BAD_FAULT
#define LTC4245_12V_POWER_BAD_FAULT
Definition: LTC4245.h:205
LTC4245_STATUS_REG
#define LTC4245_STATUS_REG
Definition: LTC4245.h:107
LTC4245_12VOUT_REG
#define LTC4245_12VOUT_REG
Definition: LTC4245.h:122
LTC4245_UNDERVOLTAGE_AUTO_RETRY_DISABLE
#define LTC4245_UNDERVOLTAGE_AUTO_RETRY_DISABLE
Definition: LTC4245.h:181
LTC4245_PGI_FAULT
#define LTC4245_PGI_FAULT
Definition: LTC4245.h:201
LTC4245_BD_SEL_STATE_CHANGE
#define LTC4245_BD_SEL_STATE_CHANGE
Definition: LTC4245.h:199
LTC4245_POWER_BAD_ENABLE
#define LTC4245_POWER_BAD_ENABLE
Definition: LTC4245.h:151
address
static uint8_t address
Definition: DC2091A.ino:83
LTC4245_SEQUENCING_DISABLE
#define LTC4245_SEQUENCING_DISABLE
Definition: LTC4245.h:166
LTC4245_FAULT1_REG
#define LTC4245_FAULT1_REG
Definition: LTC4245.h:111
LTC4245_5V_UNDERVOLTAGE_FAULT
#define LTC4245_5V_UNDERVOLTAGE_FAULT
Definition: LTC4245.h:195
LTC4245_ALERT_REG
#define LTC4245_ALERT_REG
Definition: LTC4245.h:108
LTC4245_FET_SHORT_ENABLE
#define LTC4245_FET_SHORT_ENABLE
Definition: LTC4245.h:145
main_menu_6_read_all_registers
static int8_t main_menu_6_read_all_registers()
Function to read all registers.
Definition: DC985A.ino:747
print_title
static void print_title()
Print the title block.
Definition: DC985A.ino:190
main_menu_3_send_ARA
static int8_t main_menu_3_send_ARA()
Function to send alert response (0001100) and read back the address of device that pulled ALERT pin l...
Definition: DC985A.ino:395
LTC4245_SEQUENCING_ENABLE
#define LTC4245_SEQUENCING_ENABLE
Definition: LTC4245.h:165
LTC4245_3_3V_UNDERVOLTAGE_FAULT
#define LTC4245_3_3V_UNDERVOLTAGE_FAULT
Definition: LTC4245.h:194
LTC4245_5V_OVERCURRENT_FAULT
#define LTC4245_5V_OVERCURRENT_FAULT
Definition: LTC4245.h:191
settings
static void settings()
Configures the output.
Definition: DC726B_A.ino:202
LTC4245_ARA
int8_t LTC4245_ARA(uint8_t alert_response_address, uint8_t *i2c_address)
SMBus Alert ResponseProtocol: Sends an alert response command and releases /ALERT pin...
Definition: LTC4245.cpp:82
LTC4245_GPIO1_STATE_CHANGE
#define LTC4245_GPIO1_STATE_CHANGE
Definition: LTC4245.h:198
QuikEval_EEPROM.h
QuikEval EEPROM Library.
LTC4245.h
LTC4245: Hot Swap Controller with I2C Compatible Monitoring.
LTC4245_I2C_ADDRESS
#define LTC4245_I2C_ADDRESS
Definition: LTC4245.h:99
main_menu_5_settings
static int8_t main_menu_5_settings()
Function to update control register bits.
Definition: DC985A.ino:589
LTC4245_3_3V_POWER_BAD_FAULT
#define LTC4245_3_3V_POWER_BAD_FAULT
Definition: LTC4245.h:203
LTC4245_5VOUT_REG
#define LTC4245_5VOUT_REG
Definition: LTC4245.h:125
LTC4245_BD_SEL_STATE_CHANGE_ENABLE
#define LTC4245_BD_SEL_STATE_CHANGE_ENABLE
Definition: LTC4245.h:143
LT_SPI.h
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
LTC4245_ADC_FREE_RUN_ENABLE
#define LTC4245_ADC_FREE_RUN_ENABLE
Definition: LTC4245.h:163
LTC4245_12VSENSE_REG
#define LTC4245_12VSENSE_REG
Definition: LTC4245.h:121
LTC4245_PGI_FAULT_AUTO_RETRY_DISABLE
#define LTC4245_PGI_FAULT_AUTO_RETRY_DISABLE
Definition: LTC4245.h:172
LTC4245_5VIN_REG
#define LTC4245_5VIN_REG
Definition: LTC4245.h:123
LTC4245_NEG12V_UNDERVOLTAGE_FAULT
#define LTC4245_NEG12V_UNDERVOLTAGE_FAULT
Definition: LTC4245.h:193
LT_I2C.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
LTC4245_UNDERVOLTAGE_ENABLE
#define LTC4245_UNDERVOLTAGE_ENABLE
Definition: LTC4245.h:155
LTC4245_BD_SEL_STATE_CHANGE_DISABLE
#define LTC4245_BD_SEL_STATE_CHANGE_DISABLE
Definition: LTC4245.h:144
main_menu_2_read_and_clear_faults
static int8_t main_menu_2_read_and_clear_faults()
Function to read and clear fault register.
Definition: DC985A.ino:339
LTC4245_5VSENSE_REG
#define LTC4245_5VSENSE_REG
Definition: LTC4245.h:124
demo_name
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
discover_DC985A
static uint8_t discover_DC985A(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
Definition: DC985A.ino:155
UserInterface.h
read_int
int32_t read_int()
Definition: UserInterface.cpp:93
LTC4245_VEESENSE_REG
#define LTC4245_VEESENSE_REG
Definition: LTC4245.h:130
LTC4245_FET_SHORT_FAULT
#define LTC4245_FET_SHORT_FAULT
Definition: LTC4245.h:200
print_prompt
static void print_prompt()
Print the main menu.
Definition: DC985A.ino:203
LTC4245_OVERCURRENT_AUTO_RETRY_DISABLE
#define LTC4245_OVERCURRENT_AUTO_RETRY_DISABLE
Definition: LTC4245.h:178
LTC4245_3_3VOUT_REG
#define LTC4245_3_3VOUT_REG
Definition: LTC4245.h:128
LTC4245_PGI_FAULT_DISABLE
#define LTC4245_PGI_FAULT_DISABLE
Definition: LTC4245.h:148
LTC4245_UNDERVOLTAGE_DISABLE
#define LTC4245_UNDERVOLTAGE_DISABLE
Definition: LTC4245.h:156
demo_board_type::product_name
char product_name[15]
LTC Product (LTC2654-L16)
Definition: QuikEval_EEPROM.h:70
LTC4245_PGI_ENABLE
#define LTC4245_PGI_ENABLE
Definition: LTC4245.h:175
LTC4245_POWER_BAD_DISABLE
#define LTC4245_POWER_BAD_DISABLE
Definition: LTC4245.h:152
LTC4245_5V_POWER_BAD_FAULT
#define LTC4245_5V_POWER_BAD_FAULT
Definition: LTC4245.h:204
LTC4245_GPIO1_STATE_CHANGE_ENABLE
#define LTC4245_GPIO1_STATE_CHANGE_ENABLE
Definition: LTC4245.h:141
LTC4245_12VIN_REG
#define LTC4245_12VIN_REG
Definition: LTC4245.h:120
LTC4245_read
int8_t LTC4245_read(uint8_t i2c_address, uint8_t command, uint8_t *code)
Reads an 8-bit adc_code from LTC4245.
Definition: LTC4245.cpp:98
quikeval_I2C_init
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
loop
static void loop()
Repeats Linduino loop.
Definition: DC985A.ino:109
quikeval_I2C_connect
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
Definition: LT_I2C.cpp:401
LTC4245_3_3V_OVERCURRENT_FAULT
#define LTC4245_3_3V_OVERCURRENT_FAULT
Definition: LTC4245.h:190
LTC4245_write
int8_t LTC4245_write(uint8_t i2c_address, uint8_t command, uint8_t code)
Write an 8-bit code to the LTC4245.
Definition: LTC4245.cpp:90
LTC4245_12V_OVERCURRENT_FAULT
#define LTC4245_12V_OVERCURRENT_FAULT
Definition: LTC4245.h:192
LTC4245_PGI_FAULT_ENABLE
#define LTC4245_PGI_FAULT_ENABLE
Definition: LTC4245.h:147
LTC4245_FAULT2_REG
#define LTC4245_FAULT2_REG
Definition: LTC4245.h:112
LTC4245_3_3VSENSE_REG
#define LTC4245_3_3VSENSE_REG
Definition: LTC4245.h:127
LTC4245_NEG12V_OVERCURRENT_FAULT
#define LTC4245_NEG12V_OVERCURRENT_FAULT
Definition: LTC4245.h:189
LTC4245_VEEIN_REG
#define LTC4245_VEEIN_REG
Definition: LTC4245.h:129
read_quikeval_id_string
uint8_t read_quikeval_id_string(char *buffer)
Read the id string from the EEPROM, then parse the product name, demo board name, and demo board opti...
Definition: QuikEval_EEPROM.cpp:77
ui_buffer
char ui_buffer[UI_BUFFER_SIZE]
Definition: UserInterface.cpp:46
LTC4245_PGI_DISABLE
#define LTC4245_PGI_DISABLE
Definition: LTC4245.h:174