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

Dependencies:   MaximTinyTester CmdLine MAX541 USBDevice

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Test_Menu_MAX11043.cpp Source File

Test_Menu_MAX11043.cpp

00001 // /*******************************************************************************
00002 // * Copyright (C) 2020 Maxim Integrated Products, Inc., All Rights Reserved.
00003 // *
00004 // * Permission is hereby granted, free of charge, to any person obtaining a
00005 // * copy of this software and associated documentation files (the "Software"),
00006 // * to deal in the Software without restriction, including without limitation
00007 // * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008 // * and/or sell copies of the Software, and to permit persons to whom the
00009 // * Software is furnished to do so, subject to the following conditions:
00010 // *
00011 // * The above copyright notice and this permission notice shall be included
00012 // * in all copies or substantial portions of the Software.
00013 // *
00014 // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00015 // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00016 // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00017 // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
00018 // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00019 // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00020 // * OTHER DEALINGS IN THE SOFTWARE.
00021 // *
00022 // * Except as contained in this notice, the name of Maxim Integrated
00023 // * Products, Inc. shall not be used except as stated in the Maxim Integrated
00024 // * Products, Inc. Branding Policy.
00025 // *
00026 // * The mere transfer of this software does not imply any licenses
00027 // * of trade secrets, proprietary technology, copyrights, patents,
00028 // * trademarks, maskwork rights, or any other form of intellectual
00029 // * property whatsoever. Maxim Integrated Products, Inc. retains all
00030 // * ownership rights.
00031 // *******************************************************************************
00032 // */ * MANUAL EDITS PRESENT *
00033 #include "CmdLine.h"
00034 #include "MaximTinyTester.h"
00035 // CODE GENERATOR: class declaration and docstrings
00036 // CODE GENERATOR: example code includes
00037 // example code includes
00038 // standard include for target platform -- Platform_Include_Boilerplate
00039 #include "mbed.h"
00040 // Platforms:
00041 //   - MAX32625MBED
00042 //      - supports mbed-os-5.11, requires USBDevice library
00043 //      - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
00044 //      - remove max32630fthr library (if present)
00045 //      - remove MAX32620FTHR library (if present)
00046 //   - MAX32600MBED
00047 //      - remove max32630fthr library (if present)
00048 //      - remove MAX32620FTHR library (if present)
00049 //      - Windows 10 note:  Don't connect HDK until you are ready to load new firmware into the board.
00050 //   - NUCLEO_F446RE
00051 //      - remove USBDevice library
00052 //      - remove max32630fthr library (if present)
00053 //      - remove MAX32620FTHR library (if present)
00054 //   - NUCLEO_F401RE
00055 //      - remove USBDevice library
00056 //      - remove max32630fthr library (if present)
00057 //      - remove MAX32620FTHR library (if present)
00058 //   - MAX32630FTHR
00059 //      - #include "max32630fthr.h"
00060 //      - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/
00061 //      - remove MAX32620FTHR library (if present)
00062 //   - MAX32620FTHR
00063 //      - #include "MAX32620FTHR.h"
00064 //      - remove max32630fthr library (if present)
00065 //      - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
00066 //      - not tested yet
00067 //   - MAX32625PICO
00068 //      - remove max32630fthr library (if present)
00069 //      - remove MAX32620FTHR library (if present)
00070 //      - not tested yet
00071 //
00072 // end Platform_Include_Boilerplate
00073 #include "MAX11043.h"
00074 #include "CmdLine.h"
00075 #include "MaximTinyTester.h"
00076 // CODE GENERATOR: class declaration statement open
00077 
00078 // CODE GENERATOR: Test_Menu externs
00079 #include "MAX11043.h"
00080 extern MAX11043 g_MAX11043_device; // defined in main.cpp
00081 
00082 //--------------------------------------------------
00083 // Diagnostic: Read 4 command -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.
00084 #ifndef Has_Read4Command_Command
00085 #define Has_Read4Command_Command 1
00086 #endif // Has_Read4Command_Command
00087 #if Has_Read4Command_Command
00088 #endif // Has_Read4Command_Command
00089 //--------------------------------------------------
00090 // Diagnostic: Read 4 command -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.
00091 #ifndef Use_Read4Command_Thread
00092 #define Use_Read4Command_Thread 1
00093 #endif // Use_Read4Command_Thread
00094 #if Use_Read4Command_Thread
00095 #endif // Use_Read4Command_Thread
00096 
00097 //--------------------------------------------------
00098 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
00099 #ifndef MAX11043_ScopeTrigger_MAX32625MBED_D5
00100 #define MAX11043_ScopeTrigger_MAX32625MBED_D5 1
00101 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
00102 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
00103 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
00104 // WIP MAX11043 interrupt EOC echo - moving DigitalOut ScopeTrigger to global scope, it compiles but there is no activity on scope
00105 extern DigitalInOut digitalInOut5; // declared in Test_Main_MAX11043.cpp (D5, PIN_INPUT, PullUp, 1) 
00106 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
00107 
00108 #if Use_Read4Command_Thread
00109 #define MYTIMEREVENTFLAG_ENABLE_SPI     (1UL << 0)
00110 #define MYTIMEREVENTFLAG_RESET_MINMAX   (1UL << 1)
00111 #define MYTIMEREVENTFLAG_FAKE_DATA      (1UL << 2)
00112 EventFlags Read4Command_Thread_event_flags;
00113 Thread Read4Command_Thread;
00114 int adca_newest = 0;
00115 int adcb_newest = 0;
00116 int adcc_newest = 0;
00117 int adcd_newest = 0;
00118 int adcX_MIN_SEEN_INIT_INT16_MAX = 0x7FFF; // INT16_MAX
00119 int adcX_MAX_SEEN_INIT_INT16_MIN = 0x8000; // INT16_MIN
00120 int adca_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
00121 int adca_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
00122 int adcb_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
00123 int adcb_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
00124 int adcc_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
00125 int adcc_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
00126 int adcd_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
00127 int adcd_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
00128 #endif // Use_Read4Command_Thread
00129 #if Use_Read4Command_Thread
00130 void Read4Command_Thread_handler()
00131 {
00132     const int convrun_pulse_width_us = 30;
00133     const int convrun_stop_us = 10;
00134     // running in thread context in Thread Read4Command_Thread
00135     // operate the SPI interface at specified sample rate
00136     // shared read only: periodicInterruptTimer_interval_usec
00137     while (true) {
00138 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
00139 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
00140         //~ digitalInOut5.write(0); // ScopeTrigger
00141         digitalInOut5.write(1); // ScopeTrigger
00142 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
00143         //signal_wait(int32_t signals, uint32_t millisec=osWaitForever)
00144         //flags_read = Read4Command_Thread_event_flags.wait_any(MYTIMEREVENTFLAG_ENABLE_SPI);
00145         Read4Command_Thread_event_flags.wait_any(MYTIMEREVENTFLAG_ENABLE_SPI, osWaitForever, false); // clear=false: don't auto clear the flag
00146         //
00147         if (Read4Command_Thread_event_flags.get() & MYTIMEREVENTFLAG_RESET_MINMAX)
00148         {
00149             adca_MIN_SEEN = +32767; // adcX_MIN_SEEN_INIT_INT16_MAX
00150             adcb_MIN_SEEN = +32767; // adcX_MIN_SEEN_INIT_INT16_MAX
00151             adcc_MIN_SEEN = +32767; // adcX_MIN_SEEN_INIT_INT16_MAX
00152             adcd_MIN_SEEN = +32767; // adcX_MIN_SEEN_INIT_INT16_MAX
00153             //
00154             adca_MAX_SEEN = -32768; // adcX_MAX_SEEN_INIT_INT16_MIN
00155             adcb_MAX_SEEN = -32768; // adcX_MAX_SEEN_INIT_INT16_MIN
00156             adcc_MAX_SEEN = -32768; // adcX_MAX_SEEN_INIT_INT16_MIN
00157             adcd_MAX_SEEN = -32768; // adcX_MAX_SEEN_INIT_INT16_MIN
00158             //
00159             Read4Command_Thread_event_flags.clear(MYTIMEREVENTFLAG_RESET_MINMAX);
00160         }
00161         //
00162         // CONVRUN = H -- perform ADC conversions (EOC will pulse, and data registers will update)
00163         g_MAX11043_device.CONVRUNoutputValue(1);
00164         //
00165         // delay at least 9us to ensure at least one converion happens
00166         wait_us(convrun_pulse_width_us);
00167         //
00168         // CONVRUN = L -- stop ADC conversions
00169         g_MAX11043_device.CONVRUNoutputValue(0);
00170         //
00171         // delay at least 9us to ensure final converion complete
00172         wait_us(convrun_stop_us);
00173         //
00174         // run SPI to capture 4 channels
00175         if (Read4Command_Thread_event_flags.get() & MYTIMEREVENTFLAG_FAKE_DATA)
00176         {
00177             // raw uint32_t result code
00178             g_MAX11043_device.adca = 0x7FFF; // +32767 adcX_MIN_SEEN_INIT_INT16_MAX;
00179             g_MAX11043_device.adcb = 0x000A; // +10
00180             g_MAX11043_device.adcc = 0xFFF6; // -10
00181             g_MAX11043_device.adcd = 0x8000; // -32768 adcX_MAX_SEEN_INIT_INT16_MIN;
00182             
00183             // are the initial MIN/MAX swapped? adcX_MAX_SEEN_INIT_INT16_MIN adcX_MIN_SEEN_INIT_INT16_MAX
00184             adca_MIN_SEEN = +32767; // adcX_MIN_SEEN_INIT_INT16_MAX
00185             adcb_MIN_SEEN = +32767; // adcX_MIN_SEEN_INIT_INT16_MAX
00186             adcc_MIN_SEEN = +32767; // adcX_MIN_SEEN_INIT_INT16_MAX
00187             adcd_MIN_SEEN = +32767; // adcX_MIN_SEEN_INIT_INT16_MAX
00188             //
00189             adca_MAX_SEEN = -32768; // adcX_MAX_SEEN_INIT_INT16_MIN
00190             adcb_MAX_SEEN = -32768; // adcX_MAX_SEEN_INIT_INT16_MIN
00191             adcc_MAX_SEEN = -32768; // adcX_MAX_SEEN_INIT_INT16_MIN
00192             adcd_MAX_SEEN = -32768; // adcX_MAX_SEEN_INIT_INT16_MIN
00193         }
00194         else
00195         {
00196             g_MAX11043_device.Read_ADCabcd();
00197         }
00198         // post: g_MAX11043_device.adca was updated
00199         // post: g_MAX11043_device.adcb was updated
00200         // post: g_MAX11043_device.adcc was updated
00201         // post: g_MAX11043_device.adcd was updated
00202         //
00203         // TODO: capture min/max 2's complement value each channel
00204         // #define SIGN_EXTEND_INT16_VALUE(x) (((x)&(0x8000))?((x)-65536):(x))
00205         // adca_newest = SIGN_EXTEND_INT16_VALUE(g_MAX11043_device.adca);
00206         // adcb_newest = SIGN_EXTEND_INT16_VALUE(g_MAX11043_device.adcb);
00207         // adcc_newest = SIGN_EXTEND_INT16_VALUE(g_MAX11043_device.adcc);
00208         // adcd_newest = SIGN_EXTEND_INT16_VALUE(g_MAX11043_device.adcd);
00209         adca_newest = g_MAX11043_device.adca; // if (adca_newest & 0x8000) { adca_newest = adca_newest - 65536; }
00210         adcb_newest = g_MAX11043_device.adcb; // if (adcb_newest & 0x8000) { adcb_newest = adcb_newest - 65536; }
00211         adcc_newest = g_MAX11043_device.adcc; // if (adcc_newest & 0x8000) { adcc_newest = adcc_newest - 65536; }
00212         adcd_newest = g_MAX11043_device.adcd; // if (adcd_newest & 0x8000) { adcd_newest = adcd_newest - 65536; }
00213         // 2020-02-26 this fails because using LDRHI instruction (unsigned comparison), must use signed instead.
00214         // Try SIGN_EXTEND_INT16_VALUE to force signed comparison (ldrGE, ldrLT, ldrGT, ldrLE) instead of unsigned comparision (ldrHS, ldrLO, ldrHI, ldrLS)
00215         if (adca_MAX_SEEN < adca_newest) {
00216             adca_MAX_SEEN = adca_newest;
00217 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
00218 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
00219             if (Read4Command_Thread_event_flags.get() & MYTIMEREVENTFLAG_FAKE_DATA == 0)
00220             {
00221             digitalInOut5.write(0); // ScopeTrigger
00222             wait_us(5);
00223             digitalInOut5.write(1); // ScopeTrigger
00224             }
00225 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
00226         }
00227         if (adca_MIN_SEEN > adca_newest) {
00228             adca_MIN_SEEN = adca_newest;
00229 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
00230 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
00231             if (Read4Command_Thread_event_flags.get() & MYTIMEREVENTFLAG_FAKE_DATA == 0)
00232             {
00233             digitalInOut5.write(0); // ScopeTrigger
00234             wait_us(10);
00235             digitalInOut5.write(1); // ScopeTrigger
00236             }
00237 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
00238         }
00239         if (adcb_MAX_SEEN < adcb_newest) {
00240             adcb_MAX_SEEN = adcb_newest;
00241 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
00242 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
00243             if (Read4Command_Thread_event_flags.get() & MYTIMEREVENTFLAG_FAKE_DATA == 0)
00244             {
00245             digitalInOut5.write(0); // ScopeTrigger
00246             wait_us(15);
00247             digitalInOut5.write(1); // ScopeTrigger
00248             }
00249 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
00250         }
00251         if (adcb_MIN_SEEN > adcb_newest) {
00252             adcb_MIN_SEEN = adcb_newest;
00253 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
00254 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
00255             if (Read4Command_Thread_event_flags.get() & MYTIMEREVENTFLAG_FAKE_DATA == 0)
00256             {
00257             digitalInOut5.write(0); // ScopeTrigger
00258             wait_us(20);
00259             digitalInOut5.write(1); // ScopeTrigger
00260             }
00261 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
00262         }
00263         if (adcc_MAX_SEEN < adcc_newest) {
00264             adcc_MAX_SEEN = adcc_newest;
00265 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
00266 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
00267             if (Read4Command_Thread_event_flags.get() & MYTIMEREVENTFLAG_FAKE_DATA == 0)
00268             {
00269             digitalInOut5.write(0); // ScopeTrigger
00270             wait_us(15);
00271             digitalInOut5.write(1); // ScopeTrigger
00272             }
00273 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
00274         }
00275         if (adcc_MIN_SEEN > adcc_newest) {
00276             adcc_MIN_SEEN = adcc_newest;
00277 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
00278 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
00279             if (Read4Command_Thread_event_flags.get() & MYTIMEREVENTFLAG_FAKE_DATA == 0)
00280             {
00281             digitalInOut5.write(0); // ScopeTrigger
00282             wait_us(20);
00283             digitalInOut5.write(1); // ScopeTrigger
00284             }
00285 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
00286         }
00287         if (adcd_MAX_SEEN < adcd_newest) {
00288             adcd_MAX_SEEN = adcd_newest;
00289 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
00290 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
00291             if (Read4Command_Thread_event_flags.get() & MYTIMEREVENTFLAG_FAKE_DATA == 0)
00292             {
00293             digitalInOut5.write(0); // ScopeTrigger
00294             wait_us(15);
00295             digitalInOut5.write(1); // ScopeTrigger
00296             }
00297 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
00298         }
00299         if (adcd_MIN_SEEN > adcd_newest) {
00300             adcd_MIN_SEEN = adcd_newest;
00301 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
00302 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
00303             if (Read4Command_Thread_event_flags.get() & MYTIMEREVENTFLAG_FAKE_DATA == 0)
00304             {
00305             digitalInOut5.write(0); // ScopeTrigger
00306             wait_us(20);
00307             digitalInOut5.write(1); // ScopeTrigger
00308             }
00309 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
00310         }
00311         // TODO: compare with thresholds, report if exceeded
00312         //
00313         // blocking delay time us_timestamp_t periodicInterruptTimer_interval_usec
00314         //~ const us_timestamp_t overhead_usec = 24;
00315         //~ if (periodicInterruptTimer_interval_usec > overhead_usec) {
00316             //~ wait_us(periodicInterruptTimer_interval_usec - overhead_usec);
00317         //~ }
00318     }
00319 }
00320 #endif // Use_Read4Command_Thread
00321 #if Use_Read4Command_Thread
00322     //~ Read4Command_Thread_event_flags.set(MYTIMEREVENTFLAG_ENABLE_SPI);
00323 #endif // Use_Read4Command_Thread
00324 #if Use_Read4Command_Thread
00325     //~ Read4Command_Thread_event_flags.clear(MYTIMEREVENTFLAG_ENABLE_SPI);
00326 #endif // Use_Read4Command_Thread
00327 #if Use_Read4Command_Thread
00328     // init
00329     //~ Read4Command_Thread.start(Read4Command_Thread_handler);
00330 #endif // Use_Read4Command_Thread
00331 
00332 // CODE GENERATOR: build testMenuCommand list
00333 // CODE GENERATOR: build testMenuGlobalArgsDict common/global argument list
00334 // CODE GENERATOR: class member function declarations
00335 // CODE GENERATOR: MAX11043 Command Name = Init (void) --> uint8_t
00336 // CODE GENERATOR: Menu item hint description Menu item '!'
00337 // CODE GENERATOR: Menu item '!' -- Menu item !
00338 // CODE GENERATOR: test menu case '!':
00339 // CODE GENERATOR:           helpString '! -- Init'
00340 // CODE GENERATOR:           CMD_ 'None'
00341 // CODE GENERATOR:           CommandName 'Init'
00342 // CODE GENERATOR:           CommandParamIn 'void'
00343 // CODE GENERATOR:           CommandReturnType 'uint8_t'
00344 // CODE GENERATOR:           CommandPre ''
00345 // CODE GENERATOR:           CommandDocParamIn ''
00346 // CODE GENERATOR:           CommandDocParamOut ''
00347 // CODE GENERATOR:           CommandPost ''
00348 // CODE GENERATOR:           CommandReturn '@return 1 on success; 0 on failure'
00349 // CODE GENERATOR: MAX11043 Command Name = RegWrite (MAX11043_CMD_enum_t commandByte, uint32_t regData) --> uint8_t
00350 // CODE GENERATOR: no Menu item hint in description
00351 // CODE GENERATOR: MAX11043 Command Name = RegRead (MAX11043_CMD_enum_t commandByte, uint32_t* ptrRegData) --> uint8_t
00352 // CODE GENERATOR: no Menu item hint in description
00353 // CODE GENERATOR: MAX11043 Command Name = RegSize (MAX11043_CMD_enum_t commandByte) --> uint8_t
00354 // CODE GENERATOR: no Menu item hint in description
00355 // CODE GENERATOR: MAX11043 Command Name = DecodeCommand (MAX11043_CMD_enum_t commandByte) --> MAX11043::MAX11043_CMDOP_enum_t
00356 // CODE GENERATOR: no Menu item hint in description
00357 // CODE GENERATOR: MAX11043 Command Name = RegAddrOfCommand (MAX11043_CMD_enum_t commandByte) --> uint8_t
00358 // CODE GENERATOR: no Menu item hint in description
00359 // CODE GENERATOR: MAX11043 Command Name = IsRegReadCommand (MAX11043_CMD_enum_t commandByte) --> uint8_t
00360 // CODE GENERATOR: no Menu item hint in description
00361 // CODE GENERATOR: MAX11043 Command Name = RegName (MAX11043_CMD_enum_t commandByte) --> const char*
00362 // CODE GENERATOR: no Menu item hint in description
00363 // CODE GENERATOR: MAX11043 Command Name = Read_ADCabcd (void) --> uint8_t
00364 // CODE GENERATOR: Menu item hint description Menu item '$' -> adca, adcb, adcc, adcd
00365 // CODE GENERATOR: Menu item '$' -> adca, adcb, adcc, adcd -- Menu item $
00366 // CODE GENERATOR: test menu case '$':
00367 // CODE GENERATOR:           helpString '$ -- Read_ADCabcd'
00368 // CODE GENERATOR:           CMD_ 'None'
00369 // CODE GENERATOR:           CommandName 'Read_ADCabcd'
00370 // CODE GENERATOR:           CommandParamIn 'void'
00371 // CODE GENERATOR:           CommandReturnType 'uint8_t'
00372 // CODE GENERATOR:           CommandPre ''
00373 // CODE GENERATOR:           CommandDocParamIn ''
00374 // CODE GENERATOR:           CommandDocParamOut ''
00375 // CODE GENERATOR:           CommandPost ''
00376 // CODE GENERATOR:           CommandReturn '@return 1 on success; 0 on failure'
00377 // CODE GENERATOR: MAX11043 Command Name = Write_AGain (uint32_t gain) --> uint8_t
00378 // CODE GENERATOR: Menu item hint description Menu item 'GA'
00379 // CODE GENERATOR: Menu item 'GA' -- Menu item GA
00380 // CODE GENERATOR: MAX11043 help: GA uint32_t gain -- Write_AGain
00381 // CODE GENERATOR: MAX11043 helpString: 'GA gain=? -- Write_AGain'
00382 // CODE GENERATOR: test menu case 'GA':
00383 // CODE GENERATOR:           helpString 'GA gain=? -- Write_AGain'
00384 // CODE GENERATOR:           CMD_ 'None'
00385 // CODE GENERATOR:           CommandName 'Write_AGain'
00386 // CODE GENERATOR:           CommandParamIn 'uint32_t gain'
00387 // CODE GENERATOR:           CommandReturnType 'uint8_t'
00388 // CODE GENERATOR:           CommandPre ''
00389 // CODE GENERATOR:           CommandDocParamIn '@param[in] gain 2's complement, 0x800=0.25V/V, 0x1000=0.5V/V, 0x2000=1V/V, 0x4000=2V/V, default=0x2000'
00390 // CODE GENERATOR:           CommandDocParamOut ''
00391 // CODE GENERATOR:           CommandPost ''
00392 // CODE GENERATOR:           CommandReturn '@return 1 on success; 0 on failure'
00393 // CODE GENERATOR: MAX11043 Command Name = Configure_Demo (void) --> void
00394 // CODE GENERATOR: Menu item hint description Menu item 'XD'
00395 // CODE GENERATOR: Menu item 'XD' -- Menu item XD
00396 // CODE GENERATOR: test menu case 'XD':
00397 // CODE GENERATOR:           helpString 'XD -- Configure_Demo'
00398 // CODE GENERATOR:           CMD_ 'None'
00399 // CODE GENERATOR:           CommandName 'Configure_Demo'
00400 // CODE GENERATOR:           CommandParamIn 'void'
00401 // CODE GENERATOR:           CommandReturnType 'void'
00402 // CODE GENERATOR:           CommandPre ''
00403 // CODE GENERATOR:           CommandDocParamIn ''
00404 // CODE GENERATOR:           CommandDocParamOut ''
00405 // CODE GENERATOR:           CommandPost ''
00406 // CODE GENERATOR:           CommandReturn ''
00407 // CODE GENERATOR: MAX11043 Command Name = Configure_XXXXX (uint8_t linef, uint8_t rate) --> uint8_t
00408 // CODE GENERATOR: Menu item hint description Menu item 'XX'
00409 // CODE GENERATOR: Menu item 'XX' -- Menu item XX
00410 // CODE GENERATOR: MAX11043 help: XX uint8_t linef, uint8_t rate -- Configure_XXXXX
00411 // CODE GENERATOR: MAX11043 helpString: 'XX linef=? rate=? -- Configure_XXXXX'
00412 // CODE GENERATOR: test menu case 'XX':
00413 // CODE GENERATOR:           helpString 'XX linef=? rate=? -- Configure_XXXXX'
00414 // CODE GENERATOR:           CMD_ 'None'
00415 // CODE GENERATOR:           CommandName 'Configure_XXXXX'
00416 // CODE GENERATOR:           CommandParamIn 'uint8_t linef, uint8_t rate'
00417 // CODE GENERATOR:           CommandReturnType 'uint8_t'
00418 // CODE GENERATOR:           CommandPre ''
00419 // CODE GENERATOR:           CommandDocParamIn ''
00420 // CODE GENERATOR:           CommandDocParamOut ''
00421 // CODE GENERATOR:           CommandPost ''
00422 // CODE GENERATOR:           CommandReturn '@return 1 on success; 0 on failure'
00423 // CODE GENERATOR: MAX11043 Command Name = Configure_XXXXY (uint8_t linef, uint8_t rate) --> uint8_t
00424 // CODE GENERATOR: Menu item hint description Menu item 'XY'
00425 // CODE GENERATOR: Menu item 'XY' -- Menu item XY
00426 // CODE GENERATOR: MAX11043 help: XY uint8_t linef, uint8_t rate -- Configure_XXXXY
00427 // CODE GENERATOR: MAX11043 helpString: 'XY linef=? rate=? -- Configure_XXXXY'
00428 // CODE GENERATOR: test menu case 'XY':
00429 // CODE GENERATOR:           helpString 'XY linef=? rate=? -- Configure_XXXXY'
00430 // CODE GENERATOR:           CMD_ 'None'
00431 // CODE GENERATOR:           CommandName 'Configure_XXXXY'
00432 // CODE GENERATOR:           CommandParamIn 'uint8_t linef, uint8_t rate'
00433 // CODE GENERATOR:           CommandReturnType 'uint8_t'
00434 // CODE GENERATOR:           CommandPre ''
00435 // CODE GENERATOR:           CommandDocParamIn ''
00436 // CODE GENERATOR:           CommandDocParamOut ''
00437 // CODE GENERATOR:           CommandPost ''
00438 // CODE GENERATOR:           CommandReturn '@return 1 on success; 0 on failure'
00439 // CODE GENERATOR: testMenuGlobalArgsDict scan global property list g_MAX11043_device
00440 
00441 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.VRef
00442 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.VRef argname = VRef
00443 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['alias'] = 'None'
00444 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['argtype'] = 'double'
00445 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedByCommandName'] = 'None'
00446 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedBytestMenuItemName'] = 'None'
00447 
00448 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.config
00449 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.config shadow of argname = config
00450 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.config argname = config
00451 // CODE GENERATOR: testMenuGlobalArgsDict['config']['alias'] = 'None'
00452 // CODE GENERATOR: testMenuGlobalArgsDict['config']['argtype'] = 'uint16_t'
00453 // CODE GENERATOR: testMenuGlobalArgsDict['config']['usedByCommandName'] = 'None'
00454 // CODE GENERATOR: testMenuGlobalArgsDict['config']['usedBytestMenuItemName'] = 'None'
00455 
00456 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.status
00457 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.status shadow of argname = status
00458 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.status argname = status
00459 // CODE GENERATOR: testMenuGlobalArgsDict['status']['alias'] = 'None'
00460 // CODE GENERATOR: testMenuGlobalArgsDict['status']['argtype'] = 'uint8_t'
00461 // CODE GENERATOR: testMenuGlobalArgsDict['status']['usedByCommandName'] = 'None'
00462 // CODE GENERATOR: testMenuGlobalArgsDict['status']['usedBytestMenuItemName'] = 'None'
00463 
00464 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adca
00465 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adca shadow of argname = ADCa
00466 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adca argname = ADCa
00467 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['alias'] = 'None'
00468 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['argtype'] = 'int'
00469 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['usedByCommandName'] = 'None'
00470 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['usedBytestMenuItemName'] = 'None'
00471 
00472 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcb
00473 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcb shadow of argname = ADCb
00474 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcb argname = ADCb
00475 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['alias'] = 'None'
00476 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['argtype'] = 'int'
00477 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['usedByCommandName'] = 'None'
00478 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['usedBytestMenuItemName'] = 'None'
00479 
00480 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcc
00481 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcc shadow of argname = ADCc
00482 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcc argname = ADCc
00483 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['alias'] = 'None'
00484 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['argtype'] = 'int'
00485 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['usedByCommandName'] = 'None'
00486 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['usedBytestMenuItemName'] = 'None'
00487 
00488 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcd
00489 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcd shadow of argname = ADCd
00490 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcd argname = ADCd
00491 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['alias'] = 'None'
00492 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['argtype'] = 'int'
00493 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['usedByCommandName'] = 'None'
00494 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['usedBytestMenuItemName'] = 'None'
00495 
00496 
00497 // CODE GENERATOR: scan testMenuCommand list for items that can be shortened to single character
00498 // CODE GENERATOR: multiple commands begin with character 'X'
00499 // CODE GENERATOR: multiple commands begin with character 'X'
00500 // CODE GENERATOR: shorten testMenuCommand to single character if unambiguous
00501 // CODE GENERATOR: testMenuCommand '!' already single character
00502 // CODE GENERATOR: testMenuCommand '$' already single character
00503 // CODE GENERATOR: shorten testMenuCommand 'GA' to single character 'G'
00504 // CODE GENERATOR: re.sub pattern:'GA' with repl:'G' in helpString 'GA gain=? -- Write_AGain'
00505 // CODE GENERATOR: updated 'G' help string to 'G gain=? -- Write_AGain'
00506 // CODE GENERATOR: cannot shorten testMenuCommand 'XD' to single character due to duplicates
00507 // CODE GENERATOR: cannot shorten testMenuCommand 'XX' to single character due to duplicates
00508 // CODE GENERATOR: cannot shorten testMenuCommand 'XY' to single character due to duplicates
00509 
00510 // CODE GENERATOR: help menu
00511 bool MAX11043_menu_help(CmdLine & cmdLine)
00512 {
00513     // CODE GENERATOR: command: !
00514     // CODE GENERATOR: help: ! -- Init
00515     cmdLine.serial().printf("\r\n ! -- Init");
00516     // CODE GENERATOR: command: $
00517     // CODE GENERATOR: help: $ -- Read_ADCabcd
00518     cmdLine.serial().printf("\r\n $ -- Read_ADCabcd");
00519     // CODE GENERATOR: command: G
00520     // CODE GENERATOR: help: G gain=? -- Write_AGain
00521     cmdLine.serial().printf("\r\n G gain=? -- Write_AGain");
00522     // CODE GENERATOR: command: XD
00523     // CODE GENERATOR: help: XD -- Configure_Demo
00524     cmdLine.serial().printf("\r\n XD -- Configure_Demo");
00525     // CODE GENERATOR: command: XX
00526     // CODE GENERATOR: help: XX linef=? rate=? -- Configure_XXXXX
00527     cmdLine.serial().printf("\r\n XX linef=? rate=? -- Configure_XXXXX");
00528     // CODE GENERATOR: command: XY
00529     // CODE GENERATOR: help: XY linef=? rate=? -- Configure_XXXXY
00530     cmdLine.serial().printf("\r\n XY linef=? rate=? -- Configure_XXXXY");
00531     //
00532     cmdLine.serial().printf("\r\n @ -- print MAX11043 configuration");
00533 
00534 // CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register
00535     cmdLine.serial().printf("\r\n *regname? -- read register\r\n *regname=regvalue -- write register");
00536 
00537     //
00538 // CODE GENERATOR: TODO1: generate GPIO commands for LDAC, CLR, etc. based on device driver function names (menu_help)
00539         // case 'G'..'Z','g'..'z' are reserved for GPIO commands
00540         // case 'A'..'F','a'..'f' may be available if not claimed by bitstream commands
00541 // CODE GENERATOR: TODO1: prevent conflict ExternFunctionGPIOPinCommand with reserved case 'A'..'F','a'..'f'
00542 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN'
00543 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Direction'] = 'output'
00544 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Operation'] = 'Value'
00545 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['FunctionName'] = 'CONVRUNoutputValue'
00546 
00547 // CODE GENERATOR: warning: conflict testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN'
00548 #warning "No command case for 'CONVRUN' 'PinName' 'CONVRUN' due to conflict with reserved commands A-F, try changing pin name"
00549 #warning "Randomly assigned command 'H' for 'CONVRUN' due to name conflict"
00550 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP'
00551 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Direction'] = 'output'
00552 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Operation'] = 'Value'
00553 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['FunctionName'] = 'DACSTEPoutputValue'
00554 
00555 // CODE GENERATOR: warning: conflict testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP'
00556 #warning "No command case for 'DACSTEP' 'PinName' 'DACSTEP' due to conflict with reserved commands A-F, try changing pin name"
00557 #warning "Randomly assigned command 'I' for 'DACSTEP' due to name conflict"
00558 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC'
00559 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Direction'] = 'input'
00560 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Operation'] = 'Value'
00561 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['FunctionName'] = 'EOCinputValue'
00562 
00563 // CODE GENERATOR: warning: conflict testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC'
00564 #warning "No command case for 'EOC' 'PinName' 'EOC' due to conflict with reserved commands A-F, try changing pin name"
00565 #warning "Randomly assigned command 'J' for 'EOC' due to name conflict"
00566 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['PinName'] = 'SHDN'
00567 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Direction'] = 'output'
00568 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Operation'] = 'Value'
00569 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['FunctionName'] = 'SHDNoutputValue'
00570 
00571 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['PinName'] = 'UP_slash_DWNb'
00572 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Direction'] = 'output'
00573 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Operation'] = 'Value'
00574 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['FunctionName'] = 'UP_slash_DWNboutputValue'
00575 
00576 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'H' 'CONVRUN'
00577 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN'
00578 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Direction'] = 'output'
00579 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Operation'] = 'Value'
00580 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['FunctionName'] = 'CONVRUNoutputValue'
00581     cmdLine.serial().printf("\r\n H -- CONVRUN output HH high HL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict
00582 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'I' 'DACSTEP'
00583 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP'
00584 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Direction'] = 'output'
00585 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Operation'] = 'Value'
00586 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['FunctionName'] = 'DACSTEPoutputValue'
00587     cmdLine.serial().printf("\r\n I -- DACSTEP output IH high IL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict
00588 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'J' 'EOC'
00589 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC'
00590 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Direction'] = 'input'
00591 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Operation'] = 'Value'
00592 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['FunctionName'] = 'EOCinputValue'
00593     cmdLine.serial().printf("\r\n J -- EOC input value"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict
00594 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'S' 'SHDN'
00595 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['PinName'] = 'SHDN'
00596 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Direction'] = 'output'
00597 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Operation'] = 'Value'
00598 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['FunctionName'] = 'SHDNoutputValue'
00599     cmdLine.serial().printf("\r\n S -- SHDN output SH high SL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict
00600 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'U' 'UP_slash_DWNb'
00601 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['PinName'] = 'UP_slash_DWNb'
00602 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Direction'] = 'output'
00603 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Operation'] = 'Value'
00604 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['FunctionName'] = 'UP_slash_DWNboutputValue'
00605     cmdLine.serial().printf("\r\n U -- UP_slash_DWNb output UH high UL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict
00606 
00607 #if Has_Read4Command_Command
00608 // Read 4 command -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.
00609     cmdLine.serial().printf("\r\n ^ -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.");
00610 #endif // Has_Read4Command_Command
00611 
00612     //
00613     return true; // why is MAXxxxxx_menu_help() function bool not void?
00614 }
00615 
00616 bool MAX11043_menu_onEOLcommandParser(CmdLine & cmdLine)
00617 {
00618 
00619 // CODE GENERATOR: testMenuGlobalArgsDict Consolidate common/global argument parsing
00620 
00621 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['alias'] = 'None'
00622 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['argtype'] = 'int'
00623 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['usedByCommandName'] = 'None'
00624 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['usedBytestMenuItemName'] = 'None'
00625                     // parse argument int ADCa
00626         //int ADCa = 0; // ~~~ g_MAX11043_device.__WARNING_no_match_for_argname_ADCa_in_MAX11043_device_t__; // default to global property value
00627         //if (cmdLine.parse_int16_dec("ADCa", ADCa))
00628         // [Error] Test_Menu_MAX11043.cpp@627,49: invalid initialization of non-const reference of type 'int16_t& {aka short int&}' from an rvalue of type 'int16_t {aka short int}'
00629         //{
00630             // g_MAX11043_device.__WARNING_no_match_for_argname_ADCa_in_MAX11043_device_t__ = ADCa; // update global property value
00631         //}
00632 
00633 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['alias'] = 'None'
00634 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['argtype'] = 'int'
00635 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['usedByCommandName'] = 'None'
00636 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['usedBytestMenuItemName'] = 'None'
00637                     // parse argument int ADCb
00638         //int ADCb = 0; // ~~~ g_MAX11043_device.__WARNING_no_match_for_argname_ADCb_in_MAX11043_device_t__; // default to global property value
00639         //if (cmdLine.parse_int16_dec("ADCb", ADCb))
00640         //{
00641         //    // g_MAX11043_device.__WARNING_no_match_for_argname_ADCb_in_MAX11043_device_t__ = ADCb; // update global property value
00642         //}
00643 
00644 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['alias'] = 'None'
00645 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['argtype'] = 'int'
00646 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['usedByCommandName'] = 'None'
00647 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['usedBytestMenuItemName'] = 'None'
00648                     // parse argument int ADCc
00649         //int ADCc = 0; // ~~~ g_MAX11043_device.__WARNING_no_match_for_argname_ADCc_in_MAX11043_device_t__; // default to global property value
00650         //if (cmdLine.parse_int16_dec("ADCc", ADCc))
00651         //{
00652         //    // g_MAX11043_device.__WARNING_no_match_for_argname_ADCc_in_MAX11043_device_t__ = ADCc; // update global property value
00653         //}
00654 
00655 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['alias'] = 'None'
00656 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['argtype'] = 'int'
00657 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['usedByCommandName'] = 'None'
00658 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['usedBytestMenuItemName'] = 'None'
00659                     // parse argument int ADCd
00660         //int ADCd = 0; // ~~~ g_MAX11043_device.__WARNING_no_match_for_argname_ADCd_in_MAX11043_device_t__; // default to global property value
00661         //if (cmdLine.parse_int16_dec("ADCd", ADCd))
00662         //{
00663         //    // g_MAX11043_device.__WARNING_no_match_for_argname_ADCd_in_MAX11043_device_t__ = ADCd; // update global property value
00664         //}
00665 
00666 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['alias'] = 'None'
00667 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['argtype'] = 'double'
00668 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedByCommandName'] = 'None'
00669 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedBytestMenuItemName'] = 'None'
00670                     // parse argument double VRef
00671         double VRef = g_MAX11043_device.VRef; // default to global property value
00672         if (cmdLine.parse_double("VRef", VRef))
00673         {
00674             g_MAX11043_device.VRef = VRef; // update global property value
00675         }
00676 
00677 // CODE GENERATOR: testMenuGlobalArgsDict['config']['alias'] = 'None'
00678 // CODE GENERATOR: testMenuGlobalArgsDict['config']['argtype'] = 'uint16_t'
00679 // CODE GENERATOR: testMenuGlobalArgsDict['config']['usedByCommandName'] = 'None'
00680 // CODE GENERATOR: testMenuGlobalArgsDict['config']['usedBytestMenuItemName'] = 'None'
00681                     // parse argument uint16_t config
00682         uint16_t config = g_MAX11043_device.config; // default to global property value
00683         if (cmdLine.parse_uint16_dec("config", config))
00684         {
00685             g_MAX11043_device.config = config; // update global property value
00686         }
00687 
00688 // CODE GENERATOR: testMenuGlobalArgsDict['status']['alias'] = 'None'
00689 // CODE GENERATOR: testMenuGlobalArgsDict['status']['argtype'] = 'uint8_t'
00690 // CODE GENERATOR: testMenuGlobalArgsDict['status']['usedByCommandName'] = 'None'
00691 // CODE GENERATOR: testMenuGlobalArgsDict['status']['usedBytestMenuItemName'] = 'None'
00692                     // parse argument uint8_t status
00693         uint8_t status = g_MAX11043_device.status; // default to global property value
00694         if (cmdLine.parse_uint8_dec("status", status))
00695         {
00696             g_MAX11043_device.status = status; // update global property value
00697         }
00698 
00699     switch (cmdLine[0])
00700     {
00701 #if Has_Read4Command_Command
00702 // Read 4 command -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.
00703         case '^':
00704         {
00705             // cmdLine.serial().printf("\r\n ^ -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.");
00706 #if Use_Read4Command_Thread
00707             Callback<void(size_t, uint8_t*, uint8_t*)> saved_onSPIprint_handler = g_MAX11043_device.onSPIprint;
00708             g_MAX11043_device.onSPIprint = NULL; // temporarily suppress SPI diagnostic messages
00709             //~ int convrun_pulse_width_us = 30;
00710             //~ int convrun_stop_us = 10;
00711             cmdLine.serial().printf(" Testing CONVRUN pulsed H then L, EOC ignored.\r\n");
00712             cmdLine.serial().printf(" press D to display min/max limits (based on data seen)\r\n");
00713             cmdLine.serial().printf(" press R to reset min/max limits (force scope trigger)\r\n");
00714             cmdLine.serial().printf(" press F for fake data +32767, +1, -1, -32768 (internal 2's complement test) \r\n");
00715             cmdLine.serial().printf(" press X to stop...\r\n");
00716             //~ cmdLine.serial().printf(" Testing, press RESET to stop...\r\n");
00717             //~ int serial_is_blocking = cmdLine.serial().is_blocking();
00718             //~ cmdLine.serial().set_blocking(0);
00719             //
00720 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
00721             digitalInOut5.output(); // ScopeTrigger
00722             digitalInOut5.write(1); // ScopeTrigger
00723 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
00724             //
00725             // reset min/max limits
00726             adca_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
00727             adca_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
00728             adcb_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
00729             adcb_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
00730             //
00731             // init thread
00732             Read4Command_Thread.start(Read4Command_Thread_handler);
00733             // TODO: is there any harm in multiple start?
00734             //
00735             // Start the test
00736             Read4Command_Thread_event_flags.set(MYTIMEREVENTFLAG_ENABLE_SPI);
00737             // Work will be done inside Read4Command_Thread_handler
00738             while (1)
00739             {
00740                 char ch = cmdLine.serial().getc(); // blocking read
00741                 if (ch == '\r') { cmdLine.serial().printf(" (ignored \\r) "); continue; }
00742                 if (ch == '\n') { cmdLine.serial().printf(" (ignored \\n) "); continue; }
00743                 if (ch == '?') {
00744                     cmdLine.serial().printf(" Testing CONVRUN pulsed H then L, EOC ignored.\r\n");
00745                     cmdLine.serial().printf(" press D to display min/max limits (based on data seen)\r\n");
00746                     cmdLine.serial().printf(" press R to reset min/max limits (force scope trigger)\r\n");
00747                     cmdLine.serial().printf(" press F for fake data +32767, +1, -1, -32768 (internal 2's complement test) \r\n");
00748                     cmdLine.serial().printf(" press X to stop...\r\n");
00749                     continue;
00750                 }
00751                 if (ch == 'R' || ch == 'r') {
00752                     // reset min/max limits
00753                     Read4Command_Thread_event_flags.clear(MYTIMEREVENTFLAG_FAKE_DATA);
00754                     Read4Command_Thread_event_flags.set(MYTIMEREVENTFLAG_RESET_MINMAX);
00755                     cmdLine.serial().printf(" Reset limts \r\n");
00756                     wait_us(100);
00757                 }
00758                 if (ch == 'F' || ch == 'f') {
00759                     // fake data
00760                     Read4Command_Thread_event_flags.set(MYTIMEREVENTFLAG_FAKE_DATA);
00761                     // g_MAX11043_device.adca = 0x7FFF; // +32767 adcX_MIN_SEEN_INIT_INT16_MAX;
00762                     // g_MAX11043_device.adcb = 0x0001; // +1
00763                     // g_MAX11043_device.adcc = 0xFFFF; // -1
00764                     // g_MAX11043_device.adcd = 0x8000; // -32768 adcX_MAX_SEEN_INIT_INT16_MIN;
00765                     cmdLine.serial().printf(" fake data +32767, +1, -1, -32768 (internal 2's complement test) \r\n");
00766                     wait_us(100);
00767                 }
00768                 if (ch == 'D' || ch == 'd' || ch == 'F' || ch == 'f' || ch == 'R' || ch == 'r' || ch == 'X' || ch == 'x' || ch == '\x03') {
00769                     // display min/max limits
00770                     cmdLine.serial().printf(" %s\tNEW 0x%4.4x %+6d \tMIN 0x%4.4x %+6d \tMAX 0x%4.4x %+6d \r\n",
00771                         "adca",
00772                         (adca_newest   & 0xFFFF),
00773                         (adca_newest           ),
00774                         (adca_MIN_SEEN & 0xFFFF),
00775                         (adca_MIN_SEEN         ),
00776                         (adca_MAX_SEEN & 0xFFFF),
00777                         (adca_MAX_SEEN         )
00778                     );
00779                     cmdLine.serial().printf(" %s\tNEW 0x%4.4x %+6d \tMIN 0x%4.4x %+6d \tMAX 0x%4.4x %+6d \r\n",
00780                         "adcb",
00781                         (adcb_newest   & 0xFFFF),
00782                         (adcb_newest           ),
00783                         (adcb_MIN_SEEN & 0xFFFF),
00784                         (adcb_MIN_SEEN         ),
00785                         (adcb_MAX_SEEN & 0xFFFF),
00786                         (adcb_MAX_SEEN         )
00787                     );
00788                     cmdLine.serial().printf(" %s\tNEW 0x%4.4x %+6d \tMIN 0x%4.4x %+6d \tMAX 0x%4.4x %+6d \r\n",
00789                         "adcc",
00790                         (adcc_newest   & 0xFFFF),
00791                         (adcc_newest           ),
00792                         (adcc_MIN_SEEN & 0xFFFF),
00793                         (adcc_MIN_SEEN         ),
00794                         (adcc_MAX_SEEN & 0xFFFF),
00795                         (adcc_MAX_SEEN         )
00796                     );
00797                     cmdLine.serial().printf(" %s\tNEW 0x%4.4x %+6d \tMIN 0x%4.4x %+6d \tMAX 0x%4.4x %+6d \r\n",
00798                         "adcd__",
00799                         (adcd_newest   & 0xFFFF),
00800                         (adcd_newest           ),
00801                         (adcd_MIN_SEEN & 0xFFFF),
00802                         (adcd_MIN_SEEN         ),
00803                         (adcd_MAX_SEEN & 0xFFFF),
00804                         (adcd_MAX_SEEN         )
00805                     );
00806                     cmdLine.serial().printf("\r\n");
00807                 }
00808                 if (ch == 'D' || ch == 'd' || ch == 'F' || ch == 'f' || ch == 'R' || ch == 'r') {
00809                     continue;
00810                 }
00811                 if (ch == 'X' || ch == 'x' || ch == '\x03') {
00812                     break;
00813                 }
00814                 cmdLine.serial().printf(" (ignored \\x%2.2x)\r\nD:Display F:Fake R:Reset X:Exit\r\n", (int)ch);
00815             }
00816             // Stop the test
00817             Read4Command_Thread_event_flags.clear(MYTIMEREVENTFLAG_ENABLE_SPI);
00818             wait_us(200);
00819             //~ cmdLine.serial().set_blocking(serial_is_blocking);
00820             cmdLine.serial().printf(" Stopped.\r\n");
00821             g_MAX11043_device.onSPIprint = saved_onSPIprint_handler;
00822 #else // Use_Read4Command_Thread
00823             int convrun_pulse_width_us = 30;
00824             int convrun_stop_us = 10;
00825             //~ cmdLine.serial().printf(" Testing, press X to stop...\r\n");
00826             cmdLine.serial().printf(" Testing, press RESET to stop...\r\n");
00827             //~ int serial_is_blocking = cmdLine.serial().is_blocking();
00828             //~ cmdLine.serial().set_blocking(0);
00829             while (1)
00830             {
00831                 // TODO: CONVRUN = H -- perform ADC conversions (EOC will pulse, and data registers will update)
00832                 g_MAX11043_device.CONVRUNoutputValue(1);
00833                 //
00834                 // TODO: delay at least 9us to ensure at least one converion happens
00835                 wait_us(convrun_pulse_width_us);
00836                 //
00837                 // TODO: CONVRUN = L -- stop ADC conversions
00838                 g_MAX11043_device.CONVRUNoutputValue(0);
00839                 //
00840                 // TODO: delay at least 9us to ensure final converion complete
00841                 wait_us(convrun_stop_us);
00842                 //
00843                 // TODO: run SPI to capture 4 channels
00844                 // TODO: get rid of the other interrupt/thread, only to read here
00845                 g_MAX11043_device.Read_ADCabcd();
00846                 // post: g_MAX11043_device.adca was updated
00847                 // post: g_MAX11043_device.adcb was updated
00848                 // post: g_MAX11043_device.adcc was updated
00849                 // post: g_MAX11043_device.adcd was updated
00850                 //
00851                 // TODO: compare with thresholds, report if exceeded
00852                 //
00853                 // TODO: break on keypress
00854                 // TODO: this isn't working, serial().getc() is blocking and .readable() always returns 1 so we stall in getc().
00855                 unsigned int num_read_available = cmdLine.serial().readable();
00856                 if (num_read_available > 1) // should test >0; but always returns 1?
00857                 {
00858                     cmdLine.serial().printf(" (num_read_available %u) ", num_read_available);
00859                     char ch = cmdLine.serial().getc(); // blocking read
00860                     if (ch == '\r') { cmdLine.serial().printf(" (ignored \\r) "); continue; }
00861                     if (ch == '\n') { cmdLine.serial().printf(" (ignored \\n) "); continue; }
00862                     if (ch == '\x03') break; // CTRL+C break
00863                     if (ch == 'x') break;
00864                     if (ch == 'X') break;
00865                     cmdLine.serial().printf(" (ignored \\x%2.2x) ", (int)ch);
00866                 }
00867             }
00868             //~ cmdLine.serial().set_blocking(serial_is_blocking);
00869             cmdLine.serial().printf(" Stopped.\r\n");
00870 #endif // Use_Read4Command_Thread
00871             return true; // command handled by MAX11043
00872         }
00873         break;
00874 #endif // Has_Read4Command_Command
00875 // CODE GENERATOR: generate * command read/write reg *reg? *reg=value
00876         case '*':
00877         {
00878             // if buffer starts with a regName:
00879             // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))):
00880             cmdLine.serial().printf(" scan RegName...\r\n");
00881             for (uint8_t regAddress = 0; regAddress < 0x80; regAddress++)
00882             {
00883                 uint32_t regData = 0;
00884                 bool is_regname_query = false;
00885                 bool is_regname_assignment = false;
00886                 if (cmdLine.parse_uint32_dec(g_MAX11043_device.RegName((MAX11043::MAX11043_CMD_enum_t)regAddress), regData))
00887                 {
00888                     cmdLine.serial().printf(" regAddress=0x%2.2X\r\n", (regAddress & 0xFF));
00889                     cmdLine.serial().printf(" RegName=%s\r\n", g_MAX11043_device.RegName((MAX11043::MAX11043_CMD_enum_t)regAddress));
00890                     // accept regName "?" as "RegRead" by name
00891                     is_regname_query = (cmdLine.chSeparator == '?');
00892                     is_regname_assignment = (cmdLine.chSeparator == '=');
00893                     if (is_regname_query)
00894                     {
00895                         cmdLine.serial().printf(" RegRead");
00896                         g_MAX11043_device.RegRead((MAX11043::MAX11043_CMD_enum_t)regAddress, &regData);
00897                         cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF));
00898                         return true; // command handled by MAX11043
00899                     }
00900                     // accept regName "=0x123456" as "RegWrite" by name
00901                     if (is_regname_assignment)
00902                     {
00903                         cmdLine.serial().printf(" RegWrite");
00904                         cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF));
00905                         g_MAX11043_device.RegWrite((MAX11043::MAX11043_CMD_enum_t)regAddress, regData);
00906                         return true; // command handled by MAX11043
00907                     }
00908                 }
00909             } // end for regAddr
00910             // not a valid register name
00911             Callback<void(size_t, uint8_t*, uint8_t*)> saved_onSPIprint_handler = g_MAX11043_device.onSPIprint;
00912             g_MAX11043_device.onSPIprint = NULL; // temporarily suppress SPI diagnostic messages
00913             // read "all" registers by name
00914             // TODO: KLUDGE: this constant array should live in the device driver, not the menu
00915             const MAX11043::MAX11043_CMD_enum_t readAllStatusList[] = {
00916                     MAX11043::CMD_0000_0010_d16o8_Rd00_ADCa,
00917                     MAX11043::CMD_0000_0110_d16o8_Rd01_ADCb,
00918                     MAX11043::CMD_0000_1010_d16o8_Rd02_ADCc,
00919                     MAX11043::CMD_0000_1110_d16o8_Rd03_ADCd,
00920                     MAX11043::CMD_0001_1110_d8_Rd07_Status,
00921                     MAX11043::CMD_0010_0010_d16_Rd08_Configuration,
00922                     MAX11043::CMD_0010_0110_d16_Rd09_DAC,
00923                     MAX11043::CMD_0010_1010_d16_Rd0A_DACStep,
00924                     MAX11043::CMD_0010_1110_d16_Rd0B_DACHDACL,
00925                     MAX11043::CMD_0011_0010_d16_Rd0C_ConfigA,
00926                     MAX11043::CMD_0011_0110_d16_Rd0D_ConfigB,
00927                     MAX11043::CMD_0011_1010_d16_Rd0E_ConfigC,
00928                     MAX11043::CMD_0011_1110_d16_Rd0F_ConfigD,
00929                     MAX11043::CMD_0100_0010_d16_Rd10_Reference,
00930                     MAX11043::CMD_0100_0110_d16_Rd11_AGain,
00931                     MAX11043::CMD_0100_1010_d16_Rd12_BGain,
00932                     MAX11043::CMD_0100_1110_d16_Rd13_CGain,
00933                     MAX11043::CMD_0101_0010_d16_Rd14_DGain,
00934                 };
00935             for (uint8_t readAllStatusIndex = 0; readAllStatusIndex < (sizeof(readAllStatusList)/sizeof(MAX11043::MAX11043_CMD_enum_t)); readAllStatusIndex++)
00936             {
00937                 MAX11043::MAX11043_CMD_enum_t regAddress = readAllStatusList[readAllStatusIndex];
00938                 uint32_t regData = 0;
00939                 if (g_MAX11043_device.RegSize(regAddress) == 0) continue; // skip undefined regs
00940                 if (g_MAX11043_device.RegRead(regAddress, &regData) == 0) continue; // skip unreadable regs
00941                 cmdLine.serial().printf("%s=0x%6.6x\r\n", g_MAX11043_device.RegName(regAddress), regData);
00942             } // end for regAddr
00943             g_MAX11043_device.onSPIprint = saved_onSPIprint_handler;
00944             return true; // command handled by MAX11043
00945         }
00946         break;
00947 
00948 // CODE GENERATOR: generate @ command print global property values of  g_MAX11043_device
00949         case '@':
00950         {
00951 // CODE GENERATOR: @ command print double g_MAX11043_device.VRef
00952                     cmdLine.serial().printf("VRef = ");
00953                     cmdLine.serial().printf("%f\r\n", g_MAX11043_device.VRef);
00954 // CODE GENERATOR: @ command print uint16_t g_MAX11043_device.config
00955                     cmdLine.serial().printf("config = ");
00956                     cmdLine.serial().printf("%d = 0x%4.4x\r\n", g_MAX11043_device.config, g_MAX11043_device.config);
00957 // CODE GENERATOR: @ command print uint8_t g_MAX11043_device.status
00958                     cmdLine.serial().printf("status = ");
00959                     cmdLine.serial().printf("%d = 0x%2.2x\r\n", g_MAX11043_device.status, g_MAX11043_device.status);
00960 // CODE GENERATOR: @ command print int g_MAX11043_device.adca
00961                     cmdLine.serial().printf("adca = ");
00962                     cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.adca, g_MAX11043_device.adca);
00963 // CODE GENERATOR: @ command print int g_MAX11043_device.adcb
00964                     cmdLine.serial().printf("adcb = ");
00965                     cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.adcb, g_MAX11043_device.adcb);
00966 // CODE GENERATOR: @ command print int g_MAX11043_device.adcc
00967                     cmdLine.serial().printf("adcc = ");
00968                     cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.adcc, g_MAX11043_device.adcc);
00969 // CODE GENERATOR: @ command print int g_MAX11043_device.adcd
00970                     cmdLine.serial().printf("adcd = ");
00971                     cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.adcd, g_MAX11043_device.adcd);
00972                     return true; // command handled by MAX11043
00973             break;
00974         }
00975 // CODE GENERATOR: TODO1: generate GPIO commands for LDAC, CLR, etc. based on device driver function names
00976         // case 'G'..'Z','g'..'z' are reserved for GPIO commands
00977         // case 'A'..'F','a'..'f' may be available if not claimed by bitstream commands
00978 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'H' 'CONVRUN'
00979 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN'
00980 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Direction'] = 'output'
00981 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Operation'] = 'Value'
00982 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['FunctionName'] = 'CONVRUNoutputValue'
00983         case 'H':
00984         {
00985             switch (cmdLine[1])
00986             {
00987                 case 'H':
00988                 {
00989                     g_MAX11043_device.CONVRUNoutputValue(1);
00990                     break;
00991                 }
00992                 case 'L':
00993                 {
00994                     g_MAX11043_device.CONVRUNoutputValue(0);
00995                     break;
00996                 }
00997             }
00998                     return true; // command handled by MAX11043
00999             break;
01000         }
01001 
01002 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'I' 'DACSTEP'
01003 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP'
01004 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Direction'] = 'output'
01005 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Operation'] = 'Value'
01006 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['FunctionName'] = 'DACSTEPoutputValue'
01007         case 'I':
01008         {
01009             switch (cmdLine[1])
01010             {
01011                 case 'H':
01012                 {
01013                     g_MAX11043_device.DACSTEPoutputValue(1);
01014                     break;
01015                 }
01016                 case 'L':
01017                 {
01018                     g_MAX11043_device.DACSTEPoutputValue(0);
01019                     break;
01020                 }
01021             }
01022                     return true; // command handled by MAX11043
01023             break;
01024         }
01025 
01026 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'J' 'EOC'
01027 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC'
01028 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Direction'] = 'input'
01029 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Operation'] = 'Value'
01030 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['FunctionName'] = 'EOCinputValue'
01031         case 'J':
01032         {
01033                 // TODO capture and print input Value
01034                 cmdLine.serial().printf("%d", g_MAX11043_device.EOCinputValue());
01035                     return true; // command handled by MAX11043
01036             break;
01037         }
01038 
01039 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'S' 'SHDN'
01040 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['PinName'] = 'SHDN'
01041 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Direction'] = 'output'
01042 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Operation'] = 'Value'
01043 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['FunctionName'] = 'SHDNoutputValue'
01044         case 'S':
01045         {
01046             switch (cmdLine[1])
01047             {
01048                 case 'H':
01049                 {
01050                     g_MAX11043_device.SHDNoutputValue(1);
01051                     break;
01052                 }
01053                 case 'L':
01054                 {
01055                     g_MAX11043_device.SHDNoutputValue(0);
01056                     break;
01057                 }
01058             }
01059                     return true; // command handled by MAX11043
01060             break;
01061         }
01062 
01063 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'U' 'UP_slash_DWNb'
01064 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['PinName'] = 'UP_slash_DWNb'
01065 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Direction'] = 'output'
01066 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Operation'] = 'Value'
01067 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['FunctionName'] = 'UP_slash_DWNboutputValue'
01068         case 'U':
01069         {
01070             switch (cmdLine[1])
01071             {
01072                 case 'H':
01073                 {
01074                     g_MAX11043_device.UP_slash_DWNboutputValue(1);
01075                     break;
01076                 }
01077                 case 'L':
01078                 {
01079                     g_MAX11043_device.UP_slash_DWNboutputValue(0);
01080                     break;
01081                 }
01082             }
01083                     return true; // command handled by MAX11043
01084             break;
01085         }
01086 
01087 
01088 // CODE GENERATOR: test menu
01089         // case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands
01090         // has_register_write_command: case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands
01091 // CODE GENERATOR: top of loop: testMenuCommand="!", testMenuFirstCharHandler="None"
01092 // CODE GENERATOR: test menu case '!':
01093 // CODE GENERATOR:           helpString '! -- Init'
01094 // CODE GENERATOR:           CMD_ 'None'
01095 // CODE GENERATOR:           CommandName 'Init'
01096 // CODE GENERATOR:           CommandParamIn 'void'
01097 // CODE GENERATOR:           CommandReturnType 'uint8_t'
01098 // CODE GENERATOR:           CommandPre ''
01099 // CODE GENERATOR:           CommandDocParamIn ''
01100 // CODE GENERATOR:           CommandDocParamOut ''
01101 // CODE GENERATOR:           CommandPost ''
01102 // CODE GENERATOR:           CommandReturn '@return 1 on success; 0 on failure'
01103         // case '!': // (single character) (testMenuFirstCharHandler="None")
01104         case '!':
01105         {
01106                     // test menu command '!' handler:
01107                     // helpString='! -- Init'
01108                     // CMD_='None'
01109                     // CommandName='Init'
01110                     // CommandParamIn='void'
01111                     // CommandReturnType='uint8_t'
01112                     // @Pre=''
01113                     // @Param[in]=''
01114                     // @Param[out]=''
01115                     // @Post=''
01116                     // displayPost=''
01117                     // @Return='@return 1 on success; 0 on failure'
01118                     cmdLine.serial().printf("Init");
01119                     // call function Init
01120                     uint8_t result = g_MAX11043_device.Init();
01121                     cmdLine.serial().printf(" =%d\r\n", result);
01122                     return true; // command handled by MAX11043
01123 // CODE GENERATOR: bottom of loop: testMenuCommand="!", testMenuFirstCharHandler="None"
01124         } // end case '!'
01125         break;
01126 
01127 // CODE GENERATOR: top of loop: testMenuCommand="$", testMenuFirstCharHandler="None"
01128 // CODE GENERATOR: test menu case '$':
01129 // CODE GENERATOR:           helpString '$ -- Read_ADCabcd'
01130 // CODE GENERATOR:           CMD_ 'None'
01131 // CODE GENERATOR:           CommandName 'Read_ADCabcd'
01132 // CODE GENERATOR:           CommandParamIn 'void'
01133 // CODE GENERATOR:           CommandReturnType 'uint8_t'
01134 // CODE GENERATOR:           CommandPre ''
01135 // CODE GENERATOR:           CommandDocParamIn ''
01136 // CODE GENERATOR:           CommandDocParamOut ''
01137 // CODE GENERATOR:           CommandPost ''
01138 // CODE GENERATOR:           CommandReturn '@return 1 on success; 0 on failure'
01139         // case '$': // (single character) (testMenuFirstCharHandler="None")
01140         case '$':
01141         {
01142                     // test menu command '$' handler:
01143                     // helpString='$ -- Read_ADCabcd'
01144                     // CMD_='None'
01145                     // CommandName='Read_ADCabcd'
01146                     // CommandParamIn='void'
01147                     // CommandReturnType='uint8_t'
01148                     // @Pre=''
01149                     // @Param[in]=''
01150                     // @Param[out]=''
01151                     // @Post=''
01152                     // displayPost='adca, adcb, adcc, adcd'
01153                     // @Return='@return 1 on success; 0 on failure'
01154                     cmdLine.serial().printf("Read_ADCabcd");
01155                     // call function Read_ADCabcd
01156                     uint8_t result = g_MAX11043_device.Read_ADCabcd();
01157                     cmdLine.serial().printf(" =%d\r\n", result);
01158                     // Menu item '$' -> adca, adcb, adcc, adcd
01159                     cmdLine.serial().printf("%s=%d\r\n", "adca", g_MAX11043_device.adca);
01160                     cmdLine.serial().printf("%s=%d\r\n", "adcb", g_MAX11043_device.adcb);
01161                     cmdLine.serial().printf("%s=%d\r\n", "adcc", g_MAX11043_device.adcc);
01162                     cmdLine.serial().printf("%s=%d\r\n", "adcd", g_MAX11043_device.adcd);
01163                     return true; // command handled by MAX11043
01164 // CODE GENERATOR: bottom of loop: testMenuCommand="$", testMenuFirstCharHandler="None"
01165         } // end case '$'
01166         break;
01167 
01168 // CODE GENERATOR: top of loop: testMenuCommand="G", testMenuFirstCharHandler="None"
01169 // CODE GENERATOR: test menu case 'G':
01170 // CODE GENERATOR:           helpString 'G gain=? -- Write_AGain'
01171 // CODE GENERATOR:           CMD_ 'None'
01172 // CODE GENERATOR:           CommandName 'Write_AGain'
01173 // CODE GENERATOR:           CommandParamIn 'uint32_t gain'
01174 // CODE GENERATOR:           CommandReturnType 'uint8_t'
01175 // CODE GENERATOR:           CommandPre ''
01176 // CODE GENERATOR:           CommandDocParamIn '@param[in] gain 2's complement, 0x800=0.25V/V, 0x1000=0.5V/V, 0x2000=1V/V, 0x4000=2V/V, default=0x2000'
01177 // CODE GENERATOR:           CommandDocParamOut ''
01178 // CODE GENERATOR:           CommandPost ''
01179 // CODE GENERATOR:           CommandReturn '@return 1 on success; 0 on failure'
01180         // case 'G': // (single character) (testMenuFirstCharHandler="None")
01181         case 'G':
01182         {
01183                     // test menu command 'G' handler:
01184                     // helpString='G gain=? -- Write_AGain'
01185                     // CMD_='None'
01186                     // CommandName='Write_AGain'
01187                     // CommandParamIn='uint32_t gain'
01188                     // CommandReturnType='uint8_t'
01189                     // @Pre=''
01190                     // @Param[in]='@param[in] gain 2's complement, 0x800=0.25V/V, 0x1000=0.5V/V, 0x2000=1V/V, 0x4000=2V/V, default=0x2000'
01191                     // @Param[out]=''
01192                     // @Post=''
01193                     // displayPost=''
01194                     // @Return='@return 1 on success; 0 on failure'
01195                     // parse argument list
01196                     // argname default_argvalue numeric literal specified in CommandDocParamIn @Param[in]='@param[in] gain 2's complement, 0x800=0.25V/V, 0x1000=0.5V/V, 0x2000=1V/V, 0x4000=2V/V, default=0x2000'
01197                     // parse argument uint32_t gain
01198                     uint32_t gain = (uint32_t)0x2000; // --- g_MAX11043_device.__WARNING_no_match_for_argname_gain_in_MAX11043_device_t__; // default to global property value
01199                     if (cmdLine.parse_uint32_dec("gain", gain))
01200                     {
01201                         // g_MAX11043_device.__WARNING_no_match_for_argname_gain_in_MAX11043_device_t__ = gain; // update global property value
01202                     }
01203                     // print arguments
01204                     cmdLine.serial().printf("Write_AGain");
01205                     cmdLine.serial().printf(" gain=%d", gain);
01206                     cmdLine.serial().printf("\r\n");
01207                     // call function Write_AGain(gain)
01208                     uint8_t result = g_MAX11043_device.Write_AGain(gain);
01209                     cmdLine.serial().printf(" =%d\r\n", result);
01210                     return true; // command handled by MAX11043
01211 // CODE GENERATOR: bottom of loop: testMenuCommand="G", testMenuFirstCharHandler="None"
01212         } // end case 'G'
01213         break;
01214 
01215 // CODE GENERATOR: top of loop: testMenuCommand="XD", testMenuFirstCharHandler="None"
01216 // CODE GENERATOR: test menu case 'XD':
01217 // CODE GENERATOR:           helpString 'XD -- Configure_Demo'
01218 // CODE GENERATOR:           CMD_ 'None'
01219 // CODE GENERATOR:           CommandName 'Configure_Demo'
01220 // CODE GENERATOR:           CommandParamIn 'void'
01221 // CODE GENERATOR:           CommandReturnType 'void'
01222 // CODE GENERATOR:           CommandPre ''
01223 // CODE GENERATOR:           CommandDocParamIn ''
01224 // CODE GENERATOR:           CommandDocParamOut ''
01225 // CODE GENERATOR:           CommandPost ''
01226 // CODE GENERATOR:           CommandReturn ''
01227         case 'X': // (multiple characters) (testMenuFirstCharHandler="X"):
01228         {
01229             switch (cmdLine[1])
01230             {
01231                 case 'D': // (nested inside case 'X')
01232                 {
01233                     // test menu command 'XD' handler:
01234                     // helpString='XD -- Configure_Demo'
01235                     // CMD_='None'
01236                     // CommandName='Configure_Demo'
01237                     // CommandParamIn='void'
01238                     // CommandReturnType='void'
01239                     // @Pre=''
01240                     // @Param[in]=''
01241                     // @Param[out]=''
01242                     // @Post=''
01243                     // displayPost=''
01244                     // @Return=''
01245                     cmdLine.serial().printf("Configure_Demo");
01246                     // call function Configure_Demo
01247                     g_MAX11043_device.Configure_Demo();
01248                     return true; // command handled by MAX11043
01249 // CODE GENERATOR: bottom of loop: testMenuCommand="XD", testMenuFirstCharHandler="X"
01250                 } // end nested case 'XD'
01251                 break;
01252 
01253 // CODE GENERATOR: top of loop: testMenuCommand="XX", testMenuFirstCharHandler="X"
01254 // CODE GENERATOR: top of loop: nested switch "X" is currently open
01255 // CODE GENERATOR: test menu case 'XX':
01256 // CODE GENERATOR:           helpString 'XX linef=? rate=? -- Configure_XXXXX'
01257 // CODE GENERATOR:           CMD_ 'None'
01258 // CODE GENERATOR:           CommandName 'Configure_XXXXX'
01259 // CODE GENERATOR:           CommandParamIn 'uint8_t linef, uint8_t rate'
01260 // CODE GENERATOR:           CommandReturnType 'uint8_t'
01261 // CODE GENERATOR:           CommandPre ''
01262 // CODE GENERATOR:           CommandDocParamIn ''
01263 // CODE GENERATOR:           CommandDocParamOut ''
01264 // CODE GENERATOR:           CommandPost ''
01265 // CODE GENERATOR:           CommandReturn '@return 1 on success; 0 on failure'
01266                 case 'X': // (nested inside case 'X')
01267                 {
01268                     // test menu command 'XX' handler:
01269                     // helpString='XX linef=? rate=? -- Configure_XXXXX'
01270                     // CMD_='None'
01271                     // CommandName='Configure_XXXXX'
01272                     // CommandParamIn='uint8_t linef, uint8_t rate'
01273                     // CommandReturnType='uint8_t'
01274                     // @Pre=''
01275                     // @Param[in]=''
01276                     // @Param[out]=''
01277                     // @Post=''
01278                     // displayPost=''
01279                     // @Return='@return 1 on success; 0 on failure'
01280                     // parse argument list
01281                     // parse argument uint8_t linef
01282                     uint8_t linef = 0; // --- g_MAX11043_device.__WARNING_no_match_for_argname_linef_in_MAX11043_device_t__; // default to global property value
01283                     if (cmdLine.parse_uint8_dec("linef", linef))
01284                     {
01285                         // g_MAX11043_device.__WARNING_no_match_for_argname_linef_in_MAX11043_device_t__ = linef; // update global property value
01286                     }
01287                     // parse argument uint8_t rate
01288                     uint8_t rate = 0; // --- g_MAX11043_device.__WARNING_no_match_for_argname_rate_in_MAX11043_device_t__; // default to global property value
01289                     if (cmdLine.parse_uint8_dec("rate", rate))
01290                     {
01291                         // g_MAX11043_device.__WARNING_no_match_for_argname_rate_in_MAX11043_device_t__ = rate; // update global property value
01292                     }
01293                     // print arguments
01294                     cmdLine.serial().printf("Configure_XXXXX");
01295                     cmdLine.serial().printf(" linef=%d", linef);
01296                     cmdLine.serial().printf(" rate=%d", rate);
01297                     cmdLine.serial().printf("\r\n");
01298                     // call function Configure_XXXXX(linef, rate)
01299                     uint8_t result = g_MAX11043_device.Configure_XXXXX(linef, rate);
01300                     cmdLine.serial().printf(" =%d\r\n", result);
01301                     return true; // command handled by MAX11043
01302 // CODE GENERATOR: bottom of loop: testMenuCommand="XX", testMenuFirstCharHandler="X"
01303                 } // end nested case 'XX'
01304                 break;
01305 
01306 // CODE GENERATOR: top of loop: testMenuCommand="XY", testMenuFirstCharHandler="X"
01307 // CODE GENERATOR: top of loop: nested switch "X" is currently open
01308 // CODE GENERATOR: test menu case 'XY':
01309 // CODE GENERATOR:           helpString 'XY linef=? rate=? -- Configure_XXXXY'
01310 // CODE GENERATOR:           CMD_ 'None'
01311 // CODE GENERATOR:           CommandName 'Configure_XXXXY'
01312 // CODE GENERATOR:           CommandParamIn 'uint8_t linef, uint8_t rate'
01313 // CODE GENERATOR:           CommandReturnType 'uint8_t'
01314 // CODE GENERATOR:           CommandPre ''
01315 // CODE GENERATOR:           CommandDocParamIn ''
01316 // CODE GENERATOR:           CommandDocParamOut ''
01317 // CODE GENERATOR:           CommandPost ''
01318 // CODE GENERATOR:           CommandReturn '@return 1 on success; 0 on failure'
01319                 case 'Y': // (nested inside case 'X')
01320                 {
01321                     // test menu command 'XY' handler:
01322                     // helpString='XY linef=? rate=? -- Configure_XXXXY'
01323                     // CMD_='None'
01324                     // CommandName='Configure_XXXXY'
01325                     // CommandParamIn='uint8_t linef, uint8_t rate'
01326                     // CommandReturnType='uint8_t'
01327                     // @Pre=''
01328                     // @Param[in]=''
01329                     // @Param[out]=''
01330                     // @Post=''
01331                     // displayPost=''
01332                     // @Return='@return 1 on success; 0 on failure'
01333                     // parse argument list
01334                     // parse argument uint8_t linef
01335                     uint8_t linef = 0; // --- g_MAX11043_device.__WARNING_no_match_for_argname_linef_in_MAX11043_device_t__; // default to global property value
01336                     if (cmdLine.parse_uint8_dec("linef", linef))
01337                     {
01338                         // g_MAX11043_device.__WARNING_no_match_for_argname_linef_in_MAX11043_device_t__ = linef; // update global property value
01339                     }
01340                     // parse argument uint8_t rate
01341                     uint8_t rate = 0; // --- g_MAX11043_device.__WARNING_no_match_for_argname_rate_in_MAX11043_device_t__; // default to global property value
01342                     if (cmdLine.parse_uint8_dec("rate", rate))
01343                     {
01344                         // g_MAX11043_device.__WARNING_no_match_for_argname_rate_in_MAX11043_device_t__ = rate; // update global property value
01345                     }
01346                     // print arguments
01347                     cmdLine.serial().printf("Configure_XXXXY");
01348                     cmdLine.serial().printf(" linef=%d", linef);
01349                     cmdLine.serial().printf(" rate=%d", rate);
01350                     cmdLine.serial().printf("\r\n");
01351                     // call function Configure_XXXXY(linef, rate)
01352                     uint8_t result = g_MAX11043_device.Configure_XXXXY(linef, rate);
01353                     cmdLine.serial().printf(" =%d\r\n", result);
01354                     return true; // command handled by MAX11043
01355 // CODE GENERATOR: bottom of loop: testMenuCommand="XY", testMenuFirstCharHandler="X"
01356                 } // end nested case 'XY'
01357                 break;
01358 
01359             } // end nested switch (cmdLine[1]) inside case 'X'
01360             break;
01361         } // end case 'X'
01362         // has_register_write_command: case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands
01363         case '0': case '1': case '2': case '3': case '4':
01364         case '5': case '6': case '7': case '8': case '9':
01365         case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
01366         case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
01367         {
01368             // hexadecimal codes get parsed as bytecodes
01369             //
01370             // parse_byteCount_byteList_dec() assumes all keyword args have already been removed from the buffer
01371                     // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
01372                     #define MAX_SPI_BYTE_COUNT 32
01373                     size_t byteCount = byteCount;
01374                     static char mosiData[MAX_SPI_BYTE_COUNT];
01375                     static char misoData[MAX_SPI_BYTE_COUNT];
01376                     if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
01377                                                              MAX_SPI_BYTE_COUNT))
01378                     {
01379                         // TODO: decode operation from commandByte
01380                         // TODO: OVERSIMPLIFICATION: if length is 1 byte then operation is RegRead, otherwise RegWrite
01381                         // register_read_function 'IsRegReadCommand'
01382                         // register_write_function 'RegWrite'
01383                         // register_name_function 'RegName'
01384                         // register_size_function 'RegSize'
01385 // CODE GENERATOR: does the chip have a defined CMDOP_1aaa_aaaa_ReadRegister bit?
01386                         // MAX11043::MAX11043_CMD_enum_t regAddress = (MAX11043::MAX11043_CMD_enum_t)((mosiData[0] &~ MAX11043::CMDOP_1aaa_aaaa_ReadRegister) & 0xFF);
01387                         MAX11043::MAX11043_CMD_enum_t commandByte = (MAX11043::MAX11043_CMD_enum_t)(mosiData[0]);
01388                         MAX11043::MAX11043_CMDOP_enum_t commandOp = g_MAX11043_device.DecodeCommand(commandByte);
01389                         int regAddress = g_MAX11043_device.RegAddrOfCommand(commandByte);
01390                         cmdLine.serial().printf(" regAddress=0x%2.2x\r\n", (regAddress & 0xFF));
01391                         cmdLine.serial().printf(" RegName=%s\r\n", g_MAX11043_device.RegName(commandByte));
01392                         uint32_t regData = 0;
01393                         int regSize = g_MAX11043_device.RegSize(commandByte);
01394                         cmdLine.serial().printf(" RegSize=%d\r\n", regSize);
01395                         switch(regSize)
01396                         {
01397                         case 8:
01398                             regData = ((uint32_t)mosiData[1] & 0xFF);
01399                             break;
01400                         case 16:
01401                             regData = (((uint32_t)mosiData[1] & 0xFF) << 8) + ((uint32_t)mosiData[2] & 0xFF);
01402                             break;
01403                         case 24:
01404                             regData = (((uint32_t)mosiData[1] & 0xFF) << 16) + (((uint32_t)mosiData[2] & 0xFF) << 8) + ((uint32_t)mosiData[3] & 0xFF);
01405                             break;
01406                         }
01407 // CODE GENERATOR: does the chip have a defined CMDOP_1aaa_aaaa_ReadRegister bit?
01408                         // if ((byteCount == 1) || (regAddress & MAX11043::CMDOP_1aaa_aaaa_ReadRegister))
01409                         if ((byteCount == 1) || g_MAX11043_device.IsRegReadCommand(commandByte))
01410                         {
01411                             cmdLine.serial().printf(" RegRead");
01412                             g_MAX11043_device.RegRead(commandByte, &regData);
01413                             cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF));
01414                         }
01415                         else
01416                         {
01417                             cmdLine.serial().printf(" RegWrite regData=0x%6.6X\r\n", (regData & 0x00FFFFFF));
01418                             g_MAX11043_device.RegWrite(commandByte, regData);
01419                         }
01420                         // is there support function shadow regValue of regAddr?
01421                     }
01422                     return true; // command handled by MAX11043
01423             //
01424         } // end case '0'..'9','A'..'F','a'..'f'
01425         break;
01426     } // end switch (cmdLine[0])
01427     return false; // command not handled by MAX11043
01428 } // end bool MAX11043_menu_onEOLcommandParser(CmdLine & cmdLine)
01429 
01430 // CODE GENERATOR: class declaration statement close