Maxim Integrated MAX11131 SPI 12-bit 16-channel ADC with SampleSet

Dependents:   MAX11131BOB_Tester MAX11131BOB_12bit_16ch_SampleSet_SPI_ADC MAX11131BOB_Serial_Tester

Revision:
5:6ef046dbe77e
Parent:
4:8a0ae95546fa
Child:
6:cb7bdeb185d0
--- a/MAX11131.h	Sun Aug 04 00:14:52 2019 -0700
+++ b/MAX11131.h	Sun Aug 04 01:16:46 2019 -0700
@@ -63,6 +63,7 @@
 #ifndef __MAX11131_H__
 #define __MAX11131_H__
 
+// standard include for target platform
 #include "mbed.h"
 
 // CODE GENERATOR: conditional defines
@@ -110,37 +111,37 @@
 // CUSTOMIZE: select one of the following options
 // either by uncommenting in this file or define at the project level
 //--------------------
+// all single-ended channels use GND as common
+//~ #define PDIFF_COMM_0 	1
+//
+//--------------------
 // all single-ended channels are pseudo-differential with REF- as common
 //~ #define PDIFF_COMM_1 	1
 //
 //--------------------
-// all single-ended channels use GND as common
-//~ #define PDIFF_COMM_0 	1
-//
-//--------------------
 //
 // Default settings if not defined at project level
-#ifndef PDIFF_COMM_1
-# ifndef PDIFF_COMM_0
+#ifndef PDIFF_COMM_0
+# ifndef PDIFF_COMM_1
+#  define PDIFF_COMM_0 	1
 #  define PDIFF_COMM_1 	0
-#  define PDIFF_COMM_0 	1
-# endif // PDIFF_COMM_0
-#endif // PDIFF_COMM_1
+# endif // PDIFF_COMM_1
+#endif // PDIFF_COMM_0
 //
 // (optional diagnostic) pragma message the active setting
+#if PDIFF_COMM_0
+//~ #  pragma message("PDIFF_COMM_0: all single-ended channels use GND as common")
+#endif // PDIFF_COMM_0
 #if PDIFF_COMM_1
 //~ #  pragma message("PDIFF_COMM_1: all single-ended channels are pseudo-differential with REF- as common")
 #endif // PDIFF_COMM_1
+//
+// Validate the PDIFF_COMM_0 setting
 #if PDIFF_COMM_0
-//~ #  pragma message("PDIFF_COMM_0: all single-ended channels use GND as common")
+# if PDIFF_COMM_1
+#  error("cannot have both PDIFF_COMM_0 and PDIFF_COMM_1; choose one")
+# endif // PDIFF_COMM_1
 #endif // PDIFF_COMM_0
-//
-// Validate the PDIFF_COMM_1 setting
-#if PDIFF_COMM_1
-# if PDIFF_COMM_0
-#  error("cannot have both PDIFF_COMM_1 and PDIFF_COMM_0; choose one")
-# endif // PDIFF_COMM_0
-#endif // PDIFF_COMM_1
 
 //----------------------------------------
 // ADC Channels AIN0, AIN1
@@ -148,14 +149,14 @@
 // CUSTOMIZE: select one of the following options
 // either by uncommenting in this file or define at the project level
 //--------------------
-// ADC Channels AIN0, AIN1 = Differential Unipolar (AIN0 > AIN1)
-// Full Scale = VREF
+// ADC Channels AIN0, AIN1 = Differential Bipolar
+// Full Scale = 2 * VREF
 // Voltage per LSB count = VREF/2048
-// AIN0, AIN1 are a Differential pair using Unipolar transfer function.
+// AIN0, AIN1 are a Differential pair using Bipolar transfer function with range (+/-)Vref
 // AIN0 voltage must always be between 0 and VREF.
 // AIN1 voltage must always be between 0 and VREF.
 //
-//~ #define AIN_0_1_DifferentialUnipolar 	1
+//~ #define AIN_0_1_DifferentialBipolarFS2Vref 	1
 //
 //--------------------
 // ADC Channels AIN0, AIN1 = Differential Bipolar
@@ -168,14 +169,14 @@
 //~ #define AIN_0_1_DifferentialBipolarFSVref 	1
 //
 //--------------------
-// ADC Channels AIN0, AIN1 = Differential Bipolar
-// Full Scale = 2 * VREF
+// ADC Channels AIN0, AIN1 = Differential Unipolar (AIN0 > AIN1)
+// Full Scale = VREF
 // Voltage per LSB count = VREF/2048
-// AIN0, AIN1 are a Differential pair using Bipolar transfer function with range (+/-)Vref
+// AIN0, AIN1 are a Differential pair using Unipolar transfer function.
 // AIN0 voltage must always be between 0 and VREF.
 // AIN1 voltage must always be between 0 and VREF.
 //
-//~ #define AIN_0_1_DifferentialBipolarFS2Vref 	1
+//~ #define AIN_0_1_DifferentialUnipolar 	1
 //
 //--------------------
 // ADC Channels AIN0, AIN1 = Both Single-Ended, Unipolar
@@ -192,62 +193,62 @@
 //--------------------
 //
 // Default settings if not defined at project level
-#ifndef AIN_0_1_DifferentialUnipolar
+#ifndef AIN_0_1_DifferentialBipolarFS2Vref
 # ifndef AIN_0_1_DifferentialBipolarFSVref
-#  ifndef AIN_0_1_DifferentialBipolarFS2Vref
+#  ifndef AIN_0_1_DifferentialUnipolar
 #   ifndef AIN_0_1_SingleEnded
+#    define AIN_0_1_DifferentialBipolarFS2Vref 	0
+#    define AIN_0_1_DifferentialBipolarFSVref 	0
 #    define AIN_0_1_DifferentialUnipolar 	0
-#    define AIN_0_1_DifferentialBipolarFSVref 	0
-#    define AIN_0_1_DifferentialBipolarFS2Vref 	0
 #    define AIN_0_1_SingleEnded 	1
 #   endif // AIN_0_1_SingleEnded
-#  endif // AIN_0_1_DifferentialBipolarFS2Vref
+#  endif // AIN_0_1_DifferentialUnipolar
 # endif // AIN_0_1_DifferentialBipolarFSVref
-#endif // AIN_0_1_DifferentialUnipolar
+#endif // AIN_0_1_DifferentialBipolarFS2Vref
 //
 // (optional diagnostic) pragma message the active setting
+#if AIN_0_1_DifferentialBipolarFS2Vref
+//~ #  pragma message("AIN_0_1_DifferentialBipolarFS2Vref: ADC Channels AIN0, AIN1 = Differential Bipolar")
+#endif // AIN_0_1_DifferentialBipolarFS2Vref
+#if AIN_0_1_DifferentialBipolarFSVref
+//~ #  pragma message("AIN_0_1_DifferentialBipolarFSVref: ADC Channels AIN0, AIN1 = Differential Bipolar")
+#endif // AIN_0_1_DifferentialBipolarFSVref
 #if AIN_0_1_DifferentialUnipolar
 //~ #  pragma message("AIN_0_1_DifferentialUnipolar: ADC Channels AIN0, AIN1 = Differential Unipolar (AIN0 > AIN1)")
 #endif // AIN_0_1_DifferentialUnipolar
-#if AIN_0_1_DifferentialBipolarFSVref
-//~ #  pragma message("AIN_0_1_DifferentialBipolarFSVref: ADC Channels AIN0, AIN1 = Differential Bipolar")
-#endif // AIN_0_1_DifferentialBipolarFSVref
-#if AIN_0_1_DifferentialBipolarFS2Vref
-//~ #  pragma message("AIN_0_1_DifferentialBipolarFS2Vref: ADC Channels AIN0, AIN1 = Differential Bipolar")
-#endif // AIN_0_1_DifferentialBipolarFS2Vref
 #if AIN_0_1_SingleEnded
 //~ #  pragma message("AIN_0_1_SingleEnded: ADC Channels AIN0, AIN1 = Both Single-Ended, Unipolar")
 #endif // AIN_0_1_SingleEnded
 //
-// Validate the AIN_0_1_DifferentialUnipolar setting
-#if AIN_0_1_DifferentialUnipolar
+// Validate the AIN_0_1_DifferentialBipolarFS2Vref setting
+#if AIN_0_1_DifferentialBipolarFS2Vref
 # if AIN_0_1_DifferentialBipolarFSVref
-#  error("cannot have both AIN_0_1_DifferentialUnipolar and AIN_0_1_DifferentialBipolarFSVref; choose one")
+#  error("cannot have both AIN_0_1_DifferentialBipolarFS2Vref and AIN_0_1_DifferentialBipolarFSVref; choose one")
 # endif // AIN_0_1_DifferentialBipolarFSVref
-# if AIN_0_1_DifferentialBipolarFS2Vref
-#  error("cannot have both AIN_0_1_DifferentialUnipolar and AIN_0_1_DifferentialBipolarFS2Vref; choose one")
-# endif // AIN_0_1_DifferentialBipolarFS2Vref
+# if AIN_0_1_DifferentialUnipolar
+#  error("cannot have both AIN_0_1_DifferentialBipolarFS2Vref and AIN_0_1_DifferentialUnipolar; choose one")
+# endif // AIN_0_1_DifferentialUnipolar
 # if AIN_0_1_SingleEnded
