SCT ROD configuration data structure and function calls: Version 0.7 ==================================================================== Revision History ================ 21 Feb 2000. JCH. Initial version. 22 Feb 2000. JCH. Version 0.1. Follow my own coding rules, add a few more comments. 22 Feb 2000. JCH. Version 0.2. Get the structure definitions right. 23 Feb 2000. JCH. Version 0.3. Need to know the SELECT setting for each module. 24 Feb 2000. JCH. Version 0.4. Minor tidying up. 25 Feb 2000. JCH. Version 0.5. Add a module mask. 25 Feb 2000. JCH. Version 0.6. Add initial ideas on function calls. 14 Apr 2000. JCH. Version 0.7. Reorganise the structures, so that the trim DACs are separated from the other registers - they change relatively rarely, so this might improve speed of access to the other items. =================================================================== #define N_RODS 16 #define N_MODULES 48 #define N_CHIPS 12 #define N_CHANS 128 /* The following typedefs are for clarity, and obviously may need to change depending on platform. */ typedef unsigned short UINT16; typedef unsigned int UINT32; /* structure definitions */ struct CONFIG { unsigned int readoutMode : 2; unsigned int calibMode : 2; unsigned int dataoutDelay : 1; /* 2 bits not used */ unsigned int testMode : 1; /* on ABCD */ unsigned int edgeDetect : 1; unsigned int mask : 1; unsigned int accumulate : 1; unsigned int inputBypass : 1; unsigned int outputBypass : 1; unsigned int master : 1; unsigned int end : 1; unsigned int feedThrough : 1; : 2; /*pad to 16 bits */ } ; struct THRESHCALIB { unsigned int calibAmp : 8; unsigned int threshold : 8; } ; struct BIAS { unsigned int shaper : 5; : 3; unsigned int input : 5; : 3; /*pad to 16 bits */ } ; /* Structures for a single chip. Trim DACs split off */ struct CHIPREG { UINT32 maskReg[4]; struct CONFIG configReg; struct THRESHCALIB threshCalibReg; struct BIAS biasReg; UINT16 strobeReg; } oneChipRegConfig; struct CHIPDAC { UINT16 trimDac[N_CHANS]; } oneChipDacConfig; /* Structures for a single module. Trim DACs separate from other items */ struct MODULEREG { struct CHIPREG chipRegConfig[N_CHIPS]; UINT16 select; /*are we using the redundancy? */ } oneModuleRegConfig; struct MODULEDAC { struct CHIPDAC chipDacConfig[N_CHIPS]; } oneModuleDacConfig; /* Single ROD structure */ struct ROD { UINT32 moduleMask[N_MODULES/4]; struct MODULEREG moduleRegConfig[N_MODULES]; struct MODULEDAC moduleDacConfig[N_MODULES]; } oneRodConfig; struct { struct ROD rodConfig[N_RODS]; } sctConfig; /* function definitions */ int sctConfigInit(UINT16 numRods); /*initialise the structure?*/ int sctConfigLoad(char *filename); /*fill the structure from data in a file*/ int sctConfigReadBiasReg(UINT16 rod, UINT16 module, UINT16 chip, UINT16 &value); /*read the bias register*/ int sctConfigReadConfigReg(UINT16 rod, UINT16 module, UINT16 chip, \ UINT16 &value); /*read the config register*/ int sctConfigReadMaskReg(UINT16 rod, UINT16 module, UINT16 chip, UINT16 &value); /*read the mask register*/ int sctConfigReadModuleMask(UINT16 rod, UINT32 &value[N_MODULES/4]); /*read the module mask*/ int sctConfigReadSelect(UINT16 rod, UINT16 module, UINT16 &value); /*read the value of select*/ int sctConfigReadStrobeReg(UINT16 rod, UINT16 module, UINT16 chip, \ UINT16 &value); /*read the strobe register*/ int sctConfigReadThreshCalibReg(UINT16 rod, UINT16 module, UINT16 chip, \ UINT16 &value); /*read the threshold/calibration register*/ int sctConfigReadTrimDac(UINT16 rod, UINT16 module, UINT16 chip, UINT16 dac, \ UINT16 &value); /*read a trim DAC*/ int sctConfigSetBiasReg(UINT16 rod, UINT16 module, UINT16 chip, UINT16 value); /*set the bias register*/ int sctConfigSetConfigReg(UINT16 rod, UINT16 module, UINT16 chip, UINT16 value); /*set the config register*/ int sctConfigSetMaskReg(UINT16 rod, UINT16 module, UINT16 chip, UINT16 value); /*set the mask register*/ int sctConfigSetModuleMask(UINT16 rod, UINT32 value[N_MODULES/4]); /*set the module mask*/ int sctConfigSetSelect(UINT16 rod, UINT16 module, UINT16 value); /*set the value of select*/ int sctConfigSetStrobeReg(UINT16 rod, UINT16 module, UINT16 chip, UINT16 value); /*set the strobe register*/ int sctConfigSetThreshCalibReg(UINT16 rod, UINT16 module, UINT16 chip, \ UINT16 value); /*set the threshold/calibration register*/ int sctConfigSetTrimDac(UINT16 rod, UINT16 module, UINT16 chip, UINT16 dac, \ UINT16 value); /*set a trim DAC*/ Notes ===== 1) Trim DACs are only 4 bits - we could save a lot of storage by more efficient packing. 2) Strobe delay - only 6 bits are significant - same comments as above. 3) SCT modules have 12 chips, numbered 0-5 and 8-13. Chip address field is 6 bits. Bit 5 must always be high for ABCD, and is fixed high by ABC. Bit 4 determined by SELECT line (redundancy scheme). If chip address field is binary 111111, then all chips respond (the current structure ideas do not allow for this to be taken advantage of). 4) The biasReg definition given is that for ABCD. ABC only has a single 4-bit DAC, using bits 8-11 of the register. 5) The bit order is not defined in the C language for structures like CONFIG, so we may have to revert to #define and masks. 6) The revised structure only separates the trim DACs for a single ROD - would it be better to keep a whole crates-worth together? 7) The above structure definitions would take up 156kB/ROD (i.e. ~2.5MB for a full crate). 8) All functions return the status as an int. <0 indicates errors, >0 means probable success but with issues. 9) List of functions is clearly not complete - for example we may need higher level functions?