Fix TeensyHID bootloader for the largest AVRs - only the ATMEGA128x needs the alterna...
[pub/USBasp.git] / Demos / Host / ClassDriver / PrinterHost / PrinterHost.c
index adbf187..df71f4c 100644 (file)
@@ -1,13 +1,13 @@
 /*\r
              LUFA Library\r
 /*\r
              LUFA Library\r
-     Copyright (C) Dean Camera, 2009.\r
+     Copyright (C) Dean Camera, 2010.\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
-  Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
@@ -62,6 +62,7 @@ int main(void)
        puts_P(PSTR(ESC_FG_CYAN "Printer Host Demo running.\r\n" ESC_FG_WHITE));\r
 \r
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
        puts_P(PSTR(ESC_FG_CYAN "Printer Host Demo running.\r\n" ESC_FG_WHITE));\r
 \r
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
+       sei();\r
 \r
        for (;;)\r
        {\r
 \r
        for (;;)\r
        {\r
@@ -76,7 +77,7 @@ int main(void)
                                if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,\r
                                                                       sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful)\r
                                {\r
                                if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,\r
                                                                       sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful)\r
                                {\r
-                                       printf("Error Retrieving Configuration Descriptor.\r\n");\r
+                                       puts_P(PSTR("Error Retrieving Configuration Descriptor.\r\n"));\r
                                        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
                                        USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                        break;\r
                                        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
                                        USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                        break;\r
@@ -85,7 +86,7 @@ int main(void)
                                if (PRNT_Host_ConfigurePipes(&Printer_PRNT_Interface,\r
                                                             ConfigDescriptorSize, ConfigDescriptorData) != PRNT_ENUMERROR_NoError)\r
                                {\r
                                if (PRNT_Host_ConfigurePipes(&Printer_PRNT_Interface,\r
                                                             ConfigDescriptorSize, ConfigDescriptorData) != PRNT_ENUMERROR_NoError)\r
                                {\r
-                                       printf("Attached Device Not a Valid Printer Class Device.\r\n");\r
+                                       puts_P(PSTR("Attached Device Not a Valid Printer Class Device.\r\n"));\r
                                        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
                                        USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                        break;\r
                                        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
                                        USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                        break;\r
@@ -93,7 +94,7 @@ int main(void)
                                \r
                                if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)\r
                                {\r
                                \r
                                if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)\r
                                {\r
-                                       printf("Error Setting Device Configuration.\r\n");\r
+                                       puts_P(PSTR("Error Setting Device Configuration.\r\n"));\r
                                        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
                                        USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                        break;\r
                                        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
                                        USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                        break;\r
@@ -101,31 +102,32 @@ int main(void)
                                \r
                                if (PRNT_Host_SetBidirectionalMode(&Printer_PRNT_Interface) != HOST_SENDCONTROL_Successful)\r
                                {\r
                                \r
                                if (PRNT_Host_SetBidirectionalMode(&Printer_PRNT_Interface) != HOST_SENDCONTROL_Successful)\r
                                {\r
-                                       printf("Error Setting Bidirectional Mode.\r\n");\r
+                                       puts_P(PSTR("Error Setting Bidirectional Mode.\r\n"));\r
                                        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
                                        USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                        break;\r
                                }\r
                                \r
                                        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
                                        USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                        break;\r
                                }\r
                                \r
-                               printf("Printer Device Enumerated.\r\n");\r
+                               puts_P(PSTR("Printer Device Enumerated.\r\n"));\r
+                               LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
                                USB_HostState = HOST_STATE_Configured;\r
                                break;\r
                        case HOST_STATE_Configured:\r
                                LEDs_SetAllLEDs(LEDMASK_USB_BUSY);\r
                                \r
                                USB_HostState = HOST_STATE_Configured;\r
                                break;\r
                        case HOST_STATE_Configured:\r
                                LEDs_SetAllLEDs(LEDMASK_USB_BUSY);\r
                                \r
-                               printf("Retrieving Device ID...\r\n");\r
+                               puts_P(PSTR("Retrieving Device ID...\r\n"));\r
                                \r
                                char DeviceIDString[300];\r
                                if (PRNT_Host_GetDeviceID(&Printer_PRNT_Interface, DeviceIDString,\r
                                                          sizeof(DeviceIDString)) != HOST_SENDCONTROL_Successful)\r
                                {\r
                                \r
                                char DeviceIDString[300];\r
                                if (PRNT_Host_GetDeviceID(&Printer_PRNT_Interface, DeviceIDString,\r
                                                          sizeof(DeviceIDString)) != HOST_SENDCONTROL_Successful)\r
                                {\r
-                                       printf("Error Getting Device ID.\r\n");\r
+                                       puts_P(PSTR("Error Getting Device ID.\r\n"));\r
                                        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
                                        USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                        break;\r
                                }\r
                                \r
                                        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
                                        USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                        break;\r
                                }\r
                                \r
-                               printf("Device ID: %s.\r\n", DeviceIDString);\r
+                               printf_P(PSTR("Device ID: %s.\r\n"), DeviceIDString);\r
                                \r
                                char  TestPageData[]    = "\033%-12345X\033E" "LUFA PCL Test Page" "\033E\033%-12345X";\r
                                uint16_t TestPageLength = strlen(TestPageData);\r
                                \r
                                char  TestPageData[]    = "\033%-12345X\033E" "LUFA PCL Test Page" "\033E\033%-12345X";\r
                                uint16_t TestPageLength = strlen(TestPageData);\r
@@ -134,7 +136,7 @@ int main(void)
 \r
                                if (PRNT_Host_SendData(&Printer_PRNT_Interface, &TestPageData, TestPageLength) != PIPE_RWSTREAM_NoError)\r
                                {\r
 \r
                                if (PRNT_Host_SendData(&Printer_PRNT_Interface, &TestPageData, TestPageLength) != PIPE_RWSTREAM_NoError)\r
                                {\r
-                                       printf("Error Sending Page Data.\r\n");\r
+                                       puts_P(PSTR("Error Sending Page Data.\r\n"));\r
                                        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
                                        USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                        break;\r
                                        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
                                        USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                        break;\r