Commit 3a85962f authored by Dean Camera's avatar Dean Camera
Browse files

Fix USBtoSerial device demos -- ensure the UDR1 register contents is read in...

Fix USBtoSerial device demos -- ensure the UDR1 register contents is read in under all circumstances which fire the ISR, so that the receive complete interrupt is cleared correctly to prevent freezes.
parent b71ff7c8
......@@ -147,8 +147,10 @@ void EVENT_USB_Device_UnhandledControlPacket(void)
*/
ISR(USART1_RX_vect, ISR_BLOCK)
{
uint8_t ReceivedByte = UDR1;
if (USB_DeviceState == DEVICE_STATE_Configured)
Buffer_StoreElement(&Tx_Buffer, UDR1);
Buffer_StoreElement(&Tx_Buffer, ReceivedByte);
}
/** Event handler for the CDC Class driver Line Encoding Changed event.
......
......@@ -296,9 +296,11 @@ void CDC_Task(void)
*/
ISR(USART1_RX_vect, ISR_BLOCK)
{
uint8_t ReceivedByte = UDR1;
/* Only store received characters if the USB interface is connected */
if ((USB_DeviceState != DEVICE_STATE_Configured) && LineEncoding.BaudRateBPS)
Buffer_StoreElement(&Tx_Buffer, UDR1);
Buffer_StoreElement(&Tx_Buffer, ReceivedByte);
}
/** Reconfigures the USART to match the current serial port settings issued by the host as closely as possible. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment