/**************************************************** * RFControlBoard_main.h * * Header file for the RFControlBoard module * This module will be adaptable to the Struck SIS8300 board and the vadatech board * * Extra requriements for the module of RFControlBoard * 1. This module should be adaptable to different implementation of the firmware. * 2. This module should be adaptable to both SIS8300 board and the future Vadatech board * * Some naming conventions used in this module: * 1. All items for this module will have a head of "RFCB_" for RF Control Board ... * 2. All new data types will be markd by "_type_" * 3. All data structures will be marked by "_struc_" * 4. All global variables will be marked by "_gvar_" * 5. All global buffers will be marked by "_gbuf_" * 6. All API functions will be marked by "_API_" * * 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: Use the virtual function to access the hardware * * Modified by: Zheqiao Geng * Modified on: 2/26/2013 * Description: Extend the data definition to fit into the EICSYS firmware ****************************************************/ #ifndef RF_CONTROL_BOARD_H #define RF_CONTROL_BOARD_H #include "EPICSLib_wrapper.h" #include "RFControlBoard_requiredInterface.h" #define RFCB_CONST_MAX_DEV_NUM 3 /* the devices in /dev used by this module, especially for eicsys */ #ifdef __cplusplus extern "C" { #endif /** * Define the enum for devices */ typedef enum { RFCB_DEV_SYS = 0, RFCB_DEV_USR = 1, RFCB_DEV_DMA = 2 } RFCB_enum_devSpace; /** * Data structure for the RF Control Board module */ typedef struct { EPICSLIB_type_linkedListNode node; /* to fit this structure to linked list */ /* --- strings --- */ char moduleName[EPICSLIB_CONST_NAME_LEN]; /* name of the module instance */ char deviceName[RFCB_CONST_MAX_DEV_NUM][EPICSLIB_CONST_NAME_LEN]; /* name of the device shown in the '/dev' folder */ char firmwareFileName[EPICSLIB_CONST_PATH_LEN]; /* full path for firmware file name */ /* --- flags --- */ int deviceOpened[RFCB_CONST_MAX_DEV_NUM]; /* 1 means the device already opened */ int mutexCreated; /* 1 means the local mutex already created */ int firmwareOK; /* 1 means the firmware is OK */ /* --- private data --- */ int deviceFp[RFCB_CONST_MAX_DEV_NUM]; /* device descripter for system purpose */ void *DMADataPool; /* pointer to the DMA data pool (only for eicsys driver) */ EPICSLIB_type_mutexId localMutex; /* mutex for this board */ /* --- hardware access functions --- */ RFCB_struc_hwAccessFunc hwFunc; } RFCB_struc_moduleData; /** * Routines for the RF Control Board module */ int RFCB_func_createModule(RFCB_struc_moduleData *arg, const char *moduleName); /* create an instance of this module,INIT ALL PARAMETERS! */ int RFCB_func_destroyModule(RFCB_struc_moduleData *arg); /* destroy the instance */ int RFCB_func_setDeviceName(RFCB_struc_moduleData *arg, const char *deviceName, RFCB_enum_devSpace dev); /* device name shown in /dev folder */ int RFCB_func_setFirmwareFile(RFCB_struc_moduleData *arg, const char *firmwareFileName); /* set the firmware file for the FPGA */ void RFCB_func_openBoard(RFCB_struc_moduleData *arg, const char *deviceName, RFCB_enum_devSpace dev); void RFCB_func_closeBoard(RFCB_struc_moduleData *arg, RFCB_enum_devSpace dev); void RFCB_func_readRegister(RFCB_struc_moduleData *arg, unsigned int addr, unsigned int *data, RFCB_enum_devSpace dev); /* REAL-TIME */ void RFCB_func_writeRegister(RFCB_struc_moduleData *arg, unsigned int addr, unsigned int data, RFCB_enum_devSpace dev); /* REAL-TIME */ void RFCB_func_readBuffer(RFCB_struc_moduleData *arg, unsigned int addr, unsigned int pno, unsigned int *data, RFCB_enum_devSpace dev); /* REAL-TIME */ void RFCB_func_writeBuffer(RFCB_struc_moduleData *arg, unsigned int addr, unsigned int pno, unsigned int *data, RFCB_enum_devSpace dev); /* REAL-TIME */ int RFCB_func_configureFPGA(RFCB_struc_moduleData *arg); int RFCB_func_pullInterrupt(RFCB_struc_moduleData *arg, RFCB_enum_devSpace dev); void RFCB_func_getModuleStatus(RFCB_struc_moduleData *arg, char *deviceName, int *deviceOpened, RFCB_enum_devSpace dev); int RFCB_func_setupDMA(RFCB_struc_moduleData *arg, unsigned int offset, unsigned int size); void* RFCB_func_getDMADataPoolPtr(RFCB_struc_moduleData *arg, unsigned int *DMADataPoolSize); #ifdef __cplusplus } #endif #endif