From a504a3a010ec2441dda0209f195492fb36e7c97b Mon Sep 17 00:00:00 2001
From: Dean Camera <dean@fourwalledcubicle.com>
Date: Fri, 24 Apr 2009 07:28:51 +0000
Subject: [PATCH] Endpoint configuration is now refined to give better output
 when all configurations have static inputs - removed the now useless
 STATIC_ENDPOINT_CONFIGURATION compile time token.

---
 Bootloaders/CDC/makefile                  |  4 +-
 Bootloaders/DFU/makefile                  |  4 +-
 Bootloaders/TeensyHID/makefile            |  4 +-
 Demos/Device/AudioInput/makefile          |  2 +-
 Demos/Device/AudioOutput/makefile         |  2 +-
 Demos/Device/CDC/Descriptors.c            |  2 +-
 Demos/Device/CDC/makefile                 |  2 +-
 Demos/Device/DualCDC/makefile             |  2 +-
 Demos/Device/GenericHID/makefile          |  2 +-
 Demos/Device/Joystick/makefile            |  2 +-
 Demos/Device/Keyboard/makefile            |  2 +-
 Demos/Device/KeyboardMouse/makefile       |  2 +-
 Demos/Device/MIDI/makefile                |  2 +-
 Demos/Device/MassStorage/SCSI.c           |  2 +-
 Demos/Device/MassStorage/SCSI.h           |  6 +++
 Demos/Device/MassStorage/makefile         |  2 +-
 Demos/Device/Mouse/makefile               |  2 +-
 Demos/Device/RNDISEthernet/makefile       |  3 +-
 Demos/Device/USBtoSerial/makefile         |  2 +-
 LUFA/ChangeLog.txt                        |  4 +-
 LUFA/CompileTimeTokens.txt                | 10 +----
 LUFA/Drivers/USB/Class/ConfigDescriptor.c |  2 +-
 LUFA/Drivers/USB/Class/ConfigDescriptor.h |  4 +-
 LUFA/Drivers/USB/LowLevel/Endpoint.c      | 19 ++-------
 LUFA/Drivers/USB/LowLevel/Endpoint.h      | 52 +++++++++--------------
 LUFA/MigrationInformation.txt             |  1 +
 Projects/Magstripe/makefile               |  3 +-
 27 files changed, 61 insertions(+), 83 deletions(-)

diff --git a/Bootloaders/CDC/makefile b/Bootloaders/CDC/makefile
index 022742720..39a7a7da4 100644
--- a/Bootloaders/CDC/makefile
+++ b/Bootloaders/CDC/makefile
@@ -176,9 +176,9 @@ BOOT_START = 0x1E000
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
-CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DUSE_SINGLE_DEVICE_CONFIGURATION
+CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL
 
 
 # Place -D or -U options here for ASM sources
diff --git a/Bootloaders/DFU/makefile b/Bootloaders/DFU/makefile
index d55235b5d..5b225b4db 100644
--- a/Bootloaders/DFU/makefile
+++ b/Bootloaders/DFU/makefile
@@ -176,9 +176,9 @@ BOOT_START = 0x1E000
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DCONTROL_ONLY_DEVICE
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=32
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=32 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
-CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DUSE_SINGLE_DEVICE_CONFIGURATION
+CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL
 
 
 # Place -D or -U options here for ASM sources
diff --git a/Bootloaders/TeensyHID/makefile b/Bootloaders/TeensyHID/makefile
index 12b1b453f..48c4d1ee9 100644
--- a/Bootloaders/TeensyHID/makefile
+++ b/Bootloaders/TeensyHID/makefile
@@ -176,9 +176,9 @@ BOOT_START = 0xC000
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DCONTROL_ONLY_DEVICE
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
-CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DUSE_SINGLE_DEVICE_CONFIGURATION
+CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL
 
 
 # Place -D or -U options here for ASM sources
diff --git a/Demos/Device/AudioInput/makefile b/Demos/Device/AudioInput/makefile
index 19dc5e225..4b3938a79 100644
--- a/Demos/Device/AudioInput/makefile
+++ b/Demos/Device/AudioInput/makefile
@@ -185,7 +185,7 @@ CSTANDARD = -std=gnu99
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
 
 
diff --git a/Demos/Device/AudioOutput/makefile b/Demos/Device/AudioOutput/makefile
index b1a0511cd..bb609afd4 100644
--- a/Demos/Device/AudioOutput/makefile
+++ b/Demos/Device/AudioOutput/makefile
@@ -185,7 +185,7 @@ CSTANDARD = -std=gnu99
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
 CDEFS += -DAUDIO_OUT_STEREO
 
