10.2.6.14.10 Detach Procedure (Software Disconnect)
The user can detach the device from the USB bus under software control by setting the UDPHS_CTRL.DETACH bit.
If the device is currently operating at high speed, software will first force the device to Full-Speed mode by writing UDPHS_TST.SPEED_CFG = 3 (FULL_SPEED).
Note: Setting DETACH directly from High Speed operation is not
supported and is not reliably observed by the host as a disconnect.
To detach the device:
- Write UDPHS_TST.SPEED_CFG = 3 (FULL_SPEED).
- Write UDPHS_CTRL.DETACH = 1.
No software delay between the two writes is required.
On re-attach, the writes must occur in the reverse order:
- Write UDPHS_TST.SPEED_CFG = 0 (NORMAL).
- Write UDPHS_CTRL.DETACH = 0.
Note: The same sequence can be applied regardless of the current
speed.
Pseudo-code:
/* Detach */
UDPHS_TST = (UDPHS_TST & ~0x3) | 0x3; /* SPEED_CFG = FULL_SPEED */
UDPHS_CTRL = UDPHS_CTRL | UDPHS_DETACH; /* DETACH = 1 */
/* Re-attach */
UDPHS_TST = UDPHS_TST & ~0x3; /* SPEED_CFG = NORMAL */
UDPHS_CTRL = UDPHS_CTRL & ~UDPHS_DETACH; /* DETACH = 0 */