-#  error("cannot have both AIN_0_1_DifferentialUnipolar and AIN_0_1_SingleEnded; choose one")
+#  error("cannot have both AIN_0_1_DifferentialBipolarFS2Vref and AIN_0_1_SingleEnded; choose one")
 # endif // AIN_0_1_SingleEnded
-#endif // AIN_0_1_DifferentialUnipolar
+#endif // AIN_0_1_DifferentialBipolarFS2Vref
 //
 // Validate the AIN_0_1_DifferentialBipolarFSVref setting
 #if AIN_0_1_DifferentialBipolarFSVref
-# if AIN_0_1_DifferentialBipolarFS2Vref
-#  error("cannot have both AIN_0_1_DifferentialBipolarFSVref and AIN_0_1_DifferentialBipolarFS2Vref; choose one")
-# endif // AIN_0_1_DifferentialBipolarFS2Vref
+# if AIN_0_1_DifferentialUnipolar
+#  error("cannot have both AIN_0_1_DifferentialBipolarFSVref and AIN_0_1_DifferentialUnipolar; choose one")
+# endif // AIN_0_1_DifferentialUnipolar
 # if AIN_0_1_SingleEnded
 #  error("cannot have both AIN_0_1_DifferentialBipolarFSVref and AIN_0_1_SingleEnded; choose one")
 # endif // AIN_0_1_SingleEnded
 #endif // AIN_0_1_DifferentialBipolarFSVref
 //
-// Validate the AIN_0_1_DifferentialBipolarFS2Vref setting
-#if AIN_0_1_DifferentialBipolarFS2Vref
+// Validate the AIN_0_1_DifferentialUnipolar setting
+#if AIN_0_1_DifferentialUnipolar
 # if AIN_0_1_SingleEnded
-#  error("cannot have both AIN_0_1_DifferentialBipolarFS2Vref and AIN_0_1_SingleEnded; choose one")
+#  error("cannot have both AIN_0_1_DifferentialUnipolar and AIN_0_1_SingleEnded; choose one")
 # endif // AIN_0_1_SingleEnded
-#endif // AIN_0_1_DifferentialBipolarFS2Vref
+#endif // AIN_0_1_DifferentialUnipolar
 
 //----------------------------------------
 // ADC Channels AIN2, AIN3
@@ -256,6 +257,16 @@
 // either by uncommenting in this file or define at the project level
 //--------------------
 // ADC Channels AIN2, AIN3 = Differential Bipolar
+// Full Scale = 2 * VREF
+// Voltage per LSB count = VREF/2048
+// AIN2, AIN3 are a Differential pair using Bipolar transfer function with range (+/-)Vref
+// AIN2 voltage must always be between 0 and VREF.
+// AIN3 voltage must always be between 0 and VREF.
+//
+//~ #define AIN_2_3_DifferentialBipolarFS2Vref 	1
+//
+//--------------------
+// ADC Channels AIN2, AIN3 = Differential Bipolar
 // Full Scale = VREF
 // Voltage per LSB count = VREF/2048
 // AIN2, AIN3 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
@@ -265,14 +276,14 @@
 //~ #define AIN_2_3_DifferentialBipolarFSVref 	1
 //
 //--------------------
-// ADC Channels AIN2, AIN3 = Differential Bipolar
-// Full Scale = 2 * VREF
+// ADC Channels AIN2, AIN3 = Differential Unipolar (AIN2 > AIN3)
+// Full Scale = VREF
 // Voltage per LSB count = VREF/2048
-// AIN2, AIN3 are a Differential pair using Bipolar transfer function with range (+/-)Vref
+// AIN2, AIN3 are a Differential pair using Unipolar transfer function.
 // AIN2 voltage must always be between 0 and VREF.
 // AIN3 voltage must always be between 0 and VREF.
 //
-//~ #define AIN_2_3_DifferentialBipolarFS2Vref 	1
+//~ #define AIN_2_3_DifferentialUnipolar 	1
 //
 //--------------------
 // ADC Channels AIN2, AIN3 = Both Single-Ended, Unipolar
@@ -287,74 +298,64 @@
 //~ #define AIN_2_3_SingleEnded 	1
 //
 //--------------------
-// ADC Channels AIN2, AIN3 = Differential Unipolar (AIN2 > AIN3)
-// Full Scale = VREF
-// Voltage per LSB count = VREF/2048
-// AIN2, AIN3 are a Differential pair using Unipolar transfer function.
-// AIN2 voltage must always be between 0 and VREF.
-// AIN3 voltage must always be between 0 and VREF.
-//
-//~ #define AIN_2_3_DifferentialUnipolar 	1
-//
-//--------------------
 //
 // Default settings if not defined at project level
-#ifndef AIN_2_3_DifferentialBipolarFSVref
-# ifndef AIN_2_3_DifferentialBipolarFS2Vref
-#  ifndef AIN_2_3_SingleEnded
-#   ifndef AIN_2_3_DifferentialUnipolar
+#ifndef AIN_2_3_DifferentialBipolarFS2Vref
+# ifndef AIN_2_3_DifferentialBipolarFSVref
+#  ifndef AIN_2_3_DifferentialUnipolar
+#   ifndef AIN_2_3_SingleEnded
+#    define AIN_2_3_DifferentialBipolarFS2Vref 	0
 #    define AIN_2_3_DifferentialBipolarFSVref 	0
-#    define AIN_2_3_DifferentialBipolarFS2Vref 	0
+#    define AIN_2_3_DifferentialUnipolar 	0
 #    define AIN_2_3_SingleEnded 	1
-#    define AIN_2_3_DifferentialUnipolar 	0
-#   endif // AIN_2_3_DifferentialUnipolar
-#  endif // AIN_2_3_SingleEnded
-# endif // AIN_2_3_DifferentialBipolarFS2Vref
-#endif // AIN_2_3_DifferentialBipolarFSVref
+#   endif // AIN_2_3_SingleEnded
+#  endif // AIN_2_3_DifferentialUnipolar
+# endif // AIN_2_3_DifferentialBipolarFSVref
+#endif // AIN_2_3_DifferentialBipolarFS2Vref
 //
 // (optional diagnostic) pragma message the active setting
+#if AIN_2_3_DifferentialBipolarFS2Vref
+//~ #  pragma message("AIN_2_3_DifferentialBipolarFS2Vref: ADC Channels AIN2, AIN3 = Differential Bipolar")
+#endif // AIN_2_3_DifferentialBipolarFS2Vref
 #if AIN_2_3_DifferentialBipolarFSVref
 //~ #  pragma message("AIN_2_3_DifferentialBipolarFSVref: ADC Channels AIN2, AIN3 = Differential Bipolar")
 #endif // AIN_2_3_DifferentialBipolarFSVref
-#if AIN_2_3_DifferentialBipolarFS2Vref
-//~ #  pragma message("AIN_2_3_DifferentialBipolarFS2Vref: ADC Channels AIN2, AIN3 = Differential Bipolar")
-#endif // AIN_2_3_DifferentialBipolarFS2Vref
+#if AIN_2_3_DifferentialUnipolar
+//~ #  pragma message("AIN_2_3_DifferentialUnipolar: ADC Channels AIN2, AIN3 = Differential Unipolar (AIN2 > AIN3)")
+#endif // AIN_2_3_DifferentialUnipolar
 #if AIN_2_3_SingleEnded
 //~ #  pragma message("AIN_2_3_SingleEnded: ADC Channels AIN2, AIN3 = Both Single-Ended, Unipolar")
 #endif // AIN_2_3_SingleEnded
-#if AIN_2_3_DifferentialUnipolar
-//~ #  pragma message("AIN_2_3_DifferentialUnipolar: ADC Channels AIN2, AIN3 = Differential Unipolar (AIN2 > AIN3)")
-#endif // AIN_2_3_DifferentialUnipolar
+//
+// Validate the AIN_2_3_DifferentialBipolarFS2Vref setting
+#if AIN_2_3_DifferentialBipolarFS2Vref
+# if AIN_2_3_DifferentialBipolarFSVref
+#  error("cannot have both AIN_2_3_DifferentialBipolarFS2Vref and AIN_2_3_DifferentialBipolarFSVref; choose one")
+# endif // AIN_2_3_DifferentialBipolarFSVref
+# if AIN_2_3_DifferentialUnipolar
+#  error("cannot have both AIN_2_3_DifferentialBipolarFS2Vref and AIN_2_3_DifferentialUnipolar; choose one")
+# endif // AIN_2_3_DifferentialUnipolar
+# if AIN_2_3_SingleEnded
+#  error("cannot have both AIN_2_3_DifferentialBipolarFS2Vref and AIN_2_3_SingleEnded; choose one")
+# endif // AIN_2_3_SingleEnded
+#endif // AIN_2_3_DifferentialBipolarFS2Vref
 //
 // Validate the AIN_2_3_DifferentialBipolarFSVref setting
 #if AIN_2_3_DifferentialBipolarFSVref
