Example #1
0
File: gr909.c Project: aircross/ray
void RENtest (  unsigned short *ren)
{  
	unsigned short max=0, i, readingILOOP;

//	doReset();
//	initialize(); 
//	changeCID(0);
	writeRam(VOC,0X1000);
	writeRam(SBIAS, 0X61);  // TURN OFF SLOW FEED
	writeReg(LINEFEED,1);  // Go to Active
	
	delay (1000);
	writeRam(VOC, 0x800);

	delay(20);
	for (i=0;i<30	;i++)
	{
	
		readingILOOP =  0x7fff& readRam(ILOOP);
		max = (readingILOOP>max)?readingILOOP:max;

	}

	*ren = max /240;
	if (*ren >5)
		printf("\nRen >5");
	else if ((*ren) ==0)
		LowREN();
	else
		printf("\nRen = %i",*ren);
	delay (1000);

}
Example #2
0
File: gr909.c Project: aircross/ray
int LowREN( void)  
{
	unsigned short a[200], i ;
//	doReset();
//	initialize(); 
//	changeCID(0);

	writeRam(VOC,3*TENVOLTINC);
	writeRam(SBIAS, 0X61);  // TURN OFF SLOW FEED
	writeReg(LINEFEED,1);  // Go to Active
	writeRam(DIAGDCCO,0X1fFF);


	delay(40);
	writeReg(LINEFEED,0);
	delay(100);
	for(i=0;i<200; i++)
	{
		delay (2);
		a[i] = readRam(VRING);
	}


	if  (((a[0]-a[4]) < 300)  && (a[4] >3410))
	{

		printf("\t\t\t\t\nREN between .175 and 1");
		return(-1);

	}

	printf("\t\t\t\t\nREN < .175");
	return(0);

}
Example #3
0
File: gr909.c Project: aircross/ray
void tipRingCurrentOverVoltageRev( short currents[])  // 0 to 50 volts in 5 volt increments
{ 
	unsigned short vocValue =0 , i ;
//	doReset();
//	initialize();  /* initialize one Dual ProSLIC */
	writeRam(VCM,0);
	writeRam(VOC,TENVOLTINC);
	writeRam(VOCDELTA,0);
	writeRam(SBIAS, 0X61);  // TURN OFF SLOW FEED
	writeReg(LINEFEED,5);  // Go to Active
	writeReg(DIAG,0XCC) ; // High Preciscion current loop current
	writeRam(DIAGDCCO,0X20);
	for ( vocValue = TENVOLTINC, i=0 ; i < 5; i++) 
	{

		delay(20);
		writeRam(VOC, vocValue); // Write out voltages starting with zero and going to 50 volts
		vocValue += TENVOLTINC;
		
		writeRam(DIAGDCCO,FLUSH);
		delay(100);
		writeRam(DIAGDCCO,LPFPOLE);
		delay(PROCESSING);
		currents[i] = readRam(DIAGDC);
		
	}
	printf("\n  TiptoRing =");
	for (i=0;i<5;i++) printf(" %d ",  currents[i]);
}
Example #4
0
File: gr909.c Project: aircross/ray
void logitudinalCurrentOverVoltageReverseAcitive(unsigned short currents[])  // 0 to 50 volts in 5 volt increments
{ 
	unsigned short vcmValue =0 , i ;
	writeReg(LINEFEED,5);  // Go to Reverse Active
	delay (30);
	writeReg(DIAG,0XCD);  // High Preciscion current loop current
	writeRam(VOC, 0 );
	for ( vcmValue = 0, i=0 ; i < 50; i++) 
	{
		writeRam(VCM, vcmValue); // Write out voltages starting with zero and going to 50 volts
		vcmValue += ONEVOLTINC;
		delay(40000/64);
		currents[i] = readRam(DIAGDC);
	}

}
Example #5
0
File: gr909.c Project: aircross/ray
void RTRringopen ( )  // 0 to 50 volts in 5 volt increments

