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

📄 s3c4510.c

📁 这是写入4510的flash的文件
💻 C
📖 第 1 页 / 共 2 页
字号:
 LPT D1      Pin 3  and TMS (bit 1 lptaddress ) LPT D0      Pin 2  and TRST (bit 0 lptaddress )  Input pin ( S3C4510 board drives) LPT BUSY    Pin 11 and TDO (bit 7 lptaddress + 1)  * modify history:	if you change the function please give the discription-----------------------------------------------------------------*/int putp( int tdi, int tms, int rp ){	int tdo = -1;	int t1, t2;	t1 = tdi*8 + tms*2;	OUTB( lpt_address, t1+0x01 );         //TCK low		t1= tdi*8 + tms*2 + 4;	OUTB( lpt_address, t1+0x01 );         // TCK high		//need read from JTAG	if(rp == RP) {        OUTB( lpt_address, tdi*8 + tms*2 + 0x01 );        // TCK low		t1 = INB( lpt_address + 1 );		t2 = t1>>7;        tdo = !t2;  // get TDO data    }    	return tdo;}/*----------------------------------------------------------------	 * brief : 	hardware to reset the JTAG * author:	dailzh * param:	none * retval:	none * modify history:	-----------------------------------------------------------------*/void reset_jtag( void ){	int i;     OUTB(lpt_address, 0);               // TRST low    OUTB(lpt_address, 0);               // TRST low    OUTB(lpt_address, 0);               // TRST low    OUTB(lpt_address, 1);               // TRST high    OUTB(lpt_address, 1);               // TRST high    OUTB(lpt_address, 1);               // TRST high    	for( i=0; i<8; i++) putp(1,1,IP);   // move to TEST_LOGIC/RESET	putp(1,0,IP);                       // move to Run_Test/Idle}/*----------------------------------------------------------------	 * brief : 	software to reset the JTAG * author:	dailzh * param:	none * retval:	none * modify history:	-----------------------------------------------------------------*/void test_logic_reset( void ){	putp(1,1,IP);	// keep TMS set to 1 force a test logic reset	putp(1,1,IP);	// no matter where you are in the TAP controller	putp(1,1,IP);	putp(1,1,IP);	putp(1,1,IP);	putp(1,1,IP);}/*----------------------------------------------------------------	 * brief : 	compare passed device ID to the one returned from the ID command * author:	dailzh * param:	device_id-----the checked cpu id * retval:	-1--------different 			0---------the same * modify history:	if you change the function please give the discription-----------------------------------------------------------------*/int check_id( char *device_id ){	char in_id[40];		//hold the get device id    int i;    for( i = 34; i >= 0; i-- ) {    	//add the space to the cpu id		if( i == 4 || i == 21 || i == 33 ) {			in_id[i] = ' ';			i--;		}				//read a bit from JTAG		if( putp( 1, 0, RP ) == 0 )			in_id[i] = '0';		else			in_id[i] = '1';		//compare to the s3c4510 cpu id		if( ( in_id[i] != *( device_id + i ) ) && ( *(device_id + i) != '*' ) ) {			printf("error, failed to read device ID\n");			printf("check cables and power\n");			return -1;		}	}//for( i = 34; i >= 0; i-- )		// print S3C4510 device revision	in_id[35] = 0;    if( !strcmp( in_id,S3C4510ID ) ) {        int s3c_rev =			(int)(in_id[0] - '0') * 8 +			(int)(in_id[1] - '0') * 4 +			(int)(in_id[2] - '0') * 2 +			(int)(in_id[3] - '0');        printf("Found S3C4510B, Revision %d\n",s3c_rev);	}		return 0;}/*----------------------------------------------------------------	 * brief : 	check the cpu id( JTAG part ) * author:	dailzh * param:	none * retval:	-1--------error 			0---------succeed * modify history:	if you change the function please give the discription-----------------------------------------------------------------*/int id_command( void ){	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle	putp(1,1,IP);	putp(1,1,IP);	//select IR scan	putp(1,0,IP);	//capture IR	putp(1,0,IP);	//shift IR    putp(0,0,IP);   //S3C4510 IDCODE, LSB first    putp(1,0,IP);   //    putp(1,0,IP);   //    putp(1,1,IP);   //Exit1-IR	putp(1,1,IP);	//Update-IR	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle    putp(1,1,IP);   //select DR scan    putp(1,0,IP);   //capture DR    if( check_id( S3C4510ID ) ) {        printf( "failed to read device ID for the S3C4510" );        return -1;	}	putp(1,1,IP);	//Exit1-DR	putp(1,1,IP);	//Update-DR	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle		return 0;}/*----------------------------------------------------------------	 * brief : 	select a one bit bypass reg between TDI and TDO * author:	dailzh * param:	none * retval:	none * modify history:	-----------------------------------------------------------------*/void bypass_all( void ){	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle	putp(1,1,IP);	putp(1,1,IP);	//select IR scan	putp(1,0,IP);	//capture IR	putp(1,0,IP);	//shift IR    putp(1,0,IP);   //S3C4510 BYPASS	putp(1,0,IP);	//	putp(1,0,IP);	//	putp(1,1,IP);	//Exit1-IR	putp(1,1,IP);	//Update-IR	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle}/*----------------------------------------------------------------	 * brief : 	select scan boundary reg between TDI and TDO * author:	dailzh * param:	none * retval:	none * modify history:	-----------------------------------------------------------------*/void extest( void ){	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle	putp(1,1,IP);	putp(1,1,IP);	//select IR scan	putp(1,0,IP);	//capture IR	putp(1,0,IP);	//shift IR    putp(0,0,IP);   //S3C4510 extest	putp(0,0,IP);	//	putp(0,0,IP);	//    putp(0,1,IP);   //Exit1-IR	putp(1,1,IP);	//Update-IR	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle	putp(1,0,IP);	//Run-Test/Idle}/*----------------------------------------------------------------	 * brief : 	read or write bus * author:	dailzh * param:	rw--------define the operation            address---the address signal of the bus            data------the write data            rp--------ignore output or not * retval:	data read from the bus * modify history:	-----------------------------------------------------------------*/unsigned int access_bus( int rw, unsigned int address, unsigned int data, int rp){    int     out_dat[300], i;    int     cs;    unsigned int   li, busdat = 0;    //set the chip select signal    cs = nRCS_0_OUT;    // Preset S3C4510 pins to default values (all others set in S3C4510.h)    pin[nRCS_0_OUT] = 1;    pin[nRCS_1_OUT] = 1;    pin[nRCS_2_OUT] = 1;    pin[nRCS_3_OUT] = 1;    pin[nRCS_4_OUT] = 1;    pin[nRCS_5_OUT] = 1;    pin[nECS_0_OUT] = 1;    pin[nECS_1_OUT] = 1;    pin[nECS_2_OUT] = 1;    pin[nECS_3_OUT] = 1;    pin[nOE_OUT]    = 0;    pin[nWBE_0_OUT] = 1;    pin[nWBE_1_OUT] = 1;    pin[nWBE_2_OUT] = 1;    pin[nWBE_3_OUT] = 1;    pin[D_OUT_ENB] = 0;    for(i = 0; i < 22; i++)        pin[149-i] = (int)((address >> i) & 1);  // set address 0 thru 21	if(rw == READ)	{        pin[cs] = 0;		pin[D_OUT_ENB] = 1;		pin[nOE_OUT]    = 0;	}	if(rw == WRITE)	{        pin[cs]         = 0;        pin[nWBE_0_OUT] = 0;        pin[nOE_OUT]    = 1;        pin[D_OUT_ENB]  = 0;  // switch data pins to drive        for(li = 0L; li < 32L; li++)            pin[125-li*2] = (int)((data >> li) & 1L);  // set data pins	}	if( rw == HOLD)	// just like a write except WE, WE needs setup time	{		pin[cs]         = 1;        pin[nOE_OUT]   = 1;        pin[D_OUT_ENB] = 0;		pin[nWBE_0_OUT] = 1;        //for(li = 0L; li < 32L; li++)        //    pin[125-li*2] = (int)((data >> li) & 1L);  // serialize data pins	}		if(rw == SETUP )	// just like a write except WE, WE needs setup time	{		pin[cs]         = 0;        pin[nOE_OUT]   = 1;        pin[D_OUT_ENB] = 0;		pin[nWBE_0_OUT] = 1;        for(li = 0L; li < 32L; li++)            pin[125-li*2] = (int)((data >> li) & 1L);  // serialize data pins	}	if(rw == RS)	// setup prior to RD_nWR_OUT	{		pin[nOE_OUT] = 1;		pin[cs]      = 0;		pin[nWBE_0_OUT] = 0;	}    putp(1,0,IP);   // Run-Test/Idle    putp(1,0,IP);   // Run-Test/Idle    putp(1,0,IP);   // Run-Test/Idle    putp(1,0,IP);   // Run-Test/Idle    putp(1,1,IP);   // select DR scan    putp(1,0,IP);   // capture DR    putp(1,0,IP);   // shift IR    for(i = 0; i < 232; i++)    // shift write data in to JTAG port and read data out        out_dat[i] = putp(pin[i],0,rp);    putp(0,1,IP);   // Exit1-DR    putp(1,1,IP);   // Update-DR    putp(1,0,IP);   // Run-Test/Idle    putp(1,0,IP);   // Run-Test/Idle    putp(1,0,IP);   // Run-Test/Idle    busdat = 0;	for(i = 0; i < 32; i++)	// convert serial data to single DWORD	{        busdat = busdat | (unsigned int)(out_dat[125 - i*2] << i);	}	return(busdat);}

⌨️ 快捷键说明

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