亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tapctrl.c

?? Jtag調試驅動的例子程序
?? C
字號:
/*
 * tapctrl.c : 
 	1). Implement TAP controller state transitions.
 	2). Implement required JTAG public instructions.
 *
 * Copyright (C) 2004, OPEN-JTAG, All rights reserved.
 */

#include <windows.h>
#include "jtag.h"
#include "xjerr.h"
#include "tapctrl.h"


/* Used to record the current TAP state */
static int tap_state = TAPSTAT_UNDEFINED;				


/* 
 * TAP state transition array -
 *		This array descripes the TAP state machine. It is used
 *		to instruct the TAP state transition.
 */
static const tap_state_t state_trans[NUM_OF_STATES] =
{ {TAPSTAT_SHIFT_DR, TAPSTAT_UPDATE_DR},			//TAPSTAT_EXIT2_DR
  {TAPSTAT_PAUSE_DR, TAPSTAT_UPDATE_DR},			//TAPSTAT_EXIT1_DR
  {TAPSTAT_SHIFT_DR, TAPSTAT_EXIT1_DR},				//TAPSTAT_SHIFT_DR					
  {TAPSTAT_PAUSE_DR, TAPSTAT_EXIT2_DR},				//TAPSTAT_PAUSE_DR
  {TAPSTAT_CAPTURE_IR, TAPSTAT_TSTLOG_RST},			//TAPSTAT_SELECT_IR_SCAN
  {TAPSTAT_RUNTEST_IDLE, TAPSTAT_SELECT_DR_SCAN},	//TAPSTAT_UPDATE_DR
  {TAPSTAT_SHIFT_DR, TAPSTAT_EXIT1_DR},				//TAPSTAT_CAPTURE_DR
  {TAPSTAT_CAPTURE_DR, TAPSTAT_SELECT_IR_SCAN},		//TAPSTAT_SELECT_DR_SCAN
  {TAPSTAT_SHIFT_IR, TAPSTAT_UPDATE_IR},			//TAPSTAT_EXIT2_IR
  {TAPSTAT_PAUSE_IR, TAPSTAT_UPDATE_IR},			//TAPSTAT_EXIT1_IR
  {TAPSTAT_SHIFT_IR, TAPSTAT_EXIT1_IR},				//TAPSTAT_SHIFT_IR
  {TAPSTAT_PAUSE_IR, TAPSTAT_EXIT2_IR},				//TAPSTAT_PAUSE_IR
  {TAPSTAT_RUNTEST_IDLE, TAPSTAT_SELECT_DR_SCAN},	//TAPSTAT_RUNTST_IDLE
  {TAPSTAT_RUNTEST_IDLE, TAPSTAT_SELECT_DR_SCAN},	//TAPSTAT_UPDATE_IR
  {TAPSTAT_SHIFT_IR, TAPSTAT_EXIT1_IR},				//TAPSTAT_CAPTURE_IR
  {TAPSTAT_RUNTEST_IDLE, TAPSTAT_TSTLOG_RST},		//TAPSTAT_TSTLOG_RST
};


/*
 * tapctrl_next_state() -	
 *		Make TAP controller go to the next adjacent state 
 *		according to the value of tms. Before exit from this 
 *		route, the current state of TAP controller will be 
 *		updated.
 *
 *		@tms: the new logic value for TMS signal, it must be 0 or 1.
 */
static int tapctrl_next_state(u8 tms)
{
	if(tap_state < 0x0 || tap_state > 0xF)
		return XJERR_TAPSTATE_INVALID;
		
	jtag_wri_tms(tms);
	jtag_wri_tck();
	if(tms)
		tap_state = state_trans[tap_state].next_state[1];
	else
		tap_state = state_trans[tap_state].next_state[0];

	return XJ_OK;
}


/*
 * tapctrl_acs_reg() - 	
 *		This route is used to access selected test data registers or
 *		instruction regisger depending on the current TAP controller's 
 * 		state. If the TAP controller's state is Shift-DR, selected 
 *		test data register will be accessed. If the TAP controller's 
 *		state is Shift-IR, the instruction register will be accessed.
 *		When calling this route, please make sure that the current TAP's
 * 		state is Shift-DR or Shift-IR. When return from this route, the
 *		TAP controller will enter the Exit1-DR/Exit1-IR state.
 *
 *		@bit_len:	the length in terms of bit to be shifted into the selected register.
 *		@shift_in:	data to be shifted into the selected register.
 *		@shift_out: buffer to receive the data shifted out from selected register.
 * 
 *		shift_in and shift_out can't both be NULL at the same time.
 */
