forked from mfulz_github/qmk_firmware
Finish Class Driver MouseHost demo. Update HID Host Class driver; boot protocol now works, still need to finish and test report protocol mode.
This commit is contained in:
parent
51566d1a81
commit
aa640330a1
|
@ -117,8 +117,14 @@ int main(void)
|
|||
uint8_t ReportID = 0;
|
||||
uint8_t LEDMask = LEDS_NO_LEDS;
|
||||
|
||||
/* Receive next boot protocol mouse report from the device */
|
||||
HID_Host_ReceiveReport(&Mouse_HID_Interface, false, &ReportID, &MouseReport);
|
||||
|
||||
/* Print mouse report data through the serial port */
|
||||
printf_P(PSTR("dX:%2d dY:%2d Button:%d\r\n"), MouseReport.X,
|
||||
MouseReport.Y,
|
||||
MouseReport.Button);
|
||||
|
||||
/* Alter status LEDs according to mouse X movement */
|
||||
if (MouseReport.X > 0)
|
||||
LEDMask |= LEDS_LED1;
|
||||
|
@ -137,10 +143,6 @@ int main(void)
|
|||
|
||||
LEDs_SetAllLEDs(LEDMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDS_NO_LEDS);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/** \file
|
||||
*
|
||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
/** \mainpage Mouse Host Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
*
|
||||
* The following table indicates what microcontrollers are compatible with this demo.
|
||||
*
|
||||
* - AT90USB1287
|
||||
* - AT90USB647
|
||||
*
|
||||
* \section SSec_Info USB Information:
|
||||
*
|
||||
* The following table gives a rundown of the USB utilization of this demo.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>USB Mode:</b></td>
|
||||
* <td>Host</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>N/A</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Relevant Standards:</b></td>
|
||||
* <td>USBIF HID Specification, USBIF HID Usage Tables</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Usable Speeds:</b></td>
|
||||
* <td>Low Speed Mode, Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Mouse host demonstration application. This gives a simple reference
|
||||
* application for implementing a USB Mouse host, for USB mice using
|
||||
* the standard mouse HID profile.
|
||||
*
|
||||
* Mouse movement and button presses are displayed on the board LEDs,
|
||||
* as well as printed out the serial terminal as formatted dY, dY and
|
||||
* button status information.
|
||||
*
|
||||
* This uses a naive method where the mouse is set to Boot Protocol mode, so
|
||||
* that the report structure is fixed and known. A better implementation
|
||||
* uses the HID report parser for correct report data processing across
|
||||
* all compatible mice with advanced characteristics, as shown in the
|
||||
* MouseHostWithParser demo application.
|
||||
*
|
||||
* Currently only single interface mice are supported.
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td>
|
||||
* None
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
File diff suppressed because one or more lines are too long
|
@ -75,7 +75,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint
|
|||
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
|
||||
DComp_HID_Host_NextHIDInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
|
||||
{
|
||||
if (FoundEndpoints == (1 << HID_FOUND_DATAPIPE_IN))
|
||||
if (FoundEndpoints & HID_FOUND_DATAPIPE_IN)
|
||||
break;
|
||||
|
||||
return HID_ENUMERROR_EndpointsNotFound;
|
||||
|
@ -200,6 +200,7 @@ uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, bool
|
|||
if ((ErrorCode = Pipe_Read_Stream_LE(Buffer, ReportSize, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
|
||||
return ErrorCode;
|
||||
|
||||
Pipe_ClearIN();
|
||||
Pipe_Freeze();
|
||||
|
||||
return PIPE_RWSTREAM_NoError;
|
||||
|
@ -239,6 +240,7 @@ uint8_t HID_Host_SendReport(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint8_t
|
|||
if ((ErrorCode = Pipe_Write_Stream_LE(Buffer, ReportSize, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
|
||||
return ErrorCode;
|
||||
|
||||
Pipe_ClearOUT();
|
||||
Pipe_Freeze();
|
||||
|
||||
return PIPE_RWSTREAM_NoError;
|
||||
|
@ -255,7 +257,7 @@ bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo)
|
|||
Pipe_SelectPipe(HIDInterfaceInfo->Config.DataINPipeNumber);
|
||||
Pipe_Unfreeze();
|
||||
|
||||
ReportReceived = Pipe_IsReadWriteAllowed();
|
||||
ReportReceived = Pipe_IsINReceived();
|
||||
|
||||
Pipe_Freeze();
|
||||
|
||||
|
@ -264,16 +266,13 @@ bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo)
|
|||
|
||||
uint8_t USB_HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo)
|
||||
{
|
||||
if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive))
|
||||
return false;
|
||||
|
||||
uint8_t ErrorCode;
|
||||
|
||||
USB_ControlRequest = (USB_Request_Header_t)
|
||||
{
|
||||
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
|
||||
.bRequest = REQ_SetProtocol,
|
||||
.wValue = 1,
|
||||
.wValue = 0,
|
||||
.wIndex = HIDInterfaceInfo->State.InterfaceNumber,
|
||||
.wLength = 0,
|
||||
};
|
||||
|
@ -293,9 +292,6 @@ uint8_t USB_HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo)
|
|||
|
||||
uint8_t USB_HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo)
|
||||
{
|
||||
if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive))
|
||||
return false;
|
||||
|
||||
uint8_t ErrorCode;
|
||||
|
||||
uint8_t HIDReportData[HIDInterfaceInfo->State.HIDReportSize];
|
||||
|
@ -318,7 +314,7 @@ uint8_t USB_HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* HIDInterfaceInf
|
|||
{
|
||||
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
|
||||
.bRequest = REQ_SetProtocol,
|
||||
.wValue = 0,
|
||||
.wValue = 1,
|
||||
.wIndex = HIDInterfaceInfo->State.InterfaceNumber,
|
||||
.wLength = 0,
|
||||
};
|
||||
|
|
|
@ -246,21 +246,21 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
|
|||
{
|
||||
case TAG_MAIN_INPUT:
|
||||
NewReportItem.ItemType = REPORT_ITEM_TYPE_In;
|
||||
NewReportItem.BitOffset = CurrReportIDInfo->BitsIn;
|
||||
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_In];
|
||||
|
||||
CurrReportIDInfo->BitsIn += CurrStateTable->Attributes.BitSize;
|
||||
CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_In] += CurrStateTable->Attributes.BitSize;
|
||||
break;
|
||||
case TAG_MAIN_OUTPUT:
|
||||
NewReportItem.ItemType = REPORT_ITEM_TYPE_Out;
|
||||
NewReportItem.BitOffset = CurrReportIDInfo->BitsOut;
|
||||
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_Out];
|
||||
|
||||
CurrReportIDInfo->BitsOut += CurrStateTable->Attributes.BitSize;
|
||||
CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_Out] += CurrStateTable->Attributes.BitSize;
|
||||
break;
|
||||
case TAG_MAIN_FEATURE:
|
||||
NewReportItem.ItemType = REPORT_ITEM_TYPE_Feature;
|
||||
NewReportItem.BitOffset = CurrReportIDInfo->BitsFeature;
|
||||
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_Feature];
|
||||
|
||||
CurrReportIDInfo->BitsFeature += CurrStateTable->Attributes.BitSize;
|
||||
CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_Feature] += CurrStateTable->Attributes.BitSize;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -347,17 +347,7 @@ uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData, uint8_t Report
|
|||
for (uint8_t i = 0; i < HID_MAX_REPORT_IDS; i++)
|
||||
{
|
||||
if (ParserData->ReportIDSizes[i].ReportID == ReportID)
|
||||
{
|
||||
switch (ReportType)
|
||||
{
|
||||
case REPORT_ITEM_TYPE_In:
|
||||
return ParserData->ReportIDSizes[i].BitsIn;
|
||||
case REPORT_ITEM_TYPE_Out:
|
||||
return ParserData->ReportIDSizes[i].BitsOut;
|
||||
case REPORT_ITEM_TYPE_Feature:
|
||||
return ParserData->ReportIDSizes[i].BitsFeature;
|
||||
}
|
||||
}
|
||||
return ParserData->ReportIDSizes[i].ReportSizeBits[ReportType];
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -208,9 +208,9 @@
|
|||
typedef struct
|
||||
{
|
||||
uint8_t ReportID; /** Report ID of the report within the HID interface */
|
||||
uint8_t BitsIn; /** Total number of IN data bits in the current report ID */
|
||||
uint8_t BitsOut; /** Total number of OUT data bits in the current report ID */
|
||||
uint8_t BitsFeature; /** Total number of FEATURE data bits in the current report ID */
|
||||
uint8_t ReportSizeBits[3]; /** Total number of bits in each report type for the given Report ID,
|
||||
* indexed by the \ref HID_ReportItemTypes_t enum
|
||||
*/
|
||||
} HID_ReportSizeInfo_t;
|
||||
|
||||
/** Type define for a complete processed HID report, including all report item data and collections. */
|
||||
|
|
Loading…
Reference in New Issue