SD card interface

Committer:
lharoon
Date:
Mon Oct 08 11:14:07 2012 +0000
Revision:
0:22612ae617a0
1st edition

Who changed what in which revision?

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