forked from PAWPAW-Mirror/lib_xua
Compare commits
37 Commits
takstar_us
...
feat/dummy
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a2926d1d8 | ||
|
|
85fd297336 | ||
|
|
c92a640439 | ||
|
|
355df6d6b8 | ||
|
|
0bff3dc5a8 | ||
|
|
9abd3b33f3 | ||
|
|
0932ca0ccc | ||
|
|
f1df805b17 | ||
|
|
867fb3f228 | ||
|
|
9cbdf6374e | ||
|
|
a5922ce3ea | ||
|
|
e24bbe42eb | ||
|
|
1488ace820 | ||
|
|
06bd547c69 | ||
|
|
c2e1a8f17a | ||
|
|
58bb074f0d | ||
|
|
c794ee77d5 | ||
|
|
1cd24963d5 | ||
|
|
b27514fd9a | ||
|
|
5d886487fa | ||
|
|
1b50abb7a2 | ||
|
|
d3f0f11d9e | ||
|
|
897328f9c1 | ||
|
|
f7b05be05b | ||
|
|
fbda8fe92a | ||
|
|
be69d3468e | ||
|
|
7cae9c385c | ||
|
|
d9de1f0322 | ||
|
|
dd21ed0a84 | ||
|
|
d50c9510c6 | ||
|
|
b032310302 | ||
|
|
8f9828ea2c | ||
|
|
50097db00d | ||
|
|
c59f9a7c0c | ||
|
|
7ae04ca313 | ||
|
|
2562f0eb31 | ||
|
|
baaef3b749 |
@@ -1,35 +1,14 @@
|
||||
lib_xua Change Log
|
||||
==================
|
||||
|
||||
3.5.1
|
||||
-----
|
||||
UNRELEASED
|
||||
----------
|
||||
|
||||
* FIXED: Respect I2S_CHANS_PER_FRAME when calculating bit-clock rates
|
||||
|
||||
* Changes to dependencies:
|
||||
|
||||
- lib_spdif: 5.0.0 -> 5.0.1
|
||||
|
||||
3.5.0
|
||||
-----
|
||||
|
||||
* ADDED: Configurable word-length for I2S/TDM via XUA_I2S_N_BITS
|
||||
* ADDED: Support for statically defined custom HID descriptor
|
||||
* CHANGED: Rearranged main() such that adding custom code that uses lib_xud
|
||||
is possible
|
||||
* CHANGED: bNumConfigurations changed from 2 to 1, removing a work-around to
|
||||
stop old Windows versions loading the composite driver
|
||||
* FIXED: Memory corruption due to erroneous initialisation of mixer
|
||||
weights when not in use (#152)
|
||||
* ADDED: Configurable word-length for I2S/TDM via XUA_I2S_N_BITS
|
||||
* FIXED: Memory corruption due to erroneous initialisation of mixer weights when not in use (#152)
|
||||
* FIXED: UserHostActive() not being called as expected (#326)
|
||||
* FIXED: Exception when entering DSD mode (#327)
|
||||
|
||||
* Changes to dependencies:
|
||||
|
||||
- lib_spdif: 4.2.1 -> 5.0.0
|
||||
|
||||
- lib_xud: 2.2.2 -> 2.2.3
|
||||
|
||||
3.4.0
|
||||
-----
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
lib_xua
|
||||
#######
|
||||
|
||||
:Version: 3.5.1
|
||||
:Version: 3.4.0
|
||||
:Vendor: XMOS
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ Key features of the various components in this repository are as follows
|
||||
|
||||
- Synchronisation to external digital streams i.e. S/PDIF or ADAT (when in asynchronous mode)
|
||||
|
||||
- I2S (slave/master modes with configurable word-length)
|
||||
- I2S slave & master modes
|
||||
|
||||
- TDM (slave/master modes with configurable word-length)
|
||||
- TDM slave & master modes
|
||||
|
||||
- MIDI input/output (Compliant to USB Class Specification for MIDI devices)
|
||||
|
||||
@@ -53,8 +53,6 @@ Key features of the various components in this repository are as follows
|
||||
|
||||
- Simple playback controls via USB Human Interface Device (HID) Class
|
||||
|
||||
- Support for adding custom HID interfaces
|
||||
|
||||
Note, not all features may be supported at all sample frequencies, simultaneously or on all devices.
|
||||
Some features may also require specific host driver support.
|
||||
|
||||
|
||||
@@ -50,10 +50,6 @@ 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
|
||||
@@ -82,10 +78,6 @@ 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
|
||||
|
||||
@@ -197,6 +197,23 @@
|
||||
#define I2S_DOWNSAMPLE_CHANS_IN I2S_CHANS_ADC
|
||||
#endif
|
||||
|
||||
#ifndef XUA_I2S_DUMMY_SAMPS
|
||||
#define XUA_I2S_DUMMY_SAMPS (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Number of bits per channel for I2S/TDM. Supported values: 16/32-bit.
|
||||
*
|
||||
* Default: 32 bits
|
||||
*/
|
||||
#ifndef XUA_I2S_N_BITS
|
||||
#define XUA_I2S_N_BITS (32)
|
||||
#endif
|
||||
|
||||
#if (XUA_I2S_N_BITS != 16) && (XUA_I2S_N_BITS != 32)
|
||||
#error Unsupported value for XUA_I2S_N_BITS (only values 16/32 supported)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Number of bits per channel for I2S/TDM. Supported values: 16/32-bit.
|
||||
*
|
||||
@@ -448,40 +465,6 @@
|
||||
#define HID_CONTROLS (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* HID may be required in two forms: the built-in XUA-HID reports, or a
|
||||
* user-provided static HID. Some sections of code are always needed, they
|
||||
* are enclosed in XUA_OR_STATIC_HID_ENABLED; code specific to XUA-HID
|
||||
* reports are enclosed in XUA_HID_ENABLED.
|
||||
*
|
||||
* HID_CONTROLS implies that the XUA_HID is used, and hence defines both.
|
||||
* In order to roll your own, do not enable HID_CONTROLS, but instead
|
||||
* create a file static_hid_report.h that contains the static descriptor.
|
||||
*
|
||||
* You must also supply your own function to deal with the HID endpoint(s)
|
||||
* in this case.
|
||||
*/
|
||||
#if( 0 < HID_CONTROLS )
|
||||
#define XUA_HID_ENABLED (1)
|
||||
#define XUA_OR_STATIC_HID_ENABLED (1)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__static_hid_report_h_exists__)
|
||||
#define XUA_OR_STATIC_HID_ENABLED (1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable a HID OUT endpoint. Only use this if you supply your own HID control.
|
||||
*
|
||||
* 1 for enabled, 0 for disabled.
|
||||
*
|
||||
* Default 0 (Disabled)
|
||||
*/
|
||||
#ifndef HID_OUT_REQUIRED
|
||||
#define HID_OUT_REQUIRED (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Defines whether XMOS device runs as master (i.e. drives LR and Bit clocks)
|
||||
*
|
||||
@@ -1197,7 +1180,7 @@ enum USBEndpointNumber_In
|
||||
#ifdef MIDI
|
||||
ENDPOINT_NUMBER_IN_MIDI,
|
||||
#endif
|
||||
#if XUA_OR_STATIC_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
ENDPOINT_NUMBER_IN_HID,
|
||||
#endif
|
||||
#ifdef IAP
|
||||
@@ -1224,9 +1207,6 @@ enum USBEndpointNumber_Out
|
||||
#ifdef IAP_EA_NATIVE_TRANS
|
||||
ENDPOINT_NUMBER_OUT_IAP_EA_NATIVE_TRANS,
|
||||
#endif
|
||||
#endif
|
||||
#if XUA_OR_STATIC_HID_ENABLED && HID_OUT_REQUIRED
|
||||
ENDPOINT_NUMBER_OUT_HID,
|
||||
#endif
|
||||
XUA_ENDPOINT_COUNT_OUT /* End marker */
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
VERSION = 3.5.1
|
||||
VERSION = 3.4.0
|
||||
|
||||
DEBUG ?= 0
|
||||
|
||||
@@ -35,7 +35,7 @@ XCC_FLAGS_dfu.xc = $(MODULE_XCC_FLAGS) -Os -mno-dual-issue
|
||||
XCC_FLAGS_flash_interface.c = $(MODULE_XCC_FLAGS) -Os -mno-dual-issue
|
||||
XCC_FLAGS_flashlib_user.c = $(MODULE_XCC_FLAGS) -Os -mno-dual-issue
|
||||
|
||||
OPTIONAL_HEADERS += xua_conf.h static_hid_report.h
|
||||
OPTIONAL_HEADERS += xua_conf.h
|
||||
|
||||
EXPORT_INCLUDE_DIRS = api \
|
||||
src/core \
|
||||
|
||||
@@ -38,12 +38,12 @@ void InitPorts_master(buffered _XUA_CLK_DIR port:32 p_lrclk, buffered _XUA_CLK_D
|
||||
#endif
|
||||
|
||||
unsigned tmp;
|
||||
|
||||
|
||||
if(XUA_I2S_N_BITS == 32)
|
||||
p_lrclk <: 0 @ tmp;
|
||||
else
|
||||
tmp = partout_timestamped(p_lrclk, XUA_I2S_N_BITS, 0);
|
||||
|
||||
|
||||
tmp += 100;
|
||||
|
||||
/* Since BCLK is free-running, setup outputs/inputs at a known point in the future */
|
||||
@@ -72,7 +72,7 @@ void InitPorts_master(buffered _XUA_CLK_DIR port:32 p_lrclk, buffered _XUA_CLK_D
|
||||
for(int i = 0; i < I2S_WIRES_ADC; i++)
|
||||
{
|
||||
asm("setpt res[%0], %1"::"r"(p_i2s_adc[i]),"r"(tmp-1));
|
||||
|
||||
|
||||
if(XUA_I2S_N_BITS != 32)
|
||||
set_port_shift_count(p_i2s_adc[i], XUA_I2S_N_BITS);
|
||||
}
|
||||
@@ -127,13 +127,13 @@ void InitPorts_slave(buffered _XUA_CLK_DIR port:32 p_lrclk, buffered _XUA_CLK_DI
|
||||
for(int i = 0; i < I2S_WIRES_ADC; i++)
|
||||
{
|
||||
asm("setpt res[%0], %1"::"r"(p_i2s_adc[i]),"r"(tmp-1));
|
||||
if(XUA_I2S_N_BITS != 32)
|
||||
if(XUA_I2S_N_BITS != 32)
|
||||
set_port_shift_count(p_i2s_adc[i], XUA_I2S_N_BITS);
|
||||
}
|
||||
#endif
|
||||
|
||||
asm("setpt res[%0], %1"::"r"(p_lrclk),"r"(tmp-1));
|
||||
if(XUA_I2S_N_BITS != 32)
|
||||
if(XUA_I2S_N_BITS != 32)
|
||||
set_port_shift_count(p_lrclk, XUA_I2S_N_BITS);
|
||||
#endif /* (I2S_CHANS_ADC != 0 || I2S_CHANS_DAC != 0) */
|
||||
}
|
||||
|
||||
@@ -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) + EXTRA_I2S_ADC)
|
||||
#define IN_CHAN_COUNT (I2S_CHANS_ADC + XUA_NUM_PDM_MICS + (8*XUA_ADAT_RX_EN) + (2*XUA_SPDIF_RX_EN))
|
||||
|
||||
unsigned samplesIn[2][MAX(NUM_USB_CHAN_IN, IN_CHAN_COUNT)];
|
||||
|
||||
@@ -80,13 +80,21 @@ unsigned dsdMode = DSD_MODE_OFF;
|
||||
#endif
|
||||
#include "xua_audiohub_st.h"
|
||||
|
||||
static inline void PortOutput(buffered out port:32 p, int bits, int value)
|
||||
{
|
||||
if(bits == 32)
|
||||
p <: value;
|
||||
else
|
||||
partout(p, bits, value);
|
||||
}
|
||||
|
||||
static inline int HandleSampleClock(int frameCount, buffered _XUA_CLK_DIR port:32 p_lrclk)
|
||||
{
|
||||
#if CODEC_MASTER
|
||||
unsigned syncError = 0;
|
||||
unsigned lrval = 0;
|
||||
const unsigned lrval_mask = (0xffffffff << (32 - XUA_I2S_N_BITS));
|
||||
|
||||
|
||||
if(XUA_I2S_N_BITS != 32)
|
||||
{
|
||||
asm volatile("in %0, res[%1]":"=r"(lrval):"r"(p_lrclk):"memory");
|
||||
@@ -286,6 +294,19 @@ unsigned static AudioHub_MainLoop(chanend ?c_out, chanend ?c_spd_out
|
||||
else
|
||||
#endif
|
||||
{
|
||||
|
||||
#if XUA_I2S_DUMMY_SAMPS
|
||||
if(frameCount == 0)
|
||||
{
|
||||
for(int j = 0; j < XUA_I2S_DUMMY_SAMPS; j++)
|
||||
for(int i = 0; i < I2S_WIRES_DAC; i++)
|
||||
{
|
||||
PortOutput(p_i2s_dac[i], XUA_I2S_N_BITS, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if (I2S_CHANS_ADC != 0)
|
||||
#if (AUD_TO_USB_RATIO > 1)
|
||||
if (0 == audioToUsbRatioCounter)
|
||||
@@ -306,7 +327,7 @@ unsigned static AudioHub_MainLoop(chanend ?c_out, chanend ?c_spd_out
|
||||
// Manual IN instruction since compiler generates an extra setc per IN (bug #15256)
|
||||
unsigned sample;
|
||||
asm volatile("in %0, res[%1]" : "=r"(sample) : "r"(p_i2s_adc[index]));
|
||||
|
||||
|
||||
sample = bitrev(sample);
|
||||
if(XUA_I2S_N_BITS != 32)
|
||||
{
|
||||
@@ -478,6 +499,25 @@ unsigned static AudioHub_MainLoop(chanend ?c_out, chanend ?c_spd_out
|
||||
}
|
||||
#endif
|
||||
|
||||
#if XUA_I2S_DUMMY_SAMPS
|
||||
if(frameCount == 1)
|
||||
{
|
||||
int dummyBits;
|
||||
for(int j = 0; j < XUA_I2S_DUMMY_SAMPS; j++)
|
||||
{
|
||||
for(int i = 0; i < I2S_WIRES_ADC; i++)
|
||||
{
|
||||
asm volatile("in %0, res[%1]" : "=r"(dummyBits) : "r"(p_i2s_adc[i]));
|
||||
if(XUA_I2S_N_BITS)
|
||||
set_port_shift_count(p_i2s_adc[i], XUA_I2S_N_BITS);
|
||||
}
|
||||
asm volatile("in %0, res[%1]" : "=r"(dummyBits) : "r"(p_lrclk));
|
||||
if(XUA_I2S_N_BITS)
|
||||
set_port_shift_count(p_lrclk, XUA_I2S_N_BITS);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (I2S_CHANS_ADC != 0 || I2S_CHANS_DAC != 0)
|
||||
syncError += HandleSampleClock(frameCount, p_lrclk);
|
||||
#endif
|
||||
@@ -715,7 +755,13 @@ void XUA_AudioHub(chanend ?c_aud, clock ?clk_audio_mclk, clock ?clk_audio_bclk,
|
||||
/* Calculate master clock to bit clock (or DSD clock) divide for current sample freq
|
||||
* e.g. 11.289600 / (176400 * 64) = 1 */
|
||||
{
|
||||
unsigned numBits = XUA_I2S_N_BITS * I2S_CHANS_PER_FRAME;
|
||||
unsigned numBits = XUA_I2S_N_BITS * 2;
|
||||
|
||||
if(XUA_PCM_FORMAT == XUA_PCM_FORMAT_TDM)
|
||||
{
|
||||
/* TDM has 8 channels */
|
||||
numBits *= 4;
|
||||
}
|
||||
|
||||
#if (DSD_CHANS_DAC > 0)
|
||||
if(dsdMode == DSD_MODE_DOP)
|
||||
|
||||
@@ -394,7 +394,7 @@ __builtin_unreachable();
|
||||
unsigned l;
|
||||
unsafe
|
||||
{
|
||||
mult = multInPtr[i];
|
||||
mult = multInPtr[i];
|
||||
}
|
||||
{h, l} = macs(mult, sample, 0, 0);
|
||||
sample = h << 3;
|
||||
@@ -427,7 +427,7 @@ __builtin_unreachable();
|
||||
unsigned l;
|
||||
unsafe
|
||||
{
|
||||
mult = multInPtr[i];
|
||||
mult = multInPtr[i];
|
||||
}
|
||||
{h, l} = macs(mult, sample, 0, 0);
|
||||
sample = h << 3;
|
||||
@@ -461,7 +461,7 @@ __builtin_unreachable();
|
||||
unsigned l;
|
||||
unsafe
|
||||
{
|
||||
mult = multInPtr[i];
|
||||
mult = multInPtr[i];
|
||||
}
|
||||
{h, l} = macs(mult, sample, 0, 0);
|
||||
sample = h << 3;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2011-2023 XMOS LIMITED.
|
||||
// Copyright 2011-2022 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include "xua.h"
|
||||
#if XUA_USB_EN
|
||||
@@ -10,20 +10,13 @@
|
||||
#include "xud.h"
|
||||
#include "testct_byref.h"
|
||||
|
||||
#if XUA_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
#include "xua_hid_report.h"
|
||||
#include "user_hid.h"
|
||||
#include "xua_hid.h"
|
||||
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)
|
||||
@@ -110,10 +103,6 @@ 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
|
||||
@@ -145,14 +134,9 @@ void XUA_Buffer(
|
||||
c_clk_int,
|
||||
#endif
|
||||
c_sof, c_aud_ctl, p_off_mclk
|
||||
#if XUA_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
, c_hid
|
||||
#endif
|
||||
|
||||
#ifdef PAWPAW_INOUTHID
|
||||
, c_hid
|
||||
, c_hid_out
|
||||
#endif //#ifdef PAWPAW_INOUTHID
|
||||
#ifdef CHAN_BUFF_CTRL
|
||||
, c_buff_ctrl
|
||||
#endif
|
||||
@@ -203,11 +187,6 @@ 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
|
||||
@@ -245,15 +224,9 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
||||
XUD_ep ep_int = XUD_InitEp(c_ep_int);
|
||||
#endif
|
||||
|
||||
#if XUA_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
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;
|
||||
@@ -359,7 +332,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if XUA_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
|
||||
while (!hidIsReportDescriptorPrepared())
|
||||
;
|
||||
@@ -392,11 +365,6 @@ 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;
|
||||
@@ -929,8 +897,8 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if XUA_HID_ENABLED
|
||||
/* HID Report Data */
|
||||
#if( 0 < HID_CONTROLS )
|
||||
/* HID Report Data */
|
||||
case XUD_SetData_Select(c_hid, ep_hid, result):
|
||||
hid_ready_flag = 0U;
|
||||
unsigned reportTime;
|
||||
@@ -942,41 +910,6 @@ 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):
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#if (NUM_USB_CHAN_OUT > 1-1)
|
||||
.outputChanStr_1 = ""
|
||||
#if (1 < I2S_CHANS_DAC+1)
|
||||
"Playback 1"
|
||||
"Analogue 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)
|
||||
"Playback 2"
|
||||
"Analogue 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)
|
||||
"Playback 3"
|
||||
"Analogue 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)
|
||||
"Playback 4"
|
||||
"Analogue 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)
|
||||
"Playback 5"
|
||||
"Analogue 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)
|
||||
"Playback 6"
|
||||
"Analogue 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)
|
||||
"Playback 7"
|
||||
"Analogue 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)
|
||||
"Playback 8"
|
||||
"Analogue 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 = "Mic1"
|
||||
.inputChanStr_1 = ""
|
||||
#if (1 < I2S_CHANS_ADC+1)
|
||||
"Mix 1"
|
||||
"Analogue 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 = "Mic2"
|
||||
.inputChanStr_2 = ""
|
||||
#if (2 < I2S_CHANS_ADC+1)
|
||||
"Analogue 2"
|
||||
#endif
|
||||
@@ -1371,9 +1371,9 @@
|
||||
#endif
|
||||
|
||||
#if (NUM_USB_CHAN_IN > 3-1)
|
||||
.inputChanStr_3 = "OTG In 3"
|
||||
.inputChanStr_3 = ""
|
||||
#if (3 < I2S_CHANS_ADC+1)
|
||||
"OTG In 3"
|
||||
"Analogue 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 = "OTG In 4"
|
||||
.inputChanStr_4 = ""
|
||||
#if (4 < I2S_CHANS_ADC+1)
|
||||
"OTG In 4"
|
||||
"Analogue 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 = "Line In 5"
|
||||
.inputChanStr_5 = ""
|
||||
#if (5 < I2S_CHANS_ADC+1)
|
||||
"Line In 5"
|
||||
"Analogue 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 = "Line In 6"
|
||||
.inputChanStr_6 = ""
|
||||
#if (6 < I2S_CHANS_ADC+1)
|
||||
"Line In 6"
|
||||
"Analogue 6"
|
||||
#endif
|
||||
#if ((6 < SPDIF_RX_INDEX+2+1) && (6 > SPDIF_RX_INDEX)) && (XUA_SPDIF_RX_EN)
|
||||
#if (6 < I2S_CHANS_ADC+1)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2015-2023 XMOS LIMITED.
|
||||
// Copyright 2015-2021 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
|
||||
#ifndef __DESCRIPTOR_DEFS_H__
|
||||
@@ -33,7 +33,6 @@
|
||||
#define ENDPOINT_ADDRESS_OUT_MIDI (ENDPOINT_NUMBER_OUT_MIDI)
|
||||
#define ENDPOINT_ADDRESS_OUT_IAP (ENDPOINT_NUMBER_OUT_IAP)
|
||||
#define ENDPOINT_ADDRESS_OUT_IAP_EA_NATIVE_TRANS (ENDPOINT_NUMBER_OUT_IAP_EA_NATIVE_TRANS)
|
||||
#define ENDPOINT_ADDRESS_OUT_HID (ENDPOINT_NUMBER_OUT_HID)
|
||||
|
||||
/* Interface numbers enum */
|
||||
enum USBInterfaceNumber
|
||||
@@ -61,7 +60,7 @@ enum USBInterfaceNumber
|
||||
INTERFACE_NUMBER_IAP_EA_NATIVE_TRANS,
|
||||
#endif
|
||||
#endif
|
||||
#if XUA_OR_STATIC_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
INTERFACE_NUMBER_HID,
|
||||
#endif
|
||||
INTERFACE_COUNT /* End marker */
|
||||
@@ -71,8 +70,4 @@ enum USBInterfaceNumber
|
||||
#define ENDPOINT_INT_INTERVAL_IN_HID 0x08
|
||||
#endif
|
||||
|
||||
#ifndef ENDPOINT_INT_INTERVAL_OUT_HID
|
||||
#define ENDPOINT_INT_INTERVAL_OUT_HID 0x08
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "xc_ptr.h"
|
||||
#include "xua_ep0_uacreqs.h"
|
||||
|
||||
#if XUA_OR_STATIC_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
#include "hid.h"
|
||||
#include "xua_hid.h"
|
||||
#include "xua_hid_report.h"
|
||||
@@ -442,35 +442,6 @@ void XUA_Endpoint0_setBcdDevice(unsigned short bcd) {
|
||||
#endif // AUDIO_CLASS == 1}
|
||||
}
|
||||
|
||||
#if defined(__static_hid_report_h_exists__)
|
||||
#define hidReportDescriptorLength (sizeof(hidReportDescriptorPtr))
|
||||
static unsigned char hidReportDescriptorPtr[] = {
|
||||
#include "static_hid_report.h"
|
||||
};
|
||||
#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_)
|
||||
{
|
||||
@@ -542,13 +513,11 @@ void XUA_Endpoint0_init(chanend c_ep0_out, chanend c_ep0_in, NULLABLE_RESOURCE(c
|
||||
|
||||
#endif // XUA_USB_DESCRIPTOR_OVERWRITE_RATE_RES
|
||||
|
||||
#if XUA_OR_STATIC_HID_ENABLED
|
||||
#if XUA_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
hidReportInit();
|
||||
hidPrepareReportDescriptor();
|
||||
|
||||
size_t hidReportDescriptorLength = hidGetReportDescriptorLength();
|
||||
#endif
|
||||
unsigned char hidReportDescriptorLengthLo = hidReportDescriptorLength & 0xFF;
|
||||
unsigned char hidReportDescriptorLengthHi = (hidReportDescriptorLength & 0xFF00) >> 8;
|
||||
|
||||
@@ -559,7 +528,6 @@ void XUA_Endpoint0_init(chanend c_ep0_out, chanend c_ep0_in, NULLABLE_RESOURCE(c
|
||||
|
||||
hidDescriptor[HID_DESCRIPTOR_LENGTH_FIELD_OFFSET ] = hidReportDescriptorLengthLo;
|
||||
hidDescriptor[HID_DESCRIPTOR_LENGTH_FIELD_OFFSET + 1] = hidReportDescriptorLengthHi;
|
||||
|
||||
#endif // 0 < HID_CONTROLS
|
||||
|
||||
}
|
||||
@@ -763,7 +731,7 @@ void XUA_Endpoint0_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0
|
||||
|
||||
switch(sp.bRequest)
|
||||
{
|
||||
#if XUA_OR_STATIC_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
case USB_GET_DESCRIPTOR:
|
||||
|
||||
/* Check what inteface request is for */
|
||||
@@ -778,17 +746,15 @@ void XUA_Endpoint0_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0
|
||||
{
|
||||
/* Return HID Descriptor */
|
||||
result = XUD_DoGetRequest(ep0_out, ep0_in, hidDescriptor,
|
||||
hidDescriptor[0], sp.wLength);
|
||||
sizeof(hidDescriptor), sp.wLength);
|
||||
}
|
||||
break;
|
||||
case HID_REPORT:
|
||||
{
|
||||
/* Return HID report descriptor */
|
||||
#if XUA_HID_ENABLED
|
||||
unsigned char* hidReportDescriptorPtr;
|
||||
hidReportDescriptorPtr = hidGetReportDescriptor();
|
||||
size_t hidReportDescriptorLength = hidGetReportDescriptorLength();
|
||||
#endif
|
||||
result = XUD_DoGetRequest(ep0_out, ep0_in, hidReportDescriptorPtr,
|
||||
hidReportDescriptorLength, sp.wLength);
|
||||
}
|
||||
@@ -892,22 +858,12 @@ void XUA_Endpoint0_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if XUA_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
if (interfaceNum == INTERFACE_NUMBER_HID)
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -481,7 +481,7 @@ USB_Descriptor_Device_t devDesc_Audio2 =
|
||||
.iManufacturer = offsetof(StringDescTable_t, vendorStr)/sizeof(char *),
|
||||
.iProduct = offsetof(StringDescTable_t, productStr_Audio2)/sizeof(char *),
|
||||
.iSerialNumber = offsetof(StringDescTable_t, serialStr)/sizeof(char *),
|
||||
.bNumConfigurations = 0x01
|
||||
.bNumConfigurations = 0x02 /* Set to 2 such that windows does not load composite driver */
|
||||
};
|
||||
|
||||
/* Device Descriptor for Null Device */
|
||||
@@ -787,13 +787,10 @@ typedef struct
|
||||
#endif
|
||||
#endif // IAP
|
||||
|
||||
#if XUA_OR_STATIC_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
USB_Descriptor_Interface_t HID_Interface;
|
||||
USB_HID_Descriptor_t HID_Descriptor;
|
||||
USB_Descriptor_Endpoint_t HID_In_Endpoint;
|
||||
#if HID_OUT_REQUIRED
|
||||
USB_Descriptor_Endpoint_t HID_Out_Endpoint;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}__attribute__((packed)) USB_Config_Descriptor_Audio2_t;
|
||||
@@ -2211,14 +2208,14 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2=
|
||||
#endif
|
||||
#endif /* IAP */
|
||||
|
||||
#if XUA_OR_STATIC_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
#include "xua_hid_descriptors.h"
|
||||
#endif
|
||||
|
||||
};
|
||||
#endif /* (AUDIO_CLASS == 2) */
|
||||
|
||||
#if XUA_OR_STATIC_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
#if (AUDIO_CLASS ==1 )
|
||||
unsigned char hidDescriptor[] =
|
||||
{
|
||||
@@ -2333,14 +2330,14 @@ const unsigned num_freqs_a1 = MAX(3, (0
|
||||
#define DFU_INTERFACES_A1 0
|
||||
#endif
|
||||
|
||||
#if XUA_OR_STATIC_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
/*
|
||||
* The value of HID_INTERFACE_BYTES must match the length of the descriptors defined in
|
||||
* - xua_hid_descriptor_contents.h
|
||||
* - xua_hid_endpoint_descriptor_contents.h and
|
||||
* - xua_hid_interface_descriptor_contents.h
|
||||
*/
|
||||
#define HID_INTERFACE_BYTES ( 9 + 9 + (7 * (1 + HID_OUT_REQUIRED))) // always IN
|
||||
#define HID_INTERFACE_BYTES ( 9 + 9 + 7 )
|
||||
#define HID_INTERFACES_A1 1
|
||||
#else
|
||||
#define HID_INTERFACE_BYTES 0
|
||||
@@ -2382,7 +2379,7 @@ const unsigned num_freqs_a1 = MAX(3, (0
|
||||
|
||||
#endif
|
||||
|
||||
#if XUA_OR_STATIC_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
#define USB_HID_DESCRIPTOR_OFFSET (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 + INTERFACE_DESCRIPTOR_BYTES)
|
||||
#endif
|
||||
|
||||
@@ -2896,7 +2893,7 @@ unsigned char cfgDesc_Audio1[] =
|
||||
offsetof(StringDescTable_t, ctrlStr)/sizeof(char *), /* 8 iInterface */
|
||||
#endif
|
||||
|
||||
#if XUA_OR_STATIC_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
#include "xua_hid_descriptors.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
@@ -145,7 +145,7 @@ static void updateMasterVol(int unitID, chanend ?c_mix_ctl)
|
||||
outuint(c_mix_ctl, x);
|
||||
outct(c_mix_ctl, XS1_CT_END);
|
||||
}
|
||||
#else
|
||||
#else
|
||||
unsafe
|
||||
{
|
||||
unsigned int * unsafe multOutPtr = multOut;
|
||||
@@ -166,9 +166,7 @@ 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))
|
||||
{
|
||||
@@ -237,7 +235,6 @@ 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);
|
||||
|
||||
@@ -213,9 +213,6 @@ XUD_EpType epTypeTableOut[ENDPOINT_COUNT_OUT] = { XUD_EPTYPE_CTL | XUD_STATUS_EN
|
||||
#ifdef MIDI
|
||||
XUD_EPTYPE_BUL, /* MIDI */
|
||||
#endif
|
||||
#if HID_OUT_REQUIRED
|
||||
XUD_EPTYPE_INT,
|
||||
#endif
|
||||
#ifdef IAP
|
||||
XUD_EPTYPE_BUL, /* iAP */
|
||||
#ifdef IAP_EA_NATIVE_TRANS
|
||||
@@ -236,7 +233,7 @@ XUD_EpType epTypeTableIn[ENDPOINT_COUNT_IN] = { XUD_EPTYPE_CTL | XUD_STATUS_ENAB
|
||||
#ifdef MIDI
|
||||
XUD_EPTYPE_BUL,
|
||||
#endif
|
||||
#if XUA_OR_STATIC_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
XUD_EPTYPE_INT,
|
||||
#endif
|
||||
#ifdef IAP
|
||||
@@ -270,6 +267,115 @@ void xscope_user_init()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if XUA_USB_EN
|
||||
/* Core USB Audio functions - must be called on the Tile connected to the USB Phy */
|
||||
void usb_audio_core(chanend c_mix_out
|
||||
#ifdef MIDI
|
||||
, chanend c_midi
|
||||
#endif
|
||||
#if (MIXER)
|
||||
, chanend c_mix_ctl
|
||||
#endif
|
||||
, chanend ?c_clk_int
|
||||
, chanend ?c_clk_ctl
|
||||
, client interface i_dfu ?dfuInterface
|
||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
||||
, client interface pll_ref_if i_pll_ref
|
||||
#endif
|
||||
VENDOR_REQUESTS_PARAMS_DEC_
|
||||
)
|
||||
{
|
||||
chan c_sof;
|
||||
chan c_xud_out[ENDPOINT_COUNT_OUT]; /* Endpoint channels for XUD */
|
||||
chan c_xud_in[ENDPOINT_COUNT_IN];
|
||||
chan c_aud_ctl;
|
||||
|
||||
#if (!MIXER)
|
||||
#define c_mix_ctl null
|
||||
#endif
|
||||
|
||||
#ifdef IAP_EA_NATIVE_TRANS
|
||||
chan c_EANativeTransport_ctrl;
|
||||
#else
|
||||
#define c_EANativeTransport_ctrl null
|
||||
#endif
|
||||
|
||||
par
|
||||
{
|
||||
{
|
||||
#ifdef XUD_PRIORITY_HIGH
|
||||
set_core_high_priority_on();
|
||||
#endif
|
||||
|
||||
/* 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, xudPwrCfg);
|
||||
}
|
||||
|
||||
{
|
||||
unsigned x;
|
||||
thread_speed();
|
||||
|
||||
/* Attach mclk count port to mclk clock-block (for feedback) */
|
||||
//set_port_clock(p_for_mclk_count, clk_audio_mclk);
|
||||
#if(AUDIO_IO_TILE != XUD_TILE)
|
||||
set_clock_src(clk_audio_mclk_usb, p_mclk_in_usb);
|
||||
set_port_clock(p_for_mclk_count, clk_audio_mclk_usb);
|
||||
start_clock(clk_audio_mclk_usb);
|
||||
#else
|
||||
/* Clock port from same clock-block as I2S */
|
||||
/* TODO remove asm() */
|
||||
asm("ldw %0, dp[clk_audio_mclk]":"=r"(x));
|
||||
asm("setclk res[%0], %1"::"r"(p_for_mclk_count), "r"(x));
|
||||
#endif
|
||||
/* Endpoint & audio buffering cores */
|
||||
XUA_Buffer(c_xud_out[ENDPOINT_NUMBER_OUT_AUDIO],/* Audio Out*/
|
||||
#if (NUM_USB_CHAN_IN > 0)
|
||||
|
||||
c_xud_in[ENDPOINT_NUMBER_IN_AUDIO], /* Audio In */
|
||||
#endif
|
||||
#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP)
|
||||
c_xud_in[ENDPOINT_NUMBER_IN_FEEDBACK], /* Audio FB */
|
||||
#endif
|
||||
#ifdef MIDI
|
||||
c_xud_out[ENDPOINT_NUMBER_OUT_MIDI], /* MIDI Out */ // 2
|
||||
c_xud_in[ENDPOINT_NUMBER_IN_MIDI], /* MIDI In */ // 4
|
||||
c_midi,
|
||||
#endif
|
||||
#if (XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN)
|
||||
/* Audio Interrupt - only used for interrupts on external clock change */
|
||||
c_xud_in[ENDPOINT_NUMBER_IN_INTERRUPT],
|
||||
c_clk_int,
|
||||
#endif
|
||||
c_sof, c_aud_ctl, p_for_mclk_count
|
||||
#if (HID_CONTROLS)
|
||||
, c_xud_in[ENDPOINT_NUMBER_IN_HID]
|
||||
#endif
|
||||
, c_mix_out
|
||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
||||
, i_pll_ref
|
||||
#endif
|
||||
);
|
||||
//:
|
||||
}
|
||||
|
||||
/* Endpoint 0 Core */
|
||||
{
|
||||
thread_speed();
|
||||
XUA_Endpoint0( c_xud_out[0], c_xud_in[0], c_aud_ctl, c_mix_ctl, c_clk_ctl, c_EANativeTransport_ctrl, dfuInterface VENDOR_REQUESTS_PARAMS_);
|
||||
}
|
||||
|
||||
//:
|
||||
}
|
||||
}
|
||||
#endif /* XUA_USB_EN */
|
||||
|
||||
|
||||
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
void SpdifTxWrapper(chanend c_spdif_tx)
|
||||
{
|
||||
@@ -405,9 +511,6 @@ 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()
|
||||
@@ -472,20 +575,6 @@ int main()
|
||||
|
||||
#if ((XUA_SYNCMODE == XUA_SYNCMODE_SYNC) || XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN)
|
||||
interface pll_ref_if i_pll_ref;
|
||||
#endif
|
||||
chan c_sof;
|
||||
chan c_xud_out[ENDPOINT_COUNT_OUT]; /* Endpoint channels for XUD */
|
||||
chan c_xud_in[ENDPOINT_COUNT_IN];
|
||||
chan c_aud_ctl;
|
||||
|
||||
#if (!MIXER)
|
||||
#define c_mix_ctl null
|
||||
#endif
|
||||
|
||||
#ifdef IAP_EA_NATIVE_TRANS
|
||||
chan c_EANativeTransport_ctrl;
|
||||
#else
|
||||
#define c_EANativeTransport_ctrl null
|
||||
#endif
|
||||
|
||||
USER_MAIN_DECLARATIONS
|
||||
@@ -508,90 +597,33 @@ int main()
|
||||
#endif
|
||||
#endif
|
||||
#if XUA_USB_EN
|
||||
|
||||
/* Core USB task, buffering, USB etc */
|
||||
{
|
||||
#ifdef XUD_PRIORITY_HIGH
|
||||
set_core_high_priority_on();
|
||||
#endif
|
||||
|
||||
/* 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, xudPwrCfg);
|
||||
}
|
||||
|
||||
/* Core USB audio task, buffering, USB etc */
|
||||
{
|
||||
unsigned x;
|
||||
thread_speed();
|
||||
|
||||
/* Attach mclk count port to mclk clock-block (for feedback) */
|
||||
//set_port_clock(p_for_mclk_count, clk_audio_mclk);
|
||||
#if(AUDIO_IO_TILE != XUD_TILE)
|
||||
set_clock_src(clk_audio_mclk_usb, p_mclk_in_usb);
|
||||
set_port_clock(p_for_mclk_count, clk_audio_mclk_usb);
|
||||
start_clock(clk_audio_mclk_usb);
|
||||
#else
|
||||
/* Clock port from same clock-block as I2S */
|
||||
/* TODO remove asm() */
|
||||
asm("ldw %0, dp[clk_audio_mclk]":"=r"(x));
|
||||
asm("setclk res[%0], %1"::"r"(p_for_mclk_count), "r"(x));
|
||||
#endif
|
||||
/* Endpoint & audio buffering cores */
|
||||
XUA_Buffer(c_xud_out[ENDPOINT_NUMBER_OUT_AUDIO],/* Audio Out*/
|
||||
#if (NUM_USB_CHAN_IN > 0)
|
||||
|
||||
c_xud_in[ENDPOINT_NUMBER_IN_AUDIO], /* Audio In */
|
||||
#endif
|
||||
#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP)
|
||||
c_xud_in[ENDPOINT_NUMBER_IN_FEEDBACK], /* Audio FB */
|
||||
#endif
|
||||
usb_audio_core(c_mix_out
|
||||
#ifdef MIDI
|
||||
c_xud_out[ENDPOINT_NUMBER_OUT_MIDI], /* MIDI Out */ // 2
|
||||
c_xud_in[ENDPOINT_NUMBER_IN_MIDI], /* MIDI In */ // 4
|
||||
c_midi,
|
||||
, c_midi
|
||||
#endif
|
||||
#if (XUA_SPDIF_RX_EN || XUA_ADAT_RX_EN)
|
||||
/* Audio Interrupt - only used for interrupts on external clock change */
|
||||
c_xud_in[ENDPOINT_NUMBER_IN_INTERRUPT],
|
||||
c_clk_int,
|
||||
#ifdef IAP
|
||||
, c_iap
|
||||
#ifdef IAP_EA_NATIVE_TRANS
|
||||
, c_ea_data
|
||||
#endif
|
||||
c_sof, c_aud_ctl, p_for_mclk_count
|
||||
#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 (MIXER)
|
||||
, c_mix_ctl
|
||||
#endif
|
||||
, c_clk_int, c_clk_ctl, dfuInterface
|
||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
||||
, i_pll_ref
|
||||
, i_pll_ref
|
||||
#endif
|
||||
);
|
||||
//:
|
||||
}
|
||||
|
||||
/* Endpoint 0 Core */
|
||||
{
|
||||
thread_speed();
|
||||
XUA_Endpoint0( c_xud_out[0], c_xud_in[0], c_aud_ctl, c_mix_ctl, c_clk_ctl, c_EANativeTransport_ctrl, dfuInterface VENDOR_REQUESTS_PARAMS_);
|
||||
}
|
||||
VENDOR_REQUESTS_PARAMS_
|
||||
|
||||
);
|
||||
#endif /* XUA_USB_EN */
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2013-2023 XMOS LIMITED.
|
||||
// Copyright 2013-2021 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
|
||||
/**
|
||||
@@ -34,7 +34,7 @@ typedef struct hidEvent_t {
|
||||
#define HID_MAX_DATA_BYTES ( 4 )
|
||||
#define HID_EVENT_INVALID_ID ( 0x100 )
|
||||
|
||||
#if XUA_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
|
||||
/**
|
||||
* \brief Get the data for the next HID Report
|
||||
@@ -61,5 +61,21 @@ size_t UserHIDGetData( const unsigned id, unsigned char hidData[ HID_MAX_DATA_BY
|
||||
*/
|
||||
void UserHIDInit( void );
|
||||
|
||||
/**
|
||||
* \brief Record that a HID event has occurred
|
||||
*
|
||||
* \param[in] hidEvent A list of events which have occurred.
|
||||
* Each element specifies a HID Report ID, a bit and byte
|
||||
* within the HID Report and the value for it.
|
||||
* Set the Report ID to zero if not using Report IDs
|
||||
* (see 5.6, 6.2.2.7, 8.1 and 8.2).
|
||||
* \param[in] hidEventCnt The length of the \a hidEvent list.
|
||||
*
|
||||
* \returns The index of the first unrecorded event in \a hidEvent
|
||||
* \retval Zero indicates no events were recorded
|
||||
* \retval \a hidEventCnt indicates all events were recorded
|
||||
*/
|
||||
size_t UserHIDRecordEvent( const hidEvent_t hidEvent[], const size_t hidEventCnt );
|
||||
|
||||
#endif /* ( 0 < HID_CONTROLS ) */
|
||||
#endif /* __USER_HID_H__ */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 XMOS LIMITED.
|
||||
// Copyright 2019-2022 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include <stdint.h>
|
||||
#include <xs1.h>
|
||||
@@ -13,7 +13,7 @@
|
||||
#define DEBUG_PRINT_ENABLE_HID_XC 0
|
||||
#include "debug_print.h"
|
||||
|
||||
#if XUA_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
static unsigned HidCalcNewReportTime( const unsigned currentPeriod, const unsigned reportTime, const unsigned reportToSetIdleInterval, const unsigned newPeriod );
|
||||
static unsigned HidCalcReportToSetIdleInterval( const unsigned reportTime );
|
||||
static unsigned HidFindSetIdleActivationPoint( const unsigned currentPeriod, const unsigned timeWithinPeriod );
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2021-2023 XMOS LIMITED.
|
||||
// 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 XUA_HID_ENABLED
|
||||
#if( 0 < HID_CONTROLS )
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021-2023 XMOS LIMITED.
|
||||
// Copyright 2021 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
|
||||
/**
|
||||
@@ -31,19 +31,6 @@
|
||||
HID_ENDPOINT_DESCRIPTOR_PACKET_SIZE_HI, /* 5 wMaxPacketSize */
|
||||
ENDPOINT_INT_INTERVAL_IN_HID, /* 6 bInterval */
|
||||
|
||||
#if (HID_OUT_REQUIRED)
|
||||
|
||||
/* HID Endpoint descriptor (OUT) */
|
||||
HID_ENDPOINT_DESCRIPTOR_LENGTH, /* 0 bLength */
|
||||
HID_ENDPOINT_DESCRIPTOR_TYPE, /* 1 bDescriptorType */
|
||||
ENDPOINT_ADDRESS_OUT_HID, /* 2 bEndpointAddress */
|
||||
HID_ENDPOINT_ATTRIBUTES, /* 3 bmAttributes (INTERRUPT) */
|
||||
HID_ENDPOINT_DESCRIPTOR_PACKET_SIZE_LO, /* 4 wMaxPacketSize */
|
||||
HID_ENDPOINT_DESCRIPTOR_PACKET_SIZE_HI, /* 5 wMaxPacketSize */
|
||||
ENDPOINT_INT_INTERVAL_OUT_HID, /* 6 bInterval */
|
||||
|
||||
#endif
|
||||
|
||||
#elif (AUDIO_CLASS == 2)
|
||||
|
||||
.HID_In_Endpoint =
|
||||
@@ -57,21 +44,6 @@
|
||||
.bInterval = ENDPOINT_INT_INTERVAL_IN_HID,
|
||||
},
|
||||
|
||||
#if (HID_OUT_REQUIRED)
|
||||
|
||||
.HID_Out_Endpoint =
|
||||
{
|
||||
/* Endpoint descriptor (OUT) */
|
||||
.bLength = sizeof(USB_Descriptor_Endpoint_t),
|
||||
.bDescriptorType = HID_ENDPOINT_DESCRIPTOR_TYPE,
|
||||
.bEndpointAddress = ENDPOINT_ADDRESS_OUT_HID,
|
||||
.bmAttributes = HID_ENDPOINT_ATTRIBUTES,
|
||||
.wMaxPacketSize = HID_ENDPOINT_DESCRIPTOR_PACKET_SIZE_LO,
|
||||
.bInterval = ENDPOINT_INT_INTERVAL_OUT_HID,
|
||||
},
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error "Unknown Audio Class"
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021-2023 XMOS LIMITED.
|
||||
// Copyright 2021 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
|
||||
/**
|
||||
@@ -15,8 +15,7 @@
|
||||
#define HID_INTERFACE_DESCRIPTOR_LENGTH ( 0x09 ) /* Size of descriptor in Bytes */
|
||||
#define HID_INTERFACE_DESCRIPTOR_TYPE ( 0x04 ) /* Interface 0x04 */
|
||||
#define HID_INTERFACE_ALTERNATE_SETTING ( 0x00 ) /* Value used alternate interfaces using SetInterface Request */
|
||||
#define HID_INTERFACE_NUMBER_OF_ENDPOINTS ( 0x01 + HID_OUT_REQUIRED )
|
||||
/* Number of endpoints for this interface (excluding 0) */
|
||||
#define HID_INTERFACE_NUMBER_OF_ENDPOINTS ( 0x01 ) /* Number of endpoitns for this interface (excluding 0) */
|
||||
#define HID_INTERFACE_CLASS ( 0x03 )
|
||||
#define HID_INTERFACE_SUBCLASS ( 0x00 ) /* No boot device */
|
||||
#define HID_INTERFACE_PROTOCOL ( 0x00 )
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2016-2023 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#ifdef SIMULATION
|
||||
#include "xua.h"
|
||||
|
||||
#include <platform.h>
|
||||
#include <print.h>
|
||||
@@ -45,7 +46,7 @@ void slave_mode_clk_setup(const unsigned samFreq, const unsigned chans_per_frame
|
||||
const unsigned mclk_freq = 24576000;
|
||||
|
||||
const unsigned mclk_bclk_ratio = mclk_freq / (chans_per_frame * samFreq * data_bits);
|
||||
const unsigned bclk_lrclk_ratio = (chans_per_frame * data_bits); // 48.828Hz LRCLK
|
||||
const unsigned bclk_lrclk_ratio = (chans_per_frame * data_bits + (data_bits * XUA_I2S_DUMMY_SAMPS)); // 48.828Hz LRCLK
|
||||
|
||||
//bclk
|
||||
configure_clock_src_divide(clk_audio_bclk_gen, p_mclk_gen, mclk_bclk_ratio/2);
|
||||
|
||||
Reference in New Issue
Block a user