// I2C_Analyser.cpp : Defines the entry point for the console application. // #include #include #include #include #include "stdafx.h" // I2CC - Include the SPIIC DLL extern "C" { #include "I2CC.h" } int _tmain(int argc, _TCHAR* argv[]) { int ch; // // Go to the work directory // printf("\nGoing to the work directory...\n"); #ifdef _DEBUG _chdir("..\\debug"); #else _chdir("..\\release"); #endif; // // Initialise the I2C library // printf("\nInitialising the I2C library... "); i2c_I2CC(); printf("done\n"); // // Load configuration // printf("Load configuration...\n"); i2c_LoadConfig("..\\cfg_files\\i2c_Analyser.i2c"); // // Run the analyser // printf("Running...\n"); i2c_RunAnalyser(); // // Retrieve data // unsigned int Index = 0; unsigned int Cmd; unsigned int Address; unsigned int AddrType; unsigned int Length; char *pData = (char *)malloc(256); char STA; char STO; char Valid; while (i2c_CmdBufGet(Index, (unsigned int *)&Cmd, (unsigned int *)&Address, (unsigned int *)&AddrType, (unsigned int *)&Length, pData, (char *)&STA, (char *)&STO, (char *)&Valid) == 0) { printf("\nDecoded I2C transfer:\n"); printf("\tCmd : %s\n", Cmd == 1 ? "read" : "write"); printf("\tAddress : 0x%02x\n", Address); printf("\tAddressType : %d bit\n", (AddrType == 1) ? 7 : 10); printf("\tLength : %d\n", Length); printf("\tData : "); for (unsigned int i=0; i