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

Dependencies:   MaximTinyTester CmdLine MAX5171 USBDevice

Revision:
22:a14c19b97d0b
Parent:
11:48aefcaa1d29
Child:
23:abd02fed1ae4
--- a/Test_Menu_MAX5171.cpp	Sun Sep 22 18:23:07 2019 -0700
+++ b/Test_Menu_MAX5171.cpp	Thu Mar 12 23:37:48 2020 +0000
@@ -1,5 +1,5 @@
-// /*******************************************************************************
-// * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved.
+// /*******************************************************************************
+// * Copyright (C) 2020 Maxim Integrated Products, Inc., All Rights Reserved.
 // *
 // * Permission is hereby granted, free of charge, to any person obtaining a
 // * copy of this software and associated documentation files (the "Software"),
@@ -30,189 +30,348 @@
 // * ownership rights.
 // *******************************************************************************
 // */
-
+// example code includes
+// standard include for target platform -- Platform_Include_Boilerplate
 #include "mbed.h"
+// Platforms:
+//   - MAX32625MBED
+//      - supports mbed-os-5.11, requires USBDevice library
+//      - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
+//      - remove max32630fthr library (if present)
+//      - remove MAX32620FTHR library (if present)
+//   - MAX32600MBED
+//      - remove max32630fthr library (if present)
+//      - remove MAX32620FTHR library (if present)
+//      - Windows 10 note:  Don't connect HDK until you are ready to load new firmware into the board.
+//   - NUCLEO_F446RE
+//      - remove USBDevice library
+//      - remove max32630fthr library (if present)
+//      - remove MAX32620FTHR library (if present)
+//   - NUCLEO_F401RE
+//      - remove USBDevice library
+//      - remove max32630fthr library (if present)
+//      - remove MAX32620FTHR library (if present)
+//   - MAX32630FTHR
+//      - #include "max32630fthr.h"
+//      - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/
+//      - remove MAX32620FTHR library (if present)
+//   - MAX32620FTHR
+//      - #include "MAX32620FTHR.h"
+//      - remove max32630fthr library (if present)
+//      - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
+//      - not tested yet
+//   - MAX32625PICO
+//      - remove max32630fthr library (if present)
+//      - remove MAX32620FTHR library (if present)
+//      - not tested yet
+//
+// end Platform_Include_Boilerplate
 #include "MAX5171.h"
 #include "CmdLine.h"
+#include "MaximTinyTester.h"
 
-//--------------------------------------------------
-// tolerate AT commands, which may be sent during probe, such as:
-//  AT
-//  AT+CGMI      -- request manufacturer identification AT+CMGI=?
-//  AT+CGMM      -- request manufacturer model
-//  AT%IPSYS?
-//  ATE0         -- echo disable
-//  ATV1         -- verbose result codes OK | ERROR | NO CARRIER
-//  AT+CMEE=1
-//  ATX4
-//  AT&C1
-//  ATE0
-//  AT+CMEE=1
-//  AT+GCAP
-//  ATI
-//  AT+CPIN?
-//  AT+CGMM
-#ifndef IGNORE_AT_COMMANDS
-#define IGNORE_AT_COMMANDS 1
-#endif
+#include "MAX5171.h"
+extern MAX5171 g_MAX5171_device; // defined in main.cpp
+
+
 
