Library for MCP4822 SPI 12-bit DAC, both outputs supported, nLDAC connected to GND.

Dependents:   MCP4822_2aLerche

Revision:
0:014a10a4fed1
Child:
2:eb2c8b6c0b42
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MCP4822.h	Fri Jan 21 10:55:58 2011 +0000
@@ -0,0 +1,66 @@
+/* MCP4822 library 
+ * Copyright (c) 2008-2010, Lerche
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "mbed.h"
+
+#ifndef MCP4822_H
+#define MCP4822_H
+
+/* Class: MCP4822
+ *  Abstraction for a SPI DAC
+ */ 
+ 
+ namespace mbed {
+class MCP4822 {
+
+public:
+     /* Constructor: MCP4822
+      *  Create an instance of the MCP4822 connected to specfied SPI pins.
+      * 
+      * Variables: 
+      *  SCK - The SPI clock pin 
+      *  SDO - The SPI Data out pin 
+      *  /CS - The ChipSelect pin 
+      */ 
+    MCP4822 (PinName mosi, PinName sclk, PinName ncs);
+     /* Function: write to A-output 
+      *  Write to the A-output, max 4095 (0xFFF) with 1 mV steps
+      * 
+      * Variables: 
+      *  ValueA
+      */ 
+    void writeA (int ValueA);
+     /* Function: write to B-output 
+      *  Write to the B-output, max 4095 (0xFFF) with 1 mV steps
+      * 
+      * Variables: 
+      *  ValueB
+      */ 
+    void writeB (int ValueB);
+    
+    private :    
+        SPI _spi;
+        DigitalOut _ncs;
+        void _init();
+  };
+}
+#endif
\ No newline at end of file