General usable MCP4728 quad DAC implementation only limited function has to be used together with the DevInterface lib

Dependents:   mbedSerialInterface_talkback2 MCP4728test mbedSerialInterface_sequencer

Files at this revision

API Documentation at this revision

Comitter:
wbeaumont
Date:
Wed Jul 06 14:55:28 2016 +0000
Parent:
4:f45f4ff5a51a
Commit message:
added methods to set output gain, ref source and power mode

Changed in this revision

mcp4728.h Show annotated file Show diff for this revision Revisions of this file
diff -r f45f4ff5a51a -r 164362cf5836 mcp4728.h
--- a/mcp4728.h	Tue Jan 12 16:04:02 2016 +0000
+++ b/mcp4728.h	Wed Jul 06 14:55:28 2016 +0000
@@ -9,7 +9,7 @@
 #include "I2CInterface.h" 
 #include "DACInterface.h" 
 
-#define VERSION_MCP4728_HDR "0.45"
+#define VERSION_MCP4728_HDR "0.50"
 
 /** MCP4728 class.
  *  Used for interfacing with a mcp4728 12-Bit QUAD  Digital-to-Analog Converter.
@@ -19,9 +19,11 @@
  *  An implementation of the I2Cinterface class for the MBED can be found at 
  * 
  *  ( DACInterface inherits getVersion  )
- * ee-prom set / read not tested / implemented. 
- * 
- * (C) Wim Beaumont Universiteit Antwerpen 2015        
+ *  ee-prom set / read not tested / implemented. 
+ *
+ *  V 0.50 added methods to set the modes ( gain, ch power mode , reference 
+ *
+ * (C) Wim Beaumont Universiteit Antwerpen 2015  2016
  *  
  */
 class MCP4728 : public DACInterface {
@@ -150,7 +152,87 @@
     
     virtual int setVoltage (float voltage, int ch=0);
     
+    /**  prepare power mode to 1k for all channels , mode becomes active with the next set voltage for the channel
+    */
+    void setPowerMode1k(){ for ( int ch=0;ch<4;ch++) ChCfg[ch].pwr=PowerDown1k;}
     
+    /**  prepare power mode to 1k for a channel , mode becomes active with the next set voltage for the channel
+        @param the channel the power mode has to be set for. 
+    */
+    void  setPowerMode1k(int ch ){  ChCfg[ch].pwr=PowerDown1k;}
+    
+    /**  prepare power mode to 100k for all channels , mode becomes active with the next set voltage for the channel
+    */
+    void  setPowerMode100k(){ for ( int ch=0;ch<4;ch++) ChCfg[ch].pwr=PowerDown100k;}
+    
+    /**  prepare power mode to 100k for a channel , mode becomes active with the next set voltage for the channel
+        @param the channel the power mode has to be set for. 
+    */
+    void  setPowerMode100k(int ch ){  ChCfg[ch].pwr=PowerDown100k;}
+
+    /**  prepare power mode to 500k for all channels , mode becomes active with the next set voltage for the channel
+    */
+    void  setPowerMode500k(){ for ( int ch=0;ch<4;ch++) ChCfg[ch].pwr=PowerDown500k;}
+    
+    /**  prepare power mode to 500k for a channel , mode becomes active with the next set voltage for the channel
+        @param the channel the power mode has to be set for. 
+    */
+    void  setPowerMode500k(int ch ){  ChCfg[ch].pwr=PowerDown500k;}
+
+    /**  prepare power mode to normal (active) for all channels , mode becomes active with the next set voltage for the channel
+    */
+    void  setPowerModeNormal(){ for ( int ch=0;ch<4;ch++) ChCfg[ch].pwr=Normal;}
+    
+    /**  prepare power mode to normal (active)  for a channel , mode becomes active with the next set voltage for the channel
+        @param the channel the power mode has to be set for. 
+    */
+    void setPowerModeNormal(int ch ){  ChCfg[ch].pwr=Normal;}
+
+    /**  prepare to intern reference for a channel , mode becomes active with the next set voltage for the channel
+        @param the channel the power mode has to be set for. 
+    */
+    void setRefIntern ( ) { for ( int ch=0;ch<4;ch++)  ChCfg[ch].vref=InternRef;}
+    
+    /**  prepare to intern reference  for a channel , mode becomes active with the next set voltage for the channel
+        @param the channel the reference  has to be set for. 
+    */
+    void setRefIntern (int ch ) {   ChCfg[ch].vref=InternRef;}
+
+    /**  prepare to extern reference for a channel , mode becomes active with the next set voltage for the channel
+        @param the channel the power mode has to be set for. 
+    */
+    void setRefExtern ( ) { for ( int ch=0;ch<4;ch++)  ChCfg[ch].vref=ExternRef;}
+
+    /**  prepare to intern reference  for a channel. 
+        mode becomes active with the next set voltage for the channel!!
+        @param the channel the reference  has to be set for. 
+    */
+    void setRefExtern (int ch ) {  ChCfg[ch].vref=ExternRef;}
+    
+    /**  prepare to set the output gain to 2 for all channel 
+        mode becomes active with the next set voltage for the channel!!
+        @param the channel the power mode has to be set for. 
+    */
+    void setGainX2 () {for ( int ch=0;ch<4;ch++)   ChCfg[ch].gain=GainX2;}
+    
+    /**  prepare to set the output gain to 2  for a channel 
+        mode becomes active with the next set voltage for the channel!!
+        @param the channel the reference  has to be set for. 
+    */
+    void  setGainX2 (int ch) {  ChCfg[ch].gain=GainX2;}
+    
+    /**  prepare to set the output gain to 1 for all channel 
+        mode becomes active with the next set voltage for the channel!!
+        @param the channel the power mode has to be set for. 
+    */
+    void setGainX1 () {for ( int ch=0;ch<4;ch++)   ChCfg[ch].gain=GainX1;}
+    
+    /**  prepare to set the output gain to 1  for a channel 
+        mode becomes active with the next set voltage for the channel!!
+        @param the channel the reference  has to be set for. 
+    */
+    void setGainX1 (int ch) {  ChCfg[ch].gain=GainX1;}
+  
     
     protected:
     /** pointer to the I2C interface driver. */