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

📄 usbtcdnet2280devicecontrol.c

📁 This the compressed USB driver source code for vxworks5.6. It has device controller driver and other
💻 C
📖 第 1 页 / 共 2 页
字号:
/* usbTcdNET2280DeviceControl.c - defines modules for device control features*/

/* Copyright 2004 Wind River Systems, Inc. */

/*
Modification history
--------------------
01e,22sep04,pdg  Fix for setting the address
01d,21sep04,pdg  OURADDR values changed
01c,17sep04,ami  After Control, Interrupt IN and Bulk OUT Testing
01b,08sep04,ami  Code Review Comments Incorporated
01a,2sep04,gpd Written

*/

/*
DESCRIPTION

This module implements the hardware dependent device control and status
functionalities of the NET2280.

INCLUDE FILES: usb/usbPlatform.h, usb/ossLib.h, usb/usb.h,
               usb/target/usbHalCommon.h, usb/target/usbTcd.h
               drv/usb/target/usbNET2280.h,
               drv/usb/target/usbNET2280Tcd.h, usb/target/usbPeriphInstr.h
*/
/* includes */

#include "usb/usbPlatform.h"	             
#include "usb/ossLib.h" 		     
#include "usb/usb.h"                         
#include "usb/target/usbHalCommon.h"         
#include "usb/target/usbTcd.h"               
#include "drv/usb/target/usbNET2280.h"       
#include "drv/usb/target/usbNET2280Tcd.h"   
#include "drv/usb/target/usbTcdNET2280Debug.h" 
#include "usb/target/usbPeriphInstr.h"

/******************************************************************************
*
* usbTcdNET2280FncAddressSet - implements function code TCD_FNC_ADDRESS_SET
*
* This function is used to set the address register with the specified
* address.
*
* RETURNS: OK or ERROR, if not able to set the specified address.
*
* ERRNO:
* \is
* \i S_usbTcdLib_BAD_PARAM
* Bad Parameter is passed.
* \ie
*
* \NOMANUAL
*/

LOCAL STATUS usbTcdNET2280FncAddressSet
    (
    pTRB_ADDRESS_SET	pTrb		/* TRB to be executed */
    )

    {
    pTRB_HEADER	pHeader = (pTRB_HEADER) pTrb;	/* TRB_HEADER */
    pUSB_TCD_NET2280_TARGET	pTarget = NULL;	/* USB_TCD_NET2280_TARGET */
    UINT32	addrData = 0;			/* temporary variable */
    
    /* WindView Instrumentation */

    USB_TCD_LOG_EVENT(USB_TCD_NET2280_DEVICE_CONTROL,
    "usbTcdNET2280FncAddressSet entered...", USB_TCD_NET2280_WV_FILTER);

    USB_NET2280_DEBUG ("usbTcdNET2280FncAddressSet : Entered...\n",0,0,0,0,0,0);

    /* Validate parameters */

    if ((pHeader == NULL) || (pHeader->trbLength < sizeof (TRB_HEADER)) ||
        (pHeader->handle == NULL))
        {
        	
        /* WindView Instrumentation */

        USB_TCD_LOG_EVENT (USB_TCD_NET2280_DEVICE_CONTROL,
        "usbTcdNET2280FncAddressSet exiting...Bad Parameters received",
        USB_TCD_NET2280_WV_FILTER);

        USB_NET2280_ERROR ("usbTcdNET2280FncAddressSet : Bad Parameters...\n",
        0,0,0,0,0,0);
        return ossStatus (S_usbTcdLib_BAD_PARAM);
        }

    /* Extract the pointer to the USB_TCD_NET2280_TARGET from the handle */

    pTarget =  (pUSB_TCD_NET2280_TARGET) pHeader->handle;

    /* Read the contents of OURADDR register */
    addrData = NET2280_CFG_READ (pTarget,NET2280_OURADDR_REG);

    /* Clear the address field */
    addrData &= ~NET2280_OURADDR_REG_MASK;

    /* Not doing anything here. Everything is from interrupt context */

    /* Write to OURADDR register */
    NET2280_CFG_WRITE(pTarget, NET2280_OURADDR_REG, addrData);


    USB_NET2280_DEBUG ("usbTcdNET2280FncAddressSet : Exiting...\n",0,0,0,0,0,0);

    return OK;
    }

/******************************************************************************
*
* usbTcdNET2280FncSignalResume - implements TCD_FNC_SIGNAL_RESUME.
*
* This function implements the TCD_FNC_SIGNAL_RESUME function code. This
* function is used to signal a resume on the USB.
*
* RETURNS : OK or ERROR, if any.
*
* ERRNO:
* \is
* \i S_usbTcdLib_BAD_PARAM
* Bad Parameter is passed.
* \ie
*
* \NOMANUAL
*/

