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

📄 usbhubcommon.h

📁 风河的vxworks-6.3 FOR amcc440epx BSP!
💻 H
📖 第 1 页 / 共 3 页
字号:

#define USB_HUB_DESC_GET_NUMPORT_OFFSET(pHubDescriptor,uOffset)                    \
{                                                                              \
    UINT8 uNbrOfPorts = HUB_DESC_bNbrPorts(pHubDescriptor);                    \
    /* give the 0th Bit Padding */                                             \
    uNbrOfPorts++;                                                             \
    /* Implement the byte granurality */                                       \
    uOffset = USB_HUB_BYTE_GRANULARITY(uNbrOfPorts);                               \
}                                                                              \


/*******************************************************************************
 * Macro Name  : HUB_DESC_DevRemovableMapStart
 * Description : This parses the hub descriptor and returns the pointer to the
 *               start of the DeviceRemovable bit map
 * Parameters  : pHubDescriptor          IN   pointer to the Hub descriptor.
 * Return Type : PUINT8
 ******************************************************************************/

#define USB_HUB_DESC_DevRemovableMapStart(pHubDescriptor)                          \
    ((UINT8*)(    ( (UINT32) (pHubDescriptor) )+7 )  )                         \


/*******************************************************************************
 * Macro Name  : HUB_DESC_PortPwrCtrlMaskStart
 * Description : This parses the hub descriptor and returns the pointer to the
 *               start of the PortPwrCtrlMask bit map
 * Parameters  : pHubDescriptor          IN   pointer to the Hub descriptor.
 * Return Type : PUINT8
 ******************************************************************************/

#define USB_HUB_DESC_PortPwrCtrlMaskStart(pHubDescriptor,pPortPwrCtrlMask)         \
{                                                                              \
    UINT8 uOffset = 0;                                                         \
    HUB_DESC_GET_NUMPORT_OFFSET (pHubDescriptor,uOffset);                      \
    pPortPwrCtrlMask    =  ((UINT8*)( ( (UINT32) (pHubDescriptor) )            \
                                         +7+uOffset ) );                       \
}                                                                              \


/*******************************************************************************
 * Macro Name  : HUB_DESC_IS_GANG_POWERED
 * Description : This parses the hub descriptor and returns if the device is
 *               Gang powered or not.
 * Parameters  : pHubDescriptor          IN   pointer to the Hub descriptor.
 * Return Type : BOOLEAN
 ******************************************************************************/

#define USB_HUB_DESC_IS_GANG_POWERED(pHubDescriptor)                               \
    (0==(UINT8)(HUB_DESC_wHubCharacteristics(pHubDescriptor)&0x1)?             \
           FALSE:TRUE)                                                         \


/*******************************************************************************
 * Macro Name  : HUB_CONFIG_wTotalLength
 * Description : This parses the config descriptor and returns the total length
 *               of the descriptor
 * Parameters  : pConfigDescriptor        IN   pointer to the config descriptor.
 * Return Type : UINT16
 ******************************************************************************/

#define USB_HUB_CONFIG_wTotalLength(pConfigDescriptor)                             \
    (((pConfigDescriptor)[2]&0xff) | ((pConfigDescriptor)[3]&0xff)<<8)         \


/*******************************************************************************
 * Macro Name  : HUB_DESC_IS_COMPOUND_DEVICE
 * Description : This parses the hub descriptor and returns if the hub is part
 *               of a compound device or not.
 * Parameters  : pHubDescriptor          IN   pointer to the Hub descriptor.
 * Return Type : BOOLEAN
 ******************************************************************************/

#define USB_HUB_DESC_IS_COMPOUND_DEVICE(pHubDescriptor)                            \
    (0==(UINT8)(USB_HUB_DESC_wHubCharacteristics(pHubDescriptor)&0x4)?             \
           FALSE:TRUE)                                                         \


/*******************************************************************************
 * Macro Name  : HUB_DESC_POWER_PROTECTION_SCHEME
 * Description : This parses the hub descriptor and returns the power protection
 *               scheme used - if this field is 0 this is Global protection
 *               scheme, if 1, it has per port reporting. If >1 then it has no
 *               power current protection
 * Parameters  : pHubDescriptor          IN   pointer to the Hub descriptor.
 * Return Type : UINT8
 ******************************************************************************/

#define USB_HUB_DESC_POWER_PROTECTION_SCHEME(pHubDescriptor)                       \
    ( (USB_HUB_DESC_wHubCharacteristics(pHubDescriptor)&0x18)>>3 )                 \


/*******************************************************************************
 * Macro Name  : HUB_IS_HUB_EVENT
 * Description : This parses the Event for a given Status and returns if any
 *               hub event has occurred.
 * Parameters  : uStatus                IN   Change status bitmap of the hub.
 * Return Type : BOOLEAN
 ******************************************************************************/

#define USB_HUB_IS_EVENT(uStatus)                                              \
    ( ( 0==(((UINT8*)(uStatus))[0]&0x01))?FALSE:TRUE)                          \

/*******************************************************************************
 * Macro Name  : HUB_IS_PORT_EVENT
 * Description : This parses the Event for a given Status and returns if any
 *               event has occurred in the port specified.
 * Parameters  : pStatus                IN   Change status bitmap of the hub.
 *               uPortNumber            IN   The port number of the change
 *               bResult                OUT  The result of the check
 * Return Type : None.
 ******************************************************************************/

