diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6daa9709..765da1a4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,7 @@ lib_xua Change Log * CHANGED: HID event ID from list to bit and byte location in HID Report * CHANGED: Interface to UserHIDRecordEvent() * ADDED: Support for multiple flash specs defined by DFU_FLASH_DEVICE + * ADDED: Nullable c_aud_ctl chan-end optimisation for fixed rate devices 1.3.0 ----- diff --git a/lib_xua/api/xua_endpoint0.h b/lib_xua/api/xua_endpoint0.h index b7cfdfc6..05d56d6d 100644 --- a/lib_xua/api/xua_endpoint0.h +++ b/lib_xua/api/xua_endpoint0.h @@ -15,7 +15,10 @@ * \param c_ep0_out Chanend connected to the XUD_Manager() out endpoint array * \param c_ep0_in Chanend connected to the XUD_Manager() in endpoint array * \param c_audioCtrl Chanend connected to the decouple thread for control - * audio (sample rate changes etc.) + * audio (sample rate changes etc.). Note when nulled, the + * audio device only supports single sample rate/format and + * DFU is not supported either since this channel is used + * to carry messages about format, rate and DFU state * \param c_mix_ctl Optional chanend to be connected to the mixer thread if * present * \param c_clk_ctl Optional chanend to be connected to the clockgen thread if @@ -25,7 +28,7 @@ * \param c_EANativeTransport_ctrl Optional chanend to be connected to EA Native * endpoint manager if present */ -void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioCtrl, +void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend ?c_audioCtrl, chanend ?c_mix_ctl,chanend ?c_clk_ctl, chanend ?c_EANativeTransport_ctr, client interface i_dfu ?dfuInterface VENDOR_REQUESTS_PARAMS_DEC_); diff --git a/lib_xua/src/core/endpoint0/vendorrequests.c b/lib_xua/src/core/endpoint0/vendorrequests.c index 66a1ac09..e5384b9c 100644 --- a/lib_xua/src/core/endpoint0/vendorrequests.c +++ b/lib_xua/src/core/endpoint0/vendorrequests.c @@ -7,12 +7,12 @@ #include "vendorrequests.h" int VendorAudioRequests(XUD_ep ep0_out, XUD_ep ep0_in, unsigned char bRequest, unsigned char cs, unsigned char cn, - unsigned short unitId, unsigned char direction, chanend c_audioControl, + unsigned short unitId, unsigned char direction, NULLABLE_RESOURCE(chanend, c_audioControl), NULLABLE_RESOURCE(chanend, c_mix_ctl), NULLABLE_RESOURCE(chanend, c_clk_ctL)) __attribute__ ((weak)); int VendorAudioRequests(XUD_ep ep0_out, XUD_ep ep0_in, unsigned char bRequest, unsigned char cs, unsigned char cn, - unsigned short unitId, unsigned char direction, chanend c_audioControl, + unsigned short unitId, unsigned char direction, NULLABLE_RESOURCE(chanend, c_audioControl), NULLABLE_RESOURCE(chanend, c_mix_ctl), NULLABLE_RESOURCE(chanend, c_clk_ctL)) { diff --git a/lib_xua/src/core/endpoint0/vendorrequests.h b/lib_xua/src/core/endpoint0/vendorrequests.h index c241011d..d00a5873 100644 --- a/lib_xua/src/core/endpoint0/vendorrequests.h +++ b/lib_xua/src/core/endpoint0/vendorrequests.h @@ -33,7 +33,7 @@ #endif int VendorAudioRequests(XUD_ep ep0_out, XUD_ep ep0_in, unsigned char bRequest, unsigned char cs, unsigned char cn, - unsigned short unitId, unsigned char direction, chanend c_audioControl, + unsigned short unitId, unsigned char direction, NULLABLE_RESOURCE(chanend, c_audioControl), NULLABLE_RESOURCE(chanend, c_mix_ctl), NULLABLE_RESOURCE(chanend, c_clk_ctL)); diff --git a/lib_xua/src/core/endpoint0/xua_endpoint0.c b/lib_xua/src/core/endpoint0/xua_endpoint0.c index 9af03eb2..a89f6330 100755 --- a/lib_xua/src/core/endpoint0/xua_endpoint0.c +++ b/lib_xua/src/core/endpoint0/xua_endpoint0.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "xua.h" #if XUA_USB_EN @@ -394,7 +395,7 @@ void XUA_Endpoint0_setBcdDevice(unsigned short bcd) { #endif // AUDIO_CLASS == 1} } -void XUA_Endpoint0_init(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, +void XUA_Endpoint0_init(chanend c_ep0_out, chanend c_ep0_in, NULLABLE_RESOURCE(chanend, c_audioControl), chanend c_mix_ctl, chanend c_clk_ctl, chanend c_EANativeTransport_ctrl, CLIENT_INTERFACE(i_dfu, dfuInterface) VENDOR_REQUESTS_PARAMS_DEC_) { ep0_out = XUD_InitEp(c_ep0_out); @@ -481,6 +482,8 @@ void XUA_Endpoint0_init(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioCont /* Check if device has started in DFU mode */ if (DFUReportResetState(null)) { + assert((c_audioControl != NULL) && msg("DFU not supported when c_audioControl is null")); + /* Stop audio */ outuint(c_audioControl, SET_SAMPLE_FREQ); outuint(c_audioControl, AUDIO_STOP_FOR_DFU); @@ -539,7 +542,7 @@ void XUA_Endpoint0_init(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioCont } -void XUA_Endpoint0_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, +void XUA_Endpoint0_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0_out, chanend c_ep0_in, NULLABLE_RESOURCE(chanend, c_audioControl), chanend c_mix_ctl, chanend c_clk_ctl, chanend c_EANativeTransport_ctrl, CLIENT_INTERFACE(i_dfu, dfuInterface) VENDOR_REQUESTS_PARAMS_DEC_) { if (result == XUD_RES_OKAY) @@ -566,6 +569,7 @@ void XUA_Endpoint0_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0 /* Only send change if we need to */ if((sp.wValue > 0) && (g_curStreamAlt_Out != sp.wValue)) { + assert((c_audioControl != null) && msg("Format change not supported when c_audioControl is null")); g_curStreamAlt_Out = sp.wValue; /* Send format of data onto buffering */ @@ -601,6 +605,7 @@ void XUA_Endpoint0_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0 /* Only send change if we need to */ if((sp.wValue > 0) && (g_curStreamAlt_In != sp.wValue)) { + assert((c_audioControl != null) && msg("Format change not supported when c_audioControl is null")); g_curStreamAlt_In = sp.wValue; /* Send format of data onto buffering */ @@ -845,6 +850,7 @@ void XUA_Endpoint0_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0 if ((DFU_IF == INTERFACE_NUMBER_DFU) && (sp.bRequest != XMOS_DFU_SAVESTATE) && (sp.bRequest != XMOS_DFU_RESTORESTATE)) { + assert((c_audioControl != null) && msg("DFU not supported when c_audioControl is null")); // Stop audio outuint(c_audioControl, SET_SAMPLE_FREQ); outuint(c_audioControl, AUDIO_STOP_FOR_DFU); @@ -1087,7 +1093,7 @@ void XUA_Endpoint0_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0 } /* Endpoint 0 function. Handles all requests to the device */ -void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, +void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, NULLABLE_RESOURCE(chanend, c_audioControl), chanend c_mix_ctl, chanend c_clk_ctl, chanend c_EANativeTransport_ctrl, CLIENT_INTERFACE(i_dfu, dfuInterface) VENDOR_REQUESTS_PARAMS_DEC_) { USB_SetupPacket_t sp;