Commit 64e5c408 authored by Dean Camera's avatar Dean Camera
Browse files

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.
parent f29fc1ab
......@@ -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,
......
......@@ -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,
},
......
......@@ -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,
......
......@@ -45,7 +45,10 @@ USB_ClassInfo_MIDI_Host_t Keyboard_MIDI_Interface =
.Config =
{
.DataINPipeNumber = 1,
.DataINPipeDoubleBank = false,
.DataOUTPipeNumber = 2,
.DataOUTPipeDoubleBank = false,
},
};
......
......@@ -45,7 +45,10 @@ USB_ClassInfo_MS_Host_t FlashDisk_MS_Interface =
.Config =
{
.DataINPipeNumber = 1,
.DataINPipeDoubleBank = false,
.DataOUTPipeNumber = 2,
.DataOUTPipeDoubleBank = false,
},
};
......
......@@ -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,
},
......
......@@ -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,
......
......@@ -45,7 +45,10 @@ USB_ClassInfo_PRNT_Host_t Printer_PRNT_Interface =
.Config =
{
.DataINPipeNumber = 1,
.DataINPipeDoubleBank = false,
.DataOUTPipeNumber = 2,
.DataOUTPipeDoubleBank = false,
},
};
......
......@@ -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,
},
};
......
......@@ -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();
}
......
......@@ -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;
......
......@@ -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.
......
......@@ -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;
......
......@@ -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.
......
......@@ -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;
......
......@@ -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.
*
......
......@@ -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;
......
......@@ -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.
......
......@@ -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;
......
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment