Enhanced class drivers to use the same public/private section seperations as other portions of the library.

pull/1469/head
Dean Camera 16 years ago
parent afe6ae1402
commit b7049da11b

@ -36,6 +36,12 @@
#include "CDCHost.h" #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 /** Main program entry point. This routine configures the hardware required by the application, then
* starts the scheduler to run the application tasks. * starts the scheduler to run the application tasks.
*/ */

@ -51,100 +51,101 @@
extern "C" { extern "C" {
#endif #endif
/* Function Prototypes: */ /* Public Interface - May be used in end-application: */
/** Configures the endpoints of a given Audio interface, ready for use. This should be linked to the library /* Function Prototypes: */
* \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the /** Configures the endpoints of a given Audio interface, ready for use. This should be linked to the library
* given Audio interface is selected. * \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. *
* * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
* \return Boolean true if the endpoints were sucessfully configured, false otherwise *
*/ * \return Boolean true if the endpoints were sucessfully configured, false otherwise
bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_t* AudioInterfaceInfo); */
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. /** 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. *
*/ * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
void Audio_Device_ProcessControlPacket(USB_ClassInfo_Audio_t* AudioInterfaceInfo); */
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(). /** 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. *
*/ * \param AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
void Audio_Device_USBTask(USB_ClassInfo_Audio_t* AudioInterfaceInfo); */
void Audio_Device_USBTask(USB_ClassInfo_Audio_t* AudioInterfaceInfo);
/** Reads the next 8-bit audio sample from the current audio interface.
* /** 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. * \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 *
*/ * \return Signed 8-bit audio sample from the audio interface
int8_t Audio_Device_ReadSample8(void); */
int8_t Audio_Device_ReadSample8(void);
/** Reads the next 16-bit audio sample from the current audio interface.
* /** 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. * \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 *
*/ * \return Signed 16-bit audio sample from the audio interface
int16_t Audio_Device_ReadSample16(void); */
int16_t Audio_Device_ReadSample16(void);
/** Reads the next 24-bit audio sample from the current audio interface.
* /** 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. * \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 *
*/ * \return Signed 24-bit audio sample from the audio interface
int32_t Audio_Device_ReadSample24(void); */
int32_t Audio_Device_ReadSample24(void);
/** Writes the next 8-bit audio sample to the current audio interface.
* /** 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. * \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 *
*/ * \param Sample Signed 8-bit audio sample
void Audio_Device_WriteSample8(int8_t Sample); */
void Audio_Device_WriteSample8(int8_t Sample);
/** Writes the next 16-bit audio sample to the current audio interface.
* /** 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. * \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 *
*/ * \param Sample Signed 16-bit audio sample
void Audio_Device_WriteSample16(int16_t Sample); */
void Audio_Device_WriteSample16(int16_t Sample);
/** Writes the next 24-bit audio sample to the current audio interface.
* /** 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. * \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 *
*/ * \param Sample Signed 24-bit audio sample
void Audio_Device_WriteSample24(int32_t Sample); */
void Audio_Device_WriteSample24(int32_t Sample);
/** Determines if the given audio interface is ready for a sample to be read from it.
* /** 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. *
* * \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 *
*/ * \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); */
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.
* /** 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. *
* * \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 *
*/ * \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); */
bool Audio_Device_IsReadyForNextSample(USB_ClassInfo_Audio_t* AudioInterfaceInfo);
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)

