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

Dependencies:   MaximTinyTester CmdLine MAX5171 MAX541 USBDevice

Committer:
whismanoid
Date:
Thu Jul 18 18:40:46 2019 -0700
Revision:
19:906f8a15a728
Parent:
11:48aefcaa1d29
MAX32620FTHR support: USBSerial not working yet...

Who changed what in which revision?

UserRevisionLine numberNew contents of line
whismanoid 11:48aefcaa1d29 1 // /*******************************************************************************
whismanoid 11:48aefcaa1d29 2 // * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved.
whismanoid 11:48aefcaa1d29 3 // *
whismanoid 11:48aefcaa1d29 4 // * Permission is hereby granted, free of charge, to any person obtaining a
whismanoid 11:48aefcaa1d29 5 // * copy of this software and associated documentation files (the "Software"),
whismanoid 11:48aefcaa1d29 6 // * to deal in the Software without restriction, including without limitation
whismanoid 11:48aefcaa1d29 7 // * the rights to use, copy, modify, merge, publish, distribute, sublicense,
whismanoid 11:48aefcaa1d29 8 // * and/or sell copies of the Software, and to permit persons to whom the
whismanoid 11:48aefcaa1d29 9 // * Software is furnished to do so, subject to the following conditions:
whismanoid 11:48aefcaa1d29 10 // *
whismanoid 11:48aefcaa1d29 11 // * The above copyright notice and this permission notice shall be included
whismanoid 11:48aefcaa1d29 12 // * in all copies or substantial portions of the Software.
whismanoid 11:48aefcaa1d29 13 // *
whismanoid 11:48aefcaa1d29 14 // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
whismanoid 11:48aefcaa1d29 15 // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
whismanoid 11:48aefcaa1d29 16 // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
whismanoid 11:48aefcaa1d29 17 // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
whismanoid 11:48aefcaa1d29 18 // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
whismanoid 11:48aefcaa1d29 19 // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
whismanoid 11:48aefcaa1d29 20 // * OTHER DEALINGS IN THE SOFTWARE.
whismanoid 11:48aefcaa1d29 21 // *
whismanoid 11:48aefcaa1d29 22 // * Except as contained in this notice, the name of Maxim Integrated
whismanoid 11:48aefcaa1d29 23 // * Products, Inc. shall not be used except as stated in the Maxim Integrated
whismanoid 11:48aefcaa1d29 24 // * Products, Inc. Branding Policy.
whismanoid 11:48aefcaa1d29 25 // *
whismanoid 11:48aefcaa1d29 26 // * The mere transfer of this software does not imply any licenses
whismanoid 11:48aefcaa1d29 27 // * of trade secrets, proprietary technology, copyrights, patents,
whismanoid 11:48aefcaa1d29 28 // * trademarks, maskwork rights, or any other form of intellectual
whismanoid 11:48aefcaa1d29 29 // * property whatsoever. Maxim Integrated Products, Inc. retains all
whismanoid 11:48aefcaa1d29 30 // * ownership rights.
whismanoid 11:48aefcaa1d29 31 // *******************************************************************************
whismanoid 11:48aefcaa1d29 32 // */
whismanoid 11:48aefcaa1d29 33
whismanoid 11:48aefcaa1d29 34 #include "mbed.h"
whismanoid 11:48aefcaa1d29 35 #include "MAX5171.h"
whismanoid 11:48aefcaa1d29 36 #include "CmdLine.h"
whismanoid 11:48aefcaa1d29 37
whismanoid 11:48aefcaa1d29 38 //--------------------------------------------------
whismanoid 11:48aefcaa1d29 39 // tolerate AT commands, which may be sent during probe, such as:
whismanoid 11:48aefcaa1d29 40 // AT
whismanoid 11:48aefcaa1d29 41 // AT+CGMI -- request manufacturer identification AT+CMGI=?
whismanoid 11:48aefcaa1d29 42 // AT+CGMM -- request manufacturer model
whismanoid 11:48aefcaa1d29 43 // AT%IPSYS?
whismanoid 11:48aefcaa1d29 44 // ATE0 -- echo disable
whismanoid 11:48aefcaa1d29 45 // ATV1 -- verbose result codes OK | ERROR | NO CARRIER
whismanoid 11:48aefcaa1d29 46 // AT+CMEE=1
whismanoid 11:48aefcaa1d29 47 // ATX4
whismanoid 11:48aefcaa1d29 48 // AT&C1
whismanoid 11:48aefcaa1d29 49 // ATE0
whismanoid 11:48aefcaa1d29 50 // AT+CMEE=1
whismanoid 11:48aefcaa1d29 51 // AT+GCAP
whismanoid 11:48aefcaa1d29 52 // ATI
whismanoid 11:48aefcaa1d29 53 // AT+CPIN?
whismanoid 11:48aefcaa1d29 54 // AT+CGMM
whismanoid 11:48aefcaa1d29 55 #ifndef IGNORE_AT_COMMANDS
whismanoid 11:48aefcaa1d29 56 #define IGNORE_AT_COMMANDS 1
whismanoid 11:48aefcaa1d29 57 #endif
whismanoid 11:48aefcaa1d29 58
whismanoid 11:48aefcaa1d29 59 extern MAX5171 g_MAX5171_device; // defined in main.cpp
whismanoid 11:48aefcaa1d29 60
whismanoid 11:48aefcaa1d29 61 bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 11:48aefcaa1d29 62 {
whismanoid 11:48aefcaa1d29 63 switch (cmdLine[0])
whismanoid 11:48aefcaa1d29 64 {
whismanoid 11:48aefcaa1d29 65 case '0':
whismanoid 11:48aefcaa1d29 66 {
whismanoid 11:48aefcaa1d29 67 // recommended for hex command codes 10..1F
whismanoid 11:48aefcaa1d29 68 //~ cmdLine.serial().printf("\r\n 0 code=? -- CODE");
whismanoid 11:48aefcaa1d29 69 uint16_t code;
whismanoid 11:48aefcaa1d29 70 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 11:48aefcaa1d29 71 {
whismanoid 11:48aefcaa1d29 72 }
whismanoid 11:48aefcaa1d29 73 cmdLine.serial().printf("CODE code=%d", code);
whismanoid 11:48aefcaa1d29 74 g_MAX5171_device.CODE(code);
whismanoid 11:48aefcaa1d29 75 return true; // command was handled by MAX5171
whismanoid 11:48aefcaa1d29 76 }
whismanoid 11:48aefcaa1d29 77 break;
whismanoid 11:48aefcaa1d29 78 case '4':
whismanoid 11:48aefcaa1d29 79 {
whismanoid 11:48aefcaa1d29 80 // recommended for hex command codes 10..1F
whismanoid 11:48aefcaa1d29 81 //~ cmdLine.serial().printf("\r\n 4 code=? -- CODE_LOAD");
whismanoid 11:48aefcaa1d29 82 uint16_t code;
whismanoid 11:48aefcaa1d29 83 if (cmdLine.parse_uint16_dec("code", code))
whismanoid 11:48aefcaa1d29 84 {
whismanoid 11:48aefcaa1d29 85 }
whismanoid 11:48aefcaa1d29 86 cmdLine.serial().printf("CODE_LOAD code=%d", code);
whismanoid 11:48aefcaa1d29 87 g_MAX5171_device.CODE_LOAD(code);
whismanoid 11:48aefcaa1d29 88 return true; // command was handled by MAX5171
whismanoid 11:48aefcaa1d29 89 }
whismanoid 11:48aefcaa1d29 90 break;
whismanoid 11:48aefcaa1d29 91 case '8':
whismanoid 11:48aefcaa1d29 92 {
whismanoid 11:48aefcaa1d29 93 // recommended for hex command codes 10..1F
whismanoid 11:48aefcaa1d29 94 //~ cmdLine.serial().printf("\r\n 8 -- LOAD");
whismanoid 11:48aefcaa1d29 95 cmdLine.serial().printf("LOAD");
whismanoid 11:48aefcaa1d29 96 g_MAX5171_device.LOAD();
whismanoid 11:48aefcaa1d29 97 return true; // command was handled by MAX5171
whismanoid 11:48aefcaa1d29 98 }
whismanoid 11:48aefcaa1d29 99 break;
whismanoid 11:48aefcaa1d29 100 case 'c': case 'C':
whismanoid 11:48aefcaa1d29 101 {
whismanoid 11:48aefcaa1d29 102 // recommended for hex command codes 10..1F
whismanoid 11:48aefcaa1d29 103 //~ cmdLine.serial().printf("\r\n c -- NOP");
whismanoid 11:48aefcaa1d29 104 cmdLine.serial().printf("NOP");
whismanoid 11:48aefcaa1d29 105 g_MAX5171_device.NOP();
whismanoid 11:48aefcaa1d29 106 return true; // command was handled by MAX5171
whismanoid 11:48aefcaa1d29 107 }
whismanoid 11:48aefcaa1d29 108 break;
whismanoid 11:48aefcaa1d29 109 case 'd': case 'D':
whismanoid 11:48aefcaa1d29 110 {
whismanoid 11:48aefcaa1d29 111 // recommended for hex command codes 10..1F
whismanoid 11:48aefcaa1d29 112 //~ cmdLine.serial().printf("\r\n d -- SHUTDOWN");
whismanoid 11:48aefcaa1d29 113 cmdLine.serial().printf("SHUTDOWN");
whismanoid 11:48aefcaa1d29 114 g_MAX5171_device.SHUTDOWN();
whismanoid 11:48aefcaa1d29 115 return true; // command was handled by MAX5171
whismanoid 11:48aefcaa1d29 116 }
whismanoid 11:48aefcaa1d29 117 break;
whismanoid 11:48aefcaa1d29 118 case 'e': case 'E':
whismanoid 11:48aefcaa1d29 119 {
whismanoid 11:48aefcaa1d29 120 switch (cmdLine[1])
whismanoid 11:48aefcaa1d29 121 {
whismanoid 11:48aefcaa1d29 122 case '0':
whismanoid 11:48aefcaa1d29 123 {
whismanoid 11:48aefcaa1d29 124 // recommended for hex command codes 10..1F
whismanoid 11:48aefcaa1d29 125 //~ cmdLine.serial().printf("\r\n e0 -- UPO_LOW");
whismanoid 11:48aefcaa1d29 126 cmdLine.serial().printf("UPO_LOW");
whismanoid 11:48aefcaa1d29 127 g_MAX5171_device.UPO_LOW();
whismanoid 11:48aefcaa1d29 128 return true; // command was handled by MAX5171
whismanoid 11:48aefcaa1d29 129 }
whismanoid 11:48aefcaa1d29 130 break;
whismanoid 11:48aefcaa1d29 131 case '8':
whismanoid 11:48aefcaa1d29 132 {
whismanoid 11:48aefcaa1d29 133 // recommended for hex command codes 10..1F
whismanoid 11:48aefcaa1d29 134 //~ cmdLine.serial().printf("\r\n e8 -- UPO_HIGH");
whismanoid 11:48aefcaa1d29 135 cmdLine.serial().printf("UPO_HIGH");
whismanoid 11:48aefcaa1d29 136 g_MAX5171_device.UPO_HIGH();
whismanoid 11:48aefcaa1d29 137 return true; // command was handled by MAX5171
whismanoid 11:48aefcaa1d29 138 }
whismanoid 11:48aefcaa1d29 139 break;
whismanoid 11:48aefcaa1d29 140 }
whismanoid 11:48aefcaa1d29 141 }
whismanoid 11:48aefcaa1d29 142 break;
whismanoid 11:48aefcaa1d29 143 case 'f': case 'F':
whismanoid 11:48aefcaa1d29 144 {
whismanoid 11:48aefcaa1d29 145 switch (cmdLine[1])
whismanoid 11:48aefcaa1d29 146 {
whismanoid 11:48aefcaa1d29 147 case '0':
whismanoid 11:48aefcaa1d29 148 {
whismanoid 11:48aefcaa1d29 149 // recommended for hex command codes 10..1F
whismanoid 11:48aefcaa1d29 150 //~ cmdLine.serial().printf("\r\n f0 -- MODE1_DOUT_SCLK_RISING_EDGE");
whismanoid 11:48aefcaa1d29 151 cmdLine.serial().printf("MODE1_DOUT_SCLK_RISING_EDGE");
whismanoid 11:48aefcaa1d29 152 g_MAX5171_device.MODE1_DOUT_SCLK_RISING_EDGE();
whismanoid 11:48aefcaa1d29 153 return true; // command was handled by MAX5171
whismanoid 11:48aefcaa1d29 154 }
whismanoid 11:48aefcaa1d29 155 break;
whismanoid 11:48aefcaa1d29 156 case '8':
whismanoid 11:48aefcaa1d29 157 {
whismanoid 11:48aefcaa1d29 158 // recommended for hex command codes 10..1F
whismanoid 11:48aefcaa1d29 159 //~ cmdLine.serial().printf("\r\n f8 -- MODE0_DOUT_SCLK_FALLING_EDGE");
whismanoid 11:48aefcaa1d29 160 cmdLine.serial().printf("MODE0_DOUT_SCLK_FALLING_EDGE");
whismanoid 11:48aefcaa1d29 161 g_MAX5171_device.MODE0_DOUT_SCLK_FALLING_EDGE();
whismanoid 11:48aefcaa1d29 162 return true; // command was handled by MAX5171
whismanoid 11:48aefcaa1d29 163 }
whismanoid 11:48aefcaa1d29 164 break;
whismanoid 11:48aefcaa1d29 165 }
whismanoid 11:48aefcaa1d29 166 }
whismanoid 11:48aefcaa1d29 167 break;
whismanoid 11:48aefcaa1d29 168 case 'a': case 'A':
whismanoid 11:48aefcaa1d29 169 {
whismanoid 11:48aefcaa1d29 170 // recommended for hex command codes A0..AF
whismanoid 11:48aefcaa1d29 171 switch (cmdLine[1])
whismanoid 11:48aefcaa1d29 172 {
whismanoid 11:48aefcaa1d29 173 case 't': case 'T':
whismanoid 11:48aefcaa1d29 174 #if IGNORE_AT_COMMANDS
whismanoid 11:48aefcaa1d29 175 # if HAS_DAPLINK_SERIAL
whismanoid 11:48aefcaa1d29 176 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 11:48aefcaa1d29 177 # endif // HAS_DAPLINK_SERIAL
whismanoid 11:48aefcaa1d29 178 // AT command: skip the prompt to avoid confusing modem detector
whismanoid 11:48aefcaa1d29 179 return false; // command not handled
whismanoid 11:48aefcaa1d29 180 #endif // IGNORE_AT_COMMANDS
whismanoid 11:48aefcaa1d29 181 }
whismanoid 11:48aefcaa1d29 182 }
whismanoid 11:48aefcaa1d29 183 break;
whismanoid 11:48aefcaa1d29 184 case 'x': case 'X':
whismanoid 11:48aefcaa1d29 185 {
whismanoid 11:48aefcaa1d29 186 }
whismanoid 11:48aefcaa1d29 187 break;
whismanoid 11:48aefcaa1d29 188 case 'y': case 'Y':
whismanoid 11:48aefcaa1d29 189 {
whismanoid 11:48aefcaa1d29 190 }
whismanoid 11:48aefcaa1d29 191 break;
whismanoid 11:48aefcaa1d29 192 case 'z': case 'Z':
whismanoid 11:48aefcaa1d29 193 {
whismanoid 11:48aefcaa1d29 194 }
whismanoid 11:48aefcaa1d29 195 break;
whismanoid 11:48aefcaa1d29 196 case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command
whismanoid 11:48aefcaa1d29 197 {
whismanoid 11:48aefcaa1d29 198 // TODO: '~' is not recommended for menu commands, interferes with ssh
whismanoid 11:48aefcaa1d29 199 #if IGNORE_AT_COMMANDS
whismanoid 11:48aefcaa1d29 200 # if HAS_DAPLINK_SERIAL
whismanoid 11:48aefcaa1d29 201 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 11:48aefcaa1d29 202 # endif // HAS_DAPLINK_SERIAL
whismanoid 11:48aefcaa1d29 203 #endif // IGNORE_AT_COMMANDS
whismanoid 11:48aefcaa1d29 204 }
whismanoid 11:48aefcaa1d29 205 break;
whismanoid 11:48aefcaa1d29 206 case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command
whismanoid 11:48aefcaa1d29 207 {
whismanoid 11:48aefcaa1d29 208 #if IGNORE_AT_COMMANDS
whismanoid 11:48aefcaa1d29 209 # if HAS_DAPLINK_SERIAL
whismanoid 11:48aefcaa1d29 210 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 11:48aefcaa1d29 211 # endif // HAS_DAPLINK_SERIAL
whismanoid 11:48aefcaa1d29 212 #endif // IGNORE_AT_COMMANDS
whismanoid 11:48aefcaa1d29 213 }
whismanoid 11:48aefcaa1d29 214 break;
whismanoid 11:48aefcaa1d29 215 } // end switch (cmdLine[0])
whismanoid 11:48aefcaa1d29 216 return false; // command not handled
whismanoid 11:48aefcaa1d29 217 } // end bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 11:48aefcaa1d29 218