@@ -32,6 +32,8 @@ implement the bare minimum to control the root HCD port.
32
32
#define HUB_ROOT_HCD_PORT_FIFO_BIAS HCD_PORT_FIFO_BIAS_BALANCED
33
33
#endif
34
34
35
+ #define SET_ADDR_RECOVERY_INTERVAL_MS CONFIG_USB_HOST_SET_ADDR_RECOVERY_MS
36
+
35
37
#define ENUM_CTRL_TRANSFER_MAX_DATA_LEN CONFIG_USB_HOST_CONTROL_TRANSFER_MAX_SIZE
36
38
#define ENUM_DEV_ADDR 1 //Device address used in enumeration
37
39
#define ENUM_CONFIG_INDEX 0 //Index of the first configuration of the device
@@ -79,6 +81,7 @@ typedef enum {
79
81
ENUM_STAGE_SECOND_RESET , /**< Reset the device again (Workaround for old USB devices that get confused by the previous short dev desc request). */
80
82
ENUM_STAGE_SET_ADDR , /**< Send SET_ADDRESS request */
81
83
ENUM_STAGE_CHECK_ADDR , /**< Update the enum pipe's target address */
84
+ ENUM_STAGE_SET_ADDR_RECOVERY , /**< Wait SET ADDRESS recovery interval at least for 2ms due to usb_20, chapter 9.2.6.3 */
82
85
ENUM_STAGE_GET_FULL_DEV_DESC , /**< Get the full dev desc */
83
86
ENUM_STAGE_CHECK_FULL_DEV_DESC , /**< Check the full dev desc, fill it into the device object in USBH. Save the string descriptor indexes*/
84
87
ENUM_STAGE_GET_SHORT_CONFIG_DESC , /**< Getting a short config desc (wLength is ENUM_SHORT_DESC_REQ_LEN) */
@@ -117,6 +120,7 @@ const char *const enum_stage_strings[] = {
117
120
"SECOND_RESET" ,
118
121
"SET_ADDR" ,
119
122
"CHECK_ADDR" ,
123
+ "SET_ADDR_RECOVERY" ,
120
124
"GET_FULL_DEV_DESC" ,
121
125
"CHECK_FULL_DEV_DESC" ,
122
126
"GET_SHORT_CONFIG_DESC" ,
@@ -411,6 +415,22 @@ static bool enum_stage_transfer(enum_ctrl_t *enum_ctrl)
411
415
return true;
412
416
}
413
417
418
+ static bool enum_stage_wait (enum_ctrl_t * enum_ctrl )
419
+ {
420
+ switch (enum_ctrl -> stage ) {
421
+ case ENUM_STAGE_SET_ADDR_RECOVERY : {
422
+ vTaskDelay (pdMS_TO_TICKS (SET_ADDR_RECOVERY_INTERVAL_MS )); // Need a short delay before device is ready. Todo: IDF-7007
423
+ return true;
424
+ }
425
+
426
+ default : //Should never occur
427
+ abort ();
428
+ break ;
429
+ }
430
+
431
+ return false;
432
+ }
433
+
414
434
static bool enum_stage_transfer_check (enum_ctrl_t * enum_ctrl )
415
435
{
416
436
//Dequeue the URB
@@ -696,6 +716,7 @@ static void enum_set_next_stage(enum_ctrl_t *enum_ctrl, bool last_stage_pass)
696
716
case ENUM_STAGE_GET_SHORT_DEV_DESC :
697
717
case ENUM_STAGE_SECOND_RESET :
698
718
case ENUM_STAGE_SET_ADDR :
719
+ case ENUM_STAGE_SET_ADDR_RECOVERY :
699
720
case ENUM_STAGE_GET_FULL_DEV_DESC :
700
721
case ENUM_STAGE_GET_SHORT_CONFIG_DESC :
701
722
case ENUM_STAGE_GET_FULL_CONFIG_DESC :
@@ -857,6 +878,10 @@ static void enum_handle_events(void)
857
878
case ENUM_STAGE_GET_FULL_SER_STR_DESC :
858
879
stage_pass = enum_stage_transfer (enum_ctrl );
859
880
break ;
881
+ //Recovery interval
882
+ case ENUM_STAGE_SET_ADDR_RECOVERY :
883
+ stage_pass = enum_stage_wait (enum_ctrl );
884
+ break ;
860
885
//Transfer check stages
861
886
case ENUM_STAGE_CHECK_SHORT_DEV_DESC :
862
887
case ENUM_STAGE_CHECK_ADDR :
0 commit comments