From 64e5c4084f862267d96b0947f462de7058f3dc4c Mon Sep 17 00:00:00 2001
From: Dean Camera <dean@fourwalledcubicle.com>
Date: Sat, 7 Nov 2009 03:51:24 +0000
Subject: [PATCH] Add optional pipe double banking support to the Host mode
 Class drivers.

Descriptor processing routines now pass around void pointers rather than uint8_t pointers, as their destination datatype is know well known -- they are just streams of bytes until they are cast to the correct destination type by DESCRIPTOR_CAST.
---
 .../JoystickHostWithParser/JoystickHostWithParser.c |  3 +++
 Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c  |  3 +++
 .../KeyboardHostWithParser/KeyboardHostWithParser.c |  3 +++
 Demos/Host/ClassDriver/MIDIHost/MIDIHost.c          |  3 +++
 .../ClassDriver/MassStorageHost/MassStorageHost.c   |  3 +++
 Demos/Host/ClassDriver/MouseHost/MouseHost.c        |  3 +++
 .../MouseHostWithParser/MouseHostWithParser.c       |  3 +++
 Demos/Host/ClassDriver/PrinterHost/PrinterHost.c    |  3 +++
 .../ClassDriver/StillImageHost/StillImageHost.c     |  5 +++++
 LUFA/Drivers/USB/Class/Device/Audio.c               |  2 +-
 LUFA/Drivers/USB/Class/Host/CDC.c                   |  2 +-
 LUFA/Drivers/USB/Class/Host/CDC.h                   |  7 ++++++-
 LUFA/Drivers/USB/Class/Host/HID.c                   |  8 +++++---
 LUFA/Drivers/USB/Class/Host/HID.h                   |  5 ++++-
 LUFA/Drivers/USB/Class/Host/MIDI.c                  |  8 +++++---
 LUFA/Drivers/USB/Class/Host/MIDI.h                  |  5 ++++-
 LUFA/Drivers/USB/Class/Host/MassStorage.c           |  6 +++---
 LUFA/Drivers/USB/Class/Host/MassStorage.h           | 13 ++++++++-----
 LUFA/Drivers/USB/Class/Host/Printer.c               |  6 +++---
 LUFA/Drivers/USB/Class/Host/Printer.h               |  5 ++++-
 LUFA/Drivers/USB/Class/Host/StillImage.c            |  8 ++++----
 LUFA/Drivers/USB/Class/Host/StillImage.h            |  7 ++++++-
 LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c       |  8 ++++----
 LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h       | 12 ++++++------
 LUFA/Drivers/USB/LowLevel/DevChapter9.c             |  4 ++--
 25 files changed, 95 insertions(+), 40 deletions(-)

diff --git a/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c b/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c
index 6695efa23..76fb638ac 100644
--- a/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c
+++ b/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c
@@ -48,7 +48,10 @@ USB_ClassInfo_HID_Host_t Joystick_HID_Interface =
 		.Config =
 			{
 				.DataINPipeNumber       = 1,
+				.DataINPipeDoubleBank   = false,
+
 				.DataOUTPipeNumber      = 2,
+				.DataOUTPipeDoubleBank  = false,
 				
 				.HIDInterfaceProtocol   = HID_NON_BOOT_PROTOCOL,
 				
diff --git a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c
index b483defa7..1b5f8c725 100644
--- a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c
+++ b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c
@@ -45,7 +45,10 @@ USB_ClassInfo_HID_Host_t Keyboard_HID_Interface =
 		.Config =
 			{
 				.DataINPipeNumber       = 1,
+				.DataINPipeDoubleBank   = false,
+
 				.DataOUTPipeNumber      = 2,
+				.DataOUTPipeDoubleBank  = false,
 				
 				.HIDInterfaceProtocol   = HID_BOOT_KEYBOARD_PROTOCOL,
 			},
diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c
index bccfb8ca9..971dcf227 100644
--- a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c
+++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c
@@ -48,7 +48,10 @@ USB_ClassInfo_HID_Host_t Keyboard_HID_Interface =
 		.Config =
 			{
 				.DataINPipeNumber       = 1,
+				.DataINPipeDoubleBank   = false,
+
 				.DataOUTPipeNumber      = 2,
+				.DataOUTPipeDoubleBank  = false,
 				
 				.HIDInterfaceProtocol   = HID_NON_BOOT_PROTOCOL,
 				
diff --git a/Demos/Host/ClassDriver/MIDIHost/MIDIHost.c b/Demos/Host/ClassDriver/MIDIHost/MIDIHost.c
index f575d8ecf..9a59be082 100644
--- a/Demos/Host/ClassDriver/MIDIHost/MIDIHost.c
+++ b/Demos/Host/ClassDriver/MIDIHost/MIDIHost.c
@@ -45,7 +45,10 @@ USB_ClassInfo_MIDI_Host_t Keyboard_MIDI_Interface =
 		.Config =
 			{
 				.DataINPipeNumber       = 1,
+				.DataINPipeDoubleBank   = false,
+				
 				.DataOUTPipeNumber      = 2,
+				.DataOUTPipeDoubleBank  = false,
 			},
 	};
 
diff --git a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c
index 1bb0a8454..7489ad10a 100644
--- a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c
+++ b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c
@@ -45,7 +45,10 @@ USB_ClassInfo_MS_Host_t FlashDisk_MS_Interface =
 		.Config =
 			{
 				.DataINPipeNumber       = 1,
+				.DataINPipeDoubleBank   = false,
+				
 				.DataOUTPipeNumber      = 2,
+				.DataOUTPipeDoubleBank  = false,
 			},
 	};
 
diff --git a/Demos/Host/ClassDriver/MouseHost/MouseHost.c b/Demos/Host/ClassDriver/MouseHost/MouseHost.c
index fbf35c0d6..aa04c2e28 100644
--- a/Demos/Host/ClassDriver/MouseHost/MouseHost.c
+++ b/Demos/Host/ClassDriver/MouseHost/MouseHost.c
@@ -45,7 +45,10 @@ USB_ClassInfo_HID_Host_t Mouse_HID_Interface =
 		.Config =
 			{
 				.DataINPipeNumber       = 1,
+				.DataINPipeDoubleBank   = false,
+				
 				.DataOUTPipeNumber      = 2,
+				.DataOUTPipeDoubleBank  = false,
 				
 				.HIDInterfaceProtocol   = HID_BOOT_MOUSE_PROTOCOL,
 			},
diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c
index 80ddc5527..022a102d3 100644
--- a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c
+++ b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c
@@ -48,7 +48,10 @@ USB_ClassInfo_HID_Host_t Mouse_HID_Interface =
 		.Config =
 			{
 				.DataINPipeNumber       = 1,
+				.DataINPipeDoubleBank   = false,
+
 				.DataOUTPipeNumber      = 2,
+				.DataOUTPipeDoubleBank  = false,
 				
 				.HIDInterfaceProtocol   = HID_NON_BOOT_PROTOCOL,
 				
diff --git a/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c b/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c
index f854e1bf7..f94bf632a 100644
--- a/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c
+++ b/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c
@@ -45,7 +45,10 @@ USB_ClassInfo_PRNT_Host_t Printer_PRNT_Interface =
 		.Config =
 			{
 				.DataINPipeNumber       = 1,
+				.DataINPipeDoubleBank   = false,
+				
 				.DataOUTPipeNumber      = 2,
+				.DataOUTPipeDoubleBank  = false,
 			},
 	};
 
diff --git a/Demos/Host/ClassDriver/StillImageHost/StillImageHost.c b/Demos/Host/ClassDriver/StillImageHost/StillImageHost.c
index d8146af29..2959af59d 100644
--- a/Demos/Host/ClassDriver/StillImageHost/StillImageHost.c
+++ b/Demos/Host/ClassDriver/StillImageHost/StillImageHost.c
@@ -45,8 +45,13 @@ USB_ClassInfo_SI_Host_t DigitalCamera_SI_Interface =
 		.Config =
 			{
 				.DataINPipeNumber       = 1,
+				.DataINPipeDoubleBank   = false,
+				
 				.DataOUTPipeNumber      = 2,
+				.DataOUTPipeDoubleBank  = false,
+				
 				.EventsPipeNumber       = 3,
+				.EventsPipeDoubleBank   = false,
 			},
 	};
 
