\r
void SideShow_Task(void)\r
{\r
- /* Check if the USB System is connected to a Host */\r
- if (USB_IsConnected)\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+\r
+ /* Select the SideShow data out endpoint */\r
+ Endpoint_SelectEndpoint(SIDESHOW_OUT_EPNUM);\r
+ \r
+ /* Check to see if a new SideShow message has been received */\r
+ if (Endpoint_IsReadWriteAllowed())\r
{\r
- /* Select the SideShow data out endpoint */\r
- Endpoint_SelectEndpoint(SIDESHOW_OUT_EPNUM);\r
- \r
- /* Check to see if a new SideShow message has been received */\r
- if (Endpoint_IsReadWriteAllowed())\r
- {\r
- /* Process the received SideShow message */\r
- Sideshow_ProcessCommandPacket();\r
- }\r
+ /* Process the received SideShow message */\r
+ Sideshow_ProcessCommandPacket();\r
}\r
}\r
/** Task to manage the Audio interface, reading in ADC samples from the microphone, and them to the host. */\r
void USB_Audio_Task(void)\r
{\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+\r
/* Check to see if the streaming interface is selected, if not the host is not receiving audio */\r
if (!(StreamingAudioInterfaceSelected))\r
return;\r
*/\r
void USB_Audio_Task(void)\r
{\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+\r
/* Check to see if the streaming interface is selected, if not the host is not receiving audio */\r
if (!(StreamingAudioInterfaceSelected))\r
return; \r
"Joystick Pressed\r\n",\r
};\r
\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+ \r
#if 0\r
/* NOTE: Here you can use the notification endpoint to send back line state changes to the host, for the special RS-232\r
* handshake signal lines (and some error states), via the CONTROL_LINE_IN_* masks and the following code:\r
uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
static bool ActionSent = false;\r
\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+\r
char* JoystickStrings[] =\r
{\r
"Joystick Up\r\n",\r
*/\r
void CDC2_Task(void)\r
{\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+\r
/* Select the Serial Rx Endpoint */\r
Endpoint_SelectEndpoint(CDC2_RX_EPNUM);\r
\r
\r
void HID_Task(void)\r
{\r
- /* Check if the USB system is connected to a host */\r
- if (USB_IsConnected)\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+\r
+ Endpoint_SelectEndpoint(GENERIC_OUT_EPNUM);\r
+ \r
+ /* Check to see if a packet has been sent from the host */\r
+ if (Endpoint_IsOUTReceived())\r
{\r
- Endpoint_SelectEndpoint(GENERIC_OUT_EPNUM);\r
- \r
- /* Check to see if a packet has been sent from the host */\r
- if (Endpoint_IsOUTReceived())\r
+ /* Check to see if the packet contains data */\r
+ if (Endpoint_IsReadWriteAllowed())\r
{\r
- /* Check to see if the packet contains data */\r
- if (Endpoint_IsReadWriteAllowed())\r
- {\r
- /* Create a temporary buffer to hold the read in report from the host */\r
- uint8_t GenericData[GENERIC_REPORT_SIZE];\r
- \r
- /* Read Generic Report Data */\r
- Endpoint_Read_Stream_LE(&GenericData, sizeof(GenericData));\r
- \r
- /* Process Generic Report Data */\r
- ProcessGenericHIDReport(GenericData);\r
- }\r
+ /* Create a temporary buffer to hold the read in report from the host */\r
+ uint8_t GenericData[GENERIC_REPORT_SIZE];\r
+ \r
+ /* Read Generic Report Data */\r
+ Endpoint_Read_Stream_LE(&GenericData, sizeof(GenericData));\r
+ \r
+ /* Process Generic Report Data */\r
+ ProcessGenericHIDReport(GenericData);\r
+ }\r
\r
- /* Finalize the stream transfer to send the last packet */\r
- Endpoint_ClearOUT();\r
- } \r
+ /* Finalize the stream transfer to send the last packet */\r
+ Endpoint_ClearOUT();\r
+ } \r
\r
- Endpoint_SelectEndpoint(GENERIC_IN_EPNUM);\r
+ Endpoint_SelectEndpoint(GENERIC_IN_EPNUM);\r
+ \r
+ /* Check to see if the host is ready to accept another packet */\r
+ if (Endpoint_IsINReady())\r
+ {\r
+ /* Create a temporary buffer to hold the report to send to the host */\r
+ uint8_t GenericData[GENERIC_REPORT_SIZE];\r
\r
- /* Check to see if the host is ready to accept another packet */\r
- if (Endpoint_IsINReady())\r
- {\r
- /* Create a temporary buffer to hold the report to send to the host */\r
- uint8_t GenericData[GENERIC_REPORT_SIZE];\r
- \r
- /* Create Generic Report Data */\r
- CreateGenericHIDReport(GenericData);\r
+ /* Create Generic Report Data */\r
+ CreateGenericHIDReport(GenericData);\r
\r
- /* Write Generic Report Data */\r
- Endpoint_Write_Stream_LE(&GenericData, sizeof(GenericData));\r
+ /* Write Generic Report Data */\r
+ Endpoint_Write_Stream_LE(&GenericData, sizeof(GenericData));\r
\r
- /* Finalize the stream transfer to send the last packet */\r
- Endpoint_ClearIN();\r
- }\r
+ /* Finalize the stream transfer to send the last packet */\r
+ Endpoint_ClearIN();\r
}\r
}\r
/** Function to manage HID report generation and transmission to the host. */\r
void HID_Task(void)\r
{\r
- /* Check if the USB System is connected to a Host */\r
- if (USB_IsConnected)\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+ \r
+ /* Select the Joystick Report Endpoint */\r
+ Endpoint_SelectEndpoint(JOYSTICK_EPNUM);\r
+\r
+ /* Check to see if the host is ready for another packet */\r
+ if (Endpoint_IsINReady())\r
{\r
- /* Select the Joystick Report Endpoint */\r
- Endpoint_SelectEndpoint(JOYSTICK_EPNUM);\r
-\r
- /* Check to see if the host is ready for another packet */\r
- if (Endpoint_IsINReady())\r
- {\r
- USB_JoystickReport_Data_t JoystickReportData;\r
- \r
- /* Create the next HID report to send to the host */\r
- GetNextReport(&JoystickReportData);\r
+ USB_JoystickReport_Data_t JoystickReportData;\r
\r
- /* Write Joystick Report Data */\r
- Endpoint_Write_Stream_LE(&JoystickReportData, sizeof(JoystickReportData));\r
-\r
- /* Finalize the stream transfer to send the last packet */\r
- Endpoint_ClearIN();\r
- \r
- /* Clear the report data afterwards */\r
- memset(&JoystickReportData, 0, sizeof(JoystickReportData));\r
- }\r
+ /* Create the next HID report to send to the host */\r
+ GetNextReport(&JoystickReportData);\r
+ \r
+ /* Write Joystick Report Data */\r
+ Endpoint_Write_Stream_LE(&JoystickReportData, sizeof(JoystickReportData));\r
+\r
+ /* Finalize the stream transfer to send the last packet */\r
+ Endpoint_ClearIN();\r
+ \r
+ /* Clear the report data afterwards */\r
+ memset(&JoystickReportData, 0, sizeof(JoystickReportData));\r
}\r
}\r
/** Function to manage HID report generation and transmission to the host, when in report mode. */\r
void HID_Task(void)\r
{\r
- /* Check if the USB system is connected to a host */\r
- if (USB_IsConnected)\r
- {\r
- /* Send the next keypress report to the host */\r
- SendNextReport();\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+ \r
+ /* Send the next keypress report to the host */\r
+ SendNextReport();\r
\r
- /* Process the LED report sent from the host */\r
- ReceiveNextReport();\r
- }\r
+ /* Process the LED report sent from the host */\r
+ ReceiveNextReport();\r
}\r
{\r
uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+\r
/* Check if board button is not pressed, if so mouse mode enabled */\r
if (!(Buttons_GetStatus() & BUTTONS_BUTTON1))\r
{\r
if (JoyStatus_LCL & JOY_PRESS)\r
KeyboardReportData.KeyCode[0] = 0x08; // E\r
}\r
- \r
- /* Check if the USB system is connected to a host and report protocol mode is enabled */\r
- if (USB_IsConnected)\r
+\r
+ /* Select the Keyboard Report Endpoint */\r
+ Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM);\r
+\r
+ /* Check if Keyboard Endpoint Ready for Read/Write */\r
+ if (Endpoint_IsReadWriteAllowed())\r
{\r
- /* Select the Keyboard Report Endpoint */\r
- Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM);\r
-\r
- /* Check if Keyboard Endpoint Ready for Read/Write */\r
- if (Endpoint_IsReadWriteAllowed())\r
- {\r
- /* Write Keyboard Report Data */\r
- Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData));\r
-\r
- /* Finalize the stream transfer to send the last packet */\r
- Endpoint_ClearIN();\r
-\r
- /* Clear the report data afterwards */\r
- memset(&KeyboardReportData, 0, sizeof(KeyboardReportData));\r
- }\r
-\r
- /* Select the Keyboard LED Report Endpoint */\r
- Endpoint_SelectEndpoint(KEYBOARD_OUT_EPNUM);\r
-\r
- /* Check if Keyboard LED Endpoint Ready for Read/Write */\r
- if (Endpoint_IsReadWriteAllowed())\r
- { \r
- /* Read in the LED report from the host */\r
- uint8_t LEDStatus = Endpoint_Read_Byte();\r
- uint8_t LEDMask = LEDS_LED2;\r
- \r
- if (LEDStatus & 0x01) // NUM Lock\r
- LEDMask |= LEDS_LED1;\r
- \r
- if (LEDStatus & 0x02) // CAPS Lock\r
- LEDMask |= LEDS_LED3;\r
+ /* Write Keyboard Report Data */\r
+ Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData));\r
+\r
+ /* Finalize the stream transfer to send the last packet */\r
+ Endpoint_ClearIN();\r
+\r
+ /* Clear the report data afterwards */\r
+ memset(&KeyboardReportData, 0, sizeof(KeyboardReportData));\r
+ }\r
+\r
+ /* Select the Keyboard LED Report Endpoint */\r
+ Endpoint_SelectEndpoint(KEYBOARD_OUT_EPNUM);\r
+\r
+ /* Check if Keyboard LED Endpoint Ready for Read/Write */\r
+ if (Endpoint_IsReadWriteAllowed())\r
+ { \r
+ /* Read in the LED report from the host */\r
+ uint8_t LEDStatus = Endpoint_Read_Byte();\r
+ uint8_t LEDMask = LEDS_LED2;\r
+ \r
+ if (LEDStatus & 0x01) // NUM Lock\r
+ LEDMask |= LEDS_LED1;\r
+ \r
+ if (LEDStatus & 0x02) // CAPS Lock\r
+ LEDMask |= LEDS_LED3;\r
\r
- if (LEDStatus & 0x04) // SCROLL Lock\r
- LEDMask |= LEDS_LED4;\r
+ if (LEDStatus & 0x04) // SCROLL Lock\r
+ LEDMask |= LEDS_LED4;\r
\r
- /* Set the status LEDs to the current Keyboard LED status */\r
- LEDs_SetAllLEDs(LEDMask);\r
+ /* Set the status LEDs to the current Keyboard LED status */\r
+ LEDs_SetAllLEDs(LEDMask);\r
\r
- /* Handshake the OUT Endpoint - clear endpoint and ready for next report */\r
- Endpoint_ClearOUT();\r
- }\r
+ /* Handshake the OUT Endpoint - clear endpoint and ready for next report */\r
+ Endpoint_ClearOUT();\r
}\r
}\r
\r
{\r
uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+\r
/* Check if board button is pressed, if so mouse mode enabled */\r
if (Buttons_GetStatus() & BUTTONS_BUTTON1)\r
{\r
MouseReportData.Button = (1 << 0);\r
}\r
\r
- /* Check if the USB system is connected to a host and report protocol mode is enabled */\r
- if (USB_IsConnected)\r
- {\r
- /* Select the Mouse Report Endpoint */\r
- Endpoint_SelectEndpoint(MOUSE_IN_EPNUM);\r
+ /* Select the Mouse Report Endpoint */\r
+ Endpoint_SelectEndpoint(MOUSE_IN_EPNUM);\r
\r
- /* Check if Mouse Endpoint Ready for Read/Write */\r
- if (Endpoint_IsReadWriteAllowed())\r
- {\r
- /* Write Mouse Report Data */\r
- Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData));\r
+ /* Check if Mouse Endpoint Ready for Read/Write */\r
+ if (Endpoint_IsReadWriteAllowed())\r
+ {\r
+ /* Write Mouse Report Data */\r
+ Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData));\r
\r
- /* Finalize the stream transfer to send the last packet */\r
- Endpoint_ClearIN();\r
+ /* Finalize the stream transfer to send the last packet */\r
+ Endpoint_ClearIN();\r
\r
- /* Clear the report data afterwards */\r
- memset(&MouseReportData, 0, sizeof(MouseReportData));\r
- }\r
+ /* Clear the report data afterwards */\r
+ memset(&MouseReportData, 0, sizeof(MouseReportData));\r
}\r
}\r
{\r
static uint8_t PrevJoystickStatus;\r
\r
- /* Select the MIDI IN stream */\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+\r
Endpoint_SelectEndpoint(MIDI_STREAM_IN_EPNUM);\r
\r
- /* Check if endpoint is ready to be written to */\r
if (Endpoint_IsINReady())\r
{\r
uint8_t MIDICommand = 0;\r
uint8_t MIDIPitch;\r
\r
- /* Get current joystick mask, XOR with previous to detect joystick changes */\r
uint8_t JoystickStatus = Joystick_GetStatus();\r
uint8_t JoystickChanges = (JoystickStatus ^ PrevJoystickStatus);\r
\r
/** Task to manage HID report generation and transmission to the host, when in report mode. */\r
void Mouse_Task(void)\r
{\r
- /* Check if the USB system is connected to a host */\r
- if (USB_IsConnected)\r
- {\r
- /* Send the next mouse report to the host */\r
- SendNextReport();\r
- }\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+ \r
+ /* Send the next mouse report to the host */\r
+ SendNextReport();\r
}\r
outgoing frames should be loaded into the FrameOUT structure. Both structures can only hold a single\r
Ethernet frame at a time, so the FrameInBuffer bool is used to indicate when the buffers contain data. */\r
\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+\r
/* Check if a frame has been written to the IN frame buffer */\r
if (FrameIN.FrameInBuffer)\r
{\r
/** Task to manage CDC data transmission and reception to and from the host, from and to the physical USART. */\r
void CDC_Task(void)\r
{\r
- if (USB_IsConnected)\r
- {\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+ \r
#if 0\r
- /* NOTE: Here you can use the notification endpoint to send back line state changes to the host, for the special RS-232\r
- handshake signal lines (and some error states), via the CONTROL_LINE_IN_* masks and the following code:\r
- */\r
+ /* NOTE: Here you can use the notification endpoint to send back line state changes to the host, for the special RS-232\r
+ handshake signal lines (and some error states), via the CONTROL_LINE_IN_* masks and the following code:\r
+ */\r
\r
- USB_Notification_Header_t Notification = (USB_Notification_Header_t)\r
- {\r
- .NotificationType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),\r
- .Notification = NOTIF_SerialState,\r
- .wValue = 0,\r
- .wIndex = 0,\r
- .wLength = sizeof(uint16_t),\r
- };\r
- \r
- uint16_t LineStateMask;\r
- \r
- // Set LineStateMask here to a mask of CONTROL_LINE_IN_* masks to set the input handshake line states to send to the host\r
+ USB_Notification_Header_t Notification = (USB_Notification_Header_t)\r
+ {\r
+ .NotificationType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .Notification = NOTIF_SerialState,\r
+ .wValue = 0,\r
+ .wIndex = 0,\r
+ .wLength = sizeof(uint16_t),\r
+ };\r
\r
- Endpoint_SelectEndpoint(CDC_NOTIFICATION_EPNUM);\r
- Endpoint_Write_Stream_LE(&Notification, sizeof(Notification));\r
- Endpoint_Write_Stream_LE(&LineStateMask, sizeof(LineStateMask));\r
- Endpoint_ClearIN();\r
+ uint16_t LineStateMask;\r
+ \r
+ // Set LineStateMask here to a mask of CONTROL_LINE_IN_* masks to set the input handshake line states to send to the host\r
+ \r
+ Endpoint_SelectEndpoint(CDC_NOTIFICATION_EPNUM);\r
+ Endpoint_Write_Stream_LE(&Notification, sizeof(Notification));\r
+ Endpoint_Write_Stream_LE(&LineStateMask, sizeof(LineStateMask));\r
+ Endpoint_ClearIN();\r
#endif\r
\r
- /* Select the Serial Rx Endpoint */\r
- Endpoint_SelectEndpoint(CDC_RX_EPNUM);\r
- \r
- /* Check to see if a packet has been received from the host */\r
- if (Endpoint_IsOUTReceived())\r
+ /* Select the Serial Rx Endpoint */\r
+ Endpoint_SelectEndpoint(CDC_RX_EPNUM);\r
+ \r
+ /* Check to see if a packet has been received from the host */\r
+ if (Endpoint_IsOUTReceived())\r
+ {\r
+ /* Read the bytes in from the endpoint into the buffer while space is available */\r
+ while (Endpoint_BytesInEndpoint() && (Rx_Buffer.Elements != BUFF_STATICSIZE))\r
{\r
- /* Read the bytes in from the endpoint into the buffer while space is available */\r
- while (Endpoint_BytesInEndpoint() && (Rx_Buffer.Elements != BUFF_STATICSIZE))\r
- {\r
- /* Store each character from the endpoint */\r
- Buffer_StoreElement(&Rx_Buffer, Endpoint_Read_Byte());\r
- }\r
- \r
- /* Check to see if all bytes in the current packet have been read */\r
- if (!(Endpoint_BytesInEndpoint()))\r
- {\r
- /* Clear the endpoint buffer */\r
- Endpoint_ClearOUT();\r
- }\r
+ /* Store each character from the endpoint */\r
+ Buffer_StoreElement(&Rx_Buffer, Endpoint_Read_Byte());\r
}\r
\r
- /* Check if Rx buffer contains data - if so, send it */\r
- if (Rx_Buffer.Elements)\r
- Serial_TxByte(Buffer_GetElement(&Rx_Buffer));\r
+ /* Check to see if all bytes in the current packet have been read */\r
+ if (!(Endpoint_BytesInEndpoint()))\r
+ {\r
+ /* Clear the endpoint buffer */\r
+ Endpoint_ClearOUT();\r
+ }\r
+ }\r
+ \r
+ /* Check if Rx buffer contains data - if so, send it */\r
+ if (Rx_Buffer.Elements)\r
+ Serial_TxByte(Buffer_GetElement(&Rx_Buffer));\r
+\r
+ /* Select the Serial Tx Endpoint */\r
+ Endpoint_SelectEndpoint(CDC_TX_EPNUM);\r
\r
- /* Select the Serial Tx Endpoint */\r
- Endpoint_SelectEndpoint(CDC_TX_EPNUM);\r
+ /* Check if the Tx buffer contains anything to be sent to the host */\r
+ if (Tx_Buffer.Elements)\r
+ {\r
+ /* Wait until Serial Tx Endpoint Ready for Read/Write */\r
+ while (!(Endpoint_IsReadWriteAllowed()));\r
+ \r
+ /* Write the bytes from the buffer to the endpoint while space is available */\r
+ while (Tx_Buffer.Elements && Endpoint_IsReadWriteAllowed())\r
+ {\r
+ /* Write each byte retreived from the buffer to the endpoint */\r
+ Endpoint_Write_Byte(Buffer_GetElement(&Tx_Buffer));\r
+ }\r
+ \r
+ /* Remember if the packet to send completely fills the endpoint */\r
+ bool IsFull = (Endpoint_BytesInEndpoint() == CDC_TXRX_EPSIZE);\r
+ \r
+ /* Send the data */\r
+ Endpoint_ClearIN();\r
\r
- /* Check if the Tx buffer contains anything to be sent to the host */\r
- if (Tx_Buffer.Elements)\r
+ /* If no more data to send and the last packet filled the endpoint, send an empty packet to release\r
+ * the buffer on the receiver (otherwise all data will be cached until a non-full packet is received) */\r
+ if (IsFull && !(Tx_Buffer.Elements))\r
{\r
/* Wait until Serial Tx Endpoint Ready for Read/Write */\r
while (!(Endpoint_IsReadWriteAllowed()));\r
- \r
- /* Write the bytes from the buffer to the endpoint while space is available */\r
- while (Tx_Buffer.Elements && Endpoint_IsReadWriteAllowed())\r
- {\r
- /* Write each byte retreived from the buffer to the endpoint */\r
- Endpoint_Write_Byte(Buffer_GetElement(&Tx_Buffer));\r
- }\r
- \r
- /* Remember if the packet to send completely fills the endpoint */\r
- bool IsFull = (Endpoint_BytesInEndpoint() == CDC_TXRX_EPSIZE);\r
- \r
- /* Send the data */\r
- Endpoint_ClearIN();\r
\r
- /* If no more data to send and the last packet filled the endpoint, send an empty packet to release\r
- * the buffer on the receiver (otherwise all data will be cached until a non-full packet is received) */\r
- if (IsFull && !(Tx_Buffer.Elements))\r
- {\r
- /* Wait until Serial Tx Endpoint Ready for Read/Write */\r
- while (!(Endpoint_IsReadWriteAllowed()));\r
-\r
- /* Send an empty packet to terminate the transfer */\r
- Endpoint_ClearIN();\r
- }\r
+ /* Send an empty packet to terminate the transfer */\r
+ Endpoint_ClearIN();\r
}\r
}\r
}\r
{\r
SetupHardware();\r
\r
- puts_P(PSTR(ESC_FG_CYAN "CDC Host Demo running.\r\n"));\r
+ puts_P(PSTR(ESC_FG_CYAN "CDC Host Demo running.\r\n" ESC_FG_WHITE));\r
\r
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
\r
{\r
case HOST_STATE_Addressed:\r
if (!(CDC_Host_ConfigurePipes(&VirtualSerial_CDC_Interface)))\r
- LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
- \r
+ {\r
+ LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
+ }\r
+ \r
USB_HostState = HOST_STATE_Configured;\r
break;\r
case HOST_STATE_Configured:\r
{\r
USB_ShutDown();\r
\r
- puts_P(PSTR(ESC_FG_RED "Host Mode Error\r\n" ESC_FG_WHITE));\r
- printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode);\r
+ puts_P(PSTR(ESC_FG_RED "Host Mode Error\r\n"));\r
+ printf_P(PSTR(" -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode);\r
\r
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
for(;;);\r
\r
Printer_Data_t TestPageData =\r
{\r
- "\033%-12345X\033E LUFA PCL Test Page \033E\033%-12345X",\r
+ "\033%-12345X\033E" "LUFA PCL Test Page" "\033E\033%-12345X",\r
(sizeof(TestPageData.Data) - 1)\r
};\r
\r
\r
void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)\r
{\r
- if (!(USB_IsConnected))\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
return;\r
\r
Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber);\r
\r
void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)\r
{\r
- if (!(USB_IsConnected))\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
return;\r
\r
Endpoint_SelectEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber);\r
\r
void MS_Device_USBTask(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)\r
{\r
- if (!(USB_IsConnected))\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
return;\r
\r
Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpointNumber);\r
\r
void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo)\r
{\r
- if (!(USB_IsConnected))\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
return;\r
\r
RNDIS_Message_Header_t* MessageHeader = (RNDIS_Message_Header_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;\r