X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/7f9f97c792dee6875fbca9806422bdd7d6c5a657..842e219bf3341020b9e3a5f04fe67dabd796e82d:/Bootloaders/TeensyHID/Descriptors.c?ds=sidebyside diff --git a/Bootloaders/TeensyHID/Descriptors.c b/Bootloaders/TeensyHID/Descriptors.c index 596ed6eef..52d6c737a 100644 --- a/Bootloaders/TeensyHID/Descriptors.c +++ b/Bootloaders/TeensyHID/Descriptors.c @@ -45,16 +45,20 @@ */ USB_Descriptor_HIDReport_Datatype_t HIDReport[] = { - 0x06, 0x9c, 0xff, /* Usage Page (Vendor Defined) */ - 0x09, 0x1B, /* Usage (Vendor Defined) */ - 0xa1, 0x01, /* Collection (Vendor Defined) */ - 0x0a, 0x19, 0x00, /* Usage (Vendor Defined) */ - 0x75, 0x08, /* Report Size (8) */ - 0x95, 0x82, /* Report Count (130) */ - 0x15, 0x00, /* Logical Minimum (0) */ - 0x25, 0xff, /* Logical Maximum (255) */ - 0x91, 0x02, /* Output (Data, Variable, Absolute) */ - 0xc0 /* End Collection */ + 0x06, 0x9c, 0xff, /* Usage Page (Vendor Defined) */ + 0x09, TEENSY_USAGEPAGE, /* Usage (Vendor Defined) */ + 0xa1, 0x01, /* Collection (Vendor Defined) */ + 0x0a, 0x19, 0x00, /* Usage (Vendor Defined) */ + 0x75, 0x08, /* Report Size (8) */ +#if (SPM_PAGESIZE == 128) /* Report Count (SPM_PAGESIZE + 2) */ + 0x95, (SPM_PAGESIZE + 2), +#else + 0x96, ((SPM_PAGESIZE + 2) & 0xFF), ((SPM_PAGESIZE + 2) >> 8), +#endif + 0x15, 0x00, /* Logical Minimum (0) */ + 0x25, 0xff, /* Logical Maximum (255) */ + 0x91, 0x02, /* Output (Data, Variable, Absolute) */ + 0xc0 /* End Collection */ }; /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall @@ -106,7 +110,7 @@ USB_Descriptor_Configuration_t ConfigurationDescriptor = .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) }, - .Interface = + .HID_Interface = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, @@ -122,7 +126,7 @@ USB_Descriptor_Configuration_t ConfigurationDescriptor = .InterfaceStrIndex = NO_DESCRIPTOR }, - .HIDDescriptor = + .HID_VendorHID = { .Header = {.Size = sizeof(USB_Descriptor_HID_t), .Type = DTYPE_HID}, @@ -133,7 +137,7 @@ USB_Descriptor_Configuration_t ConfigurationDescriptor = .HIDReportLength = sizeof(HIDReport) }, - .HIDEndpoint = + .HID_ReportINEndpoint = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, @@ -157,26 +161,29 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void* Address = NULL; uint16_t Size = NO_DESCRIPTOR; - switch (DescriptorType) + /* If/Else If chain compiles slightly smaller than a switch case */ + + if (DescriptorType == DTYPE_Device) + { + Address = (void*)&DeviceDescriptor; + Size = sizeof(USB_Descriptor_Device_t); + } + else if (DescriptorType == DTYPE_Configuration) + { + Address = (void*)&ConfigurationDescriptor; + Size = sizeof(USB_Descriptor_Configuration_t); + } + else if (DescriptorType == DTYPE_HID) + { + Address = (void*)&ConfigurationDescriptor.HID_VendorHID; + Size = sizeof(USB_Descriptor_HID_t); + } + else { - case DTYPE_Device: - Address = (void*)&DeviceDescriptor; - Size = sizeof(USB_Descriptor_Device_t); - break; - case DTYPE_Configuration: - Address = (void*)&ConfigurationDescriptor; - Size = sizeof(USB_Descriptor_Configuration_t); - break; - case DTYPE_HID: - Address = (void*)&ConfigurationDescriptor.HIDDescriptor; - Size = sizeof(USB_Descriptor_HID_t); - break; - case DTYPE_Report: - Address = (void*)&HIDReport; - Size = sizeof(HIDReport); - break; + Address = (void*)&HIDReport; + Size = sizeof(HIDReport); } - + *DescriptorAddress = Address; return Size; }