{ 
#ifdef PCM_SLIC_FLOAT		
	double tipVoltage,ringVoltage, rrgdiv, tipRingVoltage,rrgdiv2;
//	doReset();
//	changeCID(0);
//	initialize();  /* initialize one Dual ProSLIC */
	writeRam(VCM,0);

	writeRam(VOC,TENVOLTINC);
	writeRam(SBIAS, 0X61);  // TURN OFF SLOW FEED
	writeReg(LINEFEED,5);  // Go to Active
	writeRam(VOC,5*TENVOLTINC/3 ); // Write out voltages starting with zero and going to 50/3 ; this is the expected voltage on the high imp resistor
//	delay (100);
	writeReg(LINEFEED,7);
	writeRam(VOC,5*TENVOLTINC );
		delay(1000);// wait a long time for capassitance to settle
		ringVoltage = -1 *.00492 * (float) readRam(VRING);
		tipVoltage = -1 * .00492 * (float) readRam(VTIP);
		tipRingVoltage = tipVoltage-ringVoltage;
		rrgdiv = ((tipRingVoltage)/((ringVoltage-1.5)/402));
		rrgdiv = rrgdiv*1000;
		rrgdiv2 = (rrgdiv*800000)/(800000-rrgdiv);
	writeRam(VOC,2 * TENVOLTINC); // step through voltage slowly to avoid ringing ringer
	writeRam(VOC,0);
	
	printf("\nR T-Rringopen = %.0f ohms", rrgdiv2);
#endif
}
Example #6
0
File: gr909.c Project: aircross/ray
int lineCap ( void)  

{

	// This function requires calibration per applicaton 
	const double constanttime = 8.30565e-10;
	__s64 time1,time2;
	unsigned short sum=0 ,   i , sixtyVolts, fiftyFiveVolts;
#ifdef PCM_SLIC_FLOAT		
	double finaltime,capValue;
#endif	
	
//	doReset();
//	changeCID(0);
//	initialize();
	
	writeRam(VCM,0);
	writeReg(ILIM,5);
	
	writeRam(SBIAS, 0x61);  // TURN OFF SLOW FEED

	writeReg(LINEFEED,5);  
	for (i=0;i<12;i++){
		writeRam(VOC,(unsigned short) ((i/2)*TENVOLTINC));
		delay(50);
	}
	writeRam(VOC,6*TENVOLTINC);
	delay(50);
	sixtyVolts=readRam(VTIP);
	writeRam(VOC,11*TENVOLTINC/2);
	delay(50);
	fiftyFiveVolts=readRam(VTIP);	

	time1=readTSC(); //record initial time 
	for(i=0;i<50;i++)
	{
		writeRam(VOC,6*TENVOLTINC);
		while(readRam(VTIP)!=sixtyVolts);
		writeRam(VOC,11*TENVOLTINC/2);
		while (readRam(VTIP)!=fiftyFiveVolts);
	}
	
	time2=readTSC();//record final time
	time2-=time1;
	
	writeReg(LINEFEED,0); 
	delay(50);
	printf(" \n Time = %I64i",time2);
#ifdef PCM_SLIC_FLOAT	
	time2-=beta; //subtract beta, see AN71
	
	finaltime = (double) time2;
	capValue = (finaltime/alpha)*1e6;//divide alpha, see AN71	
	//output capicatance
	printf("\n Cap = %f uF  ",  capValue);
#endif	
	return(0);		
	
}
void DisplayImpl::clear(Point p1, Point p2, Color color)
{
    imageWindow(p1,p2);
    writeIdx(0x22);//Write to GRAM
    int numPixels=(p2.x()-p1.x()+1)*(p2.y()-p1.y()+1);
    int fastPixels=numPixels/2;
    unsigned int twoPixColor=color | color<<16;
    for(int i=0;i<fastPixels;i++) DISPLAY->TWOPIX_RAM=twoPixColor;
    if(numPixels & 0x1) writeRam(color);
}
Example #8
0
File: gr909.c Project: aircross/ray
int fusePresent ( short scratch[])  // 0 to 50 volts in 5 volt increments

