Pinscape Controller version 1 fork. This is a fork to allow for ongoing bug fixes to the original controller version, from before the major changes for the expansion board project.

Dependencies:   FastIO FastPWM SimpleDMA mbed

Fork of Pinscape_Controller by Mike R

Committer:
mjr
Date:
Thu Feb 11 18:12:52 2016 +0000
Revision:
52:63f0a9b45f0c
Convert FastAnalogIn and USBDevice libraries to folders

Who changed what in which revision?

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