mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
refractor hub
This commit is contained in:
parent
821f85cb20
commit
5fb22e3f34
@ -67,8 +67,8 @@
|
|||||||
#include "oem_base_board/pca9532.h" // LEDs
|
#include "oem_base_board/pca9532.h" // LEDs
|
||||||
|
|
||||||
|
|
||||||
#define CFG_PRINTF_TARGET PRINTF_TARGET_SWO
|
//#define CFG_PRINTF_TARGET PRINTF_TARGET_SWO
|
||||||
//#define CFG_PRINTF_TARGET PRINTF_TARGET_UART // FIXME keil's cmsis rtx does not work with UART (work with SWO)
|
#define CFG_PRINTF_TARGET PRINTF_TARGET_UART // FIXME keil's cmsis rtx does not work with UART (work with SWO)
|
||||||
|
|
||||||
/*=========================================================================
|
/*=========================================================================
|
||||||
HARDWARE MAC ADDRESS
|
HARDWARE MAC ADDRESS
|
||||||
|
@ -762,8 +762,8 @@
|
|||||||
<Focus>0</Focus>
|
<Focus>0</Focus>
|
||||||
<ColumnNumber>0</ColumnNumber>
|
<ColumnNumber>0</ColumnNumber>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<TopLine>1</TopLine>
|
<TopLine>74</TopLine>
|
||||||
<CurrentLine>1</CurrentLine>
|
<CurrentLine>93</CurrentLine>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\tinyusb\host\hub.c</PathWithFileName>
|
<PathWithFileName>..\..\..\tinyusb\host\hub.c</PathWithFileName>
|
||||||
<FilenameWithoutPath>hub.c</FilenameWithoutPath>
|
<FilenameWithoutPath>hub.c</FilenameWithoutPath>
|
||||||
@ -778,8 +778,8 @@
|
|||||||
<Focus>0</Focus>
|
<Focus>0</Focus>
|
||||||
<ColumnNumber>0</ColumnNumber>
|
<ColumnNumber>0</ColumnNumber>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<TopLine>1</TopLine>
|
<TopLine>328</TopLine>
|
||||||
<CurrentLine>1</CurrentLine>
|
<CurrentLine>334</CurrentLine>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\..\tinyusb\host\usbh.c</PathWithFileName>
|
<PathWithFileName>..\..\..\tinyusb\host\usbh.c</PathWithFileName>
|
||||||
<FilenameWithoutPath>usbh.c</FilenameWithoutPath>
|
<FilenameWithoutPath>usbh.c</FilenameWithoutPath>
|
||||||
@ -1080,10 +1080,10 @@
|
|||||||
<FileType>2</FileType>
|
<FileType>2</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<Focus>0</Focus>
|
<Focus>0</Focus>
|
||||||
<ColumnNumber>18</ColumnNumber>
|
<ColumnNumber>5</ColumnNumber>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<TopLine>145</TopLine>
|
<TopLine>145</TopLine>
|
||||||
<CurrentLine>147</CurrentLine>
|
<CurrentLine>152</CurrentLine>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName>
|
<PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName>
|
||||||
<FilenameWithoutPath>startup_LPC43xx.s</FilenameWithoutPath>
|
<FilenameWithoutPath>startup_LPC43xx.s</FilenameWithoutPath>
|
||||||
|
@ -64,6 +64,40 @@ uint8_t hub_enum_buffer[sizeof(descriptor_hub_desc_t)] TUSB_CFG_ATTR_USBRAM;
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// HUB
|
// HUB
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
tusb_error_t hub_port_clear_feature_subtask(uint8_t feature)
|
||||||
|
{
|
||||||
|
tusb_error_t error;
|
||||||
|
|
||||||
|
OSAL_SUBTASK_BEGIN
|
||||||
|
|
||||||
|
SUBTASK_ASSERT(HUB_FEATURE_PORT_CONNECTION_CHANGE <= feature &&
|
||||||
|
feature <= HUB_FEATURE_PORT_RESET_CHANGE);
|
||||||
|
|
||||||
|
//------------- Clear Port Feature request -------------//
|
||||||
|
OSAL_SUBTASK_INVOKED_AND_WAIT(
|
||||||
|
usbh_control_xfer_subtask( usbh_devices[0].hub_addr, bm_request_type(TUSB_DIR_HOST_TO_DEV, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_OTHER),
|
||||||
|
HUB_REQUEST_CLEAR_FEATURE, feature, usbh_devices[0].hub_port,
|
||||||
|
0, NULL ),
|
||||||
|
error
|
||||||
|
);
|
||||||
|
SUBTASK_ASSERT_STATUS( error );
|
||||||
|
|
||||||
|
//------------- Get Port Status to check if feature is cleared -------------//
|
||||||
|
OSAL_SUBTASK_INVOKED_AND_WAIT(
|
||||||
|
usbh_control_xfer_subtask( usbh_devices[0].hub_addr, bm_request_type(TUSB_DIR_DEV_TO_HOST, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_OTHER),
|
||||||
|
HUB_REQUEST_GET_STATUS, 0, usbh_devices[0].hub_port,
|
||||||
|
4, hub_enum_buffer ),
|
||||||
|
error
|
||||||
|
);
|
||||||
|
SUBTASK_ASSERT_STATUS( error );
|
||||||
|
|
||||||
|
//------------- Check if feature is cleared -------------//
|
||||||
|
hub_port_status_response_t * p_port_status = (hub_port_status_response_t *) hub_enum_buffer;
|
||||||
|
SUBTASK_ASSERT( !BIT_TEST_(p_port_status->status_change.value, feature-16) );
|
||||||
|
|
||||||
|
OSAL_SUBTASK_END
|
||||||
|
}
|
||||||
|
|
||||||
tusb_error_t hub_enumerate_subtask(void)
|
tusb_error_t hub_enumerate_subtask(void)
|
||||||
{
|
{
|
||||||
tusb_error_t error;
|
tusb_error_t error;
|
||||||
@ -90,28 +124,10 @@ tusb_error_t hub_enumerate_subtask(void)
|
|||||||
SUBTASK_EXIT(TUSB_ERROR_NONE);
|
SUBTASK_EXIT(TUSB_ERROR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hub connection
|
// Acknowledge Port Connection Change
|
||||||
//------------- Clear Hub Port Connect Status Change -------------//
|
OSAL_SUBTASK_INVOKED_AND_WAIT( hub_port_clear_feature_subtask(HUB_FEATURE_PORT_CONNECTION_CHANGE), error );
|
||||||
OSAL_SUBTASK_INVOKED_AND_WAIT(
|
|
||||||
usbh_control_xfer_subtask( usbh_devices[0].hub_addr, bm_request_type(TUSB_DIR_HOST_TO_DEV, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_OTHER),
|
|
||||||
HUB_REQUEST_CLEAR_FEATURE, HUB_FEATURE_PORT_CONNECTION_CHANGE, usbh_devices[0].hub_port,
|
|
||||||
0, NULL ),
|
|
||||||
error
|
|
||||||
);
|
|
||||||
SUBTASK_ASSERT_STATUS( error );
|
SUBTASK_ASSERT_STATUS( error );
|
||||||
|
|
||||||
//------------- Get Port Status again to make sure Connect Change is cleared -------------//
|
|
||||||
OSAL_SUBTASK_INVOKED_AND_WAIT(
|
|
||||||
usbh_control_xfer_subtask( usbh_devices[0].hub_addr, bm_request_type(TUSB_DIR_DEV_TO_HOST, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_OTHER),
|
|
||||||
HUB_REQUEST_GET_STATUS, 0, usbh_devices[0].hub_port,
|
|
||||||
4, hub_enum_buffer ),
|
|
||||||
error
|
|
||||||
);
|
|
||||||
SUBTASK_ASSERT_STATUS( error );
|
|
||||||
|
|
||||||
p_port_status = (hub_port_status_response_t *) hub_enum_buffer;
|
|
||||||
SUBTASK_ASSERT( !p_port_status->status_change.connect_status); // this has to be cleared
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// PORT RESET & WAIT FOR STATUS ENDPOINT & GET STATUS & CLEAR RESET CHANGE
|
// PORT RESET & WAIT FOR STATUS ENDPOINT & GET STATUS & CLEAR RESET CHANGE
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -144,10 +144,14 @@ enum{
|
|||||||
|
|
||||||
// data in response of HUB_REQUEST_GET_STATUS, wIndex = 0 (hub)
|
// data in response of HUB_REQUEST_GET_STATUS, wIndex = 0 (hub)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
union{
|
||||||
ATTR_PACKED_STRUCT(struct) {
|
ATTR_PACKED_STRUCT(struct) {
|
||||||
uint16_t local_power_source : 1;
|
uint16_t local_power_source : 1;
|
||||||
uint16_t over_current : 1;
|
uint16_t over_current : 1;
|
||||||
uint16_t : 14;
|
uint16_t : 14;
|
||||||
|
};
|
||||||
|
|
||||||
|
uint16_t value;
|
||||||
} status, status_change;
|
} status, status_change;
|
||||||
} hub_status_response_t;
|
} hub_status_response_t;
|
||||||
|
|
||||||
@ -155,6 +159,7 @@ STATIC_ASSERT( sizeof(hub_status_response_t) == 4, "size is not correct");
|
|||||||
|
|
||||||
// data in response of HUB_REQUEST_GET_STATUS, wIndex = Port num
|
// data in response of HUB_REQUEST_GET_STATUS, wIndex = Port num
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
union {
|
||||||
ATTR_PACKED_STRUCT(struct) {
|
ATTR_PACKED_STRUCT(struct) {
|
||||||
uint16_t connect_status : 1;
|
uint16_t connect_status : 1;
|
||||||
uint16_t port_enable : 1;
|
uint16_t port_enable : 1;
|
||||||
@ -169,6 +174,9 @@ typedef struct {
|
|||||||
uint16_t port_test_mode : 1;
|
uint16_t port_test_mode : 1;
|
||||||
uint16_t port_indicator_control : 1;
|
uint16_t port_indicator_control : 1;
|
||||||
uint16_t : 0;
|
uint16_t : 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
uint16_t value;
|
||||||
} status_current, status_change;
|
} status_current, status_change;
|
||||||
} hub_port_status_response_t;
|
} hub_port_status_response_t;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user