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