Maxim Integrated MAX5719 20-bit, 0.05nV-sec DAC Test program running on MAX32625MBED. Control through USB Serial commands using a terminal emulator such as teraterm or putty.
Dependencies: MaximTinyTester CmdLine MAX5719 USBDevice
Test_Menu_MAX5719.cpp@28:bae17ff10fa7, 2021-06-08 (annotated)
- Committer:
- whismanoid
- Date:
- Tue Jun 08 17:44:53 2021 -0700
- Revision:
- 28:bae17ff10fa7
- Parent:
- 27:485b1b2f334c
- Child:
- 29:074e680ba5ea
cmdLine.parse_double_or_uint32 support DACCodeOfVoltage conversion to code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
whismanoid | 25:9d4012b0887f | 1 | // /******************************************************************************* |
whismanoid | 25:9d4012b0887f | 2 | // * Copyright (C) 2021 Maxim Integrated Products, Inc., All Rights Reserved. |
whismanoid | 25:9d4012b0887f | 3 | // * |
whismanoid | 25:9d4012b0887f | 4 | // * Permission is hereby granted, free of charge, to any person obtaining a |
whismanoid | 25:9d4012b0887f | 5 | // * copy of this software and associated documentation files (the "Software"), |
whismanoid | 25:9d4012b0887f | 6 | // * to deal in the Software without restriction, including without limitation |
whismanoid | 25:9d4012b0887f | 7 | // * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
whismanoid | 25:9d4012b0887f | 8 | // * and/or sell copies of the Software, and to permit persons to whom the |
whismanoid | 25:9d4012b0887f | 9 | // * Software is furnished to do so, subject to the following conditions: |
whismanoid | 25:9d4012b0887f | 10 | // * |
whismanoid | 25:9d4012b0887f | 11 | // * The above copyright notice and this permission notice shall be included |
whismanoid | 25:9d4012b0887f | 12 | // * in all copies or substantial portions of the Software. |
whismanoid | 25:9d4012b0887f | 13 | // * |
whismanoid | 25:9d4012b0887f | 14 | // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
whismanoid | 25:9d4012b0887f | 15 | // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
whismanoid | 25:9d4012b0887f | 16 | // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
whismanoid | 25:9d4012b0887f | 17 | // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
whismanoid | 25:9d4012b0887f | 18 | // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
whismanoid | 25:9d4012b0887f | 19 | // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
whismanoid | 25:9d4012b0887f | 20 | // * OTHER DEALINGS IN THE SOFTWARE. |
whismanoid | 25:9d4012b0887f | 21 | // * |
whismanoid | 25:9d4012b0887f | 22 | // * Except as contained in this notice, the name of Maxim Integrated |
whismanoid | 25:9d4012b0887f | 23 | // * Products, Inc. shall not be used except as stated in the Maxim Integrated |
whismanoid | 25:9d4012b0887f | 24 | // * Products, Inc. Branding Policy. |
whismanoid | 25:9d4012b0887f | 25 | // * |
whismanoid | 25:9d4012b0887f | 26 | // * The mere transfer of this software does not imply any licenses |
whismanoid | 25:9d4012b0887f | 27 | // * of trade secrets, proprietary technology, copyrights, patents, |
whismanoid | 25:9d4012b0887f | 28 | // * trademarks, maskwork rights, or any other form of intellectual |
whismanoid | 25:9d4012b0887f | 29 | // * property whatsoever. Maxim Integrated Products, Inc. retains all |
whismanoid | 25:9d4012b0887f | 30 | // * ownership rights. |
whismanoid | 25:9d4012b0887f | 31 | // ******************************************************************************* |
whismanoid | 25:9d4012b0887f | 32 | // */ |
whismanoid | 25:9d4012b0887f | 33 | // example code includes |
whismanoid | 25:9d4012b0887f | 34 | // standard include for target platform -- Platform_Include_Boilerplate |
whismanoid | 25:9d4012b0887f | 35 | #include "mbed.h" |
whismanoid | 25:9d4012b0887f | 36 | // Platforms: |
whismanoid | 25:9d4012b0887f | 37 | // - MAX32625MBED |
whismanoid | 25:9d4012b0887f | 38 | // - supports mbed-os-5.11, requires USBDevice library |
whismanoid | 25:9d4012b0887f | 39 | // - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/ |
whismanoid | 25:9d4012b0887f | 40 | // - remove max32630fthr library (if present) |
whismanoid | 25:9d4012b0887f | 41 | // - remove MAX32620FTHR library (if present) |
whismanoid | 25:9d4012b0887f | 42 | // - MAX32600MBED |
whismanoid | 25:9d4012b0887f | 43 | // - Please note the last supported version is Mbed OS 6.3. |
whismanoid | 25:9d4012b0887f | 44 | // - remove max32630fthr library (if present) |
whismanoid | 25:9d4012b0887f | 45 | // - remove MAX32620FTHR library (if present) |
whismanoid | 25:9d4012b0887f | 46 | // - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board. |
whismanoid | 25:9d4012b0887f | 47 | // - NUCLEO_F446RE |
whismanoid | 25:9d4012b0887f | 48 | // - remove USBDevice library |
whismanoid | 25:9d4012b0887f | 49 | // - remove max32630fthr library (if present) |
whismanoid | 25:9d4012b0887f | 50 | // - remove MAX32620FTHR library (if present) |
whismanoid | 25:9d4012b0887f | 51 | // - NUCLEO_F401RE |
whismanoid | 25:9d4012b0887f | 52 | // - remove USBDevice library |
whismanoid | 25:9d4012b0887f | 53 | // - remove max32630fthr library (if present) |
whismanoid | 25:9d4012b0887f | 54 | // - remove MAX32620FTHR library (if present) |
whismanoid | 25:9d4012b0887f | 55 | // - MAX32630FTHR |
whismanoid | 25:9d4012b0887f | 56 | // - #include "max32630fthr.h" |
whismanoid | 25:9d4012b0887f | 57 | // - add http://developer.mbed.org/teams/MaximIntegrated/code/max32630fthr/ |
whismanoid | 25:9d4012b0887f | 58 | // - remove MAX32620FTHR library (if present) |
whismanoid | 25:9d4012b0887f | 59 | // - MAX32620FTHR |
whismanoid | 25:9d4012b0887f | 60 | // - #include "MAX32620FTHR.h" |
whismanoid | 25:9d4012b0887f | 61 | // - remove max32630fthr library (if present) |
whismanoid | 25:9d4012b0887f | 62 | // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/ |
whismanoid | 25:9d4012b0887f | 63 | // - not tested yet |
whismanoid | 25:9d4012b0887f | 64 | // - MAX32625PICO |
whismanoid | 25:9d4012b0887f | 65 | // - #include "max32625pico.h" |
whismanoid | 25:9d4012b0887f | 66 | // - add https://os.mbed.com/users/switches/code/max32625pico/ |
whismanoid | 25:9d4012b0887f | 67 | // - remove max32630fthr library (if present) |
whismanoid | 25:9d4012b0887f | 68 | // - remove MAX32620FTHR library (if present) |
whismanoid | 25:9d4012b0887f | 69 | // - not tested yet |
whismanoid | 25:9d4012b0887f | 70 | // - see https://os.mbed.com/users/switches/code/max32625pico/ |
whismanoid | 25:9d4012b0887f | 71 | // - see https://os.mbed.com/users/switches/code/PICO_board_demo/ |
whismanoid | 25:9d4012b0887f | 72 | // - see https://os.mbed.com/users/switches/code/PICO_USB_I2C_SPI/ |
whismanoid | 25:9d4012b0887f | 73 | // - see https://os.mbed.com/users/switches/code/SerialInterface/ |
whismanoid | 25:9d4012b0887f | 74 | // - Note: To load the MAX32625PICO firmware, hold the button while |
whismanoid | 25:9d4012b0887f | 75 | // connecting the USB cable, then copy firmware bin file |
whismanoid | 25:9d4012b0887f | 76 | // to the MAINTENANCE drive. |
whismanoid | 25:9d4012b0887f | 77 | // - see https://os.mbed.com/platforms/MAX32625PICO/ |
whismanoid | 25:9d4012b0887f | 78 | // - see https://os.mbed.com/teams/MaximIntegrated/wiki/MAX32625PICO-Firmware-Updates |
whismanoid | 25:9d4012b0887f | 79 | // |
whismanoid | 25:9d4012b0887f | 80 | // end Platform_Include_Boilerplate |
whismanoid | 25:9d4012b0887f | 81 | #include "MAX5719.h" |
whismanoid | 25:9d4012b0887f | 82 | #include "CmdLine.h" |
whismanoid | 25:9d4012b0887f | 83 | #include "MaximTinyTester.h" |
whismanoid | 25:9d4012b0887f | 84 | |
whismanoid | 25:9d4012b0887f | 85 | #include "MAX5719.h" |
whismanoid | 25:9d4012b0887f | 86 | extern MAX5719 g_MAX5719_device; // defined in main.cpp |
whismanoid | 25:9d4012b0887f | 87 | |
whismanoid | 25:9d4012b0887f | 88 | |
whismanoid | 25:9d4012b0887f | 89 | |
whismanoid | 25:9d4012b0887f | 90 | void MAX5719_menu_help(CmdLine & cmdLine) |
whismanoid | 25:9d4012b0887f | 91 | { |
whismanoid | 25:9d4012b0887f | 92 | cmdLine.serial().printf("\r\n ! -- Init"); |
whismanoid | 25:9d4012b0887f | 93 | cmdLine.serial().printf("\r\n A code=? -- CODE"); |
whismanoid | 25:9d4012b0887f | 94 | cmdLine.serial().printf("\r\n B -- LOAD"); |
whismanoid | 25:9d4012b0887f | 95 | cmdLine.serial().printf("\r\n C code=? -- CODE_LOAD"); |
whismanoid | 25:9d4012b0887f | 96 | // |
whismanoid | 25:9d4012b0887f | 97 | cmdLine.serial().printf("\r\n @ -- print MAX5719 configuration"); |
whismanoid | 25:9d4012b0887f | 98 | |
whismanoid | 25:9d4012b0887f | 99 | // |
whismanoid | 25:9d4012b0887f | 100 | // case 'G'..'Z','g'..'z' are reserved for GPIO commands |
whismanoid | 25:9d4012b0887f | 101 | // case 'A'..'F','a'..'f' may be available if not claimed by bitstream commands |
whismanoid | 25:9d4012b0887f | 102 | cmdLine.serial().printf("\r\n L -- LDACb output LH high LL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict |
whismanoid | 25:9d4012b0887f | 103 | |
whismanoid | 25:9d4012b0887f | 104 | // |
whismanoid | 25:9d4012b0887f | 105 | } |
whismanoid | 25:9d4012b0887f | 106 | |
whismanoid | 25:9d4012b0887f | 107 | bool MAX5719_menu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 25:9d4012b0887f | 108 | { |
whismanoid | 25:9d4012b0887f | 109 | |
whismanoid | 25:9d4012b0887f | 110 | |
whismanoid | 25:9d4012b0887f | 111 | // parse argument int32_t DACCode |
whismanoid | 25:9d4012b0887f | 112 | int32_t DACCode = g_MAX5719_device.DACCode; // default to global property value |
whismanoid | 25:9d4012b0887f | 113 | if (cmdLine.parse_int32_dec("DACCode", DACCode)) |
whismanoid | 25:9d4012b0887f | 114 | { |
whismanoid | 25:9d4012b0887f | 115 | g_MAX5719_device.DACCode = DACCode; // update global property value |
whismanoid | 25:9d4012b0887f | 116 | } |
whismanoid | 28:bae17ff10fa7 | 117 | #if 1 |
whismanoid | 28:bae17ff10fa7 | 118 | // "code" is an alias for argument "DACCode"; support DACCodeOfVoltage |
whismanoid | 28:bae17ff10fa7 | 119 | double voltageV; // support DACCodeOfVoltage |
whismanoid | 28:bae17ff10fa7 | 120 | switch (cmdLine.parse_double_or_int32("code", voltageV, DACCode)) |
whismanoid | 28:bae17ff10fa7 | 121 | { |
whismanoid | 28:bae17ff10fa7 | 122 | case 2: // 2: parsed as double |
whismanoid | 28:bae17ff10fa7 | 123 | // parse_double_or_uint32 returns 1: parsed as integer; 2: parsed as double |
whismanoid | 28:bae17ff10fa7 | 124 | DACCode = g_MAX5719_device.DACCodeOfVoltage((double)voltageV); |
whismanoid | 28:bae17ff10fa7 | 125 | g_MAX5719_device.DACCode = DACCode; // update global property value |
whismanoid | 28:bae17ff10fa7 | 126 | cmdLine.serial().printf("\r\nDACCodeOfVoltage(%1.6fV)=0x%6.6X\r\n", voltageV, g_MAX5719_device.DACCode); |
whismanoid | 28:bae17ff10fa7 | 127 | break; |
whismanoid | 28:bae17ff10fa7 | 128 | case 1: // 1: parsed as integer |
whismanoid | 28:bae17ff10fa7 | 129 | g_MAX5719_device.DACCode = DACCode; // update global property value |
whismanoid | 28:bae17ff10fa7 | 130 | break; |
whismanoid | 28:bae17ff10fa7 | 131 | } |
whismanoid | 28:bae17ff10fa7 | 132 | #else |
whismanoid | 25:9d4012b0887f | 133 | // "code" is an alias for argument "DACCode" |
whismanoid | 25:9d4012b0887f | 134 | if (cmdLine.parse_int32_dec("code", DACCode)) |
whismanoid | 25:9d4012b0887f | 135 | { |
whismanoid | 25:9d4012b0887f | 136 | g_MAX5719_device.DACCode = DACCode; // update global property value |
whismanoid | 25:9d4012b0887f | 137 | } |
whismanoid | 28:bae17ff10fa7 | 138 | #endif |
whismanoid | 25:9d4012b0887f | 139 | |
whismanoid | 25:9d4012b0887f | 140 | // parse argument double VRef |
whismanoid | 25:9d4012b0887f | 141 | double VRef = g_MAX5719_device.VRef; // default to global property value |
whismanoid | 25:9d4012b0887f | 142 | if (cmdLine.parse_double("VRef", VRef)) |
whismanoid | 25:9d4012b0887f | 143 | { |
whismanoid | 25:9d4012b0887f | 144 | g_MAX5719_device.VRef = VRef; // update global property value |
whismanoid | 25:9d4012b0887f | 145 | } |
whismanoid | 25:9d4012b0887f | 146 | |
whismanoid | 25:9d4012b0887f | 147 | switch (cmdLine[0]) |
whismanoid | 25:9d4012b0887f | 148 | { |
whismanoid | 25:9d4012b0887f | 149 | case '@': |
whismanoid | 25:9d4012b0887f | 150 | { |
whismanoid | 25:9d4012b0887f | 151 | cmdLine.serial().printf("VRef = "); |
whismanoid | 25:9d4012b0887f | 152 | cmdLine.serial().printf("%1.6f\r\n", g_MAX5719_device.VRef); |
whismanoid | 25:9d4012b0887f | 153 | cmdLine.serial().printf("DACCode = "); |
whismanoid | 25:9d4012b0887f | 154 | cmdLine.serial().printf("%ld = 0x%8.8lx\r\n", g_MAX5719_device.DACCode, g_MAX5719_device.DACCode); |
whismanoid | 25:9d4012b0887f | 155 | return true; // command handled by MAX5719 |
whismanoid | 25:9d4012b0887f | 156 | break; |
whismanoid | 25:9d4012b0887f | 157 | } |
whismanoid | 25:9d4012b0887f | 158 | // case 'G'..'Z','g'..'z' are reserved for GPIO commands |
whismanoid | 25:9d4012b0887f | 159 | // case 'A'..'F','a'..'f' may be available if not claimed by bitstream commands |
whismanoid | 25:9d4012b0887f | 160 | case 'L': |
whismanoid | 25:9d4012b0887f | 161 | { |
whismanoid | 25:9d4012b0887f | 162 | switch (cmdLine[1]) |
whismanoid | 25:9d4012b0887f | 163 | { |
whismanoid | 25:9d4012b0887f | 164 | case 'H': |
whismanoid | 25:9d4012b0887f | 165 | { |
whismanoid | 25:9d4012b0887f | 166 | g_MAX5719_device.LDACboutputValue(1); |
whismanoid | 25:9d4012b0887f | 167 | break; |
whismanoid | 25:9d4012b0887f | 168 | } |
whismanoid | 25:9d4012b0887f | 169 | case 'L': |
whismanoid | 25:9d4012b0887f | 170 | { |
whismanoid | 25:9d4012b0887f | 171 | g_MAX5719_device.LDACboutputValue(0); |
whismanoid | 25:9d4012b0887f | 172 | break; |
whismanoid | 25:9d4012b0887f | 173 | } |
whismanoid | 25:9d4012b0887f | 174 | } |
whismanoid | 25:9d4012b0887f | 175 | return true; // command handled by MAX5719 |
whismanoid | 25:9d4012b0887f | 176 | break; |
whismanoid | 25:9d4012b0887f | 177 | } |
whismanoid | 25:9d4012b0887f | 178 | // case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands |
whismanoid | 25:9d4012b0887f | 179 | case '!': |
whismanoid | 25:9d4012b0887f | 180 | { |
whismanoid | 25:9d4012b0887f | 181 | // test menu command '!' handler: |
whismanoid | 25:9d4012b0887f | 182 | // helpString='! -- Init' |
whismanoid | 25:9d4012b0887f | 183 | // CMD_='None' |
whismanoid | 25:9d4012b0887f | 184 | // CommandName='Init' |
whismanoid | 25:9d4012b0887f | 185 | // CommandParamIn='void' |
whismanoid | 25:9d4012b0887f | 186 | // CommandReturnType='void' |
whismanoid | 25:9d4012b0887f | 187 | // @Pre='' |
whismanoid | 25:9d4012b0887f | 188 | // @Param[in]='' |
whismanoid | 25:9d4012b0887f | 189 | // @Param[out]='' |
whismanoid | 25:9d4012b0887f | 190 | // @Post='' |
whismanoid | 25:9d4012b0887f | 191 | // displayPost='' |
whismanoid | 25:9d4012b0887f | 192 | // @Return='' |
whismanoid | 25:9d4012b0887f | 193 | // @Test='@test group CODE_LOAD // Verify function CODE_LOAD vs platform AIN0 analog input (enabled by default)' |
whismanoid | 25:9d4012b0887f | 194 | // @Test='@test group CODE_LOAD tinyTester.print("VRef = 4.096 MAX5719 20-bit LSB = 0.000004V = 3.90625uV")' |
whismanoid | 25:9d4012b0887f | 195 | // @Test='@test group CODE_LOAD tinyTester.print("Wire MAX5719 OUT to platform AIN0 for analog loopback tests...")' |
whismanoid | 25:9d4012b0887f | 196 | // @Test='@test group CODE_LOAD VRef = 4.096' |
whismanoid | 25:9d4012b0887f | 197 | // @Test='@test group CODE_LOAD tinyTester.blink_time_msec = 75 // default 75 resume hardware self test' |
whismanoid | 25:9d4012b0887f | 198 | // @Test='@test group CODE_LOAD tinyTester.settle_time_msec = 500' |
whismanoid | 25:9d4012b0887f | 199 | // @Test='@test Init()' |
whismanoid | 25:9d4012b0887f | 200 | // @Test='@test VRef expect 4.096 // Nominal Full-Scale Voltage Reference' |
whismanoid | 25:9d4012b0887f | 201 | // @Test='@test group CODE_LOAD tinyTester.err_threshold = 0.050' |
whismanoid | 25:9d4012b0887f | 202 | // @Test='@test group CODE_LOAD tinyTester.print("0x000000 = 0.000V")' |
whismanoid | 25:9d4012b0887f | 203 | // @Test='@test group CODE_LOAD CODE_LOAD(0x000000) // 0.000V' |
whismanoid | 25:9d4012b0887f | 204 | // @Test='@test group CODE_LOAD tinyTester.Wait_Output_Settling()' |
whismanoid | 25:9d4012b0887f | 205 | // @Test='@test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(0.000000)' |
whismanoid | 27:485b1b2f334c | 206 | // @Test='/*mbed:@test group CODE_LOAD tinyTester.AnalogIn1_Read_Report_voltageV(); // remove unwanted loading on AIN0 */' |
whismanoid | 25:9d4012b0887f | 207 | // @Test='@test group CODE_LOAD tinyTester.print("0x01f400 = 0.500V")' |
whismanoid | 25:9d4012b0887f | 208 | // @Test='@test group CODE_LOAD CODE_LOAD(0x01f400) // 0.500V' |
whismanoid | 25:9d4012b0887f | 209 | // @Test='@test group CODE_LOAD tinyTester.Wait_Output_Settling()' |
whismanoid | 25:9d4012b0887f | 210 | // @Test='@test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(0.500000)' |
whismanoid | 27:485b1b2f334c | 211 | // @Test='/*mbed:@test group CODE_LOAD tinyTester.AnalogIn1_Read_Report_voltageV(); // remove unwanted loading on AIN0 */' |
whismanoid | 25:9d4012b0887f | 212 | // @Test='@test group CODE_LOAD tinyTester.print("0x03e800 = 1.000V")' |
whismanoid | 25:9d4012b0887f | 213 | // @Test='@test group CODE_LOAD CODE_LOAD(0x03e800) // 1.000V' |
whismanoid | 25:9d4012b0887f | 214 | // @Test='@test group CODE_LOAD tinyTester.Wait_Output_Settling()' |
whismanoid | 25:9d4012b0887f | 215 | // @Test='@test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(1.000000)' |
whismanoid | 27:485b1b2f334c | 216 | // @Test='/*mbed:@test group CODE_LOAD tinyTester.AnalogIn1_Read_Report_voltageV(); // remove unwanted loading on AIN0 */' |
whismanoid | 26:ec719cd9a579 | 217 | // @Test='@test group CODE_LOAD tinyTester.err_threshold = /*Arduino:0.050*/ /*mbed:0.075*/ /*eabi:0.050*/' |
whismanoid | 25:9d4012b0887f | 218 | // @Test='@test group CODE_LOAD tinyTester.print("0x05dc00 = 1.500V")' |
whismanoid | 25:9d4012b0887f | 219 | // @Test='@test group CODE_LOAD CODE_LOAD(0x05dc00) // 1.500V' |
whismanoid | 25:9d4012b0887f | 220 | // @Test='@test group CODE_LOAD tinyTester.Wait_Output_Settling()' |
whismanoid | 25:9d4012b0887f | 221 | // @Test='@test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(1.500000)' |
whismanoid | 27:485b1b2f334c | 222 | // @Test='/*mbed:@test group CODE_LOAD tinyTester.AnalogIn1_Read_Report_voltageV(); // remove unwanted loading on AIN0 */' |
whismanoid | 26:ec719cd9a579 | 223 | // @Test='@test group CODE_LOAD tinyTester.err_threshold = /*Arduino:0.050*/ /*mbed:0.100*/ /*eabi:0.050*/' |
whismanoid | 25:9d4012b0887f | 224 | // @Test='@test group CODE_LOAD tinyTester.print("0x07d000 = 2.000V")' |
whismanoid | 25:9d4012b0887f | 225 | // @Test='@test group CODE_LOAD CODE_LOAD(0x07d000) // 2.000V' |
whismanoid | 25:9d4012b0887f | 226 | // @Test='@test group CODE_LOAD tinyTester.Wait_Output_Settling()' |
whismanoid | 25:9d4012b0887f | 227 | // @Test='@test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(2.000000)' |
whismanoid | 27:485b1b2f334c | 228 | // @Test='/*mbed:@test group CODE_LOAD tinyTester.AnalogIn1_Read_Report_voltageV(); // remove unwanted loading on AIN0 */' |
whismanoid | 26:ec719cd9a579 | 229 | // @Test='@test group CODE_LOAD tinyTester.err_threshold = /*Arduino:0.050*/ /*mbed:0.150*/ /*eabi:0.050*/' |
whismanoid | 25:9d4012b0887f | 230 | // @Test='@test group CODE_LOAD tinyTester.print("0x09c400 = 2.500V")' |
whismanoid | 25:9d4012b0887f | 231 | // @Test='@test group CODE_LOAD CODE_LOAD(0x09c400) // 2.500V' |
whismanoid | 25:9d4012b0887f | 232 | // @Test='@test group CODE_LOAD tinyTester.Wait_Output_Settling()' |
whismanoid | 25:9d4012b0887f | 233 | // @Test='@test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(2.500000)' |
whismanoid | 27:485b1b2f334c | 234 | // @Test='/*mbed:@test group CODE_LOAD tinyTester.AnalogIn1_Read_Report_voltageV(); // remove unwanted loading on AIN0 */' |
whismanoid | 26:ec719cd9a579 | 235 | // @Test='@test group CODE_LOAD tinyTester.err_threshold = /*Arduino:0.050*/ /*mbed:0.200*/ /*eabi:0.050*/' |
whismanoid | 25:9d4012b0887f | 236 | // @Test='@test group CODE_LOAD tinyTester.print("0x0bb800 = 3.000V")' |
whismanoid | 25:9d4012b0887f | 237 | // @Test='@test group CODE_LOAD CODE_LOAD(0x0bb800) // 3.000V' |
whismanoid | 25:9d4012b0887f | 238 | // @Test='@test group CODE_LOAD tinyTester.Wait_Output_Settling()' |
whismanoid | 25:9d4012b0887f | 239 | // @Test='@test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(3.000000)' |
whismanoid | 27:485b1b2f334c | 240 | // @Test='/*mbed:@test group CODE_LOAD tinyTester.AnalogIn1_Read_Report_voltageV(); // remove unwanted loading on AIN0 */' |
whismanoid | 26:ec719cd9a579 | 241 | // @Test='@test group CODE_LOAD tinyTester.err_threshold = /*Arduino:0.075*/ /*mbed:0.250*/ /*eabi:0.050*/' |
whismanoid | 25:9d4012b0887f | 242 | // @Test='@test group CODE_LOAD tinyTester.print("0x0dac00 = 3.500V")' |
whismanoid | 25:9d4012b0887f | 243 | // @Test='@test group CODE_LOAD CODE_LOAD(0x0dac00) // 3.500V' |
whismanoid | 25:9d4012b0887f | 244 | // @Test='@test group CODE_LOAD tinyTester.Wait_Output_Settling()' |
whismanoid | 25:9d4012b0887f | 245 | // @Test='@test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(3.500000)' |
whismanoid | 27:485b1b2f334c | 246 | // @Test='/*mbed:@test group CODE_LOAD tinyTester.AnalogIn1_Read_Report_voltageV(); // remove unwanted loading on AIN0 */' |
whismanoid | 26:ec719cd9a579 | 247 | // @Test='@test group CODE_LOAD tinyTester.err_threshold = /*Arduino:0.075*/ /*mbed:0.500*/ /*eabi:0.050*/' |
whismanoid | 25:9d4012b0887f | 248 | // @Test='@test group CODE_LOAD tinyTester.print("0x0fa000 = 4.000V")' |
whismanoid | 25:9d4012b0887f | 249 | // @Test='@test group CODE_LOAD CODE_LOAD(0x0fa000) // 4.000V' |
whismanoid | 25:9d4012b0887f | 250 | // @Test='@test group CODE_LOAD tinyTester.Wait_Output_Settling()' |
whismanoid | 25:9d4012b0887f | 251 | // @Test='@test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(4.000000)' |
whismanoid | 27:485b1b2f334c | 252 | // @Test='/*mbed:@test group CODE_LOAD tinyTester.AnalogIn1_Read_Report_voltageV(); // remove unwanted loading on AIN0 */' |
whismanoid | 26:ec719cd9a579 | 253 | // @Test='@test group CODE_LOAD tinyTester.err_threshold = /*Arduino:0.100*/ /*mbed:0.750*/ /*eabi:0.050*/' |
whismanoid | 25:9d4012b0887f | 254 | // @Test='@test group CODE_LOAD tinyTester.print("0x0fffff = 4.095V")' |
whismanoid | 25:9d4012b0887f | 255 | // @Test='@test group CODE_LOAD CODE_LOAD(0x0fffff) // 4.095V' |
whismanoid | 25:9d4012b0887f | 256 | // @Test='@test group CODE_LOAD tinyTester.Wait_Output_Settling()' |
whismanoid | 25:9d4012b0887f | 257 | // @Test='@test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(4.095000)' |
whismanoid | 27:485b1b2f334c | 258 | // @Test='/*mbed:@test group CODE_LOAD tinyTester.AnalogIn1_Read_Report_voltageV(); // remove unwanted loading on AIN0 */' |
whismanoid | 26:ec719cd9a579 | 259 | // @Test='@test group CODE_LOAD tinyTester.err_threshold = /*Arduino:0.050*/ /*mbed:0.200*/ /*eabi:0.050*/' |
whismanoid | 25:9d4012b0887f | 260 | // @Test='@test group CODE_LOAD tinyTester.print("0x080000 // 2.048V")' |
whismanoid | 25:9d4012b0887f | 261 | // @Test='@test group CODE_LOAD CODE_LOAD(0x080000) // 2.048V' |
whismanoid | 25:9d4012b0887f | 262 | // @Test='@test group CODE_LOAD tinyTester.Wait_Output_Settling()' |
whismanoid | 25:9d4012b0887f | 263 | // @Test='@test group CODE_LOAD tinyTester.AnalogIn0_Read_Expect_voltageV(2.048000)' |
whismanoid | 27:485b1b2f334c | 264 | // @Test='/*mbed:@test group CODE_LOAD tinyTester.AnalogIn1_Read_Report_voltageV(); // remove unwanted loading on AIN0 */' |
whismanoid | 25:9d4012b0887f | 265 | cmdLine.serial().printf("Init"); |
whismanoid | 25:9d4012b0887f | 266 | // call function Init |
whismanoid | 25:9d4012b0887f | 267 | g_MAX5719_device.Init(); |
whismanoid | 25:9d4012b0887f | 268 | return true; // command handled by MAX5719 |
whismanoid | 25:9d4012b0887f | 269 | } // end case '!' |
whismanoid | 25:9d4012b0887f | 270 | break; |
whismanoid | 25:9d4012b0887f | 271 | case 'A': |
whismanoid | 25:9d4012b0887f | 272 | { |
whismanoid | 25:9d4012b0887f | 273 | // test menu command 'A' handler: |
whismanoid | 25:9d4012b0887f | 274 | // helpString='A code=? -- CODE' |
whismanoid | 25:9d4012b0887f | 275 | // CMD_='None' |
whismanoid | 25:9d4012b0887f | 276 | // CommandName='CODE' |
whismanoid | 25:9d4012b0887f | 277 | // CommandParamIn='uint32_t dacCodeLsbs' |
whismanoid | 25:9d4012b0887f | 278 | // CommandReturnType='uint8_t' |
whismanoid | 25:9d4012b0887f | 279 | // @Pre='' |
whismanoid | 25:9d4012b0887f | 280 | // @Param[in]='' |
whismanoid | 25:9d4012b0887f | 281 | // @Param[out]='' |
whismanoid | 25:9d4012b0887f | 282 | // @Post='' |
whismanoid | 25:9d4012b0887f | 283 | // displayPost='' |
whismanoid | 25:9d4012b0887f | 284 | // @Return='@return 1 on success; 0 on failure' |
whismanoid | 25:9d4012b0887f | 285 | // parse argument list |
whismanoid | 25:9d4012b0887f | 286 | // parse argument uint32_t dacCodeLsbs |
whismanoid | 25:9d4012b0887f | 287 | uint32_t dacCodeLsbs = 0; // --- g_MAX5719_device.__WARNING_no_match_for_argname_dacCodeLsbs_in_MAX5719_device_t__; // default to global property value |
whismanoid | 25:9d4012b0887f | 288 | if (cmdLine.parse_uint32_dec("dacCodeLsbs", dacCodeLsbs)) |
whismanoid | 25:9d4012b0887f | 289 | { |
whismanoid | 25:9d4012b0887f | 290 | // g_MAX5719_device.__WARNING_no_match_for_argname_dacCodeLsbs_in_MAX5719_device_t__ = dacCodeLsbs; // update global property value |
whismanoid | 25:9d4012b0887f | 291 | } |
whismanoid | 28:bae17ff10fa7 | 292 | #if 1 |
whismanoid | 28:bae17ff10fa7 | 293 | // "code" is an alias for argument "dacCodeLsbs"; support DACCodeOfVoltage |
whismanoid | 28:bae17ff10fa7 | 294 | double voltageV; // support DACCodeOfVoltage |
whismanoid | 28:bae17ff10fa7 | 295 | switch (cmdLine.parse_double_or_uint32("code", voltageV, dacCodeLsbs)) |
whismanoid | 28:bae17ff10fa7 | 296 | { |
whismanoid | 28:bae17ff10fa7 | 297 | case 2: // 2: parsed as double |
whismanoid | 28:bae17ff10fa7 | 298 | // parse_double_or_uint32 returns 1: parsed as integer; 2: parsed as double |
whismanoid | 28:bae17ff10fa7 | 299 | dacCodeLsbs = g_MAX5719_device.DACCodeOfVoltage((double)voltageV); |
whismanoid | 28:bae17ff10fa7 | 300 | // g_MAX5719_device.DACCode = DACCode; // update global property value |
whismanoid | 28:bae17ff10fa7 | 301 | cmdLine.serial().printf("\r\nDACCodeOfVoltage(%1.6fV)=0x%6.6X\r\n", voltageV, dacCodeLsbs); |
whismanoid | 28:bae17ff10fa7 | 302 | break; |
whismanoid | 28:bae17ff10fa7 | 303 | case 1: // 1: parsed as integer |
whismanoid | 28:bae17ff10fa7 | 304 | // g_MAX5719_device.DACCode = DACCode; // update global property value |
whismanoid | 28:bae17ff10fa7 | 305 | break; |
whismanoid | 28:bae17ff10fa7 | 306 | } |
whismanoid | 28:bae17ff10fa7 | 307 | #else |
whismanoid | 25:9d4012b0887f | 308 | // "code" is an alias for argument "dacCodeLsbs" |
whismanoid | 25:9d4012b0887f | 309 | if (cmdLine.parse_uint32_dec("code", dacCodeLsbs)) |
whismanoid | 25:9d4012b0887f | 310 | { |
whismanoid | 25:9d4012b0887f | 311 | // g_MAX5719_device.__WARNING_no_match_for_argname_dacCodeLsbs_in_MAX5719_device_t__ = dacCodeLsbs; // update global property value |
whismanoid | 25:9d4012b0887f | 312 | } |
whismanoid | 28:bae17ff10fa7 | 313 | #endif |
whismanoid | 25:9d4012b0887f | 314 | // print arguments |
whismanoid | 25:9d4012b0887f | 315 | cmdLine.serial().printf("CODE"); |
whismanoid | 25:9d4012b0887f | 316 | cmdLine.serial().printf(" dacCodeLsbs=%ld", dacCodeLsbs); |
whismanoid | 25:9d4012b0887f | 317 | cmdLine.serial().printf("\r\n"); |
whismanoid | 25:9d4012b0887f | 318 | // call function CODE(dacCodeLsbs) |
whismanoid | 25:9d4012b0887f | 319 | uint8_t result = g_MAX5719_device.CODE(dacCodeLsbs); |
whismanoid | 25:9d4012b0887f | 320 | cmdLine.serial().printf(" =%d\r\n", result); |
whismanoid | 25:9d4012b0887f | 321 | return true; // command handled by MAX5719 |
whismanoid | 25:9d4012b0887f | 322 | } // end case 'A' |
whismanoid | 25:9d4012b0887f | 323 | break; |
whismanoid | 25:9d4012b0887f | 324 | case 'B': |
whismanoid | 25:9d4012b0887f | 325 | { |
whismanoid | 25:9d4012b0887f | 326 | // test menu command 'B' handler: |
whismanoid | 25:9d4012b0887f | 327 | // helpString='B -- LOAD' |
whismanoid | 25:9d4012b0887f | 328 | // CMD_='None' |
whismanoid | 25:9d4012b0887f | 329 | // CommandName='LOAD' |
whismanoid | 25:9d4012b0887f | 330 | // CommandParamIn='void' |
whismanoid | 25:9d4012b0887f | 331 | // CommandReturnType='uint8_t' |
whismanoid | 25:9d4012b0887f | 332 | // @Pre='' |
whismanoid | 25:9d4012b0887f | 333 | // @Param[in]='' |
whismanoid | 25:9d4012b0887f | 334 | // @Param[out]='' |
whismanoid | 25:9d4012b0887f | 335 | // @Post='' |
whismanoid | 25:9d4012b0887f | 336 | // displayPost='' |
whismanoid | 25:9d4012b0887f | 337 | // @Return='@return 1 on success; 0 on failure' |
whismanoid | 25:9d4012b0887f | 338 | cmdLine.serial().printf("LOAD"); |
whismanoid | 25:9d4012b0887f | 339 | // call function LOAD |
whismanoid | 25:9d4012b0887f | 340 | uint8_t result = g_MAX5719_device.LOAD(); |
whismanoid | 25:9d4012b0887f | 341 | cmdLine.serial().printf(" =%d\r\n", result); |
whismanoid | 25:9d4012b0887f | 342 | return true; // command handled by MAX5719 |
whismanoid | 25:9d4012b0887f | 343 | } // end case 'B' |
whismanoid | 25:9d4012b0887f | 344 | break; |
whismanoid | 25:9d4012b0887f | 345 | case 'C': |
whismanoid | 25:9d4012b0887f | 346 | { |
whismanoid | 25:9d4012b0887f | 347 | // test menu command 'C' handler: |
whismanoid | 25:9d4012b0887f | 348 | // helpString='C code=? -- CODE_LOAD' |
whismanoid | 25:9d4012b0887f | 349 | // CMD_='None' |
whismanoid | 25:9d4012b0887f | 350 | // CommandName='CODE_LOAD' |
whismanoid | 25:9d4012b0887f | 351 | // CommandParamIn='uint32_t dacCodeLsbs' |
whismanoid | 25:9d4012b0887f | 352 | // CommandReturnType='uint8_t' |
whismanoid | 25:9d4012b0887f | 353 | // @Pre='' |
whismanoid | 25:9d4012b0887f | 354 | // @Param[in]='' |
whismanoid | 25:9d4012b0887f | 355 | // @Param[out]='' |
whismanoid | 25:9d4012b0887f | 356 | // @Post='' |
whismanoid | 25:9d4012b0887f | 357 | // displayPost='' |
whismanoid | 25:9d4012b0887f | 358 | // @Return='@return 1 on success; 0 on failure' |
whismanoid | 25:9d4012b0887f | 359 | // parse argument list |
whismanoid | 25:9d4012b0887f | 360 | // parse argument uint32_t dacCodeLsbs |
whismanoid | 25:9d4012b0887f | 361 | uint32_t dacCodeLsbs = 0; // --- g_MAX5719_device.__WARNING_no_match_for_argname_dacCodeLsbs_in_MAX5719_device_t__; // default to global property value |
whismanoid | 25:9d4012b0887f | 362 | if (cmdLine.parse_uint32_dec("dacCodeLsbs", dacCodeLsbs)) |
whismanoid | 25:9d4012b0887f | 363 | { |
whismanoid | 25:9d4012b0887f | 364 | // g_MAX5719_device.__WARNING_no_match_for_argname_dacCodeLsbs_in_MAX5719_device_t__ = dacCodeLsbs; // update global property value |
whismanoid | 25:9d4012b0887f | 365 | } |
whismanoid | 28:bae17ff10fa7 | 366 | #if 1 |
whismanoid | 28:bae17ff10fa7 | 367 | // "code" is an alias for argument "dacCodeLsbs"; support DACCodeOfVoltage |
whismanoid | 28:bae17ff10fa7 | 368 | double voltageV; // support DACCodeOfVoltage |
whismanoid | 28:bae17ff10fa7 | 369 | switch (cmdLine.parse_double_or_uint32("code", voltageV, dacCodeLsbs)) |
whismanoid | 28:bae17ff10fa7 | 370 | { |
whismanoid | 28:bae17ff10fa7 | 371 | case 2: // 2: parsed as double |
whismanoid | 28:bae17ff10fa7 | 372 | // parse_double_or_uint32 returns 1: parsed as integer; 2: parsed as double |
whismanoid | 28:bae17ff10fa7 | 373 | dacCodeLsbs = g_MAX5719_device.DACCodeOfVoltage((double)voltageV); |
whismanoid | 28:bae17ff10fa7 | 374 | // g_MAX5719_device.DACCode = DACCode; // update global property value |
whismanoid | 28:bae17ff10fa7 | 375 | cmdLine.serial().printf("\r\nDACCodeOfVoltage(%1.6fV)=0x%6.6X\r\n", voltageV, dacCodeLsbs); |
whismanoid | 28:bae17ff10fa7 | 376 | break; |
whismanoid | 28:bae17ff10fa7 | 377 | case 1: // 1: parsed as integer |
whismanoid | 28:bae17ff10fa7 | 378 | // g_MAX5719_device.DACCode = DACCode; // update global property value |
whismanoid | 28:bae17ff10fa7 | 379 | break; |
whismanoid | 28:bae17ff10fa7 | 380 | } |
whismanoid | 28:bae17ff10fa7 | 381 | #else |
whismanoid | 25:9d4012b0887f | 382 | // "code" is an alias for argument "dacCodeLsbs" |
whismanoid | 25:9d4012b0887f | 383 | if (cmdLine.parse_uint32_dec("code", dacCodeLsbs)) |
whismanoid | 25:9d4012b0887f | 384 | { |
whismanoid | 25:9d4012b0887f | 385 | // g_MAX5719_device.__WARNING_no_match_for_argname_dacCodeLsbs_in_MAX5719_device_t__ = dacCodeLsbs; // update global property value |
whismanoid | 25:9d4012b0887f | 386 | } |
whismanoid | 28:bae17ff10fa7 | 387 | #endif |
whismanoid | 25:9d4012b0887f | 388 | // print arguments |
whismanoid | 25:9d4012b0887f | 389 | cmdLine.serial().printf("CODE_LOAD"); |
whismanoid | 25:9d4012b0887f | 390 | cmdLine.serial().printf(" dacCodeLsbs=%ld", dacCodeLsbs); |
whismanoid | 25:9d4012b0887f | 391 | cmdLine.serial().printf("\r\n"); |
whismanoid | 25:9d4012b0887f | 392 | // call function CODE_LOAD(dacCodeLsbs) |
whismanoid | 25:9d4012b0887f | 393 | uint8_t result = g_MAX5719_device.CODE_LOAD(dacCodeLsbs); |
whismanoid | 25:9d4012b0887f | 394 | cmdLine.serial().printf(" =%d\r\n", result); |
whismanoid | 25:9d4012b0887f | 395 | return true; // command handled by MAX5719 |
whismanoid | 25:9d4012b0887f | 396 | } // end case 'C' |
whismanoid | 25:9d4012b0887f | 397 | break; |
whismanoid | 25:9d4012b0887f | 398 | } // end switch (cmdLine[0]) |
whismanoid | 25:9d4012b0887f | 399 | return false; // command not handled by MAX5719 |
whismanoid | 25:9d4012b0887f | 400 | } // end bool MAX5719_menu_onEOLcommandParser(CmdLine & cmdLine) |
whismanoid | 25:9d4012b0887f | 401 |