#ifndef _PULSER_REGISTERS_H_ #define _PULSER_REGISTERS_H_ #include #include #include "jvme.h" #include "v1495.h" #define pulser_OK ( 0) #define pulser_ERROR (-1) #define PULSER_NUM (56) /* Total number of pulsers */ #define PULSER_TICK_PERIOD_NS (10) #define TRUE_PULSER_ID (0x50554C53) /* Daughter board IDs */ #define DAUGHTERBOARD_ID_A395A (0x0) #define DAUGHTERBOARD_ID_A395B (0x1) #define DAUGHTERBOARD_ID_A395C (0x2) #define DAUGHTERBOARD_ID_A395D (0x3) /* Pulser indexes */ #define PULSER_IDX_C(n) (0+n) #define PULSER_IDX_D(n) (31+n) #define PULSER_IDX_E(n) (39+n) #define PULSER_IDX_F(n) (47+n) /* Structure to hold the parameters for each individual pulser */ typedef struct { /* 0x0000-0x0003 */ unsigned int Period; /* 0x0004-0x0007 */ unsigned int Width; /* 0x0008-0x000B */ unsigned int NPulses; /* 0x000C-0x000F */ unsigned int Reserved0; } PulserPeriph; /* Register layout of the pulser program yb Ben Raydo */ typedef struct { // /* 0x0000-0x0FFF */ unsigned int Reserved0[(0x1000-0x0000)/4]; /* 0x1000-0x1003 */ unsigned int PulserId; /* Board Identification */ /* 0x1004-0x1007 */ unsigned int FirmwareRev; /* Firmware revision */ /* 0x1008-0x100B */ unsigned int DaughterBoardId; /* A395x board ID */ /* 0x100C-0x100F */ unsigned int Jumpers; /* Jumper Configuration */ /* 0x1010-0x1013 */ unsigned int PulserStatusH; /* Pulser Active Status High */ /* 0x1014-0x1017 */ unsigned int PulserStatusL; /* Pulser Active Status Low */ /* 0x1018-0x101B */ unsigned int PulserStartMaskH; /* Pulser Start Mask High */ /* 0x101C-0x101F */ unsigned int PulserStartMaskL; /* Pulser Start Mask Low */ /* 0x1020-0x1023 */ unsigned int PulserStopMaskH; /* Pulser Stop Mask High */ /* 0x1024-0x1027 */ unsigned int PulserStopMaskL; /* Pulser Stop Mask Low */ /* 0x1028-0x102B */ unsigned int PulserGinMaskH; /* Pulser GIN OR Mask High */ /* 0x102C-0x102F */ unsigned int PulserGinMaskL; /* Pulser GIN OR Mask Low */ /* 0x1030-0x1033 */ unsigned int PulserStartStop; /* Pulser Start/Stop */ /* 0x1034-0x10FF */ unsigned int Reserved1[(0x1100-0x1034)/4]; /* 0x1100-0x1103 */ unsigned int MasterOrDelay; /* Master OR Output Delay*/ /* 0x1104-0x1107 */ unsigned int MasterOrWidth; /* Pulser Pulse Width */ /* 0x1108-0x1FFF */ unsigned int Reserved2[(0x2000-0x1108)/4]; /* 0x2000-0x2xxx */ PulserPeriph Pulsers[PULSER_NUM]; /* Pulser Characteristics */ } pulser_REGS; /* Basic pulser function declarations are below */ /* In the functions below base address is the VME base address of the board */ /* not the local address */ int16_t pulser_getPulserId( char* baseAddr, uint32_t* val ); /* Board Identification */ int16_t pulser_getFirmwareRev( char* baseAddr, uint32_t* val ); /* Firmware revision */ int16_t pulser_getDaughterBoardId( char* baseAddr, uint32_t* val ); /* A395x board ID */ int16_t pulser_getJumpers( char* baseAddr, uint32_t* val ); /* Jumper Configuration */ int16_t pulser_getPulserStatusH( char* baseAddr, uint32_t* val ); /* Pulser Active Status High */ int16_t pulser_getPulserStatusL( char* baseAddr, uint32_t* val ); /* Pulser Active Status Low */ int16_t pulser_getPulserStartMaskH( char* baseAddr, uint32_t* val ); /* Pulser Start Mask High */ int16_t pulser_getPulserStartMaskL( char* baseAddr, uint32_t* val ); /* Pulser Start Mask Low */ int16_t pulser_getPulserStopMaskH( char* baseAddr, uint32_t* val ); /* Pulser Stop Mask High */ int16_t pulser_getPulserStopMaskL( char* baseAddr, uint32_t* val ); /* Pulser Stop Mask Low */ int16_t pulser_getPulserGinMaskH( char* baseAddr, uint32_t* val ); /* Pulser GIN OR Mask High */ int16_t pulser_getPulserGinMaskL( char* baseAddr, uint32_t* val ); /* Pulser GIN OR Mask Low */ int16_t pulser_getPulserStartStop( char* baseAddr, uint32_t* val ); /* Pulser Start/Stop */ int16_t pulser_getMasterOrDelay( char* baseAddr, uint32_t* val ); /* Master OR Output Delay*/ int16_t pulser_getMasterOrWidth( char* baseAddr, uint32_t* val ); /* Master OR Output Width*/ int16_t pulser_setPulserStartMaskH( char* baseAddr, uint32_t val ); /* Pulser Start Mask High */ int16_t pulser_setPulserStartMaskL( char* baseAddr, uint32_t val ); /* Pulser Start Mask Low */ int16_t pulser_setPulserStopMaskH( char* baseAddr, uint32_t val ); /* Pulser Stop Mask High */ int16_t pulser_setPulserStopMaskL( char* baseAddr, uint32_t val ); /* Pulser Stop Mask Low */ int16_t pulser_setPulserGinMaskH( char* baseAddr, uint32_t val ); /* Pulser GIN OR Mask High */ int16_t pulser_setPulserGinMaskL( char* baseAddr, uint32_t val ); /* Pulser GIN OR Mask Low */ int16_t pulser_setPulserStartStop( char* baseAddr, uint32_t val ); /* Pulser Start/Stop */ int16_t pulser_setMasterOrDelay( char* baseAddr, uint32_t val ); /* Master OR Output Delay*/ int16_t pulser_setMasterOrWidth( char* baseAddr, uint32_t val ); /* Master OR Output Width*/ /* The functions below are more complicated since the ordering of the registers are not * in terms unsigneds but in terms of structures */ int16_t pulser_getPeriod( char* baseAddr, unsigned chan, uint32_t* val ); /* Pulser Pulse Period */ int16_t pulser_getWidth( char* baseAddr, unsigned chan, uint32_t* val ); /* Pulser Pulse Width */ int16_t pulser_getNPulses( char* baseAddr, unsigned chan, uint32_t* val ); /* Pulser Pulser Pulse Count */ //int16_t pulser_getPulsers( char* baseAddr, unsigned chan, PulserPeriph* val ); /* Pulser Characteristics */ int16_t pulser_setPeriod( char* baseAddr, unsigned chan, uint32_t val ); /* Pulser Pulse Period */ int16_t pulser_setWidth( char* baseAddr, unsigned chan, uint32_t val ); /* Pulser Pulse Width */ int16_t pulser_setNPulses( char* baseAddr, unsigned chan, uint32_t val ); /* Pulser Pulser Pulse Count */ //int16_t pulser_setPulsers( char* baseAddr, unsigned chan, PulserPeriph* val ); /* Individual Pulser Characteristics */ /* Function to return the address of the pulser registers */ int16_t pulser_getRegs( char* baseAddr, pulser_REGS** regs ); /* Get the address of the registers */ #endif