diff --git a/LUFA/Drivers/USB/Class/Device/Audio.c b/LUFA/Drivers/USB/Class/Device/Audio.c
index 337437c94..abc754606 100644
--- a/LUFA/Drivers/USB/Class/Device/Audio.c
+++ b/LUFA/Drivers/USB/Class/Device/Audio.c
@@ -48,7 +48,7 @@ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const Audi
 			{
 				Endpoint_ClearSETUP();
 				
-				AudioInterfaceInfo->State.InterfaceEnabled = (USB_ControlRequest.wValue != 0);
+				AudioInterfaceInfo->State.InterfaceEnabled = ((USB_ControlRequest.wValue & 0xFF) != 0);
 				  
 				Endpoint_ClearStatusStage();
 			}
diff --git a/LUFA/Drivers/USB/Class/Host/CDC.c b/LUFA/Drivers/USB/Class/Host/CDC.c
index aac0931b1..db2f72183 100644
--- a/LUFA/Drivers/USB/Class/Host/CDC.c
+++ b/LUFA/Drivers/USB/Class/Host/CDC.c
@@ -35,7 +35,7 @@
 #include "CDC.h"
 
 uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, uint16_t ConfigDescriptorSize,
-                                uint8_t* ConfigDescriptorData)
+                                void* ConfigDescriptorData)
 {
 	uint8_t FoundEndpoints = 0;
 
diff --git a/LUFA/Drivers/USB/Class/Host/CDC.h b/LUFA/Drivers/USB/Class/Host/CDC.h
index 4132d882c..6b3a320f0 100644
--- a/LUFA/Drivers/USB/Class/Host/CDC.h
+++ b/LUFA/Drivers/USB/Class/Host/CDC.h
@@ -64,8 +64,13 @@
 				const struct
 				{
 					uint8_t  DataINPipeNumber; /**< Pipe number of the CDC interface's IN data pipe */
+					bool     DataINPipeDoubleBank; /** Indicates if the CDC interface's IN data pipe should use double banking */
+
 					uint8_t  DataOUTPipeNumber; /**< Pipe number of the CDC interface's OUT data pipe */
+					bool     DataOUTPipeDoubleBank; /** Indicates if the CDC interface's OUT data pipe should use double banking */
+
 					uint8_t  NotificationPipeNumber; /**< Pipe number of the CDC interface's IN notification endpoint, if used */			
+					bool     NotificationPipeDoubleBank; /** Indicates if the CDC interface's notification pipe should use double banking */
 				} Config; /**< Config data for the USB class interface within the device. All elements in this section
 				           *   <b>must</b> be set or the interface will fail to enumerate and operate correctly.
 				           */
@@ -139,7 +144,7 @@
 			 *  \return A value from the \ref CDCHost_EnumerationFailure_ErrorCodes_t enum
 			 */
 			uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, uint16_t ConfigDescriptorSize,
-			                                uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
+			                                void* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
 			
 			/** Sets the line encoding for the attached device's virtual serial port. This should be called when the LineEncoding
 			 *  values of the interface have been changed to push the new settings to the USB device.
diff --git a/LUFA/Drivers/USB/Class/Host/HID.c b/LUFA/Drivers/USB/Class/Host/HID.c
index 7d6a6dcb2..7d9b3b559 100644
--- a/LUFA/Drivers/USB/Class/Host/HID.c
+++ b/LUFA/Drivers/USB/Class/Host/HID.c
@@ -35,7 +35,7 @@
 #include "HID.h"
 
 uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, uint16_t ConfigDescriptorSize,
-                                uint8_t* ConfigDescriptorData)
+                                void* ConfigDescriptorData)
 {
 	uint8_t FoundEndpoints = 0;
 
@@ -84,7 +84,8 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
 		if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
 		{
 			Pipe_ConfigurePipe(HIDInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
-							   EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);
+							   EndpointData->EndpointAddress, EndpointData->EndpointSize,
+							   HIDInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
 			HIDInterfaceInfo->State.DataINPipeSize = EndpointData->EndpointSize;
 			
 			FoundEndpoints |= HID_FOUND_DATAPIPE_IN;
@@ -92,7 +93,8 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
 		else
 		{
 			Pipe_ConfigurePipe(HIDInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_INTERRUPT, PIPE_TOKEN_OUT,
-							   EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);
+							   EndpointData->EndpointAddress, EndpointData->EndpointSize,
+							   HIDInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
 			HIDInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize;
 			
 			HIDInterfaceInfo->State.DeviceUsesOUTPipe = true;
diff --git a/LUFA/Drivers/USB/Class/Host/HID.h b/LUFA/Drivers/USB/Class/Host/HID.h
index a852f10d9..89cb3d860 100644
--- a/LUFA/Drivers/USB/Class/Host/HID.h
+++ b/LUFA/Drivers/USB/Class/Host/HID.h
@@ -70,7 +70,10 @@
 				const struct
 				{
 					uint8_t  DataINPipeNumber; /**< Pipe number of the HID interface's IN data pipe */
+					bool     DataINPipeDoubleBank; /** Indicates if the HID interface's IN data pipe should use double banking */
+
 					uint8_t  DataOUTPipeNumber; /**< Pipe number of the HID interface's OUT data pipe */
+					bool     DataOUTPipeDoubleBank; /** Indicates if the HID interface's OUT data pipe should use double banking */
 
 					uint8_t  HIDInterfaceProtocol; /**< HID interface protocol value to match against if a specific
 					                                *   boot subclass protocol is required, either \ref HID_BOOT_MOUSE_PROTOCOL,
@@ -151,7 +154,7 @@
 			 *  \return A value from the \ref HIDHost_EnumerationFailure_ErrorCodes_t enum
 			 */
 			uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, uint16_t ConfigDescriptorSize,
-			                                uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
+			                                void* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
 
 
 			/** Receives a HID IN report from the attached HID device, when a report has been received on the HID IN Data pipe.
diff --git a/LUFA/Drivers/USB/Class/Host/MIDI.c b/LUFA/Drivers/USB/Class/Host/MIDI.c
index 69118cd5b..5d3b148a0 100644
--- a/LUFA/Drivers/USB/Class/Host/MIDI.c
+++ b/LUFA/Drivers/USB/Class/Host/MIDI.c
@@ -35,7 +35,7 @@
 #include "MIDI.h"
 
 uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo, uint16_t ConfigDescriptorSize,
-                                 uint8_t* ConfigDescriptorData)
+                                 void* ConfigDescriptorData)
 {
 	uint8_t FoundEndpoints = 0;
 
@@ -63,7 +63,8 @@ uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceI
 		if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
 		{
 			Pipe_ConfigurePipe(MIDIInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_IN,
-							   EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);
+							   EndpointData->EndpointAddress, EndpointData->EndpointSize,
+							   MIDIInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
 			MIDIInterfaceInfo->State.DataINPipeSize = EndpointData->EndpointSize;
 			
 			FoundEndpoints |= MIDI_FOUND_DATAPIPE_IN;
@@ -71,7 +72,8 @@ uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceI
 		else
 		{
 			Pipe_ConfigurePipe(MIDIInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,
-							   EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);
+							   EndpointData->EndpointAddress, EndpointData->EndpointSize,
+							   MIDIInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
 			MIDIInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize;
 
 			FoundEndpoints |= MIDI_FOUND_DATAPIPE_OUT;
diff --git a/LUFA/Drivers/USB/Class/Host/MIDI.h b/LUFA/Drivers/USB/Class/Host/MIDI.h
index 35671f902..cc294a42e 100644
--- a/LUFA/Drivers/USB/Class/Host/MIDI.h
+++ b/LUFA/Drivers/USB/Class/Host/MIDI.h
@@ -64,7 +64,10 @@
 				const struct
 				{
 					uint8_t  DataINPipeNumber; /**< Pipe number of the MIDI interface's streaming IN data pipe */
+					bool     DataINPipeDoubleBank; /** Indicates if the MIDI interface's IN data pipe should use double banking */
+					
 					uint8_t  DataOUTPipeNumber; /**< Pipe number of the MIDI interface's streaming OUT data pipe */
+					bool     DataOUTPipeDoubleBank; /** Indicates if the MIDI interface's OUT data pipe should use double banking */
 				} Config; /**< Config data for the USB class interface within the device. All elements in this section
 				           *   <b>must</b> be set or the interface will fail to enumerate and operate correctly.
 				           */