-# if AIN_2_3_DifferentialBipolarFS2Vref
-#  error("cannot have both AIN_2_3_DifferentialBipolarFSVref and AIN_2_3_DifferentialBipolarFS2Vref; choose one")
-# endif // AIN_2_3_DifferentialBipolarFS2Vref
+# if AIN_2_3_DifferentialUnipolar
+#  error("cannot have both AIN_2_3_DifferentialBipolarFSVref and AIN_2_3_DifferentialUnipolar; choose one")
+# endif // AIN_2_3_DifferentialUnipolar
 # if AIN_2_3_SingleEnded
 #  error("cannot have both AIN_2_3_DifferentialBipolarFSVref and AIN_2_3_SingleEnded; choose one")
 # endif // AIN_2_3_SingleEnded
-# if AIN_2_3_DifferentialUnipolar
-#  error("cannot have both AIN_2_3_DifferentialBipolarFSVref and AIN_2_3_DifferentialUnipolar; choose one")
-# endif // AIN_2_3_DifferentialUnipolar
 #endif // AIN_2_3_DifferentialBipolarFSVref
 //
-// Validate the AIN_2_3_DifferentialBipolarFS2Vref setting
-#if AIN_2_3_DifferentialBipolarFS2Vref
+// Validate the AIN_2_3_DifferentialUnipolar setting
+#if AIN_2_3_DifferentialUnipolar
 # if AIN_2_3_SingleEnded
-#  error("cannot have both AIN_2_3_DifferentialBipolarFS2Vref and AIN_2_3_SingleEnded; choose one")
+#  error("cannot have both AIN_2_3_DifferentialUnipolar and AIN_2_3_SingleEnded; choose one")
 # endif // AIN_2_3_SingleEnded
-# if AIN_2_3_DifferentialUnipolar
-#  error("cannot have both AIN_2_3_DifferentialBipolarFS2Vref and AIN_2_3_DifferentialUnipolar; choose one")
-# endif // AIN_2_3_DifferentialUnipolar
-#endif // AIN_2_3_DifferentialBipolarFS2Vref
-//
-// Validate the AIN_2_3_SingleEnded setting
-#if AIN_2_3_SingleEnded
-# if AIN_2_3_DifferentialUnipolar
-#  error("cannot have both AIN_2_3_SingleEnded and AIN_2_3_DifferentialUnipolar; choose one")
-# endif // AIN_2_3_DifferentialUnipolar
-#endif // AIN_2_3_SingleEnded
+#endif // AIN_2_3_DifferentialUnipolar
 
 //----------------------------------------
 // ADC Channels AIN4, AIN5
@@ -362,14 +363,14 @@
 // CUSTOMIZE: select one of the following options
 // either by uncommenting in this file or define at the project level
 //--------------------
-// ADC Channels AIN4, AIN5 = Differential Unipolar (AIN4 > AIN5)
-// Full Scale = VREF
+// ADC Channels AIN4, AIN5 = Differential Bipolar
+// Full Scale = 2 * VREF
 // Voltage per LSB count = VREF/2048
-// AIN4, AIN5 are a Differential pair using Unipolar transfer function.
+// AIN4, AIN5 are a Differential pair using Bipolar transfer function with range (+/-)Vref
 // AIN4 voltage must always be between 0 and VREF.
 // AIN5 voltage must always be between 0 and VREF.
 //
-//~ #define AIN_4_5_DifferentialUnipolar 	1
+//~ #define AIN_4_5_DifferentialBipolarFS2Vref 	1
 //
 //--------------------
 // ADC Channels AIN4, AIN5 = Differential Bipolar
@@ -382,14 +383,14 @@
 //~ #define AIN_4_5_DifferentialBipolarFSVref 	1
 //
 //--------------------
-// ADC Channels AIN4, AIN5 = Differential Bipolar
-// Full Scale = 2 * VREF
+// ADC Channels AIN4, AIN5 = Differential Unipolar (AIN4 > AIN5)
+// Full Scale = VREF
 // Voltage per LSB count = VREF/2048
-// AIN4, AIN5 are a Differential pair using Bipolar transfer function with range (+/-)Vref
+// AIN4, AIN5 are a Differential pair using Unipolar transfer function.
 // AIN4 voltage must always be between 0 and VREF.
 // AIN5 voltage must always be between 0 and VREF.
 //
-//~ #define AIN_4_5_DifferentialBipolarFS2Vref 	1
+//~ #define AIN_4_5_DifferentialUnipolar 	1
 //
 //--------------------
 // ADC Channels AIN4, AIN5 = Both Single-Ended, Unipolar
@@ -406,62 +407,62 @@
 //--------------------
 //
 // Default settings if not defined at project level
-#ifndef AIN_4_5_DifferentialUnipolar
+#ifndef AIN_4_5_DifferentialBipolarFS2Vref
 # ifndef AIN_4_5_DifferentialBipolarFSVref
-#  ifndef AIN_4_5_DifferentialBipolarFS2Vref
+#  ifndef AIN_4_5_DifferentialUnipolar
 #   ifndef AIN_4_5_SingleEnded
+#    define AIN_4_5_DifferentialBipolarFS2Vref 	0
+#    define AIN_4_5_DifferentialBipolarFSVref 	0
 #    define AIN_4_5_DifferentialUnipolar 	0
-#    define AIN_4_5_DifferentialBipolarFSVref 	0
-#    define AIN_4_5_DifferentialBipolarFS2Vref 	0
 #    define AIN_4_5_SingleEnded 	1
 #   endif // AIN_4_5_SingleEnded
-#  endif // AIN_4_5_DifferentialBipolarFS2Vref
+#  endif // AIN_4_5_DifferentialUnipolar
 # endif // AIN_4_5_DifferentialBipolarFSVref
-#endif // AIN_4_5_DifferentialUnipolar
+#endif // AIN_4_5_DifferentialBipolarFS2Vref
 //
 // (optional diagnostic) pragma message the active setting
+#if AIN_4_5_DifferentialBipolarFS2Vref
+//~ #  pragma message("AIN_4_5_DifferentialBipolarFS2Vref: ADC Channels AIN4, AIN5 = Differential Bipolar")
+#endif // AIN_4_5_DifferentialBipolarFS2Vref
+#if AIN_4_5_DifferentialBipolarFSVref
+//~ #  pragma message("AIN_4_5_DifferentialBipolarFSVref: ADC Channels AIN4, AIN5 = Differential Bipolar")
+#endif // AIN_4_5_DifferentialBipolarFSVref
 #if AIN_4_5_DifferentialUnipolar
 //~ #  pragma message("AIN_4_5_DifferentialUnipolar: ADC Channels AIN4, AIN5 = Differential Unipolar (AIN4 > AIN5)")
 #endif // AIN_4_5_DifferentialUnipolar
-#if AIN_4_5_DifferentialBipolarFSVref
-//~ #  pragma message("AIN_4_5_DifferentialBipolarFSVref: ADC Channels AIN4, AIN5 = Differential Bipolar")
-#endif // AIN_4_5_DifferentialBipolarFSVref
-#if AIN_4_5_DifferentialBipolarFS2Vref
-//~ #  pragma message("AIN_4_5_DifferentialBipolarFS2Vref: ADC Channels AIN4, AIN5 = Differential Bipolar")
-#endif // AIN_4_5_DifferentialBipolarFS2Vref
 #if AIN_4_5_SingleEnded
 //~ #  pragma message("AIN_4_5_SingleEnded: ADC Channels AIN4, AIN5 = Both Single-Ended, Unipolar")
 #endif // AIN_4_5_SingleEnded
 //
-// Validate the AIN_4_5_DifferentialUnipolar setting
-#if AIN_4_5_DifferentialUnipolar
+// Validate the AIN_4_5_DifferentialBipolarFS2Vref setting
+#if AIN_4_5_DifferentialBipolarFS2Vref
 # if AIN_4_5_DifferentialBipolarFSVref
-#  error("cannot have both AIN_4_5_DifferentialUnipolar and AIN_4_5_DifferentialBipolarFSVref; choose one")
+#  error("cannot have both AIN_4_5_DifferentialBipolarFS2Vref and AIN_4_5_DifferentialBipolarFSVref; choose one")
 # endif // AIN_4_5_DifferentialBipolarFSVref
-# if AIN_4_5_DifferentialBipolarFS2Vref
-#  error("cannot have both AIN_4_5_DifferentialUnipolar and AIN_4_5_DifferentialBipolarFS2Vref; choose one")
-# endif // AIN_4_5_DifferentialBipolarFS2Vref
+# if AIN_4_5_DifferentialUnipolar
+#  error("cannot have both AIN_4_5_DifferentialBipolarFS2Vref and AIN_4_5_DifferentialUnipolar; choose one")
+# endif // AIN_4_5_DifferentialUnipolar
 # if AIN_4_5_SingleEnded
