예제 #1
0
파일: apuserdev.c 프로젝트: timburrow/ovj3
/*--------------------------------------------------------------*/
void setdataoffset(codeint rtdataoffset)
{
   putcode(ISETDATAOFFSET);	/*  */
   putcode((codeint)rtdataoffset);
   putcode((codeint)rtdataoffset);
   putcode((codeint)dtmcntrl);
}
예제 #2
0
/*-------------------------------------------------------------------
|
|	starthardloop()/1 
|	index is to v1-v14, number of times to cycle through loop
|	This start a hardware loop.
|	hwlooping flag is set.
|	curfifocount is saved so that the # of fifo words in the
|	 hardwarre loop can be calcualted later in 'endhardloop'.
|	pointer to the starthardloop Acode is save so that the
|	 values can update later by 'endhardloop'
|	 1. setICM is inserted in nop, if this loop acquires data
|	     and no previous hardware loop did.
|	 2. # of fifo words in hardware loop is set.
|	 3. enable interrupt is nulled if only one hardware loop
|	    exists.
|	
|				Author Greg Brissey  7/10/86
+------------------------------------------------------------------*/
void starthardloop(codeint rtindex)
{
    setSSHAdisable();
    if(bgflag)
	fprintf(stderr,"starthardloop(): v# index: %d \n",rtindex);
    if (hwlooping)	/* No nesting of hardware loops */
    {
	text_error("Missing endhardloop after previous starthardloop\n");
	psg_abort(0);
    }
    hwlooping = TRUE;	/* mark the start of a hardware loop */
    starthwfifocnt = curfifocount; /* must know # words in fifo */
    fifostarttime = totaltime; /* must know time of loop */
    hwloopelements = 0;  /* reset pulse elements in hardware loop to zero */
    putcode(0);		/* nop that might be change to a setSTM acode */
    hwloop_ptr = (codeint) (Codeptr - Aacode); /* save location for use */
    putcode(HWLOOP);	/* hardwareloop Acode */
    putcode(0);		/* will be then number of fifo words in loop */
    putcode(2);		/* default to enable looping interrupt in acq.  */
			/* for multiple hardware loops */
    putcode(rtindex);   /* real time variable containing # of cycles of loop */

    /* Update time for loop */
    hwloopcnt4time = get_acqvar(rtindex); /* get count for this loop	*/
}
예제 #3
0
파일: lk_sh.c 프로젝트: timburrow/ovj3
lk_sampling_off()		/* turn off lock sampling */
{
    putcode(APBOUT);
    putcode(1);
    putcode(0xab51);
    putcode(0xbb4a);
}
예제 #4
0
파일: lk_sh.c 프로젝트: timburrow/ovj3
lk_autotrig()
{
    HSgate(0x2000000,FALSE);	/* Reset LK RCVR line to 0, as always */
    putcode(APBOUT);
    putcode(1);
    putcode(0xab51);
    putcode(0xbb0a);		/* do 2 kHz auto mode for XMTR and RCVR */
}
예제 #5
0
파일: lk_sh.c 프로젝트: timburrow/ovj3
lk_hslines()
{
    HSgate(0x2000000,TRUE);	/* Set LK RCVR line to 1 = OFF */
    putcode(APBOUT);
    putcode(1);
    putcode(0xab51);
    putcode(0xbb3a);		/* follow chan 6 HS lines for XMTR and RCVR */
}
예제 #6
0
파일: lk_sh.c 프로젝트: timburrow/ovj3
lk_sample()
{
    if (ap_interface!=4)
    {
        /* an error message could be displayed but they probably already
         * got one from using lk_hold()
         */
        return;
    }
    putcode(SMPL_HOLD);
    putcode(SMPL);
}
예제 #7
0
/*------------------------------------------------
|  pre_expsequence():
|  This routine is for users that want to preform
|  functions once prior to the experiment.
|  Change the follow function to suit your needs.
+------------------------------------------------*/
void pre_expsequence()
{
  /*-----------------------------------------------------------------------
  |  You are responsible for any any fifo words generated to be outputed 
  |  failure to do so may result in unpredictable and possibly destructive
  |  settings of the hardware!!!!
  +----------------------------------------------------------------------*/
  /* Example of outputing fifo words:  */
#ifdef XXX
  G_Delay(DELAY_TIME, 0.01, 0);  /* time for SFIFO code to stuff halt before foo */
  putcode(STFIFO);            /* start fifo */
  putcode(SFIFO);             /* Stop and wait for fifo to finish */
  curfifocount = 0;
#endif
  return;
}
예제 #8
0
파일: lk_sh.c 프로젝트: timburrow/ovj3
lk_hold()
{
    static int errorsent = 0;
    if (ap_interface!=4)
    {
        if (!errorsent)
        {
            text_error("lk_hold is not valid with this hardware configuration\n");
            text_error("lk_hold is ignored\n");
            errorsent = 1;
        }
        return;
    }
    putcode(SMPL_HOLD);
    putcode(HOLD);
}
예제 #9
0
파일: tvm.c 프로젝트: fy0/tinyre
_INLINE static
int do_ins_cmp(VMState* vms) {
    VMSnap* snap = vms->snap;
    uint32_t char_code = *(snap->codes + 1);

#ifdef TRE_DEBUG
    printf_u8("%12s ", "CMP");
    putcode(char_code);
    printf(" ");
    putcode(snap->chrcode);
    putchar('\n');
#endif
    if (snap->text_end) return 0;
    if (char_cmp(char_code, snap->chrcode, vms->flag))
        return 2;
    return 0;
}
예제 #10
0
파일: apuserdev.c 프로젝트: timburrow/ovj3
void vapread(int rtparam, int addrreg, double apsyncdelay)
{
    int ticks,secs;
    short *ptr;

    if (!newacq)
    {
	text_error("Warning: vapread available only on Inova systems.\n");
	text_error("         vapread ignored.\n");
	return;
    }
    
    timerwords(apsyncdelay,&ticks,&secs);

    putcode((c68int)IAPREAD);
    putcode((c68int)addrreg);
    putcode((c68int)rtparam);
    ptr = (short *) &secs;
    putcode((codeint) *ptr);	/* timerword one */
    ptr++;
    putcode((codeint) *ptr);	/* timerword one */
    ptr = (short *) &ticks;
    putcode((codeint) *ptr);	/* timerword one */
    ptr++;
    putcode((codeint) *ptr);	/* timerword one */
	
}
예제 #11
0
/* ------------------------------------------------------------------------ */
void
encode_p_st0(unsigned short j)
{
    unsigned short  i;

    i = j >> 6;
    putcode(pt_len[i], pt_code[i]);
    putbits(6, j & 0x3f);
}
예제 #12
0
pre_fidsequence()
{
    int chan;
    int attn;

    chan = 1;

    if (find("tupwr") == -1){   /* Optional parameter "tupwr" sets tune pwr */
        attn = 60;
    }else{
        attn = (int)getval("tupwr");
    }

    /* Start tune mode */
    putcode(TUNE_START);
    putcode(chan);
    putcode(attn);
    delay(0.01);
}
예제 #13
0
파일: apuserdev.c 프로젝트: timburrow/ovj3
/*--------------------------------------------------------------*/
void signal_acqi_updt_cmplt()
{
    if (!newacq)
    {
	text_error("Warning: signal_acqi_updt_cmplt available only on Inova systems.\n");
	text_error("         signal_acqi_updt_cmplt ignored.\n");
	return;
    }
    putcode((c68int)IACQIUPDTCMPLT);
}
예제 #14
0
파일: leds.c 프로젝트: BASM/super-clock
int leds_put(unsigned char num, unsigned char dot){
#define DOTNUM (1<<7)
    // 0 -- '-'
    // 1 -- left up
    // 2 -- up
    // 3 -- rigth up
    // 4 -- left down
    // 5 -- down
    // 6 -- rigth down
    //    .   RD  D   LD  RU  U   LU  -
    // 0  0   1   1   1   1   1   1   0
    // 1  0   1   0   0   1   0   0   0
    // 2  0   0   1   1   1   1   0   1
    // 3  0   1   1   0   1   1   0   1
    // 4  0   1   0   0   1   0   1   1
    // 5  0   1   1   0   0   1   1   1
    // 6  0   1   1   1   0   1   1   1
    // 7  0   1   0   0   1   1   0   0
    // 8  0   1   1   1   1   1   1   1
    // 9  0   1   1   0   1   1   1   1
    // A  0   1   0   1   1   1   1   1
    // B  0   1   1   1   1   1   1   1
    // C  0   0   1   1   0   1   1   0
    // D  0   1   1   1   1   1   1   0
    // E  0   0   1   1   0   1   1   1
    // F  0   0   0   1   0   1   1   1
    // -  0   0   0   0   0   0   0   1
      //                 0    1     2     3     4     5     6     7     8     9
      //                 -   
  unsigned char ARA[]={0x7e, 0x48, 0x3d, 0x6d, 0x4b, 0x67, 0x77, 0x4c, 0x7f, 0x6f,
      //                
      //                 A    B     C     D     E     F     -
                       0x5f, 0x7f, 0x36, 0x7e, 0x37, 0x17, 0x01, 0x00};

  if(num>sizeof(ARA))
    return -1;

  if(dot)  putcode(ARA[num]|DOTNUM);
  else     putcode(ARA[num]);

  return 0;
}
예제 #15
0
파일: apuserdev.c 프로젝트: timburrow/ovj3
/*--------------------------------------------------------------*/
void start_acqi_updt(double delaytime)
{
    if (!newacq)
    {
      text_error("Warning: start_acqi_updt available only on Inova systems.\n");
      text_error("         start_acqi_updt ignored.\n");
      return;
    }
    delay(delaytime);
    putcode((c68int)ISTARTACQIUPDT);
}
예제 #16
0
/*
 * Load an APBOUT string into the Acode stream
 */
