aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2013-05-05 19:32:07 +0000
committerDean Camera <dean@fourwalledcubicle.com>2013-05-05 19:32:07 +0000
commit961da384f985f81e7e0127d4f271ad8bf4817917 (patch)
treeb210c6a2cbe4ab504b28c9b9ff7c6a9b7ad8ce23 /LUFA
parent95ba6527a5e764a430c3917b4e24e48699976fa9 (diff)
downloadlufa-961da384f985f81e7e0127d4f271ad8bf4817917.tar.gz
lufa-961da384f985f81e7e0127d4f271ad8bf4817917.tar.bz2
lufa-961da384f985f81e7e0127d4f271ad8bf4817917.zip
Add proper reset handling to the USB Printer Device Class driver.
Diffstat (limited to 'LUFA')
-rw-r--r--LUFA/Drivers/USB/Class/Device/PrinterClassDevice.c19
-rw-r--r--LUFA/Drivers/USB/Class/Device/PrinterClassDevice.h12
2 files changed, 27 insertions, 4 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.c b/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.c
index 5a87f2073..3d34047eb 100644
--- a/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.c
+++ b/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.c
@@ -59,7 +59,7 @@ void PRNT_Device_ProcessControlRequest(USB_ClassInfo_PRNT_Device_t* const PRNTIn
}
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();
}
@@ -87,6 +87,8 @@ void PRNT_Device_ProcessControlRequest(USB_ClassInfo_PRNT_Device_t* const PRNTIn
Endpoint_ClearSETUP();
Endpoint_ClearStatusStage();
+ PRNTInterfaceInfo->State.IsPrinterReset = true;
+
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 (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,
diff --git a/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.h b/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.h
index bcb892f41..1c50a9803 100644
--- a/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.h
+++ b/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.h
@@ -87,14 +87,20 @@
USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */
char* IEEE1284String; /**< IEEE 1284 identification string, sent to the host during enumeration
- * to identify the printer model, manufacturer and other characteristics. */
+ * to identify the printer model, manufacturer and other characteristics.
+ */
} Config; /**< Config data for the USB class interface within the device. All elements in this section
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
*/
struct
{
uint8_t PortStatus; /**< Current status of the Printer virtual port, a collection of \c PRNT_PORTSTATUS_*
- * bitmask values. */
+ * bitmask values.
+ */
+
+ volatile bool IsPrinterReset; /**< Flag indicating that the host has requested that the Printer interface be reset
+ * and that all current Mass Storage operations should immediately abort.
+ */
} State; /**< State data for the USB class interface within the device. All elements in this section
* are reset to their defaults when the interface is enumerated.
*/
@@ -131,7 +137,7 @@
*
* \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class configuration and state.
*/
- void EVENT_PRNT_Device_SoftReset(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
+ void EVENT_PRNT_Device_SoftReset(USB_ClassInfo_PRNT_Device_t* const PRNTInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Sends a given data buffer to the attached USB host, if connected. If a host is not connected when the function is
* called, the string is discarded. Bytes will be queued for transmission to the host until either the endpoint bank