📄 micro_dynamic_target.c
字号:
xsvfDoXSDRTDOBCE, /* 17 */ xsvfDoXSTATE, /* 18 */ xsvfDoXENDXR, /* 19 */ xsvfDoXENDXR, /* 20 */ xsvfDoXSIR2, /* 21 */ xsvfDoXCOMMENT, /* 22 */ xsvfDoXWAIT /* 23 *//* Insert new command functions here */};#ifdef DEBUG_MODE char* xsvf_pzCommandName[] = { "XCOMPLETE", "XTDOMASK", "XSIR", "XSDR", "XRUNTEST", "Reserved5", "Reserved6", "XREPEAT", "XSDRSIZE", "XSDRTDO", "XSETSDRMASKS", "XSDRINC", "XSDRB", "XSDRC", "XSDRE", "XSDRTDOB", "XSDRTDOC", "XSDRTDOE", "XSTATE", "XENDIR", "XENDDR", "XSIR2", "XCOMMENT", "XWAIT" }; char* xsvf_pzErrorName[] = { "No error", "ERROR: Unknown", "ERROR: TDO mismatch", "ERROR: TDO mismatch and exceeded max retries", "ERROR: Unsupported XSVF command", "ERROR: Illegal state specification", "ERROR: Data overflows allocated MAX_LEN buffer size" }; char* xsvf_pzTapState[] = { "RESET", /* 0x00 */ "RUNTEST/IDLE", /* 0x01 */ "DRSELECT", /* 0x02 */ "DRCAPTURE", /* 0x03 */ "DRSHIFT", /* 0x04 */ "DREXIT1", /* 0x05 */ "DRPAUSE", /* 0x06 */ "DREXIT2", /* 0x07 */ "DRUPDATE", /* 0x08 */ "IRSELECT", /* 0x09 */ "IRCAPTURE", /* 0x0A */ "IRSHIFT", /* 0x0B */ "IREXIT1", /* 0x0C */ "IRPAUSE", /* 0x0D */ "IREXIT2", /* 0x0E */ "IRUPDATE" /* 0x0F */ };#endif /* DEBUG_MODE */#ifdef DEBUG_MODE FILE* in; /* Legacy DEBUG_MODE file pointer */ int xsvf_iDebugLevel;#endif /* DEBUG_MODE *//*============================================================================* Utility Functions============================================================================*//****************************************************************************** Function: xsvfPrintLenVal* Description: Print the lenval value in hex.* Parameters: plv - ptr to lenval.* Returns: void.*****************************************************************************/#ifdef DEBUG_MODEvoid xsvfPrintLenVal( lenVal *plv ){ int i; if ( plv ) { printf( "0x" ); for ( i = 0; i < plv->len; ++i ) { printf( "%02x", ((unsigned int)(plv->val[ i ])) ); } }}#endif /* DEBUG_MODE *//****************************************************************************** Function: xsvfInfoInit* Description: Initialize the xsvfInfo data.* Parameters: pXsvfInfo - ptr to the XSVF info structure.* Returns: int - 0 = success; otherwise error.*****************************************************************************/int xsvfInfoInit( SXsvfInfo* pXsvfInfo ){ XSVFDBG_PRINTF1( 4, " sizeof( SXsvfInfo ) = %d bytes\n", sizeof( SXsvfInfo ) ); pXsvfInfo->ucComplete = 0; pXsvfInfo->ucCommand = XCOMPLETE; pXsvfInfo->lCommandCount = 0; pXsvfInfo->iErrorCode = XSVF_ERROR_NONE; pXsvfInfo->ucMaxRepeat = 0; pXsvfInfo->ucTapState = XTAPSTATE_RESET; pXsvfInfo->ucEndIR = XTAPSTATE_RUNTEST; pXsvfInfo->ucEndDR = XTAPSTATE_RUNTEST; pXsvfInfo->lShiftLengthBits = 0L; pXsvfInfo->sShiftLengthBytes= 0; pXsvfInfo->lRunTestTime = 0L; pXsvfInfo->iHir = 0; pXsvfInfo->iTir = 0; pXsvfInfo->iHdr = 0; pXsvfInfo->iTdr = 0; pXsvfInfo->iHdrFpga = 0; return( 0 );}/****************************************************************************** Function: xsvfInfoCleanup* Description: Cleanup the xsvfInfo data.* Parameters: pXsvfInfo - ptr to the XSVF info structure.* Returns: void.*****************************************************************************/void xsvfInfoCleanup( SXsvfInfo* pXsvfInfo ){}/****************************************************************************** Function: xsvfGetAsNumBytes* Description: Calculate the number of bytes the given number of bits* consumes.* Parameters: lNumBits - the number of bits.* Returns: short - the number of bytes to store the number of bits.*****************************************************************************/short xsvfGetAsNumBytes( long lNumBits ){ return( (short)( ( lNumBits + 7L ) / 8L ) );}/****************************************************************************** Function: xsvfTmsTransition* Description: Apply TMS and transition TAP controller by applying one TCK* cycle.* Parameters: sTms - new TMS value.* Returns: void.*****************************************************************************/void xsvfTmsTransition( short sTms ){ setPort( TMS, sTms ); setPort( TCK, 0 ); setPort( TCK, 1 );}/****************************************************************************** Function: xsvfGotoTapState* Description: From the current TAP state, go to the named TAP state.* A target state of RESET ALWAYS causes TMS reset sequence.* All SVF standard stable state paths are supported.* All state transitions are supported except for the following* which cause an XSVF_ERROR_ILLEGALSTATE:* - Target==DREXIT2; Start!=DRPAUSE* - Target==IREXIT2; Start!=IRPAUSE* Parameters: pucTapState - Current TAP state; returns final TAP state.* ucTargetState - New target TAP state.* Returns: int - 0 = success; otherwise error.*****************************************************************************/int xsvfGotoTapState( unsigned char* pucTapState, unsigned char ucTargetState ){ int i; int iErrorCode; iErrorCode = XSVF_ERROR_NONE; if ( ucTargetState == XTAPSTATE_RESET ) { /* If RESET, always perform TMS reset sequence to reset/sync TAPs */ xsvfTmsTransition( 1 ); for ( i = 0; i < 5; ++i ) { setPort( TCK, 0 ); setPort( TCK, 1 ); } *pucTapState = XTAPSTATE_RESET; XSVFDBG_PRINTF( 3, " TMS Reset Sequence -> Test-Logic-Reset\n" ); XSVFDBG_PRINTF1( 3, " TAP State = %s\n", xsvf_pzTapState[ *pucTapState ] ); } else if ( ( ucTargetState != *pucTapState ) && ( ( ( ucTargetState == XTAPSTATE_EXIT2DR ) && ( *pucTapState != XTAPSTATE_PAUSEDR ) ) || ( ( ucTargetState == XTAPSTATE_EXIT2IR ) && ( *pucTapState != XTAPSTATE_PAUSEIR ) ) ) ) { /* Trap illegal TAP state path specification */ iErrorCode = XSVF_ERROR_ILLEGALSTATE; } else { if ( ucTargetState == *pucTapState ) { /* Already in target state. Do nothing except when in DRPAUSE or in IRPAUSE to comply with SVF standard */ if ( ucTargetState == XTAPSTATE_PAUSEDR ) { xsvfTmsTransition( 1 ); *pucTapState = XTAPSTATE_EXIT2DR; XSVFDBG_PRINTF1( 3, " TAP State = %s\n", xsvf_pzTapState[ *pucTapState ] ); } else if ( ucTargetState == XTAPSTATE_PAUSEIR ) { xsvfTmsTransition( 1 ); *pucTapState = XTAPSTATE_EXIT2IR; XSVFDBG_PRINTF1( 3, " TAP State = %s\n", xsvf_pzTapState[ *pucTapState ] ); } } /* Perform TAP state transitions to get to the target state */ while ( ucTargetState != *pucTapState ) { switch ( *pucTapState ) { case XTAPSTATE_RESET: xsvfTmsTransition( 0 ); *pucTapState = XTAPSTATE_RUNTEST; break; case XTAPSTATE_RUNTEST: xsvfTmsTransition( 1 ); *pucTapState = XTAPSTATE_SELECTDR; break; case XTAPSTATE_SELECTDR: if ( ucTargetState >= XTAPSTATE_IRSTATES ) { xsvfTmsTransition( 1 ); *pucTapState = XTAPSTATE_SELECTIR; } else { xsvfTmsTransition( 0 ); *pucTapState = XTAPSTATE_CAPTUREDR; } break; case XTAPSTATE_CAPTUREDR: if ( ucTargetState == XTAPSTATE_SHIFTDR ) { xsvfTmsTransition( 0 ); *pucTapState = XTAPSTATE_SHIFTDR; } else { xsvfTmsTransition( 1 ); *pucTapState = XTAPSTATE_EXIT1DR; } break; case XTAPSTATE_SHIFTDR: xsvfTmsTransition( 1 ); *pucTapState = XTAPSTATE_EXIT1DR; break; case XTAPSTATE_EXIT1DR: if ( ucTargetState == XTAPSTATE_PAUSEDR ) { xsvfTmsTransition( 0 ); *pucTapState = XTAPSTATE_PAUSEDR; } else { xsvfTmsTransition( 1 ); *pucTapState = XTAPSTATE_UPDATEDR; } break; case XTAPSTATE_PAUSEDR: xsvfTmsTransition( 1 ); *pucTapState = XTAPSTATE_EXIT2DR; break; case XTAPSTATE_EXIT2DR: if ( ucTargetState == XTAPSTATE_SHIFTDR ) { xsvfTmsTransition( 0 ); *pucTapState = XTAPSTATE_SHIFTDR; } else { xsvfTmsTransition( 1 ); *pucTapState = XTAPSTATE_UPDATEDR; } break; case XTAPSTATE_UPDATEDR: if ( ucTargetState == XTAPSTATE_RUNTEST ) { xsvfTmsTransition( 0 ); *pucTapState = XTAPSTATE_RUNTEST; } else { xsvfTmsTransition( 1 ); *pucTapState = XTAPSTATE_SELECTDR; } break; case XTAPSTATE_SELECTIR: xsvfTmsTransition( 0 ); *pucTapState = XTAPSTATE_CAPTUREIR; break; case XTAPSTATE_CAPTUREIR: if ( ucTargetState == XTAPSTATE_SHIFTIR ) { xsvfTmsTransition( 0 ); *pucTapState = XTAPSTATE_SHIFTIR; } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -