From 22a6a2505a5d22804cd6f0a3a7a0f2bfdbad6ef6 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 4 Oct 2022 11:24:31 +0100 Subject: [PATCH 1/2] Define SELF_POWERED changed to XUA_POWERMODE and associated defines (#291) Define SELF_POWERED changed to XUA_POWERMODE and associated defines --- CHANGELOG.rst | 2 + lib_xua/api/xua_conf_default.h | 37 +++++++------------ .../src/core/endpoint0/xua_ep0_descriptors.h | 12 +++--- lib_xua/src/core/main.xc | 5 ++- 4 files changed, 24 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8c592a0a..da23763f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,8 @@ UNRELEASED * CHANGED: Define ADAT_RX renamed to XUA_ADAT_RX_EN * CHANGED: Define ADAT_TX renamed to XUA_ADAT_TX_EN * CHANGED: Define SPDIF_RX renamed to XUA_SPDIF_RX_EN + * CHANGED: Define SELF_POWERED changed to XUA_POWERMODE and associated + defines * CHANGED: Drive strength of I2S clock lines upped to 8mA on xCORE.ai * CHANGED: ADC datalines sampled on falling edge of clock in TDM mode * CHANGED: Improved startup behaviour of TDM clocks diff --git a/lib_xua/api/xua_conf_default.h b/lib_xua/api/xua_conf_default.h index d85806de..7d426f07 100644 --- a/lib_xua/api/xua_conf_default.h +++ b/lib_xua/api/xua_conf_default.h @@ -957,43 +957,32 @@ /* Power */ +#define XUA_POWERMODE_SELF (0) +#define XUA_POWERMODE_BUS (1) /** - * @brief Report as self to the host when enabled, else reports as bus-powered. This affects descriptors - * and XUD usage. + * @brief Report as self or bus powered device. This affects descriptors + * and XUD usage and is important for USB compliance * - * Default: 0 (Disabled) + * Default: XUA_POWERMODE_BUS */ -#ifndef SELF_POWERED -#define SELF_POWERED (0) -#endif - -/* Tidy-up historical ifndef usage */ -#if defined(SELF_POWERED) && (SELF_POWERED==0) -#undef SELF_POWERED +#ifndef XUA_POWERMODE +#define XUA_POWERMODE XUA_POWERMODE_BUS #endif /** * @brief Power drawn from the host (in mA x 2) * - * Default: 0 when SELF_POWERED enabled else 250 (500mA) + * Default: 0 when self-powered, else 250 (500mA) */ -#ifdef SELF_POWERED +#if (XUA_POWERMODE == XUA_POWERMODE_SELF) /* Default to taking no power from the bus in self-powered mode */ - #ifndef BMAX_POWER - #define BMAX_POWER 0 + #ifndef _XUA_BMAX_POWER + #define _XUA_BMAX_POWER (0) #endif #else /* Default to taking 500mA from the bus in bus-powered mode */ - #ifndef BMAX_POWER - #define BMAX_POWER 250 - #endif -#endif - -#ifndef XUD_PWR_CFG - #ifdef SELF_POWERED - #define XUD_PWR_CFG XUD_PWR_SELF - #else - #define XUD_PWR_CFG XUD_PWR_BUS + #ifndef _XUA_BMAX_POWER + #define _XUA_BMAX_POWER (250) #endif #endif diff --git a/lib_xua/src/core/endpoint0/xua_ep0_descriptors.h b/lib_xua/src/core/endpoint0/xua_ep0_descriptors.h index d5ab31c0..c4ddcbe4 100644 --- a/lib_xua/src/core/endpoint0/xua_ep0_descriptors.h +++ b/lib_xua/src/core/endpoint0/xua_ep0_descriptors.h @@ -806,12 +806,12 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= .bNumInterfaces = INTERFACE_COUNT, .bConfigurationValue = 0x01, .iConfiguration = 0x00, -#ifdef SELF_POWERED +#if (XUA_POWERMODE == XUA_POWERMODE_SELF) .bmAttributes = 192, #else .bmAttributes = 128, #endif - .bMaxPower = BMAX_POWER, + .bMaxPower = _XUA_BMAX_POWER, }, .Audio_InterfaceAssociation = @@ -2239,12 +2239,12 @@ unsigned char cfgDesc_Null[] = 0x01, /* 4 bNumInterface: Number of interfaces*/ 0x01, /* 5 bConfigurationValue */ 0x00, /* 6 iConfiguration */ -#ifdef SELF_POWERED +#if (XUA_POWERMODE == XUA_POWERMODE_SELF) 192, /* 7 bmAttributes */ #else 128, #endif - BMAX_POWER, /* 8 bMaxPower */ + _XUA_BMAX_POWER, /* 8 bMaxPower */ 0x09, /* 0 bLength : Size of this descriptor, in bytes. (field size 1 bytes) */ 0x04, /* 1 bDescriptorType : INTERFACE descriptor. (field size 1 bytes) */ @@ -2399,12 +2399,12 @@ unsigned char cfgDesc_Audio1[] = NUM_INTERFACES_A1, /* numInterfaces - we dont support MIDI in audio 1.0 mode*/ 0x01, /* ID of this configuration */ 0x00, /* Unused */ -#ifdef SELF_POWERED +#if (XUA_POWERMODE == XUA_POWERMODE_SELF) 192, /* 7 bmAttributes */ #else 128, /* 7 bmAttributes */ #endif - BMAX_POWER, /* 8 bMaxPower */ + _XUA_BMAX_POWER, /* 8 bMaxPower */ /* Standard AC interface descriptor */ 0x09, diff --git a/lib_xua/src/core/main.xc b/lib_xua/src/core/main.xc index 7e2aacf5..31f92abf 100755 --- a/lib_xua/src/core/main.xc +++ b/lib_xua/src/core/main.xc @@ -309,10 +309,11 @@ VENDOR_REQUESTS_PARAMS_DEC_ /* Run UAC2.0 at high-speed, UAC1.0 at full-speed */ unsigned usbSpeed = (AUDIO_CLASS == 2) ? XUD_SPEED_HS : XUD_SPEED_FS; - + unsigned xudPwrCfg = (XUA_POWERMODE == XUA_POWERMODE_SELF) ? XUD_PWR_SELF : XUD_PWR_BUS; + /* USB Interface Core */ XUD_Main(c_xud_out, ENDPOINT_COUNT_OUT, c_xud_in, ENDPOINT_COUNT_IN, - c_sof, epTypeTableOut, epTypeTableIn, usbSpeed, XUD_PWR_CFG); + c_sof, epTypeTableOut, epTypeTableIn, usbSpeed, xudPwrCfg); } /* USB Packet buffering Core */ From 77b20c13dcb738f5729647fc72509d589788d52f Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Fri, 7 Oct 2022 11:22:19 +0100 Subject: [PATCH 2/2] Add lib_adat to dep list (#293) Add lib_adat to dep list --- lib_xua/module_build_info | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_xua/module_build_info b/lib_xua/module_build_info index 7d9f5ddd..eecbfd34 100644 --- a/lib_xua/module_build_info +++ b/lib_xua/module_build_info @@ -13,7 +13,8 @@ DEPENDENT_MODULES = lib_locks(>=2.1.0) \ lib_mic_array(>=4.5.0) \ lib_spdif(>=4.1.0) \ lib_xassert(>=4.1.0) \ - lib_xud(>=2.1.0) + lib_xud(>=2.1.0) \ + lib_adat(>=1.0.0) MODULE_XCC_FLAGS = $(XCC_FLAGS) \ -O3 \