| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

DC786A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC786A Demonstration Board.
3 LTC4260: 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 48 V. Ensure all jumpers on the
11 demo board are installed in their default positions from the factory. Refer to
12 Demo Manual DC786A.
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 LTC4260.
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/LTC4260
32
33 http://www.linear.com/product/LTC4260#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 LTC4260
72 */
73
74 // Headerfiles
75 #include <Arduino.h>
76 #include <stdint.h>
77 #include "LT_I2C.h"
78 #include "LT_SPI.h"
79 #include "UserInterface.h"
80 #include "QuikEval_EEPROM.h"
81 #include <Wire.h>
82 #include <SPI.h>
83 #include "LTC4260.h"
84
85 // Macros
86 #define SENSE_RESISTOR 0.008
87
88 // Function Declarations
89 void print_title();
90 void print_prompt();
91 int8_t main_menu_1_continuous_mode();
92 int8_t main_menu_2_read_and_clear_faults();
93 int8_t main_menu_3_send_ARA();
94 int8_t main_menu_4_manage_alerts();
95 int8_t main_menu_5_settings();
96 int8_t main_menu_6_read_all_registers();
97
98 //! Initialize Linduino
99 void setup()
100 {
101 char demo_name[] = "DC786"; // Demo Board Name stored in QuikEval EEPROM
102 quikeval_I2C_init(); // Enable the I2C port
103 quikeval_I2C_connect();
104 Serial.begin(115200); // Initialize the serial port to the PC
105 print_title();
106 discover_DC786A(demo_name);
107 print_prompt();
108 }
109
110 //! Repeats Linduino loop
111 void loop()
112 {
113 if (1)
114 {
115 int8_t ack = 0; // I2C acknowledge indicator
116 static uint8_t user_command; // The user input command
117 if (Serial.available()) //! Do nothing if serial is not available
118 {
119 user_command = read_int(); //! Read user input command
120 if (user_command != 'm')
121 Serial.println(user_command);
122 Serial.println();
123 ack = 0;
124 switch (user_command) //! Prints the appropriate submenu
125 {
126 case 1:
127 ack |= main_menu_1_continuous_mode(); // continous mode
128 break;
129 case 2:
130 ack |= main_menu_2_read_and_clear_faults(); // read and clear faults
131 break;
132 case 3:
133 ack |= main_menu_3_send_ARA();// read address of alert
134 break;
135 case 4:
136 ack |= main_menu_4_manage_alerts(); // manage alerts
137 break;
138 case 5:
139 ack |= main_menu_5_settings(); // settings
140 break;
141 case 6:
142 ack |= main_menu_6_read_all_registers();
143 break;
144 default:
145 Serial.println("Incorrect Option");
146 break;
147 }
148
149 print_prompt();
150 }
151 }
152 }
153
154 //! Read the ID string from the EEPROM and determine if the correct board is connected.
155 //! Returns 1 if successful, 0 if not successful
156 uint8_t discover_DC786A(char *demo_name)
157 {
158 Serial.print(F("\nChecking EEPROM contents..."));
159 read_quikeval_id_string(&ui_buffer[0]);
160 ui_buffer[48] = 0;
161 Serial.println(ui_buffer);
162
163 if (!strcmp(demo_board.name, demo_name))
164 {
165 Serial.print("Demo Board Name: ");
166 Serial.println(demo_board.name);
167 Serial.print("Product Name: ");
168 Serial.println(demo_board.product_name);
169 if (demo_board.option)
170 {
171 Serial.print("Demo Board Option: ");
172 Serial.println(demo_board.option);
173 }
174 Serial.println(F("Demo board connected"));
175 Serial.println(F("\n\n\t\t\t\tPress Enter to Continue..."));
176 read_int();
177 return 1;
178 }
179 else
180 {
181 Serial.print("Demo board ");
182 Serial.print(demo_name);
183 Serial.print(" not found, \nfound ");
184 Serial.print(demo_board.name);
185 Serial.println(" instead. \nConnect the correct demo board, then press the reset button.");
186 return 0;
187 }
188 }
189
190 //! Print the title block
191 void print_title()
192 {
193 Serial.println(F("\n*****************************************************************"));
194 Serial.print(F("* DC786A Demonstration Program *\n"));
195 Serial.print(F("* *\n"));
196 Serial.print(F("* This program demonstrates how to send and receive data from *\n"));
197 Serial.print(F("* LTC4260 Hot Swap Controller with I2C Compatible Monitoring *\n"));
198 Serial.print(F("* Set the baud rate to 115200 and select the newline terminator.*\n"));
199 Serial.print(F("* *\n"));
200 Serial.print(F("*****************************************************************\n"));
201 }
202
203 //! Print the main menu
204 void print_prompt()
205 {
206 Serial.print(F("\n\nMain Menu\n"));
207 Serial.print(F(" 1. Read current and voltage on continous mode\n"));
208 Serial.print(F(" 2. Read and clear faults\n"));
209 Serial.print(F(" 3. Request for alert response address (ARA)\n"));
210 Serial.print(F(" 4. Manage alerts\n"));
211 Serial.print(F(" 5. Settings\n"));
212 Serial.print(F(" 6. Read all registers\n\n"));
213 Serial.print(F("Enter a command: "));
214 }
215
216 //! Function to read Rsense current, ADIN voltage and ADIN2 voltage in continous mode
217 int8_t main_menu_1_continuous_mode()
218 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
219 {
220 int8_t ack = 0;
221 float sense_voltage, source_voltage, adin_voltage;
222 uint8_t sense_code, source_code, adin_code;
223 float adin_lsb = (2.56/255), adin_resisive_ratio = ((392 + 10)/10);
224 float source_lsb = (102.4/255), source_resisive_ratio = 1; // Set voltage divider ratio to 1, for no resistor divider circuit.
225 float sense_lsb = (0.0768/255), sense_resisive_ratio = 1;
226
227 do
228 {
229 uint8_t faults;
230 Serial.print(F("********** Press Enter to Exit ***********\n\n"));
231 ack |= LTC4260_read(LTC4260_I2C_ADDRESS, LTC4260_FAULT_REG, &faults);
232 if (faults != 0)
233 {
234 Serial.println(F("Faults Detected :"));
235 if (faults & LTC4260_FET_SHORT_FAULT )
236 Serial.println(F(" FET SHORT DETECTED"));
237 if (faults & LTC4260_EN_STATE_CHANGE)
238 Serial.println(F(" !EN STATE CHANGE DETECTED"));
239 if (faults & LTC4260_POWER_BAD_FAULT )
240 Serial.println(F(" BAD POWER DETECTED"));
241 if (faults & LTC4260_OVERCURRENT_FAULT )
242 Serial.println(F(" OVERCURRENT DETECTED"));
243 if (faults & LTC4260_UNDERVOLTAGE_FAULT )
244 Serial.println(F(" UNDERVOLTAGE DETECTED"));
245 if (faults & LTC4260_OVERVOLTAGE_FAULT )
246 Serial.println(F(" OVERVOLTAGE DETECTED"));
247 }
248 else
249 Serial.println(F(" NO FAULTS DETECTED"));
250
251 ack |= LTC4260_read(LTC4260_I2C_ADDRESS, LTC4260_SENSE_REG, &sense_code);
252 ack |= LTC4260_read(LTC4260_I2C_ADDRESS, LTC4260_SOURCE_REG, &source_code);
253 ack |= LTC4260_read(LTC4260_I2C_ADDRESS, LTC4260_ADIN_REG, &adin_code);
254
255 sense_voltage = LTC4260_code_to_voltage(sense_code, sense_lsb, sense_resisive_ratio);
256 source_voltage = LTC4260_code_to_voltage(source_code, source_lsb, source_resisive_ratio);
257 adin_voltage = LTC4260_code_to_voltage(adin_code, adin_lsb, adin_resisive_ratio);
258
259 Serial.print(F("\nSENSE VOLTAGE CODE: "));
260 Serial.println(sense_code, HEX);
261 Serial.print(F("SENSE CURRENT CALCULATED: "));
262 Serial.println((sense_voltage / SENSE_RESISTOR), 4);
263 Serial.print(F("\nSOURCE VOLTAGE CODE: "));
264 Serial.println(source_code, HEX);
265 Serial.print(F("SOURCE VOLTAGE CALCULATED: "));
266 Serial.println(source_voltage, 4);
267 Serial.print(F("\nADIN CODE: "));
268 Serial.println(adin_code, HEX);
269 Serial.print(F("VOLTAGE CALCULATED AT ADIN: "));
270 Serial.println(adin_voltage, 4);
271 Serial.print("\n");
272 delay(2000);
273 }
274 while (Serial.available()==false && ack== 0);
275 if (Serial.available())
276 read_int(); // clears the Serial.available()
277 return (ack);
278 }
279
280 //! Function to read and clear fault register
281 int8_t main_menu_2_read_and_clear_faults()
282 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
283 {
284 int8_t ack = 0;
285
286 uint8_t faults;
287 ack |= LTC4260_read(LTC4260_I2C_ADDRESS, LTC4260_FAULT_REG, &faults);
288 if (faults != 0)
289 {
290 Serial.println(F("Faults Detected :"));
291 if (faults & LTC4260_FET_SHORT_FAULT)
292 Serial.println(F(" FET SHORT DETECTED"));
293 if (faults & LTC4260_EN_STATE_CHANGE)
294 Serial.println(F(" !EN STATE CHANGE DETECTED"));
295 if (faults & LTC4260_POWER_BAD_FAULT)
296 Serial.println(F(" BAD POWER DETECTED"));
297 if (faults & LTC4260_OVERCURRENT_FAULT)
298 Serial.println(F(" OVERCURRENT DETECTED"));
299 if (faults & LTC4260_UNDERVOLTAGE_FAULT)
300 Serial.println(F(" UNDERVOLTAGE DETECTED"));
301 if (faults & LTC4260_OVERVOLTAGE_FAULT)
302 Serial.println(F(" OVERVOLTAGE DETECTED"));
303 }
304 ack |= LTC4260_write(LTC4260_I2C_ADDRESS, LTC4260_FAULT_REG, 0x00);
305 Serial.print(F("\nALL FAULTS CLEARED \n\n"));
306
307 return (ack);
308 }
309
310 //! Function to send alert response (0001100) and read back the address of device that pulled ALERT pin low.
311 int8_t main_menu_3_send_ARA()
312 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
313 {
314 int8_t ack = 0;
315 uint8_t address;
316 ack |= LTC4260_ARA(LTC4260_I2C_ALERT_RESPONSE, &address);// send ARA
317 Serial.print(F(" ALERT RESPONSE ADDRESS : 0x"));
318 Serial.println(address,HEX);
319 if (address == 0xFF && ack == 1)
320 {
321 ack = 0;
322 Serial.print(F(" NO RESPONSE\n\n"));
323 }
324 return(ack);
325 }
326
327 //! Function to update alert register bits
328 int8_t main_menu_4_manage_alerts()
329 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
330 {
331 int8_t ack = 0;
332 uint8_t alert_settings = 0;
333 int8_t user_command;
334 do
335 {
336 Serial.println(F("GPIO OUTPUT"));
337 Serial.println(F(" 1. Enable"));
338 Serial.println(F(" 2. Disable"));
339 Serial.print(F("Enter a command: "));
340 user_command = read_int();
341 if (user_command == 'm')
342 Serial.println("m");
343 else
344 Serial.println(user_command);
345 Serial.println();
346 if (user_command == 1)
347 alert_settings |= LTC4260_GPIO_OUTPUT_ENABLE;
348 else if (user_command ==2)
349 alert_settings &= LTC4260_GPIO_OUTPUT_DISABLE;
350 else if (user_command != 'm')
351 Serial.println("Incorrect Option\n");
352 else
353 return(ack);
354
355 Serial.println(F("FET SHORT ALERT"));
356 Serial.println(F(" 1. Enable"));
357 Serial.println(F(" 2. Disable"));
358 Serial.print(F("Enter a command: "));
359 user_command = read_int();
360 if (user_command == 'm')
361 Serial.println("m");
362 else
363 Serial.println(user_command);
364 Serial.println();
365 if (user_command == 1)
366 alert_settings |= LTC4260_FET_SHORT_ENABLE;
367 else if (user_command ==2)
368 alert_settings &= LTC4260_FET_SHORT_DISABLE;
369 else if (user_command != 'm')
370 Serial.println("Incorrect Option\n");
371 else
372 return(ack);
373
374 Serial.println(F("!EN STATE CHANGE ALERT"));
375 Serial.println(F(" 1. Enable"));
376 Serial.println(F(" 2. Disable"));
377 Serial.print(F("Enter a command: "));
378 user_command = read_int();
379 if (user_command == 'm')
380 Serial.println("m");
381 else
382 Serial.println(user_command);
383 Serial.println();
384 if (user_command == 1)
385 alert_settings |= LTC4260_EN_STATE_ENABLE;
386 else if (user_command ==2)
387 alert_settings &= LTC4260_EN_STATE_DISABLE;
388 else if (user_command != 'm')
389 Serial.println("Incorrect Option\n");
390 else
391 return(ack);
392
393 Serial.println(F("POWER BAD ALERT"));
394 Serial.println(F(" 1. Enable"));
395 Serial.println(F(" 2. Disable"));
396 Serial.print(F("Enter a command: "));
397 user_command = read_int();
398 if (user_command == 'm')
399 Serial.println("m");
400 else
401 Serial.println(user_command);
402 Serial.println();
403 if (user_command == 1)
404 alert_settings |= LTC4260_POWER_BAD_ENABLE;
405 else if (user_command ==2)
406 alert_settings &= LTC4260_POWER_BAD_DISABLE;
407 else if (user_command != 'm')
408 Serial.println("Incorrect Option\n");
409 else
410 return(ack);
411
412 Serial.println(F("OVERCURRENT ALERT"));
413 Serial.println(F(" 1. Enable"));
414 Serial.println(F(" 2. Disable"));
415 Serial.print(F("Enter a command: "));
416 user_command = read_int();
417 if (user_command == 'm')
418 Serial.println("m");
419 else
420 Serial.println(user_command);
421 Serial.println();
422 if (user_command == 1)
423 alert_settings |= LTC4260_OVERCURRENT_ENABLE;
424 else if (user_command ==2)
425 alert_settings &= LTC4260_OVERCURRENT_DISABLE;
426 else if (user_command != 'm')
427 Serial.println("Incorrect Option\n");
428 else
429 return(ack);
430
431 Serial.println(F("UNDERVOLTAGE ALERT"));
432 Serial.println(F(" 1. Enable"));
433 Serial.println(F(" 2. Disable"));
434 Serial.print(F("Enter a command: "));
435 user_command = read_int();
436 if (user_command == 'm')
437 Serial.println("m");
438 else
439 Serial.println(user_command);
440 Serial.println();
441 if (user_command == 1)
442 alert_settings |= LTC4260_UNDERVOLTAGE_ENABLE;
443 else if (user_command ==2)
444 alert_settings &= LTC4260_UNDERVOLTAGE_DISABLE;
445 else if (user_command != 'm')
446 Serial.println("Incorrect Option\n");
447 else
448 return(ack);
449
450 Serial.println(F("OVERVOLTAGE ALERT"));
451 Serial.println(F(" 1. Enable"));
452 Serial.println(F(" 2. Disable"));
453 Serial.print(F("Enter a command: "));
454 user_command = read_int();
455 if (user_command == 'm')
456 Serial.println("m");
457 else
458 Serial.println(user_command);
459 Serial.println();
460 if (user_command == 1)
461 alert_settings |= LTC4260_OVERVOLTAGE_ENABLE;
462 else if (user_command ==2)
463 alert_settings &= LTC4260_OVERVOLTAGE_DISABLE;
464 else if (user_command != 'm')
465 Serial.println("Incorrect Option\n");
466 else
467 return(ack);
468 ack |= LTC4260_write(LTC4260_I2C_ADDRESS, LTC4260_ALERT_REG, alert_settings);
469 Serial.print(F("\n ALERTS UPDATED\n\n"));
470 Serial.println(F(" m. Main Menu"));
471 Serial.println(F(" 1. Repeat"));
472 Serial.print(F("Enter a command: "));
473 user_command = read_int();
474 if (user_command == 'm')
475 Serial.println("m");
476 else
477 Serial.println(user_command);
478 Serial.println();
479 }
480 while (!((user_command == 'm') || (ack)));
481 return(ack);
482 }
483
484 //! Function to update control register bits
485 int8_t main_menu_5_settings()
486 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
487 {
488 int8_t ack = 0;
489 uint8_t settings =0;
490 int8_t user_command;
491 do
492 {
493 Serial.println(F("PGIO"));
494 Serial.println(F(" 1. !POWER GOOD"));
495 Serial.println(F(" 2. POWER GOOD"));
496 Serial.println(F(" 3. General Purpose Output"));
497 Serial.println(F(" 4. General Purpose Input"));
498 Serial.print(F("Enter a command: "));
499 user_command = read_int();
500 if (user_command == 'm')
501 {
502 Serial.println("m");
503 return(ack);
504 }
505 else
506 Serial.println(user_command);
507 Serial.println();
508 switch (user_command)
509 {
510 case 1:
511 settings |= LTC4260_PGIO_POWER_GOODX;
512 break;
513 case 2:
514 settings |= LTC4260_PGIO_POWER_GOOD;
515 break;
516 case 3:
517 settings |= LTC4260_PGIO_GENERAL_PURPOSE_OUTPUT;
518 break;
519 case 4:
520 settings |= LTC4260_PGIO_GENERAL_PURPOSE_INPUT;
521 break;
522 default:
523 if (user_command != 'm')
524 Serial.println("Incorrect Option\n");
525 break;
526 }
527
528 Serial.println(F("TEST MODE ENABLE"));
529 Serial.println(F(" 1. Enable"));
530 Serial.println(F(" 2. Disable"));
531 Serial.print(F("Enter a command: "));
532 user_command = read_int();
533 if (user_command == 'm')
534 Serial.println("m");
535 else
536 Serial.println(user_command);
537 Serial.println();
538 if (user_command == 1)
539 settings |= LTC4260_TEST_MODE_ENABLE;
540 else if (user_command ==2)
541 settings &= LTC4260_TEST_MODE_DISABLE;
542 else if (user_command != 'm')
543 Serial.println("Incorrect Option\n");
544 else
545 return(ack);
546
547 Serial.println(F("MASS WRITE ENABLE"));
548 Serial.println(F(" 1. Enable"));
549 Serial.println(F(" 2. Disable"));
550 Serial.print(F("Enter a command: "));
551 user_command = read_int();
552 if (user_command == 'm')
553 Serial.println("m");
554 else
555 Serial.println(user_command);
556 Serial.println();
557 if (user_command == 1)
558 settings |= LTC4260_MASS_WRITE_ENABLE;
559 else if (user_command ==2)
560 settings &= LTC4260_MASS_WRITE_DISABLE;
561 else if (user_command != 'm')
562 Serial.println("Incorrect Option\n");
563 else
564 return(ack);
565
566 Serial.println(F("FET STATUS"));
567 Serial.println(F(" 1. ON"));
568 Serial.println(F(" 2. OFF"));
569 Serial.print(F("Enter a command: "));
570 user_command = read_int();
571 if (user_command == 'm')
572 Serial.println("m");
573 else
574 Serial.println(user_command);
575 Serial.println();
576 if (user_command == 1)
577 settings |= LTC4260_FET_ON;
578 else if (user_command ==2)
579 settings &= LTC4260_FET_OFF;
580 else if (user_command != 'm')
581 Serial.println("Incorrect Option\n");
582 else
583 return(ack);
584
585 Serial.println(F("OVERCURRENT AUTO RETRY"));
586 Serial.println(F(" 1. Enable"));
587 Serial.println(F(" 2. Disable"));
588 Serial.print(F("Enter a command: "));
589 user_command = read_int();
590 if (user_command == 'm')
591 Serial.println("m");
592 else
593 Serial.println(user_command);
594 Serial.println();
595 if (user_command == 1)
596 settings |= LTC4260_OVERCURRENT_AUTO_RETRY_ENABLE;
597 else if (user_command ==2)
598 settings &= LTC4260_OVERCURRENT_AUTO_RETRY_DISABLE;
599 else if (user_command != 'm')
600 Serial.println("Incorrect Option\n");
601 else
602 return(ack);
603
604 Serial.println(F("UNDERVOLTAGE AUTO RETRY"));
605 Serial.println(F(" 1. Enable"));
606 Serial.println(F(" 2. Disable"));
607 Serial.print(F("Enter a command: "));
608 user_command = read_int();
609 if (user_command == 'm')
610 Serial.println("m");
611 else
612 Serial.println(user_command);
613 Serial.println();
614 if (user_command == 1)
615 settings |= LTC4260_UNDERVOLTAGE_AUTO_RETRY_ENABLE;
616 else if (user_command ==2)
617 settings &= LTC4260_UNDERVOLTAGE_AUTO_RETRY_DISABLE;
618 else if (user_command != 'm')
619 Serial.println("Incorrect Option\n");
620 else
621 return(ack);
622
623 Serial.println(F("OVERVOLTAGE AUTO RETRY"));
624 Serial.println(F(" 1. Enable"));
625 Serial.println(F(" 2. Disable"));
626 Serial.print(F("Enter a command: "));
627 user_command = read_int();
628 if (user_command == 'm')
629 Serial.println("m");
630 else
631 Serial.println(user_command);
632 Serial.println();
633 if (user_command == 1)
634 settings |= LTC4260_OVERVOLTAGE_AUTO_RETRY_ENABLE;
635 else if (user_command ==2)
636 settings &= LTC4260_OVERVOLTAGE_AUTO_RETRY_DISABLE;
637 else if (user_command != 'm')
638 Serial.println("Incorrect Option\n");
639 else
640 return(ack);
641 ack |= LTC4260_write(LTC4260_I2C_ADDRESS, LTC4260_CONTROL_REG, settings);
642 Serial.print(F("\nSETTINGS UPDATED\n\n"));
643 Serial.println(F(" m. Main Menu"));
644 Serial.println(F(" 1. Repeat"));
645 Serial.print(F("Enter a command: "));
646 user_command = read_int();
647 if (user_command == 'm')
648 Serial.println("m");
649 else
650 Serial.println(user_command);
651 Serial.println();
652 }
653 while (!((user_command == 'm') || (ack)));
654 return(ack);
655 }
656
657 //! Function to read all registers.
658 int8_t main_menu_6_read_all_registers()
659 //! @return Returns the state of the acknowledge bit after the I2C address read. 0=acknowledge, 1=no acknowledge.
660 {
661 int8_t ack = 0;
662 uint8_t faults;
663 ack |= LTC4260_read(LTC4260_I2C_ADDRESS, LTC4260_FAULT_REG, &faults);
664 Serial.print(" FAULT REGISTER : 0b");
665 Serial.println(faults, BIN);
666 ack |= LTC4260_read(LTC4260_I2C_ADDRESS, LTC4260_STATUS_REG, &faults);
667 Serial.print(" STATUS REGISTER : 0b");
668 Serial.println(faults, BIN);
669 ack |= LTC4260_read(LTC4260_I2C_ADDRESS, LTC4260_ALERT_REG, &faults);
670 Serial.print(" ALERT REGISTER : 0b");
671 Serial.println(faults, BIN);
672 ack |= LTC4260_read(LTC4260_I2C_ADDRESS, LTC4260_CONTROL_REG, &faults);
673 Serial.print(" CONTROL REGISTER : 0b");
674 Serial.println(faults, BIN);
675 Serial.println();
676 return ack;
677 }
demo_board
struct demo_board_type demo_board
Instantiate demo board structure.
Definition: QuikEval_EEPROM.cpp:71
loop
static void loop()
Repeats Linduino loop.
Definition: DC786A.ino:111
demo_board_type::option
char option
Demo Circuit option (A)
Definition: QuikEval_EEPROM.h:72
LTC4260_ARA
int8_t LTC4260_ARA(uint8_t alert_response_address, uint8_t *i2c_address)
SMBus Alert ResponseProtocol: Sends an alert response command and releases /ALERT pin...
Definition: LTC4260.cpp:81
LTC4260_I2C_ADDRESS
#define LTC4260_I2C_ADDRESS
Definition: LTC4260.h:99
LTC4260_POWER_BAD_FAULT
#define LTC4260_POWER_BAD_FAULT
Definition: LTC4260.h:121
LTC4260_GPIO_OUTPUT_DISABLE
#define LTC4260_GPIO_OUTPUT_DISABLE
Definition: LTC4260.h:131
LTC4260_OVERCURRENT_AUTO_RETRY_DISABLE
#define LTC4260_OVERCURRENT_AUTO_RETRY_DISABLE
Definition: LTC4260.h:164
user_command
unsigned char user_command
Definition: Serial_EEPROM_Test.ino:75
setup
static void setup()
Initialize Linduino.
Definition: DC786A.ino:99
LTC4260_SENSE_REG
#define LTC4260_SENSE_REG
Definition: LTC4260.h:111
demo_board_type::name
char name[15]
Demo Circuit number (DC1678)
Definition: QuikEval_EEPROM.h:71
LTC4260_PGIO_POWER_GOODX
#define LTC4260_PGIO_POWER_GOODX
Definition: LTC4260.h:149
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: DC786A.ino:217
LTC4260_FET_SHORT_ENABLE
#define LTC4260_FET_SHORT_ENABLE
Definition: LTC4260.h:132
LTC4260_read
int8_t LTC4260_read(uint8_t i2c_address, uint8_t command, uint8_t *code)
Reads an 8-bit adc_code from LTC4260.
Definition: LTC4260.cpp:97
adin_lsb
const float adin_lsb
Definition: DC998A.ino:99
LTC4260_CONTROL_REG
#define LTC4260_CONTROL_REG
Definition: LTC4260.h:107
LTC4260_write
int8_t LTC4260_write(uint8_t i2c_address, uint8_t command, uint8_t code)
Write an 8-bit code to the LTC4260.
Definition: LTC4260.cpp:89
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: DC786A.ino:311
LTC4260_STATUS_REG
#define LTC4260_STATUS_REG
Definition: LTC4260.h:109
LTC4260_FET_SHORT_FAULT
#define LTC4260_FET_SHORT_FAULT
Definition: LTC4260.h:119
LTC4260_FET_OFF
#define LTC4260_FET_OFF
Definition: LTC4260.h:161
LTC4260_OVERVOLTAGE_ENABLE
#define LTC4260_OVERVOLTAGE_ENABLE
Definition: LTC4260.h:142
LTC4260_UNDERVOLTAGE_AUTO_RETRY_DISABLE
#define LTC4260_UNDERVOLTAGE_AUTO_RETRY_DISABLE
Definition: LTC4260.h:167
LTC4260_OVERVOLTAGE_AUTO_RETRY_ENABLE
#define LTC4260_OVERVOLTAGE_AUTO_RETRY_ENABLE
Definition: LTC4260.h:169
address
static uint8_t address
Definition: DC2091A.ino:83
main_menu_5_settings
static int8_t main_menu_5_settings()
Function to update control register bits.
Definition: DC786A.ino:485
LTC4260_TEST_MODE_DISABLE
#define LTC4260_TEST_MODE_DISABLE
Definition: LTC4260.h:155
LTC4260_FET_SHORT_DISABLE
#define LTC4260_FET_SHORT_DISABLE
Definition: LTC4260.h:133
LTC4260_UNDERVOLTAGE_AUTO_RETRY_ENABLE
#define LTC4260_UNDERVOLTAGE_AUTO_RETRY_ENABLE
Definition: LTC4260.h:166
main_menu_6_read_all_registers
static int8_t main_menu_6_read_all_registers()
Function to read all registers.
Definition: DC786A.ino:658
LTC4260_I2C_ALERT_RESPONSE
#define LTC4260_I2C_ALERT_RESPONSE
Definition: LTC4260.h:100
LTC4260_FET_ON
#define LTC4260_FET_ON
Definition: LTC4260.h:160
LTC4260_OVERVOLTAGE_DISABLE
#define LTC4260_OVERVOLTAGE_DISABLE
Definition: LTC4260.h:143
LTC4260_ADIN_REG
#define LTC4260_ADIN_REG
Definition: LTC4260.h:113
settings
static void settings()
Configures the output.
Definition: DC726B_A.ino:202
LTC4260_PGIO_POWER_GOOD
#define LTC4260_PGIO_POWER_GOOD
Definition: LTC4260.h:150
QuikEval_EEPROM.h
QuikEval EEPROM Library.
LTC4260_EN_STATE_DISABLE
#define LTC4260_EN_STATE_DISABLE
Definition: LTC4260.h:135
LTC4260_OVERCURRENT_FAULT
#define LTC4260_OVERCURRENT_FAULT
Definition: LTC4260.h:122
print_title
static void print_title()
Print the title block.
Definition: DC786A.ino:191
discover_DC786A
static uint8_t discover_DC786A(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
Definition: DC786A.ino:156
LTC4260_POWER_BAD_DISABLE
#define LTC4260_POWER_BAD_DISABLE
Definition: LTC4260.h:137
LTC4260_EN_STATE_ENABLE
#define LTC4260_EN_STATE_ENABLE
Definition: LTC4260.h:134
LTC4260_MASS_WRITE_DISABLE
#define LTC4260_MASS_WRITE_DISABLE
Definition: LTC4260.h:158
LT_SPI.h
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
LTC4260_POWER_BAD_ENABLE
#define LTC4260_POWER_BAD_ENABLE
Definition: LTC4260.h:136
LTC4260_UNDERVOLTAGE_DISABLE
#define LTC4260_UNDERVOLTAGE_DISABLE
Definition: LTC4260.h:141
LTC4260_code_to_voltage
float LTC4260_code_to_voltage(uint8_t register_code, float LSB, float resistor_divider_ratio)
Calculates voltage from register code data.
Definition: LTC4260.cpp:72
LTC4260.h
LTC4260: Hot Swap Controller with I2C Compatible Monitoring.
LT_I2C.h
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
LTC4260_OVERCURRENT_ENABLE
#define LTC4260_OVERCURRENT_ENABLE
Definition: LTC4260.h:138
LTC4260_OVERCURRENT_DISABLE
#define LTC4260_OVERCURRENT_DISABLE
Definition: LTC4260.h:139
demo_name
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
LTC4260_OVERCURRENT_AUTO_RETRY_ENABLE
#define LTC4260_OVERCURRENT_AUTO_RETRY_ENABLE
Definition: LTC4260.h:163
UserInterface.h
print_prompt
static void print_prompt()
Print the main menu.
Definition: DC786A.ino:204
read_int
int32_t read_int()
Definition: UserInterface.cpp:93
LTC4260_OVERVOLTAGE_FAULT
#define LTC4260_OVERVOLTAGE_FAULT
Definition: LTC4260.h:124
LTC4260_SOURCE_REG
#define LTC4260_SOURCE_REG
Definition: LTC4260.h:112
LTC4260_GPIO_OUTPUT_ENABLE
#define LTC4260_GPIO_OUTPUT_ENABLE
Definition: LTC4260.h:130
demo_board_type::product_name
char product_name[15]
LTC Product (LTC2654-L16)
Definition: QuikEval_EEPROM.h:70
LTC4260_FAULT_REG
#define LTC4260_FAULT_REG
Definition: LTC4260.h:110
LTC4260_EN_STATE_CHANGE
#define LTC4260_EN_STATE_CHANGE
Definition: LTC4260.h:120
LTC4260_PGIO_GENERAL_PURPOSE_OUTPUT
#define LTC4260_PGIO_GENERAL_PURPOSE_OUTPUT
Definition: LTC4260.h:151
quikeval_I2C_init
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
SENSE_RESISTOR
#define SENSE_RESISTOR
Definition: DC786A.ino:86
quikeval_I2C_connect
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
Definition: LT_I2C.cpp:401
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: DC786A.ino:281
LTC4260_TEST_MODE_ENABLE
#define LTC4260_TEST_MODE_ENABLE
Definition: LTC4260.h:154
LTC4260_PGIO_GENERAL_PURPOSE_INPUT
#define LTC4260_PGIO_GENERAL_PURPOSE_INPUT
Definition: LTC4260.h:152
LTC4260_MASS_WRITE_ENABLE
#define LTC4260_MASS_WRITE_ENABLE
Definition: LTC4260.h:157
LTC4260_UNDERVOLTAGE_FAULT
#define LTC4260_UNDERVOLTAGE_FAULT
Definition: LTC4260.h:123
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
main_menu_4_manage_alerts
static int8_t main_menu_4_manage_alerts()
Function to update alert register bits.
Definition: DC786A.ino:328
LTC4260_UNDERVOLTAGE_ENABLE
#define LTC4260_UNDERVOLTAGE_ENABLE
Definition: LTC4260.h:140
LTC4260_ALERT_REG
#define LTC4260_ALERT_REG
Definition: LTC4260.h:108
LTC4260_OVERVOLTAGE_AUTO_RETRY_DISABLE
#define LTC4260_OVERVOLTAGE_AUTO_RETRY_DISABLE
Definition: LTC4260.h:170