-#  error("cannot have both AIN_4_5_DifferentialUnipolar and AIN_4_5_SingleEnded; choose one")
+#  error("cannot have both AIN_4_5_DifferentialBipolarFS2Vref and AIN_4_5_SingleEnded; choose one")
 # endif // AIN_4_5_SingleEnded
-#endif // AIN_4_5_DifferentialUnipolar
+#endif // AIN_4_5_DifferentialBipolarFS2Vref
 //
 // Validate the AIN_4_5_DifferentialBipolarFSVref setting
 #if AIN_4_5_DifferentialBipolarFSVref
-# if AIN_4_5_DifferentialBipolarFS2Vref
-#  error("cannot have both AIN_4_5_DifferentialBipolarFSVref and AIN_4_5_DifferentialBipolarFS2Vref; choose one")
-# endif // AIN_4_5_DifferentialBipolarFS2Vref
+# if AIN_4_5_DifferentialUnipolar
+#  error("cannot have both AIN_4_5_DifferentialBipolarFSVref and AIN_4_5_DifferentialUnipolar; choose one")
+# endif // AIN_4_5_DifferentialUnipolar
 # if AIN_4_5_SingleEnded
 #  error("cannot have both AIN_4_5_DifferentialBipolarFSVref and AIN_4_5_SingleEnded; choose one")
 # endif // AIN_4_5_SingleEnded
 #endif // AIN_4_5_DifferentialBipolarFSVref
 //
-// Validate the AIN_4_5_DifferentialBipolarFS2Vref setting
-#if AIN_4_5_DifferentialBipolarFS2Vref
+// Validate the AIN_4_5_DifferentialUnipolar setting
+#if AIN_4_5_DifferentialUnipolar
 # if AIN_4_5_SingleEnded
-#  error("cannot have both AIN_4_5_DifferentialBipolarFS2Vref and AIN_4_5_SingleEnded; choose one")
+#  error("cannot have both AIN_4_5_DifferentialUnipolar and AIN_4_5_SingleEnded; choose one")
 # endif // AIN_4_5_SingleEnded
-#endif // AIN_4_5_DifferentialBipolarFS2Vref
+#endif // AIN_4_5_DifferentialUnipolar
 
 //----------------------------------------
 // ADC Channels AIN6, AIN7
@@ -470,6 +471,16 @@
 // either by uncommenting in this file or define at the project level
 //--------------------
 // ADC Channels AIN6, AIN7 = Differential Bipolar
+// Full Scale = 2 * VREF
+// Voltage per LSB count = VREF/2048
+// AIN6, AIN7 are a Differential pair using Bipolar transfer function with range (+/-)Vref
+// AIN6 voltage must always be between 0 and VREF.
+// AIN7 voltage must always be between 0 and VREF.
+//
+//~ #define AIN_6_7_DifferentialBipolarFS2Vref 	1
+//
+//--------------------
+// ADC Channels AIN6, AIN7 = Differential Bipolar
 // Full Scale = VREF
 // Voltage per LSB count = VREF/2048
 // AIN6, AIN7 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
@@ -479,14 +490,14 @@
 //~ #define AIN_6_7_DifferentialBipolarFSVref 	1
 //
 //--------------------
-// ADC Channels AIN6, AIN7 = Differential Bipolar
-// Full Scale = 2 * VREF
+// ADC Channels AIN6, AIN7 = Differential Unipolar (AIN6 > AIN7)
+// Full Scale = VREF
 // Voltage per LSB count = VREF/2048
-// AIN6, AIN7 are a Differential pair using Bipolar transfer function with range (+/-)Vref
+// AIN6, AIN7 are a Differential pair using Unipolar transfer function.
 // AIN6 voltage must always be between 0 and VREF.
 // AIN7 voltage must always be between 0 and VREF.
 //
-//~ #define AIN_6_7_DifferentialBipolarFS2Vref 	1
+//~ #define AIN_6_7_DifferentialUnipolar 	1
 //
 //--------------------
 // ADC Channels AIN6, AIN7 = Both Single-Ended, Unipolar
@@ -501,74 +512,64 @@
 //~ #define AIN_6_7_SingleEnded 	1
 //
 //--------------------
-// ADC Channels AIN6, AIN7 = Differential Unipolar (AIN6 > AIN7)
-// Full Scale = VREF
-// Voltage per LSB count = VREF/2048
-// AIN6, AIN7 are a Differential pair using Unipolar transfer function.
-// AIN6 voltage must always be between 0 and VREF.
-// AIN7 voltage must always be between 0 and VREF.
-//
-//~ #define AIN_6_7_DifferentialUnipolar 	1
-//
-//--------------------
 //
 // Default settings if not defined at project level
-#ifndef AIN_6_7_DifferentialBipolarFSVref
-# ifndef AIN_6_7_DifferentialBipolarFS2Vref
-#  ifndef AIN_6_7_SingleEnded
-#   ifndef AIN_6_7_DifferentialUnipolar
+#ifndef AIN_6_7_DifferentialBipolarFS2Vref
+# ifndef AIN_6_7_DifferentialBipolarFSVref
+#  ifndef AIN_6_7_DifferentialUnipolar
+#   ifndef AIN_6_7_SingleEnded
+#    define AIN_6_7_DifferentialBipolarFS2Vref 	0
 #    define AIN_6_7_DifferentialBipolarFSVref 	0
-#    define AIN_6_7_DifferentialBipolarFS2Vref 	0
+#    define AIN_6_7_DifferentialUnipolar 	0
 #    define AIN_6_7_SingleEnded 	1
-#    define AIN_6_7_DifferentialUnipolar 	0
-#   endif // AIN_6_7_DifferentialUnipolar
-#  endif // AIN_6_7_SingleEnded
-# endif // AIN_6_7_DifferentialBipolarFS2Vref
-#endif // AIN_6_7_DifferentialBipolarFSVref
+#   endif // AIN_6_7_SingleEnded
+#  endif // AIN_6_7_DifferentialUnipolar
+# endif // AIN_6_7_DifferentialBipolarFSVref
+#endif // AIN_6_7_DifferentialBipolarFS2Vref
 //
 // (optional diagnostic) pragma message the active setting
+#if AIN_6_7_DifferentialBipolarFS2Vref
+//~ #  pragma message("AIN_6_7_DifferentialBipolarFS2Vref: ADC Channels AIN6, AIN7 = Differential Bipolar")
+#endif // AIN_6_7_DifferentialBipolarFS2Vref
 #if AIN_6_7_DifferentialBipolarFSVref
 //~ #  pragma message("AIN_6_7_DifferentialBipolarFSVref: ADC Channels AIN6, AIN7 = Differential Bipolar")
 #endif // AIN_6_7_DifferentialBipolarFSVref
-#if AIN_6_7_DifferentialBipolarFS2Vref
-//~ #  pragma message("AIN_6_7_DifferentialBipolarFS2Vref: ADC Channels AIN6, AIN7 = Differential Bipolar")
-#endif // AIN_6_7_DifferentialBipolarFS2Vref
+#if AIN_6_7_DifferentialUnipolar
+//~ #  pragma message("AIN_6_7_DifferentialUnipolar: ADC Channels AIN6, AIN7 = Differential Unipolar (AIN6 > AIN7)")
+#endif // AIN_6_7_DifferentialUnipolar
 #if AIN_6_7_SingleEnded
 //~ #  pragma message("AIN_6_7_SingleEnded: ADC Channels AIN6, AIN7 = Both Single-Ended, Unipolar")
 #endif // AIN_6_7_SingleEnded
-#if AIN_6_7_DifferentialUnipolar
-//~ #  pragma message("AIN_6_7_DifferentialUnipolar: ADC Channels AIN6, AIN7 = Differential Unipolar (AIN6 > AIN7)")
-#endif // AIN_6_7_DifferentialUnipolar
+//
+// Validate the AIN_6_7_DifferentialBipolarFS2Vref setting
+#if AIN_6_7_DifferentialBipolarFS2Vref
+# if AIN_6_7_DifferentialBipolarFSVref
+#  error("cannot have both AIN_6_7_DifferentialBipolarFS2Vref and AIN_6_7_DifferentialBipolarFSVref; choose one")
+# endif // AIN_6_7_DifferentialBipolarFSVref
+# if AIN_6_7_DifferentialUnipolar
+#  error("cannot have both AIN_6_7_DifferentialBipolarFS2Vref and AIN_6_7_DifferentialUnipolar; choose one")
+# endif // AIN_6_7_DifferentialUnipolar
+# if AIN_6_7_SingleEnded
+#  error("cannot have both AIN_6_7_DifferentialBipolarFS2Vref and AIN_6_7_SingleEnded; choose one")
+# endif // AIN_6_7_SingleEnded
+#endif // AIN_6_7_DifferentialBipolarFS2Vref
 //
 // Validate the AIN_6_7_DifferentialBipolarFSVref setting
 #if AIN_6_7_DifferentialBipolarFSVref
