86 #define SENSE_RESISTOR 0.008 104 Serial.begin(115200);
117 if (Serial.available())
120 if (user_command !=
'm')
121 Serial.println(user_command);
124 switch (user_command)
145 Serial.println(
"Incorrect Option");
158 Serial.print(F(
"\nChecking EEPROM contents..."));
165 Serial.print(
"Demo Board Name: ");
167 Serial.print(
"Product Name: ");
171 Serial.print(
"Demo Board Option: ");
174 Serial.println(F(
"Demo board connected"));
175 Serial.println(F(
"\n\n\t\t\t\tPress Enter to Continue..."));
181 Serial.print(
"Demo board ");
182 Serial.print(demo_name);
183 Serial.print(
" not found, \nfound ");
185 Serial.println(
" instead. \nConnect the correct demo board, then press the reset button.");
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"));
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: "));
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;
225 float sense_lsb = (0.0768/255), sense_resisive_ratio = 1;
230 Serial.print(F(
"********** Press Enter to Exit ***********\n\n"));
234 Serial.println(F(
"Faults Detected :"));
236 Serial.println(F(
" FET SHORT DETECTED"));
238 Serial.println(F(
" !EN STATE CHANGE DETECTED"));
240 Serial.println(F(
" BAD POWER DETECTED"));
242 Serial.println(F(
" OVERCURRENT DETECTED"));
244 Serial.println(F(
" UNDERVOLTAGE DETECTED"));
246 Serial.println(F(
" OVERVOLTAGE DETECTED"));
249 Serial.println(F(
" NO FAULTS DETECTED"));
259 Serial.print(F(
"\nSENSE VOLTAGE CODE: "));
260 Serial.println(sense_code, HEX);
261 Serial.print(F(
"SENSE CURRENT CALCULATED: "));
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);
274 while (Serial.available()==
false && ack== 0);
275 if (Serial.available())
290 Serial.println(F(
"Faults Detected :"));
292 Serial.println(F(
" FET SHORT DETECTED"));
294 Serial.println(F(
" !EN STATE CHANGE DETECTED"));
296 Serial.println(F(
" BAD POWER DETECTED"));
298 Serial.println(F(
" OVERCURRENT DETECTED"));
300 Serial.println(F(
" UNDERVOLTAGE DETECTED"));
302 Serial.println(F(
" OVERVOLTAGE DETECTED"));
305 Serial.print(F(
"\nALL FAULTS CLEARED \n\n"));
317 Serial.print(F(
" ALERT RESPONSE ADDRESS : 0x"));
318 Serial.println(address,HEX);
319 if (address == 0xFF && ack == 1)
322 Serial.print(F(
" NO RESPONSE\n\n"));
332 uint8_t alert_settings = 0;
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: "));
341 if (user_command ==
'm')
344 Serial.println(user_command);
346 if (user_command == 1)
348 else if (user_command ==2)
350 else if (user_command !=
'm')
351 Serial.println(
"Incorrect Option\n");
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: "));
360 if (user_command ==
'm')
363 Serial.println(user_command);
365 if (user_command == 1)
367 else if (user_command ==2)
369 else if (user_command !=
'm')
370 Serial.println(
"Incorrect Option\n");
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: "));
379 if (user_command ==
'm')
382 Serial.println(user_command);
384 if (user_command == 1)
386 else if (user_command ==2)
388 else if (user_command !=
'm')
389 Serial.println(
"Incorrect Option\n");
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: "));
398 if (user_command ==
'm')
401 Serial.println(user_command);
403 if (user_command == 1)
405 else if (user_command ==2)
407 else if (user_command !=
'm')
408 Serial.println(
"Incorrect Option\n");
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: "));
417 if (user_command ==
'm')
420 Serial.println(user_command);
422 if (user_command == 1)
424 else if (user_command ==2)
426 else if (user_command !=
'm')
427 Serial.println(
"Incorrect Option\n");
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: "));
436 if (user_command ==
'm')
439 Serial.println(user_command);
441 if (user_command == 1)
443 else if (user_command ==2)
445 else if (user_command !=
'm')
446 Serial.println(
"Incorrect Option\n");
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: "));
455 if (user_command ==
'm')
458 Serial.println(user_command);
460 if (user_command == 1)
462 else if (user_command ==2)
464 else if (user_command !=
'm')
465 Serial.println(
"Incorrect Option\n");
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: "));
474 if (user_command ==
'm')
477 Serial.println(user_command);
480 while (!((user_command ==
'm') || (ack)));
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: "));
500 if (user_command ==
'm')
506 Serial.println(user_command);
508 switch (user_command)
523 if (user_command !=
'm')
524 Serial.println(
"Incorrect Option\n");
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: "));
533 if (user_command ==
'm')
536 Serial.println(user_command);
538 if (user_command == 1)
540 else if (user_command ==2)
542 else if (user_command !=
'm')
543 Serial.println(
"Incorrect Option\n");
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: "));
552 if (user_command ==
'm')
555 Serial.println(user_command);
557 if (user_command == 1)
559 else if (user_command ==2)
561 else if (user_command !=
'm')
562 Serial.println(
"Incorrect Option\n");
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: "));
571 if (user_command ==
'm')
574 Serial.println(user_command);
576 if (user_command == 1)
578 else if (user_command ==2)
580 else if (user_command !=
'm')
581 Serial.println(
"Incorrect Option\n");
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: "));
590 if (user_command ==
'm')
593 Serial.println(user_command);
595 if (user_command == 1)
597 else if (user_command ==2)
599 else if (user_command !=
'm')
600 Serial.println(
"Incorrect Option\n");
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: "));
609 if (user_command ==
'm')
612 Serial.println(user_command);
614 if (user_command == 1)
616 else if (user_command ==2)
618 else if (user_command !=
'm')
619 Serial.println(
"Incorrect Option\n");
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: "));
628 if (user_command ==
'm')
631 Serial.println(user_command);
633 if (user_command == 1)
635 else if (user_command ==2)
637 else if (user_command !=
'm')
638 Serial.println(
"Incorrect Option\n");
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: "));
647 if (user_command ==
'm')
650 Serial.println(user_command);
653 while (!((user_command ==
'm') || (ack)));
664 Serial.print(
" FAULT REGISTER : 0b");
665 Serial.println(faults, BIN);
667 Serial.print(
" STATUS REGISTER : 0b");
668 Serial.println(faults, BIN);
670 Serial.print(
" ALERT REGISTER : 0b");
671 Serial.println(faults, BIN);
673 Serial.print(
" CONTROL REGISTER : 0b");
674 Serial.println(faults, BIN);
struct demo_board_type demo_board
Instantiate demo board structure.
static void loop()
Repeats Linduino loop.
char option
Demo Circuit option (A)
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...
#define LTC4260_I2C_ADDRESS
#define LTC4260_POWER_BAD_FAULT
#define LTC4260_GPIO_OUTPUT_DISABLE
#define LTC4260_OVERCURRENT_AUTO_RETRY_DISABLE
unsigned char user_command
static void setup()
Initialize Linduino.
#define LTC4260_SENSE_REG
char name[15]
Demo Circuit number (DC1678)
#define LTC4260_PGIO_POWER_GOODX
static int8_t main_menu_1_continuous_mode()
Function to read Rsense current, ADIN voltage and ADIN2 voltage in continous mode.
#define LTC4260_FET_SHORT_ENABLE
int8_t LTC4260_read(uint8_t i2c_address, uint8_t command, uint8_t *code)
Reads an 8-bit adc_code from LTC4260.
#define LTC4260_CONTROL_REG
int8_t LTC4260_write(uint8_t i2c_address, uint8_t command, uint8_t code)
Write an 8-bit code to the LTC4260.
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 LTC4260_STATUS_REG
#define LTC4260_FET_SHORT_FAULT
#define LTC4260_OVERVOLTAGE_ENABLE
#define LTC4260_UNDERVOLTAGE_AUTO_RETRY_DISABLE
#define LTC4260_OVERVOLTAGE_AUTO_RETRY_ENABLE
static int8_t main_menu_5_settings()
Function to update control register bits.
#define LTC4260_TEST_MODE_DISABLE
#define LTC4260_FET_SHORT_DISABLE
#define LTC4260_UNDERVOLTAGE_AUTO_RETRY_ENABLE
static int8_t main_menu_6_read_all_registers()
Function to read all registers.
#define LTC4260_I2C_ALERT_RESPONSE
#define LTC4260_OVERVOLTAGE_DISABLE
static void settings()
Configures the output.
#define LTC4260_PGIO_POWER_GOOD
#define LTC4260_EN_STATE_DISABLE
#define LTC4260_OVERCURRENT_FAULT
static void print_title()
Print the title block.
static uint8_t discover_DC786A(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
#define LTC4260_POWER_BAD_DISABLE
#define LTC4260_EN_STATE_ENABLE
#define LTC4260_MASS_WRITE_DISABLE
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
#define LTC4260_POWER_BAD_ENABLE
#define LTC4260_UNDERVOLTAGE_DISABLE
float LTC4260_code_to_voltage(uint8_t register_code, float LSB, float resistor_divider_ratio)
Calculates voltage from register code data.
LTC4260: Hot Swap Controller with I2C Compatible Monitoring.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
#define LTC4260_OVERCURRENT_ENABLE
#define LTC4260_OVERCURRENT_DISABLE
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
#define LTC4260_OVERCURRENT_AUTO_RETRY_ENABLE
static void print_prompt()
Print the main menu.
#define LTC4260_OVERVOLTAGE_FAULT
#define LTC4260_SOURCE_REG
#define LTC4260_GPIO_OUTPUT_ENABLE
char product_name[15]
LTC Product (LTC2654-L16)
#define LTC4260_FAULT_REG
#define LTC4260_EN_STATE_CHANGE
#define LTC4260_PGIO_GENERAL_PURPOSE_OUTPUT
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
static int8_t main_menu_2_read_and_clear_faults()
Function to read and clear fault register.
#define LTC4260_TEST_MODE_ENABLE
#define LTC4260_PGIO_GENERAL_PURPOSE_INPUT
#define LTC4260_MASS_WRITE_ENABLE
#define LTC4260_UNDERVOLTAGE_FAULT
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]
static int8_t main_menu_4_manage_alerts()
Function to update alert register bits.
#define LTC4260_UNDERVOLTAGE_ENABLE
#define LTC4260_ALERT_REG
#define LTC4260_OVERVOLTAGE_AUTO_RETRY_DISABLE