forked from PAWPAW-Mirror/lib_xua
Merge remote-tracking branch 'origin/IAP2_DEV'
This commit is contained in:
@@ -170,6 +170,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
|
||||
int iap_data_remaining_to_device = 0;
|
||||
int iap_data_collected_from_device = 0;
|
||||
int iap_expected_data_length = 0;
|
||||
int iap_draining_chan = 0;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -555,7 +556,8 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
|
||||
else if(tmp==-1)
|
||||
{
|
||||
XUD_ResetEndpoint(ep_iap_from_host, null);
|
||||
iap_send_reset(c_iap); // What if this happen in the middle of a send/ack?
|
||||
iap_send_reset(c_iap);
|
||||
iap_draining_chan = 1; // Drain c_iap until a reset is sent back
|
||||
iap_data_collected_from_device = 0;
|
||||
iap_data_remaining_to_device = -1;
|
||||
iap_expected_data_length = 0;
|
||||
@@ -644,6 +646,17 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
|
||||
/* Received word from iap thread - Check for ACK or Data */
|
||||
case iap_get_ack_or_reset_or_data(c_iap, is_ack_iap, is_reset, datum_iap):
|
||||
|
||||
if (iap_draining_chan)
|
||||
{
|
||||
/* As we're draining the iAP channel now, ignore ACKs and data */
|
||||
if (is_reset)
|
||||
{
|
||||
// The iAP core has returned a reset token, so we can stop draining the iAP channel now
|
||||
iap_draining_chan = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_ack_iap)
|
||||
{
|
||||
/* An ack from the iap/uart thread means it has accepted some data we sent it
|
||||
@@ -662,7 +675,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
|
||||
iap_data_remaining_to_device -= 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (!is_reset)
|
||||
{
|
||||
if (iap_expected_data_length == 0)
|
||||
{
|
||||
@@ -689,6 +702,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
|
||||
{
|
||||
XUD_SetReady_In(ep_iap_to_host_int, gc_zero_buffer, 0);
|
||||
XUD_SetReady_In(ep_iap_to_host, iap_to_host_buffer, iap_data_collected_from_device);
|
||||
printintln(iap_data_collected_from_device);
|
||||
iap_data_collected_from_device = 0;
|
||||
iap_expected_data_length = 0;
|
||||
}
|
||||
@@ -699,6 +713,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user