forked from PAWPAW-Mirror/lib_xua
Merge branch 'master' into refactor_i2s
* master: Fixes #12 Patches up #11 Buffer file arrangement tidy Resolved build issue related to XS2 DSD fix Chnagelog update Manually applied XS2 DSD fix - could not easily cherry pick due to conflicts CHANGELOG tidy Added basic PDM mic delay (based on MIC_BUFFER_DEPTH). Default, 1 sample. Added XUA_ENDPOINT_COUNT_CUSTOM_IN/OUT define ADAT related build fixes Syntax error in main with digital RX Build fixes relating to SPDIF SPDIF_TX and XUA_DFU_EN changes for build Fixed BCD_DEVICE_N def Extra comment Use a define for USB class of control interface (from sc_usb_audio vf_spk_1.1.2 branch) # Conflicts: # lib_xua/src/core/audiohub/xua_audiohub.xc
This commit is contained in:
@@ -7,19 +7,20 @@ lib_xua Change Log
|
||||
- ADDED: Linux Makefile for xmosdfu host application
|
||||
- ADDED: Raspberry Pi Makefile for xmosdfu host application
|
||||
- ADDED: Documentation of PID argument to xmosdfu
|
||||
- ADDED: Optional build time microphone delay line (MIC_BUFFER_DEPTH)
|
||||
- CHANGE: Removal of audManage_if, users should define their own interfaces as required
|
||||
- CHANGE: Vendor specific control interface in UAC1 descriptor now has a string descriptor
|
||||
so it shows up with a descriptive name in Windows Device Manager
|
||||
- CHANGE: DFU_BCD_DEVICE removed (now uses BCD_DEVICE)
|
||||
- CHANGE: Renaming in descriptors.h to avoid clashes with application
|
||||
- RESOLVED: FIR gain compensation for PDM mics set incorrectly for divide of 8
|
||||
- RESOLVED: Incorrect xmosdfu DYLD path in test script code
|
||||
- RESOLVED: xmosdfu cannot find XMOS device on modern MacBook Pro (#17897)
|
||||
- RESOLVED: Issue when feedback is initially incorrect when two SOF's are not yet received
|
||||
- RESOLVED: AUDIO_TILE and PDM_TILE may now share the same value/tile
|
||||
- RESOLVED: Cope with out of order interface numbers in xmosdfu
|
||||
- CHANGE: Renaming in descriptors.h to avoid clashes with application
|
||||
- CHANGE: Vendor specific control interface in UAC1 descriptor now has a string descriptor
|
||||
so it shows up with a descriptive name in Windows Device Manager
|
||||
- CHANGE: DFU_BCD_DEVICE removed (used BCD_DEVICE)
|
||||
- CHANGE: Fork from sc_usb_audio to lib_xua
|
||||
|
||||
- RESOLVED: DSD playback not functional on xCORE-200 (introduced in sc_usb_audio 6.14)
|
||||
|
||||
Legacy release history
|
||||
----------------------
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* CODEC configuration functions.
|
||||
*/
|
||||
void XUA_AudioHub(chanend ?c_aud
|
||||
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
, chanend c_spdif_tx
|
||||
#endif
|
||||
#if(defined(SPDIF_RX) || defined(ADAT_RX))
|
||||
|
||||
@@ -299,13 +299,8 @@
|
||||
/**
|
||||
* @brief Enables SPDIF Tx. Default: 0 (Disabled)
|
||||
*/
|
||||
#ifndef SPDIF_TX
|
||||
#define SPDIF_TX (0)
|
||||
#endif
|
||||
|
||||
/* Tidy up old SPDIF usage */
|
||||
#if defined(SPDIF_TX) && (SPDIF_TX == 0)
|
||||
#undef SPDIF_TX
|
||||
#ifndef XUA_SPDIF_TX_EN
|
||||
#define XUA_SPDIF_TX_EN (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -521,21 +516,21 @@
|
||||
* @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number.
|
||||
*/
|
||||
#ifndef BCD_DEVICE_J
|
||||
#define BCD_DEVICE_J 1
|
||||
#define BCD_DEVICE_J (1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number.
|
||||
*/
|
||||
#ifndef BCD_DEVICE_M
|
||||
#define BCD_DEVICE_M 0
|
||||
#define BCD_DEVICE_M (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number.
|
||||
*/
|
||||
#ifndef BCD_DEVICE_N
|
||||
#define BCD_DEVICE_N
|
||||
#define BCD_DEVICE_N (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -1193,7 +1188,7 @@ enum USBEndpointNumber_In
|
||||
ENDPOINT_NUMBER_IN_IAP_EA_NATIVE_TRANS,
|
||||
#endif
|
||||
#endif
|
||||
ENDPOINT_COUNT_IN /* End marker */
|
||||
XUA_ENDPOINT_COUNT_IN /* End marker */
|
||||
};
|
||||
|
||||
enum USBEndpointNumber_Out
|
||||
@@ -1209,9 +1204,21 @@ enum USBEndpointNumber_Out
|
||||
ENDPOINT_NUMBER_OUT_IAP_EA_NATIVE_TRANS,
|
||||
#endif
|
||||
#endif
|
||||
ENDPOINT_COUNT_OUT /* End marker */
|
||||
XUA_ENDPOINT_COUNT_OUT /* End marker */
|
||||
};
|
||||
|
||||
|
||||
#ifndef XUA_ENDPOINT_COUNT_CUSTOM_OUT
|
||||
#define XUA_ENDPOINT_COUNT_CUSTOM_OUT 0
|
||||
#endif
|
||||
|
||||
#ifndef XUA_ENDPOINT_COUNT_CUSTOM_IN
|
||||
#define XUA_ENDPOINT_COUNT_CUSTOM_IN 0
|
||||
#endif
|
||||
|
||||
#define ENDPOINT_COUNT_IN (XUA_ENDPOINT_COUNT_IN + XUA_ENDPOINT_COUNT_CUSTOM_IN)
|
||||
#define ENDPOINT_COUNT_OUT (XUA_ENDPOINT_COUNT_OUT + XUA_ENDPOINT_COUNT_CUSTOM_OUT)
|
||||
|
||||
#endif
|
||||
|
||||
/*** Internal defines below here. NOT FOR MODIFICATION ***/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file audio.xc
|
||||
* @brief XMOS L1/L2 USB 2,0 Audio Reference Design. Audio Functions.
|
||||
* @file xua_audiohub.xc
|
||||
* @brief XMOS USB 2.0 Audio Reference Design. Audio Functions.
|
||||
* @author Ross Owen, XMOS Semiconductor Ltd
|
||||
*
|
||||
* This thread handles I2S and pars an additional SPDIF Tx thread. It forwards samples to the SPDIF Tx thread.
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "audioports.h"
|
||||
#include "audiohw.h"
|
||||
#include "mic_array_conf.h"
|
||||
#ifdef SPDIF_TX
|
||||
#if (XUA_SPDIF_TX_EN)
|
||||
#include "SpdifTransmit.h"
|
||||
#endif
|
||||
#ifdef ADAT_TX
|
||||
@@ -103,7 +103,7 @@ unsigned dsdMode = DSD_MODE_OFF;
|
||||
extern unsafe port p_mclk_in;
|
||||
extern in port p_mclk_in2;
|
||||
|
||||
#ifdef SPDIF_TX
|
||||
#if (XUA_SPDIF_TX_EN)
|
||||
extern buffered out port:32 p_spdif_tx;
|
||||
#endif
|
||||
|
||||
@@ -113,9 +113,12 @@ extern buffered out port:32 p_adat_tx;
|
||||
|
||||
extern clock clk_audio_mclk;
|
||||
extern clock clk_audio_bclk;
|
||||
extern clock clk_mst_spd;
|
||||
|
||||
extern void device_reboot(void);
|
||||
#if XUA_SPDIF_TX_EN || defined(ADAT_TX)
|
||||
extern clock clk_mst_spd;
|
||||
#endif
|
||||
|
||||
//extern void device_reboot(void);
|
||||
|
||||
#define MAX_DIVIDE_48 (MCLK_48/MIN_FREQ_48/64)
|
||||
#define MAX_DIVIDE_44 (MCLK_44/MIN_FREQ_44/64)
|
||||
@@ -812,7 +815,7 @@ unsigned static deliver_master(chanend ?c_out, chanend ?c_spd_out
|
||||
/* Request digital data (with prefill) */
|
||||
outuint(c_dig_rx, 0);
|
||||
#endif
|
||||
#if defined(SPDIF_TX) && (NUM_USB_CHAN_OUT > 0)
|
||||
#if (XUA_SPDIF_TX_EN) && (NUM_USB_CHAN_OUT > 0)
|
||||
outuint(c_spd_out, samplesOut[SPDIF_TX_INDEX]); /* Forward sample to S/PDIF Tx thread */
|
||||
unsigned sample = samplesOut[SPDIF_TX_INDEX + 1];
|
||||
outuint(c_spd_out, sample); /* Forward sample to S/PDIF Tx thread */
|
||||
@@ -1380,8 +1383,7 @@ unsigned static deliver_slave(chanend ?c_out, chanend ?c_spd_out
|
||||
}
|
||||
#endif //CODEC_MASTER
|
||||
|
||||
|
||||
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
void SpdifTxWrapper(chanend c_spdif_tx)
|
||||
{
|
||||
unsigned portId;
|
||||
@@ -1465,21 +1467,21 @@ static void dummy_deliver(chanend ?c_out, unsigned &command)
|
||||
}
|
||||
|
||||
void XUA_AudioHub(chanend ?c_mix_out
|
||||
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
chanend c_spdif_out,
|
||||
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
, chanend c_spdif_out
|
||||
#endif
|
||||
#if (defined(ADAT_RX) || defined(SPDIF_RX))
|
||||
chanend c_dig_rx,
|
||||
, chanend c_dig_rx
|
||||
#endif
|
||||
#if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1)
|
||||
, server interface i_dfu ?dfuInterface
|
||||
, server interface i_dfu ?dfuInterface
|
||||
#endif
|
||||
#if (NUM_PDM_MICS > 0)
|
||||
, chanend c_pdm_in
|
||||
, chanend c_pdm_in
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#if defined (SPDIF_TX) && (SPDIF_TX_TILE == AUDIO_IO_TILE)
|
||||
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE == AUDIO_IO_TILE)
|
||||
chan c_spdif_out;
|
||||
#endif
|
||||
#ifdef ADAT_TX
|
||||
@@ -1515,16 +1517,22 @@ chanend c_dig_rx,
|
||||
#endif
|
||||
#ifdef ADAT_TX
|
||||
/* Share SPDIF clk blk */
|
||||
configure_clock_src(clk_mst_spd, p_mclk_in);
|
||||
unsafe
|
||||
{
|
||||
configure_clock_src(clk_mst_spd, (port)p_mclk_in);
|
||||
}
|
||||
configure_out_port_no_ready(p_adat_tx, clk_mst_spd, 0);
|
||||
set_clock_fall_delay(clk_mst_spd, 7);
|
||||
#ifndef SPDIF_TX
|
||||
#if (XUA_SPDIF_TX_EN == 0)
|
||||
start_clock(clk_mst_spd);
|
||||
#endif
|
||||
#endif
|
||||
/* Configure ADAT/SPDIF tx ports */
|
||||
#if defined(SPDIF_TX) && (SPDIF_TX_TILE == AUDIO_IO_TILE)
|
||||
SpdifTransmitPortConfig(p_spdif_tx, clk_mst_spd, p_mclk_in);
|
||||
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE == AUDIO_IO_TILE)
|
||||
unsafe
|
||||
{
|
||||
SpdifTransmitPortConfig(p_spdif_tx, clk_mst_spd, (port)p_mclk_in);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Perform required CODEC/ADC/DAC initialisation */
|
||||
@@ -1670,7 +1678,7 @@ chanend c_dig_rx,
|
||||
par
|
||||
{
|
||||
|
||||
#if defined(SPDIF_TX) && (SPDIF_TX_TILE == AUDIO_IO_TILE)
|
||||
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE == AUDIO_IO_TILE)
|
||||
{
|
||||
set_thread_fast_mode_on();
|
||||
SpdifTransmit(p_spdif_tx, c_spdif_out);
|
||||
@@ -1684,7 +1692,7 @@ chanend c_dig_rx,
|
||||
}
|
||||
#endif
|
||||
{
|
||||
#ifdef SPDIF_TX
|
||||
#if (XUA_SPDIF_TX_EN)
|
||||
/* Communicate master clock and sample freq to S/PDIF thread */
|
||||
outuint(c_spdif_out, curSamFreq);
|
||||
outuint(c_spdif_out, mClk);
|
||||
@@ -1713,7 +1721,7 @@ chanend c_dig_rx,
|
||||
#else
|
||||
command = deliver_master(c_mix_out
|
||||
#endif
|
||||
#ifdef SPDIF_TX
|
||||
#ifdef XUA_SPDIF_TX_EN
|
||||
, c_spdif_out
|
||||
#else
|
||||
, null
|
||||
@@ -1779,7 +1787,7 @@ chanend c_dig_rx,
|
||||
|
||||
#endif /* NO_USB */
|
||||
|
||||
#ifdef SPDIF_TX
|
||||
#if (XUA_SPDIF_TX_EN)
|
||||
/* Notify S/PDIF task of impending new freq... */
|
||||
outct(c_spdif_out, XS1_CT_END);
|
||||
#endif
|
||||
|
||||
@@ -61,8 +61,13 @@ static xc_ptr p_multIn;
|
||||
#endif
|
||||
|
||||
/* Number of channels to/from the USB bus - initialised to HS Audio 2.0 */
|
||||
unsigned g_numUsbChan_Out = NUM_USB_CHAN_OUT;
|
||||
#if (AUDIO_CLASS == 1)
|
||||
unsigned g_numUsbChan_In = NUM_USB_CHAN_IN_FS;
|
||||
unsigned g_numUsbChan_Out = NUM_USB_CHAN_OUT_FS;
|
||||
#else
|
||||
unsigned g_numUsbChan_In = NUM_USB_CHAN_IN;
|
||||
unsigned g_numUsbChan_Out = NUM_USB_CHAN_OUT;
|
||||
#endif
|
||||
|
||||
/* Circular audio buffers */
|
||||
unsigned outAudioBuff[(BUFF_SIZE_OUT >> 2)+ (MAX_DEVICE_AUD_PACKET_SIZE_OUT >> 2)];
|
||||
@@ -588,6 +593,15 @@ static inline void SetupZerosSendBuffer(XUD_ep aud_to_host_usb_ep, unsigned samp
|
||||
|
||||
asm volatile("stw %0, %1[0]"::"r"(mid),"r"(g_aud_to_host_zeros));
|
||||
|
||||
#if XUA_DEBUG_BUFFER
|
||||
printstr("slotSize: ");
|
||||
printintln(slotSize);
|
||||
printstr("g_numUsbChan_In: ");
|
||||
printintln(g_numUsbChan_In);
|
||||
printstr("mid: ");
|
||||
printintln(mid);
|
||||
#endif
|
||||
|
||||
/* Mark EP ready with the zero buffer. Note this will simply update the packet size
|
||||
* if it is already ready */
|
||||
|
||||
@@ -693,7 +707,7 @@ void XUA_Buffer_Decouple(chanend c_mix_out
|
||||
/* NOTE: For UAC2 IN EP not marked ready at this point - Initial size of zero buffer not known
|
||||
* since we don't know the USB bus-speed yet.
|
||||
* The host will send a SetAltInterface before streaming which will lead to this core
|
||||
* getting a SET_CHANNEL_COUNT_IN. This will setup the EP for the first packet */
|
||||
* getting a SET_STREAM_FORMAT_IN. This will setup the EP for the first packet */
|
||||
#if (AUDIO_CLASS == 1)
|
||||
/* For UAC1 we know we only run at FS */
|
||||
/* Set buffer back to zeros buffer */
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef NO_USB
|
||||
#include <interrupt.h>
|
||||
#include "interrupt.h"
|
||||
|
||||
register_interrupt_handler(handle_audio_request, 1, 200)
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#include "xua.h" /* Device specific defines */
|
||||
#include "xua.h" /* Device specific defines */
|
||||
#ifndef EXCLUDE_USB_AUDIO_MAIN
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ unsafe
|
||||
on tile[XUD_TILE] : in port p_for_mclk_count = PORT_MCLK_COUNT;
|
||||
#endif
|
||||
|
||||
#ifdef SPDIF_TX
|
||||
#if (XUA_SPDIF_TX_EN == 1)
|
||||
on tile[SPDIF_TX_TILE] : buffered out port:32 p_spdif_tx = PORT_SPDIF_OUT;
|
||||
#endif
|
||||
|
||||
@@ -177,7 +177,7 @@ clock clk_pdm = on tile[PDM_TILE]:
|
||||
on tile[MIDI_TILE] : clock clk_midi = CLKBLK_MIDI;
|
||||
#endif
|
||||
|
||||
#if defined(SPDIF_TX) || defined(ADAT_TX)
|
||||
#if XUA_SPDIF_TX_EN || defined(ADAT_TX)
|
||||
on tile[SPDIF_TX_TILE] : clock clk_mst_spd = CLKBLK_SPDIF_TX;
|
||||
#endif
|
||||
|
||||
@@ -370,8 +370,11 @@ VENDOR_REQUESTS_PARAMS_DEC_
|
||||
asm("setclk res[%0], %1"::"r"(p_for_mclk_count), "r"(x));
|
||||
#endif
|
||||
//:buffer
|
||||
XUA_Buffer(c_xud_out[ENDPOINT_NUMBER_OUT_AUDIO], /* Audio Out*/
|
||||
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
|
||||
@@ -423,7 +426,7 @@ VENDOR_REQUESTS_PARAMS_DEC_
|
||||
#endif /* NO_USB */
|
||||
|
||||
void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc,
|
||||
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
chanend c_spdif_tx,
|
||||
#endif
|
||||
#ifdef MIXER
|
||||
@@ -433,7 +436,7 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc,
|
||||
chanend ?c_adat_rx,
|
||||
chanend ?c_clk_ctl,
|
||||
chanend ?c_clk_int
|
||||
#if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0)
|
||||
#if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1)
|
||||
, server interface i_dfu ?dfuInterface
|
||||
#endif
|
||||
#if (NUM_PDM_MICS > 0)
|
||||
@@ -469,11 +472,11 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc,
|
||||
#define AUDIO_CHANNEL c_aud_in
|
||||
#endif
|
||||
XUA_AudioHub(AUDIO_CHANNEL
|
||||
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
c_spdif_tx,
|
||||
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
, c_spdif_tx
|
||||
#endif
|
||||
#if defined(SPDIF_RX) || defined(ADAT_RX)
|
||||
c_dig_rx,
|
||||
, c_dig_rx
|
||||
#endif
|
||||
#if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1)
|
||||
, dfuInterface
|
||||
@@ -545,7 +548,7 @@ int main()
|
||||
#define c_adat_rx null
|
||||
#endif
|
||||
|
||||
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
chan c_spdif_tx;
|
||||
#endif
|
||||
|
||||
@@ -617,7 +620,7 @@ int main()
|
||||
p_mclk_in = p_mclk_in_;
|
||||
}
|
||||
usb_audio_io(c_mix_out, c_adc
|
||||
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
, c_spdif_tx
|
||||
#endif
|
||||
#ifdef MIXER
|
||||
@@ -633,7 +636,7 @@ int main()
|
||||
);
|
||||
}
|
||||
|
||||
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
|
||||
on tile[SPDIF_TX_TILE]:
|
||||
{
|
||||
thread_speed();
|
||||
|
||||
@@ -34,6 +34,10 @@ extern unsafe port p_mclk_in;
|
||||
/* Delcared in main.xc */
|
||||
extern clock clk_pdm;
|
||||
|
||||
#ifndef MIC_BUFFER_DEPTH
|
||||
#define MIC_BUFFER_DEPTH 1
|
||||
#endif
|
||||
|
||||
int mic_decimator_fir_data[8][THIRD_STAGE_COEFS_PER_STAGE * MAX_DECIMATION_FACTOR] = {{0}};
|
||||
|
||||
mic_array_frame_time_domain mic_audio[2];
|
||||
@@ -50,7 +54,7 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio)
|
||||
{
|
||||
unsigned buffer;
|
||||
unsigned samplerate;
|
||||
int output[NUM_PDM_MICS];
|
||||
int output[MIC_BUFFER_DEPTH][NUM_PDM_MICS];
|
||||
|
||||
#ifdef MIC_PROCESSING_USE_INTERFACE
|
||||
i_mic_process.init();
|
||||
@@ -64,12 +68,15 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio)
|
||||
unsigned decimatorCount = 1;
|
||||
#endif
|
||||
|
||||
unsigned micBufferWrite = (MIC_BUFFER_DEPTH -1);
|
||||
unsigned micBufferRead = 0;
|
||||
|
||||
mic_array_decimator_conf_common_t dcc;
|
||||
const int * unsafe fir_coefs[7];
|
||||
mic_array_frame_time_domain * unsafe current;
|
||||
mic_array_decimator_config_t dc[2];
|
||||
|
||||
/* Get initial sample-rate and compute decimation factor */
|
||||
/* Get initial sample-rate to run this thread at and compute decimation factor */
|
||||
c_audio :> samplerate;
|
||||
unsigned decimationfactor = 96000/samplerate;
|
||||
|
||||
@@ -154,8 +161,11 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio)
|
||||
#pragma loop unroll
|
||||
for(int i = 0; i < NUM_PDM_MICS; i++)
|
||||
{
|
||||
c_audio <: output[i];
|
||||
c_audio <: output[micBufferRead][i];
|
||||
}
|
||||
micBufferRead++;
|
||||
if(micBufferRead == MIC_BUFFER_DEPTH)
|
||||
micBufferRead = 0;
|
||||
}
|
||||
|
||||
/* Get a new frame of mic data */
|
||||
@@ -171,8 +181,11 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio)
|
||||
#pragma loop unroll
|
||||
for(int i = 0; i < NUM_PDM_MICS; i++)
|
||||
{
|
||||
output[i] = current->data[i][0];
|
||||
output[micBufferWrite][i] = current->data[i][0];
|
||||
}
|
||||
micBufferWrite++;
|
||||
if(micBufferWrite == MIC_BUFFER_DEPTH)
|
||||
micBufferWrite = 0;
|
||||
}
|
||||
else
|
||||
unsafe{
|
||||
@@ -199,8 +212,11 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio)
|
||||
#pragma loop unroll
|
||||
for(int i = 0; i < NUM_PDM_MICS; i++)
|
||||
{
|
||||
output[i] = current->data[i][0];
|
||||
output[micBufferWrite][i] = current->data[i][0];
|
||||
}
|
||||
micBufferWrite++;
|
||||
if(micBufferWrite == MIC_BUFFER_DEPTH)
|
||||
micBufferWrite = 0;
|
||||
}
|
||||
break;
|
||||
} /* select */
|
||||
|
||||
@@ -1985,7 +1985,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2=
|
||||
INTERFACE_NUMBER_DFU, /* 2 bInterfaceNumber : Index of this interface. (field size 1 bytes) */
|
||||
0x00, /* 3 bAlternateSetting : Index of this setting. (field size 1 bytes) */
|
||||
0x00, /* 4 bNumEndpoints : 0 endpoints. (field size 1 bytes) */
|
||||
0xFE, /* 5 bInterfaceClass : DFU. (field size 1 bytes) */
|
||||
0xFE, /* 5 bInterfaceClass : DFU. (Application Specific) (field size 1 bytes) */
|
||||
0x01, /* 6 bInterfaceSubclass : (field size 1 bytes) */
|
||||
0x01, /* 7 bInterfaceProtocol : Unused. (field size 1 bytes) */
|
||||
offsetof(StringDescTable_t, dfuStr)/sizeof(char *), /* 8 iInterface */
|
||||
@@ -2751,7 +2751,7 @@ unsigned char cfgDesc_Audio1[] =
|
||||
(OUTPUT_INTERFACES_A1 + INPUT_INTERFACES_A1 + NUM_CONTROL_USB_INTERFACES + 1), /* 2 bInterfaceNumber : Index of this interface. (field size 1 bytes) */
|
||||
0x00, /* 3 bAlternateSetting : Index of this setting. (field size 1 bytes) */
|
||||
0x00, /* 4 bNumEndpoints : 0 endpoints. (field size 1 bytes) */
|
||||
0xFE, /* 5 bInterfaceClass : DFU. (field size 1 bytes) */
|
||||
0xFE, /* 5 bInterfaceClass : DFU. (Application Specific) (field size 1 bytes) */
|
||||
0x01, /* 6 bInterfaceSubclass : (field size 1 bytes) */
|
||||
0x01, /* 7 bInterfaceProtocol : Unused. (field size 1 bytes) */
|
||||
offsetof(StringDescTable_t, dfuStr)/sizeof(char *), /* 8 iInterface */
|
||||
@@ -2775,7 +2775,7 @@ unsigned char cfgDesc_Audio1[] =
|
||||
(OUTPUT_INTERFACES_A1 + INPUT_INTERFACES_A1 + 1), /* 2 bInterfaceNumber */
|
||||
0x00, /* 3 bAlternateSetting : Index of this setting. (field size 1 bytes) */
|
||||
0x00, /* 4 bNumEndpoints : 0 endpoints. (field size 1 bytes) */
|
||||
0xFF, /* 5 bInterfaceClass : DFU. (field size 1 bytes) */
|
||||
USB_CLASS_VENDOR_SPECIFIC, /* 5 bInterfaceClass : Vendor specific. (field size 1 bytes) */
|
||||
0xFF, /* 6 bInterfaceSubclass : (field size 1 bytes) */
|
||||
0xFF, /* 7 bInterfaceProtocol : Unused. (field size 1 bytes) */
|
||||
offsetof(StringDescTable_t, ctrlStr)/sizeof(char *), /* 8 iInterface */
|
||||
|
||||
Reference in New Issue
Block a user