/**************************************************** * RFControlBoard_requiredInterface.h * * Header file for the required interface for RFControlBoard * All platform dependent code will be realized here. Please note that * EPICS will be also viewed as a platform for the software * * Created by: Zheqiao Geng, gengzq@slac.stanford.edu * Created on: 2011.04.12 * Description: Initial creation * * Modified by: Zheqiao Geng * Modified on: 2011.07.05 * Description: Define function pointers for hardware access, so that the design * can be adpated to different board and driver versions * To introduce new board or new drivers * 1. define the functions here for the new board/driver * 2. implement the functions in a new .c file * 3. modify the RFControlBoard_availableInterface.c/RFCB_API_setupModule to allow the user to * assign your function to the virtual function pointers * * Modified by: Zheqiao Geng * Modified on: 2011.07.08 * Description: Use the EPICSLib in the LLRFLibs instead of the EPICS things here * * Modified by: Zheqiao Geng * Modified on: 2/26/2013 * Description: Update the function realization to fit with the eicsys firmware and software ****************************************************/ #ifndef RF_CONTROL_BOARD_REQUIRED_INTERFACE_H #define RF_CONTROL_BOARD_REQUIRED_INTERFACE_H #include #include #include #include #ifdef __cplusplus extern "C" { #endif /** * Access of the hardware (reading/writing the registers/buffers) * Here we use function pointers to pretend to be the virtual functions in C++ ... */ /* Function pointers - common functions */ typedef int (*RFCB_FUNCPTR_OPEN)(const char*); typedef void (*RFCB_FUNCPTR_CLOSE)(int); typedef void (*RFCB_FUNCPTR_READREG)(int, unsigned int, unsigned int*); typedef void (*RFCB_FUNCPTR_WRITEREG)(int, unsigned int, unsigned int); typedef void (*RFCB_FUNCPTR_READBUF)(int, unsigned int, unsigned int, unsigned int*); typedef void (*RFCB_FUNCPTR_WRITEBUF)(int, unsigned int, unsigned int, unsigned int*); typedef int (*RFCB_FUNCPTR_CONFIGFPGA)(int, const char*); typedef int (*RFCB_FUNCPTR_PULLINT)(int); /* Function pointers - Functions only used by eicsys driver */ typedef void* (*RFCB_FUNCPTR_MAPDMADATAPOOL)(int); typedef void (*RFCB_FUNCPTR_UMMAPDMADATAPOOL)(int, void *); typedef int (*RFCB_FUNCPTR_SETDMAPARAM)(int, unsigned int, unsigned int); typedef int (*RFCB_FUNCPTR_GETDMAPARAM)(int, unsigned int *); /* Structure of the functions */ typedef struct { RFCB_FUNCPTR_OPEN RFCB_func_open; RFCB_FUNCPTR_CLOSE RFCB_func_close; RFCB_FUNCPTR_READREG RFCB_func_readReg; RFCB_FUNCPTR_WRITEREG RFCB_func_writeReg; RFCB_FUNCPTR_READBUF RFCB_func_readBuf; RFCB_FUNCPTR_WRITEBUF RFCB_func_writeBuf; RFCB_FUNCPTR_CONFIGFPGA RFCB_func_configFPGA; RFCB_FUNCPTR_PULLINT RFCB_func_pullInt; RFCB_FUNCPTR_MAPDMADATAPOOL RFCB_func_mapDMADataPool; RFCB_FUNCPTR_UMMAPDMADATAPOOL RFCB_func_unMapDMADataPool; RFCB_FUNCPTR_SETDMAPARAM RFCB_func_setDMAParam; RFCB_FUNCPTR_GETDMAPARAM RFCB_func_getDMAParam; } RFCB_struc_hwAccessFunc; /** * Functions for Struck SIS8300 board, EICSYS driver * They are implemented in the file of "RFControlBoard_requiredInterface_sis8300_eicsys.c" */ #define RFCB_EICSYS_CONST_DMA_POOL_SIZE 4194304 /* 4MByte */ #define RFCB_EICSYS_CONST_DMA_PAGE_SIZE 4096 /* 4096 Byte */ int RFCB_func_open_sis8300_eicsys(const char* deviceName); void RFCB_func_close_sis8300_eicsys(int fp); __inline__ void RFCB_func_readReg_sis8300_eicsys(int fp, unsigned int addr, unsigned int *data); /* REAL-TIME */ __inline__ void RFCB_func_writeReg_sis8300_eicsys(int fp, unsigned int addr, unsigned int data); /* REAL-TIME */ __inline__ void RFCB_func_readBuf_sis8300_eicsys(int fp, unsigned int addr, unsigned int pno, unsigned int *data); /* REAL-TIME */ __inline__ void RFCB_func_writeBuf_sis8300_eicsys(int fp, unsigned int addr, unsigned int pno, unsigned int *data); /* REAL-TIME */ int RFCB_func_configFPGA_sis8300_eicsys(int fp, const char *firmwareFileName); __inline__ int RFCB_func_pullInt_sis8300_eicsys(int fp); /* Pull the interrupt of the board */ void* RFCB_func_mapDMADataPool_eicsys(int fp); /* Map the local pointer to kernel DMA buffer */ void RFCB_func_unMapDMADataPool_eicsys(int, void *ptr); int RFCB_func_setDMAParam_eicsys(int fp, unsigned int offset, unsigned int size); /* set the DMA offset and DMA size */ int RFCB_func_getDMAParam_eicsys(int fp, unsigned int *size); /* get the DMA size */ /** * Functions for Struck SIS8300 board, Struck driver * They are implemented in the file of "RFControlBoard_requiredInterface_sis8300_struck.c" */ int RFCB_func_open_sis8300_struck(const char* deviceName); void RFCB_func_close_sis8300_struck(int fp); __inline__ void RFCB_func_readReg_sis8300_struck(int fp, unsigned int addr, unsigned int *data); /* REAL-TIME */ __inline__ void RFCB_func_writeReg_sis8300_struck(int fp, unsigned int addr, unsigned int data); /* REAL-TIME */ __inline__ void RFCB_func_readBuf_sis8300_struck(int fp, unsigned int addr, unsigned int pno, unsigned int *data); /* REAL-TIME */ __inline__ void RFCB_func_writeBuf_sis8300_struck(int fp, unsigned int addr, unsigned int pno, unsigned int *data); /* REAL-TIME */ int RFCB_func_configFPGA_sis8300_struck(int fp, const char *firmwareFileName); __inline__ int RFCB_func_pullInt_sis8300_struck(int fp); /* Pull the interrupt of the board */ #ifdef __cplusplus } #endif #endif