State information for class drivers is now zeroed out during enumeration (both in device and host mode) to ensure sane values after each enumeration. User code should no longer explicitly set state information as this is no longer preserved.

pull/1469/head
Dean Camera 15 years ago
parent b9dd51cd63
commit 864196c884

@ -49,11 +49,6 @@ USB_ClassInfo_Audio_Device_t Microphone_Audio_Interface =
.DataINEndpointNumber = AUDIO_STREAM_EPNUM, .DataINEndpointNumber = AUDIO_STREAM_EPNUM,
.DataINEndpointSize = AUDIO_STREAM_EPSIZE, .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 /** Main program entry point. This routine contains the overall program flow, including initial

@ -49,11 +49,6 @@ USB_ClassInfo_Audio_Device_t Speaker_Audio_Interface =
.DataINEndpointNumber = AUDIO_STREAM_EPNUM, .DataINEndpointNumber = AUDIO_STREAM_EPNUM,
.DataINEndpointSize = AUDIO_STREAM_EPSIZE, .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 /** Main program entry point. This routine contains the overall program flow, including initial

@ -55,11 +55,6 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
.NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM, .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, .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 /** Main program entry point. This routine contains the overall program flow, including initial

@ -56,11 +56,6 @@ USB_ClassInfo_CDC_Device_t VirtualSerial1_CDC_Interface =
.NotificationEndpointNumber = CDC1_NOTIFICATION_EPNUM, .NotificationEndpointNumber = CDC1_NOTIFICATION_EPNUM,
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
}, },
.State =
{
// Leave all state values to their defaults
}
}; };
/** LUFA CDC Class driver interface configuration and state information. This structure is /** LUFA CDC Class driver interface configuration and state information. This structure is

@ -51,11 +51,6 @@ USB_ClassInfo_HID_Device_t Generic_HID_Interface =
.ReportINBufferSize = GENERIC_REPORT_SIZE, .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 /** Main program entry point. This routine contains the overall program flow, including initial

@ -51,11 +51,6 @@ USB_ClassInfo_HID_Device_t Joystick_HID_Interface =
.ReportINBufferSize = sizeof(USB_JoystickReport_Data_t), .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 /** Main program entry point. This routine contains the overall program flow, including initial

@ -52,11 +52,6 @@ USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
.ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t), .ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t),
}, },
.State =
{
.IdleCount = 500,
}
}; };
/** Main program entry point. This routine contains the overall program flow, including initial /** Main program entry point. This routine contains the overall program flow, including initial

@ -53,11 +53,6 @@ USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
.ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t), .ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t),
}, },
.State =
{
.IdleCount = 500,
}
}; };
/** LUFA HID Class driver interface configuration and state information. This structure is /** LUFA HID Class driver interface configuration and state information. This structure is

@ -52,11 +52,6 @@ USB_ClassInfo_MIDI_Device_t Keyboard_MIDI_Interface =
.DataOUTEndpointNumber = MIDI_STREAM_OUT_EPNUM, .DataOUTEndpointNumber = MIDI_STREAM_OUT_EPNUM,
.DataOUTEndpointSize = MIDI_STREAM_EPSIZE, .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 /** Main program entry point. This routine contains the overall program flow, including initial

@ -54,11 +54,6 @@ USB_ClassInfo_MS_Device_t Disk_MS_Interface =
.TotalLUNs = TOTAL_LUNS, .TotalLUNs = TOTAL_LUNS,
}, },
.State =
{
// Leave all state values to their defaults
}
}; };
/** Main program entry point. This routine contains the overall program flow, including initial /** Main program entry point. This routine contains the overall program flow, including initial

@ -51,11 +51,6 @@ USB_ClassInfo_HID_Device_t Mouse_HID_Interface =
.ReportINBufferSize = sizeof(USB_MouseReport_Data_t), .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 /** Main program entry point. This routine contains the overall program flow, including initial

@ -58,11 +58,6 @@ USB_ClassInfo_RNDIS_Device_t Ethernet_RNDIS_Interface =
.AdapterVendorDescription = "LUFA RNDIS Demo Adapter", .AdapterVendorDescription = "LUFA RNDIS Demo Adapter",
.AdapterMACAddress = {ADAPTER_MAC_ADDRESS}, .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 /** Main program entry point. This routine contains the overall program flow, including initial

@ -61,11 +61,6 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
.NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM, .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, .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 /** Main program entry point. This routine contains the overall program flow, including initial

@ -48,11 +48,6 @@ USB_ClassInfo_CDC_Host_t VirtualSerial_CDC_Interface =
.DataOUTPipeNumber = 2, .DataOUTPipeNumber = 2,
.NotificationPipeNumber = 3, .NotificationPipeNumber = 3,
}, },
.State =
{
// Leave all state values to their defaults
}
}; };

@ -50,11 +50,6 @@ USB_ClassInfo_HID_Host_t Mouse_HID_Interface =
.MatchInterfaceProtocol = true, .MatchInterfaceProtocol = true,
.HIDInterfaceProtocol = 0x02, .HIDInterfaceProtocol = 0x02,
}, },
.State =
{
// Leave all state values to their defaults
}
}; };

@ -59,6 +59,8 @@ void Audio_Device_ProcessControlPacket(USB_ClassInfo_Audio_Device_t* const Audio
bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_Device_t* AudioInterfaceInfo) bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_Device_t* AudioInterfaceInfo)
{ {
memset(&AudioInterfaceInfo->State, 0x00, sizeof(AudioInterfaceInfo->State));
if (AudioInterfaceInfo->Config.DataINEndpointNumber) if (AudioInterfaceInfo->Config.DataINEndpointNumber)
{ {
if (!(Endpoint_ConfigureEndpoint(AudioInterfaceInfo->Config.DataINEndpointNumber, EP_TYPE_ISOCHRONOUS, if (!(Endpoint_ConfigureEndpoint(AudioInterfaceInfo->Config.DataINEndpointNumber, EP_TYPE_ISOCHRONOUS,

@ -91,8 +91,7 @@
* of the Audio Streaming interface. * of the Audio Streaming interface.
*/ */
} State; /**< State data for the USB class interface within the device. All elements in this section } State; /**< State data for the USB class interface within the device. All elements in this section
* <b>may</b> be set to initial values, but may also be ignored to default to sane values when * are reset to their defaults when the interface is enumerated.
* the interface is enumerated.
*/ */
} USB_ClassInfo_Audio_Device_t; } USB_ClassInfo_Audio_Device_t;

