Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of USBDevice by
USBMIDI.h
00001 /* Copyright (c) 2010-2011 mbed.org, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without 00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish, 00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 00007 * Software is furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 00019 #ifndef USBMIDI_H 00020 #define USBMIDI_H 00021 00022 /* These headers are included for child class. */ 00023 #include "USBDevice/USBDevice/USBEndpoints.h" 00024 #include "USBDevice/USBDevice/USBDescriptor.h" 00025 #include "USBDevice/USBDevice/USBDevice_Types.h" 00026 00027 #include "USBDevice/USBDevice/USBDevice.h" 00028 #include "MIDIMessage.h" 00029 00030 #define DEFAULT_CONFIGURATION (1) 00031 00032 /** 00033 * USBMIDI example 00034 * 00035 * @code 00036 * #include "mbed.h" 00037 * #include "USBMIDI.h" 00038 * 00039 * USBMIDI midi; 00040 * 00041 * int main() { 00042 * while (1) { 00043 * for(int i=48; i<83; i++) { // send some messages! 00044 * midi.write(MIDIMessage::NoteOn(i)); 00045 * wait(0.25); 00046 * midi.write(MIDIMessage::NoteOff(i)); 00047 * wait(0.5); 00048 * } 00049 * } 00050 * } 00051 * @endcode 00052 */ 00053 class USBMIDI: public USBDevice 00054 { 00055 public: 00056 00057 /** 00058 * Constructor 00059 * 00060 * @param vendor_id Your vendor_id 00061 * @param product_id Your product_id 00062 * @param product_release Your preoduct_release 00063 */ 00064 USBMIDI( uint16_t vendor_id = 0x0700, uint16_t product_id = 0x0101, uint16_t product_release = 0x0001 ); 00065 00066 /** 00067 * Send a MIDIMessage 00068 * 00069 * @param m The MIDIMessage to send 00070 */ 00071 void write( MIDIMessage m ); 00072 00073 /** 00074 * Attach a callback for when a MIDIEvent is received 00075 * 00076 * @param fptr function pointer 00077 */ 00078 void attach( void ( *fptr )( MIDIMessage ) ); 00079 00080 00081 protected: 00082 virtual bool EP2_OUT_callback(); 00083 virtual bool USBCallback_setConfiguration( uint8_t configuration ); 00084 /* 00085 * Get string product descriptor 00086 * 00087 * @returns pointer to the string product descriptor 00088 */ 00089 virtual uint8_t *stringIproductDesc(); 00090 00091 /* 00092 * Get string interface descriptor 00093 * 00094 * @returns pointer to the string interface descriptor 00095 */ 00096 virtual uint8_t *stringIinterfaceDesc(); 00097 00098 /* 00099 * Get configuration descriptor 00100 * 00101 * @returns pointer to the configuration descriptor 00102 */ 00103 virtual uint8_t *configurationDesc(); 00104 00105 private: 00106 void ( *midi_evt )( MIDIMessage ); 00107 00108 }; 00109 00110 #endif 00111
Generated on Sat Jul 16 2022 03:17:41 by
1.7.2
