aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Class/Device
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-04-20 08:52:51 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-04-20 08:52:51 +0000
commit8252b4febd928718c4b416d7be262afa6a39075f (patch)
tree3b5b40f68de13e8d8ebe2bc66c4ab0b7d66b0907 /LUFA/Drivers/USB/Class/Device
parentd03d6513d0d24cf63225c8d3dfa07675d9107f40 (diff)
downloadlufa-8252b4febd928718c4b416d7be262afa6a39075f.tar.gz
lufa-8252b4febd928718c4b416d7be262afa6a39075f.tar.bz2
lufa-8252b4febd928718c4b416d7be262afa6a39075f.zip
Fixed HID Device Class Driver not allocating a temporary buffer when the host requests a report via the control endpoint and the user has set the PrevReportINBuffer driver configuration element to NULL (thanks to Lars Noschinski).
Clean up incomplete BluetoothHost debugging commands to use GCC extension to avoid NULL parameters when no formatting is required.
Diffstat (limited to 'LUFA/Drivers/USB/Class/Device')
-rw-r--r--LUFA/Drivers/USB/Class/Device/HID.c10
-rw-r--r--LUFA/Drivers/USB/Class/Device/HID.h3
2 files changed, 9 insertions, 4 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/HID.c b/LUFA/Drivers/USB/Class/Device/HID.c
index cc1ad43b5..7ff32498b 100644
--- a/LUFA/Drivers/USB/Class/Device/HID.c
+++ b/LUFA/Drivers/USB/Class/Device/HID.c
@@ -53,11 +53,15 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter
uint16_t ReportINSize = 0;
uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF);
uint8_t ReportType = (USB_ControlRequest.wValue >> 8) - 1;
+ uint8_t ReportINData[HIDInterfaceInfo->Config.PrevReportINBufferSize];
+
+ memset(ReportINData, 0, sizeof(ReportINData));
- memset(HIDInterfaceInfo->Config.PrevReportINBuffer, 0, HIDInterfaceInfo->Config.PrevReportINBufferSize);
-
CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportType,
HIDInterfaceInfo->Config.PrevReportINBuffer, &ReportINSize);
+
+ if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL)
+ memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, HIDInterfaceInfo->Config.PrevReportINBufferSize);
Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
Endpoint_Write_Control_Stream_LE(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize);
@@ -169,7 +173,7 @@ void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)
if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL)
{
StatesChanged = (memcmp(ReportINData, HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize) != 0);
- memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, ReportINSize);
+ memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, HIDInterfaceInfo->Config.PrevReportINBufferSize);
}
if (ReportINSize && (ForceSend || StatesChanged || IdlePeriodElapsed))
diff --git a/LUFA/Drivers/USB/Class/Device/HID.h b/LUFA/Drivers/USB/Class/Device/HID.h
index 1ab71771f..92751241b 100644
--- a/LUFA/Drivers/USB/Class/Device/HID.h
+++ b/LUFA/Drivers/USB/Class/Device/HID.h
@@ -106,7 +106,8 @@
uint8_t PrevReportINBufferSize; /**< Size in bytes of the given input report buffer. This is used to create a
* second buffer of the same size within the driver so that subsequent reports
* can be compared. If the user app is to determine when reports are to be sent
- * exclusively (i.e. \ref PrevReportINBuffer is NULL) this value is ignored.
+ * exclusively (i.e. \ref PrevReportINBuffer is NULL) this value must still be
+ * set to the size of the largest report the device can issue to the host.
*/
} Config; /**< Config data for the USB class interface within the device. All elements in this section
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.