aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Device
diff options
context:
space:
mode:
Diffstat (limited to 'Demos/Device')
-rw-r--r--Demos/Device/ClassDriver/AudioInput/AudioInput.c18
-rw-r--r--Demos/Device/ClassDriver/AudioOutput/AudioOutput.c20
-rw-r--r--Demos/Device/ClassDriver/CDC/CDC.c24
-rw-r--r--Demos/Device/ClassDriver/DualCDC/DualCDC.c54
-rw-r--r--Demos/Device/ClassDriver/GenericHID/GenericHID.c32
-rw-r--r--Demos/Device/ClassDriver/GenericHID/GenericHID.h5
-rw-r--r--Demos/Device/ClassDriver/Joystick/Joystick.c32
-rw-r--r--Demos/Device/ClassDriver/Joystick/Joystick.h5
-rw-r--r--Demos/Device/ClassDriver/Keyboard/Keyboard.c34
-rw-r--r--Demos/Device/ClassDriver/Keyboard/Keyboard.h5
-rw-r--r--Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c58
-rw-r--r--Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.h5
-rw-r--r--Demos/Device/ClassDriver/MIDI/MIDI.c20
-rw-r--r--Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c8
-rw-r--r--Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h4
-rw-r--r--Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c52
-rw-r--r--Demos/Device/ClassDriver/MassStorage/Lib/SCSI.h12
-rw-r--r--Demos/Device/ClassDriver/MassStorage/MassStorage.c30
-rw-r--r--Demos/Device/ClassDriver/MassStorage/MassStorage.h2
-rw-r--r--Demos/Device/ClassDriver/Mouse/Mouse.c30
-rw-r--r--Demos/Device/ClassDriver/Mouse/Mouse.h5
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c16
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h2
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c40
-rw-r--r--Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.c61
-rw-r--r--Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.h2
26 files changed, 352 insertions, 224 deletions
diff --git a/Demos/Device/ClassDriver/AudioInput/AudioInput.c b/Demos/Device/ClassDriver/AudioInput/AudioInput.c
index a361ea1a4..af0f6d2c7 100644
--- a/Demos/Device/ClassDriver/AudioInput/AudioInput.c
+++ b/Demos/Device/ClassDriver/AudioInput/AudioInput.c
@@ -40,12 +40,20 @@
* passed to all Audio Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
-USB_ClassInfo_Audio_t Microphone_Audio_Interface =
+USB_ClassInfo_Audio_Device_t Microphone_Audio_Interface =
{
- .StreamingInterfaceNumber = 1,
+ .Config =
+ {
+ .StreamingInterfaceNumber = 1,
- .DataINEndpointNumber = AUDIO_STREAM_EPNUM,
- .DataINEndpointSize = AUDIO_STREAM_EPSIZE,
+ .DataINEndpointNumber = AUDIO_STREAM_EPNUM,
+ .DataINEndpointSize = AUDIO_STREAM_EPSIZE,
+ },
+
+ .State =
+ {
+ // Leave all state values to their defaults
+ }
};
/** Main program entry point. This routine contains the overall program flow, including initial
@@ -59,7 +67,7 @@ int main(void)
for (;;)
{
- if (Microphone_Audio_Interface.InterfaceEnabled)
+ if (Microphone_Audio_Interface.State.InterfaceEnabled)
ProcessNextSample();
Audio_Device_USBTask(&Microphone_Audio_Interface);
diff --git a/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c b/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c
index 67e08f2c3..f859c7c6e 100644
--- a/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c
+++ b/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c
@@ -40,12 +40,20 @@
* passed to all Audio Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
-USB_ClassInfo_Audio_t Speaker_Audio_Interface =
+USB_ClassInfo_Audio_Device_t Speaker_Audio_Interface =
{
- .StreamingInterfaceNumber = 1,
-
- .DataOUTEndpointNumber = AUDIO_STREAM_EPNUM,
- .DataOUTEndpointSize = AUDIO_STREAM_EPSIZE,
+ .Config =
+ {
+ .StreamingInterfaceNumber = 1,
+
+ .DataINEndpointNumber = AUDIO_STREAM_EPNUM,
+ .DataINEndpointSize = AUDIO_STREAM_EPSIZE,
+ },
+
+ .State =
+ {
+ // Leave all state values to their defaults
+ }
};
/** Main program entry point. This routine contains the overall program flow, including initial
@@ -59,7 +67,7 @@ int main(void)
for (;;)
{
- if (Speaker_Audio_Interface.InterfaceEnabled)
+ if (Speaker_Audio_Interface.State.InterfaceEnabled)
ProcessNextSample();
Audio_Device_USBTask(&Speaker_Audio_Interface);
diff --git a/Demos/Device/ClassDriver/CDC/CDC.c b/Demos/Device/ClassDriver/CDC/CDC.c
index 86d5c36c1..8ecfb7b37 100644
--- a/Demos/Device/ClassDriver/CDC/CDC.c
+++ b/Demos/Device/ClassDriver/CDC/CDC.c
@@ -40,18 +40,26 @@
* passed to all CDC Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
-USB_ClassInfo_CDC_t VirtualSerial_CDC_Interface =
+USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
{
- .ControlInterfaceNumber = 0,
+ .Config =
+ {
+ .ControlInterfaceNumber = 0,
- .DataINEndpointNumber = CDC_TX_EPNUM,
- .DataINEndpointSize = CDC_TXRX_EPSIZE,
+ .DataINEndpointNumber = CDC_TX_EPNUM,
+ .DataINEndpointSize = CDC_TXRX_EPSIZE,
- .DataOUTEndpointNumber = CDC_RX_EPNUM,
- .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
+ .DataOUTEndpointNumber = CDC_RX_EPNUM,
+ .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
- .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
- .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
+ .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
+ .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
+ },
+
+ .State =
+ {
+ // Leave all state values to their defaults
+ }
};
/** Main program entry point. This routine contains the overall program flow, including initial
diff --git a/Demos/Device/ClassDriver/DualCDC/DualCDC.c b/Demos/Device/ClassDriver/DualCDC/DualCDC.c
index ca33f10ac..82bfdc8f7 100644
--- a/Demos/Device/ClassDriver/DualCDC/DualCDC.c
+++ b/Demos/Device/ClassDriver/DualCDC/DualCDC.c
@@ -41,18 +41,26 @@
* within a device can be differentiated from one another. This is for the first CDC interface,
* which sends strings to the host for each joystick movement.
*/
-USB_ClassInfo_CDC_t VirtualSerial1_CDC_Interface =
+USB_ClassInfo_CDC_Device_t VirtualSerial1_CDC_Interface =
{
- .ControlInterfaceNumber = 0,
+ .Config =
+ {
+ .ControlInterfaceNumber = 0,
- .DataINEndpointNumber = CDC1_TX_EPNUM,
- .DataINEndpointSize = CDC_TXRX_EPSIZE,
+ .DataINEndpointNumber = CDC1_TX_EPNUM,
+ .DataINEndpointSize = CDC_TXRX_EPSIZE,
- .DataOUTEndpointNumber = CDC1_RX_EPNUM,
- .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
+ .DataOUTEndpointNumber = CDC1_RX_EPNUM,
+ .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
- .NotificationEndpointNumber = CDC1_NOTIFICATION_EPNUM,
- .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
+ .NotificationEndpointNumber = CDC1_NOTIFICATION_EPNUM,
+ .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
+ },
+
+ .State =
+ {
+ // Leave all state values to their defaults
+ }
};
/** LUFA CDC Class driver interface configuration and state information. This structure is
@@ -60,18 +68,26 @@ USB_ClassInfo_CDC_t VirtualSerial1_CDC_Interface =
* within a device can be differentiated from one another. This is for the second CDC interface,
* which echos back all received data from the host.
*/
-USB_ClassInfo_CDC_t VirtualSerial2_CDC_Interface =
+USB_ClassInfo_CDC_Device_t VirtualSerial2_CDC_Interface =
{
- .ControlInterfaceNumber = 2,
-
- .DataINEndpointNumber = CDC2_TX_EPNUM,
- .DataINEndpointSize = CDC_TXRX_EPSIZE,
-
- .DataOUTEndpointNumber = CDC2_RX_EPNUM,
- .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
-
- .NotificationEndpointNumber = CDC2_NOTIFICATION_EPNUM,
- .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
+ .Config =
+ {
+ .ControlInterfaceNumber = 2,
+
+ .DataINEndpointNumber = CDC2_TX_EPNUM,
+ .DataINEndpointSize = CDC_TXRX_EPSIZE,
+
+ .DataOUTEndpointNumber = CDC2_RX_EPNUM,
+ .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
+
+ .NotificationEndpointNumber = CDC2_NOTIFICATION_EPNUM,
+ .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
+ },
+
+ .State =
+ {
+ // Leave all state values to their defaults
+ }
};
/** Main program entry point. This routine contains the overall program flow, including initial
diff --git a/Demos/Device/ClassDriver/GenericHID/GenericHID.c b/Demos/Device/ClassDriver/GenericHID/GenericHID.c
index 58cb6df4e..823fa45b8 100644
--- a/Demos/Device/ClassDriver/GenericHID/GenericHID.c
+++ b/Demos/Device/ClassDriver/GenericHID/GenericHID.c
@@ -40,16 +40,22 @@
* passed to all HID Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
-USB_ClassInfo_HID_t Generic_HID_Interface =
+USB_ClassInfo_HID_Device_t Generic_HID_Interface =
{
- .InterfaceNumber = 0,
-
- .ReportINEndpointNumber = GENERIC_IN_EPNUM,
- .ReportINEndpointSize = GENERIC_EPSIZE,
-
- .ReportINBufferSize = GENERIC_REPORT_SIZE,
-
- .UsingReportProtocol = true,
+ .Config =
+ {
+ .InterfaceNumber = 0,
+
+ .ReportINEndpointNumber = GENERIC_IN_EPNUM,
+ .ReportINEndpointSize = GENERIC_EPSIZE,
+
+ .ReportINBufferSize = GENERIC_REPORT_SIZE,
+ },
+
+ .State =
+ {
+ // Leave all state values to their defaults
+ }
};
/** Main program entry point. This routine contains the overall program flow, including initial
@@ -119,8 +125,8 @@ void EVENT_USB_UnhandledControlPacket(void)
/** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */
ISR(TIMER0_COMPA_vect, ISR_BLOCK)
{
- if (Generic_HID_Interface.IdleMSRemaining)
- Generic_HID_Interface.IdleMSRemaining--;
+ if (Generic_HID_Interface.State.IdleMSRemaining)
+ Generic_HID_Interface.State.IdleMSRemaining--;
}
/** HID class driver callback function for the creation of HID reports to the host.
@@ -131,7 +137,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
*
* \return Number of bytes written in the report (or zero if no report is to be sent
*/
-uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)
+uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)
{
// Create generic HID report here
@@ -145,7 +151,7 @@ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceIn
* \param ReportData Pointer to a buffer where the created report has been stored
* \param ReportSize Size in bytes of the received HID report
*/
-void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
+void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t ReportID,
void* ReportData, uint16_t ReportSize)
{
// Process received generic HID report here
diff --git a/Demos/Device/ClassDriver/GenericHID/GenericHID.h b/Demos/Device/ClassDriver/GenericHID/GenericHID.h
index d40fbb11f..843b262d4 100644
--- a/Demos/Device/ClassDriver/GenericHID/GenericHID.h
+++ b/Demos/Device/ClassDriver/GenericHID/GenericHID.h
@@ -72,8 +72,9 @@
void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void);
- uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData);
- void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
+ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t* ReportID,
+ void* ReportData);
+ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t ReportID,
void* ReportData, uint16_t ReportSize);
#endif
diff --git a/Demos/Device/ClassDriver/Joystick/Joystick.c b/Demos/Device/ClassDriver/Joystick/Joystick.c
index 85f670e61..0a1d3809f 100644
--- a/Demos/Device/ClassDriver/Joystick/Joystick.c
+++ b/Demos/Device/ClassDriver/Joystick/Joystick.c
@@ -40,16 +40,22 @@
* passed to all HID Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
-USB_ClassInfo_HID_t Joystick_HID_Interface =
+USB_ClassInfo_HID_Device_t Joystick_HID_Interface =
{
- .InterfaceNumber = 0,
-
- .ReportINEndpointNumber = JOYSTICK_EPNUM,
- .ReportINEndpointSize = JOYSTICK_EPSIZE,
-
- .ReportINBufferSize = sizeof(USB_JoystickReport_Data_t),
-
- .UsingReportProtocol = true,
+ .Config =
+ {
+ .InterfaceNumber = 0,
+
+ .ReportINEndpointNumber = JOYSTICK_EPNUM,
+ .ReportINEndpointSize = JOYSTICK_EPSIZE,
+
+ .ReportINBufferSize = sizeof(USB_JoystickReport_Data_t),
+ },
+
+ .State =
+ {
+ // Leave all state values to their defaults
+ }
};
/** Main program entry point. This routine contains the overall program flow, including initial
@@ -121,8 +127,8 @@ void EVENT_USB_UnhandledControlPacket(void)
/** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */
ISR(TIMER0_COMPA_vect, ISR_BLOCK)
{
- if (Joystick_HID_Interface.IdleMSRemaining)
- Joystick_HID_Interface.IdleMSRemaining--;
+ if (Joystick_HID_Interface.State.IdleMSRemaining)
+ Joystick_HID_Interface.State.IdleMSRemaining--;
}
/** HID class driver callback function for the creation of HID reports to the host.
@@ -133,7 +139,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
*
* \return Number of bytes written in the report (or zero if no report is to be sent
*/
-uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)
+uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)
{
USB_JoystickReport_Data_t* JoystickReport = (USB_JoystickReport_Data_t*)ReportData;
@@ -166,7 +172,7 @@ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceIn
* \param ReportData Pointer to a buffer where the created report has been stored
* \param ReportSize Size in bytes of the received HID report
*/
-void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
+void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t ReportID,
void* ReportData, uint16_t ReportSize)
{
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
diff --git a/Demos/Device/ClassDriver/Joystick/Joystick.h b/Demos/Device/ClassDriver/Joystick/Joystick.h
index e3bcaa6ab..343b190e7 100644
--- a/Demos/Device/ClassDriver/Joystick/Joystick.h
+++ b/Demos/Device/ClassDriver/Joystick/Joystick.h
@@ -83,8 +83,9 @@
void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void);
- uint16_t CALLBACK_HID_Device_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData);
- void CALLBACK_HID_Device_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
+ uint16_t CALLBACK_HID_Device_CreateNextHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t* ReportID,
+ void* ReportData);
+ void CALLBACK_HID_Device_ProcessReceivedHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t ReportID,
void* ReportData, uint16_t ReportSize);
#endif
diff --git a/Demos/Device/ClassDriver/Keyboard/Keyboard.c b/Demos/Device/ClassDriver/Keyboard/Keyboard.c
index 7318edb8c..f44a93451 100644
--- a/Demos/Device/ClassDriver/Keyboard/Keyboard.c
+++ b/Demos/Device/ClassDriver/Keyboard/Keyboard.c
@@ -41,16 +41,22 @@
* passed to all HID Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
-USB_ClassInfo_HID_t Keyboard_HID_Interface =
- {
- .InterfaceNumber = 0,
-
- .ReportINEndpointNumber = KEYBOARD_EPNUM,
- .ReportINEndpointSize = KEYBOARD_EPSIZE,
-
- .ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t),
-
- .IdleCount = 500,
+USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
+ {
+ .Config =
+ {
+ .InterfaceNumber = 0,
+
+ .ReportINEndpointNumber = KEYBOARD_EPNUM,
+ .ReportINEndpointSize = KEYBOARD_EPSIZE,
+
+ .ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t),
+ },
+
+ .State =
+ {
+ .IdleCount = 500,
+ }
};
/** Main program entry point. This routine contains the overall program flow, including initial
@@ -122,8 +128,8 @@ void EVENT_USB_UnhandledControlPacket(void)
/** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */
ISR(TIMER0_COMPA_vect, ISR_BLOCK)
{
- if (Keyboard_HID_Interface.IdleMSRemaining)
- Keyboard_HID_Interface.IdleMSRemaining--;
+ if (Keyboard_HID_Interface.State.IdleMSRemaining)
+ Keyboard_HID_Interface.State.IdleMSRemaining--;
}
/** HID class driver callback function for the creation of HID reports to the host.
@@ -134,7 +140,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
*
* \return Number of bytes written in the report (or zero if no report is to be sent
*/
-uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)
+uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)
{
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;
@@ -167,7 +173,7 @@ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceIn
* \param ReportData Pointer to a buffer where the created report has been stored
* \param ReportSize Size in bytes of the received HID report
*/
-void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
+void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t ReportID,
void* ReportData, uint16_t ReportSize)
{
uint8_t LEDMask = LEDS_NO_LEDS;
diff --git a/Demos/Device/ClassDriver/Keyboard/Keyboard.h b/Demos/Device/ClassDriver/Keyboard/Keyboard.h
index 74802fdd9..3dc7eaeec 100644
--- a/Demos/Device/ClassDriver/Keyboard/Keyboard.h
+++ b/Demos/Device/ClassDriver/Keyboard/Keyboard.h
@@ -86,8 +86,9 @@
void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void);
- uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData);
- void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
+ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t* ReportID,
+ void* ReportData);
+ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t ReportID,
void* ReportData, uint16_t ReportSize);
#endif
diff --git a/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c b/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c
index 30e90f4a9..93722195a 100644
--- a/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c
+++ b/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c
@@ -42,16 +42,22 @@
* within a device can be differentiated from one another. This is for the keyboard HID
* interface within the device.
*/
-USB_ClassInfo_HID_t Keyboard_HID_Interface =
+USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
{
- .InterfaceNumber = 0,
-
- .ReportINEndpointNumber = KEYBOARD_IN_EPNUM,
- .ReportINEndpointSize = HID_EPSIZE,
-
- .ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t),
-
- .IdleCount = 500,
+ .Config =
+ {
+ .InterfaceNumber = 0,
+
+ .ReportINEndpointNumber = KEYBOARD_IN_EPNUM,
+ .ReportINEndpointSize = HID_EPSIZE,
+
+ .ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t),
+ },
+
+ .State =
+ {
+ .IdleCount = 500,
+ }
};
/** LUFA HID Class driver interface configuration and state information. This structure is
@@ -59,14 +65,22 @@ USB_ClassInfo_HID_t Keyboard_HID_Interface =
* within a device can be differentiated from one another. This is for the mouse HID
* interface within the device.
*/
-USB_ClassInfo_HID_t Mouse_HID_Interface =
+USB_ClassInfo_HID_Device_t Mouse_HID_Interface =
{
- .InterfaceNumber = 0,
-
- .ReportINEndpointNumber = MOUSE_IN_EPNUM,
- .ReportINEndpointSize = HID_EPSIZE,
-
- .ReportINBufferSize = sizeof(USB_MouseReport_Data_t),
+ .Config =
+ {
+ .InterfaceNumber = 0,
+
+ .ReportINEndpointNumber = MOUSE_IN_EPNUM,
+ .ReportINEndpointSize = HID_EPSIZE,
+
+ .ReportINBufferSize = sizeof(USB_MouseReport_Data_t),
+ },
+
+ .State =
+ {
+ // Leave all state values to their defaults
+ }
};
/** Main program entry point. This routine contains the overall program flow, including initial
@@ -142,11 +156,11 @@ void EVENT_USB_UnhandledControlPacket(void)
/** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */
ISR(TIMER0_COMPA_vect, ISR_BLOCK)
{
- if (Keyboard_HID_Interface.IdleMSRemaining)
- Keyboard_HID_Interface.IdleMSRemaining--;
+ if (Keyboard_HID_Interface.State.IdleMSRemaining)
+ Keyboard_HID_Interface.State.IdleMSRemaining--;
- if (Mouse_HID_Interface.IdleMSRemaining)
- Mouse_HID_Interface.IdleMSRemaining--;
+ if (Mouse_HID_Interface.State.IdleMSRemaining)
+ Mouse_HID_Interface.State.IdleMSRemaining--;
}
/** HID class driver callback function for the creation of HID reports to the host.
@@ -157,7 +171,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
*
* \return Number of bytes written in the report (or zero if no report is to be sent
*/
-uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)
+uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)
{
uint8_t JoyStatus_LCL = Joystick_GetStatus();
uint8_t ButtonStatus_LCL = Buttons_GetStatus();
@@ -217,7 +231,7 @@ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceIn
* \param ReportData Pointer to a buffer where the created report has been stored
* \param ReportSize Size in bytes of the received HID report
*/
-void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
+void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t ReportID,
void* ReportData, uint16_t ReportSize)
{
if (HIDInterfaceInfo == &Keyboard_HID_Interface)
diff --git a/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.h b/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.h
index 5f166979f..81ca3f6ef 100644
--- a/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.h
+++ b/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.h
@@ -90,8 +90,9 @@
void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void);
- uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData);
- void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
+ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t* ReportID,
+ void* ReportData);
+ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t ReportID,
void* ReportData, uint16_t ReportSize);
#endif
diff --git a/Demos/Device/ClassDriver/MIDI/MIDI.c b/Demos/Device/ClassDriver/MIDI/MIDI.c
index 511f280d6..3dca7430a 100644
--- a/Demos/Device/ClassDriver/MIDI/MIDI.c
+++ b/Demos/Device/ClassDriver/MIDI/MIDI.c
@@ -40,15 +40,23 @@
* passed to all MIDI Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
-USB_ClassInfo_MIDI_t Keyboard_MIDI_Interface =
+USB_ClassInfo_MIDI_Device_t Keyboard_MIDI_Interface =
{
- .StreamingInterfaceNumber = 1,
+ .Config =
+ {
+ .StreamingInterfaceNumber = 1,
- .DataINEndpointNumber = MIDI_STREAM_IN_EPNUM,
- .DataINEndpointSize = MIDI_STREAM_EPSIZE,
+ .DataINEndpointNumber = MIDI_STREAM_IN_EPNUM,
+ .DataINEndpointSize = MIDI_STREAM_EPSIZE,
- .DataOUTEndpointNumber = MIDI_STREAM_OUT_EPNUM,
- .DataOUTEndpointSize = MIDI_STREAM_EPSIZE,
+ .DataOUTEndpointNumber = MIDI_STREAM_OUT_EPNUM,
+ .DataOUTEndpointSize = MIDI_STREAM_EPSIZE,
+ },
+
+ .State =
+ {
+ // Leave all state values to their defaults
+ }
};
/** Main program entry point. This routine contains the overall program flow, including initial
diff --git a/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c b/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c
index 4ec52c345..5b5a2bd90 100644
--- a/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c
+++ b/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c
@@ -47,7 +47,7 @@
* \param BlockAddress Data block starting address for the write sequence
* \param TotalBlocks Number of blocks of data to write
*/
-void DataflashManager_WriteBlocks(USB_ClassInfo_MS_t* MSInterfaceInfo, const uint32_t BlockAddress, uint16_t TotalBlocks)
+void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, const uint32_t BlockAddress, uint16_t TotalBlocks)
{
uint16_t CurrDFPage = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) / DATAFLASH_PAGE_SIZE);
uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE);
@@ -143,7 +143,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_t* MSInterfaceInfo, const uin
BytesInBlockDiv16++;
/* Check if the current command is being aborted by the host */
- if (MSInterfaceInfo->IsMassStoreReset)
+ if (MSInterfaceInfo->State.IsMassStoreReset)
return;
}
@@ -173,7 +173,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_t* MSInterfaceInfo, const uin
* \param BlockAddress Data block starting address for the read sequence
* \param TotalBlocks Number of blocks of data to read
*/
-void DataflashManager_ReadBlocks(USB_ClassInfo_MS_t* MSInterfaceInfo, const uint32_t BlockAddress, uint16_t TotalBlocks)
+void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, const uint32_t BlockAddress, uint16_t TotalBlocks)
{
uint16_t CurrDFPage = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) / DATAFLASH_PAGE_SIZE);
uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE);
@@ -252,7 +252,7 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_t* MSInterfaceInfo, const uint
BytesInBlockDiv16++;
/* Check if the current command is being aborted by the host */
- if (MSInterfaceInfo->IsMassStoreReset)
+ if (MSInterfaceInfo->State.IsMassStoreReset)
return;
}
diff --git a/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h b/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h
index 8cf190727..ace6231db 100644
--- a/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h
+++ b/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h
@@ -64,9 +64,9 @@
#define VIRTUAL_MEMORY_BLOCKS (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE)
/* Function Prototypes: */
- void DataflashManager_WriteBlocks(USB_ClassInfo_MS_t* MSInterfaceInfo, const uint32_t BlockAddress,
+ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, const uint32_t BlockAddress,
uint16_t TotalBlocks);
- void DataflashManager_ReadBlocks(USB_ClassInfo_MS_t* MSInterfaceInfo, const uint32_t BlockAddress,
+ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, const uint32_t BlockAddress,
uint16_t TotalBlocks);
void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress, uint16_t TotalBlocks,
uint8_t* BufferPtr) ATTR_NON_NULL_PTR_ARG(3);
diff --git a/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c b/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c
index d56e343a7..4e6c05013 100644
--- a/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c
+++ b/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c
@@ -86,12 +86,12 @@ SCSI_Request_Sense_Response_t SenseData =
*
* \param MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
*/
-bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_t* MSInterfaceInfo)
+bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)
{
bool CommandSuccess = false;
/* Run the appropriate SCSI command hander function based on the passed command */
- switch (MSInterfaceInfo->CommandBlock.SCSICommandData[0])
+ switch (MSInterfaceInfo->State.CommandBlock.SCSICommandData[0])
{
case SCSI_CMD_INQUIRY:
CommandSuccess = SCSI_Command_Inquiry(MSInterfaceInfo);
@@ -116,7 +116,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_t* MSInterfaceInfo)
case SCSI_CMD_VERIFY_10:
/* These commands should just succeed, no handling required */
CommandSuccess = true;
- MSInterfaceInfo->CommandBlock.DataTransferLength = 0;
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;
break;
default:
/* Update the SENSE key to reflect the invalid command */
@@ -146,16 +146,16 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_t* MSInterfaceInfo)
*
* \return Boolean true if the command completed successfully, false otherwise.
*/
-static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_t* MSInterfaceInfo)
+static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)
{
- uint16_t AllocationLength = (((uint16_t)MSInterfaceInfo->CommandBlock.SCSICommandData[3] << 8) |
- MSInterfaceInfo->CommandBlock.SCSICommandData[4]);
+ uint16_t AllocationLength = (((uint16_t)MSInterfaceInfo->State.CommandBlock.SCSICommandData[3] << 8) |
+ MSInterfaceInfo->State.CommandBlock.SCSICommandData[4]);
uint16_t BytesTransferred = (AllocationLength < sizeof(InquiryData))? AllocationLength :
sizeof(InquiryData);
/* Only the standard INQUIRY data is supported, check if any optional INQUIRY bits set */
- if ((MSInterfaceInfo->CommandBlock.SCSICommandData[1] & ((1 << 0) | (1 << 1))) ||
- MSInterfaceInfo->CommandBlock.SCSICommandData[2])
+ if ((MSInterfaceInfo->State.CommandBlock.SCSICommandData[1] & ((1 << 0) | (1 << 1))) ||
+ MSInterfaceInfo->State.CommandBlock.SCSICommandData[2])
{
/* Optional but unsupported bits set - update the SENSE key and fail the request */
SCSI_SET_SENSE(SCSI_SENSE_KEY_ILLEGAL_REQUEST,
@@ -176,7 +176,7 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_t* MSInterfaceInfo)
Endpoint_ClearIN();
/* Succeed the command and update the bytes transferred counter */
- MSInterfaceInfo->CommandBlock.DataTransferLength -= BytesTransferred;
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength -= BytesTransferred;
return true;
}
@@ -188,9 +188,9 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_t* MSInterfaceInfo)
*
* \return Boolean true if the command completed successfully, false otherwise.
*/
-static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_t* MSInterfaceInfo)
+static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)
{
- uint8_t AllocationLength = MSInterfaceInfo->CommandBlock.SCSICommandData[4];
+ uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData);
uint8_t PadBytes[AllocationLength - BytesTransferred];
@@ -200,7 +200,7 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_t* MSInterfaceInfo)
Endpoint_ClearIN();
/* Succeed the command and update the bytes transferred counter */
- MSInterfaceInfo->CommandBlock.DataTransferLength -= BytesTransferred;
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength -= BytesTransferred;
return true;
}
@@ -212,7 +212,7 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_t* MSInterfaceInfo)
*
* \return Boolean true if the command completed successfully, false otherwise.
*/
-static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_t* MSInterfaceInfo)
+static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)
{
uint32_t TotalLUNs = (LUN_MEDIA_BLOCKS - 1);
uint32_t MediaBlockSize = VIRTUAL_MEMORY_BLOCK_SIZE;
@@ -222,7 +222,7 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_t* MSInterfaceInfo)
Endpoint_ClearIN();
/* Succeed the command and update the bytes transferred counter */
- MSInterfaceInfo->CommandBlock.DataTransferLength -= 8;
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength -= 8;
return true;
}
@@ -235,12 +235,12 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_t* MSInterfaceInfo)
*
* \return Boolean true if the command completed successfully, false otherwise.
*/
-static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_t* MSInterfaceInfo)
+static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)
{
uint8_t ReturnByte;
/* Check to see if the SELF TEST bit is not set */
- if (!(MSInterfaceInfo->CommandBlock.SCSICommandData[1] & (1 << 2)))
+ if (!(MSInterfaceInfo->State.CommandBlock.SCSICommandData[1] & (1 << 2)))
{
/* Only self-test supported - update SENSE key and fail the command */
SCSI_SET_SENSE(SCSI_SENSE_KEY_ILLEGAL_REQUEST,
@@ -287,7 +287,7 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_t* MSInterfaceInfo)
#endif
/* Succeed the command and update the bytes transferred counter */
- MSInterfaceInfo->CommandBlock.DataTransferLength = 0;
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;
return true;
}
@@ -301,20 +301,20 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_t* MSInterfaceInfo)
*
* \return Boolean true if the command completed successfully, false otherwise.
*/
-static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_t* MSInterfaceInfo, const bool IsDataRead)
+static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, const bool IsDataRead)
{
uint32_t BlockAddress;
uint16_t TotalBlocks;
/* Load in the 32-bit block address (SCSI uses big-endian, so have to do it byte-by-byte) */
- ((uint8_t*)&BlockAddress)[3] = MSInterfaceInfo->CommandBlock.SCSICommandData[2];
- ((uint8_t*)&BlockAddress)[2] = MSInterfaceInfo->CommandBlock.SCSICommandData[3];
- ((uint8_t*)&BlockAddress)[1] = MSInterfaceInfo->CommandBlock.SCSICommandData[4];
- ((uint8_t*)&BlockAddress)[0] = MSInterfaceInfo->CommandBlock.SCSICommandData[5];
+ ((uint8_t*)&BlockAddress)[3] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[2];
+ ((uint8_t*)&BlockAddress)[2] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[3];
+ ((uint8_t*)&BlockAddress)[1] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
+ ((uint8_t*)&BlockAddress)[0] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[5];
/* Load in the 16-bit total blocks (SCSI uses big-endian, so have to do it byte-by-byte) */
- ((uint8_t*)&TotalBlocks)[1] = MSInterfaceInfo->CommandBlock.SCSICommandData[7];
- ((uint8_t*)&TotalBlocks)[0] = MSInterfaceInfo->CommandBlock.SCSICommandData[8];
+ ((uint8_t*)&TotalBlocks)[1] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[7];
+ ((uint8_t*)&TotalBlocks)[0] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[8];
/* Check if the block address is outside the maximum allowable value for the LUN */
if (BlockAddress >= LUN_MEDIA_BLOCKS)
@@ -329,7 +329,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_t* MSInterfaceInfo, const
#if (TOTAL_LUNS > 1)
/* Adjust the given block address to the real media address based on the selected LUN */
- BlockAddress += ((uint32_t)MSInterfaceInfo->CommandBlock.LUN * LUN_MEDIA_BLOCKS);
+ BlockAddress += ((uint32_t)MSInterfaceInfo->State.CommandBlock.LUN * LUN_MEDIA_BLOCKS);
#endif
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
@@ -339,7 +339,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_t* MSInterfaceInfo, const
DataflashManager_WriteBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
/* Update the bytes transferred counter and succeed the command */
- MSInterfaceInfo->CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * VIRTUAL_MEMORY_BLOCK_SIZE);
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * VIRTUAL_MEMORY_BLOCK_SIZE);
return true;
}
diff --git a/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.h b/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.h
index 8c3e104d9..bf61d8edc 100644
--- a/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.h
+++ b/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.h
@@ -135,14 +135,14 @@
} SCSI_Request_Sense_Response_t;
/* Function Prototypes: */
- bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_t* MSInterfaceInfo);
+ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* MSInterfaceInfo);
#if defined(INCLUDE_FROM_SCSI_C)
- static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_t* MSInterfaceInfo);
- static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_t* MSInterfaceInfo);
- static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_t* MSInterfaceInfo);
- static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_t* MSInterfaceInfo);
- static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_t* MSInterfaceInfo, const bool IsDataRead);
+ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* MSInterfaceInfo);
+ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* MSInterfaceInfo);
+ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* MSInterfaceInfo);
+ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* MSInterfaceInfo);
+ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, const bool IsDataRead);
#endif
#endif
diff --git a/Demos/Device/ClassDriver/MassStorage/MassStorage.c b/Demos/Device/ClassDriver/MassStorage/MassStorage.c
index 66bba8f50..87da97589 100644
--- a/Demos/Device/ClassDriver/MassStorage/MassStorage.c
+++ b/Demos/Device/ClassDriver/MassStorage/MassStorage.c
@@ -40,17 +40,25 @@
* 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_t Disk_MS_Interface =
+USB_ClassInfo_MS_Device_t Disk_MS_Interface =
{
- .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,
+ .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,
+ },
+
+ .State =
+ {
+ // Leave all state values to their defaults
+ }
};
/** Main program entry point. This routine contains the overall program flow, including initial
@@ -119,7 +127,7 @@ void EVENT_USB_UnhandledControlPacket(void)
*
* \param MSInterfaceInfo Pointer to the Mass Storage class interface configuration structure being referenced
*/
-bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_t* MSInterfaceInfo)
+bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)
{
bool CommandSuccess;
diff --git a/Demos/Device/ClassDriver/MassStorage/MassStorage.h b/Demos/Device/ClassDriver/MassStorage/MassStorage.h
index d9c298ead..71497780e 100644
--- a/Demos/Device/ClassDriver/MassStorage/MassStorage.h
+++ b/Demos/Device/ClassDriver/MassStorage/MassStorage.h
@@ -83,6 +83,6 @@
void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void);
- bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_t* MSInterfaceInfo);
+ bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* MSInterfaceInfo);
#endif
diff --git a/Demos/Device/ClassDriver/Mouse/Mouse.c b/Demos/Device/ClassDriver/Mouse/Mouse.c
index 22c4b5528..0d63c7a76 100644
--- a/Demos/Device/ClassDriver/Mouse/Mouse.c
+++ b/Demos/Device/ClassDriver/Mouse/Mouse.c
@@ -40,14 +40,22 @@
* passed to all HID Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
-USB_ClassInfo_HID_t Mouse_HID_Interface =
+USB_ClassInfo_HID_Device_t Mouse_HID_Interface =
{
- .InterfaceNumber = 0,
-
- .ReportINEndpointNumber = MOUSE_EPNUM,
- .ReportINEndpointSize = MOUSE_EPSIZE,
-
- .ReportINBufferSize = sizeof(USB_MouseReport_Data_t),
+ .Config =
+ {
+ .InterfaceNumber = 0,
+
+ .ReportINEndpointNumber = MOUSE_EPNUM,
+ .ReportINEndpointSize = MOUSE_EPSIZE,
+
+ .ReportINBufferSize = sizeof(USB_MouseReport_Data_t),
+ },
+
+ .State =
+ {
+ // Leave all state values to their defaults
+ }
};
/** Main program entry point. This routine contains the overall program flow, including initial
@@ -119,8 +127,8 @@ void EVENT_USB_UnhandledControlPacket(void)
/** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */
ISR(TIMER0_COMPA_vect, ISR_BLOCK)
{
- if (Mouse_HID_Interface.IdleMSRemaining)
- Mouse_HID_Interface.IdleMSRemaining--;
+ if (Mouse_HID_Interface.State.IdleMSRemaining)
+ Mouse_HID_Interface.State.IdleMSRemaining--;
}
/** HID class driver callback function for the creation of HID reports to the host.
@@ -131,7 +139,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
*
* \return Number of bytes written in the report (or zero if no report is to be sent
*/
-uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)
+uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)
{
USB_MouseReport_Data_t* MouseReport = (USB_MouseReport_Data_t*)ReportData;
@@ -164,7 +172,7 @@ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceIn
* \param ReportData Pointer to a buffer where the created report has been stored
* \param ReportSize Size in bytes of the received HID report
*/
-void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
+void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t ReportID,
void* ReportData, uint16_t ReportSize)
{
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
diff --git a/Demos/Device/ClassDriver/Mouse/Mouse.h b/Demos/Device/ClassDriver/Mouse/Mouse.h
index 6576cbe7a..f973f726a 100644
--- a/Demos/Device/ClassDriver/Mouse/Mouse.h
+++ b/Demos/Device/ClassDriver/Mouse/Mouse.h
@@ -85,8 +85,9 @@
void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void);
- uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData);
- void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
+ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t* ReportID,
+ void* ReportData);
+ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t ReportID,
void* ReportData, uint16_t ReportSize);
#endif
diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c b/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c
index 44a32ea51..652714985 100644
--- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c
+++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c
@@ -56,7 +56,7 @@ TCP_ConnectionState_t ConnectionStateTable[MAX_TCP_CONNECTIONS];
* level. If an application produces a response, this task constructs the appropriate Ethernet frame and places it into the Ethernet OUT
* buffer for later transmission.
*/
-void TCP_TCPTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo)
+void TCP_TCPTask(USB_ClassInfo_RNDIS_Device_t* RNDISInterfaceInfo)
{
/* Task to hand off TCP packets to and from the listening applications. */
@@ -76,7 +76,7 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo)
}
/* Bail out early if there is already a frame waiting to be sent in the Ethernet OUT buffer */
- if (RNDISInterfaceInfo->FrameOUT.FrameInBuffer)
+ if (RNDISInterfaceInfo->State.FrameOUT.FrameInBuffer)
return;
/* Send response packets from each application as the TCP packet buffers are filled by the applications */
@@ -86,11 +86,11 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo)
if ((ConnectionStateTable[CSTableEntry].Info.Buffer.Direction == TCP_PACKETDIR_OUT) &&
(ConnectionStateTable[CSTableEntry].Info.Buffer.Ready))
{
- Ethernet_Frame_Header_t* FrameOUTHeader = (Ethernet_Frame_Header_t*)&RNDISInterfaceInfo->FrameOUT.FrameData;
- IP_Header_t* IPHeaderOUT = (IP_Header_t*)&RNDISInterfaceInfo->FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t)];
- TCP_Header_t* TCPHeaderOUT = (TCP_Header_t*)&RNDISInterfaceInfo->FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +
+ Ethernet_Frame_Header_t* FrameOUTHeader = (Ethernet_Frame_Header_t*)&RNDISInterfaceInfo->State.FrameOUT.FrameData;
+ IP_Header_t* IPHeaderOUT = (IP_Header_t*)&RNDISInterfaceInfo->State.FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t)];
+ TCP_Header_t* TCPHeaderOUT = (TCP_Header_t*)&RNDISInterfaceInfo->State.FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +
sizeof(IP_Header_t)];
- void* TCPDataOUT = &RNDISInterfaceInfo->FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +
+ void* TCPDataOUT = &RNDISInterfaceInfo->State.FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +
sizeof(IP_Header_t) +
sizeof(TCP_Header_t)];
@@ -145,8 +145,8 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo)
PacketSize += sizeof(Ethernet_Frame_Header_t);
/* Set the response length in the buffer and indicate that a response is ready to be sent */
- RNDISInterfaceInfo->FrameOUT.FrameLength = PacketSize;
- RNDISInterfaceInfo->FrameOUT.FrameInBuffer = true;
+ RNDISInterfaceInfo->State.FrameOUT.FrameLength = PacketSize;
+ RNDISInterfaceInfo->State.FrameOUT.FrameInBuffer = true;
ConnectionStateTable[CSTableEntry].Info.Buffer.Ready = false;
diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h b/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h
index 3448245ed..919245a0d 100644
--- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h
+++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h
@@ -232,7 +232,7 @@
TCP_PortState_t PortStateTable[MAX_OPEN_TCP_PORTS];
/* Function Prototypes: */
- void TCP_TCPTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo);
+ void TCP_TCPTask(USB_ClassInfo_RNDIS_Device_t* RNDISInterfaceInfo);
void TCP_Init(void);
bool TCP_SetPortState(uint16_t Port, uint8_t State, void (*Handler)(TCP_ConnectionState_t*, TCP_ConnectionBuffer_t*));
uint8_t TCP_GetPortState(uint16_t Port);
diff --git a/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c b/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c
index 3c9fddfd4..ed0718455 100644
--- a/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c
+++ b/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c
@@ -40,21 +40,29 @@
* passed to all RNDIS Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
-USB_ClassInfo_RNDIS_t Ethernet_RNDIS_Interface =
+USB_ClassInfo_RNDIS_Device_t Ethernet_RNDIS_Interface =
{
- .ControlInterfaceNumber = 0,
-
- .DataINEndpointNumber = CDC_TX_EPNUM,
- .DataINEndpointSize = CDC_TXRX_EPSIZE,
-
- .DataOUTEndpointNumber = CDC_RX_EPNUM,
- .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
-
- .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
- .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
-
- .AdapterVendorDescription = "LUFA RNDIS Demo Adapter",
- .AdapterMACAddress = {ADAPTER_MAC_ADDRESS},
+ .Config =
+ {
+ .ControlInterfaceNumber = 0,
+
+ .DataINEndpointNumber = CDC_TX_EPNUM,
+ .DataINEndpointSize = CDC_TXRX_EPSIZE,
+
+ .DataOUTEndpointNumber = CDC_RX_EPNUM,
+ .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
+
+ .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
+ .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
+
+ .AdapterVendorDescription = "LUFA RNDIS Demo Adapter",
+ .AdapterMACAddress = {ADAPTER_MAC_ADDRESS},
+ },
+
+ .State =
+ {
+ // Leave all state values to their defaults
+ }
};
/** Main program entry point. This routine contains the overall program flow, including initial
@@ -73,10 +81,10 @@ int main(void)
for (;;)
{
- if (Ethernet_RNDIS_Interface.FrameIN.FrameInBuffer)
+ if (Ethernet_RNDIS_Interface.State.FrameIN.FrameInBuffer)
{
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
- Ethernet_ProcessPacket(&Ethernet_RNDIS_Interface.FrameIN, &Ethernet_RNDIS_Interface.FrameOUT);
+ Ethernet_ProcessPacket(&Ethernet_RNDIS_Interface.State.FrameIN, &Ethernet_RNDIS_Interface.State.FrameOUT);
LEDs_SetAllLEDs(LEDMASK_USB_READY);
}
diff --git a/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.c b/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.c
index dbe21c21c..a2ba253d2 100644
--- a/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.c
+++ b/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.c
@@ -46,18 +46,26 @@ RingBuff_t Tx_Buffer;
* passed to all CDC Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
-USB_ClassInfo_CDC_t VirtualSerial_CDC_Interface =
+USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
{
- .ControlInterfaceNumber = 0,
+ .Config =
+ {
+ .ControlInterfaceNumber = 0,
- .DataINEndpointNumber = CDC_TX_EPNUM,
- .DataINEndpointSize = CDC_TXRX_EPSIZE,
+ .DataINEndpointNumber = CDC_TX_EPNUM,
+ .DataINEndpointSize = CDC_TXRX_EPSIZE,
- .DataOUTEndpointNumber = CDC_RX_EPNUM,
- .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
+ .DataOUTEndpointNumber = CDC_RX_EPNUM,
+ .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
- .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
- .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
+ .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
+ .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
+ },
+
+ .State =
+ {
+ // Leave all state values to their defaults
+ }
};
/** Main program entry point. This routine contains the overall program flow, including initial
@@ -152,27 +160,38 @@ ISR(USART1_RX_vect, ISR_BLOCK)
*
* \param CDCInterfaceInfo Pointer to the CDC class interface configuration structure being referenced
*/
-void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo)
+void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
{
uint8_t ConfigMask = 0;
- if (CDCInterfaceInfo->LineEncoding.ParityType == CDC_PARITY_Odd)
- ConfigMask = ((1 << UPM11) | (1 << UPM10));
- else if (CDCInterfaceInfo->LineEncoding.ParityType == CDC_PARITY_Even)
- ConfigMask = (1 << UPM11);
+ switch (CDCInterfaceInfo->State.LineEncoding.ParityType)
+ {
+ case CDC_PARITY_Odd:
+ ConfigMask = ((1 << UPM11) | (1 << UPM10));
+ break;
+ case CDC_PARITY_Even:
+ ConfigMask = (1 << UPM11);
+ break;
+ }
- if (CDCInterfaceInfo->LineEncoding.CharFormat == CDC_LINEENCODING_TwoStopBits)
+ if (CDCInterfaceInfo->State.LineEncoding.CharFormat == CDC_LINEENCODING_TwoStopBits)
ConfigMask |= (1 << USBS1);
- if (CDCInterfaceInfo->LineEncoding.DataBits == 6)
- ConfigMask |= (1 << UCSZ10);
- else if (CDCInterfaceInfo->LineEncoding.DataBits == 7)
- ConfigMask |= (1 << UCSZ11);
- else if (CDCInterfaceInfo->LineEncoding.DataBits == 8)
- ConfigMask |= ((1 << UCSZ11) | (1 << UCSZ10));
+ switch (CDCInterfaceInfo->State.LineEncoding.DataBits)
+ {
+ case 6:
+ ConfigMask |= (1 << UCSZ10);
+ break;
+ case 7:
+ ConfigMask |= (1 << UCSZ11);
+ break;
+ case 8:
+ ConfigMask |= ((1 << UCSZ11) | (1 << UCSZ10));
+ break;
+ }
UCSR1A = (1 << U2X1);
UCSR1B = ((1 << RXCIE1) | (1 << TXEN1) | (1 << RXEN1));
UCSR1C = ConfigMask;
- UBRR1 = SERIAL_2X_UBBRVAL((uint16_t)CDCInterfaceInfo->LineEncoding.BaudRateBPS);
+ UBRR1 = SERIAL_2X_UBBRVAL((uint16_t)CDCInterfaceInfo->State.LineEncoding.BaudRateBPS);
}
diff --git a/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.h b/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.h
index 8aa29b6b4..d0d4edb6c 100644
--- a/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.h
+++ b/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.h
@@ -74,6 +74,6 @@
void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void);
- void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
+ void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo);
#endif