Internal_Datalogger but with USB support removed (for MAX40108 Demo board), proof of concept that MAX32625 can be used successfully with VDDB(USB) left unpowered, as long as the USB library is not used.

Dependencies:   max32625pico CmdLine

Revision:
28:a9a3a9db592b
Parent:
27:b4ac095b83b3
Child:
29:6a9edb6e973b
diff -r b4ac095b83b3 -r a9a3a9db592b DataLogger_Internal.cpp
--- a/DataLogger_Internal.cpp	Sun Apr 25 02:31:08 2021 -0700
+++ b/DataLogger_Internal.cpp	Mon Apr 26 16:45:02 2021 -0700
@@ -1,5 +1,5 @@
 // /*******************************************************************************
-// * Copyright (C) 2020 Maxim Integrated Products, Inc., All Rights Reserved.
+// * Copyright (C) 2021 Maxim Integrated Products, Inc., All Rights Reserved.
 // *
 // * Permission is hereby granted, free of charge, to any person obtaining a
 // * copy of this software and associated documentation files (the "Software"),
@@ -2810,6 +2810,12 @@
 }
 #endif // USE_CMDLINE_MENUS support CmdLine command menus
 
+//--------------------------------------------------
+#ifndef USE_DATALOGGER_TRIGGER_HELP_BRIEF
+#define USE_DATALOGGER_TRIGGER_HELP_BRIEF 1
+//~ #undef USE_DATALOGGER_TRIGGER_HELP_BRIEF
+#endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
+
 #if USE_CMDLINE_MENUS // support CmdLine command menus
 //--------------------------------------------------
 void main_menu_help(CmdLine & cmdLine)
@@ -2875,6 +2881,23 @@
 #endif // USE_AUX_SERIAL_CMD_FORWARDING
 //
 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
+#if USE_DATALOGGER_TRIGGER_HELP_BRIEF
+    // Datalog trigger menu
+    // brief toplevel heading for datalog help L
+    // L -- detailed help for datalog commands
+    cmdLine.serial().printf("\r\n L -- halt the datalogger; show more commands");
+    // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
+    // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
+    // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
+    //
+    // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
+    cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
+    //
+    cmdLine.serial().printf("\r\n LT count=%d base=%dms -- Datalog timer", g_timer_interval_count, g_timer_interval_msec); // trigger_Timer
+#if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
+    //~ cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
+#endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
+#else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
     // TODO Datalog trigger menu
     // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
     // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
@@ -2899,7 +2922,7 @@
 #endif // USE_DATALOGGER_SPIDeviceRegRead
     //
 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
-    cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table");
+    cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
     //
 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
@@ -2954,7 +2977,10 @@
     cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
 #endif // LOG_PLATFORM_ANALOG_IN_LSB
 #endif // defined(LOG_PLATFORM_AIN)
+#endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
+#if USE_DATALOGGER_TRIGGER_HELP_BRIEF
+#else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
 # if HAS_AUX_SERIAL
     cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
 # endif // HAS_AUX_SERIAL
@@ -2962,6 +2988,7 @@
     cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
 # endif // HAS_DAPLINK_SERIAL
     cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
+#endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
     //
     //cmdLine.serial().print(F("\r\n ! -- Initial Configuration"));
     //
@@ -3211,11 +3238,19 @@
                                 // get row number to edit from cmdLine[4]
                                 editRowIndex = atoi(cmdLine.str()+4);
                                 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
-                                    // update row
-                                    cmdLine.serial().printf("\r\n replace row %d with \"%s\"",
-                                        editRowIndex, cmdLine.str()+argIndex);
-                                    strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
-                                    command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0';
+                                    // avoid replacing with null because that would truncate the table
+                                    if (*(cmdLine.str()+argIndex)=='\0') {
+                                        cmdLine.serial().printf("\r\n cannot replace row %d with nothing",
+                                            editRowIndex);
+                                    }
+                                    else
+                                    {
+                                        // update row
+                                        cmdLine.serial().printf("\r\n replace row %d with \"%s\"",
+                                            editRowIndex, cmdLine.str()+argIndex);
+                                        strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
+                                        command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
+                                    }
                                 }
                             }
                             break;
@@ -3225,11 +3260,20 @@
                             if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
                                 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
                                 editRowIndex = command_table_row_count;