diff --git a/Demos/Device/CDC/Descriptors.c b/Demos/Device/CDC/Descriptors.c
index 6b65a760e..3618b8de7 100644
--- a/Demos/Device/CDC/Descriptors.c
+++ b/Demos/Device/CDC/Descriptors.c
@@ -51,7 +51,7 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
 	.SubClass               = 0x00,
 	.Protocol               = 0x00,
 				
-	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE,
+	.Endpoint0Size          = 8,//FIXED_CONTROL_ENDPOINT_SIZE,
 		
 	.VendorID               = 0x03EB,
 	.ProductID              = 0x2044,
diff --git a/Demos/Device/CDC/makefile b/Demos/Device/CDC/makefile
index fe839d6e2..3a0ebb1c1 100644
--- a/Demos/Device/CDC/makefile
+++ b/Demos/Device/CDC/makefile
@@ -185,7 +185,7 @@ CSTANDARD = -std=gnu99
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
 
 
diff --git a/Demos/Device/DualCDC/makefile b/Demos/Device/DualCDC/makefile
index 9134f238c..115a8f251 100644
--- a/Demos/Device/DualCDC/makefile
+++ b/Demos/Device/DualCDC/makefile
@@ -185,7 +185,7 @@ CSTANDARD = -std=gnu99
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
 
 
diff --git a/Demos/Device/GenericHID/makefile b/Demos/Device/GenericHID/makefile
index 3cf807011..74beb28b8 100644
--- a/Demos/Device/GenericHID/makefile
+++ b/Demos/Device/GenericHID/makefile
@@ -185,7 +185,7 @@ CSTANDARD = -std=gnu99
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
 
 # Place -D or -U options here for ASM sources
diff --git a/Demos/Device/Joystick/makefile b/Demos/Device/Joystick/makefile
index 5230af222..ce67e58ba 100644
--- a/Demos/Device/Joystick/makefile
+++ b/Demos/Device/Joystick/makefile
@@ -185,7 +185,7 @@ CSTANDARD = -std=gnu99
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
 
 
diff --git a/Demos/Device/Keyboard/makefile b/Demos/Device/Keyboard/makefile
index 68271f777..627e66108 100644
--- a/Demos/Device/Keyboard/makefile
+++ b/Demos/Device/Keyboard/makefile
@@ -185,7 +185,7 @@ CSTANDARD = -std=gnu99
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
 
 # Place -D or -U options here for ASM sources
