Test program running on MAX32625MBED. Control through USB Serial commands using a terminal emulator such as teraterm or putty.

Dependencies:   MaximTinyTester CmdLine MAX541 USBDevice

Committer:
whismanoid
Date:
Wed Mar 04 10:03:12 2020 +0000
Revision:
93:6b22269935a6
Parent:
90:d6ed8a8c5f26
ADCVoltageOfCode_16bit; fix typo Write_AGain 0x2000=1V/V not 1VV/V; onButton2FallingEdge call optional Configure_Demo(); blue LED on

Who changed what in which revision?

UserRevisionLine numberNew contents of line
whismanoid 53:3d5a3d241a5e 1 // /*******************************************************************************
whismanoid 53:3d5a3d241a5e 2 // * Copyright (C) 2020 Maxim Integrated Products, Inc., All Rights Reserved.
whismanoid 53:3d5a3d241a5e 3 // *
whismanoid 53:3d5a3d241a5e 4 // * Permission is hereby granted, free of charge, to any person obtaining a
whismanoid 53:3d5a3d241a5e 5 // * copy of this software and associated documentation files (the "Software"),
whismanoid 53:3d5a3d241a5e 6 // * to deal in the Software without restriction, including without limitation
whismanoid 53:3d5a3d241a5e 7 // * the rights to use, copy, modify, merge, publish, distribute, sublicense,
whismanoid 53:3d5a3d241a5e 8 // * and/or sell copies of the Software, and to permit persons to whom the
whismanoid 53:3d5a3d241a5e 9 // * Software is furnished to do so, subject to the following conditions:
whismanoid 53:3d5a3d241a5e 10 // *
whismanoid 53:3d5a3d241a5e 11 // * The above copyright notice and this permission notice shall be included
whismanoid 53:3d5a3d241a5e 12 // * in all copies or substantial portions of the Software.
whismanoid 53:3d5a3d241a5e 13 // *
whismanoid 53:3d5a3d241a5e 14 // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
whismanoid 53:3d5a3d241a5e 15 // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
whismanoid 53:3d5a3d241a5e 16 // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
whismanoid 53:3d5a3d241a5e 17 // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
whismanoid 53:3d5a3d241a5e 18 // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
whismanoid 53:3d5a3d241a5e 19 // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
whismanoid 53:3d5a3d241a5e 20 // * OTHER DEALINGS IN THE SOFTWARE.
whismanoid 53:3d5a3d241a5e 21 // *
whismanoid 53:3d5a3d241a5e 22 // * Except as contained in this notice, the name of Maxim Integrated
whismanoid 53:3d5a3d241a5e 23 // * Products, Inc. shall not be used except as stated in the Maxim Integrated
whismanoid 53:3d5a3d241a5e 24 // * Products, Inc. Branding Policy.
whismanoid 53:3d5a3d241a5e 25 // *
whismanoid 53:3d5a3d241a5e 26 // * The mere transfer of this software does not imply any licenses
whismanoid 53:3d5a3d241a5e 27 // * of trade secrets, proprietary technology, copyrights, patents,
whismanoid 53:3d5a3d241a5e 28 // * trademarks, maskwork rights, or any other form of intellectual
whismanoid 53:3d5a3d241a5e 29 // * property whatsoever. Maxim Integrated Products, Inc. retains all
whismanoid 53:3d5a3d241a5e 30 // * ownership rights.
whismanoid 53:3d5a3d241a5e 31 // *******************************************************************************
whismanoid 53:3d5a3d241a5e 32 // */
whismanoid 53:3d5a3d241a5e 33 // *********************************************************************
whismanoid 53:3d5a3d241a5e 34 // @file MAX11043.h
whismanoid 53:3d5a3d241a5e 35 // *********************************************************************
whismanoid 53:3d5a3d241a5e 36 // Header file
whismanoid 83:29bb86cc45bc 37 // DO NOT EDIT; except areas designated "CUSTOMIZE". Automatically generated file. * MANUAL EDITS PRESENT *
whismanoid 53:3d5a3d241a5e 38 // generated by XMLSystemOfDevicesToMBED.py
whismanoid 53:3d5a3d241a5e 39 // System Name = ExampleSystem
whismanoid 53:3d5a3d241a5e 40 // System Description = Device driver example
whismanoid 53:3d5a3d241a5e 41 // Device Name = MAX11043
whismanoid 53:3d5a3d241a5e 42 // Device Description = 200ksps, Low-Power, Serial SPI 24-Bit, 4-Channel, Differential/Single-Ended Input, Simultaneous-Sampling SD ADC
whismanoid 53:3d5a3d241a5e 43 // Device DeviceBriefDescription = 24-bit 200ksps Delta-Sigma ADC
whismanoid 53:3d5a3d241a5e 44 // Device Manufacturer = Maxim Integrated
whismanoid 53:3d5a3d241a5e 45 // Device PartNumber = MAX11043ATL+
whismanoid 53:3d5a3d241a5e 46 // Device RegValue_Width = DataWidth16bit_HL
whismanoid 53:3d5a3d241a5e 47 //
whismanoid 53:3d5a3d241a5e 48 // ADC MaxOutputDataRate = 200ksps
whismanoid 53:3d5a3d241a5e 49 // ADC NumChannels = 4
whismanoid 53:3d5a3d241a5e 50 // ADC ResolutionBits = 24
whismanoid 53:3d5a3d241a5e 51 //
whismanoid 53:3d5a3d241a5e 52 // SPI CS = ActiveLow
whismanoid 53:3d5a3d241a5e 53 // SPI FrameStart = CS
whismanoid 53:3d5a3d241a5e 54 // SPI CPOL = 0
whismanoid 53:3d5a3d241a5e 55 // SPI CPHA = 0
whismanoid 53:3d5a3d241a5e 56 // SPI MOSI and MISO Data are both stable on Rising edge of SCLK
whismanoid 53:3d5a3d241a5e 57 // SPI SCLK Idle Low
whismanoid 53:3d5a3d241a5e 58 // SPI SCLKMaxMHz = 40
whismanoid 53:3d5a3d241a5e 59 // SPI SCLKMinMHz = 0
whismanoid 53:3d5a3d241a5e 60 //
whismanoid 53:3d5a3d241a5e 61
whismanoid 53:3d5a3d241a5e 62
whismanoid 53:3d5a3d241a5e 63 // Prevent multiple declaration
whismanoid 53:3d5a3d241a5e 64 #ifndef __MAX11043_H__
whismanoid 53:3d5a3d241a5e 65 #define __MAX11043_H__
whismanoid 53:3d5a3d241a5e 66
whismanoid 69:989e392cf635 67 //--------------------------------------------------
whismanoid 69:989e392cf635 68 // MAX11043 ADC Read operations must be synchronized to EOC End Of Conversion
whismanoid 69:989e392cf635 69 // EOC# asserts low when new data is available.
whismanoid 69:989e392cf635 70 // Initiate a data read prior to the next rising edge of EOC# or the result is overwritten.
whismanoid 69:989e392cf635 71 #ifndef MAX11043_EOC_INTERRUPT_POLLING
whismanoid 82:9ea067fad5c3 72 #define MAX11043_EOC_INTERRUPT_POLLING 1
whismanoid 69:989e392cf635 73 #endif // MAX11043_EOC_INTERRUPT_POLLING
whismanoid 69:989e392cf635 74 //--------------------------------------------------
whismanoid 69:989e392cf635 75 // MAX11043 ADC Read operations must be synchronized to EOC End Of Conversion
whismanoid 69:989e392cf635 76 // EOC# asserts low when new data is available.
whismanoid 69:989e392cf635 77 // Initiate a data read prior to the next rising edge of EOC# or the result is overwritten.
whismanoid 69:989e392cf635 78 #if MAX11043_EOC_INTERRUPT_POLLING
whismanoid 69:989e392cf635 79 // MAX11043 EOC End Of Conversion input should be InterruptIn(PinName:EOC_pin).fall(onEOCFallingEdge);
whismanoid 69:989e392cf635 80 // Workaround using DigitalIn(PinName:EOC_pin) polled to sync with EOC falling edge for ADC reads
whismanoid 69:989e392cf635 81 // 2020-02-20 MAX11043_EOC_INTERRUPT_POLLING works on MAX32625MBED at 9us conversion rate, with 1us timing margin
whismanoid 69:989e392cf635 82 #else // MAX11043_EOC_INTERRUPT_POLLING
whismanoid 69:989e392cf635 83 // MAX11043 EOC End Of Conversion input is InterruptIn(PinName:EOC_pin).fall(onEOCFallingEdge);
whismanoid 69:989e392cf635 84 #endif // MAX11043_EOC_INTERRUPT_POLLING
whismanoid 69:989e392cf635 85 //--------------------------------------------------
whismanoid 69:989e392cf635 86
whismanoid 53:3d5a3d241a5e 87 // standard include for target platform -- Platform_Include_Boilerplate
whismanoid 53:3d5a3d241a5e 88 #include "mbed.h"
whismanoid 53:3d5a3d241a5e 89 // Platforms:
whismanoid 53:3d5a3d241a5e 90 // - MAX32625MBED
whismanoid 53:3d5a3d241a5e 91 // - supports mbed-os-5.11, requires USBDevice library
whismanoid 53:3d5a3d241a5e 92 // - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
whismanoid 53:3d5a3d241a5e 93 // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 94 // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 95 // - MAX32600MBED
whismanoid 53:3d5a3d241a5e 96 // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 97 // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 98 // - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board.
whismanoid 53:3d5a3d241a5e 99 // - NUCLEO_F446RE
whismanoid 53:3d5a3d241a5e 100 // - remove USBDevice library
whismanoid 53:3d5a3d241a5e 101 // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 102 // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 103 // - NUCLEO_F401RE
whismanoid 53:3d5a3d241a5e 104 // - remove USBDevice library
whismanoid 53:3d5a3d241a5e 105 // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 106 // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 107 // - MAX32630FTHR
whismanoid 53:3d5a3d241a5e 108 // - #include "max32630fthr.h"
whismanoid 53:3d5a3d241a5e 109 // - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/
whismanoid 53:3d5a3d241a5e 110 // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 111 // - MAX32620FTHR
whismanoid 53:3d5a3d241a5e 112 // - #include "MAX32620FTHR.h"
whismanoid 53:3d5a3d241a5e 113 // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 114 // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
whismanoid 53:3d5a3d241a5e 115 // - not tested yet
whismanoid 53:3d5a3d241a5e 116 // - MAX32625PICO
whismanoid 53:3d5a3d241a5e 117 // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 118 // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 119 // - not tested yet
whismanoid 53:3d5a3d241a5e 120 //
whismanoid 53:3d5a3d241a5e 121 // end Platform_Include_Boilerplate
whismanoid 53:3d5a3d241a5e 122
whismanoid 53:3d5a3d241a5e 123 // CODE GENERATOR: conditional defines
whismanoid 53:3d5a3d241a5e 124 // CODE GENERATOR: class declaration and docstrings
whismanoid 53:3d5a3d241a5e 125 /**
whismanoid 53:3d5a3d241a5e 126 * @brief MAX11043 200ksps, Low-Power, Serial SPI 24-Bit, 4-Channel, Differential/Single-Ended Input, Simultaneous-Sampling SD ADC
whismanoid 53:3d5a3d241a5e 127 *
whismanoid 53:3d5a3d241a5e 128 *
whismanoid 53:3d5a3d241a5e 129 *
whismanoid 53:3d5a3d241a5e 130 * Datasheet: https://www.maximintegrated.com/MAX11043
whismanoid 53:3d5a3d241a5e 131 *
whismanoid 53:3d5a3d241a5e 132 *
whismanoid 53:3d5a3d241a5e 133 *
whismanoid 53:3d5a3d241a5e 134 * //---------- CODE GENERATOR: helloCppCodeList
whismanoid 53:3d5a3d241a5e 135 * @code
whismanoid 53:3d5a3d241a5e 136 * // CODE GENERATOR: example code includes
whismanoid 53:3d5a3d241a5e 137 *
whismanoid 53:3d5a3d241a5e 138 * // example code includes
whismanoid 53:3d5a3d241a5e 139 * // standard include for target platform -- Platform_Include_Boilerplate
whismanoid 53:3d5a3d241a5e 140 * #include "mbed.h"
whismanoid 53:3d5a3d241a5e 141 * // Platforms:
whismanoid 53:3d5a3d241a5e 142 * // - MAX32625MBED
whismanoid 53:3d5a3d241a5e 143 * // - supports mbed-os-5.11, requires USBDevice library
whismanoid 53:3d5a3d241a5e 144 * // - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
whismanoid 53:3d5a3d241a5e 145 * // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 146 * // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 147 * // - MAX32600MBED
whismanoid 53:3d5a3d241a5e 148 * // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 149 * // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 150 * // - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board.
whismanoid 53:3d5a3d241a5e 151 * // - NUCLEO_F446RE
whismanoid 53:3d5a3d241a5e 152 * // - remove USBDevice library
whismanoid 53:3d5a3d241a5e 153 * // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 154 * // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 155 * // - NUCLEO_F401RE
whismanoid 53:3d5a3d241a5e 156 * // - remove USBDevice library
whismanoid 53:3d5a3d241a5e 157 * // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 158 * // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 159 * // - MAX32630FTHR
whismanoid 53:3d5a3d241a5e 160 * // - #include "max32630fthr.h"
whismanoid 53:3d5a3d241a5e 161 * // - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/
whismanoid 53:3d5a3d241a5e 162 * // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 163 * // - MAX32620FTHR
whismanoid 53:3d5a3d241a5e 164 * // - #include "MAX32620FTHR.h"
whismanoid 53:3d5a3d241a5e 165 * // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 166 * // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
whismanoid 53:3d5a3d241a5e 167 * // - not tested yet
whismanoid 53:3d5a3d241a5e 168 * // - MAX32625PICO
whismanoid 53:3d5a3d241a5e 169 * // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 170 * // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 171 * // - not tested yet
whismanoid 53:3d5a3d241a5e 172 * //
whismanoid 53:3d5a3d241a5e 173 * // end Platform_Include_Boilerplate
whismanoid 53:3d5a3d241a5e 174 * #include "MAX11043.h"
whismanoid 53:3d5a3d241a5e 175 *
whismanoid 53:3d5a3d241a5e 176 * // example code board support
whismanoid 53:3d5a3d241a5e 177 * //MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 53:3d5a3d241a5e 178 * //DigitalOut rLED(LED1);
whismanoid 53:3d5a3d241a5e 179 * //DigitalOut gLED(LED2);
whismanoid 53:3d5a3d241a5e 180 * //DigitalOut bLED(LED3);
whismanoid 53:3d5a3d241a5e 181 * //
whismanoid 53:3d5a3d241a5e 182 * // Arduino "shield" connector port definitions (MAX32625MBED shown)
whismanoid 53:3d5a3d241a5e 183 * #if defined(TARGET_MAX32625MBED)
whismanoid 53:3d5a3d241a5e 184 * #define A0 AIN_0
whismanoid 53:3d5a3d241a5e 185 * #define A1 AIN_1
whismanoid 53:3d5a3d241a5e 186 * #define A2 AIN_2
whismanoid 53:3d5a3d241a5e 187 * #define A3 AIN_3
whismanoid 53:3d5a3d241a5e 188 * #define D0 P0_0
whismanoid 53:3d5a3d241a5e 189 * #define D1 P0_1
whismanoid 53:3d5a3d241a5e 190 * #define D2 P0_2
whismanoid 53:3d5a3d241a5e 191 * #define D3 P0_3
whismanoid 53:3d5a3d241a5e 192 * #define D4 P0_4
whismanoid 53:3d5a3d241a5e 193 * #define D5 P0_5
whismanoid 53:3d5a3d241a5e 194 * #define D6 P0_6
whismanoid 53:3d5a3d241a5e 195 * #define D7 P0_7
whismanoid 53:3d5a3d241a5e 196 * #define D8 P1_4
whismanoid 53:3d5a3d241a5e 197 * #define D9 P1_5
whismanoid 53:3d5a3d241a5e 198 * #define D10 P1_3
whismanoid 53:3d5a3d241a5e 199 * #define D11 P1_1
whismanoid 53:3d5a3d241a5e 200 * #define D12 P1_2
whismanoid 53:3d5a3d241a5e 201 * #define D13 P1_0
whismanoid 53:3d5a3d241a5e 202 * #endif
whismanoid 53:3d5a3d241a5e 203 *
whismanoid 53:3d5a3d241a5e 204 * // example code declare SPI interface
whismanoid 53:3d5a3d241a5e 205 * #if defined(TARGET_MAX32625MBED)
whismanoid 68:ffee1e54d3fe 206 * // 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 D10
whismanoid 68:ffee1e54d3fe 207 * // DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: not connected
whismanoid 68:ffee1e54d3fe 208 * // Support SPI hardware-controlled CS instead of GPIO CS (mbed)
whismanoid 68:ffee1e54d3fe 209 * // 2020-02-19 MAX32625MBED GPIO CS envelope is 23us (11.4us before SCLK and 8.6us after SCLK).
whismanoid 68:ffee1e54d3fe 210 * // 2020-02-19 MAX32625MBED SPI controlled CS envelope 4 channel read reduced to 4.2us (24MHz SCLK), 1.2us setup, 0us hold.
whismanoid 68:ffee1e54d3fe 211 * // 2020-02-19 MAX11043 slowest EOC rate is 9us.
whismanoid 67:5b8a495dda1c 212 * SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK, SPI1_SS); // mosi, miso, sclk spi1 TARGET_MAX32625MBED: P1_1 P1_2 P1_0 Arduino 10-pin header D11 D12 D13 D10
whismanoid 67:5b8a495dda1c 213 * DigitalOut spi_cs(NC); // TARGET_MAX32625MBED: not connected
whismanoid 67:5b8a495dda1c 214 * // PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false
whismanoid 68:ffee1e54d3fe 215 * // add m_cs_pin.is_connected() guard before writing m_cs_pin = m_SPI_cs_state
whismanoid 68:ffee1e54d3fe 216 * // to avoid runtime error Assertion failed: obj->name != (PinName)NC
whismanoid 53:3d5a3d241a5e 217 * #elif defined(TARGET_MAX32600MBED)
whismanoid 53:3d5a3d241a5e 218 * SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 53:3d5a3d241a5e 219 * DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 53:3d5a3d241a5e 220 * #else
whismanoid 53:3d5a3d241a5e 221 * SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 53:3d5a3d241a5e 222 * DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
whismanoid 53:3d5a3d241a5e 223 * #endif
whismanoid 53:3d5a3d241a5e 224 *
whismanoid 53:3d5a3d241a5e 225 * // example code declare GPIO interface pins
whismanoid 53:3d5a3d241a5e 226 * DigitalOut CONVRUN_pin(D9); // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 227 * DigitalOut SHDN_pin(D8); // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 228 * DigitalOut DACSTEP_pin(D7); // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 229 * DigitalOut UP_slash_DWNb_pin(D6); // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 230 * DigitalIn EOC_pin(D2); // Digital Event Output from MAX11043 device
whismanoid 53:3d5a3d241a5e 231 * // example code declare device instance
whismanoid 53:3d5a3d241a5e 232 * MAX11043 g_MAX11043_device(spi, spi_cs, CONVRUN_pin, SHDN_pin, DACSTEP_pin, UP_slash_DWNb_pin, EOC_pin, MAX11043::MAX11043_IC);
whismanoid 53:3d5a3d241a5e 233 *
whismanoid 53:3d5a3d241a5e 234 * // CODE GENERATOR: example code for ADC: serial port declaration
whismanoid 53:3d5a3d241a5e 235 * //--------------------------------------------------
whismanoid 53:3d5a3d241a5e 236 * // Declare the Serial driver
whismanoid 53:3d5a3d241a5e 237 * // default baud rate settings are 9600 8N1
whismanoid 53:3d5a3d241a5e 238 * // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
whismanoid 53:3d5a3d241a5e 239 * // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
whismanoid 53:3d5a3d241a5e 240 * #if defined(TARGET_MAX32630)
whismanoid 53:3d5a3d241a5e 241 * #include "USBSerial.h"
whismanoid 53:3d5a3d241a5e 242 * // Hardware serial port over DAPLink
whismanoid 53:3d5a3d241a5e 243 * // The default baud rate for the DapLink UART is 9600
whismanoid 53:3d5a3d241a5e 244 * //Serial DAPLINKserial(P2_1, P2_0); // tx, rx
whismanoid 53:3d5a3d241a5e 245 * // #define HAS_DAPLINK_SERIAL 1
whismanoid 53:3d5a3d241a5e 246 * // Virtual serial port over USB
whismanoid 53:3d5a3d241a5e 247 * // The baud rate does not affect the virtual USBSerial UART.
whismanoid 53:3d5a3d241a5e 248 * USBSerial serial;
whismanoid 53:3d5a3d241a5e 249 * //--------------------------------------------------
whismanoid 53:3d5a3d241a5e 250 * #elif defined(TARGET_MAX32625MBED)
whismanoid 53:3d5a3d241a5e 251 * #include "USBSerial.h"
whismanoid 53:3d5a3d241a5e 252 * // Hardware serial port over DAPLink
whismanoid 53:3d5a3d241a5e 253 * // The default baud rate for the DapLink UART is 9600
whismanoid 53:3d5a3d241a5e 254 * //Serial DAPLINKserial(P2_1, P2_0); // tx, rx
whismanoid 53:3d5a3d241a5e 255 * // #define HAS_DAPLINK_SERIAL 1
whismanoid 53:3d5a3d241a5e 256 * // Virtual serial port over USB
whismanoid 53:3d5a3d241a5e 257 * // The baud rate does not affect the virtual USBSerial UART.
whismanoid 53:3d5a3d241a5e 258 * USBSerial serial;
whismanoid 53:3d5a3d241a5e 259 * //--------------------------------------------------
whismanoid 53:3d5a3d241a5e 260 * #elif defined(TARGET_MAX32600)
whismanoid 53:3d5a3d241a5e 261 * #include "USBSerial.h"
whismanoid 53:3d5a3d241a5e 262 * // Hardware serial port over DAPLink
whismanoid 53:3d5a3d241a5e 263 * // The default baud rate for the DapLink UART is 9600
whismanoid 53:3d5a3d241a5e 264 * Serial DAPLINKserial(P1_1, P1_0); // tx, rx
whismanoid 53:3d5a3d241a5e 265 * #define HAS_DAPLINK_SERIAL 1
whismanoid 53:3d5a3d241a5e 266 * // Virtual serial port over USB
whismanoid 53:3d5a3d241a5e 267 * // The baud rate does not affect the virtual USBSerial UART.
whismanoid 53:3d5a3d241a5e 268 * USBSerial serial;
whismanoid 53:3d5a3d241a5e 269 * //--------------------------------------------------
whismanoid 53:3d5a3d241a5e 270 * #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 53:3d5a3d241a5e 271 * Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 53:3d5a3d241a5e 272 * //--------------------------------------------------
whismanoid 53:3d5a3d241a5e 273 * #else
whismanoid 53:3d5a3d241a5e 274 * #if defined(SERIAL_TX)
whismanoid 53:3d5a3d241a5e 275 * #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..."
whismanoid 53:3d5a3d241a5e 276 * Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 53:3d5a3d241a5e 277 * #elif defined(USBTX)
whismanoid 53:3d5a3d241a5e 278 * #warning "target not previously tested; guess serial pins are USBTX, USBRX..."
whismanoid 53:3d5a3d241a5e 279 * Serial serial(USBTX, USBRX); // tx, rx
whismanoid 53:3d5a3d241a5e 280 * #elif defined(UART_TX)
whismanoid 53:3d5a3d241a5e 281 * #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..."
whismanoid 53:3d5a3d241a5e 282 * Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 53:3d5a3d241a5e 283 * #else
whismanoid 53:3d5a3d241a5e 284 * #warning "target not previously tested; need to define serial pins..."
whismanoid 53:3d5a3d241a5e 285 * #endif
whismanoid 53:3d5a3d241a5e 286 * #endif
whismanoid 53:3d5a3d241a5e 287 * //
whismanoid 53:3d5a3d241a5e 288 * #include "CmdLine.h"
whismanoid 53:3d5a3d241a5e 289 * CmdLine cmdLine(serial, "serial");
whismanoid 53:3d5a3d241a5e 290 *
whismanoid 53:3d5a3d241a5e 291 * // example code main function
whismanoid 53:3d5a3d241a5e 292 * int main()
whismanoid 53:3d5a3d241a5e 293 * {
whismanoid 53:3d5a3d241a5e 294 * // CODE GENERATOR: example code: member function Init
whismanoid 53:3d5a3d241a5e 295 * g_MAX11043_device.Init();
whismanoid 53:3d5a3d241a5e 296 *
whismanoid 53:3d5a3d241a5e 297 * while (1)
whismanoid 53:3d5a3d241a5e 298 * {
whismanoid 53:3d5a3d241a5e 299 * // CODE GENERATOR: example code: has no member function REF
whismanoid 53:3d5a3d241a5e 300 * // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line
whismanoid 53:3d5a3d241a5e 301 * // CODE GENERATOR: ResolutionBits = 24
whismanoid 53:3d5a3d241a5e 302 * // CODE GENERATOR: FScode = None
whismanoid 53:3d5a3d241a5e 303 * // CODE GENERATOR: NumChannels = 4
whismanoid 53:3d5a3d241a5e 304 * while(1) { // this code repeats forever
whismanoid 53:3d5a3d241a5e 305 * // this code repeats forever
whismanoid 53:3d5a3d241a5e 306 * // CODE GENERATOR: example code: has no member function ScanStandardExternalClock
whismanoid 53:3d5a3d241a5e 307 * // CODE GENERATOR: example code: has no member function ReadAINcode
whismanoid 53:3d5a3d241a5e 308 * // wait(3.0);
whismanoid 53:3d5a3d241a5e 309 * // CODE GENERATOR: print conversion result
whismanoid 53:3d5a3d241a5e 310 * // Use Arduino Serial Plotter to view output: Tools | Serial Plotter
whismanoid 53:3d5a3d241a5e 311 * cmdLine.serial().printf("%d", g_MAX11043_device.AINcode[0]);
whismanoid 53:3d5a3d241a5e 312 * for (int index = 1; index <= channelId_0_3; index++) {
whismanoid 53:3d5a3d241a5e 313 * cmdLine.serial().printf(",%d", g_MAX11043_device.AINcode[index]);
whismanoid 53:3d5a3d241a5e 314 * }
whismanoid 53:3d5a3d241a5e 315 * cmdLine.serial().printf("\r\n");
whismanoid 53:3d5a3d241a5e 316 *
whismanoid 53:3d5a3d241a5e 317 * } // this code repeats forever
whismanoid 53:3d5a3d241a5e 318 * }
whismanoid 53:3d5a3d241a5e 319 * }
whismanoid 53:3d5a3d241a5e 320 * @endcode
whismanoid 53:3d5a3d241a5e 321 * //---------- CODE GENERATOR: end helloCppCodeList
whismanoid 53:3d5a3d241a5e 322 */
whismanoid 53:3d5a3d241a5e 323 class MAX11043 {
whismanoid 53:3d5a3d241a5e 324 public:
whismanoid 53:3d5a3d241a5e 325 // CODE GENERATOR: TypedefEnum EnumItem declarations
whismanoid 57:1c9da8e90737 326 // CODE GENERATOR: TypedefEnum MAX11043_CMDOP_enum_t
whismanoid 57:1c9da8e90737 327 //----------------------------------------
whismanoid 57:1c9da8e90737 328 /// Command Operation Format (see function DecodeCommand)
whismanoid 57:1c9da8e90737 329 ///
whismanoid 57:1c9da8e90737 330 /// Naming convention is CMDOP_bitstream_OPERATION_NAME
whismanoid 57:1c9da8e90737 331 /// - 0aaa_aax0 = 5-bit register address field
whismanoid 57:1c9da8e90737 332 /// - 0xxx_xxr0 = read/write bit (1=read, 0=write)
whismanoid 57:1c9da8e90737 333 /// - xxxx = don't care
whismanoid 57:1c9da8e90737 334 typedef enum MAX11043_CMDOP_enum_t {
whismanoid 57:1c9da8e90737 335 CMDOP_0aaa_aa00_WriteRegister = 0x00, //!< 8'b00000000
whismanoid 57:1c9da8e90737 336 CMDOP_0aaa_aa10_ReadRegister = 0x02, //!< 8'b00000010
whismanoid 57:1c9da8e90737 337 CMDOP_1111_1111_NoOperationMOSIidleHigh = 0xff, //!< 8'b11111111
whismanoid 57:1c9da8e90737 338 } MAX11043_CMDOP_enum_t;
whismanoid 57:1c9da8e90737 339
whismanoid 53:3d5a3d241a5e 340 // CODE GENERATOR: TypedefEnum MAX11043_CMD_enum_t
whismanoid 53:3d5a3d241a5e 341 //----------------------------------------
whismanoid 53:3d5a3d241a5e 342 /// Register Addresses
whismanoid 53:3d5a3d241a5e 343 ///
whismanoid 53:3d5a3d241a5e 344 /// Naming convention is CMD_bitstream_WrAddr_FunctionName
whismanoid 53:3d5a3d241a5e 345 /// - first byte format is 0aaa_aar0
whismanoid 53:3d5a3d241a5e 346 /// - 0 = bitstream required 0 bit
whismanoid 53:3d5a3d241a5e 347 /// - aaa_aa = bitstream 5-bit register address field
whismanoid 53:3d5a3d241a5e 348 /// - r = bitstream read/write bit (1=read, 0=write)
whismanoid 53:3d5a3d241a5e 349 /// - WrAddr = Write operation to address Addr
whismanoid 53:3d5a3d241a5e 350 /// - RdAddr = Read operation from address Addr
whismanoid 53:3d5a3d241a5e 351 /// - d8 = 8-bit register data field
whismanoid 53:3d5a3d241a5e 352 /// - d16 = 16-bit register data field
whismanoid 59:47538bcf6cda 353 /// - d16o8 = 16-bit or 24-bit register data field
whismanoid 53:3d5a3d241a5e 354 /// - d24 = 24-bit register data field
whismanoid 53:3d5a3d241a5e 355 /// - d32 = 32-bit register data field
whismanoid 53:3d5a3d241a5e 356 /// - x = don't care
whismanoid 53:3d5a3d241a5e 357 typedef enum MAX11043_CMD_enum_t {
whismanoid 59:47538bcf6cda 358 CMD_0000_0010_d16o8_Rd00_ADCa = 0x02, //!< 8'b00000010
whismanoid 59:47538bcf6cda 359 CMD_0000_0110_d16o8_Rd01_ADCb = 0x06, //!< 8'b00000110
whismanoid 59:47538bcf6cda 360 CMD_0000_1010_d16o8_Rd02_ADCc = 0x0a, //!< 8'b00001010
whismanoid 59:47538bcf6cda 361 CMD_0000_1110_d16o8_Rd03_ADCd = 0x0e, //!< 8'b00001110
whismanoid 63:8f39d21d6157 362 CMD_0001_0010_d16o8_d16o8_Rd04_ADCab = 0x12, //!< 8'b00010010
whismanoid 63:8f39d21d6157 363 CMD_0001_0110_d16o8_d16o8_Rd05_ADCcd = 0x16, //!< 8'b00010110
whismanoid 63:8f39d21d6157 364 CMD_0001_1010_d16o8_d16o8_d16o8_d16o8_Rd06_ADCabcd = 0x1a, //!< 8'b00011010
whismanoid 53:3d5a3d241a5e 365 CMD_0001_1110_d8_Rd07_Status = 0x1e, //!< 8'b00011110
whismanoid 53:3d5a3d241a5e 366 CMD_0010_0000_d16_Wr08_Configuration = 0x20, //!< 8'b00100000
whismanoid 53:3d5a3d241a5e 367 CMD_0010_0010_d16_Rd08_Configuration = 0x22, //!< 8'b00100010
whismanoid 53:3d5a3d241a5e 368 CMD_0010_0100_d16_Wr09_DAC = 0x24, //!< 8'b00100100
whismanoid 53:3d5a3d241a5e 369 CMD_0010_0110_d16_Rd09_DAC = 0x26, //!< 8'b00100110
whismanoid 53:3d5a3d241a5e 370 CMD_0010_1000_d16_Wr0A_DACStep = 0x28, //!< 8'b00101000
whismanoid 53:3d5a3d241a5e 371 CMD_0010_1010_d16_Rd0A_DACStep = 0x2a, //!< 8'b00101010
whismanoid 53:3d5a3d241a5e 372 CMD_0010_1100_d16_Wr0B_DACHDACL = 0x2c, //!< 8'b00101100
whismanoid 53:3d5a3d241a5e 373 CMD_0010_1110_d16_Rd0B_DACHDACL = 0x2e, //!< 8'b00101110
whismanoid 53:3d5a3d241a5e 374 CMD_0011_0000_d16_Wr0C_ConfigA = 0x30, //!< 8'b00110000
whismanoid 53:3d5a3d241a5e 375 CMD_0011_0010_d16_Rd0C_ConfigA = 0x32, //!< 8'b00110010
whismanoid 53:3d5a3d241a5e 376 CMD_0011_0100_d16_Wr0D_ConfigB = 0x34, //!< 8'b00110100
whismanoid 53:3d5a3d241a5e 377 CMD_0011_0110_d16_Rd0D_ConfigB = 0x36, //!< 8'b00110110
whismanoid 53:3d5a3d241a5e 378 CMD_0011_1000_d16_Wr0E_ConfigC = 0x38, //!< 8'b00111000
whismanoid 53:3d5a3d241a5e 379 CMD_0011_1010_d16_Rd0E_ConfigC = 0x3a, //!< 8'b00111010
whismanoid 53:3d5a3d241a5e 380 CMD_0011_1100_d16_Wr0F_ConfigD = 0x3c, //!< 8'b00111100
whismanoid 53:3d5a3d241a5e 381 CMD_0011_1110_d16_Rd0F_ConfigD = 0x3e, //!< 8'b00111110
whismanoid 53:3d5a3d241a5e 382 CMD_0100_0000_d16_Wr10_Reference = 0x40, //!< 8'b01000000
whismanoid 53:3d5a3d241a5e 383 CMD_0100_0010_d16_Rd10_Reference = 0x42, //!< 8'b01000010
whismanoid 53:3d5a3d241a5e 384 CMD_0100_0100_d16_Wr11_AGain = 0x44, //!< 8'b01000100
whismanoid 53:3d5a3d241a5e 385 CMD_0100_0110_d16_Rd11_AGain = 0x46, //!< 8'b01000110
whismanoid 53:3d5a3d241a5e 386 CMD_0100_1000_d16_Wr12_BGain = 0x48, //!< 8'b01001000
whismanoid 53:3d5a3d241a5e 387 CMD_0100_1010_d16_Rd12_BGain = 0x4a, //!< 8'b01001010
whismanoid 53:3d5a3d241a5e 388 CMD_0100_1100_d16_Wr13_CGain = 0x4c, //!< 8'b01001100
whismanoid 53:3d5a3d241a5e 389 CMD_0100_1110_d16_Rd13_CGain = 0x4e, //!< 8'b01001110
whismanoid 53:3d5a3d241a5e 390 CMD_0101_0000_d16_Wr14_DGain = 0x50, //!< 8'b01010000
whismanoid 53:3d5a3d241a5e 391 CMD_0101_0010_d16_Rd14_DGain = 0x52, //!< 8'b01010010
whismanoid 53:3d5a3d241a5e 392 CMD_0101_0100_d8_Wr15_FilterCAddress = 0x54, //!< 8'b01010100
whismanoid 53:3d5a3d241a5e 393 CMD_0101_0110_d8_Rd15_FilterCAddress = 0x56, //!< 8'b01010110
whismanoid 53:3d5a3d241a5e 394 CMD_0101_1000_d32_Wr16_FilterCDataOut = 0x58, //!< 8'b01011000
whismanoid 53:3d5a3d241a5e 395 CMD_0101_1010_d32_Rd16_FilterCDataOut = 0x5a, //!< 8'b01011010
whismanoid 53:3d5a3d241a5e 396 CMD_0101_1100_d32_Wr17_FilterCDataIn = 0x5c, //!< 8'b01011100
whismanoid 53:3d5a3d241a5e 397 CMD_0101_1110_d32_Rd17_FilterCDataIn = 0x5e, //!< 8'b01011110
whismanoid 53:3d5a3d241a5e 398 CMD_0110_0000_d8_Wr18_FlashMode = 0x60, //!< 8'b01100000
whismanoid 53:3d5a3d241a5e 399 CMD_0110_0010_d8_Rd18_FlashMode = 0x62, //!< 8'b01100010
whismanoid 53:3d5a3d241a5e 400 CMD_0110_0100_d16_Wr19_FlashAddr = 0x64, //!< 8'b01100100
whismanoid 53:3d5a3d241a5e 401 CMD_0110_0110_d16_Rd19_FlashAddr = 0x66, //!< 8'b01100110
whismanoid 53:3d5a3d241a5e 402 CMD_0110_1000_d16_Wr1A_FlashDataIn = 0x68, //!< 8'b01101000
whismanoid 53:3d5a3d241a5e 403 CMD_0110_1010_d16_Rd1A_FlashDataIn = 0x6a, //!< 8'b01101010
whismanoid 53:3d5a3d241a5e 404 CMD_0110_1110_d16_Rd1B_FlashDataOut = 0x6e, //!< 8'b01101110
whismanoid 53:3d5a3d241a5e 405 } MAX11043_CMD_enum_t;
whismanoid 53:3d5a3d241a5e 406
whismanoid 53:3d5a3d241a5e 407 // CODE GENERATOR: TypedefEnum MAX11043_STATUS_enum_t
whismanoid 53:3d5a3d241a5e 408 //----------------------------------------
whismanoid 90:d6ed8a8c5f26 409 /// CMD_0001_1110_d8_Rd07_Status regAddr=07h
whismanoid 53:3d5a3d241a5e 410 /// Status: x x FlashBusy BOOT OFLGA OFLGB OFLGC OFLGD
whismanoid 53:3d5a3d241a5e 411 typedef enum MAX11043_STATUS_enum_t {
whismanoid 53:3d5a3d241a5e 412 STATUS_xxxx_xxx1_OverflowFlagOFLGD = 0x01, //!< 8'b00000001
whismanoid 53:3d5a3d241a5e 413 STATUS_xxxx_xx1x_OverflowFlagOFLGC = 0x02, //!< 8'b00000010
whismanoid 53:3d5a3d241a5e 414 STATUS_xxxx_x1xx_OverflowFlagOFLGB = 0x04, //!< 8'b00000100
whismanoid 53:3d5a3d241a5e 415 STATUS_xxxx_1xxx_OverflowFlagOFLGA = 0x08, //!< 8'b00001000
whismanoid 53:3d5a3d241a5e 416 STATUS_xxx1_xxxx_PowerOnResetBOOT = 0x10, //!< 8'b00010000
whismanoid 53:3d5a3d241a5e 417 STATUS_xx1x_xxxx_FlashBusy = 0x20, //!< 8'b00100000
whismanoid 53:3d5a3d241a5e 418 STATUS_x1xx_xxxx_RESERVED = 0x40, //!< 8'b01000000
whismanoid 53:3d5a3d241a5e 419 STATUS_1xxx_xxxx_RESERVED = 0x80, //!< 8'b10000000
whismanoid 53:3d5a3d241a5e 420 } MAX11043_STATUS_enum_t;
whismanoid 53:3d5a3d241a5e 421
whismanoid 53:3d5a3d241a5e 422 // CODE GENERATOR: TypedefEnum MAX11043_CONFIG_enum_t
whismanoid 53:3d5a3d241a5e 423 //----------------------------------------
whismanoid 90:d6ed8a8c5f26 424 /// CMD_0010_0000_d16_Wr08_Configuration regAddr=08h
whismanoid 53:3d5a3d241a5e 425 /// Config: EXTCLK CLKDIV1 CLKDIV0 PD PDA PDB PDC PDD PDDAC PDOSC 24BIT SCHANA SCHANB SCHANC SCHAND DECSEL
whismanoid 53:3d5a3d241a5e 426 typedef enum MAX11043_CONFIG_enum_t {
whismanoid 53:3d5a3d241a5e 427 CONFIG_xxxx_xxxx_xxxx_xxx1_DECSEL12 = 0x0001, //!< 16'b0000000000000001
whismanoid 53:3d5a3d241a5e 428 CONFIG_xxxx_xxxx_xxxx_xx1x_SCHAND = 0x0002, //!< 16'b0000000000000010
whismanoid 53:3d5a3d241a5e 429 CONFIG_xxxx_xxxx_xxxx_x1xx_SCHANC = 0x0004, //!< 16'b0000000000000100
whismanoid 53:3d5a3d241a5e 430 CONFIG_xxxx_xxxx_xxxx_1xxx_SCHANB = 0x0008, //!< 16'b0000000000001000
whismanoid 53:3d5a3d241a5e 431 CONFIG_xxxx_xxxx_xxx1_xxxx_SCHANA = 0x0010, //!< 16'b0000000000010000
whismanoid 53:3d5a3d241a5e 432 CONFIG_xxxx_xxxx_xx1x_xxxx_24BIT = 0x0020, //!< 16'b0000000000100000
whismanoid 53:3d5a3d241a5e 433 CONFIG_xxxx_xxxx_x1xx_xxxx_PDOSC = 0x0040, //!< 16'b0000000001000000
whismanoid 53:3d5a3d241a5e 434 CONFIG_xxxx_xxxx_1xxx_xxxx_PDDAC = 0x0080, //!< 16'b0000000010000000
whismanoid 53:3d5a3d241a5e 435 CONFIG_xxxx_xxx1_xxxx_xxxx_PDD = 0x0100, //!< 16'b0000000100000000
whismanoid 53:3d5a3d241a5e 436 CONFIG_xxxx_xx1x_xxxx_xxxx_PDC = 0x0200, //!< 16'b0000001000000000
whismanoid 53:3d5a3d241a5e 437 CONFIG_xxxx_x1xx_xxxx_xxxx_PDB = 0x0400, //!< 16'b0000010000000000
whismanoid 53:3d5a3d241a5e 438 CONFIG_xxxx_1xxx_xxxx_xxxx_PDA = 0x0800, //!< 16'b0000100000000000
whismanoid 53:3d5a3d241a5e 439 CONFIG_xxx1_xxxx_xxxx_xxxx_PD = 0x1000, //!< 16'b0001000000000000
whismanoid 53:3d5a3d241a5e 440 CONFIG_xx1x_xxxx_xxxx_xxxx_CLKDIV0 = 0x2000, //!< 16'b0010000000000000
whismanoid 53:3d5a3d241a5e 441 CONFIG_x1xx_xxxx_xxxx_xxxx_CLKDIV1 = 0x4000, //!< 16'b0100000000000000
whismanoid 53:3d5a3d241a5e 442 CONFIG_1xxx_xxxx_xxxx_xxxx_EXTCLK = 0x8000, //!< 16'b1000000000000000
whismanoid 53:3d5a3d241a5e 443 } MAX11043_CONFIG_enum_t;
whismanoid 52:607010f0c54e 444
whismanoid 53:3d5a3d241a5e 445 // CODE GENERATOR: TypedefEnum MAX11043_CONFIGABCD_enum_t
whismanoid 53:3d5a3d241a5e 446 //----------------------------------------
whismanoid 90:d6ed8a8c5f26 447 /// CMD_0011_0000_d16_Wr0C_ConfigA regAddr=0Ch
whismanoid 90:d6ed8a8c5f26 448 /// CMD_0011_0100_d16_Wr0D_ConfigB regAddr=0Dh
whismanoid 90:d6ed8a8c5f26 449 /// CMD_0011_1000_d16_Wr0E_ConfigC regAddr=0Eh
whismanoid 90:d6ed8a8c5f26 450 /// CMD_0011_1100_d16_Wr0F_ConfigD regAddr=0Fh
whismanoid 53:3d5a3d241a5e 451 /// ConfigABCD: x x x BDAC[3:0] DIFF EQ MODG[1:0] PDPGA FILT PGAG ENBIASP ENBIASN
whismanoid 53:3d5a3d241a5e 452 typedef enum MAX11043_CONFIGABCD_enum_t {
whismanoid 53:3d5a3d241a5e 453 CONFIGABCD_xxxx_xxxx_xxxx_xxx1_ENBIASN = 0x0001, //!< 16'b0000000000000001
whismanoid 53:3d5a3d241a5e 454 CONFIGABCD_xxxx_xxxx_xxxx_xx1x_ENBIASP = 0x0002, //!< 16'b0000000000000010
whismanoid 53:3d5a3d241a5e 455 CONFIGABCD_xxxx_xxxx_xxxx_x1xx_PGAG16 = 0x0004, //!< 16'b0000000000000100
whismanoid 53:3d5a3d241a5e 456 CONFIGABCD_xxxx_xxxx_xxxx_1xxx_FILTLP = 0x0008, //!< 16'b0000000000001000
whismanoid 53:3d5a3d241a5e 457 CONFIGABCD_xxxx_xxxx_xxx1_xxxx_PDPGA = 0x0010, //!< 16'b0000000000010000
whismanoid 53:3d5a3d241a5e 458 CONFIGABCD_xxxx_xxxx_xx1x_xxxx_MODG0 = 0x0020, //!< 16'b0000000000100000
whismanoid 53:3d5a3d241a5e 459 CONFIGABCD_xxxx_xxxx_x1xx_xxxx_MODG1 = 0x0040, //!< 16'b0000000001000000
whismanoid 53:3d5a3d241a5e 460 CONFIGABCD_xxxx_xxxx_1xxx_xxxx_EQ = 0x0080, //!< 16'b0000000010000000
whismanoid 53:3d5a3d241a5e 461 CONFIGABCD_xxxx_xxx1_xxxx_xxxx_DIFF = 0x0100, //!< 16'b0000000100000000
whismanoid 53:3d5a3d241a5e 462 CONFIGABCD_xxxx_xx1x_xxxx_xxxx_BDAC0 = 0x0200, //!< 16'b0000001000000000
whismanoid 53:3d5a3d241a5e 463 CONFIGABCD_xxxx_x1xx_xxxx_xxxx_BDAC1 = 0x0400, //!< 16'b0000010000000000
whismanoid 53:3d5a3d241a5e 464 CONFIGABCD_xxxx_1xxx_xxxx_xxxx_BDAC2 = 0x0800, //!< 16'b0000100000000000
whismanoid 53:3d5a3d241a5e 465 CONFIGABCD_xxx1_xxxx_xxxx_xxxx_BDAC3 = 0x1000, //!< 16'b0001000000000000
whismanoid 53:3d5a3d241a5e 466 CONFIGABCD_xx1x_xxxx_xxxx_xxxx_RESERVED = 0x2000, //!< 16'b0010000000000000
whismanoid 53:3d5a3d241a5e 467 CONFIGABCD_x1xx_xxxx_xxxx_xxxx_RESERVED = 0x4000, //!< 16'b0100000000000000
whismanoid 53:3d5a3d241a5e 468 CONFIGABCD_1xxx_xxxx_xxxx_xxxx_RESERVED = 0x8000, //!< 16'b1000000000000000
whismanoid 53:3d5a3d241a5e 469 } MAX11043_CONFIGABCD_enum_t;
whismanoid 53:3d5a3d241a5e 470
whismanoid 53:3d5a3d241a5e 471 // CODE GENERATOR: TypedefEnum MAX11043_BDAC_enum_t
whismanoid 53:3d5a3d241a5e 472 //----------------------------------------
whismanoid 90:d6ed8a8c5f26 473 /// CMD_0011_0000_d16_Wr0C_ConfigA regAddr=0Ch
whismanoid 90:d6ed8a8c5f26 474 /// CMD_0011_0100_d16_Wr0D_ConfigB regAddr=0Dh
whismanoid 90:d6ed8a8c5f26 475 /// CMD_0011_1000_d16_Wr0E_ConfigC regAddr=0Eh
whismanoid 90:d6ed8a8c5f26 476 /// CMD_0011_1100_d16_Wr0F_ConfigD regAddr=0Fh
whismanoid 90:d6ed8a8c5f26 477 ///
whismanoid 53:3d5a3d241a5e 478 /// CONFIGABCD_xxx1_xxxx_xxxx_xxxx_BDAC3
whismanoid 53:3d5a3d241a5e 479 /// CONFIGABCD_xxxx_1xxx_xxxx_xxxx_BDAC2
whismanoid 53:3d5a3d241a5e 480 /// CONFIGABCD_xxxx_x1xx_xxxx_xxxx_BDAC1
whismanoid 53:3d5a3d241a5e 481 /// CONFIGABCD_xxxx_xx1x_xxxx_xxxx_BDAC0
whismanoid 53:3d5a3d241a5e 482 /// Sets the input bias voltage for AC-coupled signals when ENBIAS_ is set to 1.
whismanoid 53:3d5a3d241a5e 483 /// ConfigABCD: x x x BDAC[3:0] DIFF EQ MODG[1:0] PDPGA FILT PGAG ENBIASP ENBIASN
whismanoid 53:3d5a3d241a5e 484 typedef enum MAX11043_BDAC_enum_t {
whismanoid 53:3d5a3d241a5e 485 BDAC_0000_033pctAVDD = 0x00, //!< 8'b00000000
whismanoid 53:3d5a3d241a5e 486 BDAC_0001_035pctAVDD = 0x01, //!< 8'b00000001
whismanoid 53:3d5a3d241a5e 487 BDAC_0010_038pctAVDD = 0x02, //!< 8'b00000010
whismanoid 53:3d5a3d241a5e 488 BDAC_0011_040pctAVDD = 0x03, //!< 8'b00000011
whismanoid 53:3d5a3d241a5e 489 BDAC_0100_042pctAVDD = 0x04, //!< 8'b00000100
whismanoid 53:3d5a3d241a5e 490 BDAC_0101_044pctAVDD = 0x05, //!< 8'b00000101
whismanoid 53:3d5a3d241a5e 491 BDAC_0110_046pctAVDD = 0x06, //!< 8'b00000110
whismanoid 53:3d5a3d241a5e 492 BDAC_0111_048pctAVDD = 0x07, //!< 8'b00000111
whismanoid 53:3d5a3d241a5e 493 BDAC_1000_050pctAVDD = 0x08, //!< 8'b00001000
whismanoid 53:3d5a3d241a5e 494 BDAC_1001_052pctAVDD = 0x09, //!< 8'b00001001
whismanoid 53:3d5a3d241a5e 495 BDAC_1010_054pctAVDD = 0x0a, //!< 8'b00001010
whismanoid 53:3d5a3d241a5e 496 BDAC_1011_056pctAVDD = 0x0b, //!< 8'b00001011
whismanoid 53:3d5a3d241a5e 497 BDAC_1100_058pctAVDD = 0x0c, //!< 8'b00001100
whismanoid 53:3d5a3d241a5e 498 BDAC_1101_060pctAVDD = 0x0d, //!< 8'b00001101
whismanoid 53:3d5a3d241a5e 499 BDAC_1110_062pctAVDD = 0x0e, //!< 8'b00001110
whismanoid 53:3d5a3d241a5e 500 BDAC_1111_065pctAVDD = 0x0f, //!< 8'b00001111
whismanoid 53:3d5a3d241a5e 501 } MAX11043_BDAC_enum_t;
whismanoid 53:3d5a3d241a5e 502
whismanoid 53:3d5a3d241a5e 503 // CODE GENERATOR: TypedefEnum MAX11043_REFERENCE_enum_t
whismanoid 53:3d5a3d241a5e 504 //----------------------------------------
whismanoid 90:d6ed8a8c5f26 505 /// CMD_0100_0000_d16_Wr10_Reference regAddr=10h
whismanoid 53:3d5a3d241a5e 506 /// ReferenceDelay: 0 0 0 PURGE[4:0] EXTREF EXBUFA EXBUFB EXBUFC EXBUFD EXBUFDAC EXBUFDACH EXBUFDACL
whismanoid 53:3d5a3d241a5e 507 typedef enum MAX11043_REFERENCE_enum_t {
whismanoid 53:3d5a3d241a5e 508 REFERENCE_xxxx_xxxx_xxxx_xxx1_EXBUFDACL = 0x0001, //!< 16'b0000000000000001
whismanoid 53:3d5a3d241a5e 509 REFERENCE_xxxx_xxxx_xxxx_xx1x_EXBUFDACH = 0x0002, //!< 16'b0000000000000010
whismanoid 53:3d5a3d241a5e 510 REFERENCE_xxxx_xxxx_xxxx_x1xx_EXBUFDAC = 0x0004, //!< 16'b0000000000000100
whismanoid 53:3d5a3d241a5e 511 REFERENCE_xxxx_xxxx_xxxx_1xxx_EXBUFD = 0x0008, //!< 16'b0000000000001000
whismanoid 53:3d5a3d241a5e 512 REFERENCE_xxxx_xxxx_xxx1_xxxx_EXBUFC = 0x0010, //!< 16'b0000000000010000
whismanoid 53:3d5a3d241a5e 513 REFERENCE_xxxx_xxxx_xx1x_xxxx_EXBUFB = 0x0020, //!< 16'b0000000000100000
whismanoid 53:3d5a3d241a5e 514 REFERENCE_xxxx_xxxx_x1xx_xxxx_EXBUFA = 0x0040, //!< 16'b0000000001000000
whismanoid 53:3d5a3d241a5e 515 REFERENCE_xxxx_xxxx_1xxx_xxxx_EXTREF = 0x0080, //!< 16'b0000000010000000
whismanoid 53:3d5a3d241a5e 516 REFERENCE_xxxx_xxx1_xxxx_xxxx_PURGE0 = 0x0100, //!< 16'b0000000100000000
whismanoid 53:3d5a3d241a5e 517 REFERENCE_xxxx_xx1x_xxxx_xxxx_PURGE1 = 0x0200, //!< 16'b0000001000000000
whismanoid 53:3d5a3d241a5e 518 REFERENCE_xxxx_x1xx_xxxx_xxxx_PURGE2 = 0x0400, //!< 16'b0000010000000000
whismanoid 53:3d5a3d241a5e 519 REFERENCE_xxxx_1xxx_xxxx_xxxx_PURGE3 = 0x0800, //!< 16'b0000100000000000
whismanoid 53:3d5a3d241a5e 520 REFERENCE_xxx1_xxxx_xxxx_xxxx_PURGE4 = 0x1000, //!< 16'b0001000000000000
whismanoid 53:3d5a3d241a5e 521 REFERENCE_xx1x_xxxx_xxxx_xxxx_RESERVED = 0x2000, //!< 16'b0010000000000000
whismanoid 53:3d5a3d241a5e 522 REFERENCE_x1xx_xxxx_xxxx_xxxx_RESERVED = 0x4000, //!< 16'b0100000000000000
whismanoid 53:3d5a3d241a5e 523 REFERENCE_1xxx_xxxx_xxxx_xxxx_RESERVED = 0x8000, //!< 16'b1000000000000000
whismanoid 53:3d5a3d241a5e 524 } MAX11043_REFERENCE_enum_t;
whismanoid 53:3d5a3d241a5e 525
whismanoid 53:3d5a3d241a5e 526 // TODO1: CODE GENERATOR: ic_variant -- IC's supported with this driver
whismanoid 53:3d5a3d241a5e 527 /**
whismanoid 53:3d5a3d241a5e 528 * @brief IC's supported with this driver
whismanoid 53:3d5a3d241a5e 529 * @details MAX11043
whismanoid 53:3d5a3d241a5e 530 */
whismanoid 53:3d5a3d241a5e 531 typedef enum
whismanoid 53:3d5a3d241a5e 532 {
whismanoid 53:3d5a3d241a5e 533 MAX11043_IC = 0,
whismanoid 53:3d5a3d241a5e 534 //MAX11043_IC = 1
whismanoid 53:3d5a3d241a5e 535 } MAX11043_ic_t;
whismanoid 53:3d5a3d241a5e 536
whismanoid 53:3d5a3d241a5e 537 // TODO1: CODE GENERATOR: class constructor declaration
whismanoid 53:3d5a3d241a5e 538 /**********************************************************//**
whismanoid 53:3d5a3d241a5e 539 * @brief Constructor for MAX11043 Class.
whismanoid 53:3d5a3d241a5e 540 *
whismanoid 53:3d5a3d241a5e 541 * @details Requires an existing SPI object as well as a DigitalOut object.
whismanoid 53:3d5a3d241a5e 542 * The DigitalOut object is used for a chip enable signal
whismanoid 53:3d5a3d241a5e 543 *
whismanoid 53:3d5a3d241a5e 544 * On Entry:
whismanoid 53:3d5a3d241a5e 545 * @param[in] spi - pointer to existing SPI object
whismanoid 53:3d5a3d241a5e 546 * @param[in] cs_pin - pointer to a DigitalOut pin object
whismanoid 53:3d5a3d241a5e 547 * CODE GENERATOR: class constructor docstrings gpio InputPin pins
whismanoid 53:3d5a3d241a5e 548 * @param[in] CONVRUN_pin - pointer to a DigitalOut pin object
whismanoid 53:3d5a3d241a5e 549 * @param[in] SHDN_pin - pointer to a DigitalOut pin object
whismanoid 53:3d5a3d241a5e 550 * @param[in] DACSTEP_pin - pointer to a DigitalOut pin object
whismanoid 53:3d5a3d241a5e 551 * @param[in] UP_slash_DWNb_pin - pointer to a DigitalOut pin object
whismanoid 53:3d5a3d241a5e 552 * CODE GENERATOR: class constructor docstrings gpio OutputPin pins
whismanoid 53:3d5a3d241a5e 553 * @param[in] EOC_pin - pointer to a DigitalIn pin object
whismanoid 53:3d5a3d241a5e 554 * @param[in] ic_variant - which type of MAX11043 is used
whismanoid 53:3d5a3d241a5e 555 *
whismanoid 53:3d5a3d241a5e 556 * On Exit:
whismanoid 53:3d5a3d241a5e 557 *
whismanoid 53:3d5a3d241a5e 558 * @return None
whismanoid 53:3d5a3d241a5e 559 **************************************************************/
whismanoid 53:3d5a3d241a5e 560 MAX11043(SPI &spi, DigitalOut &cs_pin, // SPI interface
whismanoid 53:3d5a3d241a5e 561 // CODE GENERATOR: class constructor declaration gpio InputPin pins
whismanoid 53:3d5a3d241a5e 562 DigitalOut &CONVRUN_pin, // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 563 DigitalOut &SHDN_pin, // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 564 DigitalOut &DACSTEP_pin, // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 565 DigitalOut &UP_slash_DWNb_pin, // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 566 // CODE GENERATOR: class constructor declaration gpio OutputPin pins
whismanoid 69:989e392cf635 567 // MAX11043 ADC Read operations must be synchronized to EOC End Of Conversion
whismanoid 69:989e392cf635 568 #if MAX11043_EOC_INTERRUPT_POLLING
whismanoid 69:989e392cf635 569 // MAX11043 EOC End Of Conversion input should be InterruptIn(PinName:EOC_pin).fall(onEOCFallingEdge);
whismanoid 69:989e392cf635 570 // Workaround using DigitalIn(PinName:EOC_pin) polled to sync with EOC falling edge for ADC reads
whismanoid 69:989e392cf635 571 // TODO: onEOCFallingEdge: replace DigitalIn &EOC_pin with PinName EOC_pin, so that I can create an InterruptIn(PinName:EOC_pin)
whismanoid 53:3d5a3d241a5e 572 DigitalIn &EOC_pin, // Digital Event Output from MAX11043 device
whismanoid 69:989e392cf635 573 #else // MAX11043_EOC_INTERRUPT_POLLING
whismanoid 69:989e392cf635 574 // MAX11043 EOC End Of Conversion input is InterruptIn(PinName:EOC_pin).fall(onEOCFallingEdge);
whismanoid 69:989e392cf635 575 InterruptIn &EOC_pin, // Digital Event Output from MAX11043 device
whismanoid 69:989e392cf635 576 #endif // MAX11043_EOC_INTERRUPT_POLLING
whismanoid 53:3d5a3d241a5e 577 MAX11043_ic_t ic_variant);
whismanoid 53:3d5a3d241a5e 578
whismanoid 53:3d5a3d241a5e 579 // CODE GENERATOR: class destructor declaration
whismanoid 53:3d5a3d241a5e 580 /************************************************************
whismanoid 53:3d5a3d241a5e 581 * @brief Default destructor for MAX11043 Class.
whismanoid 53:3d5a3d241a5e 582 *
whismanoid 53:3d5a3d241a5e 583 * @details Destroys SPI object if owner
whismanoid 53:3d5a3d241a5e 584 *
whismanoid 53:3d5a3d241a5e 585 * On Entry:
whismanoid 53:3d5a3d241a5e 586 *
whismanoid 53:3d5a3d241a5e 587 * On Exit:
whismanoid 53:3d5a3d241a5e 588 *
whismanoid 53:3d5a3d241a5e 589 * @return None
whismanoid 53:3d5a3d241a5e 590 **************************************************************/
whismanoid 53:3d5a3d241a5e 591 ~MAX11043();
whismanoid 53:3d5a3d241a5e 592
whismanoid 53:3d5a3d241a5e 593 // CODE GENERATOR: Declare SPI diagnostic function pointer void onSPIprint()
whismanoid 53:3d5a3d241a5e 594 /// Function pointer void f(size_t byteCount, uint8_t mosiData[], uint8_t misoData[])
whismanoid 53:3d5a3d241a5e 595 Callback<void(size_t, uint8_t*, uint8_t*)> onSPIprint; //!< optional @ref onSPIprint SPI diagnostic function
whismanoid 53:3d5a3d241a5e 596
whismanoid 53:3d5a3d241a5e 597 // CODE GENERATOR: spi_frequency setter declaration
whismanoid 53:3d5a3d241a5e 598 /// set SPI SCLK frequency
whismanoid 53:3d5a3d241a5e 599 void spi_frequency(int spi_sclk_Hz);
whismanoid 53:3d5a3d241a5e 600
whismanoid 53:3d5a3d241a5e 601 // CODE GENERATOR: spi_frequency getter declaration and definition
whismanoid 53:3d5a3d241a5e 602 /// get SPI SCLK frequency
whismanoid 53:3d5a3d241a5e 603 int get_spi_frequency() const { return m_SPI_SCLK_Hz; }
whismanoid 53:3d5a3d241a5e 604
whismanoid 53:3d5a3d241a5e 605 // CODE GENERATOR: spi_dataMode getter declaration and definition
whismanoid 53:3d5a3d241a5e 606 /// get SPI mode
whismanoid 53:3d5a3d241a5e 607 int get_spi_dataMode() const { return m_SPI_dataMode; }
whismanoid 53:3d5a3d241a5e 608
whismanoid 53:3d5a3d241a5e 609 //----------------------------------------
whismanoid 53:3d5a3d241a5e 610 // CODE GENERATOR: omit typedef enum MAX11043_device_t, class members instead of global device object
whismanoid 53:3d5a3d241a5e 611 public:
whismanoid 53:3d5a3d241a5e 612
whismanoid 59:47538bcf6cda 613 /// reference voltage, in Volts
whismanoid 59:47538bcf6cda 614 double VRef;
whismanoid 53:3d5a3d241a5e 615
whismanoid 59:47538bcf6cda 616 /// shadow of register config CMD_0010_0010_d16_Rd08_Configuration
whismanoid 59:47538bcf6cda 617 uint16_t config;
whismanoid 53:3d5a3d241a5e 618
whismanoid 59:47538bcf6cda 619 /// shadow of register status CMD_0001_1110_d8_Rd07_Status
whismanoid 90:d6ed8a8c5f26 620 uint8_t status;
whismanoid 53:3d5a3d241a5e 621
whismanoid 59:47538bcf6cda 622 /// shadow of register ADCa CMD_0000_0010_d16o8_Rd00_ADCa
whismanoid 90:d6ed8a8c5f26 623 int adca;
whismanoid 59:47538bcf6cda 624
whismanoid 59:47538bcf6cda 625 /// shadow of register ADCb CMD_0000_0110_d16o8_Rd01_ADCb
whismanoid 90:d6ed8a8c5f26 626 int adcb;
whismanoid 53:3d5a3d241a5e 627
whismanoid 59:47538bcf6cda 628 /// shadow of register ADCc CMD_0000_1010_d16o8_Rd02_ADCc
whismanoid 90:d6ed8a8c5f26 629 int adcc;
whismanoid 59:47538bcf6cda 630
whismanoid 59:47538bcf6cda 631 /// shadow of register ADCd CMD_0000_1110_d16o8_Rd03_ADCd
whismanoid 90:d6ed8a8c5f26 632 int adcd;
whismanoid 53:3d5a3d241a5e 633
whismanoid 53:3d5a3d241a5e 634 // CODE GENERATOR: omit global g_MAX11043_device
whismanoid 53:3d5a3d241a5e 635
whismanoid 53:3d5a3d241a5e 636 // CODE GENERATOR: extern function declarations
whismanoid 53:3d5a3d241a5e 637 // CODE GENERATOR: extern function declaration SPIoutputCS
whismanoid 53:3d5a3d241a5e 638 //----------------------------------------
whismanoid 53:3d5a3d241a5e 639 // Assert SPI Chip Select
whismanoid 53:3d5a3d241a5e 640 // SPI chip-select for MAX11043
whismanoid 53:3d5a3d241a5e 641 //
whismanoid 53:3d5a3d241a5e 642 void SPIoutputCS(int isLogicHigh);
whismanoid 53:3d5a3d241a5e 643
whismanoid 62:8223a7253c90 644 // CODE GENERATOR: extern function declaration SPIreadWriteWithLowCS
whismanoid 62:8223a7253c90 645 //----------------------------------------
whismanoid 62:8223a7253c90 646 // SPI read and write arbitrary number of 8-bit bytes
whismanoid 62:8223a7253c90 647 // SPI interface to MAX11043 shift mosiData into MAX11043 DIN
whismanoid 62:8223a7253c90 648 // while simultaneously capturing miso data from MAX11043 DOUT
whismanoid 62:8223a7253c90 649 //
whismanoid 62:8223a7253c90 650 int SPIreadWriteWithLowCS(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]);
whismanoid 62:8223a7253c90 651
whismanoid 53:3d5a3d241a5e 652 // CODE GENERATOR: extern function declaration SHDNoutputValue
whismanoid 53:3d5a3d241a5e 653 //----------------------------------------
whismanoid 58:2fea32db466b 654 // Assert MAX11043 SHDN pin : High = Shut Down, Low = Normal Operation.
whismanoid 53:3d5a3d241a5e 655 //
whismanoid 53:3d5a3d241a5e 656 void SHDNoutputValue(int isLogicHigh);
whismanoid 53:3d5a3d241a5e 657
whismanoid 53:3d5a3d241a5e 658 // CODE GENERATOR: extern function declaration CONVRUNoutputValue
whismanoid 53:3d5a3d241a5e 659 //----------------------------------------
whismanoid 58:2fea32db466b 660 // Assert MAX11043 CONVRUN pin : High = start continuous conversions on all 4 channels, Low = Idle.
whismanoid 53:3d5a3d241a5e 661 //
whismanoid 53:3d5a3d241a5e 662 void CONVRUNoutputValue(int isLogicHigh);
whismanoid 53:3d5a3d241a5e 663
whismanoid 89:20fd6ce5e4dd 664 // CODE GENERATOR: extern function declaration CONVRUNoutputGetValue
whismanoid 89:20fd6ce5e4dd 665 //----------------------------------------
whismanoid 89:20fd6ce5e4dd 666 // Return the state being driven onto the MAX11043 CONVRUN pin.
whismanoid 89:20fd6ce5e4dd 667 //
whismanoid 89:20fd6ce5e4dd 668 int CONVRUNoutputGetValue();
whismanoid 89:20fd6ce5e4dd 669
whismanoid 53:3d5a3d241a5e 670 // CODE GENERATOR: extern function declaration DACSTEPoutputValue
whismanoid 53:3d5a3d241a5e 671 //----------------------------------------
whismanoid 58:2fea32db466b 672 // Assert MAX11043 DACSTEP pin : High = Active, Low = Idle.
whismanoid 53:3d5a3d241a5e 673 //
whismanoid 53:3d5a3d241a5e 674 void DACSTEPoutputValue(int isLogicHigh);
whismanoid 53:3d5a3d241a5e 675
whismanoid 53:3d5a3d241a5e 676 // CODE GENERATOR: extern function declaration UP_slash_DWNboutputValue
whismanoid 53:3d5a3d241a5e 677 //----------------------------------------
whismanoid 58:2fea32db466b 678 // Assert MAX11043 UP_slash_DWNb pin : High = Up, Low = Down.
whismanoid 53:3d5a3d241a5e 679 //
whismanoid 53:3d5a3d241a5e 680 void UP_slash_DWNboutputValue(int isLogicHigh);
whismanoid 53:3d5a3d241a5e 681
whismanoid 53:3d5a3d241a5e 682 // CODE GENERATOR: extern function declaration EOCinputWaitUntilLow
whismanoid 53:3d5a3d241a5e 683 //----------------------------------------
whismanoid 53:3d5a3d241a5e 684 // Wait for MAX11043 EOC pin low, indicating end of conversion.
whismanoid 53:3d5a3d241a5e 685 // Required when using any of the InternalClock modes.
whismanoid 53:3d5a3d241a5e 686 //
whismanoid 53:3d5a3d241a5e 687 void EOCinputWaitUntilLow();
whismanoid 53:3d5a3d241a5e 688
whismanoid 53:3d5a3d241a5e 689 // CODE GENERATOR: extern function declaration EOCinputValue
whismanoid 53:3d5a3d241a5e 690 //----------------------------------------
whismanoid 53:3d5a3d241a5e 691 // Return the status of the MAX11043 EOC pin.
whismanoid 53:3d5a3d241a5e 692 //
whismanoid 53:3d5a3d241a5e 693 int EOCinputValue();
whismanoid 53:3d5a3d241a5e 694
whismanoid 53:3d5a3d241a5e 695 // CODE GENERATOR: class member data
whismanoid 53:3d5a3d241a5e 696 private:
whismanoid 53:3d5a3d241a5e 697 // CODE GENERATOR: class member data for SPI interface
whismanoid 53:3d5a3d241a5e 698 // SPI object
whismanoid 53:3d5a3d241a5e 699 SPI &m_spi;
whismanoid 53:3d5a3d241a5e 700 int m_SPI_SCLK_Hz;
whismanoid 53:3d5a3d241a5e 701 int m_SPI_dataMode;
whismanoid 53:3d5a3d241a5e 702 int m_SPI_cs_state;
whismanoid 53:3d5a3d241a5e 703
whismanoid 53:3d5a3d241a5e 704 // Selector pin object
whismanoid 53:3d5a3d241a5e 705 DigitalOut &m_cs_pin;
whismanoid 53:3d5a3d241a5e 706
whismanoid 53:3d5a3d241a5e 707 // CODE GENERATOR: class member data for gpio InputPin pins
whismanoid 53:3d5a3d241a5e 708 // InputPin Name = CONVRUN
whismanoid 53:3d5a3d241a5e 709 // InputPin Description = CONVRUN (digital input). Convert Run. Drive high to start continuous conversions on all 4 channels. The device is idle when
whismanoid 53:3d5a3d241a5e 710 // CONVRUN is low.
whismanoid 53:3d5a3d241a5e 711 // InputPin Function = Configuration
whismanoid 53:3d5a3d241a5e 712 DigitalOut &m_CONVRUN_pin;
whismanoid 53:3d5a3d241a5e 713 //
whismanoid 53:3d5a3d241a5e 714 // InputPin Name = SHDN
whismanoid 53:3d5a3d241a5e 715 // InputPin Description = Shutdown (digital input). Active-High Shutdown Input. Drive high to shut down the MAX11043.
whismanoid 53:3d5a3d241a5e 716 // InputPin Function = Configuration
whismanoid 53:3d5a3d241a5e 717 DigitalOut &m_SHDN_pin;
whismanoid 53:3d5a3d241a5e 718 //
whismanoid 53:3d5a3d241a5e 719 // InputPin Name = DACSTEP
whismanoid 53:3d5a3d241a5e 720 // InputPin Description = DACSTEP (digital input). DAC Step Input. Drive high to move the DAC output in the direction of UP/DWN on the next rising
whismanoid 53:3d5a3d241a5e 721 // edge of the system clock.
whismanoid 53:3d5a3d241a5e 722 // InputPin Function = Configuration
whismanoid 53:3d5a3d241a5e 723 DigitalOut &m_DACSTEP_pin;
whismanoid 53:3d5a3d241a5e 724 //
whismanoid 53:3d5a3d241a5e 725 // InputPin Name = UP/DWN#
whismanoid 53:3d5a3d241a5e 726 // InputPin Description = UP/DWN# (digital input). DAC Step Direction Select. Drive high to step up, drive low to step down when DACSTEP is toggled.
whismanoid 53:3d5a3d241a5e 727 // InputPin Function = Configuration
whismanoid 53:3d5a3d241a5e 728 DigitalOut &m_UP_slash_DWNb_pin;
whismanoid 53:3d5a3d241a5e 729 //
whismanoid 53:3d5a3d241a5e 730 // CODE GENERATOR: class member data for gpio OutputPin pins
whismanoid 53:3d5a3d241a5e 731 // OutputPin Name = EOC
whismanoid 53:3d5a3d241a5e 732 // OutputPin Description = End of Conversion Output. Active-Low End-of-Conversion Indicator. EOC asserts low to indicate that new data is ready.
whismanoid 53:3d5a3d241a5e 733 // OutputPin Function = Event
whismanoid 70:f44a577c9e59 734 //--------------------------------------------------
whismanoid 70:f44a577c9e59 735 // MAX11043 ADC Read operations must be synchronized to EOC End Of Conversion
whismanoid 70:f44a577c9e59 736 // EOC# asserts low when new data is available.
whismanoid 70:f44a577c9e59 737 // Initiate a data read prior to the next rising edge of EOC# or the result is overwritten.
whismanoid 70:f44a577c9e59 738 #if MAX11043_EOC_INTERRUPT_POLLING
whismanoid 70:f44a577c9e59 739 // MAX11043 EOC End Of Conversion input should be InterruptIn(PinName:EOC_pin).fall(onEOCFallingEdge);
whismanoid 70:f44a577c9e59 740 // Workaround using DigitalIn(PinName:EOC_pin) polled to sync with EOC falling edge for ADC reads
whismanoid 70:f44a577c9e59 741 // 2020-02-20 MAX11043_EOC_INTERRUPT_POLLING works on MAX32625MBED at 9us conversion rate, with 1us timing margin
whismanoid 53:3d5a3d241a5e 742 DigitalIn &m_EOC_pin;
whismanoid 70:f44a577c9e59 743 #else // MAX11043_EOC_INTERRUPT_POLLING
whismanoid 70:f44a577c9e59 744 // MAX11043 EOC End Of Conversion input is InterruptIn(PinName:EOC_pin).fall(onEOCFallingEdge);
whismanoid 70:f44a577c9e59 745 InterruptIn &m_EOC_pin;
whismanoid 70:f44a577c9e59 746 #endif // MAX11043_EOC_INTERRUPT_POLLING
whismanoid 70:f44a577c9e59 747 //--------------------------------------------------
whismanoid 53:3d5a3d241a5e 748 //
whismanoid 53:3d5a3d241a5e 749
whismanoid 53:3d5a3d241a5e 750 // Identifies which IC variant is being used
whismanoid 53:3d5a3d241a5e 751 MAX11043_ic_t m_ic_variant;
whismanoid 53:3d5a3d241a5e 752
whismanoid 53:3d5a3d241a5e 753 public:
whismanoid 53:3d5a3d241a5e 754
whismanoid 53:3d5a3d241a5e 755 // CODE GENERATOR: class member function declarations
whismanoid 53:3d5a3d241a5e 756 //----------------------------------------
whismanoid 53:3d5a3d241a5e 757 /// Menu item '!'
whismanoid 53:3d5a3d241a5e 758 /// Initialize device
whismanoid 53:3d5a3d241a5e 759 /// @return 1 on success; 0 on failure
whismanoid 53:3d5a3d241a5e 760 uint8_t Init(void);
whismanoid 53:3d5a3d241a5e 761
whismanoid 93:6b22269935a6 762 //----------------------------------------
whismanoid 93:6b22269935a6 763 /// Return the physical voltage corresponding to conversion result
whismanoid 93:6b22269935a6 764 /// (conversion format is Bipolar mode, 2's complement)
whismanoid 93:6b22269935a6 765 /// Does not perform any offset or gain correction.
whismanoid 93:6b22269935a6 766 ///
whismanoid 93:6b22269935a6 767 /// @pre CONFIG_xxxx_xxxx_xx1x_xxxx_24BIT is 0: 16-bit mode is configured
whismanoid 93:6b22269935a6 768 /// @pre g_MAX11043_device.VRef = Voltage of REF input, in Volts
whismanoid 93:6b22269935a6 769 /// @param[in] value_u24: raw 24-bit MAX11043 code (right justified).
whismanoid 93:6b22269935a6 770 /// @return physical voltage corresponding to MAX11043 code.
whismanoid 93:6b22269935a6 771 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0x7FFF) expect 2.500 within 0.030 Full Scale
whismanoid 93:6b22269935a6 772 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0x7FFF) expect 2.500 Full Scale
whismanoid 93:6b22269935a6 773 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0x6666) expect 2.000 Two Volts
whismanoid 93:6b22269935a6 774 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0x6000) expect 1.875 75% Scale
whismanoid 93:6b22269935a6 775 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0x4000) expect 1.250 Mid Scale
whismanoid 93:6b22269935a6 776 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0x3333) expect 1.000 One Volt
whismanoid 93:6b22269935a6 777 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0x2000) expect 0.625 25% Scale
whismanoid 93:6b22269935a6 778 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0x051e) expect 0.100 100mV
whismanoid 93:6b22269935a6 779 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0x0000) expect 0.00000894069671 Three LSB
whismanoid 93:6b22269935a6 780 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0x0000) expect 0.00000596046447 Two LSB
whismanoid 93:6b22269935a6 781 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0x0000) expect 0.0000029802326 One LSB
whismanoid 93:6b22269935a6 782 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0x0000) expect 0.0 Zero Scale
whismanoid 93:6b22269935a6 783 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0xFFFF) expect -0.0000029802326 Negative One LSB
whismanoid 93:6b22269935a6 784 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0xFFFF) expect -0.0000059604644 Negative Two LSB
whismanoid 93:6b22269935a6 785 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0xFFFF) expect -0.0000089406967 Negative Three LSB
whismanoid 93:6b22269935a6 786 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0xFAE1) expect -0.100 Negative 100mV
whismanoid 93:6b22269935a6 787 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0xE000) expect -0.625 Negative 25% Scale
whismanoid 93:6b22269935a6 788 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0xCCCC) expect -1.000 Negative One Volt
whismanoid 93:6b22269935a6 789 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0xC000) expect -1.250 Negative Mid Scale
whismanoid 93:6b22269935a6 790 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0xA000) expect -1.875 Negative 75% Scale
whismanoid 93:6b22269935a6 791 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0x9999) expect -2.000 Negative Two Volts
whismanoid 93:6b22269935a6 792 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0x8000) expect -2.500 Negative Full Scale
whismanoid 93:6b22269935a6 793 /// @test group BIP2C16 ADCVoltageOfCode_16bit(0x8000) expect -2.500 Negative Full Scale
whismanoid 93:6b22269935a6 794 ///
whismanoid 93:6b22269935a6 795 double ADCVoltageOfCode_16bit(uint32_t value_u16);
whismanoid 93:6b22269935a6 796
whismanoid 93:6b22269935a6 797 //----------------------------------------
whismanoid 93:6b22269935a6 798 /// Return the physical voltage corresponding to conversion result
whismanoid 93:6b22269935a6 799 /// (conversion format is Bipolar mode, 2's complement)
whismanoid 93:6b22269935a6 800 /// Does not perform any offset or gain correction.
whismanoid 93:6b22269935a6 801 ///
whismanoid 93:6b22269935a6 802 /// @pre CONFIG_xxxx_xxxx_xx1x_xxxx_24BIT is 1: 24-bit mode is configured
whismanoid 93:6b22269935a6 803 /// @pre g_MAX11043_device.VRef = Voltage of REF input, in Volts
whismanoid 93:6b22269935a6 804 /// @param[in] value_u24: raw 24-bit MAX11043 code (right justified).
whismanoid 93:6b22269935a6 805 /// @return physical voltage corresponding to MAX11043 code.
whismanoid 93:6b22269935a6 806 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0x7FFFFF) expect 2.500 within 0.030 Full Scale
whismanoid 93:6b22269935a6 807 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0x7FFFFE) expect 2.500 Full Scale
whismanoid 93:6b22269935a6 808 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0x666666) expect 2.000 Two Volts
whismanoid 93:6b22269935a6 809 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0x600000) expect 1.875 75% Scale
whismanoid 93:6b22269935a6 810 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0x400000) expect 1.250 Mid Scale
whismanoid 93:6b22269935a6 811 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0x333333) expect 1.000 One Volt
whismanoid 93:6b22269935a6 812 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0x200000) expect 0.625 25% Scale
whismanoid 93:6b22269935a6 813 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0x051eb8) expect 0.100 100mV
whismanoid 93:6b22269935a6 814 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0x000003) expect 0.00000894069671 Three LSB
whismanoid 93:6b22269935a6 815 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0x000002) expect 0.00000596046447 Two LSB
whismanoid 93:6b22269935a6 816 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0x000001) expect 0.0000029802326 One LSB
whismanoid 93:6b22269935a6 817 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0x000000) expect 0.0 Zero Scale
whismanoid 93:6b22269935a6 818 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0xFFFFFF) expect -0.0000029802326 Negative One LSB
whismanoid 93:6b22269935a6 819 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0xFFFFFE) expect -0.0000059604644 Negative Two LSB
whismanoid 93:6b22269935a6 820 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0xFFFFFD) expect -0.0000089406967 Negative Three LSB
whismanoid 93:6b22269935a6 821 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0xFAE148) expect -0.100 Negative 100mV
whismanoid 93:6b22269935a6 822 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0xE00000) expect -0.625 Negative 25% Scale
whismanoid 93:6b22269935a6 823 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0xCCCCCD) expect -1.000 Negative One Volt
whismanoid 93:6b22269935a6 824 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0xC00000) expect -1.250 Negative Mid Scale
whismanoid 93:6b22269935a6 825 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0xA00000) expect -1.875 Negative 75% Scale
whismanoid 93:6b22269935a6 826 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0x99999A) expect -2.000 Negative Two Volts
whismanoid 93:6b22269935a6 827 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0x800001) expect -2.500 Negative Full Scale
whismanoid 93:6b22269935a6 828 /// @test group BIP2C24 ADCVoltageOfCode_24bit(0x800000) expect -2.500 Negative Full Scale
whismanoid 93:6b22269935a6 829 ///
whismanoid 93:6b22269935a6 830 double ADCVoltageOfCode_24bit(uint32_t value_u24);
whismanoid 93:6b22269935a6 831
whismanoid 53:3d5a3d241a5e 832 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 833 // CODE GENERATOR: looks like this is a 'write' register access function
whismanoid 53:3d5a3d241a5e 834 //----------------------------------------
whismanoid 53:3d5a3d241a5e 835 /// Write a MAX11043 register.
whismanoid 53:3d5a3d241a5e 836 ///
whismanoid 57:1c9da8e90737 837 /// CMDOP_1aaa_aaaa_ReadRegister bit is cleared 0 indicating a write operation.
whismanoid 53:3d5a3d241a5e 838 ///
whismanoid 53:3d5a3d241a5e 839 /// MAX11043 register length can be determined by function RegSize.
whismanoid 53:3d5a3d241a5e 840 ///
whismanoid 53:3d5a3d241a5e 841 /// For 8-bit register size:
whismanoid 53:3d5a3d241a5e 842 ///
whismanoid 53:3d5a3d241a5e 843 /// SPI 16-bit transfer
whismanoid 53:3d5a3d241a5e 844 ///
whismanoid 53:3d5a3d241a5e 845 /// SPI MOSI = 0aaa_aaaa_dddd_dddd
whismanoid 53:3d5a3d241a5e 846 ///
whismanoid 53:3d5a3d241a5e 847 /// SPI MISO = xxxx_xxxx_xxxx_xxxx
whismanoid 53:3d5a3d241a5e 848 ///
whismanoid 53:3d5a3d241a5e 849 /// For 16-bit register size:
whismanoid 53:3d5a3d241a5e 850 ///
whismanoid 53:3d5a3d241a5e 851 /// SPI 24-bit or 32-bit transfer
whismanoid 53:3d5a3d241a5e 852 ///
whismanoid 53:3d5a3d241a5e 853 /// SPI MOSI = 0aaa_aaaa_dddd_dddd_dddd_dddd
whismanoid 53:3d5a3d241a5e 854 ///
whismanoid 53:3d5a3d241a5e 855 /// SPI MISO = xxxx_xxxx_xxxx_xxxx_xxxx_xxxx
whismanoid 53:3d5a3d241a5e 856 ///
whismanoid 53:3d5a3d241a5e 857 /// For 24-bit register size:
whismanoid 53:3d5a3d241a5e 858 ///
whismanoid 53:3d5a3d241a5e 859 /// SPI 32-bit transfer
whismanoid 53:3d5a3d241a5e 860 ///
whismanoid 53:3d5a3d241a5e 861 /// SPI MOSI = 0aaa_aaaa_dddd_dddd_dddd_dddd_dddd_dddd
whismanoid 53:3d5a3d241a5e 862 ///
whismanoid 53:3d5a3d241a5e 863 /// SPI MISO = xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx
whismanoid 53:3d5a3d241a5e 864 ///
whismanoid 53:3d5a3d241a5e 865 /// @return 1 on success; 0 on failure
whismanoid 53:3d5a3d241a5e 866 uint8_t RegWrite(MAX11043_CMD_enum_t commandByte, uint32_t regData);
whismanoid 53:3d5a3d241a5e 867
whismanoid 53:3d5a3d241a5e 868 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 869 // CODE GENERATOR: looks like this is a 'read' register access function
whismanoid 53:3d5a3d241a5e 870 //----------------------------------------
whismanoid 53:3d5a3d241a5e 871 /// Read an 8-bit MAX11043 register
whismanoid 53:3d5a3d241a5e 872 ///
whismanoid 57:1c9da8e90737 873 /// CMDOP_1aaa_aaaa_ReadRegister bit is set 1 indicating a read operation.
whismanoid 53:3d5a3d241a5e 874 ///
whismanoid 53:3d5a3d241a5e 875 /// MAX11043 register length can be determined by function RegSize.
whismanoid 53:3d5a3d241a5e 876 ///
whismanoid 53:3d5a3d241a5e 877 /// For 8-bit register size:
whismanoid 53:3d5a3d241a5e 878 ///
whismanoid 53:3d5a3d241a5e 879 /// SPI 16-bit transfer
whismanoid 53:3d5a3d241a5e 880 ///
whismanoid 53:3d5a3d241a5e 881 /// SPI MOSI = 1aaa_aaaa_0000_0000
whismanoid 53:3d5a3d241a5e 882 ///
whismanoid 53:3d5a3d241a5e 883 /// SPI MISO = xxxx_xxxx_dddd_dddd
whismanoid 53:3d5a3d241a5e 884 ///
whismanoid 53:3d5a3d241a5e 885 /// For 16-bit register size:
whismanoid 53:3d5a3d241a5e 886 ///
whismanoid 53:3d5a3d241a5e 887 /// SPI 24-bit or 32-bit transfer
whismanoid 53:3d5a3d241a5e 888 ///
whismanoid 53:3d5a3d241a5e 889 /// SPI MOSI = 1aaa_aaaa_0000_0000_0000_0000
whismanoid 53:3d5a3d241a5e 890 ///
whismanoid 53:3d5a3d241a5e 891 /// SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd
whismanoid 53:3d5a3d241a5e 892 ///
whismanoid 53:3d5a3d241a5e 893 /// For 24-bit register size:
whismanoid 53:3d5a3d241a5e 894 ///
whismanoid 53:3d5a3d241a5e 895 /// SPI 32-bit transfer
whismanoid 53:3d5a3d241a5e 896 ///
whismanoid 53:3d5a3d241a5e 897 /// SPI MOSI = 1aaa_aaaa_0000_0000_0000_0000_0000_0000
whismanoid 53:3d5a3d241a5e 898 ///
whismanoid 53:3d5a3d241a5e 899 /// SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd_dddd_dddd
whismanoid 53:3d5a3d241a5e 900 ///
whismanoid 53:3d5a3d241a5e 901 ///
whismanoid 53:3d5a3d241a5e 902 /// @return 1 on success; 0 on failure
whismanoid 53:3d5a3d241a5e 903 uint8_t RegRead(MAX11043_CMD_enum_t commandByte, uint32_t* ptrRegData);
whismanoid 53:3d5a3d241a5e 904
whismanoid 53:3d5a3d241a5e 905 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 906 // CODE GENERATOR: looks like this is a 'size' register access function
whismanoid 53:3d5a3d241a5e 907 //----------------------------------------
whismanoid 53:3d5a3d241a5e 908 /// Return the size of a MAX11043 register
whismanoid 53:3d5a3d241a5e 909 ///
whismanoid 53:3d5a3d241a5e 910 /// @return 8 for 8-bit, 16 for 16-bit, 24 for 24-bit, else 0 for undefined register size
whismanoid 53:3d5a3d241a5e 911 uint8_t RegSize(MAX11043_CMD_enum_t commandByte);
whismanoid 53:3d5a3d241a5e 912
whismanoid 53:3d5a3d241a5e 913 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 914 //----------------------------------------
whismanoid 57:1c9da8e90737 915 /// Decode operation from commandByte
whismanoid 57:1c9da8e90737 916 ///
whismanoid 57:1c9da8e90737 917 /// @return operation such as idle, read register, write register, etc.
whismanoid 57:1c9da8e90737 918 MAX11043::MAX11043_CMDOP_enum_t DecodeCommand(MAX11043_CMD_enum_t commandByte);
whismanoid 57:1c9da8e90737 919
whismanoid 57:1c9da8e90737 920 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 57:1c9da8e90737 921 //----------------------------------------
whismanoid 53:3d5a3d241a5e 922 /// Return the address field of a MAX11043 register
whismanoid 53:3d5a3d241a5e 923 ///
whismanoid 53:3d5a3d241a5e 924 /// @return register address field as given in datasheet
whismanoid 53:3d5a3d241a5e 925 uint8_t RegAddrOfCommand(MAX11043_CMD_enum_t commandByte);
whismanoid 53:3d5a3d241a5e 926
whismanoid 53:3d5a3d241a5e 927 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 928 // CODE GENERATOR: looks like this is a 'read' register access function
whismanoid 53:3d5a3d241a5e 929 //----------------------------------------
whismanoid 53:3d5a3d241a5e 930 /// Test whether a command byte is a register read command
whismanoid 53:3d5a3d241a5e 931 ///
whismanoid 53:3d5a3d241a5e 932 /// @return true if command byte is a register read command
whismanoid 53:3d5a3d241a5e 933 uint8_t IsRegReadCommand(MAX11043_CMD_enum_t commandByte);
whismanoid 53:3d5a3d241a5e 934
whismanoid 53:3d5a3d241a5e 935 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 936 // CODE GENERATOR: looks like this is a 'name' register access function
whismanoid 53:3d5a3d241a5e 937 //----------------------------------------
whismanoid 53:3d5a3d241a5e 938 /// Return the name of a MAX11043 register
whismanoid 53:3d5a3d241a5e 939 ///
whismanoid 53:3d5a3d241a5e 940 /// @return null-terminated constant C string containing register name or empty string
whismanoid 53:3d5a3d241a5e 941 const char* RegName(MAX11043_CMD_enum_t commandByte);
whismanoid 53:3d5a3d241a5e 942
whismanoid 59:47538bcf6cda 943 //----------------------------------------
whismanoid 64:a667cfd83492 944 /// Menu item '$' -> adca, adcb, adcc, adcd
whismanoid 64:a667cfd83492 945 /// Read ADCabcd
whismanoid 64:a667cfd83492 946 ///
whismanoid 64:a667cfd83492 947 /// @return 1 on success; 0 on failure
whismanoid 64:a667cfd83492 948 uint8_t Read_ADCabcd(void);
whismanoid 64:a667cfd83492 949
whismanoid 64:a667cfd83492 950 //----------------------------------------
whismanoid 66:3fe92f6f1cfa 951 /// Menu item 'GA'
whismanoid 64:a667cfd83492 952 /// Write AGain register
whismanoid 64:a667cfd83492 953 ///
whismanoid 93:6b22269935a6 954 /// @param[in] gain 2's complement, 0x800=0.25V/V, 0x1000=0.5V/V, 0x2000=1V/V, 0x4000=2V/V, default=0x2000
whismanoid 64:a667cfd83492 955 ///
whismanoid 64:a667cfd83492 956 /// @return 1 on success; 0 on failure
whismanoid 64:a667cfd83492 957 uint8_t Write_AGain(uint32_t gain);
whismanoid 64:a667cfd83492 958
whismanoid 64:a667cfd83492 959 //----------------------------------------
whismanoid 89:20fd6ce5e4dd 960 /// Menu item 'XD'
whismanoid 89:20fd6ce5e4dd 961 /// Example configuration.
whismanoid 89:20fd6ce5e4dd 962 /// Slowest conversion rate 1:6 = 9us,
whismanoid 89:20fd6ce5e4dd 963 /// Bypass PGA and filters, Gain=1V/V,
whismanoid 89:20fd6ce5e4dd 964 /// AOUT = 2.0V
whismanoid 89:20fd6ce5e4dd 965 ///
whismanoid 89:20fd6ce5e4dd 966 void Configure_Demo(void);
whismanoid 89:20fd6ce5e4dd 967
whismanoid 89:20fd6ce5e4dd 968 //----------------------------------------
whismanoid 59:47538bcf6cda 969 /// Menu item 'XX'
whismanoid 59:47538bcf6cda 970 ///
whismanoid 59:47538bcf6cda 971 /// @return 1 on success; 0 on failure
whismanoid 59:47538bcf6cda 972 uint8_t Configure_XXXXX(uint8_t linef, uint8_t rate);
whismanoid 59:47538bcf6cda 973
whismanoid 59:47538bcf6cda 974 //----------------------------------------
whismanoid 59:47538bcf6cda 975 /// Menu item 'XY'
whismanoid 59:47538bcf6cda 976 ///
whismanoid 59:47538bcf6cda 977 /// @return 1 on success; 0 on failure
whismanoid 59:47538bcf6cda 978 uint8_t Configure_XXXXY(uint8_t linef, uint8_t rate);
whismanoid 59:47538bcf6cda 979
whismanoid 53:3d5a3d241a5e 980 }; // end of class MAX11043
whismanoid 53:3d5a3d241a5e 981
whismanoid 53:3d5a3d241a5e 982 #endif // __MAX11043_H__
whismanoid 53:3d5a3d241a5e 983
whismanoid 53:3d5a3d241a5e 984 // End of file