Fixed broken USE_RAM_DESCRIPTORS compile time option when the FIXED_NUM_CONFIGURATION...
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Device / PrinterClassDevice.c
index 5a87f20..bd4f8e9 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2013.
+     Copyright (C) Dean Camera, 2015.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2013  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2015  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
@@ -59,7 +59,7 @@ void PRNT_Device_ProcessControlRequest(USB_ClassInfo_PRNT_Device_t* const PRNTIn
                                }
 
                                uint16_t IEEEStringLen = strlen(PRNTInterfaceInfo->Config.IEEE1284String);
                                }
 
                                uint16_t IEEEStringLen = strlen(PRNTInterfaceInfo->Config.IEEE1284String);
-                               Endpoint_Write_16_BE(IEEEStringLen + 1);
+                               Endpoint_Write_16_BE(IEEEStringLen);
                                Endpoint_Write_Control_Stream_LE(PRNTInterfaceInfo->Config.IEEE1284String, IEEEStringLen);
                                Endpoint_ClearStatusStage();
                        }
                                Endpoint_Write_Control_Stream_LE(PRNTInterfaceInfo->Config.IEEE1284String, IEEEStringLen);
                                Endpoint_ClearStatusStage();
                        }
@@ -87,6 +87,8 @@ void PRNT_Device_ProcessControlRequest(USB_ClassInfo_PRNT_Device_t* const PRNTIn
                                Endpoint_ClearSETUP();
                                Endpoint_ClearStatusStage();
 
                                Endpoint_ClearSETUP();
                                Endpoint_ClearStatusStage();
 
+                               PRNTInterfaceInfo->State.IsPrinterReset = true;
+
                                EVENT_PRNT_Device_SoftReset(PRNTInterfaceInfo);
                        }
 
                                EVENT_PRNT_Device_SoftReset(PRNTInterfaceInfo);
                        }
 
@@ -122,6 +124,21 @@ void PRNT_Device_USBTask(USB_ClassInfo_PRNT_Device_t* const PRNTInterfaceInfo)
        if (Endpoint_IsINReady())
          PRNT_Device_Flush(PRNTInterfaceInfo);
        #endif
        if (Endpoint_IsINReady())
          PRNT_Device_Flush(PRNTInterfaceInfo);
        #endif
+
+       if (PRNTInterfaceInfo->State.IsPrinterReset)
+       {
+               Endpoint_ResetEndpoint(PRNTInterfaceInfo->Config.DataOUTEndpoint.Address);
+               Endpoint_ResetEndpoint(PRNTInterfaceInfo->Config.DataINEndpoint.Address);
+
+               Endpoint_SelectEndpoint(PRNTInterfaceInfo->Config.DataOUTEndpoint.Address);
+               Endpoint_ClearStall();
+               Endpoint_ResetDataToggle();
+               Endpoint_SelectEndpoint(PRNTInterfaceInfo->Config.DataINEndpoint.Address);
+               Endpoint_ClearStall();
+               Endpoint_ResetDataToggle();
+
+               PRNTInterfaceInfo->State.IsPrinterReset = false;
+       }
 }
 
 uint8_t PRNT_Device_SendString(USB_ClassInfo_PRNT_Device_t* const PRNTInterfaceInfo,
 }
 
 uint8_t PRNT_Device_SendString(USB_ClassInfo_PRNT_Device_t* const PRNTInterfaceInfo,