75 #define NOT_BUSY 1 << 6 76 #define NOT_TRANS 1 << 4 78 #define NOT_PENDING 1 << 5 85 #define CLEAR_FAULTS 0x03 86 #define STORE_USER_ALL 0x15 87 #define RESTORE_USER_ALL 0x16 88 #define STATUS_BYTE 0x78 89 #define STATUS_WORD 0x79 90 #define STATUS_CML 0x7E 91 #define STATUS_MFR_SPECIFIC 0x80 92 #define READ_ITEMP_2977_8 0x8D 93 #define READ_ITEMP 0x8E 94 #define USER_DATA_04 0xB4 95 #define MFR_EE_UNLOCK 0xBD 96 #define MFR_EE_ERASE 0xBE 97 #define MFR_EE_DATA 0xBF 98 #define MFR_PAGE_FF_MASK 0xE4 99 #define MFR_FAULT_LOG_STORE 0xEA 100 #define MFR_FAULT_LOG_RESTORE 0xEB 101 #define MFR_FAULT_LOG_CLEAR 0xEC 102 #define MFR_SPECIAL_ID 0xE7 103 #define MFR_COMMON 0xEF 104 #define MFR_EEPROM_STATUS 0xF1 105 #define MFR_SPARE_0 0xF7 106 #define MFR_RESET 0xFD 109 #define STATUS_CML_CMD_FAULT 0x80 110 #define STATUS_CML_DATA_FAULT 0x40 111 #define STATUS_CML_PEC_FAULT 0x20 112 #define STATUS_CML_MEM_FAULT 0x10 113 #define STATUS_CML_PROC_FAULT 0x04 114 #define STATUS_CML_PMBUS_FAULT 0x02 115 #define STATUS_CML_UNKNOWN_FAULT 0x01 118 #define STATUS_MFR_SPECIFIC_NVM_CRC 0x20 121 #define STATUS_WORD_POWER_GOOD_B 0x0800 123 #define LTC3880_I2C_ADDRESS 0x30 124 #define LTC2974_I2C_ADDRESS 0x32 126 #define LTC2977_8_I2C_ADDRESS 0x33 184 is_ltc2978 = ((mfr_common & (1 <<
RESERVED2)) == 0);
193 while (timeout-- > 0)
228 if ((status & ((1 <<
CML) | (1 <<
BUSY))) &&
229 !(status & ~((1 <<
CML) | (1 <<
BUSY))))
251 while (timeout-- > 0)
255 if (mfr_common == 0xFF)
265 uint8_t mfr_eeprom_status;
269 while (timeout-- > 0)
274 if (mfr_eeprom_status == 0xFF)
276 if ((mfr_eeprom_status & 0xC0) == 0)
350 uint8_t bpos = 0, wpos;
362 for (wpos = 0; wpos < count/16; wpos++)
368 bs[bpos++] = w & 0xFF;
369 bs[bpos++] = (w >> 8) & 0xFF;
383 Serial.println(F(
" Erase not supported on LTC2978"));
386 Serial.println(F(
" No Data, please read data before erasing"));
408 Serial.println(F(
" Device has a Memory Fault"));
413 Serial.println(F(
" Device has a Fault"));
418 Serial.println(F(
" Device is too hot"));
422 Serial.println(F(
" Checksum not verified (LTC2978/A does not support direct read of NVM)"));
423 Serial.println(F(
" Device is Ok (No Memory Fault, Not Hot)"));
431 Serial.println(F(
" Device has a Memory Fault"));
436 Serial.println(F(
" Device has a Fault"));
443 Serial.println(F(
" Device has a Memory Fault"));
449 Serial.println(F(
" Device is hot"));
454 Serial.println(F(
" Device has an invalid CRC"));
457 Serial.println(F(
" Device is Ok (No Memory Fault, Not Hot, CRC is Good)"));
498 Serial.println(user, DEC);
503 Serial.println(user, DEC);
535 *data = (uint16_t *) malloc((*count) *
sizeof(uint16_t));
539 *data = (uint16_t *) malloc((*count) *
sizeof(uint16_t));
543 for (i = 0; i < *count; i++)
559 Serial.println(F(
" No Data, please read data before writing"));
578 for (i = 0; i < *count; i++)
593 for (i = 0; i < *count; i++)
597 Serial.print(F(
" Data Mismatch ("));
598 Serial.print(i, DEC);
599 Serial.print(F(
","));
600 Serial.print(d, HEX);
601 Serial.print(F(
","));
602 Serial.print((*data)[i], HEX);
603 Serial.println(F(
")"));
640 for (page = 0; page < 2; page++)
642 Serial.print(F(
"PAGE "));
643 Serial.println(page, DEC);
646 Serial.print(F(
"LTC3880 STATUS WORD 0x"));
647 Serial.println(w, HEX);
649 Serial.print(F(
"LTC3880 MFR STATUS BYTE 0x"));
650 Serial.println(b, HEX);
653 for (page = 0; page < 4; page++)
655 Serial.print(F(
"PAGE "));
656 Serial.println(page, DEC);
659 Serial.print(F(
"LTC2974 STATUS WORD 0x"));
660 Serial.println(w, HEX);
662 Serial.print(F(
"LTC2974 MFR STATUS BYTE 0x"));
663 Serial.println(b, HEX);
666 for (page = 0; page < 8; page++)
668 Serial.print(F(
"PAGE "));
669 Serial.println(page, DEC);
672 Serial.print(F(
"LTC2977 STATUS WORD 0x"));
673 Serial.println(w, HEX);
675 Serial.print(F(
"LTC2977MFR STATUS BYTE 0x"));
676 Serial.println(b, HEX);
682 Serial.begin(115200);
688 sig0 = boot_signature_byte_get (0);
689 sig2 = boot_signature_byte_get (2);
690 sig4 = boot_signature_byte_get (4);
691 if (sig0 != 0x1E || sig2 != 0x98 | sig4 != 0x01)
693 Serial.println(
"Sketch only runs on Mega 2560");
706 uint8_t revision[10];
707 uint8_t *addresses = NULL;
709 if (Serial.available())
712 if (user_command !=
'm')
713 Serial.println(user_command);
715 switch (user_command)
718 Serial.println(F(
"Check LTC3880 NVM"));
720 Serial.println(F(
"Check LTC2974 NVM"));
722 Serial.println(F(
"Check LTC2977/8 NVM"));
729 Serial.println(F(
"Store All Fault Logs"));
736 Serial.print(F(
"LTC3880 Counter "));
738 Serial.print(F(
"LTC2974 Counter "));
740 Serial.print(F(
"LTC2977/8 Counter "));
745 Serial.println(F(
"Erased LTC3880 Data"));
747 Serial.println(F(
"Erased LTC2974 Data"));
749 Serial.println(F(
"Erased LTC2977 Data"));
756 Serial.println(F(
"Read LTC3880 Data"));
758 Serial.println(F(
"Read LTC2974 Data"));
760 Serial.println(
"LTC2978/A data not read (LTC2978/A does not support direct read of NVM)");
764 Serial.println(F(
"Read LTC2977 Data"));
769 Serial.println(F(
"LTC3880 Data written to NVM"));
771 Serial.println(F(
"LTC2974 Data written to NVM"));
773 Serial.println(
"LTC2978/A data not written (LTC2978/A does not support direct read of NVM)");
777 Serial.println(F(
"LTC2977 Data written to NVM"));
800 Serial.println(F(
"Check EEPROM"));
814 Serial.println(F(
" Storing with STORE_USER_ALL...\n"));
836 Serial.println(F(
"Check NVM"));
839 Serial.println(F(
"LTC3880 failed health check"));
844 Serial.println(F(
"LTC2974 failed health check"));
849 Serial.println(F(
"LTC2977/8 failed health check"));
854 Serial.println(F(
"NVM (EEPROM) is Updated"));
857 Serial.println(F(
"Clear All Fault Logs"));
867 addresses = smbus->
probe(0);
868 while (*addresses != 0)
870 Serial.print(F(
"ADDR 0x"));
871 Serial.println(*addresses++, HEX);
902 Serial.println(F(
"Incorrect Option"));
912 Serial.print(F(
"\n********************************************************************\n"));
913 Serial.print(F(
"* DC1962C Store/Restore User All *\n"));
914 Serial.print(F(
"* *\n"));
915 Serial.print(F(
"* This program demonstrates how to store and restore EEPROM. *\n"));
916 Serial.print(F(
"* *\n"));
917 Serial.print(F(
"* Set the baud rate to 115200 and select the newline terminator. *\n"));
918 Serial.print(F(
"* *\n"));
919 Serial.print(F(
"********************************************************************\n"));
925 Serial.print(F(
"\n 1 -Check NVM (EEPROM) is Ok to Program\n"));
926 Serial.print(F(
" 2 -Read All Status\n"));
927 Serial.print(F(
" 3 -Force Fault Logs (EEPROM)\n"));
928 Serial.print(F(
" 4 -Print Counter (RAM)\n"));
929 Serial.print(F(
" 5 -Erase NVM (EEPROM)\n"));
930 Serial.print(F(
" 6 -Bulk Read NVM (EEPROM)\n"));
931 Serial.print(F(
" 7 -Bulk Write NVM (EEPROM)\n"));
932 Serial.print(F(
" 8 -Store (STORE_USER_ALL)\n"));
933 Serial.print(F(
" 9 -Clear/Erase Fault Logs (EEPROM)\n"));
934 Serial.print(F(
" 10 -Clear Faults (RAM)\n"));
935 Serial.print(F(
" 11 -Bus Probe\n"));
936 Serial.print(F(
" 12 -Reset (Will Power Cycle)\n"));
937 Serial.print(F(
"\nEnter a command:"));
static float readItemp(uint8_t address)
uint8_t readByte(uint8_t address, uint8_t command)
SMBus read byte command.
static void print_prompt()
Prints main menu.
unsigned char user_command
static void nvm_lock_reset(uint8_t address)
LTC SMBus Support: API for a shared SMBus layer.
int8_t readByteData(uint8_t address, uint8_t command, uint8_t *value)
Read a byte of data at register specified by "command", store in "value".
#define LTC2974_I2C_ADDRESS
LTC SMBus Support: Implementation for a shared SMBus layer.
LTC SMBus Support: Implementation for a shared SMBus layer.
uint8_t * probe(uint8_t command)
SMBus bus probe.
String status(void)
Returns a descriptive string based on status of pins.
static void write_bytes(uint8_t address, uint16_t **data, uint16_t *count)
Header File for Linduino Libraries and Demo Code.
bool check_nvm_data_checksum(uint8_t address)
bool is_ltc2977(uint8_t address)
bool pecEnabled(void)
Check if PEC is enabled.
void beginStoring()
Group Protocol Begin.
void execute()
Group Protocol Execute queued commands.
void writeByte(uint8_t address, uint8_t command, uint8_t data)
SMBus write byte command.
#define STATUS_CML_MEM_FAULT
float lin11_to_float(lin11_t xin)
static void read_bytes(uint8_t address, uint16_t **data, uint16_t *count)
#define MFR_FAULT_LOG_CLEAR
#define STATUS_MFR_SPECIFIC_NVM_CRC
static void wait_for_ready(uint8_t address)
static uint8_t wait_for_nvm_done(uint8_t address)
static void increment_counter(uint8_t address)
union LT_union_int32_4bytes data
bool check_health(uint8_t address)
#define READ_ITEMP_2977_8
static void clear_faults_global(void)
bool checkCRC(uint8_t *data)
Check CRC of block data organized as 31 data bytes plus CRC.
static void erase(uint8_t address, uint16_t **data)
void writeWord(uint8_t address, uint8_t command, uint16_t data)
SMBus write word command.
static void print_title()
Prints the title block when program first starts.
#define LTC3880_I2C_ADDRESS
#define STATUS_WORD_POWER_GOOD_B
static uint16_t ltc2974dataCount
static void store_fault_logs()
static void print_counter(uint8_t address)
static void lock_nvm(uint8_t address)
#define MFR_EEPROM_STATUS
static uint16_t * ltc2974data
uint16_t readWord(uint8_t address, uint8_t command)
SMBus read word command.
static void clear_fault_logs()
static float readItemp2977_8(uint8_t address)
void sendByte(uint8_t address, uint8_t command)
SMBus send byte command.
LTC SMBus Support: Implementation for a shared SMBus layer.
static uint16_t * ltc2977data
static uint16_t ltc3880dataCount
static uint16_t ltc2977dataCount
bool is_ltc297x(uint8_t address)
static void print_all_status()
Print all status bytes and words.
static uint16_t * ltc3880data
#define MFR_FAULT_LOG_STORE
bool is_ltc2978(uint8_t address)
static uint8_t wait_for_ack(uint8_t address, uint8_t command)
#define LTC2977_8_I2C_ADDRESS
#define STATUS_MFR_SPECIFIC
LTC PMBus Support: Math conversion routines.
static uint8_t wait_for_not_busy(uint8_t address)
static void unlock_nvm(uint8_t address)