⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svtrack.c

📁 GPS导航定位程序
💻 C
字号:
#include "includes.h"

static volatile int TakeMeasInProg;   /* Flag used for reentrant return */
static volatile int ProcAccumInProg;  /* Flag used for reentrant return */

/****************************************************************************
*
* Function: void SVTrack(void)
*
* Satellite tracking routine, called from GPISR, the GP2021 correlator's
* interrupt service routine. The entry point is at routine SVTrack, which
* is entered every 505 microseconds with interrupts disabled. SVTrack may
* be called reentrantly to a maximum depth of three. 
*
* This is the reentrant part of the GP2021 correlator interrupt service
* routine. On entry, interrupts are disabled. This routine may become
* interruptible for computations which are longer than the intervals between
* correlator interrupts. Interrupts must be disabled before returning to the
* caller (GPISR).                      
*                                                                       
* There are three code sections: 1) BufferAccum, which is the most time
* critical processing, reads accumulated data from the correlators, buffers
* the accumulations for more leisurely processing, and closes the carrier
* tracking loops, 2) TakeMeas, which is the next most time critical
* processing, reads measurements that become ready at each TIC interval and
* assembles them into observations which are buffered for processing by
* navigation routines, and 3) ProcAccum, which operates on the buffered
* accumulated data to close the code tracking, data bit synchronization, and 
* subframe synchronization loops.                                                                
*
* Input: None.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void SVTrack(void)
{
     unsigned OldPICAIntMask;                     /* Mask from Master PIC. */
     unsigned OldPICBIntMask;                      /* Mask from Slave PIC. */

    /* Interrupts at this point are disabled so that BuffAccumPhase itself
       cannot be interrupted. If BuffAccumPhase needed to be interrupted
       then this indicates that the PC is too slow to service the 505us
       ISR in a 505us period (obviously it needs to service it in a lot
       shorter period as there are other routines to run. */
    
    ISRNEST++;                     /* Increment the nesting level counter. */

    BufferAccumPhase();        /* Check the correlators for accumulations. */

    outportb(0xA0,0x20);                  /* Nonspecific EOI for PC PIC B. */
    outportb(0x20,0x20);                  /* Nonspecific EOI for PC PIC A. */

    /* Check if an iteration of TakeMeasPhase was in progress before the
       current iteration of SVTrack occured. */

    /* Return if the TakeMeas process is already in progress. */

    if(TakeMeasInProg)                   /* TakeMeasPhase was in progress. */  
    {
	ISRNEST--;                                   /* One less ISR nest. */   
	outportb(0xA0,0x20);              /* Nonspecific EOI for PC PIC B. */
	outportb(0x20,0x20);              /* Nonspecific EOI for PC PIC A. */
	return;
    }
    else                              /* TakeMeasPhase wasn't in progress. */ 
	TakeMeasInProg=1;                              /* so start one up. */

    OldPICAIntMask = inp(0x21);               /* Save old interrupt masks. */
    OldPICBIntMask = inp(0xA1);
    outportb(0xA1,~(1<<(GPINT-8)));     /* Mask all non-GP2021 interrupts. */
    outportb(0x21,~(1<<2));
    outportb(0xA0,0x20);                  /* Nonspecific EOI for PC PIC B. */
    outportb(0x20,0x20);                  /* Nonspecific EOI for PC PIC A. */

    /* Re-enable interrupts so that the BuffAccumPhase can interrupt the
       TakeMeasPhase. */

    enable();

    TakeMeasPhase();        /* Check the correlators for TIC measurements. */
    
    disable();                             /* Temporarily stop interrupts. */
    TakeMeasInProg=0;           /* The current TakeMeasPhase has finished. */

    /* Check if an iteration of ProcAccumPhase was in progress before the
       current iteration of SVTrack occured. */

    if(ProcAccumInProg)                 /* ProcAccumPhase was in progress. */    
    {
	ISRNEST--;                                   /* One less ISR nest. */    
	return;                          /* To current ProcAccumMeasPhase. */  
    }
    else                             /* ProcAccumPhase wasn't in progress. */
	ProcAccumInProg=1;                             /* so start one up. */   

    /* Re-enable interrupts so that the BuffAccumPhase can interrupt the
       ProcAccumPhase. */

    enable();                   

    ProcAccumPhase();                    /* Process the accumulation data. */

    /* Disable the interrupts on return from SVTrack. */   

    disable();

    ProcAccumInProg = 0;       /* The current ProcAccumPhase has finished. */  
    ISRNEST--;                                       /* One less ISR nest. */

    outportb(0x21,OldPICAIntMask);             /* Restore interrupt masks. */
    outportb(0xA1,OldPICBIntMask);  
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -