Remove magic numbers from endpoint numbers so switch between asynch/adaptive handled

This commit is contained in:
Ed Clarke
2018-11-05 11:16:21 +00:00
parent 0709860f48
commit 3214d4ea9f
3 changed files with 19 additions and 11 deletions

View File

@@ -56,7 +56,7 @@ on tile[0]: clock pdmclk6 = XS1_CLKBLK_5;
XUD_EpType epTypeTableOut[] = {XUD_EPTYPE_CTL | XUD_STATUS_ENABLE, XUD_EPTYPE_ISO};
XUD_EpType epTypeTableIn[] = {XUD_EPTYPE_CTL | XUD_STATUS_ENABLE, XUD_EPTYPE_ISO, XUD_EPTYPE_ISO};
void XUA_Buffer_lite(chanend c_ep0_out, chanend c_ep0_in, chanend c_aud_out, chanend c_feedback, chanend c_aud_in, chanend c_sof, in port p_for_mclk_count, streaming chanend c_aud_host);
void XUA_Buffer_lite(chanend c_ep0_out, chanend c_ep0_in, chanend c_aud_out, chanend ?c_feedback, chanend c_aud_in, chanend c_sof, in port p_for_mclk_count, streaming chanend c_aud_host);
[[distributable]]
void AudioHub(server i2s_frame_callback_if i2s, streaming chanend c_audio, streaming chanend (&?c_ds_output)[1]);
void setup_audio_gpio(out port p_gpio);
@@ -77,8 +77,8 @@ void burn_high_priority(void){
int main()
{
// Channels for lib_xud
chan c_ep_out[2];
chan c_ep_in[3];
chan c_ep_out[XUA_ENDPOINT_COUNT_OUT];
chan c_ep_in[XUA_ENDPOINT_COUNT_IN];
// Channel for communicating SOF notifications from XUD to the Buffering cores
chan c_sof;
@@ -125,13 +125,18 @@ int main()
par{
// Low level USB device layer core
XUD_Main(c_ep_out, 2, c_ep_in, 3,
XUD_Main(c_ep_out, XUA_ENDPOINT_COUNT_OUT, c_ep_in, XUA_ENDPOINT_COUNT_IN,
c_sof, epTypeTableOut, epTypeTableIn,
null, null, -1 ,
(AUDIO_CLASS == 1) ? XUD_SPEED_FS : XUD_SPEED_HS, XUD_PWR_BUS);
// Buffering core - handles audio and control data to/from EP's and gives/gets data to/from the audio I/O core
XUA_Buffer_lite(c_ep_out[0], c_ep_in[0], c_ep_out[1], c_ep_in[1], c_ep_in[2], c_sof, p_for_mclk_count, c_audio);
XUA_Buffer_lite(c_ep_out[0],
c_ep_in[0],
c_ep_out[1],
null, //c_ep_in[XUA_ENDPOINT_COUNT_IN - 2],/*feedback*/
c_ep_in[XUA_ENDPOINT_COUNT_IN - 1],
c_sof, p_for_mclk_count, c_audio);
par (int i = 0; i < 4; i++) burn_normal_priority();
par (int i = 0; i < 2; i++) burn_high_priority();

View File

@@ -169,7 +169,7 @@ extern XUD_ep ep0_out;
extern XUD_ep ep0_in;
void XUA_Buffer_lite(chanend c_ep0_out, chanend c_ep0_in, chanend c_aud_out, chanend c_feedback, chanend c_aud_in, chanend c_sof, in port p_for_mclk_count, streaming chanend c_audio_hub) {
void XUA_Buffer_lite(chanend c_ep0_out, chanend c_ep0_in, chanend c_aud_out, chanend ?c_feedback, chanend c_aud_in, chanend c_sof, in port p_for_mclk_count, streaming chanend c_audio_hub) {
debug_printf("%d\n", MAX_OUT_SAMPLES_PER_SOF_PERIOD);
@@ -189,8 +189,9 @@ void XUA_Buffer_lite(chanend c_ep0_out, chanend c_ep0_in, chanend c_aud_out, cha
XUD_ep ep_aud_out = XUD_InitEp(c_aud_out);
XUD_ep ep_feedback = XUD_InitEp(c_feedback);
XUD_ep ep_aud_in = XUD_InitEp(c_aud_in);
XUD_ep ep_feedback = 0;
if (!isnull(c_feedback)) ep_feedback = XUD_InitEp(c_feedback);
unsigned num_samples_received_from_host = 0;
unsigned num_samples_to_send_to_host = 0;
@@ -210,8 +211,9 @@ void XUA_Buffer_lite(chanend c_ep0_out, chanend c_ep0_in, chanend c_aud_out, cha
//Enable all EPs
XUD_SetReady_OutPtr(ep_aud_out, (unsigned)buffer_aud_out);
XUD_SetReady_InPtr(ep_aud_in, (unsigned)buffer_aud_in, num_samples_to_send_to_host);
XUD_SetReady_InPtr(ep_feedback, (unsigned)fb_clocks, (AUDIO_CLASS == 2) ? 4 : 3);
XUD_SetReady_Out(ep0_out, sbuffer);
if (!isnull(c_feedback)) XUD_SetReady_InPtr(ep_feedback, (unsigned)fb_clocks, (AUDIO_CLASS == 2) ? 4 : 3);
//Send initial samples so audiohub is not blocked
for (int i = 0; i < NUM_USB_CHAN_OUT * 6; i++) c_audio_hub <: 0;
@@ -274,8 +276,8 @@ void XUA_Buffer_lite(chanend c_ep0_out, chanend c_ep0_in, chanend c_aud_out, cha
break;
//Send asynch explicit feedback value
case XUD_SetData_Select(c_feedback, ep_feedback, result):
//Send asynch explicit feedback value, but only if enabled
case !isnull(c_feedback) => XUD_SetData_Select(c_feedback, ep_feedback, result):
timer tmr; int t0, t1; tmr :> t0;
XUD_SetReady_In(ep_feedback, (fb_clocks, unsigned char[]), (AUDIO_CLASS == 2) ? 4 : 3);

View File

@@ -30,7 +30,8 @@
#define OUTPUT_VOLUME_CONTROL 0
#define INPUT_VOLUME_CONTROL 0
#define UAC_FORCE_FEEDBACK_EP 1
#define UAC_FORCE_FEEDBACK_EP 0
#define XUA_ADAPTIVE 1
#define XUA_LITE 1 // Use simple/optimised USB buffer tasks
#define AUDIO_CLASS 1