blablabla

Dependencies:   MAG3110 MMA8451Q SLCD- TSI USBDevice mbed

Committer:
Osator
Date:
Wed Apr 16 12:20:00 2014 +0000
Revision:
0:339b7abfa147
blablabla

Who changed what in which revision?

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