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

📄 usbtargdevicecontrol.c

📁 USB source code of Vxworks 5.6. It has device and the host stack.
💻 C
📖 第 1 页 / 共 2 页
字号:
/* usbTargDeviceControl.c - modules for handling pipe specific requests *//* Copyright 2004 Wind River Systems, Inc. *//*Modification history--------------------01e,17sep04,ami  WindView Instrumentation Changes01d,29jul04,pdg  Fixed coverity bugs01c,19jul04,ami Coding Convnetion Changes01b,21jun04,ami Changes for Endianess  to Print a File01a,01apr04,ami First*//*DESCRIPTIONThis module provides interfaces for handling device control and status requests.INCLUDE FILES: usb/usbPlatform.h, string.h, usb/ossLib.h, usb/usb.h,                usb/usbHandleLib.h, usb/target/HalLib.h,               usb/target/usbHalCommon.h, usb/target/usbTargLib.h,               usb/target/usbTargUtil.h, usb/target/usbPeriphInstr.h*//* includes */#include "usb/usbPlatform.h"           #include "string.h"                    #include "usb/ossLib.h"                #include "usb/usb.h"               #include "usb/usbHandleLib.h"      #include "usb/target/usbHalLib.h"   #include "usb/target/usbHalCommon.h"   #include "usb/target/usbTargLib.h"     #include "usb/target/usbTargUtil.h"#include "usb/target/usbPeriphInstr.h"     /* forward declarations */LOCAL STATUS usbTargHandleResetEvent (pTARG_TCD pTargTcd, UINT32 speed);LOCAL STATUS usbTargHandleDisconnectEvent (pTARG_TCD pTargTcd);LOCAL STATUS controlEndptRelease (pTARG_TCD pTargTcd);/********************************************************************************* usbTargCurrentFrameGet - retrieves the current USB frame number** This function allows a caller to retrieve the current USB frame* number for the bus to which <targChannel> is connected.  Upon return, * the current frame number is stored in <pFrameNo>.** RETURNS: OK, or ERROR if unable to retrieve USB frame number** ERRNO:* \is* \i S_usbTargLib_TCD_FAULT* Fault occured in TCD * \ie*/STATUS usbTargCurrentFrameGet    (    USB_TARG_CHANNEL	targChannel,	/* target channel */    pUINT16		pFrameNo	/* current frame number */    )    {    pTARG_TCD	pTcd = NULL;		/* TARG_TCD */    STATUS	status = ERROR;    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEVICE_CONTROL,    "usbTargCurrentFrameGet entered ...", USB_TARG_WV_FILTER);       /* Validate parameters */    if ((status = validateTarg (targChannel, &pTcd)) == OK)        {        /* Get current frame number from TCD */        if (usbHalTcdCurrentFrameGet (&pTcd->tcdNexus, pFrameNo) != OK)            status = ossStatus (S_usbTargLib_TCD_FAULT);        }    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEVICE_CONTROL,    "usbTargCurrentFrameGet exiting ...", USB_TARG_WV_FILTER);       return status;    }/********************************************************************************* usbTargSignalResume - drives RESUME signalling on USB** If a USB is in the SUSPENDed state, it is possible for a device (target)* to request the bus to wake up (called remote wakeup).  This function * allows the caller to drive USB resume signalling.  The function will * return after resume signalling has completed.** RETURNS: OK, or ERROR if unable to drive RESUME signalling** ERRNO:* \is* \i S_usbTargLib_TCD_FAULT* Fault occured in TCD * \ie*/STATUS usbTargSignalResume    (    USB_TARG_CHANNEL	targChannel	/* target channel */    )    {    pTARG_TCD	pTcd = NULL;		/* TARG_TCD */    STATUS	status = ERROR;    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEVICE_CONTROL,    "usbTargSignalResume entered ...", USB_TARG_WV_FILTER);       /* Validate parameters */    if ((status = validateTarg (targChannel, &pTcd)) == OK)        {        /* Have TCD drive resume signalling */        if (usbHalTcdSignalResume (&pTcd->tcdNexus) != OK)            status = ossStatus (S_usbTargLib_TCD_FAULT);        }    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEVICE_CONTROL,    "usbTargSignalResume exiting ...", USB_TARG_WV_FILTER);       return status;    }/********************************************************************************* usbTargDeviceFeatureSet - sets or enable a specific feature** This function is used to set or enable a device specific feature.** RETURNS: OK or ERROR if not able to set the feature.** ERRNO:* \is* \i S_usbTargLib_TCD_FAULT* Fault occured in TCD * \ie*/STATUS usbTargDeviceFeatureSet    (    USB_TARG_CHANNEL	targChannel,		/* target channel */    UINT16		ufeatureSelector,	/* feature to be set */    UINT8		uTestSelector		/* test selector value */    )    {    pTARG_TCD	pTcd = NULL;		/* TARG_TCD */    STATUS	status = ERROR;    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEVICE_CONTROL,    "usbTargDeviceFeatureSet entered ...", USB_TARG_WV_FILTER);       /* Validate parameters */    if ((status = validateTarg (targChannel, &pTcd)) == OK)        {        /* Call usbHalTcdDeviceFeatureSet  */        if(usbHalTcdDeviceFeatureSet(&pTcd->tcdNexus, ufeatureSelector,                                     uTestSelector) != OK)            status = ossStatus (S_usbTargLib_TCD_FAULT);        }    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEVICE_CONTROL,    "usbTargDeviceFeatureSet exiting ...", USB_TARG_WV_FILTER);       return status;    }/********************************************************************************* usbTargDeviceFeatureClear - clears a specific feature** This function is used to clear a device specific feature.** RETURNS: OK or ERROR if not able to clear the feature.** ERRNO:* \is* \i S_usbTargLib_TCD_FAULT* Fault occured in TCD.* \ie*/STATUS usbTargDeviceFeatureClear    (    USB_TARG_CHANNEL	targChannel,		/* target channel */    UINT16		ufeatureSelector	/* feature to be cleared */    )    {    pTARG_TCD		pTcd = NULL;		/* TARG_TCD */    STATUS status = ERROR;    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEVICE_CONTROL,    "usbTargDeviceFeatureClear entered ...", USB_TARG_WV_FILTER);       /* Validate parameters */    if ((status = validateTarg (targChannel, &pTcd)) == OK)        {        /* Call usbHalTcdDeviceFeatureClear  */        if (usbHalTcdDeviceFeatureClear (&pTcd->tcdNexus,ufeatureSelector)!= OK)            status = ossStatus (S_usbTargLib_TCD_FAULT);        }    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEVICE_CONTROL,    "usbTargDeviceFeatureClear exiting ...", USB_TARG_WV_FILTER);       return status;    }/********************************************************************************* usbTargMgmtCallback - invoked when HAL detects a management event** This function is invoked by the HAL when the HAL detects a "management"* event on a target channel.** RETURNS: OK or ERROR if there is an error in handling the management event.** ERRNO:* \is* \i S_usbTargLib_TCD_FAULT* Fault occured in TCD * \ie*/STATUS usbTargMgmtCallback    (    pVOID	pTargTcd,		/* pointer to TARG_TCD structure */    UINT16	mngmtCode,		/* management event code */    pVOID	pContext		/* parameter of management event */    )    {    STATUS	status = OK;    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEVICE_CONTROL,    "usbTargMgmtCallback entered ...", USB_TARG_WV_FILTER);       switch (mngmtCode)        {        /* bus reset event has occured  */        case TCD_MNGMT_BUS_RESET :             status = usbTargHandleResetEvent (pTargTcd , (UINT32) pContext);             break;            /* suspend event has occured */        case  TCD_MNGMT_SUSPEND :              status = mngmtFunc (pTargTcd , TARG_MNGMT_SUSPEND, NULL);              break;        /* resume event has occured */        case TCD_MNGMT_RESUME :             status = mngmtFunc (pTargTcd , TARG_MNGMT_RESUME, NULL );             break;        /* Disconnect event has occured */        case TCD_MNGMT_DISCONNECT :             status = usbTargHandleDisconnectEvent (pTargTcd);             break;                default : /* Management codes donot match */                  status = ERROR;        }    if ( status == ERROR)        status = ossStatus (S_usbTargLib_GENERAL_FAULT);    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEVICE_CONTROL,    "usbTargMgmtCallback exiting ...", USB_TARG_WV_FILTER);       return status;    }/********************************************************************************* usbTargHandleResetEvent - handles the reset event** This function will be called whenever a reset event has occured. It* destroys and re-creates the default control pipe and  resets the setup* Erp with default values.** RETURNS: OK or ERROR if any.** ERRNO:

⌨️ 快捷键说明

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