Updated ep_buffer to match 3610's xua_buffer_lite

This commit is contained in:
Angel Cascarino
2022-01-12 14:47:40 +00:00
parent 64cbd072f4
commit 6b0688d23e

View File

@@ -373,15 +373,13 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
#endif
#if( 0 < HID_CONTROLS )
UserHIDInit();
while (!hidIsReportDescriptorPrepared())
;
/* Get the a report - we don't really care which it is, so long as there's some data we can grab. */
int hidReportLength = (int) UserHIDGetData(hidGetNextValidReportId(0), g_hidData);
XUD_SetReady_In(ep_hid, g_hidData, hidReportLength);
UserHIDInit();
unsigned hid_ready_flag = 0U;
unsigned hid_ready_id = 0U;
#endif
@@ -800,9 +798,9 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
midi_waiting_on_send_to_host = 0;
}
break;
#endif
#endif
#ifdef IAP
#ifdef IAP
/* IAP OUT from host. Datalength writen to tmp */
case XUD_GetData_Select(c_iap_from_host, ep_iap_from_host, length, result):
@@ -833,9 +831,9 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
if(result == XUD_RES_RST)
{
XUD_ResetEndpoint(ep_iap_to_host, null);
#ifdef IAP_INT_EP
#ifdef IAP_INT_EP
XUD_ResetEndpoint(ep_iap_to_host_int, null);
#endif
#endif
iap_send_reset(c_iap);
iap_draining_chan = 1; // Drain c_iap until a reset is sent back
iap_data_collected_from_device = 0;
@@ -850,15 +848,15 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
}
break; /* IAP IN to host */
#ifdef IAP_INT_EP
#ifdef IAP_INT_EP
case XUD_SetData_Select(c_iap_to_host_int, ep_iap_to_host_int, result):
/* Do nothing.. */
/* Note, could get a reset notification here, but deal with it in the case above */
break;
#endif
#endif
#ifdef IAP_EA_NATIVE_TRANS
#ifdef IAP_EA_NATIVE_TRANS
/* iAP EA Native Transport OUT from host */
case XUD_GetData_Select(c_iap_ea_native_out, ep_iap_ea_native_out, iap_ea_native_rx_length, result):
if ((result == XUD_RES_OKAY) && iap_ea_native_rx_length > 0)
@@ -891,31 +889,22 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
}
break;
//::
#endif
#endif
#endif
#endif
#if( 0 < HID_CONTROLS )
#if( 0 < HID_CONTROLS )
/* HID Report Data */
case (hidIsChangePending(0U) || !HidIsSetIdleSilenced(0U)) => XUD_SetData_Select(c_hid, ep_hid, result):
{
case XUD_SetData_Select(c_hid, ep_hid, result):
hid_ready_flag = 0U;
unsigned reportTime;
tmr :> reportTime;
for(unsigned id = hidIsReportIdInUse(); id < hidGetReportIdLimit(); ++id) {
if(0U == id || (hidIsChangePending(id) || !HidIsSetIdleSilenced(id))) {
hidCaptureReportTime(id, reportTime);
int hidDataLength = (int) UserHIDGetData(id, g_hidData);
XUD_SetReady_In(ep_hid, g_hidData, hidDataLength);
hidCalcNextReportTime(id);
hidClearChangePending(id);
hidCaptureReportTime(hid_ready_id, reportTime);
hidCalcNextReportTime(hid_ready_id);
hidClearChangePending(hid_ready_id);
break;
}
}
}
break;
#endif
#endif
#ifdef MIDI
#ifdef MIDI
/* Received word from MIDI thread - Check for ACK or Data */
case midi_get_ack_or_data(c_midi, is_ack, datum):
if (is_ack)
@@ -966,9 +955,9 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
}
}
break;
#endif /* ifdef MIDI */
#endif /* ifdef MIDI */
#ifdef IAP
#ifdef IAP
/* 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):
@@ -1027,16 +1016,16 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
if (iap_data_collected_from_device == iap_expected_data_length)
{
XUD_Result_t result1 = XUD_RES_OKAY, result2;
#ifdef IAP_INT_EP
#ifdef IAP_INT_EP
result1 = XUD_SetReady_In(ep_iap_to_host_int, gc_zero_buffer, 0);
#endif
#endif
result2 = XUD_SetReady_In(ep_iap_to_host, iap_to_host_buffer, iap_data_collected_from_device);
if((result1 == XUD_RES_RST) || (result2 == XUD_RES_RST))
{
#ifdef IAP_INT_EP
#ifdef IAP_INT_EP
XUD_ResetEndpoint(ep_iap_to_host_int, null);
#endif
#endif
XUD_ResetEndpoint(ep_iap_to_host, null);
iap_send_reset(c_iap);
iap_draining_chan = 1; // Drain c_iap until a reset is sent back
@@ -1057,7 +1046,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
}
break;
# if IAP_EA_NATIVE_TRANS
# if IAP_EA_NATIVE_TRANS
/* Change of EA Native Transport interface setting */
case inuint_byref(c_iap_ea_native_ctrl, iap_ea_native_interface_alt_setting):
/* Handshake */
@@ -1115,6 +1104,26 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
break;
}
break;
default:
#if ( 0 < HID_CONTROLS )
if (!hid_ready_flag)
{
for (unsigned id = hidIsReportIdInUse(); id < hidGetReportIdLimit(); id++)
{
if ( hidIsChangePending(id) || !HidIsSetIdleSilenced(id) )
{
int hidDataLength = (int) UserHIDGetData(id, g_hidData);
XUD_SetReady_In(ep_hid, g_hidData, hidDataLength);
hid_ready_id = id;
hid_ready_flag = 1U;
break;
}
}
}
#endif
break;
//::
#endif