不韋 呂 / 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:
Thu Jan 29 07:55:04 2015 +0000
Parent:
17:fd4f92ad4323
Child:
19:900efc6796d4
Commit message:
19

Changed in this revision

DAC_MCP4922.cpp Show annotated file Show diff for this revision Revisions of this file
DAC_MCP4922.hpp Show annotated file Show diff for this revision Revisions of this file
--- a/DAC_MCP4922.cpp	Thu Jan 29 05:52:57 2015 +0000
+++ b/DAC_MCP4922.cpp	Thu Jan 29 07:55:04 2015 +0000
@@ -37,32 +37,6 @@
         while (IsBusy()) {}
     }
 
-    void DAC_MCP4922::Write(float value)
-    {
-        if (value < -1.0f) value = -1.0f;
-        if (value >  1.0f) value =  1.0f;
-
-        WriteDac((uint16_t)((value + 1.0f)*2047));
-    }
-
-    void DAC_MCP4922::Write(uint16_t value)
-    {
-        WriteDac((value > 4095) ? 4095 : value);
-    }
-        
-    void DAC_MCP4922::Ldac()
-    {
-        ld_.write(0);
-        ld_.write(0);   // ensure width of "L" pulse
-        ld_.write(1);
-    }
-
-    void DAC_MCP4922::WriteDac(uint16_t value)
-    {
-        ss_->SlaveSelect();
-        mySpi_->DR = value | wcr_;
-    }
-
     void DAC_MCP4922::ScfClockTim3(uint32_t clock, PinName pin)
     {
         if ( (pin != PA_6) && (pin != PB_4) && (pin != PB_5) &&
@@ -87,3 +61,4 @@
             TIM3->CCR4 = (TIM3->ARR + 1)/2;    
     }
 }
+
--- a/DAC_MCP4922.hpp	Thu Jan 29 05:52:57 2015 +0000
+++ b/DAC_MCP4922.hpp	Thu Jan 29 07:55:04 2015 +0000
@@ -16,7 +16,7 @@
 // PA_6(D12), PB_4(D5), PC_6, PB_5(D4), PC_7(D9),
 // PC_8, or PC_9
 //
-// 2014/12/21, Copyright (c) 2014 MIKAMI, Naoki
+// 2015/01/29, Copyright (c) 2014 MIKAMI, Naoki
 //------------------------------------------------------
 
 #ifndef DAC_MCP4922_HPP
@@ -41,16 +41,29 @@
             PinName ldac = SPI_MISO);   // D12
 
         // -1.0f <= value <= 1.0f
-        void Write(float value);
+        void Write(float value)
+        {
+            if (value < -1.0f) value = -1.0f;
+            if (value >  1.0f) value =  1.0f;
+
+            WriteDac((uint16_t)((value + 1.0f)*2047));
+        }
+
         // 0 <= value <= 4095
-        void Write(uint16_t value);
+        void Write(uint16_t value)
+        {   WriteDac((value > 4095) ? 4095 : value); }
         
         // generate LDAC negative-going pulse
-        void Ldac();
+        void Ldac()
+        {
+            ld_.write(0);
+            ld_.write(0);   // ensure width of "L" pulse
+            ld_.write(1);
+        }
 
         // Check busy
         bool IsBusy()
-        { return (mySpi_->SR & SPI_FLAG_BSY) == SPI_FLAG_BSY; }
+        {   return (mySpi_->SR & SPI_FLAG_BSY) == SPI_FLAG_BSY; }
         
         // Set clock for switched-capacitor filter
         void ScfClockTim3(uint32_t clock, PinName pin = D9);
@@ -71,7 +84,11 @@
         DAC_MCP4922& operator=(const DAC_MCP4922&);     
         
         // for internal use
-        void WriteDac(uint16_t value);
+        void WriteDac(uint16_t value)
+        {
+            ss_->SlaveSelect();
+            mySpi_->DR = value | wcr_;
+        }
     };
 }
 #endif  // DAC_MCP4922_HPP