]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC/ThirdParty/LPCOpen/LPCUSBLib/Drivers/USB/Class/Common/MIDIClassCommon.h
Update LPC18xx FreeRTOS+UDP demo to use LPCOpen USB and Ethernet drivers.
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC / ThirdParty / LPCOpen / LPCUSBLib / Drivers / USB / Class / Common / MIDIClassCommon.h
1 /*\r
2  * @brief Common definitions and declarations for the library USB MIDI Class driver\r
3  *\r
4  * @note\r
5  * Copyright(C) NXP Semiconductors, 2012\r
6  * Copyright(C) Dean Camera, 2011, 2012\r
7  * All rights reserved.\r
8  *\r
9  * @par\r
10  * Software that is described herein is for illustrative purposes only\r
11  * which provides customers with programming information regarding the\r
12  * LPC products.  This software is supplied "AS IS" without any warranties of\r
13  * any kind, and NXP Semiconductors and its licensor disclaim any and\r
14  * all warranties, express or implied, including all implied warranties of\r
15  * merchantability, fitness for a particular purpose and non-infringement of\r
16  * intellectual property rights.  NXP Semiconductors assumes no responsibility\r
17  * or liability for the use of the software, conveys no license or rights under any\r
18  * patent, copyright, mask work right, or any other intellectual property rights in\r
19  * or to any products. NXP Semiconductors reserves the right to make changes\r
20  * in the software without notification. NXP Semiconductors also makes no\r
21  * representation or warranty that such application will be suitable for the\r
22  * specified use without further testing or modification.\r
23  *\r
24  * @par\r
25  * Permission to use, copy, modify, and distribute this software and its\r
26  * documentation is hereby granted, under NXP Semiconductors' and its\r
27  * licensor's relevant copyrights in the software, without fee, provided that it\r
28  * is used in conjunction with NXP Semiconductors microcontrollers.  This\r
29  * copyright, permission, and disclaimer notice must appear in all copies of\r
30  * this code.\r
31  */\r
32 \r
33 /** @ingroup Group_USBClassMIDI\r
34  *  @defgroup Group_USBClassMIDICommon  Common Class Definitions\r
35  *\r
36  *  @section Sec_ModDescription Module Description\r
37  *  Constants, Types and Enum definitions that are common to both Device and Host modes for the USB\r
38  *  MIDI Class.\r
39  *\r
40  *  @{\r
41  */\r
42 \r
43 #ifndef _MIDI_CLASS_COMMON_H_\r
44 #define _MIDI_CLASS_COMMON_H_\r
45 \r
46         /* Macros: */\r
47                 #define __INCLUDE_FROM_AUDIO_DRIVER\r
48 \r
49         /* Includes: */\r
50                 #include "../../Core/StdDescriptors.h"\r
51                 #include "AudioClassCommon.h"\r
52 \r
53         /* Enable C linkage for C++ Compilers: */\r
54                 #if defined(__cplusplus)\r
55                         extern "C" {\r
56                 #endif\r
57 \r
58         /* Preprocessor Checks: */\r
59                 #if !defined(__INCLUDE_FROM_MIDI_DRIVER)\r
60                         #error Do not include this file directly. Include LPCUSBlib/Drivers/USB.h instead.\r
61                 #endif\r
62 \r
63         /* Macros: */\r
64                 /** @name MIDI Command Values */\r
65                 //@{\r
66                 /** MIDI command for a note on (activation) event. */\r
67                 #define MIDI_COMMAND_NOTE_ON        0x90\r
68 \r
69                 /** MIDI command for a note off (deactivation) event. */\r
70                 #define MIDI_COMMAND_NOTE_OFF       0x80\r
71                 //@}\r
72 \r
73                 /** Standard key press velocity value used for all note events. */\r
74                 #define MIDI_STANDARD_VELOCITY      64\r
75 \r
76                 /** Convenience macro. MIDI channels are numbered from 1-10 (natural numbers) however the logical channel\r
77                  *  addresses are zero-indexed. This converts a natural MIDI channel number into the logical channel address.\r
78                  *\r
79                  *  @param channel  MIDI channel number to address.\r
80                  */\r
81                 #define MIDI_CHANNEL(channel)        ((channel) - 1)\r
82 \r
83         /* Enums: */\r
84                 /** Enum for the possible MIDI jack types in a MIDI device jack descriptor. */\r
85                 enum MIDI_JackTypes_t\r
86                 {\r
87                         MIDI_JACKTYPE_Embedded = 0x01, /**< MIDI class descriptor jack type value for an embedded (logical) MIDI input or output jack. */\r
88                         MIDI_JACKTYPE_External = 0x02, /**< MIDI class descriptor jack type value for an external (physical) MIDI input or output jack. */\r
89                 };\r
90 \r
91         /* Type Defines: */\r
92                 /** @brief MIDI class-specific Streaming Interface Descriptor (nxpUSBlib naming conventions).\r
93                  *\r
94                  *  Type define for an Audio class-specific MIDI streaming interface descriptor. This indicates to the host\r
95                  *  how MIDI the specification compliance of the device and the total length of the Audio class-specific descriptors.\r
96                  *  See the USB Audio specification for more details.\r
97                  *\r
98                  *  @see @ref USB_MIDI_StdDescriptor_AudioInterface_AS_t for the version of this type with standard element names.\r
99                  *\r
100                  *  @note Regardless of CPU architecture, these values should be stored as little endian.\r
101                  */\r
102                 typedef ATTR_IAR_PACKED struct\r
103                 {\r
104                         USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
105                         uint8_t                 Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
106 \r
107                         uint16_t                AudioSpecification; /**< Binary coded decimal value, indicating the supported Audio Class\r
108                                                                      *   specification version.\r
109                                                                      */\r
110                         uint16_t                TotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */\r
111                 } ATTR_PACKED USB_MIDI_Descriptor_AudioInterface_AS_t;\r
112 \r
113                 /** @brief MIDI class-specific Streaming Interface Descriptor (USB-IF naming conventions).\r
114                  *\r
115                  *  Type define for an Audio class-specific MIDI streaming interface descriptor. This indicates to the host\r
116                  *  how MIDI the specification compliance of the device and the total length of the Audio class-specific descriptors.\r
117                  *  See the USB Audio specification for more details.\r
118                  *\r
119                  *  @see @ref USB_MIDI_Descriptor_AudioInterface_AS_t for the version of this type with non-standard nxpUSBlib specific\r
120                  *       element names.\r
121                  *\r
122                  *  @note Regardless of CPU architecture, these values should be stored as little endian.\r
123                  */\r
124                 typedef ATTR_IAR_PACKED struct\r
125                 {\r
126                         uint8_t  bLength; /**< Size of the descriptor, in bytes. */\r
127                         uint8_t  bDescriptorType; /**< Type of the descriptor, either a value in @ref USB_DescriptorTypes_t or a value\r
128                                                    *   given by the specific class.\r
129                                                    */\r
130 \r
131                         uint8_t  bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
132 \r
133                         uint16_t bcdMSC; /**< Binary coded decimal value, indicating the supported MIDI Class specification version. */\r
134                         uint16_t wTotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */\r
135                 } ATTR_PACKED USB_MIDI_StdDescriptor_AudioInterface_AS_t;\r
136 \r
137                 /** @brief MIDI class-specific Input Jack Descriptor (nxpUSBlib naming conventions).\r
138                  *\r
139                  *  Type define for an Audio class-specific MIDI IN jack. This gives information to the host on a MIDI input, either\r
140                  *  a physical input jack, or a logical jack (receiving input data internally, or from the host via an endpoint).\r
141                  *\r
142                  *  @see @ref USB_MIDI_StdDescriptor_InputJack_t for the version of this type with standard element names.\r
143                  *\r
144                  *  @note Regardless of CPU architecture, these values should be stored as little endian.\r
145                  */\r
146                 typedef ATTR_IAR_PACKED struct\r
147                 {\r
148                         USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
149                         uint8_t                 Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
150 \r
151                         uint8_t                 JackType; /**< Type of jack, one of the \c JACKTYPE_* mask values. */\r
152                         uint8_t                 JackID; /**< ID value of this jack - must be a unique value within the device. */\r
153 \r
154                         uint8_t                 JackStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */\r
155                 } ATTR_PACKED USB_MIDI_Descriptor_InputJack_t;\r
156 \r
157                 /** @brief MIDI class-specific Input Jack Descriptor (USB-IF naming conventions).\r
158                  *\r
159                  *  Type define for an Audio class-specific MIDI IN jack. This gives information to the host on a MIDI input, either\r
160                  *  a physical input jack, or a logical jack (receiving input data internally, or from the host via an endpoint).\r
161                  *\r
162                  *  @see @ref USB_MIDI_Descriptor_InputJack_t for the version of this type with non-standard nxpUSBlib specific\r
163                  *       element names.\r
164                  *\r
165                  *  @note Regardless of CPU architecture, these values should be stored as little endian.\r
166                  */\r
167                 typedef ATTR_IAR_PACKED struct\r
168                 {\r
169                         uint8_t  bLength; /**< Size of the descriptor, in bytes. */\r
170                         uint8_t  bDescriptorType; /**< Type of the descriptor, either a value in @ref USB_DescriptorTypes_t or a value\r
171                                                    *   given by the specific class.\r
172                                                    */\r
173 \r
174                         uint8_t  bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
175 \r
176                         uint8_t  bJackType; /**< Type of jack, one of the \c JACKTYPE_* mask values. */\r
177                         uint8_t  bJackID; /**< ID value of this jack - must be a unique value within the device. */\r
178 \r
179                         uint8_t  iJack; /**< Index of a string descriptor describing this descriptor within the device. */\r
180                 } ATTR_PACKED USB_MIDI_StdDescriptor_InputJack_t;\r
181 \r
182                 /** @brief MIDI class-specific Output Jack Descriptor (nxpUSBlib naming conventions).\r
183                  *\r
184                  *  Type define for an Audio class-specific MIDI OUT jack. This gives information to the host on a MIDI output, either\r
185                  *  a physical output jack, or a logical jack (sending output data internally, or to the host via an endpoint).\r
186                  *\r
187                  *  @see @ref USB_MIDI_StdDescriptor_OutputJack_t for the version of this type with standard element names.\r
188                  *\r
189                  *  @note Regardless of CPU architecture, these values should be stored as little endian.\r
190                  */\r
191                 typedef ATTR_IAR_PACKED struct\r
192                 {\r
193                         USB_Descriptor_Header_t   Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
194                         uint8_t                   Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
195 \r
196                         uint8_t                   JackType; /**< Type of jack, one of the \c JACKTYPE_* mask values. */\r
197                         uint8_t                   JackID; /**< ID value of this jack - must be a unique value within the device. */\r
198 \r
199                         uint8_t                   NumberOfPins; /**< Number of output channels within the jack, either physical or logical. */\r
200                         uint8_t                   SourceJackID[1]; /**< ID of each output pin's source data jack. */\r
201                         uint8_t                   SourcePinID[1]; /**< Pin number in the input jack of each output pin's source data. */\r
202 \r
203                         uint8_t                   JackStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */\r
204                 } ATTR_PACKED USB_MIDI_Descriptor_OutputJack_t;\r
205 \r
206                 /** @brief MIDI class-specific Output Jack Descriptor (USB-IF naming conventions).\r
207                  *\r
208                  *  Type define for an Audio class-specific MIDI OUT jack. This gives information to the host on a MIDI output, either\r
209                  *  a physical output jack, or a logical jack (sending output data internally, or to the host via an endpoint).\r
210                  *\r
211                  *  @see @ref USB_MIDI_Descriptor_OutputJack_t for the version of this type with non-standard nxpUSBlib specific\r
212                  *       element names.\r
213                  *\r
214                  *  @note Regardless of CPU architecture, these values should be stored as little endian.\r
215                  */\r
216                 typedef ATTR_IAR_PACKED struct\r
217                 {\r
218                         uint8_t  bLength; /**< Size of the descriptor, in bytes. */\r
219                         uint8_t  bDescriptorType; /**< Type of the descriptor, either a value in @ref USB_DescriptorTypes_t or a value\r
220                                                    *   given by the specific class.\r
221                                                    */\r
222 \r
223                         uint8_t  bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
224 \r
225                         uint8_t  bJackType; /**< Type of jack, one of the \c JACKTYPE_* mask values. */\r
226                         uint8_t  bJackID; /**< ID value of this jack - must be a unique value within the device. */\r
227 \r
228                         uint8_t  bNrInputPins; /**< Number of output channels within the jack, either physical or logical. */\r
229                         uint8_t  baSourceID[1]; /**< ID of each output pin's source data jack. */\r
230                         uint8_t  baSourcePin[1]; /**< Pin number in the input jack of each output pin's source data. */\r
231 \r
232                         uint8_t  iJack; /**< Index of a string descriptor describing this descriptor within the device. */\r
233                 } ATTR_PACKED USB_MIDI_StdDescriptor_OutputJack_t;\r
234 \r
235                 /** @brief Audio class-specific Jack Endpoint Descriptor (nxpUSBlib naming conventions).\r
236                  *\r
237                  *  Type define for an Audio class-specific extended MIDI jack endpoint descriptor. This contains extra information\r
238                  *  on the usage of MIDI endpoints used to stream MIDI events in and out of the USB Audio device, and follows an Audio\r
239                  *  class-specific extended MIDI endpoint descriptor. See the USB Audio specification for more details.\r
240                  *\r
241                  *  @see @ref USB_MIDI_StdDescriptor_Jack_Endpoint_t for the version of this type with standard element names.\r
242                  *\r
243                  *  @note Regardless of CPU architecture, these values should be stored as little endian.\r
244                  */\r
245                 typedef ATTR_IAR_PACKED struct\r
246                 {\r
247                         USB_Descriptor_Header_t   Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
248                         uint8_t                   Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
249 \r
250                         uint8_t                   TotalEmbeddedJacks; /**< Total number of jacks inside this endpoint. */\r
251                         uint8_t                   AssociatedJackID[1]; /**< IDs of each jack inside the endpoint. */\r
252                 } ATTR_PACKED USB_MIDI_Descriptor_Jack_Endpoint_t;\r
253 \r
254                 /** @brief Audio class-specific Jack Endpoint Descriptor (USB-IF naming conventions).\r
255                  *\r
256                  *  Type define for an Audio class-specific extended MIDI jack endpoint descriptor. This contains extra information\r
257                  *  on the usage of MIDI endpoints used to stream MIDI events in and out of the USB Audio device, and follows an Audio\r
258                  *  class-specific extended MIDI endpoint descriptor. See the USB Audio specification for more details.\r
259                  *\r
260                  *  @see @ref USB_MIDI_Descriptor_Jack_Endpoint_t for the version of this type with non-standard nxpUSBlib specific\r
261                  *       element names.\r
262                  *\r
263                  *  @note Regardless of CPU architecture, these values should be stored as little endian.\r
264                  */\r
265                 typedef ATTR_IAR_PACKED struct\r
266                 {\r
267                         uint8_t  bLength; /**< Size of the descriptor, in bytes. */\r
268                         uint8_t  bDescriptorType; /**< Type of the descriptor, either a value in @ref USB_DescriptorTypes_t or a value\r
269                                                    *   given by the specific class.\r
270                                                    */\r
271 \r
272                         uint8_t  bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
273 \r
274                         uint8_t  bNumEmbMIDIJack; /**< Total number of jacks inside this endpoint. */\r
275                         uint8_t  bAssocJackID[1]; /**< IDs of each jack inside the endpoint. */\r
276                 } ATTR_PACKED USB_MIDI_StdDescriptor_Jack_Endpoint_t;\r
277 \r
278                 /** @brief MIDI Class Driver Event Packet.\r
279                  *\r
280                  *  Type define for a USB MIDI event packet, used to encapsulate sent and received MIDI messages from a USB MIDI interface.\r
281                  *\r
282                  *  @note Regardless of CPU architecture, these values should be stored as little endian.\r
283                  */\r
284                 typedef ATTR_IAR_PACKED struct\r
285                 {\r
286                         unsigned Command     : 4; /**< Upper nibble of the MIDI command being sent or received in the event packet. */\r
287                         unsigned CableNumber : 4; /**< Virtual cable number of the event being sent or received in the given MIDI interface. */\r
288 \r
289                         uint8_t  Data1; /**< First byte of data in the MIDI event. */\r
290                         uint8_t  Data2; /**< Second byte of data in the MIDI event. */\r
291                         uint8_t  Data3; /**< Third byte of data in the MIDI event. */\r
292                 } ATTR_PACKED MIDI_EventPacket_t;\r
293 \r
294         /* Disable C linkage for C++ Compilers: */\r
295                 #if defined(__cplusplus)\r
296                         }\r
297                 #endif\r
298 \r
299 #endif\r
300 \r
301 /** @} */\r
302 \r