X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/f9f1bcc25c17b031029200cd9648d76d4ee39dc4..cf610c5c91c3eee02dec7ca848acc8da831ad98a:/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c diff --git a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c index 69ba64b13..736ab522a 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c +++ b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c @@ -37,7 +37,7 @@ #include "MouseHostWithParser.h" /** Main program entry point. This routine configures the hardware required by the application, then - * starts the scheduler to run the application tasks. + * enters a loop to run the application tasks in sequence. */ int main(void) { @@ -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); @@ -181,6 +185,24 @@ void Mouse_HID_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } + + printf("Total Reports: %d\r\n", HIDReportInfo.TotalDeviceReports); + + for (uint8_t i = 0; i < HIDReportInfo.TotalDeviceReports; i++) + { + HID_ReportSizeInfo_t* CurrReportIDInfo = &HIDReportInfo.ReportIDSizes[i]; + + uint8_t ReportSizeInBits = CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_In]; + uint8_t ReportSizeOutBits = CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_Out]; + uint8_t ReportSizeFeatureBits = CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_Feature]; + + /* Print out the byte sizes of each report within the device */ + printf_P(PSTR(" + Report ID %d - In: %d bytes, Out: %d bytes, Feature: %d bytes\r\n"), + CurrReportIDInfo->ReportID, + ((ReportSizeInBits >> 3) + ((ReportSizeInBits & 0x07) != 0)), + ((ReportSizeOutBits >> 3) + ((ReportSizeOutBits & 0x07) != 0)), + ((ReportSizeFeatureBits >> 3) + ((ReportSizeFeatureBits & 0x07) != 0))); + } puts_P(PSTR("Mouse Enumerated.\r\n")); @@ -190,7 +212,7 @@ void Mouse_HID_Task(void) /* Select and unfreeze mouse data pipe */ Pipe_SelectPipe(MOUSE_DATAPIPE); Pipe_Unfreeze(); - + /* Check to see if a packet has been received */ if (Pipe_IsINReceived()) { @@ -234,8 +256,8 @@ void ProcessMouseReport(uint8_t* MouseReport) bool FoundData; - if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) && - (ReportItem->ItemType == REPORT_ITEM_TYPE_In)) + if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) && + (ReportItem->ItemType == REPORT_ITEM_TYPE_In)) { /* Get the mouse button value */ FoundData = USB_GetHIDReportItemInfo(MouseReport, ReportItem);