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

📄 usbtargdefaultpipe.c

📁 USB source code of Vxworks 5.6. It has device and the host stack.
💻 C
📖 第 1 页 / 共 4 页
字号:
    if ((*pTcd->pCallbacks->featureClear)	(pTcd->callbackParam, pTcd->targChannel,pSetup->requestType,         feature,index)!= OK)        {        cntlEndpointStall ( pTcd );        return ERROR;        }    /* Initialize the ERP for status phase */    OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK );    pTcd->controlErpPending = TRUE;    OSS_MUTEX_RELEASE (pTcd->tcdMutex);    initStatusErp (pTcd);    /* Submit Tcd */    if ((status = submitCntlErp ( pTcd )) != OK)        {        OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK );        pTcd->controlErpPending = FALSE;        OSS_MUTEX_RELEASE (pTcd->tcdMutex);        }    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE,    "usbTargFeatureClear exiting ...", USB_TARG_WV_FILTER);       return status;    }/********************************************************************************* usbTargFeatureSet - processes a SET_FEATURE request** This function is called when a SET_FEATURE request is received from the* host.** RETURNS: OK if setup packet valid, else ERROR if invalid** ERRNO:*   None** \NOMANUAL*/LOCAL STATUS usbTargFeatureSet    (    pTARG_TCD	pTcd			/* Pointer to the TCD */    )    {    pUSB_SETUP	pSetup = (pUSB_SETUP) pTcd->setupBfr;	/* USB_SETUP packet */	    STATUS	status = OK;    UINT16	feature = FROM_LITTLEW (pSetup->value); /*feature to set*/    UINT16	index = FROM_LITTLEW (pSetup->index);	/* index */		    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE,    "usbTargFeatureSet entered ...", USB_TARG_WV_FILTER);       /*      * If the callback is not registered by the target application,     * return an ERROR     */    if (pTcd->pCallbacks->featureSet == NULL)	    {        cntlEndpointStall ( pTcd );        return ERROR;        }    if ((*pTcd->pCallbacks->featureSet)	(pTcd->callbackParam, pTcd->targChannel,pSetup->requestType,         feature,index)!= OK)        {        cntlEndpointStall ( pTcd );        return ERROR;        }    OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK );    pTcd->controlErpPending = TRUE;    OSS_MUTEX_RELEASE (pTcd->tcdMutex);    initStatusErp (pTcd);    /* Submit Tcd */    if ((status = submitCntlErp ( pTcd )) != OK)        {        OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK );        pTcd->controlErpPending = FALSE;        OSS_MUTEX_RELEASE (pTcd->tcdMutex);        }    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE,    "usbTargFeatureSet exiting ...", USB_TARG_WV_FILTER);       return status;    }/********************************************************************************* usbTargConfigurationGet - processes a GET_CONFIGURATION request** This function is called when a GET_CONFIGURATION request comes from the* host. It get the current configuration and reports it back to host.** RETURNS: OK if setup packet valid, else ERROR if invalid** ERRNO:*   None** \NOMANUAL*/LOCAL STATUS usbTargConfigurationGet    (    pTARG_TCD	pTcd		/* Pointer to TCD */    )    {    STATUS	status = OK;    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE,    "usbTargConfigurationGet entered ...", USB_TARG_WV_FILTER);       /*     * If the callback is not registered by the target application,     * return an ERROR     */    if (pTcd->pCallbacks->configurationGet == NULL)        {        cntlEndpointStall ( pTcd );        return ERROR;        }    /* Get the interface setting from the target application. */    if ((*pTcd->pCallbacks->configurationGet)	(pTcd->callbackParam, pTcd->targChannel,	(pUINT8) pTcd->dataBfr) != OK)	    {        cntlEndpointStall ( pTcd );        return ERROR;        }    OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK );    pTcd->controlErpPending = TRUE;    OSS_MUTEX_RELEASE (pTcd->tcdMutex);    /* Initialize the ERP for data phase */    initDataErpForResponse ( pTcd , 1 , pTcd->dataBfr );    /* Submit Tcd */    status = submitCntlErp ( pTcd );    if ( status != OK )        {        OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK );        pTcd->controlErpPending = FALSE;        OSS_MUTEX_RELEASE (pTcd->tcdMutex);        }    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE,    "usbTargConfigurationGet exiting ...", USB_TARG_WV_FILTER);       return status;    }/********************************************************************************* usbTargConfigurationSet - processes a SET_CONFIGURATION request** This function is called when a SET_CONFIGURATION request is received* from the host. It set the current configuration with the configuration* send by host.** RETURNS: OK if setup packet valid, else ERROR if invalid** ERRNO:*   None** \NOMANUAL*/LOCAL STATUS usbTargConfigurationSet    (    pTARG_TCD	pTcd			/* Pointer to the TCD */    )    {    STATUS	status = OK;    pUSB_SETUP	pSetup = (pUSB_SETUP) pTcd->setupBfr;/* setup buffer packet */    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE,    "usbTargConfigurationSet entered ...", USB_TARG_WV_FILTER);       /*     * If the callback is not registered by the target application,     * return an ERROR     */    if (pTcd->pCallbacks->configurationSet == NULL)        {        /* Stall the control endpoints */        cntlEndpointStall ( pTcd );        return ERROR;        }    if ((*pTcd->pCallbacks->configurationSet)	(pTcd->callbackParam, pTcd->targChannel, FROM_LITTLEW(pSetup->value))        != OK)        {        /* Stall the control endpoints */        cntlEndpointStall ( pTcd );        return ERROR;        }        /* Take Mutex */    OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK );    pTcd->controlErpPending = TRUE;    /* Release Mutex */    OSS_MUTEX_RELEASE (pTcd->tcdMutex);    /* Request terminates with status phase. */    initStatusErp (pTcd);    /* Submit Tcd */    status = submitCntlErp ( pTcd );    if ( status != OK )        {        /* Take Mutex */        OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK );        pTcd->controlErpPending = FALSE;        /* Release Mutex */        OSS_MUTEX_RELEASE (pTcd->tcdMutex);        }    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE,    "usbTargConfigurationSet exiting ...", USB_TARG_WV_FILTER);       return status;    }/********************************************************************************* usbTargDescriptorSet - processes a SET_DESCRIPTOR request** This function set the descriptor value send from the host.** RETURNS: OK if setup packet valid, else ERROR if invalid** ERRNO:*   None** \NOMANUAL*/LOCAL STATUS usbTargDescriptorSet    (    pTARG_TCD	pTcd		/* Pointer to TCD */    )    {    STATUS	status = OK;    pUSB_SETUP	pSetup = (pUSB_SETUP) pTcd->setupBfr;	/* USB_SETUP packet */    UINT8	descriptorType = MSB (FROM_LITTLEW (pSetup->value));							/* descriptor type */    UINT8	descriptorIndex = LSB (FROM_LITTLEW (pSetup->value));							/* descriptor index */    UINT16	languageId = FROM_LITTLEW (pSetup->index); /* lang. id */    UINT16	length = FROM_LITTLEW (pSetup->length);/*length of descriptor*/    UINT16	actLen;				/* actual length */	    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE,    "usbTargDescriptorSet entered ...", USB_TARG_WV_FILTER);       /*     * If the callback is not registered by the target application,     * return an ERROR     */    if (pTcd->pCallbacks->descriptorSet == NULL)        {        cntlEndpointStall ( pTcd );        return ERROR;        }    /* Let the target application process the SET_DESCRIPTOR request. */    if ((*pTcd->pCallbacks->descriptorSet)	(pTcd->callbackParam, pTcd->targChannel,	pSetup->requestType, descriptorType, descriptorIndex,	languageId, length, pTcd->dataBfr, &actLen) != OK )        {        cntlEndpointStall ( pTcd );        return ERROR;        }    /* Take Mutex */    OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK );    pTcd->controlErpPending = TRUE;        /* Release Mustex */    OSS_MUTEX_RELEASE (pTcd->tcdMutex);    /* Request terminates with status phase. */    initDataErpToReceive (pTcd, actLen, pTcd->dataBfr);    /* Submit Tcd */    if ((status = submitCntlErp ( pTcd )) != OK)        {        OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK );        pTcd->controlErpPending = FALSE;        OSS_MUTEX_RELEASE (pTcd->tcdMutex);        }    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE,    "usbTargDescriptorSet exiting ...", USB_TARG_WV_FILTER);       return status;    }/********************************************************************************* usbTargDescriptorGet - processes a GET_DESCRIPTOR request** This function is called when a GET_DESCRIPTOR request is received from* the host. It gets the descriptor value from the target application and * sends it to the host.** RETURNS: OK if setup packet valid, else ERROR if invalid** ERRNO:*   None** \NOMANUAL*/LOCAL STATUS usbTargDescriptorGet    (    pTARG_TCD	pTcd		/* Pointer to TCD */    )    {    STATUS	status = OK;    pUSB_SETUP	pSetup = (pUSB_SETUP) pTcd->setupBfr;	/* USB SETUP buffer */    UINT8	descriptorType = MSB (FROM_LITTLEW (pSetup->value));							/* descriptor type */    UINT8	descriptorIndex = LSB (FROM_LITTLEW (pSetup->value));							/* descriptor index */    UINT16	languageId = FROM_LITTLEW (pSetup->index);/* lang. id */	    UINT16	length = FROM_LITTLEW (pSetup->length);	/* descriptor length */    UINT16	actLen;					/* actual length */    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE,    "usbTargDescriptorGet entered ...", USB_TARG_WV_FILTER);       /*      * If the callback is not registered by the target application,     * return an ERROR     */     if (pTcd->pCallbacks->descriptorGet == NULL)        {        cntlEndpointStall ( pTcd );        return ERROR;        }    /* Get the descriptor from the target application. */    if ((*pTcd->pCallbacks->descriptorGet)	(pTcd->callbackParam, pTcd->targChannel,	pSetup->requestType, descriptorType, descriptorIndex,	languageId, min (length, USB_MAX_DESCR_LEN), pTcd->dataBfr,	&actLen) != OK)        {        cntlEndpointStall ( pTcd );        return ERROR;        }    OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK );    pTcd->controlErpPending = TRUE;    OSS_MUTEX_RELEASE (pTcd->tcdMutex);    initDataErpForResponse ( pTcd , actLen , pTcd->dataBfr);    /*     * If the device has less data that what is requested by     * the host, then set the tcdPtr field of the ERP     */    if (actLen < length)        pTcd->defaultControlErp.tcdPtr = (pVOID)pTcd;    /* Submit Tcd */    if ((status = submitCntlErp ( pTcd )) != OK )        {        OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK );        pTcd->controlErpPending = FALSE;        OSS_MUTEX_RELEASE (pTcd->tcdMutex);        }    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE,    "usbTargDescriptorGet exiting ...", USB_TARG_WV_FILTER);       return status;    }/********************************************************************************* usbTargInterfaceGet - processes a GET_INTERFACE request** This function is called when a GET_INTERFACE request is received from* the host. It get the current interface from target application and sends* it to the host.** RETURNS: OK if setup packet valid, else ERROR if invalid** ERRNO:*   None** \NOMANUAL*/LOCAL STATUS usbTargInterfaceGet    (    pTARG_TCD	pTcd		/* Pointer to the TCD */    )    {    STATUS	status = OK;    pUSB_SETUP	pSetup = (pUSB_SETUP) pTcd->setupBfr;	/* USB_SETUP buffer */    UINT16	interface = FROM_LITTLEW (pSetup->index);/* interface index */    /* WindView Instrumentation */    USB_TARG_LOG_EVENT(USB_TARG_DEFAULT_PIPE,    "usbTargInterfaceGet entered ...", USB_TARG_WV_FILTER);       /*      * If the callback is not registered by the target application,     * return an ERROR     */    if (pTcd->pCallbacks->interfaceGet == NULL)        {        /* Stall the control endpoints */        cntlEndpointStall ( pTcd );        return ERROR;        }    /* Get the interface setting from the target application. */    if ((*pTcd->pCallbacks->interfaceGet)	(pTcd->callbackParam, pTcd->targChannel,	interface, (pUINT8) pTcd->dataBfr) != OK)        {        /* Stall the control endpoints */        cntlEndpointStall ( pTcd );        return ERROR;        }    OSS_MUTEX_TAKE ( pTcd->tcdMutex , OSS_BLOCK );    pTcd->controlErpPending = TRUE;    OSS_MUTEX_RELEASE (pTcd->tcdMutex);    /* Transmit the interface setting back to the host */    initDataErpForResponse (pTcd,1,pTcd->dataBfr);    /* Submit Tcd */    if ((status = submitCntlErp ( pTcd )) != OK )        {

⌨️ 快捷键说明

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