diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 720f1317..d2c812a0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,8 @@ UNRELEASED ---------- * CHANGED: Updated tests to use lib_locks (was legacy module_locks) + * CHANGED: Exclude HID Report functions unless the HID feature is enabled + * FIXED: Incorrect conditional compilation of HID report code * Changes to dependencies: diff --git a/Jenkinsfile b/Jenkinsfile index 61fd5394..76de12f2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ -@Library('xmos_jenkins_shared_library@v0.16.2') _ +@Library('xmos_jenkins_shared_library@v0.18.0') _ getApproval() diff --git a/legacy_tests/app_test_i2s_loopback/Makefile b/legacy_tests/app_test_i2s_loopback/Makefile index 81a8e145..c3e3ab40 100644 --- a/legacy_tests/app_test_i2s_loopback/Makefile +++ b/legacy_tests/app_test_i2s_loopback/Makefile @@ -1,7 +1,5 @@ -# Copyright (c) 2016, XMOS Ltd, All rights reserved TARGET = xk-audio-216-mc.xn -USED_MODULES = lib_xua \ - module_i2c_shared module_i2c_single_port lib_logging +USED_MODULES = lib_xua lib_i2c lib_logging BUILD_FLAGS = -O0 -g -lflash -DXUD_SERIES_SUPPORT=4 -DXUD_CORE_CLOCK=600 -fxscope -save-temps -march=xs2a -DUSB_TILE=tile[1] diff --git a/legacy_tests/app_test_i2s_loopback/xk_216_mc/audiohw.xc b/legacy_tests/app_test_i2s_loopback/xk_216_mc/audiohw.xc index 3a8cde53..ed1d5f7e 100644 --- a/legacy_tests/app_test_i2s_loopback/xk_216_mc/audiohw.xc +++ b/legacy_tests/app_test_i2s_loopback/xk_216_mc/audiohw.xc @@ -1,4 +1,4 @@ -// Copyright 2016-2021 XMOS LIMITED. +// Copyright 2016-2022 XMOS LIMITED. // This Software is subject to the terms of the XMOS Public Licence: Version 1. #ifdef HARDWARE @@ -8,7 +8,7 @@ #include "devicedefines.h" #include #include "gpio_access.h" -#include "i2c_shared.h" +#include "i2c.h" #include "cs4384.h" #include "cs5368.h" #include "cs2100.h" @@ -25,16 +25,10 @@ on tile[0] : out port p_gpio = XS1_PORT_8C; -#ifndef IAP -/* If IAP not enabled, i2c ports not declared - still needs for DAC config */ -on tile [0] : struct r_i2c r_i2c = {XS1_PORT_4A}; -#else -extern struct r_i2c r_i2c; -#endif +port p_i2c = on tile[0]:PORT_I2C; -#define DAC_REGWRITE(reg, val) {data[0] = val; i2c_shared_master_write_reg(r_i2c, CS4384_I2C_ADDR, reg, data, 1);} -#define DAC_REGREAD(reg, val) {i2c_shared_master_read_reg(r_i2c, CS4384_I2C_ADDR, reg, val, 1);} -#define ADC_REGWRITE(reg, val) {data[0] = val; i2c_shared_master_write_reg(r_i2c, CS5368_I2C_ADDR, reg, data, 1);} +#define DAC_REGWRITE(reg, val) {result = i2c.write_reg(CS4384_I2C_ADDR, reg, val);} +#define ADC_REGWRITE(reg, val) {result = i2c.write_reg(CS5368_I2C_ADDR, reg, val);} #ifdef USE_FRACTIONAL_N @@ -45,14 +39,15 @@ extern struct r_i2c r_i2c; #define PLL_SYNC_FREQ 300 #endif -#define CS2100_REGREAD(reg, data) {data[0] = 0xAA; i2c_master_read_reg(CS2100_I2C_DEVICE_ADDR, reg, data, 1, r_i2c);} -#define CS2100_REGREAD_ASSERT(reg, data, expected) {data[0] = 0xAA; i2c_master_read_reg(CS2100_I2C_DEVICE_ADDR, reg, data, 1, r_i2c); assert(data[0] == expected);} -#define CS2100_REGWRITE(reg, val) {data[0] = val; i2c_master_write_reg(CS2100_I2C_DEVICE_ADDR, reg, data, 1, r_i2c);} +#define CS2100_REGREAD(reg, data) {data[0] = i2c.read_reg(CS2100_I2C_DEVICE_ADDR, reg, result);} +#define CS2100_REGREAD_ASSERT(reg, data, expected) {data[0] = i2c.read_reg(CS2100_I2C_DEVICE_ADDR, reg, result); assert(data[0] == expected);} +#define CS2100_REGWRITE(reg, val) {result = i2c.write_reg(CS2100_I2C_DEVICE_ADDR, reg, val);} /* Init of CS2100 */ -void PllInit(void) +void PllInit(client interface i2c_master_if i2c) { unsigned char data[1] = {0}; + i2c_regop_res_t result; #if XCORE_200_MC_AUDIO_HW_VERSION < 2 /* Enable init */ @@ -73,12 +68,15 @@ void PllInit(void) CS2100_REGREAD_ASSERT(CS2100_GLOBAL_CONFIG, data, 0x01); CS2100_REGREAD_ASSERT(CS2100_FUNC_CONFIG_1, data, 0x08); CS2100_REGREAD_ASSERT(CS2100_FUNC_CONFIG_2, data, 0x00); + + i2c.shutdown(); } /* Setup PLL multiplier */ -void PllMult(unsigned output, unsigned ref) +void PllMult(unsigned output, unsigned ref, client interface i2c_master_if i2c) { unsigned char data[1] = {0}; + i2c_regop_res_t result; /* PLL expects 12:20 format, convert output and ref to 12:20 */ /* Shift up the dividend by 12 to retain format... */ @@ -120,9 +118,6 @@ void AudioHwInit(chanend ?c_codec) start_clock(clk_pll_sync); #endif - /* Init the i2c module */ - i2c_shared_master_init(r_i2c); - /* Assert reset to ADC and DAC */ set_gpio(P_GPIO_DAC_RST_N, 0); set_gpio(P_GPIO_ADC_RST_N, 0); @@ -143,7 +138,12 @@ void AudioHwInit(chanend ?c_codec) set_gpio(P_GPIO_PLL_SEL, 1); /* Initialise external PLL */ - PllInit(); + i2c_master_if i2c[1]; + par + { + i2c_master_single_port(i2c, 1, p_i2c, 10, 0, 1, 0); + PllInit(i2c[0]); + } #endif #ifdef IAP @@ -155,10 +155,11 @@ void AudioHwInit(chanend ?c_codec) /* Configures the external audio hardware for the required sample frequency. * See gpio.h for I2C helper functions and gpio access */ -void AudioHwConfig(unsigned samFreq, unsigned mClk, chanend ?c_codec, unsigned dsdMode, - unsigned sampRes_DAC, unsigned sampRes_ADC) +void AudioHwConfig2(unsigned samFreq, unsigned mClk, chanend ?c_codec, unsigned dsdMode, + unsigned sampRes_DAC, unsigned sampRes_ADC, client interface i2c_master_if i2c) { - unsigned char data[1] = {0}; + unsigned char data[1] = {0}; + i2c_regop_res_t result; /* Put ADC and DAC into reset */ set_gpio(P_GPIO_ADC_RST_N, 0); @@ -167,7 +168,7 @@ void AudioHwConfig(unsigned samFreq, unsigned mClk, chanend ?c_codec, unsigned d /* Set master clock select appropriately */ #if defined(USE_FRACTIONAL_N) /* Configure external fractional-n clock multiplier for 300Hz -> mClkFreq */ - PllMult(mClk, PLL_SYNC_FREQ); + PllMult(mClk, PLL_SYNC_FREQ, i2c); #endif /* Allow some time for mclk to lock and MCLK to stabilise - this is important to avoid glitches at start of stream */ { @@ -365,8 +366,20 @@ void AudioHwConfig(unsigned samFreq, unsigned mClk, chanend ?c_codec, unsigned d DAC_REGWRITE(CS4384_MODE_CTRL, 0b10000000); } #endif + + i2c.shutdown(); return; } -//: + +void AudioHwConfig(unsigned samFreq, unsigned mClk, chanend ?c_codec, unsigned dsdMode, + unsigned sampRes_DAC, unsigned sampRes_ADC) +{ + i2c_master_if i2c[1]; + par + { + i2c_master_single_port(i2c, 1, p_i2c, 10, 0, 1, 0); + AudioHwConfig2(samFreq, mClk, c_codec, dsdMode, sampRes_DAC, sampRes_ADC, i2c[0]); + } +} #endif diff --git a/lib_xua/src/core/buffer/decouple/decouple.xc b/lib_xua/src/core/buffer/decouple/decouple.xc index f22f9582..56f331bd 100644 --- a/lib_xua/src/core/buffer/decouple/decouple.xc +++ b/lib_xua/src/core/buffer/decouple/decouple.xc @@ -747,29 +747,32 @@ void XUA_Buffer_Decouple(chanend c_mix_out inuint(c_mix_out); outct(c_mix_out, SET_SAMPLE_FREQ); outuint(c_mix_out, sampFreq); - - inUnderflow = 1; - SET_SHARED_GLOBAL(g_aud_to_host_rdptr, aud_to_host_fifo_start); - SET_SHARED_GLOBAL(g_aud_to_host_wrptr, aud_to_host_fifo_start); - SET_SHARED_GLOBAL(g_aud_to_host_dptr,aud_to_host_fifo_start+4); - - /* Set buffer to send back to zeros buffer */ - SET_SHARED_GLOBAL(g_aud_to_host_buffer, g_aud_to_host_zeros); - - /* Update size of zeros buffer (and sampsToWrite) */ - SetupZerosSendBuffer(aud_to_host_usb_ep, sampFreq, g_curSubSlot_In); - - /* Reset OUT buffer state */ - outUnderflow = 1; - SET_SHARED_GLOBAL(g_aud_from_host_rdptr, aud_from_host_fifo_start); - SET_SHARED_GLOBAL(g_aud_from_host_wrptr, aud_from_host_fifo_start); - SET_SHARED_GLOBAL(aud_data_remaining_to_device, 0); - - if(outOverflow) + + if(sampFreq != AUDIO_STOP_FOR_DFU) { - /* If we were previously in overflow we wont have marked as ready */ - XUD_SetReady_OutPtr(aud_from_host_usb_ep, aud_from_host_fifo_start+4); - outOverflow = 0; + inUnderflow = 1; + SET_SHARED_GLOBAL(g_aud_to_host_rdptr, aud_to_host_fifo_start); + SET_SHARED_GLOBAL(g_aud_to_host_wrptr, aud_to_host_fifo_start); + SET_SHARED_GLOBAL(g_aud_to_host_dptr,aud_to_host_fifo_start+4); + + /* Set buffer to send back to zeros buffer */ + SET_SHARED_GLOBAL(g_aud_to_host_buffer, g_aud_to_host_zeros); + + /* Update size of zeros buffer (and sampsToWrite) */ + SetupZerosSendBuffer(aud_to_host_usb_ep, sampFreq, g_curSubSlot_In); + + /* Reset OUT buffer state */ + outUnderflow = 1; + SET_SHARED_GLOBAL(g_aud_from_host_rdptr, aud_from_host_fifo_start); + SET_SHARED_GLOBAL(g_aud_from_host_wrptr, aud_from_host_fifo_start); + SET_SHARED_GLOBAL(aud_data_remaining_to_device, 0); + + if(outOverflow) + { + /* If we were previously in overflow we wont have marked as ready */ + XUD_SetReady_OutPtr(aud_from_host_usb_ep, aud_from_host_fifo_start+4); + outOverflow = 0; + } } /* Wait for handshake back and pass back up */ @@ -780,7 +783,8 @@ void XUA_Buffer_Decouple(chanend c_mix_out ENABLE_INTERRUPTS(); - speedRem = 0; + if(sampFreq != AUDIO_STOP_FOR_DFU) + speedRem = 0; continue; } #if (AUDIO_CLASS == 2) diff --git a/lib_xua/src/core/buffer/ep/ep_buffer.xc b/lib_xua/src/core/buffer/ep/ep_buffer.xc index a9a9a9a1..fbdbddb0 100644 --- a/lib_xua/src/core/buffer/ep/ep_buffer.xc +++ b/lib_xua/src/core/buffer/ep/ep_buffer.xc @@ -1104,6 +1104,9 @@ void XUA_Buffer_Ep(register chanend c_aud_out, break; } break; +#endif // if IAP_EA_NATIVE_TRANS + +#endif // ifdef IAP default: #if ( 0 < HID_CONTROLS ) @@ -1125,9 +1128,6 @@ void XUA_Buffer_Ep(register chanend c_aud_out, #endif break; //:: -#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 d8513888..bd5c50c2 100644 --- a/lib_xua/src/core/endpoint0/xua_ep0_descriptors.h +++ b/lib_xua/src/core/endpoint0/xua_ep0_descriptors.h @@ -1,4 +1,4 @@ -// Copyright 2011-2021 XMOS LIMITED. +// Copyright 2011-2022 XMOS LIMITED. // This Software is subject to the terms of the XMOS Public Licence: Version 1. /** * @file xua_ep0_descriptors.h @@ -2331,9 +2331,10 @@ const unsigned num_freqs_a1 = MAX(3, (0 #define CFG_TOTAL_LENGTH_A1 (18 + AC_TOTAL_LENGTH + (INPUT_INTERFACES_A1 * (49 + num_freqs_a1 * 3)) + (OUTPUT_INTERFACES_A1 * (49 + num_freqs_a1 * 3)) + CONTROL_INTERFACE_BYTES + DFU_INTERFACE_BYTES + HID_INTERFACE_BYTES) #endif +#define INTERFACE_DESCRIPTOR_BYTES (9) + #ifdef XUA_USB_DESCRIPTOR_OVERWRITE_RATE_RES #define AS_INTERFACE_BYTES (7) - #define INTERFACE_DESCRIPTOR_BYTES (9) #define AS_FORMAT_TYPE_BYTES (17) #define USB_AS_IN_INTERFACE_DESCRIPTOR_OFFSET_SUB_FRAME (18 + AC_TOTAL_LENGTH + (OUTPUT_INTERFACES_A1 * (49 + num_freqs_a1 * 3)) + (2*INTERFACE_DESCRIPTOR_BYTES) + (AS_INTERFACE_BYTES) + 5) #define USB_AS_OUT_INTERFACE_DESCRIPTOR_OFFSET_SUB_FRAME (18 + AC_TOTAL_LENGTH + (2*INTERFACE_DESCRIPTOR_BYTES) + (AS_INTERFACE_BYTES) + 5) diff --git a/lib_xua/src/core/endpoint0/xua_ep0_uacreqs.xc b/lib_xua/src/core/endpoint0/xua_ep0_uacreqs.xc index 18d53f4d..03803423 100644 --- a/lib_xua/src/core/endpoint0/xua_ep0_uacreqs.xc +++ b/lib_xua/src/core/endpoint0/xua_ep0_uacreqs.xc @@ -1,4 +1,4 @@ -// Copyright 2011-2021 XMOS LIMITED. +// Copyright 2011-2022 XMOS LIMITED. // This Software is subject to the terms of the XMOS Public Licence: Version 1. /** * @brief Implements relevant requests from the USB Audio 2.0 Specification @@ -1280,6 +1280,9 @@ XUD_Result_t AudioClassRequests_1(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket buffer[0] = (VOLUME_RES_MIXER & 0xff); buffer[1] = (VOLUME_RES_MIXER >> 8); return XUD_DoGetRequest(ep0_out, ep0_in, buffer, 2, sp.wLength); + + default: + break; } #endif return XUD_RES_ERR; diff --git a/lib_xua/src/hid/hid_report.c b/lib_xua/src/hid/hid_report.c index 02c8122c..587840c4 100644 --- a/lib_xua/src/hid/hid_report.c +++ b/lib_xua/src/hid/hid_report.c @@ -1,5 +1,8 @@ // Copyright 2021-2022 XMOS LIMITED. // This Software is subject to the terms of the XMOS Public Licence: Version 1. +#include "xua_conf_full.h" +#if( 0 < HID_CONTROLS ) + #include #include #include @@ -851,3 +854,5 @@ unsigned hidReportValidate( void ) return hidReportValidateInfoStruct( &info ); } } + +#endif // ( 0 < HID_CONTROLS ) diff --git a/module_locks/README.rst b/module_locks/README.rst deleted file mode 100644 index ecde319a..00000000 --- a/module_locks/README.rst +++ /dev/null @@ -1,7 +0,0 @@ -module_locks Readme -=================== - -:scope: Dummy module -:description: Allows compiling legacy_tests in lib_xua with lib_locks. sc_i2c is used in the tests and it requires module_locks from sc_util, but the definitions in sc_utils conflict with the ones in lib_locks. -:keywords: dummy -:boards: XMOS Dev Kit diff --git a/module_locks/module_build_info b/module_locks/module_build_info deleted file mode 100644 index d90ffd43..00000000 --- a/module_locks/module_build_info +++ /dev/null @@ -1 +0,0 @@ -# Dummy module used in legacy_tests. See README.rst for more details. diff --git a/tests/xua_unit_tests/CMakeLists.txt b/tests/xua_unit_tests/CMakeLists.txt index 9487a471..6bccf6d6 100644 --- a/tests/xua_unit_tests/CMakeLists.txt +++ b/tests/xua_unit_tests/CMakeLists.txt @@ -49,6 +49,7 @@ foreach( testsourcefile ${APP_SOURCES} ) "-fxscope" "-target=XCORE-AI-EXPLORER" "${CMAKE_CURRENT_SOURCE_DIR}/config.xscope" + "-DHID_CONTROLS=1" "-DUNITY_SUPPORT_64" "-DUNITY_INCLUDE_DOUBLE" ) diff --git a/tests/xua_unit_tests/wscript b/tests/xua_unit_tests/wscript index da0e1fc2..a31dbfaf 100644 --- a/tests/xua_unit_tests/wscript +++ b/tests/xua_unit_tests/wscript @@ -230,6 +230,7 @@ def build(bld): makefile_opts['XCC_FLAGS'] = ['-O2', '-g', '-Wall', + '-DHID_CONTROLS=1', '-DUNITY_SUPPORT_64', '-DUNITY_INCLUDE_DOUBLE', '-DXUD_CORE_CLOCK=600',