From e2f84f77dbfbdff790c7edd0ef381473a38d07b7 Mon Sep 17 00:00:00 2001 From: Luciano Martin Date: Wed, 6 Dec 2017 15:40:05 +0000 Subject: [PATCH] - removed DFU and XUA_DFU flags and unified all the flags using XUA_DFU_EN --- lib_xua/api/xua_conf_default.h | 8 ++++---- lib_xua/src/core/audiohub/xua_audiohub.xc | 2 +- lib_xua/src/core/endpoint0/descriptor_defs.h | 2 +- lib_xua/src/core/endpoint0/xua_endpoint0.c | 18 ++++++++++-------- lib_xua/src/core/flashlib_user.c | 2 +- lib_xua/src/core/main.xc | 4 ++-- lib_xua/src/core/xua_ep0_descriptors.h | 14 +++++++------- 7 files changed, 26 insertions(+), 24 deletions(-) diff --git a/lib_xua/api/xua_conf_default.h b/lib_xua/api/xua_conf_default.h index 52a26abd..729ada18 100644 --- a/lib_xua/api/xua_conf_default.h +++ b/lib_xua/api/xua_conf_default.h @@ -412,10 +412,10 @@ * * Default: 1 (Enabled) */ -#if !defined(DFU) -#define DFU (1) -#elif defined(DFU) && (DFU == 0) -#undef DFU +#if !defined(XUA_DFU_EN) +#define XUA_DFU_EN (1) +#elif defined(XUA_DFU_EN) && (XUA_DFU_EN == 0) +#undef XUA_DFU_EN #endif /** diff --git a/lib_xua/src/core/audiohub/xua_audiohub.xc b/lib_xua/src/core/audiohub/xua_audiohub.xc index aec97f95..cd514f15 100755 --- a/lib_xua/src/core/audiohub/xua_audiohub.xc +++ b/lib_xua/src/core/audiohub/xua_audiohub.xc @@ -1379,7 +1379,7 @@ chanend c_dig_rx, curSamRes_DAC = inuint(c_mix_out); } -#if (XUA_DFU == 1) +#if (XUA_DFU_EN == 1) /* Currently no more audio will happen after this point */ if ((curSamFreq / AUD_TO_USB_RATIO) == AUDIO_STOP_FOR_DFU) { diff --git a/lib_xua/src/core/endpoint0/descriptor_defs.h b/lib_xua/src/core/endpoint0/descriptor_defs.h index cdf6f0da..3bc64f4d 100644 --- a/lib_xua/src/core/endpoint0/descriptor_defs.h +++ b/lib_xua/src/core/endpoint0/descriptor_defs.h @@ -44,7 +44,7 @@ enum USBInterfaceNumber #if defined(USB_CONTROL_DESCS) && (USB_CONTROL_DESCS != 0) INTERFACE_NUMBER_MISC_CONTROL, #endif -#if defined(DFU) && (DFU != 0) +#if defined(XUA_DFU_EN) && (XUA_DFU_EN != 0) INTERFACE_NUMBER_DFU, #endif #if defined(IAP) && (IAP != 0) diff --git a/lib_xua/src/core/endpoint0/xua_endpoint0.c b/lib_xua/src/core/endpoint0/xua_endpoint0.c index acdacaf6..61a6f3ae 100755 --- a/lib_xua/src/core/endpoint0/xua_endpoint0.c +++ b/lib_xua/src/core/endpoint0/xua_endpoint0.c @@ -11,6 +11,7 @@ #ifndef NO_USB #include "xud_device.h" /* Standard descriptor requests */ +#include "dfu_types.h" #include "usbaudio20.h" /* Defines from USB Audio 2.0 spec */ #include "xua_ep0_descriptors.h" /* This devices descriptors */ #include "commands.h" @@ -52,8 +53,8 @@ #warning DFU_PID not defined, Using PID_AUDIO_2. This is probably fine! #endif -#if (XUA_DFU == 1) -#include "dfu.h" +#if (XUA_DFU_EN == 1) +#include "xua_dfu.h" #define DFU_IF_NUM INPUT_INTERFACES + OUTPUT_INTERFACES + MIDI_INTERFACES + 1 extern void device_reboot(chanend); #endif @@ -281,7 +282,7 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, VendorAudioRequestsInit(c_audioControl, c_mix_ctl, c_clk_ctl); #endif -#if (XUA_DFU == 1) +#if (XUA_DFU_EN == 1) /* Check if device has started in DFU mode */ if (DFUReportResetState(null)) { @@ -547,7 +548,7 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, //unsigned request = (sp.bmRequestType.Recipient ) | (sp.bmRequestType.Type << 5); /* TODO Check on return value retval = */ -#if (XUA_DFU == 1) +#if (XUA_DFU_EN == 1) unsigned DFU_IF = INTERFACE_NUMBER_DFU; /* DFU interface number changes based on which mode we are currently running in */ @@ -587,7 +588,7 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, * - Audio endpoint request (Audio 1.0 Sampling freq requests are sent to the endpoint) */ if(((interfaceNum == 0) || (interfaceNum == 1) || (interfaceNum == 2)) -#if (XUA_DFU == 1) +#if (XUA_DFU_EN == 1) && !DFU_mode_active #endif ) @@ -639,7 +640,7 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, if(result == XUD_RES_ERR) { -#ifdef DFU +#if (XUA_DFU_EN == 1) if (!DFU_mode_active) { #endif @@ -750,8 +751,9 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, cfgDesc_Null, sizeof(cfgDesc_Null), (char**)&g_strTable, sizeof(g_strTable)/sizeof(char *), &sp, g_curUsbSpeed); #endif +#if (XUA_DFU_EN == 1) } -#if (XUA_DFU == 1) + else { /* Running in DFU mode - always return same descs for DFU whether HS or FS */ @@ -776,7 +778,7 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, g_curStreamAlt_Out = 0; g_curStreamAlt_In = 0; -#if (XUA_DFU == 1) +#if (XUA_DFU_EN == 1) if (DFUReportResetState(null)) { if (!DFU_mode_active) diff --git a/lib_xua/src/core/flashlib_user.c b/lib_xua/src/core/flashlib_user.c index e5bed8a1..8db8e08f 100644 --- a/lib_xua/src/core/flashlib_user.c +++ b/lib_xua/src/core/flashlib_user.c @@ -1,5 +1,5 @@ #include "xua.h" -#if (XUD_DFU == 1) +#if (XUA_DFU_EN == 1) #include "uac_hwresources.h" #include #include diff --git a/lib_xua/src/core/main.xc b/lib_xua/src/core/main.xc index c3a3d7fd..a69bc01d 100755 --- a/lib_xua/src/core/main.xc +++ b/lib_xua/src/core/main.xc @@ -558,7 +558,7 @@ int main() #define c_clk_ctl null #endif -#ifdef DFU +#if (XUA_DFU_EN == 1) interface i_dfu dfuInterface; #else #define dfuInterface null @@ -583,7 +583,7 @@ int main() { #if (XUD_TILE == 0) /* Check if USB is on the flash tile (tile 0) */ -#ifdef DFU +#if (XUA_DFU_EN == 1) [[distribute]] DFUHandler(dfuInterface, null); #endif diff --git a/lib_xua/src/core/xua_ep0_descriptors.h b/lib_xua/src/core/xua_ep0_descriptors.h index 67adf398..e6b71645 100644 --- a/lib_xua/src/core/xua_ep0_descriptors.h +++ b/lib_xua/src/core/xua_ep0_descriptors.h @@ -60,7 +60,7 @@ typedef struct STR_TABLE_ENTRY(adatClockSourceStr); /* iClockSource for external S/PDIF clock */ #endif #endif -#ifdef DFU +#if (XUA_DFU_EN == 1) STR_TABLE_ENTRY(dfuStr); /* iInterface for DFU interface */ #endif #ifdef USB_CONTROL_DESCS @@ -333,7 +333,7 @@ StringDescTable_t g_strTable = .adatClockSourceStr = APPEND_VENDOR_STR(ADAT Clock), #endif #endif -#ifdef DFU +#if (XUA_DFU_EN == 1) .dfuStr = APPEND_VENDOR_STR(DFU), #endif #ifdef USB_CONTROL_DESCS @@ -517,7 +517,7 @@ unsigned char devQualDesc_Null[] = #define MIDI_LENGTH (0) #endif -#ifdef DFU +#if (XUA_DFU_EN == 1) #define DFU_LENGTH (18) #else #define DFU_LENGTH (0) @@ -739,7 +739,7 @@ typedef struct unsigned char configDesc_Midi[MIDI_LENGTH]; #endif -#ifdef DFU +#if (XUA_DFU_EN == 1) /* DFU descriptors currently handled as a single block */ unsigned char configDesc_DFU[DFU_LENGTH]; #endif @@ -1978,7 +1978,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= }, #endif -#ifdef DFU +#if (XUA_DFU_EN == 1) /* Standard DFU class Interface descriptor */ {0x09, /* 0 bLength : Size of this descriptor, in bytes. (field size 1 bytes) */ 0x04, /* 1 bDescriptorType : INTERFACE descriptor. (field size 1 bytes) */ @@ -2268,7 +2268,7 @@ const unsigned num_freqs_a1 = MAX(3, (0 #define NUM_CONTROL_USB_INTERFACES 0 #endif -#if (DFU == 1) && (FORCE_UAC1_DFU == 1) +#if (XUA_DFU_EN == 1) && (FORCE_UAC1_DFU == 1) #define DFU_INTERFACE_BYTES 18 #define DFU_INTERFACES_A1 1 #else @@ -2741,7 +2741,7 @@ unsigned char cfgDesc_Audio1[] = 0x00, 0x00, /* Unused */ #endif -#if (DFU == 1) && (FORCE_UAC1_DFU == 1) +#if (XUA_DFU_EN == 1) && (FORCE_UAC1_DFU == 1) /* NOTE: By default we turn off DFU in UAC1.0 mode for a better user experiance in Windows */