Lucas Lim / Mbed 2 deprecated HSP_Temperature_Barometer_CS3237

Dependencies:   mbed

Committer:
lucaslwl
Date:
Mon Aug 26 08:11:41 2019 +0000
Revision:
22:5c07298d3383
add library folder

Who changed what in which revision?

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