ReSpeaker DSP V02

Dependencies:   mbed MbedJSONValue

Revision:
12:9d30df1529be
Parent:
11:07981b0d28d3
Child:
13:c0a13a99905e
--- a/main.cpp	Mon Aug 27 11:22:46 2018 +0000
+++ b/main.cpp	Tue Aug 28 08:20:15 2018 +0000
@@ -53,13 +53,16 @@
 ///////////////
 // #defines  //
 ///////////////
+
+//#define TOGGLE_IO_MODE  // loop frequency indicator
+
 // UART debug modes:
 //#define DEBUG_MOD1  // json packet recognise
-#define DEBUG_MOD2   // json parse
-#define DEBUG_MOD3   // dsp handler
-#define DEBUG_MOD10  // responsivity msges to gui
-#define DEBUG_MOD11  // loop frequency indicator
-// Sine generator
+//#define DEBUG_MOD2   // json parse
+//#define DEBUG_MOD3   // dsp handler
+//#define DEBUG_MOD10  // responsivity msges to gui
+
+// PI variable
 #define PI_DOUBLE (3.141592653589793238462)
 #define PI_FLOAT  (3.14159f)
 
@@ -70,6 +73,7 @@
 
 // Frequency counter
 #define TICKS2TOGGLE 1000000
+
 /////////////
 // Objects //
 /////////////
@@ -105,6 +109,8 @@
 uint32_t toggleCounter = 0;
 // toogle pin state
 bool toggleCounterState = 0;
+// toogle pin state
+bool toggelState=0;
 
 // json buffer
 char json[MSG_BUFFER_SIZE];
@@ -126,12 +132,6 @@
 // Dac Register for direct method of setting DAC value`s
 __IO uint32_t Dac_Reg = 0;
 
-// analog input
-//uint16_t adc_in=0;
-
-// toogle pin state
-bool toggelState=0;
-
 // create function pointer
 typedef void(*functionPtr)(void);
 functionPtr FilterFunction;
@@ -144,37 +144,6 @@
 // 3 -  hpf_trig    - High Pass filter + Trigger mode
 // 4 -  gains_trig  - highpass filter + trigger mode + Gains vector
 
-
-// Trigger mode variables
-float signalGain = 1.0; // Signal Gain
-float trigTresh = 0.5; // threshold for trigger mode
-uint32_t trigDelaySet = 5000; // counter for pulse pass
-uint32_t trigDelay = trigDelaySet; // counter for pulse pass
-uint32_t trigPause = 10; // pause after trigger in microseconds
-
-// Filter variables
-//SOS Matrix limited to order 10
-int   FilterSections=1;
-float SOSMat[5][6]= { // Predefined SOS Matrix (second order 5Khz filter
-    1, -2, 1,  1, -1.961,  0.9624,
-    0,  0, 0,  0,  0,  0,
-    0,  0, 0,  0,  0,  0,
-    0,  0, 0,  0,  0,  0,
-    0,  0, 0,  0,  0,  0
-};
-float Gscale = 0.9810f;
-float filterCurrInput[6] = {0};
-float filterLastInput[6] = {0};
-float filterLLastInput[6] = {0};
-
-// Buffer mode variables
-uint32_t bufferSizeSet = 5000;
-uint32_t bufferSize = bufferSizeSet;
-uint32_t preBufferSizeSet = 1000;
-uint32_t bufferCountDown = bufferSizeSet - preBufferSizeSet;
-float bufferADC[5000] = {0};
-
-
 ///////////////
 // Functions //
 ///////////////
@@ -255,7 +224,7 @@
         //highpass_filter();
         // more elegant but much slower option:
         //FilterFunction();
-#ifdef DEBUG_MOD11
+#ifdef TOGGLE_IO_MODE
         // toggle pin, Loop frequency indicator
         toggelState=!toggelState;
         mytoggle.write(toggelState);