X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/8ba51f090f7cafb36e1108cc58e68f5d71bc13c0..2a2de8fea94d2a524e988725585b17746cd30dba:/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c diff --git a/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c b/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c index f854e1bf7..df71f4cb2 100644 --- a/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c +++ b/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c @@ -1,21 +1,21 @@ /* LUFA Library - Copyright (C) Dean Camera, 2009. + Copyright (C) Dean Camera, 2010. dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ /* - Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + Copyright 2010 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 + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -45,7 +45,10 @@ USB_ClassInfo_PRNT_Host_t Printer_PRNT_Interface = .Config = { .DataINPipeNumber = 1, + .DataINPipeDoubleBank = false, + .DataOUTPipeNumber = 2, + .DataOUTPipeDoubleBank = false, }, }; @@ -59,6 +62,7 @@ int main(void) puts_P(PSTR(ESC_FG_CYAN "Printer Host Demo running.\r\n" ESC_FG_WHITE)); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); + sei(); for (;;) { @@ -70,10 +74,10 @@ int main(void) uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; - if (USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, - sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) + if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, + sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) { - printf("Error Retrieving Configuration Descriptor.\r\n"); + puts_P(PSTR("Error Retrieving Configuration Descriptor.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; @@ -82,7 +86,7 @@ int main(void) if (PRNT_Host_ConfigurePipes(&Printer_PRNT_Interface, ConfigDescriptorSize, ConfigDescriptorData) != PRNT_ENUMERROR_NoError) { - printf("Attached Device Not a Valid Printer Class Device.\r\n"); + puts_P(PSTR("Attached Device Not a Valid Printer Class Device.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; @@ -90,7 +94,7 @@ int main(void) if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { - printf("Error Setting Device Configuration.\r\n"); + puts_P(PSTR("Error Setting Device Configuration.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; @@ -98,31 +102,32 @@ int main(void) if (PRNT_Host_SetBidirectionalMode(&Printer_PRNT_Interface) != HOST_SENDCONTROL_Successful) { - printf("Error Setting Bidirectional Mode.\r\n"); + puts_P(PSTR("Error Setting Bidirectional Mode.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - printf("Printer Device Enumerated.\r\n"); + puts_P(PSTR("Printer Device Enumerated.\r\n")); + LEDs_SetAllLEDs(LEDMASK_USB_READY); USB_HostState = HOST_STATE_Configured; break; case HOST_STATE_Configured: LEDs_SetAllLEDs(LEDMASK_USB_BUSY); - printf("Retrieving Device ID...\r\n"); + puts_P(PSTR("Retrieving Device ID...\r\n")); char DeviceIDString[300]; if (PRNT_Host_GetDeviceID(&Printer_PRNT_Interface, DeviceIDString, sizeof(DeviceIDString)) != HOST_SENDCONTROL_Successful) { - printf("Error Getting Device ID.\r\n"); + puts_P(PSTR("Error Getting Device ID.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - printf("Device ID: %s.\r\n", DeviceIDString); + printf_P(PSTR("Device ID: %s.\r\n"), DeviceIDString); char TestPageData[] = "\033%-12345X\033E" "LUFA PCL Test Page" "\033E\033%-12345X"; uint16_t TestPageLength = strlen(TestPageData); @@ -131,7 +136,7 @@ int main(void) if (PRNT_Host_SendData(&Printer_PRNT_Interface, &TestPageData, TestPageLength) != PIPE_RWSTREAM_NoError) { - printf("Error Sending Page Data.\r\n"); + puts_P(PSTR("Error Sending Page Data.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break;