Test program running on MAX32625MBED. Control through USB Serial commands using a terminal emulator such as teraterm or putty.
Dependencies: MaximTinyTester MAX11410 CmdLine USBDevice
Diff: Test_Menu_MAX11410.cpp
- Revision:
- 35:8aa5dffe523d
- Parent:
- 32:ad00de965151
- Child:
- 37:74aa97afa030
--- a/Test_Menu_MAX11410.cpp Sun Sep 22 18:23:10 2019 -0700 +++ b/Test_Menu_MAX11410.cpp Mon Nov 11 23:30:04 2019 +0000 @@ -1,4 +1,4 @@ -// /******************************************************************************* +// /******************************************************************************* // * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved. // * // * Permission is hereby granted, free of charge, to any person obtaining a @@ -30,344 +30,318 @@ // * ownership rights. // ******************************************************************************* // */ - +#include "CmdLine.h" +// CODE GENERATOR: class declaration and docstrings +// CODE GENERATOR: example code includes +// 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 "MAX11410.h" #include "CmdLine.h" +// CODE GENERATOR: class declaration statement open -//-------------------------------------------------- -// 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 +// CODE GENERATOR: Test_Menu externs +#include "MAX11410.h" +extern MAX11410 g_MAX11410_device; // defined in main.cpp -extern MAX11410 g_MAX11410_device; // defined in main.cpp +// CODE GENERATOR: build testMenuCommand list +// CODE GENERATOR: build testMenuGlobalArgsDict common/global argument list +// CODE GENERATOR: class member function declarations +// CODE GENERATOR: MAX11410 Command Name = Init (void) --> uint8_t +// CODE GENERATOR: Menu item hint description Menu item '!' +// CODE GENERATOR: Menu item '!' -- Menu item ! +// CODE GENERATOR: test menu case '!': +// CODE GENERATOR: helpString '! -- Init' +// CODE GENERATOR: CMD_ 'None' +// CODE GENERATOR: CommandName 'Init' +// CODE GENERATOR: CommandParamIn 'void' +// CODE GENERATOR: CommandReturnType 'uint8_t' +// CODE GENERATOR: CommandPre '' +// CODE GENERATOR: CommandPost '' +// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' +// CODE GENERATOR: MAX11410 Command Name = VoltageOfCode (uint16_t value_u24) --> double +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: MAX11410 Command Name = RegWrite (MAX11410_CMD_enum_t regAddress, uint32_t regData) --> uint8_t +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: CommandDescriptionCMDWord = CMD_1aaa_aaaa_REGISTER_READ +// CODE GENERATOR: MAX11410 Command Name = RegWrite CMD_1aaa_aaaa_REGISTER_READ (MAX11410_CMD_enum_t regAddress, uint32_t regData) --> uint8_t +// CODE GENERATOR: MAX11410 Command Name = RegRead (MAX11410_CMD_enum_t regAddress, uint32_t* ptrRegData) --> uint8_t +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: CommandDescriptionCMDWord = CMD_1aaa_aaaa_REGISTER_READ +// CODE GENERATOR: MAX11410 Command Name = RegRead CMD_1aaa_aaaa_REGISTER_READ (MAX11410_CMD_enum_t regAddress, uint32_t* ptrRegData) --> uint8_t +// CODE GENERATOR: MAX11410 Command Name = RegSize (MAX11410_CMD_enum_t regAddress) --> uint8_t +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: MAX11410 Command Name = RegName (MAX11410_CMD_enum_t regAddress) --> const char* +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: MAX11410 Command Name = Configure_Voltage (MAX11410_AINP_SEL_enum_t channel_hi, MAX11410_AINN_SEL_enum_t channel_lo) --> uint8_t +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: MAX11410 Command Name = _TODO_MAX11410_Read_All_Voltages_ (MAX11410_AINP_SEL_enum_t channel_hi, MAX11410_AINN_SEL_enum_t channel_lo) --> uint8_t +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: MAX11410 Command Name = Measure_Voltage (MAX11410_AINP_SEL_enum_t channel_hi, MAX11410_AINN_SEL_enum_t channel_lo) --> uint8_t +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: MAX11410 Command Name = Configure_RTD (MAX11410_AINP_SEL_enum_t channel_RTD_Force, MAX11410_AINP_SEL_enum_t channel_RTD_Hi, MAX11410_AINN_SEL_enum_t channel_RTD_Lo) --> uint8_t +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: MAX11410 Command Name = Measure_RTD (MAX11410_AINP_SEL_enum_t channel_RTD_Force, MAX11410_AINP_SEL_enum_t channel_RTD_Hi, MAX11410_AINN_SEL_enum_t channel_RTD_Lo) --> uint8_t +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: MAX11410 Command Name = Configure_Thermocouple (MAX11410_AINP_SEL_enum_t channel_TC_Hi, MAX11410_AINN_SEL_enum_t channel_TC_Lo, MAX11410_AINP_SEL_enum_t channel_RTD_Hi, MAX11410_AINP_SEL_enum_t channel_RTD_Lo) --> uint8_t +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: MAX11410 Command Name = Measure_Thermocouple (MAX11410_AINP_SEL_enum_t channel_TC_Hi, MAX11410_AINN_SEL_enum_t channel_TC_Lo, MAX11410_AINP_SEL_enum_t channel_RTD_Hi, MAX11410_AINP_SEL_enum_t channel_RTD_Lo) --> uint8_t +// CODE GENERATOR: no Menu item hint in description +// CODE GENERATOR: testMenuGlobalArgsDict scan global property list g_MAX11410_device + +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.VRef +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.VRef argname = VRef +// CODE GENERATOR: testMenuGlobalArgsDict['VRef']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['VRef']['argtype'] = 'double' +// CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedBytestMenuItemName'] = 'None' + +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.status +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.status shadow of argname = status +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.status argname = status +// CODE GENERATOR: testMenuGlobalArgsDict['status']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['status']['argtype'] = 'uint32_t' +// CODE GENERATOR: testMenuGlobalArgsDict['status']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['status']['usedBytestMenuItemName'] = 'None' + +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.data0 +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.data0 shadow of argname = data0 +// CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11410_device.data0 argname = data0 +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['argtype'] = 'uint32_t' +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['usedBytestMenuItemName'] = 'None' + + +// CODE GENERATOR: scan testMenuCommand list for items that can be shortened to single character +// CODE GENERATOR: shorten testMenuCommand to single character if unambiguous +// CODE GENERATOR: testMenuCommand '!' already single character + +// CODE GENERATOR: help menu +bool MAX11410_menu_help(CmdLine & cmdLine) +{ + // CODE GENERATOR: command: ! + // CODE GENERATOR: help: ! -- Init + cmdLine.serial().printf("\r\n ! -- Init"); + // + cmdLine.serial().printf("\r\n @ -- print MAX11410 configuration"); + // +} bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine) { - switch (cmdLine[0]) + +// CODE GENERATOR: before switch (cmdLine[0]), test if buffer starts with a regName + // TODO: if buffer starts with a regName: + // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))): + cmdLine.serial().printf(" scan RegName... "); + for (uint8_t regAddress = 0; regAddress < 0x80; regAddress++) { - // TODO1: MAX11410 main_menu_onEOLcommandParser - case '0': - { - // // recommended for hex command codes 00..0F - // // placeholder: cmdLine.serial().printf("\r\n 3 ch=? code=? -- CODEnLOADn"); - // uint16_t ch = g_MAX5715_device.channelNumber_0_3; - // uint16_t code; - // if (cmdLine.parse_uint16_dec("ch", ch)) - // { - // } - // if (cmdLine.parse_uint16_dec("code", code)) - // { - // } - // if (cmdLine.parse_flag("xyzzy", g_xyzzy_flag, XYZZY_FLAG)) - // { - // isUpdatedSPIConfig = true; - // } - // cmdLine.serial().printf("CODEnLOADn ch=%d code=%d", ch, code); - // //~ MAX5715_CODEnLOADn(ch, code); - // cmdLine.serial().printf("\r\n placeholder"); - return true; // command was handled by MAX11410 - } - break; - case '1': - { - // recommended for hex command codes 10..1F - } - break; - case '2': - { - // recommended for hex command codes 20..2F - } - break; - case '3': - { - // recommended for hex command codes 30..3F - } - break; - case '4': + uint32_t regData = 0; + bool is_regname_query = false; + bool is_regname_assignment = false; + if (cmdLine.parse_uint32_dec(g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress), regData)) { - // recommended for hex command codes 40..4F - } - break; - case '5': - { - // recommended for hex command codes 50..5F - } - break; - case '6': - { - // recommended for hex command codes 60..6F - } - break; - case '7': - { - // recommended for hex command codes 70..7F - } - break; - case '8': - { - // recommended for hex command codes 80..8F - } - break; - case '9': - { - // recommended for hex command codes 90..9F - } - break; - case 'a': case 'A': - { - // recommended for hex command codes A0..AF - switch (cmdLine[1]) + cmdLine.serial().printf(" regAddress=0x%2.2X\r\n", (regAddress & 0xFF)); + cmdLine.serial().printf(" RegName=%s\r\n", g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress)); + // TODO: accept regName ’?’ as ‘RegRead‘ by name + is_regname_query = (cmdLine.chSeparator == '?'); + is_regname_assignment = (cmdLine.chSeparator == '='); + if (is_regname_query) { - 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 + cmdLine.serial().printf(" RegRead"); + g_MAX11410_device.RegRead((MAX11410::MAX11410_CMD_enum_t)regAddress, ®Data); + cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF)); + } + // TODO: accept regName ’=0x123456’ as ‘RegWrite’ by name + if (is_regname_assignment) + { + cmdLine.serial().printf(" RegWrite"); + cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF)); + g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData); } } - break; - case 'b': case 'B': - { - // recommended for hex command codes B0..BF - } - break; - case 'c': case 'C': - { - // recommended for hex command codes C0..CF - // cmdLine.serial().printf("\r\n CV ch=? ainp=? ainn=? pga=? -- (future) Voltage configuration"); - // cmdLine.serial().printf("\r\n CT -- (future) Thermocouple configuration"); - // cmdLine.serial().printf("\r\n CR -- (future) Resistive Temperature Device (RTD) configuration"); - #warning "Not Implemented Yet: MAX11410 menu C Voltage / Thermocouple / RTD configuration" - } - break; - case 'd': case 'D': - { - // recommended for hex command codes D0..DF - } - break; - case 'e': case 'E': - { - // recommended for hex command codes E0..EF - } - break; - case 'f': case 'F': - { - // recommended for hex command codes F0..FF - } - break; - // case 'g': case 'G': - // case 'h': case 'H': - // case 'i': case 'I': - // case 'j': case 'J': - // case 'k': case 'K': - // case 'l': case 'L': - case 'm': case 'M': - { - // cmdLine.serial().printf("\r\n MV -- (future) Voltage measurement"); - // cmdLine.serial().printf("\r\n MT -- (future) Thermocouple measurement"); - // cmdLine.serial().printf("\r\n MR -- (future) RTD measurement"); - #warning "Not Implemented Yet: MAX11410 menu M measure Voltage / Thermocouple / RTD" - } - break; - // case 'n': case 'N': - // case 'o': case 'O': - // case 'p': case 'P': - // case 'q': case 'Q': - case 'r': case 'R': - { - // cmdLine.serial().printf("\r\n R reg=? -- (future) read register"); - #warning "Not Tested Yet: MAX11410 menu R read register" - uint8_t regAddress; // = g_MAX11410_device.reg; ?? - if (cmdLine.parse_byte_dec("reg", regAddress)) - { - } - if (regAddress <= MAX11410::CMD_r001_0000_xxxx_xxxx_WAIT_START) - { - // regAddress range 0x00 .. 0x10 are 8-bit registers - uint8_t regData; - g_MAX11410_device.Read_8bit((MAX11410::MAX11410_CMD_enum_t)regAddress, ®Data); - cmdLine.serial().printf("r reg=0x%2.2x --> data=0x%2.2x\r\n", - regAddress, regData); - } - else if (regAddress <= MAX11410::CMD_r011_1001_dddd_dddd_dddd_dddd_dxxd_dddd_STATUS_IE) - { - // regAddress range 0x11 .. 0x39 are 24-bit registers - uint32_t regData; - g_MAX11410_device.Read_24bit((MAX11410::MAX11410_CMD_enum_t)regAddress, ®Data); - cmdLine.serial().printf("r reg=0x%2.2x --> data=0x%6.6lx\r\n", - regAddress, regData); - } - else - { - // regAddress range 0x3a .. 0x6f are 16-bit registers - uint16_t regData; - g_MAX11410_device.Read_16bit((MAX11410::MAX11410_CMD_enum_t)regAddress, ®Data); - cmdLine.serial().printf("r reg=0x%2.2x --> data=0x%4.4x\r\n", - regAddress, regData); - } - return true; // command was handled by MAX11410 - } - break; - case 's': case 'S': + } // end for regAddr + +// CODE GENERATOR: testMenuGlobalArgsDict Consolidate common/global argument parsing + +// CODE GENERATOR: testMenuGlobalArgsDict['VRef']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['VRef']['argtype'] = 'double' +// CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedBytestMenuItemName'] = 'None' + // parse argument double VRef + double VRef = g_MAX11410_device.VRef; // default to global property value + if (cmdLine.parse_double("VRef", VRef)) { - // cmdLine.serial().printf("\r\n S -- (future) read status register"); - #warning "Not Tested Yet: MAX11410 menu S read status register" - g_MAX11410_device.Read_24bit(MAX11410::CMD_r011_1000_dddd_dddd_dddd_dddd_dxxx_dddd_STATUS, &g_MAX11410_device.status); - cmdLine.serial().printf("status=0x%6.6lx\r\n", - g_MAX11410_device.status); - return true; // command was handled by MAX11410 + g_MAX11410_device.VRef = VRef; // update global property value } - break; - // case 't': case 'T': - // case 'u': case 'U': - // case 'v': case 'V': - case 'w': case 'W': + +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['argtype'] = 'uint32_t' +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['data0']['usedBytestMenuItemName'] = 'None' + // parse argument uint32_t data0 + uint32_t data0 = g_MAX11410_device.data0; // default to global property value + if (cmdLine.parse_uint32_dec("data0", data0)) { - // cmdLine.serial().printf("\r\n W reg=? data=? -- (future) write register"); - #warning "Not Tested Yet: MAX11410 menu W write register" - uint8_t regAddress; // = g_MAX11410_device.reg; ?? - if (cmdLine.parse_byte_dec("reg", regAddress)) - { - } - if (regAddress <= MAX11410::CMD_r001_0000_xxxx_xxxx_WAIT_START) - { - // regAddress range 0x00 .. 0x10 are 8-bit registers - uint8_t regData; - if (cmdLine.parse_byte_dec("data", regData)) - { - } - g_MAX11410_device.Write_8bit((MAX11410::MAX11410_CMD_enum_t)regAddress, regData); - cmdLine.serial().printf("w reg=0x%2.2x data=0x%2.2x\r\n", - regAddress, regData); - } - else if (regAddress <= MAX11410::CMD_r011_1001_dddd_dddd_dddd_dddd_dxxd_dddd_STATUS_IE) - { - // regAddress range 0x11 .. 0x39 are 24-bit registers -#warning "CmdLine needs to define parse_uint32_dec()" - //uint32_t regData; - //if (cmdLine.parse_uint32_dec("data", regData)) - uint16_t regData; - if (cmdLine.parse_uint16_dec("data", regData)) - { - } - g_MAX11410_device.Write_24bit((MAX11410::MAX11410_CMD_enum_t)regAddress, regData); - cmdLine.serial().printf("w reg=0x%2.2x data=0x%6.6lx\r\n", - regAddress, regData); - } - else - { - // regAddress range 0x3a .. 0x6f are 16-bit registers - uint16_t regData; - if (cmdLine.parse_uint16_dec("data", regData)) - { - } - g_MAX11410_device.Write_16bit((MAX11410::MAX11410_CMD_enum_t)regAddress, regData); - cmdLine.serial().printf("w reg=0x%2.2x regData=0x%4.4x\r\n", - regAddress, regData); - } - // g_MAX11410_device.Write_8bit(MAX11410_CMD_enum_t regAddress, uint8_t regData) - // g_MAX11410_device.Write_16bit(MAX11410_CMD_enum_t regAddress, uint16_t regData); - // g_MAX11410_device.Write_24bit(MAX11410_CMD_enum_t regAddress, uint32_t regData); - return true; // command was handled by MAX11410 + g_MAX11410_device.data0 = data0; // update global property value } - break; - case 'x': case 'X': - { - } - break; - case 'y': case 'Y': - { - } - break; - case 'z': case 'Z': - { - } - break; - case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command + +// CODE GENERATOR: testMenuGlobalArgsDict['status']['alias'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['status']['argtype'] = 'uint32_t' +// CODE GENERATOR: testMenuGlobalArgsDict['status']['usedByCommandName'] = 'None' +// CODE GENERATOR: testMenuGlobalArgsDict['status']['usedBytestMenuItemName'] = 'None' + // parse argument uint32_t status + uint32_t status = g_MAX11410_device.status; // default to global property value + if (cmdLine.parse_uint32_dec("status", status)) { - // 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 + g_MAX11410_device.status = status; // update global property value } - 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; + + switch (cmdLine[0]) + { +// CODE GENERATOR: generate @ command print global property values of g_MAX11410_device case '@': { - // // Menu @ -- print device configuration - // cmdLine.serial().printf("\r\n @ -- (future) print device configuration"); - #warning "Not Tested Yet: MAX11410 menu @ print device configuration" - // // - // print shadow register configuration - // - // shadow of write-only register CODE dddd_dddd_dddd_0000 - //~ int16_t CMD_1000_CODE; - // int index = 0; - // for (index = 0; index < 4; index++) - // { - // cmdLine.serial().printf("CODE %c=0x%4.4x MAX5715_VoltageOfCode(%d)=%5.3fV\r\n", - // (char)('A' + index), - // (g_MAX5715_device.Shadow_0010_nnnn_CODE[index] & 0xFFFF), - // g_MAX5715_device.CODE[index], - // g_MAX5715_device.VoltageOfCode(g_MAX5715_device.CODE[index]) - // ); - // } - // - // cmdLine.serial().printf("\r\n"); +// CODE GENERATOR: @ command print double g_MAX11410_device.VRef + cmdLine.serial().printf("VRef = "); + cmdLine.serial().printf("%f\n", g_MAX11410_device.VRef); +// CODE GENERATOR: @ command print uint32_t g_MAX11410_device.status + cmdLine.serial().printf("status = "); + cmdLine.serial().printf("%d = 0x%8.8x\n", g_MAX11410_device.status, g_MAX11410_device.status); +// CODE GENERATOR: @ command print uint32_t g_MAX11410_device.data0 + cmdLine.serial().printf("data0 = "); + cmdLine.serial().printf("%d = 0x%8.8x\n", g_MAX11410_device.data0, g_MAX11410_device.data0); + return true; // command handled by MAX11410 + break; + } +// CODE GENERATOR: TODO1: generate GPIO commands for LDAC, CLR, etc. based on device driver function names + // case 'G'..'Z','g'..'z' are reserved for GPIO commands + // case 'A'..'F','a'..'f' may be available if not claimed by bitstream commands + +// CODE GENERATOR: test menu + // case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands + // has_register_write_command: case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands +// CODE GENERATOR: test menu case '!': +// CODE GENERATOR: helpString '! -- Init' +// CODE GENERATOR: CMD_ 'None' +// CODE GENERATOR: CommandName 'Init' +// CODE GENERATOR: CommandParamIn 'void' +// CODE GENERATOR: CommandReturnType 'uint8_t' +// CODE GENERATOR: CommandPre '' +// CODE GENERATOR: CommandPost '' +// CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure' + case '!': + { + // test menu command '!' handler: + // helpString='! -- Init' + // CMD_='None' + // CommandName='Init' + // CommandParamIn='void' + // CommandReturnType='uint8_t' + // @Pre='' + // @Post='' + // @Return='@return 1 on success; 0 on failure' + cmdLine.serial().printf("Init"); + // call function Init + uint8_t result = g_MAX11410_device.Init(); + cmdLine.serial().printf(" =%d", result); + return true; // command handled by MAX11410 + } // end case '!' + break; + + // has_register_write_command: case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + { + // hexadecimal codes get parsed as bytecodes // - //cmdLine.serial().printf("channelNumber_0_3=%d channels_bitmask_DCBA=%d\r\n", - // (g_MAX5715_device.channelNumber_0_3 & 0xFFFF), - // (g_MAX5715_device.channels_bitmask_DCBA & 0xFFFF)); - // - cmdLine.serial().printf("VRef=%5.6fV\r\n", g_MAX11410_device.VRef); - // dtostrf width and precision: 2.5V / 2^24 LSB = ______ volts per LSB - // - // shadow of register CMD_r011_1000_dddd_dddd_dddd_dddd_dxxx_dddd_STATUS - cmdLine.serial().printf("status=0x%6.6lx\r\n", - g_MAX11410_device.status); + // parse_byteCount_byteList_dec() assumes all keyword args have already been removed from the buffer + // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT]; + #define MAX_SPI_BYTE_COUNT 32 + size_t byteCount = byteCount; + static char mosiData[MAX_SPI_BYTE_COUNT]; + static char misoData[MAX_SPI_BYTE_COUNT]; + if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData, + MAX_SPI_BYTE_COUNT)) + { + // if length is 1 byte then operation is RegRead, otherwise RegWrite + // register_read_function 'RegRead' + // register_write_function 'RegWrite' + // register_name_function 'RegName' + // register_size_function 'RegSize' + MAX11410::MAX11410_CMD_enum_t regAddress = (MAX11410::MAX11410_CMD_enum_t)((mosiData[0] &~ MAX11410::CMD_1aaa_aaaa_REGISTER_READ) & 0xFF); + cmdLine.serial().printf(" regAddress=0x%2.2x\r\n", (regAddress & 0xFF)); + cmdLine.serial().printf(" RegName=%s\r\n", g_MAX11410_device.RegName(regAddress)); + uint32_t regData = 0; + int regSize = g_MAX11410_device.RegSize(regAddress); + cmdLine.serial().printf(" RegSize=%d\r\n", regSize); + switch(regSize) + { + case 8: + regData = ((uint32_t)mosiData[1] & 0xFF); + break; + case 16: + regData = (((uint32_t)mosiData[1] & 0xFF) << 8) + ((uint32_t)mosiData[2] & 0xFF); + break; + case 24: + regData = (((uint32_t)mosiData[1] & 0xFF) << 16) + (((uint32_t)mosiData[2] & 0xFF) << 8) + ((uint32_t)mosiData[3] & 0xFF); + break; + } + if ((byteCount == 1) || (regAddress & MAX11410::CMD_1aaa_aaaa_REGISTER_READ)) + { + cmdLine.serial().printf(" RegRead"); + g_MAX11410_device.RegRead(regAddress, ®Data); + cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF)); + } + else + { + cmdLine.serial().printf(" RegWrite regData=0x%6.6X\r\n", (regData & 0x00FFFFFF)); + g_MAX11410_device.RegWrite(regAddress, regData); + } + // is there support function shadow regValue of regAddr? + } + return true; // command handled by MAX11410 // - // shadow of register CMD_r011_0000_dddd_dddd_dddd_dddd_dddd_dddd_DATA0 - double voltage_of_data0; - voltage_of_data0 = g_MAX11410_device.VoltageOfCode(g_MAX11410_device.data0); - cmdLine.serial().printf("data0=0x%6.6lx=%lu=%ld=%5.6fV\r\n", - g_MAX11410_device.data0, - g_MAX11410_device.data0, - g_MAX11410_device.data0, - voltage_of_data0); - // - return true; // command was handled by MAX11410 - } + } // end case '0'..'9','A'..'F','a'..'f' break; } // end switch (cmdLine[0]) - return false; // command not handled + return false; // command not handled by MAX11410 } // end bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine) + +// CODE GENERATOR: class declaration statement close