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

Dependents:   mbedSerialInterface_talkback2 MCP4728test mbedSerialInterface_sequencer

Revision:
3:2a2eafba8a1d
Parent:
1:cd7c70a46739
--- a/mcp4728.cpp	Tue Jan 12 15:03:38 2016 +0000
+++ b/mcp4728.cpp	Tue Jan 12 15:45:23 2016 +0000
@@ -2,7 +2,7 @@
 #include "mbed.h"
 
 
-#define VERSION_MCP4728_SRC  "0.48"  
+#define VERSION_MCP4728_SRC  "0.49"  
 
 #define VREFVOLTAGE 2.048
 #define CMDFAST  0
@@ -35,7 +35,7 @@
 int MCP4728::getDACvalue(int& value, int ch){
     ch = ch & 7;
     value =chstat[ch].dacvalue;
-    return lastreadresult;
+    return lastupdateresult;
 }
 int  MCP4728::getVoltage(float &voltage, int ch){
     int value ; 
@@ -45,7 +45,7 @@
 };
 
 int MCP4728::setVoltage (float voltage, int ch){   
-    short int value = volt2dig( voltage, chstat[ch].gain, chstat[ch].vref);
+    short int value = volt2dig( voltage, ChCfg[ch].gain, ChCfg[ch].vref);
     return  setDACvalue( (int) value, ch);
         
 };
@@ -90,7 +90,7 @@
         char addrcheck=0;
         for ( int cc =0 ; cc < 4 ; cc++) {
             bytecnt= cc*6; // 6 byte per channel
-            chstat[cc].bussy= (rbdata[bytecnt] & 0x80)? false:true;
+            chstat[cc].busy= (rbdata[bytecnt] & 0x80)? false:true;
             chstat[cc].por= (rbdata[bytecnt] & 0x40)? false:true;
             if (checkall) {
                 chancheck=(rbdata[bytecnt] & 0x30) ;
@@ -107,7 +107,7 @@
             chstat[cc].dacvalue = chstat[cc].dacvalue << 8 ;
             chstat[cc].dacvalue = chstat[cc].dacvalue | rbdata[bytecnt++] ;// point to the forth addr
             // eprom bytes             
-            chstat[cc].bussy= (rbdata[bytecnt] & 0x80)? false:true;
+            chstat[cc].busy= (rbdata[bytecnt] & 0x80)? false:true;
             chstat[cc].por= (rbdata[bytecnt] & 0x40)? false:true;
             if (checkall) {
                 chancheck=(rbdata[bytecnt] & 0x30) ;
@@ -126,7 +126,7 @@
             chstat[cc].promvalue = chstat[cc].promvalue | rbdata[bytecnt] ;       
         }
     }        
-    lastreadresult=result; 
+    lastupdateresult=result; 
     return result;
 }