Use puts_P() and printf_P() instead of the normal variants where possible in the Host mode Class Driver demos.

pull/1469/head
Dean Camera 15 years ago
parent 0063f72117
commit 9e34144c9b

@ -14,16 +14,16 @@
# code. # code.
all: all:
make -C 'DFU/' clean make -C DFU clean
make -C 'DFU/' all make -C DFU all
make -C 'CDC/' clean make -C CDC clean
make -C 'CDC/' all make -C CDC all
make -C 'TeensyHID/' clean make -C TeensyHID clean
make -C 'TeensyHID/' all make -C TeensyHID all
%: %:
make -C 'DFU/' $@ make -C DFU $@
make -C 'CDC/' $@ make -C CDC $@
make -C 'TeensyHID/' $@ make -C TeensyHID $@

@ -14,5 +14,5 @@
# code. # code.
%: %:
make -C ClassDriver/ $@ make -C ClassDriver $@
make -C LowLevel/ $@ make -C LowLevel $@

@ -85,7 +85,7 @@ int main(void)
if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,
sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -94,7 +94,7 @@ int main(void)
if (HID_Host_ConfigurePipes(&Joystick_HID_Interface, if (HID_Host_ConfigurePipes(&Joystick_HID_Interface,
ConfigDescriptorSize, ConfigDescriptorData) != HID_ENUMERROR_NoError) ConfigDescriptorSize, ConfigDescriptorData) != HID_ENUMERROR_NoError)
{ {
printf("Attached Device Not a Valid Joystick.\r\n"); puts_P(PSTR("Attached Device Not a Valid Joystick.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -102,7 +102,7 @@ int main(void)
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -110,13 +110,13 @@ int main(void)
if (HID_Host_SetReportProtocol(&Joystick_HID_Interface) != 0) if (HID_Host_SetReportProtocol(&Joystick_HID_Interface) != 0)
{ {
printf("Error Setting Report Protocol Mode or Not a Valid Joystick.\r\n"); puts_P(PSTR("Error Setting Report Protocol Mode or Not a Valid Joystick.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("Joystick Enumerated.\r\n"); puts_P(PSTR("Joystick Enumerated.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_READY); LEDs_SetAllLEDs(LEDMASK_USB_READY);
USB_HostState = HOST_STATE_Configured; USB_HostState = HOST_STATE_Configured;
break; break;

@ -80,7 +80,7 @@ int main(void)
if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,
sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -89,7 +89,7 @@ int main(void)
if (HID_Host_ConfigurePipes(&Keyboard_HID_Interface, if (HID_Host_ConfigurePipes(&Keyboard_HID_Interface,
ConfigDescriptorSize, ConfigDescriptorData) != HID_ENUMERROR_NoError) ConfigDescriptorSize, ConfigDescriptorData) != HID_ENUMERROR_NoError)
{ {
printf("Attached Device Not a Valid Keyboard.\r\n"); puts_P(PSTR("Attached Device Not a Valid Keyboard.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -97,7 +97,7 @@ int main(void)
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -105,13 +105,13 @@ int main(void)
if (HID_Host_SetBootProtocol(&Keyboard_HID_Interface) != 0) if (HID_Host_SetBootProtocol(&Keyboard_HID_Interface) != 0)
{ {
printf("Could not Set Boot Protocol Mode.\r\n"); puts_P(PSTR("Could not Set Boot Protocol Mode.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("Keyboard Enumerated.\r\n"); puts_P(PSTR("Keyboard Enumerated.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_READY); LEDs_SetAllLEDs(LEDMASK_USB_READY);
USB_HostState = HOST_STATE_Configured; USB_HostState = HOST_STATE_Configured;
break; break;

@ -85,7 +85,7 @@ int main(void)
if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,
sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -94,7 +94,7 @@ int main(void)
if (HID_Host_ConfigurePipes(&Keyboard_HID_Interface, if (HID_Host_ConfigurePipes(&Keyboard_HID_Interface,
ConfigDescriptorSize, ConfigDescriptorData) != HID_ENUMERROR_NoError) ConfigDescriptorSize, ConfigDescriptorData) != HID_ENUMERROR_NoError)
{ {
printf("Attached Device Not a Valid Keyboard.\r\n"); puts_P(PSTR("Attached Device Not a Valid Keyboard.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -102,7 +102,7 @@ int main(void)
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -110,13 +110,13 @@ int main(void)
if (HID_Host_SetReportProtocol(&Keyboard_HID_Interface) != 0) if (HID_Host_SetReportProtocol(&Keyboard_HID_Interface) != 0)
{ {
printf("Error Setting Report Protocol Mode or Not a Valid Keyboard.\r\n"); puts_P(PSTR("Error Setting Report Protocol Mode or Not a Valid Keyboard.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("Keyboard Enumerated.\r\n"); puts_P(PSTR("Keyboard Enumerated.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_READY); LEDs_SetAllLEDs(LEDMASK_USB_READY);
USB_HostState = HOST_STATE_Configured; USB_HostState = HOST_STATE_Configured;
break; break;

@ -78,7 +78,7 @@ int main(void)
if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,
sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -87,7 +87,7 @@ int main(void)
if (MIDI_Host_ConfigurePipes(&Keyboard_MIDI_Interface, if (MIDI_Host_ConfigurePipes(&Keyboard_MIDI_Interface,
ConfigDescriptorSize, ConfigDescriptorData) != MIDI_ENUMERROR_NoError) ConfigDescriptorSize, ConfigDescriptorData) != MIDI_ENUMERROR_NoError)
{ {
printf("Attached Device Not a Valid MIDI Class Device.\r\n"); puts_P(PSTR("Attached Device Not a Valid MIDI Class Device.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -95,13 +95,13 @@ int main(void)
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("MIDI Device Enumerated.\r\n"); puts_P(PSTR("MIDI Device Enumerated.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_READY); LEDs_SetAllLEDs(LEDMASK_USB_READY);
USB_HostState = HOST_STATE_Configured; USB_HostState = HOST_STATE_Configured;
break; break;

@ -78,7 +78,7 @@ int main(void)
if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,
sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -87,7 +87,7 @@ int main(void)
if (MS_Host_ConfigurePipes(&FlashDisk_MS_Interface, if (MS_Host_ConfigurePipes(&FlashDisk_MS_Interface,
ConfigDescriptorSize, ConfigDescriptorData) != MS_ENUMERROR_NoError) ConfigDescriptorSize, ConfigDescriptorData) != MS_ENUMERROR_NoError)
{ {
printf("Attached Device Not a Valid Mass Storage Device.\r\n"); puts_P(PSTR("Attached Device Not a Valid Mass Storage Device.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -95,13 +95,13 @@ int main(void)
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("Mass Storage Device Enumerated.\r\n"); puts_P(PSTR("Mass Storage Device Enumerated.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_READY); LEDs_SetAllLEDs(LEDMASK_USB_READY);
USB_HostState = HOST_STATE_Configured; USB_HostState = HOST_STATE_Configured;
break; break;
@ -111,17 +111,17 @@ int main(void)
uint8_t MaxLUNIndex; uint8_t MaxLUNIndex;
if (MS_Host_GetMaxLUN(&FlashDisk_MS_Interface, &MaxLUNIndex)) if (MS_Host_GetMaxLUN(&FlashDisk_MS_Interface, &MaxLUNIndex))
{ {
printf("Error retrieving max LUN index.\r\n"); puts_P(PSTR("Error retrieving max LUN index.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("Total LUNs: %d - Using first LUN in device.\r\n", (MaxLUNIndex + 1)); printf_P(PSTR("Total LUNs: %d - Using first LUN in device.\r\n"), (MaxLUNIndex + 1));
if (MS_Host_ResetMSInterface(&FlashDisk_MS_Interface)) if (MS_Host_ResetMSInterface(&FlashDisk_MS_Interface))
{ {
printf("Error resetting Mass Storage interface.\r\n"); puts_P(PSTR("Error resetting Mass Storage interface.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -130,7 +130,7 @@ int main(void)
SCSI_Request_Sense_Response_t SenseData; SCSI_Request_Sense_Response_t SenseData;
if (MS_Host_RequestSense(&FlashDisk_MS_Interface, 0, &SenseData) != 0) if (MS_Host_RequestSense(&FlashDisk_MS_Interface, 0, &SenseData) != 0)
{ {
printf("Error retrieving device sense.\r\n"); puts_P(PSTR("Error retrieving device sense.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -138,7 +138,7 @@ int main(void)
if (MS_Host_PreventAllowMediumRemoval(&FlashDisk_MS_Interface, 0, true)) if (MS_Host_PreventAllowMediumRemoval(&FlashDisk_MS_Interface, 0, true))
{ {
printf("Error setting Prevent Device Removal bit.\r\n"); puts_P(PSTR("Error setting Prevent Device Removal bit.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -147,15 +147,15 @@ int main(void)
SCSI_Inquiry_Response_t InquiryData; SCSI_Inquiry_Response_t InquiryData;
if (MS_Host_GetInquiryData(&FlashDisk_MS_Interface, 0, &InquiryData)) if (MS_Host_GetInquiryData(&FlashDisk_MS_Interface, 0, &InquiryData))
{ {
printf("Error retrieving device Inquiry data.\r\n"); puts_P(PSTR("Error retrieving device Inquiry data.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("Vendor \"%.8s\", Product \"%.16s\"\r\n", InquiryData.VendorID, InquiryData.ProductID); printf_P(PSTR("Vendor \"%.8s\", Product \"%.16s\"\r\n"), InquiryData.VendorID, InquiryData.ProductID);
printf("Waiting until ready...\r\n"); puts_P(PSTR("Waiting until ready...\r\n"));
for (;;) for (;;)
{ {
@ -167,37 +167,37 @@ int main(void)
/* Check if an error other than a logical command error (device busy) received */ /* Check if an error other than a logical command error (device busy) received */
if (ErrorCode != MS_ERROR_LOGICAL_CMD_FAILED) if (ErrorCode != MS_ERROR_LOGICAL_CMD_FAILED)
{ {
printf("Error waiting for device to be ready.\r\n"); puts_P(PSTR("Error waiting for device to be ready.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
} }
printf("Retrieving Capacity... "); puts_P(PSTR("Retrieving Capacity...\r\n"));
SCSI_Capacity_t DiskCapacity; SCSI_Capacity_t DiskCapacity;
if (MS_Host_ReadDeviceCapacity(&FlashDisk_MS_Interface, 0, &DiskCapacity)) if (MS_Host_ReadDeviceCapacity(&FlashDisk_MS_Interface, 0, &DiskCapacity))
{ {
printf("Error retrieving device capacity.\r\n"); puts_P(PSTR("Error retrieving device capacity.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("%lu blocks of %lu bytes.\r\n", DiskCapacity.Blocks, DiskCapacity.BlockSize); printf_P(PSTR("%lu blocks of %lu bytes.\r\n"), DiskCapacity.Blocks, DiskCapacity.BlockSize);
uint8_t BlockBuffer[DiskCapacity.BlockSize]; uint8_t BlockBuffer[DiskCapacity.BlockSize];
if (MS_Host_ReadDeviceBlocks(&FlashDisk_MS_Interface, 0, 0x00000000, 1, DiskCapacity.BlockSize, BlockBuffer)) if (MS_Host_ReadDeviceBlocks(&FlashDisk_MS_Interface, 0, 0x00000000, 1, DiskCapacity.BlockSize, BlockBuffer))
{ {
printf("Error reading device block.\r\n"); puts_P(PSTR("Error reading device block.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("\r\nContents of first block:\r\n"); puts_P(PSTR("\r\nContents of first block:"));
for (uint16_t Chunk = 0; Chunk < (DiskCapacity.BlockSize >> 4); Chunk++) for (uint16_t Chunk = 0; Chunk < (DiskCapacity.BlockSize >> 4); Chunk++)
{ {
@ -210,7 +210,7 @@ int main(void)
printf_P(PSTR("%.2X "), CurrByte); printf_P(PSTR("%.2X "), CurrByte);
} }
printf(" "); printf_P(PSTR(" "));
/* Print out the 16 bytes of the chunk in ASCII format */ /* Print out the 16 bytes of the chunk in ASCII format */
for (uint8_t ByteOffset = 0; ByteOffset < (1 << 4); ByteOffset++) for (uint8_t ByteOffset = 0; ByteOffset < (1 << 4); ByteOffset++)
@ -219,7 +219,7 @@ int main(void)
putchar(isprint(CurrByte) ? CurrByte : '.'); putchar(isprint(CurrByte) ? CurrByte : '.');
} }
printf("\r\n"); printf_P(PSTR("\r\n"));
} }
LEDs_SetAllLEDs(LEDMASK_USB_READY); LEDs_SetAllLEDs(LEDMASK_USB_READY);

@ -80,7 +80,7 @@ int main(void)
if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,
sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -89,7 +89,7 @@ int main(void)
if (HID_Host_ConfigurePipes(&Mouse_HID_Interface, if (HID_Host_ConfigurePipes(&Mouse_HID_Interface,
ConfigDescriptorSize, ConfigDescriptorData) != HID_ENUMERROR_NoError) ConfigDescriptorSize, ConfigDescriptorData) != HID_ENUMERROR_NoError)
{ {
printf("Attached Device Not a Valid Mouse.\r\n"); puts_P(PSTR("Attached Device Not a Valid Mouse.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -97,7 +97,7 @@ int main(void)
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -105,13 +105,13 @@ int main(void)
if (HID_Host_SetBootProtocol(&Mouse_HID_Interface) != 0) if (HID_Host_SetBootProtocol(&Mouse_HID_Interface) != 0)
{ {
printf("Could not Set Boot Protocol Mode.\r\n"); puts_P(PSTR("Could not Set Boot Protocol Mode.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("Mouse Enumerated.\r\n"); puts_P(PSTR("Mouse Enumerated.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_READY); LEDs_SetAllLEDs(LEDMASK_USB_READY);
USB_HostState = HOST_STATE_Configured; USB_HostState = HOST_STATE_Configured;
break; break;

@ -85,7 +85,7 @@ int main(void)
if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,
sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -94,7 +94,7 @@ int main(void)
if (HID_Host_ConfigurePipes(&Mouse_HID_Interface, if (HID_Host_ConfigurePipes(&Mouse_HID_Interface,
ConfigDescriptorSize, ConfigDescriptorData) != HID_ENUMERROR_NoError) ConfigDescriptorSize, ConfigDescriptorData) != HID_ENUMERROR_NoError)
{ {
printf("Attached Device Not a Valid Mouse.\r\n"); puts_P(PSTR("Attached Device Not a Valid Mouse.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -102,7 +102,7 @@ int main(void)
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -110,13 +110,13 @@ int main(void)
if (HID_Host_SetReportProtocol(&Mouse_HID_Interface) != 0) if (HID_Host_SetReportProtocol(&Mouse_HID_Interface) != 0)
{ {
printf("Error Setting Report Protocol Mode or Not a Valid Mouse.\r\n"); puts_P(PSTR("Error Setting Report Protocol Mode or Not a Valid Mouse.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("Mouse Enumerated.\r\n"); puts_P(PSTR("Mouse Enumerated.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_READY); LEDs_SetAllLEDs(LEDMASK_USB_READY);
USB_HostState = HOST_STATE_Configured; USB_HostState = HOST_STATE_Configured;
break; break;

@ -77,7 +77,7 @@ int main(void)
if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,
sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -86,7 +86,7 @@ int main(void)
if (PRNT_Host_ConfigurePipes(&Printer_PRNT_Interface, if (PRNT_Host_ConfigurePipes(&Printer_PRNT_Interface,
ConfigDescriptorSize, ConfigDescriptorData) != PRNT_ENUMERROR_NoError) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -94,7 +94,7 @@ int main(void)
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -102,32 +102,32 @@ int main(void)
if (PRNT_Host_SetBidirectionalMode(&Printer_PRNT_Interface) != HOST_SENDCONTROL_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("Printer Device Enumerated.\r\n"); puts_P(PSTR("Printer Device Enumerated.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_READY); LEDs_SetAllLEDs(LEDMASK_USB_READY);
USB_HostState = HOST_STATE_Configured; USB_HostState = HOST_STATE_Configured;
break; break;
case HOST_STATE_Configured: case HOST_STATE_Configured:
LEDs_SetAllLEDs(LEDMASK_USB_BUSY); LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
printf("Retrieving Device ID...\r\n"); puts_P(PSTR("Retrieving Device ID...\r\n"));
char DeviceIDString[300]; char DeviceIDString[300];
if (PRNT_Host_GetDeviceID(&Printer_PRNT_Interface, DeviceIDString, if (PRNT_Host_GetDeviceID(&Printer_PRNT_Interface, DeviceIDString,
sizeof(DeviceIDString)) != HOST_SENDCONTROL_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; 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"; char TestPageData[] = "\033%-12345X\033E" "LUFA PCL Test Page" "\033E\033%-12345X";
uint16_t TestPageLength = strlen(TestPageData); uint16_t TestPageLength = strlen(TestPageData);
@ -136,7 +136,7 @@ int main(void)
if (PRNT_Host_SendData(&Printer_PRNT_Interface, &TestPageData, TestPageLength) != PIPE_RWSTREAM_NoError) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;

@ -85,7 +85,7 @@ int main(void)
if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,
sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -94,7 +94,7 @@ int main(void)
if (RNDIS_Host_ConfigurePipes(&Ethernet_RNDIS_Interface, if (RNDIS_Host_ConfigurePipes(&Ethernet_RNDIS_Interface,
ConfigDescriptorSize, ConfigDescriptorData) != RNDIS_ENUMERROR_NoError) ConfigDescriptorSize, ConfigDescriptorData) != RNDIS_ENUMERROR_NoError)
{ {
printf("Attached Device Not a Valid RNDIS Class Device.\r\n"); puts_P(PSTR("Attached Device Not a Valid RNDIS Class Device.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -102,7 +102,7 @@ int main(void)
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -110,20 +110,20 @@ int main(void)
if (RNDIS_Host_InitializeDevice(&Ethernet_RNDIS_Interface) != HOST_SENDCONTROL_Successful) if (RNDIS_Host_InitializeDevice(&Ethernet_RNDIS_Interface) != HOST_SENDCONTROL_Successful)
{ {
printf("Error Initializing Device.\r\n"); puts_P(PSTR("Error Initializing Device.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("Device Max Transfer Size: %lu bytes.\r\n", Ethernet_RNDIS_Interface.State.DeviceMaxPacketSize); printf_P(PSTR("Device Max Transfer Size: %lu bytes.\r\n"), Ethernet_RNDIS_Interface.State.DeviceMaxPacketSize);
uint32_t PacketFilter = (REMOTE_NDIS_PACKET_DIRECTED | REMOTE_NDIS_PACKET_BROADCAST | REMOTE_NDIS_PACKET_ALL_MULTICAST); uint32_t PacketFilter = (REMOTE_NDIS_PACKET_DIRECTED | REMOTE_NDIS_PACKET_BROADCAST | REMOTE_NDIS_PACKET_ALL_MULTICAST);
if (RNDIS_Host_SetRNDISProperty(&Ethernet_RNDIS_Interface, OID_GEN_CURRENT_PACKET_FILTER, if (RNDIS_Host_SetRNDISProperty(&Ethernet_RNDIS_Interface, OID_GEN_CURRENT_PACKET_FILTER,
&PacketFilter, sizeof(PacketFilter)) != HOST_SENDCONTROL_Successful) &PacketFilter, sizeof(PacketFilter)) != HOST_SENDCONTROL_Successful)
{ {
printf("Error Setting Device Packet Filter.\r\n"); puts_P(PSTR("Error Setting Device Packet Filter.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
@ -134,16 +134,16 @@ int main(void)
if (RNDIS_Host_QueryRNDISProperty(&Ethernet_RNDIS_Interface, OID_GEN_VENDOR_ID, if (RNDIS_Host_QueryRNDISProperty(&Ethernet_RNDIS_Interface, OID_GEN_VENDOR_ID,
&VendorID, sizeof(VendorID)) != HOST_SENDCONTROL_Successful) &VendorID, sizeof(VendorID)) != HOST_SENDCONTROL_Successful)
{ {
printf("Error Getting Vendor ID.\r\n"); puts_P(PSTR("Error Getting Vendor ID.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("Device Vendor ID: 0x%08lX\r\n", VendorID); printf_P(PSTR("Device Vendor ID: 0x%08lX\r\n"), VendorID);
printf("RNDIS Device Enumerated.\r\n"); puts_P(PSTR("RNDIS Device Enumerated.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_READY); LEDs_SetAllLEDs(LEDMASK_USB_READY);
USB_HostState = HOST_STATE_Configured; USB_HostState = HOST_STATE_Configured;
break; break;
@ -168,12 +168,12 @@ void PrintIncomingPackets(void)
uint16_t PacketLength; uint16_t PacketLength;
RNDIS_Host_ReadPacket(&Ethernet_RNDIS_Interface, &PacketBuffer, &PacketLength); RNDIS_Host_ReadPacket(&Ethernet_RNDIS_Interface, &PacketBuffer, &PacketLength);
printf("***PACKET (Size %d)***\r\n", PacketLength); printf_P(PSTR("***PACKET (Size %d)***\r\n"), PacketLength);
for (uint16_t i = 0; i < PacketLength; i++) for (uint16_t i = 0; i < PacketLength; i++)
printf("%02x ", PacketBuffer[i]); printf("%02x ", PacketBuffer[i]);
printf("\r\n\r\n"); printf_P(PSTR("\r\n\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_READY); LEDs_SetAllLEDs(LEDMASK_USB_READY);
} }

@ -80,7 +80,7 @@ int main(void)
if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,
sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -89,7 +89,7 @@ int main(void)
if (SImage_Host_ConfigurePipes(&DigitalCamera_SI_Interface, if (SImage_Host_ConfigurePipes(&DigitalCamera_SI_Interface,
ConfigDescriptorSize, ConfigDescriptorData) != SI_ENUMERROR_NoError) ConfigDescriptorSize, ConfigDescriptorData) != SI_ENUMERROR_NoError)
{ {
printf("Attached Device Not a Valid Still Image Class Device.\r\n"); puts_P(PSTR("Attached Device Not a Valid Still Image Class Device.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -97,43 +97,43 @@ int main(void)
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("Still Image Device Enumerated.\r\n"); puts_P(PSTR("Still Image Device Enumerated.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_READY); LEDs_SetAllLEDs(LEDMASK_USB_READY);
USB_HostState = HOST_STATE_Configured; USB_HostState = HOST_STATE_Configured;
break; break;
case HOST_STATE_Configured: case HOST_STATE_Configured:
printf("Opening Session...\r\n"); puts_P(PSTR("Opening Session...\r\n"));
if (SImage_Host_OpenSession(&DigitalCamera_SI_Interface) != PIPE_RWSTREAM_NoError) if (SImage_Host_OpenSession(&DigitalCamera_SI_Interface) != PIPE_RWSTREAM_NoError)
{ {
printf("Could not open PIMA session.\r\n"); puts_P(PSTR("Could not open PIMA session.\r\n"));
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("Turning off Device...\r\n"); puts_P(PSTR("Turning off Device...\r\n"));
SImage_Host_SendCommand(&DigitalCamera_SI_Interface, 0x1013, 0, NULL); SImage_Host_SendCommand(&DigitalCamera_SI_Interface, 0x1013, 0, NULL);
if (SImage_Host_ReceiveResponse(&DigitalCamera_SI_Interface)) if (SImage_Host_ReceiveResponse(&DigitalCamera_SI_Interface))
{ {
printf("Could not turn off device.\r\n"); puts_P(PSTR("Could not turn off device.\r\n"));
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("Device Off.\r\n"); puts_P(PSTR("Device Off.\r\n"));
printf("Closing Session...\r\n"); puts_P(PSTR("Closing Session...\r\n"));
if (SImage_Host_CloseSession(&DigitalCamera_SI_Interface) != PIPE_RWSTREAM_NoError) if (SImage_Host_CloseSession(&DigitalCamera_SI_Interface) != PIPE_RWSTREAM_NoError)
{ {
printf("Could not close PIMA session.\r\n"); puts_P(PSTR("Could not close PIMA session.\r\n"));
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }

@ -80,7 +80,7 @@ int main(void)
if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,
sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -89,7 +89,7 @@ int main(void)
if (CDC_Host_ConfigurePipes(&VirtualSerial_CDC_Interface, if (CDC_Host_ConfigurePipes(&VirtualSerial_CDC_Interface,
ConfigDescriptorSize, ConfigDescriptorData) != CDC_ENUMERROR_NoError) ConfigDescriptorSize, ConfigDescriptorData) != CDC_ENUMERROR_NoError)
{ {
printf("Attached Device Not a Valid CDC Class Device.\r\n"); puts_P(PSTR("Attached Device Not a Valid CDC Class Device.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_ERROR); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
@ -97,13 +97,13 @@ int main(void)
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) 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); LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval; USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break; break;
} }
printf("CDC Device Enumerated.\r\n"); puts_P(PSTR("CDC Device Enumerated.\r\n"));
LEDs_SetAllLEDs(LEDMASK_USB_READY); LEDs_SetAllLEDs(LEDMASK_USB_READY);
USB_HostState = HOST_STATE_Configured; USB_HostState = HOST_STATE_Configured;
break; break;

@ -14,5 +14,5 @@
# code. # code.
%: %:
make -C ClassDriver/ $@ make -C ClassDriver $@
make -C LowLevel/ $@ make -C LowLevel $@

@ -14,6 +14,6 @@
# code. # code.
%: %:
make -C Device/ $@ make -C Device $@
make -C Host/ $@ make -C Host $@
make -C DualRole/ $@ make -C DualRole $@

@ -164,18 +164,18 @@
* \param[in,out] Data Pointer to a number containing an even number of bytes to be reversed * \param[in,out] Data Pointer to a number containing an even number of bytes to be reversed
* \param[in] Bytes Length of the data in bytes * \param[in] Bytes Length of the data in bytes
*/ */
static inline void SwapEndian_n(uint8_t* Data, uint8_t Bytes); static inline void SwapEndian_n(void* Data, uint8_t Bytes);
static inline void SwapEndian_n(uint8_t* Data, uint8_t Bytes) static inline void SwapEndian_n(void* Data, uint8_t Bytes)
{ {
uint8_t Temp; uint8_t* CurrDataPos = Data;
while (Bytes) while (Bytes)
{ {
Temp = *Data; uint8_t Temp = *CurrDataPos;
*Data = *(Data + Bytes - 1); *CurrDataPos = *(CurrDataPos + Bytes - 1);
*(Data + Bytes - 1) = Temp; *(CurrDataPos + Bytes - 1) = Temp;
Data++; CurrDataPos++;
Bytes -= 2; Bytes -= 2;
} }
} }

@ -134,6 +134,7 @@ static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInf
{ {
uint8_t ErrorCode = PIPE_RWSTREAM_NoError; uint8_t ErrorCode = PIPE_RWSTREAM_NoError;
SCSICommandBlock->Signature = CBW_SIGNATURE;
SCSICommandBlock->Tag = ++MSInterfaceInfo->State.TransactionTag; SCSICommandBlock->Tag = ++MSInterfaceInfo->State.TransactionTag;
if (MSInterfaceInfo->State.TransactionTag == 0xFFFFFFFF) if (MSInterfaceInfo->State.TransactionTag == 0xFFFFFFFF)
@ -334,7 +335,6 @@ uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, c
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{ {
.Signature = CBW_SIGNATURE,
.DataTransferLength = sizeof(SCSI_Inquiry_Response_t), .DataTransferLength = sizeof(SCSI_Inquiry_Response_t),
.Flags = COMMAND_DIRECTION_DATA_IN, .Flags = COMMAND_DIRECTION_DATA_IN,
.LUN = LUNIndex, .LUN = LUNIndex,
@ -370,7 +370,6 @@ uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, co
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{ {
.Signature = CBW_SIGNATURE,
.DataTransferLength = 0, .DataTransferLength = 0,
.Flags = COMMAND_DIRECTION_DATA_IN, .Flags = COMMAND_DIRECTION_DATA_IN,
.LUN = LUNIndex, .LUN = LUNIndex,
@ -407,7 +406,6 @@ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInf
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{ {
.Signature = CBW_SIGNATURE,
.DataTransferLength = sizeof(SCSI_Capacity_t), .DataTransferLength = sizeof(SCSI_Capacity_t),
.Flags = COMMAND_DIRECTION_DATA_IN, .Flags = COMMAND_DIRECTION_DATA_IN,
.LUN = LUNIndex, .LUN = LUNIndex,
@ -432,8 +430,8 @@ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInf
if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, DeviceCapacity)) != PIPE_RWSTREAM_NoError) if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, DeviceCapacity)) != PIPE_RWSTREAM_NoError)
return ErrorCode; return ErrorCode;
DeviceCapacity->Blocks = SwapEndian_32(DeviceCapacity->Blocks); SwapEndian_n(&DeviceCapacity->Blocks, sizeof(DeviceCapacity->Blocks));
DeviceCapacity->BlockSize = SwapEndian_32(DeviceCapacity->BlockSize); SwapEndian_n(&DeviceCapacity->BlockSize, sizeof(DeviceCapacity->BlockSize));
if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError) if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
return ErrorCode; return ErrorCode;
@ -451,7 +449,6 @@ uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, con
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{ {
.Signature = CBW_SIGNATURE,
.DataTransferLength = sizeof(SCSI_Request_Sense_Response_t), .DataTransferLength = sizeof(SCSI_Request_Sense_Response_t),
.Flags = COMMAND_DIRECTION_DATA_IN, .Flags = COMMAND_DIRECTION_DATA_IN,
.LUN = LUNIndex, .LUN = LUNIndex,
@ -488,7 +485,6 @@ uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* const MSInter
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{ {
.Signature = CBW_SIGNATURE,
.DataTransferLength = 0, .DataTransferLength = 0,
.Flags = COMMAND_DIRECTION_DATA_OUT, .Flags = COMMAND_DIRECTION_DATA_OUT,
.LUN = LUNIndex, .LUN = LUNIndex,
@ -525,7 +521,6 @@ uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{ {
.Signature = CBW_SIGNATURE,
.DataTransferLength = ((uint32_t)Blocks * BlockSize), .DataTransferLength = ((uint32_t)Blocks * BlockSize),
.Flags = COMMAND_DIRECTION_DATA_IN, .Flags = COMMAND_DIRECTION_DATA_IN,
.LUN = LUNIndex, .LUN = LUNIndex,
@ -566,7 +561,6 @@ uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{ {
.Signature = CBW_SIGNATURE,
.DataTransferLength = ((uint32_t)Blocks * BlockSize), .DataTransferLength = ((uint32_t)Blocks * BlockSize),
.Flags = COMMAND_DIRECTION_DATA_OUT, .Flags = COMMAND_DIRECTION_DATA_OUT,
.LUN = LUNIndex, .LUN = LUNIndex,

@ -29,6 +29,7 @@
* builds of avrdude at the expense of AVRStudio compatibility * builds of avrdude at the expense of AVRStudio compatibility
* - Removed two-step endpoint/pipe bank clear and switch sequence for smaller, faster endpoint/pipe code * - Removed two-step endpoint/pipe bank clear and switch sequence for smaller, faster endpoint/pipe code
* - The USB_Init() function no longer calls sei() - the user is now responsible for enabling interrupts when they are ready * - The USB_Init() function no longer calls sei() - the user is now responsible for enabling interrupts when they are ready
* for them to be enabled (thanks to Andrei Krainev)
* *
* <b>Fixed:</b> * <b>Fixed:</b>
* - Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin * - Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin

@ -18,9 +18,9 @@ all:
%: %:
@echo Executing \"make $@\" on all LUFA library elements. @echo Executing \"make $@\" on all LUFA library elements.
@echo @echo
make -C LUFA/ $@ -s make -C LUFA $@ -s
make -C Demos/ $@ -s make -C Demos $@ -s
make -C Projects/ $@ -s make -C Projects $@ -s
make -C Bootloaders/ $@ -s make -C Bootloaders $@ -s
@echo @echo
@echo LUFA \"make $@\" operation complete. @echo LUFA \"make $@\" operation complete.

Loading…
Cancel
Save