/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs and stops the USB management task. */ void EVENT_USB_Disconnect(void) { /* Stop running HID reporting and USB management tasks */ Scheduler_SetTaskMode(USB_ProcessPacket, TASK_STOP); Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); /* Indicate USB not ready */ UpdateStatus(Status_USBNotReady); }
/** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and * stops the library USB task management process. */ void EVENT_USB_DeviceUnattached(void) { /* Stop mouse and USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); Scheduler_SetTaskMode(USB_Mouse_Host, TASK_STOP); puts_P(PSTR("Device Unattached.\r\n")); UpdateStatus(Status_USBNotReady); }
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs and stops the USB management and CDC management tasks. */ void EVENT_USB_Disconnect(void) { /* Stop running CDC and USB management tasks */ Scheduler_SetTaskMode(CDC_Task, TASK_STOP); Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); /* Reset Tx and Rx buffers, device disconnected */ Buffer_Initialize(&Rx_Buffer); Buffer_Initialize(&Tx_Buffer); /* Indicate USB not ready */ UpdateStatus(Status_USBNotReady); }
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and * starts the library USB task to begin the enumeration and USB management process. */ void EVENT_USB_DeviceAttached(void) { puts_P(PSTR("Device Attached.\r\n")); UpdateStatus(Status_USBEnumerating); /* Start USB management task to enumerate the device */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); }
/** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully * enumerated by the host and is now ready to be used by the application. */ void EVENT_USB_DeviceEnumerationComplete(void) { /* Start Mouse Host task */ Scheduler_SetTaskMode(USB_Mouse_Host, TASK_RUN); /* Indicate device enumeration complete */ UpdateStatus(Status_USBReady); }
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and * starts the library USB task to begin the enumeration and USB management process. */ void EVENT_USB_Connect(void) { /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); /* Indicate USB enumerating */ UpdateStatus(Status_USBEnumerating); }
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration * of the USB device after enumeration - the device endpoints are configured and the joystick reporting task started. */ void EVENT_USB_ConfigurationChanged(void) { /* Setup Joystick Report Endpoint */ Endpoint_ConfigureEndpoint(JOYSTICK_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, JOYSTICK_EPSIZE, ENDPOINT_BANK_SINGLE); /* Indicate USB connected and ready */ UpdateStatus(Status_USBReady); /* Start joystick reporting task */ Scheduler_SetTaskMode(USB_Joystick_Report, TASK_RUN); }
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host sets the current configuration * of the USB device after enumeration, and configures the generic HID device endpoints. */ void EVENT_USB_ConfigurationChanged(void) { /* Setup USB In and Out Endpoints */ Endpoint_ConfigureEndpoint(OUT_EPNUM, EP_TYPE_BULK, ENDPOINT_DIR_OUT, OUT_EPSIZE, ENDPOINT_BANK_SINGLE); Endpoint_ConfigureEndpoint(IN_EPNUM, EP_TYPE_BULK, ENDPOINT_DIR_IN, IN_EPSIZE, ENDPOINT_BANK_SINGLE); /* Indicate USB connected and ready */ UpdateStatus(Status_USBReady); /* Start ProcessPacket task */ Scheduler_SetTaskMode(USB_ProcessPacket, TASK_RUN); }
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration * of the USB device after enumeration - the device endpoints are configured and the CDC management task started. */ void EVENT_USB_ConfigurationChanged(void) { /* Setup CDC Notification, Rx and Tx Endpoints */ Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, CDC_NOTIFICATION_EPSIZE, ENDPOINT_BANK_SINGLE); Endpoint_ConfigureEndpoint(CDC_TX_EPNUM, EP_TYPE_BULK, ENDPOINT_DIR_IN, CDC_TXRX_EPSIZE, ENDPOINT_BANK_SINGLE); Endpoint_ConfigureEndpoint(CDC_RX_EPNUM, EP_TYPE_BULK, ENDPOINT_DIR_OUT, CDC_TXRX_EPSIZE, ENDPOINT_BANK_SINGLE); /* Indicate USB connected and ready */ UpdateStatus(Status_USBReady); /* Start CDC task */ Scheduler_SetTaskMode(CDC_Task, TASK_RUN); }