forked from PAWPAW-Mirror/lib_xua
First pass combine ep0 into buffer
This commit is contained in:
@@ -49,7 +49,7 @@ on tile[0]:clock clk_audio_mclk = XS1_CLKBLK_3; // Master clock
|
||||
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_aud_out, chanend c_feedback, chanend c_aud_in, chanend c_sof, chanend c_aud_ctl, in port p_for_mclk_count, 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, chanend c_aud_host);
|
||||
[[distributable]]
|
||||
void AudioHub(server i2s_frame_callback_if i2s, chanend c_aud, client i2c_master_if ?i2c, client output_gpio_if dac_reset);
|
||||
void AudioHwConfigure(unsigned samFreq, client i2c_master_if i_i2c);
|
||||
@@ -96,6 +96,7 @@ int main()
|
||||
AudioHwConfigure(DEFAULT_FREQ, i_i2c[0]);
|
||||
}
|
||||
|
||||
debug_printf("XUD SPEED: %d\n", (AUDIO_CLASS == 1) ? XUD_SPEED_FS : XUD_SPEED_HS);
|
||||
par{
|
||||
// Low level USB device layer core
|
||||
XUD_Main(c_ep_out, 2, c_ep_in, 3,
|
||||
@@ -106,10 +107,10 @@ int main()
|
||||
// Endpoint 0 core from lib_xua
|
||||
// Note, since we are not using many features we pass in null for quite a few params..
|
||||
// XUA_Endpoint0(c_ep_out[0], c_ep_in[0], c_aud_ctl, null, null, null, null);
|
||||
XUA_Endpoint0_select(c_ep_out[0], c_ep_in[0], c_aud_ctl, null, null, null, null);
|
||||
//XUA_Endpoint0_select(c_ep_out[0], c_ep_in[0], c_aud_ctl, null, null, null, null);
|
||||
|
||||
// Buffering cores - handles audio data to/from EP's and gives/gets data to/from the audio I/O core
|
||||
XUA_Buffer_lite(c_ep_out[1], c_ep_in[1], c_ep_in[2], c_sof, c_aud_ctl, p_for_mclk_count, c_audio);
|
||||
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);
|
||||
}
|
||||
}//Tile[1] par
|
||||
}//Top level par
|
||||
|
||||
@@ -153,7 +153,25 @@ void do_feedback_calculation(unsigned &sof_count
|
||||
}
|
||||
}
|
||||
|
||||
void XUA_Buffer_lite(chanend c_aud_out, chanend c_feedback, chanend c_aud_in, chanend c_sof, chanend c_aud_ctl, in port p_for_mclk_count, chanend c_audio_hub) {
|
||||
#define SINGLE_XUA_EP_BUFFER 1
|
||||
|
||||
|
||||
#if SINGLE_XUA_EP_BUFFER
|
||||
extern "C"{
|
||||
void XUA_Endpoint0_lite_init(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
||||
chanend ?c_mix_ctl, chanend ?c_clk_ctl, chanend ?c_EANativeTransport_ctrl, CLIENT_INTERFACE(i_dfu, ?dfuInterface) VENDOR_REQUESTS_PARAMS_DEC_);
|
||||
void XUA_Endpoint0_lite_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
||||
chanend ?c_mix_ctl, chanend ?c_clk_ctl, chanend ?c_EANativeTransport_ctrl, CLIENT_INTERFACE(i_dfu, ?dfuInterface) VENDOR_REQUESTS_PARAMS_DEC_, unsigned *input_interface_num, unsigned *output_interface_num);
|
||||
}
|
||||
#pragma select handler
|
||||
void XUD_GetSetupData_Select(chanend c, XUD_ep e_out, unsigned &length, XUD_Result_t &result);
|
||||
|
||||
extern XUD_ep ep0_out;
|
||||
extern XUD_ep ep0_in;
|
||||
#endif
|
||||
|
||||
|
||||
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, chanend c_audio_hub) {
|
||||
|
||||
debug_printf("%d\n", MAX_OUT_SAMPLES_PER_SOF_PERIOD);
|
||||
|
||||
@@ -196,6 +214,20 @@ void XUA_Buffer_lite(chanend c_aud_out, chanend c_feedback, chanend c_aud_in, ch
|
||||
int32_t samples_out[NUM_USB_CHAN_OUT] = {0};
|
||||
int32_t samples_in[NUM_USB_CHAN_IN] = {0};
|
||||
|
||||
#if SINGLE_XUA_EP_BUFFER
|
||||
#define c_audioControl null
|
||||
#define dfuInterface null
|
||||
XUA_Endpoint0_lite_init(c_ep0_out, c_ep0_in, c_audioControl, null, null, null, dfuInterface);
|
||||
unsigned char sbuffer[120];
|
||||
USB_SetupPacket_t sp;
|
||||
XUD_SetReady_Out(ep0_out, sbuffer);
|
||||
|
||||
unsigned input_interface_num = 0;
|
||||
unsigned output_interface_num = 0;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
unsafe{
|
||||
|
||||
int host_to_device_fifo_storage[MAX_OUT_SAMPLES_PER_SOF_PERIOD * 2];
|
||||
@@ -209,6 +241,8 @@ void XUA_Buffer_lite(chanend c_aud_out, chanend c_feedback, chanend c_aud_in, ch
|
||||
unsigned tmp; //For select channel input by ref
|
||||
while(1){
|
||||
select{
|
||||
|
||||
#if !SINGLE_XUA_EP_BUFFER
|
||||
//Handle control path from EP0
|
||||
case testct_byref(c_aud_ctl, tmp):
|
||||
//ignore tmp as is used for reboot signalling only
|
||||
@@ -248,6 +282,22 @@ void XUA_Buffer_lite(chanend c_aud_out, chanend c_feedback, chanend c_aud_in, ch
|
||||
}
|
||||
outct(c_aud_ctl, XS1_CT_END);
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
#if SINGLE_XUA_EP_BUFFER
|
||||
case XUD_GetSetupData_Select(c_ep0_out, ep0_out, length, result):
|
||||
if (result == XUD_RES_OKAY)
|
||||
{
|
||||
/* Parse data buffer end populate SetupPacket struct */
|
||||
USB_ParseSetupPacket(sbuffer, sp);
|
||||
}
|
||||
debug_printf("ep0, result: %d, length: %d\n", result, length); //-1 reset, 0 ok, 1 error
|
||||
|
||||
XUA_Endpoint0_lite_loop(result, sp, c_ep0_out, c_ep0_in, c_audioControl, null/*mix*/, null/*clk*/, null/*EA*/, dfuInterface, &input_interface_num, &output_interface_num);
|
||||
XUD_SetReady_Out(ep0_out, sbuffer);
|
||||
break;
|
||||
#endif
|
||||
|
||||
//SOF
|
||||
case inuint_byref(c_sof, tmp):
|
||||
|
||||
Reference in New Issue
Block a user