sram_interface.c

来自「he Software folder contains the followin」· C语言 代码 · 共 83 行

C
83
字号
#include"c:\Plx\PciSdk\Win32\Samples\Common\ConsFunc.h"
#include"c:\Plx\PciSdk\Win32\Samples\Common\PlxInit.h"
#include<stdio.h>
#include<conio.h>
#include<string.h>

int Initialize_pci();
int Close_pci();
int WriteFPGAControlWord(unsigned long cntrl_word,unsigned long address);
int WriteFPGA(unsigned long data);
unsigned long ReadFPGA();
unsigned long FileToMemory(int sram_status,unsigned long initial_address);
unsigned long MemoryToFile(int sram_status,unsigned long initial_address);
long ApplyHexFormat(void);

/*************************************************************/	

//               Definitions
/**********************************************/
#define SIZE_BUFFER         0x100           // Number of bytes to transfer
//*********************************************

	//==============================
	// all variable declerations
   
    S8              DeviceSelected;
    HANDLE          hDevice;
    RETURN_CODE     rc;
    DEVICE_LOCATION Device;
 	RETURN_CODE		wc;				// write code return
	VIRTUAL_ADDRESSES Va;
	U32				PlxChipBase;
	U32				size;
	U32				PciBarNum;
	U16				regvalue;
	U32				buffer[0x5];	// write buffer of 40 data long word
	U32				data;			// data to be write
	U32				temp_add;		// temporary adress
	int		i;
	long int		dly;
//================================
// For the interrupt
	DWORD			EventStatus;
	PLX_INTR		PlxIntr;
	HANDLE			*pINTAEvent;
	PLX_INTR		IntSources;
	RETURN_CODE		tc;

    FILE *fc;
struct SRAM
{
    char inputfilename[50];
	char outputfilename[50];
}ob1;
	
int delay()
{
	for(i=0;i<1000;i++);
}
int Initialize_pci()
{
    DeviceSelected = SelectDevice( &Device );
    if (DeviceSelected == -1)
    {
        ConsoleEnd();
        exit(0);
    }
    rc = PlxPciDeviceOpen( &Device, &hDevice );
    if (rc != ApiSuccess)
    {
       exit(-1);
    } 
	PlxPciBoardReset( hDevice );
	for (PciBarNum = 0; PciBarNum < 6; PciBarNum++)
	{
		rc = PlxPciBarRangeGet(
							hDevice,
							PciBarNum,
							&size
							);
		if (rc != ApiSuccess)
		{
			// ERROR 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?