/* --------------------------------------------------------------------------- * Test functions using sequencer scanning code * * Author : J.B.Lane UCL December 2000 timscan.c * --------------------------------------------------------------------------- */ #include "timscan.h" #include "timlet.h" #include /* --------------------------------------------------------------------------- * probably remove nextL1ID *** */ int checkSink (const int size, const int next, int *indexL1A) { struct TIM_SCAN_RESULTS scanResults ; int error = 0 ; int l1id ; int bcid ; int ttid ; int nextL1ID ; if (debug_level > 2) printf("debug3: Entering checkSink...\n"); nextL1ID = next ; if (next == NONE) { timWait_seqBusys () ; l1id = timGetL1ID( *reg_L1lo, *reg_L1hi ) ; nextL1ID = l1id ; /* L1ID has not been reset ***/ } /* scanResults = scan_run (size, nextL1ID) ; */ scanResults = scan_run (size, next) ; error += scanResults.errors ; *indexL1A = scanResults.indexL1A ; l1id = timGetL1ID( *reg_L1lo, *reg_L1hi ) ; bcid = *reg_BCid & 0x0FFF ; ttid = *reg_TTid ; if (scanResults.bitCount == 0) { printf ("ERROR: SINK is empty, bytes scanned %d\n", size) ; printf ( "L1id %06X TTid %03X BCid %03X BCin %03X status %04X output %04X\n", l1id, *reg_TTid, *reg_BCid, *reg_BCin, *reg_status, *reg_output) ; timDump (size, 1) ; } error += timCheck ("SINK: (scan, l1id)", scanResults.lastL1ID, l1id) ; error += timCheck ("SINK: (scan, bcid)", scanResults.lastBCID, bcid) ; error += timCheck ("SINK: (scan, ttid)", scanResults.lastTTID, ttid) ; nextL1ID = l1id + 1 ; if (debug_level > 2) printf("debug3: Leaving checkSink...\n"); return error ; } /* --------------------------------------------------------------------------- */ struct TIM_SCAN_RESULTS scan_run (const int Size, const int NextL1ID) { struct TIM_SCAN_CONTROL scanControl = timScanDefaults () ; struct TIM_SCAN_RESULTS scanResults ; if (debug_level > 2) printf("debug3: Entering scan_run...\n"); scanControl.size = Size ; scanControl.nextL1ID = NextL1ID ; /* could use default NONE ***/ scanControl.pipeline = 26 + 3 + (*reg_delays & 0xFF) ; /* 26 + 3 for PLDs */ if ((*reg_command & RunMode) == 0) scanControl.orbit = 0x1000 ; scanResults = timScanRAM (scanControl) ; if (debug_level > 2) printf("debug3: Leaving scan_run...\n"); return scanResults ; } /* --------------------------------------------------------------------------- */ void timDump (const int Size, const int Byte) { struct TIM_SCAN_CONTROL scanControl = timScanDefaults () ; struct TIM_SCAN_RESULTS scanResults ; int l1id ; if (debug_level > 2) printf("debug3: Entering timDump...\n"); l1id = timGetL1ID( *reg_L1lo, *reg_L1hi ) ; printf ("\nTIM register dump:\n") ; printf ( "L1id %06X TTid %03X BCid %03X BCin %03X status %04X output %04X\n", l1id, *reg_TTid, *reg_BCid, *reg_BCin, *reg_status, *reg_output) ; scanControl.size = Size ; scanControl.byte = Byte ; scanControl.print = 1 ; scanControl.pipeline = 29 + (*reg_delays & 0xFF) ; scanResults = timScanRAM (scanControl) ; printf ("scan indexL1A = %d\n", scanResults.indexL1A) ; printf ("scan countL1A = %d\n", scanResults.countL1A) ; if (debug_level > 2) printf("debug3: Leaving timDump...\n"); } /* --------------------------------------------------------------------------- */ struct TIM_SCAN_CONTROL timScanDefaults (void) { struct TIM_SCAN_CONTROL scanControl ; /* NB Pixels... SCT only */ scanControl.size = TIM_RAM_SIZE ; scanControl.byte = 1 ; scanControl.print = 0 ; scanControl.offset = SCToffset ; scanControl.orbit = 3564 ; /* 3560 for Jon, 3565 for old TTCvi */ scanControl.pipeline = 99 ; scanControl.nextL1ID = NONE ; scanControl.nextBCID = NONE ; /* not implemented */ scanControl.nextTTID = NONE ; return scanControl ; } /* --------------------------------------------------------------------------- */ struct TIM_SCAN_RESULTS timScanRAM (const struct TIM_SCAN_CONTROL scanControl) { struct TIM_SCAN_RESULTS scanResults ; unsigned short buffer[TIM_RAM_SIZE] ; int i ; if (debug_level > 2) printf("debug3: Entering timScanRAM...\n"); timWait_seqBusys () ; for (i = 0 ; i < scanControl.size ; i ++) buffer[i] = ram_ptr[i] ; scanResults = timScan (buffer, scanControl) ; if (debug_level > 2) printf("debug3: Leaving timScanRAM...\n"); return scanResults ; }