My Fork of F401RE-USBHost. Add USBHostMIDI functions (originaled by Kaoru Shoji http://mbed.org/users/kshoji/code/USBHostMIDI/)

Dependencies:   FATFileSystem

Dependents:   F401RE-USBHostMIDI_RecieveExample

Fork of F401RE-USBHost by Norimasa Okamoto

Files at this revision

API Documentation at this revision

Comitter:
hsgw
Date:
Mon Oct 13 19:33:40 2014 +0000
Parent:
26:077ab26227c6
Commit message:
Fix freeze bug on F401RE.; callback functions are initialized by dummy functions.

Changed in this revision

USBHostMIDI/USBHostMIDI.cpp Show annotated file Show diff for this revision Revisions of this file
USBHostMIDI/USBHostMIDI.h Show annotated file Show diff for this revision Revisions of this file
--- a/USBHostMIDI/USBHostMIDI.cpp	Thu Sep 18 12:32:33 2014 +0000
+++ b/USBHostMIDI/USBHostMIDI.cpp	Mon Oct 13 19:33:40 2014 +0000
@@ -42,6 +42,23 @@
     midi_intf = -1;
     midi_device_found = false;
     sysExBufferPos = 0;
+    
+    // init callback functions
+    
+    miscellaneousFunctionCode = &callbackDummy3Bytes;
+    cableEvent = callbackDummy3Bytes;
+    systemCommonTwoBytes = &callbackDummy2Bytes;
+    systemCommonThreeBytes = &callbackDummy3Bytes;
+    systemExclusive = &callbackDummysystemExclusive;
+    noteOff = &callbackDummy3Bytes;
+    noteOn = &callbackDummy3Bytes;
+    polyKeyPress = &callbackDummy3Bytes;
+    controlChange = &callbackDummy3Bytes;
+    programChange = &callbackDummy2Bytes;
+    channelPressure = &callbackDummy2Bytes;
+    pitchBend = &callbackDummypitchBend;
+    singleByte = &callbackDummysingleByte;
+    
 }
 
 bool USBHostMIDI::connected()
@@ -333,6 +350,10 @@
     return sendMidiBuffer(15, data, 0, 0);
 }
 
+void callback_dummy(uint8_t firstArg, ...){
+    USB_DBG("Not attached command comming! %d\n", firstArg);
+}
+
 /*virtual*/ void USBHostMIDI::setVidPid(uint16_t vid, uint16_t pid)
 {
     // we don't check VID/PID for this driver
--- a/USBHostMIDI/USBHostMIDI.h	Thu Sep 18 12:32:33 2014 +0000
+++ b/USBHostMIDI/USBHostMIDI.h	Mon Oct 13 19:33:40 2014 +0000
@@ -347,6 +347,27 @@
     void (*singleByte)(uint8_t);
 
     bool sendMidiBuffer(uint8_t data0, uint8_t data1, uint8_t data2, uint8_t data3);
+    
+    // dummy callback function
+    static void callbackDummysingleByte(uint8_t a) {
+        USB_INFO("Not attached command comming! First byte %d\n", a);
+        return;
+    }
+    
+    static void callbackDummy2Bytes(uint8_t a, uint8_t b){
+        callbackDummysingleByte(a);
+    }
+    
+    static void callbackDummy3Bytes(uint8_t a, uint8_t b, uint8_t c){
+        callbackDummysingleByte(a);
+    }
+    
+    static void callbackDummysystemExclusive(uint8_t *a, uint16_t b, bool c){
+        callbackDummysingleByte(a[0]);
+    }
+    static void callbackDummypitchBend(uint8_t a, uint16_t b){
+        callbackDummysingleByte(a);
+    }
 
     int midi_intf;
     bool midi_device_found;