Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: UIT2_MovingAverage UIT2_AllpassReverb UIT2_CombReverb UIT2_FIR_LPF_Symmetry ... more
Revision 19:900efc6796d4, committed 2015-01-30
- Comitter:
- MikamiUitOpen
- Date:
- Fri Jan 30 07:22:28 2015 +0000
- Parent:
- 18:0bfced9d5526
- Child:
- 20:c49f3b565a87
- Commit message:
- 20
Changed in this revision
--- a/DAC_MCP4922.cpp Thu Jan 29 07:55:04 2015 +0000
+++ b/DAC_MCP4922.cpp Fri Jan 30 07:22:28 2015 +0000
@@ -1,7 +1,7 @@
//------------------------------------------------------
// Class for single DAC in MCP4922
//
-// 2015/01/29, Copyright (c) 2015 MIKAMI, Naoki
+// 2015/01/30, Copyright (c) 2015 MIKAMI, Naoki
//------------------------------------------------------
#include "DAC_MCP4922.hpp"
@@ -34,6 +34,7 @@
// Set DAC to 0
WriteDac(0);
+ Wait();
while (IsBusy()) {}
}
@@ -62,3 +63,4 @@
}
}
+
--- a/DAC_MCP4922.hpp Thu Jan 29 07:55:04 2015 +0000
+++ b/DAC_MCP4922.hpp Fri Jan 30 07:22:28 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
//
-// 2015/01/29, Copyright (c) 2014 MIKAMI, Naoki
+// 2015/01/30, Copyright (c) 2014 MIKAMI, Naoki
//------------------------------------------------------
#ifndef DAC_MCP4922_HPP
@@ -63,12 +63,15 @@
// Check busy
bool IsBusy()
- { return (mySpi_->SR & SPI_FLAG_BSY) == SPI_FLAG_BSY; }
+ { return (mySpi_->SR & SPI_SR_BSY) == SPI_SR_BSY; }
+ // Little wait
+ void Wait()
+ { __NOP(); __NOP(); __NOP(); }
+
// Set clock for switched-capacitor filter
void ScfClockTim3(uint32_t clock, PinName pin = D9);
-
private:
uint16_t wcr_; // write command register
SPI spi_; // SPI object of mbed
@@ -86,9 +89,11 @@
// for internal use
void WriteDac(uint16_t value)
{
+ while (IsBusy()) {}
ss_->SlaveSelect();
mySpi_->DR = value | wcr_;
}
};
}
#endif // DAC_MCP4922_HPP
+
--- a/DAC_MCP4922Dual.hpp Thu Jan 29 07:55:04 2015 +0000
+++ b/DAC_MCP4922Dual.hpp Fri Jan 30 07:22:28 2015 +0000
@@ -1,13 +1,16 @@
//------------------------------------------------------
// Class for dual channel DAC in MCP4922
-// 2014/11/13, Copyright (c) 2014 MIKAMI, Naoki
+// This class does not support clock for SCF
+// 2015/01/30, Copyright (c) 2015 MIKAMI, Naoki
//------------------------------------------------------
#ifndef DAC_MCP4922_DUAL_HPP
#define DAC_MCP4922_DUAL_HPP
#include "DAC_MCP4922.hpp"
+
namespace Mikami
+
{
class DAC_MCP4922Dual
{
@@ -19,8 +22,8 @@
void Write(float valA, float valB)
{
myDac1_.Write(valA); // Write to DAC A
- while (myDac1_.IsBusy()) {}
myDac2_.Write(valB); // Write to DAC B
+ myDac2_.Wait();
while (myDac2_.IsBusy()) {}
myDac1_.Ldac();
}
@@ -28,8 +31,8 @@
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
+ myDac2_.Wait();
while (myDac2_.IsBusy()) {}
myDac1_.Ldac(); // dual load
}