Frequency shifter using analytic signal for ST Nucleo F401RE.

Dependencies:   UITDSP_ADDA mbed

Revision:
4:04bb0cfea187
Parent:
2:ba46d7cbb09e
--- a/main.cpp	Sat Nov 15 06:14:15 2014 +0000
+++ b/main.cpp	Sat Jul 25 07:32:50 2015 +0000
@@ -1,13 +1,14 @@
 //--------------------------------------------------------------
 // Frequency shifter using analytic signal
 //      Frequency is shifted toward 100 Hz higher
-// 2014/11/12, Copyright (c) 2014 MIKAMI, Naoki
+//      sw number = even : No frequency shift
+//      sw number = odd  : Frequency shift
+
+// 2015/07/25, Copyright (c) 2015 MIKAMI, Naoki
 //--------------------------------------------------------------
 
-#include "mbed.h"
-
-#include "ADC_Base.hpp"             // for ADC not using interrupt
-#include "DAC_MCP4922.hpp"          // for DAC MCP4922
+#include "ADC_BuiltIn.hpp"      // for ADC not using interrupt
+#include "DAC_MCP4921.hpp"      // for DAC MCP4921, MCP4922
 
 #include "HilbertTransform.hpp"     // Hilbert transform filter
 #include "coefsHilbert114.hpp"      // Coeffisients of Hilbert transform filter
@@ -18,8 +19,9 @@
 using namespace Mikami;
 
 const int FS_ = 12000;  // 12 kHz
-ADC_Base adc_(A0, FS_);
-DAC_MCP4922 myDac_;
+ADC_BuiltIn adc_(A0, FS_);
+DAC_MCP4921 myDac_;
+DigitalIn sw_(D2, PullDown);
 
 Hilbert<ORDER_> ht_(hm_);   // Hilbert transform filter
 Biquad DcCut_(c1_);         // DC cut filter
@@ -41,6 +43,7 @@
         cosSin_.Generate(cos, sin);     // cos and sin
         float yn = yIn*cos - yQn*sin;
         
+        if (sw_.read() == 0) yn = xn;   // no frequency shift
         //-----------------------------------------------
         myDac_.Write(yn);               // Write to DAC  
     }