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

Revision:
26:077ab26227c6
Parent:
24:5281ea9f6e68
Child:
27:23fa4e04b1db
--- a/USBHostMIDI/USBHostMIDI.cpp	Thu Sep 18 11:34:43 2014 +0000
+++ b/USBHostMIDI/USBHostMIDI.cpp	Thu Sep 18 12:32:33 2014 +0000
@@ -91,7 +91,8 @@
 void USBHostMIDI::rxHandler() {
     uint8_t *midi;
     if (bulk_in) {
-        int length = bulk_in->getLengthTransferred();
+        
+        int length = bulk_in->getLengthTransferred(); // why does this method always return 64?
         if (bulk_in->getState() == USB_TYPE_IDLE || bulk_in->getState() == USB_TYPE_FREE) {
             // MIDI event handling
             for (int i = 0; i < length; i += 4) {
@@ -102,16 +103,22 @@
 
                 // read each four bytes
                 midi = &buf[i];
+                
                 // process MIDI message
+                if (midi[0] == 0 && midi[1] == 0) {
+                    // {0,0,0,0} may be not collect data
+                    continue;
+                }
+                
+                USB_DBG("raw: %d, %d, %d, %d", midi[0]&0xf, midi[1], midi[2], midi[3]);
                 // switch by code index number
-                USB_DBG("midi: %d, %d, %d, %d", midi[0]&0xf, midi[1], midi[2], midi[3]);
                 switch (midi[0] & 0xf) {
                     case 0: // miscellaneous function codes
-                        //if(midi[1] == 0) break;
-                        //miscellaneousFunctionCode(midi[1], midi[2], midi[3]);
+                        if(midi[1] == 0) break;
+                        miscellaneousFunctionCode(midi[1], midi[2], midi[3]);
                         break;
                     case 1: // cable events
-                        //cableEvent(midi[1], midi[2], midi[3]);
+                        cableEvent(midi[1], midi[2], midi[3]);
                         break;
                     case 2: // two bytes system common messages 
                         systemCommonTwoBytes(midi[1], midi[2]);