static int tapctrl_acs_reg(int bit_len, const u32 *shift_in, u32 *shift_out)
{
	int bit_idx, word_idx;
	u32 wri_data, rd_data;
	
	
	//Check the current TAP controller's state and the paramaters
	if( (tap_state != TAPSTAT_SHIFT_DR) && (tap_state != TAPSTAT_SHIFT_IR) )
		return XJ_ERROR;
	if(bit_len <= 0)
		return XJ_ERROR;
	if( (shift_in == NULL) && (shift_out == NULL) )
		return XJ_ERROR;

	//Access the cells of  selected scan chain
	for(bit_idx = 0; bit_idx < bit_len; bit_idx++){
		//update wri_data and rd_data
		if(bit_idx%32 == 0){
			word_idx = bit_idx/32;
			if(shift_in != NULL)
				wri_data = shift_in[word_idx];
			else
				wri_data = 0;
			rd_data = 0;
		}
		
		//Write 1 bit
		jtag_wri_tdi((u8) (wri_data & 0x1) );
		wri_data >>= 1;

		/*
		 * If this is the last bit, enter the next TAP state (Exit1-DR/Exit1-IR). 
		 * Otherwise, stay at current TPA state (Shift-DR/Shift-IR) for further access
		 */
		if(bit_idx == bit_len - 1)
			tapctrl_next_state(1);
		else
			tapctrl_next_state(0);

		//Read 1 bit
		if( jtag_rd_rdo() )
			rd_data |= (1 << (bit_idx%32));
		
		/* update rd_buf when necessary
		 * 1). when read 32 bits
		 * 2). last bit
		 */
		if( (bit_idx%32 == 31 || bit_idx == bit_len - 1) && shift_out != NULL )
			shift_out[word_idx] = rd_data;
	}	

	return XJ_OK;
}


/*
 * tapctrl_acs_ireg() - 
 *		This route is used to access JTAG instruction register.
 *		Please make sure that TAP controller is in the Run-Test/Idle or 
 *		Select-DR-Scan state when calling this route. If the JTAG instruction
 *		is RESTART, the TAP Controller will enter Run-Test/Idle state b4 returning;
 *      else, the TAP Controller will enter Select-DR-Scan state b4 returning.
 *
 *		@instruction:	public JTAG instruction to be shifted into the instruction 
 *						register.
 */
int tapctrl_acs_ireg(u32 instruction)
{
	int status;
	int val = 0;
	u32 shift_in;
	u32 shift_out;
	
	shift_out = 0;
	shift_in = instruction;
	
	if(tap_state == TAPSTAT_RUNTEST_IDLE)
		tapctrl_next_state(1);			//Run-Test/Idle		->		Select-DR-Scan
	else if(tap_state == TAPSTAT_SELECT_DR_SCAN)
		;								//Select-DR-Scan	->		Select-DR-Scan
	else
		return XJ_ERROR;

	tapctrl_next_state(1);				//Select-DR-Scan	->		Select-IR-Scan
	tapctrl_next_state(0);				//Select-IR-Scan	->		Capture-IR
	tapctrl_next_state(0);				//Capture-IR		->		Shift-IR
	
	status = tapctrl_acs_reg(4, &shift_in, &shift_out);

	tapctrl_next_state(1);				//Exit1-IR			->		Update-IR

	if(instruction == JTAG_RESTART)
		tapctrl_next_state(0);			//Update-IR			->		Run-Test/Idle
	else
		tapctrl_next_state(1);			//Update-IR			->		Select-DR-Scan	

	if(status != XJ_OK)
		return XJERR_ACSIREG_FAIL;
	if(shift_out != 0x1)
		return XJERR_ACSIREG_FAIL;

	return XJ_OK;
}


/*
 * tapctrl_acs_dreg() - 
 *		This route is used to access selected data register.
  *     Please make sure that TAP controller is in the Run-Test/Idle or 
 *		Select-DR-Scan state when calling this route. On returning
 *		from this route, the TAP Controller will return to Run-Test/Idle 
 *		state.
 *
 *		@bit_len:	the length in terms of bit to be shifted into the data register.
 *		@shift_in:	data to be shifted into the data register.
 *		@shift_out: buffer to receive the data shifted out from data register.
 *		@run_test:	flag used to control enter which state b4 returning.
 */
int tapctrl_acs_dreg(int bit_len, const u32 *shift_in, u32 *shift_out)
{
	int status;
	int val = 0;
	
	if(tap_state == TAPSTAT_RUNTEST_IDLE)
		tapctrl_next_state(1);			//Run-Test/Idle		->		Select-DR-Scan
	else if(tap_state == TAPSTAT_SELECT_DR_SCAN)
		;								//Select-DR-Scan	->		Select-DR-Scan
	else
		return XJ_ERROR;
	
	tapctrl_next_state(0);				//Select-DR-Scan	->		Capture-DR
	tapctrl_next_state(0);				//Capture-DR		->		Shift-DR
	
	status = tapctrl_acs_reg(bit_len, shift_in, shift_out);

	tapctrl_next_state(1);				//Exit1-DR			->		Update-DR
	tapctrl_next_state(0);				//Update-DR			->		Run-Test/Idle

	
	if(status != XJ_OK)
		return XJERR_ACSIREG_FAIL;
	else
		return XJ_OK;
}