-extern MAX5171 g_MAX5171_device; // defined in main.cpp
+void MAX5171_menu_help(CmdLine & cmdLine)
+{
+    cmdLine.serial().printf("\r\n ! -- Init");
+    cmdLine.serial().printf("\r\n 0 code=? -- CODE");
+    cmdLine.serial().printf("\r\n 4 code=? -- CODE_LOAD");
+    cmdLine.serial().printf("\r\n 8 -- LOAD");
+    cmdLine.serial().printf("\r\n c -- NOP");
+    cmdLine.serial().printf("\r\n d -- SHUTDOWN");
+    cmdLine.serial().printf("\r\n e0 -- UPO_LOW");
+    cmdLine.serial().printf("\r\n e8 -- UPO_HIGH");
+    cmdLine.serial().printf("\r\n f0 -- MODE1_DOUT_SCLK_RISING_EDGE");
+    cmdLine.serial().printf("\r\n f8 -- MODE0_DOUT_SCLK_FALLING_EDGE");
+    //
+    cmdLine.serial().printf("\r\n @ -- print MAX5171 configuration");
+
+    //
+        // case 'G'..'Z','g'..'z' are reserved for GPIO commands
+        // case 'A'..'F','a'..'f' may be available if not claimed by bitstream commands
+
+    //
+}
 
 bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine)
 {
+
+
+                    // parse argument int16_t DACCode
+        int16_t DACCode = g_MAX5171_device.DACCode; // default to global property value
+        if (cmdLine.parse_int16_dec("DACCode", DACCode))
+        {
+            g_MAX5171_device.DACCode = DACCode; // update global property value
+        }
+                    // "code" is an alias for argument "DACCode"
+        if (cmdLine.parse_int16_dec("code", DACCode))
+        {
+            g_MAX5171_device.DACCode = DACCode; // update global property value
+        }
+
+                    // parse argument double VRef
+        double VRef = g_MAX5171_device.VRef; // default to global property value
+        if (cmdLine.parse_double("VRef", VRef))
+        {
+            g_MAX5171_device.VRef = VRef; // update global property value
+        }
+
+                    // parse argument uint16_t dacCodeLsbs
+        uint16_t dacCodeLsbs = g_MAX5171_device.DACCode; // default to global property value
+        if (cmdLine.parse_uint16_dec("dacCodeLsbs", dacCodeLsbs))
+        {
+            g_MAX5171_device.DACCode = dacCodeLsbs; // update global property value
+        }
+                    // "code" is an alias for argument "dacCodeLsbs"
+        if (cmdLine.parse_uint16_dec("code", dacCodeLsbs))
+        {
+            g_MAX5171_device.DACCode = dacCodeLsbs; // update global property value
+        }
+
     switch (cmdLine[0])
     {
+        case '@':
+        {
+                    cmdLine.serial().printf("VRef = ");
+                    cmdLine.serial().printf("%f\r\n", g_MAX5171_device.VRef);
+                    cmdLine.serial().printf("DACCode = ");
+                    cmdLine.serial().printf("%d = 0x%4.4x\r\n", g_MAX5171_device.DACCode, g_MAX5171_device.DACCode);
+                    return true; // command handled by MAX5171
+            break;
+        }
+        // case 'G'..'Z','g'..'z' are reserved for GPIO commands
+        // case 'A'..'F','a'..'f' may be available if not claimed by bitstream commands
+        // case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands
+        case '!':
+        {
+                    // test menu command '!' handler:
+                    // helpString='! -- Init'
+                    // CMD_='None'
+                    // CommandName='Init'
+                    // CommandParamIn='void'
+                    // CommandReturnType='uint8_t'
+                    // @Pre=''
+                    // @Param[in]=''
+                    // @Param[out]=''
+                    // @Post=''
+                    // displayPost=''
+                    // @Return='@return 1 on success; 0 on failure'
+                    cmdLine.serial().printf("Init");
+                    // call function Init
+                    uint8_t result = g_MAX5171_device.Init();
+                    cmdLine.serial().printf(" =%d\r\n", result);
+                    return true; // command handled by MAX5171
+        } // end case '!'
+        break;
         case '0':
         {
-            // recommended for hex command codes 10..1F
-            //~ cmdLine.serial().printf("\r\n 0 code=? -- CODE");
-            uint16_t code;
-            if (cmdLine.parse_uint16_dec("code", code))
-            {
-            }
-            cmdLine.serial().printf("CODE code=%d", code);
-            g_MAX5171_device.CODE(code);
-            return true; // command was handled by MAX5171
-        }
+                    // test menu command '0' handler:
+                    // helpString='0 code=? -- CODE'
+                    // CMD_='CMD_00dd_dddd_dddd_dddd_CODE'
+                    // CommandName='CODE'
+                    // CommandParamIn='uint16_t dacCodeLsbs'
+                    // CommandReturnType='uint8_t'
+                    // @Pre=''
+                    // @Param[in]=''
+                    // @Param[out]=''
+                    // @Post=''
+                    // @Return='@return 1 on success; 0 on failure'
+                    // parse argument list
+                    // argument dacCodeLsbs alias code already parsed
+                    // print arguments
+                    cmdLine.serial().printf("CODE");
+                    cmdLine.serial().printf(" dacCodeLsbs=%d", dacCodeLsbs);
+                    cmdLine.serial().printf("\r\n");
+                    // call function CODE(dacCodeLsbs)
+                    uint8_t result = g_MAX5171_device.CODE(dacCodeLsbs);
+                    cmdLine.serial().printf(" =%d\r\n", result);
+                    return true; // command handled by MAX5171
+        } // end case '0'
         break;
         case '4':
         {
-            // recommended for hex command codes 10..1F
-            //~ cmdLine.serial().printf("\r\n 4 code=? -- CODE_LOAD");
-            uint16_t code;
-            if (cmdLine.parse_uint16_dec("code", code))
-            {
-            }
-            cmdLine.serial().printf("CODE_LOAD code=%d", code);
-            g_MAX5171_device.CODE_LOAD(code);
-            return true; // command was handled by MAX5171
-        }
+                    // test menu command '4' handler:
+                    // helpString='4 code=? -- CODE_LOAD'
+                    // CMD_='CMD_01dd_dddd_dddd_dddd_CODE_LOAD'
+                    // CommandName='CODE_LOAD'
+                    // CommandParamIn='uint16_t dacCodeLsbs'
+                    // CommandReturnType='uint8_t'
+                    // @Pre=''
+                    // @Param[in]=''
+                    // @Param[out]=''
+                    // @Post=''
+                    // @Return='@return 1 on success; 0 on failure'
+                    // parse argument list
+                    // argument dacCodeLsbs alias code already parsed
+                    // print arguments
+                    cmdLine.serial().printf("CODE_LOAD");
+                    cmdLine.serial().printf(" dacCodeLsbs=%d", dacCodeLsbs);
+                    cmdLine.serial().printf("\r\n");
+                    // call function CODE_LOAD(dacCodeLsbs)
+                    uint8_t result = g_MAX5171_device.CODE_LOAD(dacCodeLsbs);
+                    cmdLine.serial().printf(" =%d\r\n", result);
+                    return true; // command handled by MAX5171
+        } // end case '4'
         break;
         case '8':
         {
-            // recommended for hex command codes 10..1F
-            //~ cmdLine.serial().printf("\r\n 8 -- LOAD");
-            cmdLine.serial().printf("LOAD");
-            g_MAX5171_device.LOAD();
-            return true; // command was handled by MAX5171
-        }
+                    // test menu command '8' handler:
+                    // helpString='8 -- LOAD'
+                    // CMD_='CMD_10xx_xxxx_xxxx_xxxx_LOAD'
+                    // CommandName='LOAD'
+                    // CommandParamIn='void'
+                    // CommandReturnType='uint8_t'
+                    // @Pre=''
+                    // @Param[in]=''
+                    // @Param[out]=''
+                    // @Post=''
+                    // @Return='@return 1 on success; 0 on failure'
+                    cmdLine.serial().printf("LOAD");
+                    // call function LOAD
+                    uint8_t result = g_MAX5171_device.LOAD();
+                    cmdLine.serial().printf(" =%d\r\n", result);
+                    return true; // command handled by MAX5171
+        } // end case '8'
         break;
