USBMSD SD card Hello World for Mbed platforms

Dependencies:   mbed USBMSD_SD USBDevice

Committer:
samux
Date:
Fri Nov 11 15:22:53 2011 +0000
Revision:
2:27a7e7f8d399
we have 2MB with the sdcard!!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 2:27a7e7f8d399 1 /* USB_MIDI.h */
samux 2:27a7e7f8d399 2 /* MIDI device example */
samux 2:27a7e7f8d399 3 /* Copyright (c) 2011 ARM Limited. All rights reserved. */
samux 2:27a7e7f8d399 4
samux 2:27a7e7f8d399 5 #ifndef USBMIDI_H
samux 2:27a7e7f8d399 6 #define USBMIDI_H
samux 2:27a7e7f8d399 7
samux 2:27a7e7f8d399 8 /* These headers are included for child class. */
samux 2:27a7e7f8d399 9 #include "USBEndpoints.h"
samux 2:27a7e7f8d399 10 #include "USBDescriptor.h"
samux 2:27a7e7f8d399 11 #include "USBDevice_Types.h"
samux 2:27a7e7f8d399 12
samux 2:27a7e7f8d399 13 #include "USBDevice.h"
samux 2:27a7e7f8d399 14 #include "MIDIMessage.h"
samux 2:27a7e7f8d399 15
samux 2:27a7e7f8d399 16 #define DEFAULT_CONFIGURATION (1)
samux 2:27a7e7f8d399 17
samux 2:27a7e7f8d399 18 /**
samux 2:27a7e7f8d399 19 * USBMIDI example
samux 2:27a7e7f8d399 20 *
samux 2:27a7e7f8d399 21 * @code
samux 2:27a7e7f8d399 22 * #include "mbed.h"
samux 2:27a7e7f8d399 23 * #include "USBMIDI.h"
samux 2:27a7e7f8d399 24 *
samux 2:27a7e7f8d399 25 * USBMIDI midi;
samux 2:27a7e7f8d399 26 *
samux 2:27a7e7f8d399 27 * int main() {
samux 2:27a7e7f8d399 28 * while (1) {
samux 2:27a7e7f8d399 29 * for(int i=48; i<83; i++) { // send some messages!
samux 2:27a7e7f8d399 30 * midi.write(MIDIMessage::NoteOn(i));
samux 2:27a7e7f8d399 31 * wait(0.25);
samux 2:27a7e7f8d399 32 * midi.write(MIDIMessage::NoteOff(i));
samux 2:27a7e7f8d399 33 * wait(0.5);
samux 2:27a7e7f8d399 34 * }
samux 2:27a7e7f8d399 35 * }
samux 2:27a7e7f8d399 36 * }
samux 2:27a7e7f8d399 37 * @endcode
samux 2:27a7e7f8d399 38 */
samux 2:27a7e7f8d399 39 class USBMIDI: public USBDevice {
samux 2:27a7e7f8d399 40 public:
samux 2:27a7e7f8d399 41
samux 2:27a7e7f8d399 42 /**
samux 2:27a7e7f8d399 43 * Constructor
samux 2:27a7e7f8d399 44 *
samux 2:27a7e7f8d399 45 * @param vendor_id Your vendor_id
samux 2:27a7e7f8d399 46 * @param product_id Your product_id
samux 2:27a7e7f8d399 47 * @param product_release Your preoduct_release
samux 2:27a7e7f8d399 48 */
samux 2:27a7e7f8d399 49 USBMIDI(uint16_t vendor_id = 0x0700, uint16_t product_id = 0x0101, uint16_t product_release = 0x0001);
samux 2:27a7e7f8d399 50
samux 2:27a7e7f8d399 51 /**
samux 2:27a7e7f8d399 52 * Send a MIDIMessage
samux 2:27a7e7f8d399 53 *
samux 2:27a7e7f8d399 54 * @param m The MIDIMessage to send
samux 2:27a7e7f8d399 55 */
samux 2:27a7e7f8d399 56 void write(MIDIMessage m);
samux 2:27a7e7f8d399 57
samux 2:27a7e7f8d399 58 /**
samux 2:27a7e7f8d399 59 * Attach a callback for when a MIDIEvent is received
samux 2:27a7e7f8d399 60 *
samux 2:27a7e7f8d399 61 * @param fptr function pointer
samux 2:27a7e7f8d399 62 */
samux 2:27a7e7f8d399 63 void attach(void (*fptr)(MIDIMessage));
samux 2:27a7e7f8d399 64
samux 2:27a7e7f8d399 65
samux 2:27a7e7f8d399 66 protected:
samux 2:27a7e7f8d399 67 virtual bool EP2_OUT_callback();
samux 2:27a7e7f8d399 68 virtual bool USBCallback_setConfiguration(uint8_t configuration);
samux 2:27a7e7f8d399 69 /*
samux 2:27a7e7f8d399 70 * Get string product descriptor
samux 2:27a7e7f8d399 71 *
samux 2:27a7e7f8d399 72 * @returns pointer to the string product descriptor
samux 2:27a7e7f8d399 73 */
samux 2:27a7e7f8d399 74 virtual uint8_t * stringIproductDesc();
samux 2:27a7e7f8d399 75
samux 2:27a7e7f8d399 76 /*
samux 2:27a7e7f8d399 77 * Get string interface descriptor
samux 2:27a7e7f8d399 78 *
samux 2:27a7e7f8d399 79 * @returns pointer to the string interface descriptor
samux 2:27a7e7f8d399 80 */
samux 2:27a7e7f8d399 81 virtual uint8_t * stringIinterfaceDesc();
samux 2:27a7e7f8d399 82
samux 2:27a7e7f8d399 83 /*
samux 2:27a7e7f8d399 84 * Get configuration descriptor
samux 2:27a7e7f8d399 85 *
samux 2:27a7e7f8d399 86 * @returns pointer to the configuration descriptor
samux 2:27a7e7f8d399 87 */
samux 2:27a7e7f8d399 88 virtual uint8_t * configurationDesc();
samux 2:27a7e7f8d399 89
samux 2:27a7e7f8d399 90 private:
samux 2:27a7e7f8d399 91 void (*midi_evt)(MIDIMessage);
samux 2:27a7e7f8d399 92
samux 2:27a7e7f8d399 93 };
samux 2:27a7e7f8d399 94
samux 2:27a7e7f8d399 95 #endif
samux 2:27a7e7f8d399 96