?? micro.c
字號:
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 ) { putc( ' ' ); } do { readByte( &ucText ); if ( xsvf_iDebugLevel > 0 ) { putc( 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) ); XSVFDBG_PRINTF2( 3, " XWAIT: state = %s; time = %ld\n", xsvf_pzTapState[ ucWaitState ], lWaitTime ); /* If not already in <wait_state>, go to <wait_state> */ if ( pXsvfInfo->ucTapState != ucWaitState ) { xsvfGotoTapState( &(pXsvfInfo->ucTapState), ucWaitState ); } /* Wait for <wait_time> microseconds */ waitTime( lWaitTime ); /* If not already in <end_state>, go to <end_state> */ if ( pXsvfInfo->ucTapState != ucEndState ) { xsvfGotoTapState( &(pXsvfInfo->ucTapState), ucEndState ); } return( XSVF_ERROR_NONE );}/*============================================================================ * Execution Control Functions ============================================================================*//***************************************************************************** * Function: xsvfInitialize * Description: Initialize the xsvf player. * Call this before running the player to initialize the data * in the SXsvfInfo struct. * xsvfCleanup is called to clean up the data in SXsvfInfo * after the XSVF is played. * Parameters: pXsvfInfo - ptr to the XSVF information. * Returns: int - 0 = success; otherwise error. *****************************************************************************/int xsvfInitialize( SXsvfInfo* pXsvfInfo ){ /* Initialize values */ pXsvfInfo->iErrorCode = xsvfInfoInit( pXsvfInfo ); if ( !pXsvfInfo->iErrorCode ) { /* Initialize the TAPs */ pXsvfInfo->iErrorCode = xsvfGotoTapState( &(pXsvfInfo->ucTapState), XTAPSTATE_RESET ); } return( pXsvfInfo->iErrorCode );}/***************************************************************************** * Function: xsvfRun * Description: Run the xsvf player for a single command and return. * First, call xsvfInitialize. * Then, repeatedly call this function until an error is detected * or until the pXsvfInfo->ucComplete variable is non-zero. * Finally, call xsvfCleanup to cleanup any remnants. * Parameters: pXsvfInfo - ptr to the XSVF information. * Returns: int - 0 = success; otherwise error. *****************************************************************************/int xsvfRun( SXsvfInfo* pXsvfInfo ){ /* Process the XSVF commands */ if ( (!pXsvfInfo->iErrorCode) && (!pXsvfInfo->ucComplete) ) { /* read 1 byte for the instruction */ readByte( &(pXsvfInfo->ucCommand) ); ++(pXsvfInfo->lCommandCount); if ( pXsvfInfo->ucCommand < XLASTCMD ) { /* Execute the command. Func sets error code. */ XSVFDBG_PRINTF1( 2, " %s\n", xsvf_pzCommandName[pXsvfInfo->ucCommand] ); /* If your compiler cannot take this form, then convert to a switch statement */#if 0 /* test-only */ xsvf_pfDoCmd[ pXsvfInfo->ucCommand ]( pXsvfInfo );#else switch (pXsvfInfo->ucCommand) { case 0: xsvfDoXCOMPLETE(pXsvfInfo); /* 0 */ break; case 1: xsvfDoXTDOMASK(pXsvfInfo); /* 1 */ break; case 2: xsvfDoXSIR(pXsvfInfo); /* 2 */ break; case 3: xsvfDoXSDR(pXsvfInfo); /* 3 */ break; case 4: xsvfDoXRUNTEST(pXsvfInfo); /* 4 */ break; case 5: xsvfDoIllegalCmd(pXsvfInfo); /* 5 */ break; case 6: xsvfDoIllegalCmd(pXsvfInfo); /* 6 */ break; case 7: xsvfDoXREPEAT(pXsvfInfo); /* 7 */ break; case 8: xsvfDoXSDRSIZE(pXsvfInfo); /* 8 */ break; case 9: xsvfDoXSDRTDO(pXsvfInfo); /* 9 */ break;#ifdef XSVF_SUPPORT_COMPRESSION case 10: xsvfDoXSETSDRMASKS(pXsvfInfo); /* 10 */ break; case 11: xsvfDoXSDRINC(pXsvfInfo); /* 11 */ break;#else case 10: xsvfDoIllegalCmd(pXsvfInfo); /* 10 */ break; case 11: xsvfDoIllegalCmd(pXsvfInfo); /* 11 */ break;#endif /* XSVF_SUPPORT_COMPRESSION */ case 12: xsvfDoXSDRBCE(pXsvfInfo); /* 12 */ break; case 13: xsvfDoXSDRBCE(pXsvfInfo); /* 13 */ break; case 14: xsvfDoXSDRBCE(pXsvfInfo); /* 14 */ break; case 15: xsvfDoXSDRTDOBCE(pXsvfInfo); /* 15 */ break; case 16: xsvfDoXSDRTDOBCE(pXsvfInfo); /* 16 */ break; case 17: xsvfDoXSDRTDOBCE(pXsvfInfo); /* 17 */ break; case 18: xsvfDoXSTATE(pXsvfInfo); /* 18 */ break; case 19: xsvfDoXENDXR(pXsvfInfo); /* 19 */ break; case 20: xsvfDoXENDXR(pXsvfInfo); /* 20 */ break; case 21: xsvfDoXSIR2(pXsvfInfo); /* 21 */ break; case 22: xsvfDoXCOMMENT(pXsvfInfo); /* 22 */ break; case 23: xsvfDoXWAIT(pXsvfInfo); /* 23 */ break; }#endif } else { /* Illegal command value. Func sets error code. */ xsvfDoIllegalCmd( pXsvfInfo ); } } return( pXsvfInfo->iErrorCode );}/***************************************************************************** * Function: xsvfCleanup * Description: cleanup remnants of the xsvf player. * Parameters: pXsvfInfo - ptr to the XSVF information. * Returns: void. *****************************************************************************/void xsvfCleanup( SXsvfInfo* pXsvfInfo ){ xsvfInfoCleanup( pXsvfInfo );}/*============================================================================ * xsvfExecute() - The primary entry point to the XSVF player ============================================================================*//***************************************************************************** * Function: xsvfExecute * Description: Process, interpret, and apply the XSVF commands. * See port.c:readByte for source of XSVF data. * Parameters: none. * Returns: int - Legacy result values: 1 == success; 0 == failed. *****************************************************************************/int xsvfExecute(void){ SXsvfInfo xsvfInfo; xsvfInitialize( &xsvfInfo ); while ( !xsvfInfo.iErrorCode && (!xsvfInfo.ucComplete) ) { xsvfRun( &xsvfInfo ); } if ( xsvfInfo.iErrorCode ) { XSVFDBG_PRINTF1( 0, "%s\n", xsvf_pzErrorName[ ( xsvfInfo.iErrorCode < XSVF_ERROR_LAST ) ? xsvfInfo.iErrorCode : XSVF_ERROR_UNKNOWN ] ); XSVFDBG_PRINTF2( 0, "ERROR at or near XSVF command #%ld. See line #%ld in the XSVF ASCII file.\n", xsvfInfo.lCommandCount, xsvfInfo.lCommandCount ); } else { XSVFDBG_PRINTF( 0, "SUCCESS - Completed XSVF execution.\n" ); } xsvfCleanup( &xsvfInfo ); return( XSVF_ERRORCODE(xsvfInfo.iErrorCode) );}/***************************************************************************** * Function: do_cpld * Description: main function. * Specified here for creating stand-alone debug executable. * Embedded users should call xsvfExecute() directly. * Parameters: iArgc - number of command-line arguments. * ppzArgv - array of ptrs to strings (command-line arguments). * Returns: int - Legacy return value: 1 = success; 0 = error. *****************************************************************************/int do_cpld(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ int iErrorCode; char* pzXsvfFileName; unsigned long duration; unsigned long long startClock, endClock; iErrorCode = XSVF_ERRORCODE( XSVF_ERROR_NONE ); pzXsvfFileName = 0; xsvf_iDebugLevel = 0; printf("XSVF Player v%s, Xilinx, Inc.\n", XSVF_VERSION); printf("XSVF Filesize = %d bytes\n", filesize); /* Initialize the I/O. SetPort initializes I/O on first call */ setPort( TMS, 1 ); /* Execute the XSVF in the file */ startClock = get_ticks(); iErrorCode = xsvfExecute(); endClock = get_ticks(); duration = (unsigned long)(endClock - startClock); printf("\nExecution Time = %d seconds\n", (int)(duration/get_tbclk())); return( iErrorCode );}U_BOOT_CMD( cpld, 1, 1, do_cpld, "cpld - Program onboard CPLD\n", NULL );
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -