Ejemplo n.º 1
0
// measure constantly 
void bpADCCprobe(void)
{	unsigned int temp;

	//bpWline(OUMSG_PS_ADCC);
	BPMSG1042;
	//bpWline(OUMSG_PS_ANY_KEY);
	BPMSG1250; //BPMSG1043;
	//bpWstring(OUMSG_PS_ADC_VOLT_PROBE);
	BPMSG1044;
	bpWvolts(0);						// print dummy (0v)
	//bpWstring(OUMSG_PS_ADC_VOLTS);
	BPMSG1045;
	while(!UART1RXRdy())				// wait for keypress
	{	AD1CON1bits.ADON = 1;			// turn ADC ON
		temp=bpADC(BP_ADC_PROBE);
		AD1CON1bits.ADON = 0;			// turn ADC OFF
		bpWstring("\x08\x08\x08\x08\x08");	// 5x backspace ( e.g. 5.00V )
		//BPMSG1046;
		bpWvolts(temp);					// print measurement
		//bpWstring(OUMSG_PS_ADC_VOLTS);
		BPMSG1045;

		// CvD: wait xx ms??
	}
	UART1RX();
	bpWline("");							// need a linefeed :D
}
Ejemplo n.º 2
0
//self test, showProgress=1 displays the test results in the terminal, set to 0 for silent mode
//errors are counted in the global errors variable
//returns number of errors
unsigned char selfTest(unsigned char showProgress, unsigned char jumperTest){
//toggle display of test results with show Progress variable
	errors=0;
	if(!showProgress) bpConfig.quiet=1;
	
//instructions (skip pause if no display output)
	if(showProgress && jumperTest){
		//bpPOSTWline("Disconnect any devices");
		//bpPOSTWline("Connect (Vpu to +5V) and (ADC to +3.3V)");
		BPMSG1163;
		BPMSG1251; // //bpPOSTWline("Press a key to start");
		//JTR Not required while(!UART1RXRdy()); //wait for key
		UART1RX();//discard byte
	}

	//bpPOSTWline("Ctrl");
	BPMSG1164;
	BP_AUX0=1;
	BP_AUX0_DIR=0;
	//bpPOSTWstring("AUX");
	BPMSG1165;
	bpTest(BP_AUX0,1);
	BP_AUX0=0;
	BP_AUX0_DIR=1;
				
	BP_LEDMODE=1;
	BP_LEDMODE_DIR=0;	
	//bpPOSTWstring("MODE LED");
	BPMSG1166;
	bpTest(BP_LEDMODE,1);
	BP_LEDMODE=0;
	
	BP_PULLUP_ON();
	//bpPOSTWstring("PULLUP H");
	BPMSG1167;
	bpTest(BP_PULLUP,1);
	BP_PULLUP_OFF();
	//bpPOSTWstring("PULLUP L");
	BPMSG1168;
	bpTest(BP_PULLUP,0);
	
	BP_VREG_ON();
	bpDelayMS(2);//in silent mode there's not enought delay for the power supplied to come on
	//bpPOSTWstring("VREG");
	BPMSG1169;
	bpTest(BP_VREGEN,1);

#if defined (BUSPIRATEV4)
	BPMSG1265; //bpWline("EEPROM");
	BPMSG1266; //bpWstring("SCL");
	bpTest(BP_EE_SCL, 1);
	BPMSG1267; //bpWstring("SDA");
	bpTest(BP_EE_SDA, 1);
	BPMSG1268; //bpWstring("WP");
	bpTest(BP_EE_WP, 1);
	BPMSG1269; //bpWstring("ACK");
    bpTest(eetest(), 0);
#endif

	//ADC check
	//bpPOSTWline("ADC and supply");
	BPMSG1170;
	ADCON(); // turn ADC ON

#if defined (BUSPIRATEV4)
	BPMSG1270; //bpWstring("Vusb");
	bpADCPinTest(BP_ADC_USB,V5L, V5H);

	//bpPOSTWstring("5V");
	BPMSG1171;
	bpADCPinTest(BP_ADC_5V0,V5L, V5H);

	//enable 5v0 pullup and test
	BP_5VPU_ON();
	BPMSG1171; //bpWstring("5V0 VPU");
	bpWstring(" ");
	BPMSG1172; //VPU 
	
	bpDelayMS(2);
	bpADCPinTest(BP_ADC_VPU,V5L, V5H);
	BP_5VPU_OFF();

	//ADC test (3.3 volts)
	if(jumperTest){
		//ADC is connected to 3.3 volts
		//bpPOSTWstring("ADC");
		BPMSG1174;
		bpADCPinTest(BP_ADC_PROBE,V33L, V33H);
	}	

	//bpPOSTWstring("3.3V");
	BPMSG1173;
	bpADCPinTest(BP_ADC_3V3,V33L, V33H);

	//enable 3v3 pullup and test
	BP_3V3PU_ON();
	BPMSG1173; //bpWstring("3V3 VPU");
	bpWstring(" ");
	BPMSG1172; //VPU 
	
	bpDelayMS(2);
	bpADCPinTest(BP_ADC_VPU,V33L, V33H);
	BP_3V3PU_OFF();

#elif defined (BUSPIRATEV3)
	 //v3 test
	//0x030F is 5volts
	//bpPOSTWstring("5V");
	BPMSG1171;
	bpADCPinTest(BP_ADC_5V0,V5L, V5H);
	
	if(jumperTest){
		//Vpullup is connected to 5volts
		//bpPOSTWstring("VPU");
		BPMSG1172;
		bpADCPinTest(BP_ADC_VPU,V5L, V5H);
	}

	//0x0208 is 3.3volts
	//bpPOSTWstring("3.3V");
	BPMSG1173;
	bpADCPinTest(BP_ADC_3V3,V33L, V33H);

	if(jumperTest){
		//ADC is connected to 3.3volts
		//bpPOSTWstring("ADC");
		BPMSG1174;
		bpADCPinTest(BP_ADC_PROBE,V33L, V33H);
	}
#endif

	ADCOFF(); // turn ADC OFF 

//*************
//
//  Test bus pins three ways, also tests on-board pullup resistors:
//	1. normal/high, 2. open collector ground, 3. open collector high.
//
//***************

	//pullup off, pins=output & high, read input, high?
	//bpPOSTWline("Bus high");
	BPMSG1175;
	IODIR&= ~(ALLIO);//output
	IOLAT|=ALLIO; //high	
	bpDelayMS(100);
	bpBusPinsTest(1);

	//pullup on, pins=output & low, read input, low?
	//bpPOSTWline("Bus Hi-Z 0");
	BPMSG1176;
	IOLAT&= ~(ALLIO); //low
	if(jumperTest){
		#if defined	(BUSPIRATEV4)	
		BP_3V3PU_ON();
		#endif
		BP_PULLUP_ON();
	}
	bpDelayMS(100);
	bpBusPinsTest(0);

	if(jumperTest){
	//pullup on, pins=input & low, read input, high?
		//bpPOSTWline("Bus Hi-Z 1");
		BPMSG1177;
		IODIR|=ALLIO;//output
		bpDelayMS(100);
		bpBusPinsTest(1);
		#if defined	(BUSPIRATEV4)	
		BP_3V3PU_OFF();
		#endif
	}

//instructions (skip pause if no display output)
	if(showProgress && jumperTest){
		BP_VREG_ON();
		BP_MODELED_ON();
		//bpPOSTWline("MODE and VREG LEDs should be on! Any key exits.");
		#if defined (BUSPIRATEV4)
			BP_USBLED_ON();
		#endif
		BPMSG1178;
		BPMSG1250;
		//JTR Not required while(!UART1RXRdy());
		UART1RX();
		#ifdef BUSPIRATEV4
			BP_USBLED_OFF();
		#endif
		BP_MODELED_OFF();
		BP_VREG_OFF();
	}

	bpInit();//clean up

	BPMSG1179;
	bpWdec(errors);
	BPMSG1180;
	bpConfig.quiet=0;


	return errors;

}
void binpic(void)
{	unsigned char cmd;
	int ok;
	unsigned int temp;

	bpWstring("PIC1");
	modeConfig.HiZ=1;				// to allow different Vcc 
	bbL(MOSI|CLK, PICSPEED);		// pull both pins to 0 before applying Vcc and Vpp
	picmode=PICMODE6;
	piccmddelay=2;

	while(1)
	{	cmd=UART1RX();

		switch(cmd&0xC0)
		{	case 0x00:	ok=1;
						switch(cmd&0xF0)
						{	case 0x00:	switch(cmd)
										{	case 0x00:	return;
											case 0x01:	bpWstring("PIC1");
														break;
											case 0x02:	picmode=PICMODE6;
														break;
											case 0x03:	picmode=PICMODE4;
														break;
											case 0x04:
											case 0x05:
											case 0x06:
											case 0x07:	piccmddelay=(cmd-0x04);
														break;
											default:	ok=0;
										}
										break;
							case 0x10:	if(cmd&0x08)
										{	if(cmd&0x04)
											{	bbH(AUX ,5);
											}
											else
											{	bbL(AUX ,5);
											}
											if(cmd&0x02)
											{	bbH(MISO ,5);
											}
											else
											{	bbL(MISO ,5);
											}
											if(cmd&0x01)
											{	bbH(CS ,5);
											}
											else
											{	bbL(CS ,5);
											}
										}
										else
										{	if(cmd&0x04)	// pwm?
											{	PWMfreq=100;
												PWMduty=50;
												updatePWM();
											}
											else
											{	PWMfreq=0;
												updatePWM();
											}
											if(cmd&0x02)	// vreg on
											{	BP_VREG_ON();
												//modeConfig.vregEN=1;
											}
											else
											{	BP_VREG_OFF();
												//modeConfig.vregEN=0;
											}
											if(cmd&0x01)	// pullup on
#ifndef BUSPIRATEV1A
											{	BP_PULLUP_ON(); 
//												modeConfig.pullupEN=1;
											}
											else
											{	BP_PULLUP_OFF();
//												modeConfig.pullupEN=0;
											}
#endif
										}
										break;
							default:	ok=0;
						}
						if(ok)
						{	UART1TX(1);
						}
						else
						{	UART1TX(0);
						}
						break;
			case 0x40:	picmode|=PICCMD;
						picwrite(cmd&0x3F);
						picmode&=PICMODEMSK;
						UART1TX(1);
						break;
			case 0x80:	picmode|=PICCMD;
						picwrite(cmd&0x3F);
						picmode&=PICMODEMSK;
						temp=UART1RX();
						temp<<=8;
						temp|=UART1RX();
						picwrite(temp);
						UART1TX(1);
						break;
			case 0xC0:	picmode|=PICCMD;
						picwrite(cmd&0x3F);
						picmode&=PICMODEMSK;
						UART1TX(1);
						temp=picread();
						UART1TX(temp>>8);
						UART1TX(temp&0x0FF);
						break;
		}
	}
}		
Ejemplo n.º 4
0
/*
Bitbang is like a player piano or bitmap. The 1 and 0 represent the pins. 
So for the four Bus Pirate pins we use the the bits as follows:
COMMAND|POWER|PULLUP|AUX|CS|MISO|CLK|MOSI.

The Bus pirate also responds to each write with a read byte showing the current state of the pins.

The bits control the state of each of those pins when COMMAND=1. 
When COMMAND=0 then up to 127 command codes can be entered on the lower bits.
0x00 resets the Bus Pirate to bitbang mode.

Data:
1xxxxxxx //COMMAND|POWER|PULLUP|AUX|MOSI|CLK|MISO|CS

Commands:
00000000 //Reset to raw BB mode, get raw BB version string
00000001 //enter rawSPI mode
00000010 //enter raw I2C mode
00000011 //enter raw UART mode
00000100 // enter raw 1-wire
00000101 //enter raw wire mode
00000110 // enter openOCD
00000111 // pic programming mode
00001111 //reset, return to user terminal
00010000 //short self test
00010001 //full self test with jumpers
00010010 // setup PWM
00010011 // clear PWM
00010100 // ADC measurement

// Added JM  Only with BP4
00010101 // ADC ....
00010110 // ADC Stop
00011000 // XSVF Player
// End added JM
//
010xxxxx //set input(1)/output(0) pin state (returns pin read)
 */
void binBBversion(void) {
    bpWstring("BBIO1");
}