-        case 'c': case 'C':
+        case 'c':
         {
-            // recommended for hex command codes 10..1F
-            //~ cmdLine.serial().printf("\r\n c -- NOP");
-            cmdLine.serial().printf("NOP");
-            g_MAX5171_device.NOP();
-            return true; // command was handled by MAX5171
-        }
+                    // test menu command 'c' handler:
+                    // helpString='c -- NOP'
+                    // CMD_='CMD_1100_xxxx_xxxx_xxxx_NOP'
+                    // CommandName='NOP'
+                    // CommandParamIn='void'
+                    // CommandReturnType='uint8_t'
+                    // @Pre=''
+                    // @Param[in]=''
+                    // @Param[out]=''
+                    // @Post=''
+                    // @Return='@return 1 on success; 0 on failure'
+                    cmdLine.serial().printf("NOP");
+                    // call function NOP
+                    uint8_t result = g_MAX5171_device.NOP();
+                    cmdLine.serial().printf(" =%d\r\n", result);
+                    return true; // command handled by MAX5171
+        } // end case 'c'
         break;
-        case 'd': case 'D':
+        case 'd':
         {
-            // recommended for hex command codes 10..1F
-            //~ cmdLine.serial().printf("\r\n d -- SHUTDOWN");
-            cmdLine.serial().printf("SHUTDOWN");
-            g_MAX5171_device.SHUTDOWN();
-            return true; // command was handled by MAX5171
-        }
+                    // test menu command 'd' handler:
+                    // helpString='d -- SHUTDOWN'
+                    // CMD_='CMD_1101_xxxx_xxxx_xxxx_SHUTDOWN'
+                    // CommandName='SHUTDOWN'
+                    // CommandParamIn='void'
+                    // CommandReturnType='uint8_t'
+                    // @Pre=''
+                    // @Param[in]=''
+                    // @Param[out]=''
+                    // @Post=''
+                    // @Return='@return 1 on success; 0 on failure'
+                    cmdLine.serial().printf("SHUTDOWN");
+                    // call function SHUTDOWN
+                    uint8_t result = g_MAX5171_device.SHUTDOWN();
+                    cmdLine.serial().printf(" =%d\r\n", result);
+                    return true; // command handled by MAX5171
+        } // end case 'd'
         break;
