Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- usb_error_t srl_handle_usb_event(usb_event_t event, void *event_data,
- usb_callback_data_t *callback_data) {
- usb_error_t err;
- /* Delegate to srl USB callback */
- if ((err = srl_UsbEventCallback(event, event_data, callback_data)) != USB_SUCCESS) return err;
- /* Enable newly connected devices */
- switch(event){
- case USB_DEVICE_CONNECTED_EVENT:
- if (!(usb_GetRole() & USB_ROLE_DEVICE)){
- usb_device_t usb_device = event_data;
- usb_ResetDevice(usb_device);
- }
- break;
- case USB_HOST_CONFIGURE_EVENT:
- {
- usb_device_t host = usb_FindDevice(NULL, NULL, USB_SKIP_HUBS);
- if(host) usb_device = host;
- if(serial_open()) return USB_SUCCESS;
- break;
- }
- // break;
- case USB_DEVICE_ENABLED_EVENT:
- usb_device = event_data;
- if(serial_open()) return USB_SUCCESS;
- break;
- // break;
- case USB_DEVICE_DISCONNECTED_EVENT:
- srl_Close(&srl);
- RESET_FLAG(gamestate.inet.flags, INET_ACTIVE);
- MARK_FRAME_DIRTY;
- return USB_SUCCESS;
- }
- return USB_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement