102 Serial.begin(115200);
115 if (Serial.available())
118 if (user_command !=
'm')
119 Serial.println(user_command);
123 switch (user_command)
144 Serial.println(
"Incorrect Option");
157 Serial.print(F(
"\nChecking EEPROM contents..."));
164 Serial.print(
"Demo Board Name: ");
166 Serial.print(
"Product Name: ");
170 Serial.print(
"Demo Board Option: ");
173 Serial.println(F(
"Demo board connected"));
174 Serial.println(F(
"\n\n\t\t\t\tPress Enter to Continue..."));
180 Serial.print(
"Demo board ");
181 Serial.print(demo_name);
182 Serial.print(
" not found, \nfound ");
184 Serial.println(
" instead. \nConnect the correct demo board, then press the reset button.");
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"));
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: "));
221 float sense_voltage, vin_voltage, vout_voltage;
222 uint8_t sense_code, vin_code, vout_code;
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;
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);
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;
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;
244 Serial.println(F(
"1. Read in continous mode"));
245 Serial.print(F(
"2. Read in snapshot mode"));
252 Serial.print(F(
"********** Press Enter to Exit ***********\n\n"));
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);
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);
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);
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);
329 while (Serial.available()==
false && ack== 0);
330 if (Serial.available())
348 Serial.println(F(
"Faults Detected :"));
350 Serial.println(F(
" Overcurrent Fault Occurred on –12V Supply"));
352 Serial.println(F(
" Overcurrent Fault Occurred on 3.3V Supply"));
354 Serial.println(F(
" Overcurrent Fault Occurred on 5V Supply"));
356 Serial.println(F(
" Overcurrent Fault Occurred on 12V Supply"));
358 Serial.println(F(
" Undervoltage Fault Occurred on –12V Supply"));
360 Serial.println(F(
" Undervoltage Fault Occurred on 3.3V Supply"));
362 Serial.println(F(
" Undervoltage Fault Occurred on 5V Supply"));
364 Serial.println(F(
" Undervoltage Fault Occurred on 12V Supply"));
371 Serial.println(F(
" GPIO1 Pin Changed State"));
373 Serial.println(F(
" BD_SEL# Pin Changed State"));
375 Serial.println(F(
" FET Short Detected on at Least One Supply"));
377 Serial.println(F(
" PGI Fault Occurred"));
379 Serial.println(F(
" –12V Power Bad When VEEOUT Went High"));
381 Serial.println(F(
" 3.3V Power Bad When 3VOUT Went Low"));
383 Serial.println(F(
" 5V Power Bad When 5VOUT Went Low"));
385 Serial.println(F(
" 12V Power Bad When 12VOUT Went Low"));
389 Serial.print(F(
"\nALL FAULTS CLEARED \n\n"));
401 Serial.print(F(
" ALERT RESPONSE ADDRESS : 0x"));
402 Serial.println(address,HEX);
403 if (address == 0xFF && ack == 1)
406 Serial.print(F(
" NO RESPONSE\n\n"));
416 uint8_t alert_settings = 0;
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: "));
425 if (user_command ==
'm')
428 Serial.println(user_command);
430 if (user_command == 1)
432 else if (user_command ==2)
434 else if (user_command !=
'm')
435 Serial.println(
"Incorrect Option\n");
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: "));
444 if (user_command ==
'm')
447 Serial.println(user_command);
449 if (user_command == 1)
451 else if (user_command ==2)
453 else if (user_command !=
'm')
454 Serial.println(
"Incorrect Option\n");
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: "));
463 if (user_command ==
'm')
466 Serial.println(user_command);
468 if (user_command == 1)
470 else if (user_command ==2)
472 else if (user_command !=
'm')
473 Serial.println(
"Incorrect Option\n");
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: "));
482 if (user_command ==
'm')
485 Serial.println(user_command);
487 if (user_command == 1)
489 else if (user_command ==2)
491 else if (user_command !=
'm')
492 Serial.println(
"Incorrect Option\n");
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: "));
501 if (user_command ==
'm')
504 Serial.println(user_command);
506 if (user_command == 1)
508 else if (user_command ==2)
510 else if (user_command !=
'm')
511 Serial.println(
"Incorrect Option\n");
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: "));
520 if (user_command ==
'm')
523 Serial.println(user_command);
525 if (user_command == 1)
527 else if (user_command ==2)
529 else if (user_command !=
'm')
530 Serial.println(
"Incorrect Option\n");
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: "));
539 if (user_command ==
'm')
542 Serial.println(user_command);
544 if (user_command == 1)
546 else if (user_command ==2)
548 else if (user_command !=
'm')
549 Serial.println(
"Incorrect Option\n");
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: "));
558 if (user_command ==
'm')
561 Serial.println(user_command);
563 if (user_command == 1)
565 else if (user_command ==2)
567 else if (user_command !=
'm')
568 Serial.println(
"Incorrect Option\n");
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: "));
578 if (user_command ==
'm')
581 Serial.println(user_command);
584 while (!((user_command ==
'm') || (ack)));
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: "));
602 if (user_command ==
'm')
605 Serial.println(user_command);
607 if (user_command == 1)
609 else if (user_command ==2)
611 else if (user_command !=
'm')
612 Serial.println(
"Incorrect Option\n");
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: "));
621 if (user_command ==
'm')
624 Serial.println(user_command);
626 if (user_command == 1)
628 else if (user_command ==2)
630 else if (user_command !=
'm')
631 Serial.println(
"Incorrect Option\n");
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: "));
640 if (user_command ==
'm')
643 Serial.println(user_command);
645 if (user_command == 1)
647 else if (user_command ==2)
649 else if (user_command !=
'm')
650 Serial.println(
"Incorrect Option\n");
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: "));
659 if (user_command ==
'm')
662 Serial.println(user_command);
664 if (user_command == 1)
666 else if (user_command ==2)
668 else if (user_command !=
'm')
669 Serial.println(
"Incorrect Option\n");
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: "));
678 if (user_command ==
'm')
681 Serial.println(user_command);
683 if (user_command == 1)
685 else if (user_command ==2)
687 else if (user_command !=
'm')
688 Serial.println(
"Incorrect Option\n");
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: "));
697 if (user_command ==
'm')
700 Serial.println(user_command);
702 if (user_command == 1)
704 else if (user_command ==2)
706 else if (user_command !=
'm')
707 Serial.println(
"Incorrect Option\n");
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: "));
716 if (user_command ==
'm')
719 Serial.println(user_command);
721 if (user_command == 1)
723 else if (user_command ==2)
725 else if (user_command !=
'm')
726 Serial.println(
"Incorrect Option\n");
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: "));
736 if (user_command ==
'm')
739 Serial.println(user_command);
742 while (!((user_command ==
'm') || (ack)));
751 uint8_t register_val;
753 Serial.print(
" STATUS REGISTER : 0b");
754 Serial.println(register_val, BIN);
756 Serial.print(
" ALERT REGISTER : 0b");
757 Serial.println(register_val, BIN);
759 Serial.print(
" CONTROL REGISTER : 0b");
760 Serial.println(register_val, BIN);
762 Serial.print(
" ON REGISTER : 0b");
763 Serial.println(register_val, BIN);
struct demo_board_type demo_board
Instantiate demo board structure.
#define LTC4245_12V_UNDERVOLTAGE_FAULT
char option
Demo Circuit option (A)
#define LTC4245_OVERCURRENT_ENABLE
static void setup()
Initialize Linduino.
unsigned char user_command
#define LTC4245_OVERCURRENT_AUTO_RETRY_ENABLE
#define LTC4245_I2C_ALERT_RESPONSE
#define LTC4245_CONTROL_REG
#define LTC4245_3_3VIN_REG
#define LTC4245_NEG12V_POWER_BAD_FAULT
#define LTC4245_ALERT_PRESENT_DISABLE
static int8_t main_menu_4_manage_alerts()
Function to update alert register bits.
float LTC4245_code_to_voltage(uint8_t register_code, float full_scale_voltage)
Calculates voltage from register code data.
#define LTC4245_ALERT_PRESENT_ENABLE
#define LTC4245_ADC_FREE_RUN_DISABLE
#define LTC4245_PGI_FAULT_AUTO_RETRY_ENABLE
char name[15]
Demo Circuit number (DC1678)
#define LTC4245_OVERCURRENT_DISABLE
#define LTC4245_MASS_WRITE_ENABLE
#define LTC4245_FET_SHORT_DISABLE
#define LTC4245_UNDERVOLTAGE_AUTO_RETRY_ENABLE
static int8_t main_menu_1_continuous_mode()
Function to read Rsense current, ADIN voltage and ADIN2 voltage in continous mode.
#define LTC4245_MASS_WRITE_DISABLE
#define LTC4245_VEEOUT_REG
Header File for Linduino Libraries and Demo Code.
#define LTC4245_GPIO1_STATE_CHANGE_DISABLE
#define LTC4245_12V_POWER_BAD_FAULT
#define LTC4245_STATUS_REG
#define LTC4245_12VOUT_REG
#define LTC4245_UNDERVOLTAGE_AUTO_RETRY_DISABLE
#define LTC4245_PGI_FAULT
#define LTC4245_BD_SEL_STATE_CHANGE
#define LTC4245_POWER_BAD_ENABLE
#define LTC4245_SEQUENCING_DISABLE
#define LTC4245_FAULT1_REG
#define LTC4245_5V_UNDERVOLTAGE_FAULT
#define LTC4245_ALERT_REG
#define LTC4245_FET_SHORT_ENABLE
static int8_t main_menu_6_read_all_registers()
Function to read all registers.
static void print_title()
Print the title block.
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...
#define LTC4245_SEQUENCING_ENABLE
#define LTC4245_3_3V_UNDERVOLTAGE_FAULT
#define LTC4245_5V_OVERCURRENT_FAULT
static void settings()
Configures the output.
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...
#define LTC4245_GPIO1_STATE_CHANGE
LTC4245: Hot Swap Controller with I2C Compatible Monitoring.
#define LTC4245_I2C_ADDRESS
static int8_t main_menu_5_settings()
Function to update control register bits.
#define LTC4245_3_3V_POWER_BAD_FAULT
#define LTC4245_5VOUT_REG
#define LTC4245_BD_SEL_STATE_CHANGE_ENABLE
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
#define LTC4245_ADC_FREE_RUN_ENABLE
#define LTC4245_12VSENSE_REG
#define LTC4245_PGI_FAULT_AUTO_RETRY_DISABLE
#define LTC4245_NEG12V_UNDERVOLTAGE_FAULT
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
#define LTC4245_UNDERVOLTAGE_ENABLE
#define LTC4245_BD_SEL_STATE_CHANGE_DISABLE
static int8_t main_menu_2_read_and_clear_faults()
Function to read and clear fault register.
#define LTC4245_5VSENSE_REG
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
static uint8_t discover_DC985A(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
#define LTC4245_VEESENSE_REG
#define LTC4245_FET_SHORT_FAULT
static void print_prompt()
Print the main menu.
#define LTC4245_OVERCURRENT_AUTO_RETRY_DISABLE
#define LTC4245_3_3VOUT_REG
#define LTC4245_PGI_FAULT_DISABLE
#define LTC4245_UNDERVOLTAGE_DISABLE
char product_name[15]
LTC Product (LTC2654-L16)
#define LTC4245_PGI_ENABLE
#define LTC4245_POWER_BAD_DISABLE
#define LTC4245_5V_POWER_BAD_FAULT
#define LTC4245_GPIO1_STATE_CHANGE_ENABLE
#define LTC4245_12VIN_REG
int8_t LTC4245_read(uint8_t i2c_address, uint8_t command, uint8_t *code)
Reads an 8-bit adc_code from LTC4245.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
static void loop()
Repeats Linduino loop.
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
#define LTC4245_3_3V_OVERCURRENT_FAULT
int8_t LTC4245_write(uint8_t i2c_address, uint8_t command, uint8_t code)
Write an 8-bit code to the LTC4245.
#define LTC4245_12V_OVERCURRENT_FAULT
#define LTC4245_PGI_FAULT_ENABLE
#define LTC4245_FAULT2_REG
#define LTC4245_3_3VSENSE_REG
#define LTC4245_NEG12V_OVERCURRENT_FAULT
#define LTC4245_VEEIN_REG
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...
char ui_buffer[UI_BUFFER_SIZE]
#define LTC4245_PGI_DISABLE