diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-09-22 08:07:48 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-09-22 08:07:48 +0000 |
commit | 849b9535e7f4ca84aa909cfb9e985ae29f14be72 (patch) | |
tree | e111d99889ec320913fcfb3ff9c695dc31c740b4 /Demos | |
parent | 576f40f5aec3d7e48ed949fd24494b6cfb3ec93f (diff) | |
download | lufa-849b9535e7f4ca84aa909cfb9e985ae29f14be72.tar.gz lufa-849b9535e7f4ca84aa909cfb9e985ae29f14be72.tar.bz2 lufa-849b9535e7f4ca84aa909cfb9e985ae29f14be72.zip |
Add new error condition to the HID Report Parser for when a report is parsed but no unfiltered items are encountered (i.e. nothing of interest in the device report). Make all host HID "WithParser" demos print the new error condition.
Diffstat (limited to 'Demos')
6 files changed, 25 insertions, 13 deletions
diff --git a/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h b/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h index 89e21bbaf..3f477ede4 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 b7b5a1e78..cfba56d3c 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 d89807461..e9af0c0b2 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 c33b2ebde..f222eee41 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 3b97ad7ed..0cba5fccd 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 4d50ff6ab..b47858e31 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;
|