Allow nullable chanend and insert asserts to capture invalid use

This commit is contained in:
Ed
2021-07-06 15:05:21 +01:00
parent 364efa72c3
commit 65103d8c88
5 changed files with 14 additions and 7 deletions

View File

@@ -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
-----

View File

@@ -25,7 +25,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_);

View File

@@ -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))
{

View File

@@ -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));

View File

@@ -10,6 +10,7 @@
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <xassert.h>
#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(!isnull(c_audioControl) && 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(!isnull(c_audioControl) && 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(!isnull(c_audioControl) && 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(!isnull(c_audioControl) && 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;