-        case 'e': case 'E':
+        case 'e': // (multiple characters) (testMenuFirstCharHandler="e"):
         {
             switch (cmdLine[1])
             {
-                case '0':
+                case '0': // (nested inside case 'e')
                 {
-                    // recommended for hex command codes 10..1F
-                    //~ cmdLine.serial().printf("\r\n e0 -- UPO_LOW");
+                    // test menu command 'e0' handler:
+                    // helpString='e0 -- UPO_LOW'
+                    // CMD_='CMD_1110_0xxx_xxxx_xxxx_UPO_LOW'
+                    // CommandName='UPO_LOW'
+                    // CommandParamIn='void'
+                    // CommandReturnType='uint8_t'
+                    // @Pre=''
+                    // @Param[in]=''
+                    // @Param[out]=''
+                    // @Post=''
+                    // @Return='@return 1 on success; 0 on failure'
                     cmdLine.serial().printf("UPO_LOW");
-                    g_MAX5171_device.UPO_LOW();
-                    return true; // command was handled by MAX5171
-                }
+                    // call function UPO_LOW
+                    uint8_t result = g_MAX5171_device.UPO_LOW();
+                    cmdLine.serial().printf(" =%d\r\n", result);
+                    return true; // command handled by MAX5171
+                } // end nested case 'e0'
                 break;
-                case '8':
+                case '8': // (nested inside case 'e')
                 {
-                    // recommended for hex command codes 10..1F
-                    //~ cmdLine.serial().printf("\r\n e8 -- UPO_HIGH");
+                    // test menu command 'e8' handler:
+                    // helpString='e8 -- UPO_HIGH'
+                    // CMD_='CMD_1110_1xxx_xxxx_xxxx_UPO_HIGH'
+                    // CommandName='UPO_HIGH'
+                    // CommandParamIn='void'
+                    // CommandReturnType='uint8_t'
+                    // @Pre=''
+                    // @Param[in]=''
+                    // @Param[out]=''
+                    // @Post=''
+                    // @Return='@return 1 on success; 0 on failure'
                     cmdLine.serial().printf("UPO_HIGH");
-                    g_MAX5171_device.UPO_HIGH();
-                    return true; // command was handled by MAX5171
-                }
+                    // call function UPO_HIGH
+                    uint8_t result = g_MAX5171_device.UPO_HIGH();
+                    cmdLine.serial().printf(" =%d\r\n", result);
+                    return true; // command handled by MAX5171
+                } // end nested case 'e8'
                 break;
