- /* Process Printer specific control requests */
- switch (USB_ControlRequest.bRequest)
- {
- case PRNT_REQ_GetDeviceID:
- if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
- {
- /* Generic printer IEEE 1284 identification string, will bind to an in-built driver on
- * Windows systems, and will fall-back to a text-only printer driver on *nix.
- */
- const char PrinterIDString[] =
- "MFG:Generic;"
- "MDL:Generic_/_Text_Only;"
- "CMD:1284.4;"
- "CLS:PRINTER";
-
- Endpoint_ClearSETUP();
-
- while (!(Endpoint_IsINReady()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
-
- Endpoint_Write_16_BE(sizeof(PrinterIDString));
- Endpoint_Write_Control_Stream_LE(PrinterIDString, strlen(PrinterIDString));
- Endpoint_ClearStatusStage();
- }
-
- break;
- case PRNT_REQ_GetPortStatus:
- if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
- {
- Endpoint_ClearSETUP();
-
- while (!(Endpoint_IsINReady()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
-
- Endpoint_Write_8(PRNT_PORTSTATUS_NOTERROR | PRNT_PORTSTATUS_SELECT);
- Endpoint_ClearStatusStage();
- }
-
- break;
- case PRNT_REQ_SoftReset:
- if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
- {
- Endpoint_ClearSETUP();
- Endpoint_ClearStatusStage();
- }
-
- break;
- }