ryou sato / Mbed 2 deprecated LPC11U35_CTswitch_relay

Dependencies:   mbed LPC11U35_MCP41HV51-503EST

Committer:
ryousato
Date:
Mon Aug 17 01:01:49 2020 +0000
Revision:
0:df1e1f84ded8
1

Who changed what in which revision?

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