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 01:20:26 2020 +0000
Revision:
84:11cc360628a1
Parent:
83:29bb86cc45bc
Child:
85:a47ed024c508
Threaded Read 4 command -- CONVRUN pulsed HL, ignore EOC. WIP: thresholds.

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 84:11cc360628a1 112 #endif // Use_Read4Command_Thread
whismanoid 84:11cc360628a1 113 #if Use_Read4Command_Thread
whismanoid 84:11cc360628a1 114 void Read4Command_Thread_handler()
whismanoid 84:11cc360628a1 115 {
whismanoid 84:11cc360628a1 116 const int convrun_pulse_width_us = 30;
whismanoid 84:11cc360628a1 117 const int convrun_stop_us = 10;
whismanoid 84:11cc360628a1 118 // running in thread context in Thread Read4Command_Thread
whismanoid 84:11cc360628a1 119 // operate the SPI interface at specified sample rate
whismanoid 84:11cc360628a1 120 // shared read only: periodicInterruptTimer_interval_usec
whismanoid 84:11cc360628a1 121 while (true) {
whismanoid 84:11cc360628a1 122 //signal_wait(int32_t signals, uint32_t millisec=osWaitForever)
whismanoid 84:11cc360628a1 123 //flags_read = Read4Command_Thread_event_flags.wait_any(MYTIMEREVENTFLAG_ENABLE_SPI);
whismanoid 84:11cc360628a1 124 Read4Command_Thread_event_flags.wait_any(MYTIMEREVENTFLAG_ENABLE_SPI, osWaitForever, false); // clear=false: don't auto clear the flag
whismanoid 84:11cc360628a1 125 //
whismanoid 84:11cc360628a1 126 // TODO: CONVRUN = H -- perform ADC conversions (EOC will pulse, and data registers will update)
whismanoid 84:11cc360628a1 127 g_MAX11043_device.CONVRUNoutputValue(1);
whismanoid 84:11cc360628a1 128 //
whismanoid 84:11cc360628a1 129 // TODO: delay at least 9us to ensure at least one converion happens
whismanoid 84:11cc360628a1 130 wait_us(convrun_pulse_width_us);
whismanoid 84:11cc360628a1 131 //
whismanoid 84:11cc360628a1 132 // TODO: CONVRUN = L -- stop ADC conversions
whismanoid 84:11cc360628a1 133 g_MAX11043_device.CONVRUNoutputValue(0);
whismanoid 84:11cc360628a1 134 //
whismanoid 84:11cc360628a1 135 // TODO: delay at least 9us to ensure final converion complete
whismanoid 84:11cc360628a1 136 wait_us(convrun_stop_us);
whismanoid 84:11cc360628a1 137 //
whismanoid 84:11cc360628a1 138 // TODO: run SPI to capture 4 channels
whismanoid 84:11cc360628a1 139 // TODO: get rid of the other interrupt/thread, only to read here
whismanoid 84:11cc360628a1 140 g_MAX11043_device.Read_ADCabcd();
whismanoid 84:11cc360628a1 141 // post: g_MAX11043_device.adca was updated
whismanoid 84:11cc360628a1 142 // post: g_MAX11043_device.adcb was updated
whismanoid 84:11cc360628a1 143 // post: g_MAX11043_device.adcc was updated
whismanoid 84:11cc360628a1 144 // post: g_MAX11043_device.adcd was updated
whismanoid 84:11cc360628a1 145 //
whismanoid 84:11cc360628a1 146 // TODO: compare with thresholds, report if exceeded
whismanoid 84:11cc360628a1 147 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 84:11cc360628a1 148 // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected
whismanoid 84:11cc360628a1 149 digitalInOut5.write(0); // ScopeTrigger
whismanoid 84:11cc360628a1 150 digitalInOut5.write(1); // ScopeTrigger
whismanoid 84:11cc360628a1 151 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 84:11cc360628a1 152 //
whismanoid 84:11cc360628a1 153 // blocking delay time us_timestamp_t periodicInterruptTimer_interval_usec
whismanoid 84:11cc360628a1 154 //~ const us_timestamp_t overhead_usec = 24;
whismanoid 84:11cc360628a1 155 //~ if (periodicInterruptTimer_interval_usec > overhead_usec) {
whismanoid 84:11cc360628a1 156 //~ wait_us(periodicInterruptTimer_interval_usec - overhead_usec);
whismanoid 84:11cc360628a1 157 //~ }
whismanoid 84:11cc360628a1 158 }
whismanoid 84:11cc360628a1 159 }
whismanoid 84:11cc360628a1 160 #endif // Use_Read4Command_Thread
whismanoid 84:11cc360628a1 161 #if Use_Read4Command_Thread
whismanoid 84:11cc360628a1 162 //~ Read4Command_Thread_event_flags.set(MYTIMEREVENTFLAG_ENABLE_SPI);
whismanoid 84:11cc360628a1 163 #endif // Use_Read4Command_Thread
whismanoid 84:11cc360628a1 164 #if Use_Read4Command_Thread
whismanoid 84:11cc360628a1 165 //~ Read4Command_Thread_event_flags.clear(MYTIMEREVENTFLAG_ENABLE_SPI);
whismanoid 84:11cc360628a1 166 #endif // Use_Read4Command_Thread
whismanoid 84:11cc360628a1 167 #if Use_Read4Command_Thread
whismanoid 84:11cc360628a1 168 // init
whismanoid 84:11cc360628a1 169 //~ Read4Command_Thread.start(Read4Command_Thread_handler);
whismanoid 84:11cc360628a1 170 #endif // Use_Read4Command_Thread
whismanoid 84:11cc360628a1 171
whismanoid 52:607010f0c54e 172 // CODE GENERATOR: build testMenuCommand list
whismanoid 52:607010f0c54e 173 // CODE GENERATOR: build testMenuGlobalArgsDict common/global argument list
whismanoid 52:607010f0c54e 174 // CODE GENERATOR: class member function declarations
whismanoid 52:607010f0c54e 175 // CODE GENERATOR: MAX11043 Command Name = Init (void) --> uint8_t
whismanoid 52:607010f0c54e 176 // CODE GENERATOR: Menu item hint description Menu item '!'
whismanoid 52:607010f0c54e 177 // CODE GENERATOR: Menu item '!' -- Menu item !
whismanoid 52:607010f0c54e 178 // CODE GENERATOR: test menu case '!':
whismanoid 52:607010f0c54e 179 // CODE GENERATOR: helpString '! -- Init'
whismanoid 52:607010f0c54e 180 // CODE GENERATOR: CMD_ 'None'
whismanoid 52:607010f0c54e 181 // CODE GENERATOR: CommandName 'Init'
whismanoid 52:607010f0c54e 182 // CODE GENERATOR: CommandParamIn 'void'
whismanoid 52:607010f0c54e 183 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 52:607010f0c54e 184 // CODE GENERATOR: CommandPre ''
whismanoid 52:607010f0c54e 185 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 52:607010f0c54e 186 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 52:607010f0c54e 187 // CODE GENERATOR: CommandPost ''
whismanoid 52:607010f0c54e 188 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 52:607010f0c54e 189 // CODE GENERATOR: MAX11043 Command Name = RegWrite (MAX11043_CMD_enum_t commandByte, uint32_t regData) --> uint8_t
whismanoid 52:607010f0c54e 190 // CODE GENERATOR: no Menu item hint in description
whismanoid 52:607010f0c54e 191 // CODE GENERATOR: MAX11043 Command Name = RegRead (MAX11043_CMD_enum_t commandByte, uint32_t* ptrRegData) --> uint8_t
whismanoid 52:607010f0c54e 192 // CODE GENERATOR: no Menu item hint in description
whismanoid 52:607010f0c54e 193 // CODE GENERATOR: MAX11043 Command Name = RegSize (MAX11043_CMD_enum_t commandByte) --> uint8_t
whismanoid 52:607010f0c54e 194 // CODE GENERATOR: no Menu item hint in description
whismanoid 57:1c9da8e90737 195 // CODE GENERATOR: MAX11043 Command Name = DecodeCommand (MAX11043_CMD_enum_t commandByte) --> MAX11043::MAX11043_CMDOP_enum_t
whismanoid 57:1c9da8e90737 196 // CODE GENERATOR: no Menu item hint in description
whismanoid 52:607010f0c54e 197 // CODE GENERATOR: MAX11043 Command Name = RegAddrOfCommand (MAX11043_CMD_enum_t commandByte) --> uint8_t
whismanoid 52:607010f0c54e 198 // CODE GENERATOR: no Menu item hint in description
whismanoid 52:607010f0c54e 199 // CODE GENERATOR: MAX11043 Command Name = IsRegReadCommand (MAX11043_CMD_enum_t commandByte) --> uint8_t
whismanoid 52:607010f0c54e 200 // CODE GENERATOR: no Menu item hint in description
whismanoid 52:607010f0c54e 201 // CODE GENERATOR: MAX11043 Command Name = RegName (MAX11043_CMD_enum_t commandByte) --> const char*
whismanoid 52:607010f0c54e 202 // CODE GENERATOR: no Menu item hint in description
whismanoid 64:a667cfd83492 203 // CODE GENERATOR: MAX11043 Command Name = Read_ADCabcd (void) --> uint8_t
whismanoid 64:a667cfd83492 204 // CODE GENERATOR: Menu item hint description Menu item '$' -> adca, adcb, adcc, adcd
whismanoid 64:a667cfd83492 205 // CODE GENERATOR: Menu item '$' -> adca, adcb, adcc, adcd -- Menu item $
whismanoid 64:a667cfd83492 206 // CODE GENERATOR: test menu case '$':
whismanoid 64:a667cfd83492 207 // CODE GENERATOR: helpString '$ -- Read_ADCabcd'
whismanoid 64:a667cfd83492 208 // CODE GENERATOR: CMD_ 'None'
whismanoid 64:a667cfd83492 209 // CODE GENERATOR: CommandName 'Read_ADCabcd'
whismanoid 64:a667cfd83492 210 // CODE GENERATOR: CommandParamIn 'void'
whismanoid 64:a667cfd83492 211 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 64:a667cfd83492 212 // CODE GENERATOR: CommandPre ''
whismanoid 64:a667cfd83492 213 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 64:a667cfd83492 214 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 64:a667cfd83492 215 // CODE GENERATOR: CommandPost ''
whismanoid 64:a667cfd83492 216 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 64:a667cfd83492 217 // CODE GENERATOR: MAX11043 Command Name = Write_AGain (uint32_t gain) --> uint8_t
whismanoid 66:3fe92f6f1cfa 218 // CODE GENERATOR: Menu item hint description Menu item 'GA'
whismanoid 66:3fe92f6f1cfa 219 // CODE GENERATOR: Menu item 'GA' -- Menu item GA
whismanoid 66:3fe92f6f1cfa 220 // CODE GENERATOR: MAX11043 help: GA uint32_t gain -- Write_AGain
whismanoid 66:3fe92f6f1cfa 221 // CODE GENERATOR: MAX11043 helpString: 'GA gain=? -- Write_AGain'
whismanoid 66:3fe92f6f1cfa 222 // CODE GENERATOR: test menu case 'GA':
whismanoid 66:3fe92f6f1cfa 223 // CODE GENERATOR: helpString 'GA gain=? -- Write_AGain'
whismanoid 64:a667cfd83492 224 // CODE GENERATOR: CMD_ 'None'
whismanoid 64:a667cfd83492 225 // CODE GENERATOR: CommandName 'Write_AGain'
whismanoid 64:a667cfd83492 226 // CODE GENERATOR: CommandParamIn 'uint32_t gain'
whismanoid 64:a667cfd83492 227 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 64:a667cfd83492 228 // CODE GENERATOR: CommandPre ''
whismanoid 64:a667cfd83492 229 // 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 230 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 64:a667cfd83492 231 // CODE GENERATOR: CommandPost ''
whismanoid 64:a667cfd83492 232 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 59:47538bcf6cda 233 // CODE GENERATOR: MAX11043 Command Name = Configure_XXXXX (uint8_t linef, uint8_t rate) --> uint8_t
whismanoid 59:47538bcf6cda 234 // CODE GENERATOR: Menu item hint description Menu item 'XX'
whismanoid 59:47538bcf6cda 235 // CODE GENERATOR: Menu item 'XX' -- Menu item XX
whismanoid 59:47538bcf6cda 236 // CODE GENERATOR: MAX11043 help: XX uint8_t linef, uint8_t rate -- Configure_XXXXX
whismanoid 59:47538bcf6cda 237 // CODE GENERATOR: MAX11043 helpString: 'XX linef=? rate=? -- Configure_XXXXX'
whismanoid 59:47538bcf6cda 238 // CODE GENERATOR: test menu case 'XX':
whismanoid 59:47538bcf6cda 239 // CODE GENERATOR: helpString 'XX linef=? rate=? -- Configure_XXXXX'
whismanoid 59:47538bcf6cda 240 // CODE GENERATOR: CMD_ 'None'
whismanoid 59:47538bcf6cda 241 // CODE GENERATOR: CommandName 'Configure_XXXXX'
whismanoid 59:47538bcf6cda 242 // CODE GENERATOR: CommandParamIn 'uint8_t linef, uint8_t rate'
whismanoid 59:47538bcf6cda 243 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 59:47538bcf6cda 244 // CODE GENERATOR: CommandPre ''
whismanoid 59:47538bcf6cda 245 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 59:47538bcf6cda 246 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 59:47538bcf6cda 247 // CODE GENERATOR: CommandPost ''
whismanoid 59:47538bcf6cda 248 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 59:47538bcf6cda 249 // CODE GENERATOR: MAX11043 Command Name = Configure_XXXXY (uint8_t linef, uint8_t rate) --> uint8_t
whismanoid 59:47538bcf6cda 250 // CODE GENERATOR: Menu item hint description Menu item 'XY'
whismanoid 59:47538bcf6cda 251 // CODE GENERATOR: Menu item 'XY' -- Menu item XY
whismanoid 59:47538bcf6cda 252 // CODE GENERATOR: MAX11043 help: XY uint8_t linef, uint8_t rate -- Configure_XXXXY
whismanoid 59:47538bcf6cda 253 // CODE GENERATOR: MAX11043 helpString: 'XY linef=? rate=? -- Configure_XXXXY'
whismanoid 59:47538bcf6cda 254 // CODE GENERATOR: test menu case 'XY':
whismanoid 59:47538bcf6cda 255 // CODE GENERATOR: helpString 'XY linef=? rate=? -- Configure_XXXXY'
whismanoid 59:47538bcf6cda 256 // CODE GENERATOR: CMD_ 'None'
whismanoid 59:47538bcf6cda 257 // CODE GENERATOR: CommandName 'Configure_XXXXY'
whismanoid 59:47538bcf6cda 258 // CODE GENERATOR: CommandParamIn 'uint8_t linef, uint8_t rate'
whismanoid 59:47538bcf6cda 259 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 59:47538bcf6cda 260 // CODE GENERATOR: CommandPre ''
whismanoid 59:47538bcf6cda 261 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 59:47538bcf6cda 262 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 59:47538bcf6cda 263 // CODE GENERATOR: CommandPost ''
whismanoid 59:47538bcf6cda 264 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 52:607010f0c54e 265 // CODE GENERATOR: testMenuGlobalArgsDict scan global property list g_MAX11043_device
whismanoid 52:607010f0c54e 266
whismanoid 59:47538bcf6cda 267 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.VRef
whismanoid 59:47538bcf6cda 268 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.VRef argname = VRef
whismanoid 59:47538bcf6cda 269 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['alias'] = 'None'
whismanoid 59:47538bcf6cda 270 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['argtype'] = 'double'
whismanoid 59:47538bcf6cda 271 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 272 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedBytestMenuItemName'] = 'None'
whismanoid 52:607010f0c54e 273
whismanoid 59:47538bcf6cda 274 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.config
whismanoid 59:47538bcf6cda 275 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.config shadow of argname = config
whismanoid 59:47538bcf6cda 276 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.config argname = config
whismanoid 59:47538bcf6cda 277 // CODE GENERATOR: testMenuGlobalArgsDict['config']['alias'] = 'None'
whismanoid 59:47538bcf6cda 278 // CODE GENERATOR: testMenuGlobalArgsDict['config']['argtype'] = 'uint16_t'
whismanoid 59:47538bcf6cda 279 // CODE GENERATOR: testMenuGlobalArgsDict['config']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 280 // CODE GENERATOR: testMenuGlobalArgsDict['config']['usedBytestMenuItemName'] = 'None'
whismanoid 52:607010f0c54e 281
whismanoid 52:607010f0c54e 282 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.status
whismanoid 52:607010f0c54e 283 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.status shadow of argname = status
whismanoid 52:607010f0c54e 284 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.status argname = status
whismanoid 52:607010f0c54e 285 // CODE GENERATOR: testMenuGlobalArgsDict['status']['alias'] = 'None'
whismanoid 52:607010f0c54e 286 // CODE GENERATOR: testMenuGlobalArgsDict['status']['argtype'] = 'uint32_t'
whismanoid 52:607010f0c54e 287 // CODE GENERATOR: testMenuGlobalArgsDict['status']['usedByCommandName'] = 'None'
whismanoid 52:607010f0c54e 288 // CODE GENERATOR: testMenuGlobalArgsDict['status']['usedBytestMenuItemName'] = 'None'
whismanoid 52:607010f0c54e 289
whismanoid 59:47538bcf6cda 290 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adca
whismanoid 59:47538bcf6cda 291 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adca shadow of argname = ADCa
whismanoid 59:47538bcf6cda 292 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adca argname = ADCa
whismanoid 59:47538bcf6cda 293 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['alias'] = 'None'
whismanoid 59:47538bcf6cda 294 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 295 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 296 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 297
whismanoid 59:47538bcf6cda 298 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcb
whismanoid 59:47538bcf6cda 299 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcb shadow of argname = ADCb
whismanoid 59:47538bcf6cda 300 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcb argname = ADCb
whismanoid 59:47538bcf6cda 301 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['alias'] = 'None'
whismanoid 59:47538bcf6cda 302 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 303 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 304 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['usedBytestMenuItemName'] = 'None'
whismanoid 52:607010f0c54e 305
whismanoid 59:47538bcf6cda 306 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcc
whismanoid 59:47538bcf6cda 307 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcc shadow of argname = ADCc
whismanoid 59:47538bcf6cda 308 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcc argname = ADCc
whismanoid 59:47538bcf6cda 309 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['alias'] = 'None'
whismanoid 59:47538bcf6cda 310 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 311 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 312 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 313
whismanoid 59:47538bcf6cda 314 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcd
whismanoid 59:47538bcf6cda 315 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcd shadow of argname = ADCd
whismanoid 59:47538bcf6cda 316 // CODE GENERATOR: testMenuGlobalArgsDict add global property g_MAX11043_device.adcd argname = ADCd
whismanoid 59:47538bcf6cda 317 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['alias'] = 'None'
whismanoid 59:47538bcf6cda 318 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 319 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 320 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 321
whismanoid 52:607010f0c54e 322
whismanoid 52:607010f0c54e 323 // CODE GENERATOR: scan testMenuCommand list for items that can be shortened to single character
whismanoid 59:47538bcf6cda 324 // CODE GENERATOR: multiple commands begin with character 'X'
whismanoid 52:607010f0c54e 325 // CODE GENERATOR: shorten testMenuCommand to single character if unambiguous
whismanoid 52:607010f0c54e 326 // CODE GENERATOR: testMenuCommand '!' already single character
whismanoid 64:a667cfd83492 327 // CODE GENERATOR: testMenuCommand '$' already single character
whismanoid 66:3fe92f6f1cfa 328 // CODE GENERATOR: shorten testMenuCommand 'GA' to single character 'G'
whismanoid 66:3fe92f6f1cfa 329 // CODE GENERATOR: re.sub pattern:'GA' with repl:'G' in helpString 'GA gain=? -- Write_AGain'
whismanoid 66:3fe92f6f1cfa 330 // CODE GENERATOR: updated 'G' help string to 'G gain=? -- Write_AGain'
whismanoid 59:47538bcf6cda 331 // CODE GENERATOR: cannot shorten testMenuCommand 'XX' to single character due to duplicates
whismanoid 59:47538bcf6cda 332 // CODE GENERATOR: cannot shorten testMenuCommand 'XY' to single character due to duplicates
whismanoid 52:607010f0c54e 333
whismanoid 52:607010f0c54e 334 // CODE GENERATOR: help menu
whismanoid 52:607010f0c54e 335 bool MAX11043_menu_help(CmdLine & cmdLine)
whismanoid 52:607010f0c54e 336 {
whismanoid 52:607010f0c54e 337 // CODE GENERATOR: command: !
whismanoid 52:607010f0c54e 338 // CODE GENERATOR: help: ! -- Init
whismanoid 52:607010f0c54e 339 cmdLine.serial().printf("\r\n ! -- Init");
whismanoid 64:a667cfd83492 340 // CODE GENERATOR: command: $
whismanoid 64:a667cfd83492 341 // CODE GENERATOR: help: $ -- Read_ADCabcd
whismanoid 64:a667cfd83492 342 cmdLine.serial().printf("\r\n $ -- Read_ADCabcd");
whismanoid 66:3fe92f6f1cfa 343 // CODE GENERATOR: command: G
whismanoid 66:3fe92f6f1cfa 344 // CODE GENERATOR: help: G gain=? -- Write_AGain
whismanoid 66:3fe92f6f1cfa 345 cmdLine.serial().printf("\r\n G gain=? -- Write_AGain");
whismanoid 59:47538bcf6cda 346 // CODE GENERATOR: command: XX
whismanoid 59:47538bcf6cda 347 // CODE GENERATOR: help: XX linef=? rate=? -- Configure_XXXXX
whismanoid 59:47538bcf6cda 348 cmdLine.serial().printf("\r\n XX linef=? rate=? -- Configure_XXXXX");
whismanoid 59:47538bcf6cda 349 // CODE GENERATOR: command: XY
whismanoid 59:47538bcf6cda 350 // CODE GENERATOR: help: XY linef=? rate=? -- Configure_XXXXY
whismanoid 59:47538bcf6cda 351 cmdLine.serial().printf("\r\n XY linef=? rate=? -- Configure_XXXXY");
whismanoid 52:607010f0c54e 352 //
whismanoid 52:607010f0c54e 353 cmdLine.serial().printf("\r\n @ -- print MAX11043 configuration");
whismanoid 52:607010f0c54e 354
whismanoid 52:607010f0c54e 355 // CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register
whismanoid 52:607010f0c54e 356 cmdLine.serial().printf("\r\n *regname? -- read register\r\n *regname=regvalue -- write register");
whismanoid 52:607010f0c54e 357
whismanoid 52:607010f0c54e 358 //
whismanoid 52:607010f0c54e 359 // CODE GENERATOR: TODO1: generate GPIO commands for LDAC, CLR, etc. based on device driver function names (menu_help)
whismanoid 52:607010f0c54e 360 // case 'G'..'Z','g'..'z' are reserved for GPIO commands
whismanoid 52:607010f0c54e 361 // case 'A'..'F','a'..'f' may be available if not claimed by bitstream commands
whismanoid 52:607010f0c54e 362 // CODE GENERATOR: TODO1: prevent conflict ExternFunctionGPIOPinCommand with reserved case 'A'..'F','a'..'f'
whismanoid 52:607010f0c54e 363 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN'
whismanoid 52:607010f0c54e 364 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Direction'] = 'output'
whismanoid 52:607010f0c54e 365 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 366 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['FunctionName'] = 'CONVRUNoutputValue'
whismanoid 52:607010f0c54e 367
whismanoid 52:607010f0c54e 368 // CODE GENERATOR: warning: conflict testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN'
whismanoid 52:607010f0c54e 369 #warning "No command case for 'CONVRUN' 'PinName' 'CONVRUN' due to conflict with reserved commands A-F, try changing pin name"
whismanoid 66:3fe92f6f1cfa 370 #warning "Randomly assigned command 'H' for 'CONVRUN' due to name conflict"
whismanoid 52:607010f0c54e 371 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP'
whismanoid 52:607010f0c54e 372 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Direction'] = 'output'
whismanoid 52:607010f0c54e 373 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 374 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['FunctionName'] = 'DACSTEPoutputValue'
whismanoid 52:607010f0c54e 375
whismanoid 52:607010f0c54e 376 // CODE GENERATOR: warning: conflict testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP'
whismanoid 52:607010f0c54e 377 #warning "No command case for 'DACSTEP' 'PinName' 'DACSTEP' due to conflict with reserved commands A-F, try changing pin name"
whismanoid 66:3fe92f6f1cfa 378 #warning "Randomly assigned command 'I' for 'DACSTEP' due to name conflict"
whismanoid 52:607010f0c54e 379 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC'
whismanoid 52:607010f0c54e 380 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Direction'] = 'input'
whismanoid 52:607010f0c54e 381 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 382 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['FunctionName'] = 'EOCinputValue'
whismanoid 52:607010f0c54e 383
whismanoid 52:607010f0c54e 384 // CODE GENERATOR: warning: conflict testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC'
whismanoid 52:607010f0c54e 385 #warning "No command case for 'EOC' 'PinName' 'EOC' due to conflict with reserved commands A-F, try changing pin name"
whismanoid 66:3fe92f6f1cfa 386 #warning "Randomly assigned command 'J' for 'EOC' due to name conflict"
whismanoid 52:607010f0c54e 387 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['PinName'] = 'SHDN'
whismanoid 52:607010f0c54e 388 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Direction'] = 'output'
whismanoid 52:607010f0c54e 389 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 390 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['FunctionName'] = 'SHDNoutputValue'
whismanoid 52:607010f0c54e 391
whismanoid 52:607010f0c54e 392 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['PinName'] = 'UP_slash_DWNb'
whismanoid 52:607010f0c54e 393 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Direction'] = 'output'
whismanoid 52:607010f0c54e 394 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 395 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['FunctionName'] = 'UP_slash_DWNboutputValue'
whismanoid 52:607010f0c54e 396
whismanoid 66:3fe92f6f1cfa 397 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'H' 'CONVRUN'
whismanoid 52:607010f0c54e 398 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN'
whismanoid 52:607010f0c54e 399 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Direction'] = 'output'
whismanoid 52:607010f0c54e 400 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 401 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['FunctionName'] = 'CONVRUNoutputValue'
whismanoid 66:3fe92f6f1cfa 402 cmdLine.serial().printf("\r\n H -- CONVRUN output HH high HL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict
whismanoid 66:3fe92f6f1cfa 403 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'I' 'DACSTEP'
whismanoid 52:607010f0c54e 404 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP'
whismanoid 52:607010f0c54e 405 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Direction'] = 'output'
whismanoid 52:607010f0c54e 406 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 407 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['FunctionName'] = 'DACSTEPoutputValue'
whismanoid 66:3fe92f6f1cfa 408 cmdLine.serial().printf("\r\n I -- DACSTEP output IH high IL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict
whismanoid 66:3fe92f6f1cfa 409 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'J' 'EOC'
whismanoid 52:607010f0c54e 410 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC'
whismanoid 52:607010f0c54e 411 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Direction'] = 'input'
whismanoid 52:607010f0c54e 412 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 413 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['FunctionName'] = 'EOCinputValue'
whismanoid 66:3fe92f6f1cfa 414 cmdLine.serial().printf("\r\n J -- EOC input value"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict
whismanoid 52:607010f0c54e 415 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'S' 'SHDN'
whismanoid 52:607010f0c54e 416 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['PinName'] = 'SHDN'
whismanoid 52:607010f0c54e 417 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Direction'] = 'output'
whismanoid 52:607010f0c54e 418 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 419 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['FunctionName'] = 'SHDNoutputValue'
whismanoid 52:607010f0c54e 420 cmdLine.serial().printf("\r\n S -- SHDN output SH high SL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict
whismanoid 52:607010f0c54e 421 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'U' 'UP_slash_DWNb'
whismanoid 52:607010f0c54e 422 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['PinName'] = 'UP_slash_DWNb'
whismanoid 52:607010f0c54e 423 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Direction'] = 'output'
whismanoid 52:607010f0c54e 424 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 425 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['FunctionName'] = 'UP_slash_DWNboutputValue'
whismanoid 52:607010f0c54e 426 cmdLine.serial().printf("\r\n U -- UP_slash_DWNb output UH high UL low"); // TODO: ExternFunctionGPIOPinCommand testMenuGPIOItemsDict
whismanoid 52:607010f0c54e 427
whismanoid 84:11cc360628a1 428 #if Has_Read4Command_Command
whismanoid 83:29bb86cc45bc 429 // Read 4 command -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.
whismanoid 83:29bb86cc45bc 430 cmdLine.serial().printf("\r\n ^ -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.");
whismanoid 84:11cc360628a1 431 #endif // Has_Read4Command_Command
whismanoid 83:29bb86cc45bc 432
whismanoid 52:607010f0c54e 433 //
whismanoid 83:29bb86cc45bc 434 return true; // why is MAXxxxxx_menu_help() function bool not void?
whismanoid 52:607010f0c54e 435 }
whismanoid 52:607010f0c54e 436
whismanoid 52:607010f0c54e 437 bool MAX11043_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 52:607010f0c54e 438 {
whismanoid 52:607010f0c54e 439
whismanoid 52:607010f0c54e 440 // CODE GENERATOR: testMenuGlobalArgsDict Consolidate common/global argument parsing
whismanoid 52:607010f0c54e 441
whismanoid 59:47538bcf6cda 442 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['alias'] = 'None'
whismanoid 59:47538bcf6cda 443 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 444 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 445 // CODE GENERATOR: testMenuGlobalArgsDict['ADCa']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 446 // parse argument uint32_t ADCa
whismanoid 59:47538bcf6cda 447 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 448 if (cmdLine.parse_uint32_dec("ADCa", ADCa))
whismanoid 52:607010f0c54e 449 {
whismanoid 59:47538bcf6cda 450 // g_MAX11043_device.__WARNING_no_match_for_argname_ADCa_in_MAX11043_device_t__ = ADCa; // update global property value
whismanoid 59:47538bcf6cda 451 }
whismanoid 59:47538bcf6cda 452
whismanoid 59:47538bcf6cda 453 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['alias'] = 'None'
whismanoid 59:47538bcf6cda 454 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 455 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 456 // CODE GENERATOR: testMenuGlobalArgsDict['ADCb']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 457 // parse argument uint32_t ADCb
whismanoid 59:47538bcf6cda 458 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 459 if (cmdLine.parse_uint32_dec("ADCb", ADCb))
whismanoid 59:47538bcf6cda 460 {
whismanoid 59:47538bcf6cda 461 // g_MAX11043_device.__WARNING_no_match_for_argname_ADCb_in_MAX11043_device_t__ = ADCb; // update global property value
whismanoid 52:607010f0c54e 462 }
whismanoid 52:607010f0c54e 463
whismanoid 59:47538bcf6cda 464 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['alias'] = 'None'
whismanoid 59:47538bcf6cda 465 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 466 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 467 // CODE GENERATOR: testMenuGlobalArgsDict['ADCc']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 468 // parse argument uint32_t ADCc
whismanoid 59:47538bcf6cda 469 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 470 if (cmdLine.parse_uint32_dec("ADCc", ADCc))
whismanoid 52:607010f0c54e 471 {
whismanoid 59:47538bcf6cda 472 // g_MAX11043_device.__WARNING_no_match_for_argname_ADCc_in_MAX11043_device_t__ = ADCc; // update global property value
whismanoid 52:607010f0c54e 473 }
whismanoid 52:607010f0c54e 474
whismanoid 59:47538bcf6cda 475 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['alias'] = 'None'
whismanoid 59:47538bcf6cda 476 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['argtype'] = 'uint32_t'
whismanoid 59:47538bcf6cda 477 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 478 // CODE GENERATOR: testMenuGlobalArgsDict['ADCd']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 479 // parse argument uint32_t ADCd
whismanoid 59:47538bcf6cda 480 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 481 if (cmdLine.parse_uint32_dec("ADCd", ADCd))
whismanoid 52:607010f0c54e 482 {
whismanoid 59:47538bcf6cda 483 // g_MAX11043_device.__WARNING_no_match_for_argname_ADCd_in_MAX11043_device_t__ = ADCd; // update global property value
whismanoid 52:607010f0c54e 484 }
whismanoid 52:607010f0c54e 485
whismanoid 59:47538bcf6cda 486 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['alias'] = 'None'
whismanoid 59:47538bcf6cda 487 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['argtype'] = 'double'
whismanoid 59:47538bcf6cda 488 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 489 // CODE GENERATOR: testMenuGlobalArgsDict['VRef']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 490 // parse argument double VRef
whismanoid 59:47538bcf6cda 491 double VRef = g_MAX11043_device.VRef; // default to global property value
whismanoid 59:47538bcf6cda 492 if (cmdLine.parse_double("VRef", VRef))
whismanoid 52:607010f0c54e 493 {
whismanoid 59:47538bcf6cda 494 g_MAX11043_device.VRef = VRef; // update global property value
whismanoid 59:47538bcf6cda 495 }
whismanoid 59:47538bcf6cda 496
whismanoid 59:47538bcf6cda 497 // CODE GENERATOR: testMenuGlobalArgsDict['config']['alias'] = 'None'
whismanoid 59:47538bcf6cda 498 // CODE GENERATOR: testMenuGlobalArgsDict['config']['argtype'] = 'uint16_t'
whismanoid 59:47538bcf6cda 499 // CODE GENERATOR: testMenuGlobalArgsDict['config']['usedByCommandName'] = 'None'
whismanoid 59:47538bcf6cda 500 // CODE GENERATOR: testMenuGlobalArgsDict['config']['usedBytestMenuItemName'] = 'None'
whismanoid 59:47538bcf6cda 501 // parse argument uint16_t config
whismanoid 59:47538bcf6cda 502 uint16_t config = g_MAX11043_device.config; // default to global property value
whismanoid 59:47538bcf6cda 503 if (cmdLine.parse_uint16_dec("config", config))
whismanoid 59:47538bcf6cda 504 {
whismanoid 59:47538bcf6cda 505 g_MAX11043_device.config = config; // update global property value
whismanoid 52:607010f0c54e 506 }
whismanoid 52:607010f0c54e 507
whismanoid 52:607010f0c54e 508 // CODE GENERATOR: testMenuGlobalArgsDict['status']['alias'] = 'None'
whismanoid 52:607010f0c54e 509 // CODE GENERATOR: testMenuGlobalArgsDict['status']['argtype'] = 'uint32_t'
whismanoid 52:607010f0c54e 510 // CODE GENERATOR: testMenuGlobalArgsDict['status']['usedByCommandName'] = 'None'
whismanoid 52:607010f0c54e 511 // CODE GENERATOR: testMenuGlobalArgsDict['status']['usedBytestMenuItemName'] = 'None'
whismanoid 52:607010f0c54e 512 // parse argument uint32_t status
whismanoid 52:607010f0c54e 513 uint32_t status = g_MAX11043_device.status; // default to global property value
whismanoid 52:607010f0c54e 514 if (cmdLine.parse_uint32_dec("status", status))
whismanoid 52:607010f0c54e 515 {
whismanoid 52:607010f0c54e 516 g_MAX11043_device.status = status; // update global property value
whismanoid 52:607010f0c54e 517 }
whismanoid 52:607010f0c54e 518
whismanoid 52:607010f0c54e 519 switch (cmdLine[0])
whismanoid 52:607010f0c54e 520 {
whismanoid 84:11cc360628a1 521 #if Has_Read4Command_Command
whismanoid 83:29bb86cc45bc 522 // Read 4 command -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.
whismanoid 83:29bb86cc45bc 523 case '^':
whismanoid 83:29bb86cc45bc 524 {
whismanoid 83:29bb86cc45bc 525 // cmdLine.serial().printf("\r\n ^ -- Single 4-channel read: CONVRUN pulsed H then L, EOC ignored.");
whismanoid 84:11cc360628a1 526 #if Use_Read4Command_Thread
whismanoid 84:11cc360628a1 527 //~ int convrun_pulse_width_us = 30;
whismanoid 84:11cc360628a1 528 //~ int convrun_stop_us = 10;
whismanoid 84:11cc360628a1 529 cmdLine.serial().printf(" Testing, press X to stop...\r\n");
whismanoid 84:11cc360628a1 530 //~ cmdLine.serial().printf(" Testing, press RESET to stop...\r\n");
whismanoid 84:11cc360628a1 531 //~ int serial_is_blocking = cmdLine.serial().is_blocking();
whismanoid 84:11cc360628a1 532 //~ cmdLine.serial().set_blocking(0);
whismanoid 84:11cc360628a1 533 //
whismanoid 84:11cc360628a1 534 #if MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 84:11cc360628a1 535 digitalInOut5.output(); // ScopeTrigger
whismanoid 84:11cc360628a1 536 digitalInOut5.write(1); // ScopeTrigger
whismanoid 84:11cc360628a1 537 #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5
whismanoid 84:11cc360628a1 538 //
whismanoid 84:11cc360628a1 539 // init
whismanoid 84:11cc360628a1 540 Read4Command_Thread.start(Read4Command_Thread_handler);
whismanoid 84:11cc360628a1 541 // TODO: is there any harm in multiple start?
whismanoid 84:11cc360628a1 542 //
whismanoid 84:11cc360628a1 543 // Start the test
whismanoid 84:11cc360628a1 544 Read4Command_Thread_event_flags.set(MYTIMEREVENTFLAG_ENABLE_SPI);
whismanoid 84:11cc360628a1 545 // Work will be done inside Read4Command_Thread_handler
whismanoid 84:11cc360628a1 546 while (1)
whismanoid 84:11cc360628a1 547 {
whismanoid 84:11cc360628a1 548 char ch = cmdLine.serial().getc(); // blocking read
whismanoid 84:11cc360628a1 549 if (ch == '\r') { cmdLine.serial().printf(" (ignored \\r) "); continue; }
whismanoid 84:11cc360628a1 550 if (ch == '\n') { cmdLine.serial().printf(" (ignored \\n) "); continue; }
whismanoid 84:11cc360628a1 551 if (ch == '\x03') break; // CTRL+C break
whismanoid 84:11cc360628a1 552 if (ch == 'x') break;
whismanoid 84:11cc360628a1 553 if (ch == 'X') break;
whismanoid 84:11cc360628a1 554 cmdLine.serial().printf(" (ignored \\x%2.2x) ", (int)ch);
whismanoid 84:11cc360628a1 555 }
whismanoid 84:11cc360628a1 556 // Stop the test
whismanoid 84:11cc360628a1 557 Read4Command_Thread_event_flags.clear(MYTIMEREVENTFLAG_ENABLE_SPI);
whismanoid 84:11cc360628a1 558 //~ cmdLine.serial().set_blocking(serial_is_blocking);
whismanoid 84:11cc360628a1 559 cmdLine.serial().printf(" Stopped.\r\n");
whismanoid 84:11cc360628a1 560 #else // Use_Read4Command_Thread
whismanoid 83:29bb86cc45bc 561 int convrun_pulse_width_us = 30;
whismanoid 83:29bb86cc45bc 562 int convrun_stop_us = 10;
whismanoid 83:29bb86cc45bc 563 //~ cmdLine.serial().printf(" Testing, press X to stop...\r\n");
whismanoid 83:29bb86cc45bc 564 cmdLine.serial().printf(" Testing, press RESET to stop...\r\n");
whismanoid 83:29bb86cc45bc 565 //~ int serial_is_blocking = cmdLine.serial().is_blocking();
whismanoid 83:29bb86cc45bc 566 //~ cmdLine.serial().set_blocking(0);
whismanoid 83:29bb86cc45bc 567 while (1)
whismanoid 83:29bb86cc45bc 568 {
whismanoid 83:29bb86cc45bc 569 // TODO: CONVRUN = H -- perform ADC conversions (EOC will pulse, and data registers will update)
whismanoid 83:29bb86cc45bc 570 g_MAX11043_device.CONVRUNoutputValue(1);
whismanoid 83:29bb86cc45bc 571 //
whismanoid 83:29bb86cc45bc 572 // TODO: delay at least 9us to ensure at least one converion happens
whismanoid 83:29bb86cc45bc 573 wait_us(convrun_pulse_width_us);
whismanoid 83:29bb86cc45bc 574 //
whismanoid 83:29bb86cc45bc 575 // TODO: CONVRUN = L -- stop ADC conversions
whismanoid 83:29bb86cc45bc 576 g_MAX11043_device.CONVRUNoutputValue(0);
whismanoid 83:29bb86cc45bc 577 //
whismanoid 83:29bb86cc45bc 578 // TODO: delay at least 9us to ensure final converion complete
whismanoid 83:29bb86cc45bc 579 wait_us(convrun_stop_us);
whismanoid 83:29bb86cc45bc 580 //
whismanoid 83:29bb86cc45bc 581 // TODO: run SPI to capture 4 channels
whismanoid 83:29bb86cc45bc 582 // TODO: get rid of the other interrupt/thread, only to read here
whismanoid 83:29bb86cc45bc 583 g_MAX11043_device.Read_ADCabcd();
whismanoid 83:29bb86cc45bc 584 // post: g_MAX11043_device.adca was updated
whismanoid 83:29bb86cc45bc 585 // post: g_MAX11043_device.adcb was updated
whismanoid 83:29bb86cc45bc 586 // post: g_MAX11043_device.adcc was updated
whismanoid 83:29bb86cc45bc 587 // post: g_MAX11043_device.adcd was updated
whismanoid 83:29bb86cc45bc 588 //
whismanoid 83:29bb86cc45bc 589 // TODO: compare with thresholds, report if exceeded
whismanoid 83:29bb86cc45bc 590 //
whismanoid 83:29bb86cc45bc 591 // TODO: break on keypress
whismanoid 83:29bb86cc45bc 592 // TODO: this isn't working, serial().getc() is blocking and .readable() always returns 1 so we stall in getc().
whismanoid 83:29bb86cc45bc 593 unsigned int num_read_available = cmdLine.serial().readable();
whismanoid 83:29bb86cc45bc 594 if (num_read_available > 1) // should test >0; but always returns 1?
whismanoid 83:29bb86cc45bc 595 {
whismanoid 83:29bb86cc45bc 596 cmdLine.serial().printf(" (num_read_available %u) ", num_read_available);
whismanoid 83:29bb86cc45bc 597 char ch = cmdLine.serial().getc(); // blocking read
whismanoid 83:29bb86cc45bc 598 if (ch == '\r') { cmdLine.serial().printf(" (ignored \\r) "); continue; }
whismanoid 83:29bb86cc45bc 599 if (ch == '\n') { cmdLine.serial().printf(" (ignored \\n) "); continue; }
whismanoid 83:29bb86cc45bc 600 if (ch == '\x03') break; // CTRL+C break
whismanoid 83:29bb86cc45bc 601 if (ch == 'x') break;
whismanoid 83:29bb86cc45bc 602 if (ch == 'X') break;
whismanoid 83:29bb86cc45bc 603 cmdLine.serial().printf(" (ignored \\x%2.2x) ", (int)ch);
whismanoid 83:29bb86cc45bc 604 }
whismanoid 83:29bb86cc45bc 605 }
whismanoid 83:29bb86cc45bc 606 //~ cmdLine.serial().set_blocking(serial_is_blocking);
whismanoid 83:29bb86cc45bc 607 cmdLine.serial().printf(" Stopped.\r\n");
whismanoid 84:11cc360628a1 608 #endif // Use_Read4Command_Thread
whismanoid 83:29bb86cc45bc 609 return true; // command handled by MAX11043
whismanoid 83:29bb86cc45bc 610 }
whismanoid 83:29bb86cc45bc 611 break;
whismanoid 84:11cc360628a1 612 #endif // Has_Read4Command_Command
whismanoid 52:607010f0c54e 613 // CODE GENERATOR: generate * command read/write reg *reg? *reg=value
whismanoid 52:607010f0c54e 614 case '*':
whismanoid 52:607010f0c54e 615 {
whismanoid 52:607010f0c54e 616 // if buffer starts with a regName:
whismanoid 52:607010f0c54e 617 // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))):
whismanoid 52:607010f0c54e 618 cmdLine.serial().printf(" scan RegName...\r\n");
whismanoid 52:607010f0c54e 619 for (uint8_t regAddress = 0; regAddress < 0x80; regAddress++)
whismanoid 52:607010f0c54e 620 {
whismanoid 52:607010f0c54e 621 uint32_t regData = 0;
whismanoid 52:607010f0c54e 622 bool is_regname_query = false;
whismanoid 52:607010f0c54e 623 bool is_regname_assignment = false;
whismanoid 52:607010f0c54e 624 if (cmdLine.parse_uint32_dec(g_MAX11043_device.RegName((MAX11043::MAX11043_CMD_enum_t)regAddress), regData))
whismanoid 52:607010f0c54e 625 {
whismanoid 52:607010f0c54e 626 cmdLine.serial().printf(" regAddress=0x%2.2X\r\n", (regAddress & 0xFF));
whismanoid 52:607010f0c54e 627 cmdLine.serial().printf(" RegName=%s\r\n", g_MAX11043_device.RegName((MAX11043::MAX11043_CMD_enum_t)regAddress));
whismanoid 52:607010f0c54e 628 // accept regName "?" as "RegRead" by name
whismanoid 52:607010f0c54e 629 is_regname_query = (cmdLine.chSeparator == '?');
whismanoid 52:607010f0c54e 630 is_regname_assignment = (cmdLine.chSeparator == '=');
whismanoid 52:607010f0c54e 631 if (is_regname_query)
whismanoid 52:607010f0c54e 632 {
whismanoid 52:607010f0c54e 633 cmdLine.serial().printf(" RegRead");
whismanoid 52:607010f0c54e 634 g_MAX11043_device.RegRead((MAX11043::MAX11043_CMD_enum_t)regAddress, &regData);
whismanoid 52:607010f0c54e 635 cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF));
whismanoid 52:607010f0c54e 636 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 637 }
whismanoid 52:607010f0c54e 638 // accept regName "=0x123456" as "RegWrite" by name
whismanoid 52:607010f0c54e 639 if (is_regname_assignment)
whismanoid 52:607010f0c54e 640 {
whismanoid 52:607010f0c54e 641 cmdLine.serial().printf(" RegWrite");
whismanoid 52:607010f0c54e 642 cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF));
whismanoid 52:607010f0c54e 643 g_MAX11043_device.RegWrite((MAX11043::MAX11043_CMD_enum_t)regAddress, regData);
whismanoid 52:607010f0c54e 644 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 645 }
whismanoid 52:607010f0c54e 646 }
whismanoid 52:607010f0c54e 647 } // end for regAddr
whismanoid 52:607010f0c54e 648 // not a valid register name
whismanoid 57:1c9da8e90737 649 Callback<void(size_t, uint8_t*, uint8_t*)> saved_onSPIprint_handler = g_MAX11043_device.onSPIprint;
whismanoid 57:1c9da8e90737 650 g_MAX11043_device.onSPIprint = NULL; // temporarily suppress SPI diagnostic messages
whismanoid 52:607010f0c54e 651 // read "all" registers by name
whismanoid 57:1c9da8e90737 652 // TODO: KLUDGE: this constant array should live in the device driver, not the menu
whismanoid 57:1c9da8e90737 653 const MAX11043::MAX11043_CMD_enum_t readAllStatusList[] = {
whismanoid 59:47538bcf6cda 654 MAX11043::CMD_0000_0010_d16o8_Rd00_ADCa,
whismanoid 59:47538bcf6cda 655 MAX11043::CMD_0000_0110_d16o8_Rd01_ADCb,
whismanoid 59:47538bcf6cda 656 MAX11043::CMD_0000_1010_d16o8_Rd02_ADCc,
whismanoid 59:47538bcf6cda 657 MAX11043::CMD_0000_1110_d16o8_Rd03_ADCd,
whismanoid 57:1c9da8e90737 658 MAX11043::CMD_0001_1110_d8_Rd07_Status,
whismanoid 57:1c9da8e90737 659 MAX11043::CMD_0010_0010_d16_Rd08_Configuration,
whismanoid 57:1c9da8e90737 660 MAX11043::CMD_0010_0110_d16_Rd09_DAC,
whismanoid 57:1c9da8e90737 661 MAX11043::CMD_0010_1010_d16_Rd0A_DACStep,
whismanoid 57:1c9da8e90737 662 MAX11043::CMD_0010_1110_d16_Rd0B_DACHDACL,
whismanoid 57:1c9da8e90737 663 MAX11043::CMD_0011_0010_d16_Rd0C_ConfigA,
whismanoid 57:1c9da8e90737 664 MAX11043::CMD_0011_0110_d16_Rd0D_ConfigB,
whismanoid 57:1c9da8e90737 665 MAX11043::CMD_0011_1010_d16_Rd0E_ConfigC,
whismanoid 57:1c9da8e90737 666 MAX11043::CMD_0011_1110_d16_Rd0F_ConfigD,
whismanoid 57:1c9da8e90737 667 MAX11043::CMD_0100_0010_d16_Rd10_Reference,
whismanoid 57:1c9da8e90737 668 MAX11043::CMD_0100_0110_d16_Rd11_AGain,
whismanoid 57:1c9da8e90737 669 MAX11043::CMD_0100_1010_d16_Rd12_BGain,
whismanoid 57:1c9da8e90737 670 MAX11043::CMD_0100_1110_d16_Rd13_CGain,
whismanoid 57:1c9da8e90737 671 MAX11043::CMD_0101_0010_d16_Rd14_DGain,
whismanoid 57:1c9da8e90737 672 };
whismanoid 57:1c9da8e90737 673 for (uint8_t readAllStatusIndex = 0; readAllStatusIndex < (sizeof(readAllStatusList)/sizeof(MAX11043::MAX11043_CMD_enum_t)); readAllStatusIndex++)
whismanoid 52:607010f0c54e 674 {
whismanoid 57:1c9da8e90737 675 MAX11043::MAX11043_CMD_enum_t regAddress = readAllStatusList[readAllStatusIndex];
whismanoid 52:607010f0c54e 676 uint32_t regData = 0;
whismanoid 57:1c9da8e90737 677 if (g_MAX11043_device.RegSize(regAddress) == 0) continue; // skip undefined regs
whismanoid 57:1c9da8e90737 678 if (g_MAX11043_device.RegRead(regAddress, &regData) == 0) continue; // skip unreadable regs
whismanoid 57:1c9da8e90737 679 cmdLine.serial().printf("%s=0x%6.6x\r\n", g_MAX11043_device.RegName(regAddress), regData);
whismanoid 52:607010f0c54e 680 } // end for regAddr
whismanoid 52:607010f0c54e 681 g_MAX11043_device.onSPIprint = saved_onSPIprint_handler;
whismanoid 52:607010f0c54e 682 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 683 }
whismanoid 52:607010f0c54e 684 break;
whismanoid 52:607010f0c54e 685
whismanoid 52:607010f0c54e 686 // CODE GENERATOR: generate @ command print global property values of g_MAX11043_device
whismanoid 52:607010f0c54e 687 case '@':
whismanoid 52:607010f0c54e 688 {
whismanoid 59:47538bcf6cda 689 // CODE GENERATOR: @ command print double g_MAX11043_device.VRef
whismanoid 59:47538bcf6cda 690 cmdLine.serial().printf("VRef = ");
whismanoid 59:47538bcf6cda 691 cmdLine.serial().printf("%f\r\n", g_MAX11043_device.VRef);
whismanoid 59:47538bcf6cda 692 // CODE GENERATOR: @ command print uint16_t g_MAX11043_device.config
whismanoid 59:47538bcf6cda 693 cmdLine.serial().printf("config = ");
whismanoid 59:47538bcf6cda 694 cmdLine.serial().printf("%d = 0x%4.4x\r\n", g_MAX11043_device.config, g_MAX11043_device.config);
whismanoid 52:607010f0c54e 695 // CODE GENERATOR: @ command print uint32_t g_MAX11043_device.status
whismanoid 52:607010f0c54e 696 cmdLine.serial().printf("status = ");
whismanoid 52:607010f0c54e 697 cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.status, g_MAX11043_device.status);
whismanoid 59:47538bcf6cda 698 // CODE GENERATOR: @ command print uint32_t g_MAX11043_device.adca
whismanoid 59:47538bcf6cda 699 cmdLine.serial().printf("adca = ");
whismanoid 59:47538bcf6cda 700 cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.adca, g_MAX11043_device.adca);
whismanoid 59:47538bcf6cda 701 // CODE GENERATOR: @ command print uint32_t g_MAX11043_device.adcb
whismanoid 59:47538bcf6cda 702 cmdLine.serial().printf("adcb = ");
whismanoid 59:47538bcf6cda 703 cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.adcb, g_MAX11043_device.adcb);
whismanoid 59:47538bcf6cda 704 // CODE GENERATOR: @ command print uint32_t g_MAX11043_device.adcc
whismanoid 59:47538bcf6cda 705 cmdLine.serial().printf("adcc = ");
whismanoid 59:47538bcf6cda 706 cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.adcc, g_MAX11043_device.adcc);
whismanoid 59:47538bcf6cda 707 // CODE GENERATOR: @ command print uint32_t g_MAX11043_device.adcd
whismanoid 59:47538bcf6cda 708 cmdLine.serial().printf("adcd = ");
whismanoid 59:47538bcf6cda 709 cmdLine.serial().printf("%d = 0x%8.8x\r\n", g_MAX11043_device.adcd, g_MAX11043_device.adcd);
whismanoid 52:607010f0c54e 710 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 711 break;
whismanoid 52:607010f0c54e 712 }
whismanoid 52:607010f0c54e 713 // CODE GENERATOR: TODO1: generate GPIO commands for LDAC, CLR, etc. based on device driver function names
whismanoid 52:607010f0c54e 714 // case 'G'..'Z','g'..'z' are reserved for GPIO commands
whismanoid 52:607010f0c54e 715 // case 'A'..'F','a'..'f' may be available if not claimed by bitstream commands
whismanoid 66:3fe92f6f1cfa 716 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'H' 'CONVRUN'
whismanoid 52:607010f0c54e 717 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['PinName'] = 'CONVRUN'
whismanoid 52:607010f0c54e 718 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Direction'] = 'output'
whismanoid 52:607010f0c54e 719 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 720 // CODE GENERATOR: testMenuGPIOItemsDict['CONVRUN']['FunctionName'] = 'CONVRUNoutputValue'
whismanoid 66:3fe92f6f1cfa 721 case 'H':
whismanoid 52:607010f0c54e 722 {
whismanoid 52:607010f0c54e 723 switch (cmdLine[1])
whismanoid 52:607010f0c54e 724 {
whismanoid 52:607010f0c54e 725 case 'H':
whismanoid 52:607010f0c54e 726 {
whismanoid 52:607010f0c54e 727 g_MAX11043_device.CONVRUNoutputValue(1);
whismanoid 52:607010f0c54e 728 break;
whismanoid 52:607010f0c54e 729 }
whismanoid 52:607010f0c54e 730 case 'L':
whismanoid 52:607010f0c54e 731 {
whismanoid 52:607010f0c54e 732 g_MAX11043_device.CONVRUNoutputValue(0);
whismanoid 52:607010f0c54e 733 break;
whismanoid 52:607010f0c54e 734 }
whismanoid 52:607010f0c54e 735 }
whismanoid 52:607010f0c54e 736 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 737 break;
whismanoid 52:607010f0c54e 738 }
whismanoid 52:607010f0c54e 739
whismanoid 66:3fe92f6f1cfa 740 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'I' 'DACSTEP'
whismanoid 52:607010f0c54e 741 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['PinName'] = 'DACSTEP'
whismanoid 52:607010f0c54e 742 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Direction'] = 'output'
whismanoid 52:607010f0c54e 743 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 744 // CODE GENERATOR: testMenuGPIOItemsDict['DACSTEP']['FunctionName'] = 'DACSTEPoutputValue'
whismanoid 66:3fe92f6f1cfa 745 case 'I':
whismanoid 52:607010f0c54e 746 {
whismanoid 52:607010f0c54e 747 switch (cmdLine[1])
whismanoid 52:607010f0c54e 748 {
whismanoid 52:607010f0c54e 749 case 'H':
whismanoid 52:607010f0c54e 750 {
whismanoid 52:607010f0c54e 751 g_MAX11043_device.DACSTEPoutputValue(1);
whismanoid 52:607010f0c54e 752 break;
whismanoid 52:607010f0c54e 753 }
whismanoid 52:607010f0c54e 754 case 'L':
whismanoid 52:607010f0c54e 755 {
whismanoid 52:607010f0c54e 756 g_MAX11043_device.DACSTEPoutputValue(0);
whismanoid 52:607010f0c54e 757 break;
whismanoid 52:607010f0c54e 758 }
whismanoid 52:607010f0c54e 759 }
whismanoid 52:607010f0c54e 760 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 761 break;
whismanoid 52:607010f0c54e 762 }
whismanoid 52:607010f0c54e 763
whismanoid 66:3fe92f6f1cfa 764 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'J' 'EOC'
whismanoid 52:607010f0c54e 765 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['PinName'] = 'EOC'
whismanoid 52:607010f0c54e 766 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Direction'] = 'input'
whismanoid 52:607010f0c54e 767 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 768 // CODE GENERATOR: testMenuGPIOItemsDict['EOC']['FunctionName'] = 'EOCinputValue'
whismanoid 66:3fe92f6f1cfa 769 case 'J':
whismanoid 52:607010f0c54e 770 {
whismanoid 52:607010f0c54e 771 // TODO capture and print input Value
whismanoid 52:607010f0c54e 772 cmdLine.serial().printf("%d", g_MAX11043_device.EOCinputValue());
whismanoid 52:607010f0c54e 773 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 774 break;
whismanoid 52:607010f0c54e 775 }
whismanoid 52:607010f0c54e 776
whismanoid 52:607010f0c54e 777 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'S' 'SHDN'
whismanoid 52:607010f0c54e 778 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['PinName'] = 'SHDN'
whismanoid 52:607010f0c54e 779 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Direction'] = 'output'
whismanoid 52:607010f0c54e 780 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 781 // CODE GENERATOR: testMenuGPIOItemsDict['SHDN']['FunctionName'] = 'SHDNoutputValue'
whismanoid 52:607010f0c54e 782 case 'S':
whismanoid 52:607010f0c54e 783 {
whismanoid 52:607010f0c54e 784 switch (cmdLine[1])
whismanoid 52:607010f0c54e 785 {
whismanoid 52:607010f0c54e 786 case 'H':
whismanoid 52:607010f0c54e 787 {
whismanoid 52:607010f0c54e 788 g_MAX11043_device.SHDNoutputValue(1);
whismanoid 52:607010f0c54e 789 break;
whismanoid 52:607010f0c54e 790 }
whismanoid 52:607010f0c54e 791 case 'L':
whismanoid 52:607010f0c54e 792 {
whismanoid 52:607010f0c54e 793 g_MAX11043_device.SHDNoutputValue(0);
whismanoid 52:607010f0c54e 794 break;
whismanoid 52:607010f0c54e 795 }
whismanoid 52:607010f0c54e 796 }
whismanoid 52:607010f0c54e 797 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 798 break;
whismanoid 52:607010f0c54e 799 }
whismanoid 52:607010f0c54e 800
whismanoid 52:607010f0c54e 801 // CODE GENERATOR: ExternFunctionGPIOPinCommand 'U' 'UP_slash_DWNb'
whismanoid 52:607010f0c54e 802 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['PinName'] = 'UP_slash_DWNb'
whismanoid 52:607010f0c54e 803 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Direction'] = 'output'
whismanoid 52:607010f0c54e 804 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['Operation'] = 'Value'
whismanoid 52:607010f0c54e 805 // CODE GENERATOR: testMenuGPIOItemsDict['UP_slash_DWNb']['FunctionName'] = 'UP_slash_DWNboutputValue'
whismanoid 52:607010f0c54e 806 case 'U':
whismanoid 52:607010f0c54e 807 {
whismanoid 52:607010f0c54e 808 switch (cmdLine[1])
whismanoid 52:607010f0c54e 809 {
whismanoid 52:607010f0c54e 810 case 'H':
whismanoid 52:607010f0c54e 811 {
whismanoid 52:607010f0c54e 812 g_MAX11043_device.UP_slash_DWNboutputValue(1);
whismanoid 52:607010f0c54e 813 break;
whismanoid 52:607010f0c54e 814 }
whismanoid 52:607010f0c54e 815 case 'L':
whismanoid 52:607010f0c54e 816 {
whismanoid 52:607010f0c54e 817 g_MAX11043_device.UP_slash_DWNboutputValue(0);
whismanoid 52:607010f0c54e 818 break;
whismanoid 52:607010f0c54e 819 }
whismanoid 52:607010f0c54e 820 }
whismanoid 52:607010f0c54e 821 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 822 break;
whismanoid 52:607010f0c54e 823 }
whismanoid 52:607010f0c54e 824
whismanoid 52:607010f0c54e 825
whismanoid 52:607010f0c54e 826 // CODE GENERATOR: test menu
whismanoid 52:607010f0c54e 827 // case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands
whismanoid 52:607010f0c54e 828 // has_register_write_command: case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands
whismanoid 52:607010f0c54e 829 // CODE GENERATOR: top of loop: testMenuCommand="!", testMenuFirstCharHandler="None"
whismanoid 52:607010f0c54e 830 // CODE GENERATOR: test menu case '!':
whismanoid 52:607010f0c54e 831 // CODE GENERATOR: helpString '! -- Init'
whismanoid 52:607010f0c54e 832 // CODE GENERATOR: CMD_ 'None'
whismanoid 52:607010f0c54e 833 // CODE GENERATOR: CommandName 'Init'
whismanoid 52:607010f0c54e 834 // CODE GENERATOR: CommandParamIn 'void'
whismanoid 52:607010f0c54e 835 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 52:607010f0c54e 836 // CODE GENERATOR: CommandPre ''
whismanoid 52:607010f0c54e 837 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 52:607010f0c54e 838 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 52:607010f0c54e 839 // CODE GENERATOR: CommandPost ''
whismanoid 52:607010f0c54e 840 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 52:607010f0c54e 841 // case '!': // (single character) (testMenuFirstCharHandler="None")
whismanoid 52:607010f0c54e 842 case '!':
whismanoid 52:607010f0c54e 843 {
whismanoid 52:607010f0c54e 844 // test menu command '!' handler:
whismanoid 52:607010f0c54e 845 // helpString='! -- Init'
whismanoid 52:607010f0c54e 846 // CMD_='None'
whismanoid 52:607010f0c54e 847 // CommandName='Init'
whismanoid 52:607010f0c54e 848 // CommandParamIn='void'
whismanoid 52:607010f0c54e 849 // CommandReturnType='uint8_t'
whismanoid 52:607010f0c54e 850 // @Pre=''
whismanoid 52:607010f0c54e 851 // @Param[in]=''
whismanoid 52:607010f0c54e 852 // @Param[out]=''
whismanoid 52:607010f0c54e 853 // @Post=''
whismanoid 52:607010f0c54e 854 // displayPost=''
whismanoid 52:607010f0c54e 855 // @Return='@return 1 on success; 0 on failure'
whismanoid 52:607010f0c54e 856 cmdLine.serial().printf("Init");
whismanoid 52:607010f0c54e 857 // call function Init
whismanoid 52:607010f0c54e 858 uint8_t result = g_MAX11043_device.Init();
whismanoid 65:2117e32f017d 859 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 52:607010f0c54e 860 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 861 // CODE GENERATOR: bottom of loop: testMenuCommand="!", testMenuFirstCharHandler="None"
whismanoid 52:607010f0c54e 862 } // end case '!'
whismanoid 52:607010f0c54e 863 break;
whismanoid 52:607010f0c54e 864
whismanoid 64:a667cfd83492 865 // CODE GENERATOR: top of loop: testMenuCommand="$", testMenuFirstCharHandler="None"
whismanoid 64:a667cfd83492 866 // CODE GENERATOR: test menu case '$':
whismanoid 64:a667cfd83492 867 // CODE GENERATOR: helpString '$ -- Read_ADCabcd'
whismanoid 64:a667cfd83492 868 // CODE GENERATOR: CMD_ 'None'
whismanoid 64:a667cfd83492 869 // CODE GENERATOR: CommandName 'Read_ADCabcd'
whismanoid 64:a667cfd83492 870 // CODE GENERATOR: CommandParamIn 'void'
whismanoid 64:a667cfd83492 871 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 64:a667cfd83492 872 // CODE GENERATOR: CommandPre ''
whismanoid 64:a667cfd83492 873 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 64:a667cfd83492 874 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 64:a667cfd83492 875 // CODE GENERATOR: CommandPost ''
whismanoid 64:a667cfd83492 876 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 64:a667cfd83492 877 // case '$': // (single character) (testMenuFirstCharHandler="None")
whismanoid 64:a667cfd83492 878 case '$':
whismanoid 64:a667cfd83492 879 {
whismanoid 64:a667cfd83492 880 // test menu command '$' handler:
whismanoid 64:a667cfd83492 881 // helpString='$ -- Read_ADCabcd'
whismanoid 64:a667cfd83492 882 // CMD_='None'
whismanoid 64:a667cfd83492 883 // CommandName='Read_ADCabcd'
whismanoid 64:a667cfd83492 884 // CommandParamIn='void'
whismanoid 64:a667cfd83492 885 // CommandReturnType='uint8_t'
whismanoid 64:a667cfd83492 886 // @Pre=''
whismanoid 64:a667cfd83492 887 // @Param[in]=''
whismanoid 64:a667cfd83492 888 // @Param[out]=''
whismanoid 64:a667cfd83492 889 // @Post=''
whismanoid 64:a667cfd83492 890 // displayPost='adca, adcb, adcc, adcd'
whismanoid 64:a667cfd83492 891 // @Return='@return 1 on success; 0 on failure'
whismanoid 64:a667cfd83492 892 cmdLine.serial().printf("Read_ADCabcd");
whismanoid 64:a667cfd83492 893 // call function Read_ADCabcd
whismanoid 64:a667cfd83492 894 uint8_t result = g_MAX11043_device.Read_ADCabcd();
whismanoid 65:2117e32f017d 895 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 64:a667cfd83492 896 // Menu item '$' -> adca, adcb, adcc, adcd
whismanoid 64:a667cfd83492 897 cmdLine.serial().printf("%s=%d\r\n", "adca", g_MAX11043_device.adca);
whismanoid 64:a667cfd83492 898 cmdLine.serial().printf("%s=%d\r\n", "adcb", g_MAX11043_device.adcb);
whismanoid 64:a667cfd83492 899 cmdLine.serial().printf("%s=%d\r\n", "adcc", g_MAX11043_device.adcc);
whismanoid 64:a667cfd83492 900 cmdLine.serial().printf("%s=%d\r\n", "adcd", g_MAX11043_device.adcd);
whismanoid 64:a667cfd83492 901 return true; // command handled by MAX11043
whismanoid 64:a667cfd83492 902 // CODE GENERATOR: bottom of loop: testMenuCommand="$", testMenuFirstCharHandler="None"
whismanoid 64:a667cfd83492 903 } // end case '$'
whismanoid 64:a667cfd83492 904 break;
whismanoid 64:a667cfd83492 905
whismanoid 66:3fe92f6f1cfa 906 // CODE GENERATOR: top of loop: testMenuCommand="G", testMenuFirstCharHandler="None"
whismanoid 66:3fe92f6f1cfa 907 // CODE GENERATOR: test menu case 'G':
whismanoid 66:3fe92f6f1cfa 908 // CODE GENERATOR: helpString 'G gain=? -- Write_AGain'
whismanoid 64:a667cfd83492 909 // CODE GENERATOR: CMD_ 'None'
whismanoid 64:a667cfd83492 910 // CODE GENERATOR: CommandName 'Write_AGain'
whismanoid 64:a667cfd83492 911 // CODE GENERATOR: CommandParamIn 'uint32_t gain'
whismanoid 64:a667cfd83492 912 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 64:a667cfd83492 913 // CODE GENERATOR: CommandPre ''
whismanoid 64:a667cfd83492 914 // 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 915 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 64:a667cfd83492 916 // CODE GENERATOR: CommandPost ''
whismanoid 64:a667cfd83492 917 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 66:3fe92f6f1cfa 918 // case 'G': // (single character) (testMenuFirstCharHandler="None")
whismanoid 66:3fe92f6f1cfa 919 case 'G':
whismanoid 64:a667cfd83492 920 {
whismanoid 66:3fe92f6f1cfa 921 // test menu command 'G' handler:
whismanoid 66:3fe92f6f1cfa 922 // helpString='G gain=? -- Write_AGain'
whismanoid 64:a667cfd83492 923 // CMD_='None'
whismanoid 64:a667cfd83492 924 // CommandName='Write_AGain'
whismanoid 64:a667cfd83492 925 // CommandParamIn='uint32_t gain'
whismanoid 64:a667cfd83492 926 // CommandReturnType='uint8_t'
whismanoid 64:a667cfd83492 927 // @Pre=''
whismanoid 64:a667cfd83492 928 // @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 929 // @Param[out]=''
whismanoid 64:a667cfd83492 930 // @Post=''
whismanoid 64:a667cfd83492 931 // displayPost=''
whismanoid 64:a667cfd83492 932 // @Return='@return 1 on success; 0 on failure'
whismanoid 64:a667cfd83492 933 // parse argument list
whismanoid 64:a667cfd83492 934 // 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 935 // parse argument uint32_t gain
whismanoid 64:a667cfd83492 936 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 937 if (cmdLine.parse_uint32_dec("gain", gain))
whismanoid 64:a667cfd83492 938 {
whismanoid 64:a667cfd83492 939 // g_MAX11043_device.__WARNING_no_match_for_argname_gain_in_MAX11043_device_t__ = gain; // update global property value
whismanoid 64:a667cfd83492 940 }
whismanoid 64:a667cfd83492 941 // print arguments
whismanoid 64:a667cfd83492 942 cmdLine.serial().printf("Write_AGain");
whismanoid 64:a667cfd83492 943 cmdLine.serial().printf(" gain=%d", gain);
whismanoid 64:a667cfd83492 944 cmdLine.serial().printf("\r\n");
whismanoid 64:a667cfd83492 945 // call function Write_AGain(gain)
whismanoid 64:a667cfd83492 946 uint8_t result = g_MAX11043_device.Write_AGain(gain);
whismanoid 64:a667cfd83492 947 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 64:a667cfd83492 948 return true; // command handled by MAX11043
whismanoid 66:3fe92f6f1cfa 949 // CODE GENERATOR: bottom of loop: testMenuCommand="G", testMenuFirstCharHandler="None"
whismanoid 66:3fe92f6f1cfa 950 } // end case 'G'
whismanoid 64:a667cfd83492 951 break;
whismanoid 64:a667cfd83492 952
whismanoid 59:47538bcf6cda 953 // CODE GENERATOR: top of loop: testMenuCommand="XX", testMenuFirstCharHandler="None"
whismanoid 59:47538bcf6cda 954 // CODE GENERATOR: test menu case 'XX':
whismanoid 59:47538bcf6cda 955 // CODE GENERATOR: helpString 'XX linef=? rate=? -- Configure_XXXXX'
whismanoid 59:47538bcf6cda 956 // CODE GENERATOR: CMD_ 'None'
whismanoid 59:47538bcf6cda 957 // CODE GENERATOR: CommandName 'Configure_XXXXX'
whismanoid 59:47538bcf6cda 958 // CODE GENERATOR: CommandParamIn 'uint8_t linef, uint8_t rate'
whismanoid 59:47538bcf6cda 959 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 59:47538bcf6cda 960 // CODE GENERATOR: CommandPre ''
whismanoid 59:47538bcf6cda 961 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 59:47538bcf6cda 962 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 59:47538bcf6cda 963 // CODE GENERATOR: CommandPost ''
whismanoid 59:47538bcf6cda 964 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 59:47538bcf6cda 965 case 'X': // (multiple characters) (testMenuFirstCharHandler="X"):
whismanoid 59:47538bcf6cda 966 {
whismanoid 59:47538bcf6cda 967 switch (cmdLine[1])
whismanoid 59:47538bcf6cda 968 {
whismanoid 59:47538bcf6cda 969 case 'X': // (nested inside case 'X')
whismanoid 59:47538bcf6cda 970 {
whismanoid 59:47538bcf6cda 971 // test menu command 'XX' handler:
whismanoid 59:47538bcf6cda 972 // helpString='XX linef=? rate=? -- Configure_XXXXX'
whismanoid 59:47538bcf6cda 973 // CMD_='None'
whismanoid 59:47538bcf6cda 974 // CommandName='Configure_XXXXX'
whismanoid 59:47538bcf6cda 975 // CommandParamIn='uint8_t linef, uint8_t rate'
whismanoid 59:47538bcf6cda 976 // CommandReturnType='uint8_t'
whismanoid 59:47538bcf6cda 977 // @Pre=''
whismanoid 59:47538bcf6cda 978 // @Param[in]=''
whismanoid 59:47538bcf6cda 979 // @Param[out]=''
whismanoid 59:47538bcf6cda 980 // @Post=''
whismanoid 59:47538bcf6cda 981 // displayPost=''
whismanoid 59:47538bcf6cda 982 // @Return='@return 1 on success; 0 on failure'
whismanoid 59:47538bcf6cda 983 // parse argument list
whismanoid 59:47538bcf6cda 984 // parse argument uint8_t linef
whismanoid 59:47538bcf6cda 985 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 986 if (cmdLine.parse_uint8_dec("linef", linef))
whismanoid 59:47538bcf6cda 987 {
whismanoid 59:47538bcf6cda 988 // g_MAX11043_device.__WARNING_no_match_for_argname_linef_in_MAX11043_device_t__ = linef; // update global property value
whismanoid 59:47538bcf6cda 989 }
whismanoid 59:47538bcf6cda 990 // parse argument uint8_t rate
whismanoid 59:47538bcf6cda 991 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 992 if (cmdLine.parse_uint8_dec("rate", rate))
whismanoid 59:47538bcf6cda 993 {
whismanoid 59:47538bcf6cda 994 // g_MAX11043_device.__WARNING_no_match_for_argname_rate_in_MAX11043_device_t__ = rate; // update global property value
whismanoid 59:47538bcf6cda 995 }
whismanoid 59:47538bcf6cda 996 // print arguments
whismanoid 59:47538bcf6cda 997 cmdLine.serial().printf("Configure_XXXXX");
whismanoid 59:47538bcf6cda 998 cmdLine.serial().printf(" linef=%d", linef);
whismanoid 59:47538bcf6cda 999 cmdLine.serial().printf(" rate=%d", rate);
whismanoid 59:47538bcf6cda 1000 cmdLine.serial().printf("\r\n");
whismanoid 59:47538bcf6cda 1001 // call function Configure_XXXXX(linef, rate)
whismanoid 59:47538bcf6cda 1002 uint8_t result = g_MAX11043_device.Configure_XXXXX(linef, rate);
whismanoid 59:47538bcf6cda 1003 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 59:47538bcf6cda 1004 return true; // command handled by MAX11043
whismanoid 59:47538bcf6cda 1005 // CODE GENERATOR: bottom of loop: testMenuCommand="XX", testMenuFirstCharHandler="X"
whismanoid 59:47538bcf6cda 1006 } // end nested case 'XX'
whismanoid 59:47538bcf6cda 1007 break;
whismanoid 59:47538bcf6cda 1008
whismanoid 59:47538bcf6cda 1009 // CODE GENERATOR: top of loop: testMenuCommand="XY", testMenuFirstCharHandler="X"
whismanoid 59:47538bcf6cda 1010 // CODE GENERATOR: top of loop: nested switch "X" is currently open
whismanoid 59:47538bcf6cda 1011 // CODE GENERATOR: test menu case 'XY':
whismanoid 59:47538bcf6cda 1012 // CODE GENERATOR: helpString 'XY linef=? rate=? -- Configure_XXXXY'
whismanoid 59:47538bcf6cda 1013 // CODE GENERATOR: CMD_ 'None'
whismanoid 59:47538bcf6cda 1014 // CODE GENERATOR: CommandName 'Configure_XXXXY'
whismanoid 59:47538bcf6cda 1015 // CODE GENERATOR: CommandParamIn 'uint8_t linef, uint8_t rate'
whismanoid 59:47538bcf6cda 1016 // CODE GENERATOR: CommandReturnType 'uint8_t'
whismanoid 59:47538bcf6cda 1017 // CODE GENERATOR: CommandPre ''
whismanoid 59:47538bcf6cda 1018 // CODE GENERATOR: CommandDocParamIn ''
whismanoid 59:47538bcf6cda 1019 // CODE GENERATOR: CommandDocParamOut ''
whismanoid 59:47538bcf6cda 1020 // CODE GENERATOR: CommandPost ''
whismanoid 59:47538bcf6cda 1021 // CODE GENERATOR: CommandReturn '@return 1 on success; 0 on failure'
whismanoid 59:47538bcf6cda 1022 case 'Y': // (nested inside case 'X')
whismanoid 59:47538bcf6cda 1023 {
whismanoid 59:47538bcf6cda 1024 // test menu command 'XY' handler:
whismanoid 59:47538bcf6cda 1025 // helpString='XY linef=? rate=? -- Configure_XXXXY'
whismanoid 59:47538bcf6cda 1026 // CMD_='None'
whismanoid 59:47538bcf6cda 1027 // CommandName='Configure_XXXXY'
whismanoid 59:47538bcf6cda 1028 // CommandParamIn='uint8_t linef, uint8_t rate'
whismanoid 59:47538bcf6cda 1029 // CommandReturnType='uint8_t'
whismanoid 59:47538bcf6cda 1030 // @Pre=''
whismanoid 59:47538bcf6cda 1031 // @Param[in]=''
whismanoid 59:47538bcf6cda 1032 // @Param[out]=''
whismanoid 59:47538bcf6cda 1033 // @Post=''
whismanoid 59:47538bcf6cda 1034 // displayPost=''
whismanoid 59:47538bcf6cda 1035 // @Return='@return 1 on success; 0 on failure'
whismanoid 59:47538bcf6cda 1036 // parse argument list
whismanoid 59:47538bcf6cda 1037 // parse argument uint8_t linef
whismanoid 59:47538bcf6cda 1038 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 1039 if (cmdLine.parse_uint8_dec("linef", linef))
whismanoid 59:47538bcf6cda 1040 {
whismanoid 59:47538bcf6cda 1041 // g_MAX11043_device.__WARNING_no_match_for_argname_linef_in_MAX11043_device_t__ = linef; // update global property value
whismanoid 59:47538bcf6cda 1042 }
whismanoid 59:47538bcf6cda 1043 // parse argument uint8_t rate
whismanoid 59:47538bcf6cda 1044 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 1045 if (cmdLine.parse_uint8_dec("rate", rate))
whismanoid 59:47538bcf6cda 1046 {
whismanoid 59:47538bcf6cda 1047 // g_MAX11043_device.__WARNING_no_match_for_argname_rate_in_MAX11043_device_t__ = rate; // update global property value
whismanoid 59:47538bcf6cda 1048 }
whismanoid 59:47538bcf6cda 1049 // print arguments
whismanoid 59:47538bcf6cda 1050 cmdLine.serial().printf("Configure_XXXXY");
whismanoid 59:47538bcf6cda 1051 cmdLine.serial().printf(" linef=%d", linef);
whismanoid 59:47538bcf6cda 1052 cmdLine.serial().printf(" rate=%d", rate);
whismanoid 59:47538bcf6cda 1053 cmdLine.serial().printf("\r\n");
whismanoid 59:47538bcf6cda 1054 // call function Configure_XXXXY(linef, rate)
whismanoid 59:47538bcf6cda 1055 uint8_t result = g_MAX11043_device.Configure_XXXXY(linef, rate);
whismanoid 59:47538bcf6cda 1056 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 59:47538bcf6cda 1057 return true; // command handled by MAX11043
whismanoid 59:47538bcf6cda 1058 // CODE GENERATOR: bottom of loop: testMenuCommand="XY", testMenuFirstCharHandler="X"
whismanoid 59:47538bcf6cda 1059 } // end nested case 'XY'
whismanoid 59:47538bcf6cda 1060 break;
whismanoid 59:47538bcf6cda 1061
whismanoid 59:47538bcf6cda 1062 } // end nested switch (cmdLine[1]) inside case 'X'
whismanoid 59:47538bcf6cda 1063 break;
whismanoid 59:47538bcf6cda 1064 } // end case 'X'
whismanoid 52:607010f0c54e 1065 // has_register_write_command: case '0'..'9','A'..'F','a'..'f' letters are reserved for bitstream commands
whismanoid 52:607010f0c54e 1066 case '0': case '1': case '2': case '3': case '4':
whismanoid 52:607010f0c54e 1067 case '5': case '6': case '7': case '8': case '9':
whismanoid 52:607010f0c54e 1068 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
whismanoid 52:607010f0c54e 1069 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
whismanoid 52:607010f0c54e 1070 {
whismanoid 52:607010f0c54e 1071 // hexadecimal codes get parsed as bytecodes
whismanoid 52:607010f0c54e 1072 //
whismanoid 52:607010f0c54e 1073 // parse_byteCount_byteList_dec() assumes all keyword args have already been removed from the buffer
whismanoid 52:607010f0c54e 1074 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 52:607010f0c54e 1075 #define MAX_SPI_BYTE_COUNT 32
whismanoid 52:607010f0c54e 1076 size_t byteCount = byteCount;
whismanoid 52:607010f0c54e 1077 static char mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 52:607010f0c54e 1078 static char misoData[MAX_SPI_BYTE_COUNT];
whismanoid 52:607010f0c54e 1079 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 52:607010f0c54e 1080 MAX_SPI_BYTE_COUNT))
whismanoid 52:607010f0c54e 1081 {
whismanoid 57:1c9da8e90737 1082 // TODO: decode operation from commandByte
whismanoid 57:1c9da8e90737 1083 // TODO: OVERSIMPLIFICATION: if length is 1 byte then operation is RegRead, otherwise RegWrite
whismanoid 52:607010f0c54e 1084 // register_read_function 'IsRegReadCommand'
whismanoid 52:607010f0c54e 1085 // register_write_function 'RegWrite'
whismanoid 52:607010f0c54e 1086 // register_name_function 'RegName'
whismanoid 52:607010f0c54e 1087 // register_size_function 'RegSize'
whismanoid 57:1c9da8e90737 1088 // CODE GENERATOR: does the chip have a defined CMDOP_1aaa_aaaa_ReadRegister bit?
whismanoid 57:1c9da8e90737 1089 // MAX11043::MAX11043_CMD_enum_t regAddress = (MAX11043::MAX11043_CMD_enum_t)((mosiData[0] &~ MAX11043::CMDOP_1aaa_aaaa_ReadRegister) & 0xFF);
whismanoid 52:607010f0c54e 1090 MAX11043::MAX11043_CMD_enum_t commandByte = (MAX11043::MAX11043_CMD_enum_t)(mosiData[0]);
whismanoid 57:1c9da8e90737 1091 MAX11043::MAX11043_CMDOP_enum_t commandOp = g_MAX11043_device.DecodeCommand(commandByte);
whismanoid 52:607010f0c54e 1092 int regAddress = g_MAX11043_device.RegAddrOfCommand(commandByte);
whismanoid 52:607010f0c54e 1093 cmdLine.serial().printf(" regAddress=0x%2.2x\r\n", (regAddress & 0xFF));
whismanoid 52:607010f0c54e 1094 cmdLine.serial().printf(" RegName=%s\r\n", g_MAX11043_device.RegName(commandByte));
whismanoid 52:607010f0c54e 1095 uint32_t regData = 0;
whismanoid 52:607010f0c54e 1096 int regSize = g_MAX11043_device.RegSize(commandByte);
whismanoid 52:607010f0c54e 1097 cmdLine.serial().printf(" RegSize=%d\r\n", regSize);
whismanoid 52:607010f0c54e 1098 switch(regSize)
whismanoid 52:607010f0c54e 1099 {
whismanoid 52:607010f0c54e 1100 case 8:
whismanoid 52:607010f0c54e 1101 regData = ((uint32_t)mosiData[1] & 0xFF);
whismanoid 52:607010f0c54e 1102 break;
whismanoid 52:607010f0c54e 1103 case 16:
whismanoid 52:607010f0c54e 1104 regData = (((uint32_t)mosiData[1] & 0xFF) << 8) + ((uint32_t)mosiData[2] & 0xFF);
whismanoid 52:607010f0c54e 1105 break;
whismanoid 52:607010f0c54e 1106 case 24:
whismanoid 52:607010f0c54e 1107 regData = (((uint32_t)mosiData[1] & 0xFF) << 16) + (((uint32_t)mosiData[2] & 0xFF) << 8) + ((uint32_t)mosiData[3] & 0xFF);
whismanoid 52:607010f0c54e 1108 break;
whismanoid 52:607010f0c54e 1109 }
whismanoid 57:1c9da8e90737 1110 // CODE GENERATOR: does the chip have a defined CMDOP_1aaa_aaaa_ReadRegister bit?
whismanoid 57:1c9da8e90737 1111 // if ((byteCount == 1) || (regAddress & MAX11043::CMDOP_1aaa_aaaa_ReadRegister))
whismanoid 52:607010f0c54e 1112 if ((byteCount == 1) || g_MAX11043_device.IsRegReadCommand(commandByte))
whismanoid 52:607010f0c54e 1113 {
whismanoid 52:607010f0c54e 1114 cmdLine.serial().printf(" RegRead");
whismanoid 52:607010f0c54e 1115 g_MAX11043_device.RegRead(commandByte, &regData);
whismanoid 52:607010f0c54e 1116 cmdLine.serial().printf("regData=0x%6.6x\r\n", (regData & 0x00FFFFFF));
whismanoid 52:607010f0c54e 1117 }
whismanoid 52:607010f0c54e 1118 else
whismanoid 52:607010f0c54e 1119 {
whismanoid 52:607010f0c54e 1120 cmdLine.serial().printf(" RegWrite regData=0x%6.6X\r\n", (regData & 0x00FFFFFF));
whismanoid 52:607010f0c54e 1121 g_MAX11043_device.RegWrite(commandByte, regData);
whismanoid 52:607010f0c54e 1122 }
whismanoid 52:607010f0c54e 1123 // is there support function shadow regValue of regAddr?
whismanoid 52:607010f0c54e 1124 }
whismanoid 52:607010f0c54e 1125 return true; // command handled by MAX11043
whismanoid 52:607010f0c54e 1126 //
whismanoid 52:607010f0c54e 1127 } // end case '0'..'9','A'..'F','a'..'f'
whismanoid 52:607010f0c54e 1128 break;
whismanoid 52:607010f0c54e 1129 } // end switch (cmdLine[0])
whismanoid 52:607010f0c54e 1130 return false; // command not handled by MAX11043
whismanoid 52:607010f0c54e 1131 } // end bool MAX11043_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 52:607010f0c54e 1132
whismanoid 52:607010f0c54e 1133 // CODE GENERATOR: class declaration statement close