Simplified access to a Microchip Digital Potentiometer (MCP41xxx/MCP42xxx) devices

Dependents:   MCP41xxxApp MCP320xApp MCP41xxxApp

Revision:
2:7c27fb9785be
Parent:
1:cf3cee91eb87
Child:
3:0acab5201dd8
--- a/MCP4xxxx_SPI.h	Sun Jan 27 17:04:05 2013 +0000
+++ b/MCP4xxxx_SPI.h	Tue Jan 29 15:02:08 2013 +0000
@@ -41,12 +41,18 @@
          */
         static unsigned char SPIModuleRefCounter;
         
-        /** Reset state indicator (pin 11); true to reset device, false otherwise (DS11195C-page 21 Clause 5.5 Reset (RS) Pin Operation)
+        /** ChipSelect (pin 1) see DS11195C-page 12 Clause 3.4 Chip Select (CS)
+         */
+        DigitalOut *_cs;
+        
+        /** Reset state indicator (pin 11), see DS11195C-page 21 Clause 5.5 Reset (RS) Pin Operation
          */
         DigitalOut *_reset;
-        /** Shutdown state indicator (pin 12); true to shutdown device, false otherwise (DS11195C-page 21 5.6 Shutdown (SHDN) Pin Operation)
+        
+        /** Shutdown state indicator (pin 12) see DS11195C-page 21 5.6 Shutdown (SHDN) Pin Operation
          */
         DigitalOut *_shdn;
+        
         /** An unique instance of SPI class
          */
         SPI *_spiInstance;
@@ -68,11 +74,12 @@
          * @param p_mosi: MBed pin for SDI
          * @param p_miso: MBed pin for SDO. Note that this pin does not exist for MCP41xxx
          * @param p_sclk: MBed pin for CLK
+         * @param p_cs  : MBed pin for Chip Select. If NC, assumes that application manage /CS, default value is NC, not connected
          * @param p_reset: MBed pin to manage /RESET input. If NC, /RESET is not managed, default value is NC, not connected
          * @param p_shdn: MBed pin to manage /SHDN input. If NC, /SHDN is not managed, default value is NC, not connected
          * @param p_frequency: Frequency of the SPI interface (SCK), default value is 1MHz
          */
-        CMCP4xxxx_SPI(const PinName p_mosi, const PinName p_miso, const PinName p_sclk, const PinName p_reset = NC, const PinName p_shdn = NC, const unsigned int p_frequency = 1000000);
+        CMCP4xxxx_SPI(const PinName p_mosi, const PinName p_miso, const PinName p_sclk, const PinName p_cs = NC, const PinName p_reset = NC, const PinName p_shdn = NC, const unsigned int p_frequency = 1000000);
     
         /** Destructor
          */
@@ -86,7 +93,7 @@
          *
          * @param p_command The command to execute: Write or Shutdown (See DS11195C-page 18)
          * @param p_value The potentiometer selection bits (See DS11195C-page 14 Clause 4.1 Modes of Operation)
-         * @return 0x00 on success, 0Xffff otherwise
+         * @return 0x0000 on success, 0Xffff otherwise
          * Exemple:
          * @code
          * unsigned char potLevel;
@@ -103,7 +110,7 @@
          *
          * @param p_command The command to execute: Write or Shutdown (See DS11195C-page 18)
          * @param p_value The potentiometer selection bits (See DS11195C-page 14 Clause 4.1 Modes of Operation)
-         * @return 0x00 on success, 0Xffff otherwise
+         * @return 0x0000 on success, 0Xffff otherwise
          * Exemple:
          * @code
          * ...