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. usb_state = USB_POWERED;
  6. queue_send(&button_queue, SYS_USB_ATTACHED, NULL);
  7. break;
  8.  
  9.  
  10.  
  11. ==============================================
  12.  
  13.  
  14. case SYS_USB_ATTACHED:
  15. #ifdef USB_ENABLE_STORAGE
  16. usb_core_enable_driver(USB_DRIVER_MASS_STORAGE, false);
  17. #endif
  18. #ifdef USB_ENABLE_HID
  19. usb_core_enable_driver(USB_DRIVER_HID, false);
  20. #endif
  21. #ifdef USB_ENABLE_CHARGING_ONLY
  22. usb_core_enable_driver(USB_DRIVER_CHARGING_ONLY, false);
  23. #endif
  24. usb_core_enable_driver(USB_DRIVER_MTP, true);
  25. return 1;