1. case USB_INSERTED:
  2. /* inject an event into the button queue so the main thread
  3. * will run the USB-UI code and return after the desired
  4. * drivers are enabled */
  5. queue_send(&button_queue, SYS_USB_ATTACHED, NULL);
  6. usb_state = USB_POWERED;
  7. #ifdef HAVE_USBSTACK
  8. /* Check any drivers enabled at this point for exclusive storage
  9. * access requirements. */
  10. exclusive_storage_access = usb_core_any_exclusive_storage();
  11.  
  12. if(!exclusive_storage_access)
  13. {
  14. usb_attach();
  15. break;
  16. }
  17. #endif /* HAVE_USBSTACK */
  18. /* Tell all threads that they have to back off the storage.
  19. We subtract one for our own thread. */
  20. num_acks_to_expect = queue_broadcast(SYS_USB_CONNECTED, 0) - 1;
  21. DEBUGF("USB inserted. Waiting for ack from %d threads...\n",
  22. num_acks_to_expect);
  23. break;