-# if AIN_6_7_DifferentialBipolarFS2Vref
-#  error("cannot have both AIN_6_7_DifferentialBipolarFSVref and AIN_6_7_DifferentialBipolarFS2Vref; choose one")
-# endif // AIN_6_7_DifferentialBipolarFS2Vref
+# if AIN_6_7_DifferentialUnipolar
+#  error("cannot have both AIN_6_7_DifferentialBipolarFSVref and AIN_6_7_DifferentialUnipolar; choose one")
+# endif // AIN_6_7_DifferentialUnipolar
 # if AIN_6_7_SingleEnded
 #  error("cannot have both AIN_6_7_DifferentialBipolarFSVref and AIN_6_7_SingleEnded; choose one")
 # endif // AIN_6_7_SingleEnded
-# if AIN_6_7_DifferentialUnipolar
-#  error("cannot have both AIN_6_7_DifferentialBipolarFSVref and AIN_6_7_DifferentialUnipolar; choose one")
-# endif // AIN_6_7_DifferentialUnipolar
 #endif // AIN_6_7_DifferentialBipolarFSVref
 //
-// Validate the AIN_6_7_DifferentialBipolarFS2Vref setting
-#if AIN_6_7_DifferentialBipolarFS2Vref
+// Validate the AIN_6_7_DifferentialUnipolar setting
+#if AIN_6_7_DifferentialUnipolar
 # if AIN_6_7_SingleEnded
-#  error("cannot have both AIN_6_7_DifferentialBipolarFS2Vref and AIN_6_7_SingleEnded; choose one")
+#  error("cannot have both AIN_6_7_DifferentialUnipolar and AIN_6_7_SingleEnded; choose one")
 # endif // AIN_6_7_SingleEnded
-# if AIN_6_7_DifferentialUnipolar
-#  error("cannot have both AIN_6_7_DifferentialBipolarFS2Vref and AIN_6_7_DifferentialUnipolar; choose one")
-# endif // AIN_6_7_DifferentialUnipolar
-#endif // AIN_6_7_DifferentialBipolarFS2Vref
-//
-// Validate the AIN_6_7_SingleEnded setting
-#if AIN_6_7_SingleEnded
-# if AIN_6_7_DifferentialUnipolar
-#  error("cannot have both AIN_6_7_SingleEnded and AIN_6_7_DifferentialUnipolar; choose one")
-# endif // AIN_6_7_DifferentialUnipolar
-#endif // AIN_6_7_SingleEnded
+#endif // AIN_6_7_DifferentialUnipolar
 
 //----------------------------------------
 // ADC Channels AIN8, AIN9
@@ -576,14 +577,14 @@
 // CUSTOMIZE: select one of the following options
 // either by uncommenting in this file or define at the project level
 //--------------------
-// ADC Channels AIN8, AIN9 = Differential Unipolar (AIN8 > AIN9)
-// Full Scale = VREF
+// ADC Channels AIN8, AIN9 = Differential Bipolar
+// Full Scale = 2 * VREF
 // Voltage per LSB count = VREF/2048
-// AIN8, AIN9 are a Differential pair using Unipolar transfer function.
+// AIN8, AIN9 are a Differential pair using Bipolar transfer function with range (+/-)Vref
 // AIN8 voltage must always be between 0 and VREF.
 // AIN9 voltage must always be between 0 and VREF.
 //
-//~ #define AIN_8_9_DifferentialUnipolar 	1
+//~ #define AIN_8_9_DifferentialBipolarFS2Vref 	1
 //
 //--------------------
 // ADC Channels AIN8, AIN9 = Differential Bipolar
@@ -596,14 +597,14 @@
 //~ #define AIN_8_9_DifferentialBipolarFSVref 	1
 //
 //--------------------
-// ADC Channels AIN8, AIN9 = Differential Bipolar
-// Full Scale = 2 * VREF
+// ADC Channels AIN8, AIN9 = Differential Unipolar (AIN8 > AIN9)
+// Full Scale = VREF
 // Voltage per LSB count = VREF/2048
-// AIN8, AIN9 are a Differential pair using Bipolar transfer function with range (+/-)Vref
+// AIN8, AIN9 are a Differential pair using Unipolar transfer function.
 // AIN8 voltage must always be between 0 and VREF.
 // AIN9 voltage must always be between 0 and VREF.
 //
-//~ #define AIN_8_9_DifferentialBipolarFS2Vref 	1
+//~ #define AIN_8_9_DifferentialUnipolar 	1
 //
 //--------------------
 // ADC Channels AIN8, AIN9 = Both Single-Ended, Unipolar
@@ -620,62 +621,62 @@
 //--------------------
 //
 // Default settings if not defined at project level
-#ifndef AIN_8_9_DifferentialUnipolar
+#ifndef AIN_8_9_DifferentialBipolarFS2Vref
 # ifndef AIN_8_9_DifferentialBipolarFSVref
-#  ifndef AIN_8_9_DifferentialBipolarFS2Vref
+#  ifndef AIN_8_9_DifferentialUnipolar
 #   ifndef AIN_8_9_SingleEnded
+#    define AIN_8_9_DifferentialBipolarFS2Vref 	0
+#    define AIN_8_9_DifferentialBipolarFSVref 	0
 #    define AIN_8_9_DifferentialUnipolar 	0
-#    define AIN_8_9_DifferentialBipolarFSVref 	0
-#    define AIN_8_9_DifferentialBipolarFS2Vref 	0
 #    define AIN_8_9_SingleEnded 	1
 #   endif // AIN_8_9_SingleEnded
-#  endif // AIN_8_9_DifferentialBipolarFS2Vref
+#  endif // AIN_8_9_DifferentialUnipolar
 # endif // AIN_8_9_DifferentialBipolarFSVref
-#endif // AIN_8_9_DifferentialUnipolar
+#endif // AIN_8_9_DifferentialBipolarFS2Vref
 //
 // (optional diagnostic) pragma message the active setting
+#if AIN_8_9_DifferentialBipolarFS2Vref
+//~ #  pragma message("AIN_8_9_DifferentialBipolarFS2Vref: ADC Channels AIN8, AIN9 = Differential Bipolar")
+#endif // AIN_8_9_DifferentialBipolarFS2Vref
+#if AIN_8_9_DifferentialBipolarFSVref
+//~ #  pragma message("AIN_8_9_DifferentialBipolarFSVref: ADC Channels AIN8, AIN9 = Differential Bipolar")
+#endif // AIN_8_9_DifferentialBipolarFSVref
 #if AIN_8_9_DifferentialUnipolar
 //~ #  pragma message("AIN_8_9_DifferentialUnipolar: ADC Channels AIN8, AIN9 = Differential Unipolar (AIN8 > AIN9)")
 #endif // AIN_8_9_DifferentialUnipolar
-#if AIN_8_9_DifferentialBipolarFSVref
-//~ #  pragma message("AIN_8_9_DifferentialBipolarFSVref: ADC Channels AIN8, AIN9 = Differential Bipolar")
-#endif // AIN_8_9_DifferentialBipolarFSVref
-#if AIN_8_9_DifferentialBipolarFS2Vref
-//~ #  pragma message("AIN_8_9_DifferentialBipolarFS2Vref: ADC Channels AIN8, AIN9 = Differential Bipolar")
-#endif // AIN_8_9_DifferentialBipolarFS2Vref
 #if AIN_8_9_SingleEnded
 //~ #  pragma message("AIN_8_9_SingleEnded: ADC Channels AIN8, AIN9 = Both Single-Ended, Unipolar")
 #endif // AIN_8_9_SingleEnded
 //
-// Validate the AIN_8_9_DifferentialUnipolar setting
-#if AIN_8_9_DifferentialUnipolar
+// Validate the AIN_8_9_DifferentialBipolarFS2Vref setting
+#if AIN_8_9_DifferentialBipolarFS2Vref
 # if AIN_8_9_DifferentialBipolarFSVref
-#  error("cannot have both AIN_8_9_DifferentialUnipolar and AIN_8_9_DifferentialBipolarFSVref; choose one")
+#  error("cannot have both AIN_8_9_DifferentialBipolarFS2Vref and AIN_8_9_DifferentialBipolarFSVref; choose one")
 # endif // AIN_8_9_DifferentialBipolarFSVref
-# if AIN_8_9_DifferentialBipolarFS2Vref
-#  error("cannot have both AIN_8_9_DifferentialUnipolar and AIN_8_9_DifferentialBipolarFS2Vref; choose one")
-# endif // AIN_8_9_DifferentialBipolarFS2Vref
+# if AIN_8_9_DifferentialUnipolar
+#  error("cannot have both AIN_8_9_DifferentialBipolarFS2Vref and AIN_8_9_DifferentialUnipolar; choose one")
+# endif // AIN_8_9_DifferentialUnipolar
 # if AIN_8_9_SingleEnded
-#  error("cannot have both AIN_8_9_DifferentialUnipolar and AIN_8_9_SingleEnded; choose one")
+#  error("cannot have both AIN_8_9_DifferentialBipolarFS2Vref and AIN_8_9_SingleEnded; choose one")
 # endif // AIN_8_9_SingleEnded
-#endif // AIN_8_9_DifferentialUnipolar
+#endif // AIN_8_9_DifferentialBipolarFS2Vref
 //
 // Validate the AIN_8_9_DifferentialBipolarFSVref setting
 #if AIN_8_9_DifferentialBipolarFSVref
-# if AIN_8_9_DifferentialBipolarFS2Vref
-#  error("cannot have both AIN_8_9_DifferentialBipolarFSVref and AIN_8_9_DifferentialBipolarFS2Vref; choose one")
-# endif // AIN_8_9_DifferentialBipolarFS2Vref
+# if AIN_8_9_DifferentialUnipolar
+#  error("cannot have both AIN_8_9_DifferentialBipolarFSVref and AIN_8_9_DifferentialUnipolar; choose one")
+# endif // AIN_8_9_DifferentialUnipolar
 # if AIN_8_9_SingleEnded
 #  error("cannot have both AIN_8_9_DifferentialBipolarFSVref and AIN_8_9_SingleEnded; choose one")
 # endif // AIN_8_9_SingleEnded
 #endif // AIN_8_9_DifferentialBipolarFSVref
 //
-// Validate the AIN_8_9_DifferentialBipolarFS2Vref setting
-#if AIN_8_9_DifferentialBipolarFS2Vref
+// Validate the AIN_8_9_DifferentialUnipolar setting
+#if AIN_8_9_DifferentialUnipolar
 # if AIN_8_9_SingleEnded
-#  error("cannot have both AIN_8_9_DifferentialBipolarFS2Vref and AIN_8_9_SingleEnded; choose one")
+#  error("cannot have both AIN_8_9_DifferentialUnipolar and AIN_8_9_SingleEnded; choose one")
 # endif // AIN_8_9_SingleEnded
-#endif // AIN_8_9_DifferentialBipolarFS2Vref
+#endif // AIN_8_9_DifferentialUnipolar
 
 //----------------------------------------
 // ADC Channels AIN10, AIN11
@@ -693,16 +694,14 @@
 //~ #define AIN_10_11_DifferentialBipolarFS2Vref 	1
 //
 //--------------------
-// ADC Channels AIN10, AIN11 = Both Single-Ended, Unipolar
+// ADC Channels AIN10, AIN11 = Differential Bipolar
 // Full Scale = VREF
 // Voltage per LSB count = VREF/2048
-// AIN10 is a Single-Ended input using Unipolar transfer function.
-// AIN11 is a Single-Ended input using Unipolar transfer function.
-// If PDIFF_COM_1, both are Pseudo-Differential with REF- as common.
+// AIN10, AIN11 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
 // AIN10 voltage must always be between 0 and VREF.
 // AIN11 voltage must always be between 0 and VREF.
 //
-//~ #define AIN_10_11_SingleEnded 	1
+//~ #define AIN_10_11_DifferentialBipolarFSVref 	1
 //
 //--------------------
 // ADC Channels AIN10, AIN11 = Differential Unipolar (AIN10 > AIN11)
@@ -715,73 +714,75 @@
 //~ #define AIN_10_11_DifferentialUnipolar 	1
 //
 //--------------------
-// ADC Channels AIN10, AIN11 = Differential Bipolar
+// ADC Channels AIN10, AIN11 = Both Single-Ended, Unipolar
 // Full Scale = VREF
 // Voltage per LSB count = VREF/2048
-// AIN10, AIN11 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
+// AIN10 is a Single-Ended input using Unipolar transfer function.
+// AIN11 is a Single-Ended input using Unipolar transfer function.
+// If PDIFF_COM_1, both are Pseudo-Differential with REF- as common.
 // AIN10 voltage must always be between 0 and VREF.
 // AIN11 voltage must always be between 0 and VREF.
 //
-//~ #define AIN_10_11_DifferentialBipolarFSVref 	1
+//~ #define AIN_10_11_SingleEnded 	1
 //
 //--------------------
 //
 // Default settings if not defined at project level
 #ifndef AIN_10_11_DifferentialBipolarFS2Vref
-# ifndef AIN_10_11_SingleEnded
+# ifndef AIN_10_11_DifferentialBipolarFSVref
 #  ifndef AIN_10_11_DifferentialUnipolar
-#   ifndef AIN_10_11_DifferentialBipolarFSVref
+#   ifndef AIN_10_11_SingleEnded
 #    define AIN_10_11_DifferentialBipolarFS2Vref 	0
+#    define AIN_10_11_DifferentialBipolarFSVref 	0
+#    define AIN_10_11_DifferentialUnipolar 	0
 #    define AIN_10_11_SingleEnded 	1
-#    define AIN_10_11_DifferentialUnipolar 	0
-#    define AIN_10_11_DifferentialBipolarFSVref 	0
-#   endif // AIN_10_11_DifferentialBipolarFSVref
+#   endif // AIN_10_11_SingleEnded
 #  endif // AIN_10_11_DifferentialUnipolar
-# endif // AIN_10_11_SingleEnded
+# endif // AIN_10_11_DifferentialBipolarFSVref
 #endif // AIN_10_11_DifferentialBipolarFS2Vref
 //
 // (optional diagnostic) pragma message the active setting
 #if AIN_10_11_DifferentialBipolarFS2Vref
 //~ #  pragma message("AIN_10_11_DifferentialBipolarFS2Vref: ADC Channels AIN10, AIN11 = Differential Bipolar")
 #endif // AIN_10_11_DifferentialBipolarFS2Vref
+#if AIN_10_11_DifferentialBipolarFSVref
+//~ #  pragma message("AIN_10_11_DifferentialBipolarFSVref: ADC Channels AIN10, AIN11 = Differential Bipolar")
+#endif // AIN_10_11_DifferentialBipolarFSVref
+#if AIN_10_11_DifferentialUnipolar
+//~ #  pragma message("AIN_10_11_DifferentialUnipolar: ADC Channels AIN10, AIN11 = Differential Unipolar (AIN10 > AIN11)")
+#endif // AIN_10_11_DifferentialUnipolar
 #if AIN_10_11_SingleEnded
 //~ #  pragma message("AIN_10_11_SingleEnded: ADC Channels AIN10, AIN11 = Both Single-Ended, Unipolar")
 #endif // AIN_10_11_SingleEnded
-#if AIN_10_11_DifferentialUnipolar
-//~ #  pragma message("AIN_10_11_DifferentialUnipolar: ADC Channels AIN10, AIN11 = Differential Unipolar (AIN10 > AIN11)")
-#endif // AIN_10_11_DifferentialUnipolar
-#if AIN_10_11_DifferentialBipolarFSVref
-//~ #  pragma message("AIN_10_11_DifferentialBipolarFSVref: ADC Channels AIN10, AIN11 = Differential Bipolar")
-#endif // AIN_10_11_DifferentialBipolarFSVref
 //
 // Validate the AIN_10_11_DifferentialBipolarFS2Vref setting
 #if AIN_10_11_DifferentialBipolarFS2Vref
+# if AIN_10_11_DifferentialBipolarFSVref
+#  error("cannot have both AIN_10_11_DifferentialBipolarFS2Vref and AIN_10_11_DifferentialBipolarFSVref; choose one")
+# endif // AIN_10_11_DifferentialBipolarFSVref
+# if AIN_10_11_DifferentialUnipolar
+#  error("cannot have both AIN_10_11_DifferentialBipolarFS2Vref and AIN_10_11_DifferentialUnipolar; choose one")
+# endif // AIN_10_11_DifferentialUnipolar
 # if AIN_10_11_SingleEnded
 #  error("cannot have both AIN_10_11_DifferentialBipolarFS2Vref and AIN_10_11_SingleEnded; choose one")
 # endif // AIN_10_11_SingleEnded
-# if AIN_10_11_DifferentialUnipolar
-#  error("cannot have both AIN_10_11_DifferentialBipolarFS2Vref and AIN_10_11_DifferentialUnipolar; choose one")
-# endif // AIN_10_11_DifferentialUnipolar
-# if AIN_10_11_DifferentialBipolarFSVref
-#  error("cannot have both AIN_10_11_DifferentialBipolarFS2Vref and AIN_10_11_DifferentialBipolarFSVref; choose one")
-# endif // AIN_10_11_DifferentialBipolarFSVref
 #endif // AIN_10_11_DifferentialBipolarFS2Vref
 //
-// Validate the AIN_10_11_SingleEnded setting
-#if AIN_10_11_SingleEnded
+// Validate the AIN_10_11_DifferentialBipolarFSVref setting
+#if AIN_10_11_DifferentialBipolarFSVref
 # if AIN_10_11_DifferentialUnipolar
-#  error("cannot have both AIN_10_11_SingleEnded and AIN_10_11_DifferentialUnipolar; choose one")
+#  error("cannot have both AIN_10_11_DifferentialBipolarFSVref and AIN_10_11_DifferentialUnipolar; choose one")
 # endif // AIN_10_11_DifferentialUnipolar
