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

Dependencies:   MaximTinyTester CmdLine MAX541 USBDevice

Committer:
whismanoid
Date:
Thu Feb 27 03:42:16 2020 +0000
Revision:
87:4bc981dfd54b
Parent:
86:c116654dfa32
Child:
88:e4fd5033a55f
WIP signed compare

Who changed what in which revision?

UserRevisionLine numberNew contents of line
whismanoid 52:607010f0c54e 1 // /*******************************************************************************
whismanoid 52:607010f0c54e 2 // * Copyright (C) 2020 Maxim Integrated Products, Inc., All Rights Reserved.
whismanoid 52:607010f0c54e 3 // *
whismanoid 52:607010f0c54e 4 // * Permission is hereby granted, free of charge, to any person obtaining a
whismanoid 52:607010f0c54e 5 // * copy of this software and associated documentation files (the "Software"),
whismanoid 52:607010f0c54e 6 // * to deal in the Software without restriction, including without limitation
whismanoid 52:607010f0c54e 7 // * the rights to use, copy, modify, merge, publish, distribute, sublicense,
whismanoid 52:607010f0c54e 8 // * and/or sell copies of the Software, and to permit persons to whom the
whismanoid 52:607010f0c54e 9 // * Software is furnished to do so, subject to the following conditions:
whismanoid 52:607010f0c54e 10 // *
whismanoid 52:607010f0c54e 11 // * The above copyright notice and this permission notice shall be included
whismanoid 52:607010f0c54e 12 // * in all copies or substantial portions of the Software.
whismanoid 52:607010f0c54e 13 // *
whismanoid 52:607010f0c54e 14 // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
whismanoid 52:607010f0c54e 15 // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
whismanoid 52:607010f0c54e 16 // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
whismanoid 52:607010f0c54e 17 // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
whismanoid 52:607010f0c54e 18 // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
whismanoid 52:607010f0c54e 19 // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
whismanoid 52:607010f0c54e 20 // * OTHER DEALINGS IN THE SOFTWARE.
whismanoid 52:607010f0c54e 21 // *
whismanoid 52:607010f0c54e 22 // * Except as contained in this notice, the name of Maxim Integrated
whismanoid 52:607010f0c54e 23 // * Products, Inc. shall not be used except as stated in the Maxim Integrated
whismanoid 52:607010f0c54e 24 // * Products, Inc. Branding Policy.
whismanoid 52:607010f0c54e 25 // *
whismanoid 52:607010f0c54e 26 // * The mere transfer of this software does not imply any licenses
whismanoid 52:607010f0c54e 27 // * of trade secrets, proprietary technology, copyrights, patents,
whismanoid 52:607010f0c54e 28 // * trademarks, maskwork rights, or any other form of intellectual
whismanoid 52:607010f0c54e 29 // * property whatsoever. Maxim Integrated Products, Inc. retains all
whismanoid 52:607010f0c54e 30 // * ownership rights.
whismanoid 52:607010f0c54e 31 // *******************************************************************************
whismanoid 83:29bb86cc45bc 32 // */ * MANUAL EDITS PRESENT *
whismanoid 52:607010f0c54e 33 #include "CmdLine.h"
whismanoid 52:607010f0c54e 34 #include "MaximTinyTester.h"
whismanoid 52:607010f0c54e 35 // CODE GENERATOR: class declaration and docstrings
whismanoid 52:607010f0c54e 36 // CODE GENERATOR: example code includes
whismanoid 52:607010f0c54e 37 // example code includes
whismanoid 52:607010f0c54e 38 // standard include for target platform -- Platform_Include_Boilerplate
whismanoid 52:607010f0c54e 39 #include "mbed.h"
whismanoid 52:607010f0c54e 40 // Platforms:
whismanoid 52:607010f0c54e 41 // - MAX32625MBED
whismanoid 52:607010f0c54e 42 // - supports mbed-os-5.11, requires USBDevice library
whismanoid 52:607010f0c54e 43 // - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
whismanoid 52:607010f0c54e 44 // - remove max32630fthr library (if present)
whismanoid 52:607010f0c54e 45 // - remove MAX32620FTHR library (if present)
whismanoid 52:607010f0c54e 46 // - MAX32600MBED
whismanoid 52:607010f0c54e 47 // - remove max32630fthr library (if present)
whismanoid 52:607010f0c54e 48 // - remove MAX32620FTHR library (if present)
whismanoid 52:607010f0c54e 49 // - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board.
whismanoid 52:607010f0c54e 50 // - NUCLEO_F446RE
whismanoid 52:607010f0c54e 51 // - remove USBDevice library
whismanoid 52:607010f0c54e 52 // - remove max32630fthr library (if present)
whismanoid 52:607010f0c54e 53 // - remove MAX32620FTHR library (if present)
whismanoid 52:607010f0c54e 54 // - NUCLEO_F401RE
whismanoid 52:607010f0c54e 55 // - remove USBDevice library
whismanoid 52:607010f0c54e 56 // - remove max32630fthr library (if present)
whismanoid 52:607010f0c54e 57 // - remove MAX32620FTHR library (if present)
whismanoid 52:607010f0c54e 58 // - MAX32630FTHR
whismanoid 52:607010f0c54e 59 // - #include "max32630fthr.h"
whismanoid 52:607010f0c54e 60 // - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/
whismanoid 52:607010f0c54e 61 // - remove MAX32620FTHR library (if present)
whismanoid 52:607010f0c54e 62 // - MAX32620FTHR
whismanoid 52:607010f0c54e 63 // - #include "MAX32620FTHR.h"
whismanoid 52:607010f0c54e 64 // - remove max32630fthr library (if present)
whismanoid 52:607010f0c54e 65 // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
whismanoid 52:607010f0c54e 66 // - not tested yet
whismanoid 52:607010f0c54e 67 // - MAX32625PICO
whismanoid 52:607010f0c54e 68 // - remove max32630fthr library (if present)
whismanoid 52:607010f0c54e 69 // - remove MAX32620FTHR library (if present)
whismanoid 52:607010f0c54e 70 // - not tested yet
whismanoid 52:607010f0c54e 71 //
whismanoid 52:607010f0c54e 72 // end Platform_Include_Boilerplate
whismanoid 52:607010f0c54e 73 #include "MAX11043.h"
whismanoid 52:607010f0c54e 74 #include "CmdLine.h"
whismanoid 52:607010f0c54e 75 #include "MaximTinyTester.h"
whismanoid 52:607010f0c54e 76 // CODE GENERATOR: class declaration statement open
whismanoid 52:607010f0c54e 77
whismanoid 52:607010f0c54e 78 // CODE GENERATOR: Test_Menu externs
whismanoid 52:607010f0c54e 79 #include "MAX11043.h"
whismanoid 52:607010f0c54e 80 extern MAX11043 g_MAX11043_device; // defined in main.cpp
whismanoid 52:607010f0c54e 81
whismanoid 84:11cc360628a1 82 //--------------------------------------------------
whismanoid 84:11cc360628a1 83 // Diagnostic: Read 4 command -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.
whismanoid 84:11cc360628a1 84 #ifndef Has_Read4Command_Command
whismanoid 84:11cc360628a1 85 #define Has_Read4Command_Command 1
whismanoid 84:11cc360628a1 86 #endif // Has_Read4Command_Command
whismanoid 84:11cc360628a1 87 #if Has_Read4Command_Command
whismanoid 84:11cc360628a1 88 #endif // Has_Read4Command_Command
whismanoid 84:11cc360628a1 89 //--------------------------------------------------
whismanoid 84:11cc360628a1 90 // Diagnostic: Read 4 command -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.
whismanoid 84:11cc360628a1 91 #ifndef Use_Read4Command_Thread
whismanoid 84:11cc360628a1 92 #define Use_Read4Command_Thread 1
whismanoid 84:11cc360628a1 93 #endif // Use_Read4Command_Thread
whismanoid 84:11cc360628a1 94 #if Use_Read4Command_Thread
whismanoid 84:11cc360628a1 95 #endif // Use_Read4Command_Thread
whismanoid 84:11cc360628a1 96
whismanoid 84:11cc360628a1 97 //--------------------------------------------------
whismanoid 84:11cc360628a1 98 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
whismanoid 84:11cc360628a1 99 #ifndef MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 84:11cc360628a1 100 #define MAX11043_ScopeTrigger_MAX32625MBED_D5 1
whismanoid 84:11cc360628a1 101 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 84:11cc360628a1 102 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 84:11cc360628a1 103 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
whismanoid 84:11cc360628a1 104 // WIP MAX11043 interrupt EOC echo - moving DigitalOut ScopeTrigger to global scope, it compiles but there is no activity on scope
whismanoid 84:11cc360628a1 105 extern DigitalInOut digitalInOut5; // declared in Test_Main_MAX11043.cpp (D5, PIN_INPUT, PullUp, 1)
whismanoid 84:11cc360628a1 106 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 84:11cc360628a1 107
whismanoid 84:11cc360628a1 108 #if Use_Read4Command_Thread
whismanoid 84:11cc360628a1 109 #define MYTIMEREVENTFLAG_ENABLE_SPI (1UL << 0)
whismanoid 84:11cc360628a1 110 EventFlags Read4Command_Thread_event_flags;
whismanoid 84:11cc360628a1 111 Thread Read4Command_Thread;
whismanoid 87:4bc981dfd54b 112 int adca_newest = 0;
whismanoid 87:4bc981dfd54b 113 int adcb_newest = 0;
whismanoid 87:4bc981dfd54b 114 int adcc_newest = 0;
whismanoid 87:4bc981dfd54b 115 int adcd_newest = 0;
whismanoid 87:4bc981dfd54b 116 int adcX_MIN_SEEN_INIT_INT16_MAX = 0x7FFF; // INT16_MAX
whismanoid 87:4bc981dfd54b 117 int adcX_MAX_SEEN_INIT_INT16_MIN = 0x8000; // INT16_MIN
whismanoid 87:4bc981dfd54b 118 int adca_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
whismanoid 87:4bc981dfd54b 119 int adca_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
whismanoid 87:4bc981dfd54b 120 int adcb_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
whismanoid 87:4bc981dfd54b 121 int adcb_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
whismanoid 87:4bc981dfd54b 122 int adcc_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
whismanoid 87:4bc981dfd54b 123 int adcc_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
whismanoid 87:4bc981dfd54b 124 int adcd_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
whismanoid 87:4bc981dfd54b 125 int adcd_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
whismanoid 84:11cc360628a1 126 #endif // Use_Read4Command_Thread
whismanoid 84:11cc360628a1 127 #if Use_Read4Command_Thread
whismanoid 84:11cc360628a1 128 void Read4Command_Thread_handler()
whismanoid 84:11cc360628a1 129 {
whismanoid 84:11cc360628a1 130 const int convrun_pulse_width_us = 30;
whismanoid 84:11cc360628a1 131 const int convrun_stop_us = 10;
whismanoid 84:11cc360628a1 132 // running in thread context in Thread Read4Command_Thread
whismanoid 84:11cc360628a1 133 // operate the SPI interface at specified sample rate
whismanoid 84:11cc360628a1 134 // shared read only: periodicInterruptTimer_interval_usec
whismanoid 84:11cc360628a1 135 while (true) {
whismanoid 85:a47ed024c508 136 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 85:a47ed024c508 137 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
whismanoid 85:a47ed024c508 138 //~ digitalInOut5.write(0); // ScopeTrigger
whismanoid 85:a47ed024c508 139 digitalInOut5.write(1); // ScopeTrigger
whismanoid 85:a47ed024c508 140 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 84:11cc360628a1 141 //signal_wait(int32_t signals, uint32_t millisec=osWaitForever)
whismanoid 84:11cc360628a1 142 //flags_read = Read4Command_Thread_event_flags.wait_any(MYTIMEREVENTFLAG_ENABLE_SPI);
whismanoid 84:11cc360628a1 143 Read4Command_Thread_event_flags.wait_any(MYTIMEREVENTFLAG_ENABLE_SPI, osWaitForever, false); // clear=false: don't auto clear the flag
whismanoid 84:11cc360628a1 144 //
whismanoid 85:a47ed024c508 145 // CONVRUN = H -- perform ADC conversions (EOC will pulse, and data registers will update)
whismanoid 84:11cc360628a1 146 g_MAX11043_device.CONVRUNoutputValue(1);
whismanoid 84:11cc360628a1 147 //
whismanoid 85:a47ed024c508 148 // delay at least 9us to ensure at least one converion happens
whismanoid 84:11cc360628a1 149 wait_us(convrun_pulse_width_us);
whismanoid 84:11cc360628a1 150 //
whismanoid 85:a47ed024c508 151 // CONVRUN = L -- stop ADC conversions
whismanoid 84:11cc360628a1 152 g_MAX11043_device.CONVRUNoutputValue(0);
whismanoid 84:11cc360628a1 153 //
whismanoid 85:a47ed024c508 154 // delay at least 9us to ensure final converion complete
whismanoid 84:11cc360628a1 155 wait_us(convrun_stop_us);
whismanoid 84:11cc360628a1 156 //
whismanoid 85:a47ed024c508 157 // run SPI to capture 4 channels
whismanoid 84:11cc360628a1 158 g_MAX11043_device.Read_ADCabcd();
whismanoid 84:11cc360628a1 159 // post: g_MAX11043_device.adca was updated
whismanoid 84:11cc360628a1 160 // post: g_MAX11043_device.adcb was updated
whismanoid 84:11cc360628a1 161 // post: g_MAX11043_device.adcc was updated
whismanoid 84:11cc360628a1 162 // post: g_MAX11043_device.adcd was updated
whismanoid 84:11cc360628a1 163 //
whismanoid 85:a47ed024c508 164 // TODO: capture min/max 2's complement value each channel
whismanoid 87:4bc981dfd54b 165 // #define SIGN_EXTEND_INT16_VALUE(x) (((x)&(0x8000))?((x)-65536):(x))
whismanoid 87:4bc981dfd54b 166 // adca_newest = SIGN_EXTEND_INT16_VALUE(g_MAX11043_device.adca);
whismanoid 87:4bc981dfd54b 167 // adcb_newest = SIGN_EXTEND_INT16_VALUE(g_MAX11043_device.adcb);
whismanoid 87:4bc981dfd54b 168 // adcc_newest = SIGN_EXTEND_INT16_VALUE(g_MAX11043_device.adcc);
whismanoid 87:4bc981dfd54b 169 // adcd_newest = SIGN_EXTEND_INT16_VALUE(g_MAX11043_device.adcd);
whismanoid 87:4bc981dfd54b 170 adca_newest = g_MAX11043_device.adca; if (adca_newest & 0x8000) { adca_newest = adca_newest - 65536; }
whismanoid 87:4bc981dfd54b 171 adcb_newest = g_MAX11043_device.adcb; if (adcb_newest & 0x8000) { adcb_newest = adcb_newest - 65536; }
whismanoid 87:4bc981dfd54b 172 adcc_newest = g_MAX11043_device.adcc; if (adcc_newest & 0x8000) { adcc_newest = adcc_newest - 65536; }
whismanoid 87:4bc981dfd54b 173 adcd_newest = g_MAX11043_device.adcd; if (adcd_newest & 0x8000) { adcd_newest = adcd_newest - 65536; }
whismanoid 87:4bc981dfd54b 174 // 2020-02-26 this fails because using LDRHI instruction (unsigned comparison), must use signed instead.
whismanoid 87:4bc981dfd54b 175 // Try SIGN_EXTEND_INT16_VALUE to force signed comparison (ldrGE, ldrLT, ldrGT, ldrLE) instead of unsigned comparision (ldrHS, ldrLO, ldrHI, ldrLS)
whismanoid 87:4bc981dfd54b 176 if (adca_MAX_SEEN < adca_newest) {
whismanoid 87:4bc981dfd54b 177 adca_MAX_SEEN = adca_newest;
whismanoid 85:a47ed024c508 178 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 85:a47ed024c508 179 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
whismanoid 85:a47ed024c508 180 digitalInOut5.write(0); // ScopeTrigger
whismanoid 85:a47ed024c508 181 wait_us(5);
whismanoid 85:a47ed024c508 182 digitalInOut5.write(1); // ScopeTrigger
whismanoid 85:a47ed024c508 183 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 85:a47ed024c508 184 }
whismanoid 87:4bc981dfd54b 185 if (adca_MIN_SEEN > adca_newest) {
whismanoid 87:4bc981dfd54b 186 adca_MIN_SEEN = adca_newest;
whismanoid 84:11cc360628a1 187 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 84:11cc360628a1 188 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
whismanoid 85:a47ed024c508 189 digitalInOut5.write(0); // ScopeTrigger
whismanoid 85:a47ed024c508 190 wait_us(10);
whismanoid 85:a47ed024c508 191 digitalInOut5.write(1); // ScopeTrigger
whismanoid 84:11cc360628a1 192 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 85:a47ed024c508 193 }
whismanoid 87:4bc981dfd54b 194 if (adcb_MAX_SEEN < adcb_newest) {
whismanoid 87:4bc981dfd54b 195 adcb_MAX_SEEN = adcb_newest;
whismanoid 85:a47ed024c508 196 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 85:a47ed024c508 197 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
whismanoid 85:a47ed024c508 198 digitalInOut5.write(0); // ScopeTrigger
whismanoid 85:a47ed024c508 199 wait_us(15);
whismanoid 85:a47ed024c508 200 digitalInOut5.write(1); // ScopeTrigger
whismanoid 85:a47ed024c508 201 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 85:a47ed024c508 202 }
whismanoid 87:4bc981dfd54b 203 if (adcb_MIN_SEEN > adcb_newest) {
whismanoid 87:4bc981dfd54b 204 adcb_MIN_SEEN = adcb_newest;
whismanoid 85:a47ed024c508 205 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 85:a47ed024c508 206 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
whismanoid 85:a47ed024c508 207 digitalInOut5.write(0); // ScopeTrigger
whismanoid 85:a47ed024c508 208 wait_us(20);
whismanoid 85:a47ed024c508 209 digitalInOut5.write(1); // ScopeTrigger
whismanoid 85:a47ed024c508 210 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 85:a47ed024c508 211 }
whismanoid 87:4bc981dfd54b 212 // TODO: compare adcc_newest, update MIN_SEEN MAX_SEEN
whismanoid 87:4bc981dfd54b 213 // TODO: compare adcd_newest, update MIN_SEEN MAX_SEEN
whismanoid 85:a47ed024c508 214 // TODO: compare with thresholds, report if exceeded
whismanoid 84:11cc360628a1 215 //
whismanoid 84:11cc360628a1 216 // blocking delay time us_timestamp_t periodicInterruptTimer_interval_usec
whismanoid 84:11cc360628a1 217 //~ const us_timestamp_t overhead_usec = 24;
whismanoid 84:11cc360628a1 218 //~ if (periodicInterruptTimer_interval_usec > overhead_usec) {
whismanoid 84:11cc360628a1 219 //~ wait_us(periodicInterruptTimer_interval_usec - overhead_usec);
whismanoid 84:11cc360628a1 220 //~ }
whismanoid 84:11cc360628a1 221 }
whismanoid 84:11cc360628a1 222 }
whismanoid 84:11cc360628a1 223 #endif // Use_Read4Command_Thread
whismanoid 84:11cc360628a1 224 #if Use_Read4Command_Thread
whismanoid 84:11cc360628a1 225 //~ Read4Command_Thread_event_flags.set(MYTIMEREVENTFLAG_ENABLE_SPI);
whismanoid 84:11cc360628a1 226 #endif // Use_Read4Command_Thread
whismanoid 84:11cc360628a1 227 #if Use_Read4Command_Thread
whismanoid 84:11cc360628a1 228 //~ Read4Command_Thread_event_flags.clear(MYTIMEREVENTFLAG_ENABLE_SPI);
whismanoid 84:11cc360628a1 229 #endif // Use_Read4Command_Thread
whismanoid 84:11cc360628a1 230 #if Use_Read4Command_Thread
whismanoid 84:11cc360628a1 231 // init
whismanoid 84:11cc360628a1 232 //~ Read4Command_Thread.start(Read4Command_Thread_handler);
whismanoid 84:11cc360628a1 233 #endif // Use_Read4Command_Thread
whismanoid 84:11cc360628a1 234
whismanoid 52:607010f0c54e 235 // CODE GENERATOR: build testMenuCommand list
whismanoid 52:607010f0c54e 236 // CODE GENERATOR: build testMenuGlobalArgsDict common/global argument list
whismanoid 52:607010f0c54e 237 // CODE GENERATOR: class member function declarations
whismanoid 52:607010f0c54e 238 // CODE GENERATOR: MAX11043 Command Name = Init (void) --> uint8_t
whismanoid 52:607010f0c54e 239 // CODE GENERATOR: Menu item hint description Menu item '!'
whismanoid 52:607010f0c54e 240 // CODE GENERATOR: Menu item '!' -- Menu item !
whismanoid 52:607010f0c54e 241 // CODE GENERATOR: test menu case '!':
whismanoid 52:607010f0c54e 242 // CODE GENERATOR: helpString '! -- Init'
whismanoid 52:607010f0c54e 243 // CODE GENERATOR: CMD_ 'None'
whismanoid 52:607010f0c54e 244 // CODE GENERATOR: CommandName 'Init'
whismanoid 52:607010f0c54e 245 // CODE GENERATOR: CommandParamIn 'void'
whismanoid 52:607010f0c54e 246 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 52:607010f0c54e 247 // CODE GENERATOR: CommandPre ''
whismanoid 52:607010f0c54e 248 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 52:607010f0c54e 249 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 52:607010f0c54e 250 // CODE GENERATOR: CommandPost ''
whismanoid 52:607010f0c54e 251 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 52:607010f0c54e 252 // CODE GENERATOR: MAX11043 Command Name = RegWrite (MAX11043_CMD_enum_t commandByte, uint32_t regData) --> uint8_t
whismanoid 52:607010f0c54e 253 // CODE GENERATOR: no Menu item hint in description
whismanoid 52:607010f0c54e 254 // CODE GENERATOR: MAX11043 Command Name = RegRead (MAX11043_CMD_enum_t commandByte, uint32_t* ptrRegData) --> uint8_t
whismanoid 52:607010f0c54e 255 // CODE GENERATOR: no Menu item hint in description
whismanoid 52:607010f0c54e 256 // CODE GENERATOR: MAX11043 Command Name = RegSize (MAX11043_CMD_enum_t commandByte) --> uint8_t
whismanoid 52:607010f0c54e 257 // CODE GENERATOR: no Menu item hint in description
whismanoid 57:1c9da8e90737 258 // CODE GENERATOR: MAX11043 Command Name = DecodeCommand (MAX11043_CMD_enum_t commandByte) --> MAX11043::MAX11043_CMDOP_enum_t
whismanoid 57:1c9da8e90737 259 // CODE GENERATOR: no Menu item hint in description
whismanoid 52:607010f0c54e 260 // CODE GENERATOR: MAX11043 Command Name = RegAddrOfCommand (MAX11043_CMD_enum_t commandByte) --> uint8_t
whismanoid 52:607010f0c54e 261 // CODE GENERATOR: no Menu item hint in description
whismanoid 52:607010f0c54e 262 // CODE GENERATOR: MAX11043 Command Name = IsRegReadCommand (MAX11043_CMD_enum_t commandByte) --> uint8_t
whismanoid 52:607010f0c54e 263 // CODE GENERATOR: no Menu item hint in description
whismanoid 52:607010f0c54e 264 // CODE GENERATOR: MAX11043 Command Name = RegName (MAX11043_CMD_enum_t commandByte) --> const char*
whismanoid 52:607010f0c54e 265 // CODE GENERATOR: no Menu item hint in description
whismanoid 64:a667cfd83492 266 // CODE GENERATOR: MAX11043 Command Name = Read_ADCabcd (void) --> uint8_t
whismanoid 64:a667cfd83492 267 // CODE GENERATOR: Menu item hint description Menu item '$' -> adca, adcb, adcc, adcd
whismanoid 64:a667cfd83492 268 // CODE GENERATOR: Menu item '$' -> adca, adcb, adcc, adcd -- Menu item $
whismanoid 64:a667cfd83492 269 // CODE GENERATOR: test menu case '$':
whismanoid 64:a667cfd83492 270 // CODE GENERATOR: helpString '$ -- Read_ADCabcd'
whismanoid 64:a667cfd83492 271 // CODE GENERATOR: CMD_ 'None'
whismanoid 64:a667cfd83492 272 // CODE GENERATOR: CommandName 'Read_ADCabcd'
whismanoid 64:a667cfd83492 273 // CODE GENERATOR: CommandParamIn 'void'
whismanoid 64:a667cfd83492 274 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 64:a667cfd83492 275 // CODE GENERATOR: CommandPre ''
whismanoid 64:a667cfd83492 276 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 64:a667cfd83492 277 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 64:a667cfd83492 278 // CODE GENERATOR: CommandPost ''
whismanoid 64:a667cfd83492 279 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 64:a667cfd83492 280 // CODE GENERATOR: MAX11043 Command Name = Write_AGain (uint32_t gain) --> uint8_t
whismanoid 66:3fe92f6f1cfa 281 // CODE GENERATOR: Menu item hint description Menu item 'GA'
whismanoid 66:3fe92f6f1cfa 282 // CODE GENERATOR: Menu item 'GA' -- Menu item GA
whismanoid 66:3fe92f6f1cfa 283 // CODE GENERATOR: MAX11043 help: GA uint32_t gain -- Write_AGain
whismanoid 66:3fe92f6f1cfa 284 // CODE GENERATOR: MAX11043 helpString: 'GA gain=? -- Write_AGain'
whismanoid 66:3fe92f6f1cfa 285 // CODE GENERATOR: test menu case 'GA':
whismanoid 66:3fe92f6f1cfa 286 // CODE GENERATOR: helpString 'GA gain=? -- Write_AGain'
whismanoid 64:a667cfd83492 287 // CODE GENERATOR: CMD_ 'None'
whismanoid 64:a667cfd83492 288 // CODE GENERATOR: CommandName 'Write_AGain'
whismanoid 64:a667cfd83492 289 // CODE GENERATOR: CommandParamIn 'uint32_t gain'
whismanoid 64:a667cfd83492 290 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 64:a667cfd83492 291 // CODE GENERATOR: CommandPre ''
whismanoid 64:a667cfd83492 292 // CODE GENERATOR: CommandDocParamIn '@param[in] gain 2's complement, 0x800=0.25V/V, 0x1000=0.5V/V, 0x2000=1VV/V, 0x4000=2V/V, default=0x2000'
whismanoid 64:a667cfd83492 293 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 64:a667cfd83492 294 // CODE GENERATOR: CommandPost ''
whismanoid 64:a667cfd83492 295 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 59:47538bcf6cda 296 // CODE GENERATOR: MAX11043 Command Name = Configure_XXXXX (uint8_t linef, uint8_t rate) --> uint8_t
whismanoid 59:47538bcf6cda 297 // CODE GENERATOR: Menu item hint description Menu item 'XX'
whismanoid 59:47538bcf6cda 298 // CODE GENERATOR: Menu item 'XX' -- Menu item XX
whismanoid 59:47538bcf6cda 299 // CODE GENERATOR: MAX11043 help: XX uint8_t linef, uint8_t rate -- Configure_XXXXX
whismanoid 59:47538bcf6cda 300 // CODE GENERATOR: MAX11043 helpString: 'XX linef=? rate=? -- Configure_XXXXX'
whismanoid 59:47538bcf6cda 301 // CODE GENERATOR: test menu case 'XX':
whismanoid 59:47538bcf6cda 302 // CODE GENERATOR: helpString 'XX linef=? rate=? -- Configure_XXXXX'
whismanoid 59:47538bcf6cda 303 // CODE GENERATOR: CMD_ 'None'
whismanoid 59:47538bcf6cda 304 // CODE GENERATOR: CommandName 'Configure_XXXXX'
whismanoid 59:47538bcf6cda 305 // CODE GENERATOR: CommandParamIn 'uint8_t linef, uint8_t rate'
whismanoid 59:47538bcf6cda 306 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 59:47538bcf6cda 307 // CODE GENERATOR: CommandPre ''
whismanoid 59:47538bcf6cda 308 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 59:47538bcf6cda 309 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 59:47538bcf6cda 310 // CODE GENERATOR: CommandPost ''
whismanoid 59:47538bcf6cda 311 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 59:47538bcf6cda 312 // CODE GENERATOR: MAX11043 Command Name = Configure_XXXXY (uint8_t linef, uint8_t rate) --> uint8_t
whismanoid 59:47538bcf6cda 313 // CODE GENERATOR: Menu item hint description Menu item 'XY'
whismanoid 59:47538bcf6cda 314 // CODE GENERATOR: Menu item 'XY' -- Menu item XY
whismanoid 59:47538bcf6cda 315 // CODE GENERATOR: MAX11043 help: XY uint8_t linef, uint8_t rate -- Configure_XXXXY
whismanoid 59:47538bcf6cda 316 // CODE GENERATOR: MAX11043 helpString: 'XY linef=? rate=? -- Configure_XXXXY'
whismanoid 59:47538bcf6cda 317 // CODE GENERATOR: test menu case 'XY':
whismanoid 59:47538bcf6cda 318 // CODE GENERATOR: helpString 'XY linef=? rate=? -- Configure_XXXXY'
whismanoid 59:47538bcf6cda 319 // CODE GENERATOR: CMD_ 'None'
whismanoid 59:47538bcf6cda 320 // CODE GENERATOR: CommandName 'Configure_XXXXY'
whismanoid 59:47538bcf6cda 321 // CODE GENERATOR: CommandParamIn 'uint8_t linef, uint8_t rate'
whismanoid 59:47538bcf6cda 322 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 59:47538bcf6cda 323 // CODE GENERATOR: CommandPre ''
whismanoid 59:47538bcf6cda 324 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 59:47538bcf6cda 325 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 59:47538bcf6cda 326 // CODE GENERATOR: CommandPost ''
whismanoid 59:47538bcf6cda 327 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 52:607010f0c54e 328 // CODE GENERATOR: testMenuGlobalArgsDict scan global property list g_MAX11043_device
whismanoid 52:607010f0c54e 329
whismanoid 59:47538bcf6cda 330 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.VRef
whismanoid 59:47538bcf6cda 331 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.VRef argname = VRef
whismanoid 59:47538bcf6cda 332 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['alias'] = 'None'
whismanoid 59:47538bcf6cda 333 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['argtype'] = 'double'
whismanoid 59:47538bcf6cda 334 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 335 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedBytestMenuItemName'] = 'None'
whismanoid 52:607010f0c54e 336
whismanoid 59:47538bcf6cda 337 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.config
whismanoid 59:47538bcf6cda 338 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.config shadow of argname = config
whismanoid 59:47538bcf6cda 339 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.config argname = config
whismanoid 59:47538bcf6cda 340 // CODE GENERATOR: testMenuGlobalArgsDict['config']['alias'] = 'None'
whismanoid 59:47538bcf6cda 341 // CODE GENERATOR: testMenuGlobalArgsDict['config']['argtype'] = 'uint16_t'
whismanoid 59:47538bcf6cda 342 // CODE GENERATOR: testMenuGlobalArgsDict['config']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 343 // CODE GENERATOR: testMenuGlobalArgsDict['config']['usedBytestMenuItemName'] = 'None'
whismanoid 52:607010f0c54e 344
whismanoid 52:607010f0c54e 345 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.status
whismanoid 52:607010f0c54e 346 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.status shadow of argname = status
whismanoid 52:607010f0c54e 347 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.status argname = status
whismanoid 52:607010f0c54e 348 // CODE GENERATOR: testMenuGlobalArgsDict['status']['alias'] = 'None'
whismanoid 52:607010f0c54e 349 // CODE GENERATOR: testMenuGlobalArgsDict['status']['argtype'] = 'uint32_t'
whismanoid 52:607010f0c54e 350 // CODE GENERATOR: testMenuGlobalArgsDict['status']['usedByCommandName'] = 'None'
whismanoid 52:607010f0c54e 351 // CODE GENERATOR: testMenuGlobalArgsDict['status']['usedBytestMenuItemName'] = 'None'
whismanoid 52:607010f0c54e 352
whismanoid 59:47538bcf6cda 353 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adca
whismanoid 59:47538bcf6cda 354 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adca shadow of argname = ADCa
whismanoid 59:47538bcf6cda 355 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adca argname = ADCa
whismanoid 59:47538bcf6cda 356 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['alias'] = 'None'
whismanoid 59:47538bcf6cda 357 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 358 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 359 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 360
whismanoid 59:47538bcf6cda 361 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcb
whismanoid 59:47538bcf6cda 362 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcb shadow of argname = ADCb
whismanoid 59:47538bcf6cda 363 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcb argname = ADCb
whismanoid 59:47538bcf6cda 364 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['alias'] = 'None'
whismanoid 59:47538bcf6cda 365 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 366 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 367 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['usedBytestMenuItemName'] = 'None'
whismanoid 52:607010f0c54e 368
whismanoid 59:47538bcf6cda 369 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcc
whismanoid 59:47538bcf6cda 370 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcc shadow of argname = ADCc
whismanoid 59:47538bcf6cda 371 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcc argname = ADCc
whismanoid 59:47538bcf6cda 372 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['alias'] = 'None'
whismanoid 59:47538bcf6cda 373 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 374 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 375 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 376
whismanoid 59:47538bcf6cda 377 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcd
whismanoid 59:47538bcf6cda 378 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcd shadow of argname = ADCd
whismanoid 59:47538bcf6cda 379 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcd argname = ADCd
whismanoid 59:47538bcf6cda 380 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['alias'] = 'None'
whismanoid 59:47538bcf6cda 381 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 382 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 383 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 384
whismanoid 52:607010f0c54e 385
whismanoid 52:607010f0c54e 386 // CODE GENERATOR: scan testMenuCommand list for items that can be shortened to single character
whismanoid 59:47538bcf6cda 387 // CODE GENERATOR: multiple commands begin with character 'X'
whismanoid 52:607010f0c54e 388 // CODE GENERATOR: shorten testMenuCommand to single character if unambiguous
whismanoid 52:607010f0c54e 389 // CODE GENERATOR: testMenuCommand '!' already single character
whismanoid 64:a667cfd83492 390 // CODE GENERATOR: testMenuCommand '$' already single character
whismanoid 66:3fe92f6f1cfa 391 // CODE GENERATOR: shorten testMenuCommand 'GA' to single character 'G'
whismanoid 66:3fe92f6f1cfa 392 // CODE GENERATOR: re.sub pattern:'GA' with repl:'G' in helpString 'GA gain=? -- Write_AGain'
whismanoid 66:3fe92f6f1cfa 393 // CODE GENERATOR: updated 'G' help string to 'G gain=? -- Write_AGain'
whismanoid 59:47538bcf6cda 394 // CODE GENERATOR: cannot shorten testMenuCommand 'XX' to single character due to duplicates
whismanoid 59:47538bcf6cda 395 // CODE GENERATOR: cannot shorten testMenuCommand 'XY' to single character due to duplicates
whismanoid 52:607010f0c54e 396
whismanoid 52:607010f0c54e 397 // CODE GENERATOR: help menu
whismanoid 52:607010f0c54e 398 bool MAX11043_menu_help(CmdLine & cmdLine)
whismanoid 52:607010f0c54e 399 {
whismanoid 52:607010f0c54e 400 // CODE GENERATOR: command: !
whismanoid 52:607010f0c54e 401 // CODE GENERATOR: help: ! -- Init
whismanoid 52:607010f0c54e 402 cmdLine.serial().printf("\r\n ! -- Init");
whismanoid 64:a667cfd83492 403 // CODE GENERATOR: command: $
whismanoid 64:a667cfd83492 404 // CODE GENERATOR: help: $ -- Read_ADCabcd
whismanoid 64:a667cfd83492 405 cmdLine.serial().printf("\r\n $ -- Read_ADCabcd");
whismanoid 66:3fe92f6f1cfa 406 // CODE GENERATOR: command: G
whismanoid 66:3fe92f6f1cfa 407 // CODE GENERATOR: help: G gain=? -- Write_AGain
whismanoid 66:3fe92f6f1cfa 408 cmdLine.serial().printf("\r\n G gain=? -- Write_AGain");
whismanoid 59:47538bcf6cda 409 // CODE GENERATOR: command: XX
whismanoid 59:47538bcf6cda 410 // CODE GENERATOR: help: XX linef=? rate=? -- Configure_XXXXX
whismanoid 59:47538bcf6cda 411 cmdLine.serial().printf("\r\n XX linef=? rate=? -- Configure_XXXXX");
whismanoid 59:47538bcf6cda 412 // CODE GENERATOR: command: XY
whismanoid 59:47538bcf6cda 413 // CODE GENERATOR: help: XY linef=? rate=? -- Configure_XXXXY
whismanoid 59:47538bcf6cda 414 cmdLine.serial().printf("\r\n XY linef=? rate=? -- Configure_XXXXY");
whismanoid 52:607010f0c54e 415 //
whismanoid 52:607010f0c54e 416 cmdLine.serial().printf("\r\n @ -- print MAX11043 configuration");
whismanoid 52:607010f0c54e 417
whismanoid 52:607010f0c54e 418 // CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register
whismanoid 52:607010f0c54e 419 cmdLine.serial().printf("\r\n *regname? -- read register\r\n *regname=regvalue -- write register");
whismanoid 52:607010f0c54e 420
whismanoid 52:607010f0c54e 421 //
whismanoid 52:607010f0c54e 422 // CODE GENERATOR: TODO1: generate GPIO commands for LDAC, CLR, etc. based on device driver function names (menu_help)
whismanoid 52:607010f0c54e 423 // case 'G'..'Z','g'..'z' are reserved for GPIO commands
whismanoid 52:607010f0c54e 424 // case 'A'..'F','a'..'f' may be available if not claimed by bitstream commands
whismanoid 52:607010f0c54e 425 // CODE GENERATOR: TODO1: prevent conflict ExternFunctionGPIOPinCommand with reserved case 'A'..'F','a'..'f'
whismanoid 52:607010f0c54e 426 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN'
whismanoid 52:607010f0c54e 427 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Direction'] = 'output'
whismanoid 52:607010f0c54e 428 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 429 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['FunctionName'] = 'CONVRUNoutputValue'
whismanoid 52:607010f0c54e 430
whismanoid 52:607010f0c54e 431 // CODE GENERATOR: warning: conflict testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN'
whismanoid 52:607010f0c54e 432 #warning "No command case for 'CONVRUN' 'PinName' 'CONVRUN' due to conflict with reserved commands A-F, try changing pin name"
whismanoid 66:3fe92f6f1cfa 433 #warning "Randomly assigned command 'H' for 'CONVRUN' due to name conflict"
whismanoid 52:607010f0c54e 434 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP'
whismanoid 52:607010f0c54e 435 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Direction'] = 'output'
whismanoid 52:607010f0c54e 436 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 437 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['FunctionName'] = 'DACSTEPoutputValue'
whismanoid 52:607010f0c54e 438
whismanoid 52:607010f0c54e 439 // CODE GENERATOR: warning: conflict testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP'
whismanoid 52:607010f0c54e 440 #warning "No command case for 'DACSTEP' 'PinName' 'DACSTEP' due to conflict with reserved commands A-F, try changing pin name"
whismanoid 66:3fe92f6f1cfa 441 #warning "Randomly assigned command 'I' for 'DACSTEP' due to name conflict"
whismanoid 52:607010f0c54e 442 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC'
whismanoid 52:607010f0c54e 443 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Direction'] = 'input'
whismanoid 52:607010f0c54e 444 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 445 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['FunctionName'] = 'EOCinputValue'
whismanoid 52:607010f0c54e 446
whismanoid 52:607010f0c54e 447 // CODE GENERATOR: warning: conflict testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC'
whismanoid 52:607010f0c54e 448 #warning "No command case for 'EOC' 'PinName' 'EOC' due to conflict with reserved commands A-F, try changing pin name"
whismanoid 66:3fe92f6f1cfa 449 #warning "Randomly assigned command 'J' for 'EOC' due to name conflict"
whismanoid 52:607010f0c54e 450 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['PinName'] = 'SHDN'
whismanoid 52:607010f0c54e 451 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Direction'] = 'output'
whismanoid 52:607010f0c54e 452 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 453 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['FunctionName'] = 'SHDNoutputValue'
whismanoid 52:607010f0c54e 454
whismanoid 52:607010f0c54e 455 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['PinName'] = 'UP_slash_DWNb'
whismanoid 52:607010f0c54e 456 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Direction'] = 'output'
whismanoid 52:607010f0c54e 457 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 458 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['FunctionName'] = 'UP_slash_DWNboutputValue'
whismanoid 52:607010f0c54e 459
whismanoid 66:3fe92f6f1cfa 460 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'H' 'CONVRUN'
whismanoid 52:607010f0c54e 461 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN'
whismanoid 52:607010f0c54e 462 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Direction'] = 'output'
whismanoid 52:607010f0c54e 463 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 464 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['FunctionName'] = 'CONVRUNoutputValue'
whismanoid 66:3fe92f6f1cfa 465 cmdLine.serial().printf("\r\n H -- CONVRUN output HH high HL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict
whismanoid 66:3fe92f6f1cfa 466 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'I' 'DACSTEP'
whismanoid 52:607010f0c54e 467 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP'
whismanoid 52:607010f0c54e 468 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Direction'] = 'output'
whismanoid 52:607010f0c54e 469 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 470 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['FunctionName'] = 'DACSTEPoutputValue'
whismanoid 66:3fe92f6f1cfa 471 cmdLine.serial().printf("\r\n I -- DACSTEP output IH high IL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict
whismanoid 66:3fe92f6f1cfa 472 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'J' 'EOC'
whismanoid 52:607010f0c54e 473 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC'
whismanoid 52:607010f0c54e 474 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Direction'] = 'input'
whismanoid 52:607010f0c54e 475 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 476 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['FunctionName'] = 'EOCinputValue'
whismanoid 66:3fe92f6f1cfa 477 cmdLine.serial().printf("\r\n J -- EOC input value"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict
whismanoid 52:607010f0c54e 478 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'S' 'SHDN'
whismanoid 52:607010f0c54e 479 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['PinName'] = 'SHDN'
whismanoid 52:607010f0c54e 480 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Direction'] = 'output'
whismanoid 52:607010f0c54e 481 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 482 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['FunctionName'] = 'SHDNoutputValue'
whismanoid 52:607010f0c54e 483 cmdLine.serial().printf("\r\n S -- SHDN output SH high SL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict
whismanoid 52:607010f0c54e 484 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'U' 'UP_slash_DWNb'
whismanoid 52:607010f0c54e 485 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['PinName'] = 'UP_slash_DWNb'
whismanoid 52:607010f0c54e 486 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Direction'] = 'output'
whismanoid 52:607010f0c54e 487 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 488 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['FunctionName'] = 'UP_slash_DWNboutputValue'
whismanoid 52:607010f0c54e 489 cmdLine.serial().printf("\r\n U -- UP_slash_DWNb output UH high UL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict
whismanoid 52:607010f0c54e 490
whismanoid 84:11cc360628a1 491 #if Has_Read4Command_Command
whismanoid 83:29bb86cc45bc 492 // Read 4 command -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.
whismanoid 83:29bb86cc45bc 493 cmdLine.serial().printf("\r\n ^ -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.");
whismanoid 84:11cc360628a1 494 #endif // Has_Read4Command_Command
whismanoid 83:29bb86cc45bc 495
whismanoid 52:607010f0c54e 496 //
whismanoid 83:29bb86cc45bc 497 return true; // why is MAXxxxxx_menu_help() function bool not void?
whismanoid 52:607010f0c54e 498 }
whismanoid 52:607010f0c54e 499
whismanoid 52:607010f0c54e 500 bool MAX11043_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 52:607010f0c54e 501 {
whismanoid 52:607010f0c54e 502
whismanoid 52:607010f0c54e 503 // CODE GENERATOR: testMenuGlobalArgsDict Consolidate common/global argument parsing
whismanoid 52:607010f0c54e 504
whismanoid 59:47538bcf6cda 505 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['alias'] = 'None'
whismanoid 59:47538bcf6cda 506 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 507 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 508 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 509 // parse argument uint32_t ADCa
whismanoid 59:47538bcf6cda 510 uint32_t ADCa = 0; // ~~~ g_MAX11043_device.__WARNING_no_match_for_argname_ADCa_in_MAX11043_device_t__; // default to global property value
whismanoid 59:47538bcf6cda 511 if (cmdLine.parse_uint32_dec("ADCa", ADCa))
whismanoid 52:607010f0c54e 512 {
whismanoid 59:47538bcf6cda 513 // g_MAX11043_device.__WARNING_no_match_for_argname_ADCa_in_MAX11043_device_t__ = ADCa; // update global property value
whismanoid 59:47538bcf6cda 514 }
whismanoid 59:47538bcf6cda 515
whismanoid 59:47538bcf6cda 516 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['alias'] = 'None'
whismanoid 59:47538bcf6cda 517 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 518 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 519 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 520 // parse argument uint32_t ADCb
whismanoid 59:47538bcf6cda 521 uint32_t ADCb = 0; // ~~~ g_MAX11043_device.__WARNING_no_match_for_argname_ADCb_in_MAX11043_device_t__; // default to global property value
whismanoid 59:47538bcf6cda 522 if (cmdLine.parse_uint32_dec("ADCb", ADCb))
whismanoid 59:47538bcf6cda 523 {
whismanoid 59:47538bcf6cda 524 // g_MAX11043_device.__WARNING_no_match_for_argname_ADCb_in_MAX11043_device_t__ = ADCb; // update global property value
whismanoid 52:607010f0c54e 525 }
whismanoid 52:607010f0c54e 526
whismanoid 59:47538bcf6cda 527 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['alias'] = 'None'
whismanoid 59:47538bcf6cda 528 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 529 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 530 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 531 // parse argument uint32_t ADCc
whismanoid 59:47538bcf6cda 532 uint32_t ADCc = 0; // ~~~ g_MAX11043_device.__WARNING_no_match_for_argname_ADCc_in_MAX11043_device_t__; // default to global property value
whismanoid 59:47538bcf6cda 533 if (cmdLine.parse_uint32_dec("ADCc", ADCc))
whismanoid 52:607010f0c54e 534 {
whismanoid 59:47538bcf6cda 535 // g_MAX11043_device.__WARNING_no_match_for_argname_ADCc_in_MAX11043_device_t__ = ADCc; // update global property value
whismanoid 52:607010f0c54e 536 }
whismanoid 52:607010f0c54e 537
whismanoid 59:47538bcf6cda 538 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['alias'] = 'None'
whismanoid 59:47538bcf6cda 539 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 540 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 541 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 542 // parse argument uint32_t ADCd
whismanoid 59:47538bcf6cda 543 uint32_t ADCd = 0; // ~~~ g_MAX11043_device.__WARNING_no_match_for_argname_ADCd_in_MAX11043_device_t__; // default to global property value
whismanoid 59:47538bcf6cda 544 if (cmdLine.parse_uint32_dec("ADCd", ADCd))
whismanoid 52:607010f0c54e 545 {
whismanoid 59:47538bcf6cda 546 // g_MAX11043_device.__WARNING_no_match_for_argname_ADCd_in_MAX11043_device_t__ = ADCd; // update global property value
whismanoid 52:607010f0c54e 547 }
whismanoid 52:607010f0c54e 548
whismanoid 59:47538bcf6cda 549 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['alias'] = 'None'
whismanoid 59:47538bcf6cda 550 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['argtype'] = 'double'
whismanoid 59:47538bcf6cda 551 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 552 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 553 // parse argument double VRef
whismanoid 59:47538bcf6cda 554 double VRef = g_MAX11043_device.VRef; // default to global property value
whismanoid 59:47538bcf6cda 555 if (cmdLine.parse_double("VRef", VRef))
whismanoid 52:607010f0c54e 556 {
whismanoid 59:47538bcf6cda 557 g_MAX11043_device.VRef = VRef; // update global property value
whismanoid 59:47538bcf6cda 558 }
whismanoid 59:47538bcf6cda 559
whismanoid 59:47538bcf6cda 560 // CODE GENERATOR: testMenuGlobalArgsDict['config']['alias'] = 'None'
whismanoid 59:47538bcf6cda 561 // CODE GENERATOR: testMenuGlobalArgsDict['config']['argtype'] = 'uint16_t'
whismanoid 59:47538bcf6cda 562 // CODE GENERATOR: testMenuGlobalArgsDict['config']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 563 // CODE GENERATOR: testMenuGlobalArgsDict['config']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 564 // parse argument uint16_t config
whismanoid 59:47538bcf6cda 565 uint16_t config = g_MAX11043_device.config; // default to global property value
whismanoid 59:47538bcf6cda 566 if (cmdLine.parse_uint16_dec("config", config))
whismanoid 59:47538bcf6cda 567 {
whismanoid 59:47538bcf6cda 568 g_MAX11043_device.config = config; // update global property value
whismanoid 52:607010f0c54e 569 }
whismanoid 52:607010f0c54e 570
whismanoid 52:607010f0c54e 571 // CODE GENERATOR: testMenuGlobalArgsDict['status']['alias'] = 'None'
whismanoid 52:607010f0c54e 572 // CODE GENERATOR: testMenuGlobalArgsDict['status']['argtype'] = 'uint32_t'
whismanoid 52:607010f0c54e 573 // CODE GENERATOR: testMenuGlobalArgsDict['status']['usedByCommandName'] = 'None'
whismanoid 52:607010f0c54e 574 // CODE GENERATOR: testMenuGlobalArgsDict['status']['usedBytestMenuItemName'] = 'None'
whismanoid 52:607010f0c54e 575 // parse argument uint32_t status
whismanoid 52:607010f0c54e 576 uint32_t status = g_MAX11043_device.status; // default to global property value
whismanoid 52:607010f0c54e 577 if (cmdLine.parse_uint32_dec("status", status))
whismanoid 52:607010f0c54e 578 {
whismanoid 52:607010f0c54e 579 g_MAX11043_device.status = status; // update global property value
whismanoid 52:607010f0c54e 580 }
whismanoid 52:607010f0c54e 581
whismanoid 52:607010f0c54e 582 switch (cmdLine[0])
whismanoid 52:607010f0c54e 583 {
whismanoid 84:11cc360628a1 584 #if Has_Read4Command_Command
whismanoid 83:29bb86cc45bc 585 // Read 4 command -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.
whismanoid 83:29bb86cc45bc 586 case '^':
whismanoid 83:29bb86cc45bc 587 {
whismanoid 83:29bb86cc45bc 588 // cmdLine.serial().printf("\r\n ^ -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.");
whismanoid 84:11cc360628a1 589 #if Use_Read4Command_Thread
whismanoid 85:a47ed024c508 590 Callback<void(size_t, uint8_t*, uint8_t*)> saved_onSPIprint_handler = g_MAX11043_device.onSPIprint;
whismanoid 85:a47ed024c508 591 g_MAX11043_device.onSPIprint = NULL; // temporarily suppress SPI diagnostic messages
whismanoid 84:11cc360628a1 592 //~ int convrun_pulse_width_us = 30;
whismanoid 84:11cc360628a1 593 //~ int convrun_stop_us = 10;
whismanoid 85:a47ed024c508 594 cmdLine.serial().printf(" Testing CONVRUN pulsed H then L, EOC ignored.\r\n");
whismanoid 85:a47ed024c508 595 cmdLine.serial().printf(" press D to display min/max limits (based on data seen)\r\n");
whismanoid 85:a47ed024c508 596 cmdLine.serial().printf(" press R to reset min/max limits (force scope trigger)\r\n");
whismanoid 85:a47ed024c508 597 cmdLine.serial().printf(" press X to stop...\r\n");
whismanoid 84:11cc360628a1 598 //~ cmdLine.serial().printf(" Testing, press RESET to stop...\r\n");
whismanoid 84:11cc360628a1 599 //~ int serial_is_blocking = cmdLine.serial().is_blocking();
whismanoid 84:11cc360628a1 600 //~ cmdLine.serial().set_blocking(0);
whismanoid 84:11cc360628a1 601 //
whismanoid 84:11cc360628a1 602 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 84:11cc360628a1 603 digitalInOut5.output(); // ScopeTrigger
whismanoid 84:11cc360628a1 604 digitalInOut5.write(1); // ScopeTrigger
whismanoid 84:11cc360628a1 605 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 84:11cc360628a1 606 //
whismanoid 85:a47ed024c508 607 // reset min/max limits
whismanoid 86:c116654dfa32 608 adca_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
whismanoid 86:c116654dfa32 609 adca_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
whismanoid 86:c116654dfa32 610 adcb_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
whismanoid 86:c116654dfa32 611 adcb_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
whismanoid 85:a47ed024c508 612 //
whismanoid 85:a47ed024c508 613 // init thread
whismanoid 84:11cc360628a1 614 Read4Command_Thread.start(Read4Command_Thread_handler);
whismanoid 84:11cc360628a1 615 // TODO: is there any harm in multiple start?
whismanoid 84:11cc360628a1 616 //
whismanoid 84:11cc360628a1 617 // Start the test
whismanoid 84:11cc360628a1 618 Read4Command_Thread_event_flags.set(MYTIMEREVENTFLAG_ENABLE_SPI);
whismanoid 84:11cc360628a1 619 // Work will be done inside Read4Command_Thread_handler
whismanoid 84:11cc360628a1 620 while (1)
whismanoid 84:11cc360628a1 621 {
whismanoid 84:11cc360628a1 622 char ch = cmdLine.serial().getc(); // blocking read
whismanoid 84:11cc360628a1 623 if (ch == '\r') { cmdLine.serial().printf(" (ignored \\r) "); continue; }
whismanoid 84:11cc360628a1 624 if (ch == '\n') { cmdLine.serial().printf(" (ignored \\n) "); continue; }
whismanoid 85:a47ed024c508 625 if (ch == '?') {
whismanoid 85:a47ed024c508 626 cmdLine.serial().printf(" Testing CONVRUN pulsed H then L, EOC ignored.\r\n");
whismanoid 85:a47ed024c508 627 cmdLine.serial().printf(" press D to display min/max limits (based on data seen)\r\n");
whismanoid 85:a47ed024c508 628 cmdLine.serial().printf(" press R to reset min/max limits (force scope trigger)\r\n");
whismanoid 85:a47ed024c508 629 cmdLine.serial().printf(" press X to stop...\r\n");
whismanoid 85:a47ed024c508 630 continue;
whismanoid 85:a47ed024c508 631 }
whismanoid 85:a47ed024c508 632 if (ch == 'R' || ch == 'r') {
whismanoid 85:a47ed024c508 633 // reset min/max limits
whismanoid 86:c116654dfa32 634 adca_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
whismanoid 86:c116654dfa32 635 adca_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
whismanoid 86:c116654dfa32 636 adcb_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
whismanoid 86:c116654dfa32 637 adcb_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
whismanoid 87:4bc981dfd54b 638 adcc_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
whismanoid 87:4bc981dfd54b 639 adcc_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
whismanoid 87:4bc981dfd54b 640 adcd_MIN_SEEN = adcX_MIN_SEEN_INIT_INT16_MAX;
whismanoid 87:4bc981dfd54b 641 adcd_MAX_SEEN = adcX_MAX_SEEN_INIT_INT16_MIN;
whismanoid 87:4bc981dfd54b 642 }
whismanoid 87:4bc981dfd54b 643 if (ch == 'D' || ch == 'd' || ch == 'R' || ch == 'r') {
whismanoid 87:4bc981dfd54b 644 // display min/max limits
whismanoid 87:4bc981dfd54b 645 cmdLine.serial().printf(" %s\tNEW 0x%4.4x %+d \tMIN 0x%4.4x %+d \tMAX 0x%4.4x %+d \r\n",
whismanoid 87:4bc981dfd54b 646 "adca",
whismanoid 87:4bc981dfd54b 647 (adca_newest & 0xFFFF),
whismanoid 87:4bc981dfd54b 648 (adca_newest ),
whismanoid 87:4bc981dfd54b 649 (adca_MIN_SEEN & 0xFFFF),
whismanoid 87:4bc981dfd54b 650 (adca_MIN_SEEN ),
whismanoid 87:4bc981dfd54b 651 (adca_MAX_SEEN & 0xFFFF),
whismanoid 87:4bc981dfd54b 652 (adca_MAX_SEEN )
whismanoid 87:4bc981dfd54b 653 );
whismanoid 87:4bc981dfd54b 654 cmdLine.serial().printf(" %s\tNEW 0x%4.4x %+d \tMIN 0x%4.4x %+d \tMAX 0x%4.4x %+d \r\n",
whismanoid 87:4bc981dfd54b 655 "adcb",
whismanoid 87:4bc981dfd54b 656 (adcb_newest & 0xFFFF),
whismanoid 87:4bc981dfd54b 657 (adcb_newest ),
whismanoid 87:4bc981dfd54b 658 (adcb_MIN_SEEN & 0xFFFF),
whismanoid 87:4bc981dfd54b 659 (adcb_MIN_SEEN ),
whismanoid 87:4bc981dfd54b 660 (adcb_MAX_SEEN & 0xFFFF),
whismanoid 87:4bc981dfd54b 661 (adcb_MAX_SEEN )
whismanoid 87:4bc981dfd54b 662 );
whismanoid 87:4bc981dfd54b 663 cmdLine.serial().printf(" %s\tNEW 0x%4.4x %+d \tMIN 0x%4.4x %+d \tMAX 0x%4.4x %+d \r\n",
whismanoid 87:4bc981dfd54b 664 "adcc",
whismanoid 87:4bc981dfd54b 665 (adcc_newest & 0xFFFF),
whismanoid 87:4bc981dfd54b 666 (adcc_newest ),
whismanoid 87:4bc981dfd54b 667 (adcc_MIN_SEEN & 0xFFFF),
whismanoid 87:4bc981dfd54b 668 (adcc_MIN_SEEN ),
whismanoid 87:4bc981dfd54b 669 (adcc_MAX_SEEN & 0xFFFF),
whismanoid 87:4bc981dfd54b 670 (adcc_MAX_SEEN )
whismanoid 87:4bc981dfd54b 671 );
whismanoid 87:4bc981dfd54b 672 cmdLine.serial().printf(" %s\tNEW 0x%4.4x %+d \tMIN 0x%4.4x %+d \tMAX 0x%4.4x %+d \r\n",
whismanoid 87:4bc981dfd54b 673 "adcd",
whismanoid 87:4bc981dfd54b 674 (adcd_newest & 0xFFFF),
whismanoid 87:4bc981dfd54b 675 (adcd_newest ),
whismanoid 87:4bc981dfd54b 676 (adcd_MIN_SEEN & 0xFFFF),
whismanoid 87:4bc981dfd54b 677 (adcd_MIN_SEEN ),
whismanoid 87:4bc981dfd54b 678 (adcd_MAX_SEEN & 0xFFFF),
whismanoid 87:4bc981dfd54b 679 (adcd_MAX_SEEN )
whismanoid 87:4bc981dfd54b 680 );
whismanoid 87:4bc981dfd54b 681 }
whismanoid 87:4bc981dfd54b 682 if (ch == 'D' || ch == 'd' || ch == 'R' || ch == 'r') {
whismanoid 85:a47ed024c508 683 continue;
whismanoid 85:a47ed024c508 684 }
whismanoid 85:a47ed024c508 685 if (ch == 'X' || ch == 'x' || ch == '\x03') {
whismanoid 85:a47ed024c508 686 break;
whismanoid 85:a47ed024c508 687 }
whismanoid 84:11cc360628a1 688 cmdLine.serial().printf(" (ignored \\x%2.2x) ", (int)ch);
whismanoid 84:11cc360628a1 689 }
whismanoid 84:11cc360628a1 690 // Stop the test
whismanoid 84:11cc360628a1 691 Read4Command_Thread_event_flags.clear(MYTIMEREVENTFLAG_ENABLE_SPI);
whismanoid 84:11cc360628a1 692 //~ cmdLine.serial().set_blocking(serial_is_blocking);
whismanoid 84:11cc360628a1 693 cmdLine.serial().printf(" Stopped.\r\n");
whismanoid 85:a47ed024c508 694 cmdLine.serial().printf(" adca_MIN_SEEN 0x%4.4x %d\r\n",
whismanoid 85:a47ed024c508 695 (adca_MIN_SEEN & 0xFFFF), (adca_MIN_SEEN & 0xFFFF));
whismanoid 85:a47ed024c508 696 cmdLine.serial().printf(" adca_MAX_SEEN 0x%4.4x %d\r\n",
whismanoid 85:a47ed024c508 697 (adca_MAX_SEEN & 0xFFFF), (adca_MAX_SEEN & 0xFFFF));
whismanoid 85:a47ed024c508 698 cmdLine.serial().printf(" adcb_MIN_SEEN 0x%4.4x %d\r\n",
whismanoid 85:a47ed024c508 699 (adcb_MIN_SEEN & 0xFFFF), (adcb_MIN_SEEN & 0xFFFF));
whismanoid 85:a47ed024c508 700 cmdLine.serial().printf(" adcb_MAX_SEEN 0x%4.4x %d\r\n",
whismanoid 85:a47ed024c508 701 (adcb_MAX_SEEN & 0xFFFF), (adcb_MAX_SEEN & 0xFFFF));
whismanoid 85:a47ed024c508 702 g_MAX11043_device.onSPIprint = saved_onSPIprint_handler;
whismanoid 84:11cc360628a1 703 #else // Use_Read4Command_Thread
whismanoid 83:29bb86cc45bc 704 int convrun_pulse_width_us = 30;
whismanoid 83:29bb86cc45bc 705 int convrun_stop_us = 10;
whismanoid 83:29bb86cc45bc 706 //~ cmdLine.serial().printf(" Testing, press X to stop...\r\n");
whismanoid 83:29bb86cc45bc 707 cmdLine.serial().printf(" Testing, press RESET to stop...\r\n");
whismanoid 83:29bb86cc45bc 708 //~ int serial_is_blocking = cmdLine.serial().is_blocking();
whismanoid 83:29bb86cc45bc 709 //~ cmdLine.serial().set_blocking(0);
whismanoid 83:29bb86cc45bc 710 while (1)
whismanoid 83:29bb86cc45bc 711 {
whismanoid 83:29bb86cc45bc 712 // TODO: CONVRUN = H -- perform ADC conversions (EOC will pulse, and data registers will update)
whismanoid 83:29bb86cc45bc 713 g_MAX11043_device.CONVRUNoutputValue(1);
whismanoid 83:29bb86cc45bc 714 //
whismanoid 83:29bb86cc45bc 715 // TODO: delay at least 9us to ensure at least one converion happens
whismanoid 83:29bb86cc45bc 716 wait_us(convrun_pulse_width_us);
whismanoid 83:29bb86cc45bc 717 //
whismanoid 83:29bb86cc45bc 718 // TODO: CONVRUN = L -- stop ADC conversions
whismanoid 83:29bb86cc45bc 719 g_MAX11043_device.CONVRUNoutputValue(0);
whismanoid 83:29bb86cc45bc 720 //
whismanoid 83:29bb86cc45bc 721 // TODO: delay at least 9us to ensure final converion complete
whismanoid 83:29bb86cc45bc 722 wait_us(convrun_stop_us);
whismanoid 83:29bb86cc45bc 723 //
whismanoid 83:29bb86cc45bc 724 // TODO: run SPI to capture 4 channels
whismanoid 83:29bb86cc45bc 725 // TODO: get rid of the other interrupt/thread, only to read here
whismanoid 83:29bb86cc45bc 726 g_MAX11043_device.Read_ADCabcd();
whismanoid 83:29bb86cc45bc 727 // post: g_MAX11043_device.adca was updated
whismanoid 83:29bb86cc45bc 728 // post: g_MAX11043_device.adcb was updated
whismanoid 83:29bb86cc45bc 729 // post: g_MAX11043_device.adcc was updated
whismanoid 83:29bb86cc45bc 730 // post: g_MAX11043_device.adcd was updated
whismanoid 83:29bb86cc45bc 731 //
whismanoid 83:29bb86cc45bc 732 // TODO: compare with thresholds, report if exceeded
whismanoid 83:29bb86cc45bc 733 //
whismanoid 83:29bb86cc45bc 734 // TODO: break on keypress
whismanoid 83:29bb86cc45bc 735 // TODO: this isn't working, serial().getc() is blocking and .readable() always returns 1 so we stall in getc().
whismanoid 83:29bb86cc45bc 736 unsigned int num_read_available = cmdLine.serial().readable();
whismanoid 83:29bb86cc45bc 737 if (num_read_available > 1) // should test >0; but always returns 1?
whismanoid 83:29bb86cc45bc 738 {
whismanoid 83:29bb86cc45bc 739 cmdLine.serial().printf(" (num_read_available %u) ", num_read_available);
whismanoid 83:29bb86cc45bc 740 char ch = cmdLine.serial().getc(); // blocking read
whismanoid 83:29bb86cc45bc 741 if (ch == '\r') { cmdLine.serial().printf(" (ignored \\r) "); continue; }
whismanoid 83:29bb86cc45bc 742 if (ch == '\n') { cmdLine.serial().printf(" (ignored \\n) "); continue; }
whismanoid 83:29bb86cc45bc 743 if (ch == '\x03') break; // CTRL+C break
whismanoid 83:29bb86cc45bc 744 if (ch == 'x') break;
whismanoid 83:29bb86cc45bc 745 if (ch == 'X') break;
whismanoid 83:29bb86cc45bc 746 cmdLine.serial().printf(" (ignored \\x%2.2x) ", (int)ch);
whismanoid 83:29bb86cc45bc 747 }
whismanoid 83:29bb86cc45bc 748 }
whismanoid 83:29bb86cc45bc 749 //~ cmdLine.serial().set_blocking(serial_is_blocking);
whismanoid 83:29bb86cc45bc 750 cmdLine.serial().printf(" Stopped.\r\n");
whismanoid 84:11cc360628a1 751 #endif // Use_Read4Command_Thread
whismanoid 83:29bb86cc45bc 752 return true; // command handled by MAX11043
whismanoid 83:29bb86cc45bc 753 }
whismanoid 83:29bb86cc45bc 754 break;
whismanoid 84:11cc360628a1 755 #endif // Has_Read4Command_Command
whismanoid 52:607010f0c54e 756 // CODE GENERATOR: generate * command read/write reg *reg? *reg=value
whismanoid 52:607010f0c54e 757 case '*':
whismanoid 52:607010f0c54e 758 {
whismanoid 52:607010f0c54e 759 // if buffer starts with a regName:
whismanoid 52:607010f0c54e 760 // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))):
whismanoid 52:607010f0c54e 761 cmdLine.serial().printf(" scan RegName...\r\n");
whismanoid 52:607010f0c54e 762 for (uint8_t regAddress = 0; regAddress < 0x80; regAddress++)
whismanoid 52:607010f0c54e 763 {
whismanoid 52:607010f0c54e 764 uint32_t regData = 0;
whismanoid 52:607010f0c54e 765 bool is_regname_query = false;
whismanoid 52:607010f0c54e 766 bool is_regname_assignment = false;
whismanoid 52:607010f0c54e 767 if (cmdLine.parse_uint32_dec(g_MAX11043_device.RegName((MAX11043::MAX11043_CMD_enum_t)regAddress), regData))
whismanoid 52:607010f0c54e 768 {
whismanoid 52:607010f0c54e 769 cmdLine.serial().printf(" regAddress=0x%2.2X\r\n", (regAddress & 0xFF));
whismanoid 52:607010f0c54e 770 cmdLine.serial().printf(" RegName=%s\r\n", g_MAX11043_device.RegName((MAX11043::MAX11043_CMD_enum_t)regAddress));
whismanoid 52:607010f0c54e 771 // accept regName "?" as "RegRead" by name
whismanoid 52:607010f0c54e 772 is_regname_query = (cmdLine.chSeparator == '?');
whismanoid 52:607010f0c54e 773 is_regname_assignment = (cmdLine.chSeparator == '=');
whismanoid 52:607010f0c54e 774 if (is_regname_query)
whismanoid 52:607010f0c54e 775 {
whismanoid 52:607010f0c54e 776 cmdLine.serial().printf(" RegRead");
whismanoid 52:607010f0c54e 777 g_MAX11043_device.RegRead((MAX11043::MAX11043_CMD_enum_t)regAddress, &regData);
whismanoid 52:607010f0c54e 778 cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF));
whismanoid 52:607010f0c54e 779 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 780 }
whismanoid 52:607010f0c54e 781 // accept regName "=0x123456" as "RegWrite" by name
whismanoid 52:607010f0c54e 782 if (is_regname_assignment)
whismanoid 52:607010f0c54e 783 {
whismanoid 52:607010f0c54e 784 cmdLine.serial().printf(" RegWrite");
whismanoid 52:607010f0c54e 785 cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF));
whismanoid 52:607010f0c54e 786 g_MAX11043_device.RegWrite((MAX11043::MAX11043_CMD_enum_t)regAddress, regData);
whismanoid 52:607010f0c54e 787 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 788 }
whismanoid 52:607010f0c54e 789 }
whismanoid 52:607010f0c54e 790 } // end for regAddr
whismanoid 52:607010f0c54e 791 // not a valid register name
whismanoid 57:1c9da8e90737 792 Callback<void(size_t, uint8_t*, uint8_t*)> saved_onSPIprint_handler = g_MAX11043_device.onSPIprint;
whismanoid 57:1c9da8e90737 793 g_MAX11043_device.onSPIprint = NULL; // temporarily suppress SPI diagnostic messages
whismanoid 52:607010f0c54e 794 // read "all" registers by name
whismanoid 57:1c9da8e90737 795 // TODO: KLUDGE: this constant array should live in the device driver, not the menu
whismanoid 57:1c9da8e90737 796 const MAX11043::MAX11043_CMD_enum_t readAllStatusList[] = {
whismanoid 59:47538bcf6cda 797 MAX11043::CMD_0000_0010_d16o8_Rd00_ADCa,
whismanoid 59:47538bcf6cda 798 MAX11043::CMD_0000_0110_d16o8_Rd01_ADCb,
whismanoid 59:47538bcf6cda 799 MAX11043::CMD_0000_1010_d16o8_Rd02_ADCc,
whismanoid 59:47538bcf6cda 800 MAX11043::CMD_0000_1110_d16o8_Rd03_ADCd,
whismanoid 57:1c9da8e90737 801 MAX11043::CMD_0001_1110_d8_Rd07_Status,
whismanoid 57:1c9da8e90737 802 MAX11043::CMD_0010_0010_d16_Rd08_Configuration,
whismanoid 57:1c9da8e90737 803 MAX11043::CMD_0010_0110_d16_Rd09_DAC,
whismanoid 57:1c9da8e90737 804 MAX11043::CMD_0010_1010_d16_Rd0A_DACStep,
whismanoid 57:1c9da8e90737 805 MAX11043::CMD_0010_1110_d16_Rd0B_DACHDACL,
whismanoid 57:1c9da8e90737 806 MAX11043::CMD_0011_0010_d16_Rd0C_ConfigA,
whismanoid 57:1c9da8e90737 807 MAX11043::CMD_0011_0110_d16_Rd0D_ConfigB,
whismanoid 57:1c9da8e90737 808 MAX11043::CMD_0011_1010_d16_Rd0E_ConfigC,
whismanoid 57:1c9da8e90737 809 MAX11043::CMD_0011_1110_d16_Rd0F_ConfigD,
whismanoid 57:1c9da8e90737 810 MAX11043::CMD_0100_0010_d16_Rd10_Reference,
whismanoid 57:1c9da8e90737 811 MAX11043::CMD_0100_0110_d16_Rd11_AGain,
whismanoid 57:1c9da8e90737 812 MAX11043::CMD_0100_1010_d16_Rd12_BGain,
whismanoid 57:1c9da8e90737 813 MAX11043::CMD_0100_1110_d16_Rd13_CGain,
whismanoid 57:1c9da8e90737 814 MAX11043::CMD_0101_0010_d16_Rd14_DGain,
whismanoid 57:1c9da8e90737 815 };
whismanoid 57:1c9da8e90737 816 for (uint8_t readAllStatusIndex = 0; readAllStatusIndex < (sizeof(readAllStatusList)/sizeof(MAX11043::MAX11043_CMD_enum_t)); readAllStatusIndex++)
whismanoid 52:607010f0c54e 817 {
whismanoid 57:1c9da8e90737 818 MAX11043::MAX11043_CMD_enum_t regAddress = readAllStatusList[readAllStatusIndex];
whismanoid 52:607010f0c54e 819 uint32_t regData = 0;
whismanoid 57:1c9da8e90737 820 if (g_MAX11043_device.RegSize(regAddress) == 0) continue; // skip undefined regs
whismanoid 57:1c9da8e90737 821 if (g_MAX11043_device.RegRead(regAddress, &regData) == 0) continue; // skip unreadable regs
whismanoid 57:1c9da8e90737 822 cmdLine.serial().printf("%s=0x%6.6x\r\n", g_MAX11043_device.RegName(regAddress), regData);
whismanoid 52:607010f0c54e 823 } // end for regAddr
whismanoid 52:607010f0c54e 824 g_MAX11043_device.onSPIprint = saved_onSPIprint_handler;
whismanoid 52:607010f0c54e 825 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 826 }
whismanoid 52:607010f0c54e 827 break;
whismanoid 52:607010f0c54e 828
whismanoid 52:607010f0c54e 829 // CODE GENERATOR: generate @ command print global property values of g_MAX11043_device
whismanoid 52:607010f0c54e 830 case '@':
whismanoid 52:607010f0c54e 831 {
whismanoid 59:47538bcf6cda 832 // CODE GENERATOR: @ command print double g_MAX11043_device.VRef
whismanoid 59:47538bcf6cda 833 cmdLine.serial().printf("VRef = ");
whismanoid 59:47538bcf6cda 834 cmdLine.serial().printf("%f\r\n", g_MAX11043_device.VRef);
whismanoid 59:47538bcf6cda 835 // CODE GENERATOR: @ command print uint16_t g_MAX11043_device.config
whismanoid 59:47538bcf6cda 836 cmdLine.serial().printf("config = ");
whismanoid 59:47538bcf6cda 837 cmdLine.serial().printf("%d = 0x%4.4x\r\n", g_MAX11043_device.config, g_MAX11043_device.config);
whismanoid 52:607010f0c54e 838 // CODE GENERATOR: @ command print uint32_t g_MAX11043_device.status
whismanoid 52:607010f0c54e 839 cmdLine.serial().printf("status = ");
whismanoid 52:607010f0c54e 840 cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.status, g_MAX11043_device.status);
whismanoid 59:47538bcf6cda 841 // CODE GENERATOR: @ command print uint32_t g_MAX11043_device.adca
whismanoid 59:47538bcf6cda 842 cmdLine.serial().printf("adca = ");
whismanoid 59:47538bcf6cda 843 cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.adca, g_MAX11043_device.adca);
whismanoid 59:47538bcf6cda 844 // CODE GENERATOR: @ command print uint32_t g_MAX11043_device.adcb
whismanoid 59:47538bcf6cda 845 cmdLine.serial().printf("adcb = ");
whismanoid 59:47538bcf6cda 846 cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.adcb, g_MAX11043_device.adcb);
whismanoid 59:47538bcf6cda 847 // CODE GENERATOR: @ command print uint32_t g_MAX11043_device.adcc
whismanoid 59:47538bcf6cda 848 cmdLine.serial().printf("adcc = ");
whismanoid 59:47538bcf6cda 849 cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.adcc, g_MAX11043_device.adcc);
whismanoid 59:47538bcf6cda 850 // CODE GENERATOR: @ command print uint32_t g_MAX11043_device.adcd
whismanoid 59:47538bcf6cda 851 cmdLine.serial().printf("adcd = ");
whismanoid 59:47538bcf6cda 852 cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.adcd, g_MAX11043_device.adcd);
whismanoid 52:607010f0c54e 853 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 854 break;
whismanoid 52:607010f0c54e 855 }
whismanoid 52:607010f0c54e 856 // CODE GENERATOR: TODO1: generate GPIO commands for LDAC, CLR, etc. based on device driver function names
whismanoid 52:607010f0c54e 857 // case 'G'..'Z','g'..'z' are reserved for GPIO commands
whismanoid 52:607010f0c54e 858 // case 'A'..'F','a'..'f' may be available if not claimed by bitstream commands
whismanoid 66:3fe92f6f1cfa 859 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'H' 'CONVRUN'
whismanoid 52:607010f0c54e 860 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN'
whismanoid 52:607010f0c54e 861 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Direction'] = 'output'
whismanoid 52:607010f0c54e 862 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 863 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['FunctionName'] = 'CONVRUNoutputValue'
whismanoid 66:3fe92f6f1cfa 864 case 'H':
whismanoid 52:607010f0c54e 865 {
whismanoid 52:607010f0c54e 866 switch (cmdLine[1])
whismanoid 52:607010f0c54e 867 {
whismanoid 52:607010f0c54e 868 case 'H':
whismanoid 52:607010f0c54e 869 {
whismanoid 52:607010f0c54e 870 g_MAX11043_device.CONVRUNoutputValue(1);
whismanoid 52:607010f0c54e 871 break;
whismanoid 52:607010f0c54e 872 }
whismanoid 52:607010f0c54e 873 case 'L':
whismanoid 52:607010f0c54e 874 {
whismanoid 52:607010f0c54e 875 g_MAX11043_device.CONVRUNoutputValue(0);
whismanoid 52:607010f0c54e 876 break;
whismanoid 52:607010f0c54e 877 }
whismanoid 52:607010f0c54e 878 }
whismanoid 52:607010f0c54e 879 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 880 break;
whismanoid 52:607010f0c54e 881 }
whismanoid 52:607010f0c54e 882
whismanoid 66:3fe92f6f1cfa 883 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'I' 'DACSTEP'
whismanoid 52:607010f0c54e 884 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP'
whismanoid 52:607010f0c54e 885 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Direction'] = 'output'
whismanoid 52:607010f0c54e 886 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 887 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['FunctionName'] = 'DACSTEPoutputValue'
whismanoid 66:3fe92f6f1cfa 888 case 'I':
whismanoid 52:607010f0c54e 889 {
whismanoid 52:607010f0c54e 890 switch (cmdLine[1])
whismanoid 52:607010f0c54e 891 {
whismanoid 52:607010f0c54e 892 case 'H':
whismanoid 52:607010f0c54e 893 {
whismanoid 52:607010f0c54e 894 g_MAX11043_device.DACSTEPoutputValue(1);
whismanoid 52:607010f0c54e 895 break;
whismanoid 52:607010f0c54e 896 }
whismanoid 52:607010f0c54e 897 case 'L':
whismanoid 52:607010f0c54e 898 {
whismanoid 52:607010f0c54e 899 g_MAX11043_device.DACSTEPoutputValue(0);
whismanoid 52:607010f0c54e 900 break;
whismanoid 52:607010f0c54e 901 }
whismanoid 52:607010f0c54e 902 }
whismanoid 52:607010f0c54e 903 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 904 break;
whismanoid 52:607010f0c54e 905 }
whismanoid 52:607010f0c54e 906
whismanoid 66:3fe92f6f1cfa 907 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'J' 'EOC'
whismanoid 52:607010f0c54e 908 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC'
whismanoid 52:607010f0c54e 909 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Direction'] = 'input'
whismanoid 52:607010f0c54e 910 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 911 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['FunctionName'] = 'EOCinputValue'
whismanoid 66:3fe92f6f1cfa 912 case 'J':
whismanoid 52:607010f0c54e 913 {
whismanoid 52:607010f0c54e 914 // TODO capture and print input Value
whismanoid 52:607010f0c54e 915 cmdLine.serial().printf("%d", g_MAX11043_device.EOCinputValue());
whismanoid 52:607010f0c54e 916 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 917 break;
whismanoid 52:607010f0c54e 918 }
whismanoid 52:607010f0c54e 919
whismanoid 52:607010f0c54e 920 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'S' 'SHDN'
whismanoid 52:607010f0c54e 921 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['PinName'] = 'SHDN'
whismanoid 52:607010f0c54e 922 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Direction'] = 'output'
whismanoid 52:607010f0c54e 923 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 924 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['FunctionName'] = 'SHDNoutputValue'
whismanoid 52:607010f0c54e 925 case 'S':
whismanoid 52:607010f0c54e 926 {
whismanoid 52:607010f0c54e 927 switch (cmdLine[1])
whismanoid 52:607010f0c54e 928 {
whismanoid 52:607010f0c54e 929 case 'H':
whismanoid 52:607010f0c54e 930 {
whismanoid 52:607010f0c54e 931 g_MAX11043_device.SHDNoutputValue(1);
whismanoid 52:607010f0c54e 932 break;
whismanoid 52:607010f0c54e 933 }
whismanoid 52:607010f0c54e 934 case 'L':
whismanoid 52:607010f0c54e 935 {
whismanoid 52:607010f0c54e 936 g_MAX11043_device.SHDNoutputValue(0);
whismanoid 52:607010f0c54e 937 break;
whismanoid 52:607010f0c54e 938 }
whismanoid 52:607010f0c54e 939 }
whismanoid 52:607010f0c54e 940 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 941 break;
whismanoid 52:607010f0c54e 942 }
whismanoid 52:607010f0c54e 943
whismanoid 52:607010f0c54e 944 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'U' 'UP_slash_DWNb'
whismanoid 52:607010f0c54e 945 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['PinName'] = 'UP_slash_DWNb'
whismanoid 52:607010f0c54e 946 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Direction'] = 'output'
whismanoid 52:607010f0c54e 947 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 948 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['FunctionName'] = 'UP_slash_DWNboutputValue'
whismanoid 52:607010f0c54e 949 case 'U':
whismanoid 52:607010f0c54e 950 {
whismanoid 52:607010f0c54e 951 switch (cmdLine[1])
whismanoid 52:607010f0c54e 952 {
whismanoid 52:607010f0c54e 953 case 'H':
whismanoid 52:607010f0c54e 954 {
whismanoid 52:607010f0c54e 955 g_MAX11043_device.UP_slash_DWNboutputValue(1);
whismanoid 52:607010f0c54e 956 break;
whismanoid 52:607010f0c54e 957 }
whismanoid 52:607010f0c54e 958 case 'L':
whismanoid 52:607010f0c54e 959 {
whismanoid 52:607010f0c54e 960 g_MAX11043_device.UP_slash_DWNboutputValue(0);
whismanoid 52:607010f0c54e 961 break;
whismanoid 52:607010f0c54e 962 }
whismanoid 52:607010f0c54e 963 }
whismanoid 52:607010f0c54e 964 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 965 break;
whismanoid 52:607010f0c54e 966 }
whismanoid 52:607010f0c54e 967
whismanoid 52:607010f0c54e 968
whismanoid 52:607010f0c54e 969 // CODE GENERATOR: test menu
whismanoid 52:607010f0c54e 970 // case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands
whismanoid 52:607010f0c54e 971 // has_register_write_command: case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands
whismanoid 52:607010f0c54e 972 // CODE GENERATOR: top of loop: testMenuCommand="!", testMenuFirstCharHandler="None"
whismanoid 52:607010f0c54e 973 // CODE GENERATOR: test menu case '!':
whismanoid 52:607010f0c54e 974 // CODE GENERATOR: helpString '! -- Init'
whismanoid 52:607010f0c54e 975 // CODE GENERATOR: CMD_ 'None'
whismanoid 52:607010f0c54e 976 // CODE GENERATOR: CommandName 'Init'
whismanoid 52:607010f0c54e 977 // CODE GENERATOR: CommandParamIn 'void'
whismanoid 52:607010f0c54e 978 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 52:607010f0c54e 979 // CODE GENERATOR: CommandPre ''
whismanoid 52:607010f0c54e 980 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 52:607010f0c54e 981 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 52:607010f0c54e 982 // CODE GENERATOR: CommandPost ''
whismanoid 52:607010f0c54e 983 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 52:607010f0c54e 984 // case '!': // (single character) (testMenuFirstCharHandler="None")
whismanoid 52:607010f0c54e 985 case '!':
whismanoid 52:607010f0c54e 986 {
whismanoid 52:607010f0c54e 987 // test menu command '!' handler:
whismanoid 52:607010f0c54e 988 // helpString='! -- Init'
whismanoid 52:607010f0c54e 989 // CMD_='None'
whismanoid 52:607010f0c54e 990 // CommandName='Init'
whismanoid 52:607010f0c54e 991 // CommandParamIn='void'
whismanoid 52:607010f0c54e 992 // CommandReturnType='uint8_t'
whismanoid 52:607010f0c54e 993 // @Pre=''
whismanoid 52:607010f0c54e 994 // @Param[in]=''
whismanoid 52:607010f0c54e 995 // @Param[out]=''
whismanoid 52:607010f0c54e 996 // @Post=''
whismanoid 52:607010f0c54e 997 // displayPost=''
whismanoid 52:607010f0c54e 998 // @Return='@return 1 on success; 0 on failure'
whismanoid 52:607010f0c54e 999 cmdLine.serial().printf("Init");
whismanoid 52:607010f0c54e 1000 // call function Init
whismanoid 52:607010f0c54e 1001 uint8_t result = g_MAX11043_device.Init();
whismanoid 65:2117e32f017d 1002 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 52:607010f0c54e 1003 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 1004 // CODE GENERATOR: bottom of loop: testMenuCommand="!", testMenuFirstCharHandler="None"
whismanoid 52:607010f0c54e 1005 } // end case '!'
whismanoid 52:607010f0c54e 1006 break;
whismanoid 52:607010f0c54e 1007
whismanoid 64:a667cfd83492 1008 // CODE GENERATOR: top of loop: testMenuCommand="$", testMenuFirstCharHandler="None"
whismanoid 64:a667cfd83492 1009 // CODE GENERATOR: test menu case '$':
whismanoid 64:a667cfd83492 1010 // CODE GENERATOR: helpString '$ -- Read_ADCabcd'
whismanoid 64:a667cfd83492 1011 // CODE GENERATOR: CMD_ 'None'
whismanoid 64:a667cfd83492 1012 // CODE GENERATOR: CommandName 'Read_ADCabcd'
whismanoid 64:a667cfd83492 1013 // CODE GENERATOR: CommandParamIn 'void'
whismanoid 64:a667cfd83492 1014 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 64:a667cfd83492 1015 // CODE GENERATOR: CommandPre ''
whismanoid 64:a667cfd83492 1016 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 64:a667cfd83492 1017 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 64:a667cfd83492 1018 // CODE GENERATOR: CommandPost ''
whismanoid 64:a667cfd83492 1019 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 64:a667cfd83492 1020 // case '$': // (single character) (testMenuFirstCharHandler="None")
whismanoid 64:a667cfd83492 1021 case '$':
whismanoid 64:a667cfd83492 1022 {
whismanoid 64:a667cfd83492 1023 // test menu command '$' handler:
whismanoid 64:a667cfd83492 1024 // helpString='$ -- Read_ADCabcd'
whismanoid 64:a667cfd83492 1025 // CMD_='None'
whismanoid 64:a667cfd83492 1026 // CommandName='Read_ADCabcd'
whismanoid 64:a667cfd83492 1027 // CommandParamIn='void'
whismanoid 64:a667cfd83492 1028 // CommandReturnType='uint8_t'
whismanoid 64:a667cfd83492 1029 // @Pre=''
whismanoid 64:a667cfd83492 1030 // @Param[in]=''
whismanoid 64:a667cfd83492 1031 // @Param[out]=''
whismanoid 64:a667cfd83492 1032 // @Post=''
whismanoid 64:a667cfd83492 1033 // displayPost='adca, adcb, adcc, adcd'
whismanoid 64:a667cfd83492 1034 // @Return='@return 1 on success; 0 on failure'
whismanoid 64:a667cfd83492 1035 cmdLine.serial().printf("Read_ADCabcd");
whismanoid 64:a667cfd83492 1036 // call function Read_ADCabcd
whismanoid 64:a667cfd83492 1037 uint8_t result = g_MAX11043_device.Read_ADCabcd();
whismanoid 65:2117e32f017d 1038 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 64:a667cfd83492 1039 // Menu item '$' -> adca, adcb, adcc, adcd
whismanoid 64:a667cfd83492 1040 cmdLine.serial().printf("%s=%d\r\n", "adca", g_MAX11043_device.adca);
whismanoid 64:a667cfd83492 1041 cmdLine.serial().printf("%s=%d\r\n", "adcb", g_MAX11043_device.adcb);
whismanoid 64:a667cfd83492 1042 cmdLine.serial().printf("%s=%d\r\n", "adcc", g_MAX11043_device.adcc);
whismanoid 64:a667cfd83492 1043 cmdLine.serial().printf("%s=%d\r\n", "adcd", g_MAX11043_device.adcd);
whismanoid 64:a667cfd83492 1044 return true; // command handled by MAX11043
whismanoid 64:a667cfd83492 1045 // CODE GENERATOR: bottom of loop: testMenuCommand="$", testMenuFirstCharHandler="None"
whismanoid 64:a667cfd83492 1046 } // end case '$'
whismanoid 64:a667cfd83492 1047 break;
whismanoid 64:a667cfd83492 1048
whismanoid 66:3fe92f6f1cfa 1049 // CODE GENERATOR: top of loop: testMenuCommand="G", testMenuFirstCharHandler="None"
whismanoid 66:3fe92f6f1cfa 1050 // CODE GENERATOR: test menu case 'G':
whismanoid 66:3fe92f6f1cfa 1051 // CODE GENERATOR: helpString 'G gain=? -- Write_AGain'
whismanoid 64:a667cfd83492 1052 // CODE GENERATOR: CMD_ 'None'
whismanoid 64:a667cfd83492 1053 // CODE GENERATOR: CommandName 'Write_AGain'
whismanoid 64:a667cfd83492 1054 // CODE GENERATOR: CommandParamIn 'uint32_t gain'
whismanoid 64:a667cfd83492 1055 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 64:a667cfd83492 1056 // CODE GENERATOR: CommandPre ''
whismanoid 64:a667cfd83492 1057 // CODE GENERATOR: CommandDocParamIn '@param[in] gain 2's complement, 0x800=0.25V/V, 0x1000=0.5V/V, 0x2000=1VV/V, 0x4000=2V/V, default=0x2000'
whismanoid 64:a667cfd83492 1058 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 64:a667cfd83492 1059 // CODE GENERATOR: CommandPost ''
whismanoid 64:a667cfd83492 1060 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 66:3fe92f6f1cfa 1061 // case 'G': // (single character) (testMenuFirstCharHandler="None")
whismanoid 66:3fe92f6f1cfa 1062 case 'G':
whismanoid 64:a667cfd83492 1063 {
whismanoid 66:3fe92f6f1cfa 1064 // test menu command 'G' handler:
whismanoid 66:3fe92f6f1cfa 1065 // helpString='G gain=? -- Write_AGain'
whismanoid 64:a667cfd83492 1066 // CMD_='None'
whismanoid 64:a667cfd83492 1067 // CommandName='Write_AGain'
whismanoid 64:a667cfd83492 1068 // CommandParamIn='uint32_t gain'
whismanoid 64:a667cfd83492 1069 // CommandReturnType='uint8_t'
whismanoid 64:a667cfd83492 1070 // @Pre=''
whismanoid 64:a667cfd83492 1071 // @Param[in]='@param[in] gain 2's complement, 0x800=0.25V/V, 0x1000=0.5V/V, 0x2000=1VV/V, 0x4000=2V/V, default=0x2000'
whismanoid 64:a667cfd83492 1072 // @Param[out]=''
whismanoid 64:a667cfd83492 1073 // @Post=''
whismanoid 64:a667cfd83492 1074 // displayPost=''
whismanoid 64:a667cfd83492 1075 // @Return='@return 1 on success; 0 on failure'
whismanoid 64:a667cfd83492 1076 // parse argument list
whismanoid 64:a667cfd83492 1077 // 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=1VV/V, 0x4000=2V/V, default=0x2000'
whismanoid 64:a667cfd83492 1078 // parse argument uint32_t gain
whismanoid 64:a667cfd83492 1079 uint32_t gain = (uint32_t)0x2000; // --- g_MAX11043_device.__WARNING_no_match_for_argname_gain_in_MAX11043_device_t__; // default to global property value
whismanoid 64:a667cfd83492 1080 if (cmdLine.parse_uint32_dec("gain", gain))
whismanoid 64:a667cfd83492 1081 {
whismanoid 64:a667cfd83492 1082 // g_MAX11043_device.__WARNING_no_match_for_argname_gain_in_MAX11043_device_t__ = gain; // update global property value
whismanoid 64:a667cfd83492 1083 }
whismanoid 64:a667cfd83492 1084 // print arguments
whismanoid 64:a667cfd83492 1085 cmdLine.serial().printf("Write_AGain");
whismanoid 64:a667cfd83492 1086 cmdLine.serial().printf(" gain=%d", gain);
whismanoid 64:a667cfd83492 1087 cmdLine.serial().printf("\r\n");
whismanoid 64:a667cfd83492 1088 // call function Write_AGain(gain)
whismanoid 64:a667cfd83492 1089 uint8_t result = g_MAX11043_device.Write_AGain(gain);
whismanoid 64:a667cfd83492 1090 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 64:a667cfd83492 1091 return true; // command handled by MAX11043
whismanoid 66:3fe92f6f1cfa 1092 // CODE GENERATOR: bottom of loop: testMenuCommand="G", testMenuFirstCharHandler="None"
whismanoid 66:3fe92f6f1cfa 1093 } // end case 'G'
whismanoid 64:a667cfd83492 1094 break;
whismanoid 64:a667cfd83492 1095
whismanoid 59:47538bcf6cda 1096 // CODE GENERATOR: top of loop: testMenuCommand="XX", testMenuFirstCharHandler="None"
whismanoid 59:47538bcf6cda 1097 // CODE GENERATOR: test menu case 'XX':
whismanoid 59:47538bcf6cda 1098 // CODE GENERATOR: helpString 'XX linef=? rate=? -- Configure_XXXXX'
whismanoid 59:47538bcf6cda 1099 // CODE GENERATOR: CMD_ 'None'
whismanoid 59:47538bcf6cda 1100 // CODE GENERATOR: CommandName 'Configure_XXXXX'
whismanoid 59:47538bcf6cda 1101 // CODE GENERATOR: CommandParamIn 'uint8_t linef, uint8_t rate'
whismanoid 59:47538bcf6cda 1102 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 59:47538bcf6cda 1103 // CODE GENERATOR: CommandPre ''
whismanoid 59:47538bcf6cda 1104 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 59:47538bcf6cda 1105 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 59:47538bcf6cda 1106 // CODE GENERATOR: CommandPost ''
whismanoid 59:47538bcf6cda 1107 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 59:47538bcf6cda 1108 case 'X': // (multiple characters) (testMenuFirstCharHandler="X"):
whismanoid 59:47538bcf6cda 1109 {
whismanoid 59:47538bcf6cda 1110 switch (cmdLine[1])
whismanoid 59:47538bcf6cda 1111 {
whismanoid 59:47538bcf6cda 1112 case 'X': // (nested inside case 'X')
whismanoid 59:47538bcf6cda 1113 {
whismanoid 59:47538bcf6cda 1114 // test menu command 'XX' handler:
whismanoid 59:47538bcf6cda 1115 // helpString='XX linef=? rate=? -- Configure_XXXXX'
whismanoid 59:47538bcf6cda 1116 // CMD_='None'
whismanoid 59:47538bcf6cda 1117 // CommandName='Configure_XXXXX'
whismanoid 59:47538bcf6cda 1118 // CommandParamIn='uint8_t linef, uint8_t rate'
whismanoid 59:47538bcf6cda 1119 // CommandReturnType='uint8_t'
whismanoid 59:47538bcf6cda 1120 // @Pre=''
whismanoid 59:47538bcf6cda 1121 // @Param[in]=''
whismanoid 59:47538bcf6cda 1122 // @Param[out]=''
whismanoid 59:47538bcf6cda 1123 // @Post=''
whismanoid 59:47538bcf6cda 1124 // displayPost=''
whismanoid 59:47538bcf6cda 1125 // @Return='@return 1 on success; 0 on failure'
whismanoid 59:47538bcf6cda 1126 // parse argument list
whismanoid 59:47538bcf6cda 1127 // parse argument uint8_t linef
whismanoid 59:47538bcf6cda 1128 uint8_t linef = 0; // --- g_MAX11043_device.__WARNING_no_match_for_argname_linef_in_MAX11043_device_t__; // default to global property value
whismanoid 59:47538bcf6cda 1129 if (cmdLine.parse_uint8_dec("linef", linef))
whismanoid 59:47538bcf6cda 1130 {
whismanoid 59:47538bcf6cda 1131 // g_MAX11043_device.__WARNING_no_match_for_argname_linef_in_MAX11043_device_t__ = linef; // update global property value
whismanoid 59:47538bcf6cda 1132 }
whismanoid 59:47538bcf6cda 1133 // parse argument uint8_t rate
whismanoid 59:47538bcf6cda 1134 uint8_t rate = 0; // --- g_MAX11043_device.__WARNING_no_match_for_argname_rate_in_MAX11043_device_t__; // default to global property value
whismanoid 59:47538bcf6cda 1135 if (cmdLine.parse_uint8_dec("rate", rate))
whismanoid 59:47538bcf6cda 1136 {
whismanoid 59:47538bcf6cda 1137 // g_MAX11043_device.__WARNING_no_match_for_argname_rate_in_MAX11043_device_t__ = rate; // update global property value
whismanoid 59:47538bcf6cda 1138 }
whismanoid 59:47538bcf6cda 1139 // print arguments
whismanoid 59:47538bcf6cda 1140 cmdLine.serial().printf("Configure_XXXXX");
whismanoid 59:47538bcf6cda 1141 cmdLine.serial().printf(" linef=%d", linef);
whismanoid 59:47538bcf6cda 1142 cmdLine.serial().printf(" rate=%d", rate);
whismanoid 59:47538bcf6cda 1143 cmdLine.serial().printf("\r\n");
whismanoid 59:47538bcf6cda 1144 // call function Configure_XXXXX(linef, rate)
whismanoid 59:47538bcf6cda 1145 uint8_t result = g_MAX11043_device.Configure_XXXXX(linef, rate);
whismanoid 59:47538bcf6cda 1146 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 59:47538bcf6cda 1147 return true; // command handled by MAX11043
whismanoid 59:47538bcf6cda 1148 // CODE GENERATOR: bottom of loop: testMenuCommand="XX", testMenuFirstCharHandler="X"
whismanoid 59:47538bcf6cda 1149 } // end nested case 'XX'
whismanoid 59:47538bcf6cda 1150 break;
whismanoid 59:47538bcf6cda 1151
whismanoid 59:47538bcf6cda 1152 // CODE GENERATOR: top of loop: testMenuCommand="XY", testMenuFirstCharHandler="X"
whismanoid 59:47538bcf6cda 1153 // CODE GENERATOR: top of loop: nested switch "X" is currently open
whismanoid 59:47538bcf6cda 1154 // CODE GENERATOR: test menu case 'XY':
whismanoid 59:47538bcf6cda 1155 // CODE GENERATOR: helpString 'XY linef=? rate=? -- Configure_XXXXY'
whismanoid 59:47538bcf6cda 1156 // CODE GENERATOR: CMD_ 'None'
whismanoid 59:47538bcf6cda 1157 // CODE GENERATOR: CommandName 'Configure_XXXXY'
whismanoid 59:47538bcf6cda 1158 // CODE GENERATOR: CommandParamIn 'uint8_t linef, uint8_t rate'
whismanoid 59:47538bcf6cda 1159 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 59:47538bcf6cda 1160 // CODE GENERATOR: CommandPre ''
whismanoid 59:47538bcf6cda 1161 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 59:47538bcf6cda 1162 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 59:47538bcf6cda 1163 // CODE GENERATOR: CommandPost ''
whismanoid 59:47538bcf6cda 1164 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 59:47538bcf6cda 1165 case 'Y': // (nested inside case 'X')
whismanoid 59:47538bcf6cda 1166 {
whismanoid 59:47538bcf6cda 1167 // test menu command 'XY' handler:
whismanoid 59:47538bcf6cda 1168 // helpString='XY linef=? rate=? -- Configure_XXXXY'
whismanoid 59:47538bcf6cda 1169 // CMD_='None'
whismanoid 59:47538bcf6cda 1170 // CommandName='Configure_XXXXY'
whismanoid 59:47538bcf6cda 1171 // CommandParamIn='uint8_t linef, uint8_t rate'
whismanoid 59:47538bcf6cda 1172 // CommandReturnType='uint8_t'
whismanoid 59:47538bcf6cda 1173 // @Pre=''
whismanoid 59:47538bcf6cda 1174 // @Param[in]=''
whismanoid 59:47538bcf6cda 1175 // @Param[out]=''
whismanoid 59:47538bcf6cda 1176 // @Post=''
whismanoid 59:47538bcf6cda 1177 // displayPost=''
whismanoid 59:47538bcf6cda 1178 // @Return='@return 1 on success; 0 on failure'
whismanoid 59:47538bcf6cda 1179 // parse argument list
whismanoid 59:47538bcf6cda 1180 // parse argument uint8_t linef
whismanoid 59:47538bcf6cda 1181 uint8_t linef = 0; // --- g_MAX11043_device.__WARNING_no_match_for_argname_linef_in_MAX11043_device_t__; // default to global property value
whismanoid 59:47538bcf6cda 1182 if (cmdLine.parse_uint8_dec("linef", linef))
whismanoid 59:47538bcf6cda 1183 {
whismanoid 59:47538bcf6cda 1184 // g_MAX11043_device.__WARNING_no_match_for_argname_linef_in_MAX11043_device_t__ = linef; // update global property value
whismanoid 59:47538bcf6cda 1185 }
whismanoid 59:47538bcf6cda 1186 // parse argument uint8_t rate
whismanoid 59:47538bcf6cda 1187 uint8_t rate = 0; // --- g_MAX11043_device.__WARNING_no_match_for_argname_rate_in_MAX11043_device_t__; // default to global property value
whismanoid 59:47538bcf6cda 1188 if (cmdLine.parse_uint8_dec("rate", rate))
whismanoid 59:47538bcf6cda 1189 {
whismanoid 59:47538bcf6cda 1190 // g_MAX11043_device.__WARNING_no_match_for_argname_rate_in_MAX11043_device_t__ = rate; // update global property value
whismanoid 59:47538bcf6cda 1191 }
whismanoid 59:47538bcf6cda 1192 // print arguments
whismanoid 59:47538bcf6cda 1193 cmdLine.serial().printf("Configure_XXXXY");
whismanoid 59:47538bcf6cda 1194 cmdLine.serial().printf(" linef=%d", linef);
whismanoid 59:47538bcf6cda 1195 cmdLine.serial().printf(" rate=%d", rate);
whismanoid 59:47538bcf6cda 1196 cmdLine.serial().printf("\r\n");
whismanoid 59:47538bcf6cda 1197 // call function Configure_XXXXY(linef, rate)
whismanoid 59:47538bcf6cda 1198 uint8_t result = g_MAX11043_device.Configure_XXXXY(linef, rate);
whismanoid 59:47538bcf6cda 1199 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 59:47538bcf6cda 1200 return true; // command handled by MAX11043
whismanoid 59:47538bcf6cda 1201 // CODE GENERATOR: bottom of loop: testMenuCommand="XY", testMenuFirstCharHandler="X"
whismanoid 59:47538bcf6cda 1202 } // end nested case 'XY'
whismanoid 59:47538bcf6cda 1203 break;
whismanoid 59:47538bcf6cda 1204
whismanoid 59:47538bcf6cda 1205 } // end nested switch (cmdLine[1]) inside case 'X'
whismanoid 59:47538bcf6cda 1206 break;
whismanoid 59:47538bcf6cda 1207 } // end case 'X'
whismanoid 52:607010f0c54e 1208 // has_register_write_command: case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands
whismanoid 52:607010f0c54e 1209 case '0': case '1': case '2': case '3': case '4':
whismanoid 52:607010f0c54e 1210 case '5': case '6': case '7': case '8': case '9':
whismanoid 52:607010f0c54e 1211 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
whismanoid 52:607010f0c54e 1212 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
whismanoid 52:607010f0c54e 1213 {
whismanoid 52:607010f0c54e 1214 // hexadecimal codes get parsed as bytecodes
whismanoid 52:607010f0c54e 1215 //
whismanoid 52:607010f0c54e 1216 // parse_byteCount_byteList_dec() assumes all keyword args have already been removed from the buffer
whismanoid 52:607010f0c54e 1217 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 52:607010f0c54e 1218 #define MAX_SPI_BYTE_COUNT 32
whismanoid 52:607010f0c54e 1219 size_t byteCount = byteCount;
whismanoid 52:607010f0c54e 1220 static char mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 52:607010f0c54e 1221 static char misoData[MAX_SPI_BYTE_COUNT];
whismanoid 52:607010f0c54e 1222 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 52:607010f0c54e 1223 MAX_SPI_BYTE_COUNT))
whismanoid 52:607010f0c54e 1224 {
whismanoid 57:1c9da8e90737 1225 // TODO: decode operation from commandByte
whismanoid 57:1c9da8e90737 1226 // TODO: OVERSIMPLIFICATION: if length is 1 byte then operation is RegRead, otherwise RegWrite
whismanoid 52:607010f0c54e 1227 // register_read_function 'IsRegReadCommand'
whismanoid 52:607010f0c54e 1228 // register_write_function 'RegWrite'
whismanoid 52:607010f0c54e 1229 // register_name_function 'RegName'
whismanoid 52:607010f0c54e 1230 // register_size_function 'RegSize'
whismanoid 57:1c9da8e90737 1231 // CODE GENERATOR: does the chip have a defined CMDOP_1aaa_aaaa_ReadRegister bit?
whismanoid 57:1c9da8e90737 1232 // MAX11043::MAX11043_CMD_enum_t regAddress = (MAX11043::MAX11043_CMD_enum_t)((mosiData[0] &~ MAX11043::CMDOP_1aaa_aaaa_ReadRegister) & 0xFF);
whismanoid 52:607010f0c54e 1233 MAX11043::MAX11043_CMD_enum_t commandByte = (MAX11043::MAX11043_CMD_enum_t)(mosiData[0]);
whismanoid 57:1c9da8e90737 1234 MAX11043::MAX11043_CMDOP_enum_t commandOp = g_MAX11043_device.DecodeCommand(commandByte);
whismanoid 52:607010f0c54e 1235 int regAddress = g_MAX11043_device.RegAddrOfCommand(commandByte);
whismanoid 52:607010f0c54e 1236 cmdLine.serial().printf(" regAddress=0x%2.2x\r\n", (regAddress & 0xFF));
whismanoid 52:607010f0c54e 1237 cmdLine.serial().printf(" RegName=%s\r\n", g_MAX11043_device.RegName(commandByte));
whismanoid 52:607010f0c54e 1238 uint32_t regData = 0;
whismanoid 52:607010f0c54e 1239 int regSize = g_MAX11043_device.RegSize(commandByte);
whismanoid 52:607010f0c54e 1240 cmdLine.serial().printf(" RegSize=%d\r\n", regSize);
whismanoid 52:607010f0c54e 1241 switch(regSize)
whismanoid 52:607010f0c54e 1242 {
whismanoid 52:607010f0c54e 1243 case 8:
whismanoid 52:607010f0c54e 1244 regData = ((uint32_t)mosiData[1] & 0xFF);
whismanoid 52:607010f0c54e 1245 break;
whismanoid 52:607010f0c54e 1246 case 16:
whismanoid 52:607010f0c54e 1247 regData = (((uint32_t)mosiData[1] & 0xFF) << 8) + ((uint32_t)mosiData[2] & 0xFF);
whismanoid 52:607010f0c54e 1248 break;
whismanoid 52:607010f0c54e 1249 case 24:
whismanoid 52:607010f0c54e 1250 regData = (((uint32_t)mosiData[1] & 0xFF) << 16) + (((uint32_t)mosiData[2] & 0xFF) << 8) + ((uint32_t)mosiData[3] & 0xFF);
whismanoid 52:607010f0c54e 1251 break;
whismanoid 52:607010f0c54e 1252 }
whismanoid 57:1c9da8e90737 1253 // CODE GENERATOR: does the chip have a defined CMDOP_1aaa_aaaa_ReadRegister bit?
whismanoid 57:1c9da8e90737 1254 // if ((byteCount == 1) || (regAddress & MAX11043::CMDOP_1aaa_aaaa_ReadRegister))
whismanoid 52:607010f0c54e 1255 if ((byteCount == 1) || g_MAX11043_device.IsRegReadCommand(commandByte))
whismanoid 52:607010f0c54e 1256 {
whismanoid 52:607010f0c54e 1257 cmdLine.serial().printf(" RegRead");
whismanoid 52:607010f0c54e 1258 g_MAX11043_device.RegRead(commandByte, &regData);
whismanoid 52:607010f0c54e 1259 cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF));
whismanoid 52:607010f0c54e 1260 }
whismanoid 52:607010f0c54e 1261 else
whismanoid 52:607010f0c54e 1262 {
whismanoid 52:607010f0c54e 1263 cmdLine.serial().printf(" RegWrite regData=0x%6.6X\r\n", (regData & 0x00FFFFFF));
whismanoid 52:607010f0c54e 1264 g_MAX11043_device.RegWrite(commandByte, regData);
whismanoid 52:607010f0c54e 1265 }
whismanoid 52:607010f0c54e 1266 // is there support function shadow regValue of regAddr?
whismanoid 52:607010f0c54e 1267 }
whismanoid 52:607010f0c54e 1268 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 1269 //
whismanoid 52:607010f0c54e 1270 } // end case '0'..'9','A'..'F','a'..'f'
whismanoid 52:607010f0c54e 1271 break;
whismanoid 52:607010f0c54e 1272 } // end switch (cmdLine[0])
whismanoid 52:607010f0c54e 1273 return false; // command not handled by MAX11043
whismanoid 52:607010f0c54e 1274 } // end bool MAX11043_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 52:607010f0c54e 1275
whismanoid 52:607010f0c54e 1276 // CODE GENERATOR: class declaration statement close