@ -51,101 +51,107 @@
extern "C" { extern "C" {
#endif #endif
/* Function Prototypes: */ /* Public Interface - May be used in end-application: */
#if defined(INCLUDE_FROM_CDC_CLASS_DEVICE_C) /* Function Prototypes: */
void CDC_Device_Event_Stub(void); /** Configures the endpoints of a given CDC interface, ready for use. This should be linked to the library
void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo) * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the
ATTR_WEAK ATTR_ALIAS(CDC_Device_Event_Stub); * given CDC interface is selected.
void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo) *
ATTR_WEAK ATTR_ALIAS(CDC_Device_Event_Stub); * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
#endif *
* \return Boolean true if the endpoints were sucessfully configured, false otherwise
/** 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 bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
* given CDC interface is selected.
* /** Processes incomming control requests from the host, that are directed to the given CDC class interface. This should be
* \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. * linked to the library \ref EVENT_USB_UnhandledControlPacket() event.
* *
* \return Boolean true if the endpoints were sucessfully configured, false otherwise * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
*/ */
bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_t* CDCInterfaceInfo); 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 /** General management task for a given CDC class interface, required for the correct operation of the interface. This should
* linked to the library \ref EVENT_USB_UnhandledControlPacket() event. * 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. * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
*/ */
void CDC_Device_ProcessControlPacket(USB_ClassInfo_CDC_t* CDCInterfaceInfo); 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 /** CDC class driver event for a line encoding change on a CDC interface. This event fires each time the host requests a
* be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). * 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
* \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. * settings are available in the LineEncoding structure inside the CDC interface structure passed as a parameter.
*/ *
void CDC_Device_USBTask(USB_ClassInfo_CDC_t* CDCInterfaceInfo); * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
*/
/** CDC class driver event for a line encoding change on a CDC interface. This event fires each time the host requests a void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
* 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 /** CDC class driver event for a control line state change on a CDC interface. This event fires each time the host requests a
* settings are available in the LineEncoding structure inside the CDC interface structure passed as a parameter. * 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
* \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. * 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.
void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo); *
* \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
/** 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 void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
* 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 /** Sends a given string to the attached USB host, if connected. If a host is not connected when the function is called, the
* CDC_CONTROL_LINE_OUT_* masks. * string is discarded.
* *
* \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
*/ * \param Data Pointer to the string to send to the host
void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo); * \param Length Size in bytes of the string to send to the host
*/
/** Sends a given string to the attached USB host, if connected. If a host is not connected when the function is called, the void CDC_Device_SendString(USB_ClassInfo_CDC_t* CDCInterfaceInfo, char* Data, uint16_t Length);
* string is discarded.
* /** Sends a given byte to the attached USB host, if connected. If a host is not connected when the function is called, the
* \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. * byte is discarded.
* \param Data Pointer to the string to send to the host *
* \param Length Size in bytes of the string to send to the host * \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_SendString(USB_ClassInfo_CDC_t* CDCInterfaceInfo, char* Data, uint16_t Length); */
void CDC_Device_SendByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint8_t Data);
/** 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. /** 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. * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
* \param Data Byte of data to send to the host *
*/ * \return Total number of buffered bytes received from the host
void CDC_Device_SendByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint8_t Data); */
uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
/** Determines the number of bytes received by the CDC interface from the host, waiting to be read.
* /** 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
* \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. * returns 0. The USB_CDC_BytesReceived() function should be queried before data is recieved to ensure that no data
* * underflow occurs.
* \return Total number of buffered bytes received from the host *
*/ * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_t* CDCInterfaceInfo); *
* \return Next received byte from the host, or 0 if no data received
/** 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 uint8_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
* underflow occurs.
* /** Sends a Serial Control Line State Change notification to the host. This should be called when the virtual serial control
* \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. * 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.
* \return Next received byte from the host, or 0 if no data received *
*/ * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
uint8_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo); * \param LineStateMask Mask of CDC_CONTROL_LINE_IN_* masks giving the current control line states
*/
/** Sends a Serial Control Line State Change notification to the host. This should be called when the virtual serial control void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask);
* 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. /* Private Interface - For use in library only: */
* #if !defined(__DOXYGEN__)
* \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. /* Function Prototypes: */
* \param LineStateMask Mask of CDC_CONTROL_LINE_IN_* masks giving the current control line states #if defined(INCLUDE_FROM_CDC_CLASS_DEVICE_C)
*/ void CDC_Device_Event_Stub(void);
void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask); 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: */ /* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)

@ -51,57 +51,58 @@
extern "C" { extern "C" {
#endif #endif
/* Function Prototypes: */ /* Public Interface - May be used in end-application: */
/** Configures the endpoints of a given HID interface, ready for use. This should be linked to the library /* Function Prototypes: */
* \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration /** Configures the endpoints of a given HID interface, ready for use. This should be linked to the library
* containing the given HID interface is selected. * \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. *
* * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
* \return Boolean true if the endpoints were sucessfully configured, false otherwise *
*/ * \return Boolean true if the endpoints were sucessfully configured, false otherwise
bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_t* HIDInterfaceInfo); */
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. /** 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. *
*/ * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
void HID_Device_ProcessControlPacket(USB_ClassInfo_HID_t* HIDInterfaceInfo); */
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(). /** 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. *
*/ * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
void HID_Device_USBTask(USB_ClassInfo_HID_t* HIDInterfaceInfo); */
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 /** HID class driver callback for the user creation of a HID input report. This callback may fire in response to either
* user is responsible for the creation of the next HID input report to be sent to the host. * 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 * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
* be set to the report ID of the generated HID input report. If multiple reports are not sent via the * \param ReportID If preset to a non-zero value, this is the report ID being requested by the host. If zero, this should
* given HID interface, this parameter should be ignored. * be set to the report ID of the generated HID input report. If multiple reports are not sent via the
* \param ReportData Pointer to a buffer where the generated HID report should be stored. * 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 *
*/ * \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); */
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 /** HID class driver callback for the user processing of a received HID input report. This callback may fire in response to
* the user is responsible for the processing of the received HID output report from the host. * 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 * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
* interface, this parameter should be ignored. * \param ReportID Report ID of the received output report. If multiple reports are not received via the given HID
* \param ReportData Pointer to a buffer where the received HID report is stored. * interface, this parameter should be ignored.
* \param ReportSize Size in bytes of the received report from the host. * \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); void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, void* ReportData,
uint16_t ReportSize);
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)

@ -52,46 +52,47 @@
extern "C" { extern "C" {
#endif #endif
/* Function Prototypes: */ /* Public Interface - May be used in end-application: */
/** Configures the endpoints of a given MIDI interface, ready for use. This should be linked to the library /* Function Prototypes: */
* \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration /** Configures the endpoints of a given MIDI interface, ready for use. This should be linked to the library
* containing the given MIDI interface is selected. * \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. *
* * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
* \return Boolean true if the endpoints were sucessfully configured, false otherwise *
*/ * \return Boolean true if the endpoints were sucessfully configured, false otherwise
bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo); */
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. /** 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. *
*/ * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
void MIDI_Device_ProcessControlPacket(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo); */
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(). /** 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. *
*/ * \param MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
void MIDI_Device_USBTask(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo); */
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.
* /** 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 * \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); */
void MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event);
/** Receives a MIDI event packet from the host.
* /** 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 * \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 *
*/ * \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); */
bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event);
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)

