]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/USBDevice/USBMIDI/USBMIDI.h
1 /* Copyright (c) 2010-2011 mbed.org, MIT License
3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
4 * and associated documentation files (the "Software"), to deal in the Software without
5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7 * Software is furnished to do so, subject to the following conditions:
9 * The above copyright notice and this permission notice shall be included in all copies or
10 * substantial portions of the Software.
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 /* These headers are included for child class. */
23 #include "USBEndpoints.h"
24 #include "USBDescriptor.h"
25 #include "USBDevice_Types.h"
27 #include "USBDevice.h"
28 #include "MIDIMessage.h"
30 #define DEFAULT_CONFIGURATION (1)
37 * #include "USBMIDI.h"
43 * for(int i=48; i<83; i++) { // send some messages!
44 * midi.write(MIDIMessage::NoteOn(i));
46 * midi.write(MIDIMessage::NoteOff(i));
53 class USBMIDI
: public USBDevice
{
59 * @param vendor_id Your vendor_id
60 * @param product_id Your product_id
61 * @param product_release Your preoduct_release
63 USBMIDI(uint16_t vendor_id
= 0x0700, uint16_t product_id
= 0x0101, uint16_t product_release
= 0x0001);
68 * @param m The MIDIMessage to send
70 void write(MIDIMessage m
);
73 * Attach a callback for when a MIDIEvent is received
75 * @param fptr function pointer
77 void attach(void (*fptr
)(MIDIMessage
));
81 virtual bool EPBULK_OUT_callback();
82 virtual bool USBCallback_setConfiguration(uint8_t configuration
);
84 * Get string product descriptor
86 * @returns pointer to the string product descriptor
88 virtual uint8_t * stringIproductDesc();
91 * Get string interface descriptor
93 * @returns pointer to the string interface descriptor
95 virtual uint8_t * stringIinterfaceDesc();
98 * Get configuration descriptor
100 * @returns pointer to the configuration descriptor
102 virtual uint8_t * configurationDesc();
105 uint8_t data
[MAX_MIDI_MESSAGE_SIZE
+1];
109 void (*midi_evt
)(MIDIMessage
);