File tree Expand file tree Collapse file tree 3 files changed +26
-11
lines changed Expand file tree Collapse file tree 3 files changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ esp_err_t hub_uninstall(void);
115115 *    - ESP_OK: Hub driver started successfully 
116116 *    - ESP_ERR_INVALID_STATE: Hub driver is not installed, or root port is in other state than not powered 
117117 */ 
118- esp_err_t  hub_root_start (void );
118+ esp_err_t  hub_root_start (uint8_t   port_idx );
119119
120120/** 
121121 * @brief Stops the Hub driver's root port 
Original file line number Diff line number Diff line change @@ -734,21 +734,22 @@ esp_err_t hub_uninstall(void)
734734    return  ESP_OK ;
735735}
736736
737- esp_err_t  hub_root_start (void )
737+ esp_err_t  hub_root_start (uint8_t   port_idx )
738738{
739739    /* TODO: Support hub root port selection in USB Host (higher) layer */ 
740740    // For now, there is only one root port powered on at any time 
741741    root_port_t  * root_port ;
742742
743743    HUB_DRIVER_ENTER_CRITICAL ();
744744    HUB_DRIVER_CHECK_FROM_CRIT (p_hub_driver_obj  !=  NULL , ESP_ERR_INVALID_STATE );
745-     for  (uint8_t  port_idx  =  0 ; port_idx  <  HUB_ROOT_PORTS ; port_idx ++ ) {
746-         root_port  =  & p_hub_driver_obj -> constant .root_port_hdls [port_idx ];
747-         if  (root_port -> constant .hdl  !=  NULL ) {
748-             break ;
749-         }
750-     }
751-     HUB_DRIVER_CHECK_FROM_CRIT (root_port  !=  NULL , ESP_ERR_NOT_FOUND );
745+     // for (uint8_t port_idx = 0; port_idx < HUB_ROOT_PORTS; port_idx++) { 
746+     //     root_port = &p_hub_driver_obj->constant.root_port_hdls[port_idx]; 
747+     //     if (root_port->constant.hdl != NULL) { 
748+     //         break; 
749+     //     } 
750+     // } 
751+     // HUB_DRIVER_CHECK_FROM_CRIT(root_port != NULL, ESP_ERR_NOT_FOUND); 
752+     root_port  =  & p_hub_driver_obj -> constant .root_port_hdls [port_idx ];
752753    HUB_DRIVER_CHECK_FROM_CRIT (root_port -> dynamic .state  ==  ROOT_PORT_STATE_NOT_POWERED , ESP_ERR_INVALID_STATE );
753754    HUB_DRIVER_EXIT_CRITICAL ();
754755    // Power ON the root port 
Original file line number Diff line number Diff line change @@ -503,6 +503,19 @@ esp_err_t usb_host_install(const usb_host_config_t *config)
503503            ESP_LOGE (USB_HOST_TAG , "PHY install error: %s" , esp_err_to_name (ret ));
504504            goto phy_err ;
505505        }
506+ 
507+         usb_phy_handle_t  hs_phy_handle ;
508+         usb_phy_config_t  phy_config1  =  {
509+             .controller  =  USB_PHY_CTRL_OTG ,
510+             .target  =  USB_PHY_TARGET_UTMI ,
511+             .otg_mode  =  USB_OTG_MODE_HOST ,
512+             .otg_speed  =  USB_PHY_SPEED_UNDEFINED ,   // In Host mode, the speed is determined by the connected device 
513+         };
514+         ret  =  usb_new_phy (& phy_config1 , & hs_phy_handle );
515+         if  (ret  !=  ESP_OK ) {
516+             ESP_LOGE (USB_HOST_TAG , "PHY install error: %s" , esp_err_to_name (ret ));
517+             goto phy_err ;
518+         }
506519    }
507520
508521    // Install HCD 
@@ -589,7 +602,8 @@ esp_err_t usb_host_install(const usb_host_config_t *config)
589602
590603    if  (!config -> root_port_unpowered ) {
591604        // Start the root hub 
592-         ESP_ERROR_CHECK (hub_root_start ());
605+         ESP_ERROR_CHECK (hub_root_start (0 ));
606+         ESP_ERROR_CHECK (hub_root_start (1 ));
593607    }
594608
595609    ret  =  ESP_OK ;
@@ -748,7 +762,7 @@ esp_err_t usb_host_lib_set_root_port_power(bool enable)
748762{
749763    esp_err_t  ret ;
750764    if  (enable ) {
751-         ret  =  hub_root_start ();
765+         ret  =  hub_root_start (0 );
752766    } else  {
753767        ret  =  hub_root_stop ();
754768    }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments