From df31b1fd5b0bfbf02a766d32e23a7af075bf4911 Mon Sep 17 00:00:00 2001
From: Dean Camera <dean@fourwalledcubicle.com>
Date: Wed, 23 Dec 2009 07:38:53 +0000
Subject: [PATCH] Fix TeensyHID bootloader - change vendor page in the
 descriptors to match the undocumented page needed for the new Teensy 2.0
 boards.

Commit for the 091223 release.
---
 Bootloaders/TeensyHID/Descriptors.c | 40 ++---------------------------
 Bootloaders/TeensyHID/TeensyHID.txt |  5 +---
 Bootloaders/TeensyHID/makefile      |  2 +-
 3 files changed, 4 insertions(+), 43 deletions(-)

diff --git a/Bootloaders/TeensyHID/Descriptors.c b/Bootloaders/TeensyHID/Descriptors.c
index 098de0df8..791269cbc 100644
--- a/Bootloaders/TeensyHID/Descriptors.c
+++ b/Bootloaders/TeensyHID/Descriptors.c
@@ -46,7 +46,7 @@
 USB_Descriptor_HIDReport_Datatype_t HIDReport[] =
 {
 	0x06, 0x9c, 0xff,     /* Usage Page (Vendor Defined)                     */
-	0x09, 0x19,           /* Usage (Vendor Defined)                          */
+	0x09, 0x1B,           /* Usage (Vendor Defined)                          */
 	0xa1, 0x01,           /* Collection (Vendor Defined)                     */
 	0x0a, 0x19, 0x00,     /*   Usage (Vendor Defined)                        */
 	0x75, 0x08,           /*   Report Size (8)                               */
@@ -78,7 +78,7 @@ USB_Descriptor_Device_t DeviceDescriptor =
 	.ReleaseNumber          = 0x0120,
 		
 	.ManufacturerStrIndex   = NO_DESCRIPTOR,
-	.ProductStrIndex        = 0x01,
+	.ProductStrIndex        = NO_DESCRIPTOR,
 	.SerialNumStrIndex      = NO_DESCRIPTOR,
 		
 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
@@ -144,28 +144,6 @@ USB_Descriptor_Configuration_t ConfigurationDescriptor =
 		},
 };
 
-/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
- *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
- *  via the language ID table available at USB.org what languages the device supports for its string descriptors.
- */
-USB_Descriptor_String_t LanguageString =
-{
-	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
-		
-	.UnicodeString          = {LANGUAGE_ID_ENG}
-};
-
-/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
- *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
- *  Descriptor.
- */
-USB_Descriptor_String_t ProductString =
-{
-	.Header                 = {.Size = USB_STRING_LEN(21), .Type = DTYPE_String},
-		
-	.UnicodeString          = L"AVR Teensy Bootloader"
-};
-
 /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
  *  documentation) by the application code so that the address and size of a requested descriptor can be given
  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
@@ -175,7 +153,6 @@ USB_Descriptor_String_t ProductString =
 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  DescriptorNumber = (wValue & 0xFF);
 
 	void*    Address = NULL;
 	uint16_t Size    = NO_DESCRIPTOR;
@@ -189,19 +166,6 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex,
 		case DTYPE_Configuration:
 			Address = (void*)&ConfigurationDescriptor;
 			Size    = sizeof(USB_Descriptor_Configuration_t);
-			break;
-		case DTYPE_String:
-			if (!(DescriptorNumber))
-			{
-				Address = (void*)&LanguageString;
-				Size    = LanguageString.Header.Size;
-			}
-			else
-			{
-				Address = (void*)&ProductString;
-				Size    = ProductString.Header.Size;
-			}
-			
 			break;
 		case DTYPE_HID:
 			Address = (void*)&ConfigurationDescriptor.HIDDescriptor;
diff --git a/Bootloaders/TeensyHID/TeensyHID.txt b/Bootloaders/TeensyHID/TeensyHID.txt
index bc4e15f1c..6ee62f57c 100644
--- a/Bootloaders/TeensyHID/TeensyHID.txt
+++ b/Bootloaders/TeensyHID/TeensyHID.txt
@@ -10,10 +10,7 @@
  *
  *  The following list indicates what microcontrollers are compatible with this demo.
  *
- *  - AT90USB162
- *  - ATMEGA32U4
- *  - AT90USB646
- *  - AT90USB1286
+ *  - ATMEGA32U4 (Teensy 2.0)
  *
  *  \section SSec_Info USB Information:
  *
diff --git a/Bootloaders/TeensyHID/makefile b/Bootloaders/TeensyHID/makefile
index 8de8f8f47..c7210f0e8 100644
--- a/Bootloaders/TeensyHID/makefile
+++ b/Bootloaders/TeensyHID/makefile
@@ -122,7 +122,7 @@ LUFA_PATH = ../..
 # LUFA library compile-time options
 LUFA_OPTS  = -D USB_DEVICE_ONLY
 LUFA_OPTS += -D DEVICE_STATE_AS_GPIOR=0
-LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
+LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=64
 LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
 LUFA_OPTS += -D USE_RAM_DESCRIPTORS
 LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
-- 
GitLab