?? jtag_operates.cpp
字號:
/***********************************************************************/
/* */
/* 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;
/***********************************************************************
* 內(nèi)部函數(shù)聲明
***********************************************************************/
WORD access_rom(int rw, DWORD address, WORD data, int rp);
/***********************************************************************
* 函數(shù)實現(xiàn)定義
***********************************************************************/
/**********************************************************************
* 功 能:test_port - 尋找有效并口
* 函 數(shù)參 數(shù):是否顯示
* 返 回 值: 并口地址
* 函 數(shù) 原形:
***********************************************************************/
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 口
* 函 數(shù)參 數(shù):無
* 返 回 值: 無
* 函 數(shù) 原形:
* 注 意:有些系統(tǒng)中支持TRST,有些不支持,該系統(tǒng)不支持
***********************************************************************/
void reset_jtag(void)
{
int i =0;
//在TMS上連續(xù)加5個TCK脈沖寬度的“1”信號也可以對測試邏輯電路
//進行復位,使得TAP Controller進入Test-Logic Reset狀態(tài)。
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 - 進入外部測試模式,可以操作外部引腳
* 函 數(shù)參 數(shù):無
* 返 回 值: 無
* 函 數(shù) 原形:
* 注 意:
***********************************************************************/
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
* 函 數(shù)參 數(shù):無
* 返 回 值: 無
* 函 數(shù) 原形:
* 注 意:
***********************************************************************/
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
* 函 數(shù)參 數(shù):無
* 返 回 值: 無
* 函 數(shù) 原形:
* 注 意:
***********************************************************************/
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 - 一切操作執(zhí)行之前,必須調(diào)用
* 函 數(shù)參 數(shù):無
* 返 回 值: 無
* 函 數(shù) 原形:
* 注 意:
***********************************************************************/
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 + -