Commit f7ab433c authored by Dean Camera's avatar Dean Camera
Browse files

Add optional double-banking support to the Device mode Class Drivers, on a...

Add optional double-banking support to the Device mode Class Drivers, on a per-endpoint, per-interface level.
parent 1c7aa685
......@@ -44,16 +44,19 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
{
.Config =
{
.ControlInterfaceNumber = 0,
.ControlInterfaceNumber = 0,
.DataINEndpointNumber = CDC_TX_EPNUM,
.DataINEndpointSize = CDC_TXRX_EPSIZE,
.DataINEndpointNumber = CDC_TX_EPNUM,
.DataINEndpointSize = CDC_TXRX_EPSIZE,
.DataINEndpointDoubleBank = false,
.DataOUTEndpointNumber = CDC_RX_EPNUM,
.DataOUTEndpointSize = CDC_TXRX_EPSIZE,
.DataOUTEndpointNumber = CDC_RX_EPNUM,
.DataOUTEndpointSize = CDC_TXRX_EPSIZE,
.DataOUTEndpointDoubleBank = false,
.NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
.NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
.NotificationEndpointDoubleBank = false,
},
};
......
......@@ -44,16 +44,19 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
{
.Config =
{
.ControlInterfaceNumber = 0,
.ControlInterfaceNumber = 0,
.DataINEndpointNumber = CDC_TX_EPNUM,
.DataINEndpointSize = CDC_TXRX_EPSIZE,
.DataINEndpointNumber = CDC_TX_EPNUM,
.DataINEndpointSize = CDC_TXRX_EPSIZE,
.DataINEndpointDoubleBank = false,
.DataOUTEndpointNumber = CDC_RX_EPNUM,
.DataOUTEndpointSize = CDC_TXRX_EPSIZE,
.DataOUTEndpointNumber = CDC_RX_EPNUM,
.DataOUTEndpointSize = CDC_TXRX_EPSIZE,
.DataOUTEndpointDoubleBank = false,
.NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
.NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
.NotificationEndpointDoubleBank = false,
},
};
......@@ -68,13 +71,14 @@ USB_ClassInfo_HID_Device_t Mouse_HID_Interface =
{
.Config =
{
.InterfaceNumber = 0,
.InterfaceNumber = 0,
.ReportINEndpointNumber = MOUSE_EPNUM,
.ReportINEndpointSize = MOUSE_EPSIZE,
.ReportINEndpointNumber = MOUSE_EPNUM,
.ReportINEndpointSize = MOUSE_EPSIZE,
.ReportINEndpointDoubleBank = false,
.PrevReportINBuffer = PrevMouseHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevMouseHIDReportBuffer),
.PrevReportINBuffer = PrevMouseHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevMouseHIDReportBuffer),
},
};
......
......@@ -45,16 +45,19 @@ USB_ClassInfo_CDC_Device_t VirtualSerial1_CDC_Interface =
{
.Config =
{
.ControlInterfaceNumber = 0,
.ControlInterfaceNumber = 0,
.DataINEndpointNumber = CDC1_TX_EPNUM,
.DataINEndpointSize = CDC_TXRX_EPSIZE,
.DataINEndpointNumber = CDC1_TX_EPNUM,
.DataINEndpointSize = CDC_TXRX_EPSIZE,
.DataINEndpointDoubleBank = false,
.DataOUTEndpointNumber = CDC1_RX_EPNUM,
.DataOUTEndpointSize = CDC_TXRX_EPSIZE,
.DataOUTEndpointNumber = CDC1_RX_EPNUM,
.DataOUTEndpointSize = CDC_TXRX_EPSIZE,
.DataOUTEndpointDoubleBank = false,
.NotificationEndpointNumber = CDC1_NOTIFICATION_EPNUM,
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
.NotificationEndpointNumber = CDC1_NOTIFICATION_EPNUM,
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
.NotificationEndpointDoubleBank = false,
},
};
......@@ -67,16 +70,19 @@ USB_ClassInfo_CDC_Device_t VirtualSerial2_CDC_Interface =
{
.Config =
{
.ControlInterfaceNumber = 2,
.ControlInterfaceNumber = 2,
.DataINEndpointNumber = CDC2_TX_EPNUM,
.DataINEndpointSize = CDC_TXRX_EPSIZE,
.DataINEndpointNumber = CDC2_TX_EPNUM,
.DataINEndpointSize = CDC_TXRX_EPSIZE,
.DataINEndpointDoubleBank = false,
.DataOUTEndpointNumber = CDC2_RX_EPNUM,
.DataOUTEndpointSize = CDC_TXRX_EPSIZE,
.DataOUTEndpointNumber = CDC2_RX_EPNUM,
.DataOUTEndpointSize = CDC_TXRX_EPSIZE,
.DataOUTEndpointDoubleBank = false,
.NotificationEndpointNumber = CDC2_NOTIFICATION_EPNUM,
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
.NotificationEndpointNumber = CDC2_NOTIFICATION_EPNUM,
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
.NotificationEndpointDoubleBank = false,
},
};
......
......@@ -55,13 +55,14 @@ USB_ClassInfo_HID_Device_t Generic_HID_Interface =
{
.Config =
{
.InterfaceNumber = 0,
.InterfaceNumber = 0,
.ReportINEndpointNumber = GENERIC_IN_EPNUM,
.ReportINEndpointSize = GENERIC_EPSIZE,
.ReportINEndpointNumber = GENERIC_IN_EPNUM,
.ReportINEndpointSize = GENERIC_EPSIZE,
.ReportINEndpointDoubleBank = false,
.PrevReportINBuffer = PrevHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevHIDReportBuffer),
.PrevReportINBuffer = PrevHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevHIDReportBuffer),
},
};
......
......@@ -47,13 +47,14 @@ USB_ClassInfo_HID_Device_t Joystick_HID_Interface =
{
.Config =
{
.InterfaceNumber = 0,
.InterfaceNumber = 0,
.ReportINEndpointNumber = JOYSTICK_EPNUM,
.ReportINEndpointSize = JOYSTICK_EPSIZE,
.ReportINEndpointNumber = JOYSTICK_EPNUM,
.ReportINEndpointSize = JOYSTICK_EPSIZE,
.ReportINEndpointDoubleBank = false,
.PrevReportINBuffer = PrevJoystickHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevJoystickHIDReportBuffer),
.PrevReportINBuffer = PrevJoystickHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevJoystickHIDReportBuffer),
},
};
......
......@@ -48,13 +48,14 @@ USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
{
.Config =
{
.InterfaceNumber = 0,
.InterfaceNumber = 0,
.ReportINEndpointNumber = KEYBOARD_EPNUM,
.ReportINEndpointSize = KEYBOARD_EPSIZE,
.ReportINEndpointNumber = KEYBOARD_EPNUM,
.ReportINEndpointSize = KEYBOARD_EPSIZE,
.ReportINEndpointDoubleBank = false,
.PrevReportINBuffer = PrevKeyboardHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer),
.PrevReportINBuffer = PrevKeyboardHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer),
},
};
......
......@@ -52,13 +52,14 @@ USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
{
.Config =
{
.InterfaceNumber = 0,
.InterfaceNumber = 0,
.ReportINEndpointNumber = KEYBOARD_IN_EPNUM,
.ReportINEndpointSize = HID_EPSIZE,
.ReportINEndpointNumber = KEYBOARD_IN_EPNUM,
.ReportINEndpointSize = HID_EPSIZE,
.ReportINEndpointDoubleBank = false,
.PrevReportINBuffer = PrevKeyboardHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer),
.PrevReportINBuffer = PrevKeyboardHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer),
},
};
......
......@@ -46,11 +46,13 @@ USB_ClassInfo_MIDI_Device_t Keyboard_MIDI_Interface =
{
.StreamingInterfaceNumber = 1,
.DataINEndpointNumber = MIDI_STREAM_IN_EPNUM,
.DataINEndpointSize = MIDI_STREAM_EPSIZE,
.DataINEndpointNumber = MIDI_STREAM_IN_EPNUM,
.DataINEndpointSize = MIDI_STREAM_EPSIZE,
.DataINEndpointDoubleBank = false,
.DataOUTEndpointNumber = MIDI_STREAM_OUT_EPNUM,
.DataOUTEndpointSize = MIDI_STREAM_EPSIZE,
.DataOUTEndpointNumber = MIDI_STREAM_OUT_EPNUM,
.DataOUTEndpointSize = MIDI_STREAM_EPSIZE,
.DataOUTEndpointDoubleBank = false,
},
};
......
......@@ -44,15 +44,17 @@ USB_ClassInfo_MS_Device_t Disk_MS_Interface =
{
.Config =
{
.InterfaceNumber = 0,
.InterfaceNumber = 0,
.DataINEndpointNumber = MASS_STORAGE_IN_EPNUM,
.DataINEndpointSize = MASS_STORAGE_IO_EPSIZE,
.DataINEndpointNumber = MASS_STORAGE_IN_EPNUM,
.DataINEndpointSize = MASS_STORAGE_IO_EPSIZE,
.DataINEndpointDoubleBank = false,
.DataOUTEndpointNumber = MASS_STORAGE_OUT_EPNUM,
.DataOUTEndpointSize = MASS_STORAGE_IO_EPSIZE,
.DataOUTEndpointNumber = MASS_STORAGE_OUT_EPNUM,
.DataOUTEndpointSize = MASS_STORAGE_IO_EPSIZE,
.DataOUTEndpointDoubleBank = false,
.TotalLUNs = TOTAL_LUNS,
.TotalLUNs = TOTAL_LUNS,
},
};
......
......@@ -36,6 +36,28 @@
*/
#include "MassStorageKeyboard.h"
/** LUFA Mass Storage Class driver interface configuration and state information. This structure is
* passed to all Mass Storage Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
USB_ClassInfo_MS_Device_t Disk_MS_Interface =
{
.Config =
{
.InterfaceNumber = 0,
.DataINEndpointNumber = MASS_STORAGE_IN_EPNUM,
.DataINEndpointSize = MASS_STORAGE_IO_EPSIZE,
.DataINEndpointDoubleBank = false,
.DataOUTEndpointNumber = MASS_STORAGE_OUT_EPNUM,
.DataOUTEndpointSize = MASS_STORAGE_IO_EPSIZE,
.DataOUTEndpointDoubleBank = false,
.TotalLUNs = TOTAL_LUNS,
},
};
/** Buffer to hold the previously generated Keyboard HID report, for comparison purposes inside the HID class driver. */
uint8_t PrevKeyboardHIDReportBuffer[sizeof(USB_KeyboardReport_Data_t)];
......@@ -48,35 +70,16 @@ USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
{
.Config =
{
.InterfaceNumber = 1,
.InterfaceNumber = 1,
.ReportINEndpointNumber = KEYBOARD_EPNUM,
.ReportINEndpointSize = KEYBOARD_EPSIZE,
.ReportINEndpointNumber = KEYBOARD_EPNUM,
.ReportINEndpointSize = KEYBOARD_EPSIZE,
.ReportINEndpointDoubleBank = false,
.PrevReportINBuffer = PrevKeyboardHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer),
.PrevReportINBuffer = PrevKeyboardHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer),
},
};
/** LUFA Mass Storage Class driver interface configuration and state information. This structure is
* passed to all Mass Storage Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
USB_ClassInfo_MS_Device_t Disk_MS_Interface =
{
.Config =
{
.InterfaceNumber = 0,
.DataINEndpointNumber = MASS_STORAGE_IN_EPNUM,
.DataINEndpointSize = MASS_STORAGE_IO_EPSIZE,
.DataOUTEndpointNumber = MASS_STORAGE_OUT_EPNUM,
.DataOUTEndpointSize = MASS_STORAGE_IO_EPSIZE,
.TotalLUNs = TOTAL_LUNS,
},
};
/** Main program entry point. This routine contains the overall program flow, including initial
* setup of all components and the main program loop.
......
......@@ -47,13 +47,14 @@ USB_ClassInfo_HID_Device_t Mouse_HID_Interface =
{
.Config =
{
.InterfaceNumber = 0,
.InterfaceNumber = 0,
.ReportINEndpointNumber = MOUSE_EPNUM,
.ReportINEndpointSize = MOUSE_EPSIZE,
.ReportINEndpointNumber = MOUSE_EPNUM,
.ReportINEndpointSize = MOUSE_EPSIZE,
.ReportINEndpointDoubleBank = false,
.PrevReportINBuffer = PrevMouseHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevMouseHIDReportBuffer),
.PrevReportINBuffer = PrevMouseHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevMouseHIDReportBuffer),
},
};
......
......@@ -44,19 +44,22 @@ USB_ClassInfo_RNDIS_Device_t Ethernet_RNDIS_Interface =
{
.Config =
{
.ControlInterfaceNumber = 0,
.ControlInterfaceNumber = 0,
.DataINEndpointNumber = CDC_TX_EPNUM,
.DataINEndpointSize = CDC_TXRX_EPSIZE,
.DataINEndpointNumber = CDC_TX_EPNUM,
.DataINEndpointSize = CDC_TXRX_EPSIZE,
.DataINEndpointDoubleBank = false,
.DataOUTEndpointNumber = CDC_RX_EPNUM,
.DataOUTEndpointSize = CDC_TXRX_EPSIZE,
.DataOUTEndpointNumber = CDC_RX_EPNUM,
.DataOUTEndpointSize = CDC_TXRX_EPSIZE,
.DataOUTEndpointDoubleBank = false,
.NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
.NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
.NotificationEndpointDoubleBank = false,
.AdapterVendorDescription = "LUFA RNDIS Demo Adapter",
.AdapterMACAddress = {ADAPTER_MAC_ADDRESS},
.AdapterVendorDescription = "LUFA RNDIS Demo Adapter",
.AdapterMACAddress = {ADAPTER_MAC_ADDRESS},
},
};
......
......@@ -47,13 +47,14 @@ USB_ClassInfo_HID_Device_t Mouse_HID_Device_Interface =
{
.Config =
{
.InterfaceNumber = 0,
.InterfaceNumber = 0,
.ReportINEndpointNumber = MOUSE_EPNUM,
.ReportINEndpointSize = MOUSE_EPSIZE,
.ReportINEndpointNumber = MOUSE_EPNUM,
.ReportINEndpointSize = MOUSE_EPSIZE,
.ReportINEndpointDoubleBank = false,
.PrevReportINBuffer = PrevMouseHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevMouseHIDReportBuffer),
.PrevReportINBuffer = PrevMouseHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevMouseHIDReportBuffer),
},
};
......
......@@ -57,13 +57,9 @@
/* Includes: */
#include <avr/io.h>
#include <stdio.h>
#include <avr/version.h>
#include "FunctionAttributes.h"
#include "BoardTypes.h"
#include <alloca.h>
/* Public Interface - May be used in end-application: */
/* Macros: */
......
......@@ -66,21 +66,21 @@
const struct
{
uint8_t StreamingInterfaceNumber; /**< Index of the Audio Streaming interface within the device this
* structure controls.
* structure controls
*/
uint8_t DataINEndpointNumber; /**< Endpoint number of the incomming Audio Streaming data, if available
* (zero if unused).
* (zero if unused)
*/
uint16_t DataINEndpointSize; /**< Size in bytes of the incomming Audio Streaming data endpoint, if available
* (zero if unused).
* (zero if unused)
*/
uint8_t DataOUTEndpointNumber; /**< Endpoint number of the outgoing Audio Streaming data, if available
* (zero if unused).
* (zero if unused)
*/
uint16_t DataOUTEndpointSize; /**< Size in bytes of the outgoing Audio Streaming data endpoint, if available
* (zero if unused).
* (zero if unused)
*/
} 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.
......
......@@ -91,21 +91,21 @@ bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
if (!(Endpoint_ConfigureEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber, EP_TYPE_BULK,
ENDPOINT_DIR_IN, CDCInterfaceInfo->Config.DataINEndpointSize,
ENDPOINT_BANK_SINGLE)))
CDCInterfaceInfo->Config.DataINEndpointDoubleBank ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
{
return false;
}
if (!(Endpoint_ConfigureEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber, EP_TYPE_BULK,
ENDPOINT_DIR_OUT, CDCInterfaceInfo->Config.DataOUTEndpointSize,
ENDPOINT_BANK_SINGLE)))
CDCInterfaceInfo->Config.DataOUTEndpointDoubleBank ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
{
return false;
}
if (!(Endpoint_ConfigureEndpoint(CDCInterfaceInfo->Config.NotificationEndpointNumber, EP_TYPE_INTERRUPT,
ENDPOINT_DIR_IN, CDCInterfaceInfo->Config.NotificationEndpointSize,
ENDPOINT_BANK_SINGLE)))
CDCInterfaceInfo->Config.NotificationEndpointDoubleBank ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
{
return false;
}
......
......@@ -69,12 +69,15 @@
uint8_t DataINEndpointNumber; /**< Endpoint number of the CDC interface's IN data endpoint */
uint16_t DataINEndpointSize; /**< Size in bytes of the CDC interface's IN data endpoint */
bool DataINEndpointDoubleBank; /** Indicates if the CDC interface's IN data endpoint should use double banking */
uint8_t DataOUTEndpointNumber; /**< Endpoint number of the CDC interface's OUT data endpoint */
uint16_t DataOUTEndpointSize; /**< Size in bytes of the CDC interface's OUT data endpoint */
bool DataOUTEndpointDoubleBank; /** Indicates if the CDC interface's OUT data endpoint should use double banking */
uint8_t NotificationEndpointNumber; /**< Endpoint number of the CDC interface's IN notification endpoint, if used */
uint16_t NotificationEndpointSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used */
bool NotificationEndpointDoubleBank; /** Indicates if the CDC interface's notification endpoint 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.
*/
......
......@@ -134,7 +134,8 @@ bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_Device_t* const HIDInterfac
HIDInterfaceInfo->State.IdleCount = 500;
if (!(Endpoint_ConfigureEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber, EP_TYPE_INTERRUPT,
ENDPOINT_DIR_IN, HIDInterfaceInfo->Config.ReportINEndpointSize, ENDPOINT_BANK_SINGLE)))
ENDPOINT_DIR_IN, HIDInterfaceInfo->Config.ReportINEndpointSize,
HIDInterfaceInfo->Config.ReportINEndpointDoubleBank ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
{
return false;
}
......
......@@ -73,6 +73,7 @@
uint8_t ReportINEndpointNumber; /**< Endpoint number of the HID interface's IN report endpoint */
uint16_t ReportINEndpointSize; /**< Size in bytes of the HID interface's IN report endpoint */
bool ReportINEndpointDoubleBank; /** Indicates if the HID interface's IN report endpoint should use double banking */
void* PrevReportINBuffer; /**< Pointer to a buffer where the previously created HID input report can be
* stored by the driver, for comparison purposes to detect report changes that
......
......@@ -46,7 +46,7 @@ bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInter
{
if (!(Endpoint_ConfigureEndpoint(MIDIInterfaceInfo->Config.DataINEndpointNumber, EP_TYPE_BULK,
ENDPOINT_DIR_IN, MIDIInterfaceInfo->Config.DataINEndpointSize,
ENDPOINT_BANK_SINGLE)))
MIDIInterfaceInfo->Config.DataINEndpointDoubleBank ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
{
return false;
}
......@@ -56,7 +56,7 @@ bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInter
{
if (!(Endpoint_ConfigureEndpoint(MIDIInterfaceInfo->Config.DataOUTEndpointNumber, EP_TYPE_BULK,
ENDPOINT_DIR_OUT, MIDIInterfaceInfo->Config.DataOUTEndpointSize,
ENDPOINT_BANK_SINGLE)))
MIDIInterfaceInfo->Config.DataOUTEndpointDoubleBank ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
{
return false;
}
......
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