TeamElectronics / MCP4822
Embed: (wiki syntax)

« Back to documentation index

MCP4822 Class Reference

MCP4822 Class Reference

Interface to the 12-Bit DAC with internal Vref and SPI interface. More...

#include <MCP4822.h>

Public Member Functions

 MCP4822 (SPI &spi, PinName nLDAC, PinName nCs)
 Create an instance of the MCP4822 connected via specfied SPI instance.
 MCP4822 (PinName nLDAC, PinName mosi, PinName miso, PinName sck, PinName nCs)
 Create an instance of the MCP4261 connected with SPI pins.
void a (bool gain, int data)
 Write to output A.
void b (bool gain, int data)
 Write to output B.
void ldac (bool act)
 Output Synchronization.
void shdn (bool output, bool act)
 Output Shutdown.

Detailed Description

Interface to the 12-Bit DAC with internal Vref and SPI interface.

Using the driver:

  • remenber to setup SPI in main routine or use pins instance.

Defaults in this driver on start up:

  • Datasheet start up

Definition at line 51 of file MCP4822.h.


Constructor & Destructor Documentation

MCP4822 ( SPI &  spi,
PinName  nLDAC,
PinName  nCs 
)

Create an instance of the MCP4822 connected via specfied SPI instance.

Parameters:
spiThe mbed SPI instance (make in main routine)
nLDACThe Latch DAC Synchronization pin
nCsThe SPI chip select pin.

Definition at line 30 of file MCP4822.cpp.

MCP4822 ( PinName  nLDAC,
PinName  mosi,
PinName  miso,
PinName  sck,
PinName  nCs 
)

Create an instance of the MCP4261 connected with SPI pins.

Parameters:
nLDACThe Latch DAC Synchronization pin
mosiThe SPI Master Output, Slave Input pin.
misoThe SPI Master Input, Slave Output pin.
sckThe SPI Serial Clock pin.
nCsThe SPI chip select pin.

Definition at line 36 of file MCP4822.cpp.


Member Function Documentation

void a ( bool  gain,
int  data 
)

Write to output A.

Parameters:
gainthe gain is 2x = '0' and 1x = '1'.
dataThe 12 bits value to write to the output.

Definition at line 41 of file MCP4822.cpp.

void b ( bool  gain,
int  data 
)

Write to output B.

Parameters:
gainthe gain is 2x = '0' and 1x = '1'.
dataThe 12 bits value to write to the output.

Definition at line 46 of file MCP4822.cpp.

void ldac ( bool  act )

Output Synchronization.

Parameters:
actThe LDAC is Active = true and Inactive = false.

Definition at line 51 of file MCP4822.cpp.

void shdn ( bool  output,
bool  act 
)

Output Shutdown.

Parameters:
outputA = '0' and B = '1'.
actThe SHDN is Active = true and Inactive = false.

Definition at line 56 of file MCP4822.cpp.