diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-10-08 08:46:27 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-10-08 08:46:27 +0000 |
commit | c7bc3ec391da3904f0db6398171c7fed37d4f836 (patch) | |
tree | daec9cabab609050e8f7f693a1ee41253e03c009 /LUFA/Drivers | |
parent | 664a2921816069483604f5e05a2a02b6ddf8727a (diff) | |
download | lufa-c7bc3ec391da3904f0db6398171c7fed37d4f836.tar.gz lufa-c7bc3ec391da3904f0db6398171c7fed37d4f836.tar.bz2 lufa-c7bc3ec391da3904f0db6398171c7fed37d4f836.zip |
Add new MIDI Host Class driver to the library, and new MIDIHost ClassDriver demo.
Make MouseHost and KeyboardHost ClassDriver demos use the HID Class driver's structures for the boot protocol Mouse/Keyboard report data, rather than rolling their own.
Diffstat (limited to 'LUFA/Drivers')
-rw-r--r-- | LUFA/Drivers/USB/Class/Audio.h | 6 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/Audio.h | 22 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/CDC.h | 22 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/HID.h | 12 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/MIDI.h | 10 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/MassStorage.h | 8 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/RNDIS.h | 6 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Host/MIDI.c | 164 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Host/MIDI.h | 163 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/MIDI.h | 5 |
10 files changed, 375 insertions, 43 deletions
diff --git a/LUFA/Drivers/USB/Class/Audio.h b/LUFA/Drivers/USB/Class/Audio.h index cb5dbb20b..c429b330f 100644 --- a/LUFA/Drivers/USB/Class/Audio.h +++ b/LUFA/Drivers/USB/Class/Audio.h @@ -36,9 +36,9 @@ * - LUFA/Drivers/USB/Class/Device/Audio.c
*
* \section Module Description
- * Audio Class Driver module. This module contains an internal implementation of the USB Audio Class, for both
- * Device and Host USB modes. User applications can use this class driver instead of implementing the Audio class
- * manually via the low-level LUFA APIs.
+ * Audio Class Driver module. This module contains an internal implementation of the USB Audio Class, for Device
+ * USB mode only. User applications can use this class driver instead of implementing the Audio class manually via
+ * the low-level LUFA APIs.
*
* This module is designed to simplify the user code by exposing only the required interface needed to interace with
* Hosts or Devices using the USB Audio Class.
diff --git a/LUFA/Drivers/USB/Class/Device/Audio.h b/LUFA/Drivers/USB/Class/Device/Audio.h index 67699fdd1..0d8e0ec88 100644 --- a/LUFA/Drivers/USB/Class/Device/Audio.h +++ b/LUFA/Drivers/USB/Class/Device/Audio.h @@ -100,7 +100,7 @@ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the
* given Audio interface is selected.
*
- * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state
*
* \return Boolean true if the endpoints were sucessfully configured, false otherwise
*/
@@ -109,21 +109,21 @@ /** 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_Device_UnhandledControlRequest() event.
*
- * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state
*/
void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** 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[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state
*/
void Audio_Device_USBTask(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Determines if the given audio interface is ready for a sample to be read from it, and selects the streaming
* OUT endpoint ready for reading.
*
- * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
+ * \param[in,out] 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
*/
@@ -132,7 +132,7 @@ /** Determines if the given audio interface is ready to accept the next sample to be written to it, and selects
* the streaming IN endpoint ready for writing.
*
- * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
+ * \param[in,out] 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
*/
@@ -144,7 +144,7 @@ * \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.
*
- * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state
*
* \return Signed 8-bit audio sample from the audio interface
*/
@@ -166,7 +166,7 @@ * \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.
*
- * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state
*
* \return Signed 16-bit audio sample from the audio interface
*/
@@ -188,7 +188,7 @@ * \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.
*
- * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state
* \return Signed 24-bit audio sample from the audio interface
*/
static inline int32_t Audio_Device_ReadSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_ALWAYS_INLINE;
@@ -209,7 +209,7 @@ * \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[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state
* \param[in] Sample Signed 8-bit audio sample
*/
static inline void Audio_Device_WriteSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
@@ -228,7 +228,7 @@ * \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[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state
* \param[in] Sample Signed 16-bit audio sample
*/
static inline void Audio_Device_WriteSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
@@ -247,7 +247,7 @@ * \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[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state
* \param[in] Sample Signed 24-bit audio sample
*/
static inline void Audio_Device_WriteSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
diff --git a/LUFA/Drivers/USB/Class/Device/CDC.h b/LUFA/Drivers/USB/Class/Device/CDC.h index 5905474ce..3e7dbb08f 100644 --- a/LUFA/Drivers/USB/Class/Device/CDC.h +++ b/LUFA/Drivers/USB/Class/Device/CDC.h @@ -111,7 +111,7 @@ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing
* the given CDC interface is selected.
*
- * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state
*
* \return Boolean true if the endpoints were sucessfully configured, false otherwise
*/
@@ -120,14 +120,14 @@ /** 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_Device_UnhandledControlRequest() event.
*
- * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state
*/
void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** 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[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state
*/
void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
@@ -136,7 +136,7 @@ * 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[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state
*/
void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
@@ -146,14 +146,14 @@ * are available in the ControlLineStates.HostToDevice value inside the CDC interface structure passed as a parameter, set as
* a mask of CDC_CONTROL_LINE_OUT_* masks.
*
- * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state
*/
void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** 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[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state
* \param[in] Data Pointer to the string to send to the host
* \param[in] Length Size in bytes of the string to send to the host
*
@@ -164,7 +164,7 @@ /** 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[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state
* \param[in] Data Byte of data to send to the host
*
* \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum
@@ -173,7 +173,7 @@ /** Determines the number of bytes received by the CDC interface from the host, waiting to be read.
*
- * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state
*
* \return Total number of buffered bytes received from the host
*/
@@ -183,7 +183,7 @@ * returns 0. The \ref CDC_Device_BytesReceived() function should be queried before data is received to ensure that no data
* underflow occurs.
*
- * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
+ * \param[in,out] 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
*/
@@ -191,7 +191,7 @@ /** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.
*
- * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state
*
* \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum
*/
@@ -202,7 +202,7 @@ * until they are cleared via a second notification. This should be called each time the CDC class driver's
* ControlLineStates.DeviceToHost value is updated to push the new states to the USB host.
*
- * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state
*/
void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
diff --git a/LUFA/Drivers/USB/Class/Device/HID.h b/LUFA/Drivers/USB/Class/Device/HID.h index a3e3b8584..dee892d06 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.h +++ b/LUFA/Drivers/USB/Class/Device/HID.h @@ -102,7 +102,7 @@ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration
* containing the given HID interface is selected.
*
- * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state
*
* \return Boolean true if the endpoints were sucessfully configured, false otherwise
*/
@@ -111,14 +111,14 @@ /** 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_Device_UnhandledControlRequest() event.
*
- * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state
*/
void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** 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[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state
*/
void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
@@ -127,7 +127,7 @@ * that this be called by the \ref EVENT_USB_Device_StartOfFrame() event, once SOF events have been enabled via
* \ref USB_Device_EnableSOFEvents();.
*
- * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state
*/
void HID_Device_MillisecondElapsed(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
@@ -135,7 +135,7 @@ * 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[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state
* \param[in,out] 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 any). If multiple reports are not sent via the
* given HID interface, this parameter should be ignored.
@@ -152,7 +152,7 @@ * 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[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state
* \param[in] 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[in] ReportData Pointer to a buffer where the received HID report is stored.
diff --git a/LUFA/Drivers/USB/Class/Device/MIDI.h b/LUFA/Drivers/USB/Class/Device/MIDI.h index c7f7bd92c..c7f67e20c 100644 --- a/LUFA/Drivers/USB/Class/Device/MIDI.h +++ b/LUFA/Drivers/USB/Class/Device/MIDI.h @@ -89,7 +89,7 @@ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration
* containing the given MIDI interface is selected.
*
- * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state
*
* \return Boolean true if the endpoints were sucessfully configured, false otherwise
*/
@@ -98,20 +98,20 @@ /** 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_Device_UnhandledControlRequest() event.
*
- * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state
*/
void MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** 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[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state
*/
void MIDI_Device_USBTask(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** Sends a MIDI event packet to the host. If no host is connected, the event packet is discarded.
*
- * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state
* \param[in] Event Pointer to a populated USB_MIDI_EventPacket_t structure containing the MIDI event to send
*
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum
@@ -121,7 +121,7 @@ /** Receives a MIDI event packet from the host.
*
- * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state
* \param[out] 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
diff --git a/LUFA/Drivers/USB/Class/Device/MassStorage.h b/LUFA/Drivers/USB/Class/Device/MassStorage.h index 16e09dcbd..4dca793c5 100644 --- a/LUFA/Drivers/USB/Class/Device/MassStorage.h +++ b/LUFA/Drivers/USB/Class/Device/MassStorage.h @@ -98,7 +98,7 @@ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration
* containing the given Mass Storage interface is selected.
*
- * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state
*
* \return Boolean true if the endpoints were sucessfully configured, false otherwise
*/
@@ -107,14 +107,14 @@ /** 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_Device_UnhandledControlRequest() event.
*
- * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state
*/
void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** 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[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage configuration and state.
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage configuration and state
*/
void MS_Device_USBTask(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
@@ -123,7 +123,7 @@ * 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[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.
+ * \param[in,out] 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
*/
diff --git a/LUFA/Drivers/USB/Class/Device/RNDIS.h b/LUFA/Drivers/USB/Class/Device/RNDIS.h index 4b024d953..7d7a0f5b9 100644 --- a/LUFA/Drivers/USB/Class/Device/RNDIS.h +++ b/LUFA/Drivers/USB/Class/Device/RNDIS.h @@ -106,7 +106,7 @@ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration
* containing the given HID interface is selected.
*
- * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state
*
* \return Boolean true if the endpoints were sucessfully configured, false otherwise
*/
@@ -115,14 +115,14 @@ /** 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_Device_UnhandledControlRequest() event.
*
- * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state
*/
void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
/** 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[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state
*/
void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
diff --git a/LUFA/Drivers/USB/Class/Host/MIDI.c b/LUFA/Drivers/USB/Class/Host/MIDI.c new file mode 100644 index 000000000..1cdfa498b --- /dev/null +++ b/LUFA/Drivers/USB/Class/Host/MIDI.c @@ -0,0 +1,164 @@ +/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2009.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, and distribute this software
+ and its documentation for any purpose and without fee is hereby
+ granted, provided that the above copyright notice appear in all
+ copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+#include "../../HighLevel/USBMode.h"
+#if defined(USB_CAN_BE_HOST)
+
+#define INCLUDE_FROM_MIDI_CLASS_HOST_C
+#include "MIDI.h"
+
+uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo, uint16_t ConfigDescriptorSize,
+ uint8_t* ConfigDescriptorData)
+{
+ uint8_t FoundEndpoints = 0;
+
+ memset(&MIDIInterfaceInfo->State, 0x00, sizeof(MIDIInterfaceInfo->State));
+
+ if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)
+ return MIDI_ENUMERROR_InvalidConfigDescriptor;
+
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
+ DComp_MIDI_Host_NextMIDIStreamingInterface) != DESCRIPTOR_SEARCH_COMP_Found)
+ {
+ return MIDI_ENUMERROR_NoStreamingInterfaceFound;
+ }
+
+ while (FoundEndpoints != (MIDI_FOUND_DATAPIPE_IN | MIDI_FOUND_DATAPIPE_OUT))
+ {
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
+ DComp_MIDI_Host_NextMIDIStreamingDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
+ {
+ return MIDI_ENUMERROR_EndpointsNotFound;
+ }
+
+ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);
+
+ if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
+ {
+ Pipe_ConfigurePipe(MIDIInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_IN,
+ EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);
+ MIDIInterfaceInfo->State.DataINPipeSize = EndpointData->EndpointSize;
+
+ FoundEndpoints |= MIDI_FOUND_DATAPIPE_IN;
+ }
+ else
+ {
+ Pipe_ConfigurePipe(MIDIInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,
+ EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);
+ MIDIInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize;
+
+ FoundEndpoints |= MIDI_FOUND_DATAPIPE_OUT;
+ }
+ }
+
+ MIDIInterfaceInfo->State.IsActive = true;
+ return MIDI_ENUMERROR_NoError;
+}
+
+static uint8_t DComp_MIDI_Host_NextMIDIStreamingInterface(void* CurrentDescriptor)
+{
+ if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+ {
+ USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
+ USB_Descriptor_Interface_t);
+
+ if ((CurrentInterface->Class == MIDI_STREAMING_CLASS) &&
+ (CurrentInterface->SubClass == MIDI_STREAMING_SUBCLASS) &&
+ (CurrentInterface->Protocol == MIDI_STREAMING_PROTOCOL))
+ {
+ return DESCRIPTOR_SEARCH_Found;
+ }
+ }
+
+ return DESCRIPTOR_SEARCH_NotFound;
+}
+
+static uint8_t DComp_MIDI_Host_NextMIDIStreamingDataEndpoint(void* CurrentDescriptor)
+{
+ if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+ {
+ USB_Descriptor_Endpoint_t* CurrentEndpoint = DESCRIPTOR_PCAST(CurrentDescriptor,
+ USB_Descriptor_Endpoint_t);
+
+ uint8_t EndpointType = (CurrentEndpoint->Attributes & EP_TYPE_MASK);
+
+ if ((EndpointType == EP_TYPE_BULK) && !(Pipe_IsEndpointBound(CurrentEndpoint->EndpointAddress)))
+ return DESCRIPTOR_SEARCH_Found;
+ }
+ else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+ {
+ return DESCRIPTOR_SEARCH_Fail;
+ }
+
+ return DESCRIPTOR_SEARCH_NotFound;
+}
+
+void MIDI_Host_USBTask(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo)
+{
+
+}
+
+uint8_t MIDI_Host_SendEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo, MIDI_EventPacket_t* const Event)
+{
+ if ((USB_HostState != HOST_STATE_Configured) || !(MIDIInterfaceInfo->State.IsActive))
+ return HOST_SENDCONTROL_DeviceDisconnect;
+
+ Pipe_SelectPipe(MIDIInterfaceInfo->Config.DataOUTPipeNumber);
+
+ if (Pipe_IsReadWriteAllowed());
+ {
+ uint8_t ErrorCode;
+
+ if ((ErrorCode = Pipe_Write_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
+ return ErrorCode;
+
+ Pipe_ClearOUT();
+ }
+
+ return PIPE_RWSTREAM_NoError;
+}
+
+bool MIDI_Host_ReceiveEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo, MIDI_EventPacket_t* const Event)
+{
+ if ((USB_HostState != HOST_STATE_Configured) || !(MIDIInterfaceInfo->State.IsActive))
+ return HOST_SENDCONTROL_DeviceDisconnect;
+
+ Pipe_SelectPipe(MIDIInterfaceInfo->Config.DataINPipeNumber);
+
+ if (!(Pipe_IsReadWriteAllowed()))
+ return false;
+
+ Pipe_Read_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NO_STREAM_CALLBACK);
+ Pipe_ClearIN();
+
+ return true;
+}
+
+#endif
diff --git a/LUFA/Drivers/USB/Class/Host/MIDI.h b/LUFA/Drivers/USB/Class/Host/MIDI.h new file mode 100644 index 000000000..99e8ea177 --- /dev/null +++ b/LUFA/Drivers/USB/Class/Host/MIDI.h @@ -0,0 +1,163 @@ +/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2009.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, and distribute this software
+ and its documentation for any purpose and without fee is hereby
+ granted, provided that the above copyright notice appear in all
+ copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \ingroup Group_USBClassMIDI
+ * @defgroup Group_USBClassMIDIHost MIDI Class Host Mode Driver
+ *
+ * \section Sec_Dependencies Module Source Dependencies
+ * The following files must be built with any user project that uses this module:
+ * - LUFA/Drivers/USB/Class/Host/MIDI.c
+ *
+ * \section Module Description
+ * Host Mode USB Class driver framework interface, for the MIDI USB Class driver.
+ *
+ * @{
+ */
+
+#ifndef __MIDI_CLASS_HOST_H__
+#define __MIDI_CLASS_HOST_H__
+
+ /* Includes: */
+ #include "../../USB.h"
+ #include "../Common/MIDI.h"
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Type Defines: */
+ /** Class state structure. An instance of this structure should be made within the user application,
+ * and passed to each of the MIDI class driver functions as the MIDIInterfaceInfo parameter. This
+ * stores each MIDI interface's configuration and state information.
+ */
+ typedef struct
+ {
+ const struct
+ {
+ uint8_t DataINPipeNumber; /**< Pipe number of the MIDI interface's streaming IN data pipe */
+ uint8_t DataOUTPipeNumber; /**< Pipe number of the MIDI interface's streaming OUT data pipe */
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.
+ */
+ struct
+ {
+ bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid
+ * after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the
+ * Configured state
+ */
+
+ uint16_t DataINPipeSize; /**< Size in bytes of the MIDI Streaming Data interface's IN data pipe */
+ uint16_t DataOUTPipeSize; /**< Size in bytes of the MIDI Streaming Data interface's OUT data pipe */
+ } State; /**< State data for the USB class interface within the device. All elements in this section
+ * <b>may</b> be set to initial values, but may also be ignored to default to sane values when
+ * the interface is enumerated.
+ */
+ } USB_ClassInfo_MIDI_Host_t;
+
+ /* Enums: */
+ /** Enum for the possible error codes returned by the \ref MIDI_Host_ConfigurePipes() function. */
+ enum MIDIHost_EnumerationFailure_ErrorCodes_t
+ {
+ MIDI_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully */
+ MIDI_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor */
+ MIDI_ENUMERROR_NoStreamingInterfaceFound = 2, /**< A compatible MIDI interface was not found in the device's Configuration Descriptor */
+ MIDI_ENUMERROR_EndpointsNotFound = 3, /**< Compatible MIDI data endpoints were not found in the device's MIDI interface */
+ };
+
+ /* Function Prototypes: */
+ /** General management task for a given MIDI host 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[in,out] MIDIInterfaceInfo Pointer to a structure containing an MIDI Class host configuration and state
+ */
+ void MIDI_Host_USBTask(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
+
+ /** Host interface configuration routine, to configure a given MIDI host interface instance using the Configuration
+ * Descriptor read from an attached USB device. This function automatically updates the given MIDI Host instance's
+ * state values and configures the pipes required to communicate with the interface if it is found within the device.
+ * This should be called once after the stack has enumerated the attached device, while the host state machine is in
+ * the Addressed state.
+ *
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing an MIDI Class host configuration and state
+ * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor
+ * \param[in] DeviceConfigDescriptor Pointer to a buffer containing the attached device's Configuration Descriptor
+ *
+ * \return A value from the \ref MIDIHost_EnumerationFailure_ErrorCodes_t enum
+ */
+ uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo, uint16_t ConfigDescriptorSize,
+ uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
+
+ /** Sends a MIDI event packet to the device. If no device is connected, the event packet is discarded.
+ *
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state
+ * \param[in] Event Pointer to a populated USB_MIDI_EventPacket_t structure containing the MIDI event to send
+ *
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum
+ */
+ uint8_t MIDI_Host_SendEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo,
+ MIDI_EventPacket_t* const Event) ATTR_NON_NULL_PTR_ARG(1, 2);
+
+ /** Receives a MIDI event packet from the device.
+ *
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state
+ * \param[out] 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_Host_ReceiveEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo,
+ MIDI_EventPacket_t* const Event) ATTR_NON_NULL_PTR_ARG(1, 2);
+
+ /* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
+ /* Macros: */
+ #define MIDI_STREAMING_CLASS 0x01
+ #define MIDI_STREAMING_SUBCLASS 0x03
+ #define MIDI_STREAMING_PROTOCOL 0x00
+
+ #define MIDI_FOUND_DATAPIPE_IN (1 << 0)
+ #define MIDI_FOUND_DATAPIPE_OUT (1 << 1)
+
+ /* Function Prototypes: */
+ #if defined(INCLUDE_FROM_MIDI_CLASS_HOST_C)
+ static uint8_t DComp_MIDI_Host_NextMIDIStreamingInterface(void* CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
+ static uint8_t DComp_MIDI_Host_NextMIDIStreamingDataEndpoint(void* CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
+ #endif
+ #endif
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
diff --git a/LUFA/Drivers/USB/Class/MIDI.h b/LUFA/Drivers/USB/Class/MIDI.h index a423e0bfd..a38c3d878 100644 --- a/LUFA/Drivers/USB/Class/MIDI.h +++ b/LUFA/Drivers/USB/Class/MIDI.h @@ -34,6 +34,7 @@ * \section Sec_Dependencies Module Source Dependencies
* The following files must be built with any user project that uses this module:
* - LUFA/Drivers/USB/Class/Device/MIDI.c
+ * - LUFA/Drivers/USB/Class/Host/MIDI.c
*
* \section Module Description
* MIDI Class Driver module. This module contains an internal implementation of the USB MIDI Class, for both Device
@@ -58,6 +59,10 @@ #if defined(USB_CAN_BE_DEVICE)
#include "Device/MIDI.h"
#endif
+
+ #if defined(USB_CAN_BE_HOST)
+ #include "Host/MIDI.h"
+ #endif
#endif
|