Updated pdm code to use latest lib_array_mic code

This commit is contained in:
Ross Owen
2015-10-13 17:32:12 +01:00
parent a587c48f76
commit 2580dcc721

View File

@@ -9,6 +9,8 @@
#include <xclib.h> #include <xclib.h>
#include <stdint.h> #include <stdint.h>
#include "devicedefines.h" #include "devicedefines.h"
#include "fir_decimator.h"
#include "mic_array.h" #include "mic_array.h"
#include "mic_array_board_support.h" #include "mic_array_board_support.h"
@@ -16,7 +18,7 @@
#if 1 #if 1
in port p_pdm_clk = PORT_PDM_CLK; in port p_pdm_clk = PORT_PDM_CLK;
in port p_pdm_mics = PORT_PDM_DATA; in buffered port:32 p_pdm_mics = PORT_PDM_DATA;
in port p_mclk = PORT_PDM_MCLK; in port p_mclk = PORT_PDM_MCLK;
clock mclk = on tile[PDM_TILE]: XS1_CLKBLK_1; clock mclk = on tile[PDM_TILE]: XS1_CLKBLK_1;
@@ -96,16 +98,13 @@ void lores_DAS_fixed(streaming chanend c_ds_output_0, streaming chanend c_ds_out
#define MAX_DELAY 128 #define MAX_DELAY 128
unsigned gain = 128; unsigned gain = 4096;
#ifdef FORM_BEAM #ifdef FORM_BEAM
unsigned delay[7] = {0, 0, 0, 0, 0, 0, 0}; unsigned delay[7] = {0, 0, 0, 0, 0, 0, 0};
int delay_buffer[MAX_DELAY][7]; int delay_buffer[MAX_DELAY][7];
memset(delay_buffer, sizeof(int)*8*8, 0); memset(delay_buffer, sizeof(int)*8*8, 0);
unsigned delay_head = 0; unsigned delay_head = 0;
unsigned dir = 0; unsigned dir = 0;
#endif
#ifdef FORM_BEAM
set_dir(lb, dir, delay); set_dir(lb, dir, delay);
#else #else
int summed = 0; int summed = 0;
@@ -117,9 +116,8 @@ void lores_DAS_fixed(streaming chanend c_ds_output_0, streaming chanend c_ds_out
lb.set_led_brightness(12, 255); lb.set_led_brightness(12, 255);
#endif #endif
unsafe
{
unsafe{
c_ds_output_0 <: (frame_audio * unsafe)audio[0].data[0]; c_ds_output_0 <: (frame_audio * unsafe)audio[0].data[0];
c_ds_output_1 <: (frame_audio * unsafe)audio[0].data[4]; c_ds_output_1 <: (frame_audio * unsafe)audio[0].data[4];
@@ -302,6 +300,11 @@ void lores_DAS_fixed(streaming chanend c_ds_output_0, streaming chanend c_ds_out
} }
} }
//TODO make these not global
int data_0[8*COEFS_PER_PHASE] = {0};
int data_1[8*COEFS_PER_PHASE] = {0};
void pcm_pdm_mic(chanend c_pcm_out) void pcm_pdm_mic(chanend c_pcm_out)
{ {
@@ -318,16 +321,18 @@ void pcm_pdm_mic(chanend c_pcm_out)
start_clock(mclk); start_clock(mclk);
start_clock(pdmclk); start_clock(pdmclk);
decimator_config dc = {0, 1, 0, 0};
unsafe unsafe
{ {
const int * unsafe p[1] = {fir_1_coefs[0]};
decimator_config dc0 = {0, 1, 0, 0, 1, p, data_0, 0, {0,0, 0, 0}};
decimator_config dc1 = {0, 1, 0, 0, 1, p, data_1, 0, {0,0, 0, 0}};
par par
{ {
button_and_led_server(lb, leds, p_buttons); button_and_led_server(lb, leds, p_buttons);
pdm_rx(p_pdm_mics, c_4x_pdm_mic_0, c_4x_pdm_mic_1); pdm_rx(p_pdm_mics, c_4x_pdm_mic_0, c_4x_pdm_mic_1);
decimate_to_pcm_4ch_48KHz(c_4x_pdm_mic_0, c_ds_output_0, dc); decimate_to_pcm_4ch(c_4x_pdm_mic_0, c_ds_output_0, dc0);
decimate_to_pcm_4ch_48KHz(c_4x_pdm_mic_1, c_ds_output_1, dc); decimate_to_pcm_4ch(c_4x_pdm_mic_1, c_ds_output_1, dc1);
lores_DAS_fixed(c_ds_output_0, c_ds_output_1, lb, c_pcm_out); lores_DAS_fixed(c_ds_output_0, c_ds_output_1, lb, c_pcm_out);
} }