@@ -114,7 +117,7 @@
 			 *  \return A value from the \ref MIDIHost_EnumerationFailure_ErrorCodes_t enum
 			 */
 			uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo, uint16_t ConfigDescriptorSize,
-			                                 uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
+			                                 void* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
 
 			/** Sends a MIDI event packet to the device. If no device is connected, the event packet is discarded.
 			 *
diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.c b/LUFA/Drivers/USB/Class/Host/MassStorage.c
index 32518626d..d1622c17d 100644
--- a/LUFA/Drivers/USB/Class/Host/MassStorage.c
+++ b/LUFA/Drivers/USB/Class/Host/MassStorage.c
@@ -35,7 +35,7 @@
 #include "MassStorage.h"
 
 uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, uint16_t ConfigDescriptorSize,
-							   uint8_t* DeviceConfigDescriptor)
+							   void* DeviceConfigDescriptor)
 {
 	uint8_t FoundEndpoints = 0;
 	
@@ -66,7 +66,7 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, u
 		{
 			Pipe_ConfigurePipe(MSInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_IN,
 			                   EndpointData->EndpointAddress, EndpointData->EndpointSize,
-			                   PIPE_BANK_DOUBLE);
+			                   MSInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
 			MSInterfaceInfo->State.DataINPipeSize = EndpointData->EndpointSize;
 
 			FoundEndpoints |= MS_FOUND_DATAPIPE_IN;
@@ -75,7 +75,7 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, u
 		{
 			Pipe_ConfigurePipe(MSInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,
 			                   EndpointData->EndpointAddress, EndpointData->EndpointSize,
-			                   PIPE_BANK_DOUBLE);
+			                   MSInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
 			MSInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize;
 
 			FoundEndpoints |= MS_FOUND_DATAPIPE_OUT;
diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.h b/LUFA/Drivers/USB/Class/Host/MassStorage.h
index a651a88f8..4cd37bdf3 100644
--- a/LUFA/Drivers/USB/Class/Host/MassStorage.h
+++ b/LUFA/Drivers/USB/Class/Host/MassStorage.h
@@ -67,8 +67,11 @@
 			{
 				const struct
 				{
-					uint8_t  DataINPipeNumber; /**< Pipe number of the MS interface's IN data pipe */
-					uint8_t  DataOUTPipeNumber; /**< Pipe number of the MS interface's OUT data pipe */
+					uint8_t  DataINPipeNumber; /**< Pipe number of the Mass Storage interface's IN data pipe */
+					bool     DataINPipeDoubleBank; /** Indicates if the Mass Storage interface's IN data pipe should use double banking */
+
+					uint8_t  DataOUTPipeNumber; /**< Pipe number of the Mass Storage interface's OUT data pipe */
+					bool     DataOUTPipeDoubleBank; /** Indicates if the Mass Storage interface's OUT data pipe should use double banking */
 				} Config; /**< Config data for the USB class interface within the device. All elements in this section
 				           *   <b>must</b> be set or the interface will fail to enumerate and operate correctly.
 				           */
@@ -80,8 +83,8 @@
 					                */
 					uint8_t InterfaceNumber; /**< Interface index of the Mass Storage interface within the attached device */
 
-					uint16_t DataINPipeSize; /**< Size in bytes of the MS interface's IN data pipe */
-					uint16_t DataOUTPipeSize;  /**< Size in bytes of the MS interface's OUT data pipe */
+					uint16_t DataINPipeSize; /**< Size in bytes of the Mass Storage interface's IN data pipe */
+					uint16_t DataOUTPipeSize;  /**< Size in bytes of the Mass Storage interface's OUT data pipe */
 					
 					uint32_t TransactionTag; /**< Current transaction tag for data synchronising of packets */
 				} State; /**< State data for the USB class interface within the device. All elements in this section
@@ -194,7 +197,7 @@
 			 *  \return A value from the \ref MSHost_EnumerationFailure_ErrorCodes_t enum
 			 */
 			uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, uint16_t ConfigDescriptorSize,
-			                               uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
+			                               void* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
 
 			/** Sends a MASS STORAGE RESET control request to the attached device, resetting the Mass Storage Interface
 			 *  and readying it for the next Mass Storage command.
diff --git a/LUFA/Drivers/USB/Class/Host/Printer.c b/LUFA/Drivers/USB/Class/Host/Printer.c
index bc8fba85f..192e17f86 100644
--- a/LUFA/Drivers/USB/Class/Host/Printer.c
+++ b/LUFA/Drivers/USB/Class/Host/Printer.c
@@ -35,7 +35,7 @@
 #include "Printer.h"
 
 uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo, uint16_t ConfigDescriptorSize,
-							     uint8_t* DeviceConfigDescriptor)
+							     void* DeviceConfigDescriptor)
 {
 	uint8_t FoundEndpoints = 0;
 	
@@ -69,7 +69,7 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
 		{
 			Pipe_ConfigurePipe(PRNTInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_IN,
 			                   EndpointData->EndpointAddress, EndpointData->EndpointSize,
-			                   PIPE_BANK_DOUBLE);
+			                   PRNTInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
 			PRNTInterfaceInfo->State.DataINPipeSize = EndpointData->EndpointSize;
 
 			FoundEndpoints |= PRNT_FOUND_DATAPIPE_IN;
@@ -78,7 +78,7 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
 		{
 			Pipe_ConfigurePipe(PRNTInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,
 			                   EndpointData->EndpointAddress, EndpointData->EndpointSize,
-			                   PIPE_BANK_DOUBLE);
+			                   PRNTInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
 			PRNTInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize;
 
 			FoundEndpoints |= PRNT_FOUND_DATAPIPE_OUT;
diff --git a/LUFA/Drivers/USB/Class/Host/Printer.h b/LUFA/Drivers/USB/Class/Host/Printer.h
index d61eb4a71..34f8e4e88 100644
--- a/LUFA/Drivers/USB/Class/Host/Printer.h
+++ b/LUFA/Drivers/USB/Class/Host/Printer.h
@@ -66,7 +66,10 @@
 				const struct
 				{
 					uint8_t  DataINPipeNumber; /**< Pipe number of the Printer interface's IN data pipe */
