Test program running on MAX32625MBED. Control through USB Serial commands using a terminal emulator such as teraterm or putty.

Dependencies:   MaximTinyTester MAX11410 CmdLine USBDevice

Committer:
whismanoid
Date:
Fri Jul 26 01:34:10 2019 -0700
Revision:
30:9eb6eff512e7
Parent:
29:7d0bc70036be
Child:
31:8068c5394e0d
MAX11410 future menu items '@' VRef,status,data0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
whismanoid 19:8f951e448ab1 1 // /*******************************************************************************
whismanoid 19:8f951e448ab1 2 // * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved.
whismanoid 19:8f951e448ab1 3 // *
whismanoid 19:8f951e448ab1 4 // * Permission is hereby granted, free of charge, to any person obtaining a
whismanoid 19:8f951e448ab1 5 // * copy of this software and associated documentation files (the "Software"),
whismanoid 19:8f951e448ab1 6 // * to deal in the Software without restriction, including without limitation
whismanoid 19:8f951e448ab1 7 // * the rights to use, copy, modify, merge, publish, distribute, sublicense,
whismanoid 19:8f951e448ab1 8 // * and/or sell copies of the Software, and to permit persons to whom the
whismanoid 19:8f951e448ab1 9 // * Software is furnished to do so, subject to the following conditions:
whismanoid 19:8f951e448ab1 10 // *
whismanoid 19:8f951e448ab1 11 // * The above copyright notice and this permission notice shall be included
whismanoid 19:8f951e448ab1 12 // * in all copies or substantial portions of the Software.
whismanoid 19:8f951e448ab1 13 // *
whismanoid 19:8f951e448ab1 14 // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
whismanoid 19:8f951e448ab1 15 // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
whismanoid 19:8f951e448ab1 16 // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
whismanoid 19:8f951e448ab1 17 // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
whismanoid 19:8f951e448ab1 18 // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
whismanoid 19:8f951e448ab1 19 // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
whismanoid 19:8f951e448ab1 20 // * OTHER DEALINGS IN THE SOFTWARE.
whismanoid 19:8f951e448ab1 21 // *
whismanoid 19:8f951e448ab1 22 // * Except as contained in this notice, the name of Maxim Integrated
whismanoid 19:8f951e448ab1 23 // * Products, Inc. shall not be used except as stated in the Maxim Integrated
whismanoid 19:8f951e448ab1 24 // * Products, Inc. Branding Policy.
whismanoid 19:8f951e448ab1 25 // *
whismanoid 19:8f951e448ab1 26 // * The mere transfer of this software does not imply any licenses
whismanoid 19:8f951e448ab1 27 // * of trade secrets, proprietary technology, copyrights, patents,
whismanoid 19:8f951e448ab1 28 // * trademarks, maskwork rights, or any other form of intellectual
whismanoid 19:8f951e448ab1 29 // * property whatsoever. Maxim Integrated Products, Inc. retains all
whismanoid 19:8f951e448ab1 30 // * ownership rights.
whismanoid 19:8f951e448ab1 31 // *******************************************************************************
whismanoid 19:8f951e448ab1 32 // */
whismanoid 19:8f951e448ab1 33
whismanoid 19:8f951e448ab1 34 #include "mbed.h"
whismanoid 19:8f951e448ab1 35 #include "MAX11410.h"
whismanoid 19:8f951e448ab1 36 #include "CmdLine.h"
whismanoid 19:8f951e448ab1 37
whismanoid 19:8f951e448ab1 38 //--------------------------------------------------
whismanoid 19:8f951e448ab1 39 // tolerate AT commands, which may be sent during probe, such as:
whismanoid 19:8f951e448ab1 40 // AT
whismanoid 19:8f951e448ab1 41 // AT+CGMI -- request manufacturer identification AT+CMGI=?
whismanoid 19:8f951e448ab1 42 // AT+CGMM -- request manufacturer model
whismanoid 19:8f951e448ab1 43 // AT%IPSYS?
whismanoid 19:8f951e448ab1 44 // ATE0 -- echo disable
whismanoid 19:8f951e448ab1 45 // ATV1 -- verbose result codes OK | ERROR | NO CARRIER
whismanoid 19:8f951e448ab1 46 // AT+CMEE=1
whismanoid 19:8f951e448ab1 47 // ATX4
whismanoid 19:8f951e448ab1 48 // AT&C1
whismanoid 19:8f951e448ab1 49 // ATE0
whismanoid 19:8f951e448ab1 50 // AT+CMEE=1
whismanoid 19:8f951e448ab1 51 // AT+GCAP
whismanoid 19:8f951e448ab1 52 // ATI
whismanoid 19:8f951e448ab1 53 // AT+CPIN?
whismanoid 19:8f951e448ab1 54 // AT+CGMM
whismanoid 19:8f951e448ab1 55 #ifndef IGNORE_AT_COMMANDS
whismanoid 19:8f951e448ab1 56 #define IGNORE_AT_COMMANDS 1
whismanoid 19:8f951e448ab1 57 #endif
whismanoid 19:8f951e448ab1 58
whismanoid 30:9eb6eff512e7 59 extern MAX11410 g_MAX11410_device; // defined in main.cpp
whismanoid 19:8f951e448ab1 60
whismanoid 19:8f951e448ab1 61 bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 19:8f951e448ab1 62 {
whismanoid 19:8f951e448ab1 63 switch (cmdLine[0])
whismanoid 19:8f951e448ab1 64 {
whismanoid 19:8f951e448ab1 65 // TODO1: MAX11410 main_menu_onEOLcommandParser
whismanoid 19:8f951e448ab1 66 case '0':
whismanoid 19:8f951e448ab1 67 {
whismanoid 19:8f951e448ab1 68 // // recommended for hex command codes 00..0F
whismanoid 19:8f951e448ab1 69 // // placeholder: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn");
whismanoid 19:8f951e448ab1 70 // uint16_t ch = g_MAX5715_device.channelNumber_0_3;
whismanoid 19:8f951e448ab1 71 // uint16_t code;
whismanoid 19:8f951e448ab1 72 // if (cmdLine.parse_uint16_dec("ch", ch))
whismanoid 19:8f951e448ab1 73 // {
whismanoid 19:8f951e448ab1 74 // }
whismanoid 19:8f951e448ab1 75 // if (cmdLine.parse_uint16_dec("code", code))
whismanoid 19:8f951e448ab1 76 // {
whismanoid 19:8f951e448ab1 77 // }
whismanoid 19:8f951e448ab1 78 // if (cmdLine.parse_flag("xyzzy", g_xyzzy_flag, XYZZY_FLAG))
whismanoid 19:8f951e448ab1 79 // {
whismanoid 19:8f951e448ab1 80 // isUpdatedSPIConfig = true;
whismanoid 19:8f951e448ab1 81 // }
whismanoid 19:8f951e448ab1 82 // cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code);
whismanoid 19:8f951e448ab1 83 // //~ MAX5715_CODEnLOADn(ch, code);
whismanoid 19:8f951e448ab1 84 // cmdLine.serial().printf("\r\n placeholder");
whismanoid 19:8f951e448ab1 85 return true; // command was handled by MAX11410
whismanoid 19:8f951e448ab1 86 }
whismanoid 19:8f951e448ab1 87 break;
whismanoid 19:8f951e448ab1 88 case '1':
whismanoid 19:8f951e448ab1 89 {
whismanoid 19:8f951e448ab1 90 // recommended for hex command codes 10..1F
whismanoid 19:8f951e448ab1 91 }
whismanoid 19:8f951e448ab1 92 break;
whismanoid 19:8f951e448ab1 93 case '2':
whismanoid 19:8f951e448ab1 94 {
whismanoid 19:8f951e448ab1 95 // recommended for hex command codes 20..2F
whismanoid 19:8f951e448ab1 96 }
whismanoid 19:8f951e448ab1 97 break;
whismanoid 19:8f951e448ab1 98 case '3':
whismanoid 19:8f951e448ab1 99 {
whismanoid 19:8f951e448ab1 100 // recommended for hex command codes 30..3F
whismanoid 19:8f951e448ab1 101 }
whismanoid 19:8f951e448ab1 102 break;
whismanoid 19:8f951e448ab1 103 case '4':
whismanoid 19:8f951e448ab1 104 {
whismanoid 19:8f951e448ab1 105 // recommended for hex command codes 40..4F
whismanoid 19:8f951e448ab1 106 }
whismanoid 19:8f951e448ab1 107 break;
whismanoid 19:8f951e448ab1 108 case '5':
whismanoid 19:8f951e448ab1 109 {
whismanoid 19:8f951e448ab1 110 // recommended for hex command codes 50..5F
whismanoid 19:8f951e448ab1 111 }
whismanoid 19:8f951e448ab1 112 break;
whismanoid 19:8f951e448ab1 113 case '6':
whismanoid 19:8f951e448ab1 114 {
whismanoid 19:8f951e448ab1 115 // recommended for hex command codes 60..6F
whismanoid 19:8f951e448ab1 116 }
whismanoid 19:8f951e448ab1 117 break;
whismanoid 19:8f951e448ab1 118 case '7':
whismanoid 19:8f951e448ab1 119 {
whismanoid 19:8f951e448ab1 120 // recommended for hex command codes 70..7F
whismanoid 19:8f951e448ab1 121 }
whismanoid 19:8f951e448ab1 122 break;
whismanoid 19:8f951e448ab1 123 case '8':
whismanoid 19:8f951e448ab1 124 {
whismanoid 19:8f951e448ab1 125 // recommended for hex command codes 80..8F
whismanoid 19:8f951e448ab1 126 }
whismanoid 19:8f951e448ab1 127 break;
whismanoid 19:8f951e448ab1 128 case '9':
whismanoid 19:8f951e448ab1 129 {
whismanoid 19:8f951e448ab1 130 // recommended for hex command codes 90..9F
whismanoid 19:8f951e448ab1 131 }
whismanoid 19:8f951e448ab1 132 break;
whismanoid 19:8f951e448ab1 133 case 'a': case 'A':
whismanoid 19:8f951e448ab1 134 {
whismanoid 19:8f951e448ab1 135 // recommended for hex command codes A0..AF
whismanoid 19:8f951e448ab1 136 switch (cmdLine[1])
whismanoid 19:8f951e448ab1 137 {
whismanoid 19:8f951e448ab1 138 case 't': case 'T':
whismanoid 19:8f951e448ab1 139 #if IGNORE_AT_COMMANDS
whismanoid 19:8f951e448ab1 140 # if HAS_DAPLINK_SERIAL
whismanoid 19:8f951e448ab1 141 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 19:8f951e448ab1 142 # endif // HAS_DAPLINK_SERIAL
whismanoid 19:8f951e448ab1 143 // AT command: skip the prompt to avoid confusing modem detector
whismanoid 19:8f951e448ab1 144 return false; // command not handled
whismanoid 19:8f951e448ab1 145 #endif // IGNORE_AT_COMMANDS
whismanoid 19:8f951e448ab1 146 }
whismanoid 19:8f951e448ab1 147 }
whismanoid 19:8f951e448ab1 148 break;
whismanoid 19:8f951e448ab1 149 case 'b': case 'B':
whismanoid 19:8f951e448ab1 150 {
whismanoid 19:8f951e448ab1 151 // recommended for hex command codes B0..BF
whismanoid 19:8f951e448ab1 152 }
whismanoid 19:8f951e448ab1 153 break;
whismanoid 19:8f951e448ab1 154 case 'c': case 'C':
whismanoid 19:8f951e448ab1 155 {
whismanoid 19:8f951e448ab1 156 // recommended for hex command codes C0..CF
whismanoid 28:d2ee1c57ff81 157 // cmdLine.serial().printf("\r\n CV ch=? ainp=? ainn=? pga=? -- (future) Voltage configuration");
whismanoid 28:d2ee1c57ff81 158 // cmdLine.serial().printf("\r\n CT -- (future) Thermocouple configuration");
whismanoid 28:d2ee1c57ff81 159 // cmdLine.serial().printf("\r\n CR -- (future) Resistive Temperature Device (RTD) configuration");
whismanoid 29:7d0bc70036be 160 #warning "Not Implemented Yet: MAX11410 menu C Voltage / Thermocouple / RTD configuration"
whismanoid 19:8f951e448ab1 161 }
whismanoid 19:8f951e448ab1 162 break;
whismanoid 19:8f951e448ab1 163 case 'd': case 'D':
whismanoid 19:8f951e448ab1 164 {
whismanoid 19:8f951e448ab1 165 // recommended for hex command codes D0..DF
whismanoid 19:8f951e448ab1 166 }
whismanoid 19:8f951e448ab1 167 break;
whismanoid 19:8f951e448ab1 168 case 'e': case 'E':
whismanoid 19:8f951e448ab1 169 {
whismanoid 19:8f951e448ab1 170 // recommended for hex command codes E0..EF
whismanoid 19:8f951e448ab1 171 }
whismanoid 19:8f951e448ab1 172 break;
whismanoid 19:8f951e448ab1 173 case 'f': case 'F':
whismanoid 19:8f951e448ab1 174 {
whismanoid 19:8f951e448ab1 175 // recommended for hex command codes F0..FF
whismanoid 19:8f951e448ab1 176 }
whismanoid 19:8f951e448ab1 177 break;
whismanoid 28:d2ee1c57ff81 178 // case 'g': case 'G':
whismanoid 28:d2ee1c57ff81 179 // case 'h': case 'H':
whismanoid 28:d2ee1c57ff81 180 // case 'i': case 'I':
whismanoid 28:d2ee1c57ff81 181 // case 'j': case 'J':
whismanoid 28:d2ee1c57ff81 182 // case 'k': case 'K':
whismanoid 28:d2ee1c57ff81 183 // case 'l': case 'L':
whismanoid 28:d2ee1c57ff81 184 case 'm': case 'M':
whismanoid 28:d2ee1c57ff81 185 {
whismanoid 28:d2ee1c57ff81 186 // cmdLine.serial().printf("\r\n MV -- (future) Voltage measurement");
whismanoid 28:d2ee1c57ff81 187 // cmdLine.serial().printf("\r\n MT -- (future) Thermocouple measurement");
whismanoid 28:d2ee1c57ff81 188 // cmdLine.serial().printf("\r\n MR -- (future) RTD measurement");
whismanoid 29:7d0bc70036be 189 #warning "Not Implemented Yet: MAX11410 menu M measure Voltage / Thermocouple / RTD"
whismanoid 28:d2ee1c57ff81 190 }
whismanoid 28:d2ee1c57ff81 191 break;
whismanoid 28:d2ee1c57ff81 192 // case 'n': case 'N':
whismanoid 28:d2ee1c57ff81 193 // case 'o': case 'O':
whismanoid 28:d2ee1c57ff81 194 // case 'p': case 'P':
whismanoid 28:d2ee1c57ff81 195 // case 'q': case 'Q':
whismanoid 28:d2ee1c57ff81 196 case 'r': case 'R':
whismanoid 28:d2ee1c57ff81 197 {
whismanoid 28:d2ee1c57ff81 198 // cmdLine.serial().printf("\r\n R reg=? -- (future) read register");
whismanoid 29:7d0bc70036be 199 #warning "Not Implemented Yet: MAX11410 menu R read register"
whismanoid 28:d2ee1c57ff81 200 }
whismanoid 28:d2ee1c57ff81 201 break;
whismanoid 28:d2ee1c57ff81 202 case 's': case 'S':
whismanoid 28:d2ee1c57ff81 203 {
whismanoid 28:d2ee1c57ff81 204 // cmdLine.serial().printf("\r\n S -- (future) read status register");
whismanoid 29:7d0bc70036be 205 #warning "Not Implemented Yet: MAX11410 menu S read status register"
whismanoid 28:d2ee1c57ff81 206 }
whismanoid 28:d2ee1c57ff81 207 break;
whismanoid 28:d2ee1c57ff81 208 // case 't': case 'T':
whismanoid 28:d2ee1c57ff81 209 // case 'u': case 'U':
whismanoid 28:d2ee1c57ff81 210 // case 'v': case 'V':
whismanoid 28:d2ee1c57ff81 211 case 'w': case 'W':
whismanoid 28:d2ee1c57ff81 212 {
whismanoid 28:d2ee1c57ff81 213 // cmdLine.serial().printf("\r\n W reg=? data=? -- (future) write register");
whismanoid 29:7d0bc70036be 214 #warning "Not Implemented Yet: MAX11410 menu W write register"
whismanoid 28:d2ee1c57ff81 215 }
whismanoid 28:d2ee1c57ff81 216 break;
whismanoid 19:8f951e448ab1 217 case 'x': case 'X':
whismanoid 19:8f951e448ab1 218 {
whismanoid 19:8f951e448ab1 219 }
whismanoid 19:8f951e448ab1 220 break;
whismanoid 19:8f951e448ab1 221 case 'y': case 'Y':
whismanoid 19:8f951e448ab1 222 {
whismanoid 19:8f951e448ab1 223 }
whismanoid 19:8f951e448ab1 224 break;
whismanoid 19:8f951e448ab1 225 case 'z': case 'Z':
whismanoid 19:8f951e448ab1 226 {
whismanoid 19:8f951e448ab1 227 }
whismanoid 19:8f951e448ab1 228 break;
whismanoid 19:8f951e448ab1 229 case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command
whismanoid 19:8f951e448ab1 230 {
whismanoid 19:8f951e448ab1 231 // TODO: '~' is not recommended for menu commands, interferes with ssh
whismanoid 19:8f951e448ab1 232 #if IGNORE_AT_COMMANDS
whismanoid 19:8f951e448ab1 233 # if HAS_DAPLINK_SERIAL
whismanoid 19:8f951e448ab1 234 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 19:8f951e448ab1 235 # endif // HAS_DAPLINK_SERIAL
whismanoid 19:8f951e448ab1 236 #endif // IGNORE_AT_COMMANDS
whismanoid 19:8f951e448ab1 237 }
whismanoid 19:8f951e448ab1 238 break;
whismanoid 19:8f951e448ab1 239 case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command
whismanoid 19:8f951e448ab1 240 {
whismanoid 19:8f951e448ab1 241 #if IGNORE_AT_COMMANDS
whismanoid 19:8f951e448ab1 242 # if HAS_DAPLINK_SERIAL
whismanoid 19:8f951e448ab1 243 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 19:8f951e448ab1 244 # endif // HAS_DAPLINK_SERIAL
whismanoid 19:8f951e448ab1 245 #endif // IGNORE_AT_COMMANDS
whismanoid 19:8f951e448ab1 246 }
whismanoid 19:8f951e448ab1 247 break;
whismanoid 29:7d0bc70036be 248 case '@':
whismanoid 29:7d0bc70036be 249 {
whismanoid 29:7d0bc70036be 250 // // Menu @ -- print device configuration
whismanoid 29:7d0bc70036be 251 // cmdLine.serial().printf("\r\n @ -- (future) print device configuration");
whismanoid 30:9eb6eff512e7 252 #warning "Not Tested Yet: MAX11410 menu @ print device configuration"
whismanoid 30:9eb6eff512e7 253 // //
whismanoid 30:9eb6eff512e7 254 // print shadow register configuration
whismanoid 30:9eb6eff512e7 255 //
whismanoid 30:9eb6eff512e7 256 // shadow of write-only register CODE dddd_dddd_dddd_0000
whismanoid 30:9eb6eff512e7 257 //~ int16_t CMD_1000_CODE;
whismanoid 30:9eb6eff512e7 258 // int index = 0;
whismanoid 30:9eb6eff512e7 259 // for (index = 0; index < 4; index++)
whismanoid 30:9eb6eff512e7 260 // {
whismanoid 30:9eb6eff512e7 261 // cmdLine.serial().printf("CODE %c=0x%4.4x MAX5715_VoltageOfCode(%d)=%5.3fV\r\n",
whismanoid 30:9eb6eff512e7 262 // (char)('A' + index),
whismanoid 30:9eb6eff512e7 263 // (g_MAX5715_device.Shadow_0010_nnnn_CODE[index] & 0xFFFF),
whismanoid 30:9eb6eff512e7 264 // g_MAX5715_device.CODE[index],
whismanoid 30:9eb6eff512e7 265 // g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[index])
whismanoid 30:9eb6eff512e7 266 // );
whismanoid 30:9eb6eff512e7 267 // }
whismanoid 30:9eb6eff512e7 268 //
whismanoid 30:9eb6eff512e7 269 // cmdLine.serial().printf("\r\n");
whismanoid 30:9eb6eff512e7 270 //
whismanoid 30:9eb6eff512e7 271 //cmdLine.serial().printf("channelNumber_0_3=%d channels_bitmask_DCBA=%d\r\n",
whismanoid 30:9eb6eff512e7 272 // (g_MAX5715_device.channelNumber_0_3 & 0xFFFF),
whismanoid 30:9eb6eff512e7 273 // (g_MAX5715_device.channels_bitmask_DCBA & 0xFFFF));
whismanoid 30:9eb6eff512e7 274 //
whismanoid 30:9eb6eff512e7 275 cmdLine.serial().printf("VRef=%5.6fV\r\n", g_MAX11410_device.VRef);
whismanoid 30:9eb6eff512e7 276 // dtostrf width and precision: 2.5V / 2^24 LSB = ______ volts per LSB
whismanoid 30:9eb6eff512e7 277 //
whismanoid 30:9eb6eff512e7 278 // shadow of register CMD_r011_1000_dddd_dddd_dddd_dddd_dxxx_dddd_STATUS
whismanoid 30:9eb6eff512e7 279 cmdLine.serial().printf("status=0x%6.6x\r\n",
whismanoid 30:9eb6eff512e7 280 g_MAX11410_device.status);
whismanoid 30:9eb6eff512e7 281 //
whismanoid 30:9eb6eff512e7 282 // shadow of register CMD_r011_0000_dddd_dddd_dddd_dddd_dddd_dddd_DATA0
whismanoid 30:9eb6eff512e7 283 double voltage_of_data0;
whismanoid 30:9eb6eff512e7 284 voltage_of_data0 = g_MAX11410_device.VoltageOfCode(g_MAX11410_device.data0);
whismanoid 30:9eb6eff512e7 285 cmdLine.serial().printf("data0=0x%6.6x=%u=%d=%5.6fV\r\n",
whismanoid 30:9eb6eff512e7 286 g_MAX11410_device.data0,
whismanoid 30:9eb6eff512e7 287 g_MAX11410_device.data0,
whismanoid 30:9eb6eff512e7 288 g_MAX11410_device.data0,
whismanoid 30:9eb6eff512e7 289 voltage_of_data0);
whismanoid 30:9eb6eff512e7 290 //
whismanoid 30:9eb6eff512e7 291 return true; // command was handled by MAX11410
whismanoid 29:7d0bc70036be 292 }
whismanoid 29:7d0bc70036be 293 break;
whismanoid 19:8f951e448ab1 294 } // end switch (cmdLine[0])
whismanoid 19:8f951e448ab1 295 return false; // command not handled
whismanoid 19:8f951e448ab1 296 } // end bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine)