Library to control the 12 Bits Analog Digital Converter MCP4921
Diff: Mcp4921.h
- Revision:
- 1:1352606a60c6
- Parent:
- 0:38e03f9fa18a
--- a/Mcp4921.h Fri Nov 15 14:53:04 2013 +0000 +++ b/Mcp4921.h Sun Nov 17 13:34:18 2013 +0000 @@ -9,38 +9,57 @@ * Datasheet: http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en020398 * +*Exemple: +@code +//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 + +#include "mbed.h" +#include "Mcp4921.h" + +Mcp4921 cna(p11,p13,p14,500000); +int main() +{ + static int mv; + while(1) { + cna.write_mV(mv); + + mv+=500; + if(mv>4000) + mv=0; + } +} + +@endcode */ 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 + /**Initializes the MCP 4921 DAC with the frequency + */ Mcp4921(PinName _mosi,PinName _sck,PinName _cs, int _frequency); - /** return the frequency use by the Mcp4921 + /** @returns 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 + * @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 + * @param dataFloat A value from 0.0-1.0 to write to the DAC register */ void write(float dataFloat);