simplify dwc2 test mode
- all dwc2 ip seems to support test mode in both fs/hs -> remove TUP_USBIP_DWC2_TEST_MODE - remove dcd_check_test_mode_support(), all should be supported - move enum tusb_feature_test_mode_t to tusb_types.h
This commit is contained in:
@@ -321,9 +321,17 @@ TU_ATTR_ALWAYS_INLINE static inline bool queue_event(dcd_event_t const * event,
|
||||
static bool process_control_request(uint8_t rhport, tusb_control_request_t const * p_request);
|
||||
static bool process_set_config(uint8_t rhport, uint8_t cfg_num);
|
||||
static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const * p_request);
|
||||
|
||||
#if CFG_TUD_TEST_MODE
|
||||
static bool process_test_mode_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
|
||||
static bool process_test_mode_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request) {
|
||||
TU_VERIFY(CONTROL_STAGE_ACK == stage);
|
||||
uint8_t const selector = tu_u16_high(request->wIndex);
|
||||
TU_LOG_USBD(" Enter Test Mode (test selector index: %d)\r\n", selector);
|
||||
dcd_enter_test_mode(rhport, (tusb_feature_test_mode_t) selector);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// from usbd_control.c
|
||||
void usbd_control_reset(void);
|
||||
void usbd_control_set_request(tusb_control_request_t const *request);
|
||||
@@ -695,7 +703,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
}
|
||||
|
||||
if ( TUSB_REQ_TYPE_STANDARD != p_request->bmRequestType_bit.type ) {
|
||||
// Non standard request is not supported
|
||||
// Non-standard request is not supported
|
||||
TU_BREAKPOINT();
|
||||
return false;
|
||||
}
|
||||
@@ -759,43 +767,27 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
break;
|
||||
|
||||
case TUSB_REQ_SET_FEATURE:
|
||||
// Handle the feature selector
|
||||
switch(p_request->wValue)
|
||||
{
|
||||
// Support for remote wakeup
|
||||
switch(p_request->wValue) {
|
||||
case TUSB_REQ_FEATURE_REMOTE_WAKEUP:
|
||||
TU_LOG_USBD(" Enable Remote Wakeup\r\n");
|
||||
|
||||
// Host may enable remote wake up before suspending especially HID device
|
||||
_usbd_dev.remote_wakeup_en = true;
|
||||
tud_control_status(rhport, p_request);
|
||||
break;
|
||||
|
||||
#if CFG_TUD_TEST_MODE
|
||||
// Support for TEST_MODE
|
||||
#if CFG_TUD_TEST_MODE
|
||||
case TUSB_REQ_FEATURE_TEST_MODE: {
|
||||
// Only handle the test mode if supported and valid
|
||||
TU_VERIFY(dcd_enter_test_mode && dcd_check_test_mode_support && 0 == tu_u16_low(p_request->wIndex));
|
||||
TU_VERIFY(0 == tu_u16_low(p_request->wIndex));
|
||||
|
||||
uint8_t selector = tu_u16_high(p_request->wIndex);
|
||||
|
||||
// Stall request if the selected test mode isn't supported
|
||||
if (!dcd_check_test_mode_support((test_mode_t)selector))
|
||||
{
|
||||
TU_LOG_USBD(" Unsupported Test Mode (test selector index: %d)\r\n", selector);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Acknowledge request
|
||||
tud_control_status(rhport, p_request);
|
||||
|
||||
TU_LOG_USBD(" Enter Test Mode (test selector index: %d)\r\n", selector);
|
||||
uint8_t const selector = tu_u16_high(p_request->wIndex);
|
||||
TU_VERIFY(TUSB_FEATURE_TEST_J <= selector && selector <= TUSB_FEATURE_TEST_FORCE_ENABLE);
|
||||
|
||||
usbd_control_set_complete_callback(process_test_mode_cb);
|
||||
tud_control_status(rhport, p_request);
|
||||
break;
|
||||
}
|
||||
#endif /* CFG_TUD_TEST_MODE */
|
||||
#endif /* CFG_TUD_TEST_MODE */
|
||||
|
||||
// Stall unsupported feature selector
|
||||
default: return false;
|
||||
@@ -1127,20 +1119,6 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
|
||||
}
|
||||
}
|
||||
|
||||
#if CFG_TUD_TEST_MODE
|
||||
static bool process_test_mode_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request)
|
||||
{
|
||||
// At this point it should already be ensured that dcd_enter_test_mode() is defined
|
||||
|
||||
// Only enter the test mode after the request for it has completed
|
||||
TU_VERIFY(CONTROL_STAGE_ACK == stage);
|
||||
|
||||
dcd_enter_test_mode(rhport, (test_mode_t)tu_u16_high(request->wIndex));
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif /* CFG_TUD_TEST_MODE */
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// DCD Event Handler
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
Reference in New Issue
Block a user