CI: Build on Arch (bleeding-ege) and Ubuntu (stable) AVR-GCC toolchains.
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Device / PrinterClassDevice.c
index 5a87f20..3e60ddd 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2013.
+     Copyright (C) Dean Camera, 2018.
 
   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 2018  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,
@@ -288,7 +305,7 @@ static int PRNT_Device_getchar_Blocking(FILE* Stream)
 }
 #endif
 
 }
 #endif
 
-void PRNT_Device_Event_Stub(void)
+void PRNT_Device_Event_Stub(USB_ClassInfo_PRNT_Device_t* const PRNTInterfaceInfo)
 {
 
 }
 {
 
 }