@ -51,47 +51,53 @@
extern "C" { extern "C" {
#endif #endif
/* Function Prototypes: */ /* Public Interface - May be used in end-application: */
#if defined(INCLUDE_FROM_MS_CLASS_DEVICE_C) /* Function Prototypes: */
static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_t* MSInterfaceInfo); /** Configures the endpoints of a given Mass Storage interface, ready for use. This should be linked to the library
static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_t* MSInterfaceInfo); * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration
static uint8_t StreamCallback_MS_Device_AbortOnMassStoreReset(void); * containing the given Mass Storage interface is selected.
#endif *
* \param MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.
/** 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 * \return Boolean true if the endpoints were sucessfully configured, false otherwise
* containing the given Mass Storage interface is selected. */
* bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_t* MSInterfaceInfo);
* \param MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.
* /** Processes incomming control requests from the host, that are directed to the given Mass Storage class interface. This should be
* \return Boolean true if the endpoints were sucessfully configured, false otherwise * linked to the library \ref EVENT_USB_UnhandledControlPacket() event.
*/ *
bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_t* MSInterfaceInfo); * \param MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.
*/
/** Processes incomming control requests from the host, that are directed to the given Mass Storage class interface. This should be void MS_Device_ProcessControlPacket(USB_ClassInfo_MS_t* MSInterfaceInfo);
* linked to the library \ref EVENT_USB_UnhandledControlPacket() event.
* /** General management task for a given Mass Storage class interface, required for the correct operation of the interface. This should
* \param MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state. * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
*/ *
void MS_Device_ProcessControlPacket(USB_ClassInfo_MS_t* MSInterfaceInfo); * \param MSInterfaceInfo Pointer to a structure containing a Mass Storage configuration and state.
*/
/** General management task for a given Mass Storage class interface, required for the correct operation of the interface. This should void MS_Device_USBTask(USB_ClassInfo_MS_t* MSInterfaceInfo);
* be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
* /** Mass Storage class driver callback for the user processing of a received SCSI command. This callback will fire each time the
* \param MSInterfaceInfo Pointer to a structure containing a Mass Storage configuration and state. * 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
void MS_Device_USBTask(USB_ClassInfo_MS_t* MSInterfaceInfo); * inside the Mass Storage class state structure passed as a parameter to the callback function.
*
/** Mass Storage class driver callback for the user processing of a received SCSI command. This callback will fire each time the * \param MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.
* 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 * \return Boolean true if the SCSI command was successfully processed, false otherwise
* inside the Mass Storage class state structure passed as a parameter to the callback function. */
* bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_t* MSInterfaceInfo);
* \param MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.
* /* Private Interface - For use in library only: */
* \return Boolean true if the SCSI command was successfully processed, false otherwise #if !defined(__DOXYGEN__)
*/ /* Function Prototypes: */
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_t* MSInterfaceInfo); #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
#endif
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)

