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

📄 usbhubcommon.h

📁 风河的vxworks-6.3 FOR amcc440epx BSP!
💻 H
📖 第 1 页 / 共 3 页
字号:
 * Description : This will submit a blocking call to clear a port feature.
 * Parameters  : pHub                  IN   The Hub pointer.
 *               uPortIndex            IN   Port index +1 = port number
 *               Feature               IN   The feature on the hub to be set
 * Return Type : None
 ******************************************************************************/

#define USB_HUB_CLEAR_PORT_FEATURE(pHub,uPortIndex,Feature)                        \
        usbHubSubmitControlRequest(pHub,                                         \
                                 USB_PORT_TARGET_SET,                              \
                                 USB_CLEAR_FEATURE,                                \
                                 Feature,                                      \
                                 uPortIndex+1)                                 \


/*******************************************************************************
 * Macro Name  : HUB_GET_HUB_STATUS
 * Description : This will submit a blocking call to get a hub status.
 * Parameters  : pHub                  IN      The Hub pointer.
 *               pBuffer               IN OUT  The buffer to which the status is
 *                                             copied
 *               pBufferLength         IN OUT  The Length of the Buffer
 * Return Type : None
 ******************************************************************************/

#define USB_HUB_GET_STATUS(pHub,pBuffer,pBufferLength)                         \
        usbHubGetStatus(pHub, 0, USB_HUB_TARGET_GET,pBuffer,pBufferLength)           \


/*******************************************************************************
 * Macro Name  : HUB_GET_PORT_STATUS
 * Description : This will submit a blocking call to get a port status.
 * Parameters  : pHub                  IN      The Hub pointer.
 *               uPortIndex            IN      Port index +1 = port number
 *               pBuffer               IN OUT  The buffer to which the status is
 *                                             copied
 *               pBufferLength         IN OUT  The Length of the Buffer
 * Return Type : None
 ******************************************************************************/

#define USB_HUB_GET_PORT_STATUS(pHub,uPortIndex,pBuffer,pBufferLength)             \
        usbHubGetStatus(pHub, uPortIndex+1,USB_PORT_TARGET_GET,pBuffer,pBufferLength)\


/*******************************************************************************
 * Macro Name  : HUB_TIME_DIFF
 * Description : This finds the difference of time between the current
 *               frame number and a different frame number.
 * Parameters  : uCurrentFrame         IN   This is the current frame number.
 *               uLastFrame            IN   This is the last frame number.
 * Return Type : UINT16
 ******************************************************************************/

#define USB_HUB_TIME_DIFF(uCurrentFrame,uLastFrame)                                \
    ( ((uLastFrame)>(uCurrentFrame))?                                          \
    (USB_HUB_MAXIMUM_FRAME_NUMBER - (uLastFrame)+uCurrentFrame ):                  \
    (uCurrentFrame-(uLastFrame)) )                                             \


/*******************************************************************************
 * Macro Name  : HUB_BYTE_GRANULARITY
 * Description : This converts the parameter into nearest largest byte count
 *               (byte granularity form).
 * Parameters  : uNumberOfBits         IN   This is the value that has to be
 *                                          converted to byte granularity form.
 * Return Type : UINT8
 ******************************************************************************/

#define USB_HUB_BYTE_GRANULARITY(uNumberOfBits)		                               \
    ( (((UINT8)(uNumberOfBits)%8)>0)?                                          \
     (((uNumberOfBits)/8)+1): ((uNumberOfBits)/8) )                            \


/*******************************************************************************
 * Macro Name  : MARK_FOR_DELETE_PORT
 * Description : This marks the port for deletion. This takes care of reseting
 *               the global bus state if the device connected to the port is in
 *               default state
 * Parameters  : pHub            IN   pointer to the Hub
 *               pPort           IN   pointer to the port on the hub
 * Return Type : None.
 ******************************************************************************/

#define USB_MARK_FOR_DELETE_PORT(pHub,pPort)                                       \
        {                                                                      \
            /* Check if we have the bus information */                         \
            if ( (NULL != (pHub)->pBus) &                                      \
               (USB_HUB_PORT_CONFIGURED > (pPort)->StateOfPort )  &                \
               (USB_HUB_RESET_PENDING < (pPort)->StateOfPort ) )                   \
            {                                                                  \
                /* Set the bus state as no device is being configured */       \
                (pHub)->pBus->bDeviceBeingConfigured = FALSE;                  \
                if (NULL != pHub->pBus->pResetURB)                             \
                {                                                              \
                    /* Cancel Reset URB -We force this before we delete hub */  \
                    if (USB_HUB_RESET_COMPLETED > (pPort)->StateOfPort)           \
		            {                                                          \
                        if (USBHST_SUCCESS == usbHstURBCancel (pHub->pBus->pResetURB))  \
                        {                                                             \
                            /* Call the reset Callback */                               \
                            usbHubResetCallback(pHub->pBus->pResetURB);                  \
                        }                                                         \
                    }                                                             \
                }/* End of if (NULL !=.. */                                    \
                                                                               \
            } /* End of if (NULL !=.. */                                       \
                                                                               \
            (pPort)->StateOfPort = USB_MARKED_FOR_DELETION;                        \
                                                                               \
        } /* End of if ( (HUB_PORT_CONFIGURED > pPort->StateOfPort .. */       

/*******************************************************************************
 * Macro Name  : VALIDATE_DESCRIPTOR_SEQUENCE
 * Description : This validates the config descriptor
 *               Only valid descriptors Sequence is
 *               1) 0x24210 (Endpoint,AlternateInterface,
 *                           Endpoint,DefaultInterface,,Config)
 *               2) 0x00210 (Endpoint,DefaultInterface,Config)
 * Parameters  : uDescriptorSequence    IN   Value showing the descriptor
 *                                           sequence
 * Return Type : BOOLEAN
 ******************************************************************************/
