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

📄 springboardio.c

📁 可编程器件厂商Xilinx的手持式逻辑分析仪的逻辑设计
💻 C
📖 第 1 页 / 共 4 页
字号:
/*============================================================================*/
/* Filename:    SpringBoardIO.c                                               */
/*                                                                            */
/* Description: This file contains the functions that provide the interface   */
/*                      ...                                                   */
/*                                                                            */
/* Required Header File(s): PalmOS.h                                          */
/*                          PocketAnalyzerRsc.h                               */
/*                          Globals.h                                         */
/*                                                                            */
/* Function List:                                                             */
/*      ?()             This function ...                                     */
/*                                                                            */
/*============================================================================*/
/* COPYRIGHT (C) 2001                                                         */
/* NowTech, LLC                                                               */
/* Knoxville, TN                                                              */
/*                                                                            */
/* ALL RIGHTS RESERVED                                                        */
/*                                                                            */
/* This software and all information and ideas contained within are the sole  */
/* property of NowTech, LLC and are confidential.  Neither this software nor  */
/* any part nor any information contained in it may be disclosed or furnished */
/* to others without the prior written consent of NowTech, LLC.               */
/*                                                                            */
/*============================================================================*/

/*============================================================================*/
/* System Level Include Files:                                                */
/*============================================================================*/
#include <PalmOS.h>

/*============================================================================*/
/* Project Specific Include Files:                                            */
/*============================================================================*/
#include "PocketAnalyzerRsc.h"
#include "GlobalDefs.h"
#include "SpringBoardIO.h"
#include "HsExt.h"

/*============================================================================*/
/* Define any data structures that are used exclusively by the functions      */
/* local to this source file.                                                 */
/*============================================================================*/
/***** None *****/

/*============================================================================*/
/* Define all constants used by the functions in this source file.            */
/*============================================================================*/
/***** None *****/

/*============================================================================*/
/* Define all variables which must have project global scope.  All variables  */
/* defined in this section will be accessible by all functions in all source  */
/* files in this project and must have a corresponding extern statement in    */
/* the GlobalDefs.h include file.                                             */
/*============================================================================*/
/***** None *****/


/*============================================================================*/
/* Define all variables which must have source file global scope but not have */
/* project wide scope.  These variables must be defined with the "static"     */
/* type qualifier so that the variables scope will be limited to only the     */
/* functions in this source file.                                             */
/*============================================================================*/
/***** None *****/


/*============================================================================*/
/* Define the function prototypes for all local functions.  The prototypes    */
/* for all global functions should be defined in the GlobalDefs.h include     */
/* file.                                                                      */
/*============================================================================*/
unsigned int Counter (void);




