Maxim Integrated / MAX11131

Dependents:   MAX11131BOB_Tester MAX11131BOB_12bit_16ch_SampleSet_SPI_ADC MAX11131BOB_Serial_Tester

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MAX11131.h Source File

MAX11131.h

00001 // /*******************************************************************************
00002 // * Copyright (C) 2021 Maxim Integrated Products, Inc., All Rights Reserved.
00003 // *
00004 // * Permission is hereby granted, free of charge, to any person obtaining a
00005 // * copy of this software and associated documentation files (the "Software"),
00006 // * to deal in the Software without restriction, including without limitation
00007 // * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008 // * and/or sell copies of the Software, and to permit persons to whom the
00009 // * Software is furnished to do so, subject to the following conditions:
00010 // *
00011 // * The above copyright notice and this permission notice shall be included
00012 // * in all copies or substantial portions of the Software.
00013 // *
00014 // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00015 // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00016 // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00017 // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
00018 // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00019 // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00020 // * OTHER DEALINGS IN THE SOFTWARE.
00021 // *
00022 // * Except as contained in this notice, the name of Maxim Integrated
00023 // * Products, Inc. shall not be used except as stated in the Maxim Integrated
00024 // * Products, Inc. Branding Policy.
00025 // *
00026 // * The mere transfer of this software does not imply any licenses
00027 // * of trade secrets, proprietary technology, copyrights, patents,
00028 // * trademarks, maskwork rights, or any other form of intellectual
00029 // * property whatsoever. Maxim Integrated Products, Inc. retains all
00030 // * ownership rights.
00031 // *******************************************************************************
00032 // */
00033 // *********************************************************************
00034 // @file MAX11131.h
00035 // *********************************************************************
00036 // Header file
00037 // DO NOT EDIT; except areas designated "CUSTOMIZE". Automatically generated file.
00038 // generated by XMLSystemOfDevicesToMBED.py
00039 // System Name = ExampleSystem
00040 // System Description = Device driver example
00041 // Device Name = MAX11131
00042 // Device Description = 3Msps, Low-Power, Serial SPI 12-Bit, 16-Channel, Differential/Single-Ended Input, SAR ADC
00043 // Device DeviceBriefDescription = 12-bit 3Msps 16-ch ADC
00044 // Device Manufacturer = Maxim Integrated
00045 // Device PartNumber = MAX11131ATI+
00046 // Device RegValue_Width = DataWidth16bit_HL
00047 //
00048 // ADC MaxOutputDataRate = 3Msps
00049 // ADC NumChannels = 16
00050 // ADC ResolutionBits = 12
00051 //
00052 // SPI CS = ActiveLow
00053 // SPI FrameStart = CS
00054 // SPI CPOL = 1
00055 // SPI CPHA = 1
00056 // SPI MOSI and MISO Data are both stable on Rising edge of SCLK
00057 // SPI SCLK Idle High
00058 // SPI SCLKMaxMHz = 48
00059 // SPI SCLKMinMHz = 0.48
00060 //
00061 
00062 
00063 // Prevent multiple declaration
00064 #ifndef __MAX11131_H__
00065 #define __MAX11131_H__
00066 
00067 // standard include for target platform -- Platform_Include_Boilerplate
00068 #include "mbed.h"
00069 // Platforms:
00070 //   - MAX32625MBED
00071 //      - supports mbed-os-5.11, requires USBDevice library
00072 //      - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
00073 //      - remove max32630fthr library (if present)
00074 //      - remove MAX32620FTHR library (if present)
00075 //   - MAX32600MBED
00076 //      - Please note the last supported version is Mbed OS 6.3.
00077 //      - remove max32630fthr library (if present)
00078 //      - remove MAX32620FTHR library (if present)
00079 //      - Windows 10 note:  Don't connect HDK until you are ready to load new firmware into the board.
00080 //   - NUCLEO_F446RE
00081 //      - remove USBDevice library
00082 //      - remove max32630fthr library (if present)
00083 //      - remove MAX32620FTHR library (if present)
00084 //   - NUCLEO_F401RE
00085 //      - remove USBDevice library
00086 //      - remove max32630fthr library (if present)
00087 //      - remove MAX32620FTHR library (if present)
00088 //   - MAX32630FTHR
00089 //      - #include "max32630fthr.h"
00090 //      - add http://developer.mbed.org/teams/MaximIntegrated/code/max32630fthr/
00091 //      - remove MAX32620FTHR library (if present)
00092 //   - MAX32620FTHR
00093 //      - #include "MAX32620FTHR.h"
00094 //      - remove max32630fthr library (if present)
00095 //      - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
00096 //      - not tested yet
00097 //   - MAX32625PICO
00098 //      - #include "max32625pico.h"
00099 //      - add https://os.mbed.com/users/switches/code/max32625pico/
00100 //      - remove max32630fthr library (if present)
00101 //      - remove MAX32620FTHR library (if present)
00102 //      - not tested yet
00103 //      - see https://os.mbed.com/users/switches/code/max32625pico/
00104 //      - see https://os.mbed.com/users/switches/code/PICO_board_demo/
00105 //      - see https://os.mbed.com/users/switches/code/PICO_USB_I2C_SPI/
00106 //      - see https://os.mbed.com/users/switches/code/SerialInterface/
00107 //      - Note: To load the MAX32625PICO firmware, hold the button while
00108 //        connecting the USB cable, then copy firmware bin file 
00109 //        to the MAINTENANCE drive.
00110 //      - see https://os.mbed.com/platforms/MAX32625PICO/
00111 //      - see https://os.mbed.com/teams/MaximIntegrated/wiki/MAX32625PICO-Firmware-Updates
00112 //
00113 // end Platform_Include_Boilerplate
00114 
00115 //----------------------------------------
00116 // Global setting for all channels: ADC_CONFIGURATION.REFSEL
00117 //
00118 // CUSTOMIZE: select one of the following options
00119 // either by uncommenting in this file or define at the project level
00120 //--------------------
00121 // external single-ended reference
00122 //~ #define REFSEL_0    1
00123 //
00124 //--------------------
00125 // external differential reference (For the 16-channel chips: channel AIN15 is unavailable, the pin is assigned to REF-.)
00126 //~ #define REFSEL_1    1
00127 //
00128 //--------------------
00129 //
00130 // Default settings if not defined at project level
00131 #ifndef REFSEL_0
00132 # ifndef REFSEL_1
00133 #  define REFSEL_0  1
00134 #  define REFSEL_1  0
00135 # endif // REFSEL_1
00136 #endif // REFSEL_0
00137 //
00138 // (optional diagnostic) pragma message the active setting
00139 #if REFSEL_0
00140 //~ #  pragma message("REFSEL_0: external single-ended reference")
00141 #endif // REFSEL_0
00142 #if REFSEL_1
00143 //~ #  pragma message("REFSEL_1: external differential reference (For the 16-channel chips: channel AIN15 is unavailable, the pin is assigned to REF-.)")
00144 #endif // REFSEL_1
00145 //
00146 // Validate the REFSEL_0 setting
00147 #if REFSEL_0
00148 # if REFSEL_1
00149 #  error("cannot have both REFSEL_0 and REFSEL_1; choose one")
00150 # endif // REFSEL_1
00151 #endif // REFSEL_0
00152 
00153 //----------------------------------------
00154 // Global setting for all channels: UNIPOLAR.PDIFF_COMM
00155 //
00156 // CUSTOMIZE: select one of the following options
00157 // either by uncommenting in this file or define at the project level
00158 //--------------------
00159 // all single-ended channels use GND as common
00160 //~ #define PDIFF_COMM_0    1
00161 //
00162 //--------------------
00163 // all single-ended channels are pseudo-differential with REF- as common
00164 //~ #define PDIFF_COMM_1    1
00165 //
00166 //--------------------
00167 //
00168 // Default settings if not defined at project level
00169 #ifndef PDIFF_COMM_0
00170 # ifndef PDIFF_COMM_1
00171 #  define PDIFF_COMM_0  1
00172 #  define PDIFF_COMM_1  0
00173 # endif // PDIFF_COMM_1
00174 #endif // PDIFF_COMM_0
00175 //
00176 // (optional diagnostic) pragma message the active setting
00177 #if PDIFF_COMM_0
00178 //~ #  pragma message("PDIFF_COMM_0: all single-ended channels use GND as common")
00179 #endif // PDIFF_COMM_0
00180 #if PDIFF_COMM_1
00181 //~ #  pragma message("PDIFF_COMM_1: all single-ended channels are pseudo-differential with REF- as common")
00182 #endif // PDIFF_COMM_1
00183 //
00184 // Validate the PDIFF_COMM_0 setting
00185 #if PDIFF_COMM_0
00186 # if PDIFF_COMM_1
00187 #  error("cannot have both PDIFF_COMM_0 and PDIFF_COMM_1; choose one")
00188 # endif // PDIFF_COMM_1
00189 #endif // PDIFF_COMM_0
00190 
00191 //----------------------------------------
00192 // ADC Channels AIN0, AIN1
00193 //
00194 // CUSTOMIZE: select one of the following options
00195 // either by uncommenting in this file or define at the project level
00196 //--------------------
00197 // ADC Channels AIN0, AIN1 = Differential Bipolar
00198 // Full Scale = 2 * VREF
00199 // Voltage per LSB count = VREF/2048
00200 // AIN0, AIN1 are a Differential pair using Bipolar transfer function with range (+/-)Vref
00201 // AIN0 voltage must always be between 0 and VREF.
00202 // AIN1 voltage must always be between 0 and VREF.
00203 //
00204 //~ #define AIN_0_1_DifferentialBipolarFS2Vref  1
00205 //
00206 //--------------------
00207 // ADC Channels AIN0, AIN1 = Differential Bipolar
00208 // Full Scale = VREF
00209 // Voltage per LSB count = VREF/2048
00210 // AIN0, AIN1 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
00211 // AIN0 voltage must always be between 0 and VREF.
00212 // AIN1 voltage must always be between 0 and VREF.
00213 //
00214 //~ #define AIN_0_1_DifferentialBipolarFSVref   1
00215 //
00216 //--------------------
00217 // ADC Channels AIN0, AIN1 = Differential Unipolar (AIN0 > AIN1)
00218 // Full Scale = VREF
00219 // Voltage per LSB count = VREF/2048
00220 // AIN0, AIN1 are a Differential pair using Unipolar transfer function.
00221 // AIN0 voltage must always be between 0 and VREF.
00222 // AIN1 voltage must always be between 0 and VREF.
00223 //
00224 //~ #define AIN_0_1_DifferentialUnipolar    1
00225 //
00226 //--------------------
00227 // ADC Channels AIN0, AIN1 = Both Single-Ended, Unipolar
00228 // Full Scale = VREF
00229 // Voltage per LSB count = VREF/2048
00230 // AIN0 is a Single-Ended input using Unipolar transfer function.
00231 // AIN1 is a Single-Ended input using Unipolar transfer function.
00232 // If PDIFF_COM_1, both are Pseudo-Differential with REF- as common.
00233 // AIN0 voltage must always be between 0 and VREF.
00234 // AIN1 voltage must always be between 0 and VREF.
00235 //
00236 //~ #define AIN_0_1_SingleEnded     1
00237 //
00238 //--------------------
00239 //
00240 // Default settings if not defined at project level
00241 #ifndef AIN_0_1_DifferentialBipolarFS2Vref
00242 # ifndef AIN_0_1_DifferentialBipolarFSVref
00243 #  ifndef AIN_0_1_DifferentialUnipolar
00244 #   ifndef AIN_0_1_SingleEnded
00245 #    define AIN_0_1_DifferentialBipolarFS2Vref  0
00246 #    define AIN_0_1_DifferentialBipolarFSVref   0
00247 #    define AIN_0_1_DifferentialUnipolar    0
00248 #    define AIN_0_1_SingleEnded     1
00249 #   endif // AIN_0_1_SingleEnded
00250 #  endif // AIN_0_1_DifferentialUnipolar
00251 # endif // AIN_0_1_DifferentialBipolarFSVref
00252 #endif // AIN_0_1_DifferentialBipolarFS2Vref
00253 //
00254 // (optional diagnostic) pragma message the active setting
00255 #if AIN_0_1_DifferentialBipolarFS2Vref
00256 //~ #  pragma message("AIN_0_1_DifferentialBipolarFS2Vref: ADC Channels AIN0, AIN1 = Differential Bipolar")
00257 #endif // AIN_0_1_DifferentialBipolarFS2Vref
00258 #if AIN_0_1_DifferentialBipolarFSVref
00259 //~ #  pragma message("AIN_0_1_DifferentialBipolarFSVref: ADC Channels AIN0, AIN1 = Differential Bipolar")
00260 #endif // AIN_0_1_DifferentialBipolarFSVref
00261 #if AIN_0_1_DifferentialUnipolar
00262 //~ #  pragma message("AIN_0_1_DifferentialUnipolar: ADC Channels AIN0, AIN1 = Differential Unipolar (AIN0 > AIN1)")
00263 #endif // AIN_0_1_DifferentialUnipolar
00264 #if AIN_0_1_SingleEnded
00265 //~ #  pragma message("AIN_0_1_SingleEnded: ADC Channels AIN0, AIN1 = Both Single-Ended, Unipolar")
00266 #endif // AIN_0_1_SingleEnded
00267 //
00268 // Validate the AIN_0_1_DifferentialBipolarFS2Vref setting
00269 #if AIN_0_1_DifferentialBipolarFS2Vref
00270 # if AIN_0_1_DifferentialBipolarFSVref
00271 #  error("cannot have both AIN_0_1_DifferentialBipolarFS2Vref and AIN_0_1_DifferentialBipolarFSVref; choose one")
00272 # endif // AIN_0_1_DifferentialBipolarFSVref
00273 # if AIN_0_1_DifferentialUnipolar
00274 #  error("cannot have both AIN_0_1_DifferentialBipolarFS2Vref and AIN_0_1_DifferentialUnipolar; choose one")
00275 # endif // AIN_0_1_DifferentialUnipolar
00276 # if AIN_0_1_SingleEnded
00277 #  error("cannot have both AIN_0_1_DifferentialBipolarFS2Vref and AIN_0_1_SingleEnded; choose one")
00278 # endif // AIN_0_1_SingleEnded
00279 #endif // AIN_0_1_DifferentialBipolarFS2Vref
00280 //
00281 // Validate the AIN_0_1_DifferentialBipolarFSVref setting
00282 #if AIN_0_1_DifferentialBipolarFSVref
00283 # if AIN_0_1_DifferentialUnipolar
00284 #  error("cannot have both AIN_0_1_DifferentialBipolarFSVref and AIN_0_1_DifferentialUnipolar; choose one")
00285 # endif // AIN_0_1_DifferentialUnipolar
00286 # if AIN_0_1_SingleEnded
00287 #  error("cannot have both AIN_0_1_DifferentialBipolarFSVref and AIN_0_1_SingleEnded; choose one")
00288 # endif // AIN_0_1_SingleEnded
00289 #endif // AIN_0_1_DifferentialBipolarFSVref
00290 //
00291 // Validate the AIN_0_1_DifferentialUnipolar setting
00292 #if AIN_0_1_DifferentialUnipolar
00293 # if AIN_0_1_SingleEnded
00294 #  error("cannot have both AIN_0_1_DifferentialUnipolar and AIN_0_1_SingleEnded; choose one")
00295 # endif // AIN_0_1_SingleEnded
00296 #endif // AIN_0_1_DifferentialUnipolar
00297 
00298 //----------------------------------------
00299 // ADC Channels AIN2, AIN3
00300 //
00301 // CUSTOMIZE: select one of the following options
00302 // either by uncommenting in this file or define at the project level
00303 //--------------------
00304 // ADC Channels AIN2, AIN3 = Differential Bipolar
00305 // Full Scale = 2 * VREF
00306 // Voltage per LSB count = VREF/2048
00307 // AIN2, AIN3 are a Differential pair using Bipolar transfer function with range (+/-)Vref
00308 // AIN2 voltage must always be between 0 and VREF.
00309 // AIN3 voltage must always be between 0 and VREF.
00310 //
00311 //~ #define AIN_2_3_DifferentialBipolarFS2Vref  1
00312 //
00313 //--------------------
00314 // ADC Channels AIN2, AIN3 = Differential Bipolar
00315 // Full Scale = VREF
00316 // Voltage per LSB count = VREF/2048
00317 // AIN2, AIN3 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
00318 // AIN2 voltage must always be between 0 and VREF.
00319 // AIN3 voltage must always be between 0 and VREF.
00320 //
00321 //~ #define AIN_2_3_DifferentialBipolarFSVref   1
00322 //
00323 //--------------------
00324 // ADC Channels AIN2, AIN3 = Differential Unipolar (AIN2 > AIN3)
00325 // Full Scale = VREF
00326 // Voltage per LSB count = VREF/2048
00327 // AIN2, AIN3 are a Differential pair using Unipolar transfer function.
00328 // AIN2 voltage must always be between 0 and VREF.
00329 // AIN3 voltage must always be between 0 and VREF.
00330 //
00331 //~ #define AIN_2_3_DifferentialUnipolar    1
00332 //
00333 //--------------------
00334 // ADC Channels AIN2, AIN3 = Both Single-Ended, Unipolar
00335 // Full Scale = VREF
00336 // Voltage per LSB count = VREF/2048
00337 // AIN2 is a Single-Ended input using Unipolar transfer function.
00338 // AIN3 is a Single-Ended input using Unipolar transfer function.
00339 // If PDIFF_COM_1, both are Pseudo-Differential with REF- as common.
00340 // AIN2 voltage must always be between 0 and VREF.
00341 // AIN3 voltage must always be between 0 and VREF.
00342 //
00343 //~ #define AIN_2_3_SingleEnded     1
00344 //
00345 //--------------------
00346 //
00347 // Default settings if not defined at project level
00348 #ifndef AIN_2_3_DifferentialBipolarFS2Vref
00349 # ifndef AIN_2_3_DifferentialBipolarFSVref
00350 #  ifndef AIN_2_3_DifferentialUnipolar
00351 #   ifndef AIN_2_3_SingleEnded
00352 #    define AIN_2_3_DifferentialBipolarFS2Vref  0
00353 #    define AIN_2_3_DifferentialBipolarFSVref   0
00354 #    define AIN_2_3_DifferentialUnipolar    0
00355 #    define AIN_2_3_SingleEnded     1
00356 #   endif // AIN_2_3_SingleEnded
00357 #  endif // AIN_2_3_DifferentialUnipolar
00358 # endif // AIN_2_3_DifferentialBipolarFSVref
00359 #endif // AIN_2_3_DifferentialBipolarFS2Vref
00360 //
00361 // (optional diagnostic) pragma message the active setting
00362 #if AIN_2_3_DifferentialBipolarFS2Vref
00363 //~ #  pragma message("AIN_2_3_DifferentialBipolarFS2Vref: ADC Channels AIN2, AIN3 = Differential Bipolar")
00364 #endif // AIN_2_3_DifferentialBipolarFS2Vref
00365 #if AIN_2_3_DifferentialBipolarFSVref
00366 //~ #  pragma message("AIN_2_3_DifferentialBipolarFSVref: ADC Channels AIN2, AIN3 = Differential Bipolar")
00367 #endif // AIN_2_3_DifferentialBipolarFSVref
00368 #if AIN_2_3_DifferentialUnipolar
00369 //~ #  pragma message("AIN_2_3_DifferentialUnipolar: ADC Channels AIN2, AIN3 = Differential Unipolar (AIN2 > AIN3)")
00370 #endif // AIN_2_3_DifferentialUnipolar
00371 #if AIN_2_3_SingleEnded
00372 //~ #  pragma message("AIN_2_3_SingleEnded: ADC Channels AIN2, AIN3 = Both Single-Ended, Unipolar")
00373 #endif // AIN_2_3_SingleEnded
00374 //
00375 // Validate the AIN_2_3_DifferentialBipolarFS2Vref setting
00376 #if AIN_2_3_DifferentialBipolarFS2Vref
00377 # if AIN_2_3_DifferentialBipolarFSVref
00378 #  error("cannot have both AIN_2_3_DifferentialBipolarFS2Vref and AIN_2_3_DifferentialBipolarFSVref; choose one")
00379 # endif // AIN_2_3_DifferentialBipolarFSVref
00380 # if AIN_2_3_DifferentialUnipolar
00381 #  error("cannot have both AIN_2_3_DifferentialBipolarFS2Vref and AIN_2_3_DifferentialUnipolar; choose one")
00382 # endif // AIN_2_3_DifferentialUnipolar
00383 # if AIN_2_3_SingleEnded
00384 #  error("cannot have both AIN_2_3_DifferentialBipolarFS2Vref and AIN_2_3_SingleEnded; choose one")
00385 # endif // AIN_2_3_SingleEnded
00386 #endif // AIN_2_3_DifferentialBipolarFS2Vref
00387 //
00388 // Validate the AIN_2_3_DifferentialBipolarFSVref setting
00389 #if AIN_2_3_DifferentialBipolarFSVref
00390 # if AIN_2_3_DifferentialUnipolar
00391 #  error("cannot have both AIN_2_3_DifferentialBipolarFSVref and AIN_2_3_DifferentialUnipolar; choose one")
00392 # endif // AIN_2_3_DifferentialUnipolar
00393 # if AIN_2_3_SingleEnded
00394 #  error("cannot have both AIN_2_3_DifferentialBipolarFSVref and AIN_2_3_SingleEnded; choose one")
00395 # endif // AIN_2_3_SingleEnded
00396 #endif // AIN_2_3_DifferentialBipolarFSVref
00397 //
00398 // Validate the AIN_2_3_DifferentialUnipolar setting
00399 #if AIN_2_3_DifferentialUnipolar
00400 # if AIN_2_3_SingleEnded
00401 #  error("cannot have both AIN_2_3_DifferentialUnipolar and AIN_2_3_SingleEnded; choose one")
00402 # endif // AIN_2_3_SingleEnded
00403 #endif // AIN_2_3_DifferentialUnipolar
00404 
00405 //----------------------------------------
00406 // ADC Channels AIN4, AIN5
00407 //
00408 // CUSTOMIZE: select one of the following options
00409 // either by uncommenting in this file or define at the project level
00410 //--------------------
00411 // ADC Channels AIN4, AIN5 = Differential Bipolar
00412 // Full Scale = 2 * VREF
00413 // Voltage per LSB count = VREF/2048
00414 // AIN4, AIN5 are a Differential pair using Bipolar transfer function with range (+/-)Vref
00415 // AIN4 voltage must always be between 0 and VREF.
00416 // AIN5 voltage must always be between 0 and VREF.
00417 //
00418 //~ #define AIN_4_5_DifferentialBipolarFS2Vref  1
00419 //
00420 //--------------------
00421 // ADC Channels AIN4, AIN5 = Differential Bipolar
00422 // Full Scale = VREF
00423 // Voltage per LSB count = VREF/2048
00424 // AIN4, AIN5 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
00425 // AIN4 voltage must always be between 0 and VREF.
00426 // AIN5 voltage must always be between 0 and VREF.
00427 //
00428 //~ #define AIN_4_5_DifferentialBipolarFSVref   1
00429 //
00430 //--------------------
00431 // ADC Channels AIN4, AIN5 = Differential Unipolar (AIN4 > AIN5)
00432 // Full Scale = VREF
00433 // Voltage per LSB count = VREF/2048
00434 // AIN4, AIN5 are a Differential pair using Unipolar transfer function.
00435 // AIN4 voltage must always be between 0 and VREF.
00436 // AIN5 voltage must always be between 0 and VREF.
00437 //
00438 //~ #define AIN_4_5_DifferentialUnipolar    1
00439 //
00440 //--------------------
00441 // ADC Channels AIN4, AIN5 = Both Single-Ended, Unipolar
00442 // Full Scale = VREF
00443 // Voltage per LSB count = VREF/2048
00444 // AIN4 is a Single-Ended input using Unipolar transfer function.
00445 // AIN5 is a Single-Ended input using Unipolar transfer function.
00446 // If PDIFF_COM_1, both are Pseudo-Differential with REF- as common.
00447 // AIN4 voltage must always be between 0 and VREF.
00448 // AIN5 voltage must always be between 0 and VREF.
00449 //
00450 //~ #define AIN_4_5_SingleEnded     1
00451 //
00452 //--------------------
00453 //
00454 // Default settings if not defined at project level
00455 #ifndef AIN_4_5_DifferentialBipolarFS2Vref
00456 # ifndef AIN_4_5_DifferentialBipolarFSVref
00457 #  ifndef AIN_4_5_DifferentialUnipolar
00458 #   ifndef AIN_4_5_SingleEnded
00459 #    define AIN_4_5_DifferentialBipolarFS2Vref  0
00460 #    define AIN_4_5_DifferentialBipolarFSVref   0
00461 #    define AIN_4_5_DifferentialUnipolar    0
00462 #    define AIN_4_5_SingleEnded     1
00463 #   endif // AIN_4_5_SingleEnded
00464 #  endif // AIN_4_5_DifferentialUnipolar
00465 # endif // AIN_4_5_DifferentialBipolarFSVref
00466 #endif // AIN_4_5_DifferentialBipolarFS2Vref
00467 //
00468 // (optional diagnostic) pragma message the active setting
00469 #if AIN_4_5_DifferentialBipolarFS2Vref
00470 //~ #  pragma message("AIN_4_5_DifferentialBipolarFS2Vref: ADC Channels AIN4, AIN5 = Differential Bipolar")
00471 #endif // AIN_4_5_DifferentialBipolarFS2Vref
00472 #if AIN_4_5_DifferentialBipolarFSVref
00473 //~ #  pragma message("AIN_4_5_DifferentialBipolarFSVref: ADC Channels AIN4, AIN5 = Differential Bipolar")
00474 #endif // AIN_4_5_DifferentialBipolarFSVref
00475 #if AIN_4_5_DifferentialUnipolar
00476 //~ #  pragma message("AIN_4_5_DifferentialUnipolar: ADC Channels AIN4, AIN5 = Differential Unipolar (AIN4 > AIN5)")
00477 #endif // AIN_4_5_DifferentialUnipolar
00478 #if AIN_4_5_SingleEnded
00479 //~ #  pragma message("AIN_4_5_SingleEnded: ADC Channels AIN4, AIN5 = Both Single-Ended, Unipolar")
00480 #endif // AIN_4_5_SingleEnded
00481 //
00482 // Validate the AIN_4_5_DifferentialBipolarFS2Vref setting
00483 #if AIN_4_5_DifferentialBipolarFS2Vref
00484 # if AIN_4_5_DifferentialBipolarFSVref
00485 #  error("cannot have both AIN_4_5_DifferentialBipolarFS2Vref and AIN_4_5_DifferentialBipolarFSVref; choose one")
00486 # endif // AIN_4_5_DifferentialBipolarFSVref
00487 # if AIN_4_5_DifferentialUnipolar
00488 #  error("cannot have both AIN_4_5_DifferentialBipolarFS2Vref and AIN_4_5_DifferentialUnipolar; choose one")
00489 # endif // AIN_4_5_DifferentialUnipolar
00490 # if AIN_4_5_SingleEnded
00491 #  error("cannot have both AIN_4_5_DifferentialBipolarFS2Vref and AIN_4_5_SingleEnded; choose one")
00492 # endif // AIN_4_5_SingleEnded
00493 #endif // AIN_4_5_DifferentialBipolarFS2Vref
00494 //
00495 // Validate the AIN_4_5_DifferentialBipolarFSVref setting
00496 #if AIN_4_5_DifferentialBipolarFSVref
00497 # if AIN_4_5_DifferentialUnipolar
00498 #  error("cannot have both AIN_4_5_DifferentialBipolarFSVref and AIN_4_5_DifferentialUnipolar; choose one")
00499 # endif // AIN_4_5_DifferentialUnipolar
00500 # if AIN_4_5_SingleEnded
00501 #  error("cannot have both AIN_4_5_DifferentialBipolarFSVref and AIN_4_5_SingleEnded; choose one")
00502 # endif // AIN_4_5_SingleEnded
00503 #endif // AIN_4_5_DifferentialBipolarFSVref
00504 //
00505 // Validate the AIN_4_5_DifferentialUnipolar setting
00506 #if AIN_4_5_DifferentialUnipolar
00507 # if AIN_4_5_SingleEnded
00508 #  error("cannot have both AIN_4_5_DifferentialUnipolar and AIN_4_5_SingleEnded; choose one")
00509 # endif // AIN_4_5_SingleEnded
00510 #endif // AIN_4_5_DifferentialUnipolar
00511 
00512 //----------------------------------------
00513 // ADC Channels AIN6, AIN7
00514 //
00515 // CUSTOMIZE: select one of the following options
00516 // either by uncommenting in this file or define at the project level
00517 //--------------------
00518 // ADC Channels AIN6, AIN7 = Differential Bipolar
00519 // Full Scale = 2 * VREF
00520 // Voltage per LSB count = VREF/2048
00521 // AIN6, AIN7 are a Differential pair using Bipolar transfer function with range (+/-)Vref
00522 // AIN6 voltage must always be between 0 and VREF.
00523 // AIN7 voltage must always be between 0 and VREF.
00524 //
00525 //~ #define AIN_6_7_DifferentialBipolarFS2Vref  1
00526 //
00527 //--------------------
00528 // ADC Channels AIN6, AIN7 = Differential Bipolar
00529 // Full Scale = VREF
00530 // Voltage per LSB count = VREF/2048
00531 // AIN6, AIN7 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
00532 // AIN6 voltage must always be between 0 and VREF.
00533 // AIN7 voltage must always be between 0 and VREF.
00534 //
00535 //~ #define AIN_6_7_DifferentialBipolarFSVref   1
00536 //
00537 //--------------------
00538 // ADC Channels AIN6, AIN7 = Differential Unipolar (AIN6 > AIN7)
00539 // Full Scale = VREF
00540 // Voltage per LSB count = VREF/2048
00541 // AIN6, AIN7 are a Differential pair using Unipolar transfer function.
00542 // AIN6 voltage must always be between 0 and VREF.
00543 // AIN7 voltage must always be between 0 and VREF.
00544 //
00545 //~ #define AIN_6_7_DifferentialUnipolar    1
00546 //
00547 //--------------------
00548 // ADC Channels AIN6, AIN7 = Both Single-Ended, Unipolar
00549 // Full Scale = VREF
00550 // Voltage per LSB count = VREF/2048
00551 // AIN6 is a Single-Ended input using Unipolar transfer function.
00552 // AIN7 is a Single-Ended input using Unipolar transfer function.
00553 // If PDIFF_COM_1, both are Pseudo-Differential with REF- as common.
00554 // AIN6 voltage must always be between 0 and VREF.
00555 // AIN7 voltage must always be between 0 and VREF.
00556 //
00557 //~ #define AIN_6_7_SingleEnded     1
00558 //
00559 //--------------------
00560 //
00561 // Default settings if not defined at project level
00562 #ifndef AIN_6_7_DifferentialBipolarFS2Vref
00563 # ifndef AIN_6_7_DifferentialBipolarFSVref
00564 #  ifndef AIN_6_7_DifferentialUnipolar
00565 #   ifndef AIN_6_7_SingleEnded
00566 #    define AIN_6_7_DifferentialBipolarFS2Vref  0
00567 #    define AIN_6_7_DifferentialBipolarFSVref   0
00568 #    define AIN_6_7_DifferentialUnipolar    0
00569 #    define AIN_6_7_SingleEnded     1
00570 #   endif // AIN_6_7_SingleEnded
00571 #  endif // AIN_6_7_DifferentialUnipolar
00572 # endif // AIN_6_7_DifferentialBipolarFSVref
00573 #endif // AIN_6_7_DifferentialBipolarFS2Vref
00574 //
00575 // (optional diagnostic) pragma message the active setting
00576 #if AIN_6_7_DifferentialBipolarFS2Vref
00577 //~ #  pragma message("AIN_6_7_DifferentialBipolarFS2Vref: ADC Channels AIN6, AIN7 = Differential Bipolar")
00578 #endif // AIN_6_7_DifferentialBipolarFS2Vref
00579 #if AIN_6_7_DifferentialBipolarFSVref
00580 //~ #  pragma message("AIN_6_7_DifferentialBipolarFSVref: ADC Channels AIN6, AIN7 = Differential Bipolar")
00581 #endif // AIN_6_7_DifferentialBipolarFSVref
00582 #if AIN_6_7_DifferentialUnipolar
00583 //~ #  pragma message("AIN_6_7_DifferentialUnipolar: ADC Channels AIN6, AIN7 = Differential Unipolar (AIN6 > AIN7)")
00584 #endif // AIN_6_7_DifferentialUnipolar
00585 #if AIN_6_7_SingleEnded
00586 //~ #  pragma message("AIN_6_7_SingleEnded: ADC Channels AIN6, AIN7 = Both Single-Ended, Unipolar")
00587 #endif // AIN_6_7_SingleEnded
00588 //
00589 // Validate the AIN_6_7_DifferentialBipolarFS2Vref setting
00590 #if AIN_6_7_DifferentialBipolarFS2Vref
00591 # if AIN_6_7_DifferentialBipolarFSVref
00592 #  error("cannot have both AIN_6_7_DifferentialBipolarFS2Vref and AIN_6_7_DifferentialBipolarFSVref; choose one")
00593 # endif // AIN_6_7_DifferentialBipolarFSVref
00594 # if AIN_6_7_DifferentialUnipolar
00595 #  error("cannot have both AIN_6_7_DifferentialBipolarFS2Vref and AIN_6_7_DifferentialUnipolar; choose one")
00596 # endif // AIN_6_7_DifferentialUnipolar
00597 # if AIN_6_7_SingleEnded
00598 #  error("cannot have both AIN_6_7_DifferentialBipolarFS2Vref and AIN_6_7_SingleEnded; choose one")
00599 # endif // AIN_6_7_SingleEnded
00600 #endif // AIN_6_7_DifferentialBipolarFS2Vref
00601 //
00602 // Validate the AIN_6_7_DifferentialBipolarFSVref setting
00603 #if AIN_6_7_DifferentialBipolarFSVref
00604 # if AIN_6_7_DifferentialUnipolar
00605 #  error("cannot have both AIN_6_7_DifferentialBipolarFSVref and AIN_6_7_DifferentialUnipolar; choose one")
00606 # endif // AIN_6_7_DifferentialUnipolar
00607 # if AIN_6_7_SingleEnded
00608 #  error("cannot have both AIN_6_7_DifferentialBipolarFSVref and AIN_6_7_SingleEnded; choose one")
00609 # endif // AIN_6_7_SingleEnded
00610 #endif // AIN_6_7_DifferentialBipolarFSVref
00611 //
00612 // Validate the AIN_6_7_DifferentialUnipolar setting
00613 #if AIN_6_7_DifferentialUnipolar
00614 # if AIN_6_7_SingleEnded
00615 #  error("cannot have both AIN_6_7_DifferentialUnipolar and AIN_6_7_SingleEnded; choose one")
00616 # endif // AIN_6_7_SingleEnded
00617 #endif // AIN_6_7_DifferentialUnipolar
00618 
00619 //----------------------------------------
00620 // ADC Channels AIN8, AIN9
00621 //
00622 // CUSTOMIZE: select one of the following options
00623 // either by uncommenting in this file or define at the project level
00624 //--------------------
00625 // ADC Channels AIN8, AIN9 = Differential Bipolar
00626 // Full Scale = 2 * VREF
00627 // Voltage per LSB count = VREF/2048
00628 // AIN8, AIN9 are a Differential pair using Bipolar transfer function with range (+/-)Vref
00629 // AIN8 voltage must always be between 0 and VREF.
00630 // AIN9 voltage must always be between 0 and VREF.
00631 //
00632 //~ #define AIN_8_9_DifferentialBipolarFS2Vref  1
00633 //
00634 //--------------------
00635 // ADC Channels AIN8, AIN9 = Differential Bipolar
00636 // Full Scale = VREF
00637 // Voltage per LSB count = VREF/2048
00638 // AIN8, AIN9 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
00639 // AIN8 voltage must always be between 0 and VREF.
00640 // AIN9 voltage must always be between 0 and VREF.
00641 //
00642 //~ #define AIN_8_9_DifferentialBipolarFSVref   1
00643 //
00644 //--------------------
00645 // ADC Channels AIN8, AIN9 = Differential Unipolar (AIN8 > AIN9)
00646 // Full Scale = VREF
00647 // Voltage per LSB count = VREF/2048
00648 // AIN8, AIN9 are a Differential pair using Unipolar transfer function.
00649 // AIN8 voltage must always be between 0 and VREF.
00650 // AIN9 voltage must always be between 0 and VREF.
00651 //
00652 //~ #define AIN_8_9_DifferentialUnipolar    1
00653 //
00654 //--------------------
00655 // ADC Channels AIN8, AIN9 = Both Single-Ended, Unipolar
00656 // Full Scale = VREF
00657 // Voltage per LSB count = VREF/2048
00658 // AIN8 is a Single-Ended input using Unipolar transfer function.
00659 // AIN9 is a Single-Ended input using Unipolar transfer function.
00660 // If PDIFF_COM_1, both are Pseudo-Differential with REF- as common.
00661 // AIN8 voltage must always be between 0 and VREF.
00662 // AIN9 voltage must always be between 0 and VREF.
00663 //
00664 //~ #define AIN_8_9_SingleEnded     1
00665 //
00666 //--------------------
00667 //
00668 // Default settings if not defined at project level
00669 #ifndef AIN_8_9_DifferentialBipolarFS2Vref
00670 # ifndef AIN_8_9_DifferentialBipolarFSVref
00671 #  ifndef AIN_8_9_DifferentialUnipolar
00672 #   ifndef AIN_8_9_SingleEnded
00673 #    define AIN_8_9_DifferentialBipolarFS2Vref  0
00674 #    define AIN_8_9_DifferentialBipolarFSVref   0
00675 #    define AIN_8_9_DifferentialUnipolar    0
00676 #    define AIN_8_9_SingleEnded     1
00677 #   endif // AIN_8_9_SingleEnded
00678 #  endif // AIN_8_9_DifferentialUnipolar
00679 # endif // AIN_8_9_DifferentialBipolarFSVref
00680 #endif // AIN_8_9_DifferentialBipolarFS2Vref
00681 //
00682 // (optional diagnostic) pragma message the active setting
00683 #if AIN_8_9_DifferentialBipolarFS2Vref
00684 //~ #  pragma message("AIN_8_9_DifferentialBipolarFS2Vref: ADC Channels AIN8, AIN9 = Differential Bipolar")
00685 #endif // AIN_8_9_DifferentialBipolarFS2Vref
00686 #if AIN_8_9_DifferentialBipolarFSVref
00687 //~ #  pragma message("AIN_8_9_DifferentialBipolarFSVref: ADC Channels AIN8, AIN9 = Differential Bipolar")
00688 #endif // AIN_8_9_DifferentialBipolarFSVref
00689 #if AIN_8_9_DifferentialUnipolar
00690 //~ #  pragma message("AIN_8_9_DifferentialUnipolar: ADC Channels AIN8, AIN9 = Differential Unipolar (AIN8 > AIN9)")
00691 #endif // AIN_8_9_DifferentialUnipolar
00692 #if AIN_8_9_SingleEnded
00693 //~ #  pragma message("AIN_8_9_SingleEnded: ADC Channels AIN8, AIN9 = Both Single-Ended, Unipolar")
00694 #endif // AIN_8_9_SingleEnded
00695 //
00696 // Validate the AIN_8_9_DifferentialBipolarFS2Vref setting
00697 #if AIN_8_9_DifferentialBipolarFS2Vref
00698 # if AIN_8_9_DifferentialBipolarFSVref
00699 #  error("cannot have both AIN_8_9_DifferentialBipolarFS2Vref and AIN_8_9_DifferentialBipolarFSVref; choose one")
00700 # endif // AIN_8_9_DifferentialBipolarFSVref
00701 # if AIN_8_9_DifferentialUnipolar
00702 #  error("cannot have both AIN_8_9_DifferentialBipolarFS2Vref and AIN_8_9_DifferentialUnipolar; choose one")
00703 # endif // AIN_8_9_DifferentialUnipolar
00704 # if AIN_8_9_SingleEnded
00705 #  error("cannot have both AIN_8_9_DifferentialBipolarFS2Vref and AIN_8_9_SingleEnded; choose one")
00706 # endif // AIN_8_9_SingleEnded
00707 #endif // AIN_8_9_DifferentialBipolarFS2Vref
00708 //
00709 // Validate the AIN_8_9_DifferentialBipolarFSVref setting
00710 #if AIN_8_9_DifferentialBipolarFSVref
00711 # if AIN_8_9_DifferentialUnipolar
00712 #  error("cannot have both AIN_8_9_DifferentialBipolarFSVref and AIN_8_9_DifferentialUnipolar; choose one")
00713 # endif // AIN_8_9_DifferentialUnipolar
00714 # if AIN_8_9_SingleEnded
00715 #  error("cannot have both AIN_8_9_DifferentialBipolarFSVref and AIN_8_9_SingleEnded; choose one")
00716 # endif // AIN_8_9_SingleEnded
00717 #endif // AIN_8_9_DifferentialBipolarFSVref
00718 //
00719 // Validate the AIN_8_9_DifferentialUnipolar setting
00720 #if AIN_8_9_DifferentialUnipolar
00721 # if AIN_8_9_SingleEnded
00722 #  error("cannot have both AIN_8_9_DifferentialUnipolar and AIN_8_9_SingleEnded; choose one")
00723 # endif // AIN_8_9_SingleEnded
00724 #endif // AIN_8_9_DifferentialUnipolar
00725 
00726 //----------------------------------------
00727 // ADC Channels AIN10, AIN11
00728 //
00729 // CUSTOMIZE: select one of the following options
00730 // either by uncommenting in this file or define at the project level
00731 //--------------------
00732 // ADC Channels AIN10, AIN11 = Differential Bipolar
00733 // Full Scale = 2 * VREF
00734 // Voltage per LSB count = VREF/2048
00735 // AIN10, AIN11 are a Differential pair using Bipolar transfer function with range (+/-)Vref
00736 // AIN10 voltage must always be between 0 and VREF.
00737 // AIN11 voltage must always be between 0 and VREF.
00738 //
00739 //~ #define AIN_10_11_DifferentialBipolarFS2Vref    1
00740 //
00741 //--------------------
00742 // ADC Channels AIN10, AIN11 = Differential Bipolar
00743 // Full Scale = VREF
00744 // Voltage per LSB count = VREF/2048
00745 // AIN10, AIN11 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
00746 // AIN10 voltage must always be between 0 and VREF.
00747 // AIN11 voltage must always be between 0 and VREF.
00748 //
00749 //~ #define AIN_10_11_DifferentialBipolarFSVref     1
00750 //
00751 //--------------------
00752 // ADC Channels AIN10, AIN11 = Differential Unipolar (AIN10 > AIN11)
00753 // Full Scale = VREF
00754 // Voltage per LSB count = VREF/2048
00755 // AIN10, AIN11 are a Differential pair using Unipolar transfer function.
00756 // AIN10 voltage must always be between 0 and VREF.
00757 // AIN11 voltage must always be between 0 and VREF.
00758 //
00759 //~ #define AIN_10_11_DifferentialUnipolar  1
00760 //
00761 //--------------------
00762 // ADC Channels AIN10, AIN11 = Both Single-Ended, Unipolar
00763 // Full Scale = VREF
00764 // Voltage per LSB count = VREF/2048
00765 // AIN10 is a Single-Ended input using Unipolar transfer function.
00766 // AIN11 is a Single-Ended input using Unipolar transfer function.
00767 // If PDIFF_COM_1, both are Pseudo-Differential with REF- as common.
00768 // AIN10 voltage must always be between 0 and VREF.
00769 // AIN11 voltage must always be between 0 and VREF.
00770 //
00771 //~ #define AIN_10_11_SingleEnded   1
00772 //
00773 //--------------------
00774 //
00775 // Default settings if not defined at project level
00776 #ifndef AIN_10_11_DifferentialBipolarFS2Vref
00777 # ifndef AIN_10_11_DifferentialBipolarFSVref
00778 #  ifndef AIN_10_11_DifferentialUnipolar
00779 #   ifndef AIN_10_11_SingleEnded
00780 #    define AIN_10_11_DifferentialBipolarFS2Vref    0
00781 #    define AIN_10_11_DifferentialBipolarFSVref     0
00782 #    define AIN_10_11_DifferentialUnipolar  0
00783 #    define AIN_10_11_SingleEnded   1
00784 #   endif // AIN_10_11_SingleEnded
00785 #  endif // AIN_10_11_DifferentialUnipolar
00786 # endif // AIN_10_11_DifferentialBipolarFSVref
00787 #endif // AIN_10_11_DifferentialBipolarFS2Vref
00788 //
00789 // (optional diagnostic) pragma message the active setting
00790 #if AIN_10_11_DifferentialBipolarFS2Vref
00791 //~ #  pragma message("AIN_10_11_DifferentialBipolarFS2Vref: ADC Channels AIN10, AIN11 = Differential Bipolar")
00792 #endif // AIN_10_11_DifferentialBipolarFS2Vref
00793 #if AIN_10_11_DifferentialBipolarFSVref
00794 //~ #  pragma message("AIN_10_11_DifferentialBipolarFSVref: ADC Channels AIN10, AIN11 = Differential Bipolar")
00795 #endif // AIN_10_11_DifferentialBipolarFSVref
00796 #if AIN_10_11_DifferentialUnipolar
00797 //~ #  pragma message("AIN_10_11_DifferentialUnipolar: ADC Channels AIN10, AIN11 = Differential Unipolar (AIN10 > AIN11)")
00798 #endif // AIN_10_11_DifferentialUnipolar
00799 #if AIN_10_11_SingleEnded
00800 //~ #  pragma message("AIN_10_11_SingleEnded: ADC Channels AIN10, AIN11 = Both Single-Ended, Unipolar")
00801 #endif // AIN_10_11_SingleEnded
00802 //
00803 // Validate the AIN_10_11_DifferentialBipolarFS2Vref setting
00804 #if AIN_10_11_DifferentialBipolarFS2Vref
00805 # if AIN_10_11_DifferentialBipolarFSVref
00806 #  error("cannot have both AIN_10_11_DifferentialBipolarFS2Vref and AIN_10_11_DifferentialBipolarFSVref; choose one")
00807 # endif // AIN_10_11_DifferentialBipolarFSVref
00808 # if AIN_10_11_DifferentialUnipolar
00809 #  error("cannot have both AIN_10_11_DifferentialBipolarFS2Vref and AIN_10_11_DifferentialUnipolar; choose one")
00810 # endif // AIN_10_11_DifferentialUnipolar
00811 # if AIN_10_11_SingleEnded
00812 #  error("cannot have both AIN_10_11_DifferentialBipolarFS2Vref and AIN_10_11_SingleEnded; choose one")
00813 # endif // AIN_10_11_SingleEnded
00814 #endif // AIN_10_11_DifferentialBipolarFS2Vref
00815 //
00816 // Validate the AIN_10_11_DifferentialBipolarFSVref setting
00817 #if AIN_10_11_DifferentialBipolarFSVref
00818 # if AIN_10_11_DifferentialUnipolar
00819 #  error("cannot have both AIN_10_11_DifferentialBipolarFSVref and AIN_10_11_DifferentialUnipolar; choose one")
00820 # endif // AIN_10_11_DifferentialUnipolar
00821 # if AIN_10_11_SingleEnded
00822 #  error("cannot have both AIN_10_11_DifferentialBipolarFSVref and AIN_10_11_SingleEnded; choose one")
00823 # endif // AIN_10_11_SingleEnded
00824 #endif // AIN_10_11_DifferentialBipolarFSVref
00825 //
00826 // Validate the AIN_10_11_DifferentialUnipolar setting
00827 #if AIN_10_11_DifferentialUnipolar
00828 # if AIN_10_11_SingleEnded
00829 #  error("cannot have both AIN_10_11_DifferentialUnipolar and AIN_10_11_SingleEnded; choose one")
00830 # endif // AIN_10_11_SingleEnded
00831 #endif // AIN_10_11_DifferentialUnipolar
00832 
00833 //----------------------------------------
00834 // ADC Channels AIN12, AIN13
00835 //
00836 // CUSTOMIZE: select one of the following options
00837 // either by uncommenting in this file or define at the project level
00838 //--------------------
00839 // ADC Channels AIN12, AIN13 = Differential Bipolar
00840 // Full Scale = 2 * VREF
00841 // Voltage per LSB count = VREF/2048
00842 // AIN12, AIN13 are a Differential pair using Bipolar transfer function with range (+/-)Vref
00843 // AIN12 voltage must always be between 0 and VREF.
00844 // AIN13 voltage must always be between 0 and VREF.
00845 //
00846 //~ #define AIN_12_13_DifferentialBipolarFS2Vref    1
00847 //
00848 //--------------------
00849 // ADC Channels AIN12, AIN13 = Differential Bipolar
00850 // Full Scale = VREF
00851 // Voltage per LSB count = VREF/2048
00852 // AIN12, AIN13 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
00853 // AIN12 voltage must always be between 0 and VREF.
00854 // AIN13 voltage must always be between 0 and VREF.
00855 //
00856 //~ #define AIN_12_13_DifferentialBipolarFSVref     1
00857 //
00858 //--------------------
00859 // ADC Channels AIN12, AIN13 = Differential Unipolar (AIN12 > AIN13)
00860 // Full Scale = VREF
00861 // Voltage per LSB count = VREF/2048
00862 // AIN12, AIN13 are a Differential pair using Unipolar transfer function.
00863 // AIN12 voltage must always be between 0 and VREF.
00864 // AIN13 voltage must always be between 0 and VREF.
00865 //
00866 //~ #define AIN_12_13_DifferentialUnipolar  1
00867 //
00868 //--------------------
00869 // ADC Channels AIN12, AIN13 = Both Single-Ended, Unipolar
00870 // Full Scale = VREF
00871 // Voltage per LSB count = VREF/2048
00872 // AIN12 is a Single-Ended input using Unipolar transfer function.
00873 // AIN13 is a Single-Ended input using Unipolar transfer function.
00874 // If PDIFF_COM_1, both are Pseudo-Differential with REF- as common.
00875 // AIN12 voltage must always be between 0 and VREF.
00876 // AIN13 voltage must always be between 0 and VREF.
00877 //
00878 //~ #define AIN_12_13_SingleEnded   1
00879 //
00880 //--------------------
00881 //
00882 // Default settings if not defined at project level
00883 #ifndef AIN_12_13_DifferentialBipolarFS2Vref
00884 # ifndef AIN_12_13_DifferentialBipolarFSVref
00885 #  ifndef AIN_12_13_DifferentialUnipolar
00886 #   ifndef AIN_12_13_SingleEnded
00887 #    define AIN_12_13_DifferentialBipolarFS2Vref    0
00888 #    define AIN_12_13_DifferentialBipolarFSVref     0
00889 #    define AIN_12_13_DifferentialUnipolar  0
00890 #    define AIN_12_13_SingleEnded   1
00891 #   endif // AIN_12_13_SingleEnded
00892 #  endif // AIN_12_13_DifferentialUnipolar
00893 # endif // AIN_12_13_DifferentialBipolarFSVref
00894 #endif // AIN_12_13_DifferentialBipolarFS2Vref
00895 //
00896 // (optional diagnostic) pragma message the active setting
00897 #if AIN_12_13_DifferentialBipolarFS2Vref
00898 //~ #  pragma message("AIN_12_13_DifferentialBipolarFS2Vref: ADC Channels AIN12, AIN13 = Differential Bipolar")
00899 #endif // AIN_12_13_DifferentialBipolarFS2Vref
00900 #if AIN_12_13_DifferentialBipolarFSVref
00901 //~ #  pragma message("AIN_12_13_DifferentialBipolarFSVref: ADC Channels AIN12, AIN13 = Differential Bipolar")
00902 #endif // AIN_12_13_DifferentialBipolarFSVref
00903 #if AIN_12_13_DifferentialUnipolar
00904 //~ #  pragma message("AIN_12_13_DifferentialUnipolar: ADC Channels AIN12, AIN13 = Differential Unipolar (AIN12 > AIN13)")
00905 #endif // AIN_12_13_DifferentialUnipolar
00906 #if AIN_12_13_SingleEnded
00907 //~ #  pragma message("AIN_12_13_SingleEnded: ADC Channels AIN12, AIN13 = Both Single-Ended, Unipolar")
00908 #endif // AIN_12_13_SingleEnded
00909 //
00910 // Validate the AIN_12_13_DifferentialBipolarFS2Vref setting
00911 #if AIN_12_13_DifferentialBipolarFS2Vref
00912 # if AIN_12_13_DifferentialBipolarFSVref
00913 #  error("cannot have both AIN_12_13_DifferentialBipolarFS2Vref and AIN_12_13_DifferentialBipolarFSVref; choose one")
00914 # endif // AIN_12_13_DifferentialBipolarFSVref
00915 # if AIN_12_13_DifferentialUnipolar
00916 #  error("cannot have both AIN_12_13_DifferentialBipolarFS2Vref and AIN_12_13_DifferentialUnipolar; choose one")
00917 # endif // AIN_12_13_DifferentialUnipolar
00918 # if AIN_12_13_SingleEnded
00919 #  error("cannot have both AIN_12_13_DifferentialBipolarFS2Vref and AIN_12_13_SingleEnded; choose one")
00920 # endif // AIN_12_13_SingleEnded
00921 #endif // AIN_12_13_DifferentialBipolarFS2Vref
00922 //
00923 // Validate the AIN_12_13_DifferentialBipolarFSVref setting
00924 #if AIN_12_13_DifferentialBipolarFSVref
00925 # if AIN_12_13_DifferentialUnipolar
00926 #  error("cannot have both AIN_12_13_DifferentialBipolarFSVref and AIN_12_13_DifferentialUnipolar; choose one")
00927 # endif // AIN_12_13_DifferentialUnipolar
00928 # if AIN_12_13_SingleEnded
00929 #  error("cannot have both AIN_12_13_DifferentialBipolarFSVref and AIN_12_13_SingleEnded; choose one")
00930 # endif // AIN_12_13_SingleEnded
00931 #endif // AIN_12_13_DifferentialBipolarFSVref
00932 //
00933 // Validate the AIN_12_13_DifferentialUnipolar setting
00934 #if AIN_12_13_DifferentialUnipolar
00935 # if AIN_12_13_SingleEnded
00936 #  error("cannot have both AIN_12_13_DifferentialUnipolar and AIN_12_13_SingleEnded; choose one")
00937 # endif // AIN_12_13_SingleEnded
00938 #endif // AIN_12_13_DifferentialUnipolar
00939 
00940 //----------------------------------------
00941 // ADC Channels AIN14, AIN15
00942 //
00943 // CUSTOMIZE: select one of the following options
00944 // either by uncommenting in this file or define at the project level
00945 //--------------------
00946 // ADC Channels AIN14, AIN15 = Differential Bipolar
00947 // Full Scale = 2 * VREF
00948 // Voltage per LSB count = VREF/2048
00949 // AIN14, AIN15 are a Differential pair using Bipolar transfer function with range (+/-)Vref
00950 // AIN14 voltage must always be between 0 and VREF.
00951 // AIN15 voltage must always be between 0 and VREF.
00952 //
00953 //~ #define AIN_14_15_DifferentialBipolarFS2Vref    1
00954 //
00955 //--------------------
00956 // ADC Channels AIN14, AIN15 = Differential Bipolar
00957 // Full Scale = VREF
00958 // Voltage per LSB count = VREF/2048
00959 // AIN14, AIN15 are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
00960 // AIN14 voltage must always be between 0 and VREF.
00961 // AIN15 voltage must always be between 0 and VREF.
00962 //
00963 //~ #define AIN_14_15_DifferentialBipolarFSVref     1
00964 //
00965 //--------------------
00966 // ADC Channels AIN14, AIN15 = Differential Unipolar (AIN14 > AIN15)
00967 // Full Scale = VREF
00968 // Voltage per LSB count = VREF/2048
00969 // AIN14, AIN15 are a Differential pair using Unipolar transfer function.
00970 // AIN14 voltage must always be between 0 and VREF.
00971 // AIN15 voltage must always be between 0 and VREF.
00972 //
00973 //~ #define AIN_14_15_DifferentialUnipolar  1
00974 //
00975 //--------------------
00976 // ADC Channels AIN14, AIN15 = Both Single-Ended, Unipolar
00977 // Full Scale = VREF
00978 // Voltage per LSB count = VREF/2048
00979 // AIN14 is a Single-Ended input using Unipolar transfer function.
00980 // AIN15 is a Single-Ended input using Unipolar transfer function.
00981 // If PDIFF_COM_1, both are Pseudo-Differential with REF- as common.
00982 // AIN14 voltage must always be between 0 and VREF.
00983 // AIN15 voltage must always be between 0 and VREF.
00984 //
00985 //~ #define AIN_14_15_SingleEnded   1
00986 //
00987 //--------------------
00988 //
00989 // Default settings if not defined at project level
00990 #ifndef AIN_14_15_DifferentialBipolarFS2Vref
00991 # ifndef AIN_14_15_DifferentialBipolarFSVref
00992 #  ifndef AIN_14_15_DifferentialUnipolar
00993 #   ifndef AIN_14_15_SingleEnded
00994 #    define AIN_14_15_DifferentialBipolarFS2Vref    0
00995 #    define AIN_14_15_DifferentialBipolarFSVref     0
00996 #    define AIN_14_15_DifferentialUnipolar  0
00997 #    define AIN_14_15_SingleEnded   1
00998 #   endif // AIN_14_15_SingleEnded
00999 #  endif // AIN_14_15_DifferentialUnipolar
01000 # endif // AIN_14_15_DifferentialBipolarFSVref
01001 #endif // AIN_14_15_DifferentialBipolarFS2Vref
01002 //
01003 // (optional diagnostic) pragma message the active setting
01004 #if AIN_14_15_DifferentialBipolarFS2Vref
01005 //~ #  pragma message("AIN_14_15_DifferentialBipolarFS2Vref: ADC Channels AIN14, AIN15 = Differential Bipolar")
01006 #endif // AIN_14_15_DifferentialBipolarFS2Vref
01007 #if AIN_14_15_DifferentialBipolarFSVref
01008 //~ #  pragma message("AIN_14_15_DifferentialBipolarFSVref: ADC Channels AIN14, AIN15 = Differential Bipolar")
01009 #endif // AIN_14_15_DifferentialBipolarFSVref
01010 #if AIN_14_15_DifferentialUnipolar
01011 //~ #  pragma message("AIN_14_15_DifferentialUnipolar: ADC Channels AIN14, AIN15 = Differential Unipolar (AIN14 > AIN15)")
01012 #endif // AIN_14_15_DifferentialUnipolar
01013 #if AIN_14_15_SingleEnded
01014 //~ #  pragma message("AIN_14_15_SingleEnded: ADC Channels AIN14, AIN15 = Both Single-Ended, Unipolar")
01015 #endif // AIN_14_15_SingleEnded
01016 //
01017 // Validate the AIN_14_15_DifferentialBipolarFS2Vref setting
01018 #if AIN_14_15_DifferentialBipolarFS2Vref
01019 # if AIN_14_15_DifferentialBipolarFSVref
01020 #  error("cannot have both AIN_14_15_DifferentialBipolarFS2Vref and AIN_14_15_DifferentialBipolarFSVref; choose one")
01021 # endif // AIN_14_15_DifferentialBipolarFSVref
01022 # if AIN_14_15_DifferentialUnipolar
01023 #  error("cannot have both AIN_14_15_DifferentialBipolarFS2Vref and AIN_14_15_DifferentialUnipolar; choose one")
01024 # endif // AIN_14_15_DifferentialUnipolar
01025 # if AIN_14_15_SingleEnded
01026 #  error("cannot have both AIN_14_15_DifferentialBipolarFS2Vref and AIN_14_15_SingleEnded; choose one")
01027 # endif // AIN_14_15_SingleEnded
01028 #endif // AIN_14_15_DifferentialBipolarFS2Vref
01029 //
01030 // Validate the AIN_14_15_DifferentialBipolarFSVref setting
01031 #if AIN_14_15_DifferentialBipolarFSVref
01032 # if AIN_14_15_DifferentialUnipolar
01033 #  error("cannot have both AIN_14_15_DifferentialBipolarFSVref and AIN_14_15_DifferentialUnipolar; choose one")
01034 # endif // AIN_14_15_DifferentialUnipolar
01035 # if AIN_14_15_SingleEnded
01036 #  error("cannot have both AIN_14_15_DifferentialBipolarFSVref and AIN_14_15_SingleEnded; choose one")
01037 # endif // AIN_14_15_SingleEnded
01038 #endif // AIN_14_15_DifferentialBipolarFSVref
01039 //
01040 // Validate the AIN_14_15_DifferentialUnipolar setting
01041 #if AIN_14_15_DifferentialUnipolar
01042 # if AIN_14_15_SingleEnded
01043 #  error("cannot have both AIN_14_15_DifferentialUnipolar and AIN_14_15_SingleEnded; choose one")
01044 # endif // AIN_14_15_SingleEnded
01045 #endif // AIN_14_15_DifferentialUnipolar
01046 
01047 /**
01048  * @brief MAX11131 3Msps, Low-Power, Serial SPI 12-Bit, 16-Channel, Differential/Single-Ended Input, SAR ADC
01049  *
01050  *
01051  *
01052  * Datasheet: https://www.maximintegrated.com/MAX11131
01053  *
01054  *
01055  *
01056  * @code
01057  * // example code includes
01058  * // standard include for target platform -- Platform_Include_Boilerplate
01059  * #include "mbed.h"
01060  * // Platforms:
01061  * //   - MAX32625MBED
01062  * //      - supports mbed-os-5.11, requires USBDevice library
01063  * //      - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
01064  * //      - remove max32630fthr library (if present)
01065  * //      - remove MAX32620FTHR library (if present)
01066  * //   - MAX32600MBED
01067  * //      - Please note the last supported version is Mbed OS 6.3.
01068  * //      - remove max32630fthr library (if present)
01069  * //      - remove MAX32620FTHR library (if present)
01070  * //      - Windows 10 note:  Don't connect HDK until you are ready to load new firmware into the board.
01071  * //   - NUCLEO_F446RE
01072  * //      - remove USBDevice library
01073  * //      - remove max32630fthr library (if present)
01074  * //      - remove MAX32620FTHR library (if present)
01075  * //   - NUCLEO_F401RE
01076  * //      - remove USBDevice library
01077  * //      - remove max32630fthr library (if present)
01078  * //      - remove MAX32620FTHR library (if present)
01079  * //   - MAX32630FTHR
01080  * //      - #include "max32630fthr.h"
01081  * //      - add http://developer.mbed.org/teams/MaximIntegrated/code/max32630fthr/
01082  * //      - remove MAX32620FTHR library (if present)
01083  * //   - MAX32620FTHR
01084  * //      - #include "MAX32620FTHR.h"
01085  * //      - remove max32630fthr library (if present)
01086  * //      - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
01087  * //      - not tested yet
01088  * //   - MAX32625PICO
01089  * //      - #include "max32625pico.h"
01090  * //      - add https://os.mbed.com/users/switches/code/max32625pico/
01091  * //      - remove max32630fthr library (if present)
01092  * //      - remove MAX32620FTHR library (if present)
01093  * //      - not tested yet
01094  * //      - see https://os.mbed.com/users/switches/code/max32625pico/
01095  * //      - see https://os.mbed.com/users/switches/code/PICO_board_demo/
01096  * //      - see https://os.mbed.com/users/switches/code/PICO_USB_I2C_SPI/
01097  * //      - see https://os.mbed.com/users/switches/code/SerialInterface/
01098  * //      - Note: To load the MAX32625PICO firmware, hold the button while
01099  * //        connecting the USB cable, then copy firmware bin file
01100  * //        to the MAINTENANCE drive.
01101  * //      - see https://os.mbed.com/platforms/MAX32625PICO/
01102  * //      - see https://os.mbed.com/teams/MaximIntegrated/wiki/MAX32625PICO-Firmware-Updates
01103  * //
01104  * // end Platform_Include_Boilerplate
01105  * #include "MAX11131.h"
01106  *
01107  * // example code board support
01108  * //MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
01109  * //DigitalOut rLED(LED1);
01110  * //DigitalOut gLED(LED2);
01111  * //DigitalOut bLED(LED3);
01112  * //
01113  * // Arduino "shield" connector port definitions (MAX32625MBED shown)
01114  * #if defined(TARGET_MAX32625MBED)
01115  * #define A0 AIN_0
01116  * #define A1 AIN_1
01117  * #define A2 AIN_2
01118  * #define A3 AIN_3
01119  * #define D0 P0_0
01120  * #define D1 P0_1
01121  * #define D2 P0_2
01122  * #define D3 P0_3
01123  * #define D4 P0_4
01124  * #define D5 P0_5
01125  * #define D6 P0_6
01126  * #define D7 P0_7
01127  * #define D8 P1_4
01128  * #define D9 P1_5
01129  * #define D10 P1_3
01130  * #define D11 P1_1
01131  * #define D12 P1_2
01132  * #define D13 P1_0
01133  * #elif defined(TARGET_MAX32625PICO)
01134  * #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
01135  * #define A0 AIN_1
01136  * #define A1 AIN_2
01137  * // #define A2 AIN_3
01138  * // #define A3 AIN_0
01139  * #define D0 P0_0
01140  * #define D1 P0_1
01141  * #define D2 P0_2
01142  * #define D3 P0_3
01143  * #define D4 P1_7
01144  * #define D5 P1_6
01145  * #define D6 P4_4
01146  * #define D7 P4_5
01147  * #define D8 P4_6
01148  * #define D9 P4_7
01149  * #define D10 P0_7
01150  * #define D11 P0_6
01151  * #define D12 P0_5
01152  * #define D13 P0_4
01153  * #endif
01154  *
01155  * // example code declare SPI interface (GPIO controlled CS)
01156  * #if defined(TARGET_MAX32625MBED)
01157  * SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625MBED: P1_1 P1_2 P1_0 Arduino 10-pin header D11 D12 D13
01158  * DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
01159  * #elif defined(TARGET_MAX32625PICO)
01160  * #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
01161  * SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625PICO: pin P0_5 P0_6 P0_4
01162  * DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32625PICO: pin P0_7
01163  * #elif defined(TARGET_MAX32600MBED)
01164  * SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
01165  * DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
01166  * #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
01167  * // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
01168  * // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
01169  * //
01170  * // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses.
01171  * SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK); // mosi, miso, sclk spi1 TARGET_NUCLEO_F446RE: Arduino 10-pin header D11 D12 D13
01172  * DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10
01173  * //
01174  * #else
01175  * SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
01176  * DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
01177  * #endif
01178  *
01179  * // example code declare GPIO interface pins
01180  * DigitalOut CNVST_pin(D9); // Digital Trigger Input to MAX11131 device
01181  * // AnalogOut REF_plus_pin(Px_x_PortName_To_Be_Determined); // Reference Input to MAX11131 device
01182  * // AnalogOut REF_minus_slash_AIN15_pin(Px_x_PortName_To_Be_Determined); // Reference Input to MAX11131 device
01183  * DigitalIn EOC_pin(D2); // Digital Event Output from MAX11131 device
01184  * // example code declare device instance
01185  * MAX11131 g_MAX11131_device(spi, spi_cs, CNVST_pin, EOC_pin, MAX11131::MAX11131_IC);
01186  *
01187  * //--------------------------------------------------
01188  * // Declare the Serial driver
01189  * // default baud rate settings are 9600 8N1
01190  * // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
01191  * // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
01192  * //--------------------------------------------------
01193  * #if defined(TARGET_MAX32630)
01194  *     #include "USBSerial.h"
01195  * // Hardware serial port over DAPLink
01196  * // The default baud rate for the DapLink UART is 9600
01197  * //Serial DAPLINKserial(P2_1, P2_0);     // tx, rx
01198  * //    #define HAS_DAPLINK_SERIAL 1
01199  * // Virtual serial port over USB
01200  * // The baud rate does not affect the virtual USBSerial UART.
01201  * USBSerial serial;
01202  * //--------------------------------------------------
01203  * #elif defined(TARGET_MAX32625MBED)
01204  *     #include "USBSerial.h"
01205  * // Hardware serial port over DAPLink
01206  * // The default baud rate for the DapLink UART is 9600
01207  * //Serial DAPLINKserial(P2_1, P2_0);     // tx, rx
01208  * //    #define HAS_DAPLINK_SERIAL 1
01209  * // Virtual serial port over USB
01210  * // The baud rate does not affect the virtual USBSerial UART.
01211  * USBSerial serial;
01212  * //--------------------------------------------------
01213  * #elif defined(TARGET_MAX32600)
01214  *     #include "USBSerial.h"
01215  * // Hardware serial port over DAPLink
01216  * // The default baud rate for the DapLink UART is 9600
01217  * Serial DAPLINKserial(P1_1, P1_0);     // tx, rx
01218  *     #define HAS_DAPLINK_SERIAL 1
01219  * // Virtual serial port over USB
01220  * // The baud rate does not affect the virtual USBSerial UART.
01221  * USBSerial serial;
01222  * //--------------------------------------------------
01223  * #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
01224  * Serial serial(SERIAL_TX, SERIAL_RX);     // tx, rx
01225  * //--------------------------------------------------
01226  * #else
01227  * #if defined(SERIAL_TX)
01228  * #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..."
01229  * Serial serial(SERIAL_TX, SERIAL_RX);     // tx, rx
01230  * #elif defined(USBTX)
01231  * #warning "target not previously tested; guess serial pins are USBTX, USBRX..."
01232  * Serial serial(USBTX, USBRX);     // tx, rx
01233  * #elif defined(UART_TX)
01234  * #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..."
01235  * Serial serial(UART_TX, UART_RX);     // tx, rx
01236  * #else
01237  * #warning "target not previously tested; need to define serial pins..."
01238  * #endif
01239  * #endif
01240  * //
01241  * #include "CmdLine.h"
01242  * CmdLine cmdLine(serial, "serial");
01243  *
01244  * // example code main function
01245  * int main()
01246  * {
01247  *     // setup: put your setup code here, to run once
01248  *
01249  *     g_MAX11131_device.Init();
01250  *
01251  *     while (1)
01252  *     {
01253  *         // loop: put your main code here, to run repeatedly
01254  *
01255  *         // banner for csv data columns
01256  *         while(1) { // this code repeats forever
01257  *             // this code repeats forever
01258  *             // Measure ADC channels in sequence from AIN0 to channelNumber_0_15.
01259  *             // @param[in] g_MAX11131_device.channelNumber_0_15: AIN Channel Number
01260  *             // @param[in] g_MAX11131_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
01261  *             // @param[in] g_MAX11131_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
01262  *             int channelId_0_15 = 15;
01263  *             g_MAX11131_device.channelNumber_0_15 = channelId_0_15;
01264  *             g_MAX11131_device.PowerManagement_0_2 = 0;
01265  *             g_MAX11131_device.chan_id_0_1 = 1;
01266  *             g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock();
01267  *
01268  *             // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
01269  *             // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
01270  *             g_MAX11131_device.ReadAINcode();
01271  *             // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
01272  *             // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
01273  *
01274  *             // wait(3.0);
01275  *             // Use Arduino Serial Plotter to view output: Tools | Serial Plotter
01276  *             cmdLine.serial().printf("%d", g_MAX11131_device.AINcode[0]);
01277  *             for (int index = 1; index <= channelId_0_15; index++) {
01278  *                 cmdLine.serial().printf(",%d", g_MAX11131_device.AINcode[index]);
01279  *             }
01280  *             cmdLine.serial().printf("\r\n");
01281  *
01282  *         } // this code repeats forever
01283  *     }
01284  * }
01285  * @endcode
01286  */
01287 class MAX11131 {
01288 public:
01289     //----------------------------------------
01290     /// ADC_MODE_CONTROL.SCAN[3:0] ADC Scan Control (command)
01291     typedef enum MAX11131_SCAN_enum_t {
01292         SCAN_0000_NOP = 0x00, //!< 0b0000
01293         SCAN_0001_Manual = 0x01, //!< 0b0001
01294         SCAN_0010_Repeat = 0x02, //!< 0b0010
01295         SCAN_0011_StandardInternalClock = 0x03, //!< 0b0011
01296         SCAN_0100_StandardExternalClock = 0x04, //!< 0b0100
01297         SCAN_0101_UpperInternalClock = 0x05, //!< 0b0101
01298         SCAN_0110_UpperExternalClock = 0x06, //!< 0b0110
01299         SCAN_0111_CustomInternalClock = 0x07, //!< 0b0111
01300         SCAN_1000_CustomExternalClock = 0x08, //!< 0b1000
01301         SCAN_1001_SampleSetExternalClock = 0x09, //!< 0b1001
01302     } MAX11131_SCAN_enum_t;
01303 
01304     //----------------------------------------
01305     /// ADC_MODE_CONTROL.RESET[1:0] Reset 0=Normal 1=ResetFIFO 2=ResetAllRegisters 3=reserved
01306     typedef enum MAX11131_RESET_enum_t {
01307         RESET_00_Normal = 0x00, //!< 0b00
01308         RESET_01_ResetFIFO = 0x01, //!< 0b01
01309         RESET_10_ResetAllRegisters = 0x02, //!< 0b10
01310     } MAX11131_RESET_enum_t;
01311 
01312     //----------------------------------------
01313     /// ADC_MODE_CONTROL.PM[1:0] Power Management 0=Normal, 1=AutoShutdown, 2=AutoStandby 3=reserved
01314     typedef enum MAX11131_PM_enum_t {
01315         PM_00_Normal = 0x00, //!< 0b00
01316         PM_01_AutoShutdown = 0x01, //!< 0b01
01317         PM_10_AutoStandby = 0x02, //!< 0b10
01318     } MAX11131_PM_enum_t;
01319 
01320     /**
01321      * @brief IC's supported with this driver
01322      * @details MAX11131
01323      */
01324     typedef enum
01325     {
01326         MAX11131_IC = 0,
01327         //MAX11131_IC = 1
01328     } MAX11131_ic_t;
01329 
01330     /**********************************************************//**
01331     * @brief Constructor for MAX11131 Class.
01332     *
01333     * @details Requires an existing SPI object as well as a DigitalOut object.
01334     * The DigitalOut object is used for a chip enable signal
01335     *
01336     * On Entry:
01337     *     @param[in] spi - pointer to existing SPI object
01338     *     @param[in] cs_pin - pointer to a DigitalOut pin object
01339     *     @param[in] CNVST_pin - pointer to a DigitalOut pin object
01340     *     @param[in] EOC_pin - pointer to a DigitalIn pin object
01341     *     @param[in] ic_variant - which type of MAX11131 is used
01342     *
01343     * On Exit:
01344     *
01345     * @return None
01346     **************************************************************/
01347     MAX11131(SPI &spi, DigitalOut &cs_pin, // SPI interface
01348             DigitalOut &CNVST_pin, // Digital Trigger Input to MAX11131 device
01349             // AnalogOut &REF_plus_pin, // Reference Input to MAX11131 device
01350             // AnalogOut &REF_minus_slash_AIN15_pin, // Reference Input to MAX11131 device
01351             DigitalIn &EOC_pin, // Digital Event Output from MAX11131 device
01352             MAX11131_ic_t ic_variant);
01353 
01354     /************************************************************
01355      * @brief Default destructor for MAX11131 Class.
01356      *
01357      * @details Destroys SPI object if owner
01358      *
01359      * On Entry:
01360      *
01361      * On Exit:
01362      *
01363      * @return None
01364      **************************************************************/
01365     ~MAX11131();
01366 
01367     /// Function pointer void f(size_t byteCount, uint8_t mosiData[], uint8_t misoData[])
01368     Callback<void(size_t, uint8_t*, uint8_t*)> onSPIprint; //!< optional @ref onSPIprint SPI diagnostic function
01369 
01370     /// set SPI SCLK frequency
01371     void spi_frequency(int spi_sclk_Hz);
01372 
01373     /// get SPI SCLK frequency
01374     int get_spi_frequency() const { return m_SPI_SCLK_Hz; }
01375 
01376     /// get SPI mode
01377     int get_spi_dataMode() const { return m_SPI_dataMode; }
01378 
01379 //----------------------------------------
01380 public:
01381 
01382     /// shadow of write-only register ADC_MODE_CONTROL
01383     /// mosiData16 0x0000..0x7FFF format: 0 SCAN[3:0] CHSEL[3:0] RESET[1:0] PM[1:0] CHAN_ID SWCNV 0
01384     int16_t ADC_MODE_CONTROL;
01385 
01386     /// shadow of write-only register ADC_CONFIGURATION
01387     /// mosiData16 0x8000..0x87FF format: 1 0 0 0 0 REFSEL AVGON NAVG[1:0] NSCAN[1:0] SPM[1:0] ECHO 0 0
01388     int16_t ADC_CONFIGURATION;
01389 
01390     /// shadow of write-only register UNIPOLAR
01391     /// mosiData16 0x8800..0x8FFF format: 1 0 0 0 1 UCH0/1 UCH2/3 UCH4/5 UCH6/7 UCH8/9 UCH10/11 UCH12/13 UCH14/15 PDIFF_COM x x
01392     int16_t UNIPOLAR;
01393 
01394     /// shadow of write-only register BIPOLAR
01395     /// mosiData16 0x9000..0x97FF format: 1 0 0 1 0 BCH0/1 BCH2/3 BCH4/5 BCH6/7 BCH8/9 BCH10/11 BCH12/13 BCH14/15 x x x
01396     int16_t BIPOLAR;
01397 
01398     /// shadow of write-only register RANGE
01399     /// mosiData16 0x9800..0x9FFF format: 1 0 0 1 1 RANGE0/1 RANGE2/3 RANGE4/5 RANGE6/7 RANGE8/9 RANGE10/11 RANGE12/13 RANGE14/15 x x x
01400     int16_t RANGE;
01401 
01402     /// shadow of write-only register CSCAN0
01403     /// mosiData16 0xA000..0xA7FF format: 1 0 1 0 0 CHSCAN15 CHSCAN14 CHSCAN13 CHSCAN12 CHSCAN11 CHSCAN10 CHSCAN9 CHSCAN8 x x x
01404     int16_t CSCAN0;
01405 
01406     /// shadow of write-only register CSCAN1
01407     /// mosiData16 0xA800..0xAFFF format: 1 0 1 0 1 CHSCAN7 CHSCAN6 CHSCAN5 CHSCAN4 CHSCAN3 CHSCAN2 CHSCAN1 CHSCAN0 x x x
01408     int16_t CSCAN1;
01409 
01410     /// shadow of write-only register SAMPLESET
01411     /// mosiData16 0xB000..0xB7FF format: 1 0 1 1 0 SEQ_LENGTH[7:0] x x x followed by enabledChannelsPattern.
01412     /// NOTE: Send the sampleset pattern, with 4 entries packed into each 16-bit SPI word. Pad unused entries with 0.
01413     /// NOTE: Keep CS low during the entire enabledChannelsPattern entry.
01414     int16_t SAMPLESET;
01415 
01416     /// unpacked SAMPLESET.SEQ_LENGTH[7:0] determines length of pattern
01417     /// NOTE: SAMPLESET.SEQ_LENGTH[7:0] is the number of channel entries in the pattern.
01418     /// NOTE: Each channel entry is 4 bits. The first 4 bits are the first channel in the sequence.
01419     /// NOTE: Channels can be repeated in any arbitrary order.
01420     /// NOTE: The channel entry pattern is sent immediately after writing SAMPLESET.
01421     uint8_t enabledChannelsPatternLength_1_256;
01422 
01423     /// unpacked shadow of write-only register SAMPLESET enabledChannelsPattern.
01424     /// Array Length = enabledChannelsPatternLength_1_256.
01425     /// Each entry is a channel number between 0 and 15.
01426     uint8_t enabledChannelsPattern[256];
01427 
01428     /// Diagnostic: what is the meaning of SPI Master Out data.
01429     /// 0:Nothing 1:regWrite 2:sampleSetPattern
01430     uint8_t SPI_MOSI_Semantic;
01431 
01432     /// number of ScanRead() words needed to retrieve all measurements.
01433     uint16_t NumWords;
01434 
01435     /// Is the currently configured mode external or internal clock. 1:External Clock 0:Internal Clock
01436     uint8_t isExternalClock;
01437 
01438     /// unpacked ADC_MODE_CONTROL.SCAN[3:0] Scan Mode MAX11131_SCAN_enum_t
01439     uint8_t ScanMode;
01440 
01441     /// unpacked ADC_MODE_CONTROL.CHSEL[3:0] Analog Input Channel Select
01442     uint8_t channelNumber_0_15;
01443 
01444     /// unpacked ADC_MODE_CONTROL.PM[1:0] Power Management MAX11131_PM_enum_t
01445     uint8_t PowerManagement_0_2;
01446 
01447     /// unpacked ADC_MODE_CONTROL.CHAN_ID
01448     uint8_t chan_id_0_1;
01449 
01450     /// unpacked ADC_CONFIGURATION.AVG and ADC_CONFIGURATION.NAVG[1:0] may be 0, 4, 8, 16, or 32
01451     uint8_t average_0_4_8_16_32;
01452 
01453     /// unpacked ADC_CONFIGURATION.NSCAN[1:0] may be 4, 8, 12, or 16
01454     uint8_t nscan_4_8_12_16;
01455 
01456     /// unpacked ADC_MODE_CONTROL.SWCNV
01457     uint8_t swcnv_0_1;
01458 
01459     /// unpacked CSCAN0 and CSCAN1
01460     int16_t enabledChannelsMask;
01461 
01462     /// Each channel's most recent value in LSBs.
01463     /// Updated by ReadAINcode function.
01464     /// Use VoltageOfCode function to convert LSBs to physical voltage.
01465     uint16_t AINcode[16];
01466 
01467     /// SPI master-in slave-out data.
01468     /// Updated by ReadAINcode function.
01469     /// SampleSet mode allows up to 256 channel entry selections.
01470     int16_t RAW_misoData16[256];
01471 
01472     /// reference voltage, in Volts
01473     double VRef;
01474 
01475 
01476 //----------------------------------------
01477 // set SPI SCLK frequency for MAX11131
01478 //
01479     void SPIfrequency(int spi_sclk_Hz);
01480 
01481 //----------------------------------------
01482 // get SPI SCLK frequency for MAX11131
01483 //
01484     int SPIgetFrequency();
01485 
01486 //----------------------------------------
01487 // Assert SPI Chip Select
01488 // SPI chip-select for MAX11131
01489 //
01490     void SPIoutputCS(int isLogicHigh);
01491 
01492 //----------------------------------------
01493 // SPI write 16 bits
01494 // SPI interface to MAX11131 shift 16 bits mosiData16 into MAX11131 DIN
01495 // ignoring MAX11131 DOUT
01496 //
01497     void SPIwrite16bits(int16_t mosiData16);
01498 
01499 //----------------------------------------
01500 // SPI write 17-24 bits
01501 // SPI interface to MAX11131 shift 16 bits mosiData16 into MAX11131 DIN
01502 // followed by one additional SCLK byte.
01503 // ignoring MAX11131 DOUT
01504 //
01505     void SPIwrite24bits(int16_t mosiData16_FFFF00, int8_t mosiData8_0000FF);
01506 
01507 //----------------------------------------
01508 // SPI read 16 bits while MOSI (MAX11131 DIN) is 0
01509 // SPI interface to capture 16 bits miso data from MAX11131 DOUT
01510 //
01511     int16_t SPIread16bits();
01512 
01513 //----------------------------------------
01514 // Assert MAX11131 CNVST convert start.
01515 // Required when using any of the InternalClock modes with SWCNV 0.
01516 // Trigger measurement by driving CNVST/AIN14 pin low for a minimum active-low pulse duration of 5ns. (AIN14 is not available)
01517 //
01518     void CNVSToutputPulseLow();
01519 
01520 //----------------------------------------
01521 // Wait for MAX11131 EOC pin low, indicating end of conversion.
01522 // Required when using any of the InternalClock modes.
01523 //
01524     void EOCinputWaitUntilLow();
01525 
01526 //----------------------------------------
01527 // Return the status of the MAX11131 EOC pin.
01528 //
01529     int EOCinputValue();
01530 
01531 private:
01532     // SPI object
01533     SPI &m_spi;
01534     int m_SPI_SCLK_Hz;
01535     int m_SPI_dataMode;
01536     int m_SPI_cs_state;
01537 
01538     // Selector pin object
01539     DigitalOut &m_cs_pin;
01540 
01541 // InputPin Name = CNVST
01542 // InputPin Description = Active-Low Conversion Start Input/Analog Input 14
01543 // InputPin Function = Trigger
01544     DigitalOut &m_CNVST_pin;
01545 //
01546 // InputPin Name = REF+
01547 // InputPin Description = External Positive Reference Input. Apply a reference voltage at REF+. Bypass to GND with a 0.47uF capacitor.
01548 // InputPin Function = Reference
01549     // AnalogOut &m_REF_plus_pin;
01550 //
01551 // InputPin Name = REF-/AIN15
01552 // InputPin Description = External Differential Reference Negative Input/Analog Input 15
01553 // InputPin Function = Reference
01554     // AnalogOut &m_REF_minus_slash_AIN15_pin;
01555 //
01556 // OutputPin Name = EOC
01557 // OutputPin Description = End of Conversion Output. Data is valid after EOC pulls low (Internal clock mode only).
01558 // OutputPin Function = Event
01559     DigitalIn &m_EOC_pin;
01560 //
01561 
01562     // Identifies which IC variant is being used
01563     MAX11131_ic_t m_ic_variant;
01564 
01565 public:
01566 
01567     //----------------------------------------
01568     /// Menu item '!'
01569     /// Initialize device
01570     ///
01571     /// TODO1: #170 MAX11131 Self Test for Test Fixture Firmware
01572     /// @future test group ____ // Verify function ____ (enabled by default)
01573     ///
01574     /// @future test group DACCodeOfVoltage // Verify function DACCodeOfVoltage (enabled by default)
01575     /// @future test group DACCodeOfVoltage tinyTester.blink_time_msec = 20 // quickly speed through the software verification
01576     /// @future test group DACCodeOfVoltage tinyTester.print("VRef = 2.500  MAX5171 14-bit LSB = 0.00015V")
01577     /// @future test group DACCodeOfVoltage VRef = 2.500
01578     /// @future test group DACCodeOfVoltage tinyTester.err_threshold = 0.00015259720441921504 // 14-bit LSB (2.500/16383)
01579     ///     //
01580     /// @future test group DACCodeOfVoltage DACCodeOfVoltage(2.499847412109375) expect 0x3FFF
01581     ///     //
01582     ///     //
01583     /// @future test group CODE_LOAD // Verify function CODE_LOAD (enabled by default)
01584     /// @future test group CODE_LOAD tinyTester.blink_time_msec = 75 // default 75 resume hardware self test
01585     /// @future test group CODE_LOAD tinyTester.settle_time_msec = 250
01586     /// @future test Init()
01587     /// @future test VRef expect 2.500 // Nominal Full-Scale Voltage Reference
01588     ///     //
01589     ///     tinyTester.err_threshold = 0.030; // 30mV
01590     /// @future test group CODE_LOAD tinyTester.err_threshold = 0.030
01591     /// @future test group CODE_LOAD tinyTester.DigitalIn_Read_Expect_WarnOnly(UPO_pin, "UPO", 1, "UPO_pin is high after MAX5171 UPO_HIGH command")
01592     /// @future test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(1.2500)
01593     ///
01594     ///
01595     ///
01596     /// TODO1: #170 MAX11131 Self Test for Test Fixture Firmware
01597     /// @future test group ____ // Verify function ____ (enabled by default)
01598     /// @future test group ____ // Verify function ____ (enabled by default)
01599     ///     // MAX11131BOB self-test functions
01600     ///     //~ SelfTest_FAIL(cmdLine);
01601     ///     //~ cmdLine.serial().printf("test program not implemented yet");
01602     ///     int16_t value_u12;
01603     ///     int channelId;
01604     ///     double voltageV = 0.5;
01605     ///     //
01606     ///     //cmdLine.serial().printf("
01607     ///       0.0: MAX11131.Init()");
01608     ///     //g_MAX11131_device.Init();
01609     ///     //
01610     ///     // Device Testing: ADC commands, verify with on-board ADC and SPI framing
01611     ///     //
01612     /// @test group SPI48_3MSps // support 3MSps parts SCLK<=48MHz (enabled by default)
01613     /// @test group SPI48_3MSps tinyTester.print("SPI 48MHz")
01614     /// @test group SPI48_3MSps SPIfrequency(48000000); // support 3MSps parts SCLK<=48MHz
01615     /// @test group SPI48_3MSps SPIgetFrequency() expect 48000000
01616     /// @test group SPI48_3MSps tinyTester.settle_time_msec = 250 // default 250
01617     /// @test group SPI48_3MSps tinyTester.Wait_Output_Settling()
01618     /// @test group SPI48_3MSps SPIoutputCS(0)
01619     /// @test group SPI48_3MSps SPIread16bits()
01620     /// @test group SPI48_3MSps SPIoutputCS(1)
01621     /// //
01622     /// @test group SPI16MHz_1MSps // support 1MSps parts SCLK<=16MHz (enabled by default)
01623     /// @test group SPI16MHz_1MSps tinyTester.print("SPI 16MHz")
01624     /// @test group SPI16MHz_1MSps SPIfrequency(16000000); // support 1MSps parts SCLK<=16MHz
01625     /// @test group SPI16MHz_1MSps SPIgetFrequency() expect 16000000
01626     /// @test group SPI16MHz_1MSps tinyTester.settle_time_msec = 250 // default 250
01627     /// @test group SPI16MHz_1MSps tinyTester.Wait_Output_Settling()
01628     /// @test group SPI16MHz_1MSps SPIoutputCS(0)
01629     /// @test group SPI16MHz_1MSps SPIread16bits()
01630     /// @test group SPI16MHz_1MSps SPIoutputCS(1)
01631     /// //
01632     /// @test group SPI8MHz_500kSps // support 500kSps parts SCLK<=8MHz (enabled by default)
01633     /// @test group SPI8MHz_500kSps tinyTester.print("SPI 8MHz")
01634     /// @test group SPI8MHz_500kSps SPIfrequency(8000000); // support 500kSps parts SCLK<=8MHz
01635     /// @test group SPI8MHz_500kSps SPIgetFrequency() expect 8000000
01636     /// @test group SPI8MHz_500kSps tinyTester.settle_time_msec = 250 // default 250
01637     /// @test group SPI8MHz_500kSps tinyTester.Wait_Output_Settling()
01638     /// @test group SPI8MHz_500kSps SPIoutputCS(0)
01639     /// @test group SPI8MHz_500kSps SPIread16bits()
01640     /// @test group SPI8MHz_500kSps SPIoutputCS(1)
01641     /// //
01642     /// @test group SPI12MHz_1MSps // support 1MSps parts SCLK<=16MHz (enabled by default)
01643     /// @test group SPI12MHz_1MSps tinyTester.print("SPI 12MHz")
01644     /// @test group SPI12MHz_1MSps SPIfrequency(12000000); // support 1MSps parts SCLK<=16MHz
01645     /// @test group SPI12MHz_1MSps SPIgetFrequency() expect 12000000
01646     /// @test group SPI12MHz_1MSps tinyTester.settle_time_msec = 250 // default 250
01647     /// @test group SPI12MHz_1MSps tinyTester.Wait_Output_Settling()
01648     /// @test group SPI12MHz_1MSps SPIoutputCS(0)
01649     /// @test group SPI12MHz_1MSps SPIread16bits()
01650     /// @test group SPI12MHz_1MSps SPIoutputCS(1)
01651     /// //
01652     /// @test tinyTester.blink_time_msec = 75 // default 75 resume hardware self test
01653     ///     tinyTester.blink_time_msec = 75;
01654     ///     // MAX11131 SelfTest: MAX11131 SPI connections (Power Supply and GND, SCLK, MOSI, MISO, CS)
01655     ///     cmdLine.serial().printf("
01656     /// ");
01657     ///     cmdLine.serial().printf(
01658     ///         "
01659     ///       1.0: Test Scan_0100_StandardExt -- verify SPI (VDD, GND, SCLK, MOSI, MISO, CS)");
01660     /// @test tinyTester.print("0.0: MAX11131.Init()")
01661     ///     cmdLine.serial().printf("
01662     ///       MAX11131.Init()");
01663     ///     g_MAX11131_device.Init();
01664     /// @test Init()
01665     /// @test VRef expect 2.500 // Nominal Full-Scale Voltage Reference
01666     ///     //
01667     /// @test group TEST10_SCAN_0100 // Test SCAN_0100_StandardExt -- verify VDD,GND,SCLK,MOSI,MISO,CS (enabled by default)
01668     /// @test group TEST10_SCAN_0100 tinyTester.print("1.0: Test SCAN_0100_StandardExt -- verify VDD,GND,SCLK,MOSI,MISO,CS")
01669     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01670     /// @test group TEST10_SCAN_0100 tinyTester.print("0000_0000_0100_0010  ADC_MODE_CONTROL SCAN_0000")
01671     /// @test group TEST10_SCAN_0100 tinyTester.print("                                      CHSEL=0 RESET=2 CHANID=1")
01672     /// @test group TEST10_SCAN_0100 SPIwrite16bits(0x0040)
01673     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01674     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01675     /// @test group TEST10_SCAN_0100 SPIread16bits()
01676     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01677     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01678     /// @test group TEST10_SCAN_0100 SPIread16bits()
01679     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01680     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01681     /// @test group TEST10_SCAN_0100 SPIread16bits()
01682     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01683     /// @test group TEST10_SCAN_0100 tinyTester.print("1000_0000_0000_0000  ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0")
01684     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01685     /// @test group TEST10_SCAN_0100 SPIwrite16bits(0x8000)
01686     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01687     /// @test group TEST10_SCAN_0100 tinyTester.print("0010_0111_1010_0100  ADC_MODE_CONTROL SCAN_0100_StandardExt")
01688     /// @test group TEST10_SCAN_0100 tinyTester.print("                                      CHSEL=15 RESET=1 CHANID=1")
01689     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01690     /// @test group TEST10_SCAN_0100 SPIwrite16bits(0x27a4)
01691     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01692     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0x0xxx (channel ID 0)")
01693     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01694     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0x0000 mask 0xF000 // expect 0x0xxx (channel ID 0)
01695     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01696     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0x1xxx (channel ID 1)")
01697     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01698     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0x1000 mask 0xF000 // expect 0x1xxx (channel ID 1)
01699     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01700     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0x2xxx (channel ID 2)")
01701     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01702     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0x2000 mask 0xF000 // expect 0x2xxx (channel ID 2)
01703     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01704     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0x3xxx (channel ID 3)")
01705     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01706     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0x3000 mask 0xF000 // expect 0x3xxx (channel ID 3)
01707     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01708     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0x4xxx (channel ID 4)")
01709     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01710     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0x4000 mask 0xF000 // expect 0x4xxx (channel ID 4)
01711     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01712     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0x5xxx (channel ID 5)")
01713     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01714     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0x5000 mask 0xF000 // expect 0x5xxx (channel ID 5)
01715     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01716     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0x6xxx (channel ID 6)")
01717     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01718     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0x6000 mask 0xF000 // expect 0x6xxx (channel ID 6)
01719     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01720     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0x7xxx (channel ID 7)")
01721     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01722     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0x7000 mask 0xF000 // expect 0x7xxx (channel ID 7)
01723     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01724     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0x8xxx (channel ID 8)")
01725     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01726     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0x8000 mask 0xF000 // expect 0x8xxx (channel ID 8)
01727     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01728     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0x9xxx (channel ID 9)")
01729     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01730     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0x9000 mask 0xF000 // expect 0x9xxx (channel ID 9)
01731     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01732     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0xaxxx (channel ID 10)")
01733     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01734     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0xA000 mask 0xF000 // expect 0xaxxx (channel ID 10)
01735     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01736     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0xbxxx (channel ID 11)")
01737     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01738     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0xB000 mask 0xF000 // expect 0xbxxx (channel ID 11)
01739     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01740     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0xcxxx (channel ID 12)")
01741     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01742     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0xC000 mask 0xF000 // expect 0xcxxx (channel ID 12)
01743     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01744     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0xdxxx (channel ID 13)")
01745     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01746     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0xD000 mask 0xF000 // expect 0xdxxx (channel ID 13)
01747     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01748     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0xexxx (channel ID 14)")
01749     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01750     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0xE000 mask 0xF000 // expect 0xexxx (channel ID 14)
01751     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01752     /// @test group TEST10_SCAN_0100 tinyTester.print("MISO --> expect 0xfxxx (channel ID 15)")
01753     /// @test group TEST10_SCAN_0100 SPIoutputCS(0)
01754     /// @test group TEST10_SCAN_0100 SPIread16bits() expect 0xF000 mask 0xF000 // expect 0xfxxx (channel ID 15)
01755     /// @test group TEST10_SCAN_0100 SPIoutputCS(1)
01756     ///     //
01757     /// @test group TEST4_SCAN_0100 // 4 ch=15 pm=0 id=1 -- ScanStandardExternalCloc (enabled by default)
01758     /// @test group TEST4_SCAN_0100 tinyTester.print("4 ch=15 pm=0 id=1 -- ScanStandardExternalClock")
01759     /// @test group TEST4_SCAN_0100 tinyTester.print("channelNumber_0_15 = 15")
01760     /// @test group TEST4_SCAN_0100 channelNumber_0_15 = 15
01761     /// @test group TEST4_SCAN_0100 tinyTester.print("PowerManagement_0_2 = 0")
01762     /// @test group TEST4_SCAN_0100 PowerManagement_0_2 = 0 // 0=Normal
01763     /// @test group TEST4_SCAN_0100 tinyTester.print("chan_id_0_1 = 1")
01764     /// @test group TEST4_SCAN_0100 chan_id_0_1 = 1 // misoData16 = CH[3:0] DATA[11:0]
01765     /// @test group TEST4_SCAN_0100 tinyTester.print("ScanStandardExternalClock() expect 16")
01766     /// @test group TEST4_SCAN_0100 ScanStandardExternalClock() expect 16 // Scan_0100_StandardExt
01767     /// @test group TEST4_SCAN_0100 tinyTester.print("NumWords expect 16")
01768     /// @test group TEST4_SCAN_0100 NumWords expect 16
01769     /// @test group TEST4_SCAN_0100 ReadAINcode()
01770     /// @test group TEST4_SCAN_0100 tinyTester.print("Verify RAW_misoData16[0..15]>>12&0x000F == 0..15 channelId")
01771     /// @test group TEST4_SCAN_0100 RAW_misoData16[0]  expect 0x0000 mask 0xF000 // expect 0x0xxx (channel ID 0)
01772     /// @test group TEST4_SCAN_0100 RAW_misoData16[1]  expect 0x1000 mask 0xF000 // expect 0x1xxx (channel ID 1)
01773     /// @test group TEST4_SCAN_0100 RAW_misoData16[2]  expect 0x2000 mask 0xF000 // expect 0x2xxx (channel ID 2)
01774     /// @test group TEST4_SCAN_0100 RAW_misoData16[3]  expect 0x3000 mask 0xF000 // expect 0x3xxx (channel ID 3)
01775     /// @test group TEST4_SCAN_0100 RAW_misoData16[4]  expect 0x4000 mask 0xF000 // expect 0x4xxx (channel ID 4)
01776     /// @test group TEST4_SCAN_0100 RAW_misoData16[5]  expect 0x5000 mask 0xF000 // expect 0x5xxx (channel ID 5)
01777     /// @test group TEST4_SCAN_0100 RAW_misoData16[6]  expect 0x6000 mask 0xF000 // expect 0x6xxx (channel ID 6)
01778     /// @test group TEST4_SCAN_0100 RAW_misoData16[7]  expect 0x7000 mask 0xF000 // expect 0x7xxx (channel ID 7)
01779     /// @test group TEST4_SCAN_0100 RAW_misoData16[8]  expect 0x8000 mask 0xF000 // expect 0x8xxx (channel ID 8)
01780     /// @test group TEST4_SCAN_0100 RAW_misoData16[9]  expect 0x9000 mask 0xF000 // expect 0x9xxx (channel ID 9)
01781     /// @test group TEST4_SCAN_0100 RAW_misoData16[10] expect 0xA000 mask 0xF000 // expect 0xaxxx (channel ID 10)
01782     /// @test group TEST4_SCAN_0100 RAW_misoData16[11] expect 0xB000 mask 0xF000 // expect 0xbxxx (channel ID 11)
01783     /// @test group TEST4_SCAN_0100 RAW_misoData16[12] expect 0xC000 mask 0xF000 // expect 0xcxxx (channel ID 12)
01784     /// @test group TEST4_SCAN_0100 RAW_misoData16[13] expect 0xD000 mask 0xF000 // expect 0xdxxx (channel ID 13)
01785     /// @test group TEST4_SCAN_0100 RAW_misoData16[14] expect 0xE000 mask 0xF000 // expect 0xexxx (channel ID 14)
01786     /// @test group TEST4_SCAN_0100 RAW_misoData16[15] expect 0xF000 mask 0xF000 // expect 0xfxxx (channel ID 15)
01787     ///     // Send MOSI data       Expect MISO data    Description
01788     ///     // 1000_0000_0000_0000  xxxx_xxxx_xxxx_xxxx ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0
01789     ///     // 0010_0111_1010_0100  xxxx_xxxx_xxxx_xxxx ADC_MODE_CONTROL Scan_0100_StandardExt CHSEL=15 RESET=1 CHANID=1
01790     ///     // 0000_0000_0000_0000  0000_xxxx_xxxx_xxxx Channel ID tag = AIN0 expect high nybble 0
01791     ///     // 0000_0000_0000_0000  0001_xxxx_xxxx_xxxx Channel ID tag = AIN1 expect high nybble 1
01792     ///     // 0000_0000_0000_0000  0010_xxxx_xxxx_xxxx Channel ID tag = AIN2 expect high nybble 2
01793     ///     // 0000_0000_0000_0000  0011_xxxx_xxxx_xxxx Channel ID tag = AIN3 expect high nybble 3
01794     ///     //
01795     ///     cmdLine.serial().printf("
01796     ///       MOSI <-- 1000_0000_0000_0000  ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0");
01797     /// @test tinyTester.print("1000_0000_0000_0000  ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0")
01798     ///     g_MAX11131_device.SPIoutputCS(0); // drive CS low
01799     ///     g_MAX11131_device.SPIwrite16bits(0x8000);
01800     ///     g_MAX11131_device.SPIoutputCS(1); // drive CS high
01801     /// @test SPIoutputCS(0)
01802     /// @test SPIwrite16bits(0x8000)
01803     /// @test SPIoutputCS(1)
01804     ///     //
01805     ///     cmdLine.serial().printf(
01806     ///         "
01807     ///       MOSI <-- 0010_0111_1010_0100  ADC_MODE_CONTROL Scan_0100_StandardExt CHSEL=15 RESET=1 CHANID=1");
01808     /// @test tinyTester.print("0010_0111_1010_0100  ADC_MODE_CONTROL Scan_0100_StandardExt")
01809     /// @test tinyTester.print("                                      CHSEL=15 RESET=1 CHANID=1")
01810     ///     g_MAX11131_device.SPIoutputCS(0); // drive CS low
01811     ///     g_MAX11131_device.SPIwrite16bits(0x27a4);
01812     ///     g_MAX11131_device.SPIoutputCS(1); // drive CS high
01813     /// @test SPIoutputCS(0)
01814     /// @test SPIwrite16bits(0x27a4)
01815     /// @test SPIoutputCS(1)
01816     ///     //
01817     /// @future test SPIoutputCS(0)
01818     /// @future SPIread16bits() expect 0x0000
01819     /// @future SPIread16bits() expect 0x0000 mask 0xF000
01820     /// @future test SPIread16bits() expect 0x1000 mask 0xF000
01821     /// @future test SPIread16bits() expect 0x2000 mask 0xF000
01822     /// @future test SPIread16bits() expect 0x3000 mask 0xF000
01823     /// @future test SPIread16bits() expect 0x4000 mask 0xF000
01824     /// @future test SPIread16bits() expect 0x5000 mask 0xF000
01825     /// @future test SPIread16bits() expect 0x6000 mask 0xF000
01826     /// @future test SPIread16bits() expect 0x7000 mask 0xF000
01827     /// @future test SPIread16bits() expect 0x8000 mask 0xF000
01828     /// @future test SPIread16bits() expect 0x9000 mask 0xF000
01829     /// @future test SPIread16bits() expect 0xA000 mask 0xF000
01830     /// @future test SPIread16bits() expect 0xB000 mask 0xF000
01831     /// @future test SPIread16bits() expect 0xC000 mask 0xF000
01832     /// @future test SPIread16bits() expect 0xD000 mask 0xF000
01833     /// @future test SPIread16bits() expect 0xE000 mask 0xF000
01834     /// @future test SPIread16bits() expect 0xF000 mask 0xF000
01835     /// @future test SPIoutputCS(1)
01836     ///     //
01837     ///     for (int channelIndex = 0; channelIndex < 16; channelIndex++) {
01838     ///         //~ cmdLine.serial().printf("
01839     ///       MISO --> expect 0000_xxxx_xxxx_xxxx");
01840     ///         g_MAX11131_device.SPIoutputCS(0); // drive CS low
01841     ///         g_MAX11131_device.RAW_misoData16[channelIndex] = g_MAX11131_device.SPIread16bits();
01842     ///         g_MAX11131_device.SPIoutputCS(1); // drive CS high
01843     ///         int expect_channelId = channelIndex;
01844     ///         int actual_channelId = (g_MAX11131_device.RAW_misoData16[channelIndex] >> 12) & 0x000F;
01845     ///         if (actual_channelId != expect_channelId)
01846     ///         {
01847     ///             tinyTester.FAIL();
01848     ///             cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF));
01849     ///             cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId);
01850     ///             cmdLine.serial().printf(" but got 0x%1.1xxxx", actual_channelId);
01851     ///         }
01852     ///         else
01853     ///         {
01854     ///             tinyTester.PASS();
01855     ///             cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF));
01856     ///             cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId);
01857     ///         }
01858     ///     }
01859     /// @future test tinyTester.print("NumWords=16")
01860     /// @future test NumWords=16
01861     /// @future test tinyTester.print("ReadAINcode()")
01862     /// @future test ReadAINcode()
01863     /// @future test tinyTester.print("TODO: expect RAW_misoData16[0..15]>>12&0x000F == 0..15 channelId")
01864     /// @future test RAW_misoData16[0] expect 0x0000 mask 0xF000
01865     /// @future test RAW_misoData16[1] expect 0x1000 mask 0xF000
01866     /// @future test RAW_misoData16[2] expect 0x2000 mask 0xF000
01867     /// @future test RAW_misoData16[3] expect 0x3000 mask 0xF000
01868     ///     //
01869     ///     // MAX11131 SelfTest: MAX11131 Supports Internal Clock Modes (CNVST, EOC)
01870     ///     cmdLine.serial().printf("
01871     /// ");
01872     ///     cmdLine.serial().printf(
01873     ///         "
01874     ///       1.1: Test Scan_0011_StandardInt -- verify Internal Clock signals (CNVST, EOC)");
01875     /// @test group TEST11_SCAN_0011 // 1.1: Test Scan_0011_StandardInt -- verify Internal Clock CNVST,EOC (enabled by default)
01876     /// @test group TEST11_SCAN_0011 tinyTester.print("1.1: Test Scan_0011_StandardInt -- verify Internal Clock CNVST,EOC")
01877     ///     cmdLine.serial().printf("
01878     ///       MAX11131.Init()");
01879     /// @future test tinyTester.print("_______")
01880     /// @test group TEST11_SCAN_0011 Init();
01881     /// @test group TEST11_SCAN_0011 SPIoutputCS(0); // drive CS low
01882     ///     g_MAX11131_device.RAW_misoData16[0] = g_MAX11131_device.SPIread16bits();
01883     /// @test group TEST11_SCAN_0011 group TEST11_SCAN_0011 SPIoutputCS(1); // drive CS high
01884     /// //
01885     ///     // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect
01886     ///     tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 1, "initial value before sending commands");
01887     /// //
01888     ///     // Send MOSI data       Expect MISO data    Description
01889     ///     // 1000_0000_0000_0000  xxxx_xxxx_xxxx_xxxx ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0 No Averaging
01890     ///     // 0001_1001_1010_0000  xxxx_xxxx_xxxx_xxxx ADC_MODE_CONTROL Scan_0011_StandardInt CHSEL=3 RESET=1 SWCNV=0
01891     ///     // 0000_0000_0000_0000  0000_xxxx_xxxx_xxxx Channel ID tag = AIN0 expect high nybble 0
01892     ///     // 0000_0000_0000_0000  0001_xxxx_xxxx_xxxx Channel ID tag = AIN1 expect high nybble 1
01893     ///     // 0000_0000_0000_0000  0010_xxxx_xxxx_xxxx Channel ID tag = AIN2 expect high nybble 2
01894     ///     // 0000_0000_0000_0000  0011_xxxx_xxxx_xxxx Channel ID tag = AIN3 expect high nybble 3
01895     ///     //
01896     ///     cmdLine.serial().printf("
01897     ///       MOSI <-- 1000_0000_0000_0000  ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0");
01898     /// @test group TEST11_SCAN_0011 tinyTester.print("1000_0000_0000_0000  ADC_CONFIGURATION REFSEL=0 SPM[1:0]=0 ECHO=0")
01899     /// @test group TEST11_SCAN_0011 SPIoutputCS(0); // drive CS low
01900     /// @test group TEST11_SCAN_0011 SPIwrite16bits(0x8000);
01901     /// @test group TEST11_SCAN_0011 SPIoutputCS(1); // drive CS high
01902     ///     //
01903     ///     cmdLine.serial().printf(
01904     ///         "
01905     ///       MOSI <-- 0001_1001_1010_0000  ADC_MODE_CONTROL Scan_0011_StandardInt CHSEL=3 RESET=1 SWCNV=0");
01906     /// @test group TEST11_SCAN_0011 tinyTester.print("0001_1001_1010_0000  ADC_MODE_CONTROL Scan_0011_StandardInt")
01907     /// @test group TEST11_SCAN_0011 tinyTester.print("                                      CHSEL=3 RESET=1 SWCNV=0")
01908     /// @test group TEST11_SCAN_0011 SPIoutputCS(0); // drive CS low
01909     /// @test group TEST11_SCAN_0011 SPIwrite16bits(0x19a0);
01910     /// @test group TEST11_SCAN_0011 SPIoutputCS(1); // drive CS high
01911     ///     //
01912     ///     for (int channelIndex = 0; channelIndex < 4; channelIndex++) {
01913     ///         //~ cmdLine.serial().printf("
01914     ///       MISO --> expect 0000_xxxx_xxxx_xxxx");
01915     ///         //~ wait_ms(200); // delay
01916     ///         g_MAX11131_device.CNVSToutputPulseLow();
01917     ///         //~ g_MAX11131_device.CNVSToutputValue(0);
01918     ///         //~ wait_ms(100); // delay
01919     ///         //~ g_MAX11131_device.CNVSToutputValue(1);
01920     ///         // g_MAX11131_device.EOCinputWaitUntilLow(); // infinite wait hazard, need to fail if timeout exceeded
01921     ///         // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect
01922     ///         tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 0, "after CNVST pulse");
01923     ///         g_MAX11131_device.SPIoutputCS(0); // drive CS low
01924     ///         g_MAX11131_device.RAW_misoData16[channelIndex] = g_MAX11131_device.SPIread16bits();
01925     ///         g_MAX11131_device.SPIoutputCS(1); // drive CS high
01926     ///         // tinyTester.DigitalIn_Read_Expect_WarnOnly replaces SelfTest_MAX11131_EOC_expect
01927     ///         tinyTester.DigitalIn_Read_Expect_WarnOnly(EOCb_pin, "EOC", 1, "after SPI read");
01928     ///         int expect_channelId = channelIndex;
01929     ///         int actual_channelId = (g_MAX11131_device.RAW_misoData16[channelIndex] >> 12) & 0x000F;
01930     ///         if (actual_channelId != expect_channelId)
01931     ///         {
01932     ///             tinyTester.FAIL();
01933     ///             cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF));
01934     ///             cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId);
01935     ///             cmdLine.serial().printf(" but got 0x%1.1xxxx", actual_channelId);
01936     ///         }
01937     ///         else
01938     ///         {
01939     ///             tinyTester.PASS();
01940     ///             cmdLine.serial().printf("MISO --> 0x%4.4x", (g_MAX11131_device.RAW_misoData16[channelIndex] & 0xFFFF));
01941     ///             cmdLine.serial().printf(" expect 0x%1.1xxxx (channel ID %d)", expect_channelId, expect_channelId);
01942     ///         }
01943     ///     }
01944     ///     //
01945     ///     // MAX11131 SelfTest: Test Fixture: MAX541ACPA+ to MAX32625MBED.AIN0/AIN4
01946     ///     // Test Fixture: MAX541 connected to spi2
01947     ///     // SPI spi2_max541(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 TARGET_MAX32635MBED: P2_5 P2_6 P2_4 Arduino 2x3-pin header; microSD
01948     ///     // DigitalOut spi2_max541_cs(SPI2_SS); // TARGET_MAX32635MBED: P2_7 Arduino 2x3-pin header
01949     ///     // Test Fixture: MAX541 spi2 init
01950     ///     cmdLine.serial().printf("
01951     /// ");
01952     ///     cmdLine.serial().printf("
01953     ///       2.0: Test Fixture: MAX541 connected to spi2 (P2.4 P2.5 P2.7)?");
01954     /// @future test tinyTester.print("_______")
01955     ///     bool SelfTest_has_max541 = false;
01956     ///     // Check actual MAX541 reference voltage
01957     ///     cmdLine.serial().printf("
01958     ///       Test Fixture: MAX541 midscale voltage measure with MAX32625MBED AIN0/4");
01959     ///     max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
01960     ///     tinyTester.Wait_Output_Settling(); // wait for MAX541 to settle
01961     ///     //
01962     ///     double max541_midscale_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0     fullscale is 6.0V
01963     ///     const int average_count = 100;
01964     ///     const double average_K = 0.25;
01965     ///     for (int count = 0; count < average_count; count++) {
01966     ///         double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0     fullscale is 6.0V
01967     ///         max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
01968     ///     }
01969     ///     if (max541_midscale_V > 1.0f) {
01970     ///         max541.VRef = 2.0 * max541_midscale_V;
01971     ///         cmdLine.serial().printf("
01972     ///       Test Fixture: MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
01973     ///                                 max541_midscale_V, max541.VRef);
01974     ///         // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
01975     ///         voltageV = 1.0f;
01976     ///         SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
01977     ///     }
01978     ///     if (SelfTest_has_max541) {
01979     ///         voltageV = 0.0f;
01980     ///         SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
01981     ///     }
01982     ///     if (SelfTest_has_max541) {
01983     ///         voltageV = 2.7f;
01984     ///         SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
01985     ///     }
01986     ///     if (SelfTest_has_max541) {
01987     ///         voltageV = 1.65f;
01988     ///         SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
01989     ///     }
01990     ///     if (SelfTest_has_max541) {
01991     ///         voltageV = 2.0f;
01992     ///         SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
01993     ///     }
01994     ///     if (SelfTest_has_max541) {
01995     ///         voltageV = 0.25f;
01996     ///         SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
01997     ///     }
01998     ///     if (SelfTest_has_max541) {
01999     ///         voltageV = 0.5f;
02000     ///         SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
02001     ///     }
02002     ///     if (SelfTest_has_max541) {
02003     ///         voltageV = 1.0f;
02004     ///         SelfTest_has_max541 = SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
02005     ///     }
02006     ///     if (SelfTest_has_max541 == false) {
02007     ///         // don't fail just because we're missing the test fixture...
02008     ///         cmdLine.serial().printf("
02009     ///       Test Fixture: MAX541 not present");
02010     ///         //~ g_SelfTest_nFail--;
02011     ///     }
02012     ///     //
02013     ///     // TODO1: MAX11131 SelfTest: if Test Fixture: drive MAX541, compare MAX32625MBED.AIN0/AIN4 and MAX11131 AIN0
02014     ///     // indirectly verify the reference voltage by reading a known input voltage
02015     ///     if (SelfTest_has_max541) {
02016     ///         cmdLine.serial().printf("
02017     /// ");
02018     ///         cmdLine.serial().printf("
02019     ///       2.1: TODO1: Check MAX11131 reference voltage using Scan_0001_Manual");
02020     /// @future test tinyTester.print("_______")
02021     ///         voltageV = 1.0f;
02022     ///         SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
02023     ///         cmdLine.serial().printf("
02024     ///       MAX11131.Init()");
02025     ///         g_MAX11131_device.Init();
02026     ///         // 1 ScanManual ch=0 pm=0 id=1
02027     ///         g_MAX11131_device.channelNumber_0_15 = 0;
02028     ///         g_MAX11131_device.PowerManagement_0_2 = 0;
02029     ///         g_MAX11131_device.chan_id_0_1 = 1;
02030     ///         cmdLine.serial().printf("
02031     ///       MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15);
02032     ///         cmdLine.serial().printf("
02033     ///       MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2);
02034     ///         cmdLine.serial().printf("
02035     ///       MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1);
02036     ///         g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual();
02037     ///         cmdLine.serial().printf("
02038     ///       MAX11131.ScanManual -- NumWords = %d",
02039     ///                                 g_MAX11131_device.NumWords);
02040     ///         g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual();
02041     ///         g_MAX11131_device.ReadAINcode();
02042     ///         cmdLine.serial().printf("
02043     ///       MAX11131.ReadAINcode");
02044     ///         AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
02045     ///         //
02046     ///         //  2.1: TODO1: Check MAX11131 reference voltage -- why we read 0xffff 2.4999V here?
02047     ///         //
02048     ///         cmdLine.serial().printf("
02049     ///       MAX11131.ScanManual -- NumWords = %d",
02050     ///                                 g_MAX11131_device.NumWords);
02051     ///         // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
02052     ///         // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
02053     ///         g_MAX11131_device.ReadAINcode();
02054     ///         cmdLine.serial().printf("
02055     ///       MAX11131.ReadAINcode");
02056     ///         AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
02057     ///         //
02058     ///         //  2.1: TODO1: Check MAX11131 reference voltage -- why we read 0xffff 2.4999V here?
02059     ///         //
02060     ///         // compare with mbed/Arduino AIN0-AIN3
02061     ///         // MAX32625MBED.AIN4 = MAX11131.AIN0
02062     ///         channelId = 0;
02063     ///         value_u12 = g_MAX11131_device.AINcode[channelId];
02064     ///         voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId);
02065     /// //
02066     ///         // tinyTester.Wait_Output_Settling replaces wait_ms
02067     ///         tinyTester.Wait_Output_Settling();
02068     ///         // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
02069     ///         tinyTester.err_threshold = 0.100;
02070     ///         tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
02071     /// //
02072     ///     }
02073     ///     //
02074     ///     if (SelfTest_has_max541) {
02075     ///         voltageV = 1.0f;
02076     ///         SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
02077     ///     }
02078     ///     cmdLine.serial().printf("
02079     /// ");
02080     ///     cmdLine.serial().printf("
02081     ///       3.1: Test Scan_0001_Manual");
02082     /// @future test tinyTester.print("_______")
02083     ///     cmdLine.serial().printf("
02084     ///       MAX11131.Init()");
02085     ///     g_MAX11131_device.Init();
02086     ///     // 1 ScanManual ch=0 pm=0 id=1
02087     ///     g_MAX11131_device.channelNumber_0_15 = 0;
02088     ///     g_MAX11131_device.PowerManagement_0_2 = 0;
02089     ///     g_MAX11131_device.chan_id_0_1 = 1;
02090     ///     cmdLine.serial().printf("
02091     ///       MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15);
02092     /// @future test tinyTester.print("_______")
02093     ///     cmdLine.serial().printf("
02094     ///       MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2);
02095     /// @future test tinyTester.print("_______")
02096     ///     cmdLine.serial().printf("
02097     ///       MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1);
02098     /// @future test tinyTester.print("_______")
02099     ///     g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual();
02100     ///     cmdLine.serial().printf("
02101     ///       MAX11131.ScanManual -- NumWords = %d",
02102     ///                             g_MAX11131_device.NumWords);
02103     /// @future test tinyTester.print("_______")
02104     ///     // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
02105     ///     // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
02106     ///     g_MAX11131_device.ReadAINcode();
02107     ///     cmdLine.serial().printf("
02108     ///       MAX11131.ReadAINcode");
02109     /// @future test tinyTester.print("_______")
02110     ///     AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
02111     ///     // compare with mbed/Arduino AIN0-AIN3
02112     ///     // MAX32625MBED.AIN4 = MAX11131.AIN0
02113     ///     channelId = 0;
02114     ///     value_u12 = g_MAX11131_device.AINcode[channelId];
02115     ///     voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId);
02116     /// //
02117     ///     // tinyTester.Wait_Output_Settling replaces wait_ms
02118     ///     tinyTester.Wait_Output_Settling();
02119     ///     // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
02120     ///     tinyTester.err_threshold = 0.100;
02121     ///     tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
02122     /// //
02123     ///     //
02124     ///     cmdLine.serial().printf("
02125     /// ");
02126     ///     cmdLine.serial().printf("
02127     ///       3.4: Test Scan_0100_StandardExternalClock");
02128     /// @future test tinyTester.print("_______")
02129     ///     cmdLine.serial().printf("
02130     ///       MAX11131.Init()");
02131     ///     g_MAX11131_device.Init();
02132     ///     // MAX11131 > 4
02133     ///     // ScanStandardExternalClock ch=9 pm=0 id=1
02134     ///     // ScanRead_nWords_chanID nWords=10
02135     ///     //  ch=0 xu=2964 = 0x0b94 = 1.8091V
02136     ///     //  ch=1 xu=2227 = 0x08b3 = 1.3593V
02137     ///     //  ch=2 xu=1570 = 0x0622 = 0.9583V
02138     ///     //  ch=3 xu=865 = 0x0361 = 0.5280V
02139     ///     //  ch=4 xu=630 = 0x0276 = 0.3845V
02140     ///     //  ch=5 xu=594 = 0x0252 = 0.3625V
02141     ///     //  ch=6 xu=461 = 0x01cd = 0.2814V
02142     ///     //  ch=7 xu=364 = 0x016c = 0.2222V
02143     ///     //  ch=8 xu=480 = 0x01e0 = 0.2930V
02144     ///     //  ch=9 xu=616 = 0x0268 = 0.3760V
02145     ///     g_MAX11131_device.channelNumber_0_15 = 9;
02146     ///     g_MAX11131_device.PowerManagement_0_2 = 0;
02147     ///     g_MAX11131_device.chan_id_0_1 = 1;
02148     ///     cmdLine.serial().printf("
02149     ///       MAX11131.channelNumber_0_15=%d", g_MAX11131_device.channelNumber_0_15);
02150     /// @future test tinyTester.print("_______")
02151     ///     cmdLine.serial().printf("
02152     ///       MAX11131.PowerManagement_0_2=%d", g_MAX11131_device.PowerManagement_0_2);
02153     /// @future test tinyTester.print("_______")
02154     ///     cmdLine.serial().printf("
02155     ///       MAX11131.chan_id_0_1=%d", g_MAX11131_device.chan_id_0_1);
02156     /// @future test tinyTester.print("_______")
02157     ///     g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock();
02158     ///     cmdLine.serial().printf("
02159     ///       MAX11131.ScanStandardExternalClock -- NumWords = %d",
02160     ///                             g_MAX11131_device.NumWords);
02161     /// @future test tinyTester.print("_______")
02162     ///     // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
02163     ///     // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
02164     ///     g_MAX11131_device.ReadAINcode();
02165     ///     cmdLine.serial().printf("
02166     ///       MAX11131.ReadAINcode");
02167     /// @future test tinyTester.print("_______")
02168     ///     // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
02169     ///     // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
02170     ///     // expect g_MAX11131_device.NumWords == g_MAX11131_device.channelNumber_0_15 + 1;
02171     ///     // expect RAW_misoData16[index] msnybble 0,1,2,3,...
02172     ///     AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
02173     ///     // compare with mbed/Arduino AIN0-AIN3
02174     ///     // MAX32625MBED.AIN4 = MAX11131.AIN0
02175     ///     channelId = 0;
02176     ///     value_u12 = g_MAX11131_device.AINcode[channelId];
02177     ///     voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId);
02178     ///     // tinyTester.Wait_Output_Settling replaces wait_ms
02179     ///     tinyTester.Wait_Output_Settling();
02180     ///     // tinyTester.AnalogIn0_Read_Expect_voltageV replaces SelfTest_AnalogInput_Expect_ch_V
02181     ///     tinyTester.err_threshold = 0.100;
02182     ///     tinyTester.AnalogIn0_Read_Expect_voltageV(voltageV);
02183     ///     // compare MAX32625MBED.AIN5 = MAX11131.AIN1
02184     ///     //channelId = 1;
02185     ///     //value_u12 = g_MAX11131_device.AINcode[channelId];
02186     ///     //voltageV = g_MAX11131_device.VoltageOfCode(value_u12, channelId);
02187     ///     //SelfTest_AnalogInput_Expect_ch_V(cmdLine, 5, voltageV, 0.100);
02188     ///
02189     ///
02190     ///
02191     void Init(void);
02192 
02193     //----------------------------------------
02194     /// Menu item 'IS'
02195     /// ADC Channels AIN(channelId), AIN(channelId+1) = Both Single-Ended, Unipolar
02196     /// Full Scale = VREF
02197     /// Voltage per LSB count = VREF/4096
02198     /// AIN(channelId) is a Single-Ended input using Unipolar transfer function.
02199     /// AIN(channelId+1) is a Single-Ended input using Unipolar transfer function.
02200     /// If PDIFF_COM_1, both are Pseudo-Differential with REF- as common.
02201     /// AIN(channelId) voltage must always be between 0 and VREF.
02202     /// AIN(channelId+1) voltage must always be between 0 and VREF.
02203     ///
02204     void Reconfigure_SingleEnded(int channel_0_15);
02205 
02206     //----------------------------------------
02207     /// Menu item 'IU'
02208     /// ADC Channels AIN(channelId), AIN(channelId+1) = Differential Unipolar (AIN(channelId) > AIN(channelId+1))
02209     /// Full Scale = VREF
02210     /// Voltage per LSB count = VREF/4096
02211     /// AIN(channelId), AIN(channelId+1) are a Differential pair using Unipolar transfer function.
02212     /// AIN(channelId) voltage must always be between 0 and VREF.
02213     /// AIN(channelId+1) voltage must always be between 0 and VREF.
02214     ///
02215     void Reconfigure_DifferentialUnipolar(int channel_0_15);
02216 
02217     //----------------------------------------
02218     /// Menu item 'IB'
02219     /// ADC Channels AIN(channelId), AIN(channelId+1) = Differential Bipolar
02220     /// Full Scale = VREF
02221     /// Voltage per LSB count = VREF/4096
02222     /// AIN(channelId), AIN(channelId+1) are a Differential pair using Bipolar transfer function with range (+/-)(1/2)Vref
02223     /// AIN(channelId) voltage must always be between 0 and VREF.
02224     /// AIN(channelId+1) voltage must always be between 0 and VREF.
02225     ///
02226     void Reconfigure_DifferentialBipolarFSVref(int channel_0_15);
02227 
02228     //----------------------------------------
02229     /// Menu item 'IR'
02230     /// ADC Channels AIN(channelId), AIN(channelId+1) = Differential Bipolar
02231     /// Full Scale = 2 * VREF
02232     /// Voltage per LSB count = VREF/2048
02233     /// AIN(channelId), AIN(channelId+1) are a Differential pair using Bipolar transfer function with range (+/-)Vref
02234     /// AIN(channelId) voltage must always be between 0 and VREF.
02235     /// AIN(channelId+1) voltage must always be between 0 and VREF.
02236     ///
02237     void Reconfigure_DifferentialBipolarFS2Vref(int channel_0_15);
02238 
02239     //----------------------------------------
02240     /// SCAN_0000_NOP
02241     ///
02242     /// Shift 16 bits out of ADC, without changing configuration.
02243     /// Note: @return data format depends on CHAN_ID bit:
02244     ///     "CH[3:0] DATA[11:0]" when CHAN_ID = 1, or
02245     ///     "0 DATA[11:0] x x x" when CHAN_ID = 0.
02246     int16_t ScanRead(void);
02247 
02248     //----------------------------------------
02249     /// SCAN_0000_NOP
02250     ///
02251     /// Read raw ADC codes from device into AINcode[] and RAW_misoData16[].
02252     /// If internal clock mode with SWCNV=0, measurements will be triggered using CNVST pin.
02253     ///
02254     /// @pre one of the Scan functions was called, setting g_MAX11131_device.NumWords
02255     /// @param[in] g_MAX11131_device.NumWords: number of words to be read from the FIFO
02256     /// @post g_MAX11131_device.RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
02257     /// @post g_MAX11131_device.AINcode[NUM_CHANNELS] contains the latest readings in LSBs
02258     ///
02259     void ReadAINcode(void);
02260 
02261     //----------------------------------------
02262     /// Sign-Extend a right-aligned MAX11131 code into a signed 2's complement value.
02263     /// Supports the bipolar transfer functions.
02264     /// @param[in] value_u12: raw 12-bit MAX11131 code (right justified).
02265     /// @return sign-extended 2's complement value.
02266     ///
02267     int32_t TwosComplementValue(uint32_t regValue);
02268 
02269     //----------------------------------------
02270     /// Return the physical voltage corresponding to MAX11131 code.
02271     /// Does not perform any offset or gain correction.
02272     /// @pre g_MAX11131_device.VRef = Voltage of REF input, in Volts
02273     /// @param[in] value_u12: raw 12-bit MAX11131 code (right justified).
02274     /// @param[in] channelId: AIN channel number.
02275     /// @return physical voltage corresponding to MAX11131 code.
02276     ///
02277     double VoltageOfCode(int16_t value_u12, int channelId);
02278 
02279     //----------------------------------------
02280     /// SCAN_0001_Manual
02281     ///
02282     /// Measure ADC channel channelNumber_0_15 once.
02283     /// External clock mode.
02284     /// @param[in] g_MAX11131_device.channelNumber_0_15: AIN Channel Number
02285     /// @param[in] g_MAX11131_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
02286     /// @param[in] g_MAX11131_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
02287     /// @return number of ScanRead() words needed to retrieve the data.
02288     /// @post NumWords = number of words to be read from the FIFO
02289     /// For external clock modes, the data format depends on CHAN_ID.
02290     ///     when CHAN_ID = 0: misoData16 = 0 DATA[11:0] x x x
02291     ///     when CHAN_ID = 1: misoData16 = CH[3:0] DATA[11:0]
02292     ///
02293     int ScanManual(void);
02294 
02295     //----------------------------------------
02296     /// SCAN_0010_Repeat
02297     ///
02298     /// Measure ADC channel channelNumber_0_15 repeatedly with averaging.
02299     /// Internal clock mode.
02300     /// @param[in] g_MAX11131_device.channelNumber_0_15: AIN Channel Number
02301     /// @param[in] g_MAX11131_device.average_0_4_8_16_32: Number of samples averaged per ScanRead() word.
02302     ///     average_0_4_8_16_32=0 to disable averaging.
02303     /// @param[in] g_MAX11131_device.nscan_4_8_12_16: Number of ScanRead() words to report.
02304     /// @param[in] g_MAX11131_device.swcnv_0_1: ADC_MODE_CONTROL.SWCNV
02305     ///     SWCNV=0: trigger measurement by driving CNVST pin low.
02306     ///         Minimum active-low pulse duration of 5ns. (AIN14 is not available)
02307     ///     SWCNV=1: trigger measurement on SPI CS rising edge.
02308     ///         CS must be held low for minimum of 17 SCLK cycles.
02309     ///         CNVST pin is not used. (AIN14 is available)
02310     /// @param[in] g_MAX11131_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
02311     /// @return number of ScanRead() words needed to retrieve the data.
02312     /// @post NumWords = number of words to be read from the FIFO
02313     /// For internal clock modes, the data format always includes the channel address.
02314     ///     misoData16 = CH[3:0] DATA[11:0]
02315     ///
02316     int ScanRepeat(void);
02317 
02318     //----------------------------------------
02319     /// SCAN_0011_StandardInternalClock
02320     ///
02321     /// Measure ADC channels in sequence from AIN0 to channelNumber_0_15.
02322     /// Internal clock mode.
02323     /// @param[in] g_MAX11131_device.channelNumber_0_15: AIN Channel Number
02324     /// @param[in] g_MAX11131_device.average_0_4_8_16_32: Number of samples averaged per ScanRead() word.
02325     ///     average_0_4_8_16_32=0 to disable averaging.
02326     /// @param[in] g_MAX11131_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
02327     /// @param[in] g_MAX11131_device.swcnv_0_1: ADC_MODE_CONTROL.SWCNV
02328     ///     SWCNV=0: trigger measurement by driving CNVST pin low.
02329     ///         Minimum active-low pulse duration of 5ns. (AIN14 is not available)
02330     ///     SWCNV=1: trigger measurement on SPI CS rising edge.
02331     ///         CS must be held low for minimum of 17 SCLK cycles.
02332     ///         CNVST pin is not used. (AIN14 is available)
02333     /// @return number of ScanRead() words needed to retrieve the data.
02334     /// @post NumWords = number of words to be read from the FIFO
02335     /// For internal clock modes, the data format always includes the channel address.
02336     ///     misoData16 = CH[3:0] DATA[11:0]
02337     ///
02338     int ScanStandardInternalClock(void);
02339 
02340     //----------------------------------------
02341     /// SCAN_0100_StandardExternalClock
02342     ///
02343     /// Measure ADC channels in sequence from AIN0 to channelNumber_0_15.
02344     /// External clock mode.
02345     /// @param[in] g_MAX11131_device.channelNumber_0_15: AIN Channel Number
02346     /// @param[in] g_MAX11131_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
02347     /// @param[in] g_MAX11131_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
02348     /// @return number of ScanRead() words needed to retrieve the data.
02349     /// @post NumWords = number of words to be read from the FIFO
02350     /// For external clock modes, the data format depends on CHAN_ID.
02351     ///     when CHAN_ID = 0: misoData16 = 0 DATA[11:0] x x x
02352     ///     when CHAN_ID = 1: misoData16 = CH[3:0] DATA[11:0]
02353     ///
02354     int ScanStandardExternalClock(void);
02355 
02356     //----------------------------------------
02357     /// SCAN_0101_UpperInternalClock
02358     ///
02359     /// Measure ADC channels in sequence from channelNumber_0_15 to AIN15.
02360     /// Internal clock mode.
02361     /// @param[in] g_MAX11131_device.channelNumber_0_15: AIN Channel Number
02362     /// @param[in] g_MAX11131_device.average_0_4_8_16_32: Number of samples averaged per ScanRead() word.
02363     ///     average_0_4_8_16_32=0 to disable averaging.
02364     /// @param[in] g_MAX11131_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
02365     /// @param[in] g_MAX11131_device.swcnv_0_1: ADC_MODE_CONTROL.SWCNV
02366     ///     SWCNV=0: trigger measurement by driving CNVST pin low.
02367     ///         Minimum active-low pulse duration of 5ns. (AIN14 is not available)
02368     ///     SWCNV=1: trigger measurement on SPI CS rising edge.
02369     ///         CS must be held low for minimum of 17 SCLK cycles.
02370     ///         CNVST pin is not used. (AIN14 is available)
02371     /// @return number of ScanRead() words needed to retrieve the data.
02372     /// @post NumWords = number of words to be read from the FIFO
02373     /// For internal clock modes, the data format always includes the channel address.
02374     ///     misoData16 = CH[3:0] DATA[11:0]
02375     ///
02376     int ScanUpperInternalClock(void);
02377 
02378     //----------------------------------------
02379     /// SCAN_0110_UpperExternalClock
02380     ///
02381     /// Measure ADC channels in sequence from channelNumber_0_15 to AIN15.
02382     /// External clock mode.
02383     /// @param[in] g_MAX11131_device.channelNumber_0_15: AIN Channel Number
02384     /// @param[in] g_MAX11131_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
02385     /// @param[in] g_MAX11131_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
02386     /// @return number of ScanRead() words needed to retrieve the data.
02387     /// @post NumWords = number of words to be read from the FIFO
02388     /// For external clock modes, the data format depends on CHAN_ID.
02389     ///     when CHAN_ID = 0: misoData16 = 0 DATA[11:0] x x x
02390     ///     when CHAN_ID = 1: misoData16 = CH[3:0] DATA[11:0]
02391     ///
02392     int ScanUpperExternalClock(void);
02393 
02394     //----------------------------------------
02395     /// SCAN_0111_CustomInternalClock
02396     ///
02397     /// Measure selected ADC channels in sequence from AIN0 to AIN15,
02398     ///     using only the channels enabled by enabledChannelsMask.
02399     ///     Bit 0x0001 enables AIN0.
02400     ///     Bit 0x0002 enables AIN1.
02401     ///     Bit 0x0004 enables AIN2.
02402     ///     Bit 0x0008 enables AIN3.
02403     ///     Bit 0x0010 enables AIN4.
02404     ///     Bit 0x0020 enables AIN5.
02405     ///     Bit 0x0040 enables AIN6.
02406     ///     Bit 0x0080 enables AIN7.
02407     ///     Bit 0x0100 enables AIN8.
02408     ///     Bit 0x0200 enables AIN9.
02409     ///     Bit 0x0400 enables AIN10.
02410     ///     Bit 0x0800 enables AIN11.
02411     ///     Bit 0x1000 enables AIN12.
02412     ///     Bit 0x2000 enables AIN13.
02413     ///     Bit 0x4000 enables AIN14.
02414     ///     Bit 0x8000 enables AIN15.
02415     /// Internal clock mode.
02416     /// @param[in] g_MAX11131_device.enabledChannelsMask: Bitmap of AIN Channels to scan.
02417     /// @param[in] g_MAX11131_device.average_0_4_8_16_32: Number of samples averaged per ScanRead() word.
02418     ///     average_0_4_8_16_32=0 to disable averaging.
02419     /// @param[in] g_MAX11131_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
02420     /// @param[in] g_MAX11131_device.swcnv_0_1: ADC_MODE_CONTROL.SWCNV
02421     ///     SWCNV=0: trigger measurement by driving CNVST pin low.
02422     ///         Minimum active-low pulse duration of 5ns. (AIN14 is not available)
02423     ///     SWCNV=1: trigger measurement on SPI CS rising edge.
02424     ///         CS must be held low for minimum of 17 SCLK cycles.
02425     ///         CNVST pin is not used. (AIN14 is available)
02426     /// @return number of ScanRead() words needed to retrieve the data.
02427     /// @post NumWords = number of words to be read from the FIFO
02428     /// For internal clock modes, the data format always includes the channel address.
02429     ///     misoData16 = CH[3:0] DATA[11:0]
02430     ///
02431     int ScanCustomInternalClock(void);
02432 
02433     //----------------------------------------
02434     /// SCAN_1000_CustomExternalClock
02435     ///
02436     /// Measure selected ADC channels in sequence from AIN0 to AIN15,
02437     ///     using only the channels enabled by enabledChannelsMask.
02438     ///     Bit 0x0001 enables AIN0.
02439     ///     Bit 0x0002 enables AIN1.
02440     ///     Bit 0x0004 enables AIN2.
02441     ///     Bit 0x0008 enables AIN3.
02442     ///     Bit 0x0010 enables AIN4.
02443     ///     Bit 0x0020 enables AIN5.
02444     ///     Bit 0x0040 enables AIN6.
02445     ///     Bit 0x0080 enables AIN7.
02446     ///     Bit 0x0100 enables AIN8.
02447     ///     Bit 0x0200 enables AIN9.
02448     ///     Bit 0x0400 enables AIN10.
02449     ///     Bit 0x0800 enables AIN11.
02450     ///     Bit 0x1000 enables AIN12.
02451     ///     Bit 0x2000 enables AIN13.
02452     ///     Bit 0x4000 enables AIN14.
02453     ///     Bit 0x8000 enables AIN15.
02454     /// External clock mode.
02455     /// @param[in] g_MAX11131_device.enabledChannelsMask: Bitmap of AIN Channels to scan.
02456     /// @param[in] g_MAX11131_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
02457     /// @param[in] g_MAX11131_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
02458     /// @return number of ScanRead() words needed to retrieve the data.
02459     /// @post NumWords = number of words to be read from the FIFO
02460     /// For external clock modes, the data format depends on CHAN_ID.
02461     ///     when CHAN_ID = 0: misoData16 = 0 DATA[11:0] x x x
02462     ///     when CHAN_ID = 1: misoData16 = CH[3:0] DATA[11:0]
02463     ///
02464     int ScanCustomExternalClock(void);
02465 
02466     //----------------------------------------
02467     /// SCAN_1001_SampleSetExternalClock
02468     ///
02469     /// Measure ADC channels in an arbitrary pattern.
02470     ///     Channels can be visited in any order, with repetition allowed.
02471     /// External clock mode.
02472     /// @pre g_MAX11131_device.enabledChannelsPatternLength_1_256: number of channel selections
02473     /// @pre g_MAX11131_device.enabledChannelsPattern: array containing channel selection pattern
02474     ///     In the array, one channel select per byte.
02475     ///     In the SPI interface, immediately after SAMPLESET register is written,
02476     ///     each byte encodes two channelNumber selections.
02477     ///     The high 4 bits encode the first channelNumber.
02478     ///     (((enabledChannelsPattern[0]) & 0x0F) << 4) | ((enabledChannelsPattern[1]) & 0x0F)
02479     ///     If it is an odd number of channels, additional nybbles will be ignored.
02480     ///     CS will be asserted low during the entire SAMPLESET pattern selection.
02481     /// @param[in] g_MAX11131_device.enabledChannelsPattern: array of channel select, one channel per byte
02482     /// @param[in] g_MAX11131_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
02483     /// @param[in] g_MAX11131_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
02484     /// @return number of ScanRead() words needed to retrieve the data.
02485     /// @post NumWords = number of words to be read from the FIFO
02486     /// For external clock modes, the data format depends on CHAN_ID.
02487     ///     when CHAN_ID = 0: misoData16 = 0 DATA[11:0] x x x
02488     ///     when CHAN_ID = 1: misoData16 = CH[3:0] DATA[11:0]
02489     ///
02490     int ScanSampleSetExternalClock(void);
02491 
02492     //----------------------------------------
02493     /// Example configure and perform some measurements in ScanManual mode.
02494     /// @param[out] pd_mean = address for double mean (avearge)
02495     /// @param[out] pd_variance = address for double variance (variance)
02496     /// @param[out] pd_stddev = address for double stddev (standard deviation)
02497     /// @param[out] pd_Sx = address for double Sx (sum of all X)
02498     /// @param[out] pd_Sxx = address for double Sxx (sum of squares of each X)
02499     void Example_ScanManual(int channelNumber_0_15, int nWords, 
02500   double* pd_mean, double* pd_variance, double* pd_stddev, 
02501   double* pd_Sx, double* pd_Sxx);
02502 
02503 }; // end of class MAX11131
02504 
02505 #endif // __MAX11131_H__
02506 
02507 // End of file