Added TARGET_DISCO_F469NI in USBHOST\USBHost\TARGET_STM\USBHALHost_STM_TARGET.h

Dependents:   DISCO-F469NI_USB_Disk STM32F4xx_USB_Memory

Fork of USBHOST by ST

Committer:
kenjiArai
Date:
Sat Jan 04 23:30:59 2020 +0000
Revision:
8:3e7a33f81048
Parent:
1:ab240722d7ef
updated for STM32F4xx

Who changed what in which revision?

UserRevisionLine numberNew contents of line
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 1 /* Copyright (c) 2014 mbed.org, MIT License
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 2 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 4 * and associated documentation files (the "Software"), to deal in the Software without
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 7 * Software is furnished to do so, subject to the following conditions:
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 8 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 9 * The above copyright notice and this permission notice shall be included in all copies or
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 10 * substantial portions of the Software.
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 11 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 17 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 18
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 19 #ifndef USBHOSTMIDI_H
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 20 #define USBHOSTMIDI_H
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 21
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 22 #include "USBHostConf.h"
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 23
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 24 #if USBHOST_MIDI
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 25
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 26 #include "USBHost.h"
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 27
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 28 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 29 * A class to communicate a USB MIDI device
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 30 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 31 class USBHostMIDI : public IUSBEnumerator {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 32 public:
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 33 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 34 * Constructor
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 35 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 36 USBHostMIDI();
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 37
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 38 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 39 * Check if a USB MIDI device is connected
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 40 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 41 * @returns true if a midi device is connected
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 42 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 43 bool connected();
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 44
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 45 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 46 * Try to connect a midi device
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 47 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 48 * @return true if connection was successful
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 49 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 50 bool connect();
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 51
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 52 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 53 * Attach a callback called when miscellaneous function code is received
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 54 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 55 * @param ptr function pointer
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 56 * prototype: void onMiscellaneousFunctionCode(uint8_t data1, uint8_t data2, uint8_t data3);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 57 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 58 inline void attachMiscellaneousFunctionCode(void (*fn)(uint8_t, uint8_t, uint8_t)) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 59 miscellaneousFunctionCode = fn;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 60 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 61
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 62 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 63 * Attach a callback called when cable event is received
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 64 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 65 * @param ptr function pointer
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 66 * prototype: void onCableEvent(uint8_t data1, uint8_t data2, uint8_t data3);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 67 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 68 inline void attachCableEvent(void (*fn)(uint8_t, uint8_t, uint8_t)) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 69 cableEvent = fn;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 70 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 71
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 72 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 73 * Attach a callback called when system exclusive is received
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 74 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 75 * @param ptr function pointer
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 76 * prototype: void onSystemCommonTwoBytes(uint8_t data1, uint8_t data2);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 77 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 78 inline void attachSystemCommonTwoBytes(void (*fn)(uint8_t, uint8_t)) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 79 systemCommonTwoBytes = fn;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 80 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 81
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 82 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 83 * Attach a callback called when system exclusive is received
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 84 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 85 * @param ptr function pointer
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 86 * prototype: void onSystemCommonThreeBytes(uint8_t data1, uint8_t data2, uint8_t data3);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 87 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 88 inline void attachSystemCommonThreeBytes(void (*fn)(uint8_t, uint8_t, uint8_t)) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 89 systemCommonThreeBytes = fn;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 90 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 91
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 92 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 93 * Attach a callback called when system exclusive is received
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 94 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 95 * @param ptr function pointer
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 96 * prototype: void onSystemExclusive(uint8_t *data, uint16_t length, bool hasNextData);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 97 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 98 inline void attachSystemExclusive(void (*fn)(uint8_t *, uint16_t, bool)) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 99 systemExclusive = fn;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 100 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 101
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 102 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 103 * Attach a callback called when note on is received
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 104 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 105 * @param ptr function pointer
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 106 * prototype: void onNoteOn(uint8_t channel, uint8_t note, uint8_t velocity);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 107 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 108 inline void attachNoteOn(void (*fn)(uint8_t, uint8_t, uint8_t)) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 109 noteOn = fn;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 110 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 111
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 112 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 113 * Attach a callback called when note off is received
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 114 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 115 * @param ptr function pointer
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 116 * prototype: void onNoteOff(uint8_t channel, uint8_t note, uint8_t velocity);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 117 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 118 inline void attachNoteOff(void (*fn)(uint8_t, uint8_t, uint8_t)) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 119 noteOff = fn;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 120 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 121
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 122 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 123 * Attach a callback called when poly keypress is received
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 124 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 125 * @param ptr function pointer
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 126 * prototype: void onPolyKeyPress(uint8_t channel, uint8_t note, uint8_t pressure);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 127 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 128 inline void attachPolyKeyPress(void (*fn)(uint8_t, uint8_t, uint8_t)) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 129 polyKeyPress = fn;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 130 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 131
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 132 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 133 * Attach a callback called when control change is received
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 134 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 135 * @param ptr function pointer
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 136 * prototype: void onControlChange(uint8_t channel, uint8_t key, uint8_t value);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 137 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 138 inline void attachControlChange(void (*fn)(uint8_t, uint8_t, uint8_t)) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 139 controlChange = fn;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 140 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 141
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 142 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 143 * Attach a callback called when program change is received
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 144 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 145 * @param ptr function pointer
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 146 * prototype: void onProgramChange(uint8_t channel, uint8_t program);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 147 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 148 inline void attachProgramChange(void (*fn)(uint8_t, uint8_t)) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 149 programChange = fn;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 150 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 151
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 152 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 153 * Attach a callback called when channel pressure is received
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 154 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 155 * @param ptr function pointer
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 156 * prototype: void onChannelPressure(uint8_t channel, uint8_t pressure);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 157 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 158 inline void attachChannelPressure(void (*fn)(uint8_t, uint8_t)) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 159 channelPressure = fn;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 160 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 161
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 162 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 163 * Attach a callback called when pitch bend is received
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 164 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 165 * @param ptr function pointer
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 166 * prototype: void onPitchBend(uint8_t channel, uint16_t value);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 167 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 168 inline void attachPitchBend(void (*fn)(uint8_t, uint16_t)) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 169 pitchBend = fn;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 170 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 171
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 172 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 173 * Attach a callback called when single byte is received
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 174 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 175 * @param ptr function pointer
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 176 * prototype: void onSingleByte(uint8_t value);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 177 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 178 inline void attachSingleByte(void (*fn)(uint8_t)) {
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 179 singleByte = fn;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 180 }
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 181
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 182 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 183 * Send a cable event with 3 bytes event
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 184 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 185 * @param data1 0-255
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 186 * @param data2 0-255
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 187 * @param data3 0-255
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 188 * @return true if message sent successfully
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 189 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 190 bool sendMiscellaneousFunctionCode(uint8_t data1, uint8_t data2, uint8_t data3);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 191
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 192 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 193 * Send a cable event with 3 bytes event
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 194 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 195 * @param data1 0-255
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 196 * @param data2 0-255
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 197 * @param data3 0-255
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 198 * @return true if message sent successfully
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 199 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 200 bool sendCableEvent(uint8_t data1, uint8_t data2, uint8_t data3);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 201
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 202 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 203 * Send a system common message with 2 bytes event
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 204 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 205 * @param data1 0-255
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 206 * @param data2 0-255
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 207 * @return true if message sent successfully
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 208 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 209 bool sendSystemCommmonTwoBytes(uint8_t data1, uint8_t data2);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 210
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 211 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 212 * Send a system common message with 3 bytes event
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 213 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 214 * @param data1 0-255
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 215 * @param data2 0-255
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 216 * @param data3 0-255
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 217 * @return true if message sent successfully
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 218 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 219 bool sendSystemCommmonThreeBytes(uint8_t data1, uint8_t data2, uint8_t data3);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 220
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 221 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 222 * Send a system exclusive event
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 223 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 224 * @param buffer, starts with 0xF0, and end with 0xf7
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 225 * @param length
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 226 * @return true if message sent successfully
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 227 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 228 bool sendSystemExclusive(uint8_t *buffer, int length);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 229
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 230 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 231 * Send a note off event
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 232 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 233 * @param channel 0-15
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 234 * @param note 0-127
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 235 * @param velocity 0-127
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 236 * @return true if message sent successfully
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 237 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 238 bool sendNoteOff(uint8_t channel, uint8_t note, uint8_t velocity);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 239
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 240 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 241 * Send a note on event
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 242 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 243 * @param channel 0-15
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 244 * @param note 0-127
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 245 * @param velocity 0-127 (0 means note off)
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 246 * @return true if message sent successfully
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 247 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 248 bool sendNoteOn(uint8_t channel, uint8_t note, uint8_t velocity);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 249
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 250 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 251 * Send a poly keypress event
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 252 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 253 * @param channel 0-15
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 254 * @param note 0-127
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 255 * @param pressure 0-127
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 256 * @return true if message sent successfully
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 257 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 258 bool sendPolyKeyPress(uint8_t channel, uint8_t note, uint8_t pressure);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 259
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 260 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 261 * Send a control change event
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 262 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 263 * @param channel 0-15
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 264 * @param key 0-127
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 265 * @param value 0-127
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 266 * @return true if message sent successfully
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 267 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 268 bool sendControlChange(uint8_t channel, uint8_t key, uint8_t value);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 269
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 270 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 271 * Send a program change event
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 272 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 273 * @param channel 0-15
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 274 * @param program 0-127
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 275 * @return true if message sent successfully
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 276 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 277 bool sendProgramChange(uint8_t channel, uint8_t program);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 278
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 279 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 280 * Send a channel pressure event
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 281 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 282 * @param channel 0-15
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 283 * @param pressure 0-127
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 284 * @return true if message sent successfully
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 285 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 286 bool sendChannelPressure(uint8_t channel, uint8_t pressure);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 287
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 288 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 289 * Send a control change event
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 290 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 291 * @param channel 0-15
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 292 * @param key 0(lower)-8191(center)-16383(higher)
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 293 * @return true if message sent successfully
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 294 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 295 bool sendPitchBend(uint8_t channel, uint16_t value);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 296
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 297 /**
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 298 * Send a single byte event
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 299 *
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 300 * @param data 0-255
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 301 * @return true if message sent successfully
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 302 */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 303 bool sendSingleByte(uint8_t data);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 304
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 305 protected:
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 306 //From IUSBEnumerator
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 307 virtual void setVidPid(uint16_t vid, uint16_t pid);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 308 virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 309 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 310
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 311 private:
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 312 USBHost * host;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 313 USBDeviceConnected * dev;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 314 USBEndpoint * bulk_in;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 315 USBEndpoint * bulk_out;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 316 uint32_t size_bulk_in;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 317 uint32_t size_bulk_out;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 318
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 319 bool dev_connected;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 320
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 321 void init();
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 322
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 323 uint8_t buf[64];
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 324
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 325 void rxHandler();
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 326
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 327 uint16_t sysExBufferPos;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 328 uint8_t sysExBuffer[64];
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 329
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 330 void (*miscellaneousFunctionCode)(uint8_t, uint8_t, uint8_t);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 331 void (*cableEvent)(uint8_t, uint8_t, uint8_t);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 332 void (*systemCommonTwoBytes)(uint8_t, uint8_t);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 333 void (*systemCommonThreeBytes)(uint8_t, uint8_t, uint8_t);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 334 void (*systemExclusive)(uint8_t *, uint16_t, bool);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 335 void (*noteOff)(uint8_t, uint8_t, uint8_t);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 336 void (*noteOn)(uint8_t, uint8_t, uint8_t);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 337 void (*polyKeyPress)(uint8_t, uint8_t, uint8_t);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 338 void (*controlChange)(uint8_t, uint8_t, uint8_t);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 339 void (*programChange)(uint8_t, uint8_t);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 340 void (*channelPressure)(uint8_t, uint8_t);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 341 void (*pitchBend)(uint8_t, uint16_t);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 342 void (*singleByte)(uint8_t);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 343
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 344 bool sendMidiBuffer(uint8_t data0, uint8_t data1, uint8_t data2, uint8_t data3);
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 345
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 346 int midi_intf;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 347 bool midi_device_found;
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 348
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 349 };
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 350
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 351 #endif /* USBHOST_MIDI */
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 352
frq08711@LMECWL0871.LME.ST.COM 1:ab240722d7ef 353 #endif /* USBHOSTMIDI_H */