⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 springboardio.c

📁 可编程器件厂商Xilinx的手持式逻辑分析仪的逻辑设计
💻 C
📖 第 1 页 / 共 4 页
字号:
/*============================================================================*/
Boolean sbioWriteRunReg (Boolean bStartStop, UInt8 uiBankSelect)
{
    /*========================================================================*/
    /* Declare all local variables.                                           */
    /*========================================================================*/
    UInt16  *uiRegAddress;
    UInt16  uiStartStopSettings = 0;
    Boolean bSuccess = true;
    EventType event;

#ifndef EmulateSBIO
    /*========================================================================*/
    /* Set the Register Address equal to the Sample Rate register.            */
    /*========================================================================*/
    uiRegAddress = (unsigned short *)StartStopReg;

    /*========================================================================*/
    /* If the Start command has been sent, then set the run bit in the        */
    /* control word and set the Bank Select bits.                             */
    /*========================================================================*/
    if (bStartStop == true)
    {
        uiStartStopSettings = (uiBankSelect & 0x001F);
        uiStartStopSettings |= 0x8000;
    }

    /*========================================================================*/
    /* If the Stop command has been sent, we only need to clear the run bit   */
    /* in the control word.                                                   */
    /*========================================================================*/
    else
        uiStartStopSettings = 0;


    /*========================================================================*/
    /* Write the new sample rate setting value to the actual register.        */
    /*========================================================================*/
    HsCardErrTry
    {
        *uiRegAddress = uiStartStopSettings;
    }
    HsCardErrCatch
    {
        bSuccess = false;

        /*====================================================================*/
        /* Alert the user that the HandSpring Module must be installed before */
        /* the PocketAnalyzer Application can be run.                         */
        /*====================================================================*/
        FrmAlert (NoSpringBoardModuleAlert);

        /*====================================================================*/
        /* Add and event to the queue to inform the PocketAnalyzer application*/
        /* to stop and shutdown.                                              */
        /*====================================================================*/
        event.eType = appStopEvent;
        EvtAddEventToQueue(&event);
    } HsCardErrEnd
#endif

    return (bSuccess);
}




/*============================================================================*/
/* Function:            sbioReadRunState                                      */
/* Description:         This routine ...                                      */
/*                                                                            */
/* Arguments:           RunStateBuffer = Structure for the returned data.     */
/* Returns:             bSuccess       = Successful read of the SpringBoard   */
/*                                       module.                              */
/* Globals affected:    None                                                  */
/* Hardware affected:   None                                                  */
/*                                                                            */
/*============================================================================*/
/* Change History:                                                            */
/*                                                                            */
/* ECO#:  ?                                                                   */
/* Change Date:  dd-mmm-yyyy                                                  */
/* Changed By:   ?                                                            */
/* Description of Change:  ?                                                  */
/*                                                                            */
/*============================================================================*/
Boolean sbioReadRunState (sbioRunStateType* RunStateBuffer)
{
    /*========================================================================*/
    /* Declare all local variables.                                           */
    /*========================================================================*/
    UInt16  *uiRegAddress;
    UInt16  uiRunState;
    Boolean bSuccess = true;
    EventType event;

#ifndef EmulateSBIO
    /*========================================================================*/
    /* Set the Register Address equal to the Sample Rate register.            */
    /*========================================================================*/
    uiRegAddress = (unsigned short *)RunStateReg;

    /*========================================================================*/
    /* Read the data from the SpringBoard Module.                             */
    /*========================================================================*/
    HsCardErrTry
    {
        uiRunState = *uiRegAddress;
    }
    HsCardErrCatch
    {
        bSuccess = false;

        /*====================================================================*/
        /* Alert the user that the HandSpring Module must be installed before */
        /* the PocketAnalyzer Application can be run.                         */
        /*====================================================================*/
        FrmAlert (NoSpringBoardModuleAlert);

        /*====================================================================*/
        /* Add and event to the queue to inform the PocketAnalyzer application*/
        /* to stop and shutdown.                                              */
        /*====================================================================*/
        event.eType = appStopEvent;
        EvtAddEventToQueue(&event);
    } HsCardErrEnd


    if (bSuccess == true)
    {
        /*====================================================================*/
        /* Get the state of the Run/Stop bit.                                 */
        /*====================================================================*/
        if ((uiRunState & 0x8000) != 0)
            RunStateBuffer->bRunStop = true;
        else
            RunStateBuffer->bRunStop = false;

        /*====================================================================*/
        /* Get the state of the Trigger Found bit.                            */
        /*====================================================================*/
        if ((uiRunState & 0x4000) != 0)
            RunStateBuffer->bTrigFound = true;
        else
            RunStateBuffer->bTrigFound = false;

        /*====================================================================*/
        /* Get the value that indicates if the Trigger occurred in the high   */
        /* or low byte of the 16-bit address indicated.                       */
        /*====================================================================*/
        if ((uiRunState & 0x2000) != 0)
            RunStateBuffer->bTrigWordHiByte = true;
        else
            RunStateBuffer->bTrigWordHiByte = false;

        /*====================================================================*/
        /* Get the trigger address pointer.                                   */
        /*====================================================================*/
        RunStateBuffer->uiTrigOffset = (uiRunState & 0x1FFF);
    }

#else
    RunStateBuffer->bRunStop = false;
    RunStateBuffer->bTrigFound = true;
    RunStateBuffer->bTrigWordHiByte = true;
    RunStateBuffer->uiTrigOffset = 0;
#endif

    return (bSuccess);
}




