108 #define CONTINUOUS_MODE_DISPLAY_DELAY 1000 123 const char ack_error[] =
"Error: No Acknowledge. Check I2C Address.";
136 Serial.begin(115200);
141 Serial.println(F(
"Demo board not detected, will attempt to proceed"));
157 static int8_t CTRLA_mode = 0x00;
158 static int8_t bit_resolution = 1;
160 static float scale = (150/3);
164 if (Serial.available())
167 if (user_command !=
'm')
168 Serial.println(user_command);
171 switch (user_command)
194 Serial.println(F(
"Incorrect Option"));
199 Serial.print(F(
"*************************"));
210 Serial.println(F(
"\n*****************************************************************"));
211 Serial.print(F(
"* DC2561 Demonstration Program *\n"));
212 Serial.print(F(
"* *\n"));
213 Serial.print(F(
"* This program communicates with the LTC2992 12-Bit Dual Wide *\n"));
214 Serial.print(F(
"* Range I2C Power Monitor found on the DC2561 demo board. *\n"));
215 Serial.print(F(
"* Set the baud rate to 115200 and select the newline terminator.*\n"));
216 Serial.print(F(
"* *\n"));
217 Serial.print(F(
"*****************************************************************\n"));
223 Serial.print(F(
"\n1-Continuous Mode\n"));
224 Serial.print(F(
"2-Threshold Configuration\n"));
225 Serial.print(F(
"3-GPIO Control\n"));
226 Serial.print(F(
"4-Settings\n"));
227 Serial.print(F(
"5-Read/Clear Faults\n\n"));
228 Serial.print(F(
"Enter a command: "));
233 int8_t bit_resolution,
245 Serial.print(F(
"**********************************************************************************************\n\n"));
246 Serial.print(F(
" Channel 1 Channel 2\n\n"));
247 if (bit_resolution == 1)
249 uint32_t power1_code, power2_code, max_power1_code, max_power2_code, min_power1_code, min_power2_code;
257 float power1, power2, max_power1, max_power2, min_power1, min_power2;
265 Serial.print(F(
" Power 1: "));
266 Serial.print(power1, 4);
267 Serial.print(F(
" W"));
269 Serial.print(F(
" Power 2: "));
270 Serial.print(power2, 4);
271 Serial.print(F(
" W\n"));
273 Serial.print(F(
" Max Power 1: "));
274 Serial.print(max_power1, 4);
275 Serial.print(F(
" W"));
277 Serial.print(F(
" Max Power 2: "));
278 Serial.print(max_power2, 4);
279 Serial.print(F(
" W\n"));
281 Serial.print(F(
" Min Power 1: "));
282 Serial.print(min_power1, 4);
283 Serial.print(F(
" W"));
285 Serial.print(F(
" Min Power 2: "));
286 Serial.print(min_power2, 4);
287 Serial.print(F(
" W\n"));
289 uint16_t current1_code, current2_code, max_current1_code, max_current2_code, min_current1_code, min_current2_code;
298 float current1, current2, max_current1, max_current2, min_current1, min_current2;
307 Serial.print(F(
"\n Current 1: "));
308 Serial.print(current1, 4);
309 Serial.print(F(
" A"));
311 Serial.print(F(
" Current 2: "));
312 Serial.print(current2, 4);
313 Serial.print(F(
" A\n"));
315 Serial.print(F(
"Max Current 1: "));
316 Serial.print(max_current1, 4);
317 Serial.print(F(
" A"));
319 Serial.print(F(
" Max Current 2: "));
320 Serial.print(max_current2, 4);
321 Serial.print(F(
" A\n"));
323 Serial.print(F(
"Min Current 1: "));
324 Serial.print(min_current1, 4);
325 Serial.print(F(
" A"));
327 Serial.print(F(
" Min Current 2: "));
328 Serial.print(min_current2, 4);
329 Serial.print(F(
" A\n"));
331 uint16_t SENSE1_code, max_SENSE1_code, min_SENSE1_code;
336 float SENSE1, max_SENSE1, min_SENSE1;
341 uint16_t SENSE2_code, max_SENSE2_code, min_SENSE2_code;
346 float SENSE2, max_SENSE2, min_SENSE2;
351 Serial.print(F(
"\n SENSE 1: "));
352 Serial.print(SENSE1, 4);
353 Serial.print(F(
" V"));
355 Serial.print(F(
" SENSE 2: "));
356 Serial.print(SENSE2, 4);
357 Serial.print(F(
" V\n"));
359 Serial.print(F(
" Max SENSE 1: "));
360 Serial.print(max_SENSE1, 4);
361 Serial.print(F(
" V"));
363 Serial.print(F(
" Max SENSE 2: "));
364 Serial.print(max_SENSE2, 4);
365 Serial.print(F(
" V\n"));
367 Serial.print(F(
" Min SENSE 1: "));
368 Serial.print(min_SENSE1, 4);
369 Serial.print(F(
" V"));
371 Serial.print(F(
" Min SENSE 2: "));
372 Serial.print(min_SENSE2, 4);
373 Serial.print(F(
" V\n"));
375 uint32_t power_sum_code;
376 uint16_t current_sum_code;
380 float power_sum, current_sum;
384 Serial.print(F(
"\n Power Sum: "));
385 Serial.print(power_sum, 4);
386 Serial.print(F(
" W\n"));
388 Serial.print(F(
" Current Sum: "));
389 Serial.print(current_sum, 4);
390 Serial.print(F(
" A\n"));
392 uint16_t GPIO1_code, max_GPIO1_code, min_GPIO1_code, GPIO2_code, max_GPIO2_code, min_GPIO2_code,
393 GPIO3_code, max_GPIO3_code, min_GPIO3_code, GPIO4_code, max_GPIO4_code, min_GPIO4_code;
410 float GPIO1, max_GPIO1, min_GPIO1, GPIO2, max_GPIO2, min_GPIO2, GPIO3, max_GPIO3, min_GPIO3, GPIO4, max_GPIO4, min_GPIO4;
427 Serial.print(F(
"\n GPIO1: "));
428 Serial.print(GPIO1*scale, 4);
429 Serial.print(F(
" V"));
431 Serial.print(F(
" GPIO2: "));
432 Serial.print(GPIO2*scale, 4);
433 Serial.print(F(
" V"));
435 Serial.print(F(
" GPIO3: "));
436 Serial.print(GPIO3, 4);
437 Serial.print(F(
" V"));
439 Serial.print(F(
" GPIO4: "));
440 Serial.print(GPIO4, 4);
441 Serial.print(F(
" V\n"));
443 Serial.print(F(
"Max GPIO1: "));
444 Serial.print(max_GPIO1, 4);
445 Serial.print(F(
" V"));
447 Serial.print(F(
" Max GPIO2: "));
448 Serial.print(max_GPIO2, 4);
449 Serial.print(F(
" V"));
451 Serial.print(F(
" Max GPIO3: "));
452 Serial.print(max_GPIO3, 4);
453 Serial.print(F(
" V"));
455 Serial.print(F(
" Max GPIO4: "));
456 Serial.print(max_GPIO4, 4);
457 Serial.print(F(
" V\n"));
459 Serial.print(F(
"Min GPIO1: "));
460 Serial.print(min_GPIO1, 4);
461 Serial.print(F(
" V"));
463 Serial.print(F(
" Min GPIO2: "));
464 Serial.print(min_GPIO2, 4);
465 Serial.print(F(
" V"));
467 Serial.print(F(
" Min GPIO3: "));
468 Serial.print(min_GPIO3, 4);
469 Serial.print(F(
" V"));
471 Serial.print(F(
" Min GPIO4: "));
472 Serial.print(min_GPIO4, 4);
473 Serial.print(F(
" V\n"));
477 Serial.print(F(
"In 12 - bit mode\n"));
486 uint32_t power1_code, power2_code, max_power1_code, max_power2_code, min_power1_code, min_power2_code;
494 float power1, power2, max_power1, max_power2, min_power1, min_power2;
502 Serial.print(F(
" Power 1: "));
503 Serial.print(power1, 4);
504 Serial.print(F(
" W"));
506 Serial.print(F(
" Power 2: "));
507 Serial.print(power2, 4);
508 Serial.print(F(
" W\n"));
510 Serial.print(F(
" Max Power 1: "));
511 Serial.print(max_power1, 4);
512 Serial.print(F(
" W"));
514 Serial.print(F(
" Max Power 2: "));
515 Serial.print(max_power2, 4);
516 Serial.print(F(
" W\n"));
518 Serial.print(F(
" Min Power 1: "));
519 Serial.print(min_power1, 4);
520 Serial.print(F(
" W"));
522 Serial.print(F(
" Min Power 2: "));
523 Serial.print(min_power2, 4);
524 Serial.print(F(
" W\n"));
526 uint16_t current1_code, current2_code, max_current1_code, max_current2_code, min_current1_code, min_current2_code;
535 float current1, current2, max_current1, max_current2, min_current1, min_current2;
544 Serial.print(F(
"\n Current 1: "));
545 Serial.print(current1, 4);
546 Serial.print(F(
" A"));
548 Serial.print(F(
" Current 2: "));
549 Serial.print(current2, 4);
550 Serial.print(F(
" A\n"));
552 Serial.print(F(
"Max Current 1: "));
553 Serial.print(max_current1, 4);
554 Serial.print(F(
" A"));
556 Serial.print(F(
" Max Current 2: "));
557 Serial.print(max_current2, 4);
558 Serial.print(F(
" A\n"));
560 Serial.print(F(
"Min Current 1: "));
561 Serial.print(min_current1, 4);
562 Serial.print(F(
" A"));
564 Serial.print(F(
" Min Current 2: "));
565 Serial.print(min_current2, 4);
566 Serial.print(F(
" A\n"));
568 uint16_t SENSE1_code, max_SENSE1_code, min_SENSE1_code;
573 float SENSE1, max_SENSE1, min_SENSE1;
578 uint16_t SENSE2_code, max_SENSE2_code, min_SENSE2_code;
583 float SENSE2, max_SENSE2, min_SENSE2;
588 Serial.print(F(
"\n SENSE 1: "));
589 Serial.print(SENSE1, 4);
590 Serial.print(F(
" V"));
592 Serial.print(F(
" SENSE 2: "));
593 Serial.print(SENSE2, 4);
594 Serial.print(F(
" V\n"));
596 Serial.print(F(
" Max SENSE 1: "));
597 Serial.print(max_SENSE1, 4);
598 Serial.print(F(
" V"));
600 Serial.print(F(
" Max SENSE 2: "));
601 Serial.print(max_SENSE2, 4);
602 Serial.print(F(
" V\n"));
604 Serial.print(F(
" Min SENSE 1: "));
605 Serial.print(min_SENSE1, 4);
606 Serial.print(F(
" V"));
608 Serial.print(F(
" Min SENSE 2: "));
609 Serial.print(min_SENSE2, 4);
610 Serial.print(F(
" V\n"));
612 uint32_t power_sum_code;
613 uint16_t current_sum_code;
617 float power_sum, current_sum;
621 Serial.print(F(
"\n Power Sum: "));
622 Serial.print(power_sum, 4);
623 Serial.print(F(
" W\n"));
625 Serial.print(F(
" Current Sum: "));
626 Serial.print(current_sum, 4);
627 Serial.print(F(
" A\n"));
629 uint16_t GPIO1_code, max_GPIO1_code, min_GPIO1_code, GPIO2_code, max_GPIO2_code, min_GPIO2_code,
630 GPIO3_code, max_GPIO3_code, min_GPIO3_code, GPIO4_code, max_GPIO4_code, min_GPIO4_code;
647 float GPIO1, max_GPIO1, min_GPIO1, GPIO2, max_GPIO2, min_GPIO2, GPIO3, max_GPIO3, min_GPIO3, GPIO4, max_GPIO4, min_GPIO4;
664 Serial.print(F(
"\n GPIO1: "));
665 Serial.print(GPIO1*scale, 4);
666 Serial.print(F(
" V"));
668 Serial.print(F(
" GPIO2: "));
669 Serial.print(GPIO2*scale, 4);
670 Serial.print(F(
" V"));
672 Serial.print(F(
" GPIO3: "));
673 Serial.print(GPIO3, 4);
674 Serial.print(F(
" V"));
676 Serial.print(F(
" GPIO4: "));
677 Serial.print(GPIO4, 4);
678 Serial.print(F(
" V\n"));
680 Serial.print(F(
"Max GPIO1: "));
681 Serial.print(max_GPIO1, 4);
682 Serial.print(F(
" V"));
684 Serial.print(F(
" Max GPIO2: "));
685 Serial.print(max_GPIO2, 4);
686 Serial.print(F(
" V"));
688 Serial.print(F(
" Max GPIO3: "));
689 Serial.print(max_GPIO3, 4);
690 Serial.print(F(
" V"));
692 Serial.print(F(
" Max GPIO4: "));
693 Serial.print(max_GPIO4, 4);
694 Serial.print(F(
" V\n"));
696 Serial.print(F(
"Min GPIO1: "));
697 Serial.print(min_GPIO1, 4);
698 Serial.print(F(
" V"));
700 Serial.print(F(
" Min GPIO2: "));
701 Serial.print(min_GPIO2, 4);
702 Serial.print(F(
" V"));
704 Serial.print(F(
" Min GPIO3: "));
705 Serial.print(min_GPIO3, 4);
706 Serial.print(F(
" V"));
708 Serial.print(F(
" Min GPIO4: "));
709 Serial.print(min_GPIO4, 4);
710 Serial.print(F(
" V\n"));
715 Serial.print(F(
"In 8 - bit mode\n"));
719 Serial.print(F(
"\n\n**********************************************************************************************\n\n"));
721 Serial.print(F(
"m-Main Menu\n\n"));
725 while (Serial.available() ==
false);
732 int8_t bit_resolution)
739 Serial.print(F(
"*************************\n\n"));
740 Serial.print(F(
"1-Set Power Threshold\n"));
741 Serial.print(F(
"2-Set Current Threshold\n"));
742 Serial.print(F(
"3-Set SENSE Threshold\n"));
743 Serial.print(F(
"4-Set GPIO Threshold\n"));
744 Serial.print(F(
"5-Reset Thresholds To Default\n"));
745 Serial.print(F(
"m-Main Menu\n\n"));
746 Serial.print(F(
"Enter a command: "));
749 if (user_command ==
'm')
750 Serial.println(F(
"m"));
752 Serial.println(user_command);
754 switch (user_command)
776 if (user_command !=
'm')
777 Serial.println(F(
"Incorrect Option"));
781 while (!((user_command ==
'm') || (ack)));
790 Serial.print(F(
"Enter Max Channel 1 Power Threshold:"));
792 float max_power_threshold;
794 Serial.println(max_power_threshold, 4);
796 uint32_t max_power_threshold_code;
797 if (bit_resolution == 1)
807 Serial.print(F(
"Enter Min Channel 1 Power Threshold:"));
809 float min_power_threshold;
811 Serial.println(min_power_threshold, 4);
814 uint32_t min_power_threshold_code;
815 if (bit_resolution == 1)
826 Serial.print(F(
"Enter Max Channel 2 Power Threshold:"));
828 Serial.println(max_power_threshold, 4);
830 if (bit_resolution == 1)
841 Serial.print(F(
"Enter Min Channel 2 Power Threshold:"));
844 Serial.println(min_power_threshold, 4);
847 if (bit_resolution == 1)
858 Serial.print(F(
"Enter Max Power SUM Threshold:"));
860 Serial.println(max_power_threshold, 4);
862 if (bit_resolution == 1)
874 Serial.print(F(
"Enter Min Power Sum Threshold:"));
877 Serial.println(min_power_threshold, 4);
879 if (bit_resolution == 1)
899 Serial.print(F(
"Enter Max Channel 1 Current Threshold:"));
901 float max_current_threshold;
903 Serial.println(max_current_threshold, 4);
905 uint16_t max_current_threshold_code;
906 if (bit_resolution == 1)
918 Serial.print(F(
"Enter Min Channel 1 Current Threshold:"));
920 float min_current_threshold;
922 Serial.println(min_current_threshold, 4);
925 uint16_t min_current_threshold_code;
926 if (bit_resolution == 1)
938 Serial.print(F(
"Enter Max Channel 2 Current Threshold:"));
940 Serial.println(max_current_threshold, 4);
942 if (bit_resolution == 1)
952 Serial.print(F(
"Enter Min Channel 2 Current Threshold:"));
955 Serial.println(min_current_threshold, 4);
958 if (bit_resolution == 1)
969 Serial.print(F(
"Enter Max Current Sum Threshold:"));
971 Serial.println(max_current_threshold, 4);
973 if (bit_resolution == 1)
983 Serial.print(F(
"Enter Min Current Sum Threshold:"));
986 Serial.println(min_current_threshold, 4);
988 if (bit_resolution == 1)
1008 Serial.print(F(
"Enter Max Channel 1 SENSE Threshold:"));
1010 float max_sense_threshold;
1012 Serial.println(max_sense_threshold, 4);
1014 uint16_t max_sense_threshold_code;
1015 if (bit_resolution == 1)
1025 Serial.print(F(
"Enter Min Channel 1 SENSE Threshold:"));
1027 float min_sense_threshold;
1029 Serial.println(min_sense_threshold, 4);
1032 uint16_t min_sense_threshold_code;
1033 if (bit_resolution == 1)
1044 Serial.print(F(
"Enter Max Channel 2 SENSE Threshold:"));
1046 Serial.println(max_sense_threshold, 4);
1048 if (bit_resolution == 1)
1059 Serial.print(F(
"Enter Min Channel 2 SENSE Threshold:"));
1062 Serial.println(min_sense_threshold, 4);
1065 if (bit_resolution == 1)
1081 int8_t bit_resolution)
1085 Serial.print(F(
"Enter Max GPIO1 Threshold (Range: 0V - 100V):"));
1087 float max_gpio_threshold;
1089 Serial.println(max_gpio_threshold, 4);
1091 uint16_t max_gpio_threshold_code;
1092 if (bit_resolution == 1)
1102 Serial.print(F(
"Enter Min GPIO1 Threshold (Range: 0V - 100V):"));
1104 float min_gpio_threshold;
1106 Serial.println(min_gpio_threshold, 4);
1109 uint16_t min_gpio_threshold_code;
1110 if (bit_resolution == 1)
1121 Serial.print(F(
"Enter Max GPIO2 Threshold (Range: 0V - 100V):"));
1123 Serial.println(max_gpio_threshold, 4);
1125 if (bit_resolution == 1)
1136 Serial.print(F(
"Enter Min GPIO2 Threshold (Range: 0V - 100V):"));
1139 Serial.println(min_gpio_threshold, 4);
1142 if (bit_resolution == 1)
1153 Serial.print(F(
"Enter Max GPIO3 Threshold (Range: 0V - 2.048V):"));
1155 Serial.println(max_gpio_threshold, 4);
1157 if (bit_resolution == 1)
1168 Serial.print(F(
"Enter Min GPIO3 Threshold (Range: 0V - 2.048V):"));
1171 Serial.println(min_gpio_threshold, 4);
1174 if (bit_resolution == 1)
1185 Serial.print(F(
"Enter Max GPIO4 Threshold (Range: 0V - 2.048V):"));
1187 Serial.println(max_gpio_threshold, 4);
1189 if (bit_resolution == 1)
1200 Serial.print(F(
"Enter Min GPIO4 Threshold (Range: 0V - 2.048V):"));
1203 Serial.println(min_gpio_threshold, 4);
1206 if (bit_resolution == 1)
1227 uint32_t max_32bit_threshold = 0xFFFFFF;
1228 uint16_t max_16bit_threshold = 0xFFF0;
1229 uint32_t min_32bit_threshold = 0x000000;
1230 uint16_t min_16bit_threshold = 0x00000;
1232 uint32_t max_power_threshold_code = 0;
1233 uint32_t min_power_threshold_code = 0;
1277 Serial.println(F(
"\nThresholds Reset to Defaults\n"));
1289 uint8_t gpio_io_code;
1290 uint8_t gpio4_control_code;
1294 Serial.print(F(
"*************************\n\n"));
1295 Serial.print(F(
"1-Configure GPIO1\n"));
1296 Serial.print(F(
"2-Configure GPIO2\n"));
1297 Serial.print(F(
"3-Configure GPIO3\n"));
1298 Serial.print(F(
"4-Configure GPIO4\n"));
1299 Serial.print(F(
"m-Main Menu\n\n"));
1300 Serial.print(F(
"Enter a command: "));
1306 if (user_command ==
'm')
1307 Serial.println(F(
"m"));
1309 Serial.println(user_command);
1311 switch (user_command)
1314 Serial.print(F(
"1-GPIO1 Pulls Low, 2-GPIO1 High-Z\n"));
1316 if ((user_command > 2) || (user_command < 0))
1318 Serial.println(user_command);
1319 if (user_command == 1)
1327 Serial.print(F(
"1-GPIO2 Pulls Low, 2-GPIO2 High-Z\n"));
1329 if ((user_command > 2) || (user_command < 0))
1331 Serial.println(user_command);
1332 if (user_command == 1)
1339 Serial.print(F(
"*************************\n\n"));
1340 Serial.print(F(
"1-Configure GPIO3 as Data Ready (Latching)\n"));
1341 Serial.print(F(
"2-Configure GPIO3 as Data Ready (128us Pulse)\n"));
1342 Serial.print(F(
"3-Configure GPIO3 as Data Ready (16us Pulse)\n"));
1343 Serial.print(F(
"4-Configure GPIO3 as I/O Pin\n"));
1344 Serial.print(F(
"m-Main Menu\n\n"));
1345 Serial.print(F(
"Enter a command: "));
1347 Serial.println(user_command);
1348 switch (user_command)
1364 Serial.print(F(
"1-GPIO3 Pulls Low, 2-GPIO3 High-Z\n"));
1366 if ((user_command > 2) || (user_command < 0))
1368 Serial.println(user_command);
1369 if (user_command == 1)
1379 Serial.print(F(
"1-GPIO4 Pulls Low, 2-GPIO1 High-Z\n"));
1381 if ((user_command > 2) || (user_command < 0))
1383 Serial.println(user_command);
1384 if (user_command == 1)
1390 if (user_command !=
'm')
1391 Serial.println(F(
"Incorrect Option"));
1397 while (!((user_command ==
'm') || (ack)));
1409 uint8_t no_fault_code = 0x00;
1413 Serial.print(F(
"*************************\n\n"));
1414 Serial.print(F(
"1-Real All Faults\n"));
1415 Serial.print(F(
"2-Clear All Faults\n"));
1416 Serial.print(F(
"m-Main Menu\n\n"));
1417 Serial.print(F(
"Enter a command: "));
1420 if (user_command ==
'm')
1421 Serial.println(F(
"m"));
1423 Serial.println(user_command);
1425 switch (user_command)
1430 if ((fault_code & (1 << 7)) != 0)
1431 Serial.println(F(
"Max Channel 1 Power Fault Occured!"));
1434 if ((fault_code & (1 << 6)) != 0)
1435 Serial.println(F(
"Min Channel 1 Power Fault Occured!"));
1438 if ((fault_code & (1 << 5)) != 0)
1439 Serial.println(F(
"Max Channel 1 Current Fault Occured!"));
1442 if ((fault_code & (1 << 4)) != 0)
1443 Serial.println(F(
"Min Channel 1 Current Fault Occured!"));
1446 if ((fault_code & (1 << 3)) != 0)
1447 Serial.println(F(
"Max Channel 1 Voltage Fault Occured!"));
1450 if ((fault_code & (1 << 2)) != 0)
1451 Serial.println(F(
"Min Channel 1 Voltage Fault Occured!"));
1454 if ((fault_code & (1 << 1)) != 0)
1455 Serial.println(F(
"Max GPIO1 Fault Occured!"));
1458 if ((fault_code & (1 << 0)) != 0)
1459 Serial.println(F(
"Min GPIO1 Fault Occured!"));
1465 if ((fault_code & (1 << 7)) != 0)
1466 Serial.println(F(
"Max Channel 2 Power Fault Occured!"));
1469 if ((fault_code & (1 << 6)) != 0)
1470 Serial.println(F(
"Min Channel 2 Power Fault Occured!"));
1473 if ((fault_code & (1 << 5)) != 0)
1474 Serial.println(F(
"Max Channel 2 Current Fault Occured!"));
1477 if ((fault_code & (1 << 4)) != 0)
1478 Serial.println(F(
"Min Channel 2 Current Fault Occured!"));
1481 if ((fault_code & (1 << 3)) != 0)
1482 Serial.println(F(
"Max Channel 2 Voltage Fault Occured!"));
1485 if ((fault_code & (1 << 2)) != 0)
1486 Serial.println(F(
"Min Channel 2 Voltage Fault Occured!"));
1489 if ((fault_code & (1 << 1)) != 0)
1490 Serial.println(F(
"Max GPIO2 Fault Occured!"));
1493 if ((fault_code & (1 << 0)) != 0)
1494 Serial.println(F(
"Min GPIO2 Fault Occured!"));
1500 if ((fault_code & (1 << 7)) != 0)
1501 Serial.println(F(
"Max GPIO3 Fault Occured!"));
1504 if ((fault_code & (1 << 6)) != 0)
1505 Serial.println(F(
"Min GPIO3 Fault Occured!"));
1508 if ((fault_code & (1 << 5)) != 0)
1509 Serial.println(F(
"Max GPIO4 Fault Occured!"));
1512 if ((fault_code & (1 << 4)) != 0)
1513 Serial.println(F(
"Min GPIO4 Fault Occured!"));
1516 if ((fault_code & (1 << 3)) != 0)
1517 Serial.println(F(
"Max Current SUM Fault Occured!"));
1520 if ((fault_code & (1 << 2)) != 0)
1521 Serial.println(F(
"Min Current SUM Fault Occured!"));
1524 if ((fault_code & (1 << 1)) != 0)
1525 Serial.println(F(
"Max Power SUM Fault Occured!"));
1528 if ((fault_code & (1 << 0)) != 0)
1529 Serial.println(F(
"Min Power SUM Fault Occured!"));
1535 if ((fault_code & (1 << 4)) != 0)
1536 Serial.println(F(
"Stuck Bus Fault Occured!"));
1539 if ((fault_code & (1 << 3)) != 0)
1540 Serial.println(F(
"GPIO1 Input Fault Occured!"));
1543 if ((fault_code & (1 << 2)) != 0)
1544 Serial.println(F(
"GPIO2 Input Fault Occured!"));
1547 if ((fault_code & (1 << 1)) != 0)
1548 Serial.println(F(
"GPIO3 Input Fault Occured!"));
1552 if (no_fault_code == 28)
1554 Serial.println(F(
"No Faults Occured\n"));
1569 Serial.println(F(
"\nAll Faults Cleared\n"));
1574 if (user_command !=
'm')
1575 Serial.println(F(
"Incorrect Option"));
1579 while (!((user_command ==
'm') || (ack)));
1586 int8_t *bit_resolution)
1594 Serial.print(F(
"*************************\n\n"));
1595 Serial.print(F(
"1-Configure ADC Resolution\n"));
1596 Serial.print(F(
"2-Enable/Disable Shutdown Mode\n"));
1597 Serial.print(F(
"m-Main Menu\n\n"));
1598 Serial.print(F(
"Enter a command: "));
1601 if (user_command ==
'm')
1602 Serial.println(F(
"m"));
1604 Serial.println(user_command);
1606 switch (user_command)
1609 Serial.print(F(
"1-12-bit resolution, 2-8-bit resolution\n"));
1611 if ((user_command > 2) || (user_command < 0))
1613 Serial.println(user_command);
1614 if (user_command == 1)
1616 * bit_resolution = 1;
1621 *bit_resolution = 0;
1626 Serial.println(nadc_code);
1630 Serial.print(F(
"1-Enable Shutdown, 2-Disable Shutdown\n"));
1632 if ((user_command > 2) || (user_command < 0))
1634 Serial.println(user_command);
1635 if (user_command == 1)
1638 Serial.print(F(
"Shutdown Mode is enabled. Selecting Continious Mode in main menu will disable Shutdown mode\n"));
1643 Serial.print(F(
"Shutdown Mode is disabled. \n"));
1648 if (user_command !=
'm')
1649 Serial.println(F(
"Incorrect Option"));
1653 while (!((user_command ==
'm') || (ack)));
#define LTC2992_MAX_POWER1_THRESHOLD_MSB2_REG
static void print_title()
Print the title block.
#define LTC2992_GPIO3_OUT_LOW
#define LTC2992_MIN_POWER2_MSB2_REG
#define LTC2992_I2C_ADDRESS
#define LTC2992_MAX_DELTA1_SENSE_THRESHOLD_MSB_REG
#define LTC2992_DELTA_SENSE2_MSB_REG
#define LTC2992_MIN_DELTA2_SENSE_MSB_REG
#define LTC2992_MAX_POWER1_MSB2_REG
unsigned char user_command
#define LTC2992_MIN_SENSE1_THRESHOLD_MSB_REG
#define LTC2992_MAX_SENSE2_THRESHOLD_MSB_REG
static int8_t demo_board_connected
Set to 1 if the board is connected.
#define LTC2992_MIN_GPIO3_MSB_REG
static int8_t menu_2_threshold_menu_1_set_power(int8_t bit_resolution)
Set Power Min/Max Values.
#define LTC2992_MAX_SENSE1_THRESHOLD_MSB_REG
const float LTC2992_GPIO_8bit_lsb
Typical GPIO lsb weight for 8-bit mode in volts.
#define LTC2992_MAX_GPIO3_THRESHOLD_MSB_REG
float LTC2992_code_to_current(uint16_t adc_code, float resistor, float LTC2992_DELTA_SENSE_lsb)
Calculate the LTC2992 current with a sense resistor.
Header File for Linduino Libraries and Demo Code.
#define LTC2992_MIN_DELTA2_SENSE_THRESHOLD_MSB_REG
LTC2992: Dual Wide Range Power Monitor.
int8_t LTC2992_read(uint8_t i2c_address, uint8_t adc_command, uint8_t *adc_code)
Reads an 8-bit adc_code from LTC2992.
#define LTC2992_MIN_DELTA1_SENSE_MSB_REG
#define LTC2992_MAX_SENSE1_MSB_REG
const float LTC2992_GPIO_12bit_lsb
Typical GPIO lsb weight for 12-bit mode in volts.
#define LTC2992_MIN_ISUM_THRESHOLD_MSB_REG
const char ack_error[]
Error message.
static int8_t menu_2_threshold_menu_5_reset_thresholds()
Set All Thresholds to Default Values.
#define LTC2992_GPIO2_MSB_REG
#define LTC2992_MIN_DELTA1_SENSE_THRESHOLD_MSB_REG
const float LTC2992_DELTA_SENSE_8bit_lsb
Typical Delta lsb weight for 8-bit mode in volts.
#define LTC2992_POWER1_MSB2_REG
static void setup()
Initialize Linduino.
#define LTC2992_MAX_DELTA2_SENSE_MSB_REG
#define LTC2992_MAX_GPIO1_THRESHOLD_MSB_REG
#define LTC2992_MIN_SENSE1_MSB_REG
#define LTC2992_FAULT3_REG
#define LTC2992_CTRLA_MEASUREMENT_MODE_MASK
#define LTC2992_MAX_PSUM_THRESHOLD_MSB1_REG
#define LTC2992_DELTA_SENSE1_MSB_REG
const float LTC2992_DELTA_SENSE_12bit_lsb
Typical Delta lsb weight for 12-bit mode in volts.
#define LTC2992_GPIO4_CFG_REG
int8_t LTC2992_write_24_bits(uint8_t i2c_address, uint8_t adc_command, uint32_t code)
Write a 24-bit code to the LTC2992.
static void loop()
Repeats Linduino loop.
#define LTC2992_MAX_GPIO2_THRESHOLD_MSB_REG
#define LTC2992_MODE_CONTINUOUS
#define LTC2992_FAULT1_REG
float LTC2992_SENSE_code_to_voltage(uint16_t adc_code, float LTC2992_SENSE_lsb)
Calculate the LTC2992 SENSE voltage.
float LTC2992_code_to_current_sum(uint16_t adc_code, float resistor, float LTC2992_DELTA_SENSE_lsb)
Calculate the LTC2992 current sum with a sense resistor.
const float LTC2992_SENSE_12bit_lsb
Typical SENSE lsb weight for 12-bit mode in volts.
#define LTC2992_PSUM_MSB1_REG
static int8_t menu_2_threshold_config(float scale, int8_t bit_resolution)
Configure Threshold Values.
#define LTC2992_MIN_GPIO3_THRESHOLD_MSB_REG
#define LTC2992_GPIO3_OUT_HIGH_Z
int8_t LTC2992_write(uint8_t i2c_address, uint8_t adc_command, uint8_t code)
Write an 8-bit code to the LTC2992.
#define LTC2992_MIN_GPIO4_THRESHOLD_MSB_REG
#define LTC2992_GPIO4_MSB_REG
#define LTC2992_GPIO4_OUT_HI_Z
#define LTC2992_MAX_GPIO4_THRESHOLD_MSB_REG
float LTC2992_code_to_power_sum(int32_t adc_code, float resistor, float LTC2992_Power_lsb)
Power LSB Weight.
#define LTC2992_MIN_GPIO2_MSB_REG
static int8_t menu_2_alert_menu_4_set_adin_alerts(float scale, int8_t bit_resolution)
#define LTC2992_MIN_GPIO1_MSB_REG
#define LTC2992_GPIO3_CONFIG_LOW_DATARDY
#define LTC2992_GPIO3_CONFIG_IO
#define LTC2992_MIN_PSUM_THRESHOLD_MSB1_REG
#define LTC2992_MIN_SENSE2_THRESHOLD_MSB_REG
#define LTC2992_MAX_GPIO3_MSB_REG
#define LTC2992_MAX_GPIO4_MSB_REG
float LTC2992_GPIO_code_to_voltage(uint16_t adc_code, float LTC2992_GPIO_lsb)
Calculate the LTC2992 GPIO voltage.
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
#define LTC2992_FAULT2_REG
static int8_t menu_3_GPIO_config()
#define LTC2992_ISUM_MSB_REG
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
#define LTC2992_GPIO_IO_CONT_REG
#define LTC2992_GPIO1_MSB_REG
static int8_t menu_5_read_clear_faults()
Read/Clear Faults.
#define LTC2992_GPIO3_CONFIG_128_LOW
#define LTC2992_SENSE2_MSB_REG
#define LTC2992_GPIO2_OUT_LOW
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
#define LTC2992_MIN_POWER1_THRESHOLD_MSB2_REG
const float LTC2992_SENSE_8bit_lsb
Typical SENSE lsb weight for 8-bit mode in volts.
#define LTC2992_GPIO2_OUT_HIGH_Z
int8_t LTC2992_read_12_bits(uint8_t i2c_address, uint8_t adc_command, uint16_t *adc_code)
Reads a 12-bit adc_code from LTC2992.
const float LTC2992_Power_8bit_lsb
Typical POWER lsb weight for 8-bit mode in V^2.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
#define LTC2992_MAX_DELTA1_SENSE_MSB_REG
static void print_prompt()
Print the Prompt.
#define LTC2992_CTRLA_REG
#define LTC2992_GPIO4_OUT_LOW
static int8_t menu_2_threshold_menu_3_set_SENSE(int8_t bit_resolution)
Set Min/Max Voltage Thresholds.
#define LTC2992_MAX_GPIO1_MSB_REG
#define LTC2992_GPIO1_OUT_HIGH_Z
#define LTC2992_MAX_ISUM_THRESHOLD_MSB_REG
int8_t LTC2992_write_16_bits(uint8_t i2c_address, uint8_t adc_command, uint16_t code)
Write a 16-bit code to the LTC2992.
int8_t LTC2992_read_24_bits(uint8_t i2c_address, uint8_t adc_command, uint32_t *adc_code)
Reads a 24-bit adc_code from LTC2992.
float LTC2992_code_to_power(int32_t adc_code, float resistor, float LTC2992_Power_lsb)
Calculate the LTC2992 power.
static int8_t menu_1_continuous_mode(int8_t CTRLA_mode, int8_t bit_resolution, float scale)
Continuous Mode.
const float resistor
resistor value on demo board
#define LTC2992_GPIO1_OUT_LOW
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
#define LTC2992_MIN_GPIO1_THRESHOLD_MSB_REG
#define LTC2992_GPIOCFG_GPIO3_MASK
#define LTC2992_MIN_POWER1_MSB2_REG
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
#define LTC2992_ADC_RESOLUTION
#define LTC2992_MIN_GPIO2_THRESHOLD_MSB_REG
#define LTC2992_MAX_GPIO2_MSB_REG
#define LTC2992_GPIO3_CONFIG_16_LOW
#define LTC2992_MIN_GPIO4_MSB_REG
#define LTC2992_MIN_POWER2_THRESHOLD_MSB2_REG
static int8_t menu_4_settings(int8_t *CTRLA_mode, int8_t *bit_resolution)
Settings to configure shutdown mode and ADC Resolution.
#define CONTINUOUS_MODE_DISPLAY_DELAY
The delay between readings in continious mode.
const float LTC2992_Power_12bit_lsb
Typical POWER lsb weight for 12-bit mode in V^2.
#define LTC2992_MAX_DELTA2_SENSE_THRESHOLD_MSB_REG
#define LTC2992_POWER2_MSB2_REG
#define LTC2992_MIN_SENSE2_MSB_REG
#define LTC2992_MODE_SHUTDOWN
#define LTC2992_MAX_POWER2_THRESHOLD_MSB2_REG
#define LTC2992_MAX_POWER2_MSB2_REG
#define LTC2992_GPIO3_MSB_REG
#define LTC2992_SENSE1_MSB_REG
#define LTC2992_FAULT4_REG
#define LTC2992_MAX_SENSE2_MSB_REG
static int8_t menu_2_threshold_menu_2_set_current(int8_t bit_resolution)
Set Min/Max Current Threshold.