diff --git a/Demos/Device/KeyboardMouse/makefile b/Demos/Device/KeyboardMouse/makefile
index 000dba261..1c239ba30 100644
--- a/Demos/Device/KeyboardMouse/makefile
+++ b/Demos/Device/KeyboardMouse/makefile
@@ -185,7 +185,7 @@ CSTANDARD = -std=gnu99
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
 
 
diff --git a/Demos/Device/MIDI/makefile b/Demos/Device/MIDI/makefile
index d7d28e8d9..11a9f3623 100644
--- a/Demos/Device/MIDI/makefile
+++ b/Demos/Device/MIDI/makefile
@@ -185,7 +185,7 @@ CSTANDARD = -std=gnu99
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
 
 
diff --git a/Demos/Device/MassStorage/SCSI.c b/Demos/Device/MassStorage/SCSI.c
index 6ddd144ca..a88be515a 100644
--- a/Demos/Device/MassStorage/SCSI.c
+++ b/Demos/Device/MassStorage/SCSI.c
@@ -43,7 +43,7 @@
  */
 SCSI_Inquiry_Response_t InquiryData = 
 	{
-		.DeviceType          = 0,
+		.DeviceType          = DEVICE_TYPE_BLOCK,
 		.PeripheralQualifier = 0,
 			
 		.Removable           = true,
diff --git a/Demos/Device/MassStorage/SCSI.h b/Demos/Device/MassStorage/SCSI.h
index 58eea1b41..158b7ed2d 100644
--- a/Demos/Device/MassStorage/SCSI.h
+++ b/Demos/Device/MassStorage/SCSI.h
@@ -67,7 +67,13 @@
 
 		/** Macro for the SCSI_Command_ReadWrite_10() function, to indicate that data is to be written to the storage medium. */
 		#define DATA_WRITE     false
+
+		/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a Block Media device. */
+		#define DEVICE_TYPE_BLOCK 0x00
 		
+		/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a CD-ROM device. */
+		#define DEVICE_TYPE_CDROM 0x05
+
 	/* Type Defines: */
 		/** Type define for a SCSI response structure to a SCSI INQUIRY command. For details of the
 		 *  structure contents, refer to the SCSI specifications.
diff --git a/Demos/Device/MassStorage/makefile b/Demos/Device/MassStorage/makefile
index 9ef390db8..faee640b0 100644
--- a/Demos/Device/MassStorage/makefile
+++ b/Demos/Device/MassStorage/makefile
@@ -187,7 +187,7 @@ CSTANDARD = -std=gnu99
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DUSB_DEVICE_ONLY
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
 
 
diff --git a/Demos/Device/Mouse/makefile b/Demos/Device/Mouse/makefile
index 79e16e3ec..f7e4d89da 100644
--- a/Demos/Device/Mouse/makefile
+++ b/Demos/Device/Mouse/makefile
@@ -184,7 +184,7 @@ CSTANDARD = -std=gnu99
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
 
 # Place -D or -U options here for ASM sources
diff --git a/Demos/Device/RNDISEthernet/makefile b/Demos/Device/RNDISEthernet/makefile
index 33b37cfc9..0954c283f 100644
--- a/Demos/Device/RNDISEthernet/makefile
+++ b/Demos/Device/RNDISEthernet/makefile
@@ -197,9 +197,8 @@ CSTANDARD = -std=gnu99
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
-
 CDEFS += -DNO_DECODE_ETHERNET -DNO_DECODE_ARP -DNO_DECODE_ICMP -DNO_DECODE_IP -DNO_DECODE_TCP -DNO_DECODE_UDP -DNO_DECODE_DHCP
 
 
diff --git a/Demos/Device/USBtoSerial/makefile b/Demos/Device/USBtoSerial/makefile
index 94f23143b..189741a99 100644
--- a/Demos/Device/USBtoSerial/makefile
+++ b/Demos/Device/USBtoSerial/makefile
@@ -186,7 +186,7 @@ CSTANDARD = -std=gnu99
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
 
 
diff --git a/LUFA/ChangeLog.txt b/LUFA/ChangeLog.txt
index 1557db500..4b1c5dcef 100644
--- a/LUFA/ChangeLog.txt
+++ b/LUFA/ChangeLog.txt
@@ -60,7 +60,9 @@
   *  - The USB_UnhandledControlPacket event has had its parameters removed, in favour of accessing the new USB_ControlRequest structure
   *  - The Endpoint control stream functions now correctly send a ZLP to the host when less data than requested is sent
   *  - Fixed USB_RemoteWakeupEnabled flag never being set (the REMOTE WAKEUP Set Feature request was not being handled)
-  *  - Renamed the FEATURELESS_CONTROL_ONLY_DEVICE compile-time token to CONTROL_ONLY_DEVICE 
+  *  - Renamed the FEATURELESS_CONTROL_ONLY_DEVICE compile-time token to CONTROL_ONLY_DEVICE
+  *  - Endpoint configuration is now refined to give better output when all configurations have static inputs - removed the now useless
+  *    STATIC_ENDPOINT_CONFIGURATION compile time token
   *    
   *
   *  \section Sec_ChangeLog090401 Version 090401
diff --git a/LUFA/CompileTimeTokens.txt b/LUFA/CompileTimeTokens.txt
index 090ace8ce..e3afc59bd 100644
--- a/LUFA/CompileTimeTokens.txt
+++ b/LUFA/CompileTimeTokens.txt
@@ -98,15 +98,7 @@
  *  Normally this reduces the amount of configuration required for the library, allows the value to change dynamically (if
  *  descriptors are stored in EEPROM or RAM rather than flash memory) and reduces code maintenance. However, this token can be
  *  defined to a non-zero value instead to give the size in bytes of the control endpoint, to reduce the size of the compiled
- *  binary at the expense of flexibility.
- *
- *  <b>STATIC_ENDPOINT_CONFIGURATION</b> - ( \ref Group_EndpointManagement ) \n
- *  By default, the endpoint configuration routine is designed to accept dynamic inputs, so that the endpoints can be configured
- *  using variable values known only at runtime. This allows for a great deal of flexibility, however uses a small amount of binary
- *  space which may be wasted if all endpoint configurations are static and known at compile time. Define this token via the -D switch
- *  to optimize the endpoint configuration routine for constant inputs, to reduce the size of the compiled binary at the expense of
- *  flexibility. Note that with this option dynamic values may still be used, but will result in many times more code to be generated than
- *  if the option was disabled. This is designed to be used only if the FIXED_CONTROL_ENDPOINT_SIZE option is also used.
+ *  binary.
  *
  *  <b>USE_SINGLE_DEVICE_CONFIGURATION</b> - ( \ref Group_Device ) \n
  *  By default, the library determines the number of configurations a USB device supports by reading the device descriptor. This reduces
diff --git a/LUFA/Drivers/USB/Class/ConfigDescriptor.c b/LUFA/Drivers/USB/Class/ConfigDescriptor.c
index 367b28ae3..78838305a 100644
--- a/LUFA/Drivers/USB/Class/ConfigDescriptor.c
+++ b/LUFA/Drivers/USB/Class/ConfigDescriptor.c
@@ -114,7 +114,7 @@ void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
 	  USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, Type);
 }
 			
-uint8_t USB_GetNextDescriptorComp_P(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ComparatorPtr_t ComparatorRoutine)
+uint8_t USB_GetNextDescriptorComp_Prv(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ComparatorPtr_t ComparatorRoutine)
 {
 	uint8_t ErrorCode;
 		
diff --git a/LUFA/Drivers/USB/Class/ConfigDescriptor.h b/LUFA/Drivers/USB/Class/ConfigDescriptor.h
index da38492ff..dce7de79e 100644
--- a/LUFA/Drivers/USB/Class/ConfigDescriptor.h
+++ b/LUFA/Drivers/USB/Class/ConfigDescriptor.h
@@ -162,7 +162,7 @@
 				 */
 				uint8_t USB_GetNextDescriptorComp(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ComparatorPtr_t ComparatorRoutine);
 			#else
-				#define USB_GetNextDescriptorComp(DSize, DPos, DSearch) USB_GetNextDescriptorComp_P(DSize, DPos, DCOMP_##DSearch)
+				#define USB_GetNextDescriptorComp(DSize, DPos, DSearch) USB_GetNextDescriptorComp_Prv(DSize, DPos, DCOMP_##DSearch)
 			#endif
 			
 		/* Enums: */
@@ -270,7 +270,7 @@
 			typedef uint8_t (* const ComparatorPtr_t)(void* const);
 
 		/* Function Prototypes: */
-			uint8_t USB_GetNextDescriptorComp_P(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ComparatorPtr_t ComparatorRoutine);
+			uint8_t USB_GetNextDescriptorComp_Prv(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ComparatorPtr_t ComparatorRoutine);
 	#endif
 			
 	/* Disable C linkage for C++ Compilers: */
diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.c b/LUFA/Drivers/USB/LowLevel/Endpoint.c
index da2925ec7..4615baa69 100644
--- a/LUFA/Drivers/USB/LowLevel/Endpoint.c
+++ b/LUFA/Drivers/USB/LowLevel/Endpoint.c
@@ -39,22 +39,12 @@
 uint8_t USB_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;
 #endif
 
-#if !defined(STATIC_ENDPOINT_CONFIGURATION)
-bool Endpoint_ConfigureEndpoint(const uint8_t  Number, const uint8_t Type, const uint8_t Direction,
-			                    const uint16_t Size, const uint8_t Banks)
+uint8_t Endpoint_BytesToEPSizeMaskDynamic(const uint16_t Size)
 {
-	Endpoint_SelectEndpoint(Number);
-	Endpoint_EnableEndpoint();
-
-	UECFG1X = 0;	
-
-	UECFG0X = ((Type << EPTYPE0) | Direction);
-	UECFG1X = ((1 << ALLOC) | Banks | Endpoint_BytesToEPSizeMask(Size));
-
-	return Endpoint_IsConfigured();
+	return Endpoint_BytesToEPSizeMask(Size);
 }
-#else
-bool Endpoint_ConfigureEndpointStatic(const uint8_t Number, const uint8_t UECFG0XData, const uint8_t UECFG1XData)
+
+bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, const uint8_t UECFG0XData, const uint8_t UECFG1XData)
 {
 	Endpoint_SelectEndpoint(Number);
 	Endpoint_EnableEndpoint();
@@ -66,7 +56,6 @@ bool Endpoint_ConfigureEndpointStatic(const uint8_t Number, const uint8_t UECFG0
 
 	return Endpoint_IsConfigured();
 }
-#endif
 
 void Endpoint_ClearEndpoints(void)
 {
diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h
index 1e88e0658..4d5aa538e 100644
--- a/LUFA/Drivers/USB/LowLevel/Endpoint.h
+++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h
@@ -734,11 +734,6 @@
 			 *
 			 *  The success of this routine can be determined via the \ref Endpoint_IsConfigured() macro.
 			 *
-			 *  By default, the routine is entirely dynamic, and will accept both constant and variable inputs.
-			 *  If dynamic configuration is unused, a small space savings can be made by defining the
-			 *  STATIC_ENDPOINT_CONFIGURATION macro via the -D switch to the compiler, to optimize for constant
-			 *  input values.
-			 *
 			 *  \note This routine will select the specified endpoint, and the endpoint will remain selected
 			 *        once the routine completes regardless of if the endpoint configuration succeeds.
 			 *
@@ -1002,38 +997,33 @@
 				#define ENDPOINT_DETAILS_EP4               64,  true			
 			#endif
 
-			#if defined(STATIC_ENDPOINT_CONFIGURATION)
-				#define Endpoint_ConfigureEndpoint(Number, Type, Direction, Size, Banks)        \
-				                                     Endpoint_ConfigureEndpointStatic(Number,   \
-				                                              ((Type << EPTYPE0) | Direction),  \
-				                                              ((1 << ALLOC) | Banks | Endpoint_BytesToEPSizeMask(Size)));
-			#endif
-
+			#define Endpoint_ConfigureEndpoint(Number, Type, Direction, Size, Banks)            \
+			                                    Endpoint_ConfigureEndpoint_Prv(Number,          \
+			                                              ((Type << EPTYPE0) | Direction),      \
+			                                              ((1 << ALLOC) | Banks |               \
+			                                                (__builtin_constant_p(Size) ?       \
+			                                                 Endpoint_BytesToEPSizeMask(Size) :  \
+			                                                 Endpoint_BytesToEPSizeMaskDynamic(Size))))
+													
 		/* Function Prototypes: */
-			void Endpoint_ClearEndpoints(void);
-			bool Endpoint_ConfigureEndpointStatic(const uint8_t Number, const uint8_t UECFG0XData, const uint8_t UECFG1XData);
+			void    Endpoint_ClearEndpoints(void);
+			uint8_t Endpoint_BytesToEPSizeMaskDynamic(const uint16_t Size);
+			bool    Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, const uint8_t UECFG0XData, const uint8_t UECFG1XData);
 			
 		/* Inline Functions: */
 			static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;
 			static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)
 			{
-				if (Bytes <= 8)
-				  return (0 << EPSIZE0);
-				else if (Bytes <= 16)
-				  return (1 << EPSIZE0);
-				else if (Bytes <= 32)
-				  return (2 << EPSIZE0);
-				#if defined(USB_LIMITED_CONTROLLER)
-				else
-				  return (3 << EPSIZE0);
-				#else
-				else if (Bytes <= 64)
-				  return (3 << EPSIZE0);
-				else if (Bytes <= 128)
-				  return (4 << EPSIZE0);
-				else
-				  return (5 << EPSIZE0);
-				#endif
+				uint8_t  MaskVal    = 0;
+				uint16_t CheckBytes = 8;
+				
+				while (CheckBytes < Bytes)
+				{
+					MaskVal++;
+					CheckBytes <<= 1;
+				}
+				
+				return (MaskVal << EPSIZE0);
 			};
 
 	#endif