LOCAL STATUS usbTcdNET2280FncSignalResume
    (
    pTRB_SIGNAL_RESUME	pTrb		/* Trb to be executed */
    )
    {
    pTRB_HEADER	pHeader = (pTRB_HEADER) pTrb;	/* TRB_HEADER */
    pUSB_TCD_NET2280_TARGET	pTarget = NULL;/* USB_TCD_NET2280_TARGET */
    UINT32	statusData = 0;
    
    /* WindView Instrumentation */

    USB_TCD_LOG_EVENT (USB_TCD_NET2280_DEVICE_CONTROL,
    "usbTcdNET2280FncSignalResume entered...", USB_TCD_NET2280_WV_FILTER);

    USB_NET2280_DEBUG ("usbTcdNET2280FncSignalResume : Entered...\n",
    0,0,0,0,0,0);

    /* Validate parameters */

    if ((pHeader == NULL) || (pHeader->trbLength < sizeof (TRB_HEADER)) ||
        (pHeader->handle == NULL))
        {

        /* WindView Instrumentation */

        USB_TCD_LOG_EVENT (USB_TCD_NET2280_DEVICE_CONTROL,
        "usbTcdNET2280FncSignalResume exiting...Bad Parameters received",
        USB_TCD_NET2280_WV_FILTER);

        USB_NET2280_ERROR ("usbTcdNET2280FncSignalResume : Bad Parameters...\n",
        0,0,0,0,0,0);
        return ossStatus (S_usbTcdLib_BAD_PARAM);
        }

    /* Extract the pointer to the USB_TCD_NET2280_TARGET from the handle */

    pTarget =  (pUSB_TCD_NET2280_TARGET) pHeader->handle;

    /* Read the contents of the USBSTAT register */

    statusData = NET2280_CFG_READ(pTarget, 
                                   NET2280_USBSTAT_REG);

    /* 
     * No need to clear the Device Remote Wakeup field as a read returs
     * a zero in this field. So simply OR with the required mask value.
     */
    statusData |= NET2280_USBSTAT_REG_GENDEVREMWKUP;

    /* Write to the Device Remote Wakeup field of USBSTAT register */
    NET2280_CFG_WRITE(pTarget, 
                      NET2280_USBSTAT_REG,
                      statusData);

    USB_NET2280_DEBUG ("usbTcdNET2280FncSignalResume : Exiting...\n",
    0,0,0,0,0,0);
    return OK;
    }

/*******************************************************************************
*
* usbTcdNET2280FncCurrentFrameGet - implements TCD_FNC_CURRENT_FRAME_GET
*
* This utility function is used to implement the function code
* TCD_FNC_CURRENT_FRAME_GET. The function is used to get the current 
* frame (as encoded in the USB SOF Packet).
*
* RETURNS: OK or ERROR if any.
*
* ERRNO:
* \is
* \i S_usbTcdLib_BAD_PARAM
* Bad Parameter is passed.
* \ie
*
* \NOMANUAL
*/

LOCAL STATUS usbTcdNET2280FncCurrentFrameGet
    (
    pTRB_CURRENT_FRAME_GET	pTrb		/* Trb to be executed */
    )
    {
    pTRB_HEADER	pHeader = (pTRB_HEADER) pTrb; /* TRB_HEADER */
    pUSB_TCD_NET2280_TARGET	pTarget = NULL;	/* USB_TCD_NET2280_TARGET */
    UINT32	frameNumberRead0 = 0;		/* Frame number read 1st time */
    UINT32	frameNumberRead1 = 0;		/* Frame number read 2nd time */
    
    /* WindView Instrumentation */

    USB_TCD_LOG_EVENT (USB_TCD_NET2280_DEVICE_CONTROL,
    "usbTcdNET2280FncCurrentFrameGet entered...", USB_TCD_NET2280_WV_FILTER);

    USB_NET2280_DEBUG ("usbTcdNET2280FncCurrentFrameGet : Entered...\n",
    0,0,0,0,0,0);

    /* Validate parameters */

    if ((pHeader == NULL) || (pHeader->trbLength < sizeof (TRB_HEADER)) ||
        (pHeader->handle == NULL))
        {

        /* WindView Instrumentation */

        USB_TCD_LOG_EVENT (USB_TCD_NET2280_DEVICE_CONTROL,
        "usbTcdNET2280FncCurrentFrameGet exiting...Bad Parameters received",
        USB_TCD_NET2280_WV_FILTER);

        USB_NET2280_ERROR ("usbTcdNET2280FncCurrentFrameGet:Bad Parameters...\n",
        0,0,0,0,0,0);
        return ossStatus (S_usbTcdLib_BAD_PARAM);
        }

    /* Extract the pointer to the USB_TCD_NET2280_TARGET from the handle */
    pTarget =  (pUSB_TCD_NET2280_TARGET) pHeader->handle;

    /* Retrieve the frame number information */

    /* 
     * The address of frame number
     * register should be written to IDXADDR register. Then the IDXDATA
     * register should be read to retrieve the frame number 
     */
    NET2280_CFG_WRITE(pTarget, 
                      NET2280_IDXADDR_REG,

⌨️ 快捷键说明

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