diff --git a/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h b/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h index 89e21bbaff8a05778df9f0def549da28d86adf4a..3f477ede470264e9260e2df884011e3cddc141b9 100644 --- a/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h +++ b/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h @@ -56,11 +56,13 @@ #define VIRTUAL_MEMORY_BYTES ((uint32_t)DATAFLASH_PAGES * DATAFLASH_PAGE_SIZE * DATAFLASH_TOTALCHIPS) /** Block size of the device. This is kept at 512 to remain compatible with the OS despite the underlying - * storage media (Dataflash) using a different native block size. + * storage media (Dataflash) using a different native block size. Do not change this value. */ #define VIRTUAL_MEMORY_BLOCK_SIZE 512 - /** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. */ + /** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. Do not + * change this value; change VIRTUAL_MEMORY_BYTES instead to alter the media size. + */ #define VIRTUAL_MEMORY_BLOCKS (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE) /* Function Prototypes: */ diff --git a/Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.h b/Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.h index b7b5a1e7855c48dbba8188ac0603d4369edc7a86..cfba56d3cb904cead1ff5e3f8712c8f7ad1620a2 100644 --- a/Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.h +++ b/Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.h @@ -56,11 +56,13 @@ #define VIRTUAL_MEMORY_BYTES ((uint32_t)DATAFLASH_PAGES * DATAFLASH_PAGE_SIZE * DATAFLASH_TOTALCHIPS) /** Block size of the device. This is kept at 512 to remain compatible with the OS despite the underlying - * storage media (Dataflash) using a different native block size. + * storage media (Dataflash) using a different native block size. Do not change this value. */ #define VIRTUAL_MEMORY_BLOCK_SIZE 512 - /** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. */ + /** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. Do not + * change this value; change VIRTUAL_MEMORY_BYTES instead to alter the media size. + */ #define VIRTUAL_MEMORY_BLOCKS (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE) /* Function Prototypes: */ diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c index d89807461c973535508457e8f0ba6b78c2f2d7ac..e9af0c0b2bfd9d15696c114a0f00077faa92bd2e 100644 --- a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c +++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c @@ -106,7 +106,7 @@ int main(void) if (USB_HID_Host_SetReportProtocol(&Keyboard_HID_Interface) != 0) { - printf("Could not Set Report Protocol Mode.\r\n"); + printf("Error Setting Report Protocol Mode or Not a Valid Keyboard.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; @@ -114,7 +114,7 @@ int main(void) LEDs_SetAllLEDs(LEDS_NO_LEDS); - printf("HID Device Enumerated.\r\n"); + printf("Keyboard Enumerated.\r\n"); USB_HostState = HOST_STATE_Configured; break; case HOST_STATE_Configured: diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c index c33b2ebde862cb29748d33a37edeb3830e73ec99..f222eee41f82566fb7a77cff17da03e5ee139697 100644 --- a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c +++ b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c @@ -106,7 +106,7 @@ int main(void) if (USB_HID_Host_SetReportProtocol(&Mouse_HID_Interface) != 0) { - printf("Could not Set Report Protocol Mode.\r\n"); + printf("Error Setting Report Protocol Mode or Not a Valid Mouse.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; @@ -114,7 +114,7 @@ int main(void) LEDs_SetAllLEDs(LEDS_NO_LEDS); - printf("HID Device Enumerated.\r\n"); + printf("Mouse Enumerated.\r\n"); USB_HostState = HOST_STATE_Configured; break; case HOST_STATE_Configured: diff --git a/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c b/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c index 3b97ad7ed77b8a87190938de530e7df27b252810..0cba5fccded7ce48e43c508f55213cc02d7d49b8 100644 --- a/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c +++ b/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c @@ -172,7 +172,11 @@ void Keyboard_HID_Task(void) if ((ErrorCode = GetHIDReportData()) != ParseSuccessful) { puts_P(PSTR(ESC_FG_RED "Report Parse Error.\r\n")); - printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); + + if (!(HIDReportInfo->TotalReportItems)) + puts_P(PSTR("Not a valid Keyboard." ESC_FG_WHITE)); + else + printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -200,7 +204,7 @@ void Keyboard_HID_Task(void) ((ReportSizeFeatureBits >> 3) + ((ReportSizeFeatureBits & 0x07) != 0))); } - puts_P(PSTR("HID Device Enumerated.\r\n")); + puts_P(PSTR("Keyboard Enumerated.\r\n")); USB_HostState = HOST_STATE_Configured; break; diff --git a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c index 4d50ff6ab0ea9557cf1ba6ff1ebf5a2f4c728566..b47858e31b97ae90cc71e2a199ea25904dafa560 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c +++ b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c @@ -171,8 +171,12 @@ void Mouse_HID_Task(void) /* Get and process the device's first HID report descriptor */ if ((ErrorCode = GetHIDReportData()) != ParseSuccessful) { - printf_P(PSTR(ESC_FG_RED "Report Parse Error.\r\n" - " -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); + puts_P(PSTR(ESC_FG_RED "Report Parse Error.\r\n")); + + if (!(HIDReportInfo->TotalReportItems)) + puts_P(PSTR("Not a valid Mouse." ESC_FG_WHITE)); + else + printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -200,7 +204,7 @@ void Mouse_HID_Task(void) ((ReportSizeFeatureBits >> 3) + ((ReportSizeFeatureBits & 0x07) != 0))); } - puts_P(PSTR("HID Device Enumerated.\r\n")); + puts_P(PSTR("Mouse Enumerated.\r\n")); USB_HostState = HOST_STATE_Configured; break; diff --git a/LUFA/Drivers/USB/Class/Host/HIDParser.c b/LUFA/Drivers/USB/Class/Host/HIDParser.c index 450f6afb03feacb359c6db0c2119a3c9a01dd6de..4d433e56e245f97e4ad692cbbc1debd405a090b3 100644 --- a/LUFA/Drivers/USB/Class/Host/HIDParser.c +++ b/LUFA/Drivers/USB/Class/Host/HIDParser.c @@ -296,6 +296,9 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID } } + if (!(ParserData->TotalReportItems)) + return HID_PARSE_NoUnfilteredReportItems; + return HID_PARSE_Successful; } diff --git a/LUFA/Drivers/USB/Class/Host/HIDParser.h b/LUFA/Drivers/USB/Class/Host/HIDParser.h index 2ee3f7032d26b8cdb8f515e3e42c43ffee8bc124..4322c5106e1cfbe9396766314df886b0d8ab836f 100644 --- a/LUFA/Drivers/USB/Class/Host/HIDParser.h +++ b/LUFA/Drivers/USB/Class/Host/HIDParser.h @@ -144,6 +144,7 @@ HID_PARSE_InsufficientCollectionPaths = 5, /**< More than \ref HID_MAX_COLLECTIONS collections in the report. */ HID_PARSE_UsageStackOverflow = 6, /**< More than \ref HID_USAGE_STACK_DEPTH usages listed in a row. */ HID_PARSE_InsufficientReportIDItems = 7, /**< More than \ref HID_MAX_REPORT_IDS report IDs in the device. */ + HID_PARSE_NoUnfilteredReportItems = 8, /**< All report items from the device were filtered by the filtering callback routine. */ }; /* Type Defines: */