LPC11U35 ADC Tick & USBSerial

Dependencies:   mbed

Dependents:   SmallDoseMeter_SingleCH_AE_lpc11u35_V1_00

Committer:
H_Tsunemoto
Date:
Mon Feb 19 09:09:52 2018 +0000
Revision:
1:b1a3be5f48ab
Parent:
0:871ab6846b18
test

Who changed what in which revision?

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