cancel
Showing results for 
Search instead for 
Did you mean: 

USB Host / enforce device to disconnect and re-connect ?

dzuikov
Associate II
Posted on January 24, 2012 at 08:23

Hi, 

I'm trying to communicate with Huawei 3G USB modem using STM32 Host and Device USB Library. Those modems require to be disconnected after some configuring to switch to  CDC mode.

Is there any way to force some USB device to disconnect using USB Host library and re-enumerate interfaces? I.e to perform soft-reset of USB Stack somehow.

I haven't found any way to do it, surprisingly USBH_DeInit or HCD_PortReset or even USB_OTG_StopHost do not work as expected.

So, is there any proper way to disconnect the device? Do I need the SOF feature (SOF pin is not connected in my device) ?

0690X00000604zvQAA.png
3 REPLIES 3
gabrielharrison
Associate II
Posted on October 23, 2014 at 16:56

Hi,

Did you ever work out the correct way to do this? I'm hoping to do something similar.

Gabriel
chen
Associate II
Posted on October 23, 2014 at 17:33

Hi

I know you can force a USB device to fake a disconnect.

I have no experience with USB host implementations.

The reference manual suggests a couple of things you could try :

In OTG_HS host port control and status register (OTG_HS_HPRT)

1) Initiate a USB reset command to the device

''Bit 8 PRST: Port reset

When the application sets this bit, a reset sequence is started on this port. The application

must time the reset period and clear this bit after the reset sequence is complete.

0: Port not in reset

1: Port in reset

The application must leave this bit set for a minimum duration of at least 10 ms to start a

reset on the port. The application can leave it set for another 10 ms in addition to the

required minimum duration, before clearing the bit, even though there is no maximum limit

set by the USB standard.

High speed: 50 ms

Full speed/Low speed: 10 ms''

2) Force a power down on the port

''Bit 12 PPWR: Port power

The application uses this field to control power to this port, and the core clears this bit on an

overcurrent condition.

0: Power off

1: Power on''

gabrielharrison
Associate II
Posted on October 24, 2014 at 14:35

Thank you,

After posting yesterday I found this in usb_dcd.c (v2.1.0 19 Mar 2012). I think it does what I need but it doesn't have the 10ms delay.

/**
* @brief Disconnect device (disable internal pull-up)
* @param pdev: device instance
* @retval : None
*/
void
DCD_DevDisconnect (USB_OTG_CORE_HANDLE *pdev)
{
#ifndef USE_OTG_MODE
USB_OTG_DCTL_TypeDef dctl;
dctl.d32 = USB_OTG_READ_REG32(&pdev->regs.DREGS->DCTL);
/* Disconnect device for 3ms */
dctl.b.sftdiscon = 1;
USB_OTG_WRITE_REG32(&pdev->regs.DREGS->DCTL, dctl.d32);
USB_OTG_BSP_mDelay(3);
#endif
}

Gabriel