projects
/
pub
/
USBasp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed incorrect buffer size check in the USBtoSerial project (thanks to Yuri A Nikifo...
[pub/USBasp.git]
/
LUFA
/
Drivers
/
USB
/
Class
/
Host
/
HID.c
diff --git
a/LUFA/Drivers/USB/Class/Host/HID.c
b/LUFA/Drivers/USB/Class/Host/HID.c
index
683458d
..
fdcd6ee
100644
(file)
--- a/
LUFA/Drivers/USB/Class/Host/HID.c
+++ b/
LUFA/Drivers/USB/Class/Host/HID.c
@@
-73,7
+73,7
@@
uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
(HIDInterface->Protocol != HIDInterfaceInfo->Config.HIDInterfaceProtocol));
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
(HIDInterface->Protocol != HIDInterfaceInfo->Config.HIDInterfaceProtocol));
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
- DCOMP_HID_Host_NextHID) != DESCRIPTOR_SEARCH_COMP_Found)
+ DCOMP_HID_Host_NextHID
Descriptor
) != DESCRIPTOR_SEARCH_COMP_Found)
{
return HID_ENUMERROR_NoCompatibleInterfaceFound;
}
{
return HID_ENUMERROR_NoCompatibleInterfaceFound;
}
@@
-88,7
+88,7
@@
uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);
- if (
EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR
_DIR_IN)
+ if (
(EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT
_DIR_IN)
DataINEndpoint = EndpointData;
else
DataOUTEndpoint = EndpointData;
DataINEndpoint = EndpointData;
else
DataOUTEndpoint = EndpointData;
@@
-105,7
+105,7
@@
uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
if (PipeNum == HIDInterfaceInfo->Config.DataINPipeNumber)
{
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;
EndpointAddress = DataINEndpoint->EndpointAddress;
Token = PIPE_TOKEN_IN;
Type = EP_TYPE_INTERRUPT;
@@
-119,7
+119,7
@@
uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
if (DataOUTEndpoint == NULL)
continue;
if (DataOUTEndpoint == NULL)
continue;
- Size =
DataOUTEndpoint->EndpointSize
;
+ Size =
le16_to_cpu(DataOUTEndpoint->EndpointSize)
;
EndpointAddress = DataOUTEndpoint->EndpointAddress;
Token = PIPE_TOKEN_OUT;
Type = EP_TYPE_INTERRUPT;
EndpointAddress = DataOUTEndpoint->EndpointAddress;
Token = PIPE_TOKEN_OUT;
Type = EP_TYPE_INTERRUPT;
@@
-145,7
+145,7
@@
uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
}
HIDInterfaceInfo->State.InterfaceNumber = HIDInterface->InterfaceNumber;
}
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.SupportsBootProtocol = (HIDInterface->SubClass != HID_CSCP_NonBootProtocol);
HIDInterfaceInfo->State.LargestReportSize = 8;
HIDInterfaceInfo->State.IsActive = true;
@@
-168,7
+168,7
@@
static uint8_t DCOMP_HID_Host_NextHIDInterface(void* const CurrentDescriptor)
return DESCRIPTOR_SEARCH_NotFound;
}
return DESCRIPTOR_SEARCH_NotFound;
}
-static uint8_t DCOMP_HID_Host_NextHID(void* const CurrentDescriptor)
+static uint8_t DCOMP_HID_Host_NextHID
Descriptor
(void* const CurrentDescriptor)
{
USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
{
USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
@@
-334,6
+334,9
@@
uint8_t HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInf
{
uint8_t ErrorCode;
{
uint8_t ErrorCode;
+ if (!(HIDInterfaceInfo->State.SupportsBootProtocol))
+ return HID_ERROR_LOGICAL;
+
USB_ControlRequest = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
USB_ControlRequest = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
@@
-345,9
+348,6
@@
uint8_t HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInf
Pipe_SelectPipe(PIPE_CONTROLPIPE);
Pipe_SelectPipe(PIPE_CONTROLPIPE);
- if (!(HIDInterfaceInfo->State.SupportsBootProtocol))
- return HID_ERROR_LOGICAL;
-
if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)
return ErrorCode;
if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)
return ErrorCode;
@@
-357,11
+357,12
@@
uint8_t HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInf
return HOST_SENDCONTROL_Successful;
}
return HOST_SENDCONTROL_Successful;
}
-uint8_t HID_Host_SetIdlePeriod(const uint16_t MS)
+uint8_t HID_Host_SetIdlePeriod(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,
+ const uint16_t MS)
{
USB_ControlRequest = (USB_Request_Header_t)
{
{
USB_ControlRequest = (USB_Request_Header_t)
{
- .bmRequestType = (REQDIR_
DEVICETOHOST | REQTYPE_STANDARD
| REQREC_INTERFACE),
+ .bmRequestType = (REQDIR_
HOSTTODEVICE | REQTYPE_CLASS
| REQREC_INTERFACE),
.bRequest = HID_REQ_SetIdle,
.wValue = ((MS << 6) & 0xFF00),
.wIndex = HIDInterfaceInfo->State.InterfaceNumber,
.bRequest = HID_REQ_SetIdle,
.wValue = ((MS << 6) & 0xFF00),
.wIndex = HIDInterfaceInfo->State.InterfaceNumber,
@@
-370,7
+371,7
@@
uint8_t HID_Host_SetIdlePeriod(const uint16_t MS)
Pipe_SelectPipe(PIPE_CONTROLPIPE);
Pipe_SelectPipe(PIPE_CONTROLPIPE);
- return USB_Host_SendControlRequest(
HIDReportData
);
+ return USB_Host_SendControlRequest(
NULL
);
}
#if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)
}
#if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)