+					bool     DataINPipeDoubleBank; /** Indicates if the Printer interface's IN data pipe should use double banking */
+
 					uint8_t  DataOUTPipeNumber; /**< Pipe number of the Printer interface's OUT data pipe */
+					bool     DataOUTPipeDoubleBank; /** Indicates if the Printer interface's OUT data pipe should use double banking */
 				} Config; /**< Config data for the USB class interface within the device. All elements in this section
 				           *   <b>must</b> be set or the interface will fail to enumerate and operate correctly.
 				           */
@@ -119,7 +122,7 @@
 			 *  \return A value from the \ref PRNTHost_EnumerationFailure_ErrorCodes_t enum
 			 */
 			uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo, uint16_t ConfigDescriptorSize,
-			                                 uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
+			                                 void* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
 			
 			/** Configures the printer to enable Bidirectional mode, if it is not already in this mode. This should be called
 			 *  once the connected device's configuration has been set, to ensure the printer is ready to accept commands.
diff --git a/LUFA/Drivers/USB/Class/Host/StillImage.c b/LUFA/Drivers/USB/Class/Host/StillImage.c
index f98f508b2..e809c92dd 100644
--- a/LUFA/Drivers/USB/Class/Host/StillImage.c
+++ b/LUFA/Drivers/USB/Class/Host/StillImage.c
@@ -35,7 +35,7 @@
 #include "StillImage.h"
 
 uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, uint16_t ConfigDescriptorSize,
-                              uint8_t* DeviceConfigDescriptor)
+                               void* DeviceConfigDescriptor)
 {
 	uint8_t  FoundEndpoints = 0;
 	
@@ -66,7 +66,7 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, u
 			{
 				Pipe_ConfigurePipe(SIInterfaceInfo->Config.EventsPipeNumber, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
 								   EndpointData->EndpointAddress, EndpointData->EndpointSize,
-								   PIPE_BANK_DOUBLE);			
+								   SIInterfaceInfo->Config.EventsPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);			
 				SIInterfaceInfo->State.EventsPipeSize = EndpointData->EndpointSize;
 
 				Pipe_SetInterruptPeriod(EndpointData->PollingIntervalMS);
@@ -80,7 +80,7 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, u
 			{
 				Pipe_ConfigurePipe(SIInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_IN,
 								   EndpointData->EndpointAddress, EndpointData->EndpointSize,
-								   PIPE_BANK_DOUBLE);
+								   SIInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
 				SIInterfaceInfo->State.DataINPipeSize = EndpointData->EndpointSize;
 
 				FoundEndpoints |= SI_FOUND_DATAPIPE_IN;
@@ -89,7 +89,7 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, u
 			{
 				Pipe_ConfigurePipe(SIInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,
 								   EndpointData->EndpointAddress, EndpointData->EndpointSize,
-								   PIPE_BANK_DOUBLE);
+								   SIInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
 				SIInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize;
 
 				FoundEndpoints |= SI_FOUND_DATAPIPE_OUT;
diff --git a/LUFA/Drivers/USB/Class/Host/StillImage.h b/LUFA/Drivers/USB/Class/Host/StillImage.h
index 4f7f7fad8..0493470d9 100644
--- a/LUFA/Drivers/USB/Class/Host/StillImage.h
+++ b/LUFA/Drivers/USB/Class/Host/StillImage.h
@@ -64,8 +64,13 @@
 				const struct
 				{
 					uint8_t  DataINPipeNumber; /**< Pipe number of the Still Image interface's IN data pipe */