-# if AIN_10_11_DifferentialBipolarFSVref
-#  error("cannot have both AIN_10_11_SingleEnded and AIN_10_11_DifferentialBipolarFSVref; choose one")
-# endif // AIN_10_11_DifferentialBipolarFSVref
-#endif // AIN_10_11_SingleEnded
+# if AIN_10_11_SingleEnded
+#  error("cannot have both AIN_10_11_DifferentialBipolarFSVref and AIN_10_11_SingleEnded; choose one")
+# endif // AIN_10_11_SingleEnded
+#endif // AIN_10_11_DifferentialBipolarFSVref
 //
 // Validate the AIN_10_11_DifferentialUnipolar setting
 #if AIN_10_11_DifferentialUnipolar
-# if AIN_10_11_DifferentialBipolarFSVref
-#  error("cannot have both AIN_10_11_DifferentialUnipolar and AIN_10_11_DifferentialBipolarFSVref; choose one")
-# endif // AIN_10_11_DifferentialBipolarFSVref
+# if AIN_10_11_SingleEnded
+#  error("cannot have both AIN_10_11_DifferentialUnipolar and AIN_10_11_SingleEnded; choose one")
+# endif // AIN_10_11_SingleEnded
 #endif // AIN_10_11_DifferentialUnipolar
 
 //----------------------------------------
@@ -800,16 +801,14 @@
 //~ #define AIN_12_13_DifferentialBipolarFS2Vref 	1
 //
 //--------------------
-// ADC Channels AIN12, AIN13 = Both Single-Ended, Unipolar
+// ADC Channels AIN12, AIN13 = Differential Bipolar
 // Full Scale = VREF
 // Voltage per LSB count = VREF/2048
-// AIN12 is a Single-Ended input using Unipolar transfer function.
-// AIN13 is a Single-Ended input using Unipolar transfer function.
-// If PDIFF_COM_1, both are Pseudo-Differential with REF- as common.
+// AIN12, AIN13 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
 // AIN12 voltage must always be between 0 and VREF.
 // AIN13 voltage must always be between 0 and VREF.
 //
-//~ #define AIN_12_13_SingleEnded 	1
+//~ #define AIN_12_13_DifferentialBipolarFSVref 	1
 //
 //--------------------
 // ADC Channels AIN12, AIN13 = Differential Unipolar (AIN12 > AIN13)
@@ -822,73 +821,75 @@
 //~ #define AIN_12_13_DifferentialUnipolar 	1
 //
 //--------------------
-// ADC Channels AIN12, AIN13 = Differential Bipolar
+// ADC Channels AIN12, AIN13 = Both Single-Ended, Unipolar
 // Full Scale = VREF
 // Voltage per LSB count = VREF/2048
-// AIN12, AIN13 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
+// AIN12 is a Single-Ended input using Unipolar transfer function.
+// AIN13 is a Single-Ended input using Unipolar transfer function.
+// If PDIFF_COM_1, both are Pseudo-Differential with REF- as common.
 // AIN12 voltage must always be between 0 and VREF.
 // AIN13 voltage must always be between 0 and VREF.
 //
-//~ #define AIN_12_13_DifferentialBipolarFSVref 	1
+//~ #define AIN_12_13_SingleEnded 	1
 //
 //--------------------
 //
 // Default settings if not defined at project level
 #ifndef AIN_12_13_DifferentialBipolarFS2Vref
-# ifndef AIN_12_13_SingleEnded
+# ifndef AIN_12_13_DifferentialBipolarFSVref
 #  ifndef AIN_12_13_DifferentialUnipolar
-#   ifndef AIN_12_13_DifferentialBipolarFSVref
+#   ifndef AIN_12_13_SingleEnded
 #    define AIN_12_13_DifferentialBipolarFS2Vref 	0
+#    define AIN_12_13_DifferentialBipolarFSVref 	0
+#    define AIN_12_13_DifferentialUnipolar 	0
 #    define AIN_12_13_SingleEnded 	1
-#    define AIN_12_13_DifferentialUnipolar 	0
-#    define AIN_12_13_DifferentialBipolarFSVref 	0
-#   endif // AIN_12_13_DifferentialBipolarFSVref
+#   endif // AIN_12_13_SingleEnded
 #  endif // AIN_12_13_DifferentialUnipolar
-# endif // AIN_12_13_SingleEnded
+# endif // AIN_12_13_DifferentialBipolarFSVref
 #endif // AIN_12_13_DifferentialBipolarFS2Vref
 //
 // (optional diagnostic) pragma message the active setting
 #if AIN_12_13_DifferentialBipolarFS2Vref
 //~ #  pragma message("AIN_12_13_DifferentialBipolarFS2Vref: ADC Channels AIN12, AIN13 = Differential Bipolar")
 #endif // AIN_12_13_DifferentialBipolarFS2Vref
+#if AIN_12_13_DifferentialBipolarFSVref
+//~ #  pragma message("AIN_12_13_DifferentialBipolarFSVref: ADC Channels AIN12, AIN13 = Differential Bipolar")
+#endif // AIN_12_13_DifferentialBipolarFSVref
+#if AIN_12_13_DifferentialUnipolar
+//~ #  pragma message("AIN_12_13_DifferentialUnipolar: ADC Channels AIN12, AIN13 = Differential Unipolar (AIN12 > AIN13)")
+#endif // AIN_12_13_DifferentialUnipolar
 #if AIN_12_13_SingleEnded
 //~ #  pragma message("AIN_12_13_SingleEnded: ADC Channels AIN12, AIN13 = Both Single-Ended, Unipolar")
 #endif // AIN_12_13_SingleEnded
-#if AIN_12_13_DifferentialUnipolar
-//~ #  pragma message("AIN_12_13_DifferentialUnipolar: ADC Channels AIN12, AIN13 = Differential Unipolar (AIN12 > AIN13)")
-#endif // AIN_12_13_DifferentialUnipolar
-#if AIN_12_13_DifferentialBipolarFSVref
-//~ #  pragma message("AIN_12_13_DifferentialBipolarFSVref: ADC Channels AIN12, AIN13 = Differential Bipolar")
-#endif // AIN_12_13_DifferentialBipolarFSVref
 //
 // Validate the AIN_12_13_DifferentialBipolarFS2Vref setting
 #if AIN_12_13_DifferentialBipolarFS2Vref
+# if AIN_12_13_DifferentialBipolarFSVref
+#  error("cannot have both AIN_12_13_DifferentialBipolarFS2Vref and AIN_12_13_DifferentialBipolarFSVref; choose one")
+# endif // AIN_12_13_DifferentialBipolarFSVref
+# if AIN_12_13_DifferentialUnipolar
+#  error("cannot have both AIN_12_13_DifferentialBipolarFS2Vref and AIN_12_13_DifferentialUnipolar; choose one")
+# endif // AIN_12_13_DifferentialUnipolar
 # if AIN_12_13_SingleEnded
 #  error("cannot have both AIN_12_13_DifferentialBipolarFS2Vref and AIN_12_13_SingleEnded; choose one")
 # endif // AIN_12_13_SingleEnded
-# if AIN_12_13_DifferentialUnipolar
-#  error("cannot have both AIN_12_13_DifferentialBipolarFS2Vref and AIN_12_13_DifferentialUnipolar; choose one")
-# endif // AIN_12_13_DifferentialUnipolar
-# if AIN_12_13_DifferentialBipolarFSVref
-#  error("cannot have both AIN_12_13_DifferentialBipolarFS2Vref and AIN_12_13_DifferentialBipolarFSVref; choose one")
-# endif // AIN_12_13_DifferentialBipolarFSVref
 #endif // AIN_12_13_DifferentialBipolarFS2Vref
 //
-// Validate the AIN_12_13_SingleEnded setting
-#if AIN_12_13_SingleEnded
+// Validate the AIN_12_13_DifferentialBipolarFSVref setting
+#if AIN_12_13_DifferentialBipolarFSVref
 # if AIN_12_13_DifferentialUnipolar
-#  error("cannot have both AIN_12_13_SingleEnded and AIN_12_13_DifferentialUnipolar; choose one")
+#  error("cannot have both AIN_12_13_DifferentialBipolarFSVref and AIN_12_13_DifferentialUnipolar; choose one")
 # endif // AIN_12_13_DifferentialUnipolar
-# if AIN_12_13_DifferentialBipolarFSVref
-#  error("cannot have both AIN_12_13_SingleEnded and AIN_12_13_DifferentialBipolarFSVref; choose one")
-# endif // AIN_12_13_DifferentialBipolarFSVref
-#endif // AIN_12_13_SingleEnded
+# if AIN_12_13_SingleEnded
+#  error("cannot have both AIN_12_13_DifferentialBipolarFSVref and AIN_12_13_SingleEnded; choose one")
+# endif // AIN_12_13_SingleEnded
+#endif // AIN_12_13_DifferentialBipolarFSVref
 //
 // Validate the AIN_12_13_DifferentialUnipolar setting
 #if AIN_12_13_DifferentialUnipolar
-# if AIN_12_13_DifferentialBipolarFSVref
-#  error("cannot have both AIN_12_13_DifferentialUnipolar and AIN_12_13_DifferentialBipolarFSVref; choose one")
-# endif // AIN_12_13_DifferentialBipolarFSVref
+# if AIN_12_13_SingleEnded
+#  error("cannot have both AIN_12_13_DifferentialUnipolar and AIN_12_13_SingleEnded; choose one")
+# endif // AIN_12_13_SingleEnded
 #endif // AIN_12_13_DifferentialUnipolar
 
 //----------------------------------------
