H2M Teststand
/
Pruefprogramm_Motorteststand
Kalibriersoftware Stromwerte
USBMIDI/USBMIDI.h@0:5e35c180ed4a, 2015-11-23 (annotated)
- Committer:
- Racer01014
- Date:
- Mon Nov 23 16:09:54 2015 +0000
- Revision:
- 0:5e35c180ed4a
-
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Racer01014 | 0:5e35c180ed4a | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
Racer01014 | 0:5e35c180ed4a | 2 | * |
Racer01014 | 0:5e35c180ed4a | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
Racer01014 | 0:5e35c180ed4a | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
Racer01014 | 0:5e35c180ed4a | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
Racer01014 | 0:5e35c180ed4a | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
Racer01014 | 0:5e35c180ed4a | 7 | * Software is furnished to do so, subject to the following conditions: |
Racer01014 | 0:5e35c180ed4a | 8 | * |
Racer01014 | 0:5e35c180ed4a | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
Racer01014 | 0:5e35c180ed4a | 10 | * substantial portions of the Software. |
Racer01014 | 0:5e35c180ed4a | 11 | * |
Racer01014 | 0:5e35c180ed4a | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
Racer01014 | 0:5e35c180ed4a | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
Racer01014 | 0:5e35c180ed4a | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
Racer01014 | 0:5e35c180ed4a | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
Racer01014 | 0:5e35c180ed4a | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Racer01014 | 0:5e35c180ed4a | 17 | */ |
Racer01014 | 0:5e35c180ed4a | 18 | |
Racer01014 | 0:5e35c180ed4a | 19 | #ifndef USBMIDI_H |
Racer01014 | 0:5e35c180ed4a | 20 | #define USBMIDI_H |
Racer01014 | 0:5e35c180ed4a | 21 | |
Racer01014 | 0:5e35c180ed4a | 22 | /* These headers are included for child class. */ |
Racer01014 | 0:5e35c180ed4a | 23 | #include "USBEndpoints.h" |
Racer01014 | 0:5e35c180ed4a | 24 | #include "USBDescriptor.h" |
Racer01014 | 0:5e35c180ed4a | 25 | #include "USBDevice_Types.h" |
Racer01014 | 0:5e35c180ed4a | 26 | |
Racer01014 | 0:5e35c180ed4a | 27 | #include "USBDevice.h" |
Racer01014 | 0:5e35c180ed4a | 28 | #include "MIDIMessage.h" |
Racer01014 | 0:5e35c180ed4a | 29 | |
Racer01014 | 0:5e35c180ed4a | 30 | #define DEFAULT_CONFIGURATION (1) |
Racer01014 | 0:5e35c180ed4a | 31 | |
Racer01014 | 0:5e35c180ed4a | 32 | /** |
Racer01014 | 0:5e35c180ed4a | 33 | * USBMIDI example |
Racer01014 | 0:5e35c180ed4a | 34 | * |
Racer01014 | 0:5e35c180ed4a | 35 | * @code |
Racer01014 | 0:5e35c180ed4a | 36 | * #include "mbed.h" |
Racer01014 | 0:5e35c180ed4a | 37 | * #include "USBMIDI.h" |
Racer01014 | 0:5e35c180ed4a | 38 | * |
Racer01014 | 0:5e35c180ed4a | 39 | * USBMIDI midi; |
Racer01014 | 0:5e35c180ed4a | 40 | * |
Racer01014 | 0:5e35c180ed4a | 41 | * int main() { |
Racer01014 | 0:5e35c180ed4a | 42 | * while (1) { |
Racer01014 | 0:5e35c180ed4a | 43 | * for(int i=48; i<83; i++) { // send some messages! |
Racer01014 | 0:5e35c180ed4a | 44 | * midi.write(MIDIMessage::NoteOn(i)); |
Racer01014 | 0:5e35c180ed4a | 45 | * wait(0.25); |
Racer01014 | 0:5e35c180ed4a | 46 | * midi.write(MIDIMessage::NoteOff(i)); |
Racer01014 | 0:5e35c180ed4a | 47 | * wait(0.5); |
Racer01014 | 0:5e35c180ed4a | 48 | * } |
Racer01014 | 0:5e35c180ed4a | 49 | * } |
Racer01014 | 0:5e35c180ed4a | 50 | * } |
Racer01014 | 0:5e35c180ed4a | 51 | * @endcode |
Racer01014 | 0:5e35c180ed4a | 52 | */ |
Racer01014 | 0:5e35c180ed4a | 53 | class USBMIDI: public USBDevice { |
Racer01014 | 0:5e35c180ed4a | 54 | public: |
Racer01014 | 0:5e35c180ed4a | 55 | |
Racer01014 | 0:5e35c180ed4a | 56 | /** |
Racer01014 | 0:5e35c180ed4a | 57 | * Constructor |
Racer01014 | 0:5e35c180ed4a | 58 | * |
Racer01014 | 0:5e35c180ed4a | 59 | * @param vendor_id Your vendor_id |
Racer01014 | 0:5e35c180ed4a | 60 | * @param product_id Your product_id |
Racer01014 | 0:5e35c180ed4a | 61 | * @param product_release Your preoduct_release |
Racer01014 | 0:5e35c180ed4a | 62 | */ |
Racer01014 | 0:5e35c180ed4a | 63 | USBMIDI(uint16_t vendor_id = 0x0700, uint16_t product_id = 0x0101, uint16_t product_release = 0x0001); |
Racer01014 | 0:5e35c180ed4a | 64 | |
Racer01014 | 0:5e35c180ed4a | 65 | /** |
Racer01014 | 0:5e35c180ed4a | 66 | * Send a MIDIMessage |
Racer01014 | 0:5e35c180ed4a | 67 | * |
Racer01014 | 0:5e35c180ed4a | 68 | * @param m The MIDIMessage to send |
Racer01014 | 0:5e35c180ed4a | 69 | */ |
Racer01014 | 0:5e35c180ed4a | 70 | void write(MIDIMessage m); |
Racer01014 | 0:5e35c180ed4a | 71 | |
Racer01014 | 0:5e35c180ed4a | 72 | /** |
Racer01014 | 0:5e35c180ed4a | 73 | * Attach a callback for when a MIDIEvent is received |
Racer01014 | 0:5e35c180ed4a | 74 | * |
Racer01014 | 0:5e35c180ed4a | 75 | * @param fptr function pointer |
Racer01014 | 0:5e35c180ed4a | 76 | */ |
Racer01014 | 0:5e35c180ed4a | 77 | void attach(void (*fptr)(MIDIMessage)); |
Racer01014 | 0:5e35c180ed4a | 78 | |
Racer01014 | 0:5e35c180ed4a | 79 | |
Racer01014 | 0:5e35c180ed4a | 80 | protected: |
Racer01014 | 0:5e35c180ed4a | 81 | virtual bool EP2_OUT_callback(); |
Racer01014 | 0:5e35c180ed4a | 82 | virtual bool USBCallback_setConfiguration(uint8_t configuration); |
Racer01014 | 0:5e35c180ed4a | 83 | /* |
Racer01014 | 0:5e35c180ed4a | 84 | * Get string product descriptor |
Racer01014 | 0:5e35c180ed4a | 85 | * |
Racer01014 | 0:5e35c180ed4a | 86 | * @returns pointer to the string product descriptor |
Racer01014 | 0:5e35c180ed4a | 87 | */ |
Racer01014 | 0:5e35c180ed4a | 88 | virtual uint8_t * stringIproductDesc(); |
Racer01014 | 0:5e35c180ed4a | 89 | |
Racer01014 | 0:5e35c180ed4a | 90 | /* |
Racer01014 | 0:5e35c180ed4a | 91 | * Get string interface descriptor |
Racer01014 | 0:5e35c180ed4a | 92 | * |
Racer01014 | 0:5e35c180ed4a | 93 | * @returns pointer to the string interface descriptor |
Racer01014 | 0:5e35c180ed4a | 94 | */ |
Racer01014 | 0:5e35c180ed4a | 95 | virtual uint8_t * stringIinterfaceDesc(); |
Racer01014 | 0:5e35c180ed4a | 96 | |
Racer01014 | 0:5e35c180ed4a | 97 | /* |
Racer01014 | 0:5e35c180ed4a | 98 | * Get configuration descriptor |
Racer01014 | 0:5e35c180ed4a | 99 | * |
Racer01014 | 0:5e35c180ed4a | 100 | * @returns pointer to the configuration descriptor |
Racer01014 | 0:5e35c180ed4a | 101 | */ |
Racer01014 | 0:5e35c180ed4a | 102 | virtual uint8_t * configurationDesc(); |
Racer01014 | 0:5e35c180ed4a | 103 | |
Racer01014 | 0:5e35c180ed4a | 104 | private: |
Racer01014 | 0:5e35c180ed4a | 105 | void (*midi_evt)(MIDIMessage); |
Racer01014 | 0:5e35c180ed4a | 106 | |
Racer01014 | 0:5e35c180ed4a | 107 | }; |
Racer01014 | 0:5e35c180ed4a | 108 | |
Racer01014 | 0:5e35c180ed4a | 109 | #endif |