{ 
	unsigned short vocValue ,  average, i ,sum=0 ;
//	doReset();
//	initialize();  /* initialize one Dual ProSLIC */
	writeRam(VCM,0);

	writeRam(VOC,TENVOLTINC);
	writeRam(SBIAS, 0X61);  // TURN OFF SLOW FEED
	writeReg(LINEFEED,7);  // Go to Active
	for ( vocValue = TENVOLTINC, i=0 ; i < 5; i++) 
	{
		delay(20);
		writeRam(VOC, vocValue); // Write out voltages starting with zero and going to 50 volts
		delay(100);
		//currents[i] = readRam(VTIP);
		scratch[i] = readRam(VRING);
		vocValue += TENVOLTINC;	
	}
	printf("\n FusePresent  =");
	for (i=1;i<5;i++)
	{
	 printf(" %d ",  scratch[i]-scratch[i-1]);
	 sum+=scratch[i];
	}
	
	{
		 if (scratch[i] == 0)
		 {
			 printf("\n\t\t\t ++++Fuse Blown+++");
			 return 0;
		 }
		
		average=sum/4;
		printf("\n average = %d",average);
		printf("\n\t\t\t ---%s---", (abs(average-660) < 80) ? "No Phone Attached": "Line or Load Attached");
	}
	return((abs(average-660) < 80));
}
Example #9
0
uint8_t GameduinoSPIClass::transfer(uint8_t data)
{
    if (isSlaveSelected())
    {
        if (s_WaitAddr == 0)
        {
            int cAddr = s_CurrentAddress;
            ++s_CurrentAddress;
            if (s_Writing)
            {
                writeRam(cAddr, data);
            }
            else
            {
                return readRam(cAddr);
            }
        }
        else if (s_WaitAddr == 2)
        {
            uint8_t writing = data & 0x80;
            uint8_t hb = data - writing;
            s_CurrentAddress = hb;
            s_CurrentAddress <<= 8;
            s_Writing = (writing == 0x80);
            --s_WaitAddr;
        }
        else if (s_WaitAddr == 1)
        {
            s_CurrentAddress |= data;
            /*uint8_t writing = data & 0x80;
            int hb = data & 0x7F;
            s_CurrentAddress |= (data << 8);
            s_Writing = (writing == 0x80);*/
            // printf("%s @ %i\r\n", s_Writing ? "WRITE" : "READ", s_CurrentAddress);
            --s_WaitAddr;
        }
        return 0;
    }
    else if (digitalRead(2) == LOW && s_GdRam[IOMODE] == 'F')
    {
        // dummy stuff for satisfying selftest.cpp
        if (data == 0 && s_CurrentAddress == 0xd7)
            return 0x94;
        s_CurrentAddress = data;
        return 0;
    }
    else
    {
        return 0;
    }
}
Example #10
0
File: gr909.c Project: aircross/ray
void RTG ( )  // 0 to 50 volts in 5 volt increments