@@ -907,16 +908,14 @@
 //~ #define AIN_14_15_DifferentialBipolarFS2Vref 	1
 //
 //--------------------
-// ADC Channels AIN14, AIN15 = Both Single-Ended, Unipolar
+// ADC Channels AIN14, AIN15 = Differential Bipolar
 // Full Scale = VREF
 // Voltage per LSB count = VREF/2048
-// AIN14 is a Single-Ended input using Unipolar transfer function.
-// AIN15 is a Single-Ended input using Unipolar transfer function.
-// If PDIFF_COM_1, both are Pseudo-Differential with REF- as common.
+// AIN14, AIN15 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
 // AIN14 voltage must always be between 0 and VREF.
 // AIN15 voltage must always be between 0 and VREF.
 //
-//~ #define AIN_14_15_SingleEnded 	1
+//~ #define AIN_14_15_DifferentialBipolarFSVref 	1
 //
 //--------------------
 // ADC Channels AIN14, AIN15 = Differential Unipolar (AIN14 > AIN15)
@@ -929,73 +928,75 @@
 //~ #define AIN_14_15_DifferentialUnipolar 	1
 //
 //--------------------
-// ADC Channels AIN14, AIN15 = Differential Bipolar
+// ADC Channels AIN14, AIN15 = Both Single-Ended, Unipolar
 // Full Scale = VREF
 // Voltage per LSB count = VREF/2048
-// AIN14, AIN15 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
+// AIN14 is a Single-Ended input using Unipolar transfer function.
+// AIN15 is a Single-Ended input using Unipolar transfer function.
+// If PDIFF_COM_1, both are Pseudo-Differential with REF- as common.
 // AIN14 voltage must always be between 0 and VREF.
 // AIN15 voltage must always be between 0 and VREF.
 //
-//~ #define AIN_14_15_DifferentialBipolarFSVref 	1
+//~ #define AIN_14_15_SingleEnded 	1
 //
 //--------------------
 //
 // Default settings if not defined at project level
 #ifndef AIN_14_15_DifferentialBipolarFS2Vref
-# ifndef AIN_14_15_SingleEnded
+# ifndef AIN_14_15_DifferentialBipolarFSVref
 #  ifndef AIN_14_15_DifferentialUnipolar
-#   ifndef AIN_14_15_DifferentialBipolarFSVref
+#   ifndef AIN_14_15_SingleEnded
 #    define AIN_14_15_DifferentialBipolarFS2Vref 	0
+#    define AIN_14_15_DifferentialBipolarFSVref 	0
+#    define AIN_14_15_DifferentialUnipolar 	0
 #    define AIN_14_15_SingleEnded 	1
-#    define AIN_14_15_DifferentialUnipolar 	0
-#    define AIN_14_15_DifferentialBipolarFSVref 	0
-#   endif // AIN_14_15_DifferentialBipolarFSVref
+#   endif // AIN_14_15_SingleEnded
 #  endif // AIN_14_15_DifferentialUnipolar
-# endif // AIN_14_15_SingleEnded
+# endif // AIN_14_15_DifferentialBipolarFSVref
 #endif // AIN_14_15_DifferentialBipolarFS2Vref
 //
 // (optional diagnostic) pragma message the active setting
 #if AIN_14_15_DifferentialBipolarFS2Vref
 //~ #  pragma message("AIN_14_15_DifferentialBipolarFS2Vref: ADC Channels AIN14, AIN15 = Differential Bipolar")
 #endif // AIN_14_15_DifferentialBipolarFS2Vref
+#if AIN_14_15_DifferentialBipolarFSVref
+//~ #  pragma message("AIN_14_15_DifferentialBipolarFSVref: ADC Channels AIN14, AIN15 = Differential Bipolar")
+#endif // AIN_14_15_DifferentialBipolarFSVref
+#if AIN_14_15_DifferentialUnipolar
+//~ #  pragma message("AIN_14_15_DifferentialUnipolar: ADC Channels AIN14, AIN15 = Differential Unipolar (AIN14 > AIN15)")
+#endif // AIN_14_15_DifferentialUnipolar
 #if AIN_14_15_SingleEnded
 //~ #  pragma message("AIN_14_15_SingleEnded: ADC Channels AIN14, AIN15 = Both Single-Ended, Unipolar")
 #endif // AIN_14_15_SingleEnded
-#if AIN_14_15_DifferentialUnipolar
-//~ #  pragma message("AIN_14_15_DifferentialUnipolar: ADC Channels AIN14, AIN15 = Differential Unipolar (AIN14 > AIN15)")
-#endif // AIN_14_15_DifferentialUnipolar
-#if AIN_14_15_DifferentialBipolarFSVref
-//~ #  pragma message("AIN_14_15_DifferentialBipolarFSVref: ADC Channels AIN14, AIN15 = Differential Bipolar")
-#endif // AIN_14_15_DifferentialBipolarFSVref
 //
 // Validate the AIN_14_15_DifferentialBipolarFS2Vref setting
 #if AIN_14_15_DifferentialBipolarFS2Vref
+# if AIN_14_15_DifferentialBipolarFSVref
+#  error("cannot have both AIN_14_15_DifferentialBipolarFS2Vref and AIN_14_15_DifferentialBipolarFSVref; choose one")
+# endif // AIN_14_15_DifferentialBipolarFSVref
+# if AIN_14_15_DifferentialUnipolar
+#  error("cannot have both AIN_14_15_DifferentialBipolarFS2Vref and AIN_14_15_DifferentialUnipolar; choose one")
+# endif // AIN_14_15_DifferentialUnipolar
 # if AIN_14_15_SingleEnded
 #  error("cannot have both AIN_14_15_DifferentialBipolarFS2Vref and AIN_14_15_SingleEnded; choose one")
 # endif // AIN_14_15_SingleEnded
-# if AIN_14_15_DifferentialUnipolar
-#  error("cannot have both AIN_14_15_DifferentialBipolarFS2Vref and AIN_14_15_DifferentialUnipolar; choose one")
-# endif // AIN_14_15_DifferentialUnipolar
-# if AIN_14_15_DifferentialBipolarFSVref
-#  error("cannot have both AIN_14_15_DifferentialBipolarFS2Vref and AIN_14_15_DifferentialBipolarFSVref; choose one")
-# endif // AIN_14_15_DifferentialBipolarFSVref
 #endif // AIN_14_15_DifferentialBipolarFS2Vref
 //
-// Validate the AIN_14_15_SingleEnded setting
-#if AIN_14_15_SingleEnded
+// Validate the AIN_14_15_DifferentialBipolarFSVref setting
+#if AIN_14_15_DifferentialBipolarFSVref
 # if AIN_14_15_DifferentialUnipolar
-#  error("cannot have both AIN_14_15_SingleEnded and AIN_14_15_DifferentialUnipolar; choose one")
+#  error("cannot have both AIN_14_15_DifferentialBipolarFSVref and AIN_14_15_DifferentialUnipolar; choose one")
 # endif // AIN_14_15_DifferentialUnipolar
-# if AIN_14_15_DifferentialBipolarFSVref
-#  error("cannot have both AIN_14_15_SingleEnded and AIN_14_15_DifferentialBipolarFSVref; choose one")
-# endif // AIN_14_15_DifferentialBipolarFSVref
-#endif // AIN_14_15_SingleEnded
+# if AIN_14_15_SingleEnded
+#  error("cannot have both AIN_14_15_DifferentialBipolarFSVref and AIN_14_15_SingleEnded; choose one")
+# endif // AIN_14_15_SingleEnded
+#endif // AIN_14_15_DifferentialBipolarFSVref
 //
 // Validate the AIN_14_15_DifferentialUnipolar setting
 #if AIN_14_15_DifferentialUnipolar
-# if AIN_14_15_DifferentialBipolarFSVref
-#  error("cannot have both AIN_14_15_DifferentialUnipolar and AIN_14_15_DifferentialBipolarFSVref; choose one")
-# endif // AIN_14_15_DifferentialBipolarFSVref
+# if AIN_14_15_SingleEnded
+#  error("cannot have both AIN_14_15_DifferentialUnipolar and AIN_14_15_SingleEnded; choose one")
+# endif // AIN_14_15_SingleEnded
 #endif // AIN_14_15_DifferentialUnipolar
 
 // CODE GENERATOR: class declaration and docstrings
@@ -1012,6 +1013,7 @@
  * @code
  * // CODE GENERATOR: example code includes
  * // example code includes
+ * // standard include for target platform
  * #include "mbed.h"
  * //#include "max32625.h"
  * #include "MAX11131.h"
@@ -1192,7 +1194,7 @@
     ~MAX11131();
 
     // CODE GENERATOR: spi_frequency setter declaration
-    // set SPI SCLK frequency
+    /// set SPI SCLK frequency
     void spi_frequency(int spi_sclk_Hz);
 
 //----------------------------------------