/*============================================================================*/
/* Function:            sbioReadProbeState                                    */
/* Description:         This routine reads the current data from the          */
/*                      ProbeState register of the SpringBoard module.        */
/*                                                                            */
/* Arguments:           None                                                  */
/* Returns:             CurrentState = Current state of the probe inputs.     */
/* Globals affected:    None                                                  */
/* Hardware affected:   None                                                  */
/*                                                                            */
/*============================================================================*/
/* Change History:                                                            */
/*                                                                            */
/* ECO#:  ?                                                                   */
/* Change Date:  dd-mmm-yyyy                                                  */
/* Changed By:   ?                                                            */
/* Description of Change:  ?                                                  */
/*                                                                            */
/*============================================================================*/
UInt16 sbioReadProbeState (void)
{
    /*========================================================================*/
    /* Declare all local variables.                                           */
    /*========================================================================*/
    UInt16  *uiRegAddress;
    UInt16  uiProbeStates;
    Boolean bSuccess = true;
    EventType event;

#ifndef EmulateSBIO
    /*========================================================================*/
    /* Set the Register Address equal to the Sample Rate register.            */
    /*========================================================================*/
    uiRegAddress = (unsigned short *)ChannelStateReg;

    /*========================================================================*/
    /* Read the data from the SpringBoard Module.                             */
    /*========================================================================*/
    HsCardErrTry
    {
        uiProbeStates = *uiRegAddress;
    }
    HsCardErrCatch
    {
        bSuccess = false;

        /*====================================================================*/
        /* Alert the user that the HandSpring Module must be installed before */
        /* the PocketAnalyzer Application can be run.                         */
        /*====================================================================*/
        FrmAlert (NoSpringBoardModuleAlert);

        /*====================================================================*/
        /* Add and event to the queue to inform the PocketAnalyzer application*/
        /* to stop and shutdown.                                              */
        /*====================================================================*/
        event.eType = appStopEvent;
        EvtAddEventToQueue(&event);
    } HsCardErrEnd

    /*========================================================================*/
    /* If the data read was successful, then return the data with the high    */
    /* byte of the data cleared.  If the data read failed, then return the    */
    /* data with the high byte set and the low byte cleared.                  */
    /*========================================================================*/
    if (bSuccess == true)
        uiProbeStates &= 0x00FF;
    else
        uiProbeStates = 0xFF00;

#else
    #ifdef SimRandomIO
        uiProbeStates = (UInt16)(SysRandom(0) & 0x00FF);
    #else
        uiProbeStates = (UInt16)(Counter() & 0x00FF);
    #endif
#endif

    return (uiProbeStates);
}




/*============================================================================*/
/* Function:            sbioReadBuffData                                      */
/* Description:         This routine function reads all 8K of data from the   */
/*                      specified data bank and adjust the data to be         */
/*                      sequential based on the trigger offset into the data  */
/*                      bank.  This adjustment is necessary since the data    */
/*                      bank is a circular buffer to allow for the proper     */
/*                      collection of the pre-trigger data.                   */
/*                                                                            */
/* Arguments:           uiBankSelect  = The data bank (0-63) in which the data*/
/*                                      has been stored.                      */
/*                      uiTrigOffset  = Offset into the data bank where the   */
/*                                      trigger occurred.                     */
/*                      bTrigInHiByte = Flag indicating that the trigger      */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -