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:
47:f1a56afb4aca
Parent:
46:469d0061df5d
Child:
48:18647e0516f2
--- a/DataLogger_Internal.cpp	Wed Oct 27 22:00:21 2021 -0700
+++ b/DataLogger_Internal.cpp	Fri Oct 29 23:05:44 2021 -0700
@@ -84,6 +84,7 @@
 #include "Board_Calibration_Data.h"
 
 #ifdef BOARD_SERIAL_NUMBER
+uint32_t g_board_serial_number = 0xFFFFFFFF; // BOARD_SERIAL_NUMBER;
 // data unique to certain boards based on serial number
 # if          (BOARD_SERIAL_NUMBER) == 0
     #warning "(BOARD_SERIAL_NUMBER) == 0"
@@ -111,6 +112,7 @@
 # endif
 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
     #warning "BOARD_SERIAL_NUMBER not defined; using default values"
+uint32_t g_board_serial_number = 0xFFFFFFFF;
 //
 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
 //---------- CODE GENERATOR: DataLogHelloCppCodeList
@@ -215,7 +217,71 @@
 // error: 'FlashIAP' does not name a type
 //--------------------------------------------------
 // MAX40108 calibration values assign absolute address 
-const char flash_page_configuration_back_up[8192] __attribute__((aligned(8192))) = {0};
+const char flash_page_configuration_back_up[8192] __attribute__((aligned(8192))) = {
+    // 0x04000053, 0xffffffff, 0xffffffff, 0xffffffff, // g_board_serial_number is blank 0xFFFFFFFF
+    0x53, 0x00, 0x00, 0x04,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, // 0x04000053 g_board_serial_number is blank 0xFFFFFFFF
+    0x53, 0x10, 0x00, 0x08,     0x21, 0xbc, 0x15, 0x40,     0x33, 0x33, 0xd3, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08001053 calibration_05_V[0]
+    0x53, 0x11, 0x00, 0x08,     0x21, 0xbc, 0x15, 0x40,     0x33, 0x33, 0xd3, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08001153 calibration_05_V[1]
+    0x53, 0x12, 0x00, 0x08,     0x21, 0xbc, 0x15, 0x40,     0x33, 0x33, 0xd3, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08001253 calibration_05_V[2]
+    0x53, 0x13, 0x00, 0x08,     0x21, 0xbc, 0x15, 0x40,     0x33, 0x33, 0xd3, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08001353 calibration_05_V[3]
+    0x53, 0x14, 0x00, 0x08,     0xdf, 0x43, 0xea, 0xbf,     0xcc, 0xcc, 0xec, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08001453 calibration_05_V[4]
+    0x53, 0x15, 0x00, 0x08,     0xdf, 0x43, 0xea, 0xbf,     0xcc, 0xcc, 0xec, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08001553 calibration_05_V[5]
+    0x53, 0x20, 0x00, 0x08,     0x06, 0xb8, 0x11, 0x30,     0x69, 0x15, 0xd0, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08002053 calibration_05_normValue_0_1[0]
+    0x53, 0x21, 0x00, 0x08,     0x06, 0xb8, 0x11, 0x30,     0x69, 0x15, 0xd0, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08002153 calibration_05_normValue_0_1[1]
+    0x53, 0x22, 0x00, 0x08,     0x06, 0xb8, 0x11, 0x30,     0x69, 0x15, 0xd0, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08002253 calibration_05_normValue_0_1[2]
+    0x53, 0x23, 0x00, 0x08,     0x06, 0xb8, 0x11, 0x30,     0x69, 0x15, 0xd0, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08002353 calibration_05_normValue_0_1[3]
+    0x53, 0x24, 0x00, 0x08,     0x3d, 0x1e, 0xac, 0x5f,     0xe6, 0x84, 0xc3, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08002453 calibration_05_normValue_0_1[4]
+    0x53, 0x25, 0x00, 0x08,     0x3d, 0x1e, 0xac, 0x5f,     0xe6, 0x84, 0xc3, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08002553 calibration_05_normValue_0_1[5]
+    0x53, 0x30, 0x00, 0x08,     0xdf, 0x43, 0xea, 0xbf,     0xcc, 0xcc, 0xec, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08003053 calibration_95_V[0]
+    0x53, 0x31, 0x00, 0x08,     0xdf, 0x43, 0xea, 0xbf,     0xcc, 0xcc, 0xec, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08003153 calibration_95_V[1]
+    0x53, 0x32, 0x00, 0x08,     0xdf, 0x43, 0xea, 0xbf,     0xcc, 0xcc, 0xec, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08003253 calibration_95_V[2]
+    0x53, 0x33, 0x00, 0x08,     0xdf, 0x43, 0xea, 0xbf,     0xcc, 0xcc, 0xec, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08003353 calibration_95_V[3]
+    0x53, 0x34, 0x00, 0x08,     0xef, 0x21, 0xf5, 0x5f,     0x66, 0x66, 0x0a, 0x40,     0xff, 0xff, 0xff, 0xff, // 0x08003453 calibration_95_V[4]
+    0x53, 0x35, 0x00, 0x08,     0xef, 0x21, 0xf5, 0x5f,     0x66, 0x66, 0x0a, 0x40,     0xff, 0xff, 0xff, 0xff, // 0x08003553 calibration_95_V[5]
+    0x53, 0x40, 0x00, 0x08,     0xc2, 0xe5, 0x37, 0xa0,     0x33, 0x16, 0xe8, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08004053 calibration_95_normValue_0_1[0]
+    0x53, 0x41, 0x00, 0x08,     0xc2, 0xe5, 0x37, 0xa0,     0x33, 0x16, 0xe8, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08004153 calibration_95_normValue_0_1[1]
+    0x53, 0x42, 0x00, 0x08,     0xc2, 0xe5, 0x37, 0xa0,     0x33, 0x16, 0xe8, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08004253 calibration_95_normValue_0_1[2]
+    0x53, 0x43, 0x00, 0x08,     0xc2, 0xe5, 0x37, 0xa0,     0x33, 0x16, 0xe8, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08004353 calibration_95_normValue_0_1[3]
+    0x53, 0x44, 0x00, 0x08,     0xe5, 0xc8, 0xf8, 0x67,     0x6e, 0xb4, 0xe1, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08004453 calibration_95_normValue_0_1[4]
+    0x53, 0x45, 0x00, 0x08,     0xe5, 0xc8, 0xf8, 0x67,     0x6e, 0xb4, 0xe1, 0x3f,     0xff, 0xff, 0xff, 0xff, // 0x08004553 calibration_95_normValue_0_1[5]
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, // 0xffffffff blank space to permit saving more data
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff, 
+    0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff,     0xff, 0xff, 0xff, 0xff
+};
 // WIP #312 map values in flash_page_configuration_back_up[]
 // such as board serial number, %A calibration values,
 // business logic, button handlers, etc.
@@ -285,17 +351,17 @@
     //
     //{ 0x00010000, 0x0007FFFF, "FLASH", 5 }, // flash pages 8-62
     // Future: separate FLASH pages, allow flashPoke only on the calibration page
-    { 0x00010000, 0x00011FFF, "FLA08", 1 }, // flash page  8
-    { 0x00012000, 0x00013FFF, "FLA09", 1 }, // flash page  9
-    { 0x00014000, 0x00015FFF, "FLA10", 1 }, // flash page 10
-    { 0x00016000, 0x00017FFF, "FLA11", 1 }, // flash page 11
-    { 0x00018000, 0x00019FFF, "FLA12", 1 }, // flash page 12
-    { 0x0001A000, 0x0001BFFF, "FLA13", 1 }, // flash page 13
-    { 0x0001C000, 0x0001DFFF, "FLA14", 1 }, // flash page 14
-    { 0x0001E000, 0x0001FFFF, "FLA15", 1 }, // flash page 15
+    { 0x00010000, 0x00011FFF, "FLA08", 5 }, // flash page  8
+    { 0x00012000, 0x00013FFF, "FLA09", 5 }, // flash page  9
+    { 0x00014000, 0x00015FFF, "FLA10", 5 }, // flash page 10
+    { 0x00016000, 0x00017FFF, "FLA11", 5 }, // flash page 11
+    { 0x00018000, 0x00019FFF, "FLA12", 5 }, // flash page 12
+    { 0x0001A000, 0x0001BFFF, "FLA13", 5 }, // flash page 13
+    { 0x0001C000, 0x0001DFFF, "FLA14", 5 }, // flash page 14
+    { 0x0001E000, 0x0001FFFF, "FLA15", 5 }, // flash page 15
     //
-    { 0x00020000, 0x00021FFF, "FLA16", 1 }, // flash page 16
-    { 0x00022000, 0x00023FFF, "FLA17", 1 }, // flash page 17
+    { 0x00020000, 0x00021FFF, "FLA16", 5 }, // flash page 16
+    { 0x00022000, 0x00023FFF, "FLA17", 5 }, // flash page 17
     { 0x00024000, 0x00025FFF, "FLA18", 5 }, // flash page 18
     { 0x00026000, 0x00027FFF, "FLA19", 5 }, // flash page 19
     { 0x00028000, 0x00029FFF, "FLA20", 5 }, // flash page 20
@@ -2508,6 +2574,13 @@
 } configuration_back_up_t;
 configuration_back_up_t configuration_back_up_list[] = {
     { 0xFFFFFFFF, NULL, 0, "blank" }, // Ignore 0xFFFFFFFF blank records
+    //
+#ifdef BOARD_SERIAL_NUMBER
+    // WIP #312 flash load/save g_board_serial_number BOARD_SERIAL_NUMBER
+    { 0x04000053, &g_board_serial_number,           sizeof(g_board_serial_number            ), "g_board_serial_number" },
+#endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
+    // WIP #312 flash load/save board ID string message
+    //
     { 0x08001053, &calibration_05_V[0],             sizeof(calibration_05_V[0]              ), "calibration_05_V[0]" },
     { 0x08001153, &calibration_05_V[1],             sizeof(calibration_05_V[1]              ), "calibration_05_V[1]" },
     { 0x08001253, &calibration_05_V[2],             sizeof(calibration_05_V[2]              ), "calibration_05_V[2]" },
@@ -2532,12 +2605,15 @@
     { 0x08004353, &calibration_95_normValue_0_1[3], sizeof(calibration_95_normValue_0_1[3]  ), "calibration_95_normValue_0_1[3]" },
     { 0x08004453, &calibration_95_normValue_0_1[4], sizeof(calibration_95_normValue_0_1[4]  ), "calibration_95_normValue_0_1[4]" },
     { 0x08004553, &calibration_95_normValue_0_1[5], sizeof(calibration_95_normValue_0_1[5]  ), "calibration_95_normValue_0_1[5]" },
+    //
     // WIP #312 @L Datalogger_action_table_row_count
     // WIP #312 @L Datalogger_action_table_enabled
     // WIP #312 @L Datalogger_action_table[0] __ bytes
     // WIP #312 @L Datalogger_action_table[0] __ bytes
+    //
     // WIP #312 %B onButton1_command_table[0] __ bytes
     // WIP #312 %B onButton9_command_table[0] __ bytes
+    //
     { 0x00000000, NULL, 0, "wiped" }, // Ignore 0x00000000 wiped records; end of table
 };
 // WIP #312 store values into flash_page_configuration_back_up[] from calibration_05_V[] etc. Default save everything.
@@ -3812,7 +3888,7 @@
     cmdLine.serial().printf(" MAX40108_U%d", MAX40108_DEMO);
 #ifdef BOARD_SERIAL_NUMBER
 // data unique to certain boards based on serial number
-    cmdLine.serial().printf(" [s/n %d]", BOARD_SERIAL_NUMBER);
+    cmdLine.serial().printf(" [s/n %d]", g_board_serial_number);
 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
     #warning "BOARD_SERIAL_NUMBER not defined; using default values"
 //
@@ -6877,7 +6953,7 @@
     cmdLine.serial().printf("\r\n\r\n\"MAX40108_U%d", MAX40108_DEMO);
 #ifdef BOARD_SERIAL_NUMBER
 // data unique to certain boards based on serial number
-    cmdLine.serial().printf(" [s/n %d]", BOARD_SERIAL_NUMBER);
+    cmdLine.serial().printf(" [s/n %d]", g_board_serial_number);
 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
 #ifdef FW_REV
     cmdLine.serial().printf(" [FW_REV %d]", FW_REV);