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_MCP4922.hpp
00001 //------------------------------------------------------ 00002 // Class for single DAC in MCP4922 00003 // 00004 // 2015/04/19, Copyright (c) 2015 MIKAMI, Naoki 00005 //------------------------------------------------------ 00006 00007 #ifndef DAC_MCP4922_HPP 00008 #define DAC_MCP4922_HPP 00009 00010 #include "DAC_MCP4921.hpp" 00011 00012 namespace Mikami 00013 { 00014 class DAC_MCP4922 : public DAC_MCP4921 00015 { 00016 public: 00017 enum DAC { DAC_A = 0, DAC_B = 0x8000 }; 00018 00019 // Constructor 00020 DAC_MCP4922( 00021 DAC dac = DAC_A, // channel A 00022 PinName mosi = SPI_MOSI, // D11 00023 PinName sclk = SPI_SCK, // D13 00024 PinName cs = SPI_CS, // D10 00025 PinName ldac = SPI_MISO) // D12 00026 : DAC_MCP4921(mosi, sclk, cs, ldac), 00027 wcr_(dac | 0x3000) {} 00028 00029 protected: 00030 void SetCR(DAC dac) { wcr_ = dac | 0x3000; } 00031 00032 private: 00033 uint16_t wcr_; // write command register 00034 00035 // for inhibition of copy constructor 00036 DAC_MCP4922(const DAC_MCP4922&); 00037 // for inhibition of substitute operator 00038 DAC_MCP4922& operator=(const DAC_MCP4922&); 00039 00040 // for internal use 00041 virtual void WriteDac(uint16_t value) 00042 { 00043 while (IsBusy()) {} 00044 SlaveSelect(); 00045 WriteSpi(value | wcr_); 00046 } 00047 }; 00048 } 00049 #endif // DAC_MCP4922_HPP
Generated on Sun Jul 17 2022 05:45:25 by
1.7.2