From d921f04cd5f7e1a49ff191c3ec7a0139aa93fbea Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Thu, 7 Feb 2013 17:14:16 +0000 Subject: [PATCH] Just changes after MIDI sysex debug --- module_usb_midi/src/usb_midi.xc | 45 ++++++--------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/module_usb_midi/src/usb_midi.xc b/module_usb_midi/src/usb_midi.xc index 3b42885f..4a9c2403 100644 --- a/module_usb_midi/src/usb_midi.xc +++ b/module_usb_midi/src/usb_midi.xc @@ -11,7 +11,7 @@ #include "iapuser.h" #endif //#define MIDI_LOOPBACK 1 - +int icount = 0; static unsigned makeSymbol(unsigned data) { // Start and stop bits to the data packet @@ -32,38 +32,6 @@ static unsigned bit_time_2 = (XS1_TIMER_MHZ * 1000000 / (unsigned) RATE) / 2; int mr_count = 0; // MIDI received (from HOST) int th_count = 0; // MIDI sent (To Host) -#ifdef MIDI_LOOPBACK -static inline void handle_byte_from_uart(chanend c_midi, struct midi_in_parse_state &mips, int cable_number, - int &got_next_event, int &next_event, int &waiting_for_ack, int byte) -{ - int valid; - unsigned event; - {valid, event} = midi_in_parse(mips, cable_number, byte); - if (valid && !got_next_event) - { - // data to send to host - if (!waiting_for_ack) - { - // send data - event = byterev(event); - outuint(c_midi, event); - th_count++; - waiting_for_ack = 1; - } - else - { - event = byterev(event); - next_event = event; - got_next_event = 1; - } - } - else if (valid) - { - // printstr("g\n"); - } -} -#endif - int uout_count = 0; // UART bytes out int uin_count = 0; // UART bytes in @@ -132,7 +100,6 @@ void usb_midi(port ?p_midi_in, port ?p_midi_out, t :> txT; t2 :> rxT; -#ifndef MIDI_LOOPBACK #ifdef IAP CoProcessorDisable(); #endif @@ -142,8 +109,6 @@ void usb_midi(port ?p_midi_in, port ?p_midi_out, CoProcessorEnable(); #endif -#endif - #ifdef IAP /* Check for special case where MIDI and i2c ports are shared... */ if(isnull(c_i2c) && isnull(p_scl) && isnull(p_sda)) @@ -211,6 +176,7 @@ void usb_midi(port ?p_midi_in, port ?p_midi_out, {valid, event} = midi_in_parse(mips, cable_number, rxByte); if (valid && isempty(midi_to_host_fifo)) { + event = byterev(event); // data to send to host - add to fifo if (!waiting_for_ack) @@ -228,7 +194,7 @@ void usb_midi(port ?p_midi_in, port ?p_midi_out, } else if (valid) { - // printstr("g"); + //printstr("g"); } } isRX = 0; @@ -328,6 +294,11 @@ void usb_midi(port ?p_midi_in, port ?p_midi_out, event = byterev(event); enqueue(midi_to_host_fifo, event); } + midi_send_ack(c_midi); + } + else + { + //printstr("DROP\n"); } #else {midi[0], midi[1], midi[2], size} = midi_out_parse(event);