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

Dependencies:   MaximTinyTester MAX11131 CmdLine MAX541 USBDevice

Committer:
whismanoid
Date:
Thu Jul 18 18:39:50 2019 -0700
Revision:
19:8e81fd761a62
Parent:
11:38b95a59de02
MAX32620FTHR support: USBSerial not working yet...

Who changed what in which revision?

UserRevisionLine numberNew contents of line
whismanoid 11:38b95a59de02 1 // /*******************************************************************************
whismanoid 11:38b95a59de02 2 // * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved.
whismanoid 11:38b95a59de02 3 // *
whismanoid 11:38b95a59de02 4 // * Permission is hereby granted, free of charge, to any person obtaining a
whismanoid 11:38b95a59de02 5 // * copy of this software and associated documentation files (the "Software"),
whismanoid 11:38b95a59de02 6 // * to deal in the Software without restriction, including without limitation
whismanoid 11:38b95a59de02 7 // * the rights to use, copy, modify, merge, publish, distribute, sublicense,
whismanoid 11:38b95a59de02 8 // * and/or sell copies of the Software, and to permit persons to whom the
whismanoid 11:38b95a59de02 9 // * Software is furnished to do so, subject to the following conditions:
whismanoid 11:38b95a59de02 10 // *
whismanoid 11:38b95a59de02 11 // * The above copyright notice and this permission notice shall be included
whismanoid 11:38b95a59de02 12 // * in all copies or substantial portions of the Software.
whismanoid 11:38b95a59de02 13 // *
whismanoid 11:38b95a59de02 14 // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
whismanoid 11:38b95a59de02 15 // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
whismanoid 11:38b95a59de02 16 // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
whismanoid 11:38b95a59de02 17 // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
whismanoid 11:38b95a59de02 18 // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
whismanoid 11:38b95a59de02 19 // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
whismanoid 11:38b95a59de02 20 // * OTHER DEALINGS IN THE SOFTWARE.
whismanoid 11:38b95a59de02 21 // *
whismanoid 11:38b95a59de02 22 // * Except as contained in this notice, the name of Maxim Integrated
whismanoid 11:38b95a59de02 23 // * Products, Inc. shall not be used except as stated in the Maxim Integrated
whismanoid 11:38b95a59de02 24 // * Products, Inc. Branding Policy.
whismanoid 11:38b95a59de02 25 // *
whismanoid 11:38b95a59de02 26 // * The mere transfer of this software does not imply any licenses
whismanoid 11:38b95a59de02 27 // * of trade secrets, proprietary technology, copyrights, patents,
whismanoid 11:38b95a59de02 28 // * trademarks, maskwork rights, or any other form of intellectual
whismanoid 11:38b95a59de02 29 // * property whatsoever. Maxim Integrated Products, Inc. retains all
whismanoid 11:38b95a59de02 30 // * ownership rights.
whismanoid 11:38b95a59de02 31 // *******************************************************************************
whismanoid 11:38b95a59de02 32 // */
whismanoid 11:38b95a59de02 33
whismanoid 11:38b95a59de02 34 #include "mbed.h"
whismanoid 11:38b95a59de02 35 #include "MAX11131.h"
whismanoid 11:38b95a59de02 36 #include "CmdLine.h"
whismanoid 11:38b95a59de02 37
whismanoid 11:38b95a59de02 38 //--------------------------------------------------
whismanoid 11:38b95a59de02 39 // tolerate AT commands, which may be sent during probe, such as:
whismanoid 11:38b95a59de02 40 // AT
whismanoid 11:38b95a59de02 41 // AT+CGMI -- request manufacturer identification AT+CMGI=?
whismanoid 11:38b95a59de02 42 // AT+CGMM -- request manufacturer model
whismanoid 11:38b95a59de02 43 // AT%IPSYS?
whismanoid 11:38b95a59de02 44 // ATE0 -- echo disable
whismanoid 11:38b95a59de02 45 // ATV1 -- verbose result codes OK | ERROR | NO CARRIER
whismanoid 11:38b95a59de02 46 // AT+CMEE=1
whismanoid 11:38b95a59de02 47 // ATX4
whismanoid 11:38b95a59de02 48 // AT&C1
whismanoid 11:38b95a59de02 49 // ATE0
whismanoid 11:38b95a59de02 50 // AT+CMEE=1
whismanoid 11:38b95a59de02 51 // AT+GCAP
whismanoid 11:38b95a59de02 52 // ATI
whismanoid 11:38b95a59de02 53 // AT+CPIN?
whismanoid 11:38b95a59de02 54 // AT+CGMM
whismanoid 11:38b95a59de02 55 #ifndef IGNORE_AT_COMMANDS
whismanoid 11:38b95a59de02 56 #define IGNORE_AT_COMMANDS 1
whismanoid 11:38b95a59de02 57 #endif
whismanoid 11:38b95a59de02 58
whismanoid 11:38b95a59de02 59 extern MAX11131 g_MAX11131_device; // defined in main.cpp
whismanoid 11:38b95a59de02 60 extern void AINcode_print_value_externalClock(CmdLine& cmdLine, int nWords); // defined in main.cpp
whismanoid 11:38b95a59de02 61 extern void AINcode_print_value_chanID(CmdLine& cmdLine, int nWords); // defined in main.cpp
whismanoid 11:38b95a59de02 62 extern void AINcode_print_value_chanID_mean(CmdLine& cmdLine, int nWords); // defined in main.cpp
whismanoid 11:38b95a59de02 63 extern void MAX11131_print_register_verbose(CmdLine& cmdLine, int16_t registerData); // defined in main.cpp
whismanoid 11:38b95a59de02 64
whismanoid 11:38b95a59de02 65 bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 11:38b95a59de02 66 {
whismanoid 11:38b95a59de02 67 switch (cmdLine[0])
whismanoid 11:38b95a59de02 68 {
whismanoid 11:38b95a59de02 69 case '0':
whismanoid 11:38b95a59de02 70 {
whismanoid 11:38b95a59de02 71 // recommended for hex command codes 00..0F
whismanoid 11:38b95a59de02 72 // VERIFY: console menu command 0 int16_t MAX11131_ScanRead(void);
whismanoid 11:38b95a59de02 73 // TODO: cmdLine.serial().printf("\r\n 0 n=? -- MAX11131_ScanRead");
whismanoid 11:38b95a59de02 74 if (cmdLine.parse_uint16_dec("n", g_MAX11131_device.NumWords))
whismanoid 11:38b95a59de02 75 {
whismanoid 11:38b95a59de02 76 }
whismanoid 11:38b95a59de02 77 cmdLine.serial().printf("ScanRead NumWords=%d", g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 78 if (g_MAX11131_device.isExternalClock)
whismanoid 11:38b95a59de02 79 {
whismanoid 11:38b95a59de02 80 cmdLine.serial().printf(" External Clock");
whismanoid 11:38b95a59de02 81 //
whismanoid 11:38b95a59de02 82 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 11:38b95a59de02 83 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 11:38b95a59de02 84 g_MAX11131_device.ReadAINcode();
whismanoid 11:38b95a59de02 85 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 11:38b95a59de02 86 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 11:38b95a59de02 87 //
whismanoid 11:38b95a59de02 88 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 89 }
whismanoid 11:38b95a59de02 90 else
whismanoid 11:38b95a59de02 91 {
whismanoid 11:38b95a59de02 92 cmdLine.serial().printf(" Internal Clock");
whismanoid 11:38b95a59de02 93 //
whismanoid 11:38b95a59de02 94 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 11:38b95a59de02 95 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 11:38b95a59de02 96 g_MAX11131_device.ReadAINcode();
whismanoid 11:38b95a59de02 97 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 11:38b95a59de02 98 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 11:38b95a59de02 99 //
whismanoid 11:38b95a59de02 100 AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 101 }
whismanoid 11:38b95a59de02 102 return true; // command was handled by MAX11131
whismanoid 11:38b95a59de02 103 }
whismanoid 11:38b95a59de02 104 break;
whismanoid 11:38b95a59de02 105 case '1':
whismanoid 11:38b95a59de02 106 {
whismanoid 11:38b95a59de02 107 // recommended for hex command codes 10..1F
whismanoid 11:38b95a59de02 108 // VERIFY: console menu command 1 MAX11131_ScanManual(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 11:38b95a59de02 109 // TODO: cmdLine.serial().printf("\r\n 1 ch=? pm=? id=? -- MAX11131_ScanManual");
whismanoid 11:38b95a59de02 110 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 11:38b95a59de02 111 {
whismanoid 11:38b95a59de02 112 }
whismanoid 11:38b95a59de02 113 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 11:38b95a59de02 114 {
whismanoid 11:38b95a59de02 115 }
whismanoid 11:38b95a59de02 116 if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1))
whismanoid 11:38b95a59de02 117 {
whismanoid 11:38b95a59de02 118 }
whismanoid 11:38b95a59de02 119 cmdLine.serial().printf("ScanManual ch=%d pm=%d id=%d\r\n",
whismanoid 11:38b95a59de02 120 g_MAX11131_device.channelNumber_0_15,
whismanoid 11:38b95a59de02 121 g_MAX11131_device.PowerManagement_0_2,
whismanoid 11:38b95a59de02 122 g_MAX11131_device.chan_id_0_1);
whismanoid 11:38b95a59de02 123 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 11:38b95a59de02 124 // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1
whismanoid 11:38b95a59de02 125 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 11:38b95a59de02 126 g_MAX11131_device.NumWords = g_MAX11131_device.ScanManual();
whismanoid 11:38b95a59de02 127 //
whismanoid 11:38b95a59de02 128 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 11:38b95a59de02 129 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 11:38b95a59de02 130 g_MAX11131_device.ReadAINcode();
whismanoid 11:38b95a59de02 131 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 11:38b95a59de02 132 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 11:38b95a59de02 133 //
whismanoid 11:38b95a59de02 134 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 135 return true; // command was handled by MAX11131
whismanoid 11:38b95a59de02 136 }
whismanoid 11:38b95a59de02 137 break;
whismanoid 11:38b95a59de02 138 case '2':
whismanoid 11:38b95a59de02 139 {
whismanoid 11:38b95a59de02 140 // recommended for hex command codes 20..2F
whismanoid 11:38b95a59de02 141 // VERIFY: console menu command 2 int MAX11131_ScanRepeat(uint8_t channelNumber_0_15, uint8_t average_0_4_8_16_32, uint8_t nscan_4_8_12_16, uint8_t PowerManagement_0_2, uint8_t swcnv_0_1);
whismanoid 11:38b95a59de02 142 // TODO: cmdLine.serial().printf("\r\n 2 ch=? av=? n=? pm=? swcnv=? -- MAX11131_ScanRepeat");
whismanoid 11:38b95a59de02 143 // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs
whismanoid 11:38b95a59de02 144 // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs
whismanoid 11:38b95a59de02 145 // VERIFY: update value of g_MAX11131_device.nscan_4_8_12_16 option from strCommandArgs
whismanoid 11:38b95a59de02 146 // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs
whismanoid 11:38b95a59de02 147 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 11:38b95a59de02 148 // VERIFY: parse strCommandArgs for additional arguments including key=value pairs
whismanoid 11:38b95a59de02 149 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 11:38b95a59de02 150 {
whismanoid 11:38b95a59de02 151 }
whismanoid 11:38b95a59de02 152 if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32))
whismanoid 11:38b95a59de02 153 {
whismanoid 11:38b95a59de02 154 }
whismanoid 11:38b95a59de02 155 if (cmdLine.parse_byte_dec("n", g_MAX11131_device.nscan_4_8_12_16))
whismanoid 11:38b95a59de02 156 {
whismanoid 11:38b95a59de02 157 }
whismanoid 11:38b95a59de02 158 if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1))
whismanoid 11:38b95a59de02 159 {
whismanoid 11:38b95a59de02 160 }
whismanoid 11:38b95a59de02 161 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 11:38b95a59de02 162 {
whismanoid 11:38b95a59de02 163 }
whismanoid 11:38b95a59de02 164 cmdLine.serial().printf(
whismanoid 11:38b95a59de02 165 "ScanRepeat ch=%d average_0_4_8_16_32:%d nscan_4_8_12_16:%d swcnv=%d pm=%d\r\n",
whismanoid 11:38b95a59de02 166 g_MAX11131_device.channelNumber_0_15,
whismanoid 11:38b95a59de02 167 g_MAX11131_device.average_0_4_8_16_32,
whismanoid 11:38b95a59de02 168 g_MAX11131_device.nscan_4_8_12_16,
whismanoid 11:38b95a59de02 169 g_MAX11131_device.swcnv_0_1,
whismanoid 11:38b95a59de02 170 g_MAX11131_device.PowerManagement_0_2);
whismanoid 11:38b95a59de02 171 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 11:38b95a59de02 172 // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1
whismanoid 11:38b95a59de02 173 // VERIFY: replace argument with driver global; g_MAX11131_device.nscan_4_8_12_16 replaces nscan_4_8_12_16
whismanoid 11:38b95a59de02 174 // VERIFY: replace argument with driver global; g_MAX11131_device.average_0_4_8_16_32 replaces average_0_4_8_16_32
whismanoid 11:38b95a59de02 175 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 11:38b95a59de02 176 g_MAX11131_device.NumWords = g_MAX11131_device.ScanRepeat();
whismanoid 11:38b95a59de02 177 //
whismanoid 11:38b95a59de02 178 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 11:38b95a59de02 179 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 11:38b95a59de02 180 g_MAX11131_device.ReadAINcode();
whismanoid 11:38b95a59de02 181 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 11:38b95a59de02 182 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 11:38b95a59de02 183 //
whismanoid 11:38b95a59de02 184 AINcode_print_value_chanID_mean(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 185 return true; // command was handled by MAX11131
whismanoid 11:38b95a59de02 186 }
whismanoid 11:38b95a59de02 187 break;
whismanoid 11:38b95a59de02 188 case '3':
whismanoid 11:38b95a59de02 189 {
whismanoid 11:38b95a59de02 190 // recommended for hex command codes 30..3F
whismanoid 11:38b95a59de02 191 // VERIFY: console menu command 3 MAX11131_ScanStandardInternalClock(int channelNumber_0_15, int average_0_4_8_16_32, int PowerManagement_0_2, int swcnv_0_1);
whismanoid 11:38b95a59de02 192 // TODO: cmdLine.serial().printf("\r\n 3 ch=? av=? pm=? swcnv=? -- MAX11131_ScanStandardIntClock");
whismanoid 11:38b95a59de02 193 // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs
whismanoid 11:38b95a59de02 194 // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs
whismanoid 11:38b95a59de02 195 // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs
whismanoid 11:38b95a59de02 196 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 11:38b95a59de02 197 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 11:38b95a59de02 198 {
whismanoid 11:38b95a59de02 199 }
whismanoid 11:38b95a59de02 200 if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32))
whismanoid 11:38b95a59de02 201 {
whismanoid 11:38b95a59de02 202 }
whismanoid 11:38b95a59de02 203 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 11:38b95a59de02 204 {
whismanoid 11:38b95a59de02 205 }
whismanoid 11:38b95a59de02 206 if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1))
whismanoid 11:38b95a59de02 207 {
whismanoid 11:38b95a59de02 208 }
whismanoid 11:38b95a59de02 209 cmdLine.serial().printf("ScanStandardInternalClock ch=%d average_0_4_8_16_32:%d swcnv=%d pm=%d\r\n",
whismanoid 11:38b95a59de02 210 g_MAX11131_device.channelNumber_0_15,
whismanoid 11:38b95a59de02 211 g_MAX11131_device.average_0_4_8_16_32,
whismanoid 11:38b95a59de02 212 g_MAX11131_device.swcnv_0_1,
whismanoid 11:38b95a59de02 213 g_MAX11131_device.PowerManagement_0_2
whismanoid 11:38b95a59de02 214 );
whismanoid 11:38b95a59de02 215 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 11:38b95a59de02 216 // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1
whismanoid 11:38b95a59de02 217 // VERIFY: replace argument with driver global; g_MAX11131_device.average_0_4_8_16_32 replaces average_0_4_8_16_32
whismanoid 11:38b95a59de02 218 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 11:38b95a59de02 219 g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardInternalClock();
whismanoid 11:38b95a59de02 220 //
whismanoid 11:38b95a59de02 221 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 11:38b95a59de02 222 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 11:38b95a59de02 223 g_MAX11131_device.ReadAINcode();
whismanoid 11:38b95a59de02 224 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 11:38b95a59de02 225 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 11:38b95a59de02 226 //
whismanoid 11:38b95a59de02 227 AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 228 return true; // command was handled by MAX11131
whismanoid 11:38b95a59de02 229 }
whismanoid 11:38b95a59de02 230 break;
whismanoid 11:38b95a59de02 231 case '4':
whismanoid 11:38b95a59de02 232 {
whismanoid 11:38b95a59de02 233 // recommended for hex command codes 40..4F
whismanoid 11:38b95a59de02 234 // VERIFY: console menu command 4 MAX11131_ScanStandardExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 11:38b95a59de02 235 // TODO: cmdLine.serial().printf("\r\n 4 ch=? pm=? id=? -- MAX11131_ScanStandardExtClock");
whismanoid 11:38b95a59de02 236 // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs
whismanoid 11:38b95a59de02 237 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 11:38b95a59de02 238 // VERIFY: update value of g_MAX11131_device.chan_id_0_1 option from strCommandArgs
whismanoid 11:38b95a59de02 239 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 11:38b95a59de02 240 {
whismanoid 11:38b95a59de02 241 }
whismanoid 11:38b95a59de02 242 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 11:38b95a59de02 243 {
whismanoid 11:38b95a59de02 244 }
whismanoid 11:38b95a59de02 245 if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1))
whismanoid 11:38b95a59de02 246 {
whismanoid 11:38b95a59de02 247 }
whismanoid 11:38b95a59de02 248 cmdLine.serial().printf("ScanStandardExternalClock ch=%d pm=%d id=%d\r\n",
whismanoid 11:38b95a59de02 249 g_MAX11131_device.channelNumber_0_15,
whismanoid 11:38b95a59de02 250 g_MAX11131_device.PowerManagement_0_2,
whismanoid 11:38b95a59de02 251 g_MAX11131_device.chan_id_0_1
whismanoid 11:38b95a59de02 252 );
whismanoid 11:38b95a59de02 253 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 11:38b95a59de02 254 // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1
whismanoid 11:38b95a59de02 255 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 11:38b95a59de02 256 g_MAX11131_device.NumWords = g_MAX11131_device.ScanStandardExternalClock();
whismanoid 11:38b95a59de02 257 //
whismanoid 11:38b95a59de02 258 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 11:38b95a59de02 259 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 11:38b95a59de02 260 g_MAX11131_device.ReadAINcode();
whismanoid 11:38b95a59de02 261 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 11:38b95a59de02 262 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 11:38b95a59de02 263 //
whismanoid 11:38b95a59de02 264 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 265 return true; // command was handled by MAX11131
whismanoid 11:38b95a59de02 266 }
whismanoid 11:38b95a59de02 267 break;
whismanoid 11:38b95a59de02 268 case '5':
whismanoid 11:38b95a59de02 269 {
whismanoid 11:38b95a59de02 270 // recommended for hex command codes 50..5F
whismanoid 11:38b95a59de02 271 // VERIFY: console menu command 5 MAX11131_ScanUpperInternalClock(int channelNumber_0_15, int average_0_4_8_16_32, int PowerManagement_0_2, int swcnv_0_1);
whismanoid 11:38b95a59de02 272 // TODO: cmdLine.serial().printf("\r\n 5 ch=? av=? pm=? swcnv=? -- MAX11131_ScanUpperIntClock");
whismanoid 11:38b95a59de02 273 // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs
whismanoid 11:38b95a59de02 274 // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs
whismanoid 11:38b95a59de02 275 // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs
whismanoid 11:38b95a59de02 276 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 11:38b95a59de02 277 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 11:38b95a59de02 278 {
whismanoid 11:38b95a59de02 279 }
whismanoid 11:38b95a59de02 280 if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32))
whismanoid 11:38b95a59de02 281 {
whismanoid 11:38b95a59de02 282 }
whismanoid 11:38b95a59de02 283 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 11:38b95a59de02 284 {
whismanoid 11:38b95a59de02 285 }
whismanoid 11:38b95a59de02 286 if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1))
whismanoid 11:38b95a59de02 287 {
whismanoid 11:38b95a59de02 288 }
whismanoid 11:38b95a59de02 289 cmdLine.serial().printf("ScanUpperInternalClock ch=%d average_0_4_8_16_32:%d swcnv=%d pm=%d\r\n",
whismanoid 11:38b95a59de02 290 g_MAX11131_device.channelNumber_0_15,
whismanoid 11:38b95a59de02 291 g_MAX11131_device.average_0_4_8_16_32,
whismanoid 11:38b95a59de02 292 g_MAX11131_device.swcnv_0_1,
whismanoid 11:38b95a59de02 293 g_MAX11131_device.PowerManagement_0_2
whismanoid 11:38b95a59de02 294 );
whismanoid 11:38b95a59de02 295 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 11:38b95a59de02 296 // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1
whismanoid 11:38b95a59de02 297 // VERIFY: replace argument with driver global; g_MAX11131_device.average_0_4_8_16_32 replaces average_0_4_8_16_32
whismanoid 11:38b95a59de02 298 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 11:38b95a59de02 299 g_MAX11131_device.NumWords = g_MAX11131_device.ScanUpperInternalClock();
whismanoid 11:38b95a59de02 300 //
whismanoid 11:38b95a59de02 301 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 11:38b95a59de02 302 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 11:38b95a59de02 303 g_MAX11131_device.ReadAINcode();
whismanoid 11:38b95a59de02 304 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 11:38b95a59de02 305 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 11:38b95a59de02 306 //
whismanoid 11:38b95a59de02 307 AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 308 return true; // command was handled by MAX11131
whismanoid 11:38b95a59de02 309 }
whismanoid 11:38b95a59de02 310 break;
whismanoid 11:38b95a59de02 311 case '6':
whismanoid 11:38b95a59de02 312 {
whismanoid 11:38b95a59de02 313 // recommended for hex command codes 60..6F
whismanoid 11:38b95a59de02 314 // VERIFY: console menu command 6 MAX11131_ScanUpperExternalClock(int channelNumber_0_15, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 11:38b95a59de02 315 // TODO: cmdLine.serial().printf("\r\n 6 ch=? pm=? id=? -- MAX11131_ScanUpperExtClock");
whismanoid 11:38b95a59de02 316 // VERIFY: update value of g_MAX11131_device.channelNumber_0_15 from strCommandArgs
whismanoid 11:38b95a59de02 317 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 11:38b95a59de02 318 // VERIFY: update value of g_MAX11131_device.chan_id_0_1 option from strCommandArgs
whismanoid 11:38b95a59de02 319 if (cmdLine.parse_byte_dec("ch", g_MAX11131_device.channelNumber_0_15))
whismanoid 11:38b95a59de02 320 {
whismanoid 11:38b95a59de02 321 }
whismanoid 11:38b95a59de02 322 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 11:38b95a59de02 323 {
whismanoid 11:38b95a59de02 324 }
whismanoid 11:38b95a59de02 325 if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1))
whismanoid 11:38b95a59de02 326 {
whismanoid 11:38b95a59de02 327 }
whismanoid 11:38b95a59de02 328 cmdLine.serial().printf("ScanUpperExternalClock ch=%d pm=%d id=%d\r\n",
whismanoid 11:38b95a59de02 329 g_MAX11131_device.channelNumber_0_15,
whismanoid 11:38b95a59de02 330 g_MAX11131_device.PowerManagement_0_2,
whismanoid 11:38b95a59de02 331 g_MAX11131_device.chan_id_0_1
whismanoid 11:38b95a59de02 332 );
whismanoid 11:38b95a59de02 333 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 11:38b95a59de02 334 // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1
whismanoid 11:38b95a59de02 335 // VERIFY: replace argument with driver global; g_MAX11131_device.channelNumber_0_15 replaces channelNumber_0_15
whismanoid 11:38b95a59de02 336 g_MAX11131_device.NumWords = g_MAX11131_device.ScanUpperExternalClock();
whismanoid 11:38b95a59de02 337 //
whismanoid 11:38b95a59de02 338 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 11:38b95a59de02 339 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 11:38b95a59de02 340 g_MAX11131_device.ReadAINcode();
whismanoid 11:38b95a59de02 341 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 11:38b95a59de02 342 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 11:38b95a59de02 343 //
whismanoid 11:38b95a59de02 344 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 345 return true; // command was handled by MAX11131
whismanoid 11:38b95a59de02 346 }
whismanoid 11:38b95a59de02 347 break;
whismanoid 11:38b95a59de02 348 case '7':
whismanoid 11:38b95a59de02 349 {
whismanoid 11:38b95a59de02 350 // recommended for hex command codes 70..7F
whismanoid 11:38b95a59de02 351 // VERIFY: console menu command 7 MAX11131_ScanCustomInternalClock(int16_t enabledChannelsMask, int average_0_4_8_16_32, int PowerManagement_0_2, int swcnv_0_1);
whismanoid 11:38b95a59de02 352 // TODO: cmdLine.serial().printf("\r\n 7 enableMask=0xffff av=? pm=? swcnv=? -- MAX11131_ScanCustomIntClock");
whismanoid 11:38b95a59de02 353 // VERIFY: update value of g_MAX11131_device.average_0_4_8_16_32 option from strCommandArgs
whismanoid 11:38b95a59de02 354 // VERIFY: update value of g_MAX11131_device.swcnv_0_1 option from strCommandArgs
whismanoid 11:38b95a59de02 355 // VERIFY: update value of g_MAX11131_device.PowerManagement_0_2 option from strCommandArgs
whismanoid 11:38b95a59de02 356 if (cmdLine.parse_int16_hex("enableMask", g_MAX11131_device.enabledChannelsMask))
whismanoid 11:38b95a59de02 357 {
whismanoid 11:38b95a59de02 358 // TODO1: get g_MAX11131_device.enabledChannelsMask from strCommandArgs
whismanoid 11:38b95a59de02 359 }
whismanoid 11:38b95a59de02 360 if (cmdLine.parse_byte_dec("av", g_MAX11131_device.average_0_4_8_16_32))
whismanoid 11:38b95a59de02 361 {
whismanoid 11:38b95a59de02 362 }
whismanoid 11:38b95a59de02 363 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 11:38b95a59de02 364 {
whismanoid 11:38b95a59de02 365 }
whismanoid 11:38b95a59de02 366 if (cmdLine.parse_byte_dec("swcnv", g_MAX11131_device.swcnv_0_1))
whismanoid 11:38b95a59de02 367 {
whismanoid 11:38b95a59de02 368 }
whismanoid 11:38b95a59de02 369 cmdLine.serial().printf(
whismanoid 11:38b95a59de02 370 "ScanCustomInternalClock enabledChannelsMask:0x%4.4x average_0_4_8_16_32:%d pm=%d swcnv=%d\r\n",
whismanoid 11:38b95a59de02 371 (g_MAX11131_device.enabledChannelsMask & 0xFFFF),
whismanoid 11:38b95a59de02 372 g_MAX11131_device.average_0_4_8_16_32,
whismanoid 11:38b95a59de02 373 g_MAX11131_device.PowerManagement_0_2,
whismanoid 11:38b95a59de02 374 g_MAX11131_device.swcnv_0_1
whismanoid 11:38b95a59de02 375 );
whismanoid 11:38b95a59de02 376 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 11:38b95a59de02 377 // VERIFY: replace argument with driver global; g_MAX11131_device.swcnv_0_1 replaces swcnv_0_1
whismanoid 11:38b95a59de02 378 // VERIFY: replace argument with driver global; g_MAX11131_device.average_0_4_8_16_32 replaces average_0_4_8_16_32
whismanoid 11:38b95a59de02 379 // VERIFY: replace argument with driver global; g_MAX11131_device.enabledChannelsMask replaces enabledChannelsMask
whismanoid 11:38b95a59de02 380 g_MAX11131_device.NumWords = g_MAX11131_device.ScanCustomInternalClock();
whismanoid 11:38b95a59de02 381 //
whismanoid 11:38b95a59de02 382 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 11:38b95a59de02 383 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 11:38b95a59de02 384 g_MAX11131_device.ReadAINcode();
whismanoid 11:38b95a59de02 385 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 11:38b95a59de02 386 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 11:38b95a59de02 387 //
whismanoid 11:38b95a59de02 388 AINcode_print_value_chanID(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 389 return true; // command was handled by MAX11131
whismanoid 11:38b95a59de02 390 }
whismanoid 11:38b95a59de02 391 break;
whismanoid 11:38b95a59de02 392 case '8':
whismanoid 11:38b95a59de02 393 {
whismanoid 11:38b95a59de02 394 // recommended for hex command codes 80..8F
whismanoid 11:38b95a59de02 395 // VERIFY: console menu command 8 MAX11131_ScanCustomExternalClock(int16_t enabledChannelsMask, int PowerManagement_0_2, int chan_id_0_1);
whismanoid 11:38b95a59de02 396 // TODO: cmdLine.serial().printf("\r\n 8 enableMask=0xffff pm=0 id=1 -- MAX11131_ScanCustomExtClock");
whismanoid 11:38b95a59de02 397 if (cmdLine.parse_int16_hex("enableMask", g_MAX11131_device.enabledChannelsMask))
whismanoid 11:38b95a59de02 398 {
whismanoid 11:38b95a59de02 399 // TODO1: get g_MAX11131_device.enabledChannelsMask from strCommandArgs
whismanoid 11:38b95a59de02 400 }
whismanoid 11:38b95a59de02 401 if (cmdLine.parse_byte_dec("pm", g_MAX11131_device.PowerManagement_0_2))
whismanoid 11:38b95a59de02 402 {
whismanoid 11:38b95a59de02 403 }
whismanoid 11:38b95a59de02 404 if (cmdLine.parse_byte_dec("id", g_MAX11131_device.chan_id_0_1))
whismanoid 11:38b95a59de02 405 {
whismanoid 11:38b95a59de02 406 }
whismanoid 11:38b95a59de02 407 cmdLine.serial().printf("ScanCustomExternalClock enabledChannelsMask:0x%4.4x pm=%d id=%d\r\n",
whismanoid 11:38b95a59de02 408 (g_MAX11131_device.enabledChannelsMask & 0xFFFF),
whismanoid 11:38b95a59de02 409 g_MAX11131_device.PowerManagement_0_2,
whismanoid 11:38b95a59de02 410 g_MAX11131_device.chan_id_0_1
whismanoid 11:38b95a59de02 411 );
whismanoid 11:38b95a59de02 412 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 11:38b95a59de02 413 // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1
whismanoid 11:38b95a59de02 414 // VERIFY: replace argument with driver global; g_MAX11131_device.enabledChannelsMask replaces enabledChannelsMask
whismanoid 11:38b95a59de02 415 g_MAX11131_device.NumWords = g_MAX11131_device.ScanCustomExternalClock();
whismanoid 11:38b95a59de02 416 //
whismanoid 11:38b95a59de02 417 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 11:38b95a59de02 418 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 11:38b95a59de02 419 g_MAX11131_device.ReadAINcode();
whismanoid 11:38b95a59de02 420 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 11:38b95a59de02 421 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 11:38b95a59de02 422 //
whismanoid 11:38b95a59de02 423 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 424 return true; // command was handled by MAX11131
whismanoid 11:38b95a59de02 425 }
whismanoid 11:38b95a59de02 426 break;
whismanoid 11:38b95a59de02 427 case '9':
whismanoid 11:38b95a59de02 428 {
whismanoid 11:38b95a59de02 429 // recommended for hex command codes 90..9F
whismanoid 11:38b95a59de02 430 // VERIFY: console menu command 9 MAX11131_ScanSampleSetExternalClock(uint8_t enabledChannelsPatternLength_1_256, int16_t enabledChannelsPattern[], int PowerManagement_0_2, int chan_id_0_1);
whismanoid 11:38b95a59de02 431 // TODO: cmdLine.serial().printf("\r\n 9 channelsPattern... pm=? id=? | len=? -- MAX11131_ScanSampleSetExtClock");
whismanoid 11:38b95a59de02 432 //
whismanoid 11:38b95a59de02 433 // get MAX11131 Sampleset channel selection pattern parse_strCommandArgs(strCommandArgs);
whismanoid 11:38b95a59de02 434 // cmdLine.parse_byteCount_byteList_dec(byteCount, mosiData, MAX_SPI_BYTE_COUNT)
whismanoid 11:38b95a59de02 435 // into g_MAX11131_device.enabledChannelsPatternLength_1_256
whismanoid 11:38b95a59de02 436 // into g_MAX11131_device.enabledChannelsPattern[0..255]
whismanoid 11:38b95a59de02 437 size_t numValues;
whismanoid 11:38b95a59de02 438 char valueList[256];
whismanoid 11:38b95a59de02 439 if (cmdLine.parse_byteCount_byteList_dec( numValues, valueList, 256))
whismanoid 11:38b95a59de02 440 {
whismanoid 11:38b95a59de02 441 // first value is the "9" command itself
whismanoid 11:38b95a59de02 442 g_MAX11131_device.enabledChannelsPatternLength_1_256 = numValues - 1;
whismanoid 11:38b95a59de02 443 // copy valueList[1, ...] into g_MAX11131_device.enabledChannelsPattern[0, ...]
whismanoid 11:38b95a59de02 444 for (size_t index = 0; index < (numValues - 1); index++)
whismanoid 11:38b95a59de02 445 {
whismanoid 11:38b95a59de02 446 g_MAX11131_device.enabledChannelsPattern[index] = valueList[1 + index];
whismanoid 11:38b95a59de02 447 }
whismanoid 11:38b95a59de02 448 }
whismanoid 11:38b95a59de02 449 //
whismanoid 11:38b95a59de02 450 cmdLine.serial().printf("ScanSampleSetExternalClock enabledChannelsPattern:{ ");
whismanoid 11:38b95a59de02 451 int index;
whismanoid 11:38b95a59de02 452 for (index = 0; index < g_MAX11131_device.enabledChannelsPatternLength_1_256; index++)
whismanoid 11:38b95a59de02 453 {
whismanoid 11:38b95a59de02 454 //~ Serial.print( ((g_enabledChannelsPattern[index] >> 4) & 0x000F), DEC);
whismanoid 11:38b95a59de02 455 //~ Serial.print(" ");
whismanoid 11:38b95a59de02 456 cmdLine.serial().printf("AIN%d ", ((g_MAX11131_device.enabledChannelsPattern[index]) & 0x000F));
whismanoid 11:38b95a59de02 457 }
whismanoid 11:38b95a59de02 458 cmdLine.serial().printf("}");
whismanoid 11:38b95a59de02 459 cmdLine.serial().printf(" pm=%d id=%d\r\n", g_MAX11131_device.PowerManagement_0_2,
whismanoid 11:38b95a59de02 460 g_MAX11131_device.chan_id_0_1);
whismanoid 11:38b95a59de02 461 // VERIFY: replace argument with driver global; g_MAX11131_device.PowerManagement_0_2 replaces PowerManagement_0_2
whismanoid 11:38b95a59de02 462 // VERIFY: replace argument with driver global; g_MAX11131_device.chan_id_0_1 replaces chan_id_0_1
whismanoid 11:38b95a59de02 463 g_MAX11131_device.NumWords = g_MAX11131_device.ScanSampleSetExternalClock();
whismanoid 11:38b95a59de02 464 //
whismanoid 11:38b95a59de02 465 // Read raw ADC codes from device into AINcode[] and RAW_misoData16[]
whismanoid 11:38b95a59de02 466 // @pre one of the MAX11311_Scan functions was called, setting g_MAX11131_device.NumWords
whismanoid 11:38b95a59de02 467 g_MAX11131_device.ReadAINcode();
whismanoid 11:38b95a59de02 468 // @post RAW_misoData16[index] contains the raw SPI Master-In,Slave-Out data
whismanoid 11:38b95a59de02 469 // @post AINcode[NUM_CHANNELS] contains the latest readings in LSBs
whismanoid 11:38b95a59de02 470 //
whismanoid 11:38b95a59de02 471 AINcode_print_value_externalClock(cmdLine, g_MAX11131_device.NumWords);
whismanoid 11:38b95a59de02 472 return true; // command was handled by MAX11131
whismanoid 11:38b95a59de02 473 }
whismanoid 11:38b95a59de02 474 break;
whismanoid 11:38b95a59de02 475 case 'a': case 'A':
whismanoid 11:38b95a59de02 476 {
whismanoid 11:38b95a59de02 477 // recommended for hex command codes A0..AF
whismanoid 11:38b95a59de02 478 switch (cmdLine[1])
whismanoid 11:38b95a59de02 479 {
whismanoid 11:38b95a59de02 480 case 't': case 'T':
whismanoid 11:38b95a59de02 481 #if IGNORE_AT_COMMANDS
whismanoid 11:38b95a59de02 482 # if HAS_DAPLINK_SERIAL
whismanoid 11:38b95a59de02 483 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 11:38b95a59de02 484 # endif // HAS_DAPLINK_SERIAL
whismanoid 11:38b95a59de02 485 // AT command: skip the prompt to avoid confusing modem detector
whismanoid 11:38b95a59de02 486 return false; // command not handled
whismanoid 11:38b95a59de02 487 #endif // IGNORE_AT_COMMANDS
whismanoid 11:38b95a59de02 488 }
whismanoid 11:38b95a59de02 489 }
whismanoid 11:38b95a59de02 490 break;
whismanoid 11:38b95a59de02 491 case 'b': case 'B':
whismanoid 11:38b95a59de02 492 {
whismanoid 11:38b95a59de02 493 // recommended for hex command codes B0..BF
whismanoid 11:38b95a59de02 494 }
whismanoid 11:38b95a59de02 495 break;
whismanoid 11:38b95a59de02 496 case 'c': case 'C':
whismanoid 11:38b95a59de02 497 {
whismanoid 11:38b95a59de02 498 // recommended for hex command codes C0..CF
whismanoid 11:38b95a59de02 499 }
whismanoid 11:38b95a59de02 500 break;
whismanoid 11:38b95a59de02 501 case 'd': case 'D':
whismanoid 11:38b95a59de02 502 {
whismanoid 11:38b95a59de02 503 // recommended for hex command codes D0..DF
whismanoid 11:38b95a59de02 504 }
whismanoid 11:38b95a59de02 505 break;
whismanoid 11:38b95a59de02 506 case 'e': case 'E':
whismanoid 11:38b95a59de02 507 {
whismanoid 11:38b95a59de02 508 // recommended for hex command codes E0..EF
whismanoid 11:38b95a59de02 509 }
whismanoid 11:38b95a59de02 510 break;
whismanoid 11:38b95a59de02 511 case 'f': case 'F':
whismanoid 11:38b95a59de02 512 {
whismanoid 11:38b95a59de02 513 // recommended for hex command codes F0..FF
whismanoid 11:38b95a59de02 514 }
whismanoid 11:38b95a59de02 515 break;
whismanoid 11:38b95a59de02 516 case 'x': case 'X':
whismanoid 11:38b95a59de02 517 {
whismanoid 11:38b95a59de02 518 }
whismanoid 11:38b95a59de02 519 break;
whismanoid 11:38b95a59de02 520 case 'y': case 'Y':
whismanoid 11:38b95a59de02 521 {
whismanoid 11:38b95a59de02 522 }
whismanoid 11:38b95a59de02 523 break;
whismanoid 11:38b95a59de02 524 case 'i': case 'I':
whismanoid 11:38b95a59de02 525 {
whismanoid 11:38b95a59de02 526 // TODO: cmdLine.serial().printf("\r\n ISc) IUc) IBc) IRc) reconfigure channel single-ended/unipolar/bipolar/range");
whismanoid 11:38b95a59de02 527 char strChannelId[3];
whismanoid 11:38b95a59de02 528 strChannelId[0] = cmdLine[2];
whismanoid 11:38b95a59de02 529 strChannelId[1] = cmdLine[3];
whismanoid 11:38b95a59de02 530 strChannelId[2] = '\0';
whismanoid 11:38b95a59de02 531 int channelId_0_15 = strtoul(strChannelId, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 11:38b95a59de02 532 switch (cmdLine[1])
whismanoid 11:38b95a59de02 533 {
whismanoid 11:38b95a59de02 534 case 's': case 'S':
whismanoid 11:38b95a59de02 535 g_MAX11131_device.Reconfigure_SingleEnded(channelId_0_15);
whismanoid 11:38b95a59de02 536 break;
whismanoid 11:38b95a59de02 537 case 'u': case 'U':
whismanoid 11:38b95a59de02 538 g_MAX11131_device.Reconfigure_DifferentialUnipolar(channelId_0_15);
whismanoid 11:38b95a59de02 539 break;
whismanoid 11:38b95a59de02 540 case 'b': case 'B':
whismanoid 11:38b95a59de02 541 g_MAX11131_device.Reconfigure_DifferentialBipolarFSVref(channelId_0_15);
whismanoid 11:38b95a59de02 542 break;
whismanoid 11:38b95a59de02 543 case 'r': case 'R':
whismanoid 11:38b95a59de02 544 g_MAX11131_device.Reconfigure_DifferentialBipolarFS2Vref(channelId_0_15);
whismanoid 11:38b95a59de02 545 break;
whismanoid 11:38b95a59de02 546 }
whismanoid 11:38b95a59de02 547 // char cmd1 = strCommandArgs[0];
whismanoid 11:38b95a59de02 548 // strCommandArgs.remove(0, 1); // unsigned int index, unsigned int count
whismanoid 11:38b95a59de02 549 // // get argument int channelId_0_15
whismanoid 11:38b95a59de02 550 // // parse_strCommandArgs(strCommandArgs);
whismanoid 11:38b95a59de02 551 // int channelId_0_15 = strtoul(strCommandArgs.c_str(), NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 11:38b95a59de02 552 // if (cmd1 == 'S') {
whismanoid 11:38b95a59de02 553 // MAX11131_Reconfigure_SingleEnded(channelId_0_15);
whismanoid 11:38b95a59de02 554 // }
whismanoid 11:38b95a59de02 555 // else if (cmd1 == 'U') {
whismanoid 11:38b95a59de02 556 // MAX11131_Reconfigure_DifferentialUnipolar(channelId_0_15);
whismanoid 11:38b95a59de02 557 // }
whismanoid 11:38b95a59de02 558 // else if (cmd1 == 'B') {
whismanoid 11:38b95a59de02 559 // MAX11131_Reconfigure_DifferentialBipolarFSVref(channelId_0_15);
whismanoid 11:38b95a59de02 560 // }
whismanoid 11:38b95a59de02 561 // else if (cmd1 == 'R') {
whismanoid 11:38b95a59de02 562 // MAX11131_Reconfigure_DifferentialBipolarFS2Vref(channelId_0_15);
whismanoid 11:38b95a59de02 563 // }
whismanoid 11:38b95a59de02 564 return true; // command was handled by MAX11131
whismanoid 11:38b95a59de02 565 }
whismanoid 11:38b95a59de02 566 break;
whismanoid 11:38b95a59de02 567 case '@':
whismanoid 11:38b95a59de02 568 {
whismanoid 11:38b95a59de02 569 // TODO: cmdLine.serial().printf("\r\n @ -- print MAX11131 configuration");
whismanoid 11:38b95a59de02 570 // print shadow register configuration
whismanoid 11:38b95a59de02 571 //
whismanoid 11:38b95a59de02 572 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.ADC_MODE_CONTROL & 0xFFFF));
whismanoid 11:38b95a59de02 573 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.ADC_MODE_CONTROL);
whismanoid 11:38b95a59de02 574 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.ADC_CONFIGURATION & 0xFFFF));
whismanoid 11:38b95a59de02 575 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.ADC_CONFIGURATION);
whismanoid 11:38b95a59de02 576 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.UNIPOLAR & 0xFFFF));
whismanoid 11:38b95a59de02 577 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.UNIPOLAR);
whismanoid 11:38b95a59de02 578 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.BIPOLAR & 0xFFFF));
whismanoid 11:38b95a59de02 579 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.BIPOLAR);
whismanoid 11:38b95a59de02 580 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.RANGE & 0xFFFF));
whismanoid 11:38b95a59de02 581 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.RANGE);
whismanoid 11:38b95a59de02 582 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.CSCAN0 & 0xFFFF));
whismanoid 11:38b95a59de02 583 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.CSCAN0);
whismanoid 11:38b95a59de02 584 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.CSCAN1 & 0xFFFF));
whismanoid 11:38b95a59de02 585 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.CSCAN1);
whismanoid 11:38b95a59de02 586 cmdLine.serial().printf("0x%4.4x", (g_MAX11131_device.SAMPLESET & 0xFFFF));
whismanoid 11:38b95a59de02 587 MAX11131_print_register_verbose(cmdLine, g_MAX11131_device.SAMPLESET);
whismanoid 11:38b95a59de02 588 //
whismanoid 11:38b95a59de02 589 // VERIFY: print shadow SAMPLESET pattern entry
whismanoid 11:38b95a59de02 590 int entryIndex;
whismanoid 11:38b95a59de02 591 for (entryIndex = 0; entryIndex < g_MAX11131_device.enabledChannelsPatternLength_1_256;
whismanoid 11:38b95a59de02 592 entryIndex += 4)
whismanoid 11:38b95a59de02 593 {
whismanoid 11:38b95a59de02 594 uint16_t pack4channels = 0;
whismanoid 11:38b95a59de02 595 pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 0]) & 0x0F) << 12);
whismanoid 11:38b95a59de02 596 if ((entryIndex + 1) < g_MAX11131_device.enabledChannelsPatternLength_1_256) {
whismanoid 11:38b95a59de02 597 pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 1]) & 0x0F) << 8);
whismanoid 11:38b95a59de02 598 }
whismanoid 11:38b95a59de02 599 if ((entryIndex + 2) < g_MAX11131_device.enabledChannelsPatternLength_1_256) {
whismanoid 11:38b95a59de02 600 pack4channels |= (((g_MAX11131_device.enabledChannelsPattern[entryIndex + 2]) & 0x0F) << 4);
whismanoid 11:38b95a59de02 601 }
whismanoid 11:38b95a59de02 602 if ((entryIndex + 3) < g_MAX11131_device.enabledChannelsPatternLength_1_256) {
whismanoid 11:38b95a59de02 603 pack4channels |= ((g_MAX11131_device.enabledChannelsPattern[entryIndex + 3]) & 0x0F);
whismanoid 11:38b95a59de02 604 }
whismanoid 11:38b95a59de02 605 //~ SPIwrite16bits(pack4channels);
whismanoid 11:38b95a59de02 606 cmdLine.serial().printf(" 0x%4.4x", (pack4channels & 0xFFFF));
whismanoid 11:38b95a59de02 607 // decode SAMPLESET channel select pattern
whismanoid 11:38b95a59de02 608 cmdLine.serial().printf(" SampleSet Entry: AIN%d AIN%d AIN%d AIN%d\r\n",
whismanoid 11:38b95a59de02 609 ((pack4channels >> 12) & 0x000F),
whismanoid 11:38b95a59de02 610 ((pack4channels >> 8) & 0x000F),
whismanoid 11:38b95a59de02 611 ((pack4channels >> 4) & 0x000F),
whismanoid 11:38b95a59de02 612 ((pack4channels ) & 0x000F)
whismanoid 11:38b95a59de02 613 );
whismanoid 11:38b95a59de02 614 }
whismanoid 11:38b95a59de02 615 //cmdLine.serial().printf(" SAMPLESET enabledChannelsPattern:{ ");
whismanoid 11:38b95a59de02 616 //int index;
whismanoid 11:38b95a59de02 617 //for (index = 0; index < g_MAX11131_device.enabledChannelsPatternLength_1_256; index++)
whismanoid 11:38b95a59de02 618 //{
whismanoid 11:38b95a59de02 619 // //~ cmdLine.serial().printf( ((g_enabledChannelsPattern[index] >> 4) & 0x000F), DEC);
whismanoid 11:38b95a59de02 620 // //~ cmdLine.serial().printf(" ");
whismanoid 11:38b95a59de02 621 // cmdLine.serial().printf("AIN");
whismanoid 11:38b95a59de02 622 // cmdLine.serial().printf( ((g_MAX11131_device.enabledChannelsPattern[index]) & 0x000F), DEC);
whismanoid 11:38b95a59de02 623 // cmdLine.serial().printf(" ");
whismanoid 11:38b95a59de02 624 //}
whismanoid 11:38b95a59de02 625 //cmdLine.serial().printf("}");
whismanoid 11:38b95a59de02 626 //
whismanoid 11:38b95a59de02 627 // Menu @) print MAX11131 configuration AND g_MAX11131_device globals
whismanoid 11:38b95a59de02 628 //
whismanoid 11:38b95a59de02 629 cmdLine.serial().printf("SPI_MOSI_Semantic=%d\r\n", (g_MAX11131_device.SPI_MOSI_Semantic & 0xFFFF));
whismanoid 11:38b95a59de02 630 cmdLine.serial().printf("NumWords=%d\r\n", (g_MAX11131_device.NumWords & 0xFFFF));
whismanoid 11:38b95a59de02 631 cmdLine.serial().printf("isExternalClock=%d\r\n", (g_MAX11131_device.isExternalClock & 0xFFFF));
whismanoid 11:38b95a59de02 632 cmdLine.serial().printf("ScanMode=%d\r\n", (g_MAX11131_device.ScanMode & 0xFFFF));
whismanoid 11:38b95a59de02 633 cmdLine.serial().printf("channelNumber_0_15=%d\r\n",
whismanoid 11:38b95a59de02 634 (g_MAX11131_device.channelNumber_0_15 & 0xFFFF));
whismanoid 11:38b95a59de02 635 cmdLine.serial().printf("PowerManagement_0_2=%d\r\n",
whismanoid 11:38b95a59de02 636 (g_MAX11131_device.PowerManagement_0_2 & 0xFFFF));
whismanoid 11:38b95a59de02 637 cmdLine.serial().printf("chan_id_0_1=%d\r\n", (g_MAX11131_device.chan_id_0_1 & 0xFFFF));
whismanoid 11:38b95a59de02 638 cmdLine.serial().printf("average_0_4_8_16_32=%d\r\n",
whismanoid 11:38b95a59de02 639 (g_MAX11131_device.average_0_4_8_16_32 & 0xFFFF));
whismanoid 11:38b95a59de02 640 cmdLine.serial().printf("nscan_4_8_12_16=%d\r\n", (g_MAX11131_device.nscan_4_8_12_16 & 0xFFFF));
whismanoid 11:38b95a59de02 641 cmdLine.serial().printf("swcnv_0_1=%d\r\n", (g_MAX11131_device.swcnv_0_1 & 0xFFFF));
whismanoid 11:38b95a59de02 642 cmdLine.serial().printf("enabledChannelsMask=0x%4.4x\r\n",
whismanoid 11:38b95a59de02 643 (g_MAX11131_device.enabledChannelsMask & 0xFFFF));
whismanoid 11:38b95a59de02 644 //
whismanoid 11:38b95a59de02 645 cmdLine.serial().printf("VRef=%5.3fV\r\n", g_MAX11131_device.VRef);
whismanoid 11:38b95a59de02 646 // dtostrf width and precision: 3.3V / 1024 LSB = 0.00322265625 volts per LSB
whismanoid 11:38b95a59de02 647 //
whismanoid 11:38b95a59de02 648 return true; // command was handled by MAX11131
whismanoid 11:38b95a59de02 649 }
whismanoid 11:38b95a59de02 650 //case '&':
whismanoid 11:38b95a59de02 651 //{
whismanoid 11:38b95a59de02 652 // // TODO: cmdLine.serial().printf("\r\n & -- MAX11131_Example_ScanManual");
whismanoid 11:38b95a59de02 653 //}
whismanoid 11:38b95a59de02 654 break;
whismanoid 11:38b95a59de02 655 case '~': // TODO: IGNORE_AT_COMMANDS -- ignore ~~~ modem command
whismanoid 11:38b95a59de02 656 {
whismanoid 11:38b95a59de02 657 // TODO: '~' is not recommended for menu commands, interferes with ssh
whismanoid 11:38b95a59de02 658 #if IGNORE_AT_COMMANDS
whismanoid 11:38b95a59de02 659 # if HAS_DAPLINK_SERIAL
whismanoid 11:38b95a59de02 660 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 11:38b95a59de02 661 # endif // HAS_DAPLINK_SERIAL
whismanoid 11:38b95a59de02 662 #endif // IGNORE_AT_COMMANDS
whismanoid 11:38b95a59de02 663 }
whismanoid 11:38b95a59de02 664 break;
whismanoid 11:38b95a59de02 665 case '+': // TODO: IGNORE_AT_COMMANDS -- ignore +++ modem command
whismanoid 11:38b95a59de02 666 {
whismanoid 11:38b95a59de02 667 #if IGNORE_AT_COMMANDS
whismanoid 11:38b95a59de02 668 # if HAS_DAPLINK_SERIAL
whismanoid 11:38b95a59de02 669 cmdLine_DAPLINKserial.serial().printf("\r\n ignore AT command \"%s\"\r\n", cmdLine.str());
whismanoid 11:38b95a59de02 670 # endif // HAS_DAPLINK_SERIAL
whismanoid 11:38b95a59de02 671 #endif // IGNORE_AT_COMMANDS
whismanoid 11:38b95a59de02 672 }
whismanoid 11:38b95a59de02 673 break;
whismanoid 11:38b95a59de02 674 } // end switch (cmdLine[0])
whismanoid 11:38b95a59de02 675 return false; // command not handled
whismanoid 11:38b95a59de02 676 } // end bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 11:38b95a59de02 677