/* --------------------------------------------------------------------------- * Header file of declarations and macro definitions * for timlet AND timrun. * * Author : J.B.Lane UCL September 2000 timlet.h * --------------------------------------------------------------------------- */ #ifndef TIMLET_H #define TIMLET_H /* Definitions */ #include "generated_tim_constants.h" #define TIM_RAM_SIZE 0x4000 #define TIMID_FPGA 0x20 #define TIM_CMD_SIZE 100 /* 37 too small, 50 too small by 1 */ #define FPGA1_RAM_SIZE 0x400 /* 1K 16-bit words */ #define GET_BCID( iL1A, iBCR, offset ) ((iL1A) - (iBCR) - (offset)) typedef long INT32 ; typedef unsigned long UINT32 ; typedef unsigned short UINT16 ; typedef enum{false, true} bool; /* NB Pixels */ enum SCTdead {L1Adead = 3, ECRdead = 7, BCRdead = 7, CALdead = 27, SCToffset = 6} ; /* 7 for Jon */ enum bits { L1A = 0x01, ECR = 0x02, BCR = 0x04, CAL = 0x08, SID = 0x10, STT = 0x20, CMD = 0xCF, RES = 0xC0, FER = 0x40, SPA = 0x80, TRG = 0x31, VTRG = 0x02, VECR = 0x04, VBCR = 0x08, VCAL = 0x10, VFER = 0x20, VSPA = 0x40 } ; enum name {NONE = -999} ; enum flags { /* For timReset etc: */ Loud = 3, Quiet = 2, Silent = 1, Quick = 0, /* For CheckID(outmask,) parameter: */ PresetNextL1ID = 0 /* NB avoid clash with output bits */ } ; enum clock { TTC, External, Internal, Standalone } ; /* Register */ enum bit { EnTTCClk = 0x0001, /* reg_EnTTC */ EnIntBusy = 0x0080, /* reg_enables */ /* EnIntCLK = 0x0001, */ RunMode = 0x1000, SeqBUSY = 0x0020, SinkBUSY = 0x0040, TTCclkON = 0x0100, SAclkON = 0x0200, TIM_OK = 0x2000, EnCLK = 0x0001, TTCready = 0x4000, VMEreset = 0x8000, IntBusy = 0x0004, EnID = 0x0200, EnTType = 0x0400 }; /* Declare external variables */ int debug_level ; int timVersion ; int timID ; unsigned int TIM_FIRST_L1ID ; bool isTIM3; bool TTCrx_ready; bool ttcRQ_present; bool QPLL_lockable; bool Disable_FFTV; int register_words; /*** added to reduce testing of n registers on TIM2 */ /* Declare some more variables */ volatile unsigned short *memory_ptr ; volatile unsigned short *reg ; /*** Same value as memory_ptr, but shorter name */ volatile unsigned int *reg32 ; /* must be used with REGVAL/2 */ volatile unsigned short *ram_ptr ; volatile unsigned short *reg_srcAddr, *reg_snkAddr, *reg_enables, *reg_command, *reg_burst, *reg_freqncy, *reg_window, *reg_delays, *reg_status, *reg_FIFO, *reg_L1lo, *reg_L1hi, *reg_BCid, *reg_TTid, *reg_EnRun, *reg_sequenc, *reg_seq_end, *reg_RODmask, *reg_RODbusy, *reg_RODheld, *reg_RODmoni, *reg_TTCdata, *reg_TTCsel, *reg_BCin, *reg_TTCrx, *reg_TTCcmd, *reg_output, *reg_TIMid ; /* Stuff for timrun and other TTCvi programs */ /* ----------------------------------------- */ #define VME_BASE_TTC 0xBAD000 /* Gordon used FF1000 */ #define TTC_FIRST_L1ID 0 #define I2C_GO 0xC000 #define I2C_BUSY 0x8000 #define I2C_ABORT 0x4000 /* T3 */ #define I2C_ENABLE 0x4000 /* T2 */ #define I2C_READ 0x2000 #define I2C_WRITE 0x0000 unsigned short *ttc_ptr ; volatile unsigned short *ttc_CSR1 ; volatile unsigned short *ttc_CSR2 ; volatile unsigned short *ttc_reset ; volatile unsigned short *ttc_trig ; volatile unsigned short *ttc_IDrst; volatile unsigned short *ttc_L1hi ; volatile unsigned short *ttc_L1lo ; volatile unsigned short *ttc_0mod ; volatile unsigned short *ttc_0del ; volatile unsigned short *ttc_0dur ; volatile unsigned short *ttc_Bgo0 ; volatile unsigned short *ttc_0cmd ; volatile unsigned short *ttc_ladd ; volatile unsigned short *ttc_long ; volatile unsigned short *ttc_acmd ; /* volatile UINT32 *ttc_Bda0 ; ***/ volatile unsigned short *ttc_trigword_hi ; volatile unsigned short *ttc_trigword_lo ; /* ---------------------------------------- */ /* Prototypes */ #ifdef __cplusplus extern "C" { #endif void profile_tim (void); int test_loop (char *, int (*test_func)(const int), int, int, int) ; int test_sink (unsigned int *, const int, const int) ; int test_block (volatile unsigned short *, unsigned int *, const int, const int, const int, const unsigned short(*)) ; int timCheck (const char *, const int, const int) ; void timDump (const int, const int) ; int timGetL1ID (const int, const int) ; int timGetTIMid (void) ; void timReset (const int) ; void timRunSeq (const int) ; void timSetupPtr (void) ; void timSetupRun (void) ; void timSetupSeq (const int, const int) ; void timSetupVME (void) ; int timSwitchClk(const int) ; void ttcviSetupPtr(void); int check_clk (void) ; int check_TTCclk (void) ; int checkBCID (const int, const int) ; int checkID (const int, const int) ; int checkL1ID (const int, const int) ; int checkSink (const int, const int, int *) ; int convHz2Clk (const double) ; double convClk2Hz (const double) ; double convClk2Sec (const int) ; void dump16 (char *, volatile const unsigned short *, const int) ; void report_errors (char *, int) ; void timWait_seqBusys (void) ; void wait (void) ; void wait_secs (const int); int wait_state_timeout (const int, const int, const int, const int) ; int timTTCrxAccess(const int, const int, int *) ; #ifdef __cplusplus } #endif #endif