Jingrui wu

Jingrui wu

  • NA
  • 1
  • 0

C++ dll to C# using invoke

Jun 23 2009 11:31 PM

i need to change TERASIC_API.dll , TERASIC_API.h  to C# using Invoke or other ?
all the in TERASIC_API.h to C# window form app ?

 #ifndef _INC_TERASIC_API_H
#define _INC_TERASIC_API_H

#include <windows.h>

#ifdef __cplusplus
extern "C"{
#endif


#define TERASIC_API FAR PASCAL
typedef void *FPGA_BOARD;
typedef DWORD FPGA_REG_ADDRESS;
typedef DWORD FPGA_DDR2_PORT_ID;
//typedef DWORD FPGA_MEM_ADDRESS;
//typedef DWORD FPGA_PORT_ADDRESS;
typedef DWORD FPGA_REG_TYPE;
typedef void (TERASIC_API *FPGA_ISR)(void);

//================================================================================
// function prototype used for "static load DLL"
// system
BOOL TERASIC_API SYS_BoardNum(WORD wVendorID, WORD wDeviceID, WORD *pwBoardNum);
BOOL TERASIC_API SYS_GetDLLVersion(DWORD *pdwVersion);

// connection
BOOL TERASIC_API FPGA_Connect(FPGA_BOARD *phFPGA, WORD wVendorID, WORD wDeviceID, WORD wBoardIndex);
BOOL TERASIC_API FPGA_IsReady(FPGA_BOARD hFPGA);
BOOL TERASIC_API FPGA_GetFPGAVersion(FPGA_BOARD hFPGA, DWORD *pdwVersion);
BOOL TERASIC_API FPGA_Disconnect(FPGA_BOARD hFPGA);

// register access
BOOL TERASIC_API FPGA_RegRead (FPGA_BOARD hFPGA, FPGA_REG_ADDRESS RegAddr, FPGA_REG_TYPE *pRegValue);
BOOL TERASIC_API FPGA_RegWrite (FPGA_BOARD hFPGA, FPGA_REG_ADDRESS RegAddr, FPGA_REG_TYPE RegValue);
//BOOL TERASIC_API FPGA_MemDmaRead (FPGA_BOARD hFPGA, FPGA_MEM_ADDRESS MemAddr, void *pBuffer, DWORD dwBufSize);
//BOOL TERASIC_API FPGA_MemDmaWrite (FPGA_BOARD hFPGA, FPGA_MEM_ADDRESS MemAddr, void *pData, DWORD dwDataSize);

// fifo access
BOOL TERASIC_API FPGA_FifoDmaRead (FPGA_BOARD hFPGA, FPGA_DDR2_PORT_ID DDR2PortID, void *pBuffer, DWORD dwBufSize);
BOOL TERASIC_API FPGA_FifoDmaWrite (FPGA_BOARD hFPGA, FPGA_DDR2_PORT_ID DDR2PortID, void *pData, DWORD dwDataSize);
BOOL TERASIC_API FPGA_PortReset(FPGA_BOARD hFPGA, FPGA_DDR2_PORT_ID DDR2PortID);
BOOL TERASIC_API FPGA_PortFlush(FPGA_BOARD hFPGA, FPGA_DDR2_PORT_ID DDR2PortID);

// interrupt
BOOL TERASIC_API FPGA_RegisterISR(FPGA_BOARD hFPGA, FPGA_ISR ISR_Function);
// tick-count
BOOL TERASIC_API FPGA_GetTickCount(FPGA_BOARD hFPGA, DWORD *pdwTickCount);

// bridge
BOOL TERASIC_API FPGA_BridgeReset(FPGA_BOARD hFPGA);
BOOL TERASIC_API FPGA_GetBridgeVersion(FPGA_BOARD hFPGA, DWORD *pdwVersion);

//================================================================================
// function prototype used for "dynamic load DLL"
typedef BOOL (TERASIC_API *LPSYS_BoardNum)(WORD wVendorID, WORD wDeviceID, WORD *pwBoardNum);
typedef BOOL (TERASIC_API *LPSYS_GetDLLVersion)(DWORD *pdwVersion);

typedef BOOL (TERASIC_API *LPFPGA_Connect)(FPGA_BOARD *phFPGA, WORD wVendorID, WORD wDeviceID, WORD wBoardIndex);
typedef BOOL (TERASIC_API *LPFPGA_IsReady)(FPGA_BOARD hFPGA);
typedef BOOL (TERASIC_API *LPFPGA_GetFPGAVersion) (FPGA_BOARD hFPGA, DWORD *pdwVersion);
typedef BOOL (TERASIC_API *LPFPGA_Disconnect)(FPGA_BOARD hFPGA);

typedef BOOL (TERASIC_API *LPFPGA_RegRead)(FPGA_BOARD hFPGA, FPGA_REG_ADDRESS RegAddr, FPGA_REG_TYPE *pRegValue);
typedef BOOL (TERASIC_API *LPFPGA_RegWrite)(FPGA_BOARD hFPGA, FPGA_REG_ADDRESS RegAddr, FPGA_REG_TYPE RegValue);
//typedef BOOL (TERASIC_API *LPFPGA_MemDmaRead)(FPGA_BOARD hFPGA, FPGA_MEM_ADDRESS MemAddr, void *pBuffer, DWORD dwBufSize);
//typedef BOOL (TERASIC_API *LPFPGA_MemDmaWrite) (FPGA_BOARD hFPGA, FPGA_MEM_ADDRESS MemAddr, void *pData, DWORD dwDataSize);

typedef BOOL (TERASIC_API *LPFPGA_FifoDmaRead) (FPGA_BOARD hFPGA, FPGA_DDR2_PORT_ID DDR2PortID, void *pBuffer, DWORD dwBufSize);
typedef BOOL (TERASIC_API *LPFPGA_FifoDmaWrite) (FPGA_BOARD hFPGA, FPGA_DDR2_PORT_ID DDR2PortID, void *pData, DWORD dwDataSize);
typedef BOOL (TERASIC_API *LPFPGA_PortReset) (FPGA_BOARD hFPGA, FPGA_DDR2_PORT_ID DDR2PortID);
typedef BOOL (TERASIC_API *LPFPGA_PortFlush) (FPGA_BOARD hFPGA, FPGA_DDR2_PORT_ID DDR2PortID);
typedef BOOL (TERASIC_API *LPFPGA_RegisterISR) (FPGA_BOARD hFPGA, FPGA_ISR ISR_Function);

typedef BOOL (TERASIC_API *LPFPGA_BridgeReset)(FPGA_BOARD hFPGA);
typedef BOOL (TERASIC_API *LPFPGA_GetBridgeVersion) (FPGA_BOARD hFPGA, DWORD *pdwVersion);
typedef BOOL (TERASIC_API *LPFPGA_GetTickCount) (FPGA_BOARD hFPGA, DWORD *pdwTickCount);


#ifdef __cplusplus
}
#endif



#endif /* _INC_TERASIC_API_H */




thk thk thk anyone