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

📄 jtag_operates.cpp

📁 系统通过JTAG接口烧结挂接在LXFXP2 上的s29gl256N的FLASH的代码,
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/***********************************************************************/   
/*                                                                     */   
/* Module Name   : TJAG OPERS                                          */   
/*                                                                     */   
/* Description   : Implementation of a flash module for the            */   
/*                 TJAG OPERS .                                        */   
/*                                                                     */   
/*                                                                     */   
/* Document Ref. : - Datasheets for the TJAG OPERS                     */   
/*                                                                     */   
/* Function List : Exported                                            */   
/* Note          :                                                     */   
/*                                                                     */   
/* modification history :                                              */   
/***********************************************************************/  
                 
/***********************************************************************
* 头文件包含
***********************************************************************/
#include "stdafx.h"
#include <windows.h> 
#include "Jtag_operates.h"
#include "LXFXP2.h"

/***********************************************************************
* 变量定义
***********************************************************************/
int lpt_address = 0;

/***********************************************************************
* 内部函数声明
***********************************************************************/
WORD access_rom(int rw, DWORD address, WORD data, int rp);


/***********************************************************************
* 函数实现定义
***********************************************************************/

/**********************************************************************
* 功      能:test_port - 寻找有效并口
* 函 数参 数:是否显示
* 返  回  值: 并口地址
* 函 数 原形:
***********************************************************************/
unsigned short test_port(bool display = false)
{
    // search for valid parallel port
    lpt_address = 0;

    OUTB(LPT1, 0x55);
    if(INB(LPT1) == 0x55)  
    {
    	lpt_address = LPT1;
		if(display)
			AfxMessageBox("LPT1");
    }

    OUTB(LPT2, 0x55);
    if(INB(LPT2) == 0x55) 
	{
    	lpt_address = LPT2;
		if(display)
			AfxMessageBox("LPT2");
    }	

	OUTB(LPT3, 0x55);
    if(INB(LPT3) == 0x55)  
	{
    	lpt_address = LPT3;
		if(display)
			AfxMessageBox("LPT3");
    }

    return(lpt_address);
}

/**********************************************************************
* 功      能:reset_jtag - reset jtag 口
* 函 数参 数:无
* 返  回  值: 无
* 函 数 原形:
* 注      意:有些系统中支持TRST,有些不支持,该系统不支持
***********************************************************************/
void reset_jtag(void)                  
{   
	int i =0;
	//在TMS上连续加5个TCK脉冲宽度的“1”信号也可以对测试逻辑电路
	//进行复位,使得TAP Controller进入Test-Logic Reset状态。
    for( i=0; i<6; i++) 
    {
    	putp(1,1,IP);   // move to TEST_LOGIC/RESET
    }
    	
    putp(1,0,IP);       // move to Run_Test/Idle
}

/**********************************************************************
* 功      能:extest - 进入外部测试模式,可以操作外部引脚
* 函 数参 数:无
* 返  回  值: 无
* 函 数 原形:
* 注      意:
***********************************************************************/
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);   //Select DR scan
    putp(1,1,IP);   //select IR scan
    putp(1,0,IP);   //capture IR
    putp(1,0,IP);   //shift IR

	for(int i= 0; i< (LXFXP25E208_INSTRUC_LENGTH-1); i++ )
	{
    	putp( ((EXTEST>>i)&1) ,0,IP);   //S3C4510 extest		
	}
    putp((EXTEST >> (LXFXP25E208_INSTRUC_LENGTH-1))&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
}

/**********************************************************************
* 功      能:check_id - 测试IDCODE
* 函 数参 数:无
* 返  回  值: 无
* 函 数 原形:
* 注      意:
***********************************************************************/
int check_id(char *device_id)
{
    // compare passed device ID to the one returned from the ID command
    char in_id[40];
    BOOL error_flag = FALSE;
    int i;

    for(i = LXFXP2_IDCODE_LENGTH; i >= 0; i--)
    {
        if(i == 4 || i == 21 )
        {
            in_id[i] = ' ';
            i--;
        }
        
        if(putp(1,0,RP) == 0)
            in_id[i] = '0';
        else
            in_id[i] = '1';

        if((in_id[i] != *(device_id + i)) && (*(device_id + i) != '*'))
        {
            error_flag = TRUE;
        }
    }
    in_id[35] = 0;

    if(error_flag)
    {
    	int   count = 0;
    	char  buffer[200] ={ 0 };
    	    	
    	count = sprintf(buffer, "Read device ID ERR,ACT:%s,EXP:%s\n",in_id,device_id);
    	buffer[count]  = '\0' ;   	    	  	

		//AfxMessageBox(buffer);

        return -1;
    }
#if 0
    if(!strcmp(device_id,LXFXP25E208ID)) // print S3C4510 device revision
    {
    	int   count = 0;
    	char  buffer[40] ={ 0 };
    	    	
        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');
   	    	
    	count = sprintf(buffer, "LXFXP25E208 revision %d\n",s3c_rev);
    	buffer[count]  = '\0' ;   	    	  	

		AfxMessageBox(buffer);            
    } 
#endif       
    return 0;
}

/**********************************************************************
* 功      能:id_command - 准备测试IDCODE
* 函 数参 数:无
* 返  回  值: 无
* 函 数 原形:
* 注      意:
***********************************************************************/
void 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
    
    //IDCODE LSB First
	for(int i= 0; i< (LXFXP25E208_INSTRUC_LENGTH-1); i++ )
	{
    	putp( ((IDCODE>>i)&1) ,0,IP);   		
	}
    putp((IDCODE >> (LXFXP25E208_INSTRUC_LENGTH-1))&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(LXFXP25E208ID))
	{
        AfxMessageBox("failed to read device ID for the LXFXP25E208");
    }

    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
}

/**********************************************************************
* 功      能:LPT_initialization - 一切操作执行之前,必须调用
* 函 数参 数:无
* 返  回  值: 无
* 函 数 原形:
* 注      意:
***********************************************************************/
void LPT_initialization()
{
    int lpt_addr = 0;
    
	lpt_addr = test_port(false);  // find a valid parallel port address

⌨️ 快捷键说明

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