Merge branch 'master' of github.com:xmos/lib_xua

This commit is contained in:
xross
2018-01-08 11:41:01 +00:00
2 changed files with 34 additions and 6 deletions

View File

@@ -1188,7 +1188,7 @@ enum USBEndpointNumber_In
ENDPOINT_NUMBER_IN_IAP_EA_NATIVE_TRANS, ENDPOINT_NUMBER_IN_IAP_EA_NATIVE_TRANS,
#endif #endif
#endif #endif
ENDPOINT_COUNT_IN /* End marker */ XUA_ENDPOINT_COUNT_IN /* End marker */
}; };
enum USBEndpointNumber_Out enum USBEndpointNumber_Out
@@ -1204,9 +1204,21 @@ enum USBEndpointNumber_Out
ENDPOINT_NUMBER_OUT_IAP_EA_NATIVE_TRANS, ENDPOINT_NUMBER_OUT_IAP_EA_NATIVE_TRANS,
#endif #endif
#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 #endif
/*** Internal defines below here. NOT FOR MODIFICATION ***/ /*** Internal defines below here. NOT FOR MODIFICATION ***/

View File

@@ -34,6 +34,10 @@ extern unsafe port p_mclk_in;
/* Delcared in main.xc */ /* Delcared in main.xc */
extern clock clk_pdm; 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}}; int mic_decimator_fir_data[8][THIRD_STAGE_COEFS_PER_STAGE * MAX_DECIMATION_FACTOR] = {{0}};
mic_array_frame_time_domain mic_audio[2]; 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 buffer;
unsigned samplerate; unsigned samplerate;
int output[NUM_PDM_MICS]; int output[MIC_BUFFER_DEPTH][NUM_PDM_MICS];
#ifdef MIC_PROCESSING_USE_INTERFACE #ifdef MIC_PROCESSING_USE_INTERFACE
i_mic_process.init(); i_mic_process.init();
@@ -64,6 +68,9 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio)
unsigned decimatorCount = 1; unsigned decimatorCount = 1;
#endif #endif
unsigned micBufferWrite = (MIC_BUFFER_DEPTH -1);
unsigned micBufferRead = 0;
mic_array_decimator_conf_common_t dcc; mic_array_decimator_conf_common_t dcc;
const int * unsafe fir_coefs[7]; const int * unsafe fir_coefs[7];
mic_array_frame_time_domain * unsafe current; mic_array_frame_time_domain * unsafe current;
@@ -154,8 +161,11 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio)
#pragma loop unroll #pragma loop unroll
for(int i = 0; i < NUM_PDM_MICS; i++) 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 */ /* 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 #pragma loop unroll
for(int i = 0; i < NUM_PDM_MICS; i++) 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 else
unsafe{ unsafe{
@@ -199,8 +212,11 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio)
#pragma loop unroll #pragma loop unroll
for(int i = 0; i < NUM_PDM_MICS; i++) 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; break;
} /* select */ } /* select */