projects
/
pub
/
lufa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add static keyword to all project globals whose scope should be restricted to the...
[pub/lufa.git]
/
Bootloaders
/
HID
/
Descriptors.c
diff --git
a/Bootloaders/HID/Descriptors.c
b/Bootloaders/HID/Descriptors.c
index
0a63b79
..
f79d346
100644
(file)
--- a/
Bootloaders/HID/Descriptors.c
+++ b/
Bootloaders/HID/Descriptors.c
@@
-43,12
+43,12
@@
* the device will send, and what it may be sent back from the host. Refer to the HID specification for
\r
* more details on HID report descriptors.
\r
*/
\r
* the device will send, and what it may be sent back from the host. Refer to the HID specification for
\r
* more details on HID report descriptors.
\r
*/
\r
-USB_Descriptor_HIDReport_Datatype_t HIDReport[] =
\r
+
const
USB_Descriptor_HIDReport_Datatype_t HIDReport[] =
\r
{
\r
{
\r
- HID_RI_USAGE_PAGE(16, 0xFF
00), /* Vendor Page 1
*/
\r
- HID_RI_USAGE(8, 0x
01), /* Vendor Usage 1
*/
\r
+ HID_RI_USAGE_PAGE(16, 0xFF
DC), /* Vendor Page 0xDC
*/
\r
+ HID_RI_USAGE(8, 0x
FB), /* Vendor Usage 0xFB
*/
\r
HID_RI_COLLECTION(8, 0x01), /* Vendor Usage 1 */
\r
HID_RI_COLLECTION(8, 0x01), /* Vendor Usage 1 */
\r
- HID_RI_USAGE(8, 0x0
3), /* Vendor Usage 3
*/
\r
+ HID_RI_USAGE(8, 0x0
2), /* Vendor Usage 2
*/
\r
HID_RI_LOGICAL_MINIMUM(8, 0x00),
\r
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
\r
HID_RI_REPORT_SIZE(8, 0x08),
\r
HID_RI_LOGICAL_MINIMUM(8, 0x00),
\r
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
\r
HID_RI_REPORT_SIZE(8, 0x08),
\r
@@
-62,7
+62,7
@@
USB_Descriptor_HIDReport_Datatype_t HIDReport[] =
* number of device configurations. The descriptor is read out by the USB host when the enumeration
\r
* process begins.
\r
*/
\r
* number of device configurations. The descriptor is read out by the USB host when the enumeration
\r
* process begins.
\r
*/
\r
-USB_Descriptor_Device_t DeviceDescriptor =
\r
+
const
USB_Descriptor_Device_t DeviceDescriptor =
\r
{
\r
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
\r
\r
{
\r
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
\r
\r
@@
-89,7
+89,7
@@
USB_Descriptor_Device_t DeviceDescriptor =
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
\r
* a configuration so that the host may correctly communicate with the USB device.
\r
*/
\r
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
\r
* a configuration so that the host may correctly communicate with the USB device.
\r
*/
\r
-USB_Descriptor_Configuration_t ConfigurationDescriptor =
\r
+
const
USB_Descriptor_Configuration_t ConfigurationDescriptor =
\r
{
\r
.Config =
\r
{
\r
{
\r
.Config =
\r
{
\r
@@
-154,33
+154,23
@@
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex,
\r
const void** const DescriptorAddress)
\r
{
\r
const uint8_t wIndex,
\r
const void** const DescriptorAddress)
\r
{
\r
- const uint8_t DescriptorType
= (wValue >> 8);
\r
+ const uint8_t DescriptorType = (wValue >> 8);
\r
\r
const void* Address = NULL;
\r
uint16_t Size = NO_DESCRIPTOR;
\r
\r
\r
const void* Address = NULL;
\r
uint16_t Size = NO_DESCRIPTOR;
\r
\r
- /* If/Else If chain compiles slightly smaller than a switch case */
\r
if (DescriptorType == DTYPE_Device)
\r
if (DescriptorType == DTYPE_Device)
\r
- {
\r
- Address = &DeviceDescriptor;
\r
- Size = sizeof(USB_Descriptor_Device_t);
\r
- }
\r
+ Address = &DeviceDescriptor;
\r
else if (DescriptorType == DTYPE_Configuration)
\r
else if (DescriptorType == DTYPE_Configuration)
\r
- {
\r
- Address = &ConfigurationDescriptor;
\r
- Size = sizeof(USB_Descriptor_Configuration_t);
\r
- }
\r
+ Address = &ConfigurationDescriptor;
\r
else if (DescriptorType == HID_DTYPE_HID)
\r
else if (DescriptorType == HID_DTYPE_HID)
\r
- {
\r
- Address = &ConfigurationDescriptor.HID_VendorHID;
\r
- Size = sizeof(USB_HID_Descriptor_HID_t);
\r
- }
\r
+ Address = &ConfigurationDescriptor.HID_VendorHID;
\r
else
\r
else
\r
- {
\r
- Address = &HIDReport;
\r
- Size = sizeof(HIDReport);
\r
- }
\r
+ Address = &HIDReport;
\r
\r
\r
+ if (Address != NULL)
\r
+ Size = (Address == &HIDReport) ? sizeof(HIDReport) : ((USB_Descriptor_Header_t*)Address)->Size;
\r
+
\r
*DescriptorAddress = Address;
\r
return Size;
\r
}
\r
*DescriptorAddress = Address;
\r
return Size;
\r
}
\r