From b7049da11b6fe3c37b23d8f7dddfff08ba14f449 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Mon, 15 Jun 2009 04:38:42 +0000 Subject: [PATCH] Enhanced class drivers to use the same public/private section seperations as other portions of the library. --- Demos/Host/ClassDriver/CDCHost/CDCHost.c | 6 + LUFA/Drivers/USB/Class/Device/Audio.h | 189 ++++++++++---------- LUFA/Drivers/USB/Class/Device/CDC.h | 188 +++++++++---------- LUFA/Drivers/USB/Class/Device/HID.h | 99 +++++----- LUFA/Drivers/USB/Class/Device/MIDI.h | 75 ++++---- LUFA/Drivers/USB/Class/Device/MassStorage.h | 84 +++++---- LUFA/Drivers/USB/Class/Device/RNDIS.h | 56 +++--- LUFA/Drivers/USB/Class/Host/Audio.h | 3 +- LUFA/Drivers/USB/Class/Host/CDC.c | 2 +- LUFA/Drivers/USB/Class/Host/CDC.h | 34 ++-- LUFA/Drivers/USB/Class/Host/HID.h | 3 +- LUFA/Drivers/USB/Class/Host/MIDI.h | 3 +- LUFA/Drivers/USB/Class/Host/MassStorage.h | 3 +- LUFA/Drivers/USB/Class/Host/StillImage.h | 3 +- 14 files changed, 397 insertions(+), 351 deletions(-) diff --git a/Demos/Host/ClassDriver/CDCHost/CDCHost.c b/Demos/Host/ClassDriver/CDCHost/CDCHost.c index 9a9d8a71fa..e50a28f951 100644 --- a/Demos/Host/ClassDriver/CDCHost/CDCHost.c +++ b/Demos/Host/ClassDriver/CDCHost/CDCHost.c @@ -36,6 +36,12 @@ #include "CDCHost.h" +/** LUFA CDC Class driver interface configuration and state information. This structure is + * 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; + /** Main program entry point. This routine configures the hardware required by the application, then * starts the scheduler to run the application tasks. */ diff --git a/LUFA/Drivers/USB/Class/Device/Audio.h b/LUFA/Drivers/USB/Class/Device/Audio.h index efffcdafc2..3591358f9d 100644 --- a/LUFA/Drivers/USB/Class/Device/Audio.h +++ b/LUFA/Drivers/USB/Class/Device/Audio.h @@ -51,100 +51,101 @@ extern "C" { #endif - /* Function Prototypes: */ - /** Configures the endpoints of a given Audio interface, ready for use. This should be linked to the library - * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the - * given Audio interface is selected. - * - * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. - * - * \return Boolean true if the endpoints were sucessfully configured, false otherwise - */ - bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_t* AudioInterfaceInfo); - - /** Processes incomming control requests from the host, that are directed to the given Audio class interface. This should be - * linked to the library \ref EVENT_USB_UnhandledControlPacket() event. - * - * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. - */ - void Audio_Device_ProcessControlPacket(USB_ClassInfo_Audio_t* AudioInterfaceInfo); - - /** General management task for a given Audio class interface, required for the correct operation of the interface. This should - * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). - * - * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. - */ - void Audio_Device_USBTask(USB_ClassInfo_Audio_t* AudioInterfaceInfo); - - /** Reads the next 8-bit audio sample from the current audio interface. - * - * \note This should be preceeded immediately by a call to the USB_Audio_IsSampleReceived() function to ensure that - * the correct endpoint is selected and ready for data. - * - * \return Signed 8-bit audio sample from the audio interface - */ - int8_t Audio_Device_ReadSample8(void); - - /** Reads the next 16-bit audio sample from the current audio interface. - * - * \note This should be preceeded immediately by a call to the USB_Audio_IsSampleReceived() function to ensure that - * the correct endpoint is selected and ready for data. - * - * \return Signed 16-bit audio sample from the audio interface - */ - int16_t Audio_Device_ReadSample16(void); - - /** Reads the next 24-bit audio sample from the current audio interface. - * - * \note This should be preceeded immediately by a call to the USB_Audio_IsSampleReceived() function to ensure that - * the correct endpoint is selected and ready for data. - * - * \return Signed 24-bit audio sample from the audio interface - */ - int32_t Audio_Device_ReadSample24(void); - - /** Writes the next 8-bit audio sample to the current audio interface. - * - * \note This should be preceeded immediately by a call to the USB_Audio_IsReadyForNextSample() function to ensure that - * the correct endpoint is selected and ready for data. - * - * \param Sample Signed 8-bit audio sample - */ - void Audio_Device_WriteSample8(int8_t Sample); - - /** Writes the next 16-bit audio sample to the current audio interface. - * - * \note This should be preceeded immediately by a call to the USB_Audio_IsReadyForNextSample() function to ensure that - * the correct endpoint is selected and ready for data. - * - * \param Sample Signed 16-bit audio sample - */ - void Audio_Device_WriteSample16(int16_t Sample); - - /** Writes the next 24-bit audio sample to the current audio interface. - * - * \note This should be preceeded immediately by a call to the USB_Audio_IsReadyForNextSample() function to ensure that - * the correct endpoint is selected and ready for data. - * - * \param Sample Signed 24-bit audio sample - */ - void Audio_Device_WriteSample24(int32_t Sample); - - /** Determines if the given audio interface is ready for a sample to be read from it. - * - * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. - * - * \return Boolean true if the given Audio interface has a sample to be read, false otherwise - */ - bool Audio_Device_IsSampleReceived(USB_ClassInfo_Audio_t* AudioInterfaceInfo); - - /** Determines if the given audio interface is ready to accept the next sample to be written to it. - * - * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. - * - * \return Boolean true if the given Audio interface is ready to accept the next sample, false otherwise - */ - bool Audio_Device_IsReadyForNextSample(USB_ClassInfo_Audio_t* AudioInterfaceInfo); + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ + /** Configures the endpoints of a given Audio interface, ready for use. This should be linked to the library + * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the + * given Audio interface is selected. + * + * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * + * \return Boolean true if the endpoints were sucessfully configured, false otherwise + */ + bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_t* AudioInterfaceInfo); + + /** Processes incomming control requests from the host, that are directed to the given Audio class interface. This should be + * linked to the library \ref EVENT_USB_UnhandledControlPacket() event. + * + * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + */ + void Audio_Device_ProcessControlPacket(USB_ClassInfo_Audio_t* AudioInterfaceInfo); + + /** General management task for a given Audio class interface, required for the correct operation of the interface. This should + * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). + * + * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + */ + void Audio_Device_USBTask(USB_ClassInfo_Audio_t* AudioInterfaceInfo); + + /** Reads the next 8-bit audio sample from the current audio interface. + * + * \note This should be preceeded immediately by a call to the USB_Audio_IsSampleReceived() function to ensure that + * the correct endpoint is selected and ready for data. + * + * \return Signed 8-bit audio sample from the audio interface + */ + int8_t Audio_Device_ReadSample8(void); + + /** Reads the next 16-bit audio sample from the current audio interface. + * + * \note This should be preceeded immediately by a call to the USB_Audio_IsSampleReceived() function to ensure that + * the correct endpoint is selected and ready for data. + * + * \return Signed 16-bit audio sample from the audio interface + */ + int16_t Audio_Device_ReadSample16(void); + + /** Reads the next 24-bit audio sample from the current audio interface. + * + * \note This should be preceeded immediately by a call to the USB_Audio_IsSampleReceived() function to ensure that + * the correct endpoint is selected and ready for data. + * + * \return Signed 24-bit audio sample from the audio interface + */ + int32_t Audio_Device_ReadSample24(void); + + /** Writes the next 8-bit audio sample to the current audio interface. + * + * \note This should be preceeded immediately by a call to the USB_Audio_IsReadyForNextSample() function to ensure that + * the correct endpoint is selected and ready for data. + * + * \param Sample Signed 8-bit audio sample + */ + void Audio_Device_WriteSample8(int8_t Sample); + + /** Writes the next 16-bit audio sample to the current audio interface. + * + * \note This should be preceeded immediately by a call to the USB_Audio_IsReadyForNextSample() function to ensure that + * the correct endpoint is selected and ready for data. + * + * \param Sample Signed 16-bit audio sample + */ + void Audio_Device_WriteSample16(int16_t Sample); + + /** Writes the next 24-bit audio sample to the current audio interface. + * + * \note This should be preceeded immediately by a call to the USB_Audio_IsReadyForNextSample() function to ensure that + * the correct endpoint is selected and ready for data. + * + * \param Sample Signed 24-bit audio sample + */ + void Audio_Device_WriteSample24(int32_t Sample); + + /** Determines if the given audio interface is ready for a sample to be read from it. + * + * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * + * \return Boolean true if the given Audio interface has a sample to be read, false otherwise + */ + bool Audio_Device_IsSampleReceived(USB_ClassInfo_Audio_t* AudioInterfaceInfo); + + /** Determines if the given audio interface is ready to accept the next sample to be written to it. + * + * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * + * \return Boolean true if the given Audio interface is ready to accept the next sample, false otherwise + */ + bool Audio_Device_IsReadyForNextSample(USB_ClassInfo_Audio_t* AudioInterfaceInfo); /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) diff --git a/LUFA/Drivers/USB/Class/Device/CDC.h b/LUFA/Drivers/USB/Class/Device/CDC.h index 6938eb3d5c..2306cdfb16 100644 --- a/LUFA/Drivers/USB/Class/Device/CDC.h +++ b/LUFA/Drivers/USB/Class/Device/CDC.h @@ -51,102 +51,108 @@ extern "C" { #endif - /* Function Prototypes: */ - #if defined(INCLUDE_FROM_CDC_CLASS_DEVICE_C) - void CDC_Device_Event_Stub(void); - void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo) - ATTR_WEAK ATTR_ALIAS(CDC_Device_Event_Stub); - void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo) - ATTR_WEAK ATTR_ALIAS(CDC_Device_Event_Stub); - #endif - - /** Configures the endpoints of a given CDC interface, ready for use. This should be linked to the library - * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the - * given CDC interface is selected. - * - * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * - * \return Boolean true if the endpoints were sucessfully configured, false otherwise - */ - bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_t* CDCInterfaceInfo); + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ + /** Configures the endpoints of a given CDC interface, ready for use. This should be linked to the library + * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the + * given CDC interface is selected. + * + * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * + * \return Boolean true if the endpoints were sucessfully configured, false otherwise + */ + bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_t* CDCInterfaceInfo); - /** Processes incomming control requests from the host, that are directed to the given CDC class interface. This should be - * linked to the library \ref EVENT_USB_UnhandledControlPacket() event. - * - * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - */ - void CDC_Device_ProcessControlPacket(USB_ClassInfo_CDC_t* CDCInterfaceInfo); + /** Processes incomming control requests from the host, that are directed to the given CDC class interface. This should be + * linked to the library \ref EVENT_USB_UnhandledControlPacket() event. + * + * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + */ + void CDC_Device_ProcessControlPacket(USB_ClassInfo_CDC_t* CDCInterfaceInfo); - /** General management task for a given CDC class interface, required for the correct operation of the interface. This should - * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). - * - * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - */ - void CDC_Device_USBTask(USB_ClassInfo_CDC_t* CDCInterfaceInfo); + /** General management task for a given CDC class interface, required for the correct operation of the interface. This should + * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). + * + * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + */ + void CDC_Device_USBTask(USB_ClassInfo_CDC_t* CDCInterfaceInfo); - /** CDC class driver event for a line encoding change on a CDC interface. This event fires each time the host requests a - * line encoding change (containing the serial parity, baud and other configuration information) and may be hooked in the - * user program by declaring a handler function with the same name and parameters listed here. The new line encoding - * settings are available in the LineEncoding structure inside the CDC interface structure passed as a parameter. - * - * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - */ - void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo); - - /** CDC class driver event for a control line state change on a CDC interface. This event fires each time the host requests a - * control line state change (containing the virtual serial control line states, such as DTR) and may be hooked in the - * user program by declaring a handler function with the same name and parameters listed here. The new control line states - * are available in the ControlLineState value inside the CDC interface structure passed as a parameter, set as a mask of - * CDC_CONTROL_LINE_OUT_* masks. - * - * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - */ - void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo); + /** CDC class driver event for a line encoding change on a CDC interface. This event fires each time the host requests a + * line encoding change (containing the serial parity, baud and other configuration information) and may be hooked in the + * user program by declaring a handler function with the same name and parameters listed here. The new line encoding + * settings are available in the LineEncoding structure inside the CDC interface structure passed as a parameter. + * + * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + */ + void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo); + + /** CDC class driver event for a control line state change on a CDC interface. This event fires each time the host requests a + * control line state change (containing the virtual serial control line states, such as DTR) and may be hooked in the + * user program by declaring a handler function with the same name and parameters listed here. The new control line states + * are available in the ControlLineState value inside the CDC interface structure passed as a parameter, set as a mask of + * CDC_CONTROL_LINE_OUT_* masks. + * + * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + */ + void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo); - /** Sends a given string to the attached USB host, if connected. If a host is not connected when the function is called, the - * string is discarded. - * - * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * \param Data Pointer to the string to send to the host - * \param Length Size in bytes of the string to send to the host - */ - void CDC_Device_SendString(USB_ClassInfo_CDC_t* CDCInterfaceInfo, char* Data, uint16_t Length); - - /** Sends a given byte to the attached USB host, if connected. If a host is not connected when the function is called, the - * byte is discarded. - * - * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * \param Data Byte of data to send to the host - */ - void CDC_Device_SendByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint8_t Data); - - /** Determines the number of bytes received by the CDC interface from the host, waiting to be read. - * - * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * - * \return Total number of buffered bytes received from the host - */ - uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_t* CDCInterfaceInfo); - - /** Reads a byte of data from the host. If no data is waiting to be read of if a USB host is not connected, the function - * returns 0. The USB_CDC_BytesReceived() function should be queried before data is recieved to ensure that no data - * underflow occurs. - * - * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * - * \return Next received byte from the host, or 0 if no data received - */ - uint8_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo); - - /** Sends a Serial Control Line State Change notification to the host. This should be called when the virtual serial control - * lines (DCD, DSR, etc.) have changed states, or to give BREAK notfications to the host. Line states persist until they are - * cleared via a second notification. - * - * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * \param LineStateMask Mask of CDC_CONTROL_LINE_IN_* masks giving the current control line states - */ - void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask); + /** Sends a given string to the attached USB host, if connected. If a host is not connected when the function is called, the + * string is discarded. + * + * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param Data Pointer to the string to send to the host + * \param Length Size in bytes of the string to send to the host + */ + void CDC_Device_SendString(USB_ClassInfo_CDC_t* CDCInterfaceInfo, char* Data, uint16_t Length); + + /** Sends a given byte to the attached USB host, if connected. If a host is not connected when the function is called, the + * byte is discarded. + * + * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param Data Byte of data to send to the host + */ + void CDC_Device_SendByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint8_t Data); + + /** Determines the number of bytes received by the CDC interface from the host, waiting to be read. + * + * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * + * \return Total number of buffered bytes received from the host + */ + uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_t* CDCInterfaceInfo); + + /** Reads a byte of data from the host. If no data is waiting to be read of if a USB host is not connected, the function + * returns 0. The USB_CDC_BytesReceived() function should be queried before data is recieved to ensure that no data + * underflow occurs. + * + * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * + * \return Next received byte from the host, or 0 if no data received + */ + uint8_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo); + + /** Sends a Serial Control Line State Change notification to the host. This should be called when the virtual serial control + * lines (DCD, DSR, etc.) have changed states, or to give BREAK notfications to the host. Line states persist until they are + * cleared via a second notification. + * + * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param LineStateMask Mask of CDC_CONTROL_LINE_IN_* masks giving the current control line states + */ + void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask); + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(INCLUDE_FROM_CDC_CLASS_DEVICE_C) + void CDC_Device_Event_Stub(void); + void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo) + ATTR_WEAK ATTR_ALIAS(CDC_Device_Event_Stub); + void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo) + ATTR_WEAK ATTR_ALIAS(CDC_Device_Event_Stub); + #endif + + #endif + /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) } diff --git a/LUFA/Drivers/USB/Class/Device/HID.h b/LUFA/Drivers/USB/Class/Device/HID.h index a4317d7197..6ed6b38924 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.h +++ b/LUFA/Drivers/USB/Class/Device/HID.h @@ -51,57 +51,58 @@ extern "C" { #endif - /* Function Prototypes: */ - /** Configures the endpoints of a given HID interface, ready for use. This should be linked to the library - * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration - * containing the given HID interface is selected. - * - * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. - * - * \return Boolean true if the endpoints were sucessfully configured, false otherwise - */ - bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_t* HIDInterfaceInfo); - - /** Processes incomming control requests from the host, that are directed to the given HID class interface. This should be - * linked to the library \ref EVENT_USB_UnhandledControlPacket() event. - * - * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. - */ - void HID_Device_ProcessControlPacket(USB_ClassInfo_HID_t* HIDInterfaceInfo); + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ + /** Configures the endpoints of a given HID interface, ready for use. This should be linked to the library + * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration + * containing the given HID interface is selected. + * + * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. + * + * \return Boolean true if the endpoints were sucessfully configured, false otherwise + */ + bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_t* HIDInterfaceInfo); + + /** Processes incomming control requests from the host, that are directed to the given HID class interface. This should be + * linked to the library \ref EVENT_USB_UnhandledControlPacket() event. + * + * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. + */ + void HID_Device_ProcessControlPacket(USB_ClassInfo_HID_t* HIDInterfaceInfo); - /** General management task for a given HID class interface, required for the correct operation of the interface. This should - * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). - * - * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. - */ - void HID_Device_USBTask(USB_ClassInfo_HID_t* HIDInterfaceInfo); - - /** HID class driver callback for the user creation of a HID input report. This callback may fire in response to either - * HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback the - * user is responsible for the creation of the next HID input report to be sent to the host. - * - * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. - * \param ReportID If preset to a non-zero value, this is the report ID being requested by the host. If zero, this should - * be set to the report ID of the generated HID input report. If multiple reports are not sent via the - * given HID interface, this parameter should be ignored. - * \param ReportData Pointer to a buffer where the generated HID report should be stored. - * - * \return Number of bytes in the generated input 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); + /** General management task for a given HID class interface, required for the correct operation of the interface. This should + * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). + * + * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. + */ + void HID_Device_USBTask(USB_ClassInfo_HID_t* HIDInterfaceInfo); + + /** HID class driver callback for the user creation of a HID input report. This callback may fire in response to either + * HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback the + * user is responsible for the creation of the next HID input report to be sent to the host. + * + * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. + * \param ReportID If preset to a non-zero value, this is the report ID being requested by the host. If zero, this should + * be set to the report ID of the generated HID input report. If multiple reports are not sent via the + * given HID interface, this parameter should be ignored. + * \param ReportData Pointer to a buffer where the generated HID report should be stored. + * + * \return Number of bytes in the generated input 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); - /** HID class driver callback for the user processing of a received HID input report. This callback may fire in response to - * either HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback - * the user is responsible for the processing of the received HID output report from the host. - * - * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. - * \param ReportID Report ID of the received output report. If multiple reports are not received via the given HID - * interface, this parameter should be ignored. - * \param ReportData Pointer to a buffer where the received HID report is stored. - * \param ReportSize Size in bytes of the received report from the host. - */ - void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, void* ReportData, - uint16_t ReportSize); + /** HID class driver callback for the user processing of a received HID input report. This callback may fire in response to + * either HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback + * the user is responsible for the processing of the received HID output report from the host. + * + * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. + * \param ReportID Report ID of the received output report. If multiple reports are not received via the given HID + * interface, this parameter should be ignored. + * \param ReportData Pointer to a buffer where the received HID report is stored. + * \param ReportSize Size in bytes of the received report from the host. + */ + void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, void* ReportData, + uint16_t ReportSize); /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) diff --git a/LUFA/Drivers/USB/Class/Device/MIDI.h b/LUFA/Drivers/USB/Class/Device/MIDI.h index 0963aab024..87aabe1c52 100644 --- a/LUFA/Drivers/USB/Class/Device/MIDI.h +++ b/LUFA/Drivers/USB/Class/Device/MIDI.h @@ -52,46 +52,47 @@ extern "C" { #endif - /* Function Prototypes: */ - /** Configures the endpoints of a given MIDI interface, ready for use. This should be linked to the library - * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration - * containing the given MIDI interface is selected. - * - * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. - * - * \return Boolean true if the endpoints were sucessfully configured, false otherwise - */ - bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo); - - /** Processes incomming control requests from the host, that are directed to the given MIDI class interface. This should be - * linked to the library \ref EVENT_USB_UnhandledControlPacket() event. - * - * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. - */ - void MIDI_Device_ProcessControlPacket(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo); + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ + /** Configures the endpoints of a given MIDI interface, ready for use. This should be linked to the library + * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration + * containing the given MIDI interface is selected. + * + * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. + * + * \return Boolean true if the endpoints were sucessfully configured, false otherwise + */ + bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo); + + /** Processes incomming control requests from the host, that are directed to the given MIDI class interface. This should be + * linked to the library \ref EVENT_USB_UnhandledControlPacket() event. + * + * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. + */ + void MIDI_Device_ProcessControlPacket(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo); - /** General management task for a given MIDI class interface, required for the correct operation of the interface. This should - * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). - * - * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. - */ - void MIDI_Device_USBTask(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo); + /** General management task for a given MIDI class interface, required for the correct operation of the interface. This should + * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). + * + * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. + */ + void MIDI_Device_USBTask(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo); - /** Sends a MIDI event packet to the host. If no host is connected, the event packet is discarded. - * - * \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_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event); + /** Sends a MIDI event packet to the host. If no host is connected, the event packet is discarded. + * + * \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_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event); - /** Receives a MIDI event packet from the host. - * - * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. - * \param Event Pointer to a USB_MIDI_EventPacket_t structure where the received MIDI event is to be placed - * - * \return Boolean true if a MIDI event packet was received, false otherwise - */ - bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event); + /** Receives a MIDI event packet from the host. + * + * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. + * \param Event Pointer to a USB_MIDI_EventPacket_t structure where the received MIDI event is to be placed + * + * \return Boolean true if a MIDI event packet was received, false otherwise + */ + bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event); /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) diff --git a/LUFA/Drivers/USB/Class/Device/MassStorage.h b/LUFA/Drivers/USB/Class/Device/MassStorage.h index 0761b7af12..feaebcca40 100644 --- a/LUFA/Drivers/USB/Class/Device/MassStorage.h +++ b/LUFA/Drivers/USB/Class/Device/MassStorage.h @@ -51,47 +51,53 @@ extern "C" { #endif - /* Function Prototypes: */ - #if defined(INCLUDE_FROM_MS_CLASS_DEVICE_C) - static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_t* MSInterfaceInfo); - static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_t* MSInterfaceInfo); - static uint8_t StreamCallback_MS_Device_AbortOnMassStoreReset(void); - #endif - - /** Configures the endpoints of a given Mass Storage interface, ready for use. This should be linked to the library - * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration - * containing the given Mass Storage interface is selected. - * - * \param MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state. - * - * \return Boolean true if the endpoints were sucessfully configured, false otherwise - */ - bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_t* MSInterfaceInfo); - - /** Processes incomming control requests from the host, that are directed to the given Mass Storage class interface. This should be - * linked to the library \ref EVENT_USB_UnhandledControlPacket() event. - * - * \param MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state. - */ - void MS_Device_ProcessControlPacket(USB_ClassInfo_MS_t* MSInterfaceInfo); + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ + /** Configures the endpoints of a given Mass Storage interface, ready for use. This should be linked to the library + * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration + * containing the given Mass Storage interface is selected. + * + * \param MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state. + * + * \return Boolean true if the endpoints were sucessfully configured, false otherwise + */ + bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_t* MSInterfaceInfo); + + /** Processes incomming control requests from the host, that are directed to the given Mass Storage class interface. This should be + * linked to the library \ref EVENT_USB_UnhandledControlPacket() event. + * + * \param MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state. + */ + void MS_Device_ProcessControlPacket(USB_ClassInfo_MS_t* MSInterfaceInfo); - /** General management task for a given Mass Storage class interface, required for the correct operation of the interface. This should - * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). - * - * \param MSInterfaceInfo Pointer to a structure containing a Mass Storage configuration and state. - */ - void MS_Device_USBTask(USB_ClassInfo_MS_t* MSInterfaceInfo); + /** General management task for a given Mass Storage class interface, required for the correct operation of the interface. This should + * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). + * + * \param MSInterfaceInfo Pointer to a structure containing a Mass Storage configuration and state. + */ + void MS_Device_USBTask(USB_ClassInfo_MS_t* MSInterfaceInfo); + + /** Mass Storage class driver callback for the user processing of a received SCSI command. This callback will fire each time the + * host sends a SCSI command which requires processing by the user application. Inside this callback the user is responsible + * for the processing of the received SCSI command from the host. The SCSI command is available in the CommandBlock structure + * inside the Mass Storage class state structure passed as a parameter to the callback function. + * + * \param MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state. + * + * \return Boolean true if the SCSI command was successfully processed, false otherwise + */ + bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_t* MSInterfaceInfo); + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(INCLUDE_FROM_MS_CLASS_DEVICE_C) + static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_t* MSInterfaceInfo); + static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_t* MSInterfaceInfo); + static uint8_t StreamCallback_MS_Device_AbortOnMassStoreReset(void); + #endif - /** Mass Storage class driver callback for the user processing of a received SCSI command. This callback will fire each time the - * host sends a SCSI command which requires processing by the user application. Inside this callback the user is responsible - * for the processing of the received SCSI command from the host. The SCSI command is available in the CommandBlock structure - * inside the Mass Storage class state structure passed as a parameter to the callback function. - * - * \param MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state. - * - * \return Boolean true if the SCSI command was successfully processed, false otherwise - */ - bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_t* MSInterfaceInfo); + #endif /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) diff --git a/LUFA/Drivers/USB/Class/Device/RNDIS.h b/LUFA/Drivers/USB/Class/Device/RNDIS.h index 896266e456..93e4ebb41e 100644 --- a/LUFA/Drivers/USB/Class/Device/RNDIS.h +++ b/LUFA/Drivers/USB/Class/Device/RNDIS.h @@ -52,7 +52,35 @@ extern "C" { #endif - /* Function Prototypes: */ + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ + /** Configures the endpoints of a given RNDIS interface, ready for use. This should be linked to the library + * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration + * containing the given HID interface is selected. + * + * \param RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state. + * + * \return Boolean true if the endpoints were sucessfully configured, false otherwise + */ + bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo); + + /** Processes incomming control requests from the host, that are directed to the given RNDIS class interface. This should be + * linked to the library \ref EVENT_USB_UnhandledControlPacket() event. + * + * \param RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state. + */ + void RNDIS_Device_ProcessControlPacket(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo); + + /** General management task for a given HID class interface, required for the correct operation of the interface. This should + * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). + * + * \param RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state. + */ + void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo); + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ #if defined(INCLUDE_FROM_RNDIS_CLASS_DEVICE_C) static void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo); static bool RNDIS_Device_ProcessNDISQuery(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo, @@ -61,31 +89,9 @@ static bool RNDIS_Device_ProcessNDISSet(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo, uint32_t OId, void* SetData, uint16_t SetSize); #endif - - /** Configures the endpoints of a given RNDIS interface, ready for use. This should be linked to the library - * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration - * containing the given HID interface is selected. - * - * \param RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state. - * - * \return Boolean true if the endpoints were sucessfully configured, false otherwise - */ - bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo); - - /** Processes incomming control requests from the host, that are directed to the given RNDIS class interface. This should be - * linked to the library \ref EVENT_USB_UnhandledControlPacket() event. - * - * \param RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state. - */ - void RNDIS_Device_ProcessControlPacket(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo); - - /** General management task for a given HID class interface, required for the correct operation of the interface. This should - * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). - * - * \param RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state. - */ - void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo); + #endif + /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) } diff --git a/LUFA/Drivers/USB/Class/Host/Audio.h b/LUFA/Drivers/USB/Class/Host/Audio.h index 0047b0f923..694a2a33d4 100644 --- a/LUFA/Drivers/USB/Class/Host/Audio.h +++ b/LUFA/Drivers/USB/Class/Host/Audio.h @@ -49,7 +49,8 @@ extern "C" { #endif - /* Function Prototypes: */ + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) diff --git a/LUFA/Drivers/USB/Class/Host/CDC.c b/LUFA/Drivers/USB/Class/Host/CDC.c index 30970f1191..32cc9e6eb3 100644 --- a/LUFA/Drivers/USB/Class/Host/CDC.c +++ b/LUFA/Drivers/USB/Class/Host/CDC.c @@ -43,7 +43,7 @@ static uint8_t CDC_Host_ProcessConfigDescriptor(void) if (USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful) return ControlError; - if (ConfigDescriptorSize > MAX_CONFIG_DESCRIPTOR_SIZE) + if (ConfigDescriptorSize > 512) return DescriptorTooLarge; ConfigDescriptorData = alloca(ConfigDescriptorSize); diff --git a/LUFA/Drivers/USB/Class/Host/CDC.h b/LUFA/Drivers/USB/Class/Host/CDC.h index 35c2b27168..292411be40 100644 --- a/LUFA/Drivers/USB/Class/Host/CDC.h +++ b/LUFA/Drivers/USB/Class/Host/CDC.h @@ -49,16 +49,30 @@ extern "C" { #endif - /* Function Prototypes: */ - #if defined(INCLUDE_FROM_CDC_CLASS_HOST_C) - static uint8_t CDC_Host_ProcessConfigDescriptor(void); - static uint8_t DComp_CDC_Host_NextCDCControlInterface(void* CurrentDescriptor); - static uint8_t DComp_CDC_Host_NextCDCDataInterface(void* CurrentDescriptor); - static uint8_t DComp_CDC_Host_NextInterfaceCDCDataEndpoint(void* CurrentDescriptor); - #endif - - void CDC_Host_Task(void); - + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ + void CDC_Host_Task(void); + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define CDC_CONTROL_CLASS 0x02 + #define CDC_CONTROL_SUBCLASS 0x02 + #define CDC_CONTROL_PROTOCOL 0x01 + #define CDC_DATA_CLASS 0x0A + #define CDC_DATA_SUBCLASS 0x00 + #define CDC_DATA_PROTOCOL 0x00 + + /* Function Prototypes: */ + #if defined(INCLUDE_FROM_CDC_CLASS_HOST_C) + static uint8_t CDC_Host_ProcessConfigDescriptor(void); + static uint8_t DComp_CDC_Host_NextCDCControlInterface(void* CurrentDescriptor); + static uint8_t DComp_CDC_Host_NextCDCDataInterface(void* CurrentDescriptor); + static uint8_t DComp_CDC_Host_NextInterfaceCDCDataEndpoint(void* CurrentDescriptor); + #endif + + #endif + /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) } diff --git a/LUFA/Drivers/USB/Class/Host/HID.h b/LUFA/Drivers/USB/Class/Host/HID.h index d632466cf0..56bf04f7e5 100644 --- a/LUFA/Drivers/USB/Class/Host/HID.h +++ b/LUFA/Drivers/USB/Class/Host/HID.h @@ -49,7 +49,8 @@ extern "C" { #endif - /* Function Prototypes: */ + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) diff --git a/LUFA/Drivers/USB/Class/Host/MIDI.h b/LUFA/Drivers/USB/Class/Host/MIDI.h index b35fb6d64e..4bfe1afee4 100644 --- a/LUFA/Drivers/USB/Class/Host/MIDI.h +++ b/LUFA/Drivers/USB/Class/Host/MIDI.h @@ -49,7 +49,8 @@ extern "C" { #endif - /* Function Prototypes: */ + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.h b/LUFA/Drivers/USB/Class/Host/MassStorage.h index 4a694f38c7..e87a914371 100644 --- a/LUFA/Drivers/USB/Class/Host/MassStorage.h +++ b/LUFA/Drivers/USB/Class/Host/MassStorage.h @@ -49,7 +49,8 @@ extern "C" { #endif - /* Function Prototypes: */ + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus) diff --git a/LUFA/Drivers/USB/Class/Host/StillImage.h b/LUFA/Drivers/USB/Class/Host/StillImage.h index b522fb7e63..c83ad5bd5b 100644 --- a/LUFA/Drivers/USB/Class/Host/StillImage.h +++ b/LUFA/Drivers/USB/Class/Host/StillImage.h @@ -49,7 +49,8 @@ extern "C" { #endif - /* Function Prototypes: */ + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ /* Disable C linkage for C++ Compilers: */ #if defined(__cplusplus)