Prototype program of AD and DA using classes in UIT_ADDA. This program does not use interrupt of ADC. This program also example of exchanging input channel for ST Nucleo F401RE. UIT_ADDA のクラスを使った AD および DA のためのプログラムで,入力の切り替えを行う場合の雛形.ADC の割り込みは使わないバージョン.ST Nucleo F401 用.

Dependencies:   UIT_ACM1602NI UIT_ADDA mbed

Revision:
0:473989635348
Child:
1:5c7f4c52d797
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 27 23:51:05 2014 +0000
@@ -0,0 +1,46 @@
+//--------------------------------------------------------------
+// 割り込みを使わずに AD DA を行う場合の雛形, 入力切替
+//      Analog line Input : A0 (channel 1)
+//      Analog mic. Input : A1 (channel 2)
+//      Analog Output: MCP4922 using SPI
+//      Switch : D2
+// 2014/10/23, Copyright (c) 2014 MIKAMI, Naoki
+//--------------------------------------------------------------
+
+#include "mbed.h"
+
+#include "ADC_Interrupt.hpp"    // for ADC using interrupt
+#include "DAC_MCP4922.hpp"      // for DAC MCP4922
+#include "ScfClockTim3.hpp"     // for clock supplied to SCF
+#include "ACM1602NI.hpp"        // for LCD display
+
+using namespace Mikami;
+
+const int FS_ = 10000;          // Sampling frequency: 10 kHz
+ADC_Base adc_(A0, FS_, A1);     // for AD
+DAC_MCP4922 myDac_;             // for DA
+
+DigitalIn sw_(D2, PullDown);
+
+int main()
+{
+    ScfClockTim3(420000);      // cutoff frequency: 4.2 kHz
+    int swBefore = 0;
+
+    while (true)
+    {
+        float xn = adc_.Read();     // Read from A0
+        //-----------------------------------------------
+        // Put signal processing program here
+        //-----------------------------------------------
+        myDac_.Write(xn);           // Write to DAC
+        
+        int swNow = sw_.read();
+        if (swNow != swBefore)
+        {
+            if (swNow == 0) adc_.Select1stChannel(); // line input
+            else            adc_.Select2ndChannel(); // mic. input
+            swBefore = swNow;
+        }
+    }
+}