/*
LUFA Library
- Copyright (C) Dean Camera, 2010.
+ Copyright (C) Dean Camera, 2011.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
- Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
*/
#define __INCLUDE_FROM_USB_DRIVER
-#include "../../HighLevel/USBMode.h"
+#include "../../Core/USBMode.h"
+
#if defined(USB_CAN_BE_HOST)
#define __INCLUDE_FROM_HID_DRIVER
(HIDInterface->Protocol != HIDInterfaceInfo->Config.HIDInterfaceProtocol));
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
- DCOMP_HID_Host_NextHID) != DESCRIPTOR_SEARCH_COMP_Found)
+ DCOMP_HID_Host_NextHIDDescriptor) != DESCRIPTOR_SEARCH_COMP_Found)
{
return HID_ENUMERROR_NoCompatibleInterfaceFound;
}
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);
- if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
- DataINEndpoint = EndpointData;
+ if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN)
+ DataINEndpoint = EndpointData;
else
DataOUTEndpoint = EndpointData;
}
if (PipeNum == HIDInterfaceInfo->Config.DataINPipeNumber)
{
- Size = DataINEndpoint->EndpointSize;
+ Size = le16_to_cpu(DataINEndpoint->EndpointSize);
EndpointAddress = DataINEndpoint->EndpointAddress;
Token = PIPE_TOKEN_IN;
Type = EP_TYPE_INTERRUPT;
DoubleBanked = HIDInterfaceInfo->Config.DataINPipeDoubleBank;
InterruptPeriod = DataINEndpoint->PollingIntervalMS;
- HIDInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
+ HIDInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize;
}
else if (PipeNum == HIDInterfaceInfo->Config.DataOUTPipeNumber)
{
- Size = DataOUTEndpoint->EndpointSize;
+ if (DataOUTEndpoint == NULL)
+ continue;
+
+ Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);
EndpointAddress = DataOUTEndpoint->EndpointAddress;
Token = PIPE_TOKEN_OUT;
Type = EP_TYPE_INTERRUPT;
}
HIDInterfaceInfo->State.InterfaceNumber = HIDInterface->InterfaceNumber;
- HIDInterfaceInfo->State.HIDReportSize = HIDDescriptor->HIDReportLength;
+ HIDInterfaceInfo->State.HIDReportSize = LE16_TO_CPU(HIDDescriptor->HIDReportLength);
HIDInterfaceInfo->State.SupportsBootProtocol = (HIDInterface->SubClass != HID_CSCP_NonBootProtocol);
HIDInterfaceInfo->State.LargestReportSize = 8;
- HIDInterfaceInfo->State.IsActive = true;
+ HIDInterfaceInfo->State.IsActive = true;
return HID_ENUMERROR_NoError;
}
return DESCRIPTOR_SEARCH_NotFound;
}
-static uint8_t DCOMP_HID_Host_NextHID(void* const CurrentDescriptor)
+static uint8_t DCOMP_HID_Host_NextHIDDescriptor(void* const CurrentDescriptor)
{
USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
if (HIDInterfaceInfo->Config.HIDParserData->UsingReportIDs)
{
- ReportID = Pipe_Read_Byte();
+ ReportID = Pipe_Read_8();
*(BufferPos++) = ReportID;
}
ReportSize = Pipe_BytesInPipe();
}
- if ((ErrorCode = Pipe_Read_Stream_LE(BufferPos, ReportSize, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
+ if ((ErrorCode = Pipe_Read_Stream_LE(BufferPos, ReportSize, NULL)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
Pipe_ClearIN();
Pipe_Unfreeze();
if (ReportID)
- Pipe_Write_Stream_LE(&ReportID, sizeof(ReportID), NO_STREAM_CALLBACK);
+ Pipe_Write_Stream_LE(&ReportID, sizeof(ReportID), NULL);
- if ((ErrorCode = Pipe_Write_Stream_LE(Buffer, ReportSize, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
+ if ((ErrorCode = Pipe_Write_Stream_LE(Buffer, ReportSize, NULL)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
Pipe_ClearOUT();
{
uint8_t ErrorCode;
+ if (!(HIDInterfaceInfo->State.SupportsBootProtocol))
+ return HID_ERROR_LOGICAL;
+
USB_ControlRequest = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
Pipe_SelectPipe(PIPE_CONTROLPIPE);
- if (!(HIDInterfaceInfo->State.SupportsBootProtocol))
- return HID_ERROR_LOGICAL;
-
if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)
return ErrorCode;
return HOST_SENDCONTROL_Successful;
}
+uint8_t HID_Host_SetIdlePeriod(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,
+ const uint16_t MS)
+{
+ USB_ControlRequest = (USB_Request_Header_t)
+ {
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
+ .bRequest = HID_REQ_SetIdle,
+ .wValue = ((MS << 6) & 0xFF00),
+ .wIndex = HIDInterfaceInfo->State.InterfaceNumber,
+ .wLength = 0,
+ };
+
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);
+
+ return USB_Host_SendControlRequest(NULL);
+}
+
#if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)
uint8_t HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo)
{