@ -52,7 +52,35 @@
extern "C" { extern "C" {
#endif #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) #if defined(INCLUDE_FROM_RNDIS_CLASS_DEVICE_C)
static void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo); static void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo);
static bool RNDIS_Device_ProcessNDISQuery(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo, static bool RNDIS_Device_ProcessNDISQuery(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo,
@ -62,29 +90,7 @@
void* SetData, uint16_t SetSize); void* SetData, uint16_t SetSize);
#endif #endif
/** Configures the endpoints of a given RNDIS interface, ready for use. This should be linked to the library #endif
* \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);
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)

@ -49,7 +49,8 @@
extern "C" { extern "C" {
#endif #endif
/* Function Prototypes: */ /* Public Interface - May be used in end-application: */
/* Function Prototypes: */
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)

@ -43,7 +43,7 @@ static uint8_t CDC_Host_ProcessConfigDescriptor(void)
if (USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful) if (USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful)
return ControlError; return ControlError;
if (ConfigDescriptorSize > MAX_CONFIG_DESCRIPTOR_SIZE) if (ConfigDescriptorSize > 512)
return DescriptorTooLarge; return DescriptorTooLarge;
ConfigDescriptorData = alloca(ConfigDescriptorSize); ConfigDescriptorData = alloca(ConfigDescriptorSize);

@ -49,15 +49,29 @@
extern "C" { extern "C" {
#endif #endif
/* Function Prototypes: */ /* Public Interface - May be used in end-application: */
#if defined(INCLUDE_FROM_CDC_CLASS_HOST_C) /* Function Prototypes: */
static uint8_t CDC_Host_ProcessConfigDescriptor(void); void CDC_Host_Task(void);
static uint8_t DComp_CDC_Host_NextCDCControlInterface(void* CurrentDescriptor);
static uint8_t DComp_CDC_Host_NextCDCDataInterface(void* CurrentDescriptor); /* Private Interface - For use in library only: */
static uint8_t DComp_CDC_Host_NextInterfaceCDCDataEndpoint(void* CurrentDescriptor); #if !defined(__DOXYGEN__)
#endif /* 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
void CDC_Host_Task(void); #endif
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)

@ -49,7 +49,8 @@
extern "C" { extern "C" {
#endif #endif
/* Function Prototypes: */ /* Public Interface - May be used in end-application: */
/* Function Prototypes: */
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)

@ -49,7 +49,8 @@
extern "C" { extern "C" {
#endif #endif
/* Function Prototypes: */ /* Public Interface - May be used in end-application: */
/* Function Prototypes: */
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)

@ -49,7 +49,8 @@
extern "C" { extern "C" {
#endif #endif
/* Function Prototypes: */ /* Public Interface - May be used in end-application: */
/* Function Prototypes: */
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)

@ -49,7 +49,8 @@
extern "C" { extern "C" {
#endif #endif
/* Function Prototypes: */ /* Public Interface - May be used in end-application: */
/* Function Prototypes: */
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)

Loading…
Cancel
Save