/*
 * tapctrl_reset() - 
 *			This route is used to reset the TAP controller.
 *			This route will put the TAP controller into the 
 *			Run-Test/Idle state. Please note that this route 
 *			should be called to initialize the TAP controller before
 *			any operations can be applied to the TAP controller.
 * 
 * There are two methods to reset the TAP controller.
 * 1). The optional TRST* input provides for asynchronous initialization of 
 *     the TAP controller. To force the TAP controller into the correct state 
 *     after power-up, nTRST must be driven LOW and then HIGH again. It is 
 *     recommended that TMS should be held at 1 while the signal applied at 
 *     nTRST changes from 0 to 1.
 * 2). No matter what the original state of the controller, it will enter Test-
 *     Logic-Reset when TMS is held high for at least five rising edges of TCK. 
 *     The controller remains in this state while TMS is high. 
 */	
int tapctrl_reset(void)
{
	int i;

	//Reset the TAP controller through nTRST
	jtag_wri_tms(1);
	jtag_wri_ntrst(0);		//Drive Low first
	Sleep(50);
	jtag_wri_ntrst(1);		//Drive High 
	Sleep(50);

	//Reset the TAP controller through TMS
	for (i = 1; i <= 10; i++){
		jtag_wri_tms(1);
		jtag_wri_tck();
	}

	//Update the state of TAP controller
	tap_state = TAPSTAT_TSTLOG_RST;

	/* Now enter Run-Test/Idle state and stay here */
	tapctrl_next_state(0);		//Test-Logic Reset  -> Run-Test/Idle
	tapctrl_next_state(0); 		//Run-Test/Idle     -> Run-Test/Idle
	
	
	return XJ_OK;
}


/*
 * tapctrl_init() - 
 *		This route is used to initialize the TAP Controller by
 *		calling tapctrl_reset().
 */
int tapctrl_init(void)
{
	return tapctrl_reset();
}


/*
 * tapctrl_runtest() -
 *		Produce an TAP state trnasition from the Run-Test/Idle state
 *		to Run-Test/Idle state.
 */
