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

📄 hpe1463a.c

📁 CVI教程,用于信号采集系统的多任务开发软件.学习简单,功能实用.
💻 C
📖 第 1 页 / 共 5 页
字号:
/***************************************************************************** *----------------- Callback Declarations (Non-Exported) --------------------* *****************************************************************************/    /*- Attribute callbacks -------------------------------------------------*/static ViStatus _VI_FUNC hpe1463aAttrDriverRevision_ReadCallback (ViSession vi,                                                                  ViSession io,                                                                   ViConstString channelName,                                                                  ViAttr attributeId,                                                                   const ViConstString cacheValue);static ViStatus _VI_FUNC hpe1463aAttrVXIManfID_ReadCallback (ViSession vi,                                                             ViSession io,                                                              ViConstString channelName,                                                              ViAttr attributeId,                                                              ViInt32* value);static ViStatus _VI_FUNC hpe1463aAttrVXIModelCode_ReadCallback (ViSession vi,                                                                ViSession io,                                                                 ViConstString channelName,                                                                 ViAttr attributeId,                                                                 ViInt32* value);static ViStatus _VI_FUNC hpe1463aAttrIsDebounced_ReadCallback (ViSession vi,                                                                   ViSession io,                                                                   ViConstString channelName,                                                                   ViAttr attributeId,                                                                   ViBoolean *value);static ViStatus _VI_FUNC hpe1463aAttrOriginalSourceChannelIndex_ReadCallback (ViSession vi,                                                                              ViSession io,                                                                              ViConstString channelName,                                                                              ViAttr attributeId,                                                                              ViInt32 *value);static ViStatus _VI_FUNC hpe1463aAttrSwitchState_WriteCallback (ViSession vi,                                                                ViSession io,                                                                ViConstString channelName,                                                                ViAttr attributeId,                                                                ViInt32 value);/***************************************************************************** *------------ User-Callable Functions (Exportable Functions) ---------------* *****************************************************************************//***************************************************************************** * Function: hpe1463a_init    * Purpose:  VXIplug&play required function.  Calls the    *           hpe1463a_InitWithOptions function.    *****************************************************************************/ViStatus _VI_FUNC hpe1463a_init (ViRsrc resourceName, ViBoolean IDQuery,                                 ViBoolean resetDevice, ViSession *newVi){       ViStatus    error = VI_SUCCESS;    if (newVi == VI_NULL)        {        Ivi_SetErrorInfo (VI_NULL, VI_FALSE, IVI_ERROR_INVALID_PARAMETER,                           VI_ERROR_PARAMETER4, "Null address for Instrument Handle");        checkErr( IVI_ERROR_INVALID_PARAMETER);        }    checkErr( hpe1463a_InitWithOptions (resourceName, IDQuery, resetDevice,                                         "", newVi));Error:      return error;}/***************************************************************************** * Function: hpe1463a_InitWithOptions                                        * Purpose:  This function creates a new IVI session and calls the  *           IviInit function.                                      *****************************************************************************/ViStatus _VI_FUNC hpe1463a_InitWithOptions (ViRsrc resourceName, ViBoolean IDQuery,                                            ViBoolean resetDevice, ViString optionString,                                             ViSession *newVi){       ViStatus    error = VI_SUCCESS;    ViSession   vi = VI_NULL;        if (newVi == VI_NULL)        {        Ivi_SetErrorInfo (VI_NULL, VI_FALSE, IVI_ERROR_INVALID_PARAMETER,                           VI_ERROR_PARAMETER5, "Null address for Instrument Handle");        checkErr( IVI_ERROR_INVALID_PARAMETER);        }    *newVi = VI_NULL;            /* create a new interchangeable driver */    checkErr( Ivi_SpecificDriverNew ("hpe1463a", optionString, &vi));              /* init the driver */    checkErr( hpe1463a_IviInit (resourceName, IDQuery, resetDevice, vi));     *newVi = vi;    Error:    if (error < VI_SUCCESS)         Ivi_Dispose (vi);            return error;}/***************************************************************************** * Function: hpe1463a_IviInit                                                        * Purpose:  This function is called by hpe1463a_InitWithOptions   *           or by an IVI class driver.  This function initializes the I/O  *           interface, optionally resets the device, optionally performs an *           ID query, and sends a default setup to the instrument.                 *****************************************************************************/ViStatus _VI_FUNC hpe1463a_IviInit (ViRsrc resourceName, ViBoolean IDQuery,                                    ViBoolean reset, ViSession vi){    ViStatus    error = VI_SUCCESS;    ViSession   io = VI_NULL;        checkErr( Ivi_BuildChannelTable (vi, CHANNEL_LIST, VI_FALSE, VI_NULL));         /* Add attributes */    checkErr( hpe1463a_InitAttributes (vi));    if (!Ivi_Simulating(vi))        {        ViSession   rmSession = VI_NULL;        /* Open instrument session */        checkErr( Ivi_GetAttributeViSession (vi, VI_NULL, IVI_ATTR_VISA_RM_SESSION, 0,                                             &rmSession));         viCheckErr( viOpen (rmSession, resourceName, VI_NULL, VI_NULL, &io));        /* io session owned by driver now */        checkErr( Ivi_SetAttributeViSession (vi, VI_NULL, IVI_ATTR_IO_SESSION, 0, io));          }            /*- Reset instrument ----------------------------------------------------*/    if (reset)         checkErr( hpe1463a_reset (vi));    else  /*- Send Default Instrument Setup ---------------------------------*/        checkErr( hpe1463a_DefaultInstrSetup (vi));        /*- Identification Query ------------------------------------------------*/    if (IDQuery)        {            ViInt32 manfID = 0;            ViInt32 modelCode = 0;                #define HPE1463A_VXI_MANF_ID       0xFFF            #define HPE1463A_VXI_MODEL_CODE    0x121                checkErr( Ivi_GetAttributeViInt32 (vi, VI_NULL,                                               HPE1463A_ATTR_VXI_MANF_ID,                                               0, &manfID));                checkErr( Ivi_GetAttributeViInt32 (vi, VI_NULL,                                               HPE1463A_ATTR_VXI_MODEL_CODE,                                               0, &modelCode));                if ((manfID != HPE1463A_VXI_MANF_ID) || (modelCode != HPE1463A_VXI_MODEL_CODE))                viCheckErr( VI_ERROR_FAIL_ID_QUERY);        }Error:    if (error < VI_SUCCESS)        {        if (!Ivi_Simulating (vi) && io)            viClose (io);        }    return error;}/***************************************************************************** * Function: hpe1463a_close                                                            * Purpose:  This function closes the instrument.                             * *           Note:  This function must unlock the session before calling *           Ivi_Dispose. *****************************************************************************/ViStatus _VI_FUNC hpe1463a_close (ViSession vi){    ViStatus    error = VI_SUCCESS;        checkErr( Ivi_LockSession (vi, VI_NULL));        checkErr( hpe1463a_IviClose (vi));Error:        Ivi_UnlockSession (vi, VI_NULL);    Ivi_Dispose (vi);      return error;}/***************************************************************************** * Function: hpe1463a_IviClose                                                         * Purpose:  This function performs all of the drivers clean-up operations    *           except for closing the IVI session.  This function is called by  *           hpe1463a_close or by an IVI class driver.  * *           Note:  This function must close the I/O session and set  *           IVI_ATTR_IO_SESSION to 0. *****************************************************************************/ViStatus _VI_FUNC hpe1463a_IviClose (ViSession vi){    ViStatus error = VI_SUCCESS;    ViSession io = VI_NULL;        /* Do not lock here.  The caller manages the lock. */    checkErr( Ivi_GetAttributeViSession (vi, VI_NULL, IVI_ATTR_IO_SESSION, 0, &io));Error:    Ivi_SetAttributeViSession (vi, VI_NULL, IVI_ATTR_IO_SESSION, 0, VI_NULL);    if(io)                                                              {        viClose (io);        }    return error;   }/***************************************************************************** * Function: hpe1463a_reset                                                          * Purpose:  This function resets the instrument.                           *****************************************************************************/ViStatus _VI_FUNC hpe1463a_reset (ViSession vi){    ViStatus    error = VI_SUCCESS;    checkErr( Ivi_LockSession (vi, VI_NULL));    if (!Ivi_Simulating(vi))                /* call only when locked */                 {                                                                                      ViSession   io = Ivi_IOSession(vi); /* call only when locked */                 ViUInt16    status;                                                                                               checkErr( Ivi_SetNeedToCheckStatus (vi, VI_TRUE));        viCheckErr( viIn16 (io, VI_A16_SPACE, VXI_STATUS_CONTROL_REGISTER,                             &status));        status |= HPE1463A_VAL_SOFT_RESET_BIT;        viCheckErr( viOut16 (io, VI_A16_SPACE, VXI_STATUS_CONTROL_REGISTER,                              status));        status &= ~HPE1463A_VAL_SOFT_RESET_BIT;        viCheckErr( viOut16 (io, VI_A16_SPACE, VXI_STATUS_CONTROL_REGISTER,                              status));

⌨️ 快捷键说明

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