// SPI_MasterBurst.cpp : Defines the entry point for the console application. // #include #include #include #include "stdafx.h" extern "C" { #include "SPIIC.h" } int _tmain(int argc, _TCHAR* argv[]) { // // Go to the work directory // printf("\nGoing to the work directory...\n"); #ifdef _DEBUG _chdir("..\\debug"); #else _chdir("..\\release"); #endif; // // Open library // printf("Opening the SPIIC library...\n"); spi_SPIIC(); // // Read configuration // printf("Reading configuration and data file...\n"); spi_ReadConfFile("..\\cfg_files\\spi_simple.cfg", true); // // Initialising burst transfer // printf("Initialising burst transfer...\n"); spi_InitBurst(); // // Preparing tripple burst transfer // printf("Preparing tripple burst transfer...\n"); int DataOut[3]; int DataIn[3]; for (int i=0; i<3; i++) { DataOut[i] = 0x1000000 + i; DataIn[i] = 0; spi_ShiftWrAndRdBurst(32, (char *)&DataOut[i], (char *)&DataIn[i], true); } // // Executing burst // printf("Executing burst...\n"); spi_SendBurst(true); // // Received data // printf("Received data:\n"); for (int i=0; i<3; i++) { printf("\tDataIn[%d] : 0x%08x\n", i, DataIn[i]); } // // Close the library // spi_Terminate(); // // Wait for user input to close the window // printf("Press any key...\n", 1); int ch = _getch(); return 0; }