From 3cbdcd36868693cfc1863231a1ec64507ce3d29f Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Fri, 26 Jun 2009 11:43:56 +0000 Subject: Reduce struct name pollution - group typedef struct names by class driver name where appropriate. --- LUFA/Drivers/USB/Class/Common/Audio.h | 27 +++++--- LUFA/Drivers/USB/Class/Common/HID.h | 2 +- LUFA/Drivers/USB/Class/Common/MIDI.h | 4 +- LUFA/Drivers/USB/Class/Common/MassStorage.h | 4 +- LUFA/Drivers/USB/Class/Common/RNDIS.h | 14 ++-- LUFA/Drivers/USB/Class/Device/Audio.h | 75 ++++++++++------------ LUFA/Drivers/USB/Class/Device/CDC.h | 93 ++++++++++++--------------- LUFA/Drivers/USB/Class/Device/HID.h | 57 +++++++---------- LUFA/Drivers/USB/Class/Device/MIDI.c | 8 +-- LUFA/Drivers/USB/Class/Device/MIDI.h | 51 +++++++-------- LUFA/Drivers/USB/Class/Device/MassStorage.c | 4 +- LUFA/Drivers/USB/Class/Device/MassStorage.h | 72 +++++++++------------ LUFA/Drivers/USB/Class/Device/RNDIS.h | 85 +++++++++++-------------- LUFA/Drivers/USB/Class/Host/CDC.h | 99 +++++++++++++---------------- 14 files changed, 265 insertions(+), 330 deletions(-) (limited to 'LUFA/Drivers') diff --git a/LUFA/Drivers/USB/Class/Common/Audio.h b/LUFA/Drivers/USB/Class/Common/Audio.h index 07667a5e1..a55fd0d7c 100644 --- a/LUFA/Drivers/USB/Class/Common/Audio.h +++ b/LUFA/Drivers/USB/Class/Common/Audio.h @@ -46,6 +46,13 @@ #endif /* Macros: */ + #if !defined(AUDIO_TOTAL_SAMPLE_RATES) || defined(__DOXYGEN__) + /** Total number of discrete audio sample rates supported by the device. This value can be overridden by defining this + * token in the project makefile to the desired value, and passing it to the compiler via the -D switch. + */ + #define AUDIO_TOTAL_SAMPLE_RATES 1 + #endif + /** Descriptor header constant to indicate a Audio class interface descriptor. */ #define DTYPE_AudioInterface 0x24 @@ -223,7 +230,7 @@ uint8_t InCollection; /**< Total number of audio class interfaces within this device */ uint8_t InterfaceNumbers[1]; /**< Interface numbers of each audio interface */ - } USB_AudioInterface_AC_t; + } USB_Audio_Interface_AC_t; /** Type define for an Audio class specific Feature Unit descriptor. This indicates to the host what features * are present in the device's audio stream for basic control, such as per-channel volume. See the USB Audio @@ -241,7 +248,7 @@ uint8_t ChannelControls[3]; /**< Feature masks for the control channel, and each separate audio channel */ uint8_t FeatureUnitStrIndex; /**< Index of a string descriptor describing this descriptor within the device */ - } USB_AudioFeatureUnit_t; + } USB_Audio_FeatureUnit_t; /** Type define for an Audio class specific input terminal descriptor. This indicates to the host that the device * contains an input audio source, either from a physical terminal on the device, or a logical terminal (for example, @@ -262,7 +269,7 @@ uint8_t ChannelStrIndex; /**< Index of a string descriptor describing this channel within the device */ uint8_t TerminalStrIndex; /**< Index of a string descriptor describing this descriptor within the device */ - } USB_AudioInputTerminal_t; + } USB_Audio_InputTerminal_t; /** Type define for an Audio class specific output terminal descriptor. This indicates to the host that the device * contains an output audio sink, either to a physical terminal on the device, or a logical terminal (for example, @@ -281,7 +288,7 @@ uint8_t SourceID; /**< ID value of the unit this terminal's audio is sourced from */ uint8_t TerminalStrIndex; /**< Index of a string descriptor describing this descriptor within the device */ - } USB_AudioOutputTerminal_t; + } USB_Audio_OutputTerminal_t; /** Type define for an Audio class specific streaming interface descriptor. This indicates to the host * how audio streams within the device are formatted. See the USB Audio specification for more details. @@ -295,7 +302,7 @@ uint8_t FrameDelay; /**< Delay in frames resulting from the complete sample processing from input to output */ uint16_t AudioFormat; /**< Format of the audio stream, see Audio Device Formats specification */ - } USB_AudioInterface_AS_t; + } USB_Audio_Interface_AS_t; /** Type define for a 24bit audio sample frequency structure. GCC does not contain a built in 24bit datatype, * this this structure is used to build up the value instead. Fill this structure with the SAMPLE_FREQ() macro. @@ -304,7 +311,7 @@ { uint16_t LowWord; /**< Low 16 bits of the 24-bit value */ uint8_t HighByte; /**< Upper 8 bits of the 24-bit value */ - } AudioSampleFreq_t; + } USB_Audio_SampleFreq_t; /** Type define for an Audio class specific audio format descriptor. This is used to give the host full details * about the number of channels, the sample resolution, acceptable sample frequencies and encoding method used @@ -322,8 +329,8 @@ uint8_t BitResolution; /**< Bits of resolution of each channel's samples in the stream */ uint8_t SampleFrequencyType; /**< Total number of sample frequencies supported by the device */ - AudioSampleFreq_t SampleFrequencies[1]; /**< Sample frequencies supported by the device */ - } USB_AudioFormat_t; + USB_Audio_SampleFreq_t SampleFrequencies[AUDIO_TOTAL_SAMPLE_RATES]; /**< Sample frequencies supported by the device */ + } USB_Audio_Format_t; /** Type define for an Audio class specific endpoint descriptor. This contains a regular endpoint * descriptor with a few Audio-class specific extensions. See the USB Audio specification for more details. @@ -334,7 +341,7 @@ uint8_t Refresh; /**< Always set to zero */ uint8_t SyncEndpointNumber; /**< Endpoint address to send synchronisation information to, if needed (zero otherwise) */ - } USB_AudioStreamEndpoint_Std_t; + } USB_Audio_StreamEndpoint_Std_t; /** Type define for an Audio class specific extended endpoint descriptor. This contains extra information * on the usage of endpoints used to stream audio in and out of the USB Audio device, and follows an Audio @@ -349,7 +356,7 @@ uint8_t LockDelayUnits; /**< Units used for the LockDelay field, see Audio class specification */ uint16_t LockDelay; /**< Time required to internally lock endpoint's internal clock recovery circuitry */ - } USB_AudioStreamEndpoint_Spc_t; + } USB_Audio_StreamEndpoint_Spc_t; /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) diff --git a/LUFA/Drivers/USB/Class/Common/HID.h b/LUFA/Drivers/USB/Class/Common/HID.h index 54403d4c8..9179f6af0 100644 --- a/LUFA/Drivers/USB/Class/Common/HID.h +++ b/LUFA/Drivers/USB/Class/Common/HID.h @@ -80,7 +80,7 @@ uint8_t HIDReportType; uint16_t HIDReportLength; - } USB_Descriptor_HID_t; + } USB_HID_Descriptor_t; /** Type define for the data type used to store HID report descriptor elements. */ typedef uint8_t USB_Descriptor_HIDReport_Datatype_t; diff --git a/LUFA/Drivers/USB/Class/Common/MIDI.h b/LUFA/Drivers/USB/Class/Common/MIDI.h index fad7ad89d..dfeadb05b 100644 --- a/LUFA/Drivers/USB/Class/Common/MIDI.h +++ b/LUFA/Drivers/USB/Class/Common/MIDI.h @@ -87,7 +87,7 @@ uint16_t AudioSpecification; /**< Binary coded decimal value, indicating the supported Audio Class specification version */ uint16_t TotalLength; /**< Total length of the Audio class specific descriptors, including this descriptor */ - } USB_AudioInterface_MIDI_AS_t; + } USB_MIDI_AudioInterface_AS_t; /** Type define for an Audio class specific MIDI IN jack. This gives information to the host on a MIDI input, either * a physical input jack, or a logical jack (receiving input data internally, or from the host via an endpoint). @@ -143,7 +143,7 @@ uint8_t Data1; /**< First byte of data in the MIDI event */ uint8_t Data2; /**< Second byte of data in the MIDI event */ uint8_t Data3; /**< Third byte of data in the MIDI event */ - } USB_MIDI_EventPacket_t; + } MIDI_EventPacket_t; /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) diff --git a/LUFA/Drivers/USB/Class/Common/MassStorage.h b/LUFA/Drivers/USB/Class/Common/MassStorage.h index d00f371a0..f7e4df361 100644 --- a/LUFA/Drivers/USB/Class/Common/MassStorage.h +++ b/LUFA/Drivers/USB/Class/Common/MassStorage.h @@ -75,7 +75,7 @@ uint8_t LUN; /**< Logical Unit number this command is issued to */ uint8_t SCSICommandLength; /**< Length of the issued SCSI command within the SCSI command data array */ uint8_t SCSICommandData[16]; /**< Issued SCSI command in the Command Block */ - } CommandBlockWrapper_t; + } MS_CommandBlockWrapper_t; /** Type define for a Command Status Wrapper, used in the Mass Storage Bulk-Only Transport protocol. */ typedef struct @@ -84,7 +84,7 @@ uint32_t Tag; /**< Unique command ID value, to associate a command block wrapper with its command status wrapper */ uint32_t DataTransferResidue; /**< Number of bytes of data not processed in the SCSI command */ uint8_t Status; /**< Status code of the issued command - a value from the MassStorage_CommandStatusCodes_t enum */ - } CommandStatusWrapper_t; + } MS_CommandStatusWrapper_t; /* Enums: */ /** Enum for the possible command status wrapper return status codes. */ diff --git a/LUFA/Drivers/USB/Class/Common/RNDIS.h b/LUFA/Drivers/USB/Class/Common/RNDIS.h index c169fa448..5c875b7de 100644 --- a/LUFA/Drivers/USB/Class/Common/RNDIS.h +++ b/LUFA/Drivers/USB/Class/Common/RNDIS.h @@ -93,13 +93,6 @@ uint8_t Octets[6]; /**< Individual bytes of a MAC address */ } MAC_Address_t; - /** Type define for a RNDIS message header, sent before RNDIS messages */ - typedef struct - { - uint32_t MessageType; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */ - uint32_t MessageLength; /**< Total length of the RNDIS message, in bytes */ - } RNDIS_Message_Header_t; - /** Type define for an Ethernet frame buffer. */ typedef struct { @@ -108,6 +101,13 @@ bool FrameInBuffer; /**< Indicates if a frame is currently stored in the buffer */ } Ethernet_Frame_Info_t; + /** Type define for a RNDIS message header, sent before RNDIS messages */ + typedef struct + { + uint32_t MessageType; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */ + uint32_t MessageLength; /**< Total length of the RNDIS message, in bytes */ + } RNDIS_Message_Header_t; + /** Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter */ typedef struct { diff --git a/LUFA/Drivers/USB/Class/Device/Audio.h b/LUFA/Drivers/USB/Class/Device/Audio.h index cc3e98419..faa9c9243 100644 --- a/LUFA/Drivers/USB/Class/Device/Audio.h +++ b/LUFA/Drivers/USB/Class/Device/Audio.h @@ -52,55 +52,44 @@ #endif /* Public Interface - May be used in end-application: */ - /* Type Defines: */ - /** Configuration information structure for \ref USB_ClassInfo_Audio_Device_t Audio device interface structures. */ - typedef struct - { - uint8_t StreamingInterfaceNumber; /**< Index of the Audio Streaming interface within the device this - * structure controls. - */ - - uint8_t DataINEndpointNumber; /**< Endpoint number of the incomming Audio Streaming data, if available - * (zero if unused). - */ - uint16_t DataINEndpointSize; /**< Size in bytes of the incomming Audio Streaming data endpoint, if available - * (zero if unused). - */ - - uint8_t DataOUTEndpointNumber; /**< Endpoint number of the outgoing Audio Streaming data, if available - * (zero if unused). - */ - uint16_t DataOUTEndpointSize; /**< Size in bytes of the outgoing Audio Streaming data endpoint, if available - * (zero if unused). - */ - } USB_ClassInfo_Audio_Device_Config_t; - - /** Current State information structure for \ref USB_ClassInfo_Audio_Device_t Audio device interface structures. */ - typedef struct - { - bool InterfaceEnabled; /**< Set and cleared by the class driver to indicate if the host has enabled the streaming endpoints - * of the Audio Streaming interface. - */ - } USB_ClassInfo_Audio_Device_State_t; - + /* Type Defines: */ /** Class state structure. An instance of this structure should be made for each Audio interface * within the user application, and passed to each of the Audio class driver functions as the * AudioInterfaceInfo parameter. This stores each Audio interface's configuration and state information. */ typedef struct { - const USB_ClassInfo_Audio_Device_Config_t Config; /**< Config data for the USB class interface within - * the device. All elements in this section - * must be set or the interface will fail - * to enumerate and operate correctly. - */ - - USB_ClassInfo_Audio_Device_State_t State; /**< State data for the USB class interface within - * the device. All elements in this section - * may be set to initial values, but may - * also be ignored to default to sane values when - * the interface is enumerated. - */ + const struct + { + uint8_t StreamingInterfaceNumber; /**< Index of the Audio Streaming interface within the device this + * structure controls. + */ + + uint8_t DataINEndpointNumber; /**< Endpoint number of the incomming Audio Streaming data, if available + * (zero if unused). + */ + uint16_t DataINEndpointSize; /**< Size in bytes of the incomming Audio Streaming data endpoint, if available + * (zero if unused). + */ + + uint8_t DataOUTEndpointNumber; /**< Endpoint number of the outgoing Audio Streaming data, if available + * (zero if unused). + */ + uint16_t DataOUTEndpointSize; /**< Size in bytes of the outgoing Audio Streaming data endpoint, if available + * (zero if unused). + */ + } Config; /**< Config data for the USB class interface within the device. All elements in this section + * must be set or the interface will fail to enumerate and operate correctly. + */ + struct + { + bool InterfaceEnabled; /**< Set and cleared by the class driver to indicate if the host has enabled the streaming endpoints + * of the Audio Streaming interface. + */ + } State; /**< State data for the USB class interface within the device. All elements in this section + * may be set to initial values, but may also be ignored to default to sane values when + * the interface is enumerated. + */ } USB_ClassInfo_Audio_Device_t; /* Function Prototypes: */ diff --git a/LUFA/Drivers/USB/Class/Device/CDC.h b/LUFA/Drivers/USB/Class/Device/CDC.h index bcf8ff7b9..157b35003 100644 --- a/LUFA/Drivers/USB/Class/Device/CDC.h +++ b/LUFA/Drivers/USB/Class/Device/CDC.h @@ -53,65 +53,54 @@ /* Public Interface - May be used in end-application: */ /* Type Defines: */ - /** Configuration information structure for \ref USB_ClassInfo_CDC_Device_t CDC device interface structures. */ + /** Class state structure. An instance of this structure should be made for each CDC interface + * within the user application, and passed to each of the CDC class driver functions as the + * CDCInterfaceInfo parameter. This stores each CDC interface's configuration and state information. + */ typedef struct { - uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device */ - - 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 */ + const struct + { + uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device */ - 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 */ + 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 */ - 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 */ - } USB_ClassInfo_CDC_Device_Config_t; - - /** Current State information structure for \ref USB_ClassInfo_CDC_Device_t CDC device interface structures. */ - typedef struct - { - struct - { - uint8_t HostToDevice; /**< Control line states from the host to device, as a set of CDC_CONTROL_LINE_OUT_* - * masks. - */ - uint8_t DeviceToHost; /**< Control line states from the device to host, as a set of CDC_CONTROL_LINE_IN_* - * masks. - */ - } ControlLineStates; + 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 */ + 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 */ + } Config; /**< Config data for the USB class interface within the device. All elements in this section + * must be set or the interface will fail to enumerate and operate correctly. + */ struct { - uint32_t BaudRateBPS; /**< Baud rate of the virtual serial port, in bits per second */ - uint8_t CharFormat; /**< Character format of the virtual serial port, a value from the - * CDCDevice_CDC_LineCodingFormats_t enum - */ - uint8_t ParityType; /**< Parity setting of the virtual serial port, a value from the - * CDCDevice_LineCodingParity_t enum - */ - uint8_t DataBits; /**< Bits of data per character of the virtual serial port */ - } LineEncoding; - } USB_ClassInfo_CDC_Device_State_t; - - /** Class state structure. An instance of this structure should be made for each CDC interface - * within the user application, and passed to each of the CDC class driver functions as the - * CDCInterfaceInfo parameter. This stores each CDC interface's configuration and state information. - */ - typedef struct - { - const USB_ClassInfo_CDC_Device_Config_t Config; /**< Config data for the USB class interface within - * the device. All elements in this section - * must be set or the interface will fail - * to enumerate and operate correctly. - */ - - USB_ClassInfo_CDC_Device_State_t State; /**< State data for the USB class interface within - * the device. All elements in this section - * may be set to initial values, but may - * also be ignored to default to sane values when - * the interface is enumerated. - */ + struct + { + uint8_t HostToDevice; /**< Control line states from the host to device, as a set of CDC_CONTROL_LINE_OUT_* + * masks. + */ + uint8_t DeviceToHost; /**< Control line states from the device to host, as a set of CDC_CONTROL_LINE_IN_* + * masks. + */ + } ControlLineStates; + + struct + { + uint32_t BaudRateBPS; /**< Baud rate of the virtual serial port, in bits per second */ + uint8_t CharFormat; /**< Character format of the virtual serial port, a value from the + * CDCDevice_CDC_LineCodingFormats_t enum + */ + uint8_t ParityType; /**< Parity setting of the virtual serial port, a value from the + * CDCDevice_LineCodingParity_t enum + */ + uint8_t DataBits; /**< Bits of data per character of the virtual serial port */ + } LineEncoding; + } State; /**< State data for the USB class interface within the device. All elements in this section + * may be set to initial values, but may also be ignored to default to sane values when + * the interface is enumerated. + */ } USB_ClassInfo_CDC_Device_t; /* Function Prototypes: */ diff --git a/LUFA/Drivers/USB/Class/Device/HID.h b/LUFA/Drivers/USB/Class/Device/HID.h index 00d73a9a0..61e5eed28 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.h +++ b/LUFA/Drivers/USB/Class/Device/HID.h @@ -53,46 +53,35 @@ /* Public Interface - May be used in end-application: */ /* Type Defines: */ - /** Configuration information structure for \ref USB_ClassInfo_HID_Device_t HID device interface structures. */ - typedef struct - { - uint8_t InterfaceNumber; /**< Interface number of the HID interface within the device */ - - 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 */ - - uint8_t ReportINBufferSize; /**< Size of the largest possible report to send to the host, for - * buffer allocation purposes - */ - } USB_ClassInfo_HID_Device_Config_t; - - /** Current State information structure for \ref USB_ClassInfo_HID_Device_t HID device interface structures. */ - typedef struct - { - bool UsingReportProtocol; /**< Indicates if the HID interface is set to Boot or Report protocol mode */ - uint16_t IdleCount; /**< Report idle period, in ms, set by the host */ - 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 */ - } USB_ClassInfo_HID_Device_State_t; - /** Class state structure. An instance of this structure should be made for each HID interface * within the user application, and passed to each of the HID class driver functions as the * HIDInterfaceInfo parameter. This stores each HID interface's configuration and state information. */ typedef struct { - const USB_ClassInfo_HID_Device_Config_t Config; /**< Config data for the USB class interface within - * the device. All elements in this section - * must be set or the interface will fail - * to enumerate and operate correctly. - */ - - USB_ClassInfo_HID_Device_State_t State; /**< State data for the USB class interface within - * the device. All elements in this section - * may be set to initial values, but may - * also be ignored to default to sane values when - * the interface is enumerated. - */ + const struct + { + uint8_t InterfaceNumber; /**< Interface number of the HID interface within the device */ + + 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 */ + + uint8_t ReportINBufferSize; /**< Size of the largest possible report to send to the host, for + * buffer allocation purposes + */ + } Config; /**< Config data for the USB class interface within the device. All elements in this section + * must be set or the interface will fail to enumerate and operate correctly. + */ + struct + { + bool UsingReportProtocol; /**< Indicates if the HID interface is set to Boot or Report protocol mode */ + uint16_t IdleCount; /**< Report idle period, in ms, set by the host */ + 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 */ + } State; /**< State data for the USB class interface within the device. All elements in this section + * may be set to initial values, but may also be ignored to default to sane values when + * the interface is enumerated. + */ } USB_ClassInfo_HID_Device_t; /* Function Prototypes: */ diff --git a/LUFA/Drivers/USB/Class/Device/MIDI.c b/LUFA/Drivers/USB/Class/Device/MIDI.c index 1d342f5ce..0dcc94db9 100644 --- a/LUFA/Drivers/USB/Class/Device/MIDI.c +++ b/LUFA/Drivers/USB/Class/Device/MIDI.c @@ -68,7 +68,7 @@ void MIDI_Device_USBTask(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceInfo) } -void MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event) +void MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceInfo, MIDI_EventPacket_t* Event) { if (!(USB_IsConnected)) return; @@ -77,12 +77,12 @@ void MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceInfo, if (Endpoint_IsReadWriteAllowed()); { - Endpoint_Write_Stream_LE(Event, sizeof(USB_MIDI_EventPacket_t), NO_STREAM_CALLBACK); + Endpoint_Write_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NO_STREAM_CALLBACK); Endpoint_ClearIN(); } } -bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event) +bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceInfo, MIDI_EventPacket_t* Event) { if (!(USB_IsConnected)) return false; @@ -92,7 +92,7 @@ bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceIn if (!(Endpoint_IsReadWriteAllowed())) return false; - Endpoint_Read_Stream_LE(Event, sizeof(USB_MIDI_EventPacket_t), NO_STREAM_CALLBACK); + Endpoint_Read_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NO_STREAM_CALLBACK); Endpoint_ClearOUT(); return true; diff --git a/LUFA/Drivers/USB/Class/Device/MIDI.h b/LUFA/Drivers/USB/Class/Device/MIDI.h index 2cadeaf58..e81089c93 100644 --- a/LUFA/Drivers/USB/Class/Device/MIDI.h +++ b/LUFA/Drivers/USB/Class/Device/MIDI.h @@ -55,22 +55,10 @@ /* Public Interface - May be used in end-application: */ /* Type Define: */ /** Configuration information structure for \ref USB_ClassInfo_MIDI_Device_t MIDI device interface structures. */ - typedef struct - { - uint8_t StreamingInterfaceNumber; /**< Index of the Audio Streaming interface within the device this structure controls */ - - uint8_t DataINEndpointNumber; /**< Endpoint number of the incomming MIDI data, if available (zero if unused) */ - uint16_t DataINEndpointSize; /**< Size in bytes of the incomming MIDI data endpoint, if available (zero if unused) */ - - uint8_t DataOUTEndpointNumber; /**< Endpoint number of the outgoing MIDI data, if available (zero if unused) */ - uint16_t DataOUTEndpointSize; /**< Size in bytes of the outgoing MIDI data endpoint, if available (zero if unused) */ - } USB_ClassInfo_MIDI_Device_Config_t; + typedef USB_ClassInfo_MIDI_Device_Config_t; /** Current State information structure for \ref USB_ClassInfo_MIDI_Device_t MIDI device interface structures. */ - typedef struct - { - // No state information for this class yet - } USB_ClassInfo_MIDI_Device_State_t; + typedef USB_ClassInfo_MIDI_Device_State_t; /** Class state structure. An instance of this structure should be made for each MIDI interface * within the user application, and passed to each of the MIDI class driver functions as the @@ -78,18 +66,25 @@ */ typedef struct { - const USB_ClassInfo_MIDI_Device_Config_t Config; /**< Config data for the USB class interface within - * the device. All elements in this section - * must be set or the interface will fail - * to enumerate and operate correctly. - */ - - USB_ClassInfo_MIDI_Device_State_t State; /**< State data for the USB class interface within - * the device. All elements in this section - * may be set to initial values, but may - * also be ignored to default to sane values when - * the interface is enumerated. - */ + const struct + { + uint8_t StreamingInterfaceNumber; /**< Index of the Audio Streaming interface within the device this structure controls */ + + uint8_t DataINEndpointNumber; /**< Endpoint number of the incomming MIDI data, if available (zero if unused) */ + uint16_t DataINEndpointSize; /**< Size in bytes of the incomming MIDI data endpoint, if available (zero if unused) */ + + uint8_t DataOUTEndpointNumber; /**< Endpoint number of the outgoing MIDI data, if available (zero if unused) */ + uint16_t DataOUTEndpointSize; /**< Size in bytes of the outgoing MIDI data endpoint, if available (zero if unused) */ + } Config; /**< Config data for the USB class interface within the device. All elements in this section + * must be set or the interface will fail to enumerate and operate correctly. + */ + struct + { + // No state information for this class yet + } State; /**< State data for the USB class interface within the device. All elements in this section + * may be set to initial values, but may also be ignored to default to sane values when + * the interface is enumerated. + */ } USB_ClassInfo_MIDI_Device_t; /* Function Prototypes: */ @@ -122,7 +117,7 @@ * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. * \param Event Pointer to a populated USB_MIDI_EventPacket_t structure containing the MIDI event to send */ - void MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event); + void MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceInfo, MIDI_EventPacket_t* Event); /** Receives a MIDI event packet from the host. * @@ -131,7 +126,7 @@ * * \return Boolean true if a MIDI event packet was received, false otherwise */ - bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event); + bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceInfo, MIDI_EventPacket_t* Event); /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) diff --git a/LUFA/Drivers/USB/Class/Device/MassStorage.c b/LUFA/Drivers/USB/Class/Device/MassStorage.c index 073111e64..aedab106f 100644 --- a/LUFA/Drivers/USB/Class/Device/MassStorage.c +++ b/LUFA/Drivers/USB/Class/Device/MassStorage.c @@ -144,7 +144,7 @@ static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* MSInterfaceI CallbackMSInterfaceInfo = MSInterfaceInfo; Endpoint_Read_Stream_LE(&MSInterfaceInfo->State.CommandBlock, - (sizeof(CommandBlockWrapper_t) - 16), + (sizeof(MS_CommandBlockWrapper_t) - 16), StreamCallback_MS_Device_AbortOnMassStoreReset); if ((MSInterfaceInfo->State.CommandBlock.Signature != MS_CBW_SIGNATURE) || @@ -194,7 +194,7 @@ static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_Device_t* MSInterface } CallbackMSInterfaceInfo = MSInterfaceInfo; - Endpoint_Write_Stream_LE(&MSInterfaceInfo->State.CommandStatus, sizeof(CommandStatusWrapper_t), + Endpoint_Write_Stream_LE(&MSInterfaceInfo->State.CommandStatus, sizeof(MS_CommandStatusWrapper_t), StreamCallback_MS_Device_AbortOnMassStoreReset); Endpoint_ClearIN(); diff --git a/LUFA/Drivers/USB/Class/Device/MassStorage.h b/LUFA/Drivers/USB/Class/Device/MassStorage.h index 53eb7ab82..15be00e09 100644 --- a/LUFA/Drivers/USB/Class/Device/MassStorage.h +++ b/LUFA/Drivers/USB/Class/Device/MassStorage.h @@ -52,54 +52,42 @@ #endif /* Public Interface - May be used in end-application: */ - /* Type Defines: */ - /** Configuration information structure for \ref USB_ClassInfo_MS_Device_t Mass Storage device interface structures. */ - typedef struct - { - uint8_t InterfaceNumber; /**< Interface number of the Mass Storage interface within the device */ - - uint8_t DataINEndpointNumber; /**< Endpoint number of the Mass Storage interface's IN data endpoint */ - uint16_t DataINEndpointSize; /**< Size in bytes of the Mass Storage interface's IN data endpoint */ - - uint8_t DataOUTEndpointNumber; /**< Endpoint number of the Mass Storage interface's OUT data endpoint */ - uint16_t DataOUTEndpointSize; /**< Size in bytes of the Mass Storage interface's OUT data endpoint */ - - uint8_t TotalLUNs; /**< Total number of logical drives in the Mass Storage interface */ - } USB_ClassInfo_MS_Device_Config_t; - - /** Current State information structure for \ref USB_ClassInfo_MS_Device_t Mass Storage device interface structures. */ - typedef struct - { - CommandBlockWrapper_t CommandBlock; /**< Mass Storage class command block structure, stores the received SCSI - * command from the host which is to be processed - */ - CommandStatusWrapper_t CommandStatus; /**< Mass Storage class command status structure, set elements to indicate - * the issued command's success or failure to the host - */ - - bool IsMassStoreReset; /**< Flag indicating that the host has requested that the Mass Storage interface be reset - * and that all current Mass Storage operations should immediately abort - */ - } USB_ClassInfo_MS_Device_State_t; - + /* Type Defines: */ /** Class state structure. An instance of this structure should be made for each Mass Storage interface * within the user application, and passed to each of the Mass Storage class driver functions as the * MSInterfaceInfo parameter. This stores each Mass Storage interface's configuration and state information. */ typedef struct { - const USB_ClassInfo_MS_Device_Config_t Config; /**< Config data for the USB class interface within - * the device. All elements in this section - * must be set or the interface will fail - * to enumerate and operate correctly. - */ - - USB_ClassInfo_MS_Device_State_t State; /**< State data for the USB class interface within - * the device. All elements in this section - * may be set to initial values, but may - * also be ignored to default to sane values when - * the interface is enumerated. - */ + const struct + { + uint8_t InterfaceNumber; /**< Interface number of the Mass Storage interface within the device */ + + uint8_t DataINEndpointNumber; /**< Endpoint number of the Mass Storage interface's IN data endpoint */ + uint16_t DataINEndpointSize; /**< Size in bytes of the Mass Storage interface's IN data endpoint */ + + uint8_t DataOUTEndpointNumber; /**< Endpoint number of the Mass Storage interface's OUT data endpoint */ + uint16_t DataOUTEndpointSize; /**< Size in bytes of the Mass Storage interface's OUT data endpoint */ + + uint8_t TotalLUNs; /**< Total number of logical drives in the Mass Storage interface */ + } Config; /**< Config data for the USB class interface within the device. All elements in this section + * must be set or the interface will fail to enumerate and operate correctly. + */ + struct + { + MS_CommandBlockWrapper_t CommandBlock; /**< Mass Storage class command block structure, stores the received SCSI + * command from the host which is to be processed + */ + MS_CommandStatusWrapper_t CommandStatus; /**< Mass Storage class command status structure, set elements to indicate + * the issued command's success or failure to the host + */ + bool IsMassStoreReset; /**< Flag indicating that the host has requested that the Mass Storage interface be reset + * 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 + * may be set to initial values, but may also be ignored to default to sane values when + * the interface is enumerated. + */ } USB_ClassInfo_MS_Device_t; /* Function Prototypes: */ diff --git a/LUFA/Drivers/USB/Class/Device/RNDIS.h b/LUFA/Drivers/USB/Class/Device/RNDIS.h index 49700a1b2..21fb09400 100644 --- a/LUFA/Drivers/USB/Class/Device/RNDIS.h +++ b/LUFA/Drivers/USB/Class/Device/RNDIS.h @@ -53,60 +53,49 @@ #endif /* Public Interface - May be used in end-application: */ - /* Type Defines: */ - /** Configuration information structure for \ref USB_ClassInfo_RNDIS_Device_t RNDIS device interface structures. */ - typedef struct - { - uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device */ - - 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 */ - - 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 */ - - 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 */ - - char* AdapterVendorDescription; /**< String description of the adapter vendor */ - MAC_Address_t AdapterMACAddress; /**< MAC address of the adapter */ - } USB_ClassInfo_MS_Device_Config_t; - - /** Current State information structure for \ref USB_ClassInfo_RNDIS_Device_t RNDIS device interface structures. */ - typedef struct - { - uint8_t RNDISMessageBuffer[RNDIS_MESSAGE_BUFFER_SIZE]; /**< Buffer to hold RNDIS messages to and from the host, - * managed by the class driver - */ - bool ResponseReady; /**< Internal flag indicating if a RNDIS message is waiting to be returned to the host */ - uint8_t CurrRNDISState; /**< Current RNDIS state of the adapter, a value from the RNDIS_States_t enum */ - uint32_t CurrPacketFilter; /**< Current packet filter mode, used internally by the class driver */ - Ethernet_Frame_Info_t FrameIN; /**< Structure holding the last received Ethernet frame from the host, for user - * processing - */ - Ethernet_Frame_Info_t FrameOUT; /**< Structure holding the next Ethernet frame to send to the host, populated by the - * user application - */ - } USB_ClassInfo_MS_Device_State_t; - + /* Type Defines: */ /** Class state structure. An instance of this structure should be made for each RNDIS interface * within the user application, and passed to each of the RNDIS class driver functions as the * RNDISInterfaceInfo parameter. This stores each RNDIS interface's configuration and state information. */ typedef struct { - const USB_ClassInfo_MS_Device_Config_t Config; /**< Config data for the USB class interface within - * the device. All elements in this section - * must be set or the interface will fail - * to enumerate and operate correctly. - */ - - USB_ClassInfo_MS_Device_State_t State; /**< State data for the USB class interface within - * the device. All elements in this section - * may be set to initial values, but may - * also be ignored to default to sane values when - * the interface is enumerated. - */ + const struct + { + uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device */ + + 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 */ + + 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 */ + + 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 */ + + char* AdapterVendorDescription; /**< String description of the adapter vendor */ + MAC_Address_t AdapterMACAddress; /**< MAC address of the adapter */ + } Config; /**< Config data for the USB class interface within the device. All elements in this section + * must be set or the interface will fail to enumerate and operate correctly. + */ + struct + { + uint8_t RNDISMessageBuffer[RNDIS_MESSAGE_BUFFER_SIZE]; /**< Buffer to hold RNDIS messages to and from the host, + * managed by the class driver + */ + bool ResponseReady; /**< Internal flag indicating if a RNDIS message is waiting to be returned to the host */ + uint8_t CurrRNDISState; /**< Current RNDIS state of the adapter, a value from the RNDIS_States_t enum */ + uint32_t CurrPacketFilter; /**< Current packet filter mode, used internally by the class driver */ + Ethernet_Frame_Info_t FrameIN; /**< Structure holding the last received Ethernet frame from the host, for user + * processing + */ + Ethernet_Frame_Info_t FrameOUT; /**< Structure holding the next Ethernet frame to send to the host, populated by the + * user application + */ + } State; /**< State data for the USB class interface within the device. All elements in this section + * may be set to initial values, but may also be ignored to default to sane values when + * the interface is enumerated. + */ } USB_ClassInfo_RNDIS_Device_t; /* Function Prototypes: */ diff --git a/LUFA/Drivers/USB/Class/Host/CDC.h b/LUFA/Drivers/USB/Class/Host/CDC.h index 3c24617e1..7625c494b 100644 --- a/LUFA/Drivers/USB/Class/Host/CDC.h +++ b/LUFA/Drivers/USB/Class/Host/CDC.h @@ -50,67 +50,56 @@ #endif /* Public Interface - May be used in end-application: */ - /* Type Defines: */ - /** Configuration information structure for \ref USB_ClassInfo_CDC_Host_t CDC host interface structures. */ - typedef struct - { - uint8_t DataINPipeNumber; /**< Pipe number of the CDC interface's IN data pipe */ - uint8_t DataOUTPipeNumber; /**< Pipe number of the CDC interface's OUT data pipe */ - uint8_t NotificationPipeNumber; /**< Pipe number of the CDC interface's IN notification endpoint, if used */ - } USB_ClassInfo_CDC_Host_Config_t; - - /** Current State information structure for \ref USB_ClassInfo_CDC_Host_t CDC host interface structures. */ - typedef struct - { - uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device */ - - uint16_t DataINPipeSize; /**< Size in bytes of the CDC interface's IN data pipe */ - uint16_t DataOUTPipeSize; /**< Size in bytes of the CDC interface's OUT data pipe */ - uint16_t NotificationPipeSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used */ - - struct - { - uint8_t HostToDevice; /**< Control line states from the host to device, as a set of CDC_CONTROL_LINE_OUT_* - * masks. - */ - uint8_t DeviceToHost; /**< Control line states from the device to host, as a set of CDC_CONTROL_LINE_IN_* - * masks. - */ - } ControlLineStates; - - struct - { - bool Active; /**< Indicates if the interface is currently active, i.e. attached to the connected device */ - - uint32_t BaudRateBPS; /**< Baud rate of the virtual serial port, in bits per second */ - uint8_t CharFormat; /**< Character format of the virtual serial port, a value from the - * CDCDevice_CDC_LineCodingFormats_t enum - */ - uint8_t ParityType; /**< Parity setting of the virtual serial port, a value from the - * CDCDevice_LineCodingParity_t enum - */ - uint8_t DataBits; /**< Bits of data per character of the virtual serial port */ - } LineEncoding; - } USB_ClassInfo_CDC_Host_State_t; - + /* Type Defines: */ /** Class state structure. An instance of this structure should be made within the user application, * and passed to each of the CDC class driver functions as the CDCInterfaceInfo parameter. This * stores each CDC interface's configuration and state information. */ typedef struct { - const USB_ClassInfo_CDC_Host_Config_t Config; /**< Config data for the USB class interface within - * the device. All elements in this section - * must be set or the interface will fail - * to enumerate and operate correctly. - */ - - USB_ClassInfo_CDC_Host_State_t State; /**< State data for the USB class interface within - * the device. All elements in this section - * may be set to initial values, but may - * also be ignored to default to sane values when - * the interface is enumerated. - */ + const struct + { + uint8_t DataINPipeNumber; /**< Pipe number of the CDC interface's IN data pipe */ + uint8_t DataOUTPipeNumber; /**< Pipe number of the CDC interface's OUT data pipe */ + uint8_t NotificationPipeNumber; /**< Pipe number of the CDC interface's IN notification endpoint, if used */ + } Config; /**< Config data for the USB class interface within the device. All elements in this section + * must be set or the interface will fail to enumerate and operate correctly. + */ + struct + { + uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device */ + + uint16_t DataINPipeSize; /**< Size in bytes of the CDC interface's IN data pipe */ + uint16_t DataOUTPipeSize; /**< Size in bytes of the CDC interface's OUT data pipe */ + uint16_t NotificationPipeSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used */ + + struct + { + uint8_t HostToDevice; /**< Control line states from the host to device, as a set of CDC_CONTROL_LINE_OUT_* + * masks. + */ + uint8_t DeviceToHost; /**< Control line states from the device to host, as a set of CDC_CONTROL_LINE_IN_* + * masks. + */ + } ControlLineStates; + + struct + { + bool Active; /**< Indicates if the interface is currently active, i.e. attached to the connected device */ + + uint32_t BaudRateBPS; /**< Baud rate of the virtual serial port, in bits per second */ + uint8_t CharFormat; /**< Character format of the virtual serial port, a value from the + * CDCDevice_CDC_LineCodingFormats_t enum + */ + uint8_t ParityType; /**< Parity setting of the virtual serial port, a value from the + * CDCDevice_LineCodingParity_t enum + */ + uint8_t DataBits; /**< Bits of data per character of the virtual serial port */ + } LineEncoding; + } State; /**< State data for the USB class interface within the device. All elements in this section + * may be set to initial values, but may also be ignored to default to sane values when + * the interface is enumerated. + */ } USB_ClassInfo_CDC_Host_t; /* Enums: */ -- cgit v1.2.3