?? openingasinglecard.c
字號:
// Opening Cards Demo
// This is a simple program to show how to loacte and open a card.
//
/*
** $Id$
*/
//Note that in this project settings dimesdl.lib is included.
//dimesdl.h is required to gain access to the FUSE API functions.
//dimesdl.h and dimesdl.lib can both be found in the FUSE\include directory.
#include "dimesdl.h"
#include "vidime.h"
#include <stdio.h>
DWORD ModuleNumber=0; //THIS NUMBER NEEDS TO BE CHANGED TO THE DESIRED MODULE NUMBER.
DWORD PrimaryFPGADeviceNum=1; //THIS NUMBER NEEDS TO BE CHANGED TO THE MODULE DEVICE NUMBER.
DWORD SecondaryFPGADeviceNum=0; //THIS NUMBER NEEDS TO BE CHANGED TO THE MODULE DEVICE NUMBER.
char Filename1[]="host_interface.bit";
char Filename2[]="osc_clock_2v80.bit";
int main(int argc, char* argv[])
{
LOCATE_HANDLE hLocate = NULL;
DWORD ErrorNum,NumOfCards,LoopCntr,LEDs;
char ErrorString[1000];
DIME_HANDLE hCard1;
double ActualFrequency;
VIDIME_HANDLE viHandle;
DWORD Result=0;
DWORD j=0;
DWORD ReadData[2048];
DWORD WriteData[2048];
for(j=0;j<2048;j++)
{
WriteData[j]=j+1;
ReadData[j]=0;
}
printf("BIST Embedded Test - Test!\n\n");
//Call the function to locate all Nallatech cards on the PCI interface.
if( (hLocate = DIME_LocateCard(dlPCI,mbtALL,NULL,dldrDEFAULT,dlDEFAULT)) == NULL)
{//Error hLocate NULL
//Print the error then terminate the program
DIME_GetError(NULL,&ErrorNum,ErrorString);
printf("Error Number %d\n", ErrorNum);
printf("%s\n",ErrorString);
exit(1);
}
//Determine how many Nallatech cards have been found.
NumOfCards = DIME_LocateStatus(hLocate,0,dlNUMCARDS);
printf("%d Nallatech card(s) found.\n", NumOfCards);
//Get the details for each card detected.
for (LoopCntr=1; LoopCntr<=NumOfCards; LoopCntr++)
{
printf("Details of card number %d, of %d:\n",LoopCntr,NumOfCards);
printf("\tThe card driver for this card is a %s.\n",(char*)DIME_LocateStatusPtr(hLocate,LoopCntr,dlDESCRIPTION));
printf("\tThe cards motherboard type is %d.\n",DIME_LocateStatus(hLocate,LoopCntr,dlMBTYPE));
}
//At this stage we now have all the information we need to open a card up.
//Open up the first card found. To open the nth card found simple change the second argument to n.
hCard1 = DIME_OpenCard(hLocate,1,dccOPEN_NO_OSCILLATOR_SETUP); //opens up card 1 with default flags
if (hCard1 == NULL) //check to see if the open worked.
{
printf("Card Number One failed to open.\n");
DIME_CloseLocate(hLocate);
printf ("\nPress return to terminate the application.\n");
getchar();
return(1);
}
//Change the LEDs
LEDs = DIME_ReadLEDs(hCard1);
DIME_WriteLEDs(hCard1, (LEDs - 1));
printf("LEDs now changed on the card.\n");
//Enable the resets
// Reset the circuit and clear the PCI FIFOs for the card
DIME_CardResetControl(hCard1,drONBOARDFPGA, drENABLE,0);
DIME_CardResetControl(hCard1,drSYSTEM, drENABLE,0);
DIME_CardResetControl(hCard1,drINTERFACE, drTOGGLE,0);
//Set the clocks
DIME_SetOscillatorFrequency(hCard1,1,80.000,&ActualFrequency);
printf("ClkA: Actual frequency is %f.\n",ActualFrequency);
DIME_SetOscillatorFrequency(hCard1,2,40.000,&ActualFrequency);
printf("ClkB: Actual frequency is %f.\n",ActualFrequency);
DIME_SetOscillatorFrequency(hCard1,3,50.000,&ActualFrequency);
printf("ClkB: Actual frequency is %f.\n",ActualFrequency);
//Configure the FPGAs
//Now configure the modules primiary FPGA with the bif file.
DIME_ConfigDevice(hCard1,Filename2,ModuleNumber,SecondaryFPGADeviceNum,0,0);
//Now configure the modules primiary FPGA with the bif file.
DIME_ConfigDevice(hCard1,Filename1,ModuleNumber,PrimaryFPGADeviceNum,0,0);
//Disable the resets
DIME_CardResetControl(hCard1,drONBOARDFPGA, drDISABLE,0);
DIME_CardResetControl(hCard1,drSYSTEM, drDISABLE,0);
Sleep(500);
//Enable the resets
DIME_CardResetControl(hCard1,drONBOARDFPGA, drENABLE,0);
DIME_CardResetControl(hCard1,drSYSTEM, drENABLE,0);
DIME_CardResetControl(hCard1,drINTERFACE, drTOGGLE,0);
Sleep(500);
//Disable the resets
DIME_CardResetControl(hCard1,drONBOARDFPGA, drDISABLE,0);
DIME_CardResetControl(hCard1,drSYSTEM, drDISABLE,0);
Sleep(500); //Give it a couple second for the embedded proc to sort out the DIMETalk network i.e. reset control etc.
//Open the handle to vidime
viHandle = viDIME_Open(hCard1, 0);
Result = viDIME_DMAWrite(viHandle,WriteData,256,0, NULL, NULL, 5000);
Result = viDIME_DMARead(viHandle,ReadData,256,0, NULL, NULL, 5000);
//Close the card
viDIME_Close(viHandle);
DIME_CloseCard(hCard1);//Closes down the card.
//Finally the last thing that should be done is to close down the locate.
DIME_CloseLocate(hLocate);
printf ("\nPress return to terminate the application.\n");
getchar();
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -