} Rc;
/**********************************
- * INTERFACE2 Xilinx part *
- * based on ver10rev1, 07.05.1999 *
+ * INTERFACE3 Xilinx part *
+ * based on ver3rev1, Feb. 2000 *
**********************************/
enum Rc_regions {
static const ptrdiff_t prdoutCtr = regRegion + 0x00a;
static const ptrdiff_t ardoutCtr = regRegion + 0x00c;
static const ptrdiff_t adelCtr = regRegion + 0x00e;
-static const ptrdiff_t lcdReg = regRegion + 0x010;
-static const ptrdiff_t lcdPad = regRegion + 0x012;
+static const ptrdiff_t tagReg = regRegion + 0x010;
+static const ptrdiff_t lcReg = regRegion + 0x012;
+/* static const ptrdiff_t unused1 = regRegion + 0x014; */
+/* static const ptrdiff_t unused2 = regRegion + 0x016; */
+/* static const ptrdiff_t unused3 = regRegion + 0x018; */
+/* static const ptrdiff_t unused4 = regRegion + 0x01a; */
+static const ptrdiff_t giopReg = regRegion + 0x01c;
+static const ptrdiff_t giopPad = regRegion + 0x01e;
/* CTRL register definitions */
static unsigned short Rc_getCtrlReg(Rc * my) { return LVme_getW(my->lvme, ctrlReg); }
/* Magic numbers */
static const int PRDOUT = 0x00; /* Pattern readout (daisy chain) */
-static const int PDEL = 0x01; /* Pattern delete (buslike) */
+static const int TEST = 0x01; /* Test Mode activation (buslike) */
static const int ARDOUT = 0x02; /* Analog readout (daisy chain) */
static const int ADEL = 0x03; /* Analog delete (buslike) */
static const int RFIFO = 0x04; /* Reset FIFO (buslike) */
static const int RDAISY = 0x05; /* Reset daisy chain (buslike) */
static const int WCFG = 0x06; /* Write configuration (daisy chain) */
static const int RCFG = 0x07; /* Read configuration (daisy chain) */
-static const int NOP = 0x0F; /* No OPeration - do nothing */
+static const int NOP = 0x0F; /* No OPeration - do nothing */
+
+/* Test mode is available only in the GUF (Grand Unified Frontend) */
static void Rc_setFc(Rc * my, int fc)
{
Rc_clrRctr(my);
}
-/* LCD register definitions */
+/* TAG register definitions */
+/* This register contains the last distributed SubEventTag */
-/* Magic numbers */
-static const int CLR_DISPLAY = 0x01; /* clears display, sets cursor home, unshifts */
-static const int CRSR_HOME = 0x02; /* sets cursor home, unshifts */
-static const int CRSR_LEFT = 0x10; /* move cursor one char left */
-static const int CRSR_RIGHT = 0x14; /* move cursor one char right */
-static const int DISP_LEFT = 0x18; /* shifts whole display one char left */
-static const int DISP_RIGHT = 0x1c; /* shifts whole display one char right */
-static const int CRSR_ON = 0x0a; /* display cursor */
-static const int BLINK_ON = 0x09; /* blinks cursor */
-static const int DISP_ON = 0x0c; /* set display on */
-static const int DISP_CTRL = 0x08; /* magic byte for CRSR_ON, BLINK_ON, DISP_ON */
+static unsigned short Rc_getTagReg(Rc * my) { return LVme_getW(my->lvme, tagReg); }
-/* Do not use this function alone */
-static int Rc_readInstrLCD(Rc * my)
-{
- LVme_setW(my->lvme, lcdReg, 0x01FF);
- LVme_setBitW(my->lvme, lcdReg, 10);
- LVme_clrBitW(my->lvme, lcdReg, 10);
- return LVme_getW(my->lvme, lcdPad);
-}
-static void Rc_waitBusyLCD(Rc * my)
-{
- while((Rc_readInstrLCD(my) & 0x80) >> 7)
- {
- /* Delay loop -> something useful to put in here ? */
- }
-}
-static void Rc_writeDataLCD(Rc * my, int data)
-{
- unsigned short realData = 0x0000;
- realData = 0x0200 | data;
- Rc_waitBusyLCD(my);
- LVme_setW(my->lvme, lcdReg, realData);
- LVme_setBitW(my->lvme, lcdReg, 10);
- LVme_clrBitW(my->lvme, lcdReg, 10);
-}
-static void Rc_writeInstrLCD(Rc * my, int instr)
+/* LC register definitions */
+/* This register contains information on the last command delivered by the DTU_RICH as well */
+/* as the acknowledge of the RC99 hardware. By this register, a DTU_RICH lockup due to a */
+/* missing acknowledge of the RC99 hardware can be easily detected. */
+
+/* Do not use this function alone ! */
+static unsigned short Rc_getLcReg(Rc * my) { return LVme_getW(my->lvme, lcReg); }
+
+static unsigned short Rc_getLcStatus(Rc * my)
{
- unsigned short realInstr = 0x0000;
- realInstr = 0x0000 | instr;
- Rc_waitBusyLCD(my);
- LVme_setW(my->lvme, lcdReg, realInstr);
- LVme_setBitW(my->lvme, lcdReg, 10);
- LVme_clrBitW(my->lvme, lcdReg, 10);
+ unsigned short LcStatus = 0x0000;
+ return LcStatus = (Rc_getLcReg(my) & 0x001f);
}
-static void Rc_initLCD(Rc * my)
+
+/* GIOP register definitions */
+/* This register allows access to five free Xilinx pins equipped with a solder pad. */
+/* By default, these pads are unconnected and can be used for test purposes. */
+
+/* Do not use these functions alone ! */
+static unsigned short Rc_getgiopReg(Rc * my) { return LVme_getW(my->lvme, giopReg); }
+static unsigned short Rc_getgiopPad(Rc * my) { return LVme_getW(my->lvme, giopPad); }
+
+static unsigned short Rc_getInterfaceVersion(Rc * my)
{
- /* Function Set: 8bit, 2lines, 5x7 font */
- LVme_setW(my->lvme, lcdReg, 0x0038);
- LVme_setBitW(my->lvme, lcdReg, 10);
- LVme_clrBitW(my->lvme, lcdReg, 10);
- /* Wait more than 4.1ms */
- usleep(5000);
- /* Display ON/OFF control */
- Rc_writeInstrLCD(my, 0x0e);
- /* Entry mode set */
- Rc_writeInstrLCD(my, 0x06);
+ short giopPadValue;
+ giopPadValue = (0xFF00 & Rc_getgiopPad(my)) >> 8;
+ return giopPadValue;
}
+
/*********************************
- * MEMORY2 Xilinx part *
- * based on ver16rev1 07.05.1999 *
+ * MEMORY3 Xilinx part *
+ * based on ver7rev2 Feb. 2000 *
*********************************/
/* Offsets for MEMORY2 registers */
static const ptrdiff_t sedec_low = regRegion + 0x10a;
static const ptrdiff_t seid_high = regRegion + 0x10c;
static const ptrdiff_t seid_low = regRegion + 0x10e;
+static const ptrdiff_t versionMem = regRegion + 0x110;
+static const ptrdiff_t swCtr = regRegion + 0x112;
+static const ptrdiff_t codeMem = regRegion + 0x114;
+/* static const ptrdiff_t unused3 = regRegion + 0x116; */
+/* static const ptrdiff_t unused4 = regRegion + 0x118; */
+/* static const ptrdiff_t unused5 = regRegion + 0x11a; */
+/* static const ptrdiff_t unused6 = regRegion + 0x11c; */
+/* static const ptrdiff_t unused7 = regRegion + 0x11e; */
/* STATUSID register */
static unsigned int Rc_readStatusid(Rc * my)
static void Rc_writeStatusid(Rc * my, unsigned char value)
{
unsigned short savedStatusId;
- savedStatusId = LVme_getW(my->lvme, statusid); /* StatusID Register retten */
- savedStatusId = ( savedStatusId & 0xFF00 ) | ( value & 0x00FF ); /* Neue ID auf low byte einblenden */
- LVme_setW(my->lvme, statusid, savedStatusId); /* neues Register zurueckschreiben */
+ savedStatusId = LVme_getW(my->lvme, statusid);
+ savedStatusId = ( savedStatusId & 0xFF00 ) | ( value & 0x00FF );
+ LVme_setW(my->lvme, statusid, savedStatusId);
}
static unsigned short Rc_getStatusID(Rc * my)
{
{
return LVme_getW(my->lvme, pages);
}
+static unsigned short Rc_getPages(Rc *my)
+{
+ unsigned short realPages = 0x0000;
+ realPages = Rc_readPages(my); /* read PAGES content */
+ realPages = realPages & 0x07ff; /* mask the number out */
+ return realPages; /* return value */
+}
static void Rc_waitSwitchcomplete(Rc * my)
{
unsigned short realPages = 0x0000;
realPages = realPages & 0xc000; /* oberste zwei Bits anschauen */
while((realPages != 0x0000) || (realPages != 0xc000)) /* Schleife, bis beide Bits gleich */
{
- realPages = (Rc_readPages(my) & 0xc000); /* immer wieder reingucken */
+ realPages = (Rc_readPages(my) & 0xc000); /* immer wieder reingucken */
}
}
+static int Rc_bankRequested(Rc * my)
+{
+ unsigned short realPages = 0x0000;
+ realPages = Rc_readPages(my);
+ realPages = ((realPages & 0x4000) >> 14);
+ return (int) realPages;
+}
+static int Rc_bankConfirmed(Rc * my)
+{
+ unsigned short realPages = 0x0000;
+ realPages = Rc_readPages(my);
+ realPages = ((realPages & 0x8000) >> 15);
+ return (int) realPages;
+}
+static int Rc_SwitchStatus(Rc * my)
+{
+ unsigned short realPages = 0x0000;
+ realPages = Rc_readPages(my);
+ realPages = ((realPages & 0xc0000) >> 14);
+ return (int) realPages;
+ /* 0x03: Bank A requested and activated
+ 0x02: Bank B requested, request still pending
+ 0x01: Bank A requested, request still pending
+ 0x00: Bank B requested and activated */
+}
static int Rc_testMemfull(Rc * my)
{
unsigned short realPages = 0x0000;
realPages = Rc_readPages(my);
realPages = (realPages & 0x2000) >> 13;
- return realPages;
+ return (int) realPages;
}
/* SEDEC_HIGH register */
LVme_setW(my->lvme, seid_low, value);
}
+/* VERSIONMEM register */
+static unsigned short Rc_readVersionMem(Rc * my)
+{
+ return LVme_getW(my->lvme, versionMem);
+}
+
+/* SWCTR register */
+static unsigned short Rc_readSwCtr(Rc * my)
+{
+ return LVme_getW(my->lvme, swCtr);
+}
+
+/* CODEMEM register */
+static void Rc_HallOfMemory(Rc *my)
+{
+ int i = 0;
+ char low, high;
+ unsigned short word;
+ char fame[256];
+
+ LVme_setW(my->lvme, codeMem, 0xc0de);
+
+ do
+ {
+ word = LVme_getW(my->lvme, codeMem);
+ low = word & 0xff;
+ high = (word >> 8) & 0xff;
+ fame[i++] = high;
+ fame[i++] = low;
+
+ }
+ while(high != 0 || low != 0);
+ printf(fame);
+}
+
/***********************
* TIMING2 Xilinx part *
* based on verXrevY *
/* Offsets for TIMING2 registers */
static const ptrdiff_t evtgReg = busRegion + 0x100;
static const ptrdiff_t errReg = busRegion + 0x102;
-static const ptrdiff_t mskReg = busRegion + 0x104;
+static const ptrdiff_t mskReg = busRegion + 0x104;
+static const ptrdiff_t stwReg = busRegion + 0x106;
/* EVTG-Register read/write (16bit wide) */
static unsigned short Rc_readEvtgreg(Rc * my)
LVme_setW(my->lvme, mskReg, realValue);
}
+/* STW-Register read/write (8bit wide) */
+static int Rc_readStwreg(Rc * my)
+{
+ return LVme_getW(my->lvme, stwReg);
+}
+static void Rc_writeStwreg(Rc * my, int value)
+{
+ unsigned short realValue = 0x0000;
+ realValue = 0x0000 | value;
+ LVme_setW(my->lvme, stwReg, realValue);
+}
+
+
/****************
* Port XC part *
****************/
return LVme_getW(my->lvme, (port * portOffset + Pcontrol));
}
+/* ENXCFG bit: enable configuration of frontend FPGAs */
+static void Rc_setXcfg(Rc * my, int port)
+{
+ LVme_setBitW(my->lvme, port * portOffset + Pcontrol, 0);
+}
+
+static void Rc_clrXcfg(Rc * my, int port)
+{
+ LVme_clrBitW(my->lvme, port * portOffset + Pcontrol, 0);
+}
+
+static int Rc_getXcfg(Rc * my, int port)
+{
+ return LVme_tstBitW(my->lvme, port * portOffset + Pcontrol, 0);
+}
+
/***************
* Memory part *
static void Rc_clearMem(Rc * my)
{
long i;
- const long RC_MEMSIZE = 0x80000;
- const long CLEARVALUE = 0x00000000;
- for(i = 0; i < RC_MEMSIZE; i = i + 0x04)
+ const long memSize = 0x80000;
+ const long clearValue = 0x00000000;
+ for(i = 0; i < memSize; i = i + 0x04)
{
- Rc_writeMem(my, i, CLEARVALUE);
+ Rc_writeMem(my, i, clearValue);
}
}
static long Rc_testMem(Rc * my)
{
long i;
- const long RC_MEMSIZE = 0x80000;
- const long CLEARVALUE = 0x00000000;
+ const long memSize = 0x80000;
+ const long clearValue = 0x00000000;
unsigned long different = 0x00000000;
unsigned long memValue = 0x00000000;
- for(i = 0; i < RC_MEMSIZE; i = i + 0x04)
+ for(i = 0; i < memSize; i = i + 0x04)
{
memValue = Rc_readMem(my, i);
- if(memValue != CLEARVALUE)
+ if(memValue != clearValue)
{
different++;
printf("A: 0x%08x: 0x%08x\n", i, memValue);
static void Rc_clearDpr(Rc * my)
{
unsigned short i;
- const unsigned short DPRSIZE = 0x8000;
- const unsigned short CLEARVALUE = 0x0000;
- for(i = 0; i < DPRSIZE; i = i + 0x04)
+ const unsigned short dprSize = 0x8000;
+ const unsigned short clearValue = 0x0000;
+ for(i = 0; i < dprSize; i = i + 0x04)
{
if (i % 256 == 0)
{
printf(".");
}
- Rc_writeDpr(my, i, CLEARVALUE);
+ Rc_writeDpr(my, i, clearValue);
}
printf("\n");
}
static unsigned short Rc_testDpr(Rc * my)
{
unsigned short i;
- const unsigned short DPRSIZE = 0x8000;
- const unsigned short CLEARVALUE = 0x0000;
+ const unsigned short dprSize = 0x8000;
+ const unsigned short clearValue = 0x0000;
unsigned short different = 0x0000;
unsigned short memValue = 0x0000;
- for(i = 0; i < DPRSIZE; i = i + 0x04)
+ for(i = 0; i < dprSize; i = i + 0x04)
{
memValue = Rc_readDpr(my, i);
- if(memValue != CLEARVALUE)
+ if(memValue != clearValue)
{
different++;
printf(" -> A: 0x%08x: 0x%04x\n", i, memValue);
-/* This is a comment */
+/* This is a comment */
+
+
+
#endif
+