Base station firmware

Committer:
Perijah
Date:
Tue May 24 13:16:55 2016 +0000
Revision:
0:ecc3925d3f8c
Base station firmware

Who changed what in which revision?

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