AndroidAccessory: wait for disconnect on setup

This was causing the Nexus S to not re-enumerate correctly

Change-Id: I11285bdd0ba23d42d8f0b2235b1a81d937402f1b
Signed-off-by: Erik Gilling <konkers@android.com>
diff --git a/AndroidAccessory/AndroidAccessory.cpp b/AndroidAccessory/AndroidAccessory.cpp
index 2e86a42..a864b90 100644
--- a/AndroidAccessory/AndroidAccessory.cpp
+++ b/AndroidAccessory/AndroidAccessory.cpp
@@ -92,6 +92,12 @@
 
     usb.ctrlReq(addr, 0, USB_SETUP_HOST_TO_DEVICE | USB_SETUP_TYPE_VENDOR | USB_SETUP_RECIPIENT_DEVICE,
                 ACCESSORY_START, 0, 0, 0, 0, NULL);
+
+    while (usb.getUsbTaskState() != USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE) {
+        max.Task();
+        usb.Task();
+    }
+
     return true;
 }