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 02:07:45 2020 +0000
Revision:
85:a47ed024c508
Parent:
84:11cc360628a1
Child:
86:c116654dfa32
Threaded Read 4 command -- CONVRUN pulsed HL, ignore EOC. WIP: thresholds. Min/Max detect not working.

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