Library to control the 12 Bits Analog Digital Converter MCP4921
Mcp4921.h
- Committer:
- adelino
- Date:
- 2013-11-15
- Revision:
- 0:38e03f9fa18a
- Child:
- 1:1352606a60c6
File content as of revision 0:38e03f9fa18a:
#ifndef MCP4921_H #define MCP4921_H #include "mbed.h" /** * The MCP4921 is a single 12 bit DAC. The maximum voltage output is limited by the input voltage at V_DD which can go up to about 5.5V. * Datasheet: http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en020398 * */ class Mcp4921 { public: /** Initializes the MCP 4921 DAC with the frequency * * for exemple: * Mbed Mcp4921 * p11: Mosi <--->p4:Sdi * p12: Miso No Connected * p13: Sck <--->p3:Sck * p14 <--->p2:Cs * Vout <--->p1:Vdd * Vout <--->p6: Vref * Gnd <--->p7:Gnd * Gnd <--->p5:Ldac */ Mcp4921(PinName _mosi,PinName _sck,PinName _cs, int _frequency); /** return the frequency use by the Mcp4921 */ int getFrequency(void); /** Writes a value between 0-4095 to the currently selected DAC output * @param dataIntNum a value from 0-4095 to write to the DAC register */ void write(int dataIntNum); /** Writes a float value between 0.0-1.0 to the currently selected DAC output * @param dataFloat a value from 0.0-1.0 to write to the DAC register */ void write(float dataFloat); /** Writes a value in mV to the DAC outputs. * The output will only be accurate if Vref is set to the appropriate voltage reference scaling factor. * @param millivolt The desired voltage output in millivolts */ void write_mV(int millivolt); /**An operator for shorthand write(int) */ void operator=(int dataIntNum); /**An operator for shorthand write(float) */ void operator=(float dataFloat); protected: // void setup(void); SPI mySPI; DigitalOut myCs; int myFrequency; }; #endif