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:
Mon Feb 17 23:35:43 2020 +0000
Revision:
59:47538bcf6cda
Parent:
58:2fea32db466b
Child:
62:8223a7253c90
init d16o8 adca-adcd WIP read ADCabcd

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 53:3d5a3d241a5e 67 // standard include for target platform -- Platform_Include_Boilerplate
whismanoid 53:3d5a3d241a5e 68 #include "mbed.h"
whismanoid 53:3d5a3d241a5e 69 // Platforms:
whismanoid 53:3d5a3d241a5e 70 // - MAX32625MBED
whismanoid 53:3d5a3d241a5e 71 // - supports mbed-os-5.11, requires USBDevice library
whismanoid 53:3d5a3d241a5e 72 // - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
whismanoid 53:3d5a3d241a5e 73 // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 74 // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 75 // - MAX32600MBED
whismanoid 53:3d5a3d241a5e 76 // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 77 // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 78 // - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board.
whismanoid 53:3d5a3d241a5e 79 // - NUCLEO_F446RE
whismanoid 53:3d5a3d241a5e 80 // - remove USBDevice library
whismanoid 53:3d5a3d241a5e 81 // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 82 // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 83 // - NUCLEO_F401RE
whismanoid 53:3d5a3d241a5e 84 // - remove USBDevice library
whismanoid 53:3d5a3d241a5e 85 // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 86 // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 87 // - MAX32630FTHR
whismanoid 53:3d5a3d241a5e 88 // - #include "max32630fthr.h"
whismanoid 53:3d5a3d241a5e 89 // - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/
whismanoid 53:3d5a3d241a5e 90 // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 91 // - MAX32620FTHR
whismanoid 53:3d5a3d241a5e 92 // - #include "MAX32620FTHR.h"
whismanoid 53:3d5a3d241a5e 93 // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 94 // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
whismanoid 53:3d5a3d241a5e 95 // - not tested yet
whismanoid 53:3d5a3d241a5e 96 // - MAX32625PICO
whismanoid 53:3d5a3d241a5e 97 // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 98 // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 99 // - not tested yet
whismanoid 53:3d5a3d241a5e 100 //
whismanoid 53:3d5a3d241a5e 101 // end Platform_Include_Boilerplate
whismanoid 53:3d5a3d241a5e 102
whismanoid 53:3d5a3d241a5e 103 // CODE GENERATOR: conditional defines
whismanoid 53:3d5a3d241a5e 104 // CODE GENERATOR: class declaration and docstrings
whismanoid 53:3d5a3d241a5e 105 /**
whismanoid 53:3d5a3d241a5e 106 * @brief MAX11043 200ksps, Low-Power, Serial SPI 24-Bit, 4-Channel, Differential/Single-Ended Input, Simultaneous-Sampling SD ADC
whismanoid 53:3d5a3d241a5e 107 *
whismanoid 53:3d5a3d241a5e 108 *
whismanoid 53:3d5a3d241a5e 109 *
whismanoid 53:3d5a3d241a5e 110 * Datasheet: https://www.maximintegrated.com/MAX11043
whismanoid 53:3d5a3d241a5e 111 *
whismanoid 53:3d5a3d241a5e 112 *
whismanoid 53:3d5a3d241a5e 113 *
whismanoid 53:3d5a3d241a5e 114 * //---------- CODE GENERATOR: helloCppCodeList
whismanoid 53:3d5a3d241a5e 115 * @code
whismanoid 53:3d5a3d241a5e 116 * // CODE GENERATOR: example code includes
whismanoid 53:3d5a3d241a5e 117 *
whismanoid 53:3d5a3d241a5e 118 * // example code includes
whismanoid 53:3d5a3d241a5e 119 * // standard include for target platform -- Platform_Include_Boilerplate
whismanoid 53:3d5a3d241a5e 120 * #include "mbed.h"
whismanoid 53:3d5a3d241a5e 121 * // Platforms:
whismanoid 53:3d5a3d241a5e 122 * // - MAX32625MBED
whismanoid 53:3d5a3d241a5e 123 * // - supports mbed-os-5.11, requires USBDevice library
whismanoid 53:3d5a3d241a5e 124 * // - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
whismanoid 53:3d5a3d241a5e 125 * // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 126 * // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 127 * // - MAX32600MBED
whismanoid 53:3d5a3d241a5e 128 * // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 129 * // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 130 * // - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board.
whismanoid 53:3d5a3d241a5e 131 * // - NUCLEO_F446RE
whismanoid 53:3d5a3d241a5e 132 * // - remove USBDevice library
whismanoid 53:3d5a3d241a5e 133 * // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 134 * // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 135 * // - NUCLEO_F401RE
whismanoid 53:3d5a3d241a5e 136 * // - remove USBDevice library
whismanoid 53:3d5a3d241a5e 137 * // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 138 * // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 139 * // - MAX32630FTHR
whismanoid 53:3d5a3d241a5e 140 * // - #include "max32630fthr.h"
whismanoid 53:3d5a3d241a5e 141 * // - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/
whismanoid 53:3d5a3d241a5e 142 * // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 143 * // - MAX32620FTHR
whismanoid 53:3d5a3d241a5e 144 * // - #include "MAX32620FTHR.h"
whismanoid 53:3d5a3d241a5e 145 * // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 146 * // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
whismanoid 53:3d5a3d241a5e 147 * // - not tested yet
whismanoid 53:3d5a3d241a5e 148 * // - MAX32625PICO
whismanoid 53:3d5a3d241a5e 149 * // - remove max32630fthr library (if present)
whismanoid 53:3d5a3d241a5e 150 * // - remove MAX32620FTHR library (if present)
whismanoid 53:3d5a3d241a5e 151 * // - not tested yet
whismanoid 53:3d5a3d241a5e 152 * //
whismanoid 53:3d5a3d241a5e 153 * // end Platform_Include_Boilerplate
whismanoid 53:3d5a3d241a5e 154 * #include "MAX11043.h"
whismanoid 53:3d5a3d241a5e 155 *
whismanoid 53:3d5a3d241a5e 156 * // example code board support
whismanoid 53:3d5a3d241a5e 157 * //MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 53:3d5a3d241a5e 158 * //DigitalOut rLED(LED1);
whismanoid 53:3d5a3d241a5e 159 * //DigitalOut gLED(LED2);
whismanoid 53:3d5a3d241a5e 160 * //DigitalOut bLED(LED3);
whismanoid 53:3d5a3d241a5e 161 * //
whismanoid 53:3d5a3d241a5e 162 * // Arduino "shield" connector port definitions (MAX32625MBED shown)
whismanoid 53:3d5a3d241a5e 163 * #if defined(TARGET_MAX32625MBED)
whismanoid 53:3d5a3d241a5e 164 * #define A0 AIN_0
whismanoid 53:3d5a3d241a5e 165 * #define A1 AIN_1
whismanoid 53:3d5a3d241a5e 166 * #define A2 AIN_2
whismanoid 53:3d5a3d241a5e 167 * #define A3 AIN_3
whismanoid 53:3d5a3d241a5e 168 * #define D0 P0_0
whismanoid 53:3d5a3d241a5e 169 * #define D1 P0_1
whismanoid 53:3d5a3d241a5e 170 * #define D2 P0_2
whismanoid 53:3d5a3d241a5e 171 * #define D3 P0_3
whismanoid 53:3d5a3d241a5e 172 * #define D4 P0_4
whismanoid 53:3d5a3d241a5e 173 * #define D5 P0_5
whismanoid 53:3d5a3d241a5e 174 * #define D6 P0_6
whismanoid 53:3d5a3d241a5e 175 * #define D7 P0_7
whismanoid 53:3d5a3d241a5e 176 * #define D8 P1_4
whismanoid 53:3d5a3d241a5e 177 * #define D9 P1_5
whismanoid 53:3d5a3d241a5e 178 * #define D10 P1_3
whismanoid 53:3d5a3d241a5e 179 * #define D11 P1_1
whismanoid 53:3d5a3d241a5e 180 * #define D12 P1_2
whismanoid 53:3d5a3d241a5e 181 * #define D13 P1_0
whismanoid 53:3d5a3d241a5e 182 * #endif
whismanoid 53:3d5a3d241a5e 183 *
whismanoid 53:3d5a3d241a5e 184 * // example code declare SPI interface
whismanoid 53:3d5a3d241a5e 185 * #if defined(TARGET_MAX32625MBED)
whismanoid 53:3d5a3d241a5e 186 * 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
whismanoid 53:3d5a3d241a5e 187 * DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
whismanoid 53:3d5a3d241a5e 188 * #elif defined(TARGET_MAX32600MBED)
whismanoid 53:3d5a3d241a5e 189 * SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 53:3d5a3d241a5e 190 * DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 53:3d5a3d241a5e 191 * #else
whismanoid 53:3d5a3d241a5e 192 * SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 53:3d5a3d241a5e 193 * DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
whismanoid 53:3d5a3d241a5e 194 * #endif
whismanoid 53:3d5a3d241a5e 195 *
whismanoid 53:3d5a3d241a5e 196 * // example code declare GPIO interface pins
whismanoid 53:3d5a3d241a5e 197 * DigitalOut CONVRUN_pin(D9); // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 198 * DigitalOut SHDN_pin(D8); // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 199 * DigitalOut DACSTEP_pin(D7); // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 200 * DigitalOut UP_slash_DWNb_pin(D6); // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 201 * DigitalIn EOC_pin(D2); // Digital Event Output from MAX11043 device
whismanoid 53:3d5a3d241a5e 202 * // example code declare device instance
whismanoid 53:3d5a3d241a5e 203 * 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 204 *
whismanoid 53:3d5a3d241a5e 205 * // CODE GENERATOR: example code for ADC: serial port declaration
whismanoid 53:3d5a3d241a5e 206 * //--------------------------------------------------
whismanoid 53:3d5a3d241a5e 207 * // Declare the Serial driver
whismanoid 53:3d5a3d241a5e 208 * // default baud rate settings are 9600 8N1
whismanoid 53:3d5a3d241a5e 209 * // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
whismanoid 53:3d5a3d241a5e 210 * // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
whismanoid 53:3d5a3d241a5e 211 * #if defined(TARGET_MAX32630)
whismanoid 53:3d5a3d241a5e 212 * #include "USBSerial.h"
whismanoid 53:3d5a3d241a5e 213 * // Hardware serial port over DAPLink
whismanoid 53:3d5a3d241a5e 214 * // The default baud rate for the DapLink UART is 9600
whismanoid 53:3d5a3d241a5e 215 * //Serial DAPLINKserial(P2_1, P2_0); // tx, rx
whismanoid 53:3d5a3d241a5e 216 * // #define HAS_DAPLINK_SERIAL 1
whismanoid 53:3d5a3d241a5e 217 * // Virtual serial port over USB
whismanoid 53:3d5a3d241a5e 218 * // The baud rate does not affect the virtual USBSerial UART.
whismanoid 53:3d5a3d241a5e 219 * USBSerial serial;
whismanoid 53:3d5a3d241a5e 220 * //--------------------------------------------------
whismanoid 53:3d5a3d241a5e 221 * #elif defined(TARGET_MAX32625MBED)
whismanoid 53:3d5a3d241a5e 222 * #include "USBSerial.h"
whismanoid 53:3d5a3d241a5e 223 * // Hardware serial port over DAPLink
whismanoid 53:3d5a3d241a5e 224 * // The default baud rate for the DapLink UART is 9600
whismanoid 53:3d5a3d241a5e 225 * //Serial DAPLINKserial(P2_1, P2_0); // tx, rx
whismanoid 53:3d5a3d241a5e 226 * // #define HAS_DAPLINK_SERIAL 1
whismanoid 53:3d5a3d241a5e 227 * // Virtual serial port over USB
whismanoid 53:3d5a3d241a5e 228 * // The baud rate does not affect the virtual USBSerial UART.
whismanoid 53:3d5a3d241a5e 229 * USBSerial serial;
whismanoid 53:3d5a3d241a5e 230 * //--------------------------------------------------
whismanoid 53:3d5a3d241a5e 231 * #elif defined(TARGET_MAX32600)
whismanoid 53:3d5a3d241a5e 232 * #include "USBSerial.h"
whismanoid 53:3d5a3d241a5e 233 * // Hardware serial port over DAPLink
whismanoid 53:3d5a3d241a5e 234 * // The default baud rate for the DapLink UART is 9600
whismanoid 53:3d5a3d241a5e 235 * Serial DAPLINKserial(P1_1, P1_0); // tx, rx
whismanoid 53:3d5a3d241a5e 236 * #define HAS_DAPLINK_SERIAL 1
whismanoid 53:3d5a3d241a5e 237 * // Virtual serial port over USB
whismanoid 53:3d5a3d241a5e 238 * // The baud rate does not affect the virtual USBSerial UART.
whismanoid 53:3d5a3d241a5e 239 * USBSerial serial;
whismanoid 53:3d5a3d241a5e 240 * //--------------------------------------------------
whismanoid 53:3d5a3d241a5e 241 * #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 53:3d5a3d241a5e 242 * Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 53:3d5a3d241a5e 243 * //--------------------------------------------------
whismanoid 53:3d5a3d241a5e 244 * #else
whismanoid 53:3d5a3d241a5e 245 * #if defined(SERIAL_TX)
whismanoid 53:3d5a3d241a5e 246 * #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..."
whismanoid 53:3d5a3d241a5e 247 * Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 53:3d5a3d241a5e 248 * #elif defined(USBTX)
whismanoid 53:3d5a3d241a5e 249 * #warning "target not previously tested; guess serial pins are USBTX, USBRX..."
whismanoid 53:3d5a3d241a5e 250 * Serial serial(USBTX, USBRX); // tx, rx
whismanoid 53:3d5a3d241a5e 251 * #elif defined(UART_TX)
whismanoid 53:3d5a3d241a5e 252 * #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..."
whismanoid 53:3d5a3d241a5e 253 * Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 53:3d5a3d241a5e 254 * #else
whismanoid 53:3d5a3d241a5e 255 * #warning "target not previously tested; need to define serial pins..."
whismanoid 53:3d5a3d241a5e 256 * #endif
whismanoid 53:3d5a3d241a5e 257 * #endif
whismanoid 53:3d5a3d241a5e 258 * //
whismanoid 53:3d5a3d241a5e 259 * #include "CmdLine.h"
whismanoid 53:3d5a3d241a5e 260 * CmdLine cmdLine(serial, "serial");
whismanoid 53:3d5a3d241a5e 261 *
whismanoid 53:3d5a3d241a5e 262 * // example code main function
whismanoid 53:3d5a3d241a5e 263 * int main()
whismanoid 53:3d5a3d241a5e 264 * {
whismanoid 53:3d5a3d241a5e 265 * // CODE GENERATOR: example code: member function Init
whismanoid 53:3d5a3d241a5e 266 * g_MAX11043_device.Init();
whismanoid 53:3d5a3d241a5e 267 *
whismanoid 53:3d5a3d241a5e 268 * while (1)
whismanoid 53:3d5a3d241a5e 269 * {
whismanoid 53:3d5a3d241a5e 270 * // CODE GENERATOR: example code: has no member function REF
whismanoid 53:3d5a3d241a5e 271 * // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line
whismanoid 53:3d5a3d241a5e 272 * // CODE GENERATOR: ResolutionBits = 24
whismanoid 53:3d5a3d241a5e 273 * // CODE GENERATOR: FScode = None
whismanoid 53:3d5a3d241a5e 274 * // CODE GENERATOR: NumChannels = 4
whismanoid 53:3d5a3d241a5e 275 * while(1) { // this code repeats forever
whismanoid 53:3d5a3d241a5e 276 * // this code repeats forever
whismanoid 53:3d5a3d241a5e 277 * // CODE GENERATOR: example code: has no member function ScanStandardExternalClock
whismanoid 53:3d5a3d241a5e 278 * // CODE GENERATOR: example code: has no member function ReadAINcode
whismanoid 53:3d5a3d241a5e 279 * // wait(3.0);
whismanoid 53:3d5a3d241a5e 280 * // CODE GENERATOR: print conversion result
whismanoid 53:3d5a3d241a5e 281 * // Use Arduino Serial Plotter to view output: Tools | Serial Plotter
whismanoid 53:3d5a3d241a5e 282 * cmdLine.serial().printf("%d", g_MAX11043_device.AINcode[0]);
whismanoid 53:3d5a3d241a5e 283 * for (int index = 1; index <= channelId_0_3; index++) {
whismanoid 53:3d5a3d241a5e 284 * cmdLine.serial().printf(",%d", g_MAX11043_device.AINcode[index]);
whismanoid 53:3d5a3d241a5e 285 * }
whismanoid 53:3d5a3d241a5e 286 * cmdLine.serial().printf("\r\n");
whismanoid 53:3d5a3d241a5e 287 *
whismanoid 53:3d5a3d241a5e 288 * } // this code repeats forever
whismanoid 53:3d5a3d241a5e 289 * }
whismanoid 53:3d5a3d241a5e 290 * }
whismanoid 53:3d5a3d241a5e 291 * @endcode
whismanoid 53:3d5a3d241a5e 292 * //---------- CODE GENERATOR: end helloCppCodeList
whismanoid 53:3d5a3d241a5e 293 */
whismanoid 53:3d5a3d241a5e 294 class MAX11043 {
whismanoid 53:3d5a3d241a5e 295 public:
whismanoid 53:3d5a3d241a5e 296 // CODE GENERATOR: TypedefEnum EnumItem declarations
whismanoid 57:1c9da8e90737 297 // CODE GENERATOR: TypedefEnum MAX11043_CMDOP_enum_t
whismanoid 57:1c9da8e90737 298 //----------------------------------------
whismanoid 57:1c9da8e90737 299 /// Command Operation Format (see function DecodeCommand)
whismanoid 57:1c9da8e90737 300 ///
whismanoid 57:1c9da8e90737 301 /// Naming convention is CMDOP_bitstream_OPERATION_NAME
whismanoid 57:1c9da8e90737 302 /// - 0aaa_aax0 = 5-bit register address field
whismanoid 57:1c9da8e90737 303 /// - 0xxx_xxr0 = read/write bit (1=read, 0=write)
whismanoid 57:1c9da8e90737 304 /// - xxxx = don't care
whismanoid 57:1c9da8e90737 305 typedef enum MAX11043_CMDOP_enum_t {
whismanoid 57:1c9da8e90737 306 CMDOP_0aaa_aa00_WriteRegister = 0x00, //!< 8'b00000000
whismanoid 57:1c9da8e90737 307 CMDOP_0aaa_aa10_ReadRegister = 0x02, //!< 8'b00000010
whismanoid 57:1c9da8e90737 308 CMDOP_1111_1111_NoOperationMOSIidleHigh = 0xff, //!< 8'b11111111
whismanoid 57:1c9da8e90737 309 } MAX11043_CMDOP_enum_t;
whismanoid 57:1c9da8e90737 310
whismanoid 53:3d5a3d241a5e 311 // CODE GENERATOR: TypedefEnum MAX11043_CMD_enum_t
whismanoid 53:3d5a3d241a5e 312 //----------------------------------------
whismanoid 53:3d5a3d241a5e 313 /// Register Addresses
whismanoid 53:3d5a3d241a5e 314 ///
whismanoid 53:3d5a3d241a5e 315 /// Naming convention is CMD_bitstream_WrAddr_FunctionName
whismanoid 53:3d5a3d241a5e 316 /// - first byte format is 0aaa_aar0
whismanoid 53:3d5a3d241a5e 317 /// - 0 = bitstream required 0 bit
whismanoid 53:3d5a3d241a5e 318 /// - aaa_aa = bitstream 5-bit register address field
whismanoid 53:3d5a3d241a5e 319 /// - r = bitstream read/write bit (1=read, 0=write)
whismanoid 53:3d5a3d241a5e 320 /// - WrAddr = Write operation to address Addr
whismanoid 53:3d5a3d241a5e 321 /// - RdAddr = Read operation from address Addr
whismanoid 53:3d5a3d241a5e 322 /// - d8 = 8-bit register data field
whismanoid 53:3d5a3d241a5e 323 /// - d16 = 16-bit register data field
whismanoid 59:47538bcf6cda 324 /// - d16o8 = 16-bit or 24-bit register data field
whismanoid 53:3d5a3d241a5e 325 /// - d24 = 24-bit register data field
whismanoid 53:3d5a3d241a5e 326 /// - d32 = 32-bit register data field
whismanoid 53:3d5a3d241a5e 327 /// - x = don't care
whismanoid 53:3d5a3d241a5e 328 typedef enum MAX11043_CMD_enum_t {
whismanoid 59:47538bcf6cda 329 CMD_0000_0010_d16o8_Rd00_ADCa = 0x02, //!< 8'b00000010
whismanoid 59:47538bcf6cda 330 CMD_0000_0110_d16o8_Rd01_ADCb = 0x06, //!< 8'b00000110
whismanoid 59:47538bcf6cda 331 CMD_0000_1010_d16o8_Rd02_ADCc = 0x0a, //!< 8'b00001010
whismanoid 59:47538bcf6cda 332 CMD_0000_1110_d16o8_Rd03_ADCd = 0x0e, //!< 8'b00001110
whismanoid 53:3d5a3d241a5e 333 CMD_0001_0010_d24_d24_Rd04_ADCab = 0x12, //!< 8'b00010010
whismanoid 53:3d5a3d241a5e 334 CMD_0001_0110_d24_d24_Rd05_ADCcd = 0x16, //!< 8'b00010110
whismanoid 53:3d5a3d241a5e 335 CMD_0001_1010_d24_d24_d24_d24_Rd06_ADCabcd = 0x1a, //!< 8'b00011010
whismanoid 53:3d5a3d241a5e 336 CMD_0001_1110_d8_Rd07_Status = 0x1e, //!< 8'b00011110
whismanoid 53:3d5a3d241a5e 337 CMD_0010_0000_d16_Wr08_Configuration = 0x20, //!< 8'b00100000
whismanoid 53:3d5a3d241a5e 338 CMD_0010_0010_d16_Rd08_Configuration = 0x22, //!< 8'b00100010
whismanoid 53:3d5a3d241a5e 339 CMD_0010_0100_d16_Wr09_DAC = 0x24, //!< 8'b00100100
whismanoid 53:3d5a3d241a5e 340 CMD_0010_0110_d16_Rd09_DAC = 0x26, //!< 8'b00100110
whismanoid 53:3d5a3d241a5e 341 CMD_0010_1000_d16_Wr0A_DACStep = 0x28, //!< 8'b00101000
whismanoid 53:3d5a3d241a5e 342 CMD_0010_1010_d16_Rd0A_DACStep = 0x2a, //!< 8'b00101010
whismanoid 53:3d5a3d241a5e 343 CMD_0010_1100_d16_Wr0B_DACHDACL = 0x2c, //!< 8'b00101100
whismanoid 53:3d5a3d241a5e 344 CMD_0010_1110_d16_Rd0B_DACHDACL = 0x2e, //!< 8'b00101110
whismanoid 53:3d5a3d241a5e 345 CMD_0011_0000_d16_Wr0C_ConfigA = 0x30, //!< 8'b00110000
whismanoid 53:3d5a3d241a5e 346 CMD_0011_0010_d16_Rd0C_ConfigA = 0x32, //!< 8'b00110010
whismanoid 53:3d5a3d241a5e 347 CMD_0011_0100_d16_Wr0D_ConfigB = 0x34, //!< 8'b00110100
whismanoid 53:3d5a3d241a5e 348 CMD_0011_0110_d16_Rd0D_ConfigB = 0x36, //!< 8'b00110110
whismanoid 53:3d5a3d241a5e 349 CMD_0011_1000_d16_Wr0E_ConfigC = 0x38, //!< 8'b00111000
whismanoid 53:3d5a3d241a5e 350 CMD_0011_1010_d16_Rd0E_ConfigC = 0x3a, //!< 8'b00111010
whismanoid 53:3d5a3d241a5e 351 CMD_0011_1100_d16_Wr0F_ConfigD = 0x3c, //!< 8'b00111100
whismanoid 53:3d5a3d241a5e 352 CMD_0011_1110_d16_Rd0F_ConfigD = 0x3e, //!< 8'b00111110
whismanoid 53:3d5a3d241a5e 353 CMD_0100_0000_d16_Wr10_Reference = 0x40, //!< 8'b01000000
whismanoid 53:3d5a3d241a5e 354 CMD_0100_0010_d16_Rd10_Reference = 0x42, //!< 8'b01000010
whismanoid 53:3d5a3d241a5e 355 CMD_0100_0100_d16_Wr11_AGain = 0x44, //!< 8'b01000100
whismanoid 53:3d5a3d241a5e 356 CMD_0100_0110_d16_Rd11_AGain = 0x46, //!< 8'b01000110
whismanoid 53:3d5a3d241a5e 357 CMD_0100_1000_d16_Wr12_BGain = 0x48, //!< 8'b01001000
whismanoid 53:3d5a3d241a5e 358 CMD_0100_1010_d16_Rd12_BGain = 0x4a, //!< 8'b01001010
whismanoid 53:3d5a3d241a5e 359 CMD_0100_1100_d16_Wr13_CGain = 0x4c, //!< 8'b01001100
whismanoid 53:3d5a3d241a5e 360 CMD_0100_1110_d16_Rd13_CGain = 0x4e, //!< 8'b01001110
whismanoid 53:3d5a3d241a5e 361 CMD_0101_0000_d16_Wr14_DGain = 0x50, //!< 8'b01010000
whismanoid 53:3d5a3d241a5e 362 CMD_0101_0010_d16_Rd14_DGain = 0x52, //!< 8'b01010010
whismanoid 53:3d5a3d241a5e 363 CMD_0101_0100_d8_Wr15_FilterCAddress = 0x54, //!< 8'b01010100
whismanoid 53:3d5a3d241a5e 364 CMD_0101_0110_d8_Rd15_FilterCAddress = 0x56, //!< 8'b01010110
whismanoid 53:3d5a3d241a5e 365 CMD_0101_1000_d32_Wr16_FilterCDataOut = 0x58, //!< 8'b01011000
whismanoid 53:3d5a3d241a5e 366 CMD_0101_1010_d32_Rd16_FilterCDataOut = 0x5a, //!< 8'b01011010
whismanoid 53:3d5a3d241a5e 367 CMD_0101_1100_d32_Wr17_FilterCDataIn = 0x5c, //!< 8'b01011100
whismanoid 53:3d5a3d241a5e 368 CMD_0101_1110_d32_Rd17_FilterCDataIn = 0x5e, //!< 8'b01011110
whismanoid 53:3d5a3d241a5e 369 CMD_0110_0000_d8_Wr18_FlashMode = 0x60, //!< 8'b01100000
whismanoid 53:3d5a3d241a5e 370 CMD_0110_0010_d8_Rd18_FlashMode = 0x62, //!< 8'b01100010
whismanoid 53:3d5a3d241a5e 371 CMD_0110_0100_d16_Wr19_FlashAddr = 0x64, //!< 8'b01100100
whismanoid 53:3d5a3d241a5e 372 CMD_0110_0110_d16_Rd19_FlashAddr = 0x66, //!< 8'b01100110
whismanoid 53:3d5a3d241a5e 373 CMD_0110_1000_d16_Wr1A_FlashDataIn = 0x68, //!< 8'b01101000
whismanoid 53:3d5a3d241a5e 374 CMD_0110_1010_d16_Rd1A_FlashDataIn = 0x6a, //!< 8'b01101010
whismanoid 53:3d5a3d241a5e 375 CMD_0110_1110_d16_Rd1B_FlashDataOut = 0x6e, //!< 8'b01101110
whismanoid 53:3d5a3d241a5e 376 } MAX11043_CMD_enum_t;
whismanoid 53:3d5a3d241a5e 377
whismanoid 53:3d5a3d241a5e 378 // CODE GENERATOR: TypedefEnum MAX11043_STATUS_enum_t
whismanoid 53:3d5a3d241a5e 379 //----------------------------------------
whismanoid 53:3d5a3d241a5e 380 /// CMD_0001_1110_d8_Rd_Status
whismanoid 53:3d5a3d241a5e 381 /// regAddr=07h
whismanoid 53:3d5a3d241a5e 382 /// Status: x x FlashBusy BOOT OFLGA OFLGB OFLGC OFLGD
whismanoid 53:3d5a3d241a5e 383 typedef enum MAX11043_STATUS_enum_t {
whismanoid 53:3d5a3d241a5e 384 STATUS_xxxx_xxx1_OverflowFlagOFLGD = 0x01, //!< 8'b00000001
whismanoid 53:3d5a3d241a5e 385 STATUS_xxxx_xx1x_OverflowFlagOFLGC = 0x02, //!< 8'b00000010
whismanoid 53:3d5a3d241a5e 386 STATUS_xxxx_x1xx_OverflowFlagOFLGB = 0x04, //!< 8'b00000100
whismanoid 53:3d5a3d241a5e 387 STATUS_xxxx_1xxx_OverflowFlagOFLGA = 0x08, //!< 8'b00001000
whismanoid 53:3d5a3d241a5e 388 STATUS_xxx1_xxxx_PowerOnResetBOOT = 0x10, //!< 8'b00010000
whismanoid 53:3d5a3d241a5e 389 STATUS_xx1x_xxxx_FlashBusy = 0x20, //!< 8'b00100000
whismanoid 53:3d5a3d241a5e 390 STATUS_x1xx_xxxx_RESERVED = 0x40, //!< 8'b01000000
whismanoid 53:3d5a3d241a5e 391 STATUS_1xxx_xxxx_RESERVED = 0x80, //!< 8'b10000000
whismanoid 53:3d5a3d241a5e 392 } MAX11043_STATUS_enum_t;
whismanoid 53:3d5a3d241a5e 393
whismanoid 53:3d5a3d241a5e 394 // CODE GENERATOR: TypedefEnum MAX11043_CONFIG_enum_t
whismanoid 53:3d5a3d241a5e 395 //----------------------------------------
whismanoid 53:3d5a3d241a5e 396 /// CMD_0010_0000_d16_Wr_Configuration
whismanoid 53:3d5a3d241a5e 397 /// regAddr=08h
whismanoid 53:3d5a3d241a5e 398 /// Config: EXTCLK CLKDIV1 CLKDIV0 PD PDA PDB PDC PDD PDDAC PDOSC 24BIT SCHANA SCHANB SCHANC SCHAND DECSEL
whismanoid 53:3d5a3d241a5e 399 typedef enum MAX11043_CONFIG_enum_t {
whismanoid 53:3d5a3d241a5e 400 CONFIG_xxxx_xxxx_xxxx_xxx1_DECSEL12 = 0x0001, //!< 16'b0000000000000001
whismanoid 53:3d5a3d241a5e 401 CONFIG_xxxx_xxxx_xxxx_xx1x_SCHAND = 0x0002, //!< 16'b0000000000000010
whismanoid 53:3d5a3d241a5e 402 CONFIG_xxxx_xxxx_xxxx_x1xx_SCHANC = 0x0004, //!< 16'b0000000000000100
whismanoid 53:3d5a3d241a5e 403 CONFIG_xxxx_xxxx_xxxx_1xxx_SCHANB = 0x0008, //!< 16'b0000000000001000
whismanoid 53:3d5a3d241a5e 404 CONFIG_xxxx_xxxx_xxx1_xxxx_SCHANA = 0x0010, //!< 16'b0000000000010000
whismanoid 53:3d5a3d241a5e 405 CONFIG_xxxx_xxxx_xx1x_xxxx_24BIT = 0x0020, //!< 16'b0000000000100000
whismanoid 53:3d5a3d241a5e 406 CONFIG_xxxx_xxxx_x1xx_xxxx_PDOSC = 0x0040, //!< 16'b0000000001000000
whismanoid 53:3d5a3d241a5e 407 CONFIG_xxxx_xxxx_1xxx_xxxx_PDDAC = 0x0080, //!< 16'b0000000010000000
whismanoid 53:3d5a3d241a5e 408 CONFIG_xxxx_xxx1_xxxx_xxxx_PDD = 0x0100, //!< 16'b0000000100000000
whismanoid 53:3d5a3d241a5e 409 CONFIG_xxxx_xx1x_xxxx_xxxx_PDC = 0x0200, //!< 16'b0000001000000000
whismanoid 53:3d5a3d241a5e 410 CONFIG_xxxx_x1xx_xxxx_xxxx_PDB = 0x0400, //!< 16'b0000010000000000
whismanoid 53:3d5a3d241a5e 411 CONFIG_xxxx_1xxx_xxxx_xxxx_PDA = 0x0800, //!< 16'b0000100000000000
whismanoid 53:3d5a3d241a5e 412 CONFIG_xxx1_xxxx_xxxx_xxxx_PD = 0x1000, //!< 16'b0001000000000000
whismanoid 53:3d5a3d241a5e 413 CONFIG_xx1x_xxxx_xxxx_xxxx_CLKDIV0 = 0x2000, //!< 16'b0010000000000000
whismanoid 53:3d5a3d241a5e 414 CONFIG_x1xx_xxxx_xxxx_xxxx_CLKDIV1 = 0x4000, //!< 16'b0100000000000000
whismanoid 53:3d5a3d241a5e 415 CONFIG_1xxx_xxxx_xxxx_xxxx_EXTCLK = 0x8000, //!< 16'b1000000000000000
whismanoid 53:3d5a3d241a5e 416 } MAX11043_CONFIG_enum_t;
whismanoid 52:607010f0c54e 417
whismanoid 53:3d5a3d241a5e 418 // CODE GENERATOR: TypedefEnum MAX11043_CONFIGABCD_enum_t
whismanoid 53:3d5a3d241a5e 419 //----------------------------------------
whismanoid 53:3d5a3d241a5e 420 /// CMD_0011_0000_d16_Wr_CONFIGa
whismanoid 53:3d5a3d241a5e 421 /// CMD_0011_0100_d16_Wr_CONFIGb
whismanoid 53:3d5a3d241a5e 422 /// CMD_0011_1000_d16_Wr_CONFIGc
whismanoid 53:3d5a3d241a5e 423 /// CMD_0011_1100_d16_Wr_CONFIGd
whismanoid 53:3d5a3d241a5e 424 /// regAddr=0Ch
whismanoid 53:3d5a3d241a5e 425 /// regAddr=0Dh
whismanoid 53:3d5a3d241a5e 426 /// regAddr=0Eh
whismanoid 53:3d5a3d241a5e 427 /// regAddr=0Fh
whismanoid 53:3d5a3d241a5e 428 /// ConfigABCD: x x x BDAC[3:0] DIFF EQ MODG[1:0] PDPGA FILT PGAG ENBIASP ENBIASN
whismanoid 53:3d5a3d241a5e 429 typedef enum MAX11043_CONFIGABCD_enum_t {
whismanoid 53:3d5a3d241a5e 430 CONFIGABCD_xxxx_xxxx_xxxx_xxx1_ENBIASN = 0x0001, //!< 16'b0000000000000001
whismanoid 53:3d5a3d241a5e 431 CONFIGABCD_xxxx_xxxx_xxxx_xx1x_ENBIASP = 0x0002, //!< 16'b0000000000000010
whismanoid 53:3d5a3d241a5e 432 CONFIGABCD_xxxx_xxxx_xxxx_x1xx_PGAG16 = 0x0004, //!< 16'b0000000000000100
whismanoid 53:3d5a3d241a5e 433 CONFIGABCD_xxxx_xxxx_xxxx_1xxx_FILTLP = 0x0008, //!< 16'b0000000000001000
whismanoid 53:3d5a3d241a5e 434 CONFIGABCD_xxxx_xxxx_xxx1_xxxx_PDPGA = 0x0010, //!< 16'b0000000000010000
whismanoid 53:3d5a3d241a5e 435 CONFIGABCD_xxxx_xxxx_xx1x_xxxx_MODG0 = 0x0020, //!< 16'b0000000000100000
whismanoid 53:3d5a3d241a5e 436 CONFIGABCD_xxxx_xxxx_x1xx_xxxx_MODG1 = 0x0040, //!< 16'b0000000001000000
whismanoid 53:3d5a3d241a5e 437 CONFIGABCD_xxxx_xxxx_1xxx_xxxx_EQ = 0x0080, //!< 16'b0000000010000000
whismanoid 53:3d5a3d241a5e 438 CONFIGABCD_xxxx_xxx1_xxxx_xxxx_DIFF = 0x0100, //!< 16'b0000000100000000
whismanoid 53:3d5a3d241a5e 439 CONFIGABCD_xxxx_xx1x_xxxx_xxxx_BDAC0 = 0x0200, //!< 16'b0000001000000000
whismanoid 53:3d5a3d241a5e 440 CONFIGABCD_xxxx_x1xx_xxxx_xxxx_BDAC1 = 0x0400, //!< 16'b0000010000000000
whismanoid 53:3d5a3d241a5e 441 CONFIGABCD_xxxx_1xxx_xxxx_xxxx_BDAC2 = 0x0800, //!< 16'b0000100000000000
whismanoid 53:3d5a3d241a5e 442 CONFIGABCD_xxx1_xxxx_xxxx_xxxx_BDAC3 = 0x1000, //!< 16'b0001000000000000
whismanoid 53:3d5a3d241a5e 443 CONFIGABCD_xx1x_xxxx_xxxx_xxxx_RESERVED = 0x2000, //!< 16'b0010000000000000
whismanoid 53:3d5a3d241a5e 444 CONFIGABCD_x1xx_xxxx_xxxx_xxxx_RESERVED = 0x4000, //!< 16'b0100000000000000
whismanoid 53:3d5a3d241a5e 445 CONFIGABCD_1xxx_xxxx_xxxx_xxxx_RESERVED = 0x8000, //!< 16'b1000000000000000
whismanoid 53:3d5a3d241a5e 446 } MAX11043_CONFIGABCD_enum_t;
whismanoid 53:3d5a3d241a5e 447
whismanoid 53:3d5a3d241a5e 448 // CODE GENERATOR: TypedefEnum MAX11043_BDAC_enum_t
whismanoid 53:3d5a3d241a5e 449 //----------------------------------------
whismanoid 53:3d5a3d241a5e 450 /// CMD_0011_0000_d16_Wr_CONFIGa
whismanoid 53:3d5a3d241a5e 451 /// CMD_0011_0100_d16_Wr_CONFIGb
whismanoid 53:3d5a3d241a5e 452 /// CMD_0011_1000_d16_Wr_CONFIGc
whismanoid 53:3d5a3d241a5e 453 /// CMD_0011_1100_d16_Wr_CONFIGd
whismanoid 53:3d5a3d241a5e 454 /// CONFIGABCD_xxx1_xxxx_xxxx_xxxx_BDAC3
whismanoid 53:3d5a3d241a5e 455 /// CONFIGABCD_xxxx_1xxx_xxxx_xxxx_BDAC2
whismanoid 53:3d5a3d241a5e 456 /// CONFIGABCD_xxxx_x1xx_xxxx_xxxx_BDAC1
whismanoid 53:3d5a3d241a5e 457 /// CONFIGABCD_xxxx_xx1x_xxxx_xxxx_BDAC0
whismanoid 53:3d5a3d241a5e 458 /// Sets the input bias voltage for AC-coupled signals when ENBIAS_ is set to 1.
whismanoid 53:3d5a3d241a5e 459 /// regAddr=0Ch
whismanoid 53:3d5a3d241a5e 460 /// regAddr=0Dh
whismanoid 53:3d5a3d241a5e 461 /// regAddr=0Eh
whismanoid 53:3d5a3d241a5e 462 /// regAddr=0Fh
whismanoid 53:3d5a3d241a5e 463 /// ConfigABCD: x x x BDAC[3:0] DIFF EQ MODG[1:0] PDPGA FILT PGAG ENBIASP ENBIASN
whismanoid 53:3d5a3d241a5e 464 typedef enum MAX11043_BDAC_enum_t {
whismanoid 53:3d5a3d241a5e 465 BDAC_0000_033pctAVDD = 0x00, //!< 8'b00000000
whismanoid 53:3d5a3d241a5e 466 BDAC_0001_035pctAVDD = 0x01, //!< 8'b00000001
whismanoid 53:3d5a3d241a5e 467 BDAC_0010_038pctAVDD = 0x02, //!< 8'b00000010
whismanoid 53:3d5a3d241a5e 468 BDAC_0011_040pctAVDD = 0x03, //!< 8'b00000011
whismanoid 53:3d5a3d241a5e 469 BDAC_0100_042pctAVDD = 0x04, //!< 8'b00000100
whismanoid 53:3d5a3d241a5e 470 BDAC_0101_044pctAVDD = 0x05, //!< 8'b00000101
whismanoid 53:3d5a3d241a5e 471 BDAC_0110_046pctAVDD = 0x06, //!< 8'b00000110
whismanoid 53:3d5a3d241a5e 472 BDAC_0111_048pctAVDD = 0x07, //!< 8'b00000111
whismanoid 53:3d5a3d241a5e 473 BDAC_1000_050pctAVDD = 0x08, //!< 8'b00001000
whismanoid 53:3d5a3d241a5e 474 BDAC_1001_052pctAVDD = 0x09, //!< 8'b00001001
whismanoid 53:3d5a3d241a5e 475 BDAC_1010_054pctAVDD = 0x0a, //!< 8'b00001010
whismanoid 53:3d5a3d241a5e 476 BDAC_1011_056pctAVDD = 0x0b, //!< 8'b00001011
whismanoid 53:3d5a3d241a5e 477 BDAC_1100_058pctAVDD = 0x0c, //!< 8'b00001100
whismanoid 53:3d5a3d241a5e 478 BDAC_1101_060pctAVDD = 0x0d, //!< 8'b00001101
whismanoid 53:3d5a3d241a5e 479 BDAC_1110_062pctAVDD = 0x0e, //!< 8'b00001110
whismanoid 53:3d5a3d241a5e 480 BDAC_1111_065pctAVDD = 0x0f, //!< 8'b00001111
whismanoid 53:3d5a3d241a5e 481 } MAX11043_BDAC_enum_t;
whismanoid 53:3d5a3d241a5e 482
whismanoid 53:3d5a3d241a5e 483 // CODE GENERATOR: TypedefEnum MAX11043_REFERENCE_enum_t
whismanoid 53:3d5a3d241a5e 484 //----------------------------------------
whismanoid 53:3d5a3d241a5e 485 /// CMD_0100_0000_d16_Wr_Reference
whismanoid 53:3d5a3d241a5e 486 /// regAddr=10h
whismanoid 53:3d5a3d241a5e 487 /// ReferenceDelay: 0 0 0 PURGE[4:0] EXTREF EXBUFA EXBUFB EXBUFC EXBUFD EXBUFDAC EXBUFDACH EXBUFDACL
whismanoid 53:3d5a3d241a5e 488 typedef enum MAX11043_REFERENCE_enum_t {
whismanoid 53:3d5a3d241a5e 489 REFERENCE_xxxx_xxxx_xxxx_xxx1_EXBUFDACL = 0x0001, //!< 16'b0000000000000001
whismanoid 53:3d5a3d241a5e 490 REFERENCE_xxxx_xxxx_xxxx_xx1x_EXBUFDACH = 0x0002, //!< 16'b0000000000000010
whismanoid 53:3d5a3d241a5e 491 REFERENCE_xxxx_xxxx_xxxx_x1xx_EXBUFDAC = 0x0004, //!< 16'b0000000000000100
whismanoid 53:3d5a3d241a5e 492 REFERENCE_xxxx_xxxx_xxxx_1xxx_EXBUFD = 0x0008, //!< 16'b0000000000001000
whismanoid 53:3d5a3d241a5e 493 REFERENCE_xxxx_xxxx_xxx1_xxxx_EXBUFC = 0x0010, //!< 16'b0000000000010000
whismanoid 53:3d5a3d241a5e 494 REFERENCE_xxxx_xxxx_xx1x_xxxx_EXBUFB = 0x0020, //!< 16'b0000000000100000
whismanoid 53:3d5a3d241a5e 495 REFERENCE_xxxx_xxxx_x1xx_xxxx_EXBUFA = 0x0040, //!< 16'b0000000001000000
whismanoid 53:3d5a3d241a5e 496 REFERENCE_xxxx_xxxx_1xxx_xxxx_EXTREF = 0x0080, //!< 16'b0000000010000000
whismanoid 53:3d5a3d241a5e 497 REFERENCE_xxxx_xxx1_xxxx_xxxx_PURGE0 = 0x0100, //!< 16'b0000000100000000
whismanoid 53:3d5a3d241a5e 498 REFERENCE_xxxx_xx1x_xxxx_xxxx_PURGE1 = 0x0200, //!< 16'b0000001000000000
whismanoid 53:3d5a3d241a5e 499 REFERENCE_xxxx_x1xx_xxxx_xxxx_PURGE2 = 0x0400, //!< 16'b0000010000000000
whismanoid 53:3d5a3d241a5e 500 REFERENCE_xxxx_1xxx_xxxx_xxxx_PURGE3 = 0x0800, //!< 16'b0000100000000000
whismanoid 53:3d5a3d241a5e 501 REFERENCE_xxx1_xxxx_xxxx_xxxx_PURGE4 = 0x1000, //!< 16'b0001000000000000
whismanoid 53:3d5a3d241a5e 502 REFERENCE_xx1x_xxxx_xxxx_xxxx_RESERVED = 0x2000, //!< 16'b0010000000000000
whismanoid 53:3d5a3d241a5e 503 REFERENCE_x1xx_xxxx_xxxx_xxxx_RESERVED = 0x4000, //!< 16'b0100000000000000
whismanoid 53:3d5a3d241a5e 504 REFERENCE_1xxx_xxxx_xxxx_xxxx_RESERVED = 0x8000, //!< 16'b1000000000000000
whismanoid 53:3d5a3d241a5e 505 } MAX11043_REFERENCE_enum_t;
whismanoid 53:3d5a3d241a5e 506
whismanoid 53:3d5a3d241a5e 507 // TODO1: CODE GENERATOR: ic_variant -- IC's supported with this driver
whismanoid 53:3d5a3d241a5e 508 /**
whismanoid 53:3d5a3d241a5e 509 * @brief IC's supported with this driver
whismanoid 53:3d5a3d241a5e 510 * @details MAX11043
whismanoid 53:3d5a3d241a5e 511 */
whismanoid 53:3d5a3d241a5e 512 typedef enum
whismanoid 53:3d5a3d241a5e 513 {
whismanoid 53:3d5a3d241a5e 514 MAX11043_IC = 0,
whismanoid 53:3d5a3d241a5e 515 //MAX11043_IC = 1
whismanoid 53:3d5a3d241a5e 516 } MAX11043_ic_t;
whismanoid 53:3d5a3d241a5e 517
whismanoid 53:3d5a3d241a5e 518 // TODO1: CODE GENERATOR: class constructor declaration
whismanoid 53:3d5a3d241a5e 519 /**********************************************************//**
whismanoid 53:3d5a3d241a5e 520 * @brief Constructor for MAX11043 Class.
whismanoid 53:3d5a3d241a5e 521 *
whismanoid 53:3d5a3d241a5e 522 * @details Requires an existing SPI object as well as a DigitalOut object.
whismanoid 53:3d5a3d241a5e 523 * The DigitalOut object is used for a chip enable signal
whismanoid 53:3d5a3d241a5e 524 *
whismanoid 53:3d5a3d241a5e 525 * On Entry:
whismanoid 53:3d5a3d241a5e 526 * @param[in] spi - pointer to existing SPI object
whismanoid 53:3d5a3d241a5e 527 * @param[in] cs_pin - pointer to a DigitalOut pin object
whismanoid 53:3d5a3d241a5e 528 * CODE GENERATOR: class constructor docstrings gpio InputPin pins
whismanoid 53:3d5a3d241a5e 529 * @param[in] CONVRUN_pin - pointer to a DigitalOut pin object
whismanoid 53:3d5a3d241a5e 530 * @param[in] SHDN_pin - pointer to a DigitalOut pin object
whismanoid 53:3d5a3d241a5e 531 * @param[in] DACSTEP_pin - pointer to a DigitalOut pin object
whismanoid 53:3d5a3d241a5e 532 * @param[in] UP_slash_DWNb_pin - pointer to a DigitalOut pin object
whismanoid 53:3d5a3d241a5e 533 * CODE GENERATOR: class constructor docstrings gpio OutputPin pins
whismanoid 53:3d5a3d241a5e 534 * @param[in] EOC_pin - pointer to a DigitalIn pin object
whismanoid 53:3d5a3d241a5e 535 * @param[in] ic_variant - which type of MAX11043 is used
whismanoid 53:3d5a3d241a5e 536 *
whismanoid 53:3d5a3d241a5e 537 * On Exit:
whismanoid 53:3d5a3d241a5e 538 *
whismanoid 53:3d5a3d241a5e 539 * @return None
whismanoid 53:3d5a3d241a5e 540 **************************************************************/
whismanoid 53:3d5a3d241a5e 541 MAX11043(SPI &spi, DigitalOut &cs_pin, // SPI interface
whismanoid 53:3d5a3d241a5e 542 // CODE GENERATOR: class constructor declaration gpio InputPin pins
whismanoid 53:3d5a3d241a5e 543 DigitalOut &CONVRUN_pin, // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 544 DigitalOut &SHDN_pin, // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 545 DigitalOut &DACSTEP_pin, // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 546 DigitalOut &UP_slash_DWNb_pin, // Digital Configuration Input to MAX11043 device
whismanoid 53:3d5a3d241a5e 547 // CODE GENERATOR: class constructor declaration gpio OutputPin pins
whismanoid 53:3d5a3d241a5e 548 DigitalIn &EOC_pin, // Digital Event Output from MAX11043 device
whismanoid 53:3d5a3d241a5e 549 MAX11043_ic_t ic_variant);
whismanoid 53:3d5a3d241a5e 550
whismanoid 53:3d5a3d241a5e 551 // CODE GENERATOR: class destructor declaration
whismanoid 53:3d5a3d241a5e 552 /************************************************************
whismanoid 53:3d5a3d241a5e 553 * @brief Default destructor for MAX11043 Class.
whismanoid 53:3d5a3d241a5e 554 *
whismanoid 53:3d5a3d241a5e 555 * @details Destroys SPI object if owner
whismanoid 53:3d5a3d241a5e 556 *
whismanoid 53:3d5a3d241a5e 557 * On Entry:
whismanoid 53:3d5a3d241a5e 558 *
whismanoid 53:3d5a3d241a5e 559 * On Exit:
whismanoid 53:3d5a3d241a5e 560 *
whismanoid 53:3d5a3d241a5e 561 * @return None
whismanoid 53:3d5a3d241a5e 562 **************************************************************/
whismanoid 53:3d5a3d241a5e 563 ~MAX11043();
whismanoid 53:3d5a3d241a5e 564
whismanoid 53:3d5a3d241a5e 565 // CODE GENERATOR: Declare SPI diagnostic function pointer void onSPIprint()
whismanoid 53:3d5a3d241a5e 566 /// Function pointer void f(size_t byteCount, uint8_t mosiData[], uint8_t misoData[])
whismanoid 53:3d5a3d241a5e 567 Callback<void(size_t, uint8_t*, uint8_t*)> onSPIprint; //!< optional @ref onSPIprint SPI diagnostic function
whismanoid 53:3d5a3d241a5e 568
whismanoid 53:3d5a3d241a5e 569 // CODE GENERATOR: spi_frequency setter declaration
whismanoid 53:3d5a3d241a5e 570 /// set SPI SCLK frequency
whismanoid 53:3d5a3d241a5e 571 void spi_frequency(int spi_sclk_Hz);
whismanoid 53:3d5a3d241a5e 572
whismanoid 53:3d5a3d241a5e 573 // CODE GENERATOR: spi_frequency getter declaration and definition
whismanoid 53:3d5a3d241a5e 574 /// get SPI SCLK frequency
whismanoid 53:3d5a3d241a5e 575 int get_spi_frequency() const { return m_SPI_SCLK_Hz; }
whismanoid 53:3d5a3d241a5e 576
whismanoid 53:3d5a3d241a5e 577 // CODE GENERATOR: spi_dataMode getter declaration and definition
whismanoid 53:3d5a3d241a5e 578 /// get SPI mode
whismanoid 53:3d5a3d241a5e 579 int get_spi_dataMode() const { return m_SPI_dataMode; }
whismanoid 53:3d5a3d241a5e 580
whismanoid 53:3d5a3d241a5e 581 //----------------------------------------
whismanoid 53:3d5a3d241a5e 582 // CODE GENERATOR: omit typedef enum MAX11043_device_t, class members instead of global device object
whismanoid 53:3d5a3d241a5e 583 public:
whismanoid 53:3d5a3d241a5e 584
whismanoid 59:47538bcf6cda 585 /// reference voltage, in Volts
whismanoid 59:47538bcf6cda 586 double VRef;
whismanoid 53:3d5a3d241a5e 587
whismanoid 59:47538bcf6cda 588 /// shadow of register config CMD_0010_0010_d16_Rd08_Configuration
whismanoid 59:47538bcf6cda 589 uint16_t config;
whismanoid 53:3d5a3d241a5e 590
whismanoid 59:47538bcf6cda 591 /// shadow of register status CMD_0001_1110_d8_Rd07_Status
whismanoid 53:3d5a3d241a5e 592 uint32_t status;
whismanoid 53:3d5a3d241a5e 593
whismanoid 59:47538bcf6cda 594 /// shadow of register ADCa CMD_0000_0010_d16o8_Rd00_ADCa
whismanoid 59:47538bcf6cda 595 uint32_t adca;
whismanoid 59:47538bcf6cda 596
whismanoid 59:47538bcf6cda 597 /// shadow of register ADCb CMD_0000_0110_d16o8_Rd01_ADCb
whismanoid 59:47538bcf6cda 598 uint32_t adcb;
whismanoid 53:3d5a3d241a5e 599
whismanoid 59:47538bcf6cda 600 /// shadow of register ADCc CMD_0000_1010_d16o8_Rd02_ADCc
whismanoid 59:47538bcf6cda 601 uint32_t adcc;
whismanoid 59:47538bcf6cda 602
whismanoid 59:47538bcf6cda 603 /// shadow of register ADCd CMD_0000_1110_d16o8_Rd03_ADCd
whismanoid 59:47538bcf6cda 604 uint32_t adcd;
whismanoid 53:3d5a3d241a5e 605
whismanoid 53:3d5a3d241a5e 606 // CODE GENERATOR: omit global g_MAX11043_device
whismanoid 53:3d5a3d241a5e 607
whismanoid 53:3d5a3d241a5e 608 // CODE GENERATOR: extern function declarations
whismanoid 53:3d5a3d241a5e 609 // CODE GENERATOR: extern function declaration SPIoutputCS
whismanoid 53:3d5a3d241a5e 610 //----------------------------------------
whismanoid 53:3d5a3d241a5e 611 // Assert SPI Chip Select
whismanoid 53:3d5a3d241a5e 612 // SPI chip-select for MAX11043
whismanoid 53:3d5a3d241a5e 613 //
whismanoid 53:3d5a3d241a5e 614 void SPIoutputCS(int isLogicHigh);
whismanoid 53:3d5a3d241a5e 615
whismanoid 53:3d5a3d241a5e 616 // CODE GENERATOR: extern function declaration SPIwrite16bits
whismanoid 53:3d5a3d241a5e 617 //----------------------------------------
whismanoid 53:3d5a3d241a5e 618 // SPI write 16 bits
whismanoid 53:3d5a3d241a5e 619 // SPI interface to MAX11043 shift 16 bits mosiData into MAX11043 DIN
whismanoid 53:3d5a3d241a5e 620 //
whismanoid 53:3d5a3d241a5e 621 void SPIwrite16bits(int16_t mosiData16);
whismanoid 53:3d5a3d241a5e 622
whismanoid 53:3d5a3d241a5e 623 // CODE GENERATOR: extern function declaration SPIreadWrite16bits
whismanoid 53:3d5a3d241a5e 624 //----------------------------------------
whismanoid 53:3d5a3d241a5e 625 // SPI read and write 16 bits
whismanoid 53:3d5a3d241a5e 626 // SPI interface to MAX11043 shift 16 bits mosiData16 into MAX11043 DIN
whismanoid 53:3d5a3d241a5e 627 // while simultaneously capturing 16 bits miso data from MAX11043 DOUT
whismanoid 53:3d5a3d241a5e 628 //
whismanoid 53:3d5a3d241a5e 629 int16_t SPIreadWrite16bits(int16_t mosiData16);
whismanoid 53:3d5a3d241a5e 630
whismanoid 53:3d5a3d241a5e 631 // CODE GENERATOR: extern function declaration SPIreadWrite32bits
whismanoid 53:3d5a3d241a5e 632 //----------------------------------------
whismanoid 53:3d5a3d241a5e 633 // SPI read and write 32 bits
whismanoid 53:3d5a3d241a5e 634 // SPI interface to MAX11043 shift 32 bits mosiData into MAX11043 DIN
whismanoid 53:3d5a3d241a5e 635 // while simultaneously capturing 32 bits miso data from MAX11043 DOUT
whismanoid 53:3d5a3d241a5e 636 //
whismanoid 53:3d5a3d241a5e 637 int32_t SPIreadWrite32bits(int32_t mosiData32);
whismanoid 53:3d5a3d241a5e 638
whismanoid 53:3d5a3d241a5e 639 // CODE GENERATOR: extern function declaration SHDNoutputValue
whismanoid 53:3d5a3d241a5e 640 //----------------------------------------
whismanoid 58:2fea32db466b 641 // Assert MAX11043 SHDN pin : High = Shut Down, Low = Normal Operation.
whismanoid 53:3d5a3d241a5e 642 //
whismanoid 53:3d5a3d241a5e 643 void SHDNoutputValue(int isLogicHigh);
whismanoid 53:3d5a3d241a5e 644
whismanoid 53:3d5a3d241a5e 645 // CODE GENERATOR: extern function declaration CONVRUNoutputValue
whismanoid 53:3d5a3d241a5e 646 //----------------------------------------
whismanoid 58:2fea32db466b 647 // Assert MAX11043 CONVRUN pin : High = start continuous conversions on all 4 channels, Low = Idle.
whismanoid 53:3d5a3d241a5e 648 //
whismanoid 53:3d5a3d241a5e 649 void CONVRUNoutputValue(int isLogicHigh);
whismanoid 53:3d5a3d241a5e 650
whismanoid 53:3d5a3d241a5e 651 // CODE GENERATOR: extern function declaration DACSTEPoutputValue
whismanoid 53:3d5a3d241a5e 652 //----------------------------------------
whismanoid 58:2fea32db466b 653 // Assert MAX11043 DACSTEP pin : High = Active, Low = Idle.
whismanoid 53:3d5a3d241a5e 654 //
whismanoid 53:3d5a3d241a5e 655 void DACSTEPoutputValue(int isLogicHigh);
whismanoid 53:3d5a3d241a5e 656
whismanoid 53:3d5a3d241a5e 657 // CODE GENERATOR: extern function declaration UP_slash_DWNboutputValue
whismanoid 53:3d5a3d241a5e 658 //----------------------------------------
whismanoid 58:2fea32db466b 659 // Assert MAX11043 UP_slash_DWNb pin : High = Up, Low = Down.
whismanoid 53:3d5a3d241a5e 660 //
whismanoid 53:3d5a3d241a5e 661 void UP_slash_DWNboutputValue(int isLogicHigh);
whismanoid 53:3d5a3d241a5e 662
whismanoid 53:3d5a3d241a5e 663 // CODE GENERATOR: extern function declaration EOCinputWaitUntilLow
whismanoid 53:3d5a3d241a5e 664 //----------------------------------------
whismanoid 53:3d5a3d241a5e 665 // Wait for MAX11043 EOC pin low, indicating end of conversion.
whismanoid 53:3d5a3d241a5e 666 // Required when using any of the InternalClock modes.
whismanoid 53:3d5a3d241a5e 667 //
whismanoid 53:3d5a3d241a5e 668 void EOCinputWaitUntilLow();
whismanoid 53:3d5a3d241a5e 669
whismanoid 53:3d5a3d241a5e 670 // CODE GENERATOR: extern function declaration EOCinputValue
whismanoid 53:3d5a3d241a5e 671 //----------------------------------------
whismanoid 53:3d5a3d241a5e 672 // Return the status of the MAX11043 EOC pin.
whismanoid 53:3d5a3d241a5e 673 //
whismanoid 53:3d5a3d241a5e 674 int EOCinputValue();
whismanoid 53:3d5a3d241a5e 675
whismanoid 53:3d5a3d241a5e 676 // CODE GENERATOR: class member data
whismanoid 53:3d5a3d241a5e 677 private:
whismanoid 53:3d5a3d241a5e 678 // CODE GENERATOR: class member data for SPI interface
whismanoid 53:3d5a3d241a5e 679 // SPI object
whismanoid 53:3d5a3d241a5e 680 SPI &m_spi;
whismanoid 53:3d5a3d241a5e 681 int m_SPI_SCLK_Hz;
whismanoid 53:3d5a3d241a5e 682 int m_SPI_dataMode;
whismanoid 53:3d5a3d241a5e 683 int m_SPI_cs_state;
whismanoid 53:3d5a3d241a5e 684
whismanoid 53:3d5a3d241a5e 685 // Selector pin object
whismanoid 53:3d5a3d241a5e 686 DigitalOut &m_cs_pin;
whismanoid 53:3d5a3d241a5e 687
whismanoid 53:3d5a3d241a5e 688 // CODE GENERATOR: class member data for gpio InputPin pins
whismanoid 53:3d5a3d241a5e 689 // InputPin Name = CONVRUN
whismanoid 53:3d5a3d241a5e 690 // 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 691 // CONVRUN is low.
whismanoid 53:3d5a3d241a5e 692 // InputPin Function = Configuration
whismanoid 53:3d5a3d241a5e 693 DigitalOut &m_CONVRUN_pin;
whismanoid 53:3d5a3d241a5e 694 //
whismanoid 53:3d5a3d241a5e 695 // InputPin Name = SHDN
whismanoid 53:3d5a3d241a5e 696 // InputPin Description = Shutdown (digital input). Active-High Shutdown Input. Drive high to shut down the MAX11043.
whismanoid 53:3d5a3d241a5e 697 // InputPin Function = Configuration
whismanoid 53:3d5a3d241a5e 698 DigitalOut &m_SHDN_pin;
whismanoid 53:3d5a3d241a5e 699 //
whismanoid 53:3d5a3d241a5e 700 // InputPin Name = DACSTEP
whismanoid 53:3d5a3d241a5e 701 // 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 702 // edge of the system clock.
whismanoid 53:3d5a3d241a5e 703 // InputPin Function = Configuration
whismanoid 53:3d5a3d241a5e 704 DigitalOut &m_DACSTEP_pin;
whismanoid 53:3d5a3d241a5e 705 //
whismanoid 53:3d5a3d241a5e 706 // InputPin Name = UP/DWN#
whismanoid 53:3d5a3d241a5e 707 // 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 708 // InputPin Function = Configuration
whismanoid 53:3d5a3d241a5e 709 DigitalOut &m_UP_slash_DWNb_pin;
whismanoid 53:3d5a3d241a5e 710 //
whismanoid 53:3d5a3d241a5e 711 // CODE GENERATOR: class member data for gpio OutputPin pins
whismanoid 53:3d5a3d241a5e 712 // OutputPin Name = EOC
whismanoid 53:3d5a3d241a5e 713 // 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 714 // OutputPin Function = Event
whismanoid 53:3d5a3d241a5e 715 DigitalIn &m_EOC_pin;
whismanoid 53:3d5a3d241a5e 716 //
whismanoid 53:3d5a3d241a5e 717
whismanoid 53:3d5a3d241a5e 718 // Identifies which IC variant is being used
whismanoid 53:3d5a3d241a5e 719 MAX11043_ic_t m_ic_variant;
whismanoid 53:3d5a3d241a5e 720
whismanoid 53:3d5a3d241a5e 721 public:
whismanoid 53:3d5a3d241a5e 722
whismanoid 53:3d5a3d241a5e 723 // CODE GENERATOR: class member function declarations
whismanoid 53:3d5a3d241a5e 724 //----------------------------------------
whismanoid 53:3d5a3d241a5e 725 /// Menu item '!'
whismanoid 53:3d5a3d241a5e 726 /// Initialize device
whismanoid 53:3d5a3d241a5e 727 /// @return 1 on success; 0 on failure
whismanoid 53:3d5a3d241a5e 728 uint8_t Init(void);
whismanoid 53:3d5a3d241a5e 729
whismanoid 53:3d5a3d241a5e 730 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 731 // CODE GENERATOR: looks like this is a 'write' register access function
whismanoid 53:3d5a3d241a5e 732 //----------------------------------------
whismanoid 53:3d5a3d241a5e 733 /// Write a MAX11043 register.
whismanoid 53:3d5a3d241a5e 734 ///
whismanoid 57:1c9da8e90737 735 /// CMDOP_1aaa_aaaa_ReadRegister bit is cleared 0 indicating a write operation.
whismanoid 53:3d5a3d241a5e 736 ///
whismanoid 53:3d5a3d241a5e 737 /// MAX11043 register length can be determined by function RegSize.
whismanoid 53:3d5a3d241a5e 738 ///
whismanoid 53:3d5a3d241a5e 739 /// For 8-bit register size:
whismanoid 53:3d5a3d241a5e 740 ///
whismanoid 53:3d5a3d241a5e 741 /// SPI 16-bit transfer
whismanoid 53:3d5a3d241a5e 742 ///
whismanoid 53:3d5a3d241a5e 743 /// SPI MOSI = 0aaa_aaaa_dddd_dddd
whismanoid 53:3d5a3d241a5e 744 ///
whismanoid 53:3d5a3d241a5e 745 /// SPI MISO = xxxx_xxxx_xxxx_xxxx
whismanoid 53:3d5a3d241a5e 746 ///
whismanoid 53:3d5a3d241a5e 747 /// For 16-bit register size:
whismanoid 53:3d5a3d241a5e 748 ///
whismanoid 53:3d5a3d241a5e 749 /// SPI 24-bit or 32-bit transfer
whismanoid 53:3d5a3d241a5e 750 ///
whismanoid 53:3d5a3d241a5e 751 /// SPI MOSI = 0aaa_aaaa_dddd_dddd_dddd_dddd
whismanoid 53:3d5a3d241a5e 752 ///
whismanoid 53:3d5a3d241a5e 753 /// SPI MISO = xxxx_xxxx_xxxx_xxxx_xxxx_xxxx
whismanoid 53:3d5a3d241a5e 754 ///
whismanoid 53:3d5a3d241a5e 755 /// For 24-bit register size:
whismanoid 53:3d5a3d241a5e 756 ///
whismanoid 53:3d5a3d241a5e 757 /// SPI 32-bit transfer
whismanoid 53:3d5a3d241a5e 758 ///
whismanoid 53:3d5a3d241a5e 759 /// SPI MOSI = 0aaa_aaaa_dddd_dddd_dddd_dddd_dddd_dddd
whismanoid 53:3d5a3d241a5e 760 ///
whismanoid 53:3d5a3d241a5e 761 /// SPI MISO = xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx
whismanoid 53:3d5a3d241a5e 762 ///
whismanoid 53:3d5a3d241a5e 763 /// @return 1 on success; 0 on failure
whismanoid 53:3d5a3d241a5e 764 uint8_t RegWrite(MAX11043_CMD_enum_t commandByte, uint32_t regData);
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 'read' register access function
whismanoid 53:3d5a3d241a5e 768 //----------------------------------------
whismanoid 53:3d5a3d241a5e 769 /// Read an 8-bit MAX11043 register
whismanoid 53:3d5a3d241a5e 770 ///
whismanoid 57:1c9da8e90737 771 /// CMDOP_1aaa_aaaa_ReadRegister bit is set 1 indicating a read 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 = 1aaa_aaaa_0000_0000
whismanoid 53:3d5a3d241a5e 780 ///
whismanoid 53:3d5a3d241a5e 781 /// SPI MISO = xxxx_xxxx_dddd_dddd
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 = 1aaa_aaaa_0000_0000_0000_0000
whismanoid 53:3d5a3d241a5e 788 ///
whismanoid 53:3d5a3d241a5e 789 /// SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd
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 = 1aaa_aaaa_0000_0000_0000_0000_0000_0000
whismanoid 53:3d5a3d241a5e 796 ///
whismanoid 53:3d5a3d241a5e 797 /// SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd_dddd_dddd
whismanoid 53:3d5a3d241a5e 798 ///
whismanoid 53:3d5a3d241a5e 799 ///
whismanoid 53:3d5a3d241a5e 800 /// @return 1 on success; 0 on failure
whismanoid 53:3d5a3d241a5e 801 uint8_t RegRead(MAX11043_CMD_enum_t commandByte, uint32_t* ptrRegData);
whismanoid 53:3d5a3d241a5e 802
whismanoid 53:3d5a3d241a5e 803 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 804 // CODE GENERATOR: looks like this is a 'size' register access function
whismanoid 53:3d5a3d241a5e 805 //----------------------------------------
whismanoid 53:3d5a3d241a5e 806 /// Return the size of a MAX11043 register
whismanoid 53:3d5a3d241a5e 807 ///
whismanoid 53:3d5a3d241a5e 808 /// @return 8 for 8-bit, 16 for 16-bit, 24 for 24-bit, else 0 for undefined register size
whismanoid 53:3d5a3d241a5e 809 uint8_t RegSize(MAX11043_CMD_enum_t commandByte);
whismanoid 53:3d5a3d241a5e 810
whismanoid 53:3d5a3d241a5e 811 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 812 //----------------------------------------
whismanoid 57:1c9da8e90737 813 /// Decode operation from commandByte
whismanoid 57:1c9da8e90737 814 ///
whismanoid 57:1c9da8e90737 815 /// @return operation such as idle, read register, write register, etc.
whismanoid 57:1c9da8e90737 816 MAX11043::MAX11043_CMDOP_enum_t DecodeCommand(MAX11043_CMD_enum_t commandByte);
whismanoid 57:1c9da8e90737 817
whismanoid 57:1c9da8e90737 818 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 57:1c9da8e90737 819 //----------------------------------------
whismanoid 53:3d5a3d241a5e 820 /// Return the address field of a MAX11043 register
whismanoid 53:3d5a3d241a5e 821 ///
whismanoid 53:3d5a3d241a5e 822 /// @return register address field as given in datasheet
whismanoid 53:3d5a3d241a5e 823 uint8_t RegAddrOfCommand(MAX11043_CMD_enum_t commandByte);
whismanoid 53:3d5a3d241a5e 824
whismanoid 53:3d5a3d241a5e 825 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 826 // CODE GENERATOR: looks like this is a 'read' register access function
whismanoid 53:3d5a3d241a5e 827 //----------------------------------------
whismanoid 53:3d5a3d241a5e 828 /// Test whether a command byte is a register read command
whismanoid 53:3d5a3d241a5e 829 ///
whismanoid 53:3d5a3d241a5e 830 /// @return true if command byte is a register read command
whismanoid 53:3d5a3d241a5e 831 uint8_t IsRegReadCommand(MAX11043_CMD_enum_t commandByte);
whismanoid 53:3d5a3d241a5e 832
whismanoid 53:3d5a3d241a5e 833 // CODE GENERATOR: looks like this is a register access function because 'regAdd'
whismanoid 53:3d5a3d241a5e 834 // CODE GENERATOR: looks like this is a 'name' register access function
whismanoid 53:3d5a3d241a5e 835 //----------------------------------------
whismanoid 53:3d5a3d241a5e 836 /// Return the name of a MAX11043 register
whismanoid 53:3d5a3d241a5e 837 ///
whismanoid 53:3d5a3d241a5e 838 /// @return null-terminated constant C string containing register name or empty string
whismanoid 53:3d5a3d241a5e 839 const char* RegName(MAX11043_CMD_enum_t commandByte);
whismanoid 53:3d5a3d241a5e 840
whismanoid 59:47538bcf6cda 841 //----------------------------------------
whismanoid 59:47538bcf6cda 842 /// Menu item 'XX'
whismanoid 59:47538bcf6cda 843 ///
whismanoid 59:47538bcf6cda 844 /// @return 1 on success; 0 on failure
whismanoid 59:47538bcf6cda 845 uint8_t Configure_XXXXX(uint8_t linef, uint8_t rate);
whismanoid 59:47538bcf6cda 846
whismanoid 59:47538bcf6cda 847 //----------------------------------------
whismanoid 59:47538bcf6cda 848 /// Menu item 'XY'
whismanoid 59:47538bcf6cda 849 ///
whismanoid 59:47538bcf6cda 850 /// @return 1 on success; 0 on failure
whismanoid 59:47538bcf6cda 851 uint8_t Configure_XXXXY(uint8_t linef, uint8_t rate);
whismanoid 59:47538bcf6cda 852
whismanoid 53:3d5a3d241a5e 853 }; // end of class MAX11043
whismanoid 53:3d5a3d241a5e 854
whismanoid 53:3d5a3d241a5e 855 #endif // __MAX11043_H__
whismanoid 53:3d5a3d241a5e 856
whismanoid 53:3d5a3d241a5e 857 // End of file