📄 micro.c
字号:
&(pXsvfInfo->lvTdoExpected),
&(pXsvfInfo->lvTdoMask),
pXsvfInfo->ucEndDR,
pXsvfInfo->lRunTestTime,
pXsvfInfo->ucMaxRepeat );
if ( iErrorCode != XSVF_ERROR_NONE )
{
pXsvfInfo->iErrorCode = iErrorCode;
}
return( iErrorCode );
}
/*****************************************************************************
* Function: xsvfDoXSETSDRMASKS
* Description: XSETSDRMASKS <lenVal.AddressMask[XSDRSIZE]>
* <lenVal.DataMask[XSDRSIZE]>
* Get the prespecified address and data mask for the XSDRINC
* command.
* Used for xc9500/xl compressed XSVF data.
* Parameters: pXsvfInfo - XSVF information pointer.
* Returns: int - 0 = success; non-zero = error.
*****************************************************************************/
#ifdef XSVF_SUPPORT_COMPRESSION
int xsvfDoXSETSDRMASKS( SXsvfInfo* pXsvfInfo )
{
/* read the addressMask */
readVal( &(pXsvfInfo->lvAddressMask), pXsvfInfo->sShiftLengthBytes );
/* read the dataMask */
readVal( &(pXsvfInfo->lvDataMask), pXsvfInfo->sShiftLengthBytes );
XSVFDBG_PRINTF( 4, " Address Mask = " );
XSVFDBG_PRINTLENVAL( 4, &(pXsvfInfo->lvAddressMask) );
XSVFDBG_PRINTF( 4, "\n" );
XSVFDBG_PRINTF( 4, " Data Mask = " );
XSVFDBG_PRINTLENVAL( 4, &(pXsvfInfo->lvDataMask) );
XSVFDBG_PRINTF( 4, "\n" );
return( XSVF_ERROR_NONE );
}
#endif /* XSVF_SUPPORT_COMPRESSION */
/*****************************************************************************
* Function: xsvfDoXSDRINC
* Description: XSDRINC <lenVal.firstTDI[XSDRSIZE]> <byte(numTimes)>
* <lenVal.data[XSETSDRMASKS.dataMask.len]> ...
* Get the XSDRINC parameters and execute the XSDRINC command.
* XSDRINC starts by loading the first TDI shift value.
* Then, for numTimes, XSDRINC gets the next piece of data,
* replaces the bits from the starting TDI as defined by the
* XSETSDRMASKS.dataMask, adds the address mask from
* XSETSDRMASKS.addressMask, shifts the new TDI value,
* and compares the TDO to the expected TDO from the previous
* XSDRTDO command using the XTDOMASK.
* Used for xc9500/xl compressed XSVF data.
* Parameters: pXsvfInfo - XSVF information pointer.
* Returns: int - 0 = success; non-zero = error.
*****************************************************************************/
#ifdef XSVF_SUPPORT_COMPRESSION
int xsvfDoXSDRINC( SXsvfInfo* pXsvfInfo )
{
int iErrorCode;
int iDataMaskLen;
unsigned char ucDataMask;
unsigned char ucNumTimes;
unsigned char i;
readVal( &(pXsvfInfo->lvTdi), pXsvfInfo->sShiftLengthBytes );
iErrorCode = xsvfShift( &(pXsvfInfo->ucTapState), XTAPSTATE_SHIFTDR,
pXsvfInfo->lShiftLengthBits,
&(pXsvfInfo->lvTdi), &(pXsvfInfo->lvTdoCaptured),
&(pXsvfInfo->lvTdoExpected),
&(pXsvfInfo->lvTdoMask), pXsvfInfo->ucEndDR,
pXsvfInfo->lRunTestTime, pXsvfInfo->ucMaxRepeat );
if ( !iErrorCode )
{
/* Calculate number of data mask bits */
iDataMaskLen = 0;
for ( i = 0; i < pXsvfInfo->lvDataMask.len; ++i )
{
ucDataMask = pXsvfInfo->lvDataMask.val[ i ];
while ( ucDataMask )
{
iDataMaskLen += ( ucDataMask & 1 );
ucDataMask >>= 1;
}
}
/* Get the number of data pieces, i.e. number of times to shift */
readByte( &ucNumTimes );
/* For numTimes, get data, fix TDI, and shift */
for ( i = 0; !iErrorCode && ( i < ucNumTimes ); ++i )
{
readVal( &(pXsvfInfo->lvNextData),
xsvfGetAsNumBytes( iDataMaskLen ) );
xsvfDoSDRMasking( &(pXsvfInfo->lvTdi),
&(pXsvfInfo->lvNextData),
&(pXsvfInfo->lvAddressMask),
&(pXsvfInfo->lvDataMask) );
iErrorCode = xsvfShift( &(pXsvfInfo->ucTapState),
XTAPSTATE_SHIFTDR,
pXsvfInfo->lShiftLengthBits,
&(pXsvfInfo->lvTdi),
&(pXsvfInfo->lvTdoCaptured),
&(pXsvfInfo->lvTdoExpected),
&(pXsvfInfo->lvTdoMask),
pXsvfInfo->ucEndDR,
pXsvfInfo->lRunTestTime,
pXsvfInfo->ucMaxRepeat );
}
}
if ( iErrorCode != XSVF_ERROR_NONE )
{
pXsvfInfo->iErrorCode = iErrorCode;
}
return( iErrorCode );
}
#endif /* XSVF_SUPPORT_COMPRESSION */
/*****************************************************************************
* Function: xsvfDoXSDRBCE
* Description: XSDRB/XSDRC/XSDRE <lenVal.TDI[XSDRSIZE]>
* If not already in SHIFTDR, goto SHIFTDR.
* Shift the given TDI data into the JTAG scan chain.
* Ignore TDO.
* If cmd==XSDRE, then goto ENDDR. Otherwise, stay in ShiftDR.
* XSDRB, XSDRC, and XSDRE are the same implementation.
* Parameters: pXsvfInfo - XSVF information pointer.
* Returns: int - 0 = success; non-zero = error.
*****************************************************************************/
int xsvfDoXSDRBCE( SXsvfInfo* pXsvfInfo )
{
unsigned char ucEndDR;
int iErrorCode;
ucEndDR = (unsigned char)(( pXsvfInfo->ucCommand == XSDRE ) ?
pXsvfInfo->ucEndDR : XTAPSTATE_SHIFTDR);
iErrorCode = xsvfBasicXSDRTDO( &(pXsvfInfo->ucTapState),
pXsvfInfo->lShiftLengthBits,
pXsvfInfo->sShiftLengthBytes,
&(pXsvfInfo->lvTdi),
/*plvTdoCaptured*/0, /*plvTdoExpected*/0,
/*plvTdoMask*/0, ucEndDR,
/*lRunTestTime*/0, /*ucMaxRepeat*/0 );
if ( iErrorCode != XSVF_ERROR_NONE )
{
pXsvfInfo->iErrorCode = iErrorCode;
}
return( iErrorCode );
}
/*****************************************************************************
* Function: xsvfDoXSDRTDOBCE
* Description: XSDRB/XSDRC/XSDRE <lenVal.TDI[XSDRSIZE]> <lenVal.TDO[XSDRSIZE]>
* If not already in SHIFTDR, goto SHIFTDR.
* Shift the given TDI data into the JTAG scan chain.
* Compare TDO, but do NOT use XTDOMASK.
* If cmd==XSDRTDOE, then goto ENDDR. Otherwise, stay in ShiftDR.
* XSDRTDOB, XSDRTDOC, and XSDRTDOE are the same implementation.
* Parameters: pXsvfInfo - XSVF information pointer.
* Returns: int - 0 = success; non-zero = error.
*****************************************************************************/
int xsvfDoXSDRTDOBCE( SXsvfInfo* pXsvfInfo )
{
unsigned char ucEndDR;
int iErrorCode;
ucEndDR = (unsigned char)(( pXsvfInfo->ucCommand == XSDRTDOE ) ?
pXsvfInfo->ucEndDR : XTAPSTATE_SHIFTDR);
iErrorCode = xsvfBasicXSDRTDO( &(pXsvfInfo->ucTapState),
pXsvfInfo->lShiftLengthBits,
pXsvfInfo->sShiftLengthBytes,
&(pXsvfInfo->lvTdi),
&(pXsvfInfo->lvTdoCaptured),
&(pXsvfInfo->lvTdoExpected),
/*plvTdoMask*/0, ucEndDR,
/*lRunTestTime*/0, /*ucMaxRepeat*/0 );
if ( iErrorCode != XSVF_ERROR_NONE )
{
pXsvfInfo->iErrorCode = iErrorCode;
}
return( iErrorCode );
}
/*****************************************************************************
* Function: xsvfDoXSTATE
* Description: XSTATE <byte>
* <byte> == XTAPSTATE;
* Get the state parameter and transition the TAP to that state.
* Parameters: pXsvfInfo - XSVF information pointer.
* Returns: int - 0 = success; non-zero = error.
*****************************************************************************/
int xsvfDoXSTATE( SXsvfInfo* pXsvfInfo )
{
unsigned char ucNextState;
int iErrorCode;
readByte( &ucNextState );
iErrorCode = xsvfGotoTapState( &(pXsvfInfo->ucTapState), ucNextState );
if ( iErrorCode != XSVF_ERROR_NONE )
{
pXsvfInfo->iErrorCode = iErrorCode;
}
return( iErrorCode );
}
/*****************************************************************************
* Function: xsvfDoXENDXR
* Description: XENDIR/XENDDR <byte>
* <byte>: 0 = RUNTEST; 1 = PAUSE.
* Get the prespecified XENDIR or XENDDR.
* Both XENDIR and XENDDR use the same implementation.
* Parameters: pXsvfInfo - XSVF information pointer.
* Returns: int - 0 = success; non-zero = error.
*****************************************************************************/
int xsvfDoXENDXR( SXsvfInfo* pXsvfInfo )
{
int iErrorCode;
unsigned char ucEndState;
iErrorCode = XSVF_ERROR_NONE;
readByte( &ucEndState );
if ( ( ucEndState != XENDXR_RUNTEST ) && ( ucEndState != XENDXR_PAUSE ) )
{
iErrorCode = XSVF_ERROR_ILLEGALSTATE;
}
else
{
if ( pXsvfInfo->ucCommand == XENDIR )
{
if ( ucEndState == XENDXR_RUNTEST )
{
pXsvfInfo->ucEndIR = XTAPSTATE_RUNTEST;
}
else
{
pXsvfInfo->ucEndIR = XTAPSTATE_PAUSEIR;
}
XSVFDBG_PRINTF1( 3, " ENDIR State = %s\n",
xsvf_pzTapState[ pXsvfInfo->ucEndIR ] );
}
else /* XENDDR */
{
if ( ucEndState == XENDXR_RUNTEST )
{
pXsvfInfo->ucEndDR = XTAPSTATE_RUNTEST;
}
else
{
pXsvfInfo->ucEndDR = XTAPSTATE_PAUSEDR;
}
XSVFDBG_PRINTF1( 3, " ENDDR State = %s\n",
xsvf_pzTapState[ pXsvfInfo->ucEndDR ] );
}
}
if ( iErrorCode != XSVF_ERROR_NONE )
{
pXsvfInfo->iErrorCode = iErrorCode;
}
return( iErrorCode );
}
/*****************************************************************************
* Function: xsvfDoXCOMMENT
* Description: XCOMMENT <text string ending in \0>
* <text string ending in \0> == text comment;
* Arbitrary comment embedded in the XSVF.
* Parameters: pXsvfInfo - XSVF information pointer.
* Returns: int - 0 = success; non-zero = error.
*****************************************************************************/
int xsvfDoXCOMMENT( SXsvfInfo* pXsvfInfo )
{
/* Use the comment for debugging */
/* Otherwise, read through the comment to the end '\0' and ignore */
unsigned char ucText;
if ( xsvf_iDebugLevel > 0 )
{
putchar( ' ' );
}
do
{
readByte( &ucText );
if ( xsvf_iDebugLevel > 0 )
{
putchar( ucText ? ucText : '\n' );
}
} while ( ucText );
pXsvfInfo->iErrorCode = XSVF_ERROR_NONE;
return( pXsvfInfo->iErrorCode );
}
/*****************************************************************************
* Function: xsvfDoXWAIT
* Description: XWAIT <wait_state> <end_state> <wait_time>
* If not already in <wait_state>, then go to <wait_state>.
* Wait in <wait_state> for <wait_time> microseconds.
* Finally, if not already in <end_state>, then goto <end_state>.
* Parameters: pXsvfInfo - XSVF information pointer.
* Returns: int - 0 = success; non-zero = error.
*****************************************************************************/
int xsvfDoXWAIT( SXsvfInfo* pXsvfInfo )
{
unsigned char ucWaitState;
unsigned char ucEndState;
long lWaitTime;
/* Get Parameters */
/* <wait_state> */
readVal( &(pXsvfInfo->lvTdi), 1 );
ucWaitState = pXsvfInfo->lvTdi.val[0];
/* <end_state> */
readVal( &(pXsvfInfo->lvTdi), 1 );
ucEndState = pXsvfInfo->lvTdi.val[0];
/* <wait_time> */
readVal( &(pXsvfInfo->lvTdi), 4 );
lWaitTime = value( &(pXsvfInfo->lvTdi) );
XS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -