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:
Tue Feb 25 12:37:29 2020 +0000
Revision:
82:9ea067fad5c3
Parent:
70:f44a577c9e59
Child:
83:29bb86cc45bc
MAX11043 myOnEOCThread_POLLING_handler needs 18.80us, still too slow

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 53:3d5a3d241a5e 37 // DO NOT EDIT; except areas designated "CUSTOMIZE". Automatically generated file.
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 53:3d5a3d241a5e 409 /// CMD_0001_1110_d8_Rd_Status
whismanoid 53:3d5a3d241a5e 410 /// regAddr=07h
whismanoid 53:3d5a3d241a5e 411 /// Status: x x FlashBusy BOOT OFLGA OFLGB OFLGC OFLGD
whismanoid 53:3d5a3d241a5e 412 typedef enum MAX11043_STATUS_enum_t {
whismanoid 53:3d5a3d241a5e 413 STATUS_xxxx_xxx1_OverflowFlagOFLGD = 0x01, //!< 8'b00000001
whismanoid 53:3d5a3d241a5e 414 STATUS_xxxx_xx1x_OverflowFlagOFLGC = 0x02, //!< 8'b00000010
whismanoid 53:3d5a3d241a5e 415 STATUS_xxxx_x1xx_OverflowFlagOFLGB = 0x04, //!< 8'b00000100
whismanoid 53:3d5a3d241a5e 416 STATUS_xxxx_1xxx_OverflowFlagOFLGA = 0x08, //!< 8'b00001000
whismanoid 53:3d5a3d241a5e 417 STATUS_xxx1_xxxx_PowerOnResetBOOT = 0x10, //!< 8'b00010000
whismanoid 53:3d5a3d241a5e 418 STATUS_xx1x_xxxx_FlashBusy = 0x20, //!< 8'b00100000
whismanoid 53:3d5a3d241a5e 419 STATUS_x1xx_xxxx_RESERVED = 0x40, //!< 8'b01000000
whismanoid 53:3d5a3d241a5e 420 STATUS_1xxx_xxxx_RESERVED = 0x80, //!< 8'b10000000
whismanoid 53:3d5a3d241a5e 421 } MAX11043_STATUS_enum_t;
whismanoid 53:3d5a3d241a5e 422
whismanoid 53:3d5a3d241a5e 423 // CODE GENERATOR: TypedefEnum MAX11043_CONFIG_enum_t
whismanoid 53:3d5a3d241a5e 424 //----------------------------------------
whismanoid 53:3d5a3d241a5e 425 /// CMD_0010_0000_d16_Wr_Configuration
whismanoid 53:3d5a3d241a5e 426 /// regAddr=08h
whismanoid 53:3d5a3d241a5e 427 /// Config: EXTCLK CLKDIV1 CLKDIV0 PD PDA PDB PDC PDD PDDAC PDOSC 24BIT SCHANA SCHANB SCHANC SCHAND DECSEL
whismanoid 53:3d5a3d241a5e 428 typedef enum MAX11043_CONFIG_enum_t {
whismanoid 53:3d5a3d241a5e 429 CONFIG_xxxx_xxxx_xxxx_xxx1_DECSEL12 = 0x0001, //!< 16'b0000000000000001
whismanoid 53:3d5a3d241a5e 430 CONFIG_xxxx_xxxx_xxxx_xx1x_SCHAND = 0x0002, //!< 16'b0000000000000010
whismanoid 53:3d5a3d241a5e 431 CONFIG_xxxx_xxxx_xxxx_x1xx_SCHANC = 0x0004, //!< 16'b0000000000000100
whismanoid 53:3d5a3d241a5e 432 CONFIG_xxxx_xxxx_xxxx_1xxx_SCHANB = 0x0008, //!< 16'b0000000000001000
whismanoid 53:3d5a3d241a5e 433 CONFIG_xxxx_xxxx_xxx1_xxxx_SCHANA = 0x0010, //!< 16'b0000000000010000
whismanoid 53:3d5a3d241a5e 434 CONFIG_xxxx_xxxx_xx1x_xxxx_24BIT = 0x0020, //!< 16'b0000000000100000
whismanoid 53:3d5a3d241a5e 435 CONFIG_xxxx_xxxx_x1xx_xxxx_PDOSC = 0x0040, //!< 16'b0000000001000000
whismanoid 53:3d5a3d241a5e 436 CONFIG_xxxx_xxxx_1xxx_xxxx_PDDAC = 0x0080, //!< 16'b0000000010000000
whismanoid 53:3d5a3d241a5e 437 CONFIG_xxxx_xxx1_xxxx_xxxx_PDD = 0x0100, //!< 16'b0000000100000000
whismanoid 53:3d5a3d241a5e 438 CONFIG_xxxx_xx1x_xxxx_xxxx_PDC = 0x0200, //!< 16'b0000001000000000
whismanoid 53:3d5a3d241a5e 439 CONFIG_xxxx_x1xx_xxxx_xxxx_PDB = 0x0400, //!< 16'b0000010000000000
whismanoid 53:3d5a3d241a5e 440 CONFIG_xxxx_1xxx_xxxx_xxxx_PDA = 0x0800, //!< 16'b0000100000000000
whismanoid 53:3d5a3d241a5e 441 CONFIG_xxx1_xxxx_xxxx_xxxx_PD = 0x1000, //!< 16'b0001000000000000
whismanoid 53:3d5a3d241a5e 442 CONFIG_xx1x_xxxx_xxxx_xxxx_CLKDIV0 = 0x2000, //!< 16'b0010000000000000
whismanoid 53:3d5a3d241a5e 443 CONFIG_x1xx_xxxx_xxxx_xxxx_CLKDIV1 = 0x4000, //!< 16'b0100000000000000
whismanoid 53:3d5a3d241a5e 444 CONFIG_1xxx_xxxx_xxxx_xxxx_EXTCLK = 0x8000, //!< 16'b1000000000000000
whismanoid 53:3d5a3d241a5e 445 } MAX11043_CONFIG_enum_t;
whismanoid 52:607010f0c54e 446
whismanoid 53:3d5a3d241a5e 447 // CODE GENERATOR: TypedefEnum MAX11043_CONFIGABCD_enum_t
whismanoid 53:3d5a3d241a5e 448 //----------------------------------------
whismanoid 53:3d5a3d241a5e 449 /// CMD_0011_0000_d16_Wr_CONFIGa
whismanoid 53:3d5a3d241a5e 450 /// CMD_0011_0100_d16_Wr_CONFIGb
whismanoid 53:3d5a3d241a5e 451 /// CMD_0011_1000_d16_Wr_CONFIGc
whismanoid 53:3d5a3d241a5e 452 /// CMD_0011_1100_d16_Wr_CONFIGd
whismanoid 53:3d5a3d241a5e 453 /// regAddr=0Ch
whismanoid 53:3d5a3d241a5e 454 /// regAddr=0Dh
whismanoid 53:3d5a3d241a5e 455 /// regAddr=0Eh
whismanoid 53:3d5a3d241a5e 456 /// regAddr=0Fh
whismanoid 53:3d5a3d241a5e 457 /// ConfigABCD: x x x BDAC[3:0] DIFF EQ MODG[1:0] PDPGA FILT PGAG ENBIASP ENBIASN
whismanoid 53:3d5a3d241a5e 458 typedef enum MAX11043_CONFIGABCD_enum_t {
whismanoid 53:3d5a3d241a5e 459 CONFIGABCD_xxxx_xxxx_xxxx_xxx1_ENBIASN = 0x0001, //!< 16'b0000000000000001
whismanoid 53:3d5a3d241a5e 460 CONFIGABCD_xxxx_xxxx_xxxx_xx1x_ENBIASP = 0x0002, //!< 16'b0000000000000010
whismanoid 53:3d5a3d241a5e 461 CONFIGABCD_xxxx_xxxx_xxxx_x1xx_PGAG16 = 0x0004, //!< 16'b0000000000000100
whismanoid 53:3d5a3d241a5e 462 CONFIGABCD_xxxx_xxxx_xxxx_1xxx_FILTLP = 0x0008, //!< 16'b0000000000001000
whismanoid 53:3d5a3d241a5e 463 CONFIGABCD_xxxx_xxxx_xxx1_xxxx_PDPGA = 0x0010, //!< 16'b0000000000010000
whismanoid 53:3d5a3d241a5e 464 CONFIGABCD_xxxx_xxxx_xx1x_xxxx_MODG0 = 0x0020, //!< 16'b0000000000100000
whismanoid 53:3d5a3d241a5e 465 CONFIGABCD_xxxx_xxxx_x1xx_xxxx_MODG1 = 0x0040, //!< 16'b0000000001000000
whismanoid 53:3d5a3d241a5e 466 CONFIGABCD_xxxx_xxxx_1xxx_xxxx_EQ = 0x0080, //!< 16'b0000000010000000
whismanoid 53:3d5a3d241a5e 467 CONFIGABCD_xxxx_xxx1_xxxx_xxxx_DIFF = 0x0100, //!< 16'b0000000100000000
whismanoid 53:3d5a3d241a5e 468 CONFIGABCD_xxxx_xx1x_xxxx_xxxx_BDAC0 = 0x0200, //!< 16'b0000001000000000
whismanoid 53:3d5a3d241a5e 469 CONFIGABCD_xxxx_x1xx_xxxx_xxxx_BDAC1 = 0x0400, //!< 16'b0000010000000000
whismanoid 53:3d5a3d241a5e 470 CONFIGABCD_xxxx_1xxx_xxxx_xxxx_BDAC2 = 0x0800, //!< 16'b0000100000000000
whismanoid 53:3d5a3d241a5e 471 CONFIGABCD_xxx1_xxxx_xxxx_xxxx_BDAC3 = 0x1000, //!< 16'b0001000000000000
whismanoid 53:3d5a3d241a5e 472 CONFIGABCD_xx1x_xxxx_xxxx_xxxx_RESERVED = 0x2000, //!< 16'b0010000000000000
whismanoid 53:3d5a3d241a5e 473 CONFIGABCD_x1xx_xxxx_xxxx_xxxx_RESERVED = 0x4000, //!< 16'b0100000000000000
whismanoid 53:3d5a3d241a5e 474 CONFIGABCD_1xxx_xxxx_xxxx_xxxx_RESERVED = 0x8000, //!< 16'b1000000000000000
whismanoid 53:3d5a3d241a5e 475 } MAX11043_CONFIGABCD_enum_t;
whismanoid 53:3d5a3d241a5e 476
whismanoid 53:3d5a3d241a5e 477 // CODE GENERATOR: TypedefEnum MAX11043_BDAC_enum_t
whismanoid 53:3d5a3d241a5e 478 //----------------------------------------
whismanoid 53:3d5a3d241a5e 479 /// CMD_0011_0000_d16_Wr_CONFIGa
whismanoid 53:3d5a3d241a5e 480 /// CMD_0011_0100_d16_Wr_CONFIGb
whismanoid 53:3d5a3d241a5e 481 /// CMD_0011_1000_d16_Wr_CONFIGc
whismanoid 53:3d5a3d241a5e 482 /// CMD_0011_1100_d16_Wr_CONFIGd
whismanoid 53:3d5a3d241a5e 483 /// CONFIGABCD_xxx1_xxxx_xxxx_xxxx_BDAC3
whismanoid 53:3d5a3d241a5e 484 /// CONFIGABCD_xxxx_1xxx_xxxx_xxxx_BDAC2
whismanoid 53:3d5a3d241a5e 485 /// CONFIGABCD_xxxx_x1xx_xxxx_xxxx_BDAC1
whismanoid 53:3d5a3d241a5e 486 /// CONFIGABCD_xxxx_xx1x_xxxx_xxxx_BDAC0
whismanoid 53:3d5a3d241a5e 487 /// Sets the input bias voltage for AC-coupled signals when ENBIAS_ is set to 1.
whismanoid 53:3d5a3d241a5e 488 /// regAddr=0Ch
whismanoid 53:3d5a3d241a5e 489 /// regAddr=0Dh
whismanoid 53:3d5a3d241a5e 490 /// regAddr=0Eh
whismanoid 53:3d5a3d241a5e 491 /// regAddr=0Fh
whismanoid 53:3d5a3d241a5e 492 /// ConfigABCD: x x x BDAC[3:0] DIFF EQ MODG[1:0] PDPGA FILT PGAG ENBIASP ENBIASN
whismanoid 53:3d5a3d241a5e 493 typedef enum MAX11043_BDAC_enum_t {
whismanoid 53:3d5a3d241a5e 494 BDAC_0000_033pctAVDD = 0x00, //!< 8'b00000000
whismanoid 53:3d5a3d241a5e 495 BDAC_0001_035pctAVDD = 0x01, //!< 8'b00000001
whismanoid 53:3d5a3d241a5e 496 BDAC_0010_038pctAVDD = 0x02, //!< 8'b00000010
whismanoid 53:3d5a3d241a5e 497 BDAC_0011_040pctAVDD = 0x03, //!< 8'b00000011
whismanoid 53:3d5a3d241a5e 498 BDAC_0100_042pctAVDD = 0x04, //!< 8'b00000100
whismanoid 53:3d5a3d241a5e 499 BDAC_0101_044pctAVDD = 0x05, //!< 8'b00000101
whismanoid 53:3d5a3d241a5e 500 BDAC_0110_046pctAVDD = 0x06, //!< 8'b00000110
whismanoid 53:3d5a3d241a5e 501 BDAC_0111_048pctAVDD = 0x07, //!< 8'b00000111
whismanoid 53:3d5a3d241a5e 502 BDAC_1000_050pctAVDD = 0x08, //!< 8'b00001000
whismanoid 53:3d5a3d241a5e 503 BDAC_1001_052pctAVDD = 0x09, //!< 8'b00001001
whismanoid 53:3d5a3d241a5e 504 BDAC_1010_054pctAVDD = 0x0a, //!< 8'b00001010
whismanoid 53:3d5a3d241a5e 505 BDAC_1011_056pctAVDD = 0x0b, //!< 8'b00001011
whismanoid 53:3d5a3d241a5e 506 BDAC_1100_058pctAVDD = 0x0c, //!< 8'b00001100
whismanoid 53:3d5a3d241a5e 507 BDAC_1101_060pctAVDD = 0x0d, //!< 8'b00001101
whismanoid 53:3d5a3d241a5e 508 BDAC_1110_062pctAVDD = 0x0e, //!< 8'b00001110
whismanoid 53:3d5a3d241a5e 509 BDAC_1111_065pctAVDD = 0x0f, //!< 8'b00001111
whismanoid 53:3d5a3d241a5e 510 } MAX11043_BDAC_enum_t;
whismanoid 53:3d5a3d241a5e 511
whismanoid 53:3d5a3d241a5e 512 // CODE GENERATOR: TypedefEnum MAX11043_REFERENCE_enum_t
whismanoid 53:3d5a3d241a5e 513 //----------------------------------------
whismanoid 53:3d5a3d241a5e 514 /// CMD_0100_0000_d16_Wr_Reference
whismanoid 53:3d5a3d241a5e 515 /// regAddr=10h
whismanoid 53:3d5a3d241a5e 516 /// ReferenceDelay: 0 0 0 PURGE[4:0] EXTREF EXBUFA EXBUFB EXBUFC EXBUFD EXBUFDAC EXBUFDACH EXBUFDACL
whismanoid 53:3d5a3d241a5e 517 typedef enum MAX11043_REFERENCE_enum_t {
whismanoid 53:3d5a3d241a5e 518 REFERENCE_xxxx_xxxx_xxxx_xxx1_EXBUFDACL = 0x0001, //!< 16'b0000000000000001
whismanoid 53:3d5a3d241a5e 519 REFERENCE_xxxx_xxxx_xxxx_xx1x_EXBUFDACH = 0x0002, //!< 16'b0000000000000010
whismanoid 53:3d5a3d241a5e 520 REFERENCE_xxxx_xxxx_xxxx_x1xx_EXBUFDAC = 0x0004, //!< 16'b0000000000000100
whismanoid 53:3d5a3d241a5e 521 REFERENCE_xxxx_xxxx_xxxx_1xxx_EXBUFD = 0x0008, //!< 16'b0000000000001000
whismanoid 53:3d5a3d241a5e 522 REFERENCE_xxxx_xxxx_xxx1_xxxx_EXBUFC = 0x0010, //!< 16'b0000000000010000
whismanoid 53:3d5a3d241a5e 523 REFERENCE_xxxx_xxxx_xx1x_xxxx_EXBUFB = 0x0020, //!< 16'b0000000000100000
whismanoid 53:3d5a3d241a5e 524 REFERENCE_xxxx_xxxx_x1xx_xxxx_EXBUFA = 0x0040, //!< 16'b0000000001000000
whismanoid 53:3d5a3d241a5e 525 REFERENCE_xxxx_xxxx_1xxx_xxxx_EXTREF = 0x0080, //!< 16'b0000000010000000
whismanoid 53:3d5a3d241a5e 526 REFERENCE_xxxx_xxx1_xxxx_xxxx_PURGE0 = 0x0100, //!< 16'b0000000100000000
whismanoid 53:3d5a3d241a5e 527 REFERENCE_xxxx_xx1x_xxxx_xxxx_PURGE1 = 0x0200, //!< 16'b0000001000000000
whismanoid 53:3d5a3d241a5e 528 REFERENCE_xxxx_x1xx_xxxx_xxxx_PURGE2 = 0x0400, //!< 16'b0000010000000000
whismanoid 53:3d5a3d241a5e 529 REFERENCE_xxxx_1xxx_xxxx_xxxx_PURGE3 = 0x0800, //!< 16'b0000100000000000
whismanoid 53:3d5a3d241a5e 530 REFERENCE_xxx1_xxxx_xxxx_xxxx_PURGE4 = 0x1000, //!< 16'b0001000000000000
whismanoid 53:3d5a3d241a5e 531 REFERENCE_xx1x_xxxx_xxxx_xxxx_RESERVED = 0x2000, //!< 16'b0010000000000000
whismanoid 53:3d5a3d241a5e 532 REFERENCE_x1xx_xxxx_xxxx_xxxx_RESERVED = 0x4000, //!< 16'b0100000000000000
whismanoid 53:3d5a3d241a5e 533 REFERENCE_1xxx_xxxx_xxxx_xxxx_RESERVED = 0x8000, //!< 16'b1000000000000000
whismanoid 53:3d5a3d241a5e 534 } MAX11043_REFERENCE_enum_t;
whismanoid 53:3d5a3d241a5e 535
whismanoid 53:3d5a3d241a5e 536 // TODO1: CODE GENERATOR: ic_variant -- IC's supported with this driver
whismanoid 53:3d5a3d241a5e 537 /**
whismanoid 53:3d5a3d241a5e 538 * @brief IC's supported with this driver
whismanoid 53:3d5a3d241a5e 539 * @details MAX11043
whismanoid 53:3d5a3d241a5e 540 */
whismanoid 53:3d5a3d241a5e 541 typedef enum
whismanoid 53:3d5a3d241a5e 542 {
whismanoid 53:3d5a3d241a5e 543 MAX11043_IC = 0,
whismanoid 53:3d5a3d241a5e 544 //MAX11043_IC = 1
whismanoid 53:3d5a3d241a5e 545 } MAX11043_ic_t;
whismanoid 53:3d5a3d241a5e 546
whismanoid 53:3d5a3d241a5e 547 // TODO1: CODE GENERATOR: class constructor declaration
whismanoid 53:3d5a3d241a5e 548 /**********************************************************//**
whismanoid 53:3d5a3d241a5e 549 * @brief Constructor for MAX11043 Class.
whismanoid 53:3d5a3d241a5e 550 *
whismanoid 53:3d5a3d241a5e 551 * @details Requires an existing SPI object as well as a DigitalOut object.
whismanoid 53:3d5a3d241a5e 552 * The DigitalOut object is used for a chip enable signal
whismanoid 53:3d5a3d241a5e 553 *
whismanoid 53:3d5a3d241a5e 554 * On Entry:
whismanoid 53:3d5a3d241a5e 555 * @param[in] spi - pointer to existing SPI object
whismanoid 53:3d5a3d241a5e 556 * @param[in] cs_pin - pointer to a DigitalOut pin object
whismanoid 53:3d5a3d241a5e 557 * CODE GENERATOR: class constructor docstrings gpio InputPin pins
whismanoid 53:3d5a3d241a5e 558 * @param[in] CONVRUN_pin - pointer to a DigitalOut pin object
whismanoid 53:3d5a3d241a5e 559 * @param[in] SHDN_pin - pointer to a DigitalOut pin object
whismanoid 53:3d5a3d241a5e 560 * @param[in] DACSTEP_pin - pointer to a DigitalOut pin object
whismanoid 53:3d5a3d241a5e 561 * @param[in] UP_slash_DWNb_pin - pointer to a DigitalOut pin object
whismanoid 53:3d5a3d241a5e 562 * CODE GENERATOR: class constructor docstrings gpio OutputPin pins
whismanoid 53:3d5a3d241a5e 563 * @param[in] EOC_pin - pointer to a DigitalIn pin object
whismanoid 53:3d5a3d241a5e 564 * @param[in] ic_variant - which type of MAX11043 is used
whismanoid 53:3d5a3d241a5e 565 *
whismanoid 53:3d5a3d241a5e 566 * On Exit:
whismanoid 53:3d5a3d241a5e 567 *
whismanoid 53:3d5a3d241a5e 568 * @return None
whismanoid 53:3d5a3d241a5e 569 **************************************************************/
whismanoid 53:3d5a3d241a5e 570 MAX11043(SPI &spi, DigitalOut &cs_pin, // SPI interface
whismanoid 53:3d5a3d241a5e 571 // CODE GENERATOR: class constructor declaration gpio InputPin pins
whismanoid 53:3d5a3d241a5e 572 DigitalOut &CONVRUN_pin, // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 573 DigitalOut &SHDN_pin, // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 574 DigitalOut &DACSTEP_pin, // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 575 DigitalOut &UP_slash_DWNb_pin, // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 576 // CODE GENERATOR: class constructor declaration gpio OutputPin pins
whismanoid 69:989e392cf635 577 // MAX11043 ADC Read operations must be synchronized to EOC End Of Conversion
whismanoid 69:989e392cf635 578 #if MAX11043_EOC_INTERRUPT_POLLING
whismanoid 69:989e392cf635 579 // MAX11043 EOC End Of Conversion input should be InterruptIn(PinName:EOC_pin).fall(onEOCFallingEdge);
whismanoid 69:989e392cf635 580 // Workaround using DigitalIn(PinName:EOC_pin) polled to sync with EOC falling edge for ADC reads
whismanoid 69:989e392cf635 581 // TODO: onEOCFallingEdge: replace DigitalIn &EOC_pin with PinName EOC_pin, so that I can create an InterruptIn(PinName:EOC_pin)
whismanoid 53:3d5a3d241a5e 582 DigitalIn &EOC_pin, // Digital Event Output from MAX11043 device
whismanoid 69:989e392cf635 583 #else // MAX11043_EOC_INTERRUPT_POLLING
whismanoid 69:989e392cf635 584 // MAX11043 EOC End Of Conversion input is InterruptIn(PinName:EOC_pin).fall(onEOCFallingEdge);
whismanoid 69:989e392cf635 585 InterruptIn &EOC_pin, // Digital Event Output from MAX11043 device
whismanoid 69:989e392cf635 586 #endif // MAX11043_EOC_INTERRUPT_POLLING
whismanoid 53:3d5a3d241a5e 587 MAX11043_ic_t ic_variant);
whismanoid 53:3d5a3d241a5e 588
whismanoid 53:3d5a3d241a5e 589 // CODE GENERATOR: class destructor declaration
whismanoid 53:3d5a3d241a5e 590 /************************************************************
whismanoid 53:3d5a3d241a5e 591 * @brief Default destructor for MAX11043 Class.
whismanoid 53:3d5a3d241a5e 592 *
whismanoid 53:3d5a3d241a5e 593 * @details Destroys SPI object if owner
whismanoid 53:3d5a3d241a5e 594 *
whismanoid 53:3d5a3d241a5e 595 * On Entry:
whismanoid 53:3d5a3d241a5e 596 *
whismanoid 53:3d5a3d241a5e 597 * On Exit:
whismanoid 53:3d5a3d241a5e 598 *
whismanoid 53:3d5a3d241a5e 599 * @return None
whismanoid 53:3d5a3d241a5e 600 **************************************************************/
whismanoid 53:3d5a3d241a5e 601 ~MAX11043();
whismanoid 53:3d5a3d241a5e 602
whismanoid 53:3d5a3d241a5e 603 // CODE GENERATOR: Declare SPI diagnostic function pointer void onSPIprint()
whismanoid 53:3d5a3d241a5e 604 /// Function pointer void f(size_t byteCount, uint8_t mosiData[], uint8_t misoData[])
whismanoid 53:3d5a3d241a5e 605 Callback<void(size_t, uint8_t*, uint8_t*)> onSPIprint; //!< optional @ref onSPIprint SPI diagnostic function
whismanoid 53:3d5a3d241a5e 606
whismanoid 53:3d5a3d241a5e 607 // CODE GENERATOR: spi_frequency setter declaration
whismanoid 53:3d5a3d241a5e 608 /// set SPI SCLK frequency
whismanoid 53:3d5a3d241a5e 609 void spi_frequency(int spi_sclk_Hz);
whismanoid 53:3d5a3d241a5e 610
whismanoid 53:3d5a3d241a5e 611 // CODE GENERATOR: spi_frequency getter declaration and definition
whismanoid 53:3d5a3d241a5e 612 /// get SPI SCLK frequency
whismanoid 53:3d5a3d241a5e 613 int get_spi_frequency() const { return m_SPI_SCLK_Hz; }
whismanoid 53:3d5a3d241a5e 614
whismanoid 53:3d5a3d241a5e 615 // CODE GENERATOR: spi_dataMode getter declaration and definition
whismanoid 53:3d5a3d241a5e 616 /// get SPI mode
whismanoid 53:3d5a3d241a5e 617 int get_spi_dataMode() const { return m_SPI_dataMode; }
whismanoid 53:3d5a3d241a5e 618
whismanoid 53:3d5a3d241a5e 619 //----------------------------------------
whismanoid 53:3d5a3d241a5e 620 // CODE GENERATOR: omit typedef enum MAX11043_device_t, class members instead of global device object
whismanoid 53:3d5a3d241a5e 621 public:
whismanoid 53:3d5a3d241a5e 622
whismanoid 59:47538bcf6cda 623 /// reference voltage, in Volts
whismanoid 59:47538bcf6cda 624 double VRef;
whismanoid 53:3d5a3d241a5e 625
whismanoid 59:47538bcf6cda 626 /// shadow of register config CMD_0010_0010_d16_Rd08_Configuration
whismanoid 59:47538bcf6cda 627 uint16_t config;
whismanoid 53:3d5a3d241a5e 628
whismanoid 59:47538bcf6cda 629 /// shadow of register status CMD_0001_1110_d8_Rd07_Status
whismanoid 53:3d5a3d241a5e 630 uint32_t status;
whismanoid 53:3d5a3d241a5e 631
whismanoid 59:47538bcf6cda 632 /// shadow of register ADCa CMD_0000_0010_d16o8_Rd00_ADCa
whismanoid 59:47538bcf6cda 633 uint32_t adca;
whismanoid 59:47538bcf6cda 634
whismanoid 59:47538bcf6cda 635 /// shadow of register ADCb CMD_0000_0110_d16o8_Rd01_ADCb
whismanoid 59:47538bcf6cda 636 uint32_t adcb;
whismanoid 53:3d5a3d241a5e 637
whismanoid 59:47538bcf6cda 638 /// shadow of register ADCc CMD_0000_1010_d16o8_Rd02_ADCc
whismanoid 59:47538bcf6cda 639 uint32_t adcc;
whismanoid 59:47538bcf6cda 640
whismanoid 59:47538bcf6cda 641 /// shadow of register ADCd CMD_0000_1110_d16o8_Rd03_ADCd
whismanoid 59:47538bcf6cda 642 uint32_t adcd;
whismanoid 53:3d5a3d241a5e 643
whismanoid 53:3d5a3d241a5e 644 // CODE GENERATOR: omit global g_MAX11043_device
whismanoid 53:3d5a3d241a5e 645
whismanoid 53:3d5a3d241a5e 646 // CODE GENERATOR: extern function declarations
whismanoid 53:3d5a3d241a5e 647 // CODE GENERATOR: extern function declaration SPIoutputCS
whismanoid 53:3d5a3d241a5e 648 //----------------------------------------
whismanoid 53:3d5a3d241a5e 649 // Assert SPI Chip Select
whismanoid 53:3d5a3d241a5e 650 // SPI chip-select for MAX11043
whismanoid 53:3d5a3d241a5e 651 //
whismanoid 53:3d5a3d241a5e 652 void SPIoutputCS(int isLogicHigh);
whismanoid 53:3d5a3d241a5e 653
whismanoid 62:8223a7253c90 654 // CODE GENERATOR: extern function declaration SPIreadWriteWithLowCS
whismanoid 62:8223a7253c90 655 //----------------------------------------
whismanoid 62:8223a7253c90 656 // SPI read and write arbitrary number of 8-bit bytes
whismanoid 62:8223a7253c90 657 // SPI interface to MAX11043 shift mosiData into MAX11043 DIN
whismanoid 62:8223a7253c90 658 // while simultaneously capturing miso data from MAX11043 DOUT
whismanoid 62:8223a7253c90 659 //
whismanoid 62:8223a7253c90 660 int SPIreadWriteWithLowCS(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]);
whismanoid 62:8223a7253c90 661
whismanoid 53:3d5a3d241a5e 662 // CODE GENERATOR: extern function declaration SHDNoutputValue
whismanoid 53:3d5a3d241a5e 663 //----------------------------------------
whismanoid 58:2fea32db466b 664 // Assert MAX11043 SHDN pin : High = Shut Down, Low = Normal Operation.
whismanoid 53:3d5a3d241a5e 665 //
whismanoid 53:3d5a3d241a5e 666 void SHDNoutputValue(int isLogicHigh);
whismanoid 53:3d5a3d241a5e 667
whismanoid 53:3d5a3d241a5e 668 // CODE GENERATOR: extern function declaration CONVRUNoutputValue
whismanoid 53:3d5a3d241a5e 669 //----------------------------------------
whismanoid 58:2fea32db466b 670 // Assert MAX11043 CONVRUN pin : High = start continuous conversions on all 4 channels, Low = Idle.
whismanoid 53:3d5a3d241a5e 671 //
whismanoid 53:3d5a3d241a5e 672 void CONVRUNoutputValue(int isLogicHigh);
whismanoid 53:3d5a3d241a5e 673
whismanoid 53:3d5a3d241a5e 674 // CODE GENERATOR: extern function declaration DACSTEPoutputValue
whismanoid 53:3d5a3d241a5e 675 //----------------------------------------
whismanoid 58:2fea32db466b 676 // Assert MAX11043 DACSTEP pin : High = Active, Low = Idle.
whismanoid 53:3d5a3d241a5e 677 //
whismanoid 53:3d5a3d241a5e 678 void DACSTEPoutputValue(int isLogicHigh);
whismanoid 53:3d5a3d241a5e 679
whismanoid 53:3d5a3d241a5e 680 // CODE GENERATOR: extern function declaration UP_slash_DWNboutputValue
whismanoid 53:3d5a3d241a5e 681 //----------------------------------------
whismanoid 58:2fea32db466b 682 // Assert MAX11043 UP_slash_DWNb pin : High = Up, Low = Down.
whismanoid 53:3d5a3d241a5e 683 //
whismanoid 53:3d5a3d241a5e 684 void UP_slash_DWNboutputValue(int isLogicHigh);
whismanoid 53:3d5a3d241a5e 685
whismanoid 53:3d5a3d241a5e 686 // CODE GENERATOR: extern function declaration EOCinputWaitUntilLow
whismanoid 53:3d5a3d241a5e 687 //----------------------------------------
whismanoid 53:3d5a3d241a5e 688 // Wait for MAX11043 EOC pin low, indicating end of conversion.
whismanoid 53:3d5a3d241a5e 689 // Required when using any of the InternalClock modes.
whismanoid 53:3d5a3d241a5e 690 //
whismanoid 53:3d5a3d241a5e 691 void EOCinputWaitUntilLow();
whismanoid 53:3d5a3d241a5e 692
whismanoid 53:3d5a3d241a5e 693 // CODE GENERATOR: extern function declaration EOCinputValue
whismanoid 53:3d5a3d241a5e 694 //----------------------------------------
whismanoid 53:3d5a3d241a5e 695 // Return the status of the MAX11043 EOC pin.
whismanoid 53:3d5a3d241a5e 696 //
whismanoid 53:3d5a3d241a5e 697 int EOCinputValue();
whismanoid 53:3d5a3d241a5e 698
whismanoid 53:3d5a3d241a5e 699 // CODE GENERATOR: class member data
whismanoid 53:3d5a3d241a5e 700 private:
whismanoid 53:3d5a3d241a5e 701 // CODE GENERATOR: class member data for SPI interface
whismanoid 53:3d5a3d241a5e 702 // SPI object
whismanoid 53:3d5a3d241a5e 703 SPI &m_spi;
whismanoid 53:3d5a3d241a5e 704 int m_SPI_SCLK_Hz;
whismanoid 53:3d5a3d241a5e 705 int m_SPI_dataMode;
whismanoid 53:3d5a3d241a5e 706 int m_SPI_cs_state;
whismanoid 53:3d5a3d241a5e 707
whismanoid 53:3d5a3d241a5e 708 // Selector pin object
whismanoid 53:3d5a3d241a5e 709 DigitalOut &m_cs_pin;
whismanoid 53:3d5a3d241a5e 710
whismanoid 53:3d5a3d241a5e 711 // CODE GENERATOR: class member data for gpio InputPin pins
whismanoid 53:3d5a3d241a5e 712 // InputPin Name = CONVRUN
whismanoid 53:3d5a3d241a5e 713 // 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 714 // CONVRUN is low.
whismanoid 53:3d5a3d241a5e 715 // InputPin Function = Configuration
whismanoid 53:3d5a3d241a5e 716 DigitalOut &m_CONVRUN_pin;
whismanoid 53:3d5a3d241a5e 717 //
whismanoid 53:3d5a3d241a5e 718 // InputPin Name = SHDN
whismanoid 53:3d5a3d241a5e 719 // InputPin Description = Shutdown (digital input). Active-High Shutdown Input. Drive high to shut down the MAX11043.
whismanoid 53:3d5a3d241a5e 720 // InputPin Function = Configuration
whismanoid 53:3d5a3d241a5e 721 DigitalOut &m_SHDN_pin;
whismanoid 53:3d5a3d241a5e 722 //
whismanoid 53:3d5a3d241a5e 723 // InputPin Name = DACSTEP
whismanoid 53:3d5a3d241a5e 724 // 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 725 // edge of the system clock.
whismanoid 53:3d5a3d241a5e 726 // InputPin Function = Configuration
whismanoid 53:3d5a3d241a5e 727 DigitalOut &m_DACSTEP_pin;
whismanoid 53:3d5a3d241a5e 728 //
whismanoid 53:3d5a3d241a5e 729 // InputPin Name = UP/DWN#
whismanoid 53:3d5a3d241a5e 730 // 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 731 // InputPin Function = Configuration
whismanoid 53:3d5a3d241a5e 732 DigitalOut &m_UP_slash_DWNb_pin;
whismanoid 53:3d5a3d241a5e 733 //
whismanoid 53:3d5a3d241a5e 734 // CODE GENERATOR: class member data for gpio OutputPin pins
whismanoid 53:3d5a3d241a5e 735 // OutputPin Name = EOC
whismanoid 53:3d5a3d241a5e 736 // 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 737 // OutputPin Function = Event
whismanoid 70:f44a577c9e59 738 //--------------------------------------------------
whismanoid 70:f44a577c9e59 739 // MAX11043 ADC Read operations must be synchronized to EOC End Of Conversion
whismanoid 70:f44a577c9e59 740 // EOC# asserts low when new data is available.
whismanoid 70:f44a577c9e59 741 // Initiate a data read prior to the next rising edge of EOC# or the result is overwritten.
whismanoid 70:f44a577c9e59 742 #if MAX11043_EOC_INTERRUPT_POLLING
whismanoid 70:f44a577c9e59 743 // MAX11043 EOC End Of Conversion input should be InterruptIn(PinName:EOC_pin).fall(onEOCFallingEdge);
whismanoid 70:f44a577c9e59 744 // Workaround using DigitalIn(PinName:EOC_pin) polled to sync with EOC falling edge for ADC reads
whismanoid 70:f44a577c9e59 745 // 2020-02-20 MAX11043_EOC_INTERRUPT_POLLING works on MAX32625MBED at 9us conversion rate, with 1us timing margin
whismanoid 53:3d5a3d241a5e 746 DigitalIn &m_EOC_pin;
whismanoid 70:f44a577c9e59 747 #else // MAX11043_EOC_INTERRUPT_POLLING
whismanoid 70:f44a577c9e59 748 // MAX11043 EOC End Of Conversion input is InterruptIn(PinName:EOC_pin).fall(onEOCFallingEdge);
whismanoid 70:f44a577c9e59 749 InterruptIn &m_EOC_pin;
whismanoid 70:f44a577c9e59 750 #endif // MAX11043_EOC_INTERRUPT_POLLING
whismanoid 70:f44a577c9e59 751 //--------------------------------------------------
whismanoid 53:3d5a3d241a5e 752 //
whismanoid 53:3d5a3d241a5e 753
whismanoid 53:3d5a3d241a5e 754 // Identifies which IC variant is being used
whismanoid 53:3d5a3d241a5e 755 MAX11043_ic_t m_ic_variant;
whismanoid 53:3d5a3d241a5e 756
whismanoid 53:3d5a3d241a5e 757 public:
whismanoid 53:3d5a3d241a5e 758
whismanoid 53:3d5a3d241a5e 759 // CODE GENERATOR: class member function declarations
whismanoid 53:3d5a3d241a5e 760 //----------------------------------------
whismanoid 53:3d5a3d241a5e 761 /// Menu item '!'
whismanoid 53:3d5a3d241a5e 762 /// Initialize device
whismanoid 53:3d5a3d241a5e 763 /// @return 1 on success; 0 on failure
whismanoid 53:3d5a3d241a5e 764 uint8_t Init(void);
whismanoid 53:3d5a3d241a5e 765
whismanoid 53:3d5a3d241a5e 766 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 767 // CODE GENERATOR: looks like this is a 'write' register access function
whismanoid 53:3d5a3d241a5e 768 //----------------------------------------
whismanoid 53:3d5a3d241a5e 769 /// Write a MAX11043 register.
whismanoid 53:3d5a3d241a5e 770 ///
whismanoid 57:1c9da8e90737 771 /// CMDOP_1aaa_aaaa_ReadRegister bit is cleared 0 indicating a write operation.
whismanoid 53:3d5a3d241a5e 772 ///
whismanoid 53:3d5a3d241a5e 773 /// MAX11043 register length can be determined by function RegSize.
whismanoid 53:3d5a3d241a5e 774 ///
whismanoid 53:3d5a3d241a5e 775 /// For 8-bit register size:
whismanoid 53:3d5a3d241a5e 776 ///
whismanoid 53:3d5a3d241a5e 777 /// SPI 16-bit transfer
whismanoid 53:3d5a3d241a5e 778 ///
whismanoid 53:3d5a3d241a5e 779 /// SPI MOSI = 0aaa_aaaa_dddd_dddd
whismanoid 53:3d5a3d241a5e 780 ///
whismanoid 53:3d5a3d241a5e 781 /// SPI MISO = xxxx_xxxx_xxxx_xxxx
whismanoid 53:3d5a3d241a5e 782 ///
whismanoid 53:3d5a3d241a5e 783 /// For 16-bit register size:
whismanoid 53:3d5a3d241a5e 784 ///
whismanoid 53:3d5a3d241a5e 785 /// SPI 24-bit or 32-bit transfer
whismanoid 53:3d5a3d241a5e 786 ///
whismanoid 53:3d5a3d241a5e 787 /// SPI MOSI = 0aaa_aaaa_dddd_dddd_dddd_dddd
whismanoid 53:3d5a3d241a5e 788 ///
whismanoid 53:3d5a3d241a5e 789 /// SPI MISO = xxxx_xxxx_xxxx_xxxx_xxxx_xxxx
whismanoid 53:3d5a3d241a5e 790 ///
whismanoid 53:3d5a3d241a5e 791 /// For 24-bit register size:
whismanoid 53:3d5a3d241a5e 792 ///
whismanoid 53:3d5a3d241a5e 793 /// SPI 32-bit transfer
whismanoid 53:3d5a3d241a5e 794 ///
whismanoid 53:3d5a3d241a5e 795 /// SPI MOSI = 0aaa_aaaa_dddd_dddd_dddd_dddd_dddd_dddd
whismanoid 53:3d5a3d241a5e 796 ///
whismanoid 53:3d5a3d241a5e 797 /// SPI MISO = xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx
whismanoid 53:3d5a3d241a5e 798 ///
whismanoid 53:3d5a3d241a5e 799 /// @return 1 on success; 0 on failure
whismanoid 53:3d5a3d241a5e 800 uint8_t RegWrite(MAX11043_CMD_enum_t commandByte, uint32_t regData);
whismanoid 53:3d5a3d241a5e 801
whismanoid 53:3d5a3d241a5e 802 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 803 // CODE GENERATOR: looks like this is a 'read' register access function
whismanoid 53:3d5a3d241a5e 804 //----------------------------------------
whismanoid 53:3d5a3d241a5e 805 /// Read an 8-bit MAX11043 register
whismanoid 53:3d5a3d241a5e 806 ///
whismanoid 57:1c9da8e90737 807 /// CMDOP_1aaa_aaaa_ReadRegister bit is set 1 indicating a read operation.
whismanoid 53:3d5a3d241a5e 808 ///
whismanoid 53:3d5a3d241a5e 809 /// MAX11043 register length can be determined by function RegSize.
whismanoid 53:3d5a3d241a5e 810 ///
whismanoid 53:3d5a3d241a5e 811 /// For 8-bit register size:
whismanoid 53:3d5a3d241a5e 812 ///
whismanoid 53:3d5a3d241a5e 813 /// SPI 16-bit transfer
whismanoid 53:3d5a3d241a5e 814 ///
whismanoid 53:3d5a3d241a5e 815 /// SPI MOSI = 1aaa_aaaa_0000_0000
whismanoid 53:3d5a3d241a5e 816 ///
whismanoid 53:3d5a3d241a5e 817 /// SPI MISO = xxxx_xxxx_dddd_dddd
whismanoid 53:3d5a3d241a5e 818 ///
whismanoid 53:3d5a3d241a5e 819 /// For 16-bit register size:
whismanoid 53:3d5a3d241a5e 820 ///
whismanoid 53:3d5a3d241a5e 821 /// SPI 24-bit or 32-bit transfer
whismanoid 53:3d5a3d241a5e 822 ///
whismanoid 53:3d5a3d241a5e 823 /// SPI MOSI = 1aaa_aaaa_0000_0000_0000_0000
whismanoid 53:3d5a3d241a5e 824 ///
whismanoid 53:3d5a3d241a5e 825 /// SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd
whismanoid 53:3d5a3d241a5e 826 ///
whismanoid 53:3d5a3d241a5e 827 /// For 24-bit register size:
whismanoid 53:3d5a3d241a5e 828 ///
whismanoid 53:3d5a3d241a5e 829 /// SPI 32-bit transfer
whismanoid 53:3d5a3d241a5e 830 ///
whismanoid 53:3d5a3d241a5e 831 /// SPI MOSI = 1aaa_aaaa_0000_0000_0000_0000_0000_0000
whismanoid 53:3d5a3d241a5e 832 ///
whismanoid 53:3d5a3d241a5e 833 /// SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd_dddd_dddd
whismanoid 53:3d5a3d241a5e 834 ///
whismanoid 53:3d5a3d241a5e 835 ///
whismanoid 53:3d5a3d241a5e 836 /// @return 1 on success; 0 on failure
whismanoid 53:3d5a3d241a5e 837 uint8_t RegRead(MAX11043_CMD_enum_t commandByte, uint32_t* ptrRegData);
whismanoid 53:3d5a3d241a5e 838
whismanoid 53:3d5a3d241a5e 839 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 840 // CODE GENERATOR: looks like this is a 'size' register access function
whismanoid 53:3d5a3d241a5e 841 //----------------------------------------
whismanoid 53:3d5a3d241a5e 842 /// Return the size of a MAX11043 register
whismanoid 53:3d5a3d241a5e 843 ///
whismanoid 53:3d5a3d241a5e 844 /// @return 8 for 8-bit, 16 for 16-bit, 24 for 24-bit, else 0 for undefined register size
whismanoid 53:3d5a3d241a5e 845 uint8_t RegSize(MAX11043_CMD_enum_t commandByte);
whismanoid 53:3d5a3d241a5e 846
whismanoid 53:3d5a3d241a5e 847 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 848 //----------------------------------------
whismanoid 57:1c9da8e90737 849 /// Decode operation from commandByte
whismanoid 57:1c9da8e90737 850 ///
whismanoid 57:1c9da8e90737 851 /// @return operation such as idle, read register, write register, etc.
whismanoid 57:1c9da8e90737 852 MAX11043::MAX11043_CMDOP_enum_t DecodeCommand(MAX11043_CMD_enum_t commandByte);
whismanoid 57:1c9da8e90737 853
whismanoid 57:1c9da8e90737 854 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 57:1c9da8e90737 855 //----------------------------------------
whismanoid 53:3d5a3d241a5e 856 /// Return the address field of a MAX11043 register
whismanoid 53:3d5a3d241a5e 857 ///
whismanoid 53:3d5a3d241a5e 858 /// @return register address field as given in datasheet
whismanoid 53:3d5a3d241a5e 859 uint8_t RegAddrOfCommand(MAX11043_CMD_enum_t commandByte);
whismanoid 53:3d5a3d241a5e 860
whismanoid 53:3d5a3d241a5e 861 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 862 // CODE GENERATOR: looks like this is a 'read' register access function
whismanoid 53:3d5a3d241a5e 863 //----------------------------------------
whismanoid 53:3d5a3d241a5e 864 /// Test whether a command byte is a register read command
whismanoid 53:3d5a3d241a5e 865 ///
whismanoid 53:3d5a3d241a5e 866 /// @return true if command byte is a register read command
whismanoid 53:3d5a3d241a5e 867 uint8_t IsRegReadCommand(MAX11043_CMD_enum_t commandByte);
whismanoid 53:3d5a3d241a5e 868
whismanoid 53:3d5a3d241a5e 869 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 870 // CODE GENERATOR: looks like this is a 'name' register access function
whismanoid 53:3d5a3d241a5e 871 //----------------------------------------
whismanoid 53:3d5a3d241a5e 872 /// Return the name of a MAX11043 register
whismanoid 53:3d5a3d241a5e 873 ///
whismanoid 53:3d5a3d241a5e 874 /// @return null-terminated constant C string containing register name or empty string
whismanoid 53:3d5a3d241a5e 875 const char* RegName(MAX11043_CMD_enum_t commandByte);
whismanoid 53:3d5a3d241a5e 876
whismanoid 59:47538bcf6cda 877 //----------------------------------------
whismanoid 64:a667cfd83492 878 /// Menu item '$' -> adca, adcb, adcc, adcd
whismanoid 64:a667cfd83492 879 /// Read ADCabcd
whismanoid 64:a667cfd83492 880 ///
whismanoid 64:a667cfd83492 881 /// @return 1 on success; 0 on failure
whismanoid 64:a667cfd83492 882 uint8_t Read_ADCabcd(void);
whismanoid 64:a667cfd83492 883
whismanoid 64:a667cfd83492 884 //----------------------------------------
whismanoid 66:3fe92f6f1cfa 885 /// Menu item 'GA'
whismanoid 64:a667cfd83492 886 /// Write AGain register
whismanoid 64:a667cfd83492 887 ///
whismanoid 64:a667cfd83492 888 /// @param[in] gain 2's complement, 0x800=0.25V/V, 0x1000=0.5V/V, 0x2000=1VV/V, 0x4000=2V/V, default=0x2000
whismanoid 64:a667cfd83492 889 ///
whismanoid 64:a667cfd83492 890 /// @return 1 on success; 0 on failure
whismanoid 64:a667cfd83492 891 uint8_t Write_AGain(uint32_t gain);
whismanoid 64:a667cfd83492 892
whismanoid 64:a667cfd83492 893 //----------------------------------------
whismanoid 59:47538bcf6cda 894 /// Menu item 'XX'
whismanoid 59:47538bcf6cda 895 ///
whismanoid 59:47538bcf6cda 896 /// @return 1 on success; 0 on failure
whismanoid 59:47538bcf6cda 897 uint8_t Configure_XXXXX(uint8_t linef, uint8_t rate);
whismanoid 59:47538bcf6cda 898
whismanoid 59:47538bcf6cda 899 //----------------------------------------
whismanoid 59:47538bcf6cda 900 /// Menu item 'XY'
whismanoid 59:47538bcf6cda 901 ///
whismanoid 59:47538bcf6cda 902 /// @return 1 on success; 0 on failure
whismanoid 59:47538bcf6cda 903 uint8_t Configure_XXXXY(uint8_t linef, uint8_t rate);
whismanoid 59:47538bcf6cda 904
whismanoid 53:3d5a3d241a5e 905 }; // end of class MAX11043
whismanoid 53:3d5a3d241a5e 906
whismanoid 53:3d5a3d241a5e 907 #endif // __MAX11043_H__
whismanoid 53:3d5a3d241a5e 908
whismanoid 53:3d5a3d241a5e 909 // End of file