Library for the MAX11300

Dependents:   MAX_IOT_KIT MAX_IOT_KIT

Fork of MAX11300 by Maxim Integrated

The MAX11300/01/11/12 are configurable mixed signal integrated circuits. The MAX11300/11 offer a SPI interface while the MAX11301/12 offer an I2C interface. The MAX11300/01 are 20 port devices while the MAX11311/12 are 12 port devices.

This library supports the family of parts by providing member functions that can manipulate the GPIO, ADC, DAC, and analog switches of the device, after it has been configured. For configuration of the device, this library requires a header file that can be generated by the MAX11300/01/11/12 Configuration Software. The configuration software can be found at the following link.

https://www.maximintegrated.com/en/products/analog/data-converters/analog-to-digital-converters/MAX11300.html/tb_tab2

Include the generated MAX113XXHex.h file into your project and update the #include in MAX113XX_Pixi.h.

Revision:
15:fb674d741844
Parent:
13:546dd29b1c7a
Child:
16:01d793a25548
--- a/MAX113XX_Pixi.cpp	Tue May 09 22:26:16 2017 +0000
+++ b/MAX113XX_Pixi.cpp	Tue May 09 22:37:12 2017 +0000
@@ -133,20 +133,28 @@
 {
     MAX113XX_Pixi::CmdResult_e result = MAX113XX_Pixi::OpFailure;
     
+    //check for type of device
     if(m_device == MAX11300 || m_device == MAX11301) //20 port device
     {
+        //is this port configured for this operation?
         if(((portConfigDesignVals[port] & 0xF000) >> 12) == MAX113XX_Pixi::MODE_7)
         {
-            uint8_t num_samples = ((portConfigDesignVals[port] & port_cfg_00_funcprm_nsamples) >> 5);
-            num_samples = (1 << num_samples);
-            
-            while(num_samples--)
+            //Is device configured for continuous sweep?
+            if((device_control_DESIGNVALUE & device_control_ADCCTL) != MAX113XX_Pixi::ContinuousSweep)
             {
-                m_cnvt = 0;
-                wait_us(1);
-                m_cnvt = 1;
-                wait_us(100);
+                //No, generate sample requests for averaging
+                uint8_t num_samples = ((portConfigDesignVals[port] & port_cfg_00_funcprm_nsamples) >> 5);
+                num_samples = (1 << num_samples);
+                
+                while(num_samples--)
+                {
+                    m_cnvt = 0;
+                    wait_us(1);
+                    m_cnvt = 1;
+                    wait_us(100);
+                }
             }
+            
             data = readRegister((adc_data_port_00 + port));
             
             result = MAX113XX_Pixi::Success;
@@ -165,20 +173,28 @@
 {
     MAX113XX_Pixi::CmdResult_e result = MAX113XX_Pixi::OpFailure;
     
+    //check for type of device
     if(m_device == MAX11300 || m_device == MAX11301) //20 port device
     {
+        //is this port configured for this operation?
         if(((portConfigDesignVals[posPort] & 0xF000) >> 12) == MAX113XX_Pixi::MODE_8)
         {
-            uint8_t num_samples = ((portConfigDesignVals[posPort] & port_cfg_00_funcprm_nsamples) >> 5);
-            num_samples = (1 << num_samples);
-            
-            while(num_samples--)
+            //Is device configured for continuous sweep?
+            if((device_control_DESIGNVALUE & device_control_ADCCTL) != MAX113XX_Pixi::ContinuousSweep)
             {
-                m_cnvt = 0;
-                wait_us(1);
-                m_cnvt = 1;
-                wait_us(100);
+                //No, generate sample requests for averaging
+                uint8_t num_samples = ((portConfigDesignVals[port] & port_cfg_00_funcprm_nsamples) >> 5);
+                num_samples = (1 << num_samples);
+                
+                while(num_samples--)
+                {
+                    m_cnvt = 0;
+                    wait_us(1);
+                    m_cnvt = 1;
+                    wait_us(100);
+                }
             }
+            
             data = readRegister((adc_data_port_00 + posPort));
             if(data & 0x0800)
             {