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.
pull/9768/head
Russ Butler 2018-03-20 16:39:12 -05:00
parent 0653799b5a
commit aa76c776c9
1 changed files with 4 additions and 0 deletions

View File

@ -195,6 +195,10 @@ void USBPhyHw::connect()
void USBPhyHw::disconnect()
{
// disable all endpoints to prevent them from nacking when disconnected
for(int i = 0; i < 16; i++) {
USB0->ENDPOINT[i].ENDPT = 0x00;
}
// disable USB
USB0->CTL &= ~USB_CTL_USBENSOFEN_MASK;
// Pull up disable