8 Commits

Author SHA1 Message Date
3d9006f5e7 将 Analogue 1~8 改为 Playback 1~8 2024-02-01 09:50:06 +08:00
Virgil_lai
460b5d11e0 修改字符串描述 2024-01-30 13:35:48 +08:00
Virgil_lai
b29e6ffa91 增加MAC电脑连接的指示 2023-12-28 22:13:33 +08:00
Virgil_lai
a336bec81b 改成得胜使用的hid描述 2023-12-12 09:14:49 +08:00
Virgil_lai
791c142c94 add pawpaw user_hid_ctrl api 2023-12-11 15:03:16 +08:00
Virgil_lai
487ab06213 add pawpaw hid code 2023-12-08 00:34:32 +08:00
Virgil_lai
def348a763 add EXTRA_I2S_ADC option 2023-12-06 11:10:45 +08:00
Virgil_lai
c9f7738efd add USER_UNSAFE_USE 2023-12-05 20:07:09 +08:00
19 changed files with 397 additions and 344 deletions

View File

@@ -1,18 +1,6 @@
lib_xua Change Log
==================
HEAD
----
* ADDED: Support for XCommon CMake build system
* RESOLVED: Output volume control not enabled by default when MIXER disabled
* RESOLVED: Full 32bit result of volume processing not calculated when required
* RESOLVED: Input stream sending an erroneous zero-length packet when exiting underflow state
* RESOLVED Build failures when XUA_USB_EN = 0
* RESOLVED: Clock configuration issues when ADAT and S/PDIF receive are enabled (#352)
* CHANGED: QUAD_SPI_FLASH replaced by XUA_QUAD_SPI_FLASH (default: 1)
* CHANGED: UserBufferManagementInit() now takes a sample rate parameter
3.5.1
-----

View File

@@ -14,7 +14,7 @@ Required hardware
.................
The example code provided with the application has been implemented
and tested on the xCORE.ai Multi-channel Audio Board
and tested on the xCORE-200 Multi-channel Audio Board
Prerequisites
.............

View File

@@ -76,7 +76,7 @@ void AudioHwConfig(unsigned samFreq, unsigned mClk, unsigned dsdMode,
#endif // __XC__
void UserBufferManagementInit(unsigned samFreq);
void UserBufferManagementInit();
void UserBufferManagement(unsigned sampsFromUsbToAudio[], unsigned sampsFromAudioToUsb[]);

View File

@@ -50,6 +50,10 @@ void XUA_Buffer(
#if (HID_CONTROLS)
, chanend c_hid
#endif
#ifdef PAWPAW_INOUTHID
, chanend c_hid
, chanend c_hid_out
#endif//#ifdef PAWPAW_INOUTHID
, chanend c_aud
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) || defined(__DOXYGEN__)
, client interface pll_ref_if i_pll_ref
@@ -78,6 +82,10 @@ void XUA_Buffer_Ep(chanend c_aud_out,
#if (HID_CONTROLS)
, chanend c_hid
#endif
#ifdef PAWPAW_INOUTHID
, chanend c_hid
, chanend c_hid_out
#endif //#ifdef PAWPAW_INOUTHID
#ifdef CHAN_BUFF_CTRL
, chanend c_buff_ctrl
#endif

View File

@@ -85,10 +85,10 @@
#if defined(NATIVE_DSD) && (NATIVE_DSD == 0)
#undef NATIVE_DSD
#else
#define NATIVE_DSD (1) /* Always enable Native DSD when DSD mode is enabled */
#define NATIVE_DSD 1 /* Always enable Native DSD when DSD mode is enabled */
#endif
#else
#define DSD_CHANS_DAC (0)
#define DSD_CHANS_DAC 0
#endif
#define XUA_PCM_FORMAT_I2S (0)
@@ -114,9 +114,9 @@
**/
#ifndef I2S_CHANS_PER_FRAME
#if (XUA_PCM_FORMAT == XUA_PCM_FORMAT_TDM)
#define I2S_CHANS_PER_FRAME (8)
#define I2S_CHANS_PER_FRAME 8
#else
#define I2S_CHANS_PER_FRAME (2)
#define I2S_CHANS_PER_FRAME 2
#endif
#endif
@@ -241,9 +241,7 @@
#endif
/**
* @brief Default device sample frequency. A safe default should be used.
*
* Default: MIN_FREQ
* @brief Default device sample frequency. A safe default should be used. Default: MIN_FREQ
*/
#ifndef DEFAULT_FREQ
#define DEFAULT_FREQ (MIN_FREQ)
@@ -252,21 +250,17 @@
/* Audio Class Defines */
/**
* @brief USB Audio Class Version.
*
* Default: 2 (Audio Class version 2.0)
* @brief USB Audio Class Version. Default: 2 (Audio Class version 2.0)
*/
#ifndef AUDIO_CLASS
#define AUDIO_CLASS (2)
#define AUDIO_CLASS 2
#endif
/**
* @brief Whether or not to fall back to Audio Class 1.0 in USB Full-speed.
*
* Default: 0 (Disabled i.e. do not fall back to UAC 1.0
* @brief Whether or not to fall back to Audio Class 1.0 in USB Full-speed. Default: 0 (Disabled)
*/
#ifndef AUDIO_CLASS_FALLBACK
#define AUDIO_CLASS_FALLBACK (0)
#define AUDIO_CLASS_FALLBACK 0 /* Default to not falling back to UAC 1 */
#endif
/**
@@ -278,7 +272,7 @@
#if (AUDIO_CLASS == 2)
/* Whether to run in Audio Class 2.0 mode in USB Full-speed */
#if !defined(FULL_SPEED_AUDIO_2) && (AUDIO_CLASS_FALLBACK == 0)
#define FULL_SPEED_AUDIO_2 (1) /* Default to falling back to UAC2 */
#define FULL_SPEED_AUDIO_2 1 /* Default to falling back to UAC2 */
#endif
#endif
@@ -299,9 +293,7 @@
/* Feature defines */
/**
* @brief Number of PDM microphones in the design.
*
* Default: None
* @brief Number of PDM microphones in the design. Default: None
*/
#ifndef XUA_NUM_PDM_MICS
#define XUA_NUM_PDM_MICS (0)
@@ -318,18 +310,14 @@
#endif
/**
* @brief Size of a frame of microphone data samples.
*
* Default: 1
* @brief Size of a frame of microphone data samples. Default: 1
*/
#ifndef XUA_MIC_FRAME_SIZE
#define XUA_MIC_FRAME_SIZE (1)
#endif
/**
* @brief Enable MIDI functionality including buffering, descriptors etc.
*
* Default: 0 (Disabled)
* @brief Enable MIDI functionality including buffering, descriptors etc. Default: DISABLED
*/
#ifndef MIDI
#define MIDI (0)
@@ -363,9 +351,7 @@
#endif
/**
* @brief Enables ADAT Tx.
*
* Default: 0 (Disabled)
* @brief Enables ADAT Tx. Default: 0 (Disabled)
*/
#ifndef XUA_ADAT_TX_EN
#define XUA_ADAT_TX_EN (0)
@@ -381,18 +367,14 @@
#endif
/**
* @brief Enables SPDIF Rx.
*
* Default: 0 (Disabled)
* @brief Enables SPDIF Rx. Default: 0 (Disabled)
*/
#ifndef XUA_SPDIF_RX_EN
#define XUA_SPDIF_RX_EN (0)
#endif
/**
* @brief Enables ADAT Rx.
*
* Default: 0 (Disabled)
* @brief Enables ADAT Rx. Default: 0 (Disabled)
*/
#ifndef XUA_ADAT_RX_EN
#define XUA_ADAT_RX_EN (0)
@@ -455,15 +437,6 @@
#undef XUA_DFU_EN
#endif
/**
* @brief Use a QSPI (rather than SPI) flash for DFU (and boot)
*
* Default: 1 (True i.e use QSPI flash)
*/
#if !defined(XUA_QUAD_SPI_FLASH)
#define XUA_QUAD_SPI_FLASH (1)
#endif
/**
* @brief Enable HID playback controls functionality.
*
@@ -1160,13 +1133,9 @@
#define VOLUME_RES_MIXER (0x100)
#endif
/* Handle out volume control in the mixer - enabled by default if mixer enabled */
/* Handle out volume control in the mixer - enabled by default */
#ifndef OUT_VOLUME_IN_MIXER
#if MIXER
#define OUT_VOLUME_IN_MIXER (1)
#else
#define OUT_VOLUME_IN_MIXER (0)
#endif
#endif
/* Apply out volume controls after the mix. Only relevant when OUT_VOLUME_IN_MIXER enabled. Enabled by default */
@@ -1179,7 +1148,7 @@
#define IN_VOLUME_IN_MIXER (0)
#endif
/* Apply in volume controls after the mix. Only relevant when IN_VOLUMNE_IN MIXER enabled. Enabled by default */
/* Apply in volume controls after the mix. Only relebant when IN_VOLUMNE_IN MIXER enabled. Enabled by default */
#ifndef IN_VOLUME_AFTER_MIX
#define IN_VOLUME_AFTER_MIX (1)
#endif
@@ -1276,6 +1245,8 @@ enum USBEndpointNumber_Out
#endif /* __ASSEMBLER__ */
#define AUDIO_STOP_FOR_DFU (0x12345678)
#define AUDIO_START_FROM_DFU (0x87654321)
#define AUDIO_REBOOT_FROM_DFU (0xa5a5a5a5)
/* Result of db_to_mult(MAX_VOLUME, 8, 29) */
#define MAX_VOLUME_MULT (0x20000000)
@@ -1378,7 +1349,7 @@ enum USBEndpointNumber_Out
/* Some defines that allow us to remove unused code */
/* Useful for dropping lower part of macs in volume processing... */
#if (FS_STREAM_FORMAT_OUTPUT_1_RESOLUTION_BITS > 24) || (HS_STREAM_FORMAT_OUTPUT_1_RESOLUTION_BITS > 24) || \
#if (FS_STREAM_FORMAT_OUTPUT_1_RESOLUTION_BITS > 24) || (HS_STREAM_FORMAT_OUTPUT_2_RESOLUTION_BITS > 24) || \
(((FS_STREAM_FORMAT_OUTPUT_2_RESOLUTION_BITS > 24) || (HS_STREAM_FORMAT_OUTPUT_2_RESOLUTION_BITS > 24)) && (OUTPUT_FORMAT_COUNT > 1)) || \
(((FS_STREAM_FORMAT_OUTPUT_3_RESOLUTION_BITS > 24) || (HS_STREAM_FORMAT_OUTPUT_3_RESOLUTION_BITS > 24)) && (OUTPUT_FORMAT_COUNT > 2))
#define STREAM_FORMAT_OUTPUT_RESOLUTION_32BIT_USED 1
@@ -1412,7 +1383,7 @@ enum USBEndpointNumber_Out
#endif
/* Useful for dropping lower part of macs in volume processing... */
#if (FS_STREAM_FORMAT_INPUT_1_RESOLUTION_BITS > 24) || (HS_STREAM_FORMAT_INPUT_1_RESOLUTION_BITS > 24)
#if (FS_STREAM_FORMAT_INPUT_1_RESOLUTION_BITS > 24) || (FS_STREAM_FORMAT_INPUT_2_RESOLUTION_BITS > 24)
#define STREAM_FORMAT_INPUT_RESOLUTION_32BIT_USED 1
#else
#define STREAM_FORMAT_INPUT_RESOLUTION_32BIT_USED 0

View File

@@ -1,51 +0,0 @@
set(LIB_NAME lib_xua)
set(LIB_VERSION 3.5.1)
set(LIB_INCLUDES api
src/core
src/core/audiohub
src/core/buffer/ep
src/core/endpoint0
src/dfu
src/core/buffer/decouple
src/core/clocking
src/core/mixer
src/core/pdm_mics
src/core/ports
src/core/support
src/core/user
src/core/user/audiostream
src/core/user/hid
src/core/user/hostactive
src/hid
src/midi)
set(LIB_OPTIONAL_HEADERS xua_conf.h static_hid_report.h)
set(LIB_DEPENDENT_MODULES "lib_locks"
"lib_logging"
"lib_mic_array(feature/xcommon_cmake)"
"lib_spdif"
"lib_xassert"
"lib_xud"
"lib_adat")
set(LIB_COMPILER_FLAGS -O3 -DREF_CLK_FREQ=100 -fasm-linenum -fcomment-asm)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND LIB_COMPILER_FLAGS -DXASSERT_ENABLE_ASSERTIONS=1
-DXASSERT_ENABLE_DEBUG=1
-DXASSERT_ENBALE_LINE_NUMBERS=1)
else()
list(APPEND LIB_COMPILER_FLAGS -DXASSERT_ENABLE_ASSERTIONS=0
-DXASSERT_ENABLE_DEBUG=0
-DXASSERT_ENABLE_LINE_NUMBERS=0)
endif()
set(LIB_COMPILER_FLAGS_xua_endpoint0.c ${LIB_COMPILER_FLAGS} -Os -mno-dual-issue)
set(LIB_COMPILER_FLAGS_xua_ep0_uacreqs.xc ${LIB_COMPILER_FLAGS} -Os -mno-dual-issue)
set(LIB_COMPILER_FLAGS_dbcalc.xc ${LIB_COMPILER_FLAGS} -Os -mno-dual-issue)
set(LIB_COMPILER_FLAGS_audioports.c ${LIB_COMPILER_FLAGS} -Os -mno-dual-issue)
set(LIB_COMPILER_FLAGS_audioports.xc ${LIB_COMPILER_FLAGS} -Os -mno-dual-issue)
set(LIB_COMPILER_FLAGS_dfu.xc ${LIB_COMPILER_FLAGS} -Os -mno-dual-issue)
set(LIB_COMPILER_FLAGS_flash_interface.c ${LIB_COMPILER_FLAGS} -Os -mno-dual-issue)
set(LIB_COMPILER_FLAGS_flashlib_user.c ${LIB_COMPILER_FLAGS} -Os -mno-dual-issue)
XMOS_REGISTER_MODULE()

View File

@@ -1,11 +1,13 @@
// Copyright 2018-2023 XMOS LIMITED.
// Copyright 2018-2022 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
unsigned adatCounter = 0;
unsigned adatSamples[8];
#pragma unsafe arrays
static inline void TransferAdatTxSamples(chanend c_adat_out, const unsigned samplesFromHost[], int smux, int handshake)
{
/* Do some re-arranging for SMUX.. */
unsafe
{
@@ -27,6 +29,7 @@ static inline void TransferAdatTxSamples(chanend c_adat_out, const unsigned samp
if(adatCounter == smux)
{
#ifdef ADAT_TX_USE_SHARED_BUFF
unsafe
{

View File

@@ -48,7 +48,7 @@
unsigned samplesOut[MAX(NUM_USB_CHAN_OUT, I2S_CHANS_DAC)];
/* Two buffers for ADC data to allow for DAC and ADC I2S ports being offset */
#define IN_CHAN_COUNT (I2S_CHANS_ADC + XUA_NUM_PDM_MICS + (8*XUA_ADAT_RX_EN) + (2*XUA_SPDIF_RX_EN))
#define IN_CHAN_COUNT (I2S_CHANS_ADC + XUA_NUM_PDM_MICS + (8*XUA_ADAT_RX_EN) + (2*XUA_SPDIF_RX_EN) + EXTRA_I2S_ADC)
unsigned samplesIn[2][MAX(NUM_USB_CHAN_IN, IN_CHAN_COUNT)];
@@ -241,12 +241,12 @@ unsigned static AudioHub_MainLoop(chanend ?c_out, chanend ?c_spd_out
}
#endif // ((DEBUG_MIC_ARRAY == 1) && (XUA_NUM_PDM_MICS > 0))
UserBufferManagementInit(curSamFreq);
UserBufferManagementInit();
unsigned command = DoSampleTransfer(c_out, readBuffNo, underflowWord);
// Reinitialise user state before entering the main loop
UserBufferManagementInit(curSamFreq);
UserBufferManagementInit();
#if (XUA_ADAT_TX_EN)
unsafe{
@@ -806,7 +806,7 @@ void XUA_AudioHub(chanend ?c_aud, clock ?clk_audio_mclk, clock ?clk_audio_bclk,
{
/* TODO wait for good mclk instead of delay */
/* No delay for DFU modes */
if (((curSamFreq / AUD_TO_USB_RATIO) != AUDIO_STOP_FOR_DFU) && command)
if (((curSamFreq / AUD_TO_USB_RATIO) != AUDIO_REBOOT_FROM_DFU) && ((curSamFreq / AUD_TO_USB_RATIO) != AUDIO_STOP_FOR_DFU) && command)
{
#if 0
/* User should ensure MCLK is stable in AudioHwConfig */
@@ -916,9 +916,13 @@ void XUA_AudioHub(chanend ?c_aud, clock ?clk_audio_mclk, clock ?clk_audio_bclk,
#else
dummy_deliver(c_aud, command);
#endif
/* Note, we do not expect to reach here */
curSamFreq = inuint(c_aud);
if (curSamFreq == AUDIO_START_FROM_DFU)
{
outct(c_aud, XS1_CT_END);
break;
}
}
}
#endif

View File

@@ -1,11 +1,11 @@
// Copyright 2016-2023 XMOS LIMITED.
// Copyright 2016-2021 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include "xccompat.h"
#include "xua_audiohub.h"
/* Default implementation for UserBufferManagementInit() */
void __attribute__ ((weak)) UserBufferManagementInit(unsigned sampFreq)
void __attribute__ ((weak)) UserBufferManagementInit()
{
/* Do nothing */
}

View File

@@ -651,7 +651,6 @@ __builtin_unreachable();
#if (NUM_USB_CHAN_IN > 0)
/* Mark Endpoint (IN) ready with an appropriately sized zero buffer */
/* TODO We should properly size zeros packet rather than using "mid" */
static inline void SetupZerosSendBuffer(XUD_ep aud_to_host_usb_ep, unsigned sampFreq, unsigned slotSize,
xc_ptr aud_to_host_zeros)
{
@@ -660,8 +659,8 @@ static inline void SetupZerosSendBuffer(XUD_ep aud_to_host_usb_ep, unsigned samp
/* Set IN stream packet size to something sensible. We expect the buffer to
* over flow and this to be reset */
SET_SHARED_GLOBAL(sampsToWrite, mid);
SET_SHARED_GLOBAL(totalSampsToWrite, mid);
SET_SHARED_GLOBAL(sampsToWrite, 0);
SET_SHARED_GLOBAL(totalSampsToWrite, 0);
mid *= g_numUsbChan_In * slotSize;
@@ -822,7 +821,6 @@ void XUA_Buffer_Decouple(chanend c_mix_out
SetupZerosSendBuffer(aud_to_host_usb_ep, sampFreq, g_curSubSlot_In, aud_to_host_zeros);
#endif
#if (NUM_USB_CHAN_OUT > 0)
/* Reset OUT buffer state */
outUnderflow = 1;
SET_SHARED_GLOBAL(g_aud_from_host_rdptr, aud_from_host_fifo_start);
@@ -835,7 +833,6 @@ void XUA_Buffer_Decouple(chanend c_mix_out
XUD_SetReady_OutPtr(aud_from_host_usb_ep, aud_from_host_fifo_start+4);
outOverflow = 0;
}
#endif
}
/* Wait for handshake back and pass back up */
@@ -909,7 +906,6 @@ void XUA_Buffer_Decouple(chanend c_mix_out
GET_SHARED_GLOBAL(dataFormat, g_formatChange_DataFormat);
GET_SHARED_GLOBAL(sampRes, g_formatChange_SampRes);
#if (NUM_USB_CHAN_OUT > 0)
/* Reset OUT buffer state */
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);
@@ -925,7 +921,6 @@ void XUA_Buffer_Decouple(chanend c_mix_out
XUD_SetReady_OutPtr(aud_from_host_usb_ep, aud_from_host_fifo_start+4);
outOverflow = 0;
}
#endif
#ifdef NATIVE_DSD
if(dataFormat == UAC_FORMAT_TYPEI_RAW_DATA)

View File

@@ -17,6 +17,13 @@
unsigned char g_hidData[HID_MAX_DATA_BYTES] = {0U};
#endif
#ifdef PAWPAW_INOUTHID
#include "user_hid_ctrl.h"
#include "stdio.h"
unsigned char g_hidData_in[PAWPAW_CFG_HID_IN_BUFSIZE] = {0};
unsigned char g_hidData_out[PAWPAW_CFG_HID_OUT_BUFSIZE] = {0};
#endif//#ifdef PAWPAW_INOUTHID
void GetADCCounts(unsigned samFreq, int &min, int &mid, int &max);
#define BUFFER_SIZE_OUT (1028 >> 2)
#define BUFFER_SIZE_IN (1028 >> 2)
@@ -103,6 +110,10 @@ void XUA_Buffer(
#if (HID_CONTROLS )
, chanend c_hid
#endif
#ifdef PAWPAW_INOUTHID
, chanend c_hid
, chanend c_hid_out
#endif//#ifdef PAWPAW_INOUTHID
, chanend c_aud
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
, client interface pll_ref_if i_pll_ref
@@ -137,6 +148,11 @@ void XUA_Buffer(
#if XUA_HID_ENABLED
, c_hid
#endif
#ifdef PAWPAW_INOUTHID
, c_hid
, c_hid_out
#endif //#ifdef PAWPAW_INOUTHID
#ifdef CHAN_BUFF_CTRL
, c_buff_ctrl
#endif
@@ -187,6 +203,11 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
#if(HID_CONTROLS)
, chanend c_hid
#endif
#ifdef PAWPAW_INOUTHID
, chanend c_hid
, chanend c_hid_out
#endif//#ifdef PAWPAW_INOUTHID
#ifdef CHAN_BUFF_CTRL
, chanend c_buff_ctrl
#endif
@@ -227,6 +248,12 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
#if XUA_HID_ENABLED
XUD_ep ep_hid = XUD_InitEp(c_hid);
#endif
#ifdef PAWPAW_INOUTHID
XUD_ep ep_hid = XUD_InitEp(c_hid);
XUD_ep ep_hid_out = XUD_InitEp(c_hid_out);//dwj+
#endif//#ifdef PAWPAW_INOUTHID
unsigned u_tmp;
unsigned sampleFreq = DEFAULT_FREQ;
unsigned masterClockFreq = DEFAULT_MCLK_FREQ;
@@ -365,6 +392,11 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
i_pll_ref.toggle();
#endif
#ifdef PAWPAW_INOUTHID
XUD_SetReady_In(ep_hid, g_hidData_in, 5);// 上行
XUD_SetReady_Out(ep_hid_out,g_hidData_out);// 下行
#endif //#ifdef d
while(1)
{
XUD_Result_t result;
@@ -910,6 +942,41 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
break;
#endif
#ifdef PAWPAW_INOUTHID
case XUD_SetData_Select(c_hid, ep_hid, result):
{
// printf("HID IN\n");
if( hid_Buffer_exchange(BUF_XMOS_PC,g_hidData_in)){
}
XUD_SetReady_In(ep_hid, g_hidData_in, 5);
}
break;
#if (HID_OUT_REQUIRED)
case XUD_GetData_Select(c_hid_out, ep_hid_out,length, result):
{
XUD_SetReady_Out(ep_hid_out,g_hidData_out);
hid_Buffer_exchange(BUF_PC_XMOS,g_hidData_out);
// XMOS 获取到的HID数据
// g_hidData_out[0]...g_hidData_out[7]
// printf("g_hidData_out %d\n",length);
// for (size_t i = 0; i < 5; i++)
// {
// printf("%x ",g_hidData_out[i]);
// }
// printf("\n",length);
}
break;
#endif //#if (HID_OUT_REQUIRED)
#endif//#ifdef PAWPAW_INOUTHID
#ifdef MIDI
/* Received word from MIDI thread - Check for ACK or Data */
case midi_get_ack_or_data(c_midi, is_ack, datum):

View File

@@ -1,5 +1,6 @@
// Copyright 2011-2023 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include <xs1.h>
#include <assert.h>
#include <print.h>
@@ -140,6 +141,9 @@ static inline void setClockValidity(chanend c_interruptControl, int clkIndex, in
}
}
/* Returns 1 for valid clock found else 0 */
static inline int validSamples(Counter &counter, int clockIndex)
{
@@ -215,6 +219,18 @@ static inline int validSamples(Counter &counter, int clockIndex)
}
#endif
#if (XUA_SPDIF_RX_EN)
//:badParity
/* Returns 1 for bad parity, else 0 */
static inline int badParity(unsigned x)
{
unsigned X = (x>>4);
crc32(X, 0, 1);
return X & 1;
}
//:
#endif
#ifdef LEVEL_METER_LEDS
void VendorLedRefresh(unsigned levelData[]);
unsigned g_inputLevelData[NUM_USB_CHAN_IN];
@@ -232,7 +248,7 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
unsigned clkMode = CLOCK_INTERNAL; /* Current clocking mode in operation */
unsigned tmp;
/* Start in no-SMUX (8-channel) mode */
/* start in no-SMUX (8-channel) mode */
int smux = 0;
#ifdef LEVEL_METER_LEDS
@@ -253,10 +269,9 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
int spdifUnderflow = 1;
int spdifSamps = 0; /* Number of samples in buffer */
Counter spdifCounters;
int spdifRxTime;
int spdifReceivedTime;
unsigned tmp2;
unsigned spdifLeft = 0;
unsigned spdifRxData;
#endif
#if (XUA_ADAT_RX_EN)
@@ -281,21 +296,21 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
}
/* Init clock unit state */
clockFreq[CLOCK_INTERNAL] = 0;
clockId[CLOCK_INTERNAL] = ID_CLKSRC_INT;
clockValid[CLOCK_INTERNAL] = 0;
clockInt[CLOCK_INTERNAL] = 0;
#if (XUA_SPDIF_RX_EN)
clockFreq[CLOCK_SPDIF] = 0;
clockValid[CLOCK_SPDIF] = 0;
clockInt[CLOCK_SPDIF] = 0;
clockId[CLOCK_SPDIF] = ID_CLKSRC_SPDIF;
clockFreq[CLOCK_SPDIF_INDEX] = 0;
clockValid[CLOCK_SPDIF_INDEX] = 0;
clockInt[CLOCK_SPDIF_INDEX] = 0;
clockId[CLOCK_SPDIF_INDEX] = ID_CLKSRC_SPDIF;
#endif
clockFreq[CLOCK_INTERNAL_INDEX] = 0;
clockId[CLOCK_INTERNAL_INDEX] = ID_CLKSRC_INT;
clockValid[CLOCK_INTERNAL_INDEX] = 0;
clockInt[CLOCK_INTERNAL_INDEX] = 0;
#if (XUA_ADAT_RX_EN)
clockFreq[CLOCK_ADAT] = 0;
clockInt[CLOCK_ADAT] = 0;
clockValid[CLOCK_ADAT] = 0;
clockId[CLOCK_ADAT] = ID_CLKSRC_ADAT;
clockFreq[CLOCK_ADAT_INDEX] = 0;
clockInt[CLOCK_ADAT_INDEX] = 0;
clockValid[CLOCK_ADAT_INDEX] = 0;
clockId[CLOCK_ADAT_INDEX] = ID_CLKSRC_ADAT;
#endif
#if (XUA_SPDIF_RX_EN)
spdifCounters.receivedSamples = 0;
@@ -315,6 +330,7 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
adatCounters.samplesPerTick = 0;
#endif
t_local :> timeNextEdge;
timeLastEdge = timeNextEdge;
timeNextClockDetection = timeNextEdge + (LOCAL_CLOCK_INCREMENT / 2);
@@ -389,9 +405,13 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
case SET_SEL:
/* Update clock mode */
clkMode = inuint(c_clk_ctl);
tmp = inuint(c_clk_ctl);
chkct(c_clk_ctl, XS1_CT_END);
if(tmp!=0)
{
clkMode = tmp;
}
#ifdef CLOCK_VALIDITY_CALL
switch(clkMode)
{
@@ -400,12 +420,12 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
break;
#if (XUA_ADAT_RX_EN)
case CLOCK_ADAT:
VendorClockValidity(clockValid[CLOCK_ADAT]);
VendorClockValidity(clockValid[CLOCK_ADAT_INDEX]);
break;
#endif
#if (XUA_SPDIF_RX_EN)
case CLOCK_SPDIF:
VendorClockValidity(clockValid[CLOCK_SPDIF]);
VendorClockValidity(clockValid[CLOCK_SPDIF_INDEX]);
break;
#endif
}
@@ -479,56 +499,58 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
#endif
break;
#if (XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN)
case t_external when timerafter(timeNextClockDetection) :> void:
{
int valid;
timeNextClockDetection += (LOCAL_CLOCK_INCREMENT);
#if (XUA_SPDIF_RX_EN)
tmp = spdifCounters.samplesPerTick;
/* Returns 1 if valid clock found */
valid = validSamples(spdifCounters, CLOCK_SPDIF);
setClockValidity(c_clk_int, CLOCK_SPDIF, valid, clkMode);
tmp = validSamples(spdifCounters, CLOCK_SPDIF_INDEX);
setClockValidity(c_clk_int, CLOCK_SPDIF_INDEX, tmp, clkMode);
#endif
#if (XUA_ADAT_RX_EN)
/* Returns 1 if valid clock found */
valid = validSamples(adatCounters, CLOCK_ADAT);
setClockValidity(c_clk_int, CLOCK_ADAT, valid, clkMode);
tmp = validSamples(adatCounters, CLOCK_ADAT_INDEX);
setClockValidity(c_clk_int, CLOCK_ADAT_INDEX, tmp, clkMode);
#endif
}
break;
#endif
#if (XUA_SPDIF_RX_EN)
/* Receive sample from S/PDIF RX thread (streaming chan) */
case c_spdif_rx :> spdifRxData:
/* Receive sample from S/PDIF RX thread (steaming chan) */
case c_spdif_rx :> tmp:
/* Record time of sample */
t_local :> spdifRxTime;
t_local :> spdifReceivedTime;
/* Check parity and ignore if bad */
if(spdif_rx_check_parity(spdifRxData))
if(badParity(tmp))
continue;
/* Get preamble */
unsigned preamble = spdifRxData & SPDIF_RX_PREAMBLE_MASK;
switch(preamble)
/* Get pre-amble */
tmp2 = tmp & 0xF;
switch(tmp2)
{
/* LEFT */
case SPDIF_FRAME_X:
case SPDIF_FRAME_Z:
spdifLeft = SPDIF_RX_EXTRACT_SAMPLE(spdifRxData);
spdifLeft = tmp << 4;
break;
/* RIGHT */
case SPDIF_FRAME_Y:
/* Only store sample if not in overflow and stream is reasonably valid */
if(!spdifOverflow && clockValid[CLOCK_SPDIF])
if(!spdifOverflow && clockValid[CLOCK_SPDIF_INDEX])
{
/* Store left and right sample pair to buffer */
spdifSamples[spdifWr] = spdifLeft;
spdifSamples[spdifWr+1] = SPDIF_RX_EXTRACT_SAMPLE(spdifRxData);
spdifSamples[spdifWr+1] = tmp << 4;
spdifWr = (spdifWr + 2) & (MAX_SPDIF_SAMPLES - 1);
@@ -556,7 +578,7 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
spdifCounters.samples += 1;
if(clkMode == CLOCK_SPDIF && clockValid[CLOCK_SPDIF])
if(clkMode == CLOCK_SPDIF && clockValid[CLOCK_SPDIF_INDEX])
{
spdifCounters.receivedSamples+=1;
@@ -564,13 +586,13 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
if((spdifCounters.receivedSamples >= spdifCounters.samplesPerTick))
{
/* Check edge is about right... S/PDIF may have changed freq... */
if(timeafter(spdifRxTime, (timeLastEdge + LOCAL_CLOCK_INCREMENT - LOCAL_CLOCK_MARGIN)))
if(timeafter(spdifReceivedTime, (timeLastEdge + LOCAL_CLOCK_INCREMENT - LOCAL_CLOCK_MARGIN)))
{
/* Record edge time */
timeLastEdge = spdifRxTime;
timeLastEdge = spdifReceivedTime;
/* Setup for next edge */
timeNextEdge = spdifRxTime + LOCAL_CLOCK_INCREMENT + LOCAL_CLOCK_MARGIN;
timeNextEdge = spdifReceivedTime + LOCAL_CLOCK_INCREMENT + LOCAL_CLOCK_MARGIN;
/* Toggle edge */
i_pll_ref.toggle_timed(1);
@@ -605,7 +627,7 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
if (adatChannel == 8)
{
/* only store left samples if not in overflow and stream is reasonably valid */
if (!adatOverflow && clockValid[CLOCK_ADAT])
if (!adatOverflow && clockValid[CLOCK_ADAT_INDEX])
{
/* Unpick the SMUX.. */
if(smux == 2)
@@ -662,7 +684,7 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
{
adatCounters.samples += 1;
if (clkMode == CLOCK_ADAT && clockValid[CLOCK_ADAT])
if (clkMode == CLOCK_ADAT && clockValid[CLOCK_ADAT_INDEX])
{
adatCounters.receivedSamples += 1;
@@ -683,6 +705,7 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
/* Reset counters */
adatCounters.receivedSamples = 0;
}
}
}
@@ -693,6 +716,7 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
break;
#endif
#if (XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN)
/* AudioHub requests data */
case inuint_byref(c_dig_rx, tmp):
@@ -732,6 +756,7 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
spdifOverflow = 0;
}
}
#endif
#if (XUA_ADAT_RX_EN)
if (adatUnderflow)
@@ -817,6 +842,8 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
break;
#endif
}
}
}

View File

@@ -10,7 +10,7 @@
#if (NUM_USB_CHAN_OUT > 1-1)
.outputChanStr_1 = ""
#if (1 < I2S_CHANS_DAC+1)
"Analogue 1"
"Playback 1"
#endif
#if ((1 < SPDIF_TX_INDEX+2+1) && (1 > SPDIF_TX_INDEX)) && (XUA_SPDIF_TX_EN)
#if (1 < I2S_CHANS_DAC+1)
@@ -50,7 +50,7 @@
#if (NUM_USB_CHAN_OUT > 2-1)
.outputChanStr_2 = ""
#if (2 < I2S_CHANS_DAC+1)
"Analogue 2"
"Playback 2"
#endif
#if ((2 < SPDIF_TX_INDEX+2+1) && (2 > SPDIF_TX_INDEX)) && (XUA_SPDIF_TX_EN)
#if (2 < I2S_CHANS_DAC+1)
@@ -90,7 +90,7 @@
#if (NUM_USB_CHAN_OUT > 3-1)
.outputChanStr_3 = ""
#if (3 < I2S_CHANS_DAC+1)
"Analogue 3"
"Playback 3"
#endif
#if ((3 < SPDIF_TX_INDEX+2+1) && (3 > SPDIF_TX_INDEX)) && (XUA_SPDIF_TX_EN)
#if (3 < I2S_CHANS_DAC+1)
@@ -130,7 +130,7 @@
#if (NUM_USB_CHAN_OUT > 4-1)
.outputChanStr_4 = ""
#if (4 < I2S_CHANS_DAC+1)
"Analogue 4"
"Playback 4"
#endif
#if ((4 < SPDIF_TX_INDEX+2+1) && (4 > SPDIF_TX_INDEX)) && (XUA_SPDIF_TX_EN)
#if (4 < I2S_CHANS_DAC+1)
@@ -170,7 +170,7 @@
#if (NUM_USB_CHAN_OUT > 5-1)
.outputChanStr_5 = ""
#if (5 < I2S_CHANS_DAC+1)
"Analogue 5"
"Playback 5"
#endif
#if ((5 < SPDIF_TX_INDEX+2+1) && (5 > SPDIF_TX_INDEX)) && (XUA_SPDIF_TX_EN)
#if (5 < I2S_CHANS_DAC+1)
@@ -210,7 +210,7 @@
#if (NUM_USB_CHAN_OUT > 6-1)
.outputChanStr_6 = ""
#if (6 < I2S_CHANS_DAC+1)
"Analogue 6"
"Playback 6"
#endif
#if ((6 < SPDIF_TX_INDEX+2+1) && (6 > SPDIF_TX_INDEX)) && (XUA_SPDIF_TX_EN)
#if (6 < I2S_CHANS_DAC+1)
@@ -250,7 +250,7 @@
#if (NUM_USB_CHAN_OUT > 7-1)
.outputChanStr_7 = ""
#if (7 < I2S_CHANS_DAC+1)
"Analogue 7"
"Playback 7"
#endif
#if ((7 < SPDIF_TX_INDEX+2+1) && (7 > SPDIF_TX_INDEX)) && (XUA_SPDIF_TX_EN)
#if (7 < I2S_CHANS_DAC+1)
@@ -290,7 +290,7 @@
#if (NUM_USB_CHAN_OUT > 8-1)
.outputChanStr_8 = ""
#if (8 < I2S_CHANS_DAC+1)
"Analogue 8"
"Playback 8"
#endif
#if ((8 < SPDIF_TX_INDEX+2+1) && (8 > SPDIF_TX_INDEX)) && (XUA_SPDIF_TX_EN)
#if (8 < I2S_CHANS_DAC+1)
@@ -330,7 +330,7 @@
#if (NUM_USB_CHAN_OUT > 9-1)
.outputChanStr_9 = ""
#if (9 < I2S_CHANS_DAC+1)
"Analogue 9"
" "
#endif
#if ((9 < SPDIF_TX_INDEX+2+1) && (9 > SPDIF_TX_INDEX)) && (XUA_SPDIF_TX_EN)
#if (9 < I2S_CHANS_DAC+1)
@@ -370,7 +370,7 @@
#if (NUM_USB_CHAN_OUT > 10-1)
.outputChanStr_10 = ""
#if (10 < I2S_CHANS_DAC+1)
"Analogue 10"
" "
#endif
#if ((10 < SPDIF_TX_INDEX+2+1) && (10 > SPDIF_TX_INDEX)) && (XUA_SPDIF_TX_EN)
#if (10 < I2S_CHANS_DAC+1)
@@ -1291,9 +1291,9 @@
#if (NUM_USB_CHAN_IN > 1-1)
.inputChanStr_1 = ""
.inputChanStr_1 = "Mic1"
#if (1 < I2S_CHANS_ADC+1)
"Analogue 1"
"Mix 1"
#endif
#if ((1 < SPDIF_RX_INDEX+2+1) && (1 > SPDIF_RX_INDEX)) && (XUA_SPDIF_RX_EN)
#if (1 < I2S_CHANS_ADC+1)
@@ -1331,7 +1331,7 @@
#endif
#if (NUM_USB_CHAN_IN > 2-1)
.inputChanStr_2 = ""
.inputChanStr_2 = "Mic2"
#if (2 < I2S_CHANS_ADC+1)
"Analogue 2"
#endif
@@ -1371,9 +1371,9 @@
#endif
#if (NUM_USB_CHAN_IN > 3-1)
.inputChanStr_3 = ""
.inputChanStr_3 = "OTG In 3"
#if (3 < I2S_CHANS_ADC+1)
"Analogue 3"
"OTG In 3"
#endif
#if ((3 < SPDIF_RX_INDEX+2+1) && (3 > SPDIF_RX_INDEX)) && (XUA_SPDIF_RX_EN)
#if (3 < I2S_CHANS_ADC+1)
@@ -1411,9 +1411,9 @@
#endif
#if (NUM_USB_CHAN_IN > 4-1)
.inputChanStr_4 = ""
.inputChanStr_4 = "OTG In 4"
#if (4 < I2S_CHANS_ADC+1)
"Analogue 4"
"OTG In 4"
#endif
#if ((4 < SPDIF_RX_INDEX+2+1) && (4 > SPDIF_RX_INDEX)) && (XUA_SPDIF_RX_EN)
#if (4 < I2S_CHANS_ADC+1)
@@ -1451,9 +1451,9 @@
#endif
#if (NUM_USB_CHAN_IN > 5-1)
.inputChanStr_5 = ""
.inputChanStr_5 = "Line In 5"
#if (5 < I2S_CHANS_ADC+1)
"Analogue 5"
"Line In 5"
#endif
#if ((5 < SPDIF_RX_INDEX+2+1) && (5 > SPDIF_RX_INDEX)) && (XUA_SPDIF_RX_EN)
#if (5 < I2S_CHANS_ADC+1)
@@ -1491,9 +1491,9 @@
#endif
#if (NUM_USB_CHAN_IN > 6-1)
.inputChanStr_6 = ""
.inputChanStr_6 = "Line In 6"
#if (6 < I2S_CHANS_ADC+1)
"Analogue 6"
"Line In 6"
#endif
#if ((6 < SPDIF_RX_INDEX+2+1) && (6 > SPDIF_RX_INDEX)) && (XUA_SPDIF_RX_EN)
#if (6 < I2S_CHANS_ADC+1)

View File

@@ -450,6 +450,26 @@ static unsigned char hidReportDescriptorPtr[] = {
#endif
#ifdef PAWPAW_INOUTHID
#define hidReportDescriptorLength (sizeof(hidReportDescriptorPtr))
static unsigned char hidReportDescriptorPtr[] = {
0x05, 0x01, // USAGE_PAGE (Generic Desktop) //dwj cp 长沙西鲸
0x09, 0x00, // USAGE (0)
0xa1, 0x01, // COLLECTION (Application)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0xff, // LOGICAL_MAXIMUM (255)
0x19, 0x01, // USAGE_MINIMUM (1)
0x29, 0x05, // USAGE_MAXIMUM (8) -dwj
0x95, 0x05, // REPORT_COUNT (8) -dwj
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x19, 0x01, // USAGE_MINIMUM (1)
0x29, 0x05, // USAGE_MAXIMUM (8) -dwj
0x91, 0x02, // OUTPUT (Data,Var,Abs)
0xc0 // END_COLLECTION
};
#endif //#ifdef PAWPAW_INOUTHID
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_)
@@ -878,6 +898,16 @@ void XUA_Endpoint0_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0
result = HidInterfaceClassRequests(ep0_out, ep0_in, &sp);
}
#endif
#ifdef PAWPAW_INOUTHID
if (interfaceNum == INTERFACE_NUMBER_HID)
{
debug_printf("INTERFACE_NUMBER_HID");
extern XUD_Result_t HidInterfaceClassRequests_PAWPAW(XUD_ep c_ep0_out, XUD_ep c_ep0_in, USB_SetupPacket_t sp);
HidInterfaceClassRequests_PAWPAW(ep0_out, ep0_in, sp);
}
#endif//#ifdef PAWPAW_INOUTHID
/* Check for: - Audio CONTROL interface request - always 0, note we check for DFU first
* - Audio STREAMING interface request (In or Out)
* - Audio endpoint request (Audio 1.0 Sampling freq requests are sent to the endpoint)

View File

@@ -117,7 +117,7 @@ static unsigned longMul(unsigned a, unsigned b, int prec)
ret = (x << (32-prec) | (y >> prec));
return ret;
}
extern void sound_effect_set_pc_connect_status( int status);
/* Update master volume i.e. i.e update weights for all channels */
static void updateMasterVol(int unitID, chanend ?c_mix_ctl)
{
@@ -166,7 +166,9 @@ static void updateMasterVol(int unitID, chanend ?c_mix_ctl)
unsigned vol = volsIn[i] == 0x8000 ? 0 : db_to_mult(volsIn[i], 8, 29);
int x = longMul(master_vol, vol, 29) * !mutesIn[0] * !mutesIn[i];
//mac
sound_effect_set_pc_connect_status(1);
#if (IN_VOLUME_IN_MIXER)
if (!isnull(c_mix_ctl))
{
@@ -235,6 +237,7 @@ static void updateVol(int unitID, int channel, chanend ?c_mix_ctl)
}
case FU_USBIN:
{
//windows
/* Calc multipliers with 29 fractional bits from a db value with 8 fractional bits */
/* 0x8000 is a special value representing -inf (i.e. mute) */
unsigned master_vol = volsIn[0] == 0x8000 ? 0 : db_to_mult(volsIn[0], 8, 29);
@@ -456,35 +459,34 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c
(buffer, unsigned char[])[0] = 1;
return XUD_DoGetRequest(ep0_out, ep0_in, (buffer, unsigned char[]), 1, sp.wLength);
break;
#if (XUA_SPDIF_RX_EN)
case ID_CLKSRC_SPDIF:
/* Interogate clockgen thread for validity */
if (!isnull(c_clk_ctl))
{
outuint(c_clk_ctl, GET_VALID);
outuint(c_clk_ctl, CLOCK_SPDIF);
outuint(c_clk_ctl, CLOCK_SPDIF_INDEX);
outct(c_clk_ctl, XS1_CT_END);
(buffer, unsigned char[])[0] = inuint(c_clk_ctl);
chkct(c_clk_ctl, XS1_CT_END);
return XUD_DoGetRequest(ep0_out, ep0_in, (buffer, unsigned char[]), 1, sp.wLength);
}
break;
#endif
#if (XUA_ADAT_RX_EN)
case ID_CLKSRC_ADAT:
if (!isnull(c_clk_ctl))
{
outuint(c_clk_ctl, GET_VALID);
outuint(c_clk_ctl, CLOCK_ADAT);
outuint(c_clk_ctl, CLOCK_ADAT_INDEX);
outct(c_clk_ctl, XS1_CT_END);
(buffer, unsigned char[])[0] = inuint(c_clk_ctl);
chkct(c_clk_ctl, XS1_CT_END);
return XUD_DoGetRequest(ep0_out, ep0_in, (buffer, unsigned char[]), 1, sp.wLength);
}
break;
#endif
default:
//Unknown Unit ID in Clock Valid Control Request
@@ -514,23 +516,19 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c
return result;
}
/* Check for correct datalength for clock sel */
if(datalength == 1)
{
int clockIndex = (int) (buffer, unsigned char[])[0];
clockIndex -= 1; /* Index to/from host is 1-based */
if((clockIndex >= 0) && (clockIndex < CLOCK_COUNT))
{
if (!isnull(c_clk_ctl))
{
outuint(c_clk_ctl, SET_SEL);
outuint(c_clk_ctl, clockIndex);
outuint(c_clk_ctl, (buffer, unsigned char[])[0]);
outct(c_clk_ctl, XS1_CT_END);
}
/* Send 0 Length as status stage */
return XUD_DoSetRequestStatus(ep0_in);
}
}
}
else
{
@@ -538,15 +536,13 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c
(buffer, unsigned char[])[0] = 1;
if (!isnull(c_clk_ctl))
{
int clockIndex;
outuint(c_clk_ctl, GET_SEL);
outct(c_clk_ctl, XS1_CT_END);
clockIndex = inuint(c_clk_ctl);
clockIndex += 1; /* Index to/from host is 1-based */
(buffer, unsigned char[])[0] = (unsigned char) clockIndex;
(buffer, unsigned char[])[0] = inuint(c_clk_ctl);
chkct(c_clk_ctl, XS1_CT_END);
}
return XUD_DoGetRequest( ep0_out, ep0_in, (buffer, unsigned char[]), 1, sp.wLength );
}
}
break;
@@ -923,20 +919,17 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c
{
storeFreq((buffer, unsigned char[]), i, currentFreq44);
num_freqs++;
currentFreq44*=2;
}
currentFreq44*=2;
if((currentFreq48 <= maxFreq) && (currentFreq48 >= MIN_FREQ))
if((currentFreq48 <= maxFreq))
{
/* Note i passed byref here */
storeFreq((buffer, unsigned char[]), i, currentFreq48);
num_freqs++;
}
currentFreq48*=2;
if((currentFreq48 > MAX_FREQ) && (currentFreq44 > MAX_FREQ))
}
else
{
break;
}

View File

@@ -30,8 +30,8 @@
#include "iap.h"
#endif
#if (XUA_SPDIF_RX_EN || XUA_SPDIF_TX_EN)
#include "spdif.h" /* From lib_spdif */
#if (XUA_SPDIF_RX_EN)
#include "spdif.h"
#endif
#if (XUA_ADAT_RX_EN)
@@ -42,6 +42,10 @@
#include "xua_pdm_mic.h"
#endif
#if (XUA_SPDIF_TX_EN)
#include "spdif.h" /* From lib_spdif */
#endif
#if (XUA_DFU_EN == 1)
[[distributable]]
void DFUHandler(server interface i_dfu i, chanend ?c_user_cmd);
@@ -336,7 +340,7 @@ void usb_audio_io(chanend ?c_aud_in,
par
{
#if (MIXER && XUA_USB_EN)
#if (MIXER)
/* Mixer cores(s) */
{
thread_speed();
@@ -401,6 +405,9 @@ void usb_audio_io(chanend ?c_aud_in,
#define USER_MAIN_CORES
#endif
#ifndef USER_UNSAFE_USE
#define USER_UNSAFE_USE
#endif
/* Main for USB Audio Applications */
int main()
@@ -493,12 +500,14 @@ int main()
on tile[XUD_TILE]:
par
{
#if XUA_USB_EN
#if ((XUD_TILE == 0) && (XUA_DFU_EN == 1))
#if (XUD_TILE == 0)
/* Check if USB is on the flash tile (tile 0) */
#if (XUA_DFU_EN == 1)
[[distribute]]
DFUHandler(dfuInterface, null);
#endif
#endif
#if XUA_USB_EN
/* Core USB task, buffering, USB etc */
{
@@ -556,6 +565,10 @@ int main()
#if (XUA_HID_ENABLED)
, c_xud_in[ENDPOINT_NUMBER_IN_HID]
#endif
#ifdef PAWPAW_INOUTHID
, c_xud_in[ENDPOINT_NUMBER_IN_HID]
, c_xud_out[ENDPOINT_NUMBER_OUT_HID]
#endif //#ifdef PAWPAW_INOUTHID
, c_mix_out
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
, i_pll_ref
@@ -576,6 +589,9 @@ int main()
on tile[AUDIO_IO_TILE]:
{
/* Audio I/O task, includes mixing etc */
//user unsafe use
USER_UNSAFE_USE
usb_audio_io(c_mix_out
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
, c_spdif_tx

View File

@@ -1,7 +1,8 @@
// Copyright 2011-2023 XMOS LIMITED.
// Copyright 2011-2021 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#ifndef _XUA_COMMANDS_H_
#define _XUA_COMMANDS_H_
#ifndef __XUA_INTERNAL_CMDS_H__
#define __XUA_INTERNAL_CMDS_H__
#include "xua.h"
@@ -10,19 +11,20 @@
#define SET_SEL 1 /* Set value of clock selector */
#define GET_FREQ 2 /* Get current freq */
#define GET_VALID 3 /* Get current validity */
#define SET_SMUX 7 /* Set SMUX mode (ADAT) */
enum
{
CLOCK_INTERNAL = 0,
#if XUA_SPDIF_RX_EN
CLOCK_SPDIF,
#define CLOCK_INTERNAL 1
#define CLOCK_SPDIF 2
#if SPDIF_RX
#define CLOCK_ADAT 3
#else
#define CLOCK_ADAT 2
#endif
#if XUA_ADAT_RX_EN
CLOCK_ADAT,
#endif
CLOCK_COUNT
};
#define CLOCK_INTERNAL_INDEX (CLOCK_INTERNAL - 1)
#define CLOCK_ADAT_INDEX (CLOCK_ADAT - 1)
#define CLOCK_SPDIF_INDEX (CLOCK_SPDIF - 1)
#define SET_SMUX 7
/* c_audioControl */
#define SET_SAMPLE_FREQ 4

View File

@@ -1,4 +1,4 @@
// Copyright 2011-2023 XMOS LIMITED.
// Copyright 2011-2021 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include <xs1.h>
#include <flash.h>
@@ -72,7 +72,7 @@ int flash_cmd_init(void)
return 1;
}
#if (!XUA_QUAD_SPI_FLASH)
#ifndef QUAD_SPI_FLASH
// Disable flash protection
fl_setProtection(0);
#endif

View File

@@ -1,11 +1,11 @@
// Copyright 2012-2023 XMOS LIMITED.
// Copyright 2012-2021 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include "xua.h"
#if (XUA_DFU_EN == 1)
#include "uac_hwresources.h"
#include <xs1.h>
#include <xclib.h>
#if (XUA_QUAD_SPI_FLASH)
#ifdef QUAD_SPI_FLASH
#include <quadflashlib.h>
#else
#include <flashlib.h>
@@ -20,7 +20,7 @@
#ifdef DFU_FLASH_DEVICE
#if (XUA_QUAD_SPI_FLASH)
#ifdef QUAD_SPI_FLASH
/* Using specified flash device rather than all supported in tools */
fl_QuadDeviceSpec flash_devices[] = {DFU_FLASH_DEVICE};
#else
@@ -29,7 +29,7 @@ fl_DeviceSpec flash_devices[] = {DFU_FLASH_DEVICE};
#endif
#endif
#if (XUA_QUAD_SPI_FLASH)
#ifdef QUAD_SPI_FLASH
/*
typedef struct {
out port qspiCS;
@@ -60,7 +60,7 @@ fl_PortHolderStruct p_flash =
int flash_cmd_enable_ports()
{
int result = 0;
#if (XUA_QUAD_SPI_FLASH)
#ifdef QUAD_SPI_FLASH
/* Ports not shared */
#else
setc(p_flash.spiMISO, XS1_SETC_INUSE_OFF);
@@ -89,14 +89,14 @@ int flash_cmd_enable_ports()
#endif
#ifdef DFU_FLASH_DEVICE
#if (XUA_QUAD_SPI_FLASH)
#ifdef QUAD_SPI_FLASH
result = fl_connectToDevice(&p_qflash, flash_devices, sizeof(flash_devices) / sizeof(fl_QuadDeviceSpec));
#else
result = fl_connectToDevice(&p_flash, flash_devices, sizeof(flash_devices) / sizeof(fl_DeviceSpec));
#endif
#else
/* Use default flash list */
#if (XUA_QUAD_SPI_FLASH)
#ifdef QUAD_SPI_FLASH
result = fl_connect(&p_qflash);
#else
result = fl_connect(&p_flash);
@@ -117,7 +117,7 @@ int flash_cmd_disable_ports()
{
fl_disconnect();
#if (!XUA_QUAD_SPI_FLASH)
#ifndef QUAD_SPI_FLASH
setc(p_flash.spiMISO, XS1_SETC_INUSE_OFF);
setc(p_flash.spiCLK, XS1_SETC_INUSE_OFF);
setc(p_flash.spiMOSI, XS1_SETC_INUSE_OFF);