diff options
Diffstat (limited to 'Demos/Host/ClassDriver/PrinterHost/PrinterHost.c')
-rw-r--r-- | Demos/Host/ClassDriver/PrinterHost/PrinterHost.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c b/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c index 66c4f1302..2d776fd5d 100644 --- a/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c +++ b/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + 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 + 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 + 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 @@ -33,7 +33,7 @@ * Main source file for the PrinterHost demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "PrinterHost.h" /** LUFA Printer Class driver interface configuration and state information. This structure is @@ -46,7 +46,7 @@ USB_ClassInfo_PRNT_Host_t Printer_PRNT_Interface = { .DataINPipeNumber = 1, .DataINPipeDoubleBank = false, - + .DataOUTPipeNumber = 2, .DataOUTPipeDoubleBank = false, }, @@ -70,7 +70,7 @@ int main(void) { case HOST_STATE_Addressed: LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); - + uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; @@ -91,7 +91,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { puts_P(PSTR("Error Setting Device Configuration.\r\n")); @@ -99,7 +99,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (PRNT_Host_SetBidirectionalMode(&Printer_PRNT_Interface) != HOST_SENDCONTROL_Successful) { puts_P(PSTR("Error Setting Bidirectional Mode.\r\n")); @@ -107,16 +107,16 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + 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); - + puts_P(PSTR("Retrieving Device ID...\r\n")); - + char DeviceIDString[300]; if (PRNT_Host_GetDeviceID(&Printer_PRNT_Interface, DeviceIDString, sizeof(DeviceIDString)) != HOST_SENDCONTROL_Successful) @@ -126,12 +126,12 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + 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); - + printf_P(PSTR("Sending Test Page (%d bytes)...\r\n"), TestPageLength); if (PRNT_Host_SendString(&Printer_PRNT_Interface, &TestPageData, TestPageLength) != PIPE_RWSTREAM_NoError) @@ -148,7 +148,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + PRNT_Host_USBTask(&Printer_PRNT_Interface); USB_USBTask(); } @@ -218,6 +218,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } + |