X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/9991321321d30ca9383d795ea7e796098c92045f..5e787a4bb04f8a27f9300077361403adf2e92b3f:/Demos/USBtoSerial/USBtoSerial.c diff --git a/Demos/USBtoSerial/USBtoSerial.c b/Demos/USBtoSerial/USBtoSerial.c index 7c06007a3..0cef8d193 100644 --- a/Demos/USBtoSerial/USBtoSerial.c +++ b/Demos/USBtoSerial/USBtoSerial.c @@ -116,6 +116,10 @@ EVENT_HANDLER(USB_Disconnect) /* 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); @@ -322,8 +326,12 @@ ISR(USART1_TX_vect, ISR_BLOCK) */ ISR(USART1_RX_vect, ISR_BLOCK) { - /* Character received, store it into the buffer */ - Buffer_StoreElement(&Tx_Buffer, UDR1); + /* Only store received characters if the USB interface is connected */ + if (USB_IsConnected) + { + /* Character received, store it into the buffer */ + Buffer_StoreElement(&Tx_Buffer, UDR1); + } } /** Function to manage status updates to the user. This is done via LEDs on the given board, if available, but may be changed to