@ -87,6 +87,8 @@ void CDC_Device_ProcessControlPacket(USB_ClassInfo_CDC_Device_t* CDCInterfaceInf
bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo) bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
{ {
memset(&CDCInterfaceInfo->State, 0x00, sizeof(CDCInterfaceInfo->State));
if (!(Endpoint_ConfigureEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber, EP_TYPE_BULK, if (!(Endpoint_ConfigureEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber, EP_TYPE_BULK,
ENDPOINT_DIR_IN, CDCInterfaceInfo->Config.DataINEndpointSize, ENDPOINT_DIR_IN, CDCInterfaceInfo->Config.DataINEndpointSize,
ENDPOINT_BANK_SINGLE))) ENDPOINT_BANK_SINGLE)))

@ -102,8 +102,7 @@
uint8_t DataBits; /**< Bits of data per character of the virtual serial port */ uint8_t DataBits; /**< Bits of data per character of the virtual serial port */
} LineEncoding; } LineEncoding;
} State; /**< State data for the USB class interface within the device. All elements in this section } State; /**< State data for the USB class interface within the device. All elements in this section
* <b>may</b> be set to initial values, but may also be ignored to default to sane values when * are reset to their defaults when the interface is enumerated.
* the interface is enumerated.
*/ */
} USB_ClassInfo_CDC_Device_t; } USB_ClassInfo_CDC_Device_t;

