Test program running on MAX32625MBED. Control through USB Serial commands using a terminal emulator such as teraterm or putty.
Dependencies: MaximTinyTester CmdLine MAX541 USBDevice
MAX11043/MAX11043.h@53:3d5a3d241a5e, 2020-02-11 (annotated)
- Committer:
- whismanoid
- Date:
- Tue Feb 11 09:01:20 2020 +0000
- Revision:
- 53:3d5a3d241a5e
- Parent:
- 52:607010f0c54e
- Child:
- 57:1c9da8e90737
enable SPI commands
Who changed what in which revision?
User | Revision | Line number | New 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 | 53:3d5a3d241a5e | 297 | // CODE GENERATOR: TypedefEnum MAX11043_CMD_enum_t |
whismanoid | 53:3d5a3d241a5e | 298 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 299 | /// Register Addresses |
whismanoid | 53:3d5a3d241a5e | 300 | /// |
whismanoid | 53:3d5a3d241a5e | 301 | /// Naming convention is CMD_bitstream_WrAddr_FunctionName |
whismanoid | 53:3d5a3d241a5e | 302 | /// - first byte format is 0aaa_aar0 |
whismanoid | 53:3d5a3d241a5e | 303 | /// - 0 = bitstream required 0 bit |
whismanoid | 53:3d5a3d241a5e | 304 | /// - aaa_aa = bitstream 5-bit register address field |
whismanoid | 53:3d5a3d241a5e | 305 | /// - r = bitstream read/write bit (1=read, 0=write) |
whismanoid | 53:3d5a3d241a5e | 306 | /// - WrAddr = Write operation to address Addr |
whismanoid | 53:3d5a3d241a5e | 307 | /// - RdAddr = Read operation from address Addr |
whismanoid | 53:3d5a3d241a5e | 308 | /// - d8 = 8-bit register data field |
whismanoid | 53:3d5a3d241a5e | 309 | /// - d16 = 16-bit register data field |
whismanoid | 53:3d5a3d241a5e | 310 | /// - d24 = 24-bit register data field |
whismanoid | 53:3d5a3d241a5e | 311 | /// - d32 = 32-bit register data field |
whismanoid | 53:3d5a3d241a5e | 312 | /// - x = don't care |
whismanoid | 53:3d5a3d241a5e | 313 | typedef enum MAX11043_CMD_enum_t { |
whismanoid | 53:3d5a3d241a5e | 314 | CMD_0aaa_aa00_WrAddr_WriteAnyRegister = 0x00, //!< 8'b00000000 |
whismanoid | 53:3d5a3d241a5e | 315 | CMD_0000_0010_d24_Rd00_ADCa = 0x02, //!< 8'b00000010 |
whismanoid | 53:3d5a3d241a5e | 316 | CMD_0000_0110_d24_Rd01_ADCb = 0x06, //!< 8'b00000110 |
whismanoid | 53:3d5a3d241a5e | 317 | CMD_0000_1010_d24_Rd02_ADCc = 0x0a, //!< 8'b00001010 |
whismanoid | 53:3d5a3d241a5e | 318 | CMD_0000_1110_d24_Rd03_ADCd = 0x0e, //!< 8'b00001110 |
whismanoid | 53:3d5a3d241a5e | 319 | CMD_0001_0010_d24_d24_Rd04_ADCab = 0x12, //!< 8'b00010010 |
whismanoid | 53:3d5a3d241a5e | 320 | CMD_0001_0110_d24_d24_Rd05_ADCcd = 0x16, //!< 8'b00010110 |
whismanoid | 53:3d5a3d241a5e | 321 | CMD_0001_1010_d24_d24_d24_d24_Rd06_ADCabcd = 0x1a, //!< 8'b00011010 |
whismanoid | 53:3d5a3d241a5e | 322 | CMD_0001_1110_d8_Rd07_Status = 0x1e, //!< 8'b00011110 |
whismanoid | 53:3d5a3d241a5e | 323 | CMD_0010_0000_d16_Wr08_Configuration = 0x20, //!< 8'b00100000 |
whismanoid | 53:3d5a3d241a5e | 324 | CMD_0010_0010_d16_Rd08_Configuration = 0x22, //!< 8'b00100010 |
whismanoid | 53:3d5a3d241a5e | 325 | CMD_0010_0100_d16_Wr09_DAC = 0x24, //!< 8'b00100100 |
whismanoid | 53:3d5a3d241a5e | 326 | CMD_0010_0110_d16_Rd09_DAC = 0x26, //!< 8'b00100110 |
whismanoid | 53:3d5a3d241a5e | 327 | CMD_0010_1000_d16_Wr0A_DACStep = 0x28, //!< 8'b00101000 |
whismanoid | 53:3d5a3d241a5e | 328 | CMD_0010_1010_d16_Rd0A_DACStep = 0x2a, //!< 8'b00101010 |
whismanoid | 53:3d5a3d241a5e | 329 | CMD_0010_1100_d16_Wr0B_DACHDACL = 0x2c, //!< 8'b00101100 |
whismanoid | 53:3d5a3d241a5e | 330 | CMD_0010_1110_d16_Rd0B_DACHDACL = 0x2e, //!< 8'b00101110 |
whismanoid | 53:3d5a3d241a5e | 331 | CMD_0011_0000_d16_Wr0C_ConfigA = 0x30, //!< 8'b00110000 |
whismanoid | 53:3d5a3d241a5e | 332 | CMD_0011_0010_d16_Rd0C_ConfigA = 0x32, //!< 8'b00110010 |
whismanoid | 53:3d5a3d241a5e | 333 | CMD_0011_0100_d16_Wr0D_ConfigB = 0x34, //!< 8'b00110100 |
whismanoid | 53:3d5a3d241a5e | 334 | CMD_0011_0110_d16_Rd0D_ConfigB = 0x36, //!< 8'b00110110 |
whismanoid | 53:3d5a3d241a5e | 335 | CMD_0011_1000_d16_Wr0E_ConfigC = 0x38, //!< 8'b00111000 |
whismanoid | 53:3d5a3d241a5e | 336 | CMD_0011_1010_d16_Rd0E_ConfigC = 0x3a, //!< 8'b00111010 |
whismanoid | 53:3d5a3d241a5e | 337 | CMD_0011_1100_d16_Wr0F_ConfigD = 0x3c, //!< 8'b00111100 |
whismanoid | 53:3d5a3d241a5e | 338 | CMD_0011_1110_d16_Rd0F_ConfigD = 0x3e, //!< 8'b00111110 |
whismanoid | 53:3d5a3d241a5e | 339 | CMD_0100_0000_d16_Wr10_Reference = 0x40, //!< 8'b01000000 |
whismanoid | 53:3d5a3d241a5e | 340 | CMD_0100_0010_d16_Rd10_Reference = 0x42, //!< 8'b01000010 |
whismanoid | 53:3d5a3d241a5e | 341 | CMD_0100_0100_d16_Wr11_AGain = 0x44, //!< 8'b01000100 |
whismanoid | 53:3d5a3d241a5e | 342 | CMD_0100_0110_d16_Rd11_AGain = 0x46, //!< 8'b01000110 |
whismanoid | 53:3d5a3d241a5e | 343 | CMD_0100_1000_d16_Wr12_BGain = 0x48, //!< 8'b01001000 |
whismanoid | 53:3d5a3d241a5e | 344 | CMD_0100_1010_d16_Rd12_BGain = 0x4a, //!< 8'b01001010 |
whismanoid | 53:3d5a3d241a5e | 345 | CMD_0100_1100_d16_Wr13_CGain = 0x4c, //!< 8'b01001100 |
whismanoid | 53:3d5a3d241a5e | 346 | CMD_0100_1110_d16_Rd13_CGain = 0x4e, //!< 8'b01001110 |
whismanoid | 53:3d5a3d241a5e | 347 | CMD_0101_0000_d16_Wr14_DGain = 0x50, //!< 8'b01010000 |
whismanoid | 53:3d5a3d241a5e | 348 | CMD_0101_0010_d16_Rd14_DGain = 0x52, //!< 8'b01010010 |
whismanoid | 53:3d5a3d241a5e | 349 | CMD_0101_0100_d8_Wr15_FilterCAddress = 0x54, //!< 8'b01010100 |
whismanoid | 53:3d5a3d241a5e | 350 | CMD_0101_0110_d8_Rd15_FilterCAddress = 0x56, //!< 8'b01010110 |
whismanoid | 53:3d5a3d241a5e | 351 | CMD_0101_1000_d32_Wr16_FilterCDataOut = 0x58, //!< 8'b01011000 |
whismanoid | 53:3d5a3d241a5e | 352 | CMD_0101_1010_d32_Rd16_FilterCDataOut = 0x5a, //!< 8'b01011010 |
whismanoid | 53:3d5a3d241a5e | 353 | CMD_0101_1100_d32_Wr17_FilterCDataIn = 0x5c, //!< 8'b01011100 |
whismanoid | 53:3d5a3d241a5e | 354 | CMD_0101_1110_d32_Rd17_FilterCDataIn = 0x5e, //!< 8'b01011110 |
whismanoid | 53:3d5a3d241a5e | 355 | CMD_0110_0000_d8_Wr18_FlashMode = 0x60, //!< 8'b01100000 |
whismanoid | 53:3d5a3d241a5e | 356 | CMD_0110_0010_d8_Rd18_FlashMode = 0x62, //!< 8'b01100010 |
whismanoid | 53:3d5a3d241a5e | 357 | CMD_0110_0100_d16_Wr19_FlashAddr = 0x64, //!< 8'b01100100 |
whismanoid | 53:3d5a3d241a5e | 358 | CMD_0110_0110_d16_Rd19_FlashAddr = 0x66, //!< 8'b01100110 |
whismanoid | 53:3d5a3d241a5e | 359 | CMD_0110_1000_d16_Wr1A_FlashDataIn = 0x68, //!< 8'b01101000 |
whismanoid | 53:3d5a3d241a5e | 360 | CMD_0110_1010_d16_Rd1A_FlashDataIn = 0x6a, //!< 8'b01101010 |
whismanoid | 53:3d5a3d241a5e | 361 | CMD_0110_1110_d16_Rd1B_FlashDataOut = 0x6e, //!< 8'b01101110 |
whismanoid | 53:3d5a3d241a5e | 362 | CMD_0aaa_aa10_RdAddr_ReadAnyRegister = 0x80, //!< 8'b10000000 |
whismanoid | 53:3d5a3d241a5e | 363 | CMD_1111_1111_NoOperationMOSIidleHigh = 0xff, //!< 8'b11111111 |
whismanoid | 53:3d5a3d241a5e | 364 | } MAX11043_CMD_enum_t; |
whismanoid | 53:3d5a3d241a5e | 365 | |
whismanoid | 53:3d5a3d241a5e | 366 | // CODE GENERATOR: TypedefEnum MAX11043_STATUS_enum_t |
whismanoid | 53:3d5a3d241a5e | 367 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 368 | /// CMD_0001_1110_d8_Rd_Status |
whismanoid | 53:3d5a3d241a5e | 369 | /// regAddr=07h |
whismanoid | 53:3d5a3d241a5e | 370 | /// Status: x x FlashBusy BOOT OFLGA OFLGB OFLGC OFLGD |
whismanoid | 53:3d5a3d241a5e | 371 | typedef enum MAX11043_STATUS_enum_t { |
whismanoid | 53:3d5a3d241a5e | 372 | STATUS_xxxx_xxx1_OverflowFlagOFLGD = 0x01, //!< 8'b00000001 |
whismanoid | 53:3d5a3d241a5e | 373 | STATUS_xxxx_xx1x_OverflowFlagOFLGC = 0x02, //!< 8'b00000010 |
whismanoid | 53:3d5a3d241a5e | 374 | STATUS_xxxx_x1xx_OverflowFlagOFLGB = 0x04, //!< 8'b00000100 |
whismanoid | 53:3d5a3d241a5e | 375 | STATUS_xxxx_1xxx_OverflowFlagOFLGA = 0x08, //!< 8'b00001000 |
whismanoid | 53:3d5a3d241a5e | 376 | STATUS_xxx1_xxxx_PowerOnResetBOOT = 0x10, //!< 8'b00010000 |
whismanoid | 53:3d5a3d241a5e | 377 | STATUS_xx1x_xxxx_FlashBusy = 0x20, //!< 8'b00100000 |
whismanoid | 53:3d5a3d241a5e | 378 | STATUS_x1xx_xxxx_RESERVED = 0x40, //!< 8'b01000000 |
whismanoid | 53:3d5a3d241a5e | 379 | STATUS_1xxx_xxxx_RESERVED = 0x80, //!< 8'b10000000 |
whismanoid | 53:3d5a3d241a5e | 380 | } MAX11043_STATUS_enum_t; |
whismanoid | 53:3d5a3d241a5e | 381 | |
whismanoid | 53:3d5a3d241a5e | 382 | // CODE GENERATOR: TypedefEnum MAX11043_CONFIG_enum_t |
whismanoid | 53:3d5a3d241a5e | 383 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 384 | /// CMD_0010_0000_d16_Wr_Configuration |
whismanoid | 53:3d5a3d241a5e | 385 | /// regAddr=08h |
whismanoid | 53:3d5a3d241a5e | 386 | /// Config: EXTCLK CLKDIV1 CLKDIV0 PD PDA PDB PDC PDD PDDAC PDOSC 24BIT SCHANA SCHANB SCHANC SCHAND DECSEL |
whismanoid | 53:3d5a3d241a5e | 387 | typedef enum MAX11043_CONFIG_enum_t { |
whismanoid | 53:3d5a3d241a5e | 388 | CONFIG_xxxx_xxxx_xxxx_xxx1_DECSEL12 = 0x0001, //!< 16'b0000000000000001 |
whismanoid | 53:3d5a3d241a5e | 389 | CONFIG_xxxx_xxxx_xxxx_xx1x_SCHAND = 0x0002, //!< 16'b0000000000000010 |
whismanoid | 53:3d5a3d241a5e | 390 | CONFIG_xxxx_xxxx_xxxx_x1xx_SCHANC = 0x0004, //!< 16'b0000000000000100 |
whismanoid | 53:3d5a3d241a5e | 391 | CONFIG_xxxx_xxxx_xxxx_1xxx_SCHANB = 0x0008, //!< 16'b0000000000001000 |
whismanoid | 53:3d5a3d241a5e | 392 | CONFIG_xxxx_xxxx_xxx1_xxxx_SCHANA = 0x0010, //!< 16'b0000000000010000 |
whismanoid | 53:3d5a3d241a5e | 393 | CONFIG_xxxx_xxxx_xx1x_xxxx_24BIT = 0x0020, //!< 16'b0000000000100000 |
whismanoid | 53:3d5a3d241a5e | 394 | CONFIG_xxxx_xxxx_x1xx_xxxx_PDOSC = 0x0040, //!< 16'b0000000001000000 |
whismanoid | 53:3d5a3d241a5e | 395 | CONFIG_xxxx_xxxx_1xxx_xxxx_PDDAC = 0x0080, //!< 16'b0000000010000000 |
whismanoid | 53:3d5a3d241a5e | 396 | CONFIG_xxxx_xxx1_xxxx_xxxx_PDD = 0x0100, //!< 16'b0000000100000000 |
whismanoid | 53:3d5a3d241a5e | 397 | CONFIG_xxxx_xx1x_xxxx_xxxx_PDC = 0x0200, //!< 16'b0000001000000000 |
whismanoid | 53:3d5a3d241a5e | 398 | CONFIG_xxxx_x1xx_xxxx_xxxx_PDB = 0x0400, //!< 16'b0000010000000000 |
whismanoid | 53:3d5a3d241a5e | 399 | CONFIG_xxxx_1xxx_xxxx_xxxx_PDA = 0x0800, //!< 16'b0000100000000000 |
whismanoid | 53:3d5a3d241a5e | 400 | CONFIG_xxx1_xxxx_xxxx_xxxx_PD = 0x1000, //!< 16'b0001000000000000 |
whismanoid | 53:3d5a3d241a5e | 401 | CONFIG_xx1x_xxxx_xxxx_xxxx_CLKDIV0 = 0x2000, //!< 16'b0010000000000000 |
whismanoid | 53:3d5a3d241a5e | 402 | CONFIG_x1xx_xxxx_xxxx_xxxx_CLKDIV1 = 0x4000, //!< 16'b0100000000000000 |
whismanoid | 53:3d5a3d241a5e | 403 | CONFIG_1xxx_xxxx_xxxx_xxxx_EXTCLK = 0x8000, //!< 16'b1000000000000000 |
whismanoid | 53:3d5a3d241a5e | 404 | } MAX11043_CONFIG_enum_t; |
whismanoid | 52:607010f0c54e | 405 | |
whismanoid | 53:3d5a3d241a5e | 406 | // CODE GENERATOR: TypedefEnum MAX11043_CONFIGABCD_enum_t |
whismanoid | 53:3d5a3d241a5e | 407 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 408 | /// CMD_0011_0000_d16_Wr_CONFIGa |
whismanoid | 53:3d5a3d241a5e | 409 | /// CMD_0011_0100_d16_Wr_CONFIGb |
whismanoid | 53:3d5a3d241a5e | 410 | /// CMD_0011_1000_d16_Wr_CONFIGc |
whismanoid | 53:3d5a3d241a5e | 411 | /// CMD_0011_1100_d16_Wr_CONFIGd |
whismanoid | 53:3d5a3d241a5e | 412 | /// regAddr=0Ch |
whismanoid | 53:3d5a3d241a5e | 413 | /// regAddr=0Dh |
whismanoid | 53:3d5a3d241a5e | 414 | /// regAddr=0Eh |
whismanoid | 53:3d5a3d241a5e | 415 | /// regAddr=0Fh |
whismanoid | 53:3d5a3d241a5e | 416 | /// ConfigABCD: x x x BDAC[3:0] DIFF EQ MODG[1:0] PDPGA FILT PGAG ENBIASP ENBIASN |
whismanoid | 53:3d5a3d241a5e | 417 | typedef enum MAX11043_CONFIGABCD_enum_t { |
whismanoid | 53:3d5a3d241a5e | 418 | CONFIGABCD_xxxx_xxxx_xxxx_xxx1_ENBIASN = 0x0001, //!< 16'b0000000000000001 |
whismanoid | 53:3d5a3d241a5e | 419 | CONFIGABCD_xxxx_xxxx_xxxx_xx1x_ENBIASP = 0x0002, //!< 16'b0000000000000010 |
whismanoid | 53:3d5a3d241a5e | 420 | CONFIGABCD_xxxx_xxxx_xxxx_x1xx_PGAG16 = 0x0004, //!< 16'b0000000000000100 |
whismanoid | 53:3d5a3d241a5e | 421 | CONFIGABCD_xxxx_xxxx_xxxx_1xxx_FILTLP = 0x0008, //!< 16'b0000000000001000 |
whismanoid | 53:3d5a3d241a5e | 422 | CONFIGABCD_xxxx_xxxx_xxx1_xxxx_PDPGA = 0x0010, //!< 16'b0000000000010000 |
whismanoid | 53:3d5a3d241a5e | 423 | CONFIGABCD_xxxx_xxxx_xx1x_xxxx_MODG0 = 0x0020, //!< 16'b0000000000100000 |
whismanoid | 53:3d5a3d241a5e | 424 | CONFIGABCD_xxxx_xxxx_x1xx_xxxx_MODG1 = 0x0040, //!< 16'b0000000001000000 |
whismanoid | 53:3d5a3d241a5e | 425 | CONFIGABCD_xxxx_xxxx_1xxx_xxxx_EQ = 0x0080, //!< 16'b0000000010000000 |
whismanoid | 53:3d5a3d241a5e | 426 | CONFIGABCD_xxxx_xxx1_xxxx_xxxx_DIFF = 0x0100, //!< 16'b0000000100000000 |
whismanoid | 53:3d5a3d241a5e | 427 | CONFIGABCD_xxxx_xx1x_xxxx_xxxx_BDAC0 = 0x0200, //!< 16'b0000001000000000 |
whismanoid | 53:3d5a3d241a5e | 428 | CONFIGABCD_xxxx_x1xx_xxxx_xxxx_BDAC1 = 0x0400, //!< 16'b0000010000000000 |
whismanoid | 53:3d5a3d241a5e | 429 | CONFIGABCD_xxxx_1xxx_xxxx_xxxx_BDAC2 = 0x0800, //!< 16'b0000100000000000 |
whismanoid | 53:3d5a3d241a5e | 430 | CONFIGABCD_xxx1_xxxx_xxxx_xxxx_BDAC3 = 0x1000, //!< 16'b0001000000000000 |
whismanoid | 53:3d5a3d241a5e | 431 | CONFIGABCD_xx1x_xxxx_xxxx_xxxx_RESERVED = 0x2000, //!< 16'b0010000000000000 |
whismanoid | 53:3d5a3d241a5e | 432 | CONFIGABCD_x1xx_xxxx_xxxx_xxxx_RESERVED = 0x4000, //!< 16'b0100000000000000 |
whismanoid | 53:3d5a3d241a5e | 433 | CONFIGABCD_1xxx_xxxx_xxxx_xxxx_RESERVED = 0x8000, //!< 16'b1000000000000000 |
whismanoid | 53:3d5a3d241a5e | 434 | } MAX11043_CONFIGABCD_enum_t; |
whismanoid | 53:3d5a3d241a5e | 435 | |
whismanoid | 53:3d5a3d241a5e | 436 | // CODE GENERATOR: TypedefEnum MAX11043_BDAC_enum_t |
whismanoid | 53:3d5a3d241a5e | 437 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 438 | /// CMD_0011_0000_d16_Wr_CONFIGa |
whismanoid | 53:3d5a3d241a5e | 439 | /// CMD_0011_0100_d16_Wr_CONFIGb |
whismanoid | 53:3d5a3d241a5e | 440 | /// CMD_0011_1000_d16_Wr_CONFIGc |
whismanoid | 53:3d5a3d241a5e | 441 | /// CMD_0011_1100_d16_Wr_CONFIGd |
whismanoid | 53:3d5a3d241a5e | 442 | /// CONFIGABCD_xxx1_xxxx_xxxx_xxxx_BDAC3 |
whismanoid | 53:3d5a3d241a5e | 443 | /// CONFIGABCD_xxxx_1xxx_xxxx_xxxx_BDAC2 |
whismanoid | 53:3d5a3d241a5e | 444 | /// CONFIGABCD_xxxx_x1xx_xxxx_xxxx_BDAC1 |
whismanoid | 53:3d5a3d241a5e | 445 | /// CONFIGABCD_xxxx_xx1x_xxxx_xxxx_BDAC0 |
whismanoid | 53:3d5a3d241a5e | 446 | /// Sets the input bias voltage for AC-coupled signals when ENBIAS_ is set to 1. |
whismanoid | 53:3d5a3d241a5e | 447 | /// regAddr=0Ch |
whismanoid | 53:3d5a3d241a5e | 448 | /// regAddr=0Dh |
whismanoid | 53:3d5a3d241a5e | 449 | /// regAddr=0Eh |
whismanoid | 53:3d5a3d241a5e | 450 | /// regAddr=0Fh |
whismanoid | 53:3d5a3d241a5e | 451 | /// ConfigABCD: x x x BDAC[3:0] DIFF EQ MODG[1:0] PDPGA FILT PGAG ENBIASP ENBIASN |
whismanoid | 53:3d5a3d241a5e | 452 | typedef enum MAX11043_BDAC_enum_t { |
whismanoid | 53:3d5a3d241a5e | 453 | BDAC_0000_033pctAVDD = 0x00, //!< 8'b00000000 |
whismanoid | 53:3d5a3d241a5e | 454 | BDAC_0001_035pctAVDD = 0x01, //!< 8'b00000001 |
whismanoid | 53:3d5a3d241a5e | 455 | BDAC_0010_038pctAVDD = 0x02, //!< 8'b00000010 |
whismanoid | 53:3d5a3d241a5e | 456 | BDAC_0011_040pctAVDD = 0x03, //!< 8'b00000011 |
whismanoid | 53:3d5a3d241a5e | 457 | BDAC_0100_042pctAVDD = 0x04, //!< 8'b00000100 |
whismanoid | 53:3d5a3d241a5e | 458 | BDAC_0101_044pctAVDD = 0x05, //!< 8'b00000101 |
whismanoid | 53:3d5a3d241a5e | 459 | BDAC_0110_046pctAVDD = 0x06, //!< 8'b00000110 |
whismanoid | 53:3d5a3d241a5e | 460 | BDAC_0111_048pctAVDD = 0x07, //!< 8'b00000111 |
whismanoid | 53:3d5a3d241a5e | 461 | BDAC_1000_050pctAVDD = 0x08, //!< 8'b00001000 |
whismanoid | 53:3d5a3d241a5e | 462 | BDAC_1001_052pctAVDD = 0x09, //!< 8'b00001001 |
whismanoid | 53:3d5a3d241a5e | 463 | BDAC_1010_054pctAVDD = 0x0a, //!< 8'b00001010 |
whismanoid | 53:3d5a3d241a5e | 464 | BDAC_1011_056pctAVDD = 0x0b, //!< 8'b00001011 |
whismanoid | 53:3d5a3d241a5e | 465 | BDAC_1100_058pctAVDD = 0x0c, //!< 8'b00001100 |
whismanoid | 53:3d5a3d241a5e | 466 | BDAC_1101_060pctAVDD = 0x0d, //!< 8'b00001101 |
whismanoid | 53:3d5a3d241a5e | 467 | BDAC_1110_062pctAVDD = 0x0e, //!< 8'b00001110 |
whismanoid | 53:3d5a3d241a5e | 468 | BDAC_1111_065pctAVDD = 0x0f, //!< 8'b00001111 |
whismanoid | 53:3d5a3d241a5e | 469 | } MAX11043_BDAC_enum_t; |
whismanoid | 53:3d5a3d241a5e | 470 | |
whismanoid | 53:3d5a3d241a5e | 471 | // CODE GENERATOR: TypedefEnum MAX11043_REFERENCE_enum_t |
whismanoid | 53:3d5a3d241a5e | 472 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 473 | /// CMD_0100_0000_d16_Wr_Reference |
whismanoid | 53:3d5a3d241a5e | 474 | /// regAddr=10h |
whismanoid | 53:3d5a3d241a5e | 475 | /// ReferenceDelay: 0 0 0 PURGE[4:0] EXTREF EXBUFA EXBUFB EXBUFC EXBUFD EXBUFDAC EXBUFDACH EXBUFDACL |
whismanoid | 53:3d5a3d241a5e | 476 | typedef enum MAX11043_REFERENCE_enum_t { |
whismanoid | 53:3d5a3d241a5e | 477 | REFERENCE_xxxx_xxxx_xxxx_xxx1_EXBUFDACL = 0x0001, //!< 16'b0000000000000001 |
whismanoid | 53:3d5a3d241a5e | 478 | REFERENCE_xxxx_xxxx_xxxx_xx1x_EXBUFDACH = 0x0002, //!< 16'b0000000000000010 |
whismanoid | 53:3d5a3d241a5e | 479 | REFERENCE_xxxx_xxxx_xxxx_x1xx_EXBUFDAC = 0x0004, //!< 16'b0000000000000100 |
whismanoid | 53:3d5a3d241a5e | 480 | REFERENCE_xxxx_xxxx_xxxx_1xxx_EXBUFD = 0x0008, //!< 16'b0000000000001000 |
whismanoid | 53:3d5a3d241a5e | 481 | REFERENCE_xxxx_xxxx_xxx1_xxxx_EXBUFC = 0x0010, //!< 16'b0000000000010000 |
whismanoid | 53:3d5a3d241a5e | 482 | REFERENCE_xxxx_xxxx_xx1x_xxxx_EXBUFB = 0x0020, //!< 16'b0000000000100000 |
whismanoid | 53:3d5a3d241a5e | 483 | REFERENCE_xxxx_xxxx_x1xx_xxxx_EXBUFA = 0x0040, //!< 16'b0000000001000000 |
whismanoid | 53:3d5a3d241a5e | 484 | REFERENCE_xxxx_xxxx_1xxx_xxxx_EXTREF = 0x0080, //!< 16'b0000000010000000 |
whismanoid | 53:3d5a3d241a5e | 485 | REFERENCE_xxxx_xxx1_xxxx_xxxx_PURGE0 = 0x0100, //!< 16'b0000000100000000 |
whismanoid | 53:3d5a3d241a5e | 486 | REFERENCE_xxxx_xx1x_xxxx_xxxx_PURGE1 = 0x0200, //!< 16'b0000001000000000 |
whismanoid | 53:3d5a3d241a5e | 487 | REFERENCE_xxxx_x1xx_xxxx_xxxx_PURGE2 = 0x0400, //!< 16'b0000010000000000 |
whismanoid | 53:3d5a3d241a5e | 488 | REFERENCE_xxxx_1xxx_xxxx_xxxx_PURGE3 = 0x0800, //!< 16'b0000100000000000 |
whismanoid | 53:3d5a3d241a5e | 489 | REFERENCE_xxx1_xxxx_xxxx_xxxx_PURGE4 = 0x1000, //!< 16'b0001000000000000 |
whismanoid | 53:3d5a3d241a5e | 490 | REFERENCE_xx1x_xxxx_xxxx_xxxx_RESERVED = 0x2000, //!< 16'b0010000000000000 |
whismanoid | 53:3d5a3d241a5e | 491 | REFERENCE_x1xx_xxxx_xxxx_xxxx_RESERVED = 0x4000, //!< 16'b0100000000000000 |
whismanoid | 53:3d5a3d241a5e | 492 | REFERENCE_1xxx_xxxx_xxxx_xxxx_RESERVED = 0x8000, //!< 16'b1000000000000000 |
whismanoid | 53:3d5a3d241a5e | 493 | } MAX11043_REFERENCE_enum_t; |
whismanoid | 53:3d5a3d241a5e | 494 | |
whismanoid | 53:3d5a3d241a5e | 495 | // TODO1: CODE GENERATOR: ic_variant -- IC's supported with this driver |
whismanoid | 53:3d5a3d241a5e | 496 | /** |
whismanoid | 53:3d5a3d241a5e | 497 | * @brief IC's supported with this driver |
whismanoid | 53:3d5a3d241a5e | 498 | * @details MAX11043 |
whismanoid | 53:3d5a3d241a5e | 499 | */ |
whismanoid | 53:3d5a3d241a5e | 500 | typedef enum |
whismanoid | 53:3d5a3d241a5e | 501 | { |
whismanoid | 53:3d5a3d241a5e | 502 | MAX11043_IC = 0, |
whismanoid | 53:3d5a3d241a5e | 503 | //MAX11043_IC = 1 |
whismanoid | 53:3d5a3d241a5e | 504 | } MAX11043_ic_t; |
whismanoid | 53:3d5a3d241a5e | 505 | |
whismanoid | 53:3d5a3d241a5e | 506 | // TODO1: CODE GENERATOR: class constructor declaration |
whismanoid | 53:3d5a3d241a5e | 507 | /**********************************************************//** |
whismanoid | 53:3d5a3d241a5e | 508 | * @brief Constructor for MAX11043 Class. |
whismanoid | 53:3d5a3d241a5e | 509 | * |
whismanoid | 53:3d5a3d241a5e | 510 | * @details Requires an existing SPI object as well as a DigitalOut object. |
whismanoid | 53:3d5a3d241a5e | 511 | * The DigitalOut object is used for a chip enable signal |
whismanoid | 53:3d5a3d241a5e | 512 | * |
whismanoid | 53:3d5a3d241a5e | 513 | * On Entry: |
whismanoid | 53:3d5a3d241a5e | 514 | * @param[in] spi - pointer to existing SPI object |
whismanoid | 53:3d5a3d241a5e | 515 | * @param[in] cs_pin - pointer to a DigitalOut pin object |
whismanoid | 53:3d5a3d241a5e | 516 | * CODE GENERATOR: class constructor docstrings gpio InputPin pins |
whismanoid | 53:3d5a3d241a5e | 517 | * @param[in] CONVRUN_pin - pointer to a DigitalOut pin object |
whismanoid | 53:3d5a3d241a5e | 518 | * @param[in] SHDN_pin - pointer to a DigitalOut pin object |
whismanoid | 53:3d5a3d241a5e | 519 | * @param[in] DACSTEP_pin - pointer to a DigitalOut pin object |
whismanoid | 53:3d5a3d241a5e | 520 | * @param[in] UP_slash_DWNb_pin - pointer to a DigitalOut pin object |
whismanoid | 53:3d5a3d241a5e | 521 | * CODE GENERATOR: class constructor docstrings gpio OutputPin pins |
whismanoid | 53:3d5a3d241a5e | 522 | * @param[in] EOC_pin - pointer to a DigitalIn pin object |
whismanoid | 53:3d5a3d241a5e | 523 | * @param[in] ic_variant - which type of MAX11043 is used |
whismanoid | 53:3d5a3d241a5e | 524 | * |
whismanoid | 53:3d5a3d241a5e | 525 | * On Exit: |
whismanoid | 53:3d5a3d241a5e | 526 | * |
whismanoid | 53:3d5a3d241a5e | 527 | * @return None |
whismanoid | 53:3d5a3d241a5e | 528 | **************************************************************/ |
whismanoid | 53:3d5a3d241a5e | 529 | MAX11043(SPI &spi, DigitalOut &cs_pin, // SPI interface |
whismanoid | 53:3d5a3d241a5e | 530 | // CODE GENERATOR: class constructor declaration gpio InputPin pins |
whismanoid | 53:3d5a3d241a5e | 531 | DigitalOut &CONVRUN_pin, // Digital Configuration Input to MAX11043 device |
whismanoid | 53:3d5a3d241a5e | 532 | DigitalOut &SHDN_pin, // Digital Configuration Input to MAX11043 device |
whismanoid | 53:3d5a3d241a5e | 533 | DigitalOut &DACSTEP_pin, // Digital Configuration Input to MAX11043 device |
whismanoid | 53:3d5a3d241a5e | 534 | DigitalOut &UP_slash_DWNb_pin, // Digital Configuration Input to MAX11043 device |
whismanoid | 53:3d5a3d241a5e | 535 | // CODE GENERATOR: class constructor declaration gpio OutputPin pins |
whismanoid | 53:3d5a3d241a5e | 536 | DigitalIn &EOC_pin, // Digital Event Output from MAX11043 device |
whismanoid | 53:3d5a3d241a5e | 537 | MAX11043_ic_t ic_variant); |
whismanoid | 53:3d5a3d241a5e | 538 | |
whismanoid | 53:3d5a3d241a5e | 539 | // CODE GENERATOR: class destructor declaration |
whismanoid | 53:3d5a3d241a5e | 540 | /************************************************************ |
whismanoid | 53:3d5a3d241a5e | 541 | * @brief Default destructor for MAX11043 Class. |
whismanoid | 53:3d5a3d241a5e | 542 | * |
whismanoid | 53:3d5a3d241a5e | 543 | * @details Destroys SPI object if owner |
whismanoid | 53:3d5a3d241a5e | 544 | * |
whismanoid | 53:3d5a3d241a5e | 545 | * On Entry: |
whismanoid | 53:3d5a3d241a5e | 546 | * |
whismanoid | 53:3d5a3d241a5e | 547 | * On Exit: |
whismanoid | 53:3d5a3d241a5e | 548 | * |
whismanoid | 53:3d5a3d241a5e | 549 | * @return None |
whismanoid | 53:3d5a3d241a5e | 550 | **************************************************************/ |
whismanoid | 53:3d5a3d241a5e | 551 | ~MAX11043(); |
whismanoid | 53:3d5a3d241a5e | 552 | |
whismanoid | 53:3d5a3d241a5e | 553 | // CODE GENERATOR: Declare SPI diagnostic function pointer void onSPIprint() |
whismanoid | 53:3d5a3d241a5e | 554 | /// Function pointer void f(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]) |
whismanoid | 53:3d5a3d241a5e | 555 | Callback<void(size_t, uint8_t*, uint8_t*)> onSPIprint; //!< optional @ref onSPIprint SPI diagnostic function |
whismanoid | 53:3d5a3d241a5e | 556 | |
whismanoid | 53:3d5a3d241a5e | 557 | // CODE GENERATOR: spi_frequency setter declaration |
whismanoid | 53:3d5a3d241a5e | 558 | /// set SPI SCLK frequency |
whismanoid | 53:3d5a3d241a5e | 559 | void spi_frequency(int spi_sclk_Hz); |
whismanoid | 53:3d5a3d241a5e | 560 | |
whismanoid | 53:3d5a3d241a5e | 561 | // CODE GENERATOR: spi_frequency getter declaration and definition |
whismanoid | 53:3d5a3d241a5e | 562 | /// get SPI SCLK frequency |
whismanoid | 53:3d5a3d241a5e | 563 | int get_spi_frequency() const { return m_SPI_SCLK_Hz; } |
whismanoid | 53:3d5a3d241a5e | 564 | |
whismanoid | 53:3d5a3d241a5e | 565 | // CODE GENERATOR: spi_dataMode getter declaration and definition |
whismanoid | 53:3d5a3d241a5e | 566 | /// get SPI mode |
whismanoid | 53:3d5a3d241a5e | 567 | int get_spi_dataMode() const { return m_SPI_dataMode; } |
whismanoid | 53:3d5a3d241a5e | 568 | |
whismanoid | 53:3d5a3d241a5e | 569 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 570 | // CODE GENERATOR: omit typedef enum MAX11043_device_t, class members instead of global device object |
whismanoid | 53:3d5a3d241a5e | 571 | public: |
whismanoid | 53:3d5a3d241a5e | 572 | |
whismanoid | 53:3d5a3d241a5e | 573 | /// TODO1: AC79 MAX11043 AIN0-AIN1 reference voltage, in Volts |
whismanoid | 53:3d5a3d241a5e | 574 | double VRef_xxxxxx; |
whismanoid | 53:3d5a3d241a5e | 575 | |
whismanoid | 53:3d5a3d241a5e | 576 | /// TODO1: AC79 MAX11043 shadow of register ctrl CMD_r000_1001_dddd_dddd_CTRL |
whismanoid | 53:3d5a3d241a5e | 577 | uint32_t ctrl; |
whismanoid | 53:3d5a3d241a5e | 578 | |
whismanoid | 53:3d5a3d241a5e | 579 | /// TODO1: AC79 MAX11043 read-only pga gain 1, 2, 4, 8, 16, 32, 64, or 128 set by Configure_PGA gain index register pga CMD_r000_1110_xxdd_xddd_PGA |
whismanoid | 53:3d5a3d241a5e | 580 | uint8_t pgaGain; |
whismanoid | 53:3d5a3d241a5e | 581 | |
whismanoid | 53:3d5a3d241a5e | 582 | /// TODO1: AC79 MAX11043 shadow of register status CMD_r011_1000_dddd_dddd_dddd_dddd_dxxx_dddd_STATUS |
whismanoid | 53:3d5a3d241a5e | 583 | uint32_t status; |
whismanoid | 53:3d5a3d241a5e | 584 | |
whismanoid | 53:3d5a3d241a5e | 585 | /// TODO1: AC79 MAX11043 shadow of register data0 CMD_r011_0000_dddd_dddd_dddd_dddd_dddd_dddd_DATA0 |
whismanoid | 53:3d5a3d241a5e | 586 | uint32_t data0; |
whismanoid | 53:3d5a3d241a5e | 587 | |
whismanoid | 53:3d5a3d241a5e | 588 | /// TODO1: AC79 MAX11043 Each channel's most recent value in LSBs. |
whismanoid | 53:3d5a3d241a5e | 589 | /// Updated by Measure_Voltage function. |
whismanoid | 53:3d5a3d241a5e | 590 | /// Use VoltageOfCode function to convert LSBs to physical voltage. |
whismanoid | 53:3d5a3d241a5e | 591 | /// (Valid index range AINP_SEL_0000_AIN0 to AINP_SEL_1010_AVDD) |
whismanoid | 53:3d5a3d241a5e | 592 | /// |
whismanoid | 53:3d5a3d241a5e | 593 | uint32_t AINcode[11]; |
whismanoid | 53:3d5a3d241a5e | 594 | |
whismanoid | 53:3d5a3d241a5e | 595 | // CODE GENERATOR: omit global g_MAX11043_device |
whismanoid | 53:3d5a3d241a5e | 596 | |
whismanoid | 53:3d5a3d241a5e | 597 | // CODE GENERATOR: extern function declarations |
whismanoid | 53:3d5a3d241a5e | 598 | // CODE GENERATOR: extern function declaration SPIoutputCS |
whismanoid | 53:3d5a3d241a5e | 599 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 600 | // Assert SPI Chip Select |
whismanoid | 53:3d5a3d241a5e | 601 | // SPI chip-select for MAX11043 |
whismanoid | 53:3d5a3d241a5e | 602 | // |
whismanoid | 53:3d5a3d241a5e | 603 | void SPIoutputCS(int isLogicHigh); |
whismanoid | 53:3d5a3d241a5e | 604 | |
whismanoid | 53:3d5a3d241a5e | 605 | // CODE GENERATOR: extern function declaration SPIwrite16bits |
whismanoid | 53:3d5a3d241a5e | 606 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 607 | // SPI write 16 bits |
whismanoid | 53:3d5a3d241a5e | 608 | // SPI interface to MAX11043 shift 16 bits mosiData into MAX11043 DIN |
whismanoid | 53:3d5a3d241a5e | 609 | // |
whismanoid | 53:3d5a3d241a5e | 610 | void SPIwrite16bits(int16_t mosiData16); |
whismanoid | 53:3d5a3d241a5e | 611 | |
whismanoid | 53:3d5a3d241a5e | 612 | // CODE GENERATOR: extern function declaration SPIreadWrite16bits |
whismanoid | 53:3d5a3d241a5e | 613 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 614 | // SPI read and write 16 bits |
whismanoid | 53:3d5a3d241a5e | 615 | // SPI interface to MAX11043 shift 16 bits mosiData16 into MAX11043 DIN |
whismanoid | 53:3d5a3d241a5e | 616 | // while simultaneously capturing 16 bits miso data from MAX11043 DOUT |
whismanoid | 53:3d5a3d241a5e | 617 | // |
whismanoid | 53:3d5a3d241a5e | 618 | int16_t SPIreadWrite16bits(int16_t mosiData16); |
whismanoid | 53:3d5a3d241a5e | 619 | |
whismanoid | 53:3d5a3d241a5e | 620 | // CODE GENERATOR: extern function declaration SPIreadWrite32bits |
whismanoid | 53:3d5a3d241a5e | 621 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 622 | // SPI read and write 32 bits |
whismanoid | 53:3d5a3d241a5e | 623 | // SPI interface to MAX11043 shift 32 bits mosiData into MAX11043 DIN |
whismanoid | 53:3d5a3d241a5e | 624 | // while simultaneously capturing 32 bits miso data from MAX11043 DOUT |
whismanoid | 53:3d5a3d241a5e | 625 | // |
whismanoid | 53:3d5a3d241a5e | 626 | int32_t SPIreadWrite32bits(int32_t mosiData32); |
whismanoid | 53:3d5a3d241a5e | 627 | |
whismanoid | 53:3d5a3d241a5e | 628 | // CODE GENERATOR: extern function declaration SHDNoutputValue |
whismanoid | 53:3d5a3d241a5e | 629 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 630 | // Assert MAX11043 SHDN pin : High = _____, Low = _____. |
whismanoid | 53:3d5a3d241a5e | 631 | // |
whismanoid | 53:3d5a3d241a5e | 632 | void SHDNoutputValue(int isLogicHigh); |
whismanoid | 53:3d5a3d241a5e | 633 | |
whismanoid | 53:3d5a3d241a5e | 634 | // CODE GENERATOR: extern function declaration CONVRUNoutputValue |
whismanoid | 53:3d5a3d241a5e | 635 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 636 | // Assert MAX11043 CONVRUN pin : High = _____, Low = _____. |
whismanoid | 53:3d5a3d241a5e | 637 | // |
whismanoid | 53:3d5a3d241a5e | 638 | void CONVRUNoutputValue(int isLogicHigh); |
whismanoid | 53:3d5a3d241a5e | 639 | |
whismanoid | 53:3d5a3d241a5e | 640 | // CODE GENERATOR: extern function declaration DACSTEPoutputValue |
whismanoid | 53:3d5a3d241a5e | 641 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 642 | // Assert MAX11043 DACSTEP pin : High = _____, Low = _____. |
whismanoid | 53:3d5a3d241a5e | 643 | // |
whismanoid | 53:3d5a3d241a5e | 644 | void DACSTEPoutputValue(int isLogicHigh); |
whismanoid | 53:3d5a3d241a5e | 645 | |
whismanoid | 53:3d5a3d241a5e | 646 | // CODE GENERATOR: extern function declaration UP_slash_DWNboutputValue |
whismanoid | 53:3d5a3d241a5e | 647 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 648 | // Assert MAX11043 UP_slash_DWNb pin : High = _____, Low = _____. |
whismanoid | 53:3d5a3d241a5e | 649 | // |
whismanoid | 53:3d5a3d241a5e | 650 | void UP_slash_DWNboutputValue(int isLogicHigh); |
whismanoid | 53:3d5a3d241a5e | 651 | |
whismanoid | 53:3d5a3d241a5e | 652 | // CODE GENERATOR: extern function declaration EOCinputWaitUntilLow |
whismanoid | 53:3d5a3d241a5e | 653 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 654 | // Wait for MAX11043 EOC pin low, indicating end of conversion. |
whismanoid | 53:3d5a3d241a5e | 655 | // Required when using any of the InternalClock modes. |
whismanoid | 53:3d5a3d241a5e | 656 | // |
whismanoid | 53:3d5a3d241a5e | 657 | void EOCinputWaitUntilLow(); |
whismanoid | 53:3d5a3d241a5e | 658 | |
whismanoid | 53:3d5a3d241a5e | 659 | // CODE GENERATOR: extern function declaration EOCinputValue |
whismanoid | 53:3d5a3d241a5e | 660 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 661 | // Return the status of the MAX11043 EOC pin. |
whismanoid | 53:3d5a3d241a5e | 662 | // |
whismanoid | 53:3d5a3d241a5e | 663 | int EOCinputValue(); |
whismanoid | 53:3d5a3d241a5e | 664 | |
whismanoid | 53:3d5a3d241a5e | 665 | // CODE GENERATOR: class member data |
whismanoid | 53:3d5a3d241a5e | 666 | private: |
whismanoid | 53:3d5a3d241a5e | 667 | // CODE GENERATOR: class member data for SPI interface |
whismanoid | 53:3d5a3d241a5e | 668 | // SPI object |
whismanoid | 53:3d5a3d241a5e | 669 | SPI &m_spi; |
whismanoid | 53:3d5a3d241a5e | 670 | int m_SPI_SCLK_Hz; |
whismanoid | 53:3d5a3d241a5e | 671 | int m_SPI_dataMode; |
whismanoid | 53:3d5a3d241a5e | 672 | int m_SPI_cs_state; |
whismanoid | 53:3d5a3d241a5e | 673 | |
whismanoid | 53:3d5a3d241a5e | 674 | // Selector pin object |
whismanoid | 53:3d5a3d241a5e | 675 | DigitalOut &m_cs_pin; |
whismanoid | 53:3d5a3d241a5e | 676 | |
whismanoid | 53:3d5a3d241a5e | 677 | // CODE GENERATOR: class member data for gpio InputPin pins |
whismanoid | 53:3d5a3d241a5e | 678 | // InputPin Name = CONVRUN |
whismanoid | 53:3d5a3d241a5e | 679 | // 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 | 680 | // CONVRUN is low. |
whismanoid | 53:3d5a3d241a5e | 681 | // InputPin Function = Configuration |
whismanoid | 53:3d5a3d241a5e | 682 | DigitalOut &m_CONVRUN_pin; |
whismanoid | 53:3d5a3d241a5e | 683 | // |
whismanoid | 53:3d5a3d241a5e | 684 | // InputPin Name = SHDN |
whismanoid | 53:3d5a3d241a5e | 685 | // InputPin Description = Shutdown (digital input). Active-High Shutdown Input. Drive high to shut down the MAX11043. |
whismanoid | 53:3d5a3d241a5e | 686 | // InputPin Function = Configuration |
whismanoid | 53:3d5a3d241a5e | 687 | DigitalOut &m_SHDN_pin; |
whismanoid | 53:3d5a3d241a5e | 688 | // |
whismanoid | 53:3d5a3d241a5e | 689 | // InputPin Name = DACSTEP |
whismanoid | 53:3d5a3d241a5e | 690 | // 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 | 691 | // edge of the system clock. |
whismanoid | 53:3d5a3d241a5e | 692 | // InputPin Function = Configuration |
whismanoid | 53:3d5a3d241a5e | 693 | DigitalOut &m_DACSTEP_pin; |
whismanoid | 53:3d5a3d241a5e | 694 | // |
whismanoid | 53:3d5a3d241a5e | 695 | // InputPin Name = UP/DWN# |
whismanoid | 53:3d5a3d241a5e | 696 | // 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 | 697 | // InputPin Function = Configuration |
whismanoid | 53:3d5a3d241a5e | 698 | DigitalOut &m_UP_slash_DWNb_pin; |
whismanoid | 53:3d5a3d241a5e | 699 | // |
whismanoid | 53:3d5a3d241a5e | 700 | // CODE GENERATOR: class member data for gpio OutputPin pins |
whismanoid | 53:3d5a3d241a5e | 701 | // OutputPin Name = EOC |
whismanoid | 53:3d5a3d241a5e | 702 | // 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 | 703 | // OutputPin Function = Event |
whismanoid | 53:3d5a3d241a5e | 704 | DigitalIn &m_EOC_pin; |
whismanoid | 53:3d5a3d241a5e | 705 | // |
whismanoid | 53:3d5a3d241a5e | 706 | |
whismanoid | 53:3d5a3d241a5e | 707 | // Identifies which IC variant is being used |
whismanoid | 53:3d5a3d241a5e | 708 | MAX11043_ic_t m_ic_variant; |
whismanoid | 53:3d5a3d241a5e | 709 | |
whismanoid | 53:3d5a3d241a5e | 710 | public: |
whismanoid | 53:3d5a3d241a5e | 711 | |
whismanoid | 53:3d5a3d241a5e | 712 | // CODE GENERATOR: class member function declarations |
whismanoid | 53:3d5a3d241a5e | 713 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 714 | /// Menu item '!' |
whismanoid | 53:3d5a3d241a5e | 715 | /// Initialize device |
whismanoid | 53:3d5a3d241a5e | 716 | /// @return 1 on success; 0 on failure |
whismanoid | 53:3d5a3d241a5e | 717 | uint8_t Init(void); |
whismanoid | 53:3d5a3d241a5e | 718 | |
whismanoid | 53:3d5a3d241a5e | 719 | // CODE GENERATOR: looks like this is a register access function because 'regAdd' |
whismanoid | 53:3d5a3d241a5e | 720 | // CODE GENERATOR: looks like this is a 'write' register access function |
whismanoid | 53:3d5a3d241a5e | 721 | // CODE GENERATOR: looks like this is a register access function because 'regAdd' |
whismanoid | 53:3d5a3d241a5e | 722 | // CODE GENERATOR: looks like this is a 'write' register access function: omit this function from test menu |
whismanoid | 53:3d5a3d241a5e | 723 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 724 | /// Write a MAX11043 register. |
whismanoid | 53:3d5a3d241a5e | 725 | /// |
whismanoid | 53:3d5a3d241a5e | 726 | /// CMD_1aaa_aaaa_REGISTER_READ bit is cleared 0 indicating a write operation. |
whismanoid | 53:3d5a3d241a5e | 727 | /// |
whismanoid | 53:3d5a3d241a5e | 728 | /// MAX11043 register length can be determined by function RegSize. |
whismanoid | 53:3d5a3d241a5e | 729 | /// |
whismanoid | 53:3d5a3d241a5e | 730 | /// For 8-bit register size: |
whismanoid | 53:3d5a3d241a5e | 731 | /// |
whismanoid | 53:3d5a3d241a5e | 732 | /// SPI 16-bit transfer |
whismanoid | 53:3d5a3d241a5e | 733 | /// |
whismanoid | 53:3d5a3d241a5e | 734 | /// SPI MOSI = 0aaa_aaaa_dddd_dddd |
whismanoid | 53:3d5a3d241a5e | 735 | /// |
whismanoid | 53:3d5a3d241a5e | 736 | /// SPI MISO = xxxx_xxxx_xxxx_xxxx |
whismanoid | 53:3d5a3d241a5e | 737 | /// |
whismanoid | 53:3d5a3d241a5e | 738 | /// For 16-bit register size: |
whismanoid | 53:3d5a3d241a5e | 739 | /// |
whismanoid | 53:3d5a3d241a5e | 740 | /// SPI 24-bit or 32-bit transfer |
whismanoid | 53:3d5a3d241a5e | 741 | /// |
whismanoid | 53:3d5a3d241a5e | 742 | /// SPI MOSI = 0aaa_aaaa_dddd_dddd_dddd_dddd |
whismanoid | 53:3d5a3d241a5e | 743 | /// |
whismanoid | 53:3d5a3d241a5e | 744 | /// SPI MISO = xxxx_xxxx_xxxx_xxxx_xxxx_xxxx |
whismanoid | 53:3d5a3d241a5e | 745 | /// |
whismanoid | 53:3d5a3d241a5e | 746 | /// For 24-bit register size: |
whismanoid | 53:3d5a3d241a5e | 747 | /// |
whismanoid | 53:3d5a3d241a5e | 748 | /// SPI 32-bit transfer |
whismanoid | 53:3d5a3d241a5e | 749 | /// |
whismanoid | 53:3d5a3d241a5e | 750 | /// SPI MOSI = 0aaa_aaaa_dddd_dddd_dddd_dddd_dddd_dddd |
whismanoid | 53:3d5a3d241a5e | 751 | /// |
whismanoid | 53:3d5a3d241a5e | 752 | /// SPI MISO = xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx |
whismanoid | 53:3d5a3d241a5e | 753 | /// |
whismanoid | 53:3d5a3d241a5e | 754 | /// @return 1 on success; 0 on failure |
whismanoid | 53:3d5a3d241a5e | 755 | uint8_t RegWrite(MAX11043_CMD_enum_t commandByte, uint32_t regData); |
whismanoid | 53:3d5a3d241a5e | 756 | |
whismanoid | 53:3d5a3d241a5e | 757 | // CODE GENERATOR: looks like this is a register access function because 'regAdd' |
whismanoid | 53:3d5a3d241a5e | 758 | // CODE GENERATOR: looks like this is a 'read' register access function |
whismanoid | 53:3d5a3d241a5e | 759 | // CODE GENERATOR: looks like this is a register access function because 'regAdd' |
whismanoid | 53:3d5a3d241a5e | 760 | // CODE GENERATOR: looks like this is a 'read' register access function: omit this function from test menu |
whismanoid | 53:3d5a3d241a5e | 761 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 762 | /// Read an 8-bit MAX11043 register |
whismanoid | 53:3d5a3d241a5e | 763 | /// |
whismanoid | 53:3d5a3d241a5e | 764 | /// CMD_1aaa_aaaa_REGISTER_READ bit is set 1 indicating a read operation. |
whismanoid | 53:3d5a3d241a5e | 765 | /// |
whismanoid | 53:3d5a3d241a5e | 766 | /// MAX11043 register length can be determined by function RegSize. |
whismanoid | 53:3d5a3d241a5e | 767 | /// |
whismanoid | 53:3d5a3d241a5e | 768 | /// For 8-bit register size: |
whismanoid | 53:3d5a3d241a5e | 769 | /// |
whismanoid | 53:3d5a3d241a5e | 770 | /// SPI 16-bit transfer |
whismanoid | 53:3d5a3d241a5e | 771 | /// |
whismanoid | 53:3d5a3d241a5e | 772 | /// SPI MOSI = 1aaa_aaaa_0000_0000 |
whismanoid | 53:3d5a3d241a5e | 773 | /// |
whismanoid | 53:3d5a3d241a5e | 774 | /// SPI MISO = xxxx_xxxx_dddd_dddd |
whismanoid | 53:3d5a3d241a5e | 775 | /// |
whismanoid | 53:3d5a3d241a5e | 776 | /// For 16-bit register size: |
whismanoid | 53:3d5a3d241a5e | 777 | /// |
whismanoid | 53:3d5a3d241a5e | 778 | /// SPI 24-bit or 32-bit transfer |
whismanoid | 53:3d5a3d241a5e | 779 | /// |
whismanoid | 53:3d5a3d241a5e | 780 | /// SPI MOSI = 1aaa_aaaa_0000_0000_0000_0000 |
whismanoid | 53:3d5a3d241a5e | 781 | /// |
whismanoid | 53:3d5a3d241a5e | 782 | /// SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd |
whismanoid | 53:3d5a3d241a5e | 783 | /// |
whismanoid | 53:3d5a3d241a5e | 784 | /// For 24-bit register size: |
whismanoid | 53:3d5a3d241a5e | 785 | /// |
whismanoid | 53:3d5a3d241a5e | 786 | /// SPI 32-bit transfer |
whismanoid | 53:3d5a3d241a5e | 787 | /// |
whismanoid | 53:3d5a3d241a5e | 788 | /// SPI MOSI = 1aaa_aaaa_0000_0000_0000_0000_0000_0000 |
whismanoid | 53:3d5a3d241a5e | 789 | /// |
whismanoid | 53:3d5a3d241a5e | 790 | /// SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd_dddd_dddd |
whismanoid | 53:3d5a3d241a5e | 791 | /// |
whismanoid | 53:3d5a3d241a5e | 792 | /// |
whismanoid | 53:3d5a3d241a5e | 793 | /// @return 1 on success; 0 on failure |
whismanoid | 53:3d5a3d241a5e | 794 | uint8_t RegRead(MAX11043_CMD_enum_t commandByte, uint32_t* ptrRegData); |
whismanoid | 53:3d5a3d241a5e | 795 | |
whismanoid | 53:3d5a3d241a5e | 796 | // CODE GENERATOR: looks like this is a register access function because 'regAdd' |
whismanoid | 53:3d5a3d241a5e | 797 | // CODE GENERATOR: looks like this is a 'size' register access function |
whismanoid | 53:3d5a3d241a5e | 798 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 799 | /// Return the size of a MAX11043 register |
whismanoid | 53:3d5a3d241a5e | 800 | /// |
whismanoid | 53:3d5a3d241a5e | 801 | /// @return 8 for 8-bit, 16 for 16-bit, 24 for 24-bit, else 0 for undefined register size |
whismanoid | 53:3d5a3d241a5e | 802 | uint8_t RegSize(MAX11043_CMD_enum_t commandByte); |
whismanoid | 53:3d5a3d241a5e | 803 | |
whismanoid | 53:3d5a3d241a5e | 804 | // CODE GENERATOR: looks like this is a register access function because 'regAdd' |
whismanoid | 53:3d5a3d241a5e | 805 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 806 | /// Return the address field of a MAX11043 register |
whismanoid | 53:3d5a3d241a5e | 807 | /// |
whismanoid | 53:3d5a3d241a5e | 808 | /// @return register address field as given in datasheet |
whismanoid | 53:3d5a3d241a5e | 809 | uint8_t RegAddrOfCommand(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 | // CODE GENERATOR: looks like this is a 'read' register access function |
whismanoid | 53:3d5a3d241a5e | 813 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 814 | /// Test whether a command byte is a register read command |
whismanoid | 53:3d5a3d241a5e | 815 | /// |
whismanoid | 53:3d5a3d241a5e | 816 | /// @return true if command byte is a register read command |
whismanoid | 53:3d5a3d241a5e | 817 | uint8_t IsRegReadCommand(MAX11043_CMD_enum_t commandByte); |
whismanoid | 53:3d5a3d241a5e | 818 | |
whismanoid | 53:3d5a3d241a5e | 819 | // CODE GENERATOR: looks like this is a register access function because 'regAdd' |
whismanoid | 53:3d5a3d241a5e | 820 | // CODE GENERATOR: looks like this is a 'name' register access function |
whismanoid | 53:3d5a3d241a5e | 821 | //---------------------------------------- |
whismanoid | 53:3d5a3d241a5e | 822 | /// Return the name of a MAX11043 register |
whismanoid | 53:3d5a3d241a5e | 823 | /// |
whismanoid | 53:3d5a3d241a5e | 824 | /// @return null-terminated constant C string containing register name or empty string |
whismanoid | 53:3d5a3d241a5e | 825 | const char* RegName(MAX11043_CMD_enum_t commandByte); |
whismanoid | 53:3d5a3d241a5e | 826 | |
whismanoid | 53:3d5a3d241a5e | 827 | }; // end of class MAX11043 |
whismanoid | 53:3d5a3d241a5e | 828 | |
whismanoid | 53:3d5a3d241a5e | 829 | #endif // __MAX11043_H__ |
whismanoid | 53:3d5a3d241a5e | 830 | |
whismanoid | 53:3d5a3d241a5e | 831 | // End of file |