-                                command_table_row_count++;
-                                cmdLine.serial().printf("\r\n add new row %d containing \"%s\"",
-                                    editRowIndex, cmdLine.str()+argIndex);
-                                strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
-                                command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0';
+                                // avoid replacing with null because that would truncate the table
+                                if (*(cmdLine.str()+argIndex)=='\0') {
+                                    cmdLine.serial().printf("\r\n cannot add new row %d containing nothing",
+                                        editRowIndex);
+                                }
+                                else
+                                {
+                                    command_table_row_count++;
+                                    cmdLine.serial().printf("\r\n add new row %d containing \"%s\"",
+                                        editRowIndex, cmdLine.str()+argIndex);
+                                    strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
+                                    command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
+                                    command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
+                                }
                             }
                             break;
                         case '-':
@@ -3241,7 +3285,7 @@
                                     // %B1@-~~~ clear entire command table
                                     cmdLine.serial().printf("\r\n clear entire command table");
                                     command_table_row_count = 0;
-                                    command_table[command_table_row_count][0] =  '\0';
+                                    command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
                                     break;
                                 }
                                 else
@@ -3257,10 +3301,10 @@
                                             cmdLine.serial().printf("\r\n copy row %d into row %d: \"%s\"",
                                                 i+1, i, command_table[i+1]);
                                             strncpy(command_table[i], command_table[i+1], COMMAND_TABLE_COL_MAX-1);
-                                            command_table[i][COMMAND_TABLE_COL_MAX-1]='\0';
+                                            command_table[i][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
                                         }
                                         command_table_row_count--;
-                                        command_table[command_table_row_count][0] =  '\0';
+                                        command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
                                     }
                                 }
                             }
@@ -4558,6 +4602,98 @@
                             break;
                     }
                     break; // case '>' L>S serial enable toggle
+            default:
+                // TODO: L -- detailed help for datalog commands
+                //
+#if USE_DATALOGGER_TRIGGER // support Datalog trigger
+#if 1 // USE_DATALOGGER_TRIGGER_HELP_BRIEF
+                // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
+                cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
+                //
+                // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
+                //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
+                cmdLine.serial().printf("\r\n LT count=%d base=%dms -- Datalog timer", g_timer_interval_count, g_timer_interval_msec); // trigger_Timer
+                //
+                // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
+                //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
+                // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
+                // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
+                //
+#if USE_DATALOGGER_SPIDeviceRegRead
+                // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
+                //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
+                cmdLine.serial().printf("\r\n L$ count=10 base=500ms addr=xxx data=xxx mask=xxx -- Datalog when SPI read of address matches mask"); // trigger_SPIDeviceRegRead
+#endif // USE_DATALOGGER_SPIDeviceRegRead
+                //
+#if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
+                cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
+#endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
+                //
+                //
+#if defined(SPI_ADC_DeviceName) // SPI connected ADC
+                // LS<channel ID><verb>: Configure SPI_AIN channels
+                // channel ID: 0,1,2,... or - for all channels
+                // verb: D for disable, V for Voltage, L for LSB
+                cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
+                cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
+                cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
+                cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
+                cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
+                cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
+                //
+                // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
+                // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
+                cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
+                //
+                // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
+                // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
+                cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");    
+                //
+                // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
+                // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
+                // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
+                cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
+                // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
+                cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
+                // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
+                //
+                // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
+                // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
+                cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
+                //
+#endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
+                //
+#if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
+                // LA<channel ID><verb>: Configure Platform_AIN channels
+                // channel ID: 0,1,2,... or - for all channels
+                // verb: D for disable, V for Voltage, L for LSB
+                cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
+#if LOG_PLATFORM_ANALOG_IN_VOLTS
+                cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
+#endif // LOG_PLATFORM_ANALOG_IN_VOLTS
+#if LOG_PLATFORM_ANALOG_IN_LSB
+                cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
+#endif // LOG_PLATFORM_ANALOG_IN_LSB
+                cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
+#if LOG_PLATFORM_ANALOG_IN_VOLTS
+                cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
+#endif // LOG_PLATFORM_ANALOG_IN_VOLTS
+#if LOG_PLATFORM_ANALOG_IN_LSB
+                cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
+#endif // LOG_PLATFORM_ANALOG_IN_LSB
+#endif // defined(LOG_PLATFORM_AIN)
+#endif // USE_DATALOGGER_TRIGGER support Datalog trigger
+# if HAS_AUX_SERIAL
+                cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
+# endif // HAS_AUX_SERIAL
+# if HAS_DAPLINK_SERIAL
+                cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
+# endif // HAS_DAPLINK_SERIAL
+                cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
+                //
+#else // USE_DATALOGGER_TRIGGER_HELP_BRIEF
+#endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
+                break;
             } // switch (cmdLine[1]) inside case 'L'
         }
         break;         // case 'L'