From e2c55254fa48f88aabe514990037d0fc4dced4ef Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 26 Jun 2012 15:42:15 +0100 Subject: [PATCH] Moving to refactor XUD --- module_usb_aud_shared/devicedefines.h | 48 +++---- .../endpoint0/audiorequests.xc | 2 +- module_usb_aud_shared/usb_buffer/decouple.xc | 40 +++--- module_usb_aud_shared/usb_buffer/usb_buffer.h | 4 +- .../usb_buffer/usb_buffer.xc | 131 ++++++------------ module_usb_midi/src/usb_midi.xc | 6 +- 6 files changed, 96 insertions(+), 135 deletions(-) diff --git a/module_usb_aud_shared/devicedefines.h b/module_usb_aud_shared/devicedefines.h index a6e67e1b..1f98cb37 100644 --- a/module_usb_aud_shared/devicedefines.h +++ b/module_usb_aud_shared/devicedefines.h @@ -225,44 +225,42 @@ #define INTERFACE_NUM_HID (INPUT_INTERFACES+OUTPUT_INTERFACES+MIDI_INTERFACES+DFU_INTERFACES+IAP_INTERFACES+1) /* Endpoint Number Defines */ -#define EP_NUM_IN_FB (1) /* Always 1 */ -#define EP_NUM_IN_AUD (2) /* Always 2 */ -#define EP_NUM_IN_AUD_INT (3) /* Audio interrupt/status EP */ -#define EP_NUM_IN_MIDI ((EP_NUM_IN_AUD_INT + 1)) -#define EP_NUM_IN_HID ((EP_NUM_IN_AUD_INT + NUM_EP_IN_MIDI + 1)) -#define EP_NUM_IN_IAP ((EP_NUM_IN_AUD_INT + NUM_EP_IN_MIDI + NUM_EP_IN_HID + 1)) /* iAP Bulk */ -#define EP_NUM_IN_IAP_INT ((EP_NUM_IN_AUD_INT + NUM_EP_IN_MIDI + NUM_EP_IN_HID + 2)) /* iAP interrupt */ +#define EP_NUM_IN_FB (1) /* Always 1 */ +#define EP_NUM_IN_AUD (2) /* Always 2 */ +#define EP_NUM_IN_AUD_INT (3) /* Audio interrupt/status EP */ +#define EP_NUM_IN_MIDI ((EP_NUM_IN_AUD_INT + 1)) +#define EP_NUM_IN_HID ((EP_NUM_IN_AUD_INT + NUM_EP_IN_MIDI + 1)) +#define EP_NUM_IN_IAP ((EP_NUM_IN_AUD_INT + NUM_EP_IN_MIDI + NUM_EP_IN_HID + 1)) /* iAP Bulk */ +#define EP_NUM_IN_IAP_INT ((EP_NUM_IN_AUD_INT + NUM_EP_IN_MIDI + NUM_EP_IN_HID + 2)) /* iAP interrupt */ -#define EP_NUM_OUT_AUD 1 /* Always 1 */ -#define EP_NUM_OUT_MIDI 2 /* Always 2 */ -#define EP_NUM_OUT_IAP 3 /* Always 3 */ +#define EP_NUM_OUT_AUD 1 /* Always 1 */ +#define EP_NUM_OUT_MIDI 2 /* Always 2 */ +#define EP_NUM_OUT_IAP 3 /* Always 3 */ /* Endpoint Address Defines */ -#define EP_ADR_IN_FB (EP_NUM_IN_FB | 0x80) -#define EP_ADR_IN_AUD (EP_NUM_IN_AUD | 0x80) -#define EP_ADR_IN_AUD_INT (EP_NUM_IN_AUD_INT | 0x80) -#define EP_ADR_IN_MIDI (EP_NUM_IN_MIDI | 0x80) -#define EP_ADR_IN_HID (EP_NUM_IN_HID | 0x80) -#define EP_ADR_IN_IAP (EP_NUM_IN_IAP | 0x80) -#define EP_ADR_IN_IAP_INT (EP_NUM_IAP_INT | 0x80) +#define EP_ADR_IN_FB (EP_NUM_IN_FB | 0x80) +#define EP_ADR_IN_AUD (EP_NUM_IN_AUD | 0x80) +#define EP_ADR_IN_AUD_INT (EP_NUM_IN_AUD_INT | 0x80) +#define EP_ADR_IN_MIDI (EP_NUM_IN_MIDI | 0x80) +#define EP_ADR_IN_HID (EP_NUM_IN_HID | 0x80) +#define EP_ADR_IN_IAP (EP_NUM_IN_IAP | 0x80) +#define EP_ADR_IN_IAP_INT (EP_NUM_IAP_INT | 0x80) -#define EP_ADR_OUT_AUD EP_NUM_OUT_AUD -#define EP_ADR_OUT_MIDI EP_NUM_OUT_MIDI -#define EP_ADR_OUT_IAP EP_NUM_OUT_IAP +#define EP_ADR_OUT_AUD EP_NUM_OUT_AUD +#define EP_ADR_OUT_MIDI EP_NUM_OUT_MIDI +#define EP_ADR_OUT_IAP EP_NUM_OUT_IAP /* Endpoint count totals */ -#define NUM_EP_OUT 4// (1 + NUM_EP_OUT_AUD + NUM_EP_OUT_MIDI + NUM_EP_OUT_IAP) /* +1 due to EP0 */ -#define NUM_EP_IN 5 //(2 + NUM_EP_IN_AUD + NUM_EP_IN_MIDI + NUM_EP_IN_IAP + NUM_EP_IN_HID) /* +1 due to EP0 and Int EP */ +#define NUM_EP_OUT (1 + 1 /*NUM_EP_OUT_AUD*/ + NUM_EP_OUT_MIDI + NUM_EP_OUT_IAP) /* +1 due to EP0 */ +#define NUM_EP_IN (2 + 2 /*NUM_EP_IN_AUD*/ + NUM_EP_IN_MIDI + NUM_EP_IN_IAP + NUM_EP_IN_HID) /* +1 due to EP0 and Int EP */ -#define AUDIO_STOP_FOR_DFU (0x12345678) +#define AUDIO_STOP_FOR_DFU (0x12345678) #define AUDIO_START_FROM_DFU (0x87654321) #define AUDIO_REBOOT_FROM_DFU (0xa5a5a5a5) - #define MAX_VOL (0x20000000) - /* Length of clock unit/clock-selector units */ #if defined(SPDIF_RX) && defined(ADAT_RX) #define NUM_CLOCKS 3 diff --git a/module_usb_aud_shared/endpoint0/audiorequests.xc b/module_usb_aud_shared/endpoint0/audiorequests.xc index a06795b1..5067eaae 100644 --- a/module_usb_aud_shared/endpoint0/audiorequests.xc +++ b/module_usb_aud_shared/endpoint0/audiorequests.xc @@ -537,7 +537,7 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, SetupPacket &sp, chanend return loop; } -#if 0 +#if 1 if(unitID == FU_USBOUT) { if ((sp.wValue & 0xff) <= NUM_USB_CHAN_OUT) { diff --git a/module_usb_aud_shared/usb_buffer/decouple.xc b/module_usb_aud_shared/usb_buffer/decouple.xc index bd3d842d..16f9fc48 100644 --- a/module_usb_aud_shared/usb_buffer/decouple.xc +++ b/module_usb_aud_shared/usb_buffer/decouple.xc @@ -652,7 +652,7 @@ void check_for_interrupt(chanend ?c_clk_int) { //XUD_SetReady(int_usb_ep, 0); //asm("ldaw %0, dp[g_intData]":"=r"(x)); - XUD_SetReady_In(int_usb_ep, g_intData, 6); + //XUD_SetReady_In(int_usb_ep, g_intData, 6); } break; @@ -661,6 +661,7 @@ void check_for_interrupt(chanend ?c_clk_int) { } } +unsigned char tmpBuffer[1026]; #pragma unsafe arrays void decouple(chanend c_mix_out, @@ -781,7 +782,7 @@ void decouple(chanend c_mix_out, SET_SHARED_GLOBAL(g_midi_from_host_flag, midi_from_host_flag); // send the current host -> device buffer out of the fifo - //XUD_SetReady(midi_from_host_usb_ep, 1); + XUD_SetReady_OutPtr(midi_from_host_usb_ep, midi_from_host_buffer); #endif #ifdef IAP @@ -797,12 +798,13 @@ void decouple(chanend c_mix_out, SET_SHARED_GLOBAL(g_iap_from_host_flag, iap_from_host_flag); // send the current host -> device buffer out of the fifo - XUD_SetReady(iap_from_host_usb_ep, 1); + //XUD_SetReady(iap_from_host_usb_ep, 1); #endif #ifdef OUTPUT // wait for usb_buffer to set up - while(!aud_from_host_flag) { + while(!aud_from_host_flag) + { GET_SHARED_GLOBAL(aud_from_host_flag, g_aud_from_host_flag); } @@ -811,12 +813,13 @@ void decouple(chanend c_mix_out, // send the current host -> device buffer out of the fifo SET_SHARED_GLOBAL(g_aud_from_host_buffer, g_aud_from_host_wrptr); - //XUD_SetReady(aud_from_host_usb_ep, 1); + XUD_SetReady_OutPtr(aud_from_host_usb_ep, g_aud_from_host_wrptr); #endif #ifdef INPUT - // wait for usb_buffer to set up - while(!aud_to_host_flag) { + // Wait for usb_buffer to set up + while(!aud_to_host_flag) + { GET_SHARED_GLOBAL(aud_to_host_flag, g_aud_to_host_flag); } @@ -857,7 +860,7 @@ void decouple(chanend c_mix_out, asm("ldaw %0, dp[g_hidData]":"=r"(tmp)); if(g_hidFlag==0) { - XUD_SetReady_In(g_ep_hid, 0, tmp, 1); + //XUD_SetReady_In(g_ep_hid, 0, tmp, 1); g_hidFlag = 1; } #endif @@ -899,7 +902,7 @@ void decouple(chanend c_mix_out, /* Update the audio in buffer to send the correct * length back to the host for the new sample rate */ - XUD_Change_ReadyIn_Buffer(aud_to_host_usb_ep, p+4, len); + //XUD_Change_ReadyIn_Buffer(aud_to_host_usb_ep, p+4, len); } /* Reset OUT buffer state */ @@ -994,7 +997,7 @@ void decouple(chanend c_mix_out, if (space_left <= 0 || space_left >= MAX_USB_AUD_PACKET_SIZE) { SET_SHARED_GLOBAL(g_aud_from_host_buffer, aud_from_host_wrptr); - // XUD_SetReady(aud_from_host_usb_ep, 1); + XUD_SetReady_OutPtr(aud_from_host_usb_ep, aud_from_host_wrptr); } else { @@ -1153,6 +1156,8 @@ void decouple(chanend c_mix_out, /* Read length from buffer[0] */ read_via_xc_ptr(midi_data_remaining_to_device, midi_from_host_buffer); + + //printintln(midi_data_remaining_to_device); /* Increment read pointer - buffer[0] is length */ midi_from_host_rdptr = midi_from_host_buffer + 4; @@ -1161,6 +1166,7 @@ void decouple(chanend c_mix_out, { read_via_xc_ptr(datum, midi_from_host_rdptr); outuint(c_midi, datum); + //printhexln(datum); midi_from_host_rdptr += 4; midi_data_remaining_to_device -= 4; } @@ -1178,7 +1184,7 @@ void decouple(chanend c_mix_out, if (midi_data_remaining_to_device == 0) { /* We have read an entire packet - Mark ready to receive another */ - //XUD_SetReady(midi_from_host_usb_ep, 1); + XUD_SetReady_OutPtr(midi_from_host_usb_ep, midi_from_host_buffer+4); } else { @@ -1212,7 +1218,7 @@ void decouple(chanend c_mix_out, write_via_xc_ptr(midi_to_host_buffer_being_collected, midi_data_collected_from_device); swap(midi_to_host_buffer_being_collected, midi_to_host_buffer_being_sent); - + // Signal other side to swap XUD_SetReady_InPtr(midi_to_host_usb_ep, midi_to_host_buffer_being_sent+4, midi_data_collected_from_device); midi_data_collected_from_device = 0; @@ -1253,8 +1259,8 @@ void decouple(chanend c_mix_out, swap(iap_to_host_buffer_being_collected, iap_to_host_buffer_being_sent); /* Request to send packet */ - XUD_SetReady_InPtr(iap_to_host_int_usb_ep, 0, zero_buffer, 0); // ZLP to int ep - XUD_SetReady_InPtr(iap_to_host_usb_ep, 0, iap_to_host_buffer_being_sent+4, iap_data_collected_from_device); + //XUD_SetReady_InPtr(iap_to_host_int_usb_ep, 0, zero_buffer, 0); // ZLP to int ep + //XUD_SetReady_InPtr(iap_to_host_usb_ep, 0, iap_to_host_buffer_being_sent+4, iap_data_collected_from_device); /* Mark as waiting for host to poll us */ iap_waiting_on_send_to_host = 1; @@ -1308,7 +1314,7 @@ void decouple(chanend c_mix_out, if (iap_data_remaining_to_device == 0) { /* We have read an entire packet - Mark ready to receive another */ - XUD_SetReady(iap_from_host_usb_ep, 1); + //XUD_SetReady(iap_from_host_usb_ep, 1); } else { @@ -1349,8 +1355,8 @@ void decouple(chanend c_mix_out, swap(iap_to_host_buffer_being_collected, iap_to_host_buffer_being_sent); // Signal other side to swap - XUD_SetReady_In(iap_to_host_int_usb_ep, 0, zero_buffer, 0); - XUD_SetReady_In(iap_to_host_usb_ep, 0, iap_to_host_buffer_being_sent+4, iap_data_collected_from_device); + //XUD_SetReady_In(iap_to_host_int_usb_ep, 0, zero_buffer, 0); + //XUD_SetReady_In(iap_to_host_usb_ep, 0, iap_to_host_buffer_being_sent+4, iap_data_collected_from_device); iap_data_collected_from_device = 0; iap_waiting_on_send_to_host = 1; iap_expecting_length = 1; diff --git a/module_usb_aud_shared/usb_buffer/usb_buffer.h b/module_usb_aud_shared/usb_buffer/usb_buffer.h index 33745eb6..4fac7b0a 100644 --- a/module_usb_aud_shared/usb_buffer/usb_buffer.h +++ b/module_usb_aud_shared/usb_buffer/usb_buffer.h @@ -19,10 +19,10 @@ void buffer(chanend c_aud_out, chanend c_aud_in, chanend c_aud_fb, -//#ifdef MIDI +#ifdef MIDI chanend c_midi_from_host, chanend c_midi_to_host, -//#endif +#endif #ifdef IAP #error IAP chanend c_iap_from_host, diff --git a/module_usb_aud_shared/usb_buffer/usb_buffer.xc b/module_usb_aud_shared/usb_buffer/usb_buffer.xc index c90b5b71..4355f418 100644 --- a/module_usb_aud_shared/usb_buffer/usb_buffer.xc +++ b/module_usb_aud_shared/usb_buffer/usb_buffer.xc @@ -20,13 +20,13 @@ #include "testct_byref.h" XUD_ep XUD_Init_Ep(chanend c_ep); - -static inline void XUD_SetNotReady(XUD_ep e) -{ - int chan_array_ptr; - asm ("ldw %0, %1[0]":"=r"(chan_array_ptr):"r"(e)); - asm ("stw %0, %1[0]"::"r"(0),"r"(chan_array_ptr)); -} +// +//static inline void XUD_SetNotReady(XUD_ep e) +///{ + // int chan_array_ptr; + // asm ("ldw %0, %1[0]":"=r"(chan_array_ptr):"r"(e)); + // asm ("stw %0, %1[0]"::"r"(0),"r"(chan_array_ptr)); +//} void GetADCCounts(unsigned samFreq, int &min, int &mid, int &max); #define BUFFER_SIZE_OUT (1028 >> 2) @@ -70,10 +70,10 @@ extern unsigned g_numUsbChanIn; * @return void */ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud_fb, -//#ifdef MIDI +#ifdef MIDI chanend c_midi_from_host, chanend c_midi_to_host, -//#endif +#endif #ifdef IAP chanend c_iap_from_host, chanend c_iap_to_host, @@ -106,6 +106,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud #ifdef HID_CONTROLS XUD_ep ep_hid = XUD_Init_Ep(c_hid); #endif + unsigned datalength; unsigned tmp; @@ -224,7 +225,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud int usb_speed; int x; - //asm("ldaw %0, dp[fb_clocks]":"=r"(x)); + asm("ldaw %0, dp[fb_clocks]":"=r"(x)); GET_SHARED_GLOBAL(usb_speed, g_curUsbSpeed); if (usb_speed == XUD_SPEED_HS) @@ -242,6 +243,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud while(1) { + /* Wait for response from XUD and service relevant EP */ select { @@ -252,7 +254,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud int sent_ok = 0; /* Start XUD_SetData */ - XUD_SetData_Inline(ep_int, c_int); + //XUD_SetData_Inline(ep_int, c_int); #if 0 while (!sent_ok) @@ -268,7 +270,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud } #endif asm("stw %0, dp[g_intFlag]" :: "r" (0) ); - XUD_SetNotReady(ep_int); + //XUD_SetNotReady(ep_int); break; } #endif @@ -431,53 +433,15 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud } break; -#ifdef OUTPUT - /* Audio HOST -> DEVICE */ - case inuint_byref(c_aud_out, tmp): - asm("#h->d aud data"); - GET_SHARED_GLOBAL(aud_from_host_buffer, g_aud_from_host_buffer); - - // XUD_GetData - { - xc_ptr p = aud_from_host_buffer+4; - xc_ptr p0 = p; - int tail; - while (!testct(c_aud_out)) - { - unsigned int datum = inuint(c_aud_out); - write_via_xc_ptr(p, datum); - p += 4; - } - tail = inct(c_aud_out); - datalength = p - p0 - 4; - switch (tail) - { - case 10: - // the tail is 0 which means - datalength -= 2; - break; - default: - // the tail is 2 which means the input was word aligned - break; - } - } - - XUD_SetNotReady(ep_aud_out); - write_via_xc_ptr(aud_from_host_buffer, datalength); - /* Sync with audio thread */ - SET_SHARED_GLOBAL(g_aud_from_host_flag, 1); - - break; -#endif #ifdef INPUT /* DEVICE -> HOST */ - case inuint_byref(c_aud_in, tmp): + case XUD_SetData_Select(c_aud_in, ep_aud_in, tmp): { - XUD_SetData_Inline(ep_aud_in, c_aud_in); + //XUD_SetData_Inline(ep_aud_in, c_aud_in); - XUD_SetNotReady(ep_aud_in); + //XUD_SetNotReady(ep_aud_in); /* Inform stream that buffer sent */ SET_SHARED_GLOBAL(g_aud_to_host_flag, bufferIn+1); @@ -488,7 +452,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud #ifdef OUTPUT /* Feedback Pipe */ - case inuint_byref(c_aud_fb, tmp): + case XUD_SetData_Select(c_aud_fb, ep_aud_fb, tmp): { int usb_speed; @@ -496,8 +460,6 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud asm("#aud fb"); - XUD_SetData_Inline(ep_aud_fb, c_aud_fb); - asm("ldaw %0, dp[fb_clocks]":"=r"(x)); GET_SHARED_GLOBAL(usb_speed, g_curUsbSpeed); @@ -511,31 +473,29 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud } } break; + + /* Audio HOST -> DEVICE */ + case XUD_GetData_Select(c_aud_out, ep_aud_out, tmp): + + asm("#h->d aud data"); + + GET_SHARED_GLOBAL(aud_from_host_buffer, g_aud_from_host_buffer); + + write_via_xc_ptr(aud_from_host_buffer, tmp); + /* Sync with audio thread */ + SET_SHARED_GLOBAL(g_aud_from_host_flag, 1); + + break; #endif #ifdef MIDI - case inuint_byref(c_midi_from_host, tmp): + case XUD_GetData_Select(c_midi_from_host, ep_midi_from_host, tmp): asm("#midi h->d"); /* Get buffer data from host - MIDI OUT from host always into a single buffer */ - { - xc_ptr p = midi_from_host_buffer + 4; - xc_ptr p0 = p; - xc_ptr p1 = p + MAX_USB_MIDI_PACKET_SIZE; - while (!testct(c_midi_from_host)) - { - unsigned int datum = inuint(c_midi_from_host); - write_via_xc_ptr(p, datum); - p += 4; - } - (void) inct(c_midi_from_host); - datalength = p - p0 - 4; - } - - XUD_SetNotReady(ep_midi_from_host); - - write_via_xc_ptr(midi_from_host_buffer, datalength); + /* Write datalength (tmp) into buffer[0], data stored in buffer[4] onwards */ + write_via_xc_ptr(midi_from_host_buffer, tmp); /* release the buffer */ SET_SHARED_GLOBAL(g_midi_from_host_flag, 1); @@ -543,15 +503,10 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud break; /* MIDI IN to host */ - case inuint_byref(c_midi_to_host, tmp): + case XUD_SetData_Select(c_midi_to_host, ep_midi_to_host, tmp): asm("#midi d->h"); - // fill in the data - XUD_SetData_Inline(ep_midi_to_host, c_midi_to_host); - - XUD_SetNotReady(ep_midi_to_host); - - // ack the decouple thread to say it has been sent to host + // Ack the decouple thread to say it has been sent to host SET_SHARED_GLOBAL(g_midi_to_host_flag, 1); swap(midi_to_host_buffer, midi_to_host_waiting_buffer); @@ -605,7 +560,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud break; } - XUD_SetNotReady(ep_iap_from_host); + // XUD_SetNotReady(ep_iap_from_host); write_via_xc_ptr(iap_from_host_buffer, datalength); @@ -630,9 +585,9 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud } else { inuint(c_iap_to_host); // And discard // fill in the data - XUD_SetData_Inline(ep_iap_to_host, c_iap_to_host); + //XUD_SetData_Inline(ep_iap_to_host, c_iap_to_host); - XUD_SetNotReady(ep_iap_to_host); + //XUD_SetNotReady(ep_iap_to_host); // ack the decouple thread to say it has been sent to host SET_SHARED_GLOBAL(g_iap_to_host_flag, 1); @@ -659,8 +614,8 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud { inuint(c_iap_to_host_int); // And discard // fill in the data - XUD_SetData_Inline(ep_iap_to_host_int, c_iap_to_host_int); - XUD_SetNotReady(ep_iap_to_host_int); + // XUD_SetData_Inline(ep_iap_to_host_int, c_iap_to_host_int); + //XUD_SetNotReady(ep_iap_to_host_int); // Don't need to handle data here as always ZLP } break; @@ -670,11 +625,11 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud /* HID Report Data */ case inuint_byref(c_hid, tmp): { - XUD_SetData_Inline(ep_hid, c_hid); + //XUD_SetData_Inline(ep_hid, c_hid); asm("stw %0, dp[g_hidFlag]" :: "r" (0) ); - XUD_SetNotReady(ep_hid); + //XUD_SetNotReady(ep_hid); } break; #endif diff --git a/module_usb_midi/src/usb_midi.xc b/module_usb_midi/src/usb_midi.xc index f43acc0e..9765ed79 100644 --- a/module_usb_midi/src/usb_midi.xc +++ b/module_usb_midi/src/usb_midi.xc @@ -22,7 +22,7 @@ static unsigned makeSymbol(unsigned data) #define RATE 31250 #ifndef MIDI_SHIFT_TX -#define MIDI_SHIFT_TX 0 +#define MIDI_SHIFT_TX 7 #endif static unsigned bit_time = XS1_TIMER_MHZ * 1000000 / (unsigned) RATE; @@ -136,11 +136,13 @@ void usb_midi(port ?p_midi_in, port ?p_midi_out, #ifndef MIDI_LOOPBACK #ifdef IAP CoProcessorDisable(); -#endif +#endif + p_midi_out <: 1 << MIDI_SHIFT_TX; // Start with high bit. #ifdef IAP CoProcessorEnable(); #endif + #endif #ifdef IAP