不韋 呂 / UIT_ADDA

Dependents:   UIT2_MovingAverage UIT2_AllpassReverb UIT2_CombReverb UIT2_FIR_LPF_Symmetry ... more

Files at this revision

API Documentation at this revision

Comitter:
MikamiUitOpen
Date:
Wed Oct 22 08:59:28 2014 +0000
Parent:
0:6e0ed5adfe47
Child:
2:2a3b4ed3eb58
Commit message:
2

Changed in this revision

DAC_MCP4922Dual.hpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DAC_MCP4922Dual.hpp	Wed Oct 22 08:59:28 2014 +0000
@@ -0,0 +1,44 @@
+//------------------------------------------------------
+// Class for dual channel DAC in MCP4922
+// 2014/10/22, Copyright (c) 2014 MIKAMI, Naoki
+//------------------------------------------------------
+
+#ifndef DAC_MCP4922_DUAL_HPP
+#define DAC_MCP4922_DUAL_HPP
+
+//#include "mbed.h"
+#include "DAC_MCP4922.hpp"
+namespace Mikami
+{
+    class DAC_MCP4922Dual
+    {
+    public:
+        DAC_MCP4922Dual()
+            : myDac1_(DAC_MCP4922::DAC_A),
+              myDac2_(DAC_MCP4922::DAC_B)
+        { myDac1_.LdacH(); }
+        
+        void Write(float valA, float valB)
+        {
+            myDac1_.Write(valA);    // Write to DAC A
+            while (myDac1_.IsBusy()) {}
+            myDac2_.Write(valB);    // Write to DAC B
+            while (myDac2_.IsBusy()) {}
+            myDac1_.Ldac();
+        }
+
+        void Write(uint16_t valA, uint16_t valB)
+        {
+            myDac1_.Write(valA);    // Write to DAC A
+            while (myDac1_.IsBusy()) {}
+            myDac2_.Write(valB);    // Write to DAC B
+            while (myDac2_.IsBusy()) {}
+            myDac1_.Ldac();         // dual load
+        }
+
+    private:
+        DAC_MCP4922 myDac1_;
+        DAC_MCP4922 myDac2_;
+    };
+}
+#endif  // DAC_MCP4922_DUAL_HPP