{ 
#ifdef PCM_SLIC_FLOAT		
	double tipVoltage,ringVoltage,tipcurrent, rrgdiv, rrgImeth, rrgout, RingtipVoltage;

//	doReset();
//	changeCID(0);
//	initialize();  /* initialize one Dual ProSLIC */
	writeRam(VCM,0);

	writeRam(VOC,TENVOLTINC);
	writeRam(SBIAS, 0X61);  // TURN OFF SLOW FEED
	writeReg(LINEFEED,5);  // Go to Active
	writeRam(VOC,5*TENVOLTINC/3 ); // Write out voltages starting with zero and going to 50/3 ; this is the expected voltage on the high imp resistor
//	delay (100);
	writeReg(LINEFEED,3);
	writeRam(VOC,5*TENVOLTINC );
		delay(1000);// wait a long time for capassitance to settle
		ringVoltage = -1 *.00492 * (float) readRam(VRING);
		tipVoltage = -1 * .00492 * (float) readRam(VTIP);
		tipcurrent = readRam(ILONG);//*.0000031;
		RingtipVoltage = ringVoltage-tipVoltage;
		rrgdiv = (tipVoltage*800)/((RingtipVoltage)-(2*tipVoltage)+3);
	writeRam(VOC,2 * TENVOLTINC); // step through voltage slowly to avoid ringing ringer
	writeReg(LINEFEED,7); // Activate reverse active (low resistance feed)
	writeRam(VOC,5 * TENVOLTINC);// step up other direction ( Foward active)
	delay (1000);
	tipcurrent = -1*(readRam(ITIP)&0x7FFF) * .0000031;
	tipVoltage = -1*.00492 * (float) readRam(VRING);
	ringVoltage = -1*.00492 * (float) readRam(VRING);
	rrgImeth =tipVoltage/(1000*tipcurrent-((tipVoltage-1.5)/400) - ((tipVoltage-ringVoltage)/800));
	if (rrgdiv<15 && rrgdiv>5){
		rrgout = rrgImeth;
	}
	else
	{
		rrgout = rrgdiv;
	}
	if (rrgout<0)
		rrgout =1000;

	printf("\nR T-G = %.0f ohms", rrgout*1000);
#endif		
}
Example #11
0
// for use only by user code running on the j1
void GameduinoSPIClass::writeRam16(int offset, short value)
{
    if (offset < 0x8000)
    {
        // works fine for now, since there's no dupe needed for this atm
        writeRam(offset, value & 0xFF);
    }
    else
    {
        ((short *)(void *)&s_GdRam[offset])[0] = value;
        switch (offset)
        {
        case 0x800e: // P2_V
            digitalWrite(2, value);
            break;
        }
    }

    //printf("write8j1: %i @ %i\n", (int)value, offset);
}
Example #12
0
File: gr909.c Project: aircross/ray
int tipRingCurrentOverVoltageFwrd( short currentArray[])  // 0 to 50 volts in 5 volt increments
{  
	short vocValue  , i ;
//	doReset();
//	initialize();  /* initialize one Dual ProSLIC */
	writeRam(VCM,0);
	writeRam(VOC,TENVOLTINC);
	writeRam(VOCDELTA,0);
	writeRam(SBIAS, 0X61);  // TURN OFF SLOW FEED
	writeReg(LINEFEED,1);  // Go to  Forward Active
	writeReg(DIAG,0XCC) ; // High Preciscion current loop current

	writeRam(DIAGDCCO,0X20);
	for ( vocValue = TENVOLTINC, i=0 ; i < 5; i++) 
	{

		delay(20);
		writeRam(VOC, vocValue); // Write out voltages starting with zero and going to 50 volts
		vocValue += TENVOLTINC;
		
		writeRam(DIAGDCCO,FLUSH);
		delay(100);
		writeRam(DIAGDCCO,LPFPOLE);
		delay(PROCESSING);
		currents[i] = readRam(DIAGDC);

	}
	printf("\n  RingtoTip=");
	for (i=0;i<5;i++) printf(" %d ",  currents[i]);
	
	if ((currents[3]>200) && (currents[4]> 350))
	{
		printf("\nTip to Ring Short");
			return (0);
	}
	return(-1);
}
Example #13
0
File: gr909.c Project: aircross/ray
void RTRVImeth()
{
#ifdef PCM_SLIC_FLOAT		
	double rtr, rtr2, loopVoltage, loopcurrent;
//	doReset();
//	changeCID(0);
//	initialize(); 

	writeRam(VOC,5*TENVOLTINC);
	writeReg(LINEFEED,1);
	delay(1000);
	loopVoltage = -1 *.00492 * (float) readRam(VLOOP);
//	tipVoltage = -1 * .00492 * (float) readRam(VTIP);
//	tipRingVoltage = tipVoltage-ringVoltage;
	
	loopcurrent = -1*(readRam(ILOOP)&0x7FFF) * .000003097;
	
	rtr = loopVoltage/loopcurrent;
	rtr2 = (rtr*800000)/(800000-rtr);
	printf("\nR T-R V over I = %.0f ohms", rtr2);
#endif
}
Example #14
0
File: gr909.c Project: aircross/ray
int tipToGroundCurrent( short currents[])  // 0 to 50 volts in 5 volt increments
{ 
	unsigned short vocValue ,  i ;
//	doReset();
//	initialize();  /* initialize one Dual ProSLIC */
	writeRam(VCM,0);

	writeRam(VOC,TENVOLTINC);
	writeRam(SBIAS, 0X61);  // TURN OFF SLOW FEED
	writeReg(LINEFEED,7);  // Go to Active
	writeReg(DIAG,0XCD) ; // High Preciscion current loop current
	writeRam(DIAGDCCO,0X20);
	for ( vocValue = TENVOLTINC, i=0 ; i < 5; i++) 
	{

		delay(20);
		writeRam(VOC, vocValue); // Write out voltages starting with zero and going to 50 volts
	
		vocValue += TENVOLTINC;
		
		writeRam(DIAGDCCO,FLUSH);
		delay(100);
		writeRam(DIAGDCCO,LPFPOLE);
		delay(PROCESSING);
		currents[i] = readRam(DIAGDC);

	}
	printf("\n TipShort  =");
	for (i=0;i<5;i++) printf(" %d ",  currents[i]);
	if ((currents[4]< -100) && (currents[4]< -300))
	{
		printf("\nTip to Ground Short");
		return (0);
	}
	return(0);
}
Example #15
0
File: gr909.c Project: aircross/ray
int capUsingRinging40Hz( void)  
{ 
	unsigned short sample10ms, sample1sec ;
#ifdef PCM_SLIC_FLOAT	
	double capValue, ratio;
	

	// It is necessary to lower VOC to allow the Ringing State Machine to proceed
	delay(200);
	writeRam(RINGOF	,	0);
	writeRam( RINGFRHI,0x3DF8);
	writeRam( RINGFRLO,0x5440);
	writeRam( RINGAMP,0x4D);
	writeRam( RINGPHAS,0x0);
	writeRam( RTCOUNT,0x190);
	writeRam( RTDCTH,0x7FFF);
	writeRam( RTPER,0x28);
	writeRam( RTACTH,0x7FFF);
	writeRam( RTDCDB,3);
	writeRam( RTACDB,3);
	writeReg( RINGCON,0X0);

	writeRam(DIAGACCO,0X10);
	writeRam(VOC,0x000); 
	writeRam(VCM,0);

	writeReg(LINEFEED,4);  // start ringing
	writeReg(DIAG,0Xcc) ; // High Preciscion current loop current
	delay(10); //wait milliseconds for it to take effect 
	sample10ms= readRam(DIAGAC);
	delay(1000);
	sample1sec= readRam(DIAGAC);
	ratio=0;
	ratio = 17/(((double)sample1sec) *.000003097 * 5.5);

	
	//capValue = (((float)sample1sec-(float)sample10ms)*4.69)/ (float)(1346);	
	capValue = (1.25e-6*sqrt((double)(640512102400.01-(ratio*ratio))))/(251.3274*sqrt((double)((ratio*ratio)-102400)));
	//see AN71 for equation details.

	printf("\n Cap = %f uF  %d, %f ",  (capValue*1000000)-.16, sample1sec,ratio);

	writeReg(LINEFEED,1);
	writeRam(VOC,0x000); 
	
	delay(100);
#endif
	return(0);
}
Example #16
0
File: gr909.c Project: aircross/ray
int capUsingRinging( void)  // 0 to 50 volts in 5 volt increments
{ 
	unsigned short sample10ms, sample1sec;
#ifdef PCM_SLIC_FLOAT	
	double ratio ;
	double capValue;

	
	// It is necessary to lower VOC to allow the Ringing State Machine to proceed
	delay(200);
	writeRam( RINGOF	,	0);
	writeRam( RINGFRHI,0x3F78);
	writeRam( RINGFRLO,0x6CE8);
	writeRam( RINGAMP,0x4D);
	writeRam( RINGPHAS,0x0);
	writeRam( RTCOUNT,0x190);
	writeRam( RTDCTH,0x7FFF);
	writeRam( RTPER,0x28);
	writeRam( RTACTH,0x7FFF);
	writeRam( RTDCDB,3);
	writeRam( RTACDB,3);
	writeReg( RINGCON,0X0);


	writeRam(DIAGACCO,0X10);//see AN71 and Si3220 datasheet for info on how to use diagnostic registers
	writeRam(VOC,0x000); 
	writeRam(VCM,0);
	writeReg(LINEFEED,4);  // start ringing
	writeReg(DIAG,0Xcc) ; // High Preciscion current loop current
	delay(10); //wait milliseconds for it to take effect 
	sample10ms= readRam(DIAGAC);
	delay(1000);
	sample1sec= readRam(DIAGAC);
	

	ratio = 17/(sample1sec *.000003097 * 2.5);//1.11072);
	capValue = (1.25e-6*sqrt((double)(640512102400.01-(ratio*ratio))))/(125.663706*sqrt((double)((ratio*ratio)-102400)));
	//see AN71 for equation details.
	printf("\n Cap = %f uF  %d, %f ",  (capValue*1000000)-.16, sample1sec,ratio);

	writeReg(LINEFEED,1);
	writeRam(VOC,0x000); 
	
	delay(100);
#endif
	return(0);
}