+					bool     DataINPipeDoubleBank; /** Indicates if the Still Image interface's IN data pipe should use double banking */
+
 					uint8_t  DataOUTPipeNumber; /**< Pipe number of the Still Image interface's OUT data pipe */
+					bool     DataOUTPipeDoubleBank; /** Indicates if the Still Image interface's OUT data pipe should use double banking */
+
 					uint8_t  EventsPipeNumber; /**< Pipe number of the Still Image interface's IN events endpoint, if used */			
+					bool     EventsPipeDoubleBank; /** Indicates if the Still Image interface's events data pipe should use double banking */
 				} Config; /**< Config data for the USB class interface within the device. All elements in this section
 				           *   <b>must</b> be set or the interface will fail to enumerate and operate correctly.
 				           */
@@ -125,7 +130,7 @@
 			 *  \return A value from the \ref SIHost_EnumerationFailure_ErrorCodes_t enum
 			 */
 			uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, uint16_t ConfigDescriptorSize,
-                                           uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
+                                           void* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
 
 			/** Opens a new PIMA session with the attached device. This should be used before any session-orientated PIMA commands
 			 *  are issued to the device. Only one session can be open at the one time.
diff --git a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c
index 6b20f4642..5857fba19 100644
--- a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c
+++ b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c
@@ -69,7 +69,7 @@ uint8_t USB_GetDeviceConfigDescriptor(uint8_t ConfigNumber, uint16_t* const Conf
 #endif
 
 void USB_GetNextDescriptorOfType(uint16_t* const BytesRem,
-                                 uint8_t** const CurrConfigLoc,
+                                 void** const CurrConfigLoc,
                                  const uint8_t Type)
 {
 	while (*BytesRem)
@@ -82,7 +82,7 @@ void USB_GetNextDescriptorOfType(uint16_t* const BytesRem,
 }
 
 void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,
-                                       uint8_t** const CurrConfigLoc,
+                                       void** const CurrConfigLoc,
                                        const uint8_t Type,
                                        const uint8_t BeforeType)
 {
@@ -103,7 +103,7 @@ void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,
 }
 
 void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
-                                      uint8_t** const CurrConfigLoc,
+                                      void** const CurrConfigLoc,
                                       const uint8_t Type,
                                       const uint8_t AfterType)
 {
@@ -113,7 +113,7 @@ void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
 	  USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, Type);
 }
 			
-uint8_t USB_GetNextDescriptorComp(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine)
+uint8_t USB_GetNextDescriptorComp(uint16_t* BytesRem, void** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine)
 {
 	uint8_t ErrorCode;
 		
diff --git a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h
index 9af0f6052..6d57d2e78 100644
--- a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h
+++ b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h
@@ -152,7 +152,7 @@
 			 *  }
 			 *  \endcode
 			 */
