📄 init.c
字号:
"settings.\n");
QuitGpsBuilder();
}
else
{
printf("\n\nInterrupt test passed.");
printf("\n%lu interrupts were counted - there should have been"
" 200.",interrupt_count);
}
printf("\n\nAddress and Data Bus Interface Check.\n");
/* Load the carrier DCOs with zero for all DCOs. */
outpw(TR(ALL_CARRIER_DCO_INCR_HIGH),0x0000);
outpw(TR(ALL_CARRIER_DCO_INCR_LOW),0x0000);
outpw(TR(TEST_CONTROL),0x0008); /* Put the correlator in TM Test mode. */
WaitForFullTIC();
/* Load the carrier cycle counters (low) alternatively with testdata and
not testdata. */
testdata = 0xAAAA;
for(channel=0;channel<MAXCHANNELS;channel++)
{
outpw(TR(CH01_CARRIER_CYCLE_COUNTER + 0x0008*channel),testdata);
testdata = ~testdata;
}
WaitForFullTIC();
/* Now read CHx_CARRIER_CYCLE_COUNTER_LOW and check equivalence to
testdata or not testdata as appropriate. */
for(channel=0;channel<MAXCHANNELS;channel++)
{
cycle_count[channel] =
inpw(TR(CH01_CARRIER_CYCLE_COUNTER + 0x0008*channel));
}
testdata = 0xAAAA;
for(channel=0;channel<MAXCHANNELS;channel++)
{
if( cycle_count[channel] != testdata)
{
printf("\nAddress/Data bus error for channel %2.2d. ",
channel+1);
printf("Addr:%2.2X Read: %4.4X Should be: %4.4X",
CH01_CARRIER_CYCLE_COUNTER + 0x0008*channel,
cycle_count[channel],testdata);
printf("\nCheck the values contained in GPSBLDR2.CFG with the "
"board settings.\n");
outpw(GPIMASK,MASK_INTERRUPT); /* Mask interrupts. */
QuitGpsBuilder();
}
else
{
printf("\nAddress/Data bus test passed for channel %2.2d.",
channel+1);
printf(" Read: %4.4X Should be: %4.4X",cycle_count[channel],
testdata);
}
testdata = ~testdata;
}
WaitForFullTIC();
/* Load the carrier cycle counters (low) alternatively with testdata and
not testdata. */
testdata = 0x5555;
for(channel=0;channel<MAXCHANNELS;channel++)
{
outpw(TR(CH01_CARRIER_CYCLE_COUNTER + 0x0008*channel),testdata);
testdata = ~testdata;
}
WaitForFullTIC();
/* Now read CHx_CARRIER_CYCLE_COUNTER_LOW and check
equivalence to testdata or not testdata as appropriate. */
for(channel=0;channel<MAXCHANNELS;channel++)
{
cycle_count[channel] =
inpw(TR(CH01_CARRIER_CYCLE_COUNTER + 0x0008*channel));
}
testdata = 0x5555;
for(channel=0;channel<MAXCHANNELS;channel++)
{
if( cycle_count[channel] != testdata)
{
printf("\nAddress/Data bus error for channel %2.2d. ",
channel+1);
printf("Addr:%2.2X Read: %4.4X Should be: %4.4X",
CH01_CARRIER_CYCLE_COUNTER + 0x0008*channel,
cycle_count[channel],testdata);
printf("\nCheck the values contained in GPSBLDR2.CFG with the "
"board settings.\n");
outpw(GPIMASK,MASK_INTERRUPT); /* Mask interrupts. */
QuitGpsBuilder();
}
else
{
printf("\nAddress/Data bus test passed for channel %2.2d.",
channel+1);
printf(" Read: %4.4X Should be: %4.4X",cycle_count[channel],
testdata);
}
testdata = ~testdata;
}
}
/***************************************************************************
*
* Function: void WaitForFullTIC(void)
*
* Waits for a full TIC to occur.
*
* Input: None.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void WaitForFullTIC(void)
{
long dropout; /* Stops lock-up if no TICs detected. */
unsigned long oldGPIntCtr; /* The old interrupt count. */
/* Wait for the TIC */
dropout = 0;
inpw(TR(ACCUM_STATUS_B));
GPIntCtr = oldGPIntCtr = 0;
for(;;)
{
while(GPIntCtr==oldGPIntCtr) /* Wait for a 505us interrupt. */
continue;
oldGPIntCtr = GPIntCtr;
if((inpw(TR(ACCUM_STATUS_B))&0x2000) == 0x2000 )
break;
else
{
dropout++;
if(dropout>300000L)
{
printf("\n\nAddress/Data bus error. No TICs were detected.");
printf("\nCheck the values contained in GPSBLDR2.CFG with the "
"board settings.\n");
QuitGpsBuilder();
}
}
}
}
/***************************************************************************
*
* Function: void InterfaceTestInterruptRoutine(void)
*
* Called as an alternative to SVTRACK when running the interface check.
* ACCUM_STATUS_A needs to be read to reset each interrupt.
*
* Input: None.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void InterfaceTestInterruptRoutine(void)
{
inpw(TR(ACCUM_STATUS_A));
outportb(0xA0,0x20); /* Nonspecific EOI for PC PIC B */
outportb(0x20,0x20); /* Nonspecific EOI for PC PIC A */
return;
}
/***************************************************************************
*
* Function: void ConfigureInterrupt(void)
*
* Configures the master correlator interrupt on the PC PIC.
*
* Input: None.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void ConfigureInterrupt(void)
{
/* Set up the PC's interrupt system to enable GP2021 correlator
interrupts at the highest priority. */
disable();
oldmskA = inp(0x21); /* Save old interrupt masks. */
oldmskB = inp(0xA1);
gpvec=0x70+(GPINT-8);
gpmask=(1<<(GPINT-8));
outportb(0xA1, inportb(0xA1) | gpmask);
outportb(0x20,0xC1); /* Make IRQ 2 the highest priority on PIC A. */
/* Make the correlator's interrupt the highest priority on PIC B. */
outportb(0xA0,0xC0+((GPINT-9)&7));
/* Set a pointer to the correlator ISR in the interrupt dispatch table
table, also saving the previous interrupt vector. */
oldisrK = getvect(gpvec);
setvect(gpvec,GPISR);
/* Unmask the correlator interrupt (however, it is not yet enabled
on the GPS Builder board). */
gpmask=(1<<(GPINT-8));
outportb(0xA1,inportb(0xA1)&(~gpmask));
enable();
}
/***************************************************************************
*
* Function: void AllocateMemory(void)
*
* Allocates memory to the observation buffer and ISR stacks.
*
* Input: None.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void AllocateMemory(void)
{
int stack_counter; /* Loop counter for stack number. */
/* Allocate the observations buffer from the far heap. */
obsbuff = (obsstruc far *)
farcalloc((unsigned long)NOBS,(unsigned long)sizeof(obsstruc));
/* Allocate ISR stacks from the far heap. */
ISTACKS[0] = farmalloc((unsigned long)IStkSiz+32);
ISTACKS[1] = farmalloc((unsigned long)IStkSiz+32);
ISTACKS[2] = farmalloc((unsigned long)IStkSiz+32);
if((obsbuff==NULL) || (ISTACKS[0]==NULL) || (ISTACKS[1]==NULL) ||
(ISTACKS[2]==NULL))
{
printf("\nERROR: Insufficient conventional memory.\r\n");
QuitGpsBuilder();
}
/* Fill the ISR stacks with a signature pattern (0x55). Find the
next paragraph boundary beyond the memory blocks allocated for
the stacks. Build a table of SP:SS values for the ISR stacks. */
for(stack_counter=0;stack_counter<3;stack_counter++)
{
_fmemset(ISTACKS[stack_counter],0x55,IStkSiz);
IStkSS[stack_counter] =
FP_SEG(ISTACKS[stack_counter])+FP_OFF(ISTACKS[stack_counter])/16+1;
IStkSP[stack_counter] = IStkSiz;
}
}
/***************************************************************************
*
* Function: void ProcessCommandFile(void)
*
* Process any commands contained in the CMD.INI file.
*
* Input: None.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void ProcessCommandFile(void)
{
/* Take initialization commands from CMD.INI if it exists. */
CmdFile[CmdFileNesting] = fopen("CMD.INI","rt");
if(CmdFile[CmdFileNesting]!=NULL)
{
rewind(CmdFile[CmdFileNesting]);
CmdFileNesting++;
}
/* Read and process all the initialization commands before starting the
main program loop. */
while(CmdFileNesting)
Keyboard();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -