Updates for iAP reset

This commit is contained in:
Ross Owen
2011-11-22 15:58:39 +00:00
parent e8625e2b37
commit 1115d353ef
3 changed files with 47 additions and 6 deletions

View File

@@ -813,7 +813,7 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
if (retVal < 0) if (retVal < 0)
{ {
g_curUsbSpeed = XUD_ResetEndpoint(ep0_in, ep0_out); g_curUsbSpeed = XUD_ResetEndpoint(ep0_out, ep0_in);
g_config = 0; g_config = 0;

View File

@@ -135,7 +135,11 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
set_thread_fast_mode_on(); set_thread_fast_mode_on();
#ifdef IAP #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 #endif
#if defined(SPDIF_RX) || defined(ADAT_RX) #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 */ /* IAP IN to host */
case testct_byref(c_iap_to_host, tmp): case testct_byref(c_iap_to_host, tmp):
asm("#iap d->h"); 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 // Is a control token so reset
} else { } else {
inuint(c_iap_to_host); // And discard 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 // Is a control token so reset
//printint(1); //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); XUD_SetNotReady(ep_iap_to_host_int);
} }
else else

View File

@@ -6,8 +6,9 @@
#include "midioutparse.h" #include "midioutparse.h"
#include "queue.h" #include "queue.h"
#include "port32A.h" #include "port32A.h"
#ifdef IAP
#include "iAP.h" #include "iAP.h"
#endif
//#define MIDI_LOOPBACK 1 //#define MIDI_LOOPBACK 1
static unsigned makeSymbol(unsigned data) { static unsigned makeSymbol(unsigned data) {
@@ -62,10 +63,16 @@ extern unsigned authenticating;
// state for auto-selecting dock or USB B // state for auto-selecting dock or USB B
extern unsigned polltime; extern unsigned polltime;
#ifdef IAP
extern port p_i2c_scl; extern port p_i2c_scl;
extern port p_i2c_sda; extern port p_i2c_sda;
#define p_midi_out p_i2c_scl #define p_midi_out p_i2c_scl
#define p_midi_in p_i2c_sda #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, void usb_midi(in port ?p_midi_inj, out port ?p_midi_outj,
clock ?clk_midi, clock ?clk_midi,
@@ -119,13 +126,18 @@ chanend c_iap, chanend ?c_i2c // iOS stuff
t2 :> rxT; t2 :> rxT;
#ifndef MIDI_LOOPBACK #ifndef MIDI_LOOPBACK
#ifdef IAP
port32A_unset(P32A_I2C_NOTMIDI); port32A_unset(P32A_I2C_NOTMIDI);
#endif
p_midi_out <: 1; // Start with high bit. p_midi_out <: 1; // Start with high bit.
#ifdef IAP
port32A_set(P32A_I2C_NOTMIDI); port32A_set(P32A_I2C_NOTMIDI);
// printstr("mout0"); #endif
#endif #endif
#ifdef IAP
init_iAP(c_i2c); // uses timer for i2c initialisation pause.. init_iAP(c_i2c); // uses timer for i2c initialisation pause..
#endif
{ {
timer poll; // .. so declare this after or don't have enough timers 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 #endif
} }
break; break;
#ifdef IAP
case !(isTX || isRX) => iap_get_ack_or_reset_or_data(c_iap, is_ack, is_reset, datum): 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); handle_iap_case(is_ack, is_reset, datum, c_iap, c_i2c);
if (!authenticating) { 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) p_midi_in :> void; // Change port around to input again after authenticating (unique to midi+iAP case)
} }
break; break;
#endif
#ifdef IAP
case poll when timerafter(polltime) :> void: case poll when timerafter(polltime) :> void:
handle_poll_dev_det(poll); handle_poll_dev_det(poll);
break; break;
#endif
} }
} }
} }