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: UITDSP_ADDA_Example UIT2_MovingAv_Intr UIT2_VariableFIR UIT2_VowelSynthesizer ... more
DAC_MCP4922Dual.hpp
00001 //------------------------------------------------------ 00002 // Class for dual channel DAC in MCP4922 00003 // 2015/04/01, Copyright (c) 2015 MIKAMI, Naoki 00004 //------------------------------------------------------ 00005 00006 #ifndef DAC_MCP4922_DUAL_HPP 00007 #define DAC_MCP4922_DUAL_HPP 00008 00009 #include "DAC_MCP4922.hpp" 00010 00011 namespace Mikami 00012 00013 { 00014 class DAC_MCP4922Dual : public DAC_MCP4922 00015 { 00016 public: 00017 DAC_MCP4922Dual( 00018 PinName mosi = SPI_MOSI, // D11 00019 PinName sclk = SPI_SCK, // D13 00020 PinName cs = SPI_CS, // D10 00021 PinName ldac = SPI_MISO) // D12 00022 : DAC_MCP4922(DAC_A, mosi, sclk, cs, ldac) {} 00023 00024 00025 void Write(float valA, float valB) 00026 { 00027 SetCR(DAC_A); 00028 DAC_MCP4922::Write(valA); // Write to DAC A 00029 SetCR(DAC_B); 00030 DAC_MCP4922::Write(valB); // Write to DAC B 00031 Wait(); 00032 while (IsBusy()) {} 00033 Ldac(); 00034 } 00035 00036 void Write(uint16_t valA, uint16_t valB) 00037 { 00038 SetCR(DAC_A); 00039 DAC_MCP4922::Write(valA); // Write to DAC A 00040 SetCR(DAC_B); 00041 DAC_MCP4922::Write(valB); // Write to DAC B 00042 Wait(); 00043 while (IsBusy()) {} 00044 Ldac(); 00045 } 00046 00047 private: 00048 void Wait() // Little wait 00049 { __NOP(); __NOP(); __NOP(); } 00050 }; 00051 } 00052 #endif // DAC_MCP4922_DUAL_HPP
Generated on Sun Jul 17 2022 05:45:25 by
1.7.2