This is library for mcp320x. But operation check is not finished only "mcp3204".

Dependents:   Nucleo_mcp3204test

Files at this revision

API Documentation at this revision

Comitter:
SK_ROBO_
Date:
Fri Jan 29 03:01:37 2016 +0000
Parent:
1:66fdf46dc4de
Commit message:
deleted DEBUGlibrary.

Changed in this revision

MCP320x.cpp Show annotated file Show diff for this revision Revisions of this file
MCP320x.h Show annotated file Show diff for this revision Revisions of this file
diff -r 66fdf46dc4de -r d2c51376ee7c MCP320x.cpp
--- a/MCP320x.cpp	Fri Jan 29 02:36:06 2016 +0000
+++ b/MCP320x.cpp	Fri Jan 29 03:01:37 2016 +0000
@@ -5,8 +5,6 @@
     unsigned char CMCP320x_SPI::SPIModuleRefCounter = 0;
 
     CMCP320x_SPI::CMCP320x_SPI(const PinName p_mosi, const PinName p_miso, const PinName p_sclk, const PinName p_cs, const Mcp320xFamilly p_familly, const unsigned int p_frequency) : _internalId("") {
-        DEBUG_ENTER("CMCP320x_SPI")
-        
         CMCP320x_SPI::SPIModuleRefCounter += 1;
         if (CMCP320x_SPI::SPIModuleRefCounter > 1) {
             //FIXME Check that SPI settings are identical. Otherwise it should failed
@@ -25,30 +23,21 @@
                 _channelsNum = 8;
         } // End of 'switch' statement
         _settings = 0x02; // SGL/DIFF bit set to 1 = See DS21298E-page 19 TABLE 5-1: CONFIGURATION BITS FOR THE MCP3204/TABLE 5-2: CONFIGURATION BITS FOR THE MCP3208
-        DEBUG("CMCP320x_SPI: familly:%d - #channels:%d", _familly, _channelsNum)
         _spiInstance = new SPI(p_mosi, p_miso, p_sclk);
         _spiInstance->frequency(p_frequency); // Set the frequency of the SPI interface
         _spiInstance->format(8, 3);
-        DEBUG_ENTER("CMCP320x_SPI: refCounter=%d", CMCP320x_SPI::SPIModuleRefCounter)
 
         if (p_cs != NC) {
-            DEBUG("CMCP320x_SPI: /CS managed");
             _cs = new DigitalOut(p_cs);
             _cs->write(1); // Disable chip
         } else {
-            DEBUG("CMCP320x_SPI: /CS not managed");
             _cs = NULL; // Not used
         }
     
-   
-        DEBUG_LEAVE("CMCP320x_SPI")
-    }
+     }
     
     CMCP320x_SPI::~CMCP320x_SPI() {
-        DEBUG_ENTER("~CMCP320x_SPI")
-    
         // Release I2C instance
-        DEBUG_ENTER("~CMCP320x_SPI: refCounter=%d", CMCP320x_SPI::SPIModuleRefCounter)
         CMCP320x_SPI::SPIModuleRefCounter -= 1;
         if (CMCP320x_SPI::SPIModuleRefCounter == 0) {
             delete _spiInstance;
@@ -59,12 +48,9 @@
             _cs->write(1);
             delete _cs;
         }
-   
-        DEBUG_LEAVE("~CMCP320x_SPI")
     }
 
     float CMCP320x_SPI::Read(const Mcp320xChannels p_channels) {
-        DEBUG_ENTER("CMCP320x_SPI::Read: %d", (unsigned char)p_channels)
         
         // Read a sample
         _sample.value = 0x00;
@@ -78,16 +64,13 @@
                 Read_3201();
                 break;
         } // End of 'switch' statement 
-        DEBUG("CMCP320x_SPI::Read: 0x%02x - 0x%02x", _sample.bytes[0], _sample.bytes[1])
          //_sample.value >>= 1; // Adjust composite integer for 12 valid bits
         _sample.value &= 0x0FFF; // Mask out upper nibble of integer
         
-        DEBUG_LEAVE("CMCP320x_SPI::Read: %lu", _sample.value)
         return _sample.value;        
     }
     
     void CMCP320x_SPI::SetConfig(const bool p_settings) {
-        DEBUG_LEAVE("CMCP320x_SPI::SetConfig: %x", (unsigned char)p_settings)
         
         if (_settings) {
             _settings = 0x02;
@@ -120,7 +103,6 @@
     }
 
     void CMCP320x_SPI::Read_320x(const Mcp320xChannels p_channels) {
-        DEBUG_ENTER("CMCP320x_SPI::Read_320x: %d", (unsigned char)p_channels)
         
         unsigned char _channels = (unsigned char)p_channels % _channelsNum;
         // Set start bit 
@@ -135,7 +117,6 @@
             cmd0 = mask | ((_channels & 0x04) >> 2); // Extract D2 bit - See DS21298E-page 19 Clause 5.0 SERIAL COMMUNICATIONS
             cmd1 = _channels << 6; // MCP3204 has 8 channels in single-ended mode
         }
-        DEBUG("CMCP320x_SPI::Read_320x: cmd0:%02x - cmd1:%02x", cmd0, cmd1)
         if (_cs != NULL) {
             _cs->write(0);
             wait_us(1);
@@ -147,7 +128,6 @@
             _cs->write(1);
         }
             
-        DEBUG_LEAVE("CMCP320x_SPI::Read_320x")
     }
     
 } // End of namespace MCP320x_SPI
diff -r 66fdf46dc4de -r d2c51376ee7c MCP320x.h
--- a/MCP320x.h	Fri Jan 29 02:36:06 2016 +0000
+++ b/MCP320x.h	Fri Jan 29 03:01:37 2016 +0000
@@ -2,9 +2,9 @@
 #define __MCP320x_H__
 
 #include <string>
-#include <vector>
+//#include <vector>
 
-#include "Debug.h" // Include mbed header + debug primitives. See DebugLibrary
+#include "mbed.h"
 
 namespace MCP320x_SPI {
     class CMCP320x_SPI {