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.
USBDevice/USBMIDI/.svn/text-base/USB_MIDI.h.svn-base@0:505207de8566, 2011-11-29 (annotated)
- Committer:
- znuh
- Date:
- Tue Nov 29 21:26:20 2011 +0000
- Revision:
- 0:505207de8566
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| znuh | 0:505207de8566 | 1 | /* USB_MIDI.h */ |
| znuh | 0:505207de8566 | 2 | /* MIDI device example */ |
| znuh | 0:505207de8566 | 3 | /* Copyright (c) 2011 ARM Limited. All rights reserved. */ |
| znuh | 0:505207de8566 | 4 | |
| znuh | 0:505207de8566 | 5 | #ifndef USB_MIDI_H |
| znuh | 0:505207de8566 | 6 | #define USB_MIDI_H |
| znuh | 0:505207de8566 | 7 | |
| znuh | 0:505207de8566 | 8 | /* These headers are included for child class. */ |
| znuh | 0:505207de8566 | 9 | #include "USBEndpoints.h" |
| znuh | 0:505207de8566 | 10 | #include "USBDescriptor.h" |
| znuh | 0:505207de8566 | 11 | #include "USBDevice_Types.h" |
| znuh | 0:505207de8566 | 12 | |
| znuh | 0:505207de8566 | 13 | #include "USBDevice.h" |
| znuh | 0:505207de8566 | 14 | #include "MIDIMessage.h" |
| znuh | 0:505207de8566 | 15 | |
| znuh | 0:505207de8566 | 16 | #define DEFAULT_CONFIGURATION (1) |
| znuh | 0:505207de8566 | 17 | |
| znuh | 0:505207de8566 | 18 | |
| znuh | 0:505207de8566 | 19 | class USB_MIDI: public USBDevice { |
| znuh | 0:505207de8566 | 20 | public: |
| znuh | 0:505207de8566 | 21 | |
| znuh | 0:505207de8566 | 22 | /** |
| znuh | 0:505207de8566 | 23 | * Constructor |
| znuh | 0:505207de8566 | 24 | * |
| znuh | 0:505207de8566 | 25 | * @param vendor_id Your vendor_id |
| znuh | 0:505207de8566 | 26 | * @param product_id Your product_id |
| znuh | 0:505207de8566 | 27 | * @param product_release Your preoduct_release |
| znuh | 0:505207de8566 | 28 | */ |
| znuh | 0:505207de8566 | 29 | USB_MIDI(uint16_t vendor_id = 0x0768, uint16_t product_id = 0x0100, uint16_t product_release = 0x0001); |
| znuh | 0:505207de8566 | 30 | |
| znuh | 0:505207de8566 | 31 | virtual bool USBCallback_setConfiguration(uint8_t configuration); |
| znuh | 0:505207de8566 | 32 | |
| znuh | 0:505207de8566 | 33 | /** |
| znuh | 0:505207de8566 | 34 | * Get string product descriptor |
| znuh | 0:505207de8566 | 35 | * |
| znuh | 0:505207de8566 | 36 | * @returns pointer to the string product descriptor |
| znuh | 0:505207de8566 | 37 | */ |
| znuh | 0:505207de8566 | 38 | virtual uint8_t * stringIproductDesc(); |
| znuh | 0:505207de8566 | 39 | |
| znuh | 0:505207de8566 | 40 | /** |
| znuh | 0:505207de8566 | 41 | * Get string interface descriptor |
| znuh | 0:505207de8566 | 42 | * |
| znuh | 0:505207de8566 | 43 | * @returns pointer to the string interface descriptor |
| znuh | 0:505207de8566 | 44 | */ |
| znuh | 0:505207de8566 | 45 | virtual uint8_t * stringIinterfaceDesc(); |
| znuh | 0:505207de8566 | 46 | |
| znuh | 0:505207de8566 | 47 | /** |
| znuh | 0:505207de8566 | 48 | * Get configuration descriptor |
| znuh | 0:505207de8566 | 49 | * |
| znuh | 0:505207de8566 | 50 | * @returns pointer to the configuration descriptor |
| znuh | 0:505207de8566 | 51 | */ |
| znuh | 0:505207de8566 | 52 | virtual uint8_t * configurationDesc(); |
| znuh | 0:505207de8566 | 53 | |
| znuh | 0:505207de8566 | 54 | /** |
| znuh | 0:505207de8566 | 55 | * Send a MIDIMessage |
| znuh | 0:505207de8566 | 56 | * |
| znuh | 0:505207de8566 | 57 | * @param m The MIDIMessage to send |
| znuh | 0:505207de8566 | 58 | */ |
| znuh | 0:505207de8566 | 59 | void write(MIDIMessage m); |
| znuh | 0:505207de8566 | 60 | |
| znuh | 0:505207de8566 | 61 | /** |
| znuh | 0:505207de8566 | 62 | * Attach a callback for when a MIDIEvent is received |
| znuh | 0:505207de8566 | 63 | * |
| znuh | 0:505207de8566 | 64 | * @param fptr function pointer |
| znuh | 0:505207de8566 | 65 | */ |
| znuh | 0:505207de8566 | 66 | void attach(void (*fptr)(MIDIMessage)); |
| znuh | 0:505207de8566 | 67 | |
| znuh | 0:505207de8566 | 68 | protected: |
| znuh | 0:505207de8566 | 69 | virtual bool EPBULK_OUT_callback(); |
| znuh | 0:505207de8566 | 70 | |
| znuh | 0:505207de8566 | 71 | private: |
| znuh | 0:505207de8566 | 72 | void (*midi_evt)(MIDIMessage); |
| znuh | 0:505207de8566 | 73 | |
| znuh | 0:505207de8566 | 74 | }; |
| znuh | 0:505207de8566 | 75 | |
| znuh | 0:505207de8566 | 76 | #endif |
| znuh | 0:505207de8566 | 77 |