Skip to content

Commit 7731a16

Browse files
c1728p90xc0170
authored andcommitted
Disable endpoints when disconnecting on Kinetis
Even thought the USB phy is disabled during disconnect, endpoints still nack packets sent. This patch disables all endpoints so after disconnect no USB traffic will be sent. This allows brief disconnects of ~200us (or more) to be reliably detected by the host PC.
1 parent a5ba1ef commit 7731a16

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

targets/TARGET_Freescale/usb/USBPhy_Kinetis.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ void USBPhyHw::connect()
195195

196196
void USBPhyHw::disconnect()
197197
{
198+
// disable all endpoints to prevent them from nacking when disconnected
199+
for(int i = 0; i < 16; i++) {
200+
USB0->ENDPOINT[i].ENDPT = 0x00;
201+
}
198202
// disable USB
199203
USB0->CTL &= ~USB_CTL_USBENSOFEN_MASK;
200204
// Pull up disable

0 commit comments

Comments
 (0)