libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
midi.h
Go to the documentation of this file.
1/** @defgroup usb_audio_defines USB MIDI Type Definitions
2
3@brief <b>Defined Constants and Types for the USB MIDI Type Definitions</b>
4
5@ingroup USB_defines
6
7@version 1.0.0
8
9@author @htmlonly &copy; @endhtmlonly 2014
10Daniel Thompson <daniel@redfelineninja.org.uk>
11
12@date 19 April 2014
13
14LGPL License Terms @ref lgpl_license
15*/
16
17/*
18 * This file is part of the libopencm3 project.
19 *
20 * Copyright (C) 2014 Daniel Thompson <daniel@redfelineninja.org.uk>
21 *
22 * This library is free software: you can redistribute it and/or modify
23 * it under the terms of the GNU Lesser General Public License as published by
24 * the Free Software Foundation, either version 3 of the License, or
25 * (at your option) any later version.
26 *
27 * This library is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 *
32 * You should have received a copy of the GNU Lesser General Public License
33 * along with this library. If not, see <http://www.gnu.org/licenses/>.
34 */
35
36/**@{*/
37
38#ifndef LIBOPENCM3_USB_MIDI_H
39#define LIBOPENCM3_USB_MIDI_H
40
41#include <stdint.h>
42
43/*
44 * Definitions from the USB_MIDI_ or usb_midi_ namespace come from:
45 * "Universal Serial Bus Class Definitions for MIDI Devices, Revision 1.0"
46 */
47
48/* Appendix A.1: MS Class-Specific Interface Descriptor Subtypes */
49#define USB_MIDI_SUBTYPE_MS_DESCRIPTOR_UNDEFINED 0x00
50#define USB_MIDI_SUBTYPE_MS_HEADER 0x01
51#define USB_MIDI_SUBTYPE_MIDI_IN_JACK 0x02
52#define USB_MIDI_SUBTYPE_MIDI_OUT_JACK 0x03
53#define USB_MIDI_SUBTYPE_MIDI_ELEMENT 0x04
54
55/* Appendix A.2: MS Class-Specific Endpoint Descriptor Subtypes */
56#define USB_MIDI_SUBTYPE_DESCRIPTOR_UNDEFINED 0x00
57#define USB_MIDI_SUBTYPE_MS_GENERAL 0x01
58
59/* Appendix A.3: MS MIDI IN and OUT Jack types */
60#define USB_MIDI_JACK_TYPE_UNDEFINED 0x00
61#define USB_MIDI_JACK_TYPE_EMBEDDED 0x01
62#define USB_MIDI_JACK_TYPE_EXTERNAL 0x02
63
64/* Appendix A.5.1 Endpoint Control Selectors */
65#define USB_MIDI_EP_CONTROL_UNDEFINED 0x00
66#define USB_MIDI_ASSOCIATION_CONTROL 0x01
67
68
69/* Table 6-2: Class-Specific MS Interface Header Descriptor */
71 uint8_t bLength;
74 uint16_t bcdMSC;
75 uint16_t wTotalLength;
76} __attribute__((packed));
77
78/* Table 6-3: MIDI IN Jack Descriptor */
80 uint8_t bLength;
83 uint8_t bJackType;
84 uint8_t bJackID;
85 uint8_t iJack;
86} __attribute__((packed));
87
88/* Table 6-4: MIDI OUT Jack Descriptor (head) */
90 uint8_t bLength;
93 uint8_t bJackType;
94 uint8_t bJackID;
95 uint8_t bNrInputPins;
96 /* ... */
97} __attribute__((packed));
98
99/* Table 6.4: MIDI OUT Jack Descriptor (body) */
101 /* ... */
102 uint8_t baSourceID;
103 uint8_t baSourcePin;
104 /* ... */
105} __attribute__((packed));
106
107/* Table 6.4: MIDI OUT Jack Descriptor (tail) */
109 /* ... */
110 uint8_t iJack;
111} __attribute__((packed));
112
113/* Table 6.4: MIDI OUT Jack Descriptor (single)
114 *
115 * This structure is a convenience covering the (normal) case where
116 * there is only one input pin.
117 */
122} __attribute__((packed));
123
124/* Table 6-5: MIDI Element Descriptor (head) */
126 uint8_t bLength;
129 uint8_t bElementID;
131 /* ... */
132} __attribute__((packed));
133
134/* Table 6-5: MIDI Element Descriptor (body) */
136 /* ... */
137 uint8_t baSourceID;
138 uint8_t baSourcePin;
139 /* ... */
140} __attribute__((packed));
141
142/* Table 6-5: MIDI Element Descriptor (tail) */
144 /* ... */
148 uint8_t bElCapsSize;
149 uint16_t bmElementCaps; /* host cannot assume this is 16-bit but device
150 can (since highest defined bitmap value in
151 v1.0 is bit 11) */
152 uint8_t iElement;
153} __attribute__((packed));
154
155/* Table 6-5: MIDI Element Descriptor (single)
156 *
157 * This structure is a convenience covering the (common) case where
158 * there is only one input pin.
159 */
164} __attribute__((packed));
165
166/* Table 6-7: Class-specific MS Bulk Data Endpoint Descriptor (head) */
168 uint8_t bLength;
172} __attribute__((packed));
173
174/* Table 6-7: Class-specific MS Bulk Data Endpoint Descriptor (body) */
177} __attribute__((packed));
178
179/* Table 6.7: Class-specific MS Bulk Data Endpoint Descriptor (single)
180 *
181 * This structure is a convenience covering the (normal) case where
182 * there is only one input pin.
183 */
187} __attribute__((packed));
188
189#endif
190
191/**@}*/
192
struct usb_midi_element_descriptor_tail tail
Definition: midi.h:163
struct usb_midi_element_descriptor_head head
Definition: midi.h:161
struct usb_midi_element_descriptor_body source[1]
Definition: midi.h:162
struct usb_midi_endpoint_descriptor_head head
Definition: midi.h:185
struct usb_midi_endpoint_descriptor_body jack[1]
Definition: midi.h:186
uint8_t bDescriptorType
Definition: midi.h:72
uint8_t bDescriptorSubtype
Definition: midi.h:73
uint16_t wTotalLength
Definition: midi.h:75
uint8_t bDescriptorSubtype
Definition: midi.h:82
struct usb_midi_out_jack_descriptor_head head
Definition: midi.h:119
struct usb_midi_out_jack_descriptor_tail tail
Definition: midi.h:121
struct usb_midi_out_jack_descriptor_body source[1]
Definition: midi.h:120