-            }
-        }
-        break;
-        case 'f': case 'F':
+            } // end nested switch (cmdLine[1]) inside case 'e'
+            break;
+        } // end case 'e'
+        case 'f': // (multiple characters) (testMenuFirstCharHandler="f"):
         {
             switch (cmdLine[1])
             {
-                case '0':
+                case '0': // (nested inside case 'f')
                 {
-                    // recommended for hex command codes 10..1F
-                    //~ cmdLine.serial().printf("\r\n f0 -- MODE1_DOUT_SCLK_RISING_EDGE");
+                    // test menu command 'f0' handler:
+                    // helpString='f0 -- MODE1_DOUT_SCLK_RISING_EDGE'
+                    // CMD_='CMD_1111_0xxx_xxxx_xxxx_MODE1_DOUT_SCLK_RISING_EDGE'
+                    // CommandName='MODE1_DOUT_SCLK_RISING_EDGE'
+                    // CommandParamIn='void'
+                    // CommandReturnType='uint8_t'
+                    // @Pre=''
+                    // @Param[in]=''
+                    // @Param[out]=''
+                    // @Post=''
+                    // @Return='@return 1 on success; 0 on failure'
                     cmdLine.serial().printf("MODE1_DOUT_SCLK_RISING_EDGE");
-                    g_MAX5171_device.MODE1_DOUT_SCLK_RISING_EDGE();
-                    return true; // command was handled by MAX5171
-                }
-                break;
-                case '8':
-                {
-                    // recommended for hex command codes 10..1F
-                    //~ cmdLine.serial().printf("\r\n f8 -- MODE0_DOUT_SCLK_FALLING_EDGE");
-                    cmdLine.serial().printf("MODE0_DOUT_SCLK_FALLING_EDGE");
-                    g_MAX5171_device.MODE0_DOUT_SCLK_FALLING_EDGE();
-                    return true; // command was handled by MAX5171
-                }
+                    // call function MODE1_DOUT_SCLK_RISING_EDGE
+                    uint8_t result = g_MAX5171_device.MODE1_DOUT_SCLK_RISING_EDGE();
+                    cmdLine.serial().printf(" =%d\r\n", result);
+                    return true; // command handled by MAX5171
+                } // end nested case 'f0'
                 break;
-            }
-        }
-        break;
-        case 'a': case 'A':
-        {
-            // recommended for hex command codes A0..AF
-            switch (cmdLine[1])
-            {
-                case 't': case 'T':
-#if IGNORE_AT_COMMANDS
-# if HAS_DAPLINK_SERIAL
-                    cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
-# endif // HAS_DAPLINK_SERIAL
-                    // AT command: skip the prompt to avoid confusing modem detector
-                    return false; // command not handled
-#endif // IGNORE_AT_COMMANDS
-            }
-        }
-        break;
-        case 'x': case 'X':
-        {
-        }
-        break;
-        case 'y': case 'Y':
-        {
-        }
-        break;
-        case 'z': case 'Z':
-        {
-        }
-        break;
-        case '~':     // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command
-        {
-            // TODO: '~' is not recommended for menu commands, interferes with ssh
-#if IGNORE_AT_COMMANDS
-# if HAS_DAPLINK_SERIAL
-            cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
-# endif // HAS_DAPLINK_SERIAL
-#endif // IGNORE_AT_COMMANDS
-        }
-        break;
-        case '+':     // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command
-        {
-#if IGNORE_AT_COMMANDS
-# if HAS_DAPLINK_SERIAL
-            cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
-# endif // HAS_DAPLINK_SERIAL
-#endif // IGNORE_AT_COMMANDS
-        }
-        break;
+                case '8': // (nested inside case 'f')
+                {
+                    // test menu command 'f8' handler:
+                    // helpString='f8 -- MODE0_DOUT_SCLK_FALLING_EDGE'
+                    // CMD_='CMD_1111_1xxx_xxxx_xxxx_MODE0_DOUT_SCLK_FALLING_EDGE'
+                    // CommandName='MODE0_DOUT_SCLK_FALLING_EDGE'
+                    // CommandParamIn='void'
+                    // CommandReturnType='uint8_t'
+                    // @Pre=''
+                    // @Param[in]=''
+                    // @Param[out]=''
+                    // @Post=''
+                    // @Return='@return 1 on success; 0 on failure'
+                    cmdLine.serial().printf("MODE0_DOUT_SCLK_FALLING_EDGE");
+                    // call function MODE0_DOUT_SCLK_FALLING_EDGE
+                    uint8_t result = g_MAX5171_device.MODE0_DOUT_SCLK_FALLING_EDGE();
+                    cmdLine.serial().printf(" =%d\r\n", result);
+                    return true; // command handled by MAX5171
+                } // end nested case 'f8'
+                break;
+            } // end nested switch (cmdLine[1]) inside case 'f'
+            break;
+        } // end case 'f'
     } // end switch (cmdLine[0])
-    return false; // command not handled
+    return false; // command not handled by MAX5171
 } // end bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine)