Newer AS7 integration binary, with ASF detection fixes and newer image assets.
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Common / MIDIClassCommon.h
index 7eb6e6a..02bd015 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2012.
+     Copyright (C) Dean Camera, 2015.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2015  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
@@ -18,7 +18,7 @@
   advertising or publicity pertaining to distribution of the
   software without specific, written prior permission.
 
   advertising or publicity pertaining to distribution of the
   software without specific, written prior permission.
 
-  The author disclaim all warranties with regard to this
+  The author disclaims 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
   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
@@ -40,7 +40,7 @@
 /** \ingroup Group_USBClassMIDI
  *  \defgroup Group_USBClassMIDICommon  Common Class Definitions
  *
 /** \ingroup Group_USBClassMIDI
  *  \defgroup Group_USBClassMIDICommon  Common Class Definitions
  *
- *  \section Sec_ModDescription Module Description
+ *  \section Sec_USBClassMIDICommon_ModDescription Module Description
  *  Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
  *  MIDI Class.
  *
  *  Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
  *  MIDI Class.
  *
                #endif
 
        /* Macros: */
                #endif
 
        /* Macros: */
-               /** \name MIDI Command Values */
+               /** \name MIDI Command Values
+                *  See http://www.midi.org/techspecs/midimessages.php for more information.
+                */
                //@{
                //@{
-               /** MIDI command for a note on (activation) event. */
-               #define MIDI_COMMAND_NOTE_ON        0x90
+               /** MIDI command for System Exclusive (SysEx) single event that has one byte of data total. */
+               #define MIDI_COMMAND_SYSEX_1BYTE           MIDI_COMMAND_SYSEX_END_1BYTE
+
+               /** MIDI command for System Exclusive (SysEx) single event that has two bytes of data total. */
+               #define MIDI_COMMAND_SYSEX_2BYTE           0x20
+
+               /** MIDI command for System Exclusive (SysEx) single event that has three bytes of data total. */
+               #define MIDI_COMMAND_SYSEX_3BYTE           0x30
+
+               /** MIDI command for System Exclusive (SysEx) stream event that has at least four bytes of data total. */
+               #define MIDI_COMMAND_SYSEX_START_3BYTE     0x40
+
+               /** MIDI command for System Exclusive (SysEx) stream event terminator with one remaining data byte. */
+               #define MIDI_COMMAND_SYSEX_END_1BYTE       0x50
+
+               /** MIDI command for System Exclusive (SysEx) stream event terminator with two remaining data bytes. */
+               #define MIDI_COMMAND_SYSEX_END_2BYTE       0x60
+
+               /** MIDI command for System Exclusive (SysEx) stream event terminator with three remaining data bytes. */
+               #define MIDI_COMMAND_SYSEX_END_3BYTE       0x70
 
                /** MIDI command for a note off (deactivation) event. */
 
                /** MIDI command for a note off (deactivation) event. */
-               #define MIDI_COMMAND_NOTE_OFF       0x80
+               #define MIDI_COMMAND_NOTE_OFF              0x80
+
+               /** MIDI command for a note on (activation) event. */
+               #define MIDI_COMMAND_NOTE_ON               0x90
+
+               /** MIDI command for a note pressure change event. */
+               #define MIDI_COMMAND_NOTE_PRESSURE         0xA0
+
+               /** MIDI command for a control change event. */
+               #define MIDI_COMMAND_CONTROL_CHANGE        0xB0
+
+               /** MIDI command for a control change event. */
+               #define MIDI_COMMAND_PROGRAM_CHANGE        0xC0
+
+               /** MIDI command for a channel pressure change event. */
+               #define MIDI_COMMAND_CHANNEL_PRESSURE      0xD0
+
+               /** MIDI command for a pitch change event. */
+               #define MIDI_COMMAND_PITCH_WHEEL_CHANGE    0xE0
                //@}
 
                /** Standard key press velocity value used for all note events. */
                //@}
 
                /** Standard key press velocity value used for all note events. */
-               #define MIDI_STANDARD_VELOCITY      64
+               #define MIDI_STANDARD_VELOCITY             64
 
                /** Convenience macro. MIDI channels are numbered from 1-10 (natural numbers) however the logical channel
                 *  addresses are zero-indexed. This converts a natural MIDI channel number into the logical channel address.
                 *
                 *  \param[in] channel  MIDI channel number to address.
 
                /** Convenience macro. MIDI channels are numbered from 1-10 (natural numbers) however the logical channel
                 *  addresses are zero-indexed. This converts a natural MIDI channel number into the logical channel address.
                 *
                 *  \param[in] channel  MIDI channel number to address.
+                *
+                *  \return Constructed MIDI channel ID.
+                */
+               #define MIDI_CHANNEL(channel)              ((channel) - 1)
+
+               /** Constructs a MIDI event ID from a given MIDI command and a virtual MIDI cable index. This can then be
+                *  used to create and decode \ref MIDI_EventPacket_t MIDI event packets.
+                *
+                *  \param[in] virtualcable  Index of the virtual MIDI cable the event relates to
+                *  \param[in] command       MIDI command to send through the virtual MIDI cable
+                *
+                *  \return Constructed MIDI event ID.
                 */
                 */
-               #define MIDI_CHANNEL(channel)        ((channel) - 1)
+               #define MIDI_EVENT(virtualcable, command)  (((virtualcable) << 4) | ((command) >> 4))
 
        /* Enums: */
                /** Enum for the possible MIDI jack types in a MIDI device jack descriptor. */
 
        /* Enums: */
                /** Enum for the possible MIDI jack types in a MIDI device jack descriptor. */
 
                        uint16_t                AudioSpecification; /**< Binary coded decimal value, indicating the supported Audio Class
                                                                     *   specification version.
 
                        uint16_t                AudioSpecification; /**< Binary coded decimal value, indicating the supported Audio Class
                                                                     *   specification version.
+                                                                    *
+                                                                    *   \see \ref VERSION_BCD() utility macro.
                                                                     */
                        uint16_t                TotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */
                } ATTR_PACKED USB_MIDI_Descriptor_AudioInterface_AS_t;
                                                                     */
                        uint16_t                TotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */
                } ATTR_PACKED USB_MIDI_Descriptor_AudioInterface_AS_t;
 
                        uint8_t  bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */
 
 
                        uint8_t  bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */
 
-                       uint16_t bcdMSC; /**< Binary coded decimal value, indicating the supported MIDI Class specification version. */
+                       uint16_t bcdMSC; /**< Binary coded decimal value, indicating the supported MIDI Class specification version.
+                                         *
+                                         *   \see \ref VERSION_BCD() utility macro.
+                                         */
                        uint16_t wTotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */
                } ATTR_PACKED USB_MIDI_StdDescriptor_AudioInterface_AS_t;
 
                        uint16_t wTotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */
                } ATTR_PACKED USB_MIDI_StdDescriptor_AudioInterface_AS_t;
 
                 */
                typedef struct
                {
                 */
                typedef struct
                {
-                       unsigned Command     : 4; /**< Upper nibble of the MIDI command being sent or received in the event packet. */
-                       unsigned CableNumber : 4; /**< Virtual cable number of the event being sent or received in the given MIDI interface. */
+                       uint8_t  Event; /**< MIDI event type, constructed with the \ref MIDI_EVENT() macro. */
 
                        uint8_t  Data1; /**< First byte of data in the MIDI event. */
                        uint8_t  Data2; /**< Second byte of data in the MIDI event. */
 
                        uint8_t  Data1; /**< First byte of data in the MIDI event. */
                        uint8_t  Data2; /**< Second byte of data in the MIDI event. */