diff --git a/lib_xua/api/xua_conf_default.h b/lib_xua/api/xua_conf_default.h index 969336a5..d2908342 100644 --- a/lib_xua/api/xua_conf_default.h +++ b/lib_xua/api/xua_conf_default.h @@ -242,10 +242,6 @@ #define AUDIO_CLASS_FALLBACK 0 /* Default to not falling back to UAC 1 */ #endif -#if defined(AUDIO_CLASS_FALLBACK) && (AUDIO_CLASS_FALLBACK==0) -#undef AUDIO_CLASS_FALLBACK -#endif - /** * @brief Whether or not to run UAC2 in full-speed. When disabled device can either operate in * UAC1 mode in full-speed (if AUDIO_CLASS_FALLBACK enabled) or return "null" descriptors. @@ -254,7 +250,7 @@ */ #if (AUDIO_CLASS == 2) /* Whether to run in Audio Class 2.0 mode in USB Full-speed */ - #if !defined(FULL_SPEED_AUDIO_2) && !defined(AUDIO_CLASS_FALLBACK) + #if !defined(FULL_SPEED_AUDIO_2) && (AUDIO_CLASS_FALLBACK == 0) #define FULL_SPEED_AUDIO_2 1 /* Default to falling back to UAC2 */ #endif #endif @@ -264,7 +260,7 @@ #endif /* Some checks on full-speed functionality */ -#if defined(FULL_SPEED_AUDIO_2) && defined(AUDIO_CLASS_FALLBACK) +#if defined(FULL_SPEED_AUDIO_2) && (AUDIO_CLASS_FALLBACK) #error FULL_SPEED_AUDIO_2 and AUDIO_CLASS_FALLBACK enabled! #endif @@ -498,7 +494,7 @@ * * Default: 0x0003 */ -#if (AUDIO_CLASS==1) || defined(AUDIO_CLASS_FALLBACK) || defined(__DOXYGEN__) +#if (AUDIO_CLASS == 1) || (AUDIO_CLASS_FALLBACK) || defined(__DOXYGEN__) #ifndef PID_AUDIO_1 #define PID_AUDIO_1 (0x0003) #endif diff --git a/lib_xua/src/core/endpoint0/xua_endpoint0.c b/lib_xua/src/core/endpoint0/xua_endpoint0.c index 443ea44d..b3ef87a0 100755 --- a/lib_xua/src/core/endpoint0/xua_endpoint0.c +++ b/lib_xua/src/core/endpoint0/xua_endpoint0.c @@ -39,13 +39,13 @@ /* Windows does not have a built in DFU driver (windows will prompt), so warn that DFU will not be functional in Audio 1.0 mode */ #ifndef FORCE_UAC1_DFU -#if ((AUDIO_CLASS==1) || defined(AUDIO_CLASS_FALLBACK)) && defined(DFU) +#if ((AUDIO_CLASS == 1) || (AUDIO_CLASS_FALLBACK)) && defined(DFU) #warning DFU will not be enabled in AUDIO 1.0 mode due to Windows requesting driver #endif #endif /* MIDI not supported in Audio 1.0 mode */ -#if ((AUDIO_CLASS==1) || defined(AUDIO_CLASS_FALLBACK)) && defined(MIDI) +#if ((AUDIO_CLASS == 1) || (AUDIO_CLASS_FALLBACK)) && defined(MIDI) #warning MIDI is currently not supported and will not be enabled in AUDIO 1.0 mode #endif @@ -529,7 +529,7 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, if ((epNum == ENDPOINT_ADDRESS_OUT_AUDIO) || (epNum == ENDPOINT_ADDRESS_IN_AUDIO)) { -#if (AUDIO_CLASS == 2) && defined(AUDIO_CLASS_FALLBACK) +#if (AUDIO_CLASS == 2) && (AUDIO_CLASS_FALLBACK) if(g_curUsbSpeed == XUD_SPEED_FS) { result = AudioEndpointRequests_1(ep0_out, ep0_in, &sp, c_audioControl, c_mix_ctl, c_clk_ctl); @@ -594,7 +594,7 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, #endif ) { -#if (AUDIO_CLASS == 2) && defined(AUDIO_CLASS_FALLBACK) +#if (AUDIO_CLASS == 2) && (AUDIO_CLASS_FALLBACK) if(g_curUsbSpeed == XUD_SPEED_HS) { result = AudioClassRequests_2(ep0_out, ep0_in, &sp, c_audioControl, c_mix_ctl, c_clk_ctl); @@ -645,7 +645,7 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, if (!DFU_mode_active) { #endif -#if defined(AUDIO_CLASS_FALLBACK) && (AUDIO_CLASS != 1) +#if (AUDIO_CLASS_FALLBACK) && (AUDIO_CLASS != 1) /* Return Audio 2.0 Descriptors with Audio 1.0 as fallback */ result = USB_StandardRequests(ep0_out, ep0_in, (unsigned char*)&devDesc_Audio2, sizeof(devDesc_Audio2), diff --git a/lib_xua/src/core/endpoint0/xua_ep0_descriptors.h b/lib_xua/src/core/endpoint0/xua_ep0_descriptors.h index bafa8529..b8d02afd 100644 --- a/lib_xua/src/core/endpoint0/xua_ep0_descriptors.h +++ b/lib_xua/src/core/endpoint0/xua_ep0_descriptors.h @@ -1,6 +1,6 @@ // Copyright (c) 2011-2018, XMOS Ltd, All rights reserved /** - * @file descriptors.h + * @file xua_ep0_descriptors.h * @brief Device Descriptors * @author Ross Owen, XMOS Limited */ @@ -43,7 +43,7 @@ typedef struct STR_TABLE_ENTRY(usbInputTermStr_Audio2); /* Users sees as output from host */ STR_TABLE_ENTRY(usbOutputTermStr_Audio2); /* User sees as input to host */ #endif -#if defined (AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS == 1) +#if (AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS == 1) /* Audio 1.0 Strings */ STR_TABLE_ENTRY(productStr_Audio1); /* Product string for Audio 1 */ STR_TABLE_ENTRY(outputInterfaceStr_Audio1); /* iInterface for streaming intefaces */ @@ -317,7 +317,7 @@ StringDescTable_t g_strTable = .usbInputTermStr_Audio2 = APPEND_PRODUCT_STR_A2(), .usbOutputTermStr_Audio2 = APPEND_PRODUCT_STR_A2(), #endif -#if defined (AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS == 1) +#if (AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS == 1) .productStr_Audio1 = PRODUCT_STR_A1, .outputInterfaceStr_Audio1 = APPEND_PRODUCT_STR_A1(), .inputInterfaceStr_Audio1 = APPEND_PRODUCT_STR_A1(), @@ -392,7 +392,7 @@ StringDescTable_t g_strTable = /***** Device Descriptors *****/ -#if defined(AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS==1) +#if (AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS == 1) /* Device Descriptor for Audio Class 1.0 (Assumes Full-Speed) */ USB_Descriptor_Device_t devDesc_Audio1 = { @@ -474,7 +474,7 @@ unsigned char devQualDesc_Audio2[] = 0x00 /* 9 bReserved (must be zero) */ }; -#if defined(AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS==1) +#if (AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS == 1) /* Device Qualifier Descriptor for running at high-speed (matches audio 1.0 device descriptor) */ unsigned char devQualDesc_Audio1[] = { @@ -2208,7 +2208,7 @@ unsigned char cfgDesc_Null[] = }; -#if defined (AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS == 1) +#if (AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS == 1) /* Configuration descriptor for Audio v1.0 */ /* Note Audio 1.0 descriptors still a simple array so we need some extra defines regarding lengths.. */ #if (NUM_USB_CHAN_IN > 0) diff --git a/lib_xua/src/core/endpoint0/xua_ep0_uacreqs.xc b/lib_xua/src/core/endpoint0/xua_ep0_uacreqs.xc index db52c8e9..d10dc437 100644 --- a/lib_xua/src/core/endpoint0/xua_ep0_uacreqs.xc +++ b/lib_xua/src/core/endpoint0/xua_ep0_uacreqs.xc @@ -1069,7 +1069,7 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c } -#if defined (AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS==1) +#if (AUDIO_CLASS_FALLBACK != 0) || (AUDIO_CLASS == 1) int AudioEndpointRequests_1(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, chanend c_audioControl, chanend ?c_mix_ctl, chanend ?c_clk_ctl) { diff --git a/lib_xua/src/core/warnings.xc b/lib_xua/src/core/warnings.xc index 7e071dbf..11ebb139 100644 --- a/lib_xua/src/core/warnings.xc +++ b/lib_xua/src/core/warnings.xc @@ -46,7 +46,7 @@ Warnings relating to configuration defines located in this XC source file rather #warning BCD_DEVICE not defined. Using XMOS release version number #endif -#if (AUDIO_CLASS==1) || defined(AUDIO_CLASS_FALLBACK) +#if (AUDIO_CLASS == 1) || (AUDIO_CLASS_FALLBACK) #ifndef PID_AUDIO_1 #warning PID_AUDIO_1 not defined. Using 0x0003 #endif