-			uint8_t USB_GetNextDescriptorComp(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine);
+			uint8_t USB_GetNextDescriptorComp(uint16_t* BytesRem, void** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine);
 			
 		/* Enums: */
 			/** Enum for the possible return codes of the \ref USB_GetDeviceConfigDescriptor() function. */
@@ -213,7 +213,7 @@
 			 * \param[in] Type  Descriptor type value to search for
 			 */
 			void USB_GetNextDescriptorOfType(uint16_t* const BytesRem,
-			                                 uint8_t** const CurrConfigLoc,
+			                                 void** const CurrConfigLoc,
 			                                 const uint8_t Type)
 			                                 ATTR_NON_NULL_PTR_ARG(1, 2);
 
@@ -228,7 +228,7 @@
 			 * \param[in] BeforeType  Descriptor type value which must not be reached before the given Type descriptor
 			 */
 			void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,
-			                                       uint8_t** const CurrConfigLoc,
+			                                       void** const CurrConfigLoc,
 			                                       const uint8_t Type,
 			                                       const uint8_t BeforeType)
 			                                       ATTR_NON_NULL_PTR_ARG(1, 2);
@@ -243,7 +243,7 @@
 			 * \param[in] AfterType  Descriptor type value which must be reached before the given Type descriptor
 			 */
 			void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
-			                                      uint8_t** const CurrConfigLoc,
+			                                      void** const CurrConfigLoc,
 			                                      const uint8_t Type,
 			                                      const uint8_t AfterType)
 			                                      ATTR_NON_NULL_PTR_ARG(1, 2);
@@ -256,10 +256,10 @@
 			 * \param[in,out] CurrConfigLoc  Pointer to the current descriptor inside the configuration descriptor
 			 */
 			static inline void USB_GetNextDescriptor(uint16_t* const BytesRem,
-			                                         uint8_t** const CurrConfigLoc) 
+			                                         void** const CurrConfigLoc) 
 			                                         ATTR_NON_NULL_PTR_ARG(1, 2);									  
 			static inline void USB_GetNextDescriptor(uint16_t* const BytesRem,
-			                                         uint8_t** const CurrConfigLoc)
+			                                         void** const CurrConfigLoc)
 			{
 				uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size;
 
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c
index 89c4e2998..bb6104fec 100644
--- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c
+++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c
@@ -228,7 +228,7 @@ static void USB_Device_GetInternalSerialDescriptor(void)
 	SignatureDescriptor.Header.Size  = sizeof(SignatureDescriptor);
 	SignatureDescriptor.Header.Type  = DTYPE_String;
 	
-	uint8_t  SigReadAddress     = 0x0E;
+	uint8_t  SigReadAddress = 0x0E;
 
 	for (uint8_t SerialCharNum = 0; SerialCharNum < 20; SerialCharNum++)
 	{
@@ -314,7 +314,7 @@ static void USB_Device_GetStatus(void)
 			break;
 #if !defined(CONTROL_ONLY_DEVICE)
 		case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT):
-			Endpoint_SelectEndpoint((uint8_t)USB_ControlRequest.wIndex);
+			Endpoint_SelectEndpoint(USB_ControlRequest.wIndex & 0xFF);
 
 			CurrentStatus = Endpoint_IsStalled();
 
-- 
GitLab