#define USB_VALIDATE_DESCRIPTOR_SEQUENCE(uDescriptorSequence)                       \
    (( 0 == ((uDescriptorSequence == 0x24210) ||                                \
        (uDescriptorSequence == 0x00210 ) ) ) ? FALSE:TRUE)                     \

/* This Data Structure stores information about the hub  descriptor. */
typedef struct usb_hub_descriptor_info 
{
    UINT8   bNbrPorts;           /* The Number of Ports                       */
    UINT16  wHubCharacteristics; /* Characteristics of the hub                */
    UINT8   bPwrOn2PwrGood;      /* Time to wait before the Power is stable   */
    UINT8   bHubContrCurrent;    /* Power Requiement by the hub electronics   */
} OS_STRUCT_PACKED USB_HUB_DESCRIPTOR_INFO, * pUSB_HUB_DESCRIPTOR_INFO;

/*
 * This Data Structure stores information about the hub Status Change
 * information.
 */

/* XXX this is also defined in usb.h... This is an error! XXX SPR this. */
#if 0
typedef struct _usb_hub_status 
{
    UINT16  wHubStatus;          /* Contains the status of the hub            */
    UINT16  wHubChange;          /* Contains the change status of the hub     */
} OS_STRUCT_PACKED USB_HUB_STATUS,* pUSB_HUB_STATUS;
#endif
/*
 * This Data Structure stores information about the Port status change
 * information.
 */
typedef struct usb_hub_port_status 
{
    UINT16  wPortStatus;                  /* The port status information      */
    UINT16  wPortChange;                  /* The port status change.          */
} OS_STRUCT_PACKED USB_HUB_PORT_STATUS, * pUSB_HUB_PORT_STATUS;

/*
 * The following have been pre defined here as a method to handle cyclic
 * dependency
 */
typedef struct usb_hub_info       * pUSB_HUB_INFO;
typedef struct usb_hub_bus_info   * pUSB_HUB_BUS_INFO;
typedef struct usb_hub_port_info  * pUSB_HUB_PORT_INFO;

/*
 * This data structure holds the information about a port of a hub as to what
 * device is connected to that port. The port status is also stored in this
 * structure.
 */
typedef struct usb_hub_port_info 
{
    UINT32               uDeviceHandle;   /* Identification of the hub device */
    BOOLEAN              bDebouncePeriod; /* States if the port is in debounce*/
    BOOLEAN              bOldConnectStatus; /* previous connect status        */
    UINT16               uConnectFrame;   /* The frame num when last connected*/
    UINT8                uConnectRetry;   /* number of times connect retried  */
    pUSB_HUB_INFO            pHub;            /* pointer to the hub if this is hub*/
    USB_HUB_STATES           StateOfPort;     /* State of this port               */
} USB_HUB_PORT_INFO;

/*
 * This data structure holds the information about the BUS that is present and
 * this forms the starting point for the entire topology of the bus.
 */
typedef struct usb_hub_bus_info 
{
    UINT8         uBusHandle;             /* Identification of a Bus          */
    OS_THREAD_ID  BusManagerThreadID;     /* Thread ID of the Bus manager     */
    UINT8         uNumberOfHubEvents;     /* Number of Hub events             */
    BOOLEAN       bDeviceBeingConfigured; /* Is any device being configured   */
    UINT8         uNumberOfConfigRetries; /* Number of configuration retries  */
    UINT32        uDeviceHandle;          /* The root hub device handle       */
    UINT8         uBusSpeed;              /* Speed of the bus                 */ 
    pUSB_HUB_INFO     pRootHubInfo;           /* The pointer to root hub structure*/
    pUSBHST_URB   pResetURB;               /* pointer to the reset URB */
    struct usb_hub_bus_info *pNextBus;       /* The pointer to the next bus      */
} USB_HUB_BUS_INFO;

/*
 * This data structure holds the information about a hub and provides the
 * linking info about the devices connected to this hub.
 */
    /*
     * NOTE1: The status change bit map obtained in response to the status change
     * interrupt IN request.
     */
    /*
     * NOTE2: The pointer to the URB structure that is used for the polling of the
     * interrupt endpoint for status change bit map
     */

typedef struct usb_hub_info
{
    UINT32               uDeviceHandle;  /* Identification of the hub device  */
    UINT8        *       pStatus;        /* NOTE1:                            */
    USB_HUB_BUS_INFO   *     pBus;           /* Pointer to the bus structure      */
    UINT8                uPowerPerPort;  /* power that can be supplied to port*/
    /* The Endpoint Address where the Interrupt Pipe resides.                 */
    UINT8                uInterruptEndpointNumber;
    USB_HUB_DESCRIPTOR_INFO  HubDescriptor;  /* fields of the hub descriptor      */
    USBHST_URB           StatusChangeURB;/* NOTE2:                            */
    BOOLEAN              bURBSubmitted;  /* Denotes if the URB Was submitted  */
    UINT8                uCurrentTier;   /* USB Tier of this hub              */

    UINT8                uHubTTInfo;     /* describing the TT organization    */

    USB_HUB_STATES           StateOfHub;     /* State of this Hub              */
    USB_HUB_PORT_INFO*       pPortList[1];   /* List of pointers to ports   */
} USB_HUB_INFO;

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* End of #ifndef __HUB_COMMON_H__ */

/**************************** End of file Hub_Common.h ************************/

⌨️ 快捷键说明

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