From 6eed7dfe6d6e0661343afca0ebd2311875380489 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Fri, 29 Aug 2014 12:44:56 +0100 Subject: [PATCH] Level meter LED code fixed up --- module_usb_audio/clocking/clockgen.xc | 17 ++++++++++++----- module_usb_audio/mixer/mixer.xc | 8 ++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/module_usb_audio/clocking/clockgen.xc b/module_usb_audio/clocking/clockgen.xc index d2b430eb..f578a032 100644 --- a/module_usb_audio/clocking/clockgen.xc +++ b/module_usb_audio/clocking/clockgen.xc @@ -194,7 +194,7 @@ static inline int badParity(unsigned x) void VendorLedRefresh(unsigned levelData[]); unsigned g_inputLevelData[NUM_USB_CHAN_IN]; extern int samples_to_host_inputs[NUM_USB_CHAN_IN]; -extern int samples_to_host_inputs_buff[NUM_USB_CHAN_IN]; /* Audio transmitted to host i.e. dev inputs */ +extern int samples_to_host_inputs_buff[NUM_USB_CHAN_IN]; #endif int VendorAudCoreReqs(unsigned cmd, chanend c); @@ -326,17 +326,24 @@ void clockGen (streaming chanend c_spdif_rx, chanend ?c_adat_rx, out port p, cha for(int i = 0; i< NUM_USB_CHAN_IN; i++) { int tmp; + + /* Read level data */ //g_inputLevelData[i] = samples_to_host_inputs[i]; - asm("ldw %0, %1[%2]":"=r"(tmp):"r"(samples_to_host_inputs),"r"(i)); + asm volatile("ldw %0, %1[%2]":"=r"(tmp):"r"((const int *)samples_to_host_inputs),"r"(i)); g_inputLevelData[i] = tmp; + /* Reset level data */ //samples_to_host_inputs[i] = 0; - asm("stw %0, %1[%2]"::"r"(0),"r"(samples_to_host_inputs),"r"(i)); + asm volatile("stw %0, %1[%2]"::"r"(0),"r"((const int *)samples_to_host_inputs),"r"(i)); /* Guard against host polling slower than timer and missing peaks */ - if(g_inputLevelData[i] > samples_to_host_inputs_buff[i]) + asm volatile("ldw %0, %1[%2]":"=r"(tmp):"r"((const int *)samples_to_host_inputs_buff),"r"(i)); + + if (g_inputLevelData[i] > tmp) + //if(g_inputLevelData[i] > samples_to_host_inputs_buff[i]) { - samples_to_host_inputs_buff[i] = g_inputLevelData[i]; + //samples_to_host_inputs_buff[i] = g_inputLevelData[i]; + asm volatile("stw %0, %1[%2]"::"r"(tmp),"r"((const int *)samples_to_host_inputs),"r"(i)); } } diff --git a/module_usb_audio/mixer/mixer.xc b/module_usb_audio/mixer/mixer.xc index c651d725..6118b7b0 100644 --- a/module_usb_audio/mixer/mixer.xc +++ b/module_usb_audio/mixer/mixer.xc @@ -66,6 +66,7 @@ xc_ptr samples_to_host_inputs_ptr; #ifdef LEVEL_METER_LEDS int samples_to_host_inputs_buff[NUM_USB_CHAN_IN]; /* Audio transmitted to host i.e. dev inputs */ +xc_ptr samples_to_host_inputs_buff_ptr; #endif static int samples_from_host_streams[NUM_USB_CHAN_OUT]; /* Peak samples for audio stream from host */ @@ -414,8 +415,8 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2) //val = samples_to_host_inputs_buff[index]; //samples_to_host_inputs_buff[index] = 0; /* Access funcs used to avoid disjointness check */ - read_via_xc_ptr_indexed(val, samples_to_host_inputs_buff, index); - write_via_xc_ptr_indexed(samples_to_host_inputs_buff, index, 0); + read_via_xc_ptr_indexed(val, samples_to_host_inputs_buff_ptr, index); + write_via_xc_ptr_indexed(samples_to_host_inputs_buff_ptr, index, 0); #else /* We dont have a level LEDs process, so reset ourselves */ //val = samples_to_host_inputs[index]; @@ -711,6 +712,9 @@ void mixer(chanend c_mix_in, chanend c_mix_out, chanend c_mix_ctl) samples_to_device_map = array_to_xc_ptr((samples_to_device_map_array,unsigned[])); samples_to_host_inputs_ptr = array_to_xc_ptr((samples_to_host_inputs, unsigned[])); +#ifdef LEVEL_METER_LEDS + samples_to_host_inputs_buff_ptr = array_to_xc_ptr((samples_to_host_inputs, unsigned[])); +#endif samples_mixer_outputs_ptr = array_to_xc_ptr((samples_mixer_outputs, unsigned[])); #if MAX_MIX_COUNT >0