Add FatFS library to the Webserver project, extend the HTTP server so that it now...
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Device / CDC.c
index e9457f7..b8a673f 100644 (file)
@@ -1,13 +1,13 @@
 /*\r
              LUFA Library\r
-     Copyright (C) Dean Camera, 2009.\r
+     Copyright (C) Dean Camera, 2010.\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
-  Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
@@ -190,10 +190,17 @@ uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterface
 \r
        Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber);\r
 \r
-       if (Endpoint_IsOUTReceived() && !(Endpoint_BytesInEndpoint()))\r
-         Endpoint_ClearOUT();\r
+       if (Endpoint_IsOUTReceived())\r
+       {\r
+               if (!(Endpoint_BytesInEndpoint()))\r
+                 Endpoint_ClearOUT();\r
 \r
-       return Endpoint_BytesInEndpoint();\r
+               return Endpoint_BytesInEndpoint();\r
+       }\r
+       else\r
+       {\r
+               return 0;\r
+       }\r
 }\r
 \r
 uint8_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)\r
@@ -263,6 +270,9 @@ static int CDC_Device_getchar_Blocking(FILE* Stream)
 {\r
        while (!(CDC_Device_BytesReceived((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream))))\r
        {\r
+               if (USB_DeviceState == DEVICE_STATE_Unattached)\r
+                 return _FDEV_EOF;\r
+       \r
                CDC_Device_USBTask((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream));\r
                USB_USBTask();\r
        }\r