aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Host/Incomplete/PrinterHost/PrinterHost.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-07-19 09:36:16 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-07-19 09:36:16 +0000
commitd3fb6273aa59c60f2d3f41de321c35ff08ef8feb (patch)
treefc27c982e19dbae0ee230d2df89708621b529d63 /Demos/Host/Incomplete/PrinterHost/PrinterHost.c
parent9d2613d90868b59ac48ccce8b652819d5cd388d5 (diff)
downloadlufa-d3fb6273aa59c60f2d3f41de321c35ff08ef8feb.tar.gz
lufa-d3fb6273aa59c60f2d3f41de321c35ff08ef8feb.tar.bz2
lufa-d3fb6273aa59c60f2d3f41de321c35ff08ef8feb.zip
Fix PrinterHost demo so that it will only enumerate printers with Bidirectional protocol encapsulation. Change enumeration code to automatically select the correct alternate setting for the printer interface to select the bidirectional protocol.
Diffstat (limited to 'Demos/Host/Incomplete/PrinterHost/PrinterHost.c')
-rw-r--r--Demos/Host/Incomplete/PrinterHost/PrinterHost.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/Demos/Host/Incomplete/PrinterHost/PrinterHost.c b/Demos/Host/Incomplete/PrinterHost/PrinterHost.c
index 80fca259c..643f919c9 100644
--- a/Demos/Host/Incomplete/PrinterHost/PrinterHost.c
+++ b/Demos/Host/Incomplete/PrinterHost/PrinterHost.c
@@ -36,8 +36,6 @@
#include "PrinterHost.h"
-uint8_t PrinterProtocol;
-
int main(void)
{
@@ -150,12 +148,37 @@ void USB_Printer_Host(void)
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
}
-
+
+ /* Some printers use alternate settings to determine the communication protocol used - if so, send a SetInterface
+ * request to switch to the interface alternate setting with the Bidirection protocol */
+ if (PrinterAltSetting)
+ {
+ USB_ControlRequest = (USB_Request_Header_t)
+ {
+ bmRequestType: (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE),
+ bRequest: REQ_SetInterface,
+ wValue: PrinterAltSetting,
+ wIndex: PrinterInterfaceNumber,
+ wLength: 0,
+ };
+
+ if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)
+ {
+ puts_P(PSTR("Control Error (Set Interface).\r\n"));
+ printf_P(PSTR(" -- Error Code: %d\r\n"), ErrorCode);
+
+ /* Indicate error via status LEDs */
+ LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
+
+ /* Wait until USB device disconnected */
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
+ break;
+ }
+ }
+
USB_HostState = HOST_STATE_Configured;
break;
case HOST_STATE_Configured:
- printf_P(PSTR("Printer Protocol: %d\r\n"), PrinterProtocol);
-
puts_P(PSTR("Retrieving Device ID...\r\n"));
Device_ID_String_t DeviceIDString;