/*============================================================================*/
/* Function:            sbioWriteSmplRateReg                                  */
/* Description:         This routine receives the new target sample rate      */
/*                      setting and performs the necessary work to write the  */
/*                      proper code value to the Springboard SampleRate       */
/*                      register in order to achieve this setting.            */
/*                                                                            */
/* Arguments:           NewSampleRate = The new target sample rate.           */
/* Returns:             bSuccess = Results of operation.                      */
/*                                      true = successful,                    */
/*                                      false = unsuccessful.                 */
/* Globals affected:    None                                                  */
/* Hardware affected:   None                                                  */
/*                                                                            */
/*============================================================================*/
/* Change History:                                                            */
/*                                                                            */
/* ECO#:  ?                                                                   */
/* Change Date:  dd-mmm-yyyy                                                  */
/* Changed By:   ?                                                            */
/* Description of Change:  ?                                                  */
/*                                                                            */
/*============================================================================*/
Boolean sbioWriteSmplRateReg (TimebaseType NewSampleRate)
{
    /*========================================================================*/
    /* Declare all local variables.                                           */
    /*========================================================================*/
    Boolean bSuccess = true;
    UInt16  *uiRegAddress;
    UInt16  uiSmplRateSetting;
    EventType event;

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

    /*========================================================================*/
    /* Based on the user selected sample rate, set the Sample Rate Settings   */
    /* value to be downloaded to the Sample Rate Register.                    */
    /*========================================================================*/
    switch (NewSampleRate)
    {
        case Timebase50nsec:            /* 20MHz/50ns sample rate.            */
            uiSmplRateSetting = 0x4000;
            break;
        case Timebase100nsec:           /* 10MHz/100ns sample rate.           */
            uiSmplRateSetting = 0x4000;
            break;
        case Timebase200nsec:           /* 5MHz/200ns sample rate.            */
            uiSmplRateSetting = 0x4000;
            break;
        case Timebase500nsec:           /* 2MHz/500ns sample rate.            */
            uiSmplRateSetting = 0x4000;
            break;
        case Timebase1usec:             /* 1MHz/1us sample rate.              */
            uiSmplRateSetting = 0x4000;
            break;
        case Timebase2usec:             /* 500KHz/2us sample rate.            */
            uiSmplRateSetting = 0x4000;
            break;
        case Timebase5usec:             /* 200KHz/5us sample rate.            */
            uiSmplRateSetting = 0x4000;
            break;
        case Timebase10usec:            /* 100KHz/10us sample rate.           */
            uiSmplRateSetting = 0x4000;
            break;
        case Timebase20usec:            /* 50KHz/20us sample rate.            */
            uiSmplRateSetting = 0x4000;
            break;
        case Timebase50usec:            /* 20KHz/50us sample rate.            */
            uiSmplRateSetting = 0x4000;
            break;
        case Timebase100usec:           /* 10KHz/100us sample rate.           */
            uiSmplRateSetting = 0x4000;
            break;
        case Timebase200usec:           /* 5KHz/200us sample rate.            */
            uiSmplRateSetting = 0x4000;
            break;
        case Timebase500usec:           /* 2KHz/500us sample rate.            */
            uiSmplRateSetting = 0x800A;
            break;
        case Timebase1msec:             /* 1KHz/1ms sample rate.              */
            uiSmplRateSetting = 0x8014;
            break;
        default:
            bSuccess = false;
            return bSuccess;
            break;
    }

    /*========================================================================*/
    /* Write the new sample rate setting value to the actual register.        */
    /*========================================================================*/
    HsCardErrTry
    {
        *uiRegAddress = uiSmplRateSetting;
    }
    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:            sbioWritePreTriggerReg                                  */
/* Description:         This routine receives the number of pre-trigger       */
/*                      samples and converts the value to the number of post- */
/*                      trigger samples and downloads the formatted result to */
/*                      the SpringBoard moudle.                               */
/*                                                                            */
/* Arguments:           iPreTrigSmpls = The number of pre-trigger samples.    */
/* Returns:             bSuccess = Results of operation.                      */
/*                                      true = successful,                    */
/*                                      false = unsuccessful.                 */
/* Globals affected:    None                                                  */
/* Hardware affected:   None                                                  */
/*                                                                            */
/*============================================================================*/
/* Change History:                                                            */
/*                                                                            */
/* ECO#:  ?                                                                   */
/* Change Date:  dd-mmm-yyyy                                                  */
/* Changed By:   ?                                                            */
/* Description of Change:  ?                                                  */
/*                                                                            */
/*============================================================================*/
Boolean sbioWritePreTrigger (Int16 iPreTrigSmpls)
{
    /*========================================================================*/
    /* Declare all local variables.                                           */
    /*========================================================================*/
    Boolean bSuccess = true;
    UInt16  *uiRegAddress;
    Int16   iPostTriggerSetting;
    EventType event;

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

    /*========================================================================*/
    /* Convert the Pre-Trigger Samples to Post-Trigger samples.               */
    /*========================================================================*/
    iPostTriggerSetting = DataBuffSize - iPreTrigSmpls;

    /*========================================================================*/
    /* If the Post-Trigger sample setting is less than zero or is greater     */
    /* than the maximum buffer size, there was an invalid Pre-Trigger sample  */
    /* setting, therefore, return indicating a failure.                       */
    /*========================================================================*/
    if ((iPostTriggerSetting < 0) || (iPostTriggerSetting >= DataBuffSize))
    {
        bSuccess = false;
        return (bSuccess);
    }

    /*========================================================================*/
    /* If the Post-Trigger sample setting is equal to zero, set the value to  */
    /* one since the SpringBoard module requires a minimum of one.            */
    /*========================================================================*/
    else if (iPostTriggerSetting == 0)
        iPostTriggerSetting = 2;

    /*========================================================================*/
    /* Write the new sample rate setting value to the actual register.        */
    /*========================================================================*/
    HsCardErrTry
    {
        *uiRegAddress = (iPostTriggerSetting / 2);

⌨️ 快捷键说明

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