@ -135,6 +135,8 @@ void HID_Device_ProcessControlPacket(USB_ClassInfo_HID_Device_t* const HIDInterf
bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)
{ {
memset(&HIDInterfaceInfo->State, 0x00, sizeof(HIDInterfaceInfo->State));
HIDInterfaceInfo->State.IdleCount = 500;
HIDInterfaceInfo->State.UsingReportProtocol = true; HIDInterfaceInfo->State.UsingReportProtocol = true;
if (!(Endpoint_ConfigureEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber, EP_TYPE_INTERRUPT, if (!(Endpoint_ConfigureEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber, EP_TYPE_INTERRUPT,

@ -83,8 +83,7 @@
uint16_t IdleMSRemaining; /**< Total number of ms remaining before the idle period elapsed - this should be uint16_t IdleMSRemaining; /**< Total number of ms remaining before the idle period elapsed - this should be
* decremented by the user application if non-zero each millisecond */ * decremented by the user application if non-zero each millisecond */
} State; /**< State data for the USB class interface within the device. All elements in this section } State; /**< State data for the USB class interface within the device. All elements in this section
* <b>may</b> be set to initial values, but may also be ignored to default to sane values when * are reset to their defaults when the interface is enumerated.
* the interface is enumerated.
*/ */
} USB_ClassInfo_HID_Device_t; } USB_ClassInfo_HID_Device_t;

@ -40,6 +40,8 @@ void MIDI_Device_ProcessControlPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInt
bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo)
{ {
memset(&MIDIInterfaceInfo->State, 0x00, sizeof(MIDIInterfaceInfo->State));
if (MIDIInterfaceInfo->Config.DataINEndpointNumber) if (MIDIInterfaceInfo->Config.DataINEndpointNumber)
{ {
if (!(Endpoint_ConfigureEndpoint(MIDIInterfaceInfo->Config.DataINEndpointNumber, EP_TYPE_BULK, if (!(Endpoint_ConfigureEndpoint(MIDIInterfaceInfo->Config.DataINEndpointNumber, EP_TYPE_BULK,

@ -80,8 +80,7 @@
{ {
// No state information for this class yet // No state information for this class yet
} State; /**< State data for the USB class interface within the device. All elements in this section } State; /**< State data for the USB class interface within the device. All elements in this section
* <b>may</b> be set to initial values, but may also be ignored to default to sane values when * are reset to their defaults when the interface is enumerated.
* the interface is enumerated.
*/ */
} USB_ClassInfo_MIDI_Device_t; } USB_ClassInfo_MIDI_Device_t;

@ -74,6 +74,8 @@ void MS_Device_ProcessControlPacket(USB_ClassInfo_MS_Device_t* const MSInterface
bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
{ {
memset(&MSInterfaceInfo->State, 0x00, sizeof(MSInterfaceInfo->State));
if (!(Endpoint_ConfigureEndpoint(MSInterfaceInfo->Config.DataINEndpointNumber, EP_TYPE_BULK, if (!(Endpoint_ConfigureEndpoint(MSInterfaceInfo->Config.DataINEndpointNumber, EP_TYPE_BULK,
ENDPOINT_DIR_IN, MSInterfaceInfo->Config.DataINEndpointSize, ENDPOINT_DIR_IN, MSInterfaceInfo->Config.DataINEndpointSize,
ENDPOINT_BANK_SINGLE))) ENDPOINT_BANK_SINGLE)))

@ -89,8 +89,7 @@
* and that all current Mass Storage operations should immediately abort * and that all current Mass Storage operations should immediately abort
*/ */
} State; /**< State data for the USB class interface within the device. All elements in this section } State; /**< State data for the USB class interface within the device. All elements in this section
* <b>may</b> be set to initial values, but may also be ignored to default to sane values when * are reset to their defaults when the interface is enumerated.
* the interface is enumerated.
*/ */
} USB_ClassInfo_MS_Device_t; } USB_ClassInfo_MS_Device_t;

@ -112,6 +112,8 @@ void RNDIS_Device_ProcessControlPacket(USB_ClassInfo_RNDIS_Device_t* const RNDIS
bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo)
{ {
memset(&RNDISInterfaceInfo->State, 0x00, sizeof(RNDISInterfaceInfo->State));
if (!(Endpoint_ConfigureEndpoint(RNDISInterfaceInfo->Config.DataINEndpointNumber, EP_TYPE_BULK, if (!(Endpoint_ConfigureEndpoint(RNDISInterfaceInfo->Config.DataINEndpointNumber, EP_TYPE_BULK,
ENDPOINT_DIR_IN, RNDISInterfaceInfo->Config.DataINEndpointSize, ENDPOINT_DIR_IN, RNDISInterfaceInfo->Config.DataINEndpointSize,
ENDPOINT_BANK_SINGLE))) ENDPOINT_BANK_SINGLE)))

@ -97,8 +97,7 @@
* user application * user application
*/ */
} State; /**< State data for the USB class interface within the device. All elements in this section } State; /**< State data for the USB class interface within the device. All elements in this section
* <b>may</b> be set to initial values, but may also be ignored to default to sane values when * are reset to their defaults when the interface is enumerated.
* the interface is enumerated.
*/ */
} USB_ClassInfo_RNDIS_Device_t; } USB_ClassInfo_RNDIS_Device_t;

@ -39,6 +39,8 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* CDCInterfaceInfo, uint
{ {
uint8_t FoundEndpoints = 0; uint8_t FoundEndpoints = 0;
memset(&CDCInterfaceInfo->State, 0x00, sizeof(CDCInterfaceInfo->State));
if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)
return CDC_ENUMERROR_InvalidConfigDescriptor; return CDC_ENUMERROR_InvalidConfigDescriptor;

@ -39,6 +39,8 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint
{ {
uint8_t FoundEndpoints = 0; uint8_t FoundEndpoints = 0;
memset(&HIDInterfaceInfo->State, 0x00, sizeof(HIDInterfaceInfo->State));
if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)
return HID_ENUMERROR_InvalidConfigDescriptor; return HID_ENUMERROR_InvalidConfigDescriptor;

@ -62,7 +62,7 @@
* to only unfreeze and check one data pipe at a time) to prevent incorrect device enumerations and freezes while trasferring data * to only unfreeze and check one data pipe at a time) to prevent incorrect device enumerations and freezes while trasferring data
* - Make Pipe_ConfigurePipe() mask the given endpoint number against PIPE_EPNUM_MASK to ensure the endpoint IN direction bit is * - Make Pipe_ConfigurePipe() mask the given endpoint number against PIPE_EPNUM_MASK to ensure the endpoint IN direction bit is
* cleared to prevent endpoint type corruption * cleared to prevent endpoint type corruption
* - Fix documentation mentioning Pipe_GetCurrentToken() function when real name is Pipe_GetPipeToken() * - Fixed documentation mentioning Pipe_GetCurrentToken() function when correct function name is Pipe_GetPipeToken()
* - Fixed ADC driver for the ATMEGA32U4 and ATMEGA16U4 (thanks to Opendous Inc.) * - Fixed ADC driver for the ATMEGA32U4 and ATMEGA16U4 (thanks to Opendous Inc.)
* - Fixed CDCHost demo unfreezing the pipes at the point of configuration, rather than use * - Fixed CDCHost demo unfreezing the pipes at the point of configuration, rather than use
* - Fixed MassStorage demo not clearing the reset flag when a Mass Storage Reset is issued while not processing a command * - Fixed MassStorage demo not clearing the reset flag when a Mass Storage Reset is issued while not processing a command

@ -33,7 +33,7 @@
* *
* This folder contains drivers for several of the AVR internal peripherals such as the USART, compatible only with * This folder contains drivers for several of the AVR internal peripherals such as the USART, compatible only with
* the AT90USBXXX6, AT90USBXXX7 and ATMEGAXXU4 USB AVR models, such as the AT90USB1287. Its contents should <b>not</b> be * the AT90USBXXX6, AT90USBXXX7 and ATMEGAXXU4 USB AVR models, such as the AT90USB1287. Its contents should <b>not</b> be
* included by the user application - the dispatch header file located in the parent AT90USBXXX directory should be used * included by the user application - the dispatch header file located in the parent directory should be used
* instead. * instead.
* *
* \dir LUFA/Drivers/USB * \dir LUFA/Drivers/USB

@ -35,7 +35,7 @@
* - The \ref CALLBACK_USB_GetDescriptor() function now takes an extra parameter to specify the descriptor's memory space so that * - The \ref CALLBACK_USB_GetDescriptor() function now takes an extra parameter to specify the descriptor's memory space so that
* descriptors in mixed memory spaces can be used. The previous functionality can be returned by defining the USE_FLASH_DESCRIPTORS * descriptors in mixed memory spaces can be used. The previous functionality can be returned by defining the USE_FLASH_DESCRIPTORS
* token in the project makefile to fix all descriptors into FLASH space and remove the extra function parameter. * token in the project makefile to fix all descriptors into FLASH space and remove the extra function parameter.
* - Removed USB_IsSuspended - test \ref USB_DeviceState against \ref DEVICE_STATE_Suspended instead. * - The USB_IsSuspended global has been removed - test \ref USB_DeviceState against \ref DEVICE_STATE_Suspended instead.
* *
* *
* \section Sec_Migration090605 Migrating from 090510 to 090605 * \section Sec_Migration090605 Migrating from 090510 to 090605

@ -67,11 +67,6 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
.NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM, .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
.NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, .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 /** Main program entry point. This routine contains the overall program flow, including initial

@ -60,11 +60,6 @@ USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
.ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t), .ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t),
}, },
.State =
{
// Leave all state values to their defaults
}
}; };
/** Main program entry point. This routine contains the overall program flow, including initial /** Main program entry point. This routine contains the overall program flow, including initial

Loading…
Cancel
Save