static void
send_apbout_string(codeint *apb)
{
    int len;
    codeint *apend;

    if (apb){
        len = apb[1] + 1; /* Count word is (length - 1) */
        apend = apb + len + 2;  /* Include 2 hdr words (APBOUT + count) */
        while (apb < apend){
            /*fprintf(stderr,"0x%04x\n", (int)*apb & 0xffff);     */
            putcode(*apb++);
        }
        curfifocount += len;
    }
}
예제 #17
0
/*-------------------------------------------------------------------
|
|	endhardloop()/1 
|	This ends a hardware loop.
|	hwlooping flag is unset.
|	# of fifo words in the hardwarre loop are calculated 
|	 1. setICM is inserted in nop, if this loop acquires data
|	     and no previous hardware loop did.
|	 2. # of fifo words in hardware loop is set.
|	 3. enable interrupt is nulled if only one hardware loop
|	    exists.
|	
|				Author Greg Brissey  7/10/86
|
|   Modified   Author     Purpose
|   --------   ------     -------
|   6/15/89   Greg B.     1. Use new global parameters to calc acode offsets 
+------------------------------------------------------------------*/
void endhardloop()
{
    codeint fifowords;
    double timeofloop,time4load;

    if(bgflag)
	fprintf(stderr,"endhardloop(): \n");
    if (!hwlooping)
    {
	text_error("Missing starthardloop \n");
	psg_abort(0);
    }
    hwlooping = FALSE;	/* not hardware looping any more, mark it */
    fifowords = curfifocount - starthwfifocnt;
    if (fifowords == 0)  /* No pulse elements in hardware loop. */
    {
	codeint *tmpptr;

	text_error("Warning No pulse elements in Hardware loop.\n");
	/* --- NO_OP out the hardware loop --- */
	/* tmpptr = codestadr + hwloop_ptr; */ /* get address into codes */
	tmpptr = Aacode + hwloop_ptr; /* get address into codes */
	*tmpptr++ = NO_OP;	/* NO_OP the HWLOOP Acode */
	*tmpptr++ = NO_OP;	/* NO_OP out hwloop variables */
	*tmpptr++ = NO_OP;	/* NO_OP out hwloop variables */
	*tmpptr++ = NO_OP;	/* NO_OP out hwloop variables */
    }
    else
    {
	codeint *tmpptr;
        char     mess[80];

	if (fifowords > fifolpsize)
	{
            sprintf(mess,
	      "Hardware loop exceeds max fifo words. %d > %d Max.\n",
                fifowords,fifolpsize);
            text_error(mess);
	    psg_abort(0);
	}
	/* tmpptr = codestadr + hwloop_ptr + 1; */
	tmpptr = Aacode + hwloop_ptr + 1;
	*tmpptr = fifowords;

        timeofloop = totaltime - fifostarttime; /* total delays in loop */
        time4load = ( (double)fifowords) * PF2FTIME; /* time to load loop */
        if ( (bgflag) && (prevlooptime != -1.0) )
           fprintf(stderr,
           "%8.1lf usec for loop to empty, %8.1lf usec to load next %d word loop.\n",
           prevlooptime * 1.0e6,time4load * 1.0e6,fifowords);
        if ( (prevlooptime != -1.0) && (prevlooptime <= time4load) )
           fprintf(stdout,
           "Warning: Time between hardware loops maybe insufficient.\n");
        prevlooptime = timeofloop;

	/* inova needs end hardware loop code.  It checks for number 	*/
	/* of fifowords in hw loop down in the console.			*/
	if (newacq)
	{
	   putcode(EHWLOOP);
	   if (acqinhwloop == TRUE)
	   {
		putcode(DISABLEOVRFLOW);
		putcode(adccntrl);
 	   }
	}

	acqinhwloop = FALSE;	/* Always set to FALSE */

	/* Add time to totaltime.  The time to add is only for the 	*/
	/* loops greater than one.  The first loop has already been 	*/
	/* added to the totaltime. 					*/
	if (hwloopcnt4time > 1)		
	   totaltime += (timeofloop * (hwloopcnt4time - 1));
    }
    setSSHAreenable();
}
예제 #18
0
파일: apuserdev.c 프로젝트: timburrow/ovj3
/*--------------------------------------------------------------*/
void setnumpoints(codeint rtindex)
{
   putcode(ISETNP);	/*  */
   putcode((codeint)rtindex);
   putcode((codeint)dtmcntrl);
}
예제 #19
0
파일: init_game.c 프로젝트: elboza/WiCE
void init_game()
{
	struct array_mem_small *msmall;
	struct array_mem_mid *mmid;
	struct array_mem_norm *mlarge;
	struct Process *proc;
	struct instruction_node *in;
	struct process_thread *pthread;
	struct process_task *ptask;
	int next_offs,proc_offs,pos;
	double xx,lato_x,lato_y;
	if(arena_mem_type==MEM_TYPE_ONE)
	{
		msmall=(struct array_mem_small*)malloc(sizeof(struct array_mem_small)*size_arena);
		if(msmall==NULL) die("error malloking small array mem");
		bzero(msmall,sizeof(struct array_mem_small)*size_arena);
		arena=msmall;
	}
	if(arena_mem_type==MEM_TYPE_TWO)
	{
		mmid=(struct array_mem_mid*)malloc(sizeof(struct array_mem_mid)*size_arena);
		if(mmid==NULL) die("error malloking mid array mem");
		bzero(mmid,sizeof(struct array_mem_mid)*size_arena);
		arena=mmid;
	}
	if(arena_mem_type==MEM_TYPE_FOUR)
	{
		mlarge=(struct array_mem_norm*)malloc(sizeof(struct array_mem_norm)*size_arena);
		if(mlarge==NULL) die("error malloking large array mem");
		bzero(mlarge,sizeof(struct array_mem_norm)*size_arena);
		arena=mlarge;
	}
	next_offs=0;
	for(proc=proc_primo;proc;proc=proc->next)
	{
		//calc offset in mem
		proc_offs=(next_offs+(rand()%min_distance))%size_arena;
		//put in mem
		pos=proc_offs;
		for(in=proc->pc->first;in;in=in->next)
		{
			putcode(pos++,proc->processID,in->code);
		}
		//create pt
		pthread=(struct process_thread*)malloc(sizeof(struct process_thread));
		if(pthread==NULL) die("error alloking new thread");
		pthread->IP=proc_offs+(atoi(proc->pc->org));
		pthread->communication_in_a=0;
		pthread->communication_out_a=0;
		pthread->communication_in_b=0;
		pthread->communication_out_b=0;
		pthread->prev=NULL;
		pthread->next=NULL;
		pthread->ptask=NULL;
		ptask=(struct process_task*)malloc(sizeof(struct process_task));
		if(ptask==NULL) die("error alloking new task");
		ptask->ID=proc->processID;
		ptask->n_threads=1;
		ptask->prev=NULL;
		ptask->next=NULL;
		ptask->primo_thread=NULL;
		ptask->ultimo_thread=NULL;
		ptask->cur_thread=pthread;
		ptask->communication_in_a=0;
		ptask->communication_out_a=0;
		ptask->communication_in_b=0;
		ptask->communication_out_b=0;
		get_symbols(&ptask->out_symbol,&ptask->out_color);
		//add pt
		add_thread(pthread,ptask);
		add_task(ptask);
		//recalc next_offs
		next_offs+=proc_offs+proc->pc->len;
		//free proc&pc
		in=proc->pc->first;
		do{
			if(in->left) free_expr(in->left);
			if(in->right) free_expr(in->right);
			if(in->code) free(in->code);
			if(in->next) {in=in->next;free(in->prev);}
			else {free(in);in=NULL;}
		}while(in!=NULL);
	}
	xx=sqrt(size_arena);
	lato_y=rint(xx);
	lato_x=ceil(xx);
	max_x=(int)lato_x;
	max_y=(int)lato_y;
	if(output_mode>=OUTPUT_DEBUG)
	{
		sprintf(out_str,"max_x=%d max_y=%d\n",max_x,max_y);
		fputs(out_str,fpout);
	}
	//init_graph
	if(vo_mode==VO_FRAMEBUFFER) init_txt();
	if(vo_mode==VO_X11) init_x11();
}
예제 #20
0
/*-------------------------------------------------------------------
|
|	test4acquire() 
|	check too see if data has been acquired yet.
|	if it has not then do an implicit acuire.
|	else do not.
|				Author Greg Brissey  7/10/86
+------------------------------------------------------------------*/
void test4acquire()
{
    int	    i;
    int	    chan;
    int     MINch;
    double  acqdelay;	/* delay time between receiver On an data acquired*/
    codeint *tmpptr;	/* temp pointer into codes */
    extern void prg_dec_off();
    double truefrq=0.0, dqdfrq=0.0;
    char osskip[4];

    if (bgflag)
	fprintf(stderr,"test4acquire(): acqtriggers = %d \n",acqtriggers);
    if (acqtriggers == 0)	/* No data acquisition Yet? */
    {
	if (nf > 1.0)
	{
	    text_error("Number of FIDs (nf) Not Equal to One\n");
	    psg_abort(0);
	}
        if (ap_interface < 4)
	   HSgate(rcvr_hs_bit,FALSE);	/* turn receiver On */
	else
           SetRFChanAttr(RF_Channel[OBSch], SET_RCVRGATE, ON, 0);

	if (newacq)
        {
           /* execute osskip delay if osskip parameter set */
           if ((P_getstring(GLOBAL,"qcomp",osskip,1,2)) == 0)
           {
             if (osskip[0] == 'y')
             {
               /* fprintf(stderr,"hwlooping:test4acquire(): executing dsposskipdelay= %g\n", dsposskipdelay); */
               if (dsposskipdelay >= 0.0) G_Delay(DELAY_TIME, dsposskipdelay, 0);
             }
           }

           HSgate(INOVA_RCVRGATE,FALSE);        /* turn receiver On */
        }

	/* txphase(zero);	*/	/* set xmitter phase to zero */
	/* decphase(zero);	*/	/* set decoupler phase to zero */
	/* acqdelay = alfa + (1.0 / (beta * fb) ); */

	for (i = 1; i <= NUMch; i++)  /* zero HS phaseshifts */
	   SetRFChanAttr(RF_Channel[i], SET_RTPHASE90, zero, 0);

	if ((!noiseacquire) && (dsp_params.il_oversamp > 1))
	   find_dqdfrq(&truefrq, &dqdfrq);
	if (fabs(dqdfrq) > 0.1)
	   set_spare_freq(OBSch); 
/*	   obsoffset(truefrq+dqdfrq); */

	acqdelay = alfa + (1.0 / (beta * fb) );
	if (acqdelay > ACQUIRE_START_DELAY)
	   acqdelay = acqdelay - ACQUIRE_START_DELAY;
	if ((fabs(dqdfrq) > 0.1) && (acqdelay > 1.7e-6)) /* more like 40us?? */
	    acqdelay = acqdelay - 1.7e-6;

        if ((acqdelay < 0.0) && (ix == 1))
	   text_error("Acquisition filter delay (fb, alfa) is negative (%f).\n",
             acqdelay);
        else
	   G_Delay(DELAY_TIME,acqdelay,0);	/* alfa delay */
	acquire(np,1.0/sw);	/* acquire data */

	MINch = (ap_interface < 4) ? DODEV : TODEV;
	for (chan = MINch; chan <= NUMch; chan++)
	{
           if ( is_y(rfwg[chan-1]) )
           {
	      if ( (ModInfo[chan].MI_dm[0] == 'n') ||
                   ((ModInfo[chan].MI_dm[0] == 'y') &&
		    (ModInfo[chan].MI_dmm[0] != 'p')) )
              {
                 prg_dec_off(2, chan);
              }
           }
        }

	tmpptr = Aacode + multhwlp_ptr; /* get address into codes */
	*tmpptr = 1;		/* impliicit acquisition */
    }
    if (newacq)
    {
	if (explicitacq)
	{
              codeint *ptr;
	      /* update last acquire with disable overload */;
    	      ptr = Aacode + disovld_ptr;
	      *ptr++ = DISABLEOVRFLOW;
      	      *ptr = adccntrl;
	}
	/* Always set to FALSE for the next array element */
	explicitacq = FALSE;
    }

    if (grad_flag == TRUE) 
    {
      zero_all_gradients();
    }
    if (newacq)
    {
      gatedecoupler(A,15.0e-6);	/* init to status A conditions */
      statusindx = A;
    }
    putcode(STFIFO);	/* start fifo if it already hasn't */
    putcode(HKEEP);		/* do house keeping */
    if (newacq)
    {
      if ( getIlFlag() )
      {
	ifzero(ilflagrt);
    	   putcode(IFZFUNC);	/* brach to start of scan (NSC) if ct<nt */
	   putcode((codeint)ct);
	   putcode((codeint)ntrt);
    	   putcode(nsc_ptr);	/* pointer to nsc */
	elsenz(ilflagrt);
     	   add(strt,one,tmprt);	
   	   putcode(IFZFUNC);	/* brach to start of scan (NSC) if ct<strt+1 */
	   putcode((codeint)ct);
	   putcode((codeint)tmprt);
    	   putcode(nsc_ptr);	/* pointer to nsc */
	   modn(ct, bsval, tmprt);
    	   putcode(IFZFUNC);	/* brach to start of scan (NSC) if ct%bs */
	   putcode((codeint)zero);
	   putcode((codeint)tmprt);
    	   putcode(nsc_ptr);	/* pointer to nsc */
	endif(ilflagrt);
      }
      else
      {
    	   putcode(IFZFUNC);	/* brach to start of scan (NSC) if ct<nt */
	   putcode((codeint)ct);
	   putcode((codeint)ntrt);
    	   putcode(nsc_ptr);	/* pointer to nsc */
      }
    }
    else
    {
    	putcode(BRANCH);	/* brach back to start of scan (NSC) */
    	putcode(nsc_ptr);	/* pointer to nsc */
    }
}
예제 #21
0
/*-------------------------------------------------------------------
|
|	acquire(datapts,dwell) 
|	acquire data.
|	If acquire is in a hardware loop number of data pts w/ # timer
|	 words needed for dwell arechecked tobe sure the number of fifo 
|	 words needed collect the data is not too big for a hardware loop.
|	 Then the curfifocount is updated accordingly.
|        If this is the first acquire set the input IC mode.
|	If the acquire in not in a hardware loop, set the input card IC
|	 mode if this is the frist acquire nad not a noise acquire.
|	 update the curfifocount by 32, there 32 fifo words in an
|	 acquire loop.
|	Generate the proper Acodes for the acquire..
|	set the valid hardware loop flag 
|				Author Greg Brissey  7/10/86
+------------------------------------------------------------------*/
void acquire(double datapts, double dwell)
{
    int ntwords;		/* number of timer words */
    int tword1;			/* timer word one */
    int tword2;			/* timer word two */
    int nptop;			/* top word of datapts */
    int npbot;			/* bot word of datapts */
    int pairs;			/* number of ctc's */
    int fifowrds;		/* # fifo words required for acquire */
    int implicitlpsize;		/* the implicit acquisition fifo looping size */
    int nloops;
    int explicit_acquire_flag;
    double save_dwell = 0.0;
    double truefrq=0.0, dqdfrq=0.0;

    if (bgflag)
	fprintf(stderr,"acquire(): data pts: %lf, dwell: %le \n",
		datapts,dwell);
    explicit_acquire_flag =
	(!noiseacquire && ((int) (datapts + 0.5) != (int) (np+0.5)));
    if (dsp_params.il_oversamp > 1) /* In-line DSP */
    {
       if ( noiseacquire )
          ;  /* Do nothing special */
       else if ( explicit_acquire_flag )
          turnoff_swdsp();
       else
       {
          /*datapts *= (double) dsp_info[1];*/
          /*datapts += (double) dsp_info[3];*/
          /*dwell   /= (double) dsp_info[1];*/
          datapts *= (double) dsp_params.il_oversamp;
          datapts += (double) dsp_params.il_extrapts;
          dwell   /= (double) dsp_params.il_oversamp;
       }
       if (bgflag)
         fprintf(stderr, "after in-line DSP: datapts: %lf\n", datapts );
    }

/*  if (dsp_info[0] >= 1)  Real time DSP */
    if (dsp_params.rt_oversamp > 1) /* Real time DSP */
    {
       if ( noiseacquire && ((int) (datapts + 0.5) != 256) )
          turnoff_hwdsp();
       else if ( explicit_acquire_flag )
          turnoff_hwdsp();
       else
       {
          /*datapts *= (double) dsp_info[1];*/
          datapts *= (double) dsp_params.rt_oversamp;
          /*datapts += (double) dsp_info[3];*/
          datapts += (double) dsp_params.rt_extrapts;
          save_dwell = dwell;
          /*dwell   /= (double) dsp_info[1];*/
          dwell   /= (double) dsp_params.rt_oversamp;
       }
    }
    if (!explicit_acquire_flag)
        find_dqdfrq(&truefrq, &dqdfrq);

    if (dwell < 2.0e-7)
    {
	text_error("acquire(): dwell time must be larger than 2e-7\n");
	psg_abort(0);
    }
    if (datapts < 1.5)
    {
	text_error("must acquire at least two (one pair) data points\n");
	psg_abort(0);
    }
    timerwords(dwell,&tword1,&tword2); /* obtain timer words for dwell */
    ntwords = (tword2 == 0) ? 1 : 2;
    pairs = (int) (datapts + 0.005) / 2;
    acqtriggers++;	/* increment number acquisitions performed */

    if (ap_interface < 4)
       HSgate(rcvr_hs_bit,FALSE);
    else
    {
        if (newacq)
	   HSgate(INOVA_RCVRGATE,FALSE);	/* Turn receiver On */
	else
           SetRFChanAttr(RF_Channel[OBSch], SET_RCVRGATE, ON, 0);
    }
    if (hwlooping)	/* an acquire in a hardware loop ? */
    {
	acqinhwloop = TRUE;
	if ( ((ntwords == 1) && (pairs > fifolpsize)) ||	
	     ((ntwords == 2) && (pairs > (fifolpsize/2))) )
	{
	    text_error("Too many data points to acquire in hardware loop.\n");
	    psg_abort(0);
	}
	else
	{	/* increment fifocount for the CTCs that will be generated */
	    curfifocount += ntwords * pairs;
	}
	if (acqtriggers == 1)
        {
            codeint *ptr;

            ptr = Aacode + hwloop_ptr - 1;
            *ptr = SETICM;
        }
    }
    else	/* an acquire outside a hardware loop */
    {
/*        if (fabs(dqdfrq) > 0.1)
	    obsoffset(truefrq+dqdfrq);
	    set_spare_freq(OBSch); 
*/
	if ( (acqtriggers == 1) && (! noiseacquire))
	{
	    putcode(SETICM);		/* Acode to set up input card mode */
	}
	if (fifolpsize < 64)
	    curfifocount += 32;		/* acquire generates 32 fifo word loop  */
	else
	{
	    implicitlpsize = fifolpsize / 8;
	    fifowrds = (pairs * ntwords);
	    nloops =  fifowrds / implicitlpsize;  /* fifowords / loop_size = lp cnt */
	    curfifocount += implicitlpsize; /* acquire generates implicit word lp */
	    curfifocount += fifowrds - (nloops * implicitlpsize);
	}
    }

    /* --- type of acquire: data or noise --- */
    if (!noiseacquire)
	putcode(EXACQT);		/* acqop Acode */
    else
	putcode(NOISE);			/* noiseop Acode */

/*
 *  Remove output board differences
 *  new OB don't output HSlines, gate() does it
 *
 *    if (fifolpsize < 512)
 *       putcode((codeint) HSlines);
 *
 */

    multhwlp_ptr = (codeint) (Codeptr - Aacode);/*save location for use */
    if (hwlooping)
	putcode(0);		/* tell apio acqop not to use hardware loop */
    else
	putcode(2);		/* tell apio acqop to use hardware loop */

    convertdbl(datapts,&nptop,&npbot);
    putcode((codeint) nptop);		/* top word # of cmplx pts to take */
    putcode((codeint) npbot);		/* bot word # of cmplx pts to take */
    if (newacq)
    {
        putLongCode(tword1);    /* timerword one */
    }
    else
    {
    putcode((codeint) tword1);		/* first timer word */
    putcode((codeint) tword2);		/* second timer word */
    }

    /* add acquisition time to total time */
    checkpowerlevels(datapts * dwell / 2.0);
    if (newacq && (save_dwell > 0.0) )
    {
       /* add an extra dwell period for DSP hardware */
       if (noiseacquire)
       {
          timerwords(save_dwell,&tword1,&tword2);
          noise_dwell = tword1;
       }
       else
       {
          delay(save_dwell);
       }   
    }
    totaltime += (datapts * dwell / 2.0);
 
    /* turn receiver off if receiver off flag is enabled */
    if (newacq)
    {
	if (rcvroff_flag)
	   HSgate(INOVA_RCVRGATE,TRUE);	/* turn receiver Off */
    }

    /* --- disable ADC & Receiver OverLoad --- */
    if (newacq)
    {
      if ((acqinhwloop == FALSE) && (!noiseacquire))
      {
	   explicitacq = TRUE;
    	   disovld_ptr = (codeint) (Codeptr - Aacode); /* save location */
    	   putcode(0);	/* nop to change to a DISABLEOVRFLOW acode */
    	   putcode(0);	/* nop to change to a DISABLEOVRFLOW acode */
      }

    }
    if (fabs(dqdfrq) > 0.1) 
/*	set_std_freq(OBSch); */
	obsoffset(truefrq);
    if (bgflag) 
        fprintf(stderr,"acquire(): time = %lf totaltime = %lf\n",
	    datapts*dwell / 2.0,totaltime);

}
예제 #22
0
/*------------------------------------------------------------------
|
|	initHSlines()
|	initialize the acquisitions High Speed Lines to their
|	initial safe state. This state is also store in the structure
|	acqparams section of code for the acquisition CPU 
|       Note: HSlines is passed to acquisition in EVENT1 & EVENT2 
|	      Acodes, only then are the lines actually set
|				Author Greg Brissey 6/26/86
|
|   Modified   Author     Purpose
|   --------   ------     -------
|   6/15/89   Greg B.     1. Use new global parameters to calc acode offsets 
+-----------------------------------------------------------------*/
initHSlines()
{
    codeint *ptr;		/* pointer for Codes array */
    extern void init_pgd_hslines();
    extern void reset_decstatus();

    /* --- initialize quiescent states --- */
    /* --- establish start and current quiescent HSline states --- */

    init_pgd_hslines(&HSlines);

    /* init to status A conditions, but leave decoupler on only for dm='a' */
    setPostExpDecState(A,0.0);
    statusindx = A;

    sync_flag=0;
    reset_decstatus();

    if (newacq)
    {
	recon();		/* receiver on for safe state at end. */
	putcode(INITHSL);
        putcode( ((HSlines >> 16) & 0xffff) );	/* high order word */
        putcode( (HSlines & 0xffff) );		/* low order word */
	putcode(ISAFEHSL);
        putcode( ((HSlines >> 16) & 0xffff) );	/* high order word */
        putcode( (HSlines & 0xffff) );		/* low order word */
    }

    /*------------------------------------------------------------------*/
    /* if inova, turn receiver off. Yes, the receiver gate is active	*/
    /* low. The default state of the receiver is on which means the 	*/
    /* gate is off.  The current exception is for 4T & 3T systems. 	*/
    /*------------------------------------------------------------------*/
    if (newacq)
    {
	double tmpshimset;
	if ( P_getreal(GLOBAL,"shimset",&tmpshimset,1) < 0 )
	{
	   tmpshimset = 1.0;
	}
	if ((int)(tmpshimset) == WHOLEBODY_SHIMSET)
	{
	   /*---------------------------------------------------*/
	   /* default receiver on in order for WHOLEBODY T/R	*/
	   /* switch to work correctly.	Currently the only way	*/
	   /* to determine a wholebody system is the shimset.	*/
	   /*---------------------------------------------------*/
	   recon();
	}
	else
	{
	   recoff();	/* default receiver Off for all other systems */
	}

    }

    /* start quiencent state contain dm,dmm and dhp HS settings */
    set_lacqvar(HSlines_ptr, HSlines);
    if (newacq)
        init_acqvar(HSlines_ptr, HSlines); 

    if (bgflag)
        fprintf(stderr,
	 "initHSlines(): HSlines: 0x%x \n", HSlines);
}