X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/df31b1fd5b0bfbf02a766d32e23a7af075bf4911..ab8668b14ee05854dfe935bf143be7ebe051b8f5:/Bootloaders/TeensyHID/Descriptors.c diff --git a/Bootloaders/TeensyHID/Descriptors.c b/Bootloaders/TeensyHID/Descriptors.c index 791269cbc..4142f1247 100644 --- a/Bootloaders/TeensyHID/Descriptors.c +++ b/Bootloaders/TeensyHID/Descriptors.c @@ -1,21 +1,21 @@ /* LUFA Library - Copyright (C) Dean Camera, 2009. + Copyright (C) Dean Camera, 2010. dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ /* - Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -106,7 +106,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 +122,7 @@ USB_Descriptor_Configuration_t ConfigurationDescriptor = .InterfaceStrIndex = NO_DESCRIPTOR }, - .HIDDescriptor = + .HID_VendorHID = { .Header = {.Size = sizeof(USB_Descriptor_HID_t), .Type = DTYPE_HID}, @@ -133,7 +133,7 @@ USB_Descriptor_Configuration_t ConfigurationDescriptor = .HIDReportLength = sizeof(HIDReport) }, - .HIDEndpoint = + .HID_ReportINEndpoint = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, @@ -152,31 +152,34 @@ USB_Descriptor_Configuration_t ConfigurationDescriptor = */ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress) { - const uint8_t DescriptorType = (wValue >> 8); + const uint8_t DescriptorType = (wValue >> 8); 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_Device) + { + 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; }