Advertisement
AnthonyCagliano

Untitled

Nov 12th, 2022
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. usb_error_t srl_handle_usb_event(usb_event_t event, void *event_data,
  2. usb_callback_data_t *callback_data) {
  3.  
  4. usb_error_t err;
  5.  
  6. /* Delegate to srl USB callback */
  7. if ((err = srl_UsbEventCallback(event, event_data, callback_data)) != USB_SUCCESS) return err;
  8.  
  9. /* Enable newly connected devices */
  10. switch(event){
  11. case USB_DEVICE_CONNECTED_EVENT:
  12. if (!(usb_GetRole() & USB_ROLE_DEVICE)){
  13. usb_device_t usb_device = event_data;
  14. usb_ResetDevice(usb_device);
  15. }
  16. break;
  17. case USB_HOST_CONFIGURE_EVENT:
  18. {
  19. usb_device_t host = usb_FindDevice(NULL, NULL, USB_SKIP_HUBS);
  20. if(host) usb_device = host;
  21. if(serial_open()) return USB_SUCCESS;
  22. break;
  23. }
  24. // break;
  25. case USB_DEVICE_ENABLED_EVENT:
  26. usb_device = event_data;
  27. if(serial_open()) return USB_SUCCESS;
  28. break;
  29. // break;
  30. case USB_DEVICE_DISCONNECTED_EVENT:
  31. srl_Close(&srl);
  32. RESET_FLAG(gamestate.inet.flags, INET_ACTIVE);
  33. MARK_FRAME_DIRTY;
  34. return USB_SUCCESS;
  35.  
  36. }
  37. return USB_SUCCESS;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement