USBtoSerial demo now discards all Rx data when not connected to a USB host, rather...
authorDean Camera <dean@fourwalledcubicle.com>
Mon, 23 Feb 2009 09:30:29 +0000 (09:30 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Mon, 23 Feb 2009 09:30:29 +0000 (09:30 +0000)
Demos/USBtoSerial/USBtoSerial.c
LUFA/ChangeLog.txt

index 7c06007..0cef8d1 100644 (file)
@@ -116,6 +116,10 @@ EVENT_HANDLER(USB_Disconnect)
        /* Stop running CDC and USB management tasks */\r
        Scheduler_SetTaskMode(CDC_Task, TASK_STOP);\r
        Scheduler_SetTaskMode(USB_USBTask, TASK_STOP);\r
        /* Stop running CDC and USB management tasks */\r
        Scheduler_SetTaskMode(CDC_Task, TASK_STOP);\r
        Scheduler_SetTaskMode(USB_USBTask, TASK_STOP);\r
+       \r
+       /* Reset Tx and Rx buffers, device disconnected */\r
+       Buffer_Initialize(&Rx_Buffer);\r
+       Buffer_Initialize(&Tx_Buffer);\r
 \r
        /* Indicate USB not ready */\r
        UpdateStatus(Status_USBNotReady);\r
 \r
        /* Indicate USB not ready */\r
        UpdateStatus(Status_USBNotReady);\r
@@ -322,8 +326,12 @@ ISR(USART1_TX_vect, ISR_BLOCK)
  */\r
 ISR(USART1_RX_vect, ISR_BLOCK)\r
 {\r
  */\r
 ISR(USART1_RX_vect, ISR_BLOCK)\r
 {\r
-       /* Character received, store it into the buffer */\r
-       Buffer_StoreElement(&Tx_Buffer, UDR1);\r
+       /* Only store received characters if the USB interface is connected */\r
+       if (USB_IsConnected)\r
+       {\r
+               /* Character received, store it into the buffer */\r
+               Buffer_StoreElement(&Tx_Buffer, UDR1);\r
+       }\r
 }\r
 \r
 /** Function to manage status updates to the user. This is done via LEDs on the given board, if available, but may be changed to\r
 }\r
 \r
 /** Function to manage status updates to the user. This is done via LEDs on the given board, if available, but may be changed to\r
index 830e31e..fd21b3f 100644 (file)
@@ -19,6 +19,8 @@
   *    slowed down the enumeration of HID devices too much\r
   *  - Increased the number of bits per track which can be read in the MagStripe project to 20480 when compiled for the AT90USBXXX6/7\r
   *  - Fixed KeyboardMouse demo discarding the wIndex value in the REQ_GetReport request\r
   *    slowed down the enumeration of HID devices too much\r
   *  - Increased the number of bits per track which can be read in the MagStripe project to 20480 when compiled for the AT90USBXXX6/7\r
   *  - Fixed KeyboardMouse demo discarding the wIndex value in the REQ_GetReport request\r
+  *  - USBtoSerial demo now discards all Rx data when not connected to a USB host, rather than buffering characters for transmission\r
+  *    next time the device is attached to a host.\r
   *\r
   *  \section Sec_ChangeLog090209 Version 090209\r
   *\r
   *\r
   *  \section Sec_ChangeLog090209 Version 090209\r
   *\r