diff --git a/LUFA/MigrationInformation.txt b/LUFA/MigrationInformation.txt
index 9dbabb7e4..f3c3a6fa4 100644
--- a/LUFA/MigrationInformation.txt
+++ b/LUFA/MigrationInformation.txt
@@ -37,6 +37,7 @@
  *      the Control Request header as all Control Request header data is now preloaded by the library and made available in the
  *      USB_ControlRequest structure.
  *    - The FEATURELESS_CONTROL_ONLY_DEVICE token has been renamed to CONTROL_ONLY_DEVICE.
+ *    - The STATIC_ENDPOINT_CONFIGURATION is no longer applicable as the library will apply this optimization when appropriate automatically.
  *
  *  <b>Host Mode</b>
  *    - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0) to allow it to be used on
diff --git a/Projects/Magstripe/makefile b/Projects/Magstripe/makefile
index 8006b0cda..5d474cdba 100644
--- a/Projects/Magstripe/makefile
+++ b/Projects/Magstripe/makefile
@@ -186,9 +186,8 @@ CSTANDARD = -std=gnu99
 # Place -D or -U options here for C sources
 CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
 CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
-CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
+CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
-
 CDEFS += -DMAG_T1_CLOCK="(1 << 0)"
 CDEFS += -DMAG_T1_DATA="(1 << 1)"
 CDEFS += -DMAG_T2_CLOCK="(1 << 2)"
-- 
GitLab