12-Bit DAC with internal Vref and SPI interface

Fork of MCP4822 by TeamElectronics

Revision:
1:d97fd6c6e2e4
Parent:
0:929babff65b1
--- a/MCP4822.h	Mon Mar 23 07:53:55 2015 +0000
+++ b/MCP4822.h	Wed Jan 20 10:55:01 2016 +0000
@@ -29,12 +29,12 @@
 // Declaration of variables & custom #defines
 //=============================================================================
 
-#define CB_OUTPUT_A     0x00       // commad bit for output A
-#define CB_OUTPUT_B     0x80       // commad bit for output A
-#define CB_GAIN_1X      0x20       // commad bit for gain 1x
-#define CB_GAIN_2X      0x00       // commad bit for gain 2x
-#define CB_SHDN         0x10       // commad bit for Output enabled
-#define CB_NSHDN        0x00       // commad bit for Output buffer disabled, output is high-impedance
+#define CB_OUTPUT_A     0x00       // command bit for output A
+#define CB_OUTPUT_B     0x80       // command bit for output A
+#define CB_GAIN_1X      0x20       // command bit for gain 1x
+#define CB_GAIN_2X      0x00       // command bit for gain 2x
+#define CB_SHDN         0x10       // command bit for Output enabled
+#define CB_NSHDN        0x00       // command bit for Output buffer disabled, output is high-impedance
 
 //=============================================================================
 // Functions Declaration
@@ -56,19 +56,8 @@
      * @param nLDAC The Latch DAC Synchronization pin 
      * @param nCs The SPI chip select pin.
      */
-    MCP4822(SPI& spi, PinName nLDAC, PinName nCs);
+    MCP4822(SPI& spi, PinName nCs, PinName nLDAC);
     
-    /** Create an instance of the MCP4261 connected with SPI pins.
-     *
-     * @param nLDAC The Latch DAC Synchronization pin 
-     * @param mosi The SPI Master Output, Slave Input pin.
-     * @param miso The SPI Master Input, Slave Output pin. 
-     * @param sck The SPI Serial Clock pin.
-     * @param nCs The SPI chip select pin.
-     */
-    MCP4822(PinName nLDAC, PinName mosi, PinName miso,PinName sck, PinName nCs);
-    
-
     /** Write to output A.
      *
      * @param gain the gain is 2x = '0' and 1x = '1'.
@@ -89,6 +78,12 @@
      */
     void ldac(bool act);
     
+    /** Output Synchronization.
+     *
+     * @return The status the LDAC.
+     */
+    bool ldac();
+    
     /** Output Shutdown.
      *
      * @param output A = '0' and B = '1'.
@@ -96,12 +91,19 @@
      */
     void shdn(bool output, bool act);
     
+    /** Output Shutdown.
+     *
+     * @return The status the SHDN. 
+     */
+    bool shdn();
+    
   
 
 private:
     SPI& _spi;
     DigitalOut _nCs;
     DigitalOut _nLDAC;
+    bool _SHDN_STATUS;
     
     char _upper_half;
     char _lower_half;