#define USB_HUB_IS_PORT_EVENT(pStatus, uPortNumber)                                \
     ( (0 != ((pStatus)[(uPortNumber)/8]&((UINT8)0x1<<((uPortNumber)%8))) )?   \
            TRUE:FALSE )                                                       \


/*******************************************************************************
 * Macro Name  : HUB_IS_CONNECTION_CHANGE
 * Description : This parses the event for a given status and returns if any
 *               connect change event has occurred.
 * Parameters  : uStatus                IN   Change status of the port.
 * Return Type : BOOLEAN
 ******************************************************************************/

#define USB_HUB_IS_CONNECTION_CHANGE(uStatus)                                      \
    ((  0==((uStatus)&USB_C_PORT_CONNECTION_VALUE))? FALSE:TRUE)                   \


/*******************************************************************************
 * Macro Name  : HUB_IS_ENABLE_CHANGE
 * Description : This parses the event for a given status and returns if any
 *               enable change event has occurred.
 * Parameters  : uStatus                IN   Change status of the port.
 * Return Type : BOOLEAN
 ******************************************************************************/

#define USB_HUB_IS_ENABLE_CHANGE(uStatus)                                          \
    ((  0==((uStatus)&USB_C_PORT_ENABLE_VALUE))? FALSE:TRUE)                       \


/*******************************************************************************
 * Macro Name  : HUB_IS_SUSPEND_CHANGE
 * Description : This parses the event for a given status and returns if any
 *               suspend change event has occurred.
 * Parameters  : uStatus                IN   Change status of the port.
 * Return Type : BOOLEAN
 ******************************************************************************/

#define USB_HUB_IS_SUSPEND_CHANGE(uStatus)                                         \
    ((  0==((uStatus)&USB_C_PORT_SUSPEND_VALUE))? FALSE:TRUE)                      \


/*******************************************************************************
 * Macro Name  : HUB_IS_RESET_CHANGE
 * Description : This parses the event for a given status and returns if any
 *               reset change event has occurred.
 * Parameters  : uStatus                IN   Change status of the port.
 * Return Type : BOOLEAN
 ******************************************************************************/

#define USB_HUB_IS_RESET_CHANGE(uStatus)                                           \
    ((  0==((uStatus)&USB_C_PORT_RESET_VALUE))? FALSE:TRUE)                        \


/*******************************************************************************
 * Macro Name  : HUB_IS_OVER_CURRENT_CHANGE
 * Description : This parses the event for a given status and returns if any
 *               over current event has occurred.
 * Parameters  : uStatus                IN   Change status of the port.
 * Return Type : BOOLEAN
 ******************************************************************************/

#define USB_HUB_IS_OVER_CURRENT_CHANGE(uStatus)                                    \
    ((  0==((uStatus)&USB_C_PORT_OVER_CURRENT_VALUE))? FALSE:TRUE)                 \


/*******************************************************************************
 * Macro Name  : HUB_DEVICE_SPEED
 * Description : This detects the speed of the device from the port status
 * Parameters  : uStatus                IN   status of the port.
 * Return Type : UINT8
 ******************************************************************************/

#define USB_HUB_DEVICE_SPEED(uStatus)                                              \
        ((UINT8)((((uStatus) & USB_PORT_SPEED_VALUE) >> 9) & 0xFF))                

/*******************************************************************************
 * Macro Name  : HUB_SET_HUB_FEATURE
 * Description : This will submit a blocking call to set a hub feature.
 * Parameters  : pHub                  IN   The Hub pointer.
 *               bResult               OUT  The result will be stored here
 *               Feature               IN   The feature on the hub to be set
 * Return Type : None
 ******************************************************************************/

#define USB_HUB_SET_HUB_FEATURE(pHub,bResult,Feature)                              \
{                                                                              \
    bResult=usbHubSubmitControlRequest(pHub,USB_HUB_TARGET_SET,                     \
    USB_SET_FEATURE,Feature ,0);                                                   \
}                                                                              \


/*******************************************************************************
 * Macro Name  : HUB_CLEAR_HUB_FEATURE
 * Description : This will submit a blocking call to clear a hub feature.
 * Parameters  : pHub                  IN   The Hub pointer.
 *               bResult               OUT  The result will be stored here
 *               Feature               IN   The feature on the hub to be set
 * Return Type : None
 ******************************************************************************/

#define USB_HUB_CLEAR_HUB_FEATURE(pHub,bResult,Feature)                            \
{                                                                              \
    bResult=usbHubSubmitControlRequest(pHub, USB_HUB_TARGET_SET,                     \
    USB_CLEAR_FEATURE,Feature ,0);                                                 \
}                                                                              \


/*******************************************************************************
 * Macro Name  : HUB_SET_PORT_FEATURE
 * Description : This will submit a blocking call to set a port feature.
 *               Converts the port number
 * 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_SET_PORT_FEATURE(pHub,uPortIndex,Feature)                          \
        usbHubSubmitControlRequest(pHub,                                         \
                                 USB_PORT_TARGET_SET,                              \
                                 USB_SET_FEATURE,                                  \
                                 Feature,                                      \
                                 uPortIndex+1)                                 \


/*******************************************************************************
 * Macro Name  : HUB_CLEAR_PORT_FEATURE

⌨️ 快捷键说明

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