int tapctrl_runtest(void)
{
	if(tap_state != TAPSTAT_RUNTEST_IDLE)
		return XJ_ERROR;
	else
		return tapctrl_next_state(0);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人精品在线视频观看| 久久精品一级爱片| 一区二区三区在线免费视频| 岛国一区二区三区| 国产精品久久久久影院亚瑟| 97精品久久久午夜一区二区三区| 亚洲免费观看高清完整| 在线精品视频免费播放| 婷婷综合另类小说色区| 7777精品伊人久久久大香线蕉超级流畅| 亚洲成在人线免费| 欧美一区二区黄色| 国产一区二区美女| 国产精品日产欧美久久久久| 92精品国产成人观看免费| 亚洲黄一区二区三区| 欧美绝品在线观看成人午夜影视| 久久国产精品色婷婷| 日本一区二区免费在线观看视频| kk眼镜猥琐国模调教系列一区二区| 亚洲精品一二三| 欧美肥胖老妇做爰| 国产精品99久久久久久有的能看| 一区在线中文字幕| 欧美日韩高清一区二区三区| 国产一区二区视频在线| 亚洲欧美色图小说| 欧美一级国产精品| 不卡高清视频专区| 日韩精品亚洲专区| 欧美激情一区二区三区在线| 欧美午夜精品久久久| 黄色精品一二区| 亚洲美女偷拍久久| 久久久久久久久久久黄色| 91麻豆产精品久久久久久| 美国毛片一区二区| 曰韩精品一区二区| 久久久久久亚洲综合| 在线精品观看国产| 国产suv精品一区二区三区| 亚洲自拍偷拍图区| 欧美国产日韩在线观看| 欧美久久一二区| www.日韩精品| 国产一区二区h| 石原莉奈在线亚洲三区| 亚洲色图欧洲色图| 亚洲精品一区在线观看| 日本高清不卡视频| 国产成a人无v码亚洲福利| 亚洲成a人v欧美综合天堂下载| 久久亚洲捆绑美女| 欧美日韩国产影片| 91在线视频在线| 国产精品自拍三区| 奇米亚洲午夜久久精品| 一区二区三区不卡视频在线观看 | 一区二区三区四区国产精品| 国产精品不卡一区二区三区| 国产又黄又大久久| 亚洲精品第1页| 中文字幕一区二区5566日韩| 久久久久久一二三区| 91.麻豆视频| 91国偷自产一区二区三区成为亚洲经典| 国产一区二区三区免费看| 日韩精品乱码av一区二区| 亚洲欧美二区三区| 国产精品视频你懂的| 久久综合网色—综合色88| 日韩精品在线看片z| 91精品国产手机| 欧美精品在线一区二区三区| 欧美午夜精品免费| 日韩三级电影网址| 欧美成人r级一区二区三区| 91在线小视频| 欧洲一区在线电影| 美国十次了思思久久精品导航| 一区二区欧美国产| 一区二区三区四区激情| 一区二区三区在线视频观看| 亚洲嫩草精品久久| 亚洲激情图片qvod| 亚洲bt欧美bt精品777| 午夜亚洲福利老司机| 日韩精品亚洲专区| 九色|91porny| 国产99精品国产| 91亚洲精品久久久蜜桃| 色琪琪一区二区三区亚洲区| 欧美亚洲愉拍一区二区| 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 欧美中文字幕亚洲一区二区va在线 | 日韩精品成人一区二区三区| 亚洲成av人影院| 日韩电影免费一区| 另类综合日韩欧美亚洲| 紧缚奴在线一区二区三区| 国产99久久久国产精品潘金| 成人av网址在线| 欧美在线一区二区三区| 欧美一区二区免费视频| 久久久久久免费网| 亚洲精品日韩综合观看成人91| 亚洲超丰满肉感bbw| 免播放器亚洲一区| 国产精品系列在线播放| 色欧美88888久久久久久影院| 欧美熟乱第一页| 26uuu久久综合| 亚洲天堂网中文字| 免费成人在线观看视频| 成人高清视频在线观看| 欧美日韩中文另类| 久久夜色精品一区| 亚洲一区二区三区四区五区黄| 极品少妇一区二区| 91理论电影在线观看| 欧美一区二区三区不卡| 国产精品免费视频观看| 丝袜亚洲精品中文字幕一区| 国产精品一品视频| 欧美影视一区二区三区| 久久嫩草精品久久久精品一| 亚洲精选视频在线| 国产在线观看一区二区| 在线观看免费视频综合| 国产色一区二区| 午夜在线电影亚洲一区| 成人视屏免费看| 欧美一区二区三区在线看| 国产精品电影一区二区三区| 久久99精品国产.久久久久久| 91丨porny丨国产| 精品福利av导航| 天天综合天天做天天综合| 99精品久久免费看蜜臀剧情介绍| 欧美videossexotv100| 亚洲一区自拍偷拍| 成人国产精品免费网站| 精品国产污网站| 天堂午夜影视日韩欧美一区二区| 99在线精品观看| 久久免费精品国产久精品久久久久| 亚洲主播在线播放| av一区二区三区在线| 久久久久国产免费免费| 奇米精品一区二区三区在线观看| 欧美主播一区二区三区美女| 中文字幕一区二区三中文字幕| 国产老肥熟一区二区三区| 7777精品伊人久久久大香线蕉超级流畅| 亚洲男人电影天堂| a在线播放不卡| 中文字幕不卡一区| 国产精品中文有码| 精品久久久久久久久久久久久久久| 午夜精品久久久久久久久| 91福利视频网站| 一区二区三区日韩欧美| 97久久精品人人做人人爽| 国产欧美日韩视频在线观看| 国产盗摄一区二区三区| 久久香蕉国产线看观看99| 国内精品在线播放| 欧美大片在线观看| 极品少妇一区二区三区精品视频| 日韩视频免费观看高清在线视频| 日本美女一区二区| 91精品在线观看入口| 偷拍日韩校园综合在线| 欧美丰满少妇xxxxx高潮对白| 国产精品久久久久影院老司| 成人黄色大片在线观看| 中文字幕制服丝袜成人av| 国产高清成人在线| 国产精品免费视频观看| www.日本不卡| 中文字幕一区二区三区在线播放| 波多野结衣在线一区| 国产精品欧美久久久久一区二区| 成人国产一区二区三区精品| 亚洲人成网站在线| 91老师片黄在线观看| 一区二区三区四区高清精品免费观看| 91视频观看视频| 婷婷成人激情在线网| 日韩女优av电影| 国产自产高清不卡| 国产精品久久久久久久久晋中| 成人av影视在线观看| 亚洲大片免费看| 精品国产一区二区三区忘忧草| 久久成人麻豆午夜电影| 国产精品电影院| 在线免费不卡视频| 蜜桃视频在线一区| 久久久91精品国产一区二区精品|