/* This program is to switch the analog spy lines of the Mother * * Board. There are 48*2=96 analog spy channels for each * * Mother Board. Each Mother Board takes signals of 7 groups, * * one for the daughter board and six for power/comm boards. * * Each group contains six MCMs signals. * * Six ADG406 are placed on Mother Board. ADG406 multi * * -plexes out a signal among 16 channel, when six bits * * SPY_A(0:5) is sent to it. Also, one pair of ADG406s * * provides with one pair of analog spy signals,preamp * * and AMU spy signal. * * * * This program is compiled with: * * cc68k -c -O -DCPU=MC68020 -I$VX_VW_BASE/h analog_spy.c * * ld #include #include #include #include "taskLib.h" STATUS analog_spy() { #define BASE 0xffff6000 int imb,igroup,imcm,iomodule,iabcd,ipin,iuplo,m,n; int t_add; int go_on,lok; char command[50],atmp[50]; int spy_A; int bit_out, readback; int status; unsigned int *data; /*----------------------------------------------------------------------------*/ go_on = 1 ; strcpy(command , "help"); while(go_on){ if ( strstr(command, "help") | strstr(command,"menu") ) { printf(" +----------------------------------------------+ | read MB group MCM specify MB (1-4), | | ---- group (1-7), | | MCM (1 - 6) | | exit, quit, x, q exit the program | +----------------------------------------------+ "); } else if ( strstr(command,"read") | strstr(command,"r") ) { sscanf(command,"%s %d %d %d",atmp,&imb,&igroup,&imcm); printf("imb %d, igroup %d, imcm %d \n",imb,igroup,imcm); lok = 1; if (imb ==1) { iomodule = 1; /* This is the location of the first pin of */ iabcd = 1; /* this functional group on the I/O modules. */ ipin = 9; /* The pin mapping can be found on: */ } /* http://p25ext.lanl.gov/phenix/mvd/ ... */ else if (imb == 2) { iomodule = 1; /* ... /ancillary/logic/logic.html */ iabcd = 2; ipin = 1; } else if (imb == 3) { iomodule = 1; iabcd = 2; ipin = 17; } else if (imb == 4) { iomodule = 1; iabcd = 3; ipin = 9; } else { printf(" *** Mother Board number imb out of range (1-4) ***\n"); lok = 0; } if (igroup < 1 || igroup >7) { printf(" *** group out of range (1-7) ***\n"); lok = 0; } if (imcm <1 || imcm >6) { printf(" *** mcm out of range (1-6) ***\n"); lok = 0; } t_add = (igroup-1)*7 + imcm; /* global address of */ /* the channel to be read */ printf(" t_add = %d\n ", t_add); if ( lok == 1 ) { printf("\nReading MB %d, Group %d , MCM %d......\n", imb, igroup, imcm); bit_out = t_add - 1; /* send out six bits */ printf(" output string (hex): %x \n", bit_out); printf("iomodule %d, iabcd %d, ipin %d \n", iomodule, iabcd, ipin); /* construct address: */ data = (unsigned int *)(BASE + (iomodule-1)*0x1000 + (iabcd -1)*0x100 ); if (ipin <= 16) { /* lower word, pin 1-16 */ iuplo = 1; /* *data = 0xffffffff; */ readback = *data; /* read what's there */ printf(" readback 1 %8x \n", readback); readback = readback ^ 0xffff0000; printf(" readback 2 %8x \n", readback); bit_out = bit_out << (ipin-1); bit_out = bit_out << 16; bit_out = readback | bit_out; printf(" readback 3 %8x \n", bit_out); } else { /* upper word, pin 17-24 */ iuplo = 2; /* *data = 0xffffffff; */ readback = *data; /* read what's there */ printf(" readback 4 %8x \n", readback); readback = readback ^ 0xff; printf(" readback 5 %8x \n", readback); bit_out = bit_out << (ipin-17); /* bit_out = bit_out << 8; */ bit_out = readback | bit_out; printf(" readback 6 %8x \n", bit_out); } printf(" bit_out bit pattern: %x \n",bit_out); /* calculate the address: */ *data = 0xffffffff; printf(" readback %8x \n", readback); *data = bit_out; /* load the bits */ readback = *data; /* read what's there */ printf(" readback %8x \n", readback); } /* if input OK */ } /* end 'read' */ else if ( strstr(command,"exit") | strstr(command,"x") | strstr(command,"quit") | strstr(command,"q") ) { go_on=0; } else { printf("\n Wrong command - to see menu, type help.\n"); } if (go_on == 1) { printf("\n MVD SPY>>"); gets(command); } } /* end command loop */ printf(" done \n"); return(OK); }