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_Example2
DAC_MCP4922.hpp
- Committer:
- MikamiUitOpen
- Date:
- 2015-03-14
- Revision:
- 0:46d099dfd9d6
- Child:
- 1:e997f4e94491
File content as of revision 0:46d099dfd9d6:
//------------------------------------------------------
// Class for single DAC in MCP4922 -- Header
// Fast version
//
// 2015/02/03, Copyright (c) 2015 MIKAMI, Naoki
//------------------------------------------------------
#ifndef DAC_MCP4922_HPP
#define DAC_MCP4922_HPP
#include "DAC_MCP4921.hpp"
namespace Mikami
{
class DAC_MCP4922 : public DAC_MCP4921
{
public:
enum DAC { DAC_A = 0, DAC_B = 0x8000 };
// Constructor
DAC_MCP4922(
DAC dac = DAC_A, // channel A
PinName mosi = SPI_MOSI, // D11
PinName sclk = SPI_SCK, // D13
PinName cs = SPI_CS, // D10
PinName ldac = SPI_MISO) // D12
: DAC_MCP4921(mosi, sclk, cs, ldac),
wcr_(dac | 0x3000) {}
protected:
void SetCR(DAC dac) { wcr_ = dac | 0x3000; }
private:
uint16_t wcr_; // write command register
// for inhibition of copy constructor
DAC_MCP4922(const DAC_MCP4922&);
// for inhibition of substitute operator
DAC_MCP4922& operator=(const DAC_MCP4922&);
// for internal use
virtual void WriteDac(uint16_t value)
{
while (IsBusy()) {}
SlaveSelect();
WriteSpi(value | wcr_);
}
};
}
#endif // DAC_MCP4922_HPP