diff --git a/module_usb_aud_shared/endpoint0/endpoint0.xc b/module_usb_aud_shared/endpoint0/endpoint0.xc index 5922c4fa..071dda08 100755 --- a/module_usb_aud_shared/endpoint0/endpoint0.xc +++ b/module_usb_aud_shared/endpoint0/endpoint0.xc @@ -813,7 +813,7 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, if (retVal < 0) { - g_curUsbSpeed = XUD_ResetEndpoint(ep0_in, ep0_out); + g_curUsbSpeed = XUD_ResetEndpoint(ep0_out, ep0_in); g_config = 0; diff --git a/module_usb_aud_shared/usb_buffer/usb_buffer.xc b/module_usb_aud_shared/usb_buffer/usb_buffer.xc index c252dc40..4a0e13d4 100644 --- a/module_usb_aud_shared/usb_buffer/usb_buffer.xc +++ b/module_usb_aud_shared/usb_buffer/usb_buffer.xc @@ -135,7 +135,11 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud set_thread_fast_mode_on(); #ifdef IAP - XUD_ResetEndpoint(ep_iap_to_host_int, null); + /* Note the order here is important */ + XUD_ResetDrain(c_iap_to_host); + XUD_ResetDrain(c_iap_to_host_int); + XUD_GetBusSpeed(c_iap_to_host); + XUD_GetBusSpeed(c_iap_to_host_int); #endif #if defined(SPDIF_RX) || defined(ADAT_RX) @@ -600,7 +604,22 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud /* IAP IN to host */ case testct_byref(c_iap_to_host, tmp): asm("#iap d->h"); - if (tmp) { + if (tmp) + { + // Is a control token so reset + //XUD_ResetEndpoint(ep_iap_to_host, null); + //printint(1); + //XUD_SetNotReady(ep_iap_to_host); + //XUD_ResetDrain(c_iap_to_host); + //XUD_GetBusSpeed(c_iap_to_host); + XUD_ResetDrain(c_iap_to_host); + XUD_ResetDrain(c_iap_to_host_int); + XUD_GetBusSpeed(c_iap_to_host); + XUD_GetBusSpeed(c_iap_to_host_int); + + XUD_SetNotReady(ep_iap_to_host); + XUD_SetNotReady(ep_iap_to_host_int); + // Is a control token so reset } else { inuint(c_iap_to_host); // And discard @@ -623,7 +642,13 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud { // Is a control token so reset //printint(1); - XUD_ResetEndpoint(ep_iap_to_host_int, null); + //XUD_ResetEndpoint(ep_iap_to_host_int, null); + XUD_ResetDrain(c_iap_to_host); + XUD_ResetDrain(c_iap_to_host_int); + XUD_GetBusSpeed(c_iap_to_host); + XUD_GetBusSpeed(c_iap_to_host_int); + + XUD_SetNotReady(ep_iap_to_host); XUD_SetNotReady(ep_iap_to_host_int); } else diff --git a/module_usb_midi/src/usb_midi.xc b/module_usb_midi/src/usb_midi.xc index a0a673cb..2bffa8ac 100644 --- a/module_usb_midi/src/usb_midi.xc +++ b/module_usb_midi/src/usb_midi.xc @@ -6,8 +6,9 @@ #include "midioutparse.h" #include "queue.h" #include "port32A.h" +#ifdef IAP #include "iAP.h" - +#endif //#define MIDI_LOOPBACK 1 static unsigned makeSymbol(unsigned data) { @@ -62,10 +63,16 @@ extern unsigned authenticating; // state for auto-selecting dock or USB B extern unsigned polltime; +#ifdef IAP extern port p_i2c_scl; extern port p_i2c_sda; #define p_midi_out p_i2c_scl #define p_midi_in p_i2c_sda +#else +extern port p_midi_out; +extern port p_midi_in; +#endif + void usb_midi(in port ?p_midi_inj, out port ?p_midi_outj, clock ?clk_midi, @@ -119,13 +126,18 @@ chanend c_iap, chanend ?c_i2c // iOS stuff t2 :> rxT; #ifndef MIDI_LOOPBACK +#ifdef IAP port32A_unset(P32A_I2C_NOTMIDI); +#endif p_midi_out <: 1; // Start with high bit. +#ifdef IAP port32A_set(P32A_I2C_NOTMIDI); - // printstr("mout0"); +#endif #endif +#ifdef IAP init_iAP(c_i2c); // uses timer for i2c initialisation pause.. +#endif { timer poll; // .. so declare this after or don't have enough timers @@ -293,6 +305,7 @@ chanend c_iap, chanend ?c_i2c // iOS stuff #endif } break; +#ifdef IAP case !(isTX || isRX) => iap_get_ack_or_reset_or_data(c_iap, is_ack, is_reset, datum): handle_iap_case(is_ack, is_reset, datum, c_iap, c_i2c); if (!authenticating) { @@ -300,9 +313,12 @@ chanend c_iap, chanend ?c_i2c // iOS stuff p_midi_in :> void; // Change port around to input again after authenticating (unique to midi+iAP case) } break; +#endif +#ifdef IAP case poll when timerafter(polltime) :> void: handle_poll_dev_det(poll); break; +#endif } } }