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

Committer:
whismanoid
Date:
Fri Nov 05 12:10:41 2021 -0700
Revision:
51:a41d3fd5e441
Parent:
50:f42de27fc652
Child:
52:bb09c0f452ec
Flash load/save Datalogger_action_table and button handlers

Who changed what in which revision?

UserRevisionLine numberNew contents of line
whismanoid 0:cb44e2e9ec4c 1 // /*******************************************************************************
whismanoid 28:a9a3a9db592b 2 // * Copyright (C) 2021 Maxim Integrated Products, Inc., All Rights Reserved.
whismanoid 0:cb44e2e9ec4c 3 // *
whismanoid 0:cb44e2e9ec4c 4 // * Permission is hereby granted, free of charge, to any person obtaining a
whismanoid 0:cb44e2e9ec4c 5 // * copy of this software and associated documentation files (the "Software"),
whismanoid 0:cb44e2e9ec4c 6 // * to deal in the Software without restriction, including without limitation
whismanoid 0:cb44e2e9ec4c 7 // * the rights to use, copy, modify, merge, publish, distribute, sublicense,
whismanoid 0:cb44e2e9ec4c 8 // * and/or sell copies of the Software, and to permit persons to whom the
whismanoid 0:cb44e2e9ec4c 9 // * Software is furnished to do so, subject to the following conditions:
whismanoid 0:cb44e2e9ec4c 10 // *
whismanoid 0:cb44e2e9ec4c 11 // * The above copyright notice and this permission notice shall be included
whismanoid 0:cb44e2e9ec4c 12 // * in all copies or substantial portions of the Software.
whismanoid 0:cb44e2e9ec4c 13 // *
whismanoid 0:cb44e2e9ec4c 14 // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
whismanoid 0:cb44e2e9ec4c 15 // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
whismanoid 0:cb44e2e9ec4c 16 // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
whismanoid 0:cb44e2e9ec4c 17 // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
whismanoid 0:cb44e2e9ec4c 18 // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
whismanoid 0:cb44e2e9ec4c 19 // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
whismanoid 0:cb44e2e9ec4c 20 // * OTHER DEALINGS IN THE SOFTWARE.
whismanoid 0:cb44e2e9ec4c 21 // *
whismanoid 0:cb44e2e9ec4c 22 // * Except as contained in this notice, the name of Maxim Integrated
whismanoid 0:cb44e2e9ec4c 23 // * Products, Inc. shall not be used except as stated in the Maxim Integrated
whismanoid 0:cb44e2e9ec4c 24 // * Products, Inc. Branding Policy.
whismanoid 0:cb44e2e9ec4c 25 // *
whismanoid 0:cb44e2e9ec4c 26 // * The mere transfer of this software does not imply any licenses
whismanoid 0:cb44e2e9ec4c 27 // * of trade secrets, proprietary technology, copyrights, patents,
whismanoid 0:cb44e2e9ec4c 28 // * trademarks, maskwork rights, or any other form of intellectual
whismanoid 0:cb44e2e9ec4c 29 // * property whatsoever. Maxim Integrated Products, Inc. retains all
whismanoid 0:cb44e2e9ec4c 30 // * ownership rights.
whismanoid 0:cb44e2e9ec4c 31 // *******************************************************************************
whismanoid 0:cb44e2e9ec4c 32 // */
whismanoid 0:cb44e2e9ec4c 33 // *******************************************************************************
whismanoid 0:cb44e2e9ec4c 34 // COM port settings are 9600 baud 8N1
whismanoid 0:cb44e2e9ec4c 35 // *******************************************************************************
whismanoid 19:5ff09c8e9daf 36 // Support custom target MAX40108DEMOP2U9 based on MAX32625PICO but MAX32625_NO_BOOT
whismanoid 19:5ff09c8e9daf 37 // file custom_targets.json:
whismanoid 19:5ff09c8e9daf 38 // {
whismanoid 19:5ff09c8e9daf 39 // "MAX40108DEMOP2U9": {
whismanoid 19:5ff09c8e9daf 40 // "inherits": ["MAX32625_BASE"],
whismanoid 19:5ff09c8e9daf 41 // "macros_remove": [],
whismanoid 19:5ff09c8e9daf 42 // "macros_add": ["MAX32625_NO_BOOT"]
whismanoid 19:5ff09c8e9daf 43 // }
whismanoid 19:5ff09c8e9daf 44 // }
whismanoid 19:5ff09c8e9daf 45 // files copied from mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\TARGET_MAX32625PICO
whismanoid 19:5ff09c8e9daf 46 // file TARGET_MAX40108DEMOP2U9\PeripheralNames.h -- copied from TARGET_MAX32625PICO
whismanoid 19:5ff09c8e9daf 47 // file TARGET_MAX40108DEMOP2U9\PinNames.h -- copied from TARGET_MAX32625PICO
whismanoid 19:5ff09c8e9daf 48 // files copied from mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\device\___\TARGET_MAX32625_NO_BOOT
whismanoid 19:5ff09c8e9daf 49 // file TARGET_MAX40108DEMOP2U9\device\TOOLCHAIN_ARM_STD\MAX32625.sct
whismanoid 19:5ff09c8e9daf 50 // file TARGET_MAX40108DEMOP2U9\device\TOOLCHAIN_GCC_ARM\max32625.ld
whismanoid 19:5ff09c8e9daf 51 // file TARGET_MAX40108DEMOP2U9\device\TOOLCHAIN_IAR\MAX32625.icf
whismanoid 19:5ff09c8e9daf 52 // file mbed_app.json:
whismanoid 19:5ff09c8e9daf 53 // {
whismanoid 19:5ff09c8e9daf 54 // "config": {
whismanoid 19:5ff09c8e9daf 55 // },
whismanoid 19:5ff09c8e9daf 56 // "macros": [
whismanoid 19:5ff09c8e9daf 57 // "MAX40108_DEMO=9"
whismanoid 19:5ff09c8e9daf 58 // ],
whismanoid 19:5ff09c8e9daf 59 // "target_overrides": {
whismanoid 19:5ff09c8e9daf 60 // }
whismanoid 19:5ff09c8e9daf 61 // }
whismanoid 19:5ff09c8e9daf 62 // *******************************************************************************
whismanoid 19:5ff09c8e9daf 63 // Validating project global defines from mbed_app.json "macros": []
whismanoid 19:5ff09c8e9daf 64 #ifndef MAX40108_DEMO
whismanoid 19:5ff09c8e9daf 65 #warning "MAX40108_DEMO not defined, missing mbed_app.json"
whismanoid 19:5ff09c8e9daf 66 #else // #ifndef MAX40108_DEMO
whismanoid 19:5ff09c8e9daf 67 #warning "Note: MAX40108_DEMO is defined, which is expected"
whismanoid 19:5ff09c8e9daf 68 #if (MAX40108_DEMO)==(9)
whismanoid 19:5ff09c8e9daf 69 #warning "Note: MAX40108_DEMO is defined with the expected value of 9"
whismanoid 19:5ff09c8e9daf 70 #elif (MAX40108_DEMO)==(5)
whismanoid 19:5ff09c8e9daf 71 #warning "Note: MAX40108_DEMO is defined with the wrong value 5"
whismanoid 19:5ff09c8e9daf 72 #else
whismanoid 19:5ff09c8e9daf 73 #warning "Note: MAX40108_DEMO is defined, but with an unsupported value"
whismanoid 19:5ff09c8e9daf 74 #endif
whismanoid 19:5ff09c8e9daf 75 #endif // #ifndef MAX40108_DEMO
whismanoid 19:5ff09c8e9daf 76 // *******************************************************************************
whismanoid 14:d4092094dbfe 77 #ifndef MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 78 // #define MAX40108_DEMO 5 for U5, or #define MAX40108_DEMO 9 for U9 in banner
whismanoid 17:9397ea3ea7e9 79 #define MAX40108_DEMO 9
whismanoid 15:37c83ec50ea0 80 #define HAS_DAPLINK_SERIAL 1
whismanoid 14:d4092094dbfe 81 #endif // MAX40108_DEMO
whismanoid 42:89607d5d4e6d 82
whismanoid 42:89607d5d4e6d 83 // data unique to certain boards based on serial number
whismanoid 42:89607d5d4e6d 84 #include "Board_Calibration_Data.h"
whismanoid 42:89607d5d4e6d 85
whismanoid 36:e7aac874b8be 86 #ifdef BOARD_SERIAL_NUMBER
whismanoid 47:f1a56afb4aca 87 uint32_t g_board_serial_number = 0xFFFFFFFF; // BOARD_SERIAL_NUMBER;
whismanoid 36:e7aac874b8be 88 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 89 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 90 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 36:e7aac874b8be 91 //
whismanoid 36:e7aac874b8be 92 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 93 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 36:e7aac874b8be 94 //
whismanoid 36:e7aac874b8be 95 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 96 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 36:e7aac874b8be 97 //
whismanoid 36:e7aac874b8be 98 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 99 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 36:e7aac874b8be 100 //
whismanoid 36:e7aac874b8be 101 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 102 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 36:e7aac874b8be 103 //
whismanoid 36:e7aac874b8be 104 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 105 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 36:e7aac874b8be 106 //
whismanoid 36:e7aac874b8be 107 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 108 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 36:e7aac874b8be 109 //
whismanoid 36:e7aac874b8be 110 # else
whismanoid 36:e7aac874b8be 111 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 112 # endif
whismanoid 36:e7aac874b8be 113 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 114 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 47:f1a56afb4aca 115 uint32_t g_board_serial_number = 0xFFFFFFFF;
whismanoid 36:e7aac874b8be 116 //
whismanoid 36:e7aac874b8be 117 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 0:cb44e2e9ec4c 118 //---------- CODE GENERATOR: DataLogHelloCppCodeList
whismanoid 0:cb44e2e9ec4c 119 // CODE GENERATOR: example code includes
whismanoid 0:cb44e2e9ec4c 120
whismanoid 0:cb44e2e9ec4c 121 // example code includes
whismanoid 0:cb44e2e9ec4c 122 // standard include for target platform -- Platform_Include_Boilerplate
whismanoid 0:cb44e2e9ec4c 123 #include "mbed.h"
whismanoid 0:cb44e2e9ec4c 124 // Platforms:
whismanoid 0:cb44e2e9ec4c 125 // - MAX32625MBED
whismanoid 0:cb44e2e9ec4c 126 // - supports mbed-os-5.11, requires USBDevice library
whismanoid 0:cb44e2e9ec4c 127 // - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
whismanoid 0:cb44e2e9ec4c 128 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 129 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 130 // - MAX32600MBED
whismanoid 7:949ec8581f5e 131 // - Please note the last supported version is Mbed OS 6.3.
whismanoid 0:cb44e2e9ec4c 132 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 133 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 134 // - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board.
whismanoid 0:cb44e2e9ec4c 135 // - NUCLEO_F446RE
whismanoid 0:cb44e2e9ec4c 136 // - remove USBDevice library
whismanoid 0:cb44e2e9ec4c 137 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 138 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 139 // - NUCLEO_F401RE
whismanoid 0:cb44e2e9ec4c 140 // - remove USBDevice library
whismanoid 0:cb44e2e9ec4c 141 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 142 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 143 // - MAX32630FTHR
whismanoid 0:cb44e2e9ec4c 144 // - #include "max32630fthr.h"
whismanoid 7:949ec8581f5e 145 // - add http://developer.mbed.org/teams/MaximIntegrated/code/max32630fthr/
whismanoid 0:cb44e2e9ec4c 146 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 147 // - MAX32620FTHR
whismanoid 0:cb44e2e9ec4c 148 // - #include "MAX32620FTHR.h"
whismanoid 0:cb44e2e9ec4c 149 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 150 // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
whismanoid 0:cb44e2e9ec4c 151 // - not tested yet
whismanoid 0:cb44e2e9ec4c 152 // - MAX32625PICO
whismanoid 0:cb44e2e9ec4c 153 // - #include "max32625pico.h"
whismanoid 0:cb44e2e9ec4c 154 // - add https://os.mbed.com/users/switches/code/max32625pico/
whismanoid 0:cb44e2e9ec4c 155 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 156 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 157 // - not tested yet
whismanoid 0:cb44e2e9ec4c 158 // - see https://os.mbed.com/users/switches/code/max32625pico/
whismanoid 0:cb44e2e9ec4c 159 // - see https://os.mbed.com/users/switches/code/PICO_board_demo/
whismanoid 0:cb44e2e9ec4c 160 // - see https://os.mbed.com/users/switches/code/PICO_USB_I2C_SPI/
whismanoid 0:cb44e2e9ec4c 161 // - see https://os.mbed.com/users/switches/code/SerialInterface/
whismanoid 0:cb44e2e9ec4c 162 // - Note: To load the MAX32625PICO firmware, hold the button while
whismanoid 0:cb44e2e9ec4c 163 // connecting the USB cable, then copy firmware bin file
whismanoid 0:cb44e2e9ec4c 164 // to the MAINTENANCE drive.
whismanoid 0:cb44e2e9ec4c 165 // - see https://os.mbed.com/platforms/MAX32625PICO/
whismanoid 0:cb44e2e9ec4c 166 // - see https://os.mbed.com/teams/MaximIntegrated/wiki/MAX32625PICO-Firmware-Updates
whismanoid 41:13a6a097502c 167 // - update from mbed-os-5.11.5 to mbed-os-5.15 to support deep sleep
whismanoid 41:13a6a097502c 168 // - cd mbed-os ; mbed update mbed-os-5.15.7 ; cd .. ; mbed remove USBDevice ; mbed sync
whismanoid 41:13a6a097502c 169 // - (Internal_DataLogger_NoUSB_MAX32625PICO does not use USBDevice library anyway)
whismanoid 0:cb44e2e9ec4c 170 //
whismanoid 0:cb44e2e9ec4c 171 // end Platform_Include_Boilerplate
whismanoid 0:cb44e2e9ec4c 172
whismanoid 0:cb44e2e9ec4c 173 //--------------------------------------------------
whismanoid 46:469d0061df5d 174 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 175 #ifndef HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 176 #define HAS_FLASH_PEEK 1
whismanoid 46:469d0061df5d 177 // #undef HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 178 #endif
whismanoid 46:469d0061df5d 179 #ifndef HAS_FLASH_POKE
whismanoid 46:469d0061df5d 180 #define HAS_FLASH_POKE 0
whismanoid 46:469d0061df5d 181 // #undef HAS_FLASH_POKE
whismanoid 46:469d0061df5d 182 #endif
whismanoid 46:469d0061df5d 183 //--------------------------------------------------
whismanoid 46:469d0061df5d 184 // mbed interface to on-chip Flash
whismanoid 46:469d0061df5d 185 //--------------------------------------------------
whismanoid 46:469d0061df5d 186 #if defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 187 #if HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 188 #warning "info: using HAS_FLASH_PEEK supporting %F peek=addr len=..."
whismanoid 46:469d0061df5d 189 #endif
whismanoid 46:469d0061df5d 190 #if HAS_FLASH_POKE
whismanoid 46:469d0061df5d 191 #warning "info: using HAS_FLASH_POKE supporting %F poke=addr data... "
whismanoid 46:469d0061df5d 192 #endif
whismanoid 46:469d0061df5d 193 #if HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 194 #warning "info: using HAS_FLASH_LOAD_SAVE supporting %F save... and %F load... "
whismanoid 46:469d0061df5d 195 #endif
whismanoid 46:469d0061df5d 196 // Maxim MAX32625 flash interface flc.h not .\mbed-os\drivers\FlashIAP.h
whismanoid 46:469d0061df5d 197 // .\mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\mxc\flc.h
whismanoid 46:469d0061df5d 198 // .\mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\mxc\flc.c
whismanoid 46:469d0061df5d 199 // int FLC_Init(void);
whismanoid 46:469d0061df5d 200 // int FLC_PageErase(uint32_t address, uint8_t erase_code, uint8_t unlock_key);
whismanoid 46:469d0061df5d 201 // int FLC_Write(uint32_t address, const void *data, uint32_t length, uint8_t unlock_key);
whismanoid 46:469d0061df5d 202 // example see CommunicationHandler Interpreter.cpp
whismanoid 46:469d0061df5d 203 // https://os.mbed.com/users/MuratAslan/code/CommunicationHandler/
whismanoid 46:469d0061df5d 204 #include "flc.h"
whismanoid 46:469d0061df5d 205 //
whismanoid 46:469d0061df5d 206 // Other targets like STM use FlashIAP interface
whismanoid 46:469d0061df5d 207 // #if !DEVICE_FLASH
whismanoid 46:469d0061df5d 208 // #error [NOT_SUPPORTED] Flash API not supported for this target
whismanoid 46:469d0061df5d 209 // #else
whismanoid 46:469d0061df5d 210 // #warning "DEVICE_FLASH is defined, so FlashIAP Flash API is // supported for this target"
whismanoid 46:469d0061df5d 211 // #endif
whismanoid 46:469d0061df5d 212 // .\mbed-os\drivers\FlashIAP.h
whismanoid 46:469d0061df5d 213 // #warning "using FlashIAP.h"
whismanoid 46:469d0061df5d 214 // #include <FlashIAP.h>
whismanoid 46:469d0061df5d 215 // mbed interface to on-chip Flash
whismanoid 46:469d0061df5d 216 // FlashIAP flash;
whismanoid 46:469d0061df5d 217 // error: 'FlashIAP' does not name a type
whismanoid 46:469d0061df5d 218 //--------------------------------------------------
whismanoid 51:a41d3fd5e441 219 // MAX40108 calibration values assign absolute address
whismanoid 51:a41d3fd5e441 220 // Note this data is little-endian, least significant byte first
whismanoid 47:f1a56afb4aca 221 const char flash_page_configuration_back_up[8192] __attribute__((aligned(8192))) = {
whismanoid 47:f1a56afb4aca 222 // 0x04000053, 0xffffffff, 0xffffffff, 0xffffffff, // g_board_serial_number is blank 0xFFFFFFFF
whismanoid 51:a41d3fd5e441 223 // 3, ___2, ___1, ___0, ___7, ___6, ___5, ___4, ___b, ___a, ___9, ___8, ___f, ___e, ___d, ___c,
whismanoid 50:f42de27fc652 224 0x53, 0x00, 0x00, 0x04, 0xe9, 0xf1, 0xd3, 0x7d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 0x04000053 g_board_serial_number is blank 0xFFFFFFFF
whismanoid 50:f42de27fc652 225 0x53, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x40, 0xa6, 0x0a, 0xec, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08001053 calibration_05_V[0]
whismanoid 50:f42de27fc652 226 0x53, 0x11, 0x00, 0x08, 0x00, 0x00, 0x00, 0x40, 0xa6, 0x0a, 0xec, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08001153 calibration_05_V[1]
whismanoid 50:f42de27fc652 227 0x53, 0x12, 0x00, 0x08, 0x00, 0x00, 0x00, 0x40, 0xa6, 0x0a, 0xec, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08001253 calibration_05_V[2]
whismanoid 50:f42de27fc652 228 0x53, 0x13, 0x00, 0x08, 0x00, 0x00, 0x00, 0x40, 0xa6, 0x0a, 0xec, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08001353 calibration_05_V[3]
whismanoid 50:f42de27fc652 229 0x53, 0x14, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0xf7, 0x75, 0xf1, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08001453 calibration_05_V[4]
whismanoid 50:f42de27fc652 230 0x53, 0x15, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0xf7, 0x75, 0xf1, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08001553 calibration_05_V[5]
whismanoid 50:f42de27fc652 231 0x53, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x58, 0x3a, 0x69, 0xe7, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08002053 calibration_05_normValue_0_1[0]
whismanoid 50:f42de27fc652 232 0x53, 0x21, 0x00, 0x08, 0x00, 0x00, 0x00, 0x58, 0x3a, 0x69, 0xe7, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08002153 calibration_05_normValue_0_1[1]
whismanoid 50:f42de27fc652 233 0x53, 0x22, 0x00, 0x08, 0x00, 0x00, 0x00, 0x58, 0x3a, 0x69, 0xe7, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08002253 calibration_05_normValue_0_1[2]
whismanoid 50:f42de27fc652 234 0x53, 0x23, 0x00, 0x08, 0x00, 0x00, 0x00, 0x58, 0x3a, 0x69, 0xe7, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08002353 calibration_05_normValue_0_1[3]
whismanoid 50:f42de27fc652 235 0x53, 0x24, 0x00, 0x08, 0x00, 0x00, 0x00, 0xb0, 0xa3, 0x8e, 0xc7, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08002453 calibration_05_normValue_0_1[4]
whismanoid 50:f42de27fc652 236 0x53, 0x25, 0x00, 0x08, 0x00, 0x00, 0x00, 0xb0, 0xa3, 0x8e, 0xc7, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08002553 calibration_05_normValue_0_1[5]
whismanoid 50:f42de27fc652 237 0x53, 0x30, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0xf7, 0x75, 0xf1, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08003053 calibration_95_V[0]
whismanoid 50:f42de27fc652 238 0x53, 0x31, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0xf7, 0x75, 0xf1, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08003153 calibration_95_V[1]
whismanoid 50:f42de27fc652 239 0x53, 0x32, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0xf7, 0x75, 0xf1, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08003253 calibration_95_V[2]
whismanoid 50:f42de27fc652 240 0x53, 0x33, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0xf7, 0x75, 0xf1, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08003353 calibration_95_V[3]
whismanoid 50:f42de27fc652 241 0x53, 0x34, 0x00, 0x08, 0x00, 0x00, 0x00, 0x40, 0x33, 0x33, 0xfa, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08003453 calibration_95_V[4]
whismanoid 50:f42de27fc652 242 0x53, 0x35, 0x00, 0x08, 0x00, 0x00, 0x00, 0x40, 0x33, 0x33, 0xfa, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08003553 calibration_95_V[5]
whismanoid 50:f42de27fc652 243 0x53, 0x40, 0x00, 0x08, 0x00, 0x00, 0xe0, 0xbb, 0xc8, 0x22, 0xed, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08004053 calibration_95_normValue_0_1[0]
whismanoid 50:f42de27fc652 244 0x53, 0x41, 0x00, 0x08, 0x00, 0x00, 0xe0, 0xbb, 0xc8, 0x22, 0xed, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08004153 calibration_95_normValue_0_1[1]
whismanoid 50:f42de27fc652 245 0x53, 0x42, 0x00, 0x08, 0x00, 0x00, 0xe0, 0xbb, 0xc8, 0x22, 0xed, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08004253 calibration_95_normValue_0_1[2]
whismanoid 50:f42de27fc652 246 0x53, 0x43, 0x00, 0x08, 0x00, 0x00, 0xe0, 0xbb, 0xc8, 0x22, 0xed, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08004353 calibration_95_normValue_0_1[3]
whismanoid 50:f42de27fc652 247 0x53, 0x44, 0x00, 0x08, 0x00, 0x00, 0x00, 0x98, 0x44, 0x92, 0xd1, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08004453 calibration_95_normValue_0_1[4]
whismanoid 50:f42de27fc652 248 0x53, 0x45, 0x00, 0x08, 0x00, 0x00, 0x00, 0x98, 0x44, 0x92, 0xd1, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08004553 calibration_95_normValue_0_1[5]
whismanoid 51:a41d3fd5e441 249 // WIP #312 initial values in flash_page_configuration_back_up[]
whismanoid 47:f1a56afb4aca 250 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 0xffffffff blank space to permit saving more data
whismanoid 47:f1a56afb4aca 251 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 252 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 253 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 254 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 255 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 256 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 257 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 258 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 259 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 260 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 261 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 262 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 263 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 264 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 265 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 266 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 267 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 268 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 269 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 270 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 271 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 272 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 273 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 274 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 275 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 276 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 277 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 278 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 279 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 280 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 281 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 282 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 283 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 284 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 285 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 286 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
whismanoid 47:f1a56afb4aca 287 };
whismanoid 46:469d0061df5d 288 // WIP #312 map values in flash_page_configuration_back_up[]
whismanoid 46:469d0061df5d 289 // such as board serial number, %A calibration values,
whismanoid 46:469d0061df5d 290 // business logic, button handlers, etc.
whismanoid 46:469d0061df5d 291 // Use some pattern that stands out in the hex file dump
whismanoid 46:469d0061df5d 292 // as well as in the flash dump... note the hex file is LE/LSbyte first,
whismanoid 46:469d0061df5d 293 // while the flash memory is BE/MSbyte first.
whismanoid 46:469d0061df5d 294 //
whismanoid 46:469d0061df5d 295 // I don't have control of where this ends up because "at" attribute
whismanoid 46:469d0061df5d 296 // is not supported, but at least flash_page_configuration_back_up
whismanoid 46:469d0061df5d 297 // is page-aligned and its address is printed in the help.
whismanoid 46:469d0061df5d 298 // Also use a pattern that should stand out in the hex dump.
whismanoid 46:469d0061df5d 299 // Note that in the .bin file, "32107654" is 33 32 31 30 37 36 35 34,
whismanoid 46:469d0061df5d 300 // but in the flash memory it will be 0x30313233 0x34353637
whismanoid 46:469d0061df5d 301 // Use free hex editor to find text in .bin file,
whismanoid 46:469d0061df5d 302 // then add base address 0x00010000 to get peek address.
whismanoid 46:469d0061df5d 303 // char* TestString1 = "UUUUUUUUUUUUUUUUUUUU""32107654BA98FEDC"" MAX32625 Calibration ....####@@@@""UUUUUUUUUUUUUUUUUUUU";
whismanoid 46:469d0061df5d 304 // > %F peek=0x000241f0 len=20
whismanoid 46:469d0061df5d 305 // FLASH 0x000241f0: 0x544c4f56 0x00454741 0x55555555 0x55555555
whismanoid 46:469d0061df5d 306 // FLASH 0x00024200: 0x55555555 0x55555555 0x55555555 0x30313233
whismanoid 46:469d0061df5d 307 // FLASH 0x00024210: 0x34353637 0x38394142 0x43444546 0x58414d20
whismanoid 46:469d0061df5d 308 // FLASH 0x00024220: 0x32363233 0x61432035 0x7262696c 0x6f697461
whismanoid 46:469d0061df5d 309 // FLASH 0x00024230: 0x2020206e 0x2e2e2e2e 0x23232323 0x40404040
whismanoid 46:469d0061df5d 310 // FLASH 0x00024240: 0x55555555 0x55555555 0x55555555 0x55555555
whismanoid 46:469d0061df5d 311 // FLASH 0x00024250: 0x55555555 0x00000000 0x00000000 0x00000000
whismanoid 46:469d0061df5d 312 // FLASH 0x00024260: 0x00013b1b 0x000140d1 0x00013d9f 0x00013e2d
whismanoid 46:469d0061df5d 313 //
whismanoid 46:469d0061df5d 314 // Why did it end up at that address? Here's the linker map report:
whismanoid 46:469d0061df5d 315 // .\BUILD\MAX32625PICO\GCC_ARM\Internal_DataLogger.map
whismanoid 46:469d0061df5d 316 // .text.startup._GLOBAL__sub_I_TestString1
whismanoid 46:469d0061df5d 317 // 0x0001374c 0x33c BUILD/MAX32625PICO/GCC_ARM/DataLogger_Internal.o
whismanoid 46:469d0061df5d 318 // .rodata._GLOBAL__sub_I_TestString1.str1.1
whismanoid 46:469d0061df5d 319 // 0x00022d64 0x12 BUILD/MAX32625PICO/GCC_ARM/DataLogger_Internal.o
whismanoid 46:469d0061df5d 320 // 0x19 (size before relaxing)
whismanoid 46:469d0061df5d 321 //
whismanoid 46:469d0061df5d 322 // For calibration purposes this could still be usable,
whismanoid 46:469d0061df5d 323 // as long as the firmware knows where its calibration constants live.
whismanoid 46:469d0061df5d 324 //
whismanoid 46:469d0061df5d 325 #if defined ( __GNUC__ )
whismanoid 46:469d0061df5d 326 __attribute__ ((section(".calibration_teststring")))
whismanoid 46:469d0061df5d 327 #endif
whismanoid 46:469d0061df5d 328 char* TestString1 = "UUUU" "UUUU" "UUUU" "UUUU"
whismanoid 46:469d0061df5d 329 "\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF"
whismanoid 46:469d0061df5d 330 "\x11\x22\x33\x44" "\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF"
whismanoid 46:469d0061df5d 331 "UUUUUUUUUUUUUUUUUUUU""32107654BA98FEDC"" MAX32625 Calibration ....####@@@@""UUUUUUUUUUUUUUUUUUUU";
whismanoid 46:469d0061df5d 332 //
whismanoid 46:469d0061df5d 333 // Limit the ranges where memory write operation will be allowed
whismanoid 46:469d0061df5d 334 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 335 // FLASH (rx) : ORIGIN = 0x00010000, LENGTH = 0x00070000
whismanoid 46:469d0061df5d 336 // RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00028000
whismanoid 46:469d0061df5d 337 typedef struct {
whismanoid 46:469d0061df5d 338 uint32_t addr_min; // lowest address of range
whismanoid 46:469d0061df5d 339 uint32_t addr_max; // highest address of range
whismanoid 46:469d0061df5d 340 char name[6]; // 5-character name, pad with spaces, null-terminated
whismanoid 46:469d0061df5d 341 char can_flash_write_read; // 8=end of list, 4=flashPoke, 2=ramPoke, 1=read
whismanoid 46:469d0061df5d 342 } poke_access_t;
whismanoid 51:a41d3fd5e441 343 const char poke_access_readOnly = 1;
whismanoid 51:a41d3fd5e441 344 const char poke_access_rw_RAM = 3;
whismanoid 51:a41d3fd5e441 345 const char poke_access_rw_FLASH = 5;
whismanoid 51:a41d3fd5e441 346 const char poke_access_EndOfList = 8;
whismanoid 46:469d0061df5d 347 poke_access_t poke_access_list[] = {
whismanoid 46:469d0061df5d 348 { 0x12345678, 0x12345678, "undef", 0 }, // first record: catch undefined ranges
whismanoid 46:469d0061df5d 349 // { 0x00000000, 0x0000FFFF, " BOOT", 1 }, // boot area is flash page 0-7, but don't allow flashPoke
whismanoid 51:a41d3fd5e441 350 { 0x00000000, 0x00001FFF, "BOOT0", poke_access_readOnly }, // flash page 0
whismanoid 51:a41d3fd5e441 351 { 0x00002000, 0x00003FFF, "BOOT1", poke_access_readOnly }, // flash page 1
whismanoid 51:a41d3fd5e441 352 { 0x00004000, 0x00005FFF, "BOOT2", poke_access_readOnly }, // flash page 2
whismanoid 51:a41d3fd5e441 353 { 0x00006000, 0x00007FFF, "BOOT3", poke_access_readOnly }, // flash page 3
whismanoid 51:a41d3fd5e441 354 { 0x00008000, 0x00009FFF, "BOOT4", poke_access_readOnly }, // flash page 4
whismanoid 51:a41d3fd5e441 355 { 0x0000A000, 0x0000BFFF, "BOOT5", poke_access_readOnly }, // flash page 5
whismanoid 51:a41d3fd5e441 356 { 0x0000C000, 0x0000DFFF, "BOOT6", poke_access_readOnly }, // flash page 6
whismanoid 51:a41d3fd5e441 357 { 0x0000E000, 0x0000FFFF, "BOOT7", poke_access_readOnly }, // flash page 7
whismanoid 46:469d0061df5d 358 //
whismanoid 51:a41d3fd5e441 359 //{ 0x00010000, 0x0007FFFF, "FLASH", poke_access_rw_FLASH }, // flash pages 8-62
whismanoid 46:469d0061df5d 360 // Future: separate FLASH pages, allow flashPoke only on the calibration page
whismanoid 51:a41d3fd5e441 361 { 0x00010000, 0x00011FFF, "FLA08", poke_access_rw_FLASH }, // flash page 8
whismanoid 51:a41d3fd5e441 362 { 0x00012000, 0x00013FFF, "FLA09", poke_access_rw_FLASH }, // flash page 9
whismanoid 51:a41d3fd5e441 363 { 0x00014000, 0x00015FFF, "FLA10", poke_access_rw_FLASH }, // flash page 10
whismanoid 51:a41d3fd5e441 364 { 0x00016000, 0x00017FFF, "FLA11", poke_access_rw_FLASH }, // flash page 11
whismanoid 51:a41d3fd5e441 365 { 0x00018000, 0x00019FFF, "FLA12", poke_access_rw_FLASH }, // flash page 12
whismanoid 51:a41d3fd5e441 366 { 0x0001A000, 0x0001BFFF, "FLA13", poke_access_rw_FLASH }, // flash page 13
whismanoid 51:a41d3fd5e441 367 { 0x0001C000, 0x0001DFFF, "FLA14", poke_access_rw_FLASH }, // flash page 14
whismanoid 51:a41d3fd5e441 368 { 0x0001E000, 0x0001FFFF, "FLA15", poke_access_rw_FLASH }, // flash page 15
whismanoid 46:469d0061df5d 369 //
whismanoid 51:a41d3fd5e441 370 { 0x00020000, 0x00021FFF, "FLA16", poke_access_rw_FLASH }, // flash page 16
whismanoid 51:a41d3fd5e441 371 { 0x00022000, 0x00023FFF, "FLA17", poke_access_rw_FLASH }, // flash page 17
whismanoid 51:a41d3fd5e441 372 { 0x00024000, 0x00025FFF, "FLA18", poke_access_rw_FLASH }, // flash page 18
whismanoid 51:a41d3fd5e441 373 { 0x00026000, 0x00027FFF, "FLA19", poke_access_rw_FLASH }, // flash page 19
whismanoid 51:a41d3fd5e441 374 { 0x00028000, 0x00029FFF, "FLA20", poke_access_rw_FLASH }, // flash page 20
whismanoid 51:a41d3fd5e441 375 { 0x0002A000, 0x0002BFFF, "FLA21", poke_access_rw_FLASH }, // flash page 21
whismanoid 51:a41d3fd5e441 376 { 0x0002C000, 0x0002DFFF, "FLA22", poke_access_rw_FLASH }, // flash page 22
whismanoid 51:a41d3fd5e441 377 { 0x0002E000, 0x0002FFFF, "FLA23", poke_access_rw_FLASH }, // flash page 23
whismanoid 46:469d0061df5d 378 //
whismanoid 51:a41d3fd5e441 379 { 0x00030000, 0x00031FFF, "FLA24", poke_access_rw_FLASH }, // flash page 24
whismanoid 51:a41d3fd5e441 380 { 0x00032000, 0x00033FFF, "FLA25", poke_access_rw_FLASH }, // flash page 25
whismanoid 51:a41d3fd5e441 381 { 0x00034000, 0x00035FFF, "FLA26", poke_access_rw_FLASH }, // flash page 26
whismanoid 51:a41d3fd5e441 382 { 0x00036000, 0x00037FFF, "FLA27", poke_access_rw_FLASH }, // flash page 27
whismanoid 51:a41d3fd5e441 383 { 0x00038000, 0x00039FFF, "FLA28", poke_access_rw_FLASH }, // flash page 28
whismanoid 51:a41d3fd5e441 384 { 0x0003A000, 0x0003BFFF, "FLA29", poke_access_rw_FLASH }, // flash page 29
whismanoid 51:a41d3fd5e441 385 { 0x0003C000, 0x0003DFFF, "FLA30", poke_access_rw_FLASH }, // flash page 30
whismanoid 51:a41d3fd5e441 386 { 0x0003E000, 0x0003FFFF, "FLA31", poke_access_rw_FLASH }, // flash page 31
whismanoid 46:469d0061df5d 387 //
whismanoid 51:a41d3fd5e441 388 { 0x00040000, 0x00041FFF, "FLA32", poke_access_rw_FLASH }, // flash page 32
whismanoid 51:a41d3fd5e441 389 { 0x00042000, 0x00043FFF, "FLA33", poke_access_rw_FLASH }, // flash page 33
whismanoid 51:a41d3fd5e441 390 { 0x00044000, 0x00045FFF, "FLA34", poke_access_rw_FLASH }, // flash page 34
whismanoid 51:a41d3fd5e441 391 { 0x00046000, 0x00047FFF, "FLA35", poke_access_rw_FLASH }, // flash page 35
whismanoid 51:a41d3fd5e441 392 { 0x00048000, 0x00049FFF, "FLA36", poke_access_rw_FLASH }, // flash page 36
whismanoid 51:a41d3fd5e441 393 { 0x0004A000, 0x0004BFFF, "FLA37", poke_access_rw_FLASH }, // flash page 37
whismanoid 51:a41d3fd5e441 394 { 0x0004C000, 0x0004DFFF, "FLA38", poke_access_rw_FLASH }, // flash page 38
whismanoid 51:a41d3fd5e441 395 { 0x0004E000, 0x0004FFFF, "FLA39", poke_access_rw_FLASH }, // flash page 39
whismanoid 46:469d0061df5d 396 //
whismanoid 51:a41d3fd5e441 397 { 0x00050000, 0x00051FFF, "FLA40", poke_access_rw_FLASH }, // flash page 40
whismanoid 51:a41d3fd5e441 398 { 0x00052000, 0x00053FFF, "FLA41", poke_access_rw_FLASH }, // flash page 41
whismanoid 51:a41d3fd5e441 399 { 0x00054000, 0x00055FFF, "FLA42", poke_access_rw_FLASH }, // flash page 42
whismanoid 51:a41d3fd5e441 400 { 0x00056000, 0x00057FFF, "FLA43", poke_access_rw_FLASH }, // flash page 43
whismanoid 51:a41d3fd5e441 401 { 0x00058000, 0x00059FFF, "FLA44", poke_access_rw_FLASH }, // flash page 44
whismanoid 51:a41d3fd5e441 402 { 0x0005A000, 0x0005BFFF, "FLA45", poke_access_rw_FLASH }, // flash page 45
whismanoid 51:a41d3fd5e441 403 { 0x0005C000, 0x0005DFFF, "FLA46", poke_access_rw_FLASH }, // flash page 46
whismanoid 51:a41d3fd5e441 404 { 0x0005E000, 0x0005FFFF, "FLA47", poke_access_rw_FLASH }, // flash page 47
whismanoid 46:469d0061df5d 405 //
whismanoid 51:a41d3fd5e441 406 { 0x00060000, 0x00061FFF, "FLA48", poke_access_rw_FLASH }, // flash page 48
whismanoid 51:a41d3fd5e441 407 { 0x00062000, 0x00063FFF, "FLA49", poke_access_rw_FLASH }, // flash page 49
whismanoid 51:a41d3fd5e441 408 { 0x00064000, 0x00065FFF, "FLA50", poke_access_rw_FLASH }, // flash page 50
whismanoid 51:a41d3fd5e441 409 { 0x00066000, 0x00067FFF, "FLA51", poke_access_rw_FLASH }, // flash page 51
whismanoid 51:a41d3fd5e441 410 { 0x00068000, 0x00069FFF, "FLA52", poke_access_rw_FLASH }, // flash page 52
whismanoid 51:a41d3fd5e441 411 { 0x0006A000, 0x0006BFFF, "FLA53", poke_access_rw_FLASH }, // flash page 53
whismanoid 51:a41d3fd5e441 412 { 0x0006C000, 0x0006DFFF, "FLA54", poke_access_rw_FLASH }, // flash page 54
whismanoid 51:a41d3fd5e441 413 { 0x0006E000, 0x0006FFFF, "FLA55", poke_access_rw_FLASH }, // flash page 55
whismanoid 46:469d0061df5d 414 //
whismanoid 51:a41d3fd5e441 415 { 0x00070000, 0x00071FFF, "FLA56", poke_access_rw_FLASH }, // flash page 56
whismanoid 51:a41d3fd5e441 416 { 0x00072000, 0x00073FFF, "FLA57", poke_access_rw_FLASH }, // flash page 57
whismanoid 51:a41d3fd5e441 417 { 0x00074000, 0x00075FFF, "FLA58", poke_access_rw_FLASH }, // flash page 58
whismanoid 51:a41d3fd5e441 418 { 0x00076000, 0x00077FFF, "FLA59", poke_access_rw_FLASH }, // flash page 59
whismanoid 51:a41d3fd5e441 419 { 0x00078000, 0x00079FFF, "FLA60", poke_access_rw_FLASH }, // flash page 60
whismanoid 51:a41d3fd5e441 420 { 0x0007A000, 0x0007BFFF, "FLA61", poke_access_rw_FLASH }, // flash page 61
whismanoid 51:a41d3fd5e441 421 { 0x0007C000, 0x0007DFFF, "FLA62", poke_access_rw_FLASH }, // flash page 62
whismanoid 51:a41d3fd5e441 422 { 0x0007E000, 0x0007FFFF, "FLA63", poke_access_rw_FLASH }, // flash page 63
whismanoid 46:469d0061df5d 423 //
whismanoid 51:a41d3fd5e441 424 { 0x20000000, 0x20027FFF, " RAM", poke_access_rw_RAM }, // ramPoke + read
whismanoid 46:469d0061df5d 425 { 0x20028000, 0x2002FFFF, "skip ", 0 }, // don't read from this range
whismanoid 51:a41d3fd5e441 426 { 0x40000000, 0x400003FF, " SYS", poke_access_readOnly }, // read only
whismanoid 51:a41d3fd5e441 427 { 0x40000400, 0x400007FF, " CLK", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 428 { 0x40000800, 0x400009FF, " PWR", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 429 { 0x40000A00, 0x40000BFF, " RTC", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 430 { 0x40000C00, 0x40001FFF, "IOMAN", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 431 { 0x40002000, 0x40002FFF, " FLC", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 432 { 0x40003000, 0x40003FFF, " ICC", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 433 { 0x40004000, 0x40004FFF, " SPIX", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 434 { 0x40005000, 0x40005FFF, " PMU", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 435 { 0x40006000, 0x40006FFF, " CRC", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 436 { 0x40007000, 0x40007FFF, " TPU", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 437 { 0x40008000, 0x40008FFF, " WDT0", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 438 { 0x40009000, 0x40009FFF, " WDT1", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 439 { 0x4000A000, 0x4000AFFF, " GPIO", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 440 { 0x4000B000, 0x4000FFFF, " TMR", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 441 { 0x40011000, 0x4000FFFF, " PT", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 442 { 0x40012000, 0x4000FFFF, " UART", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 443 { 0x40016000, 0x4000FFFF, " I2CM", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 444 { 0x40019000, 0x4000FFFF, " I2CS", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 445 { 0x4001A000, 0x4000FFFF, " SPIM", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 446 { 0x4001E000, 0x4000FFFF, " OWM", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 447 { 0x4001F000, 0x4000FFFF, " ADC", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 448 { 0x40020000, 0x40000FFF, " SPIS", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 449 { 0x40100000, 0x40100FFF, " USB", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 450 { 0x40101000, 0x40101FFF, " CRC", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 451 { 0x40102000, 0x40102FFF, " TPU", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 452 { 0x40103000, 0x40103FFF, "UART0", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 453 { 0x40104000, 0x40104FFF, "UART1", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 454 { 0x40105000, 0x40105FFF, "UART2", poke_access_readOnly },
whismanoid 51:a41d3fd5e441 455 //{ 0x40106000, 0x40106FFF, "_____", poke_access_readOnly }, // reserved
whismanoid 51:a41d3fd5e441 456 { 0x40107000, 0x40107FFF, "I2CM0", poke_access_readOnly }, // I2CM0 FIFOs
whismanoid 51:a41d3fd5e441 457 { 0x40108000, 0x40108FFF, "I2CM1", poke_access_readOnly }, // I2CM1 FIFOs
whismanoid 51:a41d3fd5e441 458 //{ 0x40109000, 0x40109FFF, "_____", poke_access_readOnly }, // reserved
whismanoid 51:a41d3fd5e441 459 { 0x4010A000, 0x4010AFFF, "SPIM0", poke_access_readOnly }, // SPIM0 FIFOs
whismanoid 51:a41d3fd5e441 460 { 0x4010B000, 0x4010BFFF, "SPIM1", poke_access_readOnly }, // SPIM1 FIFOs
whismanoid 51:a41d3fd5e441 461 { 0x4010C000, 0x4010CFFF, "SPIM2", poke_access_readOnly }, // SPIM2 FIFOs
whismanoid 51:a41d3fd5e441 462 //{ 0x4010D000, 0x4010DFFF, "_____", poke_access_readOnly }, // reserved
whismanoid 51:a41d3fd5e441 463 { 0x4010E000, 0x4010EFFF, " SPIS", poke_access_readOnly }, // SPIS FIFOs
whismanoid 51:a41d3fd5e441 464 //{ 0x4010F000, 0x4010FFFF, "_____", poke_access_readOnly }, // reserved
whismanoid 46:469d0061df5d 465 //
whismanoid 51:a41d3fd5e441 466 { 0x00000000, 0xFFFFFFFF, "last?", poke_access_EndOfList }, // end of list can_flash_write_read=8, catch-all
whismanoid 46:469d0061df5d 467 };
whismanoid 46:469d0061df5d 468 int search_poke_access_list(uint32_t addr)
whismanoid 46:469d0061df5d 469 {
whismanoid 46:469d0061df5d 470 // scan poke_access_list[] for peek_addr
whismanoid 46:469d0061df5d 471 for (int i = 0; poke_access_list[i].can_flash_write_read != 8; i++)
whismanoid 46:469d0061df5d 472 {
whismanoid 46:469d0061df5d 473 if ((addr >= poke_access_list[i].addr_min) && (addr <= poke_access_list[i].addr_max))
whismanoid 46:469d0061df5d 474 {
whismanoid 46:469d0061df5d 475 return i;
whismanoid 46:469d0061df5d 476 }
whismanoid 46:469d0061df5d 477 }
whismanoid 46:469d0061df5d 478 return 0;
whismanoid 46:469d0061df5d 479 }
whismanoid 46:469d0061df5d 480 #endif // defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 481
whismanoid 46:469d0061df5d 482 //--------------------------------------------------
whismanoid 3:9055e17e181a 483 // Option to use SPI connected ADC
whismanoid 3:9055e17e181a 484 #ifndef SPI_ADC_DeviceName
whismanoid 9:45f98573eb6d 485 #define SPI_ADC_DeviceName MAX11410
whismanoid 3:9055e17e181a 486 #undef SPI_ADC_DeviceName
whismanoid 3:9055e17e181a 487 #endif
whismanoid 3:9055e17e181a 488 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 489 #include "MAX11410.h"
whismanoid 3:9055e17e181a 490 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 491
whismanoid 0:cb44e2e9ec4c 492 #if defined(TARGET)
whismanoid 0:cb44e2e9ec4c 493 // TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h
whismanoid 0:cb44e2e9ec4c 494 // Create a string definition for the TARGET
whismanoid 0:cb44e2e9ec4c 495 #define STRING_ARG(arg) #arg
whismanoid 0:cb44e2e9ec4c 496 #define STRING_NAME(name) STRING_ARG(name)
whismanoid 0:cb44e2e9ec4c 497 #define TARGET_NAME STRING_NAME(TARGET)
whismanoid 0:cb44e2e9ec4c 498 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 499 #define TARGET_NAME "MAX32600"
whismanoid 0:cb44e2e9ec4c 500 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 501 #define TARGET_NAME "LPC1768"
whismanoid 0:cb44e2e9ec4c 502 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 503 #define TARGET_NAME "NUCLEO_F446RE"
whismanoid 0:cb44e2e9ec4c 504 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 505 #define TARGET_NAME "NUCLEO_F401RE"
whismanoid 0:cb44e2e9ec4c 506 #else
whismanoid 0:cb44e2e9ec4c 507 #error TARGET NOT DEFINED
whismanoid 0:cb44e2e9ec4c 508 #endif
whismanoid 0:cb44e2e9ec4c 509 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 510 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 511 // TARGET=MAX32630FTHR ARM Cortex-M4F 96MHz 2048kB Flash 512kB SRAM
whismanoid 0:cb44e2e9ec4c 512 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 513 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 514 // ______ | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 515 // ______ | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 516 // ______ | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 517 // ______ | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 518 // analogIn0/4 | [a] AIN_0 1.2Vfs (bat) SYS [ ] | switched BAT+
whismanoid 0:cb44e2e9ec4c 519 // analogIn1/5 | [a] AIN_1 1.2Vfs PWR [ ] | external pwr btn
whismanoid 0:cb44e2e9ec4c 520 // analogIn2 | [a] AIN_2 1.2Vfs +5V VBUS [ ] | USB +5V power
whismanoid 0:cb44e2e9ec4c 521 // analogIn3 | [a] AIN_3 1.2Vfs 1-WIRE P4_0 [d] | D0 dig9
whismanoid 0:cb44e2e9ec4c 522 // (I2C2.SDA) | [d] P5_7 SDA2 SRN P5_6 [d] | D1 dig8
whismanoid 0:cb44e2e9ec4c 523 // (I2C2.SCL) | [d] P6_0 SCL2 SDIO3 P5_5 [d] | D2 dig7
whismanoid 0:cb44e2e9ec4c 524 // D13/SCLK | [s] P5_0 SCLK SDIO2 P5_4 [d] | D3 dig6
whismanoid 0:cb44e2e9ec4c 525 // D11/MOSI | [s] P5_1 MOSI SSEL P5_3 [d] | D4 dig5
whismanoid 0:cb44e2e9ec4c 526 // D12/MISO | [s] P5_2 MISO RTS P3_3 [d] | D5 dig4
whismanoid 0:cb44e2e9ec4c 527 // D10/CS | [s] P3_0 RX CTS P3_2 [d] | D6 dig3
whismanoid 0:cb44e2e9ec4c 528 // D9 dig0 | [d] P3_1 TX SCL P3_5 [d] | D7 dig2
whismanoid 0:cb44e2e9ec4c 529 // ______ | [ ] GND SDA P3_4 [d] | D8 dig1
whismanoid 0:cb44e2e9ec4c 530 // | |
whismanoid 0:cb44e2e9ec4c 531 // | XIP Flash MAX14690N |
whismanoid 0:cb44e2e9ec4c 532 // | XIP_SCLK P1_0 SDA2 P5_7 |
whismanoid 0:cb44e2e9ec4c 533 // | XIP_MOSI P1_1 SCL2 P6_0 |
whismanoid 0:cb44e2e9ec4c 534 // | XIP_MISO P1_2 PMIC_INIT P3_7 |
whismanoid 0:cb44e2e9ec4c 535 // | XIP_SSEL P1_3 MPC P2_7 |
whismanoid 0:cb44e2e9ec4c 536 // | XIP_DIO2 P1_4 MON AIN_0 |
whismanoid 0:cb44e2e9ec4c 537 // | XIP_DIO3 P1_5 |
whismanoid 0:cb44e2e9ec4c 538 // | |
whismanoid 0:cb44e2e9ec4c 539 // | PAN1326B MicroSD LED |
whismanoid 0:cb44e2e9ec4c 540 // | BT_RX P0_0 SD_SCLK P0_4 r P2_4 |
whismanoid 0:cb44e2e9ec4c 541 // | BT_TX P0_1 SD_MOSI P0_5 g P2_5 |
whismanoid 0:cb44e2e9ec4c 542 // | BT_CTS P0_2 SD_MISO P0_6 b P2_6 |
whismanoid 0:cb44e2e9ec4c 543 // | BT_RTS P0_3 SD_SSEL P0_7 |
whismanoid 0:cb44e2e9ec4c 544 // | BT_RST P1_6 DETECT P2_2 |
whismanoid 0:cb44e2e9ec4c 545 // | BT_CLK P1_7 SW2 P2_3 |
whismanoid 0:cb44e2e9ec4c 546 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 547 // MAX32630FTHR board has MAX14690 PMIC on I2C bus (P5_7 SDA, P6_0 SCL) at slave address 0101_000r 0x50 (or 0x28 for 7 MSbit address).
whismanoid 0:cb44e2e9ec4c 548 // MAX32630FTHR board has BMI160 accelerometer on I2C bus (P5_7 SDA, P6_0 SCL) at slave address 1101_000r 0xD0 (or 0x68 for 7 MSbit address).
whismanoid 0:cb44e2e9ec4c 549 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 550 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 551 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 552 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 553 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 554 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 555 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 556 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 557 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 558 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 559 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 560 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 561 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 562 //
whismanoid 0:cb44e2e9ec4c 563 #include "max32630fthr.h"
whismanoid 0:cb44e2e9ec4c 564 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 565 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 566 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 567 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 568 // Arduino connector
whismanoid 0:cb44e2e9ec4c 569 #ifndef A0
whismanoid 0:cb44e2e9ec4c 570 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 571 #endif
whismanoid 0:cb44e2e9ec4c 572 #ifndef A1
whismanoid 0:cb44e2e9ec4c 573 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 574 #endif
whismanoid 0:cb44e2e9ec4c 575 #ifndef A2
whismanoid 0:cb44e2e9ec4c 576 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 577 #endif
whismanoid 0:cb44e2e9ec4c 578 #ifndef A3
whismanoid 0:cb44e2e9ec4c 579 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 580 #endif
whismanoid 0:cb44e2e9ec4c 581 #ifndef D0
whismanoid 0:cb44e2e9ec4c 582 #define D0 P4_0
whismanoid 0:cb44e2e9ec4c 583 #endif
whismanoid 0:cb44e2e9ec4c 584 #ifndef D1
whismanoid 0:cb44e2e9ec4c 585 #define D1 P5_6
whismanoid 0:cb44e2e9ec4c 586 #endif
whismanoid 0:cb44e2e9ec4c 587 #ifndef D2
whismanoid 0:cb44e2e9ec4c 588 #define D2 P5_5
whismanoid 0:cb44e2e9ec4c 589 #endif
whismanoid 0:cb44e2e9ec4c 590 #ifndef D3
whismanoid 0:cb44e2e9ec4c 591 #define D3 P5_4
whismanoid 0:cb44e2e9ec4c 592 #endif
whismanoid 0:cb44e2e9ec4c 593 #ifndef D4
whismanoid 0:cb44e2e9ec4c 594 #define D4 P5_3
whismanoid 0:cb44e2e9ec4c 595 #endif
whismanoid 0:cb44e2e9ec4c 596 #ifndef D5
whismanoid 0:cb44e2e9ec4c 597 #define D5 P3_3
whismanoid 0:cb44e2e9ec4c 598 #endif
whismanoid 0:cb44e2e9ec4c 599 #ifndef D6
whismanoid 0:cb44e2e9ec4c 600 #define D6 P3_2
whismanoid 0:cb44e2e9ec4c 601 #endif
whismanoid 0:cb44e2e9ec4c 602 #ifndef D7
whismanoid 0:cb44e2e9ec4c 603 #define D7 P3_5
whismanoid 0:cb44e2e9ec4c 604 #endif
whismanoid 0:cb44e2e9ec4c 605 #ifndef D8
whismanoid 0:cb44e2e9ec4c 606 #define D8 P3_4
whismanoid 0:cb44e2e9ec4c 607 #endif
whismanoid 0:cb44e2e9ec4c 608 #ifndef D9
whismanoid 0:cb44e2e9ec4c 609 #define D9 P3_1
whismanoid 0:cb44e2e9ec4c 610 #endif
whismanoid 0:cb44e2e9ec4c 611 #ifndef D10
whismanoid 0:cb44e2e9ec4c 612 #define D10 P3_0
whismanoid 0:cb44e2e9ec4c 613 #endif
whismanoid 0:cb44e2e9ec4c 614 #ifndef D11
whismanoid 0:cb44e2e9ec4c 615 #define D11 P5_1
whismanoid 0:cb44e2e9ec4c 616 #endif
whismanoid 0:cb44e2e9ec4c 617 #ifndef D12
whismanoid 0:cb44e2e9ec4c 618 #define D12 P5_2
whismanoid 0:cb44e2e9ec4c 619 #endif
whismanoid 0:cb44e2e9ec4c 620 #ifndef D13
whismanoid 0:cb44e2e9ec4c 621 #define D13 P5_0
whismanoid 0:cb44e2e9ec4c 622 #endif
whismanoid 0:cb44e2e9ec4c 623 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 624 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 625 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 626 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 627 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 628 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 629 // | |
whismanoid 0:cb44e2e9ec4c 630 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 631 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 632 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 633 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 634 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 635 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 636 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 637 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 638 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 639 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 640 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 641 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 642 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 643 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 644 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 645 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 646 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 647 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 648 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 649 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 650 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 651 // \_______________________/
whismanoid 0:cb44e2e9ec4c 652 //
whismanoid 0:cb44e2e9ec4c 653 // +------------------------+
whismanoid 0:cb44e2e9ec4c 654 // | |
whismanoid 0:cb44e2e9ec4c 655 // | MicroSD LED |
whismanoid 0:cb44e2e9ec4c 656 // | SD_SCLK P2_4 r P3_0 |
whismanoid 0:cb44e2e9ec4c 657 // | SD_MOSI P2_5 g P3_1 |
whismanoid 0:cb44e2e9ec4c 658 // | SD_MISO P2_6 b P3_2 |
whismanoid 0:cb44e2e9ec4c 659 // | SD_SSEL P2_7 y P3_3 |
whismanoid 0:cb44e2e9ec4c 660 // | |
whismanoid 0:cb44e2e9ec4c 661 // | DAPLINK BUTTONS |
whismanoid 0:cb44e2e9ec4c 662 // | TX P2_1 SW3 P2_3 |
whismanoid 0:cb44e2e9ec4c 663 // | RX P2_0 SW2 P2_2 |
whismanoid 0:cb44e2e9ec4c 664 // +------------------------+
whismanoid 0:cb44e2e9ec4c 665 //
whismanoid 0:cb44e2e9ec4c 666 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 667 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 668 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 669 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 670 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 671 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 672 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 673 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 674 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 675 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 676 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 677 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 678 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 679 //
whismanoid 0:cb44e2e9ec4c 680 //#include "max32625mbed.h" // ?
whismanoid 0:cb44e2e9ec4c 681 //MAX32625MBED mbed(MAX32625MBED::VIO_3V3); // ?
whismanoid 0:cb44e2e9ec4c 682 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 683 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 684 const float ADC_FULL_SCALE_VOLTAGE = 1.200; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 685 // Arduino connector
whismanoid 0:cb44e2e9ec4c 686 #ifndef A0
whismanoid 0:cb44e2e9ec4c 687 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 688 #endif
whismanoid 0:cb44e2e9ec4c 689 #ifndef A1
whismanoid 0:cb44e2e9ec4c 690 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 691 #endif
whismanoid 0:cb44e2e9ec4c 692 #ifndef A2
whismanoid 0:cb44e2e9ec4c 693 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 694 #endif
whismanoid 0:cb44e2e9ec4c 695 #ifndef A3
whismanoid 0:cb44e2e9ec4c 696 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 697 #endif
whismanoid 0:cb44e2e9ec4c 698 #ifndef D0
whismanoid 0:cb44e2e9ec4c 699 #define D0 P0_0
whismanoid 0:cb44e2e9ec4c 700 #endif
whismanoid 0:cb44e2e9ec4c 701 #ifndef D1
whismanoid 0:cb44e2e9ec4c 702 #define D1 P0_1
whismanoid 0:cb44e2e9ec4c 703 #endif
whismanoid 0:cb44e2e9ec4c 704 #ifndef D2
whismanoid 0:cb44e2e9ec4c 705 #define D2 P0_2
whismanoid 0:cb44e2e9ec4c 706 #endif
whismanoid 0:cb44e2e9ec4c 707 #ifndef D3
whismanoid 0:cb44e2e9ec4c 708 #define D3 P0_3
whismanoid 0:cb44e2e9ec4c 709 #endif
whismanoid 0:cb44e2e9ec4c 710 #ifndef D4
whismanoid 0:cb44e2e9ec4c 711 #define D4 P0_4
whismanoid 0:cb44e2e9ec4c 712 #endif
whismanoid 0:cb44e2e9ec4c 713 #ifndef D5
whismanoid 0:cb44e2e9ec4c 714 #define D5 P0_5
whismanoid 0:cb44e2e9ec4c 715 #endif
whismanoid 0:cb44e2e9ec4c 716 #ifndef D6
whismanoid 0:cb44e2e9ec4c 717 #define D6 P0_6
whismanoid 0:cb44e2e9ec4c 718 #endif
whismanoid 0:cb44e2e9ec4c 719 #ifndef D7
whismanoid 0:cb44e2e9ec4c 720 #define D7 P0_7
whismanoid 0:cb44e2e9ec4c 721 #endif
whismanoid 0:cb44e2e9ec4c 722 #ifndef D8
whismanoid 0:cb44e2e9ec4c 723 #define D8 P1_4
whismanoid 0:cb44e2e9ec4c 724 #endif
whismanoid 0:cb44e2e9ec4c 725 #ifndef D9
whismanoid 0:cb44e2e9ec4c 726 #define D9 P1_5
whismanoid 0:cb44e2e9ec4c 727 #endif
whismanoid 0:cb44e2e9ec4c 728 #ifndef D10
whismanoid 0:cb44e2e9ec4c 729 #define D10 P1_3
whismanoid 0:cb44e2e9ec4c 730 #endif
whismanoid 0:cb44e2e9ec4c 731 #ifndef D11
whismanoid 0:cb44e2e9ec4c 732 #define D11 P1_1
whismanoid 0:cb44e2e9ec4c 733 #endif
whismanoid 0:cb44e2e9ec4c 734 #ifndef D12
whismanoid 0:cb44e2e9ec4c 735 #define D12 P1_2
whismanoid 0:cb44e2e9ec4c 736 #endif
whismanoid 0:cb44e2e9ec4c 737 #ifndef D13
whismanoid 0:cb44e2e9ec4c 738 #define D13 P1_0
whismanoid 0:cb44e2e9ec4c 739 #endif
whismanoid 0:cb44e2e9ec4c 740 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 741 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 742 // target MAX32600
whismanoid 0:cb44e2e9ec4c 743 //
whismanoid 0:cb44e2e9ec4c 744 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 745 const float ADC_FULL_SCALE_VOLTAGE = 1.500;
whismanoid 0:cb44e2e9ec4c 746 //
whismanoid 0:cb44e2e9ec4c 747 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 748 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 749 #warning "TARGET_MAX32620FTHR not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 750 #include "MAX32620FTHR.h"
whismanoid 0:cb44e2e9ec4c 751 // Initialize I/O voltages on MAX32620FTHR board
whismanoid 0:cb44e2e9ec4c 752 MAX32620FTHR fthr(MAX32620FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 753 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 754 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 755 #warning "TARGET_MAX32620FTHR not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 756 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 757 //
whismanoid 0:cb44e2e9ec4c 758 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 759 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 15:37c83ec50ea0 760 // #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 761 #include "max32625pico.h"
whismanoid 0:cb44e2e9ec4c 762 // configure MAX32625PICO VDDIOH mode, and I/O voltages for DIP pins and SWD pins
whismanoid 0:cb44e2e9ec4c 763 MAX32625PICO pico(
whismanoid 13:184a08909405 764 // Select source of higher-voltage logic high supply VDDIOH
whismanoid 0:cb44e2e9ec4c 765 // vddioh_mode_t iohMode
whismanoid 0:cb44e2e9ec4c 766 //~ MAX32625PICO::IOH_OFF, // No connections to VDDIOH
whismanoid 0:cb44e2e9ec4c 767 //~ MAX32625PICO::IOH_DIP_IN, // VDDIOH input from DIP pin 1 (AIN0)
whismanoid 0:cb44e2e9ec4c 768 //~ MAX32625PICO::IOH_SWD_IN, // VDDIOH input from SWD pin 1
whismanoid 0:cb44e2e9ec4c 769 MAX32625PICO::IOH_3V3, // VDDIOH = 3.3V from local supply
whismanoid 0:cb44e2e9ec4c 770 //~ MAX32625PICO::IOH_DIP_OUT, // VDDIOH = 3.3V output to DIP pin 1
whismanoid 0:cb44e2e9ec4c 771 //~ MAX32625PICO::IOH_SWD_OUT, // VDDIOH = 3.3V output to SWD pin 1
whismanoid 0:cb44e2e9ec4c 772 //
whismanoid 13:184a08909405 773 // Digital I/O pin logic high voltage 1.8V or 3.3V
whismanoid 0:cb44e2e9ec4c 774 // vio_t dipVio = MAX32625PICO::VIO_1V8 or MAX32625PICO::VIO_IOH
whismanoid 13:184a08909405 775 MAX32625PICO::VIO_1V8, // 1.8V IO (local)
whismanoid 13:184a08909405 776 //~ MAX32625PICO::VIO_IOH, // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 777 //
whismanoid 13:184a08909405 778 // Software Debug logic high voltage (normally use VIO_IOH)
whismanoid 0:cb44e2e9ec4c 779 // vio_t swdVio
whismanoid 0:cb44e2e9ec4c 780 //~ MAX32625PICO::VIO_1V8 // 1.8V IO (local)
whismanoid 0:cb44e2e9ec4c 781 MAX32625PICO::VIO_IOH // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 782 );
whismanoid 0:cb44e2e9ec4c 783 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 784 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 15:37c83ec50ea0 785 // #warning "TARGET_MAX32625PICO not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 786 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 787 //
whismanoid 0:cb44e2e9ec4c 788 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 789 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 790 // TODO1: target NUCLEO_F446RE
whismanoid 0:cb44e2e9ec4c 791 //
whismanoid 0:cb44e2e9ec4c 792 // USER_BUTTON PC13
whismanoid 0:cb44e2e9ec4c 793 // LED1 is shared with SPI_SCK on NUCLEO_F446RE PA_5, so don't use LED1.
whismanoid 0:cb44e2e9ec4c 794 #define USE_LEDS 0
whismanoid 0:cb44e2e9ec4c 795 // SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
whismanoid 0:cb44e2e9ec4c 796 // Serial serial(SERIAL_TX, SERIAL_RX);
whismanoid 0:cb44e2e9ec4c 797 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 798 const float ADC_FULL_SCALE_VOLTAGE = 3.300; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 799 //
whismanoid 0:cb44e2e9ec4c 800 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 801 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 802 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 803 // TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM
whismanoid 0:cb44e2e9ec4c 804 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 805 // ______ | [ ] GND +3.3V VOUT [ ] | ______
whismanoid 0:cb44e2e9ec4c 806 // ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | ______
whismanoid 0:cb44e2e9ec4c 807 // ______ | [ ] VB USB.IF- [ ] | ______
whismanoid 0:cb44e2e9ec4c 808 // ______ | [ ] nR USB.IF+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 809 // digitalInOut0 | [ ] p5 MOSI ETHERNET.RD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 810 // digitalInOut1 | [ ] p6 MISO ETHERNET.RD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 811 // digitalInOut2 | [ ] p7 SCLK ETHERNET.TD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 812 // digitalInOut3 | [ ] p8 ETHERNET.TD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 813 // digitalInOut4 | [ ] p9 TX SDA USB.D- [ ] | ______
whismanoid 0:cb44e2e9ec4c 814 // digitalInOut5 | [ ] p10 RX SCL USB.D+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 815 // digitalInOut6 | [ ] p11 MOSI CAN-RD p30 [ ] | digitalInOut13
whismanoid 0:cb44e2e9ec4c 816 // digitalInOut7 | [ ] p12 MISO CAN-TD p29 [ ] | digitalInOut12
whismanoid 0:cb44e2e9ec4c 817 // digitalInOut8 | [ ] p13 TX SCLK SDA TX p28 [ ] | digitalInOut11
whismanoid 0:cb44e2e9ec4c 818 // digitalInOut9 | [ ] p14 RX SCL RX p27 [ ] | digitalInOut10
whismanoid 0:cb44e2e9ec4c 819 // analogIn0 | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1
whismanoid 0:cb44e2e9ec4c 820 // analogIn1 | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2
whismanoid 0:cb44e2e9ec4c 821 // analogIn2 | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3
whismanoid 0:cb44e2e9ec4c 822 // analogIn3 | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4
whismanoid 0:cb44e2e9ec4c 823 // analogIn4 | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5
whismanoid 0:cb44e2e9ec4c 824 // analogIn5 | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6
whismanoid 0:cb44e2e9ec4c 825 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 826 // AIN6 = P0.3 = TGT_SBL_RXD?
whismanoid 0:cb44e2e9ec4c 827 // AIN7 = P0.2 = TGT_SBL_TXD?
whismanoid 0:cb44e2e9ec4c 828 //
whismanoid 0:cb44e2e9ec4c 829 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 830 // LPC1768 board uses VREF = 3.300V +A3,3V thru L1 to bypass capacitor C14
whismanoid 0:cb44e2e9ec4c 831 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 832 const float ADC_FULL_SCALE_VOLTAGE = 3.300;
whismanoid 0:cb44e2e9ec4c 833 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 0:cb44e2e9ec4c 834 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 835 // unknown target
whismanoid 0:cb44e2e9ec4c 836 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 837 #endif // target definition
whismanoid 0:cb44e2e9ec4c 838
whismanoid 0:cb44e2e9ec4c 839
whismanoid 0:cb44e2e9ec4c 840
whismanoid 0:cb44e2e9ec4c 841
whismanoid 18:1235c17b451e 842 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 843 // move definiton of USE_LEDS earlier than find_digitalInOutPin()
whismanoid 18:1235c17b451e 844 //--------------------------------------------------
whismanoid 18:1235c17b451e 845 // Option to use LEDs to show status
whismanoid 18:1235c17b451e 846 #ifndef USE_LEDS
whismanoid 18:1235c17b451e 847 #define USE_LEDS 1
whismanoid 18:1235c17b451e 848 #endif
whismanoid 18:1235c17b451e 849 #if USE_LEDS
whismanoid 18:1235c17b451e 850 #if defined(TARGET_MAX32630)
whismanoid 18:1235c17b451e 851 # define LED_ON 0
whismanoid 18:1235c17b451e 852 # define LED_OFF 1
whismanoid 18:1235c17b451e 853 //--------------------------------------------------
whismanoid 18:1235c17b451e 854 #elif defined(TARGET_MAX32625MBED)
whismanoid 18:1235c17b451e 855 # define LED_ON 0
whismanoid 18:1235c17b451e 856 # define LED_OFF 1
whismanoid 19:5ff09c8e9daf 857 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 18:1235c17b451e 858 # define LED_ON 0
whismanoid 18:1235c17b451e 859 # define LED_OFF 1
whismanoid 18:1235c17b451e 860 //--------------------------------------------------
whismanoid 18:1235c17b451e 861 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 18:1235c17b451e 862 #elif defined(TARGET_LPC1768)
whismanoid 18:1235c17b451e 863 # define LED_ON 1
whismanoid 18:1235c17b451e 864 # define LED_OFF 0
whismanoid 18:1235c17b451e 865 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 18:1235c17b451e 866 // USE_LEDS with some platform other than MAX32630, MAX32625MBED, LPC1768
whismanoid 18:1235c17b451e 867 // bugfix for MAX32600MBED LED blink pattern: check if LED_ON/LED_OFF already defined
whismanoid 18:1235c17b451e 868 # ifndef LED_ON
whismanoid 18:1235c17b451e 869 # define LED_ON 0
whismanoid 18:1235c17b451e 870 # endif
whismanoid 18:1235c17b451e 871 # ifndef LED_OFF
whismanoid 18:1235c17b451e 872 # define LED_OFF 1
whismanoid 18:1235c17b451e 873 # endif
whismanoid 18:1235c17b451e 874 //# define LED_ON 1
whismanoid 18:1235c17b451e 875 //# define LED_OFF 0
whismanoid 18:1235c17b451e 876 #endif // target definition
whismanoid 18:1235c17b451e 877 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 878 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 879 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 880 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 881 // change led1/2/3/4 from DigitalOut to DigitalInOut
whismanoid 18:1235c17b451e 882 DigitalInOut led1(LED1, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED1 = LED_RED
whismanoid 18:1235c17b451e 883 DigitalInOut led2(LED2, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN
whismanoid 18:1235c17b451e 884 DigitalInOut led3(LED3, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE
whismanoid 18:1235c17b451e 885 DigitalInOut led4(LED4, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 886 #else // USE_LEDS=0
whismanoid 18:1235c17b451e 887 // issue #41 support Nucleo_F446RE
whismanoid 18:1235c17b451e 888 // there are no LED indicators on the board, LED1 interferes with SPI;
whismanoid 18:1235c17b451e 889 // but we still need placeholders led1 led2 led3 led4.
whismanoid 18:1235c17b451e 890 // Declare DigitalInOut led1 led2 led3 led4 targeting safe pins.
whismanoid 18:1235c17b451e 891 // PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false
whismanoid 18:1235c17b451e 892 # define LED_ON 0
whismanoid 18:1235c17b451e 893 # define LED_OFF 1
whismanoid 18:1235c17b451e 894 // change led1/2/3/4 from DigitalOut to DigitalInOut
whismanoid 18:1235c17b451e 895 DigitalInOut led1(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 896 DigitalInOut led2(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 897 DigitalInOut led3(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 898 DigitalInOut led4(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 899 #endif // USE_LEDS
whismanoid 18:1235c17b451e 900 #define led1_RFailLED led1
whismanoid 18:1235c17b451e 901 #define led2_GPassLED led2
whismanoid 18:1235c17b451e 902 #define led3_BBusyLED led3
whismanoid 18:1235c17b451e 903
whismanoid 21:ac062a97a71d 904 //--------------------------------------------------
whismanoid 21:ac062a97a71d 905 // use BUTTON1 trigger some action
whismanoid 46:469d0061df5d 906 // support for commands %B1! .. %B9!
whismanoid 21:ac062a97a71d 907 #if defined(TARGET_MAX32630)
whismanoid 21:ac062a97a71d 908 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 909 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 910 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 911 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 25:8a61cb34191d 912 // #warning "TARGET_MAX32625PICO not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 913 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 24:032f3683cb2a 914 #if MAX40108_DEMO
whismanoid 25:8a61cb34191d 915 #if HAS_I2C
whismanoid 25:8a61cb34191d 916 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 917 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 24:032f3683cb2a 918 #define BUTTON2 P3_7
whismanoid 25:8a61cb34191d 919 #else // HAS_I2C
whismanoid 25:8a61cb34191d 920 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 921 // MAX40108DEMOP2U9 no HAS_I2C: header J91.1=1V8 J91.2=P1_6(button3/'%B3!') J91.3=P1_7(button2/'%B2!') J91.4=GND
whismanoid 25:8a61cb34191d 922 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 923 #define BUTTON2 P1_7
whismanoid 25:8a61cb34191d 924 #endif // HAS_I2C
whismanoid 24:032f3683cb2a 925 #define HAS_BUTTON2_DEMO 0
whismanoid 24:032f3683cb2a 926 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 25:8a61cb34191d 927 #if HAS_I2C
whismanoid 25:8a61cb34191d 928 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 929 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 24:032f3683cb2a 930 #define BUTTON3 P3_6
whismanoid 25:8a61cb34191d 931 #else // HAS_I2C
whismanoid 25:8a61cb34191d 932 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 933 // MAX40108DEMOP2U9 no HAS_I2C: header J91.1=1V8 J91.2=P1_6(button3/'%B3!') J91.3=P1_7(button2/'%B2!') J91.4=GND
whismanoid 25:8a61cb34191d 934 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 935 #define BUTTON3 P1_6
whismanoid 25:8a61cb34191d 936 #endif // HAS_I2C
whismanoid 24:032f3683cb2a 937 #define HAS_BUTTON3_DEMO 0
whismanoid 24:032f3683cb2a 938 #define HAS_BUTTON3_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 939 // additional buttons are assigned to unused/unaccessible pins to avoid conflicts
whismanoid 29:6a9edb6e973b 940 // activate using %B4! or action_button pin=4
whismanoid 29:6a9edb6e973b 941 #define BUTTON4 P1_5
whismanoid 29:6a9edb6e973b 942 #define HAS_BUTTON4_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 943 #define BUTTON5 P1_4
whismanoid 29:6a9edb6e973b 944 #define HAS_BUTTON5_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 945 #define BUTTON6 P1_3
whismanoid 29:6a9edb6e973b 946 #define HAS_BUTTON6_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 947 #define BUTTON7 P1_2
whismanoid 29:6a9edb6e973b 948 #define HAS_BUTTON7_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 949 #define BUTTON8 P1_1
whismanoid 29:6a9edb6e973b 950 #define HAS_BUTTON8_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 951 #define BUTTON9 P1_0
whismanoid 29:6a9edb6e973b 952 #define HAS_BUTTON9_DEMO_INTERRUPT 1
whismanoid 24:032f3683cb2a 953 #else // MAX40108_DEMO
whismanoid 21:ac062a97a71d 954 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 955 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 29:6a9edb6e973b 956 #endif // MAX40108_DEMO ---------------------------------
whismanoid 21:ac062a97a71d 957 #elif defined(TARGET_MAX32625)
whismanoid 21:ac062a97a71d 958 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 959 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 960 #elif defined(TARGET_MAX32620FTHR)
whismanoid 21:ac062a97a71d 961 #warning "TARGET_MAX32620FTHR not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 962 #define BUTTON1 SW1
whismanoid 21:ac062a97a71d 963 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 964 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 965 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 966 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 21:ac062a97a71d 967 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 968 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 969 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 21:ac062a97a71d 970 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 971 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 972 #else
whismanoid 21:ac062a97a71d 973 #warning "target not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 974 #endif
whismanoid 21:ac062a97a71d 975 //
whismanoid 21:ac062a97a71d 976 #ifndef HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 977 #define HAS_BUTTON1_DEMO 0
whismanoid 21:ac062a97a71d 978 #endif
whismanoid 21:ac062a97a71d 979 #ifndef HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 980 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 981 #endif
whismanoid 24:032f3683cb2a 982 #ifndef HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 983 #define HAS_BUTTON3_DEMO 0
whismanoid 24:032f3683cb2a 984 #endif
whismanoid 21:ac062a97a71d 985 //
whismanoid 21:ac062a97a71d 986 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 987 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 988 #ifndef HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 989 #define HAS_BUTTON1_DEMO_INTERRUPT_POLLING 1
whismanoid 21:ac062a97a71d 990 #endif
whismanoid 21:ac062a97a71d 991 //
whismanoid 21:ac062a97a71d 992 #ifndef HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 993 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 994 #endif
whismanoid 21:ac062a97a71d 995 #ifndef HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 996 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 997 #endif
whismanoid 21:ac062a97a71d 998 //
whismanoid 21:ac062a97a71d 999 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 1000 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 1001 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 1002 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 1003 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 1004 # else
whismanoid 21:ac062a97a71d 1005 InterruptIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 1006 # endif
whismanoid 21:ac062a97a71d 1007 #elif HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 1008 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 1009 #endif
whismanoid 21:ac062a97a71d 1010 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 1011 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 1012 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 1013 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 1014 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 1015 # else
whismanoid 21:ac062a97a71d 1016 InterruptIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 1017 # endif
whismanoid 21:ac062a97a71d 1018 #elif HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 1019 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 1020 #endif
whismanoid 24:032f3683cb2a 1021 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 1022 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 24:032f3683cb2a 1023 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 24:032f3683cb2a 1024 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 24:032f3683cb2a 1025 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 1026 # else
whismanoid 24:032f3683cb2a 1027 InterruptIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 1028 # endif
whismanoid 24:032f3683cb2a 1029 #elif HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 1030 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 1031 #endif
whismanoid 21:ac062a97a71d 1032
whismanoid 0:cb44e2e9ec4c 1033 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 1034 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1035 // Declare the DigitalInOut GPIO pins
whismanoid 0:cb44e2e9ec4c 1036 // Optional digitalInOut support. If there is only one it should be digitalInOut1.
whismanoid 0:cb44e2e9ec4c 1037 // D) Digital High/Low/Input Pin
whismanoid 0:cb44e2e9ec4c 1038 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1039 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 1040 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 1041 // | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 1042 // | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 1043 // | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 1044 // | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 1045 // | [ ] AIN_0 1.2Vfs (bat) SYS [ ] |
whismanoid 0:cb44e2e9ec4c 1046 // | [ ] AIN_1 1.2Vfs PWR [ ] |
whismanoid 0:cb44e2e9ec4c 1047 // | [ ] AIN_2 1.2Vfs +5V VBUS [ ] |
whismanoid 0:cb44e2e9ec4c 1048 // | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9
whismanoid 0:cb44e2e9ec4c 1049 // dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8
whismanoid 0:cb44e2e9ec4c 1050 // dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7
whismanoid 0:cb44e2e9ec4c 1051 // dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6
whismanoid 0:cb44e2e9ec4c 1052 // dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5
whismanoid 0:cb44e2e9ec4c 1053 // dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4
whismanoid 0:cb44e2e9ec4c 1054 // dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3
whismanoid 0:cb44e2e9ec4c 1055 // dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2
whismanoid 0:cb44e2e9ec4c 1056 // | [ ] GND SDA P3_4 [x] | dig1
whismanoid 0:cb44e2e9ec4c 1057 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 1058 #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 1059 #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 1060 #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 1061 #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 1062 #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 1063 #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 1064 #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 1065 #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 1066 #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 1067 #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 1068 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 1069 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1070 #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 1071 #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 1072 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1073 #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 1074 #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 1075 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1076 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 1077 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1078 #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 1079 #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 1080 #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 1081 #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 1082 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1083 #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 1084 #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 1085 #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 1086 #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 1087 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1088 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1089 DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 1090 #endif
whismanoid 0:cb44e2e9ec4c 1091 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1092 DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 1093 #endif
whismanoid 0:cb44e2e9ec4c 1094 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1095 DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 1096 #endif
whismanoid 0:cb44e2e9ec4c 1097 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1098 DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 1099 #endif
whismanoid 0:cb44e2e9ec4c 1100 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1101 DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 1102 #endif
whismanoid 0:cb44e2e9ec4c 1103 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1104 DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 1105 #endif
whismanoid 0:cb44e2e9ec4c 1106 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1107 DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 1108 #endif
whismanoid 0:cb44e2e9ec4c 1109 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1110 DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 1111 #endif
whismanoid 0:cb44e2e9ec4c 1112 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1113 DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 1114 #endif
whismanoid 0:cb44e2e9ec4c 1115 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1116 DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 1117 #endif
whismanoid 0:cb44e2e9ec4c 1118 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1119 DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 1120 #endif
whismanoid 0:cb44e2e9ec4c 1121 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1122 DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 1123 #endif
whismanoid 0:cb44e2e9ec4c 1124 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1125 DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 1126 #endif
whismanoid 0:cb44e2e9ec4c 1127 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1128 DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 1129 #endif
whismanoid 0:cb44e2e9ec4c 1130 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1131 DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 1132 #endif
whismanoid 0:cb44e2e9ec4c 1133 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1134 DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 1135 #endif
whismanoid 0:cb44e2e9ec4c 1136 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1137 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 1138 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 1139 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 1140 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 1141 // | |
whismanoid 0:cb44e2e9ec4c 1142 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 1143 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 1144 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 1145 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 1146 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 1147 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 1148 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 1149 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 1150 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 1151 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 1152 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 1153 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 1154 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 1155 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 1156 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 1157 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 1158 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 1159 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 1160 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 1161 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 1162 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 1163 // \_______________________/
whismanoid 0:cb44e2e9ec4c 1164 //
whismanoid 0:cb44e2e9ec4c 1165 #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 1166 #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 1167 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1168 #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 1169 #else
whismanoid 0:cb44e2e9ec4c 1170 #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 1171 #endif
whismanoid 0:cb44e2e9ec4c 1172 #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 1173 #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 1174 #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 1175 #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 1176 #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 1177 #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 1178 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1179 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 1180 #else
whismanoid 0:cb44e2e9ec4c 1181 #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 1182 #endif
whismanoid 0:cb44e2e9ec4c 1183 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 1184 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1185 #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 1186 #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 1187 #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 1188 #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 1189 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1190 #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 1191 #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 1192 #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 1193 #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 1194 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1195 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 1196 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1197 #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1198 #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1199 #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1200 #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1201 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1202 #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1203 #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1204 #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1205 #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1206 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1207 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1208 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 1209 #endif
whismanoid 0:cb44e2e9ec4c 1210 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1211 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 1212 #endif
whismanoid 0:cb44e2e9ec4c 1213 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1214 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 1215 #endif
whismanoid 0:cb44e2e9ec4c 1216 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1217 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 1218 #endif
whismanoid 0:cb44e2e9ec4c 1219 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1220 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 1221 #endif
whismanoid 0:cb44e2e9ec4c 1222 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1223 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 1224 #endif
whismanoid 0:cb44e2e9ec4c 1225 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1226 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 1227 #endif
whismanoid 0:cb44e2e9ec4c 1228 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1229 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 1230 #endif
whismanoid 0:cb44e2e9ec4c 1231 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1232 DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 1233 #endif
whismanoid 0:cb44e2e9ec4c 1234 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1235 DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 1236 #endif
whismanoid 0:cb44e2e9ec4c 1237 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1238 DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 1239 #endif
whismanoid 0:cb44e2e9ec4c 1240 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1241 DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 1242 #endif
whismanoid 0:cb44e2e9ec4c 1243 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1244 DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 1245 #endif
whismanoid 0:cb44e2e9ec4c 1246 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1247 DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 1248 #endif
whismanoid 0:cb44e2e9ec4c 1249 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1250 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 1251 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 1252 DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1253 #endif
whismanoid 0:cb44e2e9ec4c 1254 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1255 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 1256 DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1257 #endif
whismanoid 0:cb44e2e9ec4c 1258 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1259 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 1260 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 1261 // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V
whismanoid 0:cb44e2e9ec4c 1262 DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1263 #endif
whismanoid 0:cb44e2e9ec4c 1264 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1265 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 1266 DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1267 #endif
whismanoid 0:cb44e2e9ec4c 1268 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 1269 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 15:37c83ec50ea0 1270 // TARGET=MAX32625PICO ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 15:37c83ec50ea0 1271 // +-------------[microUSB]-------------+
whismanoid 15:37c83ec50ea0 1272 // | [27]D+ D-[26] |
whismanoid 15:37c83ec50ea0 1273 // | |
whismanoid 15:37c83ec50ea0 1274 // | [BUTTON P2_7] |
whismanoid 15:37c83ec50ea0 1275 // | P2_4 LED_R P2_5 LED_G P2_6 LED_B |
whismanoid 15:37c83ec50ea0 1276 // | |
whismanoid 15:37c83ec50ea0 1277 // 1V8 | [11] 1.8V MAX32625PICO GND [10] | GND
whismanoid 15:37c83ec50ea0 1278 // 3V3 | [12] 3.3V +5V [09] | 5V0
whismanoid 15:37c83ec50ea0 1279 // SPI CS D7 | [13] P0_7 CS s-ssel P4_7 [08] | D15
whismanoid 15:37c83ec50ea0 1280 // SPI MISO D6 | [14] P0_6 MISO s-miso P4_6 [07] | D14
whismanoid 15:37c83ec50ea0 1281 // SPI MOSI D5 | [15] P0_5 MOSI s-mosi P4_5 [06] | D13
whismanoid 15:37c83ec50ea0 1282 // SPI SCLK D4 | [16] P0_4 SCLK s-sclk P4_4 [05] | D12
whismanoid 15:37c83ec50ea0 1283 // D3 | [17] P0_3 RTS SCL P1_7 [04] | SCL/D17
whismanoid 15:37c83ec50ea0 1284 // D2 | [18] P0_2 CTS SDA P1_6 [03] | SDA/D16
whismanoid 15:37c83ec50ea0 1285 // TX/D1 | [19] P0_1 TX0 AIN_2 [02] | A2
whismanoid 15:37c83ec50ea0 1286 // RX/D0 | [20] P0_0 RX0 AIN_0 [01] | A0/A4
whismanoid 15:37c83ec50ea0 1287 // | |
whismanoid 15:37c83ec50ea0 1288 // | DAPLINK |
whismanoid 15:37c83ec50ea0 1289 // | J3 p3_3 p3_2 p3_0 p3_1 p3_7 |
whismanoid 15:37c83ec50ea0 1290 // | DAP [ ] [ ] [RX2][TX2][ ] |
whismanoid 15:37c83ec50ea0 1291 // | TOP [ ] [ ] [ ] [ ] [ ] |
whismanoid 15:37c83ec50ea0 1292 // | AIN1/A5 gnd gnd nc AIN3 |
whismanoid 15:37c83ec50ea0 1293 // | IOH 1-wire |
whismanoid 15:37c83ec50ea0 1294 // | |
whismanoid 15:37c83ec50ea0 1295 // |NO USE RST P2_0 P2_1 |
whismanoid 15:37c83ec50ea0 1296 // |BOTTOM [ ] [ ] [RX1][ ] [TX1] |
whismanoid 15:37c83ec50ea0 1297 // | RST SWC GND SWD 1V8 |
whismanoid 15:37c83ec50ea0 1298 // |BOTTOM [21] [22] [23] [24] [25] |
whismanoid 15:37c83ec50ea0 1299 // +------------------------------------+
whismanoid 15:37c83ec50ea0 1300 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 1301 // MAX40108 demo p2: D0..D7 = P0_0..P0_7; D8..15 = P4_0..P4_7; D16/D17=I2C
whismanoid 15:37c83ec50ea0 1302 #endif
whismanoid 15:37c83ec50ea0 1303 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1304 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1305 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1306 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1307 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 1308 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 1309 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 1310 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1311 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1312 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 15:37c83ec50ea0 1313 // AIN_10 = x undefined?
whismanoid 15:37c83ec50ea0 1314 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 1315 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 1316 //
whismanoid 15:37c83ec50ea0 1317 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 1318 // avoid resource conflict D0,D1 alternate function as RX/TX
whismanoid 15:37c83ec50ea0 1319 #define HAS_digitalInOut0 0
whismanoid 15:37c83ec50ea0 1320 #define HAS_digitalInOut1 0
whismanoid 15:37c83ec50ea0 1321 #else
whismanoid 15:37c83ec50ea0 1322 #define HAS_digitalInOut0 1
whismanoid 19:5ff09c8e9daf 1323 #define HAS_digitalInOut1 1
whismanoid 19:5ff09c8e9daf 1324 // P0_1 TARGET_MAX32625PICO D1
whismanoid 15:37c83ec50ea0 1325 #endif
whismanoid 15:37c83ec50ea0 1326 #if APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 1327 // avoid resource conflict D2 alternate function as interrupt input
whismanoid 15:37c83ec50ea0 1328 #define HAS_digitalInOut2 0
whismanoid 15:37c83ec50ea0 1329 #else
whismanoid 15:37c83ec50ea0 1330 #define HAS_digitalInOut2 1
whismanoid 15:37c83ec50ea0 1331 #endif
whismanoid 15:37c83ec50ea0 1332 #define HAS_digitalInOut3 1
whismanoid 15:37c83ec50ea0 1333 #define HAS_digitalInOut4 1
whismanoid 15:37c83ec50ea0 1334 #define HAS_digitalInOut5 1
whismanoid 15:37c83ec50ea0 1335 #define HAS_digitalInOut6 1
whismanoid 15:37c83ec50ea0 1336 #define HAS_digitalInOut7 1
whismanoid 15:37c83ec50ea0 1337 //
whismanoid 15:37c83ec50ea0 1338 #define HAS_digitalInOut8 1
whismanoid 15:37c83ec50ea0 1339 #define HAS_digitalInOut9 1
whismanoid 15:37c83ec50ea0 1340 #define HAS_digitalInOut10 1
whismanoid 15:37c83ec50ea0 1341 #define HAS_digitalInOut11 1
whismanoid 15:37c83ec50ea0 1342 #define HAS_digitalInOut12 1
whismanoid 15:37c83ec50ea0 1343 #define HAS_digitalInOut13 1
whismanoid 15:37c83ec50ea0 1344 #define HAS_digitalInOut14 1
whismanoid 15:37c83ec50ea0 1345 #define HAS_digitalInOut15 1
whismanoid 15:37c83ec50ea0 1346 #if HAS_I2C
whismanoid 25:8a61cb34191d 1347 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 1348 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 25:8a61cb34191d 1349 // #define BUTTON2 P3_7
whismanoid 25:8a61cb34191d 1350 // avoid resource conflict between I2C and DigitalInOut
whismanoid 25:8a61cb34191d 1351 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1352 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 1353 #else // HAS_I2C
whismanoid 25:8a61cb34191d 1354 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 1355 // MAX40108DEMOP2U9 no HAS_I2C: header J91.1=1V8 J91.2=P1_6(button3/'%B3!') J91.3=P1_7(button2/'%B2!') J91.4=GND
whismanoid 25:8a61cb34191d 1356 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1357 // #define BUTTON2 P1_7
whismanoid 25:8a61cb34191d 1358 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1359 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1360 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1361 #else // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1362 #define HAS_digitalInOut16 1 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1363 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1364 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1365 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1366 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1367 #else // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1368 #define HAS_digitalInOut17 1 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1369 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 15:37c83ec50ea0 1370 #endif // HAS_I2C
whismanoid 15:37c83ec50ea0 1371 #if HAS_digitalInOut0
whismanoid 25:8a61cb34191d 1372 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D0
whismanoid 15:37c83ec50ea0 1373 #endif
whismanoid 15:37c83ec50ea0 1374 #if HAS_digitalInOut1
whismanoid 25:8a61cb34191d 1375 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D1
whismanoid 15:37c83ec50ea0 1376 #endif
whismanoid 15:37c83ec50ea0 1377 #if HAS_digitalInOut2
whismanoid 25:8a61cb34191d 1378 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D2
whismanoid 15:37c83ec50ea0 1379 #endif
whismanoid 15:37c83ec50ea0 1380 #if HAS_digitalInOut3
whismanoid 25:8a61cb34191d 1381 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D3
whismanoid 15:37c83ec50ea0 1382 #endif
whismanoid 15:37c83ec50ea0 1383 #if HAS_digitalInOut4
whismanoid 25:8a61cb34191d 1384 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D4
whismanoid 15:37c83ec50ea0 1385 #endif
whismanoid 15:37c83ec50ea0 1386 #if HAS_digitalInOut5
whismanoid 25:8a61cb34191d 1387 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D5
whismanoid 15:37c83ec50ea0 1388 #endif
whismanoid 15:37c83ec50ea0 1389 #if HAS_digitalInOut6
whismanoid 25:8a61cb34191d 1390 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D6
whismanoid 15:37c83ec50ea0 1391 #endif
whismanoid 15:37c83ec50ea0 1392 #if HAS_digitalInOut7
whismanoid 25:8a61cb34191d 1393 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D7
whismanoid 15:37c83ec50ea0 1394 #endif
whismanoid 15:37c83ec50ea0 1395 #if HAS_digitalInOut8
whismanoid 25:8a61cb34191d 1396 DigitalInOut digitalInOut8(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX40108DEMOP2U9 D8
whismanoid 15:37c83ec50ea0 1397 #endif
whismanoid 15:37c83ec50ea0 1398 #if HAS_digitalInOut9
whismanoid 25:8a61cb34191d 1399 DigitalInOut digitalInOut9(P4_1, PIN_INPUT, PullUp, 1); // P4_1 TARGET_MAX40108DEMOP2U9 D9
whismanoid 15:37c83ec50ea0 1400 #endif
whismanoid 15:37c83ec50ea0 1401 #if HAS_digitalInOut10
whismanoid 25:8a61cb34191d 1402 DigitalInOut digitalInOut10(P4_2, PIN_INPUT, PullUp, 1); // P4_2 TARGET_MAX40108DEMOP2U9 D10
whismanoid 15:37c83ec50ea0 1403 #endif
whismanoid 15:37c83ec50ea0 1404 #if HAS_digitalInOut11
whismanoid 25:8a61cb34191d 1405 DigitalInOut digitalInOut11(P4_3, PIN_INPUT, PullUp, 1); // P4_3 TARGET_MAX40108DEMOP2U9 D11
whismanoid 15:37c83ec50ea0 1406 #endif
whismanoid 15:37c83ec50ea0 1407 #if HAS_digitalInOut12
whismanoid 25:8a61cb34191d 1408 DigitalInOut digitalInOut12(P4_4, PIN_INPUT, PullUp, 1); // P4_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D12
whismanoid 15:37c83ec50ea0 1409 #endif
whismanoid 15:37c83ec50ea0 1410 #if HAS_digitalInOut13
whismanoid 25:8a61cb34191d 1411 DigitalInOut digitalInOut13(P4_5, PIN_INPUT, PullUp, 1); // P4_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D13
whismanoid 15:37c83ec50ea0 1412 #endif
whismanoid 15:37c83ec50ea0 1413 #if HAS_digitalInOut14
whismanoid 25:8a61cb34191d 1414 DigitalInOut digitalInOut14(P4_6, PIN_INPUT, PullUp, 1); // P4_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D14
whismanoid 15:37c83ec50ea0 1415 #endif
whismanoid 15:37c83ec50ea0 1416 #if HAS_digitalInOut15
whismanoid 25:8a61cb34191d 1417 DigitalInOut digitalInOut15(P4_7, PIN_INPUT, PullUp, 1); // P4_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D15
whismanoid 15:37c83ec50ea0 1418 #endif
whismanoid 15:37c83ec50ea0 1419 #if HAS_digitalInOut16
whismanoid 15:37c83ec50ea0 1420 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 15:37c83ec50ea0 1421 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 25:8a61cb34191d 1422 DigitalInOut digitalInOut16(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 15:37c83ec50ea0 1423 #endif
whismanoid 15:37c83ec50ea0 1424 #if HAS_digitalInOut17
whismanoid 15:37c83ec50ea0 1425 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 25:8a61cb34191d 1426 DigitalInOut digitalInOut17(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 1427 #endif
whismanoid 15:37c83ec50ea0 1428 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1429 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1430 #define HAS_digitalInOut0 0
whismanoid 0:cb44e2e9ec4c 1431 #define HAS_digitalInOut1 0
whismanoid 0:cb44e2e9ec4c 1432 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1433 // D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 1434 #define HAS_digitalInOut2 0
whismanoid 0:cb44e2e9ec4c 1435 #else
whismanoid 0:cb44e2e9ec4c 1436 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1437 #endif
whismanoid 0:cb44e2e9ec4c 1438 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1439 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1440 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1441 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1442 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1443 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1444 // D8 -- MAX5715 CLRb DigitalOut
whismanoid 0:cb44e2e9ec4c 1445 #define HAS_digitalInOut8 0
whismanoid 0:cb44e2e9ec4c 1446 #else
whismanoid 0:cb44e2e9ec4c 1447 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1448 #endif
whismanoid 0:cb44e2e9ec4c 1449 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1450 // D9 -- MAX5715 LDACb DigitalOut
whismanoid 0:cb44e2e9ec4c 1451 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1452 #elif APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1453 // D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 1454 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1455 #else
whismanoid 0:cb44e2e9ec4c 1456 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1457 #endif
whismanoid 0:cb44e2e9ec4c 1458 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 1459 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1460 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1461 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1462 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1463 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1464 #define HAS_digitalInOut10 0
whismanoid 0:cb44e2e9ec4c 1465 #define HAS_digitalInOut11 0
whismanoid 0:cb44e2e9ec4c 1466 #define HAS_digitalInOut12 0
whismanoid 0:cb44e2e9ec4c 1467 #define HAS_digitalInOut13 0
whismanoid 0:cb44e2e9ec4c 1468 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1469 #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1470 #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1471 #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1472 #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1473 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1474 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 1475 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1476 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1477 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1478 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1479 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1480 #define HAS_digitalInOut14 0
whismanoid 0:cb44e2e9ec4c 1481 #define HAS_digitalInOut15 0
whismanoid 0:cb44e2e9ec4c 1482 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1483 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1484 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1485 #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1486 #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1487 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1488 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1489 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1490 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1491 DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1492 #endif
whismanoid 0:cb44e2e9ec4c 1493 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1494 DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1495 #endif
whismanoid 0:cb44e2e9ec4c 1496 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1497 DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1498 #endif
whismanoid 0:cb44e2e9ec4c 1499 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1500 DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1501 #endif
whismanoid 0:cb44e2e9ec4c 1502 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1503 DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1504 #endif
whismanoid 0:cb44e2e9ec4c 1505 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1506 DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1507 #endif
whismanoid 0:cb44e2e9ec4c 1508 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1509 DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1510 #endif
whismanoid 0:cb44e2e9ec4c 1511 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1512 DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1513 #endif
whismanoid 0:cb44e2e9ec4c 1514 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1515 DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1516 #endif
whismanoid 0:cb44e2e9ec4c 1517 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1518 DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1519 #endif
whismanoid 0:cb44e2e9ec4c 1520 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1521 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1522 DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1523 #endif
whismanoid 0:cb44e2e9ec4c 1524 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1525 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1526 DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1527 #endif
whismanoid 0:cb44e2e9ec4c 1528 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1529 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1530 DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1531 #endif
whismanoid 0:cb44e2e9ec4c 1532 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1533 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1534 DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1535 #endif
whismanoid 0:cb44e2e9ec4c 1536 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1537 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1538 DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1539 #endif
whismanoid 0:cb44e2e9ec4c 1540 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1541 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1542 DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1543 #endif
whismanoid 0:cb44e2e9ec4c 1544 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1545 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1546 DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1547 #endif
whismanoid 0:cb44e2e9ec4c 1548 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1549 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1550 DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1551 #endif
whismanoid 0:cb44e2e9ec4c 1552 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1553 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1554 #define HAS_digitalInOut0 1
whismanoid 0:cb44e2e9ec4c 1555 #define HAS_digitalInOut1 1
whismanoid 0:cb44e2e9ec4c 1556 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1557 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1558 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1559 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1560 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1561 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1562 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1563 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1564 // #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1565 // #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1566 // #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1567 // #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1568 // #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1569 // #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1570 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1571 DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3
whismanoid 0:cb44e2e9ec4c 1572 #endif
whismanoid 0:cb44e2e9ec4c 1573 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1574 DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2
whismanoid 0:cb44e2e9ec4c 1575 #endif
whismanoid 0:cb44e2e9ec4c 1576 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1577 DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1
whismanoid 0:cb44e2e9ec4c 1578 #endif
whismanoid 0:cb44e2e9ec4c 1579 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1580 DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0
whismanoid 0:cb44e2e9ec4c 1581 #endif
whismanoid 0:cb44e2e9ec4c 1582 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1583 DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1
whismanoid 0:cb44e2e9ec4c 1584 #endif
whismanoid 0:cb44e2e9ec4c 1585 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1586 DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1
whismanoid 0:cb44e2e9ec4c 1587 #endif
whismanoid 0:cb44e2e9ec4c 1588 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1589 DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1
whismanoid 0:cb44e2e9ec4c 1590 #endif
whismanoid 0:cb44e2e9ec4c 1591 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1592 DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO
whismanoid 0:cb44e2e9ec4c 1593 #endif
whismanoid 0:cb44e2e9ec4c 1594 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1595 DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK
whismanoid 0:cb44e2e9ec4c 1596 #endif
whismanoid 0:cb44e2e9ec4c 1597 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1598 DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL
whismanoid 0:cb44e2e9ec4c 1599 #endif
whismanoid 0:cb44e2e9ec4c 1600 //
whismanoid 0:cb44e2e9ec4c 1601 // these pins support analog input analogIn0 .. analogIn5
whismanoid 0:cb44e2e9ec4c 1602 //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1603 //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1604 //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1605 //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1606 //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1607 //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1608 //
whismanoid 0:cb44e2e9ec4c 1609 // these pins support PWM pwmDriver1 .. pwmDriver6
whismanoid 0:cb44e2e9ec4c 1610 //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0
whismanoid 0:cb44e2e9ec4c 1611 //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1
whismanoid 0:cb44e2e9ec4c 1612 //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2
whismanoid 0:cb44e2e9ec4c 1613 //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3
whismanoid 0:cb44e2e9ec4c 1614 //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1
whismanoid 0:cb44e2e9ec4c 1615 //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK
whismanoid 0:cb44e2e9ec4c 1616 //
whismanoid 0:cb44e2e9ec4c 1617 // these could be additional digitalInOut pins
whismanoid 0:cb44e2e9ec4c 1618 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1619 DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1
whismanoid 0:cb44e2e9ec4c 1620 #endif
whismanoid 0:cb44e2e9ec4c 1621 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1622 DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0
whismanoid 0:cb44e2e9ec4c 1623 #endif
whismanoid 0:cb44e2e9ec4c 1624 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1625 DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1
whismanoid 0:cb44e2e9ec4c 1626 #endif
whismanoid 0:cb44e2e9ec4c 1627 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1628 DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0
whismanoid 0:cb44e2e9ec4c 1629 #endif
whismanoid 0:cb44e2e9ec4c 1630 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1631 DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1632 #endif
whismanoid 0:cb44e2e9ec4c 1633 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1634 DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1635 #endif
whismanoid 0:cb44e2e9ec4c 1636 #else
whismanoid 0:cb44e2e9ec4c 1637 // unknown target
whismanoid 0:cb44e2e9ec4c 1638 #endif
whismanoid 0:cb44e2e9ec4c 1639 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1640 #if HAS_digitalInOut0 || HAS_digitalInOut1 \
whismanoid 0:cb44e2e9ec4c 1641 || HAS_digitalInOut2 || HAS_digitalInOut3 \
whismanoid 0:cb44e2e9ec4c 1642 || HAS_digitalInOut4 || HAS_digitalInOut5 \
whismanoid 0:cb44e2e9ec4c 1643 || HAS_digitalInOut6 || HAS_digitalInOut7 \
whismanoid 0:cb44e2e9ec4c 1644 || HAS_digitalInOut8 || HAS_digitalInOut9 \
whismanoid 0:cb44e2e9ec4c 1645 || HAS_digitalInOut10 || HAS_digitalInOut11 \
whismanoid 0:cb44e2e9ec4c 1646 || HAS_digitalInOut12 || HAS_digitalInOut13 \
whismanoid 0:cb44e2e9ec4c 1647 || HAS_digitalInOut14 || HAS_digitalInOut15 \
whismanoid 0:cb44e2e9ec4c 1648 || HAS_digitalInOut16 || HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1649 #define HAS_digitalInOuts 1
whismanoid 0:cb44e2e9ec4c 1650 #else
whismanoid 0:cb44e2e9ec4c 1651 #warning "Note: There are no digitalInOut resources defined"
whismanoid 0:cb44e2e9ec4c 1652 #endif
whismanoid 0:cb44e2e9ec4c 1653
whismanoid 0:cb44e2e9ec4c 1654 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 1655 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1656 // Declare the AnalogIn driver
whismanoid 0:cb44e2e9ec4c 1657 // Optional analogIn support. If there is only one it should be analogIn1.
whismanoid 0:cb44e2e9ec4c 1658 // A) analog input
whismanoid 0:cb44e2e9ec4c 1659 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1660 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1661 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1662 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1663 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1664 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1665 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1666 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1667 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1668 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1669 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1670 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1671 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1672 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1673 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1674 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1675 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1676 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1677 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1678 #endif
whismanoid 0:cb44e2e9ec4c 1679 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1680 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1681 #endif
whismanoid 0:cb44e2e9ec4c 1682 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1683 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1684 #endif
whismanoid 0:cb44e2e9ec4c 1685 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1686 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1687 #endif
whismanoid 0:cb44e2e9ec4c 1688 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1689 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1690 #endif
whismanoid 0:cb44e2e9ec4c 1691 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1692 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1693 #endif
whismanoid 0:cb44e2e9ec4c 1694 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1695 AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1696 #endif
whismanoid 0:cb44e2e9ec4c 1697 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1698 AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1699 #endif
whismanoid 0:cb44e2e9ec4c 1700 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1701 AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1702 #endif
whismanoid 0:cb44e2e9ec4c 1703 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1704 AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1705 #endif
whismanoid 0:cb44e2e9ec4c 1706 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1707 AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1708 #endif
whismanoid 0:cb44e2e9ec4c 1709 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1710 AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1711 #endif
whismanoid 0:cb44e2e9ec4c 1712 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1713 AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1714 #endif
whismanoid 0:cb44e2e9ec4c 1715 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1716 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1717 #endif
whismanoid 0:cb44e2e9ec4c 1718 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1719 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1720 #endif
whismanoid 0:cb44e2e9ec4c 1721 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1722 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1723 #endif
whismanoid 0:cb44e2e9ec4c 1724 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1725 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 1726 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1727 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1728 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1729 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1730 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1731 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1732 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1733 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1734 #endif
whismanoid 0:cb44e2e9ec4c 1735 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1736 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1737 #endif
whismanoid 0:cb44e2e9ec4c 1738 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1739 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1740 #endif
whismanoid 0:cb44e2e9ec4c 1741 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1742 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1743 #endif
whismanoid 0:cb44e2e9ec4c 1744 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1745 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1746 #endif
whismanoid 0:cb44e2e9ec4c 1747 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1748 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1749 #endif
whismanoid 0:cb44e2e9ec4c 1750 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1751 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 1752 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1753 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1754 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1755 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1756 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1757 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1758 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1759 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1760 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1761 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1762 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1763 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1764 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1765 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1766 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1767 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1768 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1769 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1770 AnalogIn analogIn0(AIN_0); // TARGET_MAX32620FTHR J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1771 #endif
whismanoid 0:cb44e2e9ec4c 1772 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1773 AnalogIn analogIn1(AIN_1); // TARGET_MAX32620FTHR J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1774 #endif
whismanoid 0:cb44e2e9ec4c 1775 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1776 AnalogIn analogIn2(AIN_2); // TARGET_MAX32620FTHR J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1777 #endif
whismanoid 0:cb44e2e9ec4c 1778 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1779 AnalogIn analogIn3(AIN_3); // TARGET_MAX32620FTHR J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1780 #endif
whismanoid 0:cb44e2e9ec4c 1781 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1782 AnalogIn analogIn4(AIN_4); // TARGET_MAX32620FTHR J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1783 #endif
whismanoid 0:cb44e2e9ec4c 1784 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1785 AnalogIn analogIn5(AIN_5); // TARGET_MAX32620FTHR J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1786 #endif
whismanoid 0:cb44e2e9ec4c 1787 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1788 AnalogIn analogIn6(AIN_6); // TARGET_MAX32620FTHR AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1789 #endif
whismanoid 0:cb44e2e9ec4c 1790 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1791 AnalogIn analogIn7(AIN_7); // TARGET_MAX32620FTHR AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1792 #endif
whismanoid 0:cb44e2e9ec4c 1793 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1794 AnalogIn analogIn8(AIN_8); // TARGET_MAX32620FTHR AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1795 #endif
whismanoid 0:cb44e2e9ec4c 1796 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1797 AnalogIn analogIn9(AIN_9); // TARGET_MAX32620FTHR AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1798 #endif
whismanoid 0:cb44e2e9ec4c 1799 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1800 AnalogIn analogIn10(____); // TARGET_MAX32620FTHR AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1801 #endif
whismanoid 0:cb44e2e9ec4c 1802 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1803 AnalogIn analogIn11(____); // TARGET_MAX32620FTHR AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1804 #endif
whismanoid 0:cb44e2e9ec4c 1805 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1806 AnalogIn analogIn12(____); // TARGET_MAX32620FTHR AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1807 #endif
whismanoid 0:cb44e2e9ec4c 1808 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1809 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1810 #endif
whismanoid 0:cb44e2e9ec4c 1811 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1812 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1813 #endif
whismanoid 0:cb44e2e9ec4c 1814 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1815 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1816 #endif
whismanoid 0:cb44e2e9ec4c 1817 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 1818 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 37:3f369235e5bc 1819 // #warning "TARGET_MAX32625PICO not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1820 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1821 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1822 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1823 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1824 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1825 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1826 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1827 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1828 #endif
whismanoid 0:cb44e2e9ec4c 1829 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1830 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1831 #endif
whismanoid 0:cb44e2e9ec4c 1832 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1833 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1834 #endif
whismanoid 0:cb44e2e9ec4c 1835 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1836 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1837 #endif
whismanoid 0:cb44e2e9ec4c 1838 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1839 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1840 #endif
whismanoid 0:cb44e2e9ec4c 1841 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1842 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1843 #endif
whismanoid 0:cb44e2e9ec4c 1844 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1845 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 1846 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1847 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1848 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1849 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1850 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1851 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1852 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1853 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1854 #endif
whismanoid 0:cb44e2e9ec4c 1855 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1856 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1857 #endif
whismanoid 0:cb44e2e9ec4c 1858 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1859 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1860 #endif
whismanoid 0:cb44e2e9ec4c 1861 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1862 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1863 #endif
whismanoid 0:cb44e2e9ec4c 1864 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1865 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1866 #endif
whismanoid 0:cb44e2e9ec4c 1867 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1868 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1869 #endif
whismanoid 0:cb44e2e9ec4c 1870 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1871 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 1872 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1873 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1874 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1875 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1876 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1877 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1878 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1879 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1880 #endif
whismanoid 0:cb44e2e9ec4c 1881 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1882 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1883 #endif
whismanoid 0:cb44e2e9ec4c 1884 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1885 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1886 #endif
whismanoid 0:cb44e2e9ec4c 1887 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1888 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1889 #endif
whismanoid 0:cb44e2e9ec4c 1890 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1891 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1892 #endif
whismanoid 0:cb44e2e9ec4c 1893 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1894 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1895 #endif
whismanoid 0:cb44e2e9ec4c 1896 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1897 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1898 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1899 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1900 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1901 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1902 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1903 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1904 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1905 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1906 #endif
whismanoid 0:cb44e2e9ec4c 1907 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1908 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1909 #endif
whismanoid 0:cb44e2e9ec4c 1910 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1911 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1912 #endif
whismanoid 0:cb44e2e9ec4c 1913 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1914 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1915 #endif
whismanoid 0:cb44e2e9ec4c 1916 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1917 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1918 #endif
whismanoid 0:cb44e2e9ec4c 1919 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1920 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1921 #endif
whismanoid 0:cb44e2e9ec4c 1922 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1923 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 1924 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1925 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1926 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1927 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1928 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1929 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1930 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1931 // #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1932 // #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1933 // #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1934 // #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1935 // #define HAS_analogIn10 1
whismanoid 0:cb44e2e9ec4c 1936 // #define HAS_analogIn11 1
whismanoid 0:cb44e2e9ec4c 1937 // #define HAS_analogIn12 1
whismanoid 0:cb44e2e9ec4c 1938 // #define HAS_analogIn13 1
whismanoid 0:cb44e2e9ec4c 1939 // #define HAS_analogIn14 1
whismanoid 0:cb44e2e9ec4c 1940 // #define HAS_analogIn15 1
whismanoid 0:cb44e2e9ec4c 1941 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1942 AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1943 #endif
whismanoid 0:cb44e2e9ec4c 1944 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1945 AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1946 #endif
whismanoid 0:cb44e2e9ec4c 1947 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1948 AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1949 #endif
whismanoid 0:cb44e2e9ec4c 1950 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1951 AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1952 #endif
whismanoid 0:cb44e2e9ec4c 1953 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1954 AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1955 #endif
whismanoid 0:cb44e2e9ec4c 1956 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1957 AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1958 #endif
whismanoid 0:cb44e2e9ec4c 1959 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1960 AnalogIn analogIn6(____);
whismanoid 0:cb44e2e9ec4c 1961 #endif
whismanoid 0:cb44e2e9ec4c 1962 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1963 AnalogIn analogIn7(____);
whismanoid 0:cb44e2e9ec4c 1964 #endif
whismanoid 0:cb44e2e9ec4c 1965 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1966 AnalogIn analogIn8(____);
whismanoid 0:cb44e2e9ec4c 1967 #endif
whismanoid 0:cb44e2e9ec4c 1968 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1969 AnalogIn analogIn9(____);
whismanoid 0:cb44e2e9ec4c 1970 #endif
whismanoid 0:cb44e2e9ec4c 1971 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1972 AnalogIn analogIn10(____);
whismanoid 0:cb44e2e9ec4c 1973 #endif
whismanoid 0:cb44e2e9ec4c 1974 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1975 AnalogIn analogIn11(____);
whismanoid 0:cb44e2e9ec4c 1976 #endif
whismanoid 0:cb44e2e9ec4c 1977 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1978 AnalogIn analogIn12(____);
whismanoid 0:cb44e2e9ec4c 1979 #endif
whismanoid 0:cb44e2e9ec4c 1980 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1981 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1982 #endif
whismanoid 0:cb44e2e9ec4c 1983 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1984 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1985 #endif
whismanoid 0:cb44e2e9ec4c 1986 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1987 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1988 #endif
whismanoid 0:cb44e2e9ec4c 1989 #else
whismanoid 0:cb44e2e9ec4c 1990 // unknown target
whismanoid 0:cb44e2e9ec4c 1991 #endif
whismanoid 0:cb44e2e9ec4c 1992 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1993 #if HAS_analogIn0 || HAS_analogIn1 \
whismanoid 0:cb44e2e9ec4c 1994 || HAS_analogIn2 || HAS_analogIn3 \
whismanoid 0:cb44e2e9ec4c 1995 || HAS_analogIn4 || HAS_analogIn5 \
whismanoid 0:cb44e2e9ec4c 1996 || HAS_analogIn6 || HAS_analogIn7 \
whismanoid 0:cb44e2e9ec4c 1997 || HAS_analogIn8 || HAS_analogIn9 \
whismanoid 0:cb44e2e9ec4c 1998 || HAS_analogIn10 || HAS_analogIn11 \
whismanoid 0:cb44e2e9ec4c 1999 || HAS_analogIn12 || HAS_analogIn13 \
whismanoid 0:cb44e2e9ec4c 2000 || HAS_analogIn14 || HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 2001 #define HAS_analogIns 1
whismanoid 0:cb44e2e9ec4c 2002 #else
whismanoid 0:cb44e2e9ec4c 2003 #warning "Note: There are no analogIn resources defined"
whismanoid 0:cb44e2e9ec4c 2004 #endif
whismanoid 0:cb44e2e9ec4c 2005
whismanoid 0:cb44e2e9ec4c 2006 // DigitalInOut pin resource: print the pin index names to serial
whismanoid 0:cb44e2e9ec4c 2007 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 2008 void list_digitalInOutPins(Stream& serialStream)
whismanoid 0:cb44e2e9ec4c 2009 {
whismanoid 0:cb44e2e9ec4c 2010 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 2011 serialStream.printf(" 0");
whismanoid 0:cb44e2e9ec4c 2012 #endif
whismanoid 0:cb44e2e9ec4c 2013 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 2014 serialStream.printf(" 1");
whismanoid 0:cb44e2e9ec4c 2015 #endif
whismanoid 0:cb44e2e9ec4c 2016 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 2017 serialStream.printf(" 2");
whismanoid 0:cb44e2e9ec4c 2018 #endif
whismanoid 0:cb44e2e9ec4c 2019 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 2020 serialStream.printf(" 3");
whismanoid 0:cb44e2e9ec4c 2021 #endif
whismanoid 0:cb44e2e9ec4c 2022 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 2023 serialStream.printf(" 4");
whismanoid 0:cb44e2e9ec4c 2024 #endif
whismanoid 0:cb44e2e9ec4c 2025 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 2026 serialStream.printf(" 5");
whismanoid 0:cb44e2e9ec4c 2027 #endif
whismanoid 0:cb44e2e9ec4c 2028 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 2029 serialStream.printf(" 6");
whismanoid 0:cb44e2e9ec4c 2030 #endif
whismanoid 0:cb44e2e9ec4c 2031 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 2032 serialStream.printf(" 7");
whismanoid 0:cb44e2e9ec4c 2033 #endif
whismanoid 0:cb44e2e9ec4c 2034 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 2035 serialStream.printf(" 8");
whismanoid 0:cb44e2e9ec4c 2036 #endif
whismanoid 0:cb44e2e9ec4c 2037 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 2038 serialStream.printf(" 9");
whismanoid 0:cb44e2e9ec4c 2039 #endif
whismanoid 0:cb44e2e9ec4c 2040 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 2041 serialStream.printf(" 10");
whismanoid 0:cb44e2e9ec4c 2042 #endif
whismanoid 0:cb44e2e9ec4c 2043 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 2044 serialStream.printf(" 11");
whismanoid 0:cb44e2e9ec4c 2045 #endif
whismanoid 0:cb44e2e9ec4c 2046 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 2047 serialStream.printf(" 12");
whismanoid 0:cb44e2e9ec4c 2048 #endif
whismanoid 0:cb44e2e9ec4c 2049 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 2050 serialStream.printf(" 13");
whismanoid 0:cb44e2e9ec4c 2051 #endif
whismanoid 0:cb44e2e9ec4c 2052 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 2053 serialStream.printf(" 14");
whismanoid 0:cb44e2e9ec4c 2054 #endif
whismanoid 0:cb44e2e9ec4c 2055 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 2056 serialStream.printf(" 15");
whismanoid 0:cb44e2e9ec4c 2057 #endif
whismanoid 0:cb44e2e9ec4c 2058 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 2059 serialStream.printf(" 16");
whismanoid 0:cb44e2e9ec4c 2060 #endif
whismanoid 0:cb44e2e9ec4c 2061 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 2062 serialStream.printf(" 17");
whismanoid 0:cb44e2e9ec4c 2063 #endif
whismanoid 18:1235c17b451e 2064 #if USE_LEDS
whismanoid 18:1235c17b451e 2065 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 2066 // support list_digitalInOutPins() listing buttons and leds as pin numbers 90/91/92/93
whismanoid 18:1235c17b451e 2067 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 2068 //~ serialStream.printf(" 90");
whismanoid 18:1235c17b451e 2069 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 2070 serialStream.printf(" 91");
whismanoid 18:1235c17b451e 2071 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 2072 serialStream.printf(" 92");
whismanoid 18:1235c17b451e 2073 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 2074 serialStream.printf(" 93");
whismanoid 18:1235c17b451e 2075 #else // USE_LEDS
whismanoid 18:1235c17b451e 2076 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 2077 }
whismanoid 0:cb44e2e9ec4c 2078 #endif
whismanoid 0:cb44e2e9ec4c 2079
whismanoid 0:cb44e2e9ec4c 2080
whismanoid 0:cb44e2e9ec4c 2081 // DigitalInOut pin resource: search index
whismanoid 0:cb44e2e9ec4c 2082 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 2083 DigitalInOut& find_digitalInOutPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 2084 {
whismanoid 0:cb44e2e9ec4c 2085 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 2086 {
whismanoid 0:cb44e2e9ec4c 2087 default: // default to the first defined digitalInOut pin
whismanoid 0:cb44e2e9ec4c 2088 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 2089 case '0': case 0x00: return digitalInOut0;
whismanoid 0:cb44e2e9ec4c 2090 #endif
whismanoid 0:cb44e2e9ec4c 2091 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 2092 case '1': case 0x01: return digitalInOut1;
whismanoid 0:cb44e2e9ec4c 2093 #endif
whismanoid 0:cb44e2e9ec4c 2094 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 2095 case '2': case 0x02: return digitalInOut2;
whismanoid 0:cb44e2e9ec4c 2096 #endif
whismanoid 0:cb44e2e9ec4c 2097 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 2098 case '3': case 0x03: return digitalInOut3;
whismanoid 0:cb44e2e9ec4c 2099 #endif
whismanoid 0:cb44e2e9ec4c 2100 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 2101 case '4': case 0x04: return digitalInOut4;
whismanoid 0:cb44e2e9ec4c 2102 #endif
whismanoid 0:cb44e2e9ec4c 2103 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 2104 case '5': case 0x05: return digitalInOut5;
whismanoid 0:cb44e2e9ec4c 2105 #endif
whismanoid 0:cb44e2e9ec4c 2106 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 2107 case '6': case 0x06: return digitalInOut6;
whismanoid 0:cb44e2e9ec4c 2108 #endif
whismanoid 0:cb44e2e9ec4c 2109 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 2110 case '7': case 0x07: return digitalInOut7;
whismanoid 0:cb44e2e9ec4c 2111 #endif
whismanoid 0:cb44e2e9ec4c 2112 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 2113 case '8': case 0x08: return digitalInOut8;
whismanoid 0:cb44e2e9ec4c 2114 #endif
whismanoid 0:cb44e2e9ec4c 2115 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 2116 case '9': case 0x09: return digitalInOut9;
whismanoid 0:cb44e2e9ec4c 2117 #endif
whismanoid 0:cb44e2e9ec4c 2118 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 2119 case 'a': case 0x0a: return digitalInOut10;
whismanoid 0:cb44e2e9ec4c 2120 #endif
whismanoid 0:cb44e2e9ec4c 2121 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 2122 case 'b': case 0x0b: return digitalInOut11;
whismanoid 0:cb44e2e9ec4c 2123 #endif
whismanoid 0:cb44e2e9ec4c 2124 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 2125 case 'c': case 0x0c: return digitalInOut12;
whismanoid 0:cb44e2e9ec4c 2126 #endif
whismanoid 0:cb44e2e9ec4c 2127 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 2128 case 'd': case 0x0d: return digitalInOut13;
whismanoid 0:cb44e2e9ec4c 2129 #endif
whismanoid 0:cb44e2e9ec4c 2130 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 2131 case 'e': case 0x0e: return digitalInOut14;
whismanoid 0:cb44e2e9ec4c 2132 #endif
whismanoid 0:cb44e2e9ec4c 2133 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 2134 case 'f': case 0x0f: return digitalInOut15;
whismanoid 0:cb44e2e9ec4c 2135 #endif
whismanoid 0:cb44e2e9ec4c 2136 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 2137 case 'g': case 0x10: return digitalInOut16;
whismanoid 0:cb44e2e9ec4c 2138 #endif
whismanoid 0:cb44e2e9ec4c 2139 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 2140 case 'h': case 0x11: return digitalInOut17;
whismanoid 0:cb44e2e9ec4c 2141 #endif
whismanoid 18:1235c17b451e 2142 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 2143 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 2144 //~ case 90: return button1;
whismanoid 18:1235c17b451e 2145 #if USE_LEDS
whismanoid 18:1235c17b451e 2146 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 2147 case 91: return led1_RFailLED;
whismanoid 18:1235c17b451e 2148 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 2149 case 92: return led2_GPassLED;
whismanoid 18:1235c17b451e 2150 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 2151 case 93: return led3_BBusyLED;
whismanoid 18:1235c17b451e 2152 #else // USE_LEDS
whismanoid 18:1235c17b451e 2153 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 2154 }
whismanoid 0:cb44e2e9ec4c 2155 }
whismanoid 0:cb44e2e9ec4c 2156 #endif
whismanoid 0:cb44e2e9ec4c 2157
whismanoid 0:cb44e2e9ec4c 2158
whismanoid 0:cb44e2e9ec4c 2159 // AnalogIn pin resource: search index
whismanoid 0:cb44e2e9ec4c 2160 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 2161 AnalogIn& find_analogInPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 2162 {
whismanoid 0:cb44e2e9ec4c 2163 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 2164 {
whismanoid 0:cb44e2e9ec4c 2165 default: // default to the first defined analogIn pin
whismanoid 0:cb44e2e9ec4c 2166 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 2167 case '0': case 0x00: return analogIn0;
whismanoid 0:cb44e2e9ec4c 2168 #endif
whismanoid 0:cb44e2e9ec4c 2169 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 2170 case '1': case 0x01: return analogIn1;
whismanoid 0:cb44e2e9ec4c 2171 #endif
whismanoid 0:cb44e2e9ec4c 2172 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 2173 case '2': case 0x02: return analogIn2;
whismanoid 0:cb44e2e9ec4c 2174 #endif
whismanoid 0:cb44e2e9ec4c 2175 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 2176 case '3': case 0x03: return analogIn3;
whismanoid 0:cb44e2e9ec4c 2177 #endif
whismanoid 0:cb44e2e9ec4c 2178 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 2179 case '4': case 0x04: return analogIn4;
whismanoid 0:cb44e2e9ec4c 2180 #endif
whismanoid 0:cb44e2e9ec4c 2181 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 2182 case '5': case 0x05: return analogIn5;
whismanoid 0:cb44e2e9ec4c 2183 #endif
whismanoid 0:cb44e2e9ec4c 2184 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 2185 case '6': case 0x06: return analogIn6;
whismanoid 0:cb44e2e9ec4c 2186 #endif
whismanoid 0:cb44e2e9ec4c 2187 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 2188 case '7': case 0x07: return analogIn7;
whismanoid 0:cb44e2e9ec4c 2189 #endif
whismanoid 0:cb44e2e9ec4c 2190 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 2191 case '8': case 0x08: return analogIn8;
whismanoid 0:cb44e2e9ec4c 2192 #endif
whismanoid 0:cb44e2e9ec4c 2193 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 2194 case '9': case 0x09: return analogIn9;
whismanoid 0:cb44e2e9ec4c 2195 #endif
whismanoid 0:cb44e2e9ec4c 2196 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 2197 case 'a': case 0x0a: return analogIn10;
whismanoid 0:cb44e2e9ec4c 2198 #endif
whismanoid 0:cb44e2e9ec4c 2199 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 2200 case 'b': case 0x0b: return analogIn11;
whismanoid 0:cb44e2e9ec4c 2201 #endif
whismanoid 0:cb44e2e9ec4c 2202 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 2203 case 'c': case 0x0c: return analogIn12;
whismanoid 0:cb44e2e9ec4c 2204 #endif
whismanoid 0:cb44e2e9ec4c 2205 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 2206 case 'd': case 0x0d: return analogIn13;
whismanoid 0:cb44e2e9ec4c 2207 #endif
whismanoid 0:cb44e2e9ec4c 2208 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 2209 case 'e': case 0x0e: return analogIn14;
whismanoid 0:cb44e2e9ec4c 2210 #endif
whismanoid 0:cb44e2e9ec4c 2211 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 2212 case 'f': case 0x0f: return analogIn15;
whismanoid 0:cb44e2e9ec4c 2213 #endif
whismanoid 0:cb44e2e9ec4c 2214 }
whismanoid 0:cb44e2e9ec4c 2215 }
whismanoid 0:cb44e2e9ec4c 2216 #endif
whismanoid 0:cb44e2e9ec4c 2217
whismanoid 0:cb44e2e9ec4c 2218 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 2219 const float analogInPin_fullScaleVoltage[] = {
whismanoid 0:cb44e2e9ec4c 2220 # if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 2221 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 2222 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 2223 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 2224 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 2225 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2226 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2227 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2228 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2229 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2230 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 2231 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 2232 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2233 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2234 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2235 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2236 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2237 # elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 2238 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 2239 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 2240 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 2241 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 2242 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 2243 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2244 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2245 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2246 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2247 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2248 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 2249 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 2250 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2251 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2252 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2253 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2254 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 19:5ff09c8e9daf 2255 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 2256 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2257 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2258 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2259 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2260 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2261 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2262 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2263 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2264 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2265 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 2266 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 2267 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2268 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2269 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2270 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2271 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2272 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 2273 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 2274 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 2275 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 2276 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 2277 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 2278 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 2279 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 2280 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 2281 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 2282 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 2283 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 2284 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 2285 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 2286 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2287 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2288 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2289 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 2290 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 2291 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 2292 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 2293 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 2294 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 2295 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 2296 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 2297 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 2298 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 2299 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 2300 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 2301 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 2302 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 2303 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2304 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2305 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2306 //#elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 2307 #else
whismanoid 0:cb44e2e9ec4c 2308 // unknown target
whismanoid 0:cb44e2e9ec4c 2309 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 2310 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 2311 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 2312 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 2313 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 2314 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 2315 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 2316 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 2317 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 2318 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 2319 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 2320 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 2321 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 2322 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2323 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2324 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2325 # endif
whismanoid 0:cb44e2e9ec4c 2326 };
whismanoid 0:cb44e2e9ec4c 2327 #endif
whismanoid 0:cb44e2e9ec4c 2328
whismanoid 0:cb44e2e9ec4c 2329
whismanoid 0:cb44e2e9ec4c 2330
whismanoid 0:cb44e2e9ec4c 2331
whismanoid 0:cb44e2e9ec4c 2332 //--------------------------------------------------
whismanoid 45:74bf1fe021e5 2333 // support CmdLine command menus (like on Serial_Tester)
whismanoid 4:d9b05924ad4c 2334 #ifndef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 2335 #define USE_CMDLINE_MENUS 1
whismanoid 4:d9b05924ad4c 2336 //~ #undef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 2337 #endif
whismanoid 4:d9b05924ad4c 2338 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2339 #include "CmdLine.h"
whismanoid 4:d9b05924ad4c 2340 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2341 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2342 extern CmdLine cmdLine; // declared later
whismanoid 4:d9b05924ad4c 2343 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2344
whismanoid 4:d9b05924ad4c 2345 //--------------------------------------------------
whismanoid 39:4d285e961435 2346 // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2347 #ifndef USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 2348 #define USE_DATALOGGER_SLEEP 1
whismanoid 39:4d285e961435 2349 //~ #undef USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 2350 #endif
whismanoid 39:4d285e961435 2351 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 2352 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 2353 // USE_DATALOGGER_SLEEP -- #include "lp.h" -- LP_EnterLP1()
whismanoid 42:89607d5d4e6d 2354 #include "lp.h"
whismanoid 43:4c4733760d4c 2355 #include "rtc.h"
whismanoid 39:4d285e961435 2356 #endif
whismanoid 39:4d285e961435 2357 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 44:84402faa8eb9 2358 // wait until UART_Busy indicates no ongoing transactions (both ports)
whismanoid 44:84402faa8eb9 2359 #include "uart.h"
whismanoid 44:84402faa8eb9 2360 int Console_PrepForSleep(void)
whismanoid 44:84402faa8eb9 2361 {
whismanoid 44:84402faa8eb9 2362 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 44:84402faa8eb9 2363 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK)
whismanoid 44:84402faa8eb9 2364 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 44:84402faa8eb9 2365 return (
whismanoid 44:84402faa8eb9 2366 (UART_PrepForSleep(MXC_UART_GET_UART(0)) == E_NO_ERROR)
whismanoid 44:84402faa8eb9 2367 && (UART_PrepForSleep(MXC_UART_GET_UART(1)) == E_NO_ERROR)
whismanoid 44:84402faa8eb9 2368 )
whismanoid 44:84402faa8eb9 2369 ? E_NO_ERROR
whismanoid 44:84402faa8eb9 2370 : E_BUSY;
whismanoid 44:84402faa8eb9 2371 }
whismanoid 44:84402faa8eb9 2372 #endif // USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 44:84402faa8eb9 2373 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2374 typedef enum Datalogger_Sleep_enum_t {
whismanoid 39:4d285e961435 2375 datalogger_Sleep_LP0_Stop = 0,
whismanoid 39:4d285e961435 2376 datalogger_Sleep_LP1_DeepSleep = 1,
whismanoid 39:4d285e961435 2377 datalogger_Sleep_LP2_Sleep = 2,
whismanoid 39:4d285e961435 2378 datalogger_Sleep_LP3_Run = 3,
whismanoid 39:4d285e961435 2379 } Datalogger_Sleep_enum_t;
whismanoid 45:74bf1fe021e5 2380 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 2381 Datalogger_Sleep_enum_t g_timer_sleepmode = datalogger_Sleep_LP1_DeepSleep;
whismanoid 39:4d285e961435 2382 #endif
whismanoid 39:4d285e961435 2383
whismanoid 39:4d285e961435 2384 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2385 // Datalog trigger types
whismanoid 4:d9b05924ad4c 2386 #ifndef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 2387 #define USE_DATALOGGER_TRIGGER 1
whismanoid 4:d9b05924ad4c 2388 //~ #undef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 2389 #endif
whismanoid 4:d9b05924ad4c 2390 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 2391 typedef enum Datalogger_Trigger_enum_t {
whismanoid 4:d9b05924ad4c 2392 trigger_Halt = 0, //!< halt
whismanoid 4:d9b05924ad4c 2393 trigger_FreeRun = 1, //!< free run as fast as possible
whismanoid 4:d9b05924ad4c 2394 trigger_Timer = 2, //!< timer (configure interval)
whismanoid 4:d9b05924ad4c 2395 trigger_PlatformDigitalInput, //!< platform digital input (configure digital input pin reference)
whismanoid 4:d9b05924ad4c 2396 trigger_SPIDeviceRegRead, //!< SPI device register read (configure regaddr, mask value, match value)
whismanoid 4:d9b05924ad4c 2397 } Datalogger_Trigger_enum_t;
whismanoid 4:d9b05924ad4c 2398 Datalogger_Trigger_enum_t Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 2399 //
whismanoid 17:9397ea3ea7e9 2400 // configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 2401 int g_timer_interval_msec = 500; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2402 int g_timer_interval_count = 10; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2403 int g_timer_interval_counter = 0; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2404 //
whismanoid 17:9397ea3ea7e9 2405 // TODO: configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 2406 //
whismanoid 17:9397ea3ea7e9 2407 // TODO: configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2408 //
whismanoid 4:d9b05924ad4c 2409 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 2410
whismanoid 4:d9b05924ad4c 2411 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2412 // support trigger_SPIDeviceRegRead: Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 2413 #ifndef USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2414 #define USE_DATALOGGER_SPIDeviceRegRead 0
whismanoid 17:9397ea3ea7e9 2415 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2416 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2417 // TODO: uint16_t regAddr;
whismanoid 17:9397ea3ea7e9 2418 // TODO: uint16_t regDataMask;
whismanoid 17:9397ea3ea7e9 2419 // TODO: uint16_t regDataTest;
whismanoid 17:9397ea3ea7e9 2420 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2421
whismanoid 17:9397ea3ea7e9 2422 //--------------------------------------------------
whismanoid 30:07197a430869 2423 // support Datalogger_PrintRow() print gstrRemarkText field from recent #remark
whismanoid 30:07197a430869 2424 #ifndef USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2425 #define USE_DATALOGGER_REMARK_FIELD 1
whismanoid 30:07197a430869 2426 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2427 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2428 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark
whismanoid 30:07197a430869 2429 const size_t gstrRemarkTextLASTINDEX = 40; // gstrRemarkText buffer size - 1
whismanoid 30:07197a430869 2430 char gstrRemarkText[gstrRemarkTextLASTINDEX+1] = "";
whismanoid 30:07197a430869 2431 char gstrRemarkHeader[] = "comment"; // comment or remark?
whismanoid 30:07197a430869 2432 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2433
whismanoid 30:07197a430869 2434 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2435 // Datalogger_RunActionTable() supported actions
whismanoid 45:74bf1fe021e5 2436 // support command L@
whismanoid 45:74bf1fe021e5 2437 // configurable "business logic" for the data log
whismanoid 17:9397ea3ea7e9 2438 #ifndef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2439 #define USE_DATALOGGER_ActionTable 1
whismanoid 17:9397ea3ea7e9 2440 //~ #undef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2441 #endif
whismanoid 17:9397ea3ea7e9 2442 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2443 //
whismanoid 17:9397ea3ea7e9 2444 // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2445 typedef enum action_type_enum_t {
whismanoid 17:9397ea3ea7e9 2446 action_noop = 0, // no operation
whismanoid 30:07197a430869 2447 action_digitalOutLow = 1, // pin = low if condition
whismanoid 30:07197a430869 2448 action_digitalOutHigh = 2, // pin = high if condition
whismanoid 30:07197a430869 2449 action_button = 3, // pin = button event index 1, 2, 3
whismanoid 30:07197a430869 2450 action_trigger_Halt = 4,
whismanoid 30:07197a430869 2451 action_trigger_FreeRun = 5,
whismanoid 30:07197a430869 2452 action_trigger_Timer = 6,
whismanoid 30:07197a430869 2453 action_trigger_PlatformDigitalInput = 7,
whismanoid 30:07197a430869 2454 action_trigger_SPIDeviceRegRead = 8,
whismanoid 17:9397ea3ea7e9 2455 } action_type_enum_t;
whismanoid 17:9397ea3ea7e9 2456 //
whismanoid 17:9397ea3ea7e9 2457 // Datalogger_RunActionTable() supported conditions
whismanoid 17:9397ea3ea7e9 2458 typedef enum action_condition_enum_t {
whismanoid 17:9397ea3ea7e9 2459 condition_always = 0, // ( true )
whismanoid 17:9397ea3ea7e9 2460 condition_if_An_gt_threshold, // (Platform_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2461 condition_if_An_lt_threshold, // (Platform_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2462 condition_if_An_eq_threshold, // (Platform_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2463 condition_if_An_ge_threshold, // (Platform_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2464 condition_if_An_le_threshold, // (Platform_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2465 condition_if_An_ne_threshold, // (Platform_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2466 condition_if_AINn_gt_threshold, // (SPI_AIN_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2467 condition_if_AINn_lt_threshold, // (SPI_AIN_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2468 condition_if_AINn_eq_threshold, // (SPI_AIN_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2469 condition_if_AINn_ge_threshold, // (SPI_AIN_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2470 condition_if_AINn_le_threshold, // (SPI_AIN_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2471 condition_if_AINn_ne_threshold, // (SPI_AIN_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2472 } condition_enum_t;
whismanoid 17:9397ea3ea7e9 2473 //
whismanoid 17:9397ea3ea7e9 2474 // Datalogger_RunActionTable() structure
whismanoid 17:9397ea3ea7e9 2475 typedef struct action_table_row_t {
whismanoid 17:9397ea3ea7e9 2476 action_type_enum_t action;
whismanoid 17:9397ea3ea7e9 2477 int digitalOutPin;
whismanoid 17:9397ea3ea7e9 2478 action_condition_enum_t condition;
whismanoid 17:9397ea3ea7e9 2479 int condition_channel;
whismanoid 17:9397ea3ea7e9 2480 double condition_threshold;
whismanoid 17:9397ea3ea7e9 2481 } action_table_row_t;
whismanoid 17:9397ea3ea7e9 2482 #if MAX40108_DEMO
whismanoid 39:4d285e961435 2483 # ifdef BOARD_SERIAL_NUMBER
whismanoid 39:4d285e961435 2484 // data unique to certain boards based on serial number
whismanoid 39:4d285e961435 2485 // channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 39:4d285e961435 2486 # if (BOARD_SERIAL_NUMBER) == 1
whismanoid 39:4d285e961435 2487 #warning "(BOARD_SERIAL_NUMBER) == 1 -- logic uses A3(CE) instead of A2(WE)"
whismanoid 39:4d285e961435 2488 const int channel_WE = 3; // use channel_CE instead on proto board s/n 1 for diagnostics; easier to sweep values
whismanoid 39:4d285e961435 2489 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 39:4d285e961435 2490 #warning "(BOARD_SERIAL_NUMBER) == 5 -- logic uses A3(CE) instead of A2(WE)"
whismanoid 39:4d285e961435 2491 const int channel_WE = 3; // use channel_CE instead on proto board s/n 1 for diagnostics; easier to sweep values
whismanoid 39:4d285e961435 2492 # else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 17:9397ea3ea7e9 2493 const int channel_WE = 2;
whismanoid 39:4d285e961435 2494 # endif
whismanoid 39:4d285e961435 2495 # endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 17:9397ea3ea7e9 2496 const double threshold_WE_0V5 = 0.5;
whismanoid 17:9397ea3ea7e9 2497 const double threshold_WE_0V6 = 0.6;
whismanoid 17:9397ea3ea7e9 2498 const double threshold_WE_0V7 = 0.7;
whismanoid 18:1235c17b451e 2499 const int pin_LED_1 = 91; // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 2500 const int pin_LED_2 = 92; // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 2501 const int pin_LED_3 = 93; // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 17:9397ea3ea7e9 2502 #endif
whismanoid 17:9397ea3ea7e9 2503 const int ACTION_TABLE_ROW_MAX = 20;
whismanoid 17:9397ea3ea7e9 2504 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2505 bool Datalogger_action_table_enabled = true;
whismanoid 45:74bf1fe021e5 2506 int Datalogger_action_table_row_count = 10; // assert (Datalogger_action_table_row_count <= ACTION_TABLE_ROW_MAX)
whismanoid 17:9397ea3ea7e9 2507 #else // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2508 int Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 2509 #endif // MAX40108_DEMO
whismanoid 45:74bf1fe021e5 2510 // configurable "business logic" for the data log
whismanoid 17:9397ea3ea7e9 2511 action_table_row_t Datalogger_action_table[ACTION_TABLE_ROW_MAX] = {
whismanoid 17:9397ea3ea7e9 2512 #if MAX40108_DEMO
whismanoid 45:74bf1fe021e5 2513 //
whismanoid 45:74bf1fe021e5 2514 // LED1 indicator on if (WE > 0.85V)
whismanoid 45:74bf1fe021e5 2515 // L@0 act=1 pin=91 if=1 ch=3 x=0.8500 -- digitalOutLow D91 if A3 > 0.85
whismanoid 45:74bf1fe021e5 2516 {action_digitalOutLow, pin_LED_1, condition_if_An_gt_threshold, channel_WE, 0.85},
whismanoid 45:74bf1fe021e5 2517 //
whismanoid 45:74bf1fe021e5 2518 // LED1 indicator off if (WE < 0.80V)
whismanoid 45:74bf1fe021e5 2519 // L@1 act=2 pin=91 if=2 ch=3 x=0.8000 -- digitalOutHigh D91 if A3 < 0.80
whismanoid 45:74bf1fe021e5 2520 {action_digitalOutHigh, pin_LED_1, condition_if_An_lt_threshold, channel_WE, 0.80},
whismanoid 45:74bf1fe021e5 2521 //
whismanoid 45:74bf1fe021e5 2522 // LED2 indicator on if (WE > 0.75V)
whismanoid 45:74bf1fe021e5 2523 // L@2 act=1 pin=92 if=1 ch=3 x=0.7500 -- digitalOutLow D92 if A3 > 0.75
whismanoid 45:74bf1fe021e5 2524 {action_digitalOutLow, pin_LED_2, condition_if_An_gt_threshold, channel_WE, 0.75},
whismanoid 17:9397ea3ea7e9 2525 //
whismanoid 45:74bf1fe021e5 2526 // LED2 indicator off if (WE < 0.70V)
whismanoid 45:74bf1fe021e5 2527 // L@3 act=2 pin=92 if=2 ch=3 x=0.7000 -- digitalOutHigh D92 if A3 < 0.70
whismanoid 45:74bf1fe021e5 2528 {action_digitalOutHigh, pin_LED_2, condition_if_An_lt_threshold, channel_WE, 0.70},
whismanoid 17:9397ea3ea7e9 2529 //
whismanoid 45:74bf1fe021e5 2530 // LED3 indicator on if (WE > 0.65V)
whismanoid 45:74bf1fe021e5 2531 // L@4 act=1 pin=93 if=1 ch=3 x=0.6500 -- digitalOutLow D93 if A3 > 0.65
whismanoid 45:74bf1fe021e5 2532 {action_digitalOutLow, pin_LED_3, condition_if_An_gt_threshold, channel_WE, 0.65},
whismanoid 45:74bf1fe021e5 2533 //
whismanoid 45:74bf1fe021e5 2534 // LED3 indicator off if (WE < 0.60V)
whismanoid 45:74bf1fe021e5 2535 // L@5 act=2 pin=93 if=2 ch=3 x=0.6000 -- digitalOutHigh D93 if A3 < 0.60
whismanoid 45:74bf1fe021e5 2536 {action_digitalOutHigh, pin_LED_3, condition_if_An_lt_threshold, channel_WE, 0.60},
whismanoid 45:74bf1fe021e5 2537 //
whismanoid 45:74bf1fe021e5 2538 // Free run if (WE > 0.70V)
whismanoid 45:74bf1fe021e5 2539 // L@6 act=5 if=1 ch=3 x=0.7000 -- LR if A3 > 0.70
whismanoid 17:9397ea3ea7e9 2540 {action_trigger_FreeRun, 0, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 17:9397ea3ea7e9 2541 //
whismanoid 45:74bf1fe021e5 2542 // Deep Sleep if (WE < 0.60V)
whismanoid 45:74bf1fe021e5 2543 // L@7 act=6 if=2 ch=3 x=0.6000 -- LT count=10 base=1000ms sleep=1 if A3 < 0.60
whismanoid 17:9397ea3ea7e9 2544 {action_trigger_Timer, 0, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 18:1235c17b451e 2545 //
whismanoid 45:74bf1fe021e5 2546 // Free run if (WE > 0.70V)
whismanoid 45:74bf1fe021e5 2547 // L@8 act=3 pin=4 if=1 ch=3 x=0.7000 -- button %B4! if A3 > 0.70
whismanoid 30:07197a430869 2548 {action_button, 4, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 29:6a9edb6e973b 2549 //
whismanoid 45:74bf1fe021e5 2550 // Deep Sleep if (WE < 0.60V)
whismanoid 45:74bf1fe021e5 2551 // L@9 act=3 pin=5 if=2 ch=3 x=0.6000 -- button %B5! if A3 < 0.60
whismanoid 30:07197a430869 2552 {action_button, 5, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 29:6a9edb6e973b 2553 //
whismanoid 17:9397ea3ea7e9 2554 #endif // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2555 //
whismanoid 17:9397ea3ea7e9 2556 {action_noop, 0, condition_always, 0, 0},
whismanoid 17:9397ea3ea7e9 2557 };
whismanoid 17:9397ea3ea7e9 2558 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2559
whismanoid 17:9397ea3ea7e9 2560 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2561 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 2562 uint8_t Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 2563 uint8_t need_reinit = true;
whismanoid 8:dffee7509bfb 2564 void Datalogger_PrintHeader(CmdLine& cmdLine);
whismanoid 5:aaf8b5f5fda1 2565 void Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 2566 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2567 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 2568 void Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 2569 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 8:dffee7509bfb 2570 void Datalogger_PrintRow(CmdLine& cmdLine);
whismanoid 4:d9b05924ad4c 2571
whismanoid 4:d9b05924ad4c 2572 //--------------------------------------------------
whismanoid 51:a41d3fd5e441 2573 // MAX32625 flash peek/poke support (MAX40108 demo) #312 - forward declarations for flash_page_configuration_back_up
whismanoid 51:a41d3fd5e441 2574 extern int Platform_AIN_Average_N; // forward declaration
whismanoid 51:a41d3fd5e441 2575 //
whismanoid 51:a41d3fd5e441 2576 extern const int COMMAND_TABLE_COL_MAX; // forward declaration
whismanoid 51:a41d3fd5e441 2577 extern char onButton1_command_table_00[];
whismanoid 51:a41d3fd5e441 2578 extern char onButton1_command_table_01[];
whismanoid 51:a41d3fd5e441 2579 extern char onButton1_command_table_02[];
whismanoid 51:a41d3fd5e441 2580 extern char onButton1_command_table_03[];
whismanoid 51:a41d3fd5e441 2581 extern char onButton1_command_table_04[];
whismanoid 51:a41d3fd5e441 2582 extern char onButton1_command_table_05[];
whismanoid 51:a41d3fd5e441 2583 extern char onButton1_command_table_06[];
whismanoid 51:a41d3fd5e441 2584 extern char onButton1_command_table_07[];
whismanoid 51:a41d3fd5e441 2585 extern char onButton1_command_table_08[];
whismanoid 51:a41d3fd5e441 2586 extern char onButton1_command_table_09[];
whismanoid 51:a41d3fd5e441 2587 //
whismanoid 51:a41d3fd5e441 2588 extern char onButton2_command_table_00[];
whismanoid 51:a41d3fd5e441 2589 extern char onButton2_command_table_01[];
whismanoid 51:a41d3fd5e441 2590 extern char onButton2_command_table_02[];
whismanoid 51:a41d3fd5e441 2591 extern char onButton2_command_table_03[];
whismanoid 51:a41d3fd5e441 2592 extern char onButton2_command_table_04[];
whismanoid 51:a41d3fd5e441 2593 extern char onButton2_command_table_05[];
whismanoid 51:a41d3fd5e441 2594 extern char onButton2_command_table_06[];
whismanoid 51:a41d3fd5e441 2595 extern char onButton2_command_table_07[];
whismanoid 51:a41d3fd5e441 2596 extern char onButton2_command_table_08[];
whismanoid 51:a41d3fd5e441 2597 extern char onButton2_command_table_09[];
whismanoid 51:a41d3fd5e441 2598 //
whismanoid 51:a41d3fd5e441 2599 extern char onButton3_command_table_00[];
whismanoid 51:a41d3fd5e441 2600 extern char onButton3_command_table_01[];
whismanoid 51:a41d3fd5e441 2601 extern char onButton3_command_table_02[];
whismanoid 51:a41d3fd5e441 2602 extern char onButton3_command_table_03[];
whismanoid 51:a41d3fd5e441 2603 extern char onButton3_command_table_04[];
whismanoid 51:a41d3fd5e441 2604 extern char onButton3_command_table_05[];
whismanoid 51:a41d3fd5e441 2605 extern char onButton3_command_table_06[];
whismanoid 51:a41d3fd5e441 2606 extern char onButton3_command_table_07[];
whismanoid 51:a41d3fd5e441 2607 extern char onButton3_command_table_08[];
whismanoid 51:a41d3fd5e441 2608 extern char onButton3_command_table_09[];
whismanoid 51:a41d3fd5e441 2609 //
whismanoid 51:a41d3fd5e441 2610 extern char onButton4_command_table_00[];
whismanoid 51:a41d3fd5e441 2611 extern char onButton4_command_table_01[];
whismanoid 51:a41d3fd5e441 2612 extern char onButton4_command_table_02[];
whismanoid 51:a41d3fd5e441 2613 extern char onButton4_command_table_03[];
whismanoid 51:a41d3fd5e441 2614 extern char onButton4_command_table_04[];
whismanoid 51:a41d3fd5e441 2615 extern char onButton4_command_table_05[];
whismanoid 51:a41d3fd5e441 2616 extern char onButton4_command_table_06[];
whismanoid 51:a41d3fd5e441 2617 extern char onButton4_command_table_07[];
whismanoid 51:a41d3fd5e441 2618 extern char onButton4_command_table_08[];
whismanoid 51:a41d3fd5e441 2619 extern char onButton4_command_table_09[];
whismanoid 51:a41d3fd5e441 2620 //
whismanoid 51:a41d3fd5e441 2621 extern char onButton5_command_table_00[];
whismanoid 51:a41d3fd5e441 2622 extern char onButton5_command_table_01[];
whismanoid 51:a41d3fd5e441 2623 extern char onButton5_command_table_02[];
whismanoid 51:a41d3fd5e441 2624 extern char onButton5_command_table_03[];
whismanoid 51:a41d3fd5e441 2625 extern char onButton5_command_table_04[];
whismanoid 51:a41d3fd5e441 2626 extern char onButton5_command_table_05[];
whismanoid 51:a41d3fd5e441 2627 extern char onButton5_command_table_06[];
whismanoid 51:a41d3fd5e441 2628 extern char onButton5_command_table_07[];
whismanoid 51:a41d3fd5e441 2629 extern char onButton5_command_table_08[];
whismanoid 51:a41d3fd5e441 2630 extern char onButton5_command_table_09[];
whismanoid 51:a41d3fd5e441 2631 //
whismanoid 51:a41d3fd5e441 2632 extern char onButton6_command_table_00[];
whismanoid 51:a41d3fd5e441 2633 extern char onButton6_command_table_01[];
whismanoid 51:a41d3fd5e441 2634 extern char onButton6_command_table_02[];
whismanoid 51:a41d3fd5e441 2635 extern char onButton6_command_table_03[];
whismanoid 51:a41d3fd5e441 2636 extern char onButton6_command_table_04[];
whismanoid 51:a41d3fd5e441 2637 extern char onButton6_command_table_05[];
whismanoid 51:a41d3fd5e441 2638 extern char onButton6_command_table_06[];
whismanoid 51:a41d3fd5e441 2639 extern char onButton6_command_table_07[];
whismanoid 51:a41d3fd5e441 2640 extern char onButton6_command_table_08[];
whismanoid 51:a41d3fd5e441 2641 extern char onButton6_command_table_09[];
whismanoid 51:a41d3fd5e441 2642 //
whismanoid 51:a41d3fd5e441 2643 extern char onButton7_command_table_00[];
whismanoid 51:a41d3fd5e441 2644 extern char onButton7_command_table_01[];
whismanoid 51:a41d3fd5e441 2645 extern char onButton7_command_table_02[];
whismanoid 51:a41d3fd5e441 2646 extern char onButton7_command_table_03[];
whismanoid 51:a41d3fd5e441 2647 extern char onButton7_command_table_04[];
whismanoid 51:a41d3fd5e441 2648 extern char onButton7_command_table_05[];
whismanoid 51:a41d3fd5e441 2649 extern char onButton7_command_table_06[];
whismanoid 51:a41d3fd5e441 2650 extern char onButton7_command_table_07[];
whismanoid 51:a41d3fd5e441 2651 extern char onButton7_command_table_08[];
whismanoid 51:a41d3fd5e441 2652 extern char onButton7_command_table_09[];
whismanoid 51:a41d3fd5e441 2653 //
whismanoid 51:a41d3fd5e441 2654 extern char onButton8_command_table_00[];
whismanoid 51:a41d3fd5e441 2655 extern char onButton8_command_table_01[];
whismanoid 51:a41d3fd5e441 2656 extern char onButton8_command_table_02[];
whismanoid 51:a41d3fd5e441 2657 extern char onButton8_command_table_03[];
whismanoid 51:a41d3fd5e441 2658 extern char onButton8_command_table_04[];
whismanoid 51:a41d3fd5e441 2659 extern char onButton8_command_table_05[];
whismanoid 51:a41d3fd5e441 2660 extern char onButton8_command_table_06[];
whismanoid 51:a41d3fd5e441 2661 extern char onButton8_command_table_07[];
whismanoid 51:a41d3fd5e441 2662 extern char onButton8_command_table_08[];
whismanoid 51:a41d3fd5e441 2663 extern char onButton8_command_table_09[];
whismanoid 51:a41d3fd5e441 2664 //
whismanoid 51:a41d3fd5e441 2665 extern char onButton9_command_table_00[];
whismanoid 51:a41d3fd5e441 2666 extern char onButton9_command_table_01[];
whismanoid 51:a41d3fd5e441 2667 extern char onButton9_command_table_02[];
whismanoid 51:a41d3fd5e441 2668 extern char onButton9_command_table_03[];
whismanoid 51:a41d3fd5e441 2669 extern char onButton9_command_table_04[];
whismanoid 51:a41d3fd5e441 2670 extern char onButton9_command_table_05[];
whismanoid 51:a41d3fd5e441 2671 extern char onButton9_command_table_06[];
whismanoid 51:a41d3fd5e441 2672 extern char onButton9_command_table_07[];
whismanoid 51:a41d3fd5e441 2673 extern char onButton9_command_table_08[];
whismanoid 51:a41d3fd5e441 2674 extern char onButton9_command_table_09[];
whismanoid 51:a41d3fd5e441 2675 //
whismanoid 46:469d0061df5d 2676 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 2677 #if HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 2678 // WIP #312 flash_page_configuration_back_up[] records map to variables
whismanoid 46:469d0061df5d 2679 typedef struct {
whismanoid 46:469d0061df5d 2680 uint32_t recordType; // unique record type for each variable, 0 end of list, -1 blank record
whismanoid 46:469d0061df5d 2681 void* addr;
whismanoid 51:a41d3fd5e441 2682 uint32_t length_bytes; // must be multiple of 4 bytes
whismanoid 46:469d0061df5d 2683 const char* name;
whismanoid 46:469d0061df5d 2684 } configuration_back_up_t;
whismanoid 51:a41d3fd5e441 2685 // WIP #312 unique recordType key values are defined by configuration_back_up_list[]
whismanoid 46:469d0061df5d 2686 configuration_back_up_t configuration_back_up_list[] = {
whismanoid 46:469d0061df5d 2687 { 0xFFFFFFFF, NULL, 0, "blank" }, // Ignore 0xFFFFFFFF blank records
whismanoid 47:f1a56afb4aca 2688 //
whismanoid 47:f1a56afb4aca 2689 #ifdef BOARD_SERIAL_NUMBER
whismanoid 47:f1a56afb4aca 2690 // WIP #312 flash load/save g_board_serial_number BOARD_SERIAL_NUMBER
whismanoid 47:f1a56afb4aca 2691 { 0x04000053, &g_board_serial_number, sizeof(g_board_serial_number ), "g_board_serial_number" },
whismanoid 47:f1a56afb4aca 2692 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 47:f1a56afb4aca 2693 // WIP #312 flash load/save board ID string message
whismanoid 47:f1a56afb4aca 2694 //
whismanoid 46:469d0061df5d 2695 { 0x08001053, &calibration_05_V[0], sizeof(calibration_05_V[0] ), "calibration_05_V[0]" },
whismanoid 46:469d0061df5d 2696 { 0x08001153, &calibration_05_V[1], sizeof(calibration_05_V[1] ), "calibration_05_V[1]" },
whismanoid 46:469d0061df5d 2697 { 0x08001253, &calibration_05_V[2], sizeof(calibration_05_V[2] ), "calibration_05_V[2]" },
whismanoid 46:469d0061df5d 2698 { 0x08001353, &calibration_05_V[3], sizeof(calibration_05_V[3] ), "calibration_05_V[3]" },
whismanoid 46:469d0061df5d 2699 { 0x08001453, &calibration_05_V[4], sizeof(calibration_05_V[4] ), "calibration_05_V[4]" },
whismanoid 46:469d0061df5d 2700 { 0x08001553, &calibration_05_V[5], sizeof(calibration_05_V[5] ), "calibration_05_V[5]" },
whismanoid 46:469d0061df5d 2701 { 0x08002053, &calibration_05_normValue_0_1[0], sizeof(calibration_05_normValue_0_1[0] ), "calibration_05_normValue_0_1[0]" },
whismanoid 46:469d0061df5d 2702 { 0x08002153, &calibration_05_normValue_0_1[1], sizeof(calibration_05_normValue_0_1[1] ), "calibration_05_normValue_0_1[1]" },
whismanoid 46:469d0061df5d 2703 { 0x08002253, &calibration_05_normValue_0_1[2], sizeof(calibration_05_normValue_0_1[2] ), "calibration_05_normValue_0_1[2]" },
whismanoid 46:469d0061df5d 2704 { 0x08002353, &calibration_05_normValue_0_1[3], sizeof(calibration_05_normValue_0_1[3] ), "calibration_05_normValue_0_1[3]" },
whismanoid 46:469d0061df5d 2705 { 0x08002453, &calibration_05_normValue_0_1[4], sizeof(calibration_05_normValue_0_1[4] ), "calibration_05_normValue_0_1[4]" },
whismanoid 46:469d0061df5d 2706 { 0x08002553, &calibration_05_normValue_0_1[5], sizeof(calibration_05_normValue_0_1[5] ), "calibration_05_normValue_0_1[5]" },
whismanoid 46:469d0061df5d 2707 { 0x08003053, &calibration_95_V[0], sizeof(calibration_95_V[0] ), "calibration_95_V[0]" },
whismanoid 46:469d0061df5d 2708 { 0x08003153, &calibration_95_V[1], sizeof(calibration_95_V[1] ), "calibration_95_V[1]" },
whismanoid 46:469d0061df5d 2709 { 0x08003253, &calibration_95_V[2], sizeof(calibration_95_V[2] ), "calibration_95_V[2]" },
whismanoid 46:469d0061df5d 2710 { 0x08003353, &calibration_95_V[3], sizeof(calibration_95_V[3] ), "calibration_95_V[3]" },
whismanoid 46:469d0061df5d 2711 { 0x08003453, &calibration_95_V[4], sizeof(calibration_95_V[4] ), "calibration_95_V[4]" },
whismanoid 46:469d0061df5d 2712 { 0x08003553, &calibration_95_V[5], sizeof(calibration_95_V[5] ), "calibration_95_V[5]" },
whismanoid 46:469d0061df5d 2713 { 0x08004053, &calibration_95_normValue_0_1[0], sizeof(calibration_95_normValue_0_1[0] ), "calibration_95_normValue_0_1[0]" },
whismanoid 46:469d0061df5d 2714 { 0x08004153, &calibration_95_normValue_0_1[1], sizeof(calibration_95_normValue_0_1[1] ), "calibration_95_normValue_0_1[1]" },
whismanoid 46:469d0061df5d 2715 { 0x08004253, &calibration_95_normValue_0_1[2], sizeof(calibration_95_normValue_0_1[2] ), "calibration_95_normValue_0_1[2]" },
whismanoid 46:469d0061df5d 2716 { 0x08004353, &calibration_95_normValue_0_1[3], sizeof(calibration_95_normValue_0_1[3] ), "calibration_95_normValue_0_1[3]" },
whismanoid 46:469d0061df5d 2717 { 0x08004453, &calibration_95_normValue_0_1[4], sizeof(calibration_95_normValue_0_1[4] ), "calibration_95_normValue_0_1[4]" },
whismanoid 46:469d0061df5d 2718 { 0x08004553, &calibration_95_normValue_0_1[5], sizeof(calibration_95_normValue_0_1[5] ), "calibration_95_normValue_0_1[5]" },
whismanoid 47:f1a56afb4aca 2719 //
whismanoid 51:a41d3fd5e441 2720 // forward declaration
whismanoid 51:a41d3fd5e441 2721 { 0x04000153, &Platform_AIN_Average_N, sizeof(Platform_AIN_Average_N ), "Platform_AIN_Average_N" },
whismanoid 51:a41d3fd5e441 2722 //
whismanoid 46:469d0061df5d 2723 // WIP #312 @L Datalogger_action_table_row_count
whismanoid 51:a41d3fd5e441 2724 { 0x04000253, &Datalogger_action_table_row_count, sizeof(Datalogger_action_table_row_count ), "Datalogger_action_table_row_count" },
whismanoid 51:a41d3fd5e441 2725 // WIP #312 @L Datalogger_action_table_enabled - only 1 byte, write will fail
whismanoid 51:a41d3fd5e441 2726 // { 0x01000353, &Datalogger_action_table_enabled, sizeof(Datalogger_action_table_enabled ), "Datalogger_action_table_enabled" },
whismanoid 46:469d0061df5d 2727 // WIP #312 @L Datalogger_action_table[0] __ bytes
whismanoid 51:a41d3fd5e441 2728 { 0x41005053, &Datalogger_action_table, sizeof(Datalogger_action_table ), "Datalogger_action_table" },
whismanoid 51:a41d3fd5e441 2729 //{ 0x08____53, &Datalogger_action_table[1], sizeof(Datalogger_action_table[1] ), "Datalogger_action_table[1]" },
whismanoid 47:f1a56afb4aca 2730 //
whismanoid 51:a41d3fd5e441 2731 // forward declaration
whismanoid 51:a41d3fd5e441 2732 // WIP #312 %B onButton1_command_table_00[0] __ bytes -- string
whismanoid 51:a41d3fd5e441 2733 { 0x42061053, &onButton1_command_table_00, COMMAND_TABLE_COL_MAX, "onButton1_command_table_00" },
whismanoid 51:a41d3fd5e441 2734 { 0x42061153, &onButton1_command_table_01, COMMAND_TABLE_COL_MAX, "onButton1_command_table_01" },
whismanoid 51:a41d3fd5e441 2735 { 0x42061253, &onButton1_command_table_02, COMMAND_TABLE_COL_MAX, "onButton1_command_table_02" },
whismanoid 51:a41d3fd5e441 2736 { 0x42061353, &onButton1_command_table_03, COMMAND_TABLE_COL_MAX, "onButton1_command_table_03" },
whismanoid 51:a41d3fd5e441 2737 { 0x42061453, &onButton1_command_table_04, COMMAND_TABLE_COL_MAX, "onButton1_command_table_04" },
whismanoid 51:a41d3fd5e441 2738 { 0x42061553, &onButton1_command_table_05, COMMAND_TABLE_COL_MAX, "onButton1_command_table_05" },
whismanoid 51:a41d3fd5e441 2739 { 0x42061653, &onButton1_command_table_06, COMMAND_TABLE_COL_MAX, "onButton1_command_table_06" },
whismanoid 51:a41d3fd5e441 2740 { 0x42061753, &onButton1_command_table_07, COMMAND_TABLE_COL_MAX, "onButton1_command_table_07" },
whismanoid 51:a41d3fd5e441 2741 { 0x42061853, &onButton1_command_table_08, COMMAND_TABLE_COL_MAX, "onButton1_command_table_08" },
whismanoid 51:a41d3fd5e441 2742 { 0x42061953, &onButton1_command_table_09, COMMAND_TABLE_COL_MAX, "onButton1_command_table_09" },
whismanoid 51:a41d3fd5e441 2743 // WIP #312 %B onButton2_command_table_00[0] __ bytes -- string
whismanoid 51:a41d3fd5e441 2744 { 0x42062053, &onButton2_command_table_00, COMMAND_TABLE_COL_MAX, "onButton2_command_table_00" },
whismanoid 51:a41d3fd5e441 2745 { 0x42062153, &onButton2_command_table_01, COMMAND_TABLE_COL_MAX, "onButton2_command_table_01" },
whismanoid 51:a41d3fd5e441 2746 { 0x42062253, &onButton2_command_table_02, COMMAND_TABLE_COL_MAX, "onButton2_command_table_02" },
whismanoid 51:a41d3fd5e441 2747 { 0x42062353, &onButton2_command_table_03, COMMAND_TABLE_COL_MAX, "onButton2_command_table_03" },
whismanoid 51:a41d3fd5e441 2748 { 0x42062453, &onButton2_command_table_04, COMMAND_TABLE_COL_MAX, "onButton2_command_table_04" },
whismanoid 51:a41d3fd5e441 2749 { 0x42062553, &onButton2_command_table_05, COMMAND_TABLE_COL_MAX, "onButton2_command_table_05" },
whismanoid 51:a41d3fd5e441 2750 { 0x42062653, &onButton2_command_table_06, COMMAND_TABLE_COL_MAX, "onButton2_command_table_06" },
whismanoid 51:a41d3fd5e441 2751 { 0x42062753, &onButton2_command_table_07, COMMAND_TABLE_COL_MAX, "onButton2_command_table_07" },
whismanoid 51:a41d3fd5e441 2752 { 0x42062853, &onButton2_command_table_08, COMMAND_TABLE_COL_MAX, "onButton2_command_table_08" },
whismanoid 51:a41d3fd5e441 2753 { 0x42062953, &onButton2_command_table_09, COMMAND_TABLE_COL_MAX, "onButton2_command_table_09" },
whismanoid 51:a41d3fd5e441 2754 // WIP #312 %B onButton3_command_table_00[0] __ bytes -- string
whismanoid 51:a41d3fd5e441 2755 { 0x42063053, &onButton3_command_table_00, COMMAND_TABLE_COL_MAX, "onButton3_command_table_00" },
whismanoid 51:a41d3fd5e441 2756 { 0x42063153, &onButton3_command_table_01, COMMAND_TABLE_COL_MAX, "onButton3_command_table_01" },
whismanoid 51:a41d3fd5e441 2757 { 0x42063253, &onButton3_command_table_02, COMMAND_TABLE_COL_MAX, "onButton3_command_table_02" },
whismanoid 51:a41d3fd5e441 2758 { 0x42063353, &onButton3_command_table_03, COMMAND_TABLE_COL_MAX, "onButton3_command_table_03" },
whismanoid 51:a41d3fd5e441 2759 { 0x42063453, &onButton3_command_table_04, COMMAND_TABLE_COL_MAX, "onButton3_command_table_04" },
whismanoid 51:a41d3fd5e441 2760 { 0x42063553, &onButton3_command_table_05, COMMAND_TABLE_COL_MAX, "onButton3_command_table_05" },
whismanoid 51:a41d3fd5e441 2761 { 0x42063653, &onButton3_command_table_06, COMMAND_TABLE_COL_MAX, "onButton3_command_table_06" },
whismanoid 51:a41d3fd5e441 2762 { 0x42063753, &onButton3_command_table_07, COMMAND_TABLE_COL_MAX, "onButton3_command_table_07" },
whismanoid 51:a41d3fd5e441 2763 { 0x42063853, &onButton3_command_table_08, COMMAND_TABLE_COL_MAX, "onButton3_command_table_08" },
whismanoid 51:a41d3fd5e441 2764 { 0x42063953, &onButton3_command_table_09, COMMAND_TABLE_COL_MAX, "onButton3_command_table_09" },
whismanoid 51:a41d3fd5e441 2765 // WIP #312 %B onButton4_command_table_00[0] __ bytes -- string
whismanoid 51:a41d3fd5e441 2766 { 0x42064053, &onButton4_command_table_00, COMMAND_TABLE_COL_MAX, "onButton4_command_table_00" },
whismanoid 51:a41d3fd5e441 2767 { 0x42064153, &onButton4_command_table_01, COMMAND_TABLE_COL_MAX, "onButton4_command_table_01" },
whismanoid 51:a41d3fd5e441 2768 { 0x42064253, &onButton4_command_table_02, COMMAND_TABLE_COL_MAX, "onButton4_command_table_02" },
whismanoid 51:a41d3fd5e441 2769 { 0x42064353, &onButton4_command_table_03, COMMAND_TABLE_COL_MAX, "onButton4_command_table_03" },
whismanoid 51:a41d3fd5e441 2770 { 0x42064453, &onButton4_command_table_04, COMMAND_TABLE_COL_MAX, "onButton4_command_table_04" },
whismanoid 51:a41d3fd5e441 2771 { 0x42064553, &onButton4_command_table_05, COMMAND_TABLE_COL_MAX, "onButton4_command_table_05" },
whismanoid 51:a41d3fd5e441 2772 { 0x42064653, &onButton4_command_table_06, COMMAND_TABLE_COL_MAX, "onButton4_command_table_06" },
whismanoid 51:a41d3fd5e441 2773 { 0x42064753, &onButton4_command_table_07, COMMAND_TABLE_COL_MAX, "onButton4_command_table_07" },
whismanoid 51:a41d3fd5e441 2774 { 0x42064853, &onButton4_command_table_08, COMMAND_TABLE_COL_MAX, "onButton4_command_table_08" },
whismanoid 51:a41d3fd5e441 2775 { 0x42064953, &onButton4_command_table_09, COMMAND_TABLE_COL_MAX, "onButton4_command_table_09" },
whismanoid 51:a41d3fd5e441 2776 // WIP #312 %B onButton5_command_table_00[0] __ bytes -- string
whismanoid 51:a41d3fd5e441 2777 { 0x42065053, &onButton5_command_table_00, COMMAND_TABLE_COL_MAX, "onButton5_command_table_00" },
whismanoid 51:a41d3fd5e441 2778 { 0x42065153, &onButton5_command_table_01, COMMAND_TABLE_COL_MAX, "onButton5_command_table_01" },
whismanoid 51:a41d3fd5e441 2779 { 0x42065253, &onButton5_command_table_02, COMMAND_TABLE_COL_MAX, "onButton5_command_table_02" },
whismanoid 51:a41d3fd5e441 2780 { 0x42065353, &onButton5_command_table_03, COMMAND_TABLE_COL_MAX, "onButton5_command_table_03" },
whismanoid 51:a41d3fd5e441 2781 { 0x42065453, &onButton5_command_table_04, COMMAND_TABLE_COL_MAX, "onButton5_command_table_04" },
whismanoid 51:a41d3fd5e441 2782 { 0x42065553, &onButton5_command_table_05, COMMAND_TABLE_COL_MAX, "onButton5_command_table_05" },
whismanoid 51:a41d3fd5e441 2783 { 0x42065653, &onButton5_command_table_06, COMMAND_TABLE_COL_MAX, "onButton5_command_table_06" },
whismanoid 51:a41d3fd5e441 2784 { 0x42065753, &onButton5_command_table_07, COMMAND_TABLE_COL_MAX, "onButton5_command_table_07" },
whismanoid 51:a41d3fd5e441 2785 { 0x42065853, &onButton5_command_table_08, COMMAND_TABLE_COL_MAX, "onButton5_command_table_08" },
whismanoid 51:a41d3fd5e441 2786 { 0x42065953, &onButton5_command_table_09, COMMAND_TABLE_COL_MAX, "onButton5_command_table_09" },
whismanoid 51:a41d3fd5e441 2787 // WIP #312 %B onButton6_command_table_00[0] __ bytes -- string
whismanoid 51:a41d3fd5e441 2788 { 0x42066053, &onButton6_command_table_00, COMMAND_TABLE_COL_MAX, "onButton6_command_table_00" },
whismanoid 51:a41d3fd5e441 2789 { 0x42066153, &onButton6_command_table_01, COMMAND_TABLE_COL_MAX, "onButton6_command_table_01" },
whismanoid 51:a41d3fd5e441 2790 { 0x42066253, &onButton6_command_table_02, COMMAND_TABLE_COL_MAX, "onButton6_command_table_02" },
whismanoid 51:a41d3fd5e441 2791 { 0x42066353, &onButton6_command_table_03, COMMAND_TABLE_COL_MAX, "onButton6_command_table_03" },
whismanoid 51:a41d3fd5e441 2792 { 0x42066453, &onButton6_command_table_04, COMMAND_TABLE_COL_MAX, "onButton6_command_table_04" },
whismanoid 51:a41d3fd5e441 2793 { 0x42066553, &onButton6_command_table_05, COMMAND_TABLE_COL_MAX, "onButton6_command_table_05" },
whismanoid 51:a41d3fd5e441 2794 { 0x42066653, &onButton6_command_table_06, COMMAND_TABLE_COL_MAX, "onButton6_command_table_06" },
whismanoid 51:a41d3fd5e441 2795 { 0x42066753, &onButton6_command_table_07, COMMAND_TABLE_COL_MAX, "onButton6_command_table_07" },
whismanoid 51:a41d3fd5e441 2796 { 0x42066853, &onButton6_command_table_08, COMMAND_TABLE_COL_MAX, "onButton6_command_table_08" },
whismanoid 51:a41d3fd5e441 2797 { 0x42066953, &onButton6_command_table_09, COMMAND_TABLE_COL_MAX, "onButton6_command_table_09" },
whismanoid 51:a41d3fd5e441 2798 // WIP #312 %B onButton7_command_table_00[0] __ bytes -- string
whismanoid 51:a41d3fd5e441 2799 { 0x42067053, &onButton7_command_table_00, COMMAND_TABLE_COL_MAX, "onButton7_command_table_00" },
whismanoid 51:a41d3fd5e441 2800 { 0x42067153, &onButton7_command_table_01, COMMAND_TABLE_COL_MAX, "onButton7_command_table_01" },
whismanoid 51:a41d3fd5e441 2801 { 0x42067253, &onButton7_command_table_02, COMMAND_TABLE_COL_MAX, "onButton7_command_table_02" },
whismanoid 51:a41d3fd5e441 2802 { 0x42067353, &onButton7_command_table_03, COMMAND_TABLE_COL_MAX, "onButton7_command_table_03" },
whismanoid 51:a41d3fd5e441 2803 { 0x42067453, &onButton7_command_table_04, COMMAND_TABLE_COL_MAX, "onButton7_command_table_04" },
whismanoid 51:a41d3fd5e441 2804 { 0x42067553, &onButton7_command_table_05, COMMAND_TABLE_COL_MAX, "onButton7_command_table_05" },
whismanoid 51:a41d3fd5e441 2805 { 0x42067653, &onButton7_command_table_06, COMMAND_TABLE_COL_MAX, "onButton7_command_table_06" },
whismanoid 51:a41d3fd5e441 2806 { 0x42067753, &onButton7_command_table_07, COMMAND_TABLE_COL_MAX, "onButton7_command_table_07" },
whismanoid 51:a41d3fd5e441 2807 { 0x42067853, &onButton7_command_table_08, COMMAND_TABLE_COL_MAX, "onButton7_command_table_08" },
whismanoid 51:a41d3fd5e441 2808 { 0x42067953, &onButton7_command_table_09, COMMAND_TABLE_COL_MAX, "onButton7_command_table_09" },
whismanoid 51:a41d3fd5e441 2809 // WIP #312 %B onButton8_command_table_00[0] __ bytes -- string
whismanoid 51:a41d3fd5e441 2810 { 0x42068053, &onButton8_command_table_00, COMMAND_TABLE_COL_MAX, "onButton8_command_table_00" },
whismanoid 51:a41d3fd5e441 2811 { 0x42068153, &onButton8_command_table_01, COMMAND_TABLE_COL_MAX, "onButton8_command_table_01" },
whismanoid 51:a41d3fd5e441 2812 { 0x42068253, &onButton8_command_table_02, COMMAND_TABLE_COL_MAX, "onButton8_command_table_02" },
whismanoid 51:a41d3fd5e441 2813 { 0x42068353, &onButton8_command_table_03, COMMAND_TABLE_COL_MAX, "onButton8_command_table_03" },
whismanoid 51:a41d3fd5e441 2814 { 0x42068453, &onButton8_command_table_04, COMMAND_TABLE_COL_MAX, "onButton8_command_table_04" },
whismanoid 51:a41d3fd5e441 2815 { 0x42068553, &onButton8_command_table_05, COMMAND_TABLE_COL_MAX, "onButton8_command_table_05" },
whismanoid 51:a41d3fd5e441 2816 { 0x42068653, &onButton8_command_table_06, COMMAND_TABLE_COL_MAX, "onButton8_command_table_06" },
whismanoid 51:a41d3fd5e441 2817 { 0x42068753, &onButton8_command_table_07, COMMAND_TABLE_COL_MAX, "onButton8_command_table_07" },
whismanoid 51:a41d3fd5e441 2818 { 0x42068853, &onButton8_command_table_08, COMMAND_TABLE_COL_MAX, "onButton8_command_table_08" },
whismanoid 51:a41d3fd5e441 2819 { 0x42068953, &onButton8_command_table_09, COMMAND_TABLE_COL_MAX, "onButton8_command_table_09" },
whismanoid 51:a41d3fd5e441 2820 // WIP #312 %B onButton9_command_table_00[0] __ bytes -- string
whismanoid 51:a41d3fd5e441 2821 { 0x42069053, &onButton9_command_table_00, COMMAND_TABLE_COL_MAX, "onButton9_command_table_00" },
whismanoid 51:a41d3fd5e441 2822 { 0x42069153, &onButton9_command_table_01, COMMAND_TABLE_COL_MAX, "onButton9_command_table_01" },
whismanoid 51:a41d3fd5e441 2823 { 0x42069253, &onButton9_command_table_02, COMMAND_TABLE_COL_MAX, "onButton9_command_table_02" },
whismanoid 51:a41d3fd5e441 2824 { 0x42069353, &onButton9_command_table_03, COMMAND_TABLE_COL_MAX, "onButton9_command_table_03" },
whismanoid 51:a41d3fd5e441 2825 { 0x42069453, &onButton9_command_table_04, COMMAND_TABLE_COL_MAX, "onButton9_command_table_04" },
whismanoid 51:a41d3fd5e441 2826 { 0x42069553, &onButton9_command_table_05, COMMAND_TABLE_COL_MAX, "onButton9_command_table_05" },
whismanoid 51:a41d3fd5e441 2827 { 0x42069653, &onButton9_command_table_06, COMMAND_TABLE_COL_MAX, "onButton9_command_table_06" },
whismanoid 51:a41d3fd5e441 2828 { 0x42069753, &onButton9_command_table_07, COMMAND_TABLE_COL_MAX, "onButton9_command_table_07" },
whismanoid 51:a41d3fd5e441 2829 { 0x42069853, &onButton9_command_table_08, COMMAND_TABLE_COL_MAX, "onButton9_command_table_08" },
whismanoid 51:a41d3fd5e441 2830 { 0x42069953, &onButton9_command_table_09, COMMAND_TABLE_COL_MAX, "onButton9_command_table_09" },
whismanoid 46:469d0061df5d 2831 // WIP #312 %B onButton9_command_table[0] __ bytes
whismanoid 47:f1a56afb4aca 2832 //
whismanoid 46:469d0061df5d 2833 { 0x00000000, NULL, 0, "wiped" }, // Ignore 0x00000000 wiped records; end of table
whismanoid 46:469d0061df5d 2834 };
whismanoid 48:18647e0516f2 2835 const uint32_t save_arg_01_pageErase = 0x00000001; // page erase and rewrite
whismanoid 48:18647e0516f2 2836 const uint32_t load_arg_01_brief = 0x00000001; // brief list loaded values
whismanoid 48:18647e0516f2 2837 const uint32_t save_arg_02_verbose = 0x00000002; // verbose diagnostic messages
whismanoid 48:18647e0516f2 2838 const uint32_t save_arg_04_reserved = 0x00000004; // reserved
whismanoid 48:18647e0516f2 2839 const uint32_t save_arg_08_reserved = 0x00000008; // reserved
whismanoid 48:18647e0516f2 2840 const uint32_t save_arg_10_calibration = 0x00000010; // save board ID and calibration
whismanoid 48:18647e0516f2 2841 const uint32_t save_arg_20_action_table = 0x00000020; // save Datalogger_action_table
whismanoid 48:18647e0516f2 2842 const uint32_t save_arg_40_command_table = 0x00000040; // save onButtonX_command_table
whismanoid 48:18647e0516f2 2843 const uint32_t save_arg_80_reserved = 0x00000080; // reserved
whismanoid 48:18647e0516f2 2844 const uint32_t save_arg_default = 0
whismanoid 48:18647e0516f2 2845 | save_arg_01_pageErase
whismanoid 48:18647e0516f2 2846 // | save_arg_02_verbose
whismanoid 48:18647e0516f2 2847 // | save_arg_04_reserved
whismanoid 48:18647e0516f2 2848 // | save_arg_08_reserved
whismanoid 48:18647e0516f2 2849 | save_arg_10_calibration
whismanoid 48:18647e0516f2 2850 | save_arg_20_action_table
whismanoid 48:18647e0516f2 2851 | save_arg_40_command_table
whismanoid 48:18647e0516f2 2852 // | save_arg_80_reserved
whismanoid 48:18647e0516f2 2853 ;
whismanoid 48:18647e0516f2 2854 const uint32_t load_arg_default = 0
whismanoid 48:18647e0516f2 2855 | load_arg_01_brief
whismanoid 48:18647e0516f2 2856 | save_arg_02_verbose
whismanoid 48:18647e0516f2 2857 // | save_arg_04_reserved
whismanoid 48:18647e0516f2 2858 // | save_arg_08_reserved
whismanoid 48:18647e0516f2 2859 | save_arg_10_calibration
whismanoid 48:18647e0516f2 2860 | save_arg_20_action_table
whismanoid 48:18647e0516f2 2861 | save_arg_40_command_table
whismanoid 48:18647e0516f2 2862 // | save_arg_80_reserved
whismanoid 48:18647e0516f2 2863 ;
whismanoid 48:18647e0516f2 2864 const uint32_t load_arg_startup = 0
whismanoid 48:18647e0516f2 2865 | load_arg_01_brief
whismanoid 48:18647e0516f2 2866 // | save_arg_02_verbose
whismanoid 48:18647e0516f2 2867 // | save_arg_04_reserved
whismanoid 48:18647e0516f2 2868 // | save_arg_08_reserved
whismanoid 48:18647e0516f2 2869 | save_arg_10_calibration
whismanoid 48:18647e0516f2 2870 | save_arg_20_action_table
whismanoid 48:18647e0516f2 2871 | save_arg_40_command_table
whismanoid 48:18647e0516f2 2872 // | save_arg_80_reserved
whismanoid 48:18647e0516f2 2873 ;
whismanoid 46:469d0061df5d 2874 // WIP #312 store values into flash_page_configuration_back_up[] from calibration_05_V[] etc. Default save everything.
whismanoid 48:18647e0516f2 2875 // @param[in] save_arg %F save=0x00000001 = page erase and rewrite, else append in next available blank space within page
whismanoid 48:18647e0516f2 2876 // @param[in] save_arg %F save=0x00000002 = verbose diagnostic messages
whismanoid 48:18647e0516f2 2877 // @param[in] save_arg %F save=0x00000004 = reserved
whismanoid 48:18647e0516f2 2878 // @param[in] save_arg %F save=0x00000008 = reserved
whismanoid 48:18647e0516f2 2879 // @param[in] save_arg %F save=0x00000010 = save board ID and calibration
whismanoid 48:18647e0516f2 2880 // @param[in] save_arg %F save=0x00000020 = save Datalogger_action_table
whismanoid 48:18647e0516f2 2881 // @param[in] save_arg %F save=0x00000040 = save onButtonX_command_table
whismanoid 48:18647e0516f2 2882 // @param[in] save_arg %F save=0x00000080 = reserved
whismanoid 46:469d0061df5d 2883 int Save_flash_page_configuration_back_up(CmdLine& cmdLine, uint32_t save_arg)
whismanoid 46:469d0061df5d 2884 {
whismanoid 48:18647e0516f2 2885 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2886 {
whismanoid 48:18647e0516f2 2887 cmdLine.serial().printf("\r\nSave_flash_page_configuration_back_up(0x%8.8lx)...", save_arg);
whismanoid 48:18647e0516f2 2888 }
whismanoid 48:18647e0516f2 2889 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2890 {
whismanoid 48:18647e0516f2 2891 // @param[in] save_arg %F save=0x00000002 = verbose diagnostic messages
whismanoid 49:359a6b9df7c1 2892 if ((save_arg & save_arg_01_pageErase) != 0) { cmdLine.serial().printf("\r\n 0x%lx: save_arg_01_pageErase", save_arg_01_pageErase); }
whismanoid 49:359a6b9df7c1 2893 if ((save_arg & save_arg_02_verbose) != 0) { cmdLine.serial().printf("\r\n 0x%lx: save_arg_02_verbose", save_arg_02_verbose); }
whismanoid 49:359a6b9df7c1 2894 if ((save_arg & save_arg_04_reserved) != 0) { cmdLine.serial().printf("\r\n 0x%lx: save_arg_04_reserved", save_arg_04_reserved); }
whismanoid 49:359a6b9df7c1 2895 if ((save_arg & save_arg_08_reserved) != 0) { cmdLine.serial().printf("\r\n 0x%lx: save_arg_08_reserved", save_arg_08_reserved); }
whismanoid 49:359a6b9df7c1 2896 if ((save_arg & save_arg_10_calibration) != 0) { cmdLine.serial().printf("\r\n 0x%lx: save_arg_10_calibration", save_arg_10_calibration); }
whismanoid 49:359a6b9df7c1 2897 if ((save_arg & save_arg_20_action_table) != 0) { cmdLine.serial().printf("\r\n 0x%lx: save_arg_20_action_table", save_arg_20_action_table); }
whismanoid 49:359a6b9df7c1 2898 if ((save_arg & save_arg_40_command_table) != 0) { cmdLine.serial().printf("\r\n 0x%lx: save_arg_40_command_table", save_arg_40_command_table); }
whismanoid 49:359a6b9df7c1 2899 if ((save_arg & save_arg_80_reserved) != 0) { cmdLine.serial().printf("\r\n 0x%lx: save_arg_80_reserved", save_arg_80_reserved); }
whismanoid 48:18647e0516f2 2900 }
whismanoid 46:469d0061df5d 2901 // WIP #312 %F save=save_arg could filter which items to append to flash file
whismanoid 46:469d0061df5d 2902 // initialize flash memory interface
whismanoid 46:469d0061df5d 2903 // FlashIAP: FlashIAP flash; flash.init();
whismanoid 46:469d0061df5d 2904 // int FLC_Init(void);
whismanoid 46:469d0061df5d 2905 // returns E_NO_ERROR or E_BUSY or E_UNKNOWN
whismanoid 48:18647e0516f2 2906 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2907 {
whismanoid 48:18647e0516f2 2908 cmdLine.serial().printf("FLC_Init ");
whismanoid 48:18647e0516f2 2909 }
whismanoid 46:469d0061df5d 2910 if (FLC_Init() != E_NO_ERROR)
whismanoid 46:469d0061df5d 2911 {
whismanoid 48:18647e0516f2 2912 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2913 {
whismanoid 48:18647e0516f2 2914 cmdLine.serial().printf("FAIL ");
whismanoid 48:18647e0516f2 2915 }
whismanoid 46:469d0061df5d 2916 return 1; // can't perform the command
whismanoid 46:469d0061df5d 2917 }
whismanoid 48:18647e0516f2 2918 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2919 {
whismanoid 48:18647e0516f2 2920 cmdLine.serial().printf("PASS ");
whismanoid 48:18647e0516f2 2921 }
whismanoid 46:469d0061df5d 2922 //
whismanoid 46:469d0061df5d 2923
whismanoid 46:469d0061df5d 2924 uint32_t file_addr = (uint32_t)&flash_page_configuration_back_up[0];
whismanoid 46:469d0061df5d 2925 // uint32_t file_addr_end = file_addr + 8192 - 4;
whismanoid 46:469d0061df5d 2926 uint32_t file_addr_end = file_addr + 256 - 4; // development: reduce listing size
whismanoid 46:469d0061df5d 2927
whismanoid 46:469d0061df5d 2928 int poke_access_list_index = search_poke_access_list(file_addr);
whismanoid 48:18647e0516f2 2929 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2930 {
whismanoid 48:18647e0516f2 2931 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 48:18647e0516f2 2932 poke_access_list_index,
whismanoid 48:18647e0516f2 2933 poke_access_list[poke_access_list_index].name,
whismanoid 48:18647e0516f2 2934 poke_access_list[poke_access_list_index].addr_min,
whismanoid 48:18647e0516f2 2935 poke_access_list[poke_access_list_index].addr_max,
whismanoid 48:18647e0516f2 2936 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 48:18647e0516f2 2937 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 48:18647e0516f2 2938 }
whismanoid 46:469d0061df5d 2939
whismanoid 48:18647e0516f2 2940 if ((save_arg & save_arg_01_pageErase) != 0)
whismanoid 46:469d0061df5d 2941 {
whismanoid 48:18647e0516f2 2942 // @param[in] save_arg %F save=0x00000001 = page erase and rewrite, else append in next available blank space within page
whismanoid 46:469d0061df5d 2943 // erase flash file before saving configuration
whismanoid 46:469d0061df5d 2944 //
whismanoid 46:469d0061df5d 2945 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: erase page ...",
whismanoid 46:469d0061df5d 2946 poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 46:469d0061df5d 2947 // page erase using flash.erase(addr, flash.get_sector_size(addr));
whismanoid 46:469d0061df5d 2948 // int FLC_PageErase(uint32_t address, MXC_V_FLC_ERASE_CODE_PAGE_ERASE, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 2949 // @param address Address of the page to be erased.
whismanoid 46:469d0061df5d 2950 // @param erase_code Flash erase code; defined as
whismanoid 46:469d0061df5d 2951 // #MXC_V_FLC_ERASE_CODE_PAGE_ERASE for page erase
whismanoid 46:469d0061df5d 2952 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 2953 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 2954 if (FLC_PageErase(file_addr, MXC_V_FLC_ERASE_CODE_PAGE_ERASE,
whismanoid 46:469d0061df5d 2955 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 2956 {
whismanoid 46:469d0061df5d 2957 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 2958 return 1; // can't perform the command
whismanoid 46:469d0061df5d 2959 }
whismanoid 46:469d0061df5d 2960 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 2961 }
whismanoid 48:18647e0516f2 2962 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2963 {
whismanoid 48:18647e0516f2 2964 // @param[in] save_arg %F save=0x00000002 = verbose diagnostic messages
whismanoid 48:18647e0516f2 2965 }
whismanoid 48:18647e0516f2 2966 if ((save_arg & save_arg_04_reserved) != 0)
whismanoid 48:18647e0516f2 2967 {
whismanoid 48:18647e0516f2 2968 // @param[in] save_arg %F save=0x00000004 = reserved
whismanoid 48:18647e0516f2 2969 }
whismanoid 48:18647e0516f2 2970 if ((save_arg & save_arg_08_reserved) != 0)
whismanoid 48:18647e0516f2 2971 {
whismanoid 48:18647e0516f2 2972 // @param[in] save_arg %F save=0x00000008 = reserved
whismanoid 48:18647e0516f2 2973 }
whismanoid 48:18647e0516f2 2974 if ((save_arg & save_arg_10_calibration) != 0)
whismanoid 48:18647e0516f2 2975 {
whismanoid 48:18647e0516f2 2976 // @param[in] save_arg %F save=0x00000010 = save board ID and calibration
whismanoid 48:18647e0516f2 2977 }
whismanoid 48:18647e0516f2 2978 if ((save_arg & save_arg_20_action_table) != 0)
whismanoid 48:18647e0516f2 2979 {
whismanoid 48:18647e0516f2 2980 // @param[in] save_arg %F save=0x00000020 = save Datalogger_action_table
whismanoid 48:18647e0516f2 2981 }
whismanoid 48:18647e0516f2 2982 if ((save_arg & save_arg_40_command_table) != 0)
whismanoid 48:18647e0516f2 2983 {
whismanoid 48:18647e0516f2 2984 // @param[in] save_arg %F save=0x00000040 = save onButtonX_command_table
whismanoid 48:18647e0516f2 2985 }
whismanoid 48:18647e0516f2 2986 if ((save_arg & save_arg_80_reserved) != 0)
whismanoid 48:18647e0516f2 2987 {
whismanoid 48:18647e0516f2 2988 // @param[in] save_arg %F save=0x00000080 = reserved
whismanoid 48:18647e0516f2 2989 }
whismanoid 48:18647e0516f2 2990
whismanoid 48:18647e0516f2 2991 // address of next 16-byte-aligned record start address
whismanoid 48:18647e0516f2 2992 uint32_t file_addr_next = (file_addr + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 2993
whismanoid 46:469d0061df5d 2994 // scan configuration_back_up_list[] for recordType
whismanoid 46:469d0061df5d 2995 for (int i = 0; configuration_back_up_list[i].recordType != 0x00000000; i++)
whismanoid 46:469d0061df5d 2996 {
whismanoid 48:18647e0516f2 2997 file_addr_next = (file_addr + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 2998 if (configuration_back_up_list[i].recordType == 0xFFFFFFFF) continue;
whismanoid 46:469d0061df5d 2999 //
whismanoid 46:469d0061df5d 3000 // configuration_back_up_list[i].recordType
whismanoid 46:469d0061df5d 3001 // configuration_back_up_list[i].addr
whismanoid 46:469d0061df5d 3002 // configuration_back_up_list[i].length_bytes
whismanoid 46:469d0061df5d 3003 // configuration_back_up_list[i].name
whismanoid 46:469d0061df5d 3004 // WIP #312 %F save=save_arg could filter which items to append to flash file
whismanoid 46:469d0061df5d 3005 //
whismanoid 48:18647e0516f2 3006 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 3007 {
whismanoid 48:18647e0516f2 3008 cmdLine.serial().printf("\r\n save 0x%8.8lx %s address 0x%8.8lx length 0x%lx bytes",
whismanoid 48:18647e0516f2 3009 configuration_back_up_list[i].recordType,
whismanoid 48:18647e0516f2 3010 configuration_back_up_list[i].name,
whismanoid 48:18647e0516f2 3011 (uint32_t)configuration_back_up_list[i].addr,
whismanoid 48:18647e0516f2 3012 configuration_back_up_list[i].length_bytes);
whismanoid 48:18647e0516f2 3013 }
whismanoid 46:469d0061df5d 3014 //
whismanoid 46:469d0061df5d 3015 // find next free space to store record in flash file
whismanoid 46:469d0061df5d 3016 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 46:469d0061df5d 3017 cmdLine.serial().printf("0x%8.8lx ", *((uint32_t*)file_addr));
whismanoid 46:469d0061df5d 3018 while (*((uint32_t*)file_addr) != 0xFFFFFFFF)
whismanoid 46:469d0061df5d 3019 {
whismanoid 46:469d0061df5d 3020 if (file_addr >= file_addr_end)
whismanoid 46:469d0061df5d 3021 {
whismanoid 46:469d0061df5d 3022 return 1; // fail: no room to write file
whismanoid 46:469d0061df5d 3023 }
whismanoid 48:18647e0516f2 3024 file_addr_next = (file_addr + 16) &~ 0x0000000F;
whismanoid 48:18647e0516f2 3025 file_addr = file_addr_next;
whismanoid 46:469d0061df5d 3026 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx ",
whismanoid 46:469d0061df5d 3027 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 3028 file_addr,
whismanoid 46:469d0061df5d 3029 *((uint32_t*)file_addr)
whismanoid 46:469d0061df5d 3030 );
whismanoid 46:469d0061df5d 3031 }
whismanoid 48:18647e0516f2 3032 file_addr_next = (file_addr + configuration_back_up_list[i].length_bytes + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 3033 //
whismanoid 46:469d0061df5d 3034 // copy data from RAM into flash file
whismanoid 46:469d0061df5d 3035 // not_memcpy(file_addr + 4, configuration_back_up_list[i].addr, configuration_back_up_list[i].length_bytes);
whismanoid 46:469d0061df5d 3036 // pageBuf[0..3] = configuration_back_up_list[i].recordType;
whismanoid 46:469d0061df5d 3037 // pageBuf[4...] = configuration_back_up_list[i].addr, configuration_back_up_list[i].length_bytes
whismanoid 46:469d0061df5d 3038 // WIP #312: FLC_Write(...) in Save_flash_page_configuration_back_up
whismanoid 48:18647e0516f2 3039 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 3040 {
whismanoid 48:18647e0516f2 3041 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: write page buffer ...",
whismanoid 48:18647e0516f2 3042 poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 48:18647e0516f2 3043 }
whismanoid 46:469d0061df5d 3044 // page write using flash.program(page_buffer, addr, page_size);
whismanoid 46:469d0061df5d 3045 // int FLC_Write(uint32_t address, const void *data, uint32_t length, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 3046 // @param address Start address for desired write. @note This address
whismanoid 46:469d0061df5d 3047 // must be 32-bit word aligned
whismanoid 46:469d0061df5d 3048 // @param data A pointer to the buffer containing the data to write.
whismanoid 46:469d0061df5d 3049 // @param length Size of the data to write in bytes. @note The length
whismanoid 46:469d0061df5d 3050 // must be in 32-bit multiples.
whismanoid 46:469d0061df5d 3051 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 3052 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 3053 if (FLC_Write(file_addr,
whismanoid 46:469d0061df5d 3054 (uint32_t*)(&configuration_back_up_list[i].recordType),
whismanoid 46:469d0061df5d 3055 sizeof(uint32_t),
whismanoid 46:469d0061df5d 3056 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 3057 {
whismanoid 48:18647e0516f2 3058 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 3059 {
whismanoid 48:18647e0516f2 3060 cmdLine.serial().printf("FAIL ");
whismanoid 48:18647e0516f2 3061 }
whismanoid 46:469d0061df5d 3062 break; // can't perform the command
whismanoid 46:469d0061df5d 3063 }
whismanoid 48:18647e0516f2 3064 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 3065 {
whismanoid 48:18647e0516f2 3066 cmdLine.serial().printf("PASS ");
whismanoid 48:18647e0516f2 3067 }
whismanoid 46:469d0061df5d 3068 if (FLC_Write(file_addr + 4,
whismanoid 46:469d0061df5d 3069 (uint32_t*)(configuration_back_up_list[i].addr),
whismanoid 46:469d0061df5d 3070 configuration_back_up_list[i].length_bytes,
whismanoid 46:469d0061df5d 3071 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 3072 {
whismanoid 48:18647e0516f2 3073 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 3074 {
whismanoid 48:18647e0516f2 3075 cmdLine.serial().printf("FAIL ");
whismanoid 48:18647e0516f2 3076 }
whismanoid 46:469d0061df5d 3077 break; // can't perform the command
whismanoid 46:469d0061df5d 3078 }
whismanoid 48:18647e0516f2 3079 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 3080 {
whismanoid 48:18647e0516f2 3081 cmdLine.serial().printf("PASS ");
whismanoid 48:18647e0516f2 3082 }
whismanoid 46:469d0061df5d 3083 // advance to next 16-byte-aligned record start address
whismanoid 48:18647e0516f2 3084 file_addr = file_addr_next;
whismanoid 46:469d0061df5d 3085 } // end for each configuration_back_up_list[...]
whismanoid 46:469d0061df5d 3086 return 0;
whismanoid 46:469d0061df5d 3087 } // end Save_flash_page_configuration_back_up
whismanoid 46:469d0061df5d 3088 // WIP #312 load values from flash_page_configuration_back_up[] into calibration_05_V[] etc. Default load everything.
whismanoid 46:469d0061df5d 3089 int Load_flash_page_configuration_back_up(CmdLine& cmdLine, uint32_t load_arg)
whismanoid 46:469d0061df5d 3090 {
whismanoid 48:18647e0516f2 3091 if ((load_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 3092 {
whismanoid 48:18647e0516f2 3093 cmdLine.serial().printf("\r\nLoad_flash_page_configuration_back_up(0x%8.8lx)...", load_arg);
whismanoid 48:18647e0516f2 3094 }
whismanoid 48:18647e0516f2 3095 if ((load_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 3096 {
whismanoid 48:18647e0516f2 3097 // @param[in] save_arg %F save=0x00000002 = verbose diagnostic messages
whismanoid 49:359a6b9df7c1 3098 if ((load_arg & load_arg_01_brief) != 0) { cmdLine.serial().printf("\r\n 0x%lx: load_arg_01_brief", load_arg_01_brief); }
whismanoid 49:359a6b9df7c1 3099 if ((load_arg & save_arg_02_verbose) != 0) { cmdLine.serial().printf("\r\n 0x%lx: save_arg_02_verbose", save_arg_02_verbose); }
whismanoid 49:359a6b9df7c1 3100 if ((load_arg & save_arg_04_reserved) != 0) { cmdLine.serial().printf("\r\n 0x%lx: save_arg_04_reserved", save_arg_04_reserved); }
whismanoid 49:359a6b9df7c1 3101 if ((load_arg & save_arg_08_reserved) != 0) { cmdLine.serial().printf("\r\n 0x%lx: save_arg_08_reserved", save_arg_08_reserved); }
whismanoid 49:359a6b9df7c1 3102 if ((load_arg & save_arg_10_calibration) != 0) { cmdLine.serial().printf("\r\n 0x%lx: save_arg_10_calibration", save_arg_10_calibration); }
whismanoid 49:359a6b9df7c1 3103 if ((load_arg & save_arg_20_action_table) != 0) { cmdLine.serial().printf("\r\n 0x%lx: save_arg_20_action_table", save_arg_20_action_table); }
whismanoid 49:359a6b9df7c1 3104 if ((load_arg & save_arg_40_command_table) != 0) { cmdLine.serial().printf("\r\n 0x%lx: save_arg_40_command_table", save_arg_40_command_table); }
whismanoid 49:359a6b9df7c1 3105 if ((load_arg & save_arg_80_reserved) != 0) { cmdLine.serial().printf("\r\n 0x%lx: save_arg_80_reserved", save_arg_80_reserved); }
whismanoid 48:18647e0516f2 3106 }
whismanoid 46:469d0061df5d 3107 // WIP #312 %F load=load_arg could filter which items to accept from flash file
whismanoid 46:469d0061df5d 3108
whismanoid 46:469d0061df5d 3109 uint32_t file_addr = (uint32_t)&flash_page_configuration_back_up[0];
whismanoid 46:469d0061df5d 3110 // uint32_t file_addr_end = file_addr + 8192 - 4; // last record at 0x00027ff0
whismanoid 46:469d0061df5d 3111 // uint32_t file_addr_end = file_addr + 256 - 4; // development: reduce listing size -- last record at 0x000260f0
whismanoid 46:469d0061df5d 3112 uint32_t file_addr_end = file_addr + 512 - 4; // development: reduce listing size -- last record at 0x000261f0
whismanoid 46:469d0061df5d 3113
whismanoid 46:469d0061df5d 3114 // diagnostic print
whismanoid 46:469d0061df5d 3115 int poke_access_list_index = search_poke_access_list(file_addr);
whismanoid 48:18647e0516f2 3116 if ((load_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 3117 {
whismanoid 48:18647e0516f2 3118 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 48:18647e0516f2 3119 poke_access_list_index,
whismanoid 48:18647e0516f2 3120 poke_access_list[poke_access_list_index].name,
whismanoid 48:18647e0516f2 3121 poke_access_list[poke_access_list_index].addr_min,
whismanoid 48:18647e0516f2 3122 poke_access_list[poke_access_list_index].addr_max,
whismanoid 48:18647e0516f2 3123 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 48:18647e0516f2 3124 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 48:18647e0516f2 3125 }
whismanoid 46:469d0061df5d 3126
whismanoid 46:469d0061df5d 3127 // Scan backup configuration file
whismanoid 46:469d0061df5d 3128 while (file_addr < file_addr_end)
whismanoid 46:469d0061df5d 3129 {
whismanoid 48:18647e0516f2 3130 if ((load_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 3131 {
whismanoid 48:18647e0516f2 3132 // diagnostic print
whismanoid 48:18647e0516f2 3133 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx ",
whismanoid 48:18647e0516f2 3134 poke_access_list[poke_access_list_index].name,
whismanoid 48:18647e0516f2 3135 file_addr,
whismanoid 48:18647e0516f2 3136 *((uint32_t*)file_addr));
whismanoid 48:18647e0516f2 3137 }
whismanoid 46:469d0061df5d 3138
whismanoid 46:469d0061df5d 3139 // address of next 16-byte-aligned record start address
whismanoid 46:469d0061df5d 3140 uint32_t file_addr_next = (file_addr + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 3141
whismanoid 46:469d0061df5d 3142 // scan configuration_back_up_list[] to decode recordType
whismanoid 46:469d0061df5d 3143 for (int i = 0; configuration_back_up_list[i].recordType != 0x00000000; i++)
whismanoid 46:469d0061df5d 3144 {
whismanoid 46:469d0061df5d 3145 // configuration_back_up_list[i].recordType
whismanoid 46:469d0061df5d 3146 // configuration_back_up_list[i].addr
whismanoid 46:469d0061df5d 3147 // configuration_back_up_list[i].length_bytes
whismanoid 46:469d0061df5d 3148 // configuration_back_up_list[i].name
whismanoid 46:469d0061df5d 3149 //
whismanoid 46:469d0061df5d 3150 uint32_t file_addr_recordType = file_addr;
whismanoid 46:469d0061df5d 3151 uint32_t file_addr_recordData = file_addr + 1;
whismanoid 46:469d0061df5d 3152 // uint32_t file_addr_recordNext = (file_addr + configuration_back_up_list[i].length_bytes) & ______;
whismanoid 46:469d0061df5d 3153 if (configuration_back_up_list[i].recordType == *((uint32_t*)file_addr_recordType))
whismanoid 46:469d0061df5d 3154 {
whismanoid 46:469d0061df5d 3155 if ((configuration_back_up_list[i].addr == 0) ||
whismanoid 46:469d0061df5d 3156 (configuration_back_up_list[i].length_bytes==0))
whismanoid 46:469d0061df5d 3157 {
whismanoid 46:469d0061df5d 3158 break; // Ignore blank record, stop searching
whismanoid 46:469d0061df5d 3159 }
whismanoid 46:469d0061df5d 3160 // found a matching recordHeader
whismanoid 48:18647e0516f2 3161 if ((load_arg & load_arg_01_brief) != 0)
whismanoid 46:469d0061df5d 3162 {
whismanoid 48:18647e0516f2 3163 // diagnostic print
whismanoid 48:18647e0516f2 3164 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx load %s",
whismanoid 46:469d0061df5d 3165 poke_access_list[poke_access_list_index].name,
whismanoid 48:18647e0516f2 3166 file_addr,
whismanoid 48:18647e0516f2 3167 *((uint32_t*)file_addr),
whismanoid 48:18647e0516f2 3168 configuration_back_up_list[i].name
whismanoid 46:469d0061df5d 3169 );
whismanoid 46:469d0061df5d 3170 }
whismanoid 48:18647e0516f2 3171 if ((load_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 3172 {
whismanoid 48:18647e0516f2 3173
whismanoid 48:18647e0516f2 3174 for (int j = 0; j <= configuration_back_up_list[i].length_bytes; j += 4)
whismanoid 48:18647e0516f2 3175 {
whismanoid 48:18647e0516f2 3176 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx",
whismanoid 48:18647e0516f2 3177 poke_access_list[poke_access_list_index].name,
whismanoid 48:18647e0516f2 3178 (file_addr + 4 + j),
whismanoid 48:18647e0516f2 3179 *((uint32_t*)(file_addr + 4 + j))
whismanoid 48:18647e0516f2 3180 );
whismanoid 48:18647e0516f2 3181 }
whismanoid 48:18647e0516f2 3182 }
whismanoid 46:469d0061df5d 3183 // cmdLine.serial().printf("\r\n load %s 0x%8.8lx length 0x%lx address 0x%8.8lx",
whismanoid 46:469d0061df5d 3184 // configuration_back_up_list[i].name,
whismanoid 46:469d0061df5d 3185 // configuration_back_up_list[i].recordType,
whismanoid 46:469d0061df5d 3186 // configuration_back_up_list[i].length_bytes,
whismanoid 46:469d0061df5d 3187 // (uint32_t)configuration_back_up_list[i].addr,
whismanoid 46:469d0061df5d 3188 // );
whismanoid 46:469d0061df5d 3189 // cmdLine.serial().printf("\r\n load %s 0x%8.8lx length 0x%lx address 0x%8.8lx",
whismanoid 46:469d0061df5d 3190 // configuration_back_up_list[i].name,
whismanoid 46:469d0061df5d 3191 // configuration_back_up_list[i].recordType,
whismanoid 46:469d0061df5d 3192 // configuration_back_up_list[i].length_bytes,
whismanoid 46:469d0061df5d 3193 // (uint32_t)configuration_back_up_list[i].addr,
whismanoid 46:469d0061df5d 3194 // );
whismanoid 46:469d0061df5d 3195 //
whismanoid 46:469d0061df5d 3196 // WIP #312: copy data from flash file into RAM in Load_flash_page_configuration_back_up
whismanoid 46:469d0061df5d 3197 memcpy(configuration_back_up_list[i].addr,
whismanoid 46:469d0061df5d 3198 (const void *)(file_addr + 4),
whismanoid 46:469d0061df5d 3199 configuration_back_up_list[i].length_bytes);
whismanoid 46:469d0061df5d 3200 //
whismanoid 46:469d0061df5d 3201 // advance to next 16-byte-aligned record start address
whismanoid 46:469d0061df5d 3202 file_addr_next = (file_addr + configuration_back_up_list[i].length_bytes + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 3203 break; // stop searching
whismanoid 46:469d0061df5d 3204 } // end if match recordType
whismanoid 46:469d0061df5d 3205 } // end for each configuration_back_up_list[...]
whismanoid 46:469d0061df5d 3206 // advance to next 16-byte-aligned record start address
whismanoid 46:469d0061df5d 3207 file_addr = file_addr_next;
whismanoid 46:469d0061df5d 3208 } // end while (file_addr < file_addr_end)
whismanoid 46:469d0061df5d 3209 return 0;
whismanoid 46:469d0061df5d 3210 } // end Load_flash_page_configuration_back_up
whismanoid 46:469d0061df5d 3211 #endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 3212
whismanoid 46:469d0061df5d 3213 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 3214 // Option to validate SPI link by reading PART_ID register
whismanoid 0:cb44e2e9ec4c 3215 #ifndef VERIFY_PART_ID_IN_LOOP
whismanoid 3:9055e17e181a 3216 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 3217 #define VERIFY_PART_ID_IN_LOOP 1
whismanoid 3:9055e17e181a 3218 #else
whismanoid 0:cb44e2e9ec4c 3219 #define VERIFY_PART_ID_IN_LOOP 0
whismanoid 3:9055e17e181a 3220 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3221 #endif
whismanoid 0:cb44e2e9ec4c 3222
whismanoid 3:9055e17e181a 3223 //--------------------------------------------------
whismanoid 3:9055e17e181a 3224 #define NUM_DUT_ANALOG_IN_CHANNELS 10
whismanoid 3:9055e17e181a 3225
whismanoid 3:9055e17e181a 3226 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 3227 // MAX11410 individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 3:9055e17e181a 3228 typedef enum SPI_AIN_Enable_t {
whismanoid 10:04022a61b527 3229 SPI_AIN_Disable = 0,
whismanoid 10:04022a61b527 3230 SPI_AIN_Enable_LSB = 1,
whismanoid 10:04022a61b527 3231 SPI_AIN_Enable_Volt = 2,
whismanoid 3:9055e17e181a 3232 } SPI_AIN_Enable_t;
whismanoid 3:9055e17e181a 3233 uint8_t SPI_AIN_Enable_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 3234 SPI_AIN_Enable_LSB, // AIN0 1=LSB
whismanoid 10:04022a61b527 3235 SPI_AIN_Enable_LSB, // AIN1 1=LSB
whismanoid 10:04022a61b527 3236 SPI_AIN_Enable_LSB, // AIN2 1=LSB
whismanoid 10:04022a61b527 3237 SPI_AIN_Enable_LSB, // AIN3 1=LSB
whismanoid 10:04022a61b527 3238 SPI_AIN_Enable_LSB, // AIN4 1=LSB
whismanoid 10:04022a61b527 3239 SPI_AIN_Enable_LSB, // AIN5 1=LSB
whismanoid 10:04022a61b527 3240 SPI_AIN_Enable_LSB, // AIN6 1=LSB
whismanoid 10:04022a61b527 3241 SPI_AIN_Enable_LSB, // AIN7 1=LSB
whismanoid 10:04022a61b527 3242 SPI_AIN_Enable_LSB, // AIN8 1=LSB
whismanoid 10:04022a61b527 3243 SPI_AIN_Enable_LSB, // AIN9 1=LSB
whismanoid 3:9055e17e181a 3244 };
whismanoid 3:9055e17e181a 3245 //
whismanoid 10:04022a61b527 3246 double SPI_AIN_Voltage[NUM_DUT_ANALOG_IN_CHANNELS];
whismanoid 13:184a08909405 3247 // Optional custom per-channel header suffix
whismanoid 45:74bf1fe021e5 3248 // This could be used to identify external hardware attached to each input
whismanoid 13:184a08909405 3249 #ifndef HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 3250 #define HAS_SPI_AIN_customChannelHeader 0
whismanoid 13:184a08909405 3251 #endif
whismanoid 13:184a08909405 3252 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 3253 const char* const SPI_AIN_customChannelHeader_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 3254 "", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 3255 "", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 3256 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 3257 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 3258 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 3259 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 3260 };
whismanoid 13:184a08909405 3261 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 3:9055e17e181a 3262 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3263 // ---------- Measure_Voltage_custom_props in Measure_Voltage @pre and in class properties ----------
whismanoid 3:9055e17e181a 3264 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 3265 // MAX11410 specific per-channel config register v_filter
whismanoid 3:9055e17e181a 3266 uint8_t SPI_AIN_Cfg_v_filter_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 3267 0x34, // AIN0 @ v_filter=0x34
whismanoid 3:9055e17e181a 3268 0x34, // AIN1 @ v_filter=0x34
whismanoid 3:9055e17e181a 3269 0x34, // AIN2 @ v_filter=0x34
whismanoid 3:9055e17e181a 3270 0x34, // AIN3 @ v_filter=0x34
whismanoid 3:9055e17e181a 3271 0x34, // AIN4 @ v_filter=0x34
whismanoid 3:9055e17e181a 3272 0x34, // AIN5 @ v_filter=0x34
whismanoid 3:9055e17e181a 3273 0x34, // AIN6 @ v_filter=0x34
whismanoid 3:9055e17e181a 3274 0x34, // AIN7 @ v_filter=0x34
whismanoid 3:9055e17e181a 3275 0x34, // AIN8 @ v_filter=0x34
whismanoid 3:9055e17e181a 3276 0x34, // AIN9 @ v_filter=0x34
whismanoid 3:9055e17e181a 3277 };
whismanoid 3:9055e17e181a 3278 //
whismanoid 4:d9b05924ad4c 3279 // MAX11410 specific per-channel config register v_ctrl
whismanoid 3:9055e17e181a 3280 uint8_t SPI_AIN_Cfg_v_ctrl_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 3281 0x42, // AIN0 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3282 0x42, // AIN1 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3283 0x42, // AIN2 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3284 0x42, // AIN3 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3285 0x42, // AIN4 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3286 0x42, // AIN5 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3287 0x42, // AIN6 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3288 0x42, // AIN7 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3289 0x42, // AIN8 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3290 0x42, // AIN9 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3291 };
whismanoid 3:9055e17e181a 3292 //
whismanoid 4:d9b05924ad4c 3293 // MAX11410 specific per-channel config register v_pga
whismanoid 3:9055e17e181a 3294 uint8_t SPI_AIN_Cfg_v_pga_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 3295 0x00, // AIN0 @ v_pga=0x00
whismanoid 3:9055e17e181a 3296 0x00, // AIN1 @ v_pga=0x00
whismanoid 3:9055e17e181a 3297 0x00, // AIN2 @ v_pga=0x00
whismanoid 3:9055e17e181a 3298 0x00, // AIN3 @ v_pga=0x00
whismanoid 3:9055e17e181a 3299 0x00, // AIN4 @ v_pga=0x00
whismanoid 3:9055e17e181a 3300 0x00, // AIN5 @ v_pga=0x00
whismanoid 3:9055e17e181a 3301 0x00, // AIN6 @ v_pga=0x00
whismanoid 3:9055e17e181a 3302 0x00, // AIN7 @ v_pga=0x00
whismanoid 3:9055e17e181a 3303 0x00, // AIN8 @ v_pga=0x00
whismanoid 3:9055e17e181a 3304 0x00, // AIN9 @ v_pga=0x00
whismanoid 3:9055e17e181a 3305 };
whismanoid 3:9055e17e181a 3306 //
whismanoid 3:9055e17e181a 3307 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3308 // ---------- Measure_Voltage_custom_props ----------
whismanoid 0:cb44e2e9ec4c 3309 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 3310 // filter register configuration in Measure_Voltage and Read_All_Voltages CONV_TYPE_01_Continuous
whismanoid 0:cb44e2e9ec4c 3311 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 3312 //~ const uint8_t custom_v_filter = 0x00; // @ v_filter=0x00 -- LINEF_00_50Hz_60Hz_FIR RATE_0000 | 1.1SPS
whismanoid 0:cb44e2e9ec4c 3313 //~ const uint8_t custom_v_filter = 0x01; // @ v_filter=0x01 -- LINEF_00_50Hz_60Hz_FIR RATE_0001 | 2.1SPS
whismanoid 0:cb44e2e9ec4c 3314 //~ const uint8_t custom_v_filter = 0x02; // @ v_filter=0x02 -- LINEF_00_50Hz_60Hz_FIR RATE_0010 | 4.2SPS
whismanoid 0:cb44e2e9ec4c 3315 //~ const uint8_t custom_v_filter = 0x03; // @ v_filter=0x03 -- LINEF_00_50Hz_60Hz_FIR RATE_0011 | 8.4SPS
whismanoid 0:cb44e2e9ec4c 3316 //~ const uint8_t custom_v_filter = 0x04; // @ v_filter=0x04 -- LINEF_00_50Hz_60Hz_FIR RATE_0100 | 16.8SPS
whismanoid 0:cb44e2e9ec4c 3317 //~ const uint8_t custom_v_filter = 0x10; // @ v_filter=0x10 -- LINEF_01_50Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 3318 //~ const uint8_t custom_v_filter = 0x11; // @ v_filter=0x11 -- LINEF_01_50Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 3319 //~ const uint8_t custom_v_filter = 0x12; // @ v_filter=0x12 -- LINEF_01_50Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 3320 //~ const uint8_t custom_v_filter = 0x13; // @ v_filter=0x13 -- LINEF_01_50Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 3321 //~ const uint8_t custom_v_filter = 0x14; // @ v_filter=0x14 -- LINEF_01_50Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 3322 //~ const uint8_t custom_v_filter = 0x15; // @ v_filter=0x15 -- LINEF_01_50Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 3323 //~ const uint8_t custom_v_filter = 0x20; // @ v_filter=0x20 -- LINEF_10_60Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 3324 //~ const uint8_t custom_v_filter = 0x21; // @ v_filter=0x21 -- LINEF_10_60Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 3325 //~ const uint8_t custom_v_filter = 0x22; // @ v_filter=0x22 -- LINEF_10_60Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 3326 //~ const uint8_t custom_v_filter = 0x23; // @ v_filter=0x23 -- LINEF_10_60Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 3327 //~ const uint8_t custom_v_filter = 0x24; // @ v_filter=0x24 -- LINEF_10_60Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 3328 //~ const uint8_t custom_v_filter = 0x25; // @ v_filter=0x25 -- LINEF_10_60Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 3329 //~ const uint8_t custom_v_filter = 0x30; // @ v_filter=0x30 -- LINEF_11_SINC4 RATE_0000 | 4SPS
whismanoid 0:cb44e2e9ec4c 3330 //~ const uint8_t custom_v_filter = 0x31; // @ v_filter=0x31 -- LINEF_11_SINC4 RATE_0001 | 10SPS
whismanoid 0:cb44e2e9ec4c 3331 //~ const uint8_t custom_v_filter = 0x32; // @ v_filter=0x32 -- LINEF_11_SINC4 RATE_0010 | 20SPS
whismanoid 0:cb44e2e9ec4c 3332 //~ const uint8_t custom_v_filter = 0x33; // @ v_filter=0x33 -- LINEF_11_SINC4 RATE_0011 | 40SPS
whismanoid 0:cb44e2e9ec4c 3333 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 3334 //~ const uint8_t custom_v_filter = 0x35; // @ v_filter=0x35 -- LINEF_11_SINC4 RATE_0101 | 120SPS
whismanoid 0:cb44e2e9ec4c 3335 //~ const uint8_t custom_v_filter = 0x36; // @ v_filter=0x36 -- LINEF_11_SINC4 RATE_0110 | 240SPS
whismanoid 0:cb44e2e9ec4c 3336 //~ const uint8_t custom_v_filter = 0x37; // @ v_filter=0x37 -- LINEF_11_SINC4 RATE_0111 | 480SPS
whismanoid 0:cb44e2e9ec4c 3337 //~ const uint8_t custom_v_filter = 0x38; // @ v_filter=0x38 -- LINEF_11_SINC4 RATE_1000 | 960SPS
whismanoid 0:cb44e2e9ec4c 3338 //~ const uint8_t custom_v_filter = 0x39; // @ v_filter=0x39 -- LINEF_11_SINC4 RATE_1001 | 1920SPS
whismanoid 0:cb44e2e9ec4c 3339 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 3340 //
whismanoid 0:cb44e2e9ec4c 3341 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 3342 // pga register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 0:cb44e2e9ec4c 3343 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 3344 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 3345 //~ const uint8_t custom_v_pga = 0x10; // @ v_pga=0x10 -- 0x10 SIG_PATH_01_BYPASS
whismanoid 0:cb44e2e9ec4c 3346 //~ const uint8_t custom_v_pga = 0x20; // @ v_pga=0x20 -- 0x20 SIG_PATH_10_PGA GAIN_000_1
whismanoid 0:cb44e2e9ec4c 3347 //~ const uint8_t custom_v_pga = 0x21; // @ v_pga=0x21 --*0x21 SIG_PATH_10_PGA GAIN_001_2
whismanoid 0:cb44e2e9ec4c 3348 //~ const uint8_t custom_v_pga = 0x22; // @ v_pga=0x22 -- 0x22 SIG_PATH_10_PGA GAIN_010_4
whismanoid 0:cb44e2e9ec4c 3349 //~ const uint8_t custom_v_pga = 0x23; // @ v_pga=0x23 -- 0x23 SIG_PATH_10_PGA GAIN_011_8
whismanoid 0:cb44e2e9ec4c 3350 //~ const uint8_t custom_v_pga = 0x24; // @ v_pga=0x24 -- 0x24 SIG_PATH_10_PGA GAIN_100_16
whismanoid 0:cb44e2e9ec4c 3351 //~ const uint8_t custom_v_pga = 0x25; // @ v_pga=0x25 -- 0x25 SIG_PATH_10_PGA GAIN_101_32
whismanoid 0:cb44e2e9ec4c 3352 //~ const uint8_t custom_v_pga = 0x26; // @ v_pga=0x26 -- 0x26 SIG_PATH_10_PGA GAIN_110_64
whismanoid 0:cb44e2e9ec4c 3353 //~ const uint8_t custom_v_pga = 0x27; // @ v_pga=0x27 -- 0x27 SIG_PATH_10_PGA GAIN_111_128
whismanoid 0:cb44e2e9ec4c 3354 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 3355 //
whismanoid 0:cb44e2e9ec4c 3356 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 3357 // ctrl register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 3:9055e17e181a 3358 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 3359 //~ const uint8_t custom_v_ctrl = 0x40; // @ v_ctrl=0x40 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1
whismanoid 0:cb44e2e9ec4c 3360 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 3361 //~ const uint8_t custom_v_ctrl = 0x58; // @ v_ctrl=0x58 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 3362 //
whismanoid 0:cb44e2e9ec4c 3363 //~ const uint8_t custom_v_ctrl = 0x41; // @ v_ctrl=0x41 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N
whismanoid 0:cb44e2e9ec4c 3364 //~ const uint8_t custom_v_ctrl = 0x45; // @ v_ctrl=0x45 -- 0x40 unipolar, 0x05 REF_SEL_101_REF1P_AGND
whismanoid 0:cb44e2e9ec4c 3365 //~ const uint8_t custom_v_ctrl = 0x59; // @ v_ctrl=0x59 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 3366 //
whismanoid 0:cb44e2e9ec4c 3367 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 3368 //~ const uint8_t custom_v_ctrl = 0x46; // @ v_ctrl=0x46 -- 0x40 unipolar, 0x06 REF_SEL_110_REF2P_AGND
whismanoid 0:cb44e2e9ec4c 3369 //~ const uint8_t custom_v_ctrl = 0x22; // @ v_ctrl=0x22 -- 0x20 bipolar offset binary, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 3370 //~ const uint8_t custom_v_ctrl = 0x02; // @ v_ctrl=0x02 -- 0x00 bipolar 2's complement, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 3371 //
whismanoid 0:cb44e2e9ec4c 3372 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 3373 //~ const uint8_t custom_v_ctrl = 0x47; // @ v_ctrl=0x47 -- 0x40 unipolar, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 3374 //~ const uint8_t custom_v_ctrl = 0x27; // @ v_ctrl=0x27 -- 0x20 bipolar offset binary, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 3375 //~ const uint8_t custom_v_ctrl = 0x07; // @ v_ctrl=0x07 -- 0x00 bipolar 2's complement, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 3376 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 3377
whismanoid 3:9055e17e181a 3378 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3379 // example code declare SPI interface (GPIO controlled CS)
whismanoid 0:cb44e2e9ec4c 3380 #if defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 3381 SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625MBED: P1_1 P1_2 P1_0 Arduino 10-pin header D11 D12 D13
whismanoid 0:cb44e2e9ec4c 3382 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
whismanoid 19:5ff09c8e9daf 3383 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 3384 #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 3385 SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625PICO: pin P0_5 P0_6 P0_4
whismanoid 0:cb44e2e9ec4c 3386 DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32625PICO: pin P0_7
whismanoid 0:cb44e2e9ec4c 3387 #elif defined(TARGET_MAX32600MBED)
whismanoid 0:cb44e2e9ec4c 3388 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 0:cb44e2e9ec4c 3389 DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 3390 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 3391 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 3392 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:cb44e2e9ec4c 3393 //
whismanoid 0:cb44e2e9ec4c 3394 // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses.
whismanoid 0:cb44e2e9ec4c 3395 SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK); // mosi, miso, sclk spi1 TARGET_NUCLEO_F446RE: Arduino 10-pin header D11 D12 D13
whismanoid 0:cb44e2e9ec4c 3396 DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 3397 //
whismanoid 0:cb44e2e9ec4c 3398 #else
whismanoid 3:9055e17e181a 3399 SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 3:9055e17e181a 3400 DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 3401 #endif
whismanoid 0:cb44e2e9ec4c 3402
whismanoid 0:cb44e2e9ec4c 3403 // example code declare GPIO interface pins
whismanoid 0:cb44e2e9ec4c 3404 // example code declare device instance
whismanoid 3:9055e17e181a 3405 MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC);
whismanoid 3:9055e17e181a 3406 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3407
whismanoid 1:747f1602abfc 3408 //--------------------------------------------------
whismanoid 3:9055e17e181a 3409 // Option to Datalog Arduino platform analog inputs
whismanoid 3:9055e17e181a 3410 #ifndef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 3411 #define LOG_PLATFORM_AIN 6
whismanoid 3:9055e17e181a 3412 //~ #undef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 3413 #endif
whismanoid 3:9055e17e181a 3414 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 1:747f1602abfc 3415 //#ifndef NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 1:747f1602abfc 3416 //#define NUM_PLATFORM_ANALOG_IN_CHANNELS 6
whismanoid 1:747f1602abfc 3417 //#endif
whismanoid 1:747f1602abfc 3418 const int NUM_PLATFORM_ANALOG_IN_CHANNELS = 6;
whismanoid 1:747f1602abfc 3419 const double adc_full_scale_voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 3420 analogInPin_fullScaleVoltage[0], // 1.2,
whismanoid 10:04022a61b527 3421 analogInPin_fullScaleVoltage[1], // 1.2,
whismanoid 10:04022a61b527 3422 analogInPin_fullScaleVoltage[2], // 1.2,
whismanoid 10:04022a61b527 3423 analogInPin_fullScaleVoltage[3], // 1.2,
whismanoid 10:04022a61b527 3424 analogInPin_fullScaleVoltage[4], // 6.0
whismanoid 10:04022a61b527 3425 analogInPin_fullScaleVoltage[5], // 6.0
whismanoid 0:cb44e2e9ec4c 3426 };
whismanoid 9:45f98573eb6d 3427 // Platform ADC individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 9:45f98573eb6d 3428 typedef enum Platform_AIN_Enable_t {
whismanoid 9:45f98573eb6d 3429 Platform_AIN_Disable = 0,
whismanoid 9:45f98573eb6d 3430 Platform_AIN_Enable_LSB = 1,
whismanoid 9:45f98573eb6d 3431 Platform_AIN_Enable_Volt = 2,
whismanoid 9:45f98573eb6d 3432 } Platform_AIN_Enable_t;
whismanoid 13:184a08909405 3433 uint8_t Platform_Enable_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 9:45f98573eb6d 3434 Platform_AIN_Enable_Volt, // AIN0 2=Volt
whismanoid 9:45f98573eb6d 3435 Platform_AIN_Enable_Volt, // AIN1 2=Volt
whismanoid 9:45f98573eb6d 3436 Platform_AIN_Enable_Volt, // AIN2 2=Volt
whismanoid 9:45f98573eb6d 3437 Platform_AIN_Enable_Volt, // AIN3 2=Volt
whismanoid 9:45f98573eb6d 3438 Platform_AIN_Enable_Volt, // AIN4 2=Volt
whismanoid 9:45f98573eb6d 3439 Platform_AIN_Enable_Volt, // AIN5 2=Volt
whismanoid 9:45f98573eb6d 3440 };
whismanoid 37:3f369235e5bc 3441 // Option to report average value of Arduino platform analog inputs
whismanoid 37:3f369235e5bc 3442 #ifndef USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3443 #define USE_Platform_AIN_Average 1
whismanoid 37:3f369235e5bc 3444 //~ #undef USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3445 #endif
whismanoid 37:3f369235e5bc 3446 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3447 #endif // USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3448 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3449 int Platform_AIN_Average_N = 16;
whismanoid 37:3f369235e5bc 3450 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 3451 // Option to apply calibration to Arduino platform analog inputs
whismanoid 34:a1993a1ee904 3452 #ifndef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3453 #define HAS_Platform_AIN_Calibration 1
whismanoid 34:a1993a1ee904 3454 //~ #undef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3455 #endif
whismanoid 34:a1993a1ee904 3456 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3457 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 3458 // Calibration is between two points for each channel, defined by
whismanoid 34:a1993a1ee904 3459 // a normalized value between 0% and 100%, and the corresponding voltage.
whismanoid 34:a1993a1ee904 3460 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 3461 // calibration_05_normValue_0_1, calibration_05_V should be around 5% or 25%
whismanoid 42:89607d5d4e6d 3462 extern double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 42:89607d5d4e6d 3463 extern double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 34:a1993a1ee904 3464 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 3465 // calibration_95_normValue_0_1, calibration_95_V should be around 95% or 75%
whismanoid 42:89607d5d4e6d 3466 extern double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 42:89607d5d4e6d 3467 extern double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 34:a1993a1ee904 3468 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3469 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3470 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1)
whismanoid 34:a1993a1ee904 3471 {
whismanoid 34:a1993a1ee904 3472 // TODO: return corrected normValue_0_1 using two-point linear calibration
whismanoid 34:a1993a1ee904 3473 // point 1: calibration_05_normValue_0_1[ch], calibration_05_V[ch]
whismanoid 34:a1993a1ee904 3474 // point 2: calibration_95_normValue_0_1[ch], calibration_95_V[ch]
whismanoid 34:a1993a1ee904 3475 // validate that there is enough span to get sensible results
whismanoid 34:a1993a1ee904 3476 //
whismanoid 34:a1993a1ee904 3477 int ch = channel_0_5;
whismanoid 34:a1993a1ee904 3478 // cmdLine.serial().printf(" %%A cal%dn=%1.9f cal%dv=%1.9fV cal%dn=%1.9f cal%dv=%1.9fV\r\n",
whismanoid 34:a1993a1ee904 3479 // ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 3480 // ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 3481 // ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 3482 // ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 3483 // );
whismanoid 34:a1993a1ee904 3484 // cmdLine.serial().printf("\r\n adc_full_scale_voltage[%d] = %1.6fV",
whismanoid 34:a1993a1ee904 3485 // ch,
whismanoid 34:a1993a1ee904 3486 // adc_full_scale_voltage[ch]
whismanoid 34:a1993a1ee904 3487 // );
whismanoid 34:a1993a1ee904 3488 // raw normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 3489 double raw_05_normValue = calibration_05_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 3490 double raw_95_normValue = calibration_95_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 3491 // calibrated normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 3492 // divide V/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 3493 double cal_05_normValue = calibration_05_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 3494 double cal_95_normValue = calibration_95_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 3495 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_05_normValue = %1.6f",
whismanoid 34:a1993a1ee904 3496 // ch,
whismanoid 34:a1993a1ee904 3497 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3498 // cal_05_normValue
whismanoid 34:a1993a1ee904 3499 // );
whismanoid 34:a1993a1ee904 3500 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_95_normValue = %1.6f",
whismanoid 34:a1993a1ee904 3501 // ch,
whismanoid 34:a1993a1ee904 3502 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3503 // cal_95_normValue
whismanoid 34:a1993a1ee904 3504 // );
whismanoid 34:a1993a1ee904 3505 //
whismanoid 34:a1993a1ee904 3506 double span_raw = raw_95_normValue - raw_05_normValue;
whismanoid 34:a1993a1ee904 3507 double span_cal = cal_95_normValue - cal_05_normValue;
whismanoid 34:a1993a1ee904 3508 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_raw = %1.6f",
whismanoid 34:a1993a1ee904 3509 // ch,
whismanoid 34:a1993a1ee904 3510 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3511 // span_raw
whismanoid 34:a1993a1ee904 3512 // );
whismanoid 34:a1993a1ee904 3513 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_cal = %1.6f",
whismanoid 34:a1993a1ee904 3514 // ch,
whismanoid 34:a1993a1ee904 3515 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3516 // span_cal
whismanoid 34:a1993a1ee904 3517 // );
whismanoid 34:a1993a1ee904 3518 // if calibration is not valid, return unmodified normValue_0_1 and print a warning
whismanoid 34:a1993a1ee904 3519 if (span_raw < 0.001) {
whismanoid 34:a1993a1ee904 3520 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_raw = %1.6f",
whismanoid 34:a1993a1ee904 3521 ch,
whismanoid 34:a1993a1ee904 3522 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3523 span_raw
whismanoid 34:a1993a1ee904 3524 );
whismanoid 34:a1993a1ee904 3525 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 3526 }
whismanoid 34:a1993a1ee904 3527 if (span_cal < 0.001) {
whismanoid 34:a1993a1ee904 3528 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_cal = %1.6f",
whismanoid 34:a1993a1ee904 3529 ch,
whismanoid 34:a1993a1ee904 3530 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3531 span_cal
whismanoid 34:a1993a1ee904 3532 );
whismanoid 34:a1993a1ee904 3533 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 3534 }
whismanoid 34:a1993a1ee904 3535 double slope_correction = span_cal / span_raw;
whismanoid 34:a1993a1ee904 3536 double corrected_normValue_0_1 = cal_05_normValue + ((raw_normValue_0_1 - raw_05_normValue) * slope_correction);
whismanoid 34:a1993a1ee904 3537 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) slope_correction = %1.6f",
whismanoid 34:a1993a1ee904 3538 // ch,
whismanoid 34:a1993a1ee904 3539 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3540 // slope_correction
whismanoid 34:a1993a1ee904 3541 // );
whismanoid 34:a1993a1ee904 3542 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) corrected_normValue_0_1 = %1.6f\r\n",
whismanoid 34:a1993a1ee904 3543 // ch,
whismanoid 34:a1993a1ee904 3544 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3545 // corrected_normValue_0_1
whismanoid 34:a1993a1ee904 3546 // );
whismanoid 34:a1993a1ee904 3547 return corrected_normValue_0_1;
whismanoid 34:a1993a1ee904 3548 }
whismanoid 34:a1993a1ee904 3549 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3550 // Option to customize channel names in datalog header line
whismanoid 45:74bf1fe021e5 3551 // This could be used to identify external hardware attached to each input
whismanoid 13:184a08909405 3552 #ifndef HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 3553 #define HAS_Platform_AIN_customChannelHeader 1
whismanoid 13:184a08909405 3554 #endif
whismanoid 13:184a08909405 3555 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 3556 const char* const Platform_AIN_customChannelHeader_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 3557 "=AIN4", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 3558 "=AIN5", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 3559 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 3560 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 3561 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 3562 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 3563 };
whismanoid 13:184a08909405 3564 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 1:747f1602abfc 3565 //--------------------------------------------------
whismanoid 1:747f1602abfc 3566 // Option to log platform analog inputs as raw LSB code
whismanoid 1:747f1602abfc 3567 #ifndef LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 3568 #define LOG_PLATFORM_ANALOG_IN_LSB 0
whismanoid 1:747f1602abfc 3569 #endif
whismanoid 1:747f1602abfc 3570 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 3571 int Platform_LSB[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 3572 #endif
whismanoid 1:747f1602abfc 3573
whismanoid 1:747f1602abfc 3574 //--------------------------------------------------
whismanoid 1:747f1602abfc 3575 // Option to use platform analog inputs as Voltage
whismanoid 1:747f1602abfc 3576 #ifndef LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 3577 #define LOG_PLATFORM_ANALOG_IN_VOLTS 1
whismanoid 1:747f1602abfc 3578 #endif
whismanoid 1:747f1602abfc 3579 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 3580 double Platform_Voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 3581 #endif
whismanoid 3:9055e17e181a 3582 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 0:cb44e2e9ec4c 3583
whismanoid 10:04022a61b527 3584 //--------------------------------------------------
whismanoid 10:04022a61b527 3585 // Option to use Command forwarding to Auxiliary serial port
whismanoid 10:04022a61b527 3586 // Command forwarding to Auxiliary serial port TX/RX
whismanoid 10:04022a61b527 3587 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial
whismanoid 10:04022a61b527 3588 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial
whismanoid 10:04022a61b527 3589 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3590 #ifndef USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3591 #define USE_AUX_SERIAL_CMD_FORWARDING 1
whismanoid 10:04022a61b527 3592 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3593 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3594 // Command forwarding to Auxiliary serial port TX/RX #257 -- global parameters
whismanoid 49:359a6b9df7c1 3595 const size_t RX_STRING_BUF_SIZE = 5000;
whismanoid 10:04022a61b527 3596 int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 3597 // transmit command string by AUX TX
whismanoid 10:04022a61b527 3598 #if 0
whismanoid 10:04022a61b527 3599 int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 3600 int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 3601 int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 3602 #endif
whismanoid 10:04022a61b527 3603 // capture received string from AUX RX
whismanoid 10:04022a61b527 3604 Timer g_auxSerialCom_Timer;
whismanoid 10:04022a61b527 3605 int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 3606 int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 3607 int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 3608 int g_auxSerialCom_rx_idle_ms = 500; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 3609 int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 3610 const int aux_serial_cmd_forwarding_rx_eot_not_used = 'x';
whismanoid 10:04022a61b527 3611 int g_auxSerialCom_rx_eot = aux_serial_cmd_forwarding_rx_eot_not_used; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 3612 //~ int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text string?
whismanoid 10:04022a61b527 3613 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3614 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3615 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257
whismanoid 10:04022a61b527 3616 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3617 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3618 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3619 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3620 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3621 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3622 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 3623 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3624 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3625 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3626 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3627 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3628 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3629 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3630 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3631
whismanoid 8:dffee7509bfb 3632 // CODE GENERATOR: example code for ADC: serial port declaration
whismanoid 8:dffee7509bfb 3633 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3634 // Declare the Serial driver
whismanoid 8:dffee7509bfb 3635 // default baud rate settings are 9600 8N1
whismanoid 8:dffee7509bfb 3636 // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
whismanoid 8:dffee7509bfb 3637 // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
whismanoid 8:dffee7509bfb 3638 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3639 #if defined(TARGET_MAX32630)
whismanoid 8:dffee7509bfb 3640 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 3641 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3642 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3643 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 3644 //
whismanoid 8:dffee7509bfb 3645 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3646 Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3647 //Serial J3AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 3648 //Serial BTAUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 3649 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3650 //
whismanoid 8:dffee7509bfb 3651 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3652 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3653 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3654 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3655 //
whismanoid 8:dffee7509bfb 3656 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3657 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3658 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3659 USBSerial serial;
whismanoid 8:dffee7509bfb 3660 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3661 #elif defined(TARGET_MAX32625MBED)
whismanoid 8:dffee7509bfb 3662 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625MBED: P0_1,P0_0 (Arduino D1,D0)
whismanoid 8:dffee7509bfb 3663 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3664 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625MBED: P3_1,P3_0 (J15-LEDgreen,LEDred)
whismanoid 8:dffee7509bfb 3665 //
whismanoid 8:dffee7509bfb 3666 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3667 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3668 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3669 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3670 //
whismanoid 8:dffee7509bfb 3671 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3672 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3673 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3674 USBSerial serial;
whismanoid 8:dffee7509bfb 3675 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 3676 #elif defined(TARGET_MAX32625PICO)
whismanoid 8:dffee7509bfb 3677 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 3678 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625PICO: P2_1,P2_0 (underside?)
whismanoid 8:dffee7509bfb 3679 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3680 //
whismanoid 8:dffee7509bfb 3681 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3682 Serial AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 3683 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3684 //
whismanoid 8:dffee7509bfb 3685 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3686 Serial DAPLINKserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3687 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3688 //
whismanoid 8:dffee7509bfb 3689 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3690 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3691 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3692 USBSerial serial;
whismanoid 22:d6dc8a85f435 3693 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 3694 #elif defined(TARGET_MAX40108DEMOP2U9)
whismanoid 22:d6dc8a85f435 3695 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 3696 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK)
whismanoid 22:d6dc8a85f435 3697 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 3698 //
whismanoid 22:d6dc8a85f435 3699 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial is used as main serial port in MAX40108 Demo board
whismanoid 22:d6dc8a85f435 3700 Serial serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 3701 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 3702 //
whismanoid 22:d6dc8a85f435 3703 // Hardware serial port over DAPLink
whismanoid 22:d6dc8a85f435 3704 // connection to external MAX32625PICO(DAPLINK) needed TX/RX swap in firmware.
whismanoid 22:d6dc8a85f435 3705 // MAX32625PICO(DAPLINK) drives DAPLINK.8, listens on DAPLINK.6.
whismanoid 22:d6dc8a85f435 3706 // See AN6350 MAX32625 Users Guide 7.5.2.3.1 TX and RX Pin Mapping for UART 1 -- Mapping Option B
whismanoid 39:4d285e961435 3707 #ifdef BOARD_SERIAL_NUMBER
whismanoid 39:4d285e961435 3708 // data unique to certain boards based on serial number
whismanoid 39:4d285e961435 3709 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 39:4d285e961435 3710 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 39:4d285e961435 3711 // s/n 0 is not really a MAX40108 board, it's actually a MAX32625PICO used for early development. So no swap.
whismanoid 39:4d285e961435 3712 Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 39:4d285e961435 3713 //Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 39:4d285e961435 3714 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3715 //
whismanoid 39:4d285e961435 3716 // # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 39:4d285e961435 3717 // #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 39:4d285e961435 3718 // //
whismanoid 39:4d285e961435 3719 // # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 39:4d285e961435 3720 // #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 39:4d285e961435 3721 // //
whismanoid 39:4d285e961435 3722 // # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 39:4d285e961435 3723 // #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 39:4d285e961435 3724 // //
whismanoid 39:4d285e961435 3725 // # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 39:4d285e961435 3726 // #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 39:4d285e961435 3727 // //
whismanoid 39:4d285e961435 3728 // # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 39:4d285e961435 3729 // #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 39:4d285e961435 3730 // //
whismanoid 39:4d285e961435 3731 // # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 39:4d285e961435 3732 // #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 39:4d285e961435 3733 // //
whismanoid 39:4d285e961435 3734 # else
whismanoid 39:4d285e961435 3735 // #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 22:d6dc8a85f435 3736 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 22:d6dc8a85f435 3737 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 22:d6dc8a85f435 3738 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3739 # endif
whismanoid 39:4d285e961435 3740 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 39:4d285e961435 3741 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 39:4d285e961435 3742 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 39:4d285e961435 3743 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 39:4d285e961435 3744 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3745 //
whismanoid 39:4d285e961435 3746 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 22:d6dc8a85f435 3747 //
whismanoid 22:d6dc8a85f435 3748 // Serial AUXserial(UART1_TX,UART1_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 3749 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 3750 //
whismanoid 22:d6dc8a85f435 3751 // Virtual serial port over USB
whismanoid 22:d6dc8a85f435 3752 // #include "USBSerial.h"
whismanoid 22:d6dc8a85f435 3753 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 22:d6dc8a85f435 3754 //USBSerial serial;
whismanoid 8:dffee7509bfb 3755 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3756 #elif defined(TARGET_MAX32620FTHR)
whismanoid 8:dffee7509bfb 3757 #warning "TARGET_MAX32620FTHR not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3758 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3759 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32620FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3760 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3761 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3762 //
whismanoid 8:dffee7509bfb 3763 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3764 Serial serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3765 //Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3766 Serial AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3767 //Serial PMOD0AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3768 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3769 //
whismanoid 8:dffee7509bfb 3770 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3771 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3772 Serial DAPLINKserial(USBTX, USBRX); // tx,rx MAX32620FTHR: P2_1,P2_0
whismanoid 8:dffee7509bfb 3773 //Serial DAPLINKserial(STDIO_UART_TX, STDIO_UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3774 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3775 //
whismanoid 8:dffee7509bfb 3776 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3777 // #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3778 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3779 //USBSerial serial; // MAX32620FTHR: USBSerial crash??
whismanoid 8:dffee7509bfb 3780 #warning "TARGET_MAX32620FTHR not previously tested; USBSerial crash?"
whismanoid 8:dffee7509bfb 3781 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3782 #elif defined(TARGET_MAX32600)
whismanoid 8:dffee7509bfb 3783 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3784 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART2 MAX32625MBED: P1_3,P1_2 (Arduino D3,D2)
whismanoid 8:dffee7509bfb 3785 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART1 MAX32625MBED: P7_3,P7_2 ( ?? )
whismanoid 8:dffee7509bfb 3786 //
whismanoid 8:dffee7509bfb 3787 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3788 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3789 Serial DAPLINKserial(P1_1,P1_0); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3790 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3791 //
whismanoid 8:dffee7509bfb 3792 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3793 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3794 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3795 USBSerial serial;
whismanoid 8:dffee7509bfb 3796 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3797 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 8:dffee7509bfb 3798 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3799 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3800 #else
whismanoid 8:dffee7509bfb 3801 #if defined(SERIAL_TX)
whismanoid 8:dffee7509bfb 3802 #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..."
whismanoid 8:dffee7509bfb 3803 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3804 #elif defined(USBTX)
whismanoid 8:dffee7509bfb 3805 #warning "target not previously tested; guess serial pins are USBTX, USBRX..."
whismanoid 8:dffee7509bfb 3806 Serial serial(USBTX, USBRX); // tx, rx
whismanoid 8:dffee7509bfb 3807 #elif defined(UART_TX)
whismanoid 8:dffee7509bfb 3808 #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..."
whismanoid 8:dffee7509bfb 3809 Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3810 #else
whismanoid 8:dffee7509bfb 3811 #warning "target not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3812 #endif
whismanoid 8:dffee7509bfb 3813 #endif
whismanoid 8:dffee7509bfb 3814 //
whismanoid 8:dffee7509bfb 3815 #include "CmdLine.h"
whismanoid 8:dffee7509bfb 3816
whismanoid 8:dffee7509bfb 3817 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3818 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3819 CmdLine cmdLine_AUXserial(AUXserial, "AUXserial");
whismanoid 10:04022a61b527 3820 uint8_t Datalogger_enable_AUXserial = {
whismanoid 10:04022a61b527 3821 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3822 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 3823 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 3824 false
whismanoid 10:04022a61b527 3825 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3826 true
whismanoid 10:04022a61b527 3827 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3828 };
whismanoid 8:dffee7509bfb 3829 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3830 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3831 CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK");
whismanoid 8:dffee7509bfb 3832 uint8_t Datalogger_enable_DAPLINKserial = true;
whismanoid 8:dffee7509bfb 3833 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3834 CmdLine cmdLine(serial, "serial");
whismanoid 8:dffee7509bfb 3835 uint8_t Datalogger_enable_serial = true;
whismanoid 8:dffee7509bfb 3836 // CODE GENERATOR: example code for ADC: serial port declaration (end)
whismanoid 8:dffee7509bfb 3837
whismanoid 21:ac062a97a71d 3838
whismanoid 21:ac062a97a71d 3839 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3840 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3841 // support for commands %B1! .. %B9!
whismanoid 23:c6c652bef4b9 3842 #ifndef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3843 #define USE_DATALOGGER_CommandTable 1
whismanoid 23:c6c652bef4b9 3844 //~ #undef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3845 #endif
whismanoid 23:c6c652bef4b9 3846 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3847 const int COMMAND_TABLE_ROW_MAX = 10;
whismanoid 23:c6c652bef4b9 3848 const int COMMAND_TABLE_COL_MAX = 40;
whismanoid 23:c6c652bef4b9 3849 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3850 //
whismanoid 23:c6c652bef4b9 3851 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3852 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3853 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3854 // onButton1_command_table[] supports command %B1! -- run, %B1@ -- edit
whismanoid 45:74bf1fe021e5 3855 // MAX40108p2 hardware pin P2_7 button SW1 active low
whismanoid 45:74bf1fe021e5 3856 //........................................................12345678901234567890
whismanoid 45:74bf1fe021e5 3857 char onButton1_command_table_00[COMMAND_TABLE_COL_MAX] = "# SW1 event";
whismanoid 45:74bf1fe021e5 3858 char onButton1_command_table_01[COMMAND_TABLE_COL_MAX] = ">>SW1=LP1 deep sleep 10 sec";
whismanoid 45:74bf1fe021e5 3859 char onButton1_command_table_02[COMMAND_TABLE_COL_MAX] = "%H91"; // LED off
whismanoid 45:74bf1fe021e5 3860 char onButton1_command_table_03[COMMAND_TABLE_COL_MAX] = "%H92"; // LED off
whismanoid 45:74bf1fe021e5 3861 char onButton1_command_table_04[COMMAND_TABLE_COL_MAX] = "%H93"; // LED off
whismanoid 45:74bf1fe021e5 3862 char onButton1_command_table_05[COMMAND_TABLE_COL_MAX] = "%H9"; // diagnostic pulse D9
whismanoid 45:74bf1fe021e5 3863 char onButton1_command_table_06[COMMAND_TABLE_COL_MAX] = "LT count=10 base=1000 sleep=1";
whismanoid 45:74bf1fe021e5 3864 char onButton1_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3865 char onButton1_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3866 char onButton1_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3867 static char* onButton1_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3868 onButton1_command_table_00,
whismanoid 23:c6c652bef4b9 3869 onButton1_command_table_01,
whismanoid 23:c6c652bef4b9 3870 onButton1_command_table_02,
whismanoid 23:c6c652bef4b9 3871 onButton1_command_table_03,
whismanoid 23:c6c652bef4b9 3872 onButton1_command_table_04,
whismanoid 23:c6c652bef4b9 3873 onButton1_command_table_05,
whismanoid 23:c6c652bef4b9 3874 onButton1_command_table_06,
whismanoid 23:c6c652bef4b9 3875 onButton1_command_table_07,
whismanoid 23:c6c652bef4b9 3876 onButton1_command_table_08,
whismanoid 23:c6c652bef4b9 3877 onButton1_command_table_09,
whismanoid 23:c6c652bef4b9 3878 };
whismanoid 23:c6c652bef4b9 3879 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3880 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3881 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3882 // onButton2_command_table[] supports command %B2! -- run, %B2@ -- edit
whismanoid 45:74bf1fe021e5 3883 // MAX40108p2 hardware pin P1_7 connector J91.3 active low
whismanoid 45:74bf1fe021e5 3884 //........................................................12345678901234567890
whismanoid 45:74bf1fe021e5 3885 char onButton2_command_table_00[COMMAND_TABLE_COL_MAX] = "# J91.3=Halt"; // remark
whismanoid 45:74bf1fe021e5 3886 char onButton2_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91"; // LED on
whismanoid 45:74bf1fe021e5 3887 char onButton2_command_table_02[COMMAND_TABLE_COL_MAX] = "L"; // halts data logging
whismanoid 45:74bf1fe021e5 3888 char onButton2_command_table_03[COMMAND_TABLE_COL_MAX] = "%H92"; // LED off
whismanoid 45:74bf1fe021e5 3889 char onButton2_command_table_04[COMMAND_TABLE_COL_MAX] = "%L93"; // LED on
whismanoid 45:74bf1fe021e5 3890 char onButton2_command_table_05[COMMAND_TABLE_COL_MAX] = ">>J91.2=Halt"; // to DAPLINK comms
whismanoid 23:c6c652bef4b9 3891 char onButton2_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3892 char onButton2_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3893 char onButton2_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3894 char onButton2_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3895 static char* onButton2_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3896 onButton2_command_table_00,
whismanoid 23:c6c652bef4b9 3897 onButton2_command_table_01,
whismanoid 23:c6c652bef4b9 3898 onButton2_command_table_02,
whismanoid 23:c6c652bef4b9 3899 onButton2_command_table_03,
whismanoid 23:c6c652bef4b9 3900 onButton2_command_table_04,
whismanoid 23:c6c652bef4b9 3901 onButton2_command_table_05,
whismanoid 23:c6c652bef4b9 3902 onButton2_command_table_06,
whismanoid 23:c6c652bef4b9 3903 onButton2_command_table_07,
whismanoid 23:c6c652bef4b9 3904 onButton2_command_table_08,
whismanoid 23:c6c652bef4b9 3905 onButton2_command_table_09,
whismanoid 23:c6c652bef4b9 3906 };
whismanoid 23:c6c652bef4b9 3907 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3908 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3909 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3910 // onButton3_command_table[] supports command %B3! -- run, %B3@ -- edit
whismanoid 45:74bf1fe021e5 3911 // MAX40108p2 hardware pin P1_6 connector J91.2 active low
whismanoid 45:74bf1fe021e5 3912 //........................................................12345678901234567890
whismanoid 45:74bf1fe021e5 3913 char onButton3_command_table_00[COMMAND_TABLE_COL_MAX] = "# J91.2 event";
whismanoid 45:74bf1fe021e5 3914 char onButton3_command_table_01[COMMAND_TABLE_COL_MAX] = ">>J91.2 event";
whismanoid 45:74bf1fe021e5 3915 char onButton3_command_table_02[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 45:74bf1fe021e5 3916 char onButton3_command_table_03[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 45:74bf1fe021e5 3917 char onButton3_command_table_04[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 45:74bf1fe021e5 3918 char onButton3_command_table_05[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 45:74bf1fe021e5 3919 char onButton3_command_table_06[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 45:74bf1fe021e5 3920 char onButton3_command_table_07[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 45:74bf1fe021e5 3921 char onButton3_command_table_08[COMMAND_TABLE_COL_MAX] = ">>LR -- run full speed";
whismanoid 45:74bf1fe021e5 3922 char onButton3_command_table_09[COMMAND_TABLE_COL_MAX] = "LR";
whismanoid 24:032f3683cb2a 3923 static char* onButton3_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 24:032f3683cb2a 3924 onButton3_command_table_00,
whismanoid 24:032f3683cb2a 3925 onButton3_command_table_01,
whismanoid 24:032f3683cb2a 3926 onButton3_command_table_02,
whismanoid 24:032f3683cb2a 3927 onButton3_command_table_03,
whismanoid 24:032f3683cb2a 3928 onButton3_command_table_04,
whismanoid 24:032f3683cb2a 3929 onButton3_command_table_05,
whismanoid 24:032f3683cb2a 3930 onButton3_command_table_06,
whismanoid 24:032f3683cb2a 3931 onButton3_command_table_07,
whismanoid 24:032f3683cb2a 3932 onButton3_command_table_08,
whismanoid 24:032f3683cb2a 3933 onButton3_command_table_09,
whismanoid 24:032f3683cb2a 3934 };
whismanoid 24:032f3683cb2a 3935 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3936 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3937 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3938 // onButton4_command_table[] supports command %B4! -- run, %B4@ -- edit
whismanoid 45:74bf1fe021e5 3939 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3940 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3941 char onButton4_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button4 event";
whismanoid 30:07197a430869 3942 char onButton4_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE>0.7:active";
whismanoid 29:6a9edb6e973b 3943 char onButton4_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3944 char onButton4_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3945 char onButton4_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3946 char onButton4_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3947 char onButton4_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3948 char onButton4_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3949 char onButton4_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3950 char onButton4_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3951 static char* onButton4_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3952 onButton4_command_table_00,
whismanoid 29:6a9edb6e973b 3953 onButton4_command_table_01,
whismanoid 29:6a9edb6e973b 3954 onButton4_command_table_02,
whismanoid 29:6a9edb6e973b 3955 onButton4_command_table_03,
whismanoid 29:6a9edb6e973b 3956 onButton4_command_table_04,
whismanoid 29:6a9edb6e973b 3957 onButton4_command_table_05,
whismanoid 29:6a9edb6e973b 3958 onButton4_command_table_06,
whismanoid 29:6a9edb6e973b 3959 onButton4_command_table_07,
whismanoid 29:6a9edb6e973b 3960 onButton4_command_table_08,
whismanoid 29:6a9edb6e973b 3961 onButton4_command_table_09,
whismanoid 29:6a9edb6e973b 3962 };
whismanoid 29:6a9edb6e973b 3963 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3964 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3965 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3966 // onButton5_command_table[] supports command %B5! -- run, %B5@ -- edit
whismanoid 45:74bf1fe021e5 3967 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3968 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3969 char onButton5_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button5 event";
whismanoid 30:07197a430869 3970 char onButton5_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE<0.6:sleep";
whismanoid 29:6a9edb6e973b 3971 char onButton5_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3972 char onButton5_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3973 char onButton5_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3974 char onButton5_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3975 char onButton5_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3976 char onButton5_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3977 char onButton5_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3978 char onButton5_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3979 static char* onButton5_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3980 onButton5_command_table_00,
whismanoid 29:6a9edb6e973b 3981 onButton5_command_table_01,
whismanoid 29:6a9edb6e973b 3982 onButton5_command_table_02,
whismanoid 29:6a9edb6e973b 3983 onButton5_command_table_03,
whismanoid 29:6a9edb6e973b 3984 onButton5_command_table_04,
whismanoid 29:6a9edb6e973b 3985 onButton5_command_table_05,
whismanoid 29:6a9edb6e973b 3986 onButton5_command_table_06,
whismanoid 29:6a9edb6e973b 3987 onButton5_command_table_07,
whismanoid 29:6a9edb6e973b 3988 onButton5_command_table_08,
whismanoid 29:6a9edb6e973b 3989 onButton5_command_table_09,
whismanoid 29:6a9edb6e973b 3990 };
whismanoid 29:6a9edb6e973b 3991 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3992 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3993 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3994 // onButton6_command_table[] supports command %B6! -- run, %B6@ -- edit
whismanoid 45:74bf1fe021e5 3995 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3996 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3997 char onButton6_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button6 event";
whismanoid 29:6a9edb6e973b 3998 char onButton6_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3999 char onButton6_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4000 char onButton6_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4001 char onButton6_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4002 char onButton6_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4003 char onButton6_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4004 char onButton6_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4005 char onButton6_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4006 char onButton6_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4007 static char* onButton6_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 4008 onButton6_command_table_00,
whismanoid 29:6a9edb6e973b 4009 onButton6_command_table_01,
whismanoid 29:6a9edb6e973b 4010 onButton6_command_table_02,
whismanoid 29:6a9edb6e973b 4011 onButton6_command_table_03,
whismanoid 29:6a9edb6e973b 4012 onButton6_command_table_04,
whismanoid 29:6a9edb6e973b 4013 onButton6_command_table_05,
whismanoid 29:6a9edb6e973b 4014 onButton6_command_table_06,
whismanoid 29:6a9edb6e973b 4015 onButton6_command_table_07,
whismanoid 29:6a9edb6e973b 4016 onButton6_command_table_08,
whismanoid 29:6a9edb6e973b 4017 onButton6_command_table_09,
whismanoid 29:6a9edb6e973b 4018 };
whismanoid 29:6a9edb6e973b 4019 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4020 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4021 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 4022 // onButton7_command_table[] supports command %B7! -- run, %B7@ -- edit
whismanoid 45:74bf1fe021e5 4023 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 4024 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 4025 char onButton7_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button7 event";
whismanoid 29:6a9edb6e973b 4026 char onButton7_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4027 char onButton7_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4028 char onButton7_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4029 char onButton7_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4030 char onButton7_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4031 char onButton7_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4032 char onButton7_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4033 char onButton7_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4034 char onButton7_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4035 static char* onButton7_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 4036 onButton7_command_table_00,
whismanoid 29:6a9edb6e973b 4037 onButton7_command_table_01,
whismanoid 29:6a9edb6e973b 4038 onButton7_command_table_02,
whismanoid 29:6a9edb6e973b 4039 onButton7_command_table_03,
whismanoid 29:6a9edb6e973b 4040 onButton7_command_table_04,
whismanoid 29:6a9edb6e973b 4041 onButton7_command_table_05,
whismanoid 29:6a9edb6e973b 4042 onButton7_command_table_06,
whismanoid 29:6a9edb6e973b 4043 onButton7_command_table_07,
whismanoid 29:6a9edb6e973b 4044 onButton7_command_table_08,
whismanoid 29:6a9edb6e973b 4045 onButton7_command_table_09,
whismanoid 29:6a9edb6e973b 4046 };
whismanoid 29:6a9edb6e973b 4047 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4048 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4049 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 4050 // onButton8_command_table[] supports command %B8! -- run, %B8@ -- edit
whismanoid 45:74bf1fe021e5 4051 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 4052 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 4053 char onButton8_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button8 event";
whismanoid 29:6a9edb6e973b 4054 char onButton8_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4055 char onButton8_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4056 char onButton8_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4057 char onButton8_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4058 char onButton8_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4059 char onButton8_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4060 char onButton8_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4061 char onButton8_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4062 char onButton8_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4063 static char* onButton8_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 4064 onButton8_command_table_00,
whismanoid 29:6a9edb6e973b 4065 onButton8_command_table_01,
whismanoid 29:6a9edb6e973b 4066 onButton8_command_table_02,
whismanoid 29:6a9edb6e973b 4067 onButton8_command_table_03,
whismanoid 29:6a9edb6e973b 4068 onButton8_command_table_04,
whismanoid 29:6a9edb6e973b 4069 onButton8_command_table_05,
whismanoid 29:6a9edb6e973b 4070 onButton8_command_table_06,
whismanoid 29:6a9edb6e973b 4071 onButton8_command_table_07,
whismanoid 29:6a9edb6e973b 4072 onButton8_command_table_08,
whismanoid 29:6a9edb6e973b 4073 onButton8_command_table_09,
whismanoid 29:6a9edb6e973b 4074 };
whismanoid 29:6a9edb6e973b 4075 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4076 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4077 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 4078 // onButton9_command_table[] supports command %B9! -- run, %B9@ -- edit
whismanoid 45:74bf1fe021e5 4079 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 4080 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 4081 char onButton9_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button9 event";
whismanoid 29:6a9edb6e973b 4082 char onButton9_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4083 char onButton9_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4084 char onButton9_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4085 char onButton9_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4086 char onButton9_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4087 char onButton9_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4088 char onButton9_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4089 char onButton9_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4090 char onButton9_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 4091 static char* onButton9_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 4092 onButton9_command_table_00,
whismanoid 29:6a9edb6e973b 4093 onButton9_command_table_01,
whismanoid 29:6a9edb6e973b 4094 onButton9_command_table_02,
whismanoid 29:6a9edb6e973b 4095 onButton9_command_table_03,
whismanoid 29:6a9edb6e973b 4096 onButton9_command_table_04,
whismanoid 29:6a9edb6e973b 4097 onButton9_command_table_05,
whismanoid 29:6a9edb6e973b 4098 onButton9_command_table_06,
whismanoid 29:6a9edb6e973b 4099 onButton9_command_table_07,
whismanoid 29:6a9edb6e973b 4100 onButton9_command_table_08,
whismanoid 29:6a9edb6e973b 4101 onButton9_command_table_09,
whismanoid 29:6a9edb6e973b 4102 };
whismanoid 29:6a9edb6e973b 4103 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 4104 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4105 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 4106 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 4107 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 4108 bool g_Run_command_table_running = false;
whismanoid 23:c6c652bef4b9 4109 void Run_command_table(char* command_table[])
whismanoid 23:c6c652bef4b9 4110 {
whismanoid 23:c6c652bef4b9 4111 // command_table: perform list of commands
whismanoid 31:47eee7e0cc2d 4112 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 4113 if (g_Run_command_table_running) {
whismanoid 31:47eee7e0cc2d 4114 // TODO: button event chaining is not supported at this time
whismanoid 31:47eee7e0cc2d 4115 } // if (g_Run_command_table_running)
whismanoid 31:47eee7e0cc2d 4116 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 4117 g_Run_command_table_running = true;
whismanoid 23:c6c652bef4b9 4118 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 4119 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 4120 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 23:c6c652bef4b9 4121 cmdLine.clear();
whismanoid 31:47eee7e0cc2d 4122 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 4123 //~ char* strIndex = command_table[lineIndex];
whismanoid 23:c6c652bef4b9 4124 for (char* strIndex = command_table[lineIndex]; *strIndex != '\0'; strIndex++)
whismanoid 23:c6c652bef4b9 4125 {
whismanoid 23:c6c652bef4b9 4126 cmdLine.append(*strIndex);
whismanoid 23:c6c652bef4b9 4127 }
whismanoid 23:c6c652bef4b9 4128 cmdLine.append('\r'); // append \r invokes onEOLcommandParser to handle command
whismanoid 23:c6c652bef4b9 4129 }
whismanoid 31:47eee7e0cc2d 4130 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 4131 g_Run_command_table_running = false;
whismanoid 31:47eee7e0cc2d 4132 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 4133 }
whismanoid 23:c6c652bef4b9 4134 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4135 //--------------------------------------------------
whismanoid 21:ac062a97a71d 4136 // When user presses button BUTTON1, perform actions
whismanoid 21:ac062a97a71d 4137 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 4138 void onButton1FallingEdge(void)
whismanoid 21:ac062a97a71d 4139 {
whismanoid 21:ac062a97a71d 4140 //~ void SelfTest(CmdLine & cmdLine);
whismanoid 21:ac062a97a71d 4141 //~ SelfTest(cmdLine_serial);
whismanoid 22:d6dc8a85f435 4142 //
whismanoid 23:c6c652bef4b9 4143 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 4144 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 4145 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 4146 Run_command_table(onButton1_command_table);
whismanoid 23:c6c652bef4b9 4147 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 4148 }
whismanoid 21:ac062a97a71d 4149 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 4150
whismanoid 21:ac062a97a71d 4151 //--------------------------------------------------
whismanoid 21:ac062a97a71d 4152 // When user presses button BUTTON2, perform actions
whismanoid 21:ac062a97a71d 4153 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 4154 void onButton2FallingEdge(void)
whismanoid 21:ac062a97a71d 4155 {
whismanoid 21:ac062a97a71d 4156 // TBD demo configuration
whismanoid 21:ac062a97a71d 4157 // TODO diagnostic LED
whismanoid 21:ac062a97a71d 4158 // led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 22:d6dc8a85f435 4159 //
whismanoid 23:c6c652bef4b9 4160 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 4161 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 4162 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 4163 Run_command_table(onButton2_command_table);
whismanoid 23:c6c652bef4b9 4164 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 4165 }
whismanoid 21:ac062a97a71d 4166 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 4167
whismanoid 24:032f3683cb2a 4168 //--------------------------------------------------
whismanoid 29:6a9edb6e973b 4169 // When user presses button BUTTON3, perform actions
whismanoid 24:032f3683cb2a 4170 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4171 void onButton3FallingEdge(void)
whismanoid 24:032f3683cb2a 4172 {
whismanoid 24:032f3683cb2a 4173 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 24:032f3683cb2a 4174 // command_table: list of commands to perform on button press
whismanoid 24:032f3683cb2a 4175 // command_table: perform list of commands
whismanoid 24:032f3683cb2a 4176 Run_command_table(onButton3_command_table);
whismanoid 24:032f3683cb2a 4177 #endif // USE_DATALOGGER_CommandTable
whismanoid 24:032f3683cb2a 4178 }
whismanoid 24:032f3683cb2a 4179 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4180 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4181 void onButton4FallingEdge(void)
whismanoid 29:6a9edb6e973b 4182 {
whismanoid 29:6a9edb6e973b 4183 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4184 Run_command_table(onButton4_command_table);
whismanoid 29:6a9edb6e973b 4185 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4186 }
whismanoid 29:6a9edb6e973b 4187 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4188 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4189 void onButton5FallingEdge(void)
whismanoid 29:6a9edb6e973b 4190 {
whismanoid 29:6a9edb6e973b 4191 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4192 Run_command_table(onButton5_command_table);
whismanoid 29:6a9edb6e973b 4193 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4194 }
whismanoid 29:6a9edb6e973b 4195 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4196 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4197 void onButton6FallingEdge(void)
whismanoid 29:6a9edb6e973b 4198 {
whismanoid 29:6a9edb6e973b 4199 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4200 Run_command_table(onButton6_command_table);
whismanoid 29:6a9edb6e973b 4201 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4202 }
whismanoid 29:6a9edb6e973b 4203 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4204 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4205 void onButton7FallingEdge(void)
whismanoid 29:6a9edb6e973b 4206 {
whismanoid 29:6a9edb6e973b 4207 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4208 Run_command_table(onButton7_command_table);
whismanoid 29:6a9edb6e973b 4209 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4210 }
whismanoid 29:6a9edb6e973b 4211 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4212 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4213 void onButton8FallingEdge(void)
whismanoid 29:6a9edb6e973b 4214 {
whismanoid 29:6a9edb6e973b 4215 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4216 Run_command_table(onButton8_command_table);
whismanoid 29:6a9edb6e973b 4217 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4218 }
whismanoid 29:6a9edb6e973b 4219 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4220 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4221 void onButton9FallingEdge(void)
whismanoid 29:6a9edb6e973b 4222 {
whismanoid 29:6a9edb6e973b 4223 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4224 Run_command_table(onButton9_command_table);
whismanoid 29:6a9edb6e973b 4225 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4226 }
whismanoid 29:6a9edb6e973b 4227 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4228
whismanoid 4:d9b05924ad4c 4229 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 4230 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 4231 inline void print_command_prompt()
whismanoid 4:d9b05924ad4c 4232 {
whismanoid 4:d9b05924ad4c 4233 //~ Serial.println(F(">"));
whismanoid 4:d9b05924ad4c 4234 cmdLine.serial().printf("\r\n> ");
whismanoid 4:d9b05924ad4c 4235 }
whismanoid 4:d9b05924ad4c 4236 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 4237
whismanoid 4:d9b05924ad4c 4238 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 4239 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 4240 void main_menu_status(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 4241 {
whismanoid 4:d9b05924ad4c 4242 cmdLine.serial().printf("\r\nMain menu");
whismanoid 4:d9b05924ad4c 4243 #if APPLICATION_MAX5715 // main_menu_status banner
whismanoid 4:d9b05924ad4c 4244 cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC");
whismanoid 4:d9b05924ad4c 4245 #elif APPLICATION_MAX11131 // main_menu_status banner
whismanoid 4:d9b05924ad4c 4246 cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC");
whismanoid 4:d9b05924ad4c 4247 #elif APPLICATION_MAX5171 // main_menu_status banner
whismanoid 4:d9b05924ad4c 4248 cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC");
whismanoid 4:d9b05924ad4c 4249 #elif APPLICATION_MAX11410 // main_menu_status banner
whismanoid 4:d9b05924ad4c 4250 cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC");
whismanoid 4:d9b05924ad4c 4251 #elif APPLICATION_MAX12345 // main_menu_status banner
whismanoid 4:d9b05924ad4c 4252 cmdLine.serial().printf(" MAX12345");
whismanoid 16:819c5aaf5271 4253 #elif MAX40108_DEMO // main_menu_status banner
whismanoid 17:9397ea3ea7e9 4254 cmdLine.serial().printf(" MAX40108_U%d", MAX40108_DEMO);
whismanoid 36:e7aac874b8be 4255 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 4256 // data unique to certain boards based on serial number
whismanoid 49:359a6b9df7c1 4257 cmdLine.serial().printf(" [s/n %ld]", g_board_serial_number);
whismanoid 36:e7aac874b8be 4258 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 4259 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 4260 //
whismanoid 36:e7aac874b8be 4261 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 4262 #ifdef FW_REV
whismanoid 37:3f369235e5bc 4263 cmdLine.serial().printf(" [FW_REV %d]", FW_REV);
whismanoid 37:3f369235e5bc 4264 #endif // FW_REV
whismanoid 4:d9b05924ad4c 4265 #else
whismanoid 4:d9b05924ad4c 4266 //cmdLine.serial().printf(" ");
whismanoid 4:d9b05924ad4c 4267 #endif
whismanoid 4:d9b05924ad4c 4268 //cmdLine.serial().printf(" %s", TARGET_NAME);
whismanoid 4:d9b05924ad4c 4269 if (cmdLine.nameStr())
whismanoid 4:d9b05924ad4c 4270 {
whismanoid 4:d9b05924ad4c 4271 cmdLine.serial().printf(" [%s]", cmdLine.nameStr());
whismanoid 4:d9b05924ad4c 4272 }
whismanoid 4:d9b05924ad4c 4273 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4274 cmdLine.serial().printf(" [Button1");
whismanoid 4:d9b05924ad4c 4275 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4276 cmdLine.serial().printf("2");
whismanoid 24:032f3683cb2a 4277 #endif
whismanoid 24:032f3683cb2a 4278 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4279 cmdLine.serial().printf("3");
whismanoid 29:6a9edb6e973b 4280 #endif
whismanoid 29:6a9edb6e973b 4281 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4282 cmdLine.serial().printf("4");
whismanoid 29:6a9edb6e973b 4283 #endif
whismanoid 29:6a9edb6e973b 4284 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4285 cmdLine.serial().printf("5");
whismanoid 29:6a9edb6e973b 4286 #endif
whismanoid 29:6a9edb6e973b 4287 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4288 cmdLine.serial().printf("6");
whismanoid 29:6a9edb6e973b 4289 #endif
whismanoid 29:6a9edb6e973b 4290 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4291 cmdLine.serial().printf("7");
whismanoid 29:6a9edb6e973b 4292 #endif
whismanoid 29:6a9edb6e973b 4293 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4294 cmdLine.serial().printf("8");
whismanoid 29:6a9edb6e973b 4295 #endif
whismanoid 29:6a9edb6e973b 4296 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4297 cmdLine.serial().printf("9");
whismanoid 29:6a9edb6e973b 4298 #endif
whismanoid 29:6a9edb6e973b 4299 cmdLine.serial().printf("]");
whismanoid 29:6a9edb6e973b 4300 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 4:d9b05924ad4c 4301 #if HAS_BUTTON1_DEMO
whismanoid 4:d9b05924ad4c 4302 // print BUTTON1 status
whismanoid 4:d9b05924ad4c 4303 cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read());
whismanoid 4:d9b05924ad4c 4304 #endif
whismanoid 4:d9b05924ad4c 4305 #if HAS_BUTTON2_DEMO
whismanoid 24:032f3683cb2a 4306 // print BUTTON2 status
whismanoid 4:d9b05924ad4c 4307 cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read());
whismanoid 4:d9b05924ad4c 4308 #endif
whismanoid 24:032f3683cb2a 4309 #if HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 4310 // print BUTTON3 status
whismanoid 24:032f3683cb2a 4311 cmdLine.serial().printf("\r\n BUTTON3 = %d", button3.read());
whismanoid 24:032f3683cb2a 4312 #endif
whismanoid 4:d9b05924ad4c 4313 cmdLine.serial().printf("\r\n ? -- help");
whismanoid 4:d9b05924ad4c 4314 }
whismanoid 4:d9b05924ad4c 4315 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 4316
whismanoid 28:a9a3a9db592b 4317 //--------------------------------------------------
whismanoid 28:a9a3a9db592b 4318 #ifndef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 4319 #define USE_DATALOGGER_TRIGGER_HELP_BRIEF 1
whismanoid 28:a9a3a9db592b 4320 //~ #undef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 4321 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 4322
whismanoid 4:d9b05924ad4c 4323 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 4324 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 4325 void main_menu_help(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 4326 {
whismanoid 4:d9b05924ad4c 4327 // ? -- help
whismanoid 4:d9b05924ad4c 4328 //~ cmdLine.serial().printf("\r\nMenu:");
whismanoid 10:04022a61b527 4329 //
whismanoid 4:d9b05924ad4c 4330 cmdLine.serial().printf("\r\n # -- lines beginning with # are comments");
whismanoid 10:04022a61b527 4331 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 4332 cmdLine.serial().printf("\r\n ! -- Init");
whismanoid 10:04022a61b527 4333 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 4334 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 4335 cmdLine.serial().printf("\r\n . -- SelfTest");
whismanoid 4:d9b05924ad4c 4336 #endif // USE_SELFTEST
whismanoid 9:45f98573eb6d 4337 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 9:45f98573eb6d 4338 // CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register
whismanoid 9:45f98573eb6d 4339 cmdLine.serial().printf("\r\n * -- read core registers\r\n *regname? -- read register\r\n *regname=regvalue -- write register");
whismanoid 9:45f98573eb6d 4340 // cmdLine.serial().printf("\r\n 01 23 45 67 89 ab cd ef -- write and read raw hex codes");
whismanoid 10:04022a61b527 4341 #endif // USE_STAR_REG_READWRITE
whismanoid 10:04022a61b527 4342 //
whismanoid 10:04022a61b527 4343 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 4344 // Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_help
whismanoid 10:04022a61b527 4345 //~ cmdLine.serial().printf("\r\n > -- auxiliary UART port");
whismanoid 10:04022a61b527 4346 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 4347 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 4348 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 4349 if (cmdLine_AUXserial.nameStr())
whismanoid 10:04022a61b527 4350 {
whismanoid 10:04022a61b527 4351 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_AUXserial.nameStr());
whismanoid 10:04022a61b527 4352 }
whismanoid 10:04022a61b527 4353 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 4354 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 4355 if (cmdLine_DAPLINKserial.nameStr())
whismanoid 10:04022a61b527 4356 {
whismanoid 10:04022a61b527 4357 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_DAPLINKserial.nameStr());
whismanoid 10:04022a61b527 4358 }
whismanoid 10:04022a61b527 4359 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 4360 # if HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 4361 // WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 4362 cmdLine.serial().printf("\r\n >xyzzy -- Forward command/data 'xyzzy' to aux TX/RX");
whismanoid 10:04022a61b527 4363 cmdLine.serial().printf("\r\n >>xyzzy -- Forward 'xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 4364 cmdLine.serial().printf("\r\n >>>xyzzy -- Forward '>xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 4365 #if 0
whismanoid 10:04022a61b527 4366 cmdLine.serial().printf("\r\n >tx_wait_echo=%d -- configure TX wait for each character echo", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 4367 cmdLine.serial().printf("\r\n >tx_char_delay_ms=%d -- configure TX delay after each char", g_auxSerialCom_tx_char_delay_ms);
whismanoid 10:04022a61b527 4368 cmdLine.serial().printf("\r\n >tx_line_delay_ms=%d -- configure TX delay after each CR/LF", g_auxSerialCom_tx_line_delay_ms);
whismanoid 10:04022a61b527 4369 #endif
whismanoid 20:78ef670955d4 4370 #if 1 // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 4371 cmdLine.serial().printf("\r\n >baud=%d message_ms=%d rx_idle_ms=%d rx_max_count=%d rx_eot=%d",
whismanoid 20:78ef670955d4 4372 g_auxSerialCom_baud,
whismanoid 20:78ef670955d4 4373 g_auxSerialCom_message_ms,
whismanoid 20:78ef670955d4 4374 g_auxSerialCom_rx_idle_ms,
whismanoid 20:78ef670955d4 4375 g_auxSerialCom_rx_max_count,
whismanoid 20:78ef670955d4 4376 g_auxSerialCom_rx_eot);
whismanoid 20:78ef670955d4 4377 #else // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 4378 cmdLine.serial().printf("\r\n >baud=%d -- configure aux TX/RX port", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 4379 cmdLine.serial().printf("\r\n >message_ms=%d -- maximum RX message total response time", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 4380 cmdLine.serial().printf("\r\n >rx_idle_ms=%d -- maximum RX message idle time between characters", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 4381 cmdLine.serial().printf("\r\n >rx_max_count=%d -- maximum RX message total length", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 4382 cmdLine.serial().printf("\r\n >rx_eot=%d -- capture RX until match end of text char (unless %d)", g_auxSerialCom_rx_eot, aux_serial_cmd_forwarding_rx_eot_not_used);
whismanoid 20:78ef670955d4 4383 #endif // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 10:04022a61b527 4384 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 4385 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 4386 //
whismanoid 4:d9b05924ad4c 4387 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 4388 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 4389 // Datalog trigger menu
whismanoid 28:a9a3a9db592b 4390 // brief toplevel heading for datalog help L
whismanoid 28:a9a3a9db592b 4391 // L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 4392 cmdLine.serial().printf("\r\n L -- halt the datalogger; show more commands");
whismanoid 28:a9a3a9db592b 4393 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 28:a9a3a9db592b 4394 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 28:a9a3a9db592b 4395 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 28:a9a3a9db592b 4396 //
whismanoid 28:a9a3a9db592b 4397 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 4398 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 4399 //
whismanoid 39:4d285e961435 4400 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 4401 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 4402 cmdLine.serial().printf("\r\n LT count=%d base=%dms sleep=%d -- Datalog timer",
whismanoid 39:4d285e961435 4403 g_timer_interval_count,
whismanoid 39:4d285e961435 4404 g_timer_interval_msec,
whismanoid 39:4d285e961435 4405 (int)g_timer_sleepmode
whismanoid 39:4d285e961435 4406 ); // trigger_Timer
whismanoid 39:4d285e961435 4407 #else // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 4408 cmdLine.serial().printf("\r\n LT count=%d base=%dms -- Datalog timer", g_timer_interval_count, g_timer_interval_msec); // trigger_Timer
whismanoid 39:4d285e961435 4409 #endif // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 4410 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 4411 //~ cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 4412 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 4413 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 4414 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 4415 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 4416 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 9:45f98573eb6d 4417 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 9:45f98573eb6d 4418 //
whismanoid 17:9397ea3ea7e9 4419 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 4:d9b05924ad4c 4420 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 9:45f98573eb6d 4421 //
whismanoid 17:9397ea3ea7e9 4422 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 4423 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 17:9397ea3ea7e9 4424 cmdLine.serial().printf("\r\n LT count=%d base=%dms -- Datalog timer", g_timer_interval_count, g_timer_interval_msec); // trigger_Timer
whismanoid 9:45f98573eb6d 4425 //
whismanoid 9:45f98573eb6d 4426 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 4427 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 4428 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 4429 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 9:45f98573eb6d 4430 //
whismanoid 17:9397ea3ea7e9 4431 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 9:45f98573eb6d 4432 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 4433 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 4434 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
whismanoid 17:9397ea3ea7e9 4435 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 4436 //
whismanoid 17:9397ea3ea7e9 4437 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 4438 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 17:9397ea3ea7e9 4439 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 9:45f98573eb6d 4440 //
whismanoid 9:45f98573eb6d 4441 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 4442 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 4443 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 4444 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 4445 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 9:45f98573eb6d 4446 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 9:45f98573eb6d 4447 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 9:45f98573eb6d 4448 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 9:45f98573eb6d 4449 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 9:45f98573eb6d 4450 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 9:45f98573eb6d 4451 //
whismanoid 9:45f98573eb6d 4452 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 4453 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 9:45f98573eb6d 4454 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 9:45f98573eb6d 4455 //
whismanoid 9:45f98573eb6d 4456 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 4457 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 4458 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 9:45f98573eb6d 4459 //
whismanoid 9:45f98573eb6d 4460 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 4461 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 9:45f98573eb6d 4462 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 4463 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 9:45f98573eb6d 4464 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 4465 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 9:45f98573eb6d 4466 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 4467 //
whismanoid 9:45f98573eb6d 4468 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 4469 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 9:45f98573eb6d 4470 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 9:45f98573eb6d 4471 //
whismanoid 9:45f98573eb6d 4472 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 4473 //
whismanoid 9:45f98573eb6d 4474 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 4475 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 4476 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 4477 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 4478 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 9:45f98573eb6d 4479 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4480 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 9:45f98573eb6d 4481 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4482 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4483 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 9:45f98573eb6d 4484 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4485 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 9:45f98573eb6d 4486 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4487 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 9:45f98573eb6d 4488 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4489 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4490 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 9:45f98573eb6d 4491 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4492 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 4493 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 4494 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 4495 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 4496 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 4497 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 4498 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 4499 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 4500 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 4501 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 4502 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 4503 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 4504 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 4505 //
whismanoid 4:d9b05924ad4c 4506 //cmdLine.serial().print(F("\r\n ! -- Initial Configuration"));
whismanoid 4:d9b05924ad4c 4507 //
whismanoid 4:d9b05924ad4c 4508 // % standardize diagnostic commands
whismanoid 4:d9b05924ad4c 4509 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 4510 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 4511 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 4512 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 4513 // %Ppin df=xx -- pwm output
whismanoid 4:d9b05924ad4c 4514 // %Wpin -- measure high pulsewidth input in usec
whismanoid 4:d9b05924ad4c 4515 // %wpin -- measure low pulsewidth input in usec
whismanoid 4:d9b05924ad4c 4516 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 4517 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 4518 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 4519 // %IW ADDR=? cmd=? data,data,data -- write
whismanoid 4:d9b05924ad4c 4520 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 4521 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4522 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 4523 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 4524 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 4525 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 4526 // A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 4527 //
whismanoid 23:c6c652bef4b9 4528 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 4529 #if USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4530 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 4531 // TODO: %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 4532 // TODO: future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 4533 // TODO: future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 4534 // TODO: %B1@ view command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 4535 // TODO: %B1@+ command add new row (if there is room to add) (ignore one space before command)
whismanoid 23:c6c652bef4b9 4536 // TODO: %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 4537 // TODO: %B1@-~~~ clear entire command table
whismanoid 23:c6c652bef4b9 4538 // TODO: %B1@nnn command replace row number nnn (ignore one space before command)
whismanoid 23:c6c652bef4b9 4539 // TODO: %B1@! disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 4540 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 4541 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 45:74bf1fe021e5 4542 // cmdLine.serial().printf("\r\n %%B1! trigger Button1 event; %%B1@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4543 cmdLine.serial().printf("\r\n %%B1! trigger Button1 event;");
whismanoid 45:74bf1fe021e5 4544 // print maximum index for %B1 submenu
whismanoid 45:74bf1fe021e5 4545 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4546 cmdLine.serial().printf(" %%B9@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4547 #elif HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4548 cmdLine.serial().printf(" %%B8@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4549 #elif HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4550 cmdLine.serial().printf(" %%B7@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4551 #elif HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4552 cmdLine.serial().printf(" %%B6@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4553 #elif HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4554 cmdLine.serial().printf(" %%B5@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4555 #elif HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4556 cmdLine.serial().printf(" %%B4@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4557 #elif HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4558 cmdLine.serial().printf(" %%B3@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4559 #elif HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4560 cmdLine.serial().printf(" %%B2@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4561 #elif HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4562 cmdLine.serial().printf(" %%B1@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4563 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4564
whismanoid 45:74bf1fe021e5 4565
whismanoid 23:c6c652bef4b9 4566 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4567 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 4568 #if HAS_digitalInOuts
whismanoid 4:d9b05924ad4c 4569 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 4570 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 4571 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 4572 cmdLine.serial().printf("\r\n %%Hn {pin:");
whismanoid 4:d9b05924ad4c 4573 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 4574 cmdLine.serial().printf("} -- High Output");
whismanoid 4:d9b05924ad4c 4575 cmdLine.serial().printf("\r\n %%Ln {pin:");
whismanoid 4:d9b05924ad4c 4576 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 4577 cmdLine.serial().printf("} -- Low Output");
whismanoid 4:d9b05924ad4c 4578 cmdLine.serial().printf("\r\n %%?n {pin:");
whismanoid 4:d9b05924ad4c 4579 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 4580 cmdLine.serial().printf("} -- Input");
whismanoid 4:d9b05924ad4c 4581 #endif
whismanoid 4:d9b05924ad4c 4582
whismanoid 4:d9b05924ad4c 4583 #if HAS_analogIns
whismanoid 4:d9b05924ad4c 4584 // Menu A) analogRead A0..7
whismanoid 4:d9b05924ad4c 4585 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 4586 // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0)
whismanoid 37:3f369235e5bc 4587 cmdLine.serial().printf("\r\n %%A -- analogRead");
whismanoid 37:3f369235e5bc 4588 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4589 // %A avg=%d -- help string display Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 4590 cmdLine.serial().printf("; %%A avg=%d -- average", Platform_AIN_Average_N);
whismanoid 37:3f369235e5bc 4591 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4592 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4593 // %A cal? view/export raw calibration values for all channels
whismanoid 37:3f369235e5bc 4594 cmdLine.serial().printf("; %%A cal? -- calibration");
whismanoid 34:a1993a1ee904 4595 #endif // HAS_Platform_AIN_Calibration
whismanoid 4:d9b05924ad4c 4596 #endif
whismanoid 4:d9b05924ad4c 4597
whismanoid 4:d9b05924ad4c 4598 #if HAS_SPI2_MAX541
whismanoid 4:d9b05924ad4c 4599 // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 4:d9b05924ad4c 4600 cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)");
whismanoid 4:d9b05924ad4c 4601 #endif
whismanoid 4:d9b05924ad4c 4602
whismanoid 46:469d0061df5d 4603 //--------------------------------------------------
whismanoid 46:469d0061df5d 4604 #if defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 4605 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 4606 // cmdLine.serial().printf("\r\n %%F -- flash support");
whismanoid 46:469d0061df5d 4607 # if HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4608 // flash peek memory %F peek=0x0007ff00 len=0x0100 -- hex dump
whismanoid 46:469d0061df5d 4609 cmdLine.serial().printf("\r\n %%F peek=0x%8.8lx len=0x2000 -- hex dump", (uint32_t)&flash_page_configuration_back_up[0]);
whismanoid 46:469d0061df5d 4610 # endif // HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4611 # if HAS_FLASH_POKE
whismanoid 46:469d0061df5d 4612 // flash poke memory %F poke=0x0007ff00 0xab 0xcd 0xef 0x27 0x18 0x28 -- erase/write flash page
whismanoid 48:18647e0516f2 4613 cmdLine.serial().printf("\r\n %%F poke=0x%8.8lx 12 34 56 78 -- erase/write flash page", (uint32_t)&flash_page_configuration_back_up[0]);
whismanoid 46:469d0061df5d 4614 # endif // HAS_FLASH_POKE
whismanoid 46:469d0061df5d 4615 # if HAS_FLASH_LOAD_SAVE
whismanoid 48:18647e0516f2 4616 // cmdLine.serial().printf("\r\n %%F save=0xFF -- erase config; %%F save=0 -- save all config");
whismanoid 48:18647e0516f2 4617 // const uint32_t save_arg_01_pageErase = 0x00000001; // page erase and rewrite
whismanoid 48:18647e0516f2 4618 // const uint32_t save_arg_02_verbose = 0x00000002; // verbose diagnostic messages
whismanoid 48:18647e0516f2 4619 // const uint32_t save_arg_04_reserved = 0x00000004; // reserved
whismanoid 48:18647e0516f2 4620 // const uint32_t save_arg_08_reserved = 0x00000008; // reserved
whismanoid 48:18647e0516f2 4621 // const uint32_t save_arg_10_calibration = 0x00000010; // save board ID and calibration
whismanoid 48:18647e0516f2 4622 // const uint32_t save_arg_20_action_table = 0x00000020; // save Datalogger_action_table
whismanoid 48:18647e0516f2 4623 // const uint32_t save_arg_40_command_table = 0x00000040; // save onButtonX_command_table
whismanoid 48:18647e0516f2 4624 // const uint32_t save_arg_80_reserved = 0x00000080; // reserved
whismanoid 49:359a6b9df7c1 4625 cmdLine.serial().printf("\r\n %%F load=0x%lx ; %%F save=0x%lx -- calibration",
whismanoid 48:18647e0516f2 4626 (load_arg_default | save_arg_02_verbose), (save_arg_default | save_arg_02_verbose));
whismanoid 48:18647e0516f2 4627 //~ cmdLine.serial().printf("\r\n %%F save=0x11 -- erase; config; %%F save=0 -- save all config");
whismanoid 48:18647e0516f2 4628 //~ cmdLine.serial().printf("\r\n %%F load -- load all config");
whismanoid 46:469d0061df5d 4629 # endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 4630 #endif
whismanoid 46:469d0061df5d 4631
whismanoid 4:d9b05924ad4c 4632 #if HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4633 // TODO: support I2C HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4634 // VERIFY: I2C utility commands SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4635 // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz);
whismanoid 4:d9b05924ad4c 4636 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 4637 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 4638 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 4639 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 4:d9b05924ad4c 4640 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 4641 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4642 //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope
whismanoid 4:d9b05924ad4c 4643 cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 4:d9b05924ad4c 4644 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 4:d9b05924ad4c 4645 (g_I2C_SCL_Hz / 1000.));
whismanoid 4:d9b05924ad4c 4646 cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read",
whismanoid 4:d9b05924ad4c 4647 g_I2C_deviceAddress7);
whismanoid 4:d9b05924ad4c 4648 //
whismanoid 4:d9b05924ad4c 4649 #if SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4650 // Menu ^ cmd=?) i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4651 cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data");
whismanoid 4:d9b05924ad4c 4652 // test low-level I2C i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4653 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4654 //cmdLine.serial().printf(" H) Hunt for attached I2C devices");
whismanoid 4:d9b05924ad4c 4655 cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices");
whismanoid 4:d9b05924ad4c 4656 // cmdLine.serial().printf(" s) search i2c address");
whismanoid 4:d9b05924ad4c 4657 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4658
whismanoid 4:d9b05924ad4c 4659 #if HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 4660 // TODO: support SPI HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 4661 // SPI test command S (mosiData)+
whismanoid 4:d9b05924ad4c 4662 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 4663 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 4664 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 4665 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 4666 // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 4:d9b05924ad4c 4667 // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 4:d9b05924ad4c 4668 // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 4:d9b05924ad4c 4669 // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 4:d9b05924ad4c 4670 // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 4:d9b05924ad4c 4671 // mode | POL PHA
whismanoid 4:d9b05924ad4c 4672 // -----+--------
whismanoid 4:d9b05924ad4c 4673 // 0 | 0 0
whismanoid 4:d9b05924ad4c 4674 // 1 | 0 1
whismanoid 4:d9b05924ad4c 4675 // 2 | 1 0
whismanoid 4:d9b05924ad4c 4676 // 3 | 1 1
whismanoid 4:d9b05924ad4c 4677 //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0");
whismanoid 4:d9b05924ad4c 4678 // fixed: mbed-os-5.11: [Warning] format '%d' expects argument of type 'int', but argument 3 has type 'uint32_t {aka long unsigned int}' [-Wformat=]
whismanoid 4:d9b05924ad4c 4679 cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config",
whismanoid 4:d9b05924ad4c 4680 g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.),
whismanoid 4:d9b05924ad4c 4681 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 4:d9b05924ad4c 4682 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0));
whismanoid 4:d9b05924ad4c 4683 cmdLine.serial().printf("\r\n %%SD -- SPI diagnostic messages ");
whismanoid 4:d9b05924ad4c 4684 if (g_MAX11410_device.onSPIprint) {
whismanoid 4:d9b05924ad4c 4685 cmdLine.serial().printf("hide");
whismanoid 4:d9b05924ad4c 4686 }
whismanoid 4:d9b05924ad4c 4687 else {
whismanoid 4:d9b05924ad4c 4688 cmdLine.serial().printf("show");
whismanoid 4:d9b05924ad4c 4689 }
whismanoid 4:d9b05924ad4c 4690 cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes");
whismanoid 4:d9b05924ad4c 4691 // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0
whismanoid 4:d9b05924ad4c 4692 #endif // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 4693 //
whismanoid 4:d9b05924ad4c 4694 // Application-specific commands (help text) here
whismanoid 4:d9b05924ad4c 4695 //
whismanoid 4:d9b05924ad4c 4696 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 4697 cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 4698 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 4699 //
whismanoid 4:d9b05924ad4c 4700
whismanoid 4:d9b05924ad4c 4701 //~ extern void MAX11410_menu_help(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp\n
whismanoid 4:d9b05924ad4c 4702 //~ MAX11410_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 4703 }
whismanoid 4:d9b05924ad4c 4704 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 4705
whismanoid 4:d9b05924ad4c 4706 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 15:37c83ec50ea0 4707
whismanoid 15:37c83ec50ea0 4708 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 4709 void pinsMonitor_submenu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 15:37c83ec50ea0 4710 {
whismanoid 15:37c83ec50ea0 4711 // % diagnostic commands submenu
whismanoid 15:37c83ec50ea0 4712 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 4713 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 4714 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 4715 // %A %Apin -- analog input
whismanoid 15:37c83ec50ea0 4716 // %Ppin df=xx -- pwm output
whismanoid 15:37c83ec50ea0 4717 // %Wpin -- measure high pulsewidth input in usec
whismanoid 15:37c83ec50ea0 4718 // %wpin -- measure low pulsewidth input in usec
whismanoid 15:37c83ec50ea0 4719 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 4720 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 4721 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 4722 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 4723 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 4724 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 4725 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 4726 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 4727 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 4728 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 4729 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 4730 //
whismanoid 15:37c83ec50ea0 4731 char strPinIndex[3];
whismanoid 15:37c83ec50ea0 4732 strPinIndex[0] = cmdLine[2];
whismanoid 15:37c83ec50ea0 4733 strPinIndex[1] = cmdLine[3];
whismanoid 15:37c83ec50ea0 4734 strPinIndex[2] = '\0';
whismanoid 15:37c83ec50ea0 4735 int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 15:37c83ec50ea0 4736 //cmdLine.serial().printf(" pinIndex=%d ", pinIndex);
whismanoid 15:37c83ec50ea0 4737 //
whismanoid 15:37c83ec50ea0 4738 // get next character
whismanoid 15:37c83ec50ea0 4739 switch (cmdLine[1])
whismanoid 15:37c83ec50ea0 4740 {
whismanoid 23:c6c652bef4b9 4741 //--------------------------------------------------
whismanoid 46:469d0061df5d 4742 #if defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 4743 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 4744 case 'F': case 'f':
whismanoid 46:469d0061df5d 4745 {
whismanoid 46:469d0061df5d 4746 # if HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4747 // Limit the ranges where memory write operation will be allowed
whismanoid 46:469d0061df5d 4748 // FLASH (rx) : ORIGIN = 0x00010000, LENGTH = 0x00070000
whismanoid 46:469d0061df5d 4749 //~ const uint32_t poke_flash_min = 0x00010000;
whismanoid 46:469d0061df5d 4750 //~ const uint32_t poke_flash_max = 0x0007FFFF;
whismanoid 46:469d0061df5d 4751 // RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00028000
whismanoid 46:469d0061df5d 4752 //~ const uint32_t poke_ram_min = 0x20000000;
whismanoid 46:469d0061df5d 4753 //~ const uint32_t poke_ram_max = 0x20027FFF;
whismanoid 46:469d0061df5d 4754 //
whismanoid 46:469d0061df5d 4755 // flash peek memory %F peek=0x0007ff00 len=0x0100 -- hex dump
whismanoid 46:469d0061df5d 4756 // get "len" keyword, default 1
whismanoid 46:469d0061df5d 4757 uint32_t peek_len = 1;
whismanoid 46:469d0061df5d 4758 if (cmdLine.parse_uint32_hex("len", peek_len))
whismanoid 46:469d0061df5d 4759 {
whismanoid 46:469d0061df5d 4760 }
whismanoid 46:469d0061df5d 4761 // get "peek" keyword, do peek operation if keyword is present
whismanoid 46:469d0061df5d 4762 uint32_t peek_addr = 0x00010000;
whismanoid 46:469d0061df5d 4763 if (cmdLine.parse_uint32_hex("peek", peek_addr))
whismanoid 46:469d0061df5d 4764 {
whismanoid 46:469d0061df5d 4765 // #312 hex dump memory from peek_addr length peek_len
whismanoid 46:469d0061df5d 4766 peek_addr = peek_addr &~ 0x00000003; // 32-bit word align
whismanoid 46:469d0061df5d 4767 //
whismanoid 46:469d0061df5d 4768 // scan poke_access_list[] for peek_addr
whismanoid 46:469d0061df5d 4769 int poke_access_list_index = search_poke_access_list(peek_addr);
whismanoid 46:469d0061df5d 4770 // post: poke_access_list[poke_access_list_index].addr_min is lowest address of range
whismanoid 46:469d0061df5d 4771 // post: poke_access_list[poke_access_list_index].addr_max is highest address of range
whismanoid 46:469d0061df5d 4772 // post: poke_access_list[poke_access_list_index].name
whismanoid 46:469d0061df5d 4773 // post: poke_access_list[poke_access_list_index].can_flash_write_read 8=end of list, 4=flashPoke, 2=ramPoke, 1=read
whismanoid 46:469d0061df5d 4774 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 46:469d0061df5d 4775 poke_access_list_index,
whismanoid 46:469d0061df5d 4776 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 4777 poke_access_list[poke_access_list_index].addr_min,
whismanoid 46:469d0061df5d 4778 poke_access_list[poke_access_list_index].addr_max,
whismanoid 46:469d0061df5d 4779 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 46:469d0061df5d 4780 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x04)
whismanoid 46:469d0061df5d 4781 {
whismanoid 46:469d0061df5d 4782 cmdLine.serial().printf("flashPoke ");
whismanoid 46:469d0061df5d 4783 }
whismanoid 46:469d0061df5d 4784 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x02)
whismanoid 46:469d0061df5d 4785 {
whismanoid 46:469d0061df5d 4786 cmdLine.serial().printf("ramPoke ");
whismanoid 46:469d0061df5d 4787 }
whismanoid 46:469d0061df5d 4788 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x01)
whismanoid 46:469d0061df5d 4789 {
whismanoid 46:469d0061df5d 4790 cmdLine.serial().printf("read ");
whismanoid 46:469d0061df5d 4791 }
whismanoid 46:469d0061df5d 4792 //
whismanoid 46:469d0061df5d 4793 //~ cmdLine.serial().printf("\r\n0x%8.8lx: ", peek_addr);
whismanoid 46:469d0061df5d 4794 if ((peek_addr & 0x0F) != 0)
whismanoid 46:469d0061df5d 4795 {
whismanoid 46:469d0061df5d 4796 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4797 }
whismanoid 46:469d0061df5d 4798 while (peek_len > 0)
whismanoid 46:469d0061df5d 4799 {
whismanoid 46:469d0061df5d 4800 if ((peek_addr & 0x0F) == 0)
whismanoid 46:469d0061df5d 4801 {
whismanoid 46:469d0061df5d 4802 poke_access_list_index = search_poke_access_list(peek_addr);
whismanoid 46:469d0061df5d 4803 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4804 }
whismanoid 46:469d0061df5d 4805 if (poke_access_list[poke_access_list_index].can_flash_write_read & 1)
whismanoid 46:469d0061df5d 4806 {
whismanoid 46:469d0061df5d 4807 // read memory by using peek_addr as a uint32_t pointer
whismanoid 46:469d0061df5d 4808 cmdLine.serial().printf("0x%8.8lx ", *((uint32_t*)peek_addr));
whismanoid 46:469d0061df5d 4809 }
whismanoid 46:469d0061df5d 4810 else
whismanoid 46:469d0061df5d 4811 {
whismanoid 46:469d0061df5d 4812 // read operation is forbidden in this address range
whismanoid 46:469d0061df5d 4813 cmdLine.serial().printf("__________ ");
whismanoid 46:469d0061df5d 4814 }
whismanoid 46:469d0061df5d 4815 peek_addr += 4;
whismanoid 46:469d0061df5d 4816 peek_len--;
whismanoid 46:469d0061df5d 4817 }
whismanoid 46:469d0061df5d 4818 }
whismanoid 46:469d0061df5d 4819 # endif // HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4820 # if HAS_FLASH_POKE
whismanoid 46:469d0061df5d 4821 // flash poke memory %F poke=0x0007ff00 0xab 0xcd 0xef 0x27 0x18 0x28 -- erase/write flash page
whismanoid 46:469d0061df5d 4822 // get "poke" keyword, do poke operation if keyword is present
whismanoid 46:469d0061df5d 4823 uint32_t poke_addr = 0x20000000;
whismanoid 46:469d0061df5d 4824 if (cmdLine.parse_uint32_hex("poke", poke_addr))
whismanoid 46:469d0061df5d 4825 {
whismanoid 46:469d0061df5d 4826 size_t byteCount = 0;
whismanoid 46:469d0061df5d 4827 uint8_t pokeDataBuf[16];
whismanoid 46:469d0061df5d 4828 // get list of bytes after processing keywords
whismanoid 46:469d0061df5d 4829 // bool parse_byteCount_byteList_hex(size_t& byteCount, char *mosiDataBuf, size_t mosiDataBufSize);
whismanoid 46:469d0061df5d 4830 if (cmdLine.parse_byteCount_byteList_hex(byteCount, ((char *)pokeDataBuf), sizeof(pokeDataBuf)))
whismanoid 46:469d0061df5d 4831 {
whismanoid 46:469d0061df5d 4832 // #312 write memory at poke_addr
whismanoid 46:469d0061df5d 4833 poke_addr = poke_addr &~ 0x00000003; // 32-bit word align
whismanoid 46:469d0061df5d 4834 //
whismanoid 46:469d0061df5d 4835 // scan poke_access_list[] for poke_addr
whismanoid 46:469d0061df5d 4836 int poke_access_list_index = search_poke_access_list(poke_addr);
whismanoid 46:469d0061df5d 4837 // post: poke_access_list[poke_access_list_index].addr_min is lowest address of range
whismanoid 46:469d0061df5d 4838 // post: poke_access_list[poke_access_list_index].addr_max is highest address of range
whismanoid 46:469d0061df5d 4839 // post: poke_access_list[poke_access_list_index].name
whismanoid 46:469d0061df5d 4840 // post: poke_access_list[poke_access_list_index].can_flash_write_read 8=end of list, 4=flashPoke, 2=ramPoke, 1=read
whismanoid 46:469d0061df5d 4841 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 46:469d0061df5d 4842 poke_access_list_index,
whismanoid 46:469d0061df5d 4843 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 4844 poke_access_list[poke_access_list_index].addr_min,
whismanoid 46:469d0061df5d 4845 poke_access_list[poke_access_list_index].addr_max,
whismanoid 46:469d0061df5d 4846 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 46:469d0061df5d 4847 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x04)
whismanoid 46:469d0061df5d 4848 {
whismanoid 46:469d0061df5d 4849 cmdLine.serial().printf("flashPoke ");
whismanoid 46:469d0061df5d 4850 }
whismanoid 46:469d0061df5d 4851 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x02)
whismanoid 46:469d0061df5d 4852 {
whismanoid 46:469d0061df5d 4853 cmdLine.serial().printf("ramPoke ");
whismanoid 46:469d0061df5d 4854 }
whismanoid 46:469d0061df5d 4855 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x01)
whismanoid 46:469d0061df5d 4856 {
whismanoid 46:469d0061df5d 4857 cmdLine.serial().printf("read ");
whismanoid 46:469d0061df5d 4858 }
whismanoid 46:469d0061df5d 4859 //
whismanoid 46:469d0061df5d 4860 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x0004)
whismanoid 46:469d0061df5d 4861 {
whismanoid 46:469d0061df5d 4862 //------------------------------
whismanoid 46:469d0061df5d 4863 // mbed interface to on-chip Flash
whismanoid 46:469d0061df5d 4864 // FlashIAP flash;
whismanoid 46:469d0061df5d 4865 // Maxim MAX32625 flash interface flc.h not .\mbed-os\drivers\FlashIAP.h
whismanoid 46:469d0061df5d 4866 // .\mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\mxc\flc.h
whismanoid 46:469d0061df5d 4867 // .\mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\mxc\flc.c
whismanoid 46:469d0061df5d 4868 //
whismanoid 46:469d0061df5d 4869 // MAX32625IWY+ Flash 512Kbyte in 64 pages of 8Kbyte per page
whismanoid 46:469d0061df5d 4870 static uint8_t pageBuf[8192];
whismanoid 46:469d0061df5d 4871 uint32_t pageBuf_addr = poke_addr &~ 0x1FFF; // 32-bit word align, 8Kbyte page boundary
whismanoid 46:469d0061df5d 4872 //
whismanoid 46:469d0061df5d 4873 // poke_addr is in FLASH address range, there's more steps
whismanoid 46:469d0061df5d 4874 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: flashPoke ...",
whismanoid 46:469d0061df5d 4875 poke_access_list[poke_access_list_index].name, poke_addr);
whismanoid 46:469d0061df5d 4876 // initialize flash memory interface
whismanoid 46:469d0061df5d 4877 // FlashIAP: FlashIAP flash; flash.init();
whismanoid 46:469d0061df5d 4878 // int FLC_Init(void);
whismanoid 46:469d0061df5d 4879 // returns E_NO_ERROR or E_BUSY or E_UNKNOWN
whismanoid 46:469d0061df5d 4880 cmdLine.serial().printf("FLC_Init ");
whismanoid 46:469d0061df5d 4881 if (FLC_Init() != E_NO_ERROR)
whismanoid 46:469d0061df5d 4882 {
whismanoid 46:469d0061df5d 4883 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4884 break; // can't perform the command
whismanoid 46:469d0061df5d 4885 }
whismanoid 46:469d0061df5d 4886 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4887 //
whismanoid 46:469d0061df5d 4888 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: start of 8KByte page containing 0x%8.8lx...",
whismanoid 46:469d0061df5d 4889 poke_access_list[poke_access_list_index].name, pageBuf_addr, poke_addr);
whismanoid 46:469d0061df5d 4890 //
whismanoid 46:469d0061df5d 4891 // page read, update buffer from command line bytes, page erase, page write
whismanoid 46:469d0061df5d 4892 cmdLine.serial().printf("\r\nPgBuf 0x%8.8lx: copy page buffer, len=0x%x words = 0x%x bytes...",
whismanoid 46:469d0061df5d 4893 pageBuf_addr, sizeof(pageBuf)/4, sizeof(pageBuf));
whismanoid 46:469d0061df5d 4894 // memcpy(uint32_t *out, uint32_t *in, unsigned int count)
whismanoid 46:469d0061df5d 4895 memcpy(&pageBuf[0], (uint32_t*)pageBuf_addr, sizeof(pageBuf));
whismanoid 46:469d0061df5d 4896 //
whismanoid 46:469d0061df5d 4897 cmdLine.serial().printf("\r\nPgBuf 0x%8.8lx: udpate page buffer ...", poke_addr);
whismanoid 46:469d0061df5d 4898 // update buffer from command line bytes using my cmdline lib
whismanoid 46:469d0061df5d 4899 // ignore pokeDataBuf[0], its 0x0F because this is command F. :(
whismanoid 46:469d0061df5d 4900 for (size_t byteIndex = 1; byteIndex < byteCount; byteIndex += 4)
whismanoid 46:469d0061df5d 4901 {
whismanoid 46:469d0061df5d 4902 // How to handle big-endian vs little-endian?
whismanoid 46:469d0061df5d 4903 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 0] = pokeDataBuf[byteIndex + 3];
whismanoid 46:469d0061df5d 4904 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 1] = pokeDataBuf[byteIndex + 2];
whismanoid 46:469d0061df5d 4905 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 2] = pokeDataBuf[byteIndex + 1];
whismanoid 46:469d0061df5d 4906 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 3] = pokeDataBuf[byteIndex + 0];
whismanoid 46:469d0061df5d 4907 // seems 0x12 0x34 0x56 0x78 becomes 0x78563412
whismanoid 46:469d0061df5d 4908 uint32_t wordbuf = 0
whismanoid 46:469d0061df5d 4909 | ((uint32_t)pokeDataBuf[byteIndex + 0] << 24)
whismanoid 46:469d0061df5d 4910 | ((uint32_t)pokeDataBuf[byteIndex + 1] << 16)
whismanoid 46:469d0061df5d 4911 | ((uint32_t)pokeDataBuf[byteIndex + 2] << 8)
whismanoid 46:469d0061df5d 4912 | ((uint32_t)pokeDataBuf[byteIndex + 3] << 0)
whismanoid 46:469d0061df5d 4913 ;
whismanoid 46:469d0061df5d 4914 cmdLine.serial().printf("\r\nPgBuf[0x%8.8lx] = FLASH 0x%8.8lx: ",
whismanoid 46:469d0061df5d 4915 (poke_addr - pageBuf_addr + byteIndex-1), (poke_addr + byteIndex-1));
whismanoid 46:469d0061df5d 4916 cmdLine.serial().printf("0x%8.8lx ", wordbuf);
whismanoid 46:469d0061df5d 4917 // poke_addr += 4;
whismanoid 46:469d0061df5d 4918 }
whismanoid 46:469d0061df5d 4919 //
whismanoid 46:469d0061df5d 4920 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: erase page ...",
whismanoid 46:469d0061df5d 4921 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 4922 // page erase using flash.erase(addr, flash.get_sector_size(addr));
whismanoid 46:469d0061df5d 4923 // int FLC_PageErase(uint32_t address, MXC_V_FLC_ERASE_CODE_PAGE_ERASE, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 4924 // @param address Address of the page to be erased.
whismanoid 46:469d0061df5d 4925 // @param erase_code Flash erase code; defined as
whismanoid 46:469d0061df5d 4926 // #MXC_V_FLC_ERASE_CODE_PAGE_ERASE for page erase
whismanoid 46:469d0061df5d 4927 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 4928 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 4929 if (FLC_PageErase(pageBuf_addr, MXC_V_FLC_ERASE_CODE_PAGE_ERASE,
whismanoid 46:469d0061df5d 4930 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 4931 {
whismanoid 46:469d0061df5d 4932 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4933 break; // can't perform the command
whismanoid 46:469d0061df5d 4934 }
whismanoid 46:469d0061df5d 4935 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4936 //
whismanoid 46:469d0061df5d 4937 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: write page buffer ...",
whismanoid 46:469d0061df5d 4938 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 4939 // page write using flash.program(page_buffer, addr, page_size);
whismanoid 46:469d0061df5d 4940 // int FLC_Write(uint32_t address, const void *data, uint32_t length, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 4941 // @param address Start address for desired write. @note This address
whismanoid 46:469d0061df5d 4942 // must be 32-bit word aligned
whismanoid 46:469d0061df5d 4943 // @param data A pointer to the buffer containing the data to write.
whismanoid 46:469d0061df5d 4944 // @param length Size of the data to write in bytes. @note The length
whismanoid 46:469d0061df5d 4945 // must be in 32-bit multiples.
whismanoid 46:469d0061df5d 4946 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 4947 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 4948 if (FLC_Write(pageBuf_addr, (uint32_t*)&pageBuf[0], sizeof(pageBuf),
whismanoid 46:469d0061df5d 4949 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 4950 {
whismanoid 46:469d0061df5d 4951 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4952 break; // can't perform the command
whismanoid 46:469d0061df5d 4953 }
whismanoid 46:469d0061df5d 4954 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4955 //
whismanoid 46:469d0061df5d 4956 // FlashIAP: close flash memory interface flash.deinit();
whismanoid 46:469d0061df5d 4957 //
whismanoid 46:469d0061df5d 4958 // verify buffer matches flash page, or fail
whismanoid 46:469d0061df5d 4959 // for verification, perform %F peek=(poke_addr) len=(from byteCount)
whismanoid 46:469d0061df5d 4960 // hex dump memory from peek_addr length peek_len
whismanoid 46:469d0061df5d 4961 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: verify page buffer ...",
whismanoid 46:469d0061df5d 4962 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 4963 int verify_failed = 0;
whismanoid 46:469d0061df5d 4964 peek_addr = poke_addr;
whismanoid 46:469d0061df5d 4965 peek_len = (byteCount - 1)/4;
whismanoid 46:469d0061df5d 4966 //~ cmdLine.serial().printf("\r\n0x%8.8lx: ", peek_addr);
whismanoid 46:469d0061df5d 4967 if ((peek_addr & 0x0F) != 0)
whismanoid 46:469d0061df5d 4968 {
whismanoid 46:469d0061df5d 4969 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4970 }
whismanoid 46:469d0061df5d 4971 while (peek_len > 0)
whismanoid 46:469d0061df5d 4972 {
whismanoid 46:469d0061df5d 4973 if ((peek_addr & 0x0F) == 0)
whismanoid 46:469d0061df5d 4974 {
whismanoid 46:469d0061df5d 4975 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4976 }
whismanoid 46:469d0061df5d 4977 // read memory by using peek_addr as a uint32_t pointer
whismanoid 46:469d0061df5d 4978 // cmdLine.serial().printf("0x%8.8lx ", *((uint32_t*)peek_addr));
whismanoid 46:469d0061df5d 4979 // #312 %F peek verify, report fail if mismatch page buffer
whismanoid 46:469d0061df5d 4980 uint32_t expect_data = 0
whismanoid 46:469d0061df5d 4981 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 3] << 24)
whismanoid 46:469d0061df5d 4982 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 2] << 16)
whismanoid 46:469d0061df5d 4983 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 1] << 8)
whismanoid 46:469d0061df5d 4984 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 0] << 0)
whismanoid 46:469d0061df5d 4985 ;
whismanoid 46:469d0061df5d 4986 uint32_t actual_data = *((uint32_t*)peek_addr);
whismanoid 46:469d0061df5d 4987 if (actual_data == expect_data)
whismanoid 46:469d0061df5d 4988 {
whismanoid 46:469d0061df5d 4989 // this word matches
whismanoid 46:469d0061df5d 4990 cmdLine.serial().printf("=0x%8.8lx ", actual_data);
whismanoid 46:469d0061df5d 4991 }
whismanoid 46:469d0061df5d 4992 else
whismanoid 46:469d0061df5d 4993 {
whismanoid 46:469d0061df5d 4994 // mismatch, verification failed
whismanoid 46:469d0061df5d 4995 cmdLine.serial().printf("#0x%8.8lx(expected 0x%8.8lx)\r\n%5s 0x%8.8lx: ",
whismanoid 46:469d0061df5d 4996 actual_data, expect_data,
whismanoid 46:469d0061df5d 4997 poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4998 verify_failed++;
whismanoid 46:469d0061df5d 4999 }
whismanoid 46:469d0061df5d 5000 //
whismanoid 46:469d0061df5d 5001 peek_addr += 4;
whismanoid 46:469d0061df5d 5002 peek_len--;
whismanoid 46:469d0061df5d 5003 }
whismanoid 46:469d0061df5d 5004 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: verify page buffer ",
whismanoid 46:469d0061df5d 5005 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 5006 if (verify_failed)
whismanoid 46:469d0061df5d 5007 {
whismanoid 46:469d0061df5d 5008 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 5009 break; // can't perform the command
whismanoid 46:469d0061df5d 5010 }
whismanoid 46:469d0061df5d 5011 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 5012 //
whismanoid 46:469d0061df5d 5013 } // end of flashPoke operation
whismanoid 46:469d0061df5d 5014 else if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x0002)
whismanoid 46:469d0061df5d 5015 {
whismanoid 46:469d0061df5d 5016 // poke_addr is in RAM address range, write directly
whismanoid 46:469d0061df5d 5017 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ramPoke ", poke_access_list[poke_access_list_index].name, poke_addr);
whismanoid 46:469d0061df5d 5018 // ignore pokeDataBuf[0], its 0x0F because this is command F. :(
whismanoid 46:469d0061df5d 5019 for (size_t byteIndex = 1; byteIndex < byteCount; byteIndex += 4)
whismanoid 46:469d0061df5d 5020 {
whismanoid 46:469d0061df5d 5021 // How to handle big-endian vs little-endian?
whismanoid 46:469d0061df5d 5022 // seems 0x12 0x34 0x56 0x78 becomes 0x78563412
whismanoid 46:469d0061df5d 5023 poke_addr += 4;
whismanoid 46:469d0061df5d 5024 uint32_t wordbuf = 0
whismanoid 46:469d0061df5d 5025 | ((uint32_t)pokeDataBuf[byteIndex + 0] << 24)
whismanoid 46:469d0061df5d 5026 | ((uint32_t)pokeDataBuf[byteIndex + 1] << 16)
whismanoid 46:469d0061df5d 5027 | ((uint32_t)pokeDataBuf[byteIndex + 2] << 8)
whismanoid 46:469d0061df5d 5028 | ((uint32_t)pokeDataBuf[byteIndex + 3] << 0)
whismanoid 46:469d0061df5d 5029 ;
whismanoid 46:469d0061df5d 5030 cmdLine.serial().printf("0x%8.8lx ", wordbuf);
whismanoid 46:469d0061df5d 5031 //
whismanoid 46:469d0061df5d 5032 // write RAM by using poke_addr as a uint32_t pointer
whismanoid 46:469d0061df5d 5033 *((uint32_t*)poke_addr) = wordbuf;
whismanoid 46:469d0061df5d 5034 //
whismanoid 46:469d0061df5d 5035 // verify?
whismanoid 46:469d0061df5d 5036 if (*((uint32_t*)poke_addr) == wordbuf)
whismanoid 46:469d0061df5d 5037 {
whismanoid 46:469d0061df5d 5038 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 5039 }
whismanoid 46:469d0061df5d 5040 else
whismanoid 46:469d0061df5d 5041 {
whismanoid 46:469d0061df5d 5042 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 5043 }
whismanoid 46:469d0061df5d 5044 }
whismanoid 46:469d0061df5d 5045 } // end of ramPoke operation
whismanoid 46:469d0061df5d 5046 else
whismanoid 46:469d0061df5d 5047 {
whismanoid 46:469d0061df5d 5048 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: no write here ", poke_access_list[poke_access_list_index].name, poke_addr);
whismanoid 46:469d0061df5d 5049 }
whismanoid 46:469d0061df5d 5050 }
whismanoid 46:469d0061df5d 5051 }
whismanoid 46:469d0061df5d 5052 # endif // HAS_FLASH_POKE
whismanoid 46:469d0061df5d 5053 # if HAS_FLASH_LOAD_SAVE
whismanoid 48:18647e0516f2 5054 uint32_t save_arg = save_arg_default;
whismanoid 46:469d0061df5d 5055 if (cmdLine.parse_uint32_hex("save", save_arg))
whismanoid 46:469d0061df5d 5056 {
whismanoid 46:469d0061df5d 5057 Save_flash_page_configuration_back_up(cmdLine, save_arg);
whismanoid 46:469d0061df5d 5058 }
whismanoid 48:18647e0516f2 5059 uint32_t load_arg = load_arg_default;
whismanoid 46:469d0061df5d 5060 if (cmdLine.parse_uint32_hex("load", load_arg))
whismanoid 46:469d0061df5d 5061 {
whismanoid 46:469d0061df5d 5062 Load_flash_page_configuration_back_up(cmdLine, load_arg);
whismanoid 46:469d0061df5d 5063 }
whismanoid 46:469d0061df5d 5064 # endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 5065 }
whismanoid 46:469d0061df5d 5066 break;
whismanoid 46:469d0061df5d 5067 #endif // defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 5068 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 5069 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 5070 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 5071 case 'B': case 'b':
whismanoid 23:c6c652bef4b9 5072 {
whismanoid 24:032f3683cb2a 5073 int command_table_button_index = 1;
whismanoid 23:c6c652bef4b9 5074 // %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 5075 // future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 5076 // future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 5077 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 5078 // cmdLine[2] == '1' selects onButton1_command_table
whismanoid 23:c6c652bef4b9 5079 char** command_table = onButton1_command_table;
whismanoid 23:c6c652bef4b9 5080 #endif
whismanoid 24:032f3683cb2a 5081 switch(cmdLine[2])
whismanoid 24:032f3683cb2a 5082 {
whismanoid 24:032f3683cb2a 5083 default:
whismanoid 24:032f3683cb2a 5084 case '1': case 'A': case 'a': case '!':
whismanoid 24:032f3683cb2a 5085 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 5086 command_table_button_index = 1;
whismanoid 24:032f3683cb2a 5087 command_table = onButton1_command_table;
whismanoid 24:032f3683cb2a 5088 #endif
whismanoid 24:032f3683cb2a 5089 break;
whismanoid 24:032f3683cb2a 5090 case '2': case 'B': case 'b': case '@':
whismanoid 23:c6c652bef4b9 5091 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 5092 command_table_button_index = 2;
whismanoid 24:032f3683cb2a 5093 command_table = onButton2_command_table;
whismanoid 24:032f3683cb2a 5094 #endif
whismanoid 24:032f3683cb2a 5095 break;
whismanoid 24:032f3683cb2a 5096 case '3': case 'C': case 'c': case '#':
whismanoid 23:c6c652bef4b9 5097 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 5098 command_table_button_index = 3;
whismanoid 24:032f3683cb2a 5099 command_table = onButton3_command_table;
whismanoid 24:032f3683cb2a 5100 #endif
whismanoid 24:032f3683cb2a 5101 break;
whismanoid 29:6a9edb6e973b 5102 case '4':
whismanoid 29:6a9edb6e973b 5103 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 5104 command_table_button_index = 4;
whismanoid 29:6a9edb6e973b 5105 command_table = onButton4_command_table;
whismanoid 29:6a9edb6e973b 5106 #endif
whismanoid 29:6a9edb6e973b 5107 break;
whismanoid 29:6a9edb6e973b 5108 case '5':
whismanoid 29:6a9edb6e973b 5109 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 5110 command_table_button_index = 5;
whismanoid 29:6a9edb6e973b 5111 command_table = onButton5_command_table;
whismanoid 29:6a9edb6e973b 5112 #endif
whismanoid 29:6a9edb6e973b 5113 break;
whismanoid 29:6a9edb6e973b 5114 case '6':
whismanoid 29:6a9edb6e973b 5115 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 5116 command_table_button_index = 6;
whismanoid 29:6a9edb6e973b 5117 command_table = onButton6_command_table;
whismanoid 29:6a9edb6e973b 5118 #endif
whismanoid 29:6a9edb6e973b 5119 break;
whismanoid 29:6a9edb6e973b 5120 case '7':
whismanoid 29:6a9edb6e973b 5121 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 5122 command_table_button_index = 7;
whismanoid 29:6a9edb6e973b 5123 command_table = onButton7_command_table;
whismanoid 29:6a9edb6e973b 5124 #endif
whismanoid 29:6a9edb6e973b 5125 break;
whismanoid 29:6a9edb6e973b 5126 case '8':
whismanoid 29:6a9edb6e973b 5127 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 5128 command_table_button_index = 8;
whismanoid 29:6a9edb6e973b 5129 command_table = onButton8_command_table;
whismanoid 29:6a9edb6e973b 5130 #endif
whismanoid 29:6a9edb6e973b 5131 break;
whismanoid 29:6a9edb6e973b 5132 case '9':
whismanoid 29:6a9edb6e973b 5133 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 5134 command_table_button_index = 9;
whismanoid 29:6a9edb6e973b 5135 command_table = onButton9_command_table;
whismanoid 29:6a9edb6e973b 5136 #endif
whismanoid 29:6a9edb6e973b 5137 break;
whismanoid 24:032f3683cb2a 5138 }
whismanoid 24:032f3683cb2a 5139 //
whismanoid 23:c6c652bef4b9 5140 switch(cmdLine[3])
whismanoid 23:c6c652bef4b9 5141 {
whismanoid 23:c6c652bef4b9 5142 case '@':
whismanoid 23:c6c652bef4b9 5143 {
whismanoid 23:c6c652bef4b9 5144 // %B1@ view/edit command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 5145 int editRowIndex = 0;
whismanoid 23:c6c652bef4b9 5146 int command_table_row_count = 0;
whismanoid 23:c6c652bef4b9 5147 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 5148 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 5149 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 5150 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 5151 }
whismanoid 24:032f3683cb2a 5152 //
whismanoid 24:032f3683cb2a 5153 // ignore extra spaces before the command
whismanoid 24:032f3683cb2a 5154 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 24:032f3683cb2a 5155 int argIndex;
whismanoid 24:032f3683cb2a 5156 for (argIndex = 5; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 5157 {
whismanoid 24:032f3683cb2a 5158 if (cmdLine[argIndex] == ' ') break;
whismanoid 24:032f3683cb2a 5159 }
whismanoid 24:032f3683cb2a 5160 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 5161 {
whismanoid 24:032f3683cb2a 5162 if (cmdLine[argIndex] != ' ') break;
whismanoid 23:c6c652bef4b9 5163 }
whismanoid 23:c6c652bef4b9 5164 //
whismanoid 23:c6c652bef4b9 5165 // Edit the contents of command_table
whismanoid 23:c6c652bef4b9 5166 switch (cmdLine[4]) // %B1@... -- Edit the contents of command_table
whismanoid 23:c6c652bef4b9 5167 {
whismanoid 23:c6c652bef4b9 5168 case '0': case '1': case '2': case '3': case '4':
whismanoid 23:c6c652bef4b9 5169 case '5': case '6': case '7': case '8': case '9':
whismanoid 24:032f3683cb2a 5170 // %B1@nnn command replace row number nnn
whismanoid 23:c6c652bef4b9 5171 // edit row data
whismanoid 33:70a28cfe9e01 5172 // get row number to edit from cmdLine[4]
whismanoid 33:70a28cfe9e01 5173 editRowIndex = atoi(cmdLine.str()+4);
whismanoid 23:c6c652bef4b9 5174 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 5175 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 5176 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 28:a9a3a9db592b 5177 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 5178 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 5179 cmdLine.serial().printf("\r\n cannot replace row %d with nothing",
whismanoid 28:a9a3a9db592b 5180 editRowIndex);
whismanoid 28:a9a3a9db592b 5181 }
whismanoid 28:a9a3a9db592b 5182 else
whismanoid 28:a9a3a9db592b 5183 {
whismanoid 28:a9a3a9db592b 5184 // update row
whismanoid 28:a9a3a9db592b 5185 cmdLine.serial().printf("\r\n replace row %d with \"%s\"",
whismanoid 28:a9a3a9db592b 5186 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 5187 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 5188 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 5189 }
whismanoid 24:032f3683cb2a 5190 }
whismanoid 33:70a28cfe9e01 5191 } // end if (command_table_row_count > 0)
whismanoid 33:70a28cfe9e01 5192 if ((editRowIndex == command_table_row_count) && (command_table_row_count < COMMAND_TABLE_ROW_MAX)) {
whismanoid 33:70a28cfe9e01 5193 // %B1@nnn command add new row (even though this looks like a replace command) if and only if nnn==next new unassigned line number
whismanoid 33:70a28cfe9e01 5194 //
whismanoid 33:70a28cfe9e01 5195 command_table_row_count++;
whismanoid 33:70a28cfe9e01 5196 cmdLine.serial().printf("\r\n add next row %d containing \"%s\"",
whismanoid 33:70a28cfe9e01 5197 editRowIndex, cmdLine.str()+argIndex);
whismanoid 33:70a28cfe9e01 5198 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 33:70a28cfe9e01 5199 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 33:70a28cfe9e01 5200 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 33:70a28cfe9e01 5201 //
whismanoid 23:c6c652bef4b9 5202 }
whismanoid 33:70a28cfe9e01 5203 //
whismanoid 23:c6c652bef4b9 5204 break;
whismanoid 23:c6c652bef4b9 5205 case '+':
whismanoid 24:032f3683cb2a 5206 // %B1@+ command add new row (if there is room to add)
whismanoid 23:c6c652bef4b9 5207 // add a new row at end of table
whismanoid 23:c6c652bef4b9 5208 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 5209 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 23:c6c652bef4b9 5210 editRowIndex = command_table_row_count;
whismanoid 28:a9a3a9db592b 5211 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 5212 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 5213 cmdLine.serial().printf("\r\n cannot add new row %d containing nothing",
whismanoid 28:a9a3a9db592b 5214 editRowIndex);
whismanoid 28:a9a3a9db592b 5215 }
whismanoid 28:a9a3a9db592b 5216 else
whismanoid 28:a9a3a9db592b 5217 {
whismanoid 28:a9a3a9db592b 5218 command_table_row_count++;
whismanoid 28:a9a3a9db592b 5219 cmdLine.serial().printf("\r\n add new row %d containing \"%s\"",
whismanoid 28:a9a3a9db592b 5220 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 5221 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 5222 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 5223 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 28:a9a3a9db592b 5224 }
whismanoid 23:c6c652bef4b9 5225 }
whismanoid 23:c6c652bef4b9 5226 break;
whismanoid 23:c6c652bef4b9 5227 case '-':
whismanoid 24:032f3683cb2a 5228 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 5229 // delete row from table
whismanoid 23:c6c652bef4b9 5230 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 5231 // if command_table_row_count == 0 then the table is empty
whismanoid 23:c6c652bef4b9 5232 if ((cmdLine[5] == '~') && (cmdLine[6] == '~') && (cmdLine[7] == '~')) {
whismanoid 23:c6c652bef4b9 5233 // %B1@-~~~ clear entire command table
whismanoid 24:032f3683cb2a 5234 cmdLine.serial().printf("\r\n clear entire command table");
whismanoid 23:c6c652bef4b9 5235 command_table_row_count = 0;
whismanoid 28:a9a3a9db592b 5236 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 23:c6c652bef4b9 5237 break;
whismanoid 23:c6c652bef4b9 5238 }
whismanoid 24:032f3683cb2a 5239 else
whismanoid 23:c6c652bef4b9 5240 {
whismanoid 24:032f3683cb2a 5241 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 24:032f3683cb2a 5242 editRowIndex = atoi(cmdLine.str()+5);
whismanoid 24:032f3683cb2a 5243 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 24:032f3683cb2a 5244 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 24:032f3683cb2a 5245 // delete row editRowIndex from Datalogger_action_table
whismanoid 24:032f3683cb2a 5246 for (int i = editRowIndex; i < (command_table_row_count-1); i++)
whismanoid 24:032f3683cb2a 5247 {
whismanoid 24:032f3683cb2a 5248 // copy row i+1 into row i
whismanoid 24:032f3683cb2a 5249 cmdLine.serial().printf("\r\n copy row %d into row %d: \"%s\"",
whismanoid 24:032f3683cb2a 5250 i+1, i, command_table[i+1]);
whismanoid 24:032f3683cb2a 5251 strncpy(command_table[i], command_table[i+1], COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 5252 command_table[i][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 24:032f3683cb2a 5253 }
whismanoid 24:032f3683cb2a 5254 command_table_row_count--;
whismanoid 28:a9a3a9db592b 5255 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 24:032f3683cb2a 5256 }
whismanoid 23:c6c652bef4b9 5257 }
whismanoid 23:c6c652bef4b9 5258 }
whismanoid 23:c6c652bef4b9 5259 break;
whismanoid 30:07197a430869 5260 case '.': // something other than ! because %B1! means trigger event
whismanoid 30:07197a430869 5261 // pause the button event
whismanoid 30:07197a430869 5262 // TODO: %B1@. disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 5263 //~ Datalogger_action_table_enabled = false;
whismanoid 23:c6c652bef4b9 5264 break;
whismanoid 23:c6c652bef4b9 5265 case '@':
whismanoid 30:07197a430869 5266 // enable the button event
whismanoid 23:c6c652bef4b9 5267 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 5268 //~ Datalogger_action_table_enabled = true;
whismanoid 23:c6c652bef4b9 5269 break;
whismanoid 23:c6c652bef4b9 5270 }
whismanoid 23:c6c652bef4b9 5271 //
whismanoid 23:c6c652bef4b9 5272 // Print the contents of command_table
whismanoid 23:c6c652bef4b9 5273 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 5274 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 5275 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 5276 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 5277 cmdLine.serial().printf("\r\n %%B%1d@%d %s",
whismanoid 24:032f3683cb2a 5278 command_table_button_index,
whismanoid 24:032f3683cb2a 5279 lineIndex,
whismanoid 24:032f3683cb2a 5280 command_table[lineIndex]);
whismanoid 23:c6c652bef4b9 5281 }
whismanoid 30:07197a430869 5282 //~ cmdLine.serial().printf("\r\n command_table_row_count = %d/%d",
whismanoid 30:07197a430869 5283 //~ command_table_row_count, COMMAND_TABLE_ROW_MAX);
whismanoid 30:07197a430869 5284 cmdLine.serial().printf("\r\n\r\nEdit Button%d event (used %d/%d, %d free):",
whismanoid 30:07197a430869 5285 command_table_button_index,
whismanoid 30:07197a430869 5286 command_table_row_count,
whismanoid 30:07197a430869 5287 COMMAND_TABLE_ROW_MAX,
whismanoid 30:07197a430869 5288 (COMMAND_TABLE_ROW_MAX - command_table_row_count)
whismanoid 30:07197a430869 5289 );
whismanoid 23:c6c652bef4b9 5290 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 5291 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 24:032f3683cb2a 5292 cmdLine.serial().printf("\r\n %%B%1d@+ command -- add new row %d at end of table",
whismanoid 24:032f3683cb2a 5293 command_table_button_index,
whismanoid 24:032f3683cb2a 5294 command_table_row_count);
whismanoid 23:c6c652bef4b9 5295 }
whismanoid 23:c6c652bef4b9 5296 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 5297 // if command_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 5298 cmdLine.serial().printf("\r\n %%B%1d@%d command -- replace row %d",
whismanoid 24:032f3683cb2a 5299 command_table_button_index,
whismanoid 23:c6c652bef4b9 5300 command_table_row_count-1,
whismanoid 23:c6c652bef4b9 5301 command_table_row_count-1);
whismanoid 24:032f3683cb2a 5302 cmdLine.serial().printf("\r\n %%B%1d@-%d -- delete row %d",
whismanoid 24:032f3683cb2a 5303 command_table_button_index,
whismanoid 24:032f3683cb2a 5304 command_table_row_count-1,
whismanoid 24:032f3683cb2a 5305 command_table_row_count-1);
whismanoid 24:032f3683cb2a 5306 cmdLine.serial().printf("\r\n %%B%1d@-~~~ -- delete all rows",
whismanoid 24:032f3683cb2a 5307 command_table_button_index);
whismanoid 30:07197a430869 5308 //~ cmdLine.serial().printf("\r\n %%B%1d@. -- pause entire command table",
whismanoid 30:07197a430869 5309 //~ command_table_button_index);
whismanoid 30:07197a430869 5310 //~ cmdLine.serial().printf("\r\n %%B%1d@@ -- enable command table",
whismanoid 30:07197a430869 5311 //~ command_table_button_index);
whismanoid 30:07197a430869 5312 cmdLine.serial().printf("\r\n %%B%1d! -- trigger Button%d event",
whismanoid 30:07197a430869 5313 command_table_button_index,
whismanoid 24:032f3683cb2a 5314 command_table_button_index);
whismanoid 23:c6c652bef4b9 5315 }
whismanoid 23:c6c652bef4b9 5316 //
whismanoid 23:c6c652bef4b9 5317 } // case '@' -- %B1@ view/edit command table
whismanoid 23:c6c652bef4b9 5318 break;
whismanoid 23:c6c652bef4b9 5319 case '!':
whismanoid 23:c6c652bef4b9 5320 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 23:c6c652bef4b9 5321 Run_command_table(command_table);
whismanoid 23:c6c652bef4b9 5322 break;
whismanoid 23:c6c652bef4b9 5323 }
whismanoid 23:c6c652bef4b9 5324 }
whismanoid 23:c6c652bef4b9 5325 break;
whismanoid 23:c6c652bef4b9 5326 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 5327 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 5328 #if HAS_digitalInOuts
whismanoid 15:37c83ec50ea0 5329 case 'H': case 'h':
whismanoid 15:37c83ec50ea0 5330 {
whismanoid 15:37c83ec50ea0 5331 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 5332 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 5333 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 5334 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 5335 #else
whismanoid 15:37c83ec50ea0 5336 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 5337 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 5338 digitalInOutPin.write(1);
whismanoid 15:37c83ec50ea0 5339 #endif
whismanoid 15:37c83ec50ea0 5340 cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex);
whismanoid 15:37c83ec50ea0 5341 }
whismanoid 15:37c83ec50ea0 5342 break;
whismanoid 15:37c83ec50ea0 5343 case 'L': case 'l':
whismanoid 15:37c83ec50ea0 5344 {
whismanoid 15:37c83ec50ea0 5345 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 5346 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 5347 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 5348 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 5349 #else
whismanoid 15:37c83ec50ea0 5350 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 5351 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 5352 digitalInOutPin.write(0);
whismanoid 15:37c83ec50ea0 5353 #endif
whismanoid 15:37c83ec50ea0 5354 cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex);
whismanoid 15:37c83ec50ea0 5355 }
whismanoid 15:37c83ec50ea0 5356 break;
whismanoid 15:37c83ec50ea0 5357 case '?':
whismanoid 15:37c83ec50ea0 5358 {
whismanoid 15:37c83ec50ea0 5359 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 5360 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 5361 pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 5362 #else
whismanoid 15:37c83ec50ea0 5363 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 5364 digitalInOutPin.input();
whismanoid 15:37c83ec50ea0 5365 #endif
whismanoid 15:37c83ec50ea0 5366 serial.printf(" digitalInOutPin %d Input ", pinIndex);
whismanoid 15:37c83ec50ea0 5367 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 5368 int value = digitalRead(pinIndex);
whismanoid 15:37c83ec50ea0 5369 #else
whismanoid 15:37c83ec50ea0 5370 int value = digitalInOutPin.read();
whismanoid 15:37c83ec50ea0 5371 #endif
whismanoid 15:37c83ec50ea0 5372 cmdLine.serial().printf("%d ", value);
whismanoid 15:37c83ec50ea0 5373 }
whismanoid 15:37c83ec50ea0 5374 break;
whismanoid 15:37c83ec50ea0 5375 #endif
whismanoid 15:37c83ec50ea0 5376 //
whismanoid 15:37c83ec50ea0 5377 #if HAS_analogIns
whismanoid 15:37c83ec50ea0 5378 case 'A': case 'a':
whismanoid 15:37c83ec50ea0 5379 {
whismanoid 15:37c83ec50ea0 5380 // %A %Apin -- analog input
whismanoid 37:3f369235e5bc 5381 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5382 // %A avg= -- set Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 5383 if (cmdLine.parse_int_dec("avg", Platform_AIN_Average_N))
whismanoid 37:3f369235e5bc 5384 {
whismanoid 37:3f369235e5bc 5385 // Platform_AIN_Average_N was updated
whismanoid 37:3f369235e5bc 5386 }
whismanoid 37:3f369235e5bc 5387 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5388 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5389 // %A cal? view/export raw calibration values for all channels
whismanoid 34:a1993a1ee904 5390 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5391 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5392 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5393 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5394 {
whismanoid 34:a1993a1ee904 5395 char valueBuf[16];
whismanoid 34:a1993a1ee904 5396 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 5397 if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 5398 {
whismanoid 34:a1993a1ee904 5399 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5400 {
whismanoid 34:a1993a1ee904 5401 cmdLine.serial().printf(" %%A cal%dn=%1.9f cal%dv=%1.9fV cal%dn=%1.9f cal%dv=%1.9fV\r\n",
whismanoid 34:a1993a1ee904 5402 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 5403 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 5404 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 5405 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 5406 );
whismanoid 34:a1993a1ee904 5407 }
whismanoid 34:a1993a1ee904 5408 //
whismanoid 34:a1993a1ee904 5409 // print extended help for %A
whismanoid 34:a1993a1ee904 5410 // %A cal0n=0.02 cal0v=0.123 cal0n=0.938 cal0v=1.132 edit/import raw calibration values for any/all channels
whismanoid 34:a1993a1ee904 5411 //~ cmdLine.serial().printf("\r\n %%A cal0n=0.02 cal0v=0.123 cal0n=0.938 cal0v=1.132 -- update calibration");
whismanoid 34:a1993a1ee904 5412 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 5413 cmdLine.serial().printf(" %%A cal0test=0.5 -- calculate voltage at 50%% of full scale");
whismanoid 49:359a6b9df7c1 5414 // #350 MAX40108 %A vl#cal / vh#cal / v#copy=
whismanoid 49:359a6b9df7c1 5415 // cmdLine.serial().printf("\r\n %%A v0cal=1.000V -- calibrate channel against a known input voltage");
whismanoid 49:359a6b9df7c1 5416 cmdLine.serial().printf("\r\n %%A v0cal=1.000V | vl5cal=0.800V | vh5cal=1.600V -- calibrate input voltage");
whismanoid 49:359a6b9df7c1 5417 cmdLine.serial().printf("\r\n %%A v4copy=5 -- copy calibration from other channel");
whismanoid 34:a1993a1ee904 5418 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 5419 cmdLine.serial().printf("\r\n %%A calreset -- reset all calibration data");
whismanoid 37:3f369235e5bc 5420 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5421 // %A avg=%d -- help string display Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 5422 cmdLine.serial().printf("\r\n %%A avg=%d -- average", Platform_AIN_Average_N);
whismanoid 37:3f369235e5bc 5423 #endif // USE_Platform_AIN_Average
whismanoid 48:18647e0516f2 5424 #ifdef BOARD_SERIAL_NUMBER
whismanoid 48:18647e0516f2 5425 // %A sn= set g_board_serial_number ; use with %F save during calibration #312
whismanoid 49:359a6b9df7c1 5426 cmdLine.serial().printf("\r\n %%A sn=%ld -- serial number", g_board_serial_number);
whismanoid 48:18647e0516f2 5427 #endif // BOARD_SERIAL_NUMBER
whismanoid 34:a1993a1ee904 5428 cmdLine.serial().printf("\r\n\r\n");
whismanoid 34:a1993a1ee904 5429 //
whismanoid 34:a1993a1ee904 5430 } // end if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 5431 }
whismanoid 34:a1993a1ee904 5432 #endif // HAS_Platform_AIN_Calibration
whismanoid 48:18647e0516f2 5433 #ifdef BOARD_SERIAL_NUMBER
whismanoid 48:18647e0516f2 5434 {
whismanoid 48:18647e0516f2 5435 // %A sn= set g_board_serial_number ; use with %F save during calibration #312
whismanoid 48:18647e0516f2 5436 if (cmdLine.parse_uint32_dec("sn", g_board_serial_number))
whismanoid 48:18647e0516f2 5437 {
whismanoid 48:18647e0516f2 5438 }
whismanoid 48:18647e0516f2 5439 }
whismanoid 48:18647e0516f2 5440 #endif // BOARD_SERIAL_NUMBER
whismanoid 34:a1993a1ee904 5441 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5442 {
whismanoid 34:a1993a1ee904 5443 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 5444 char valueBuf[16];
whismanoid 34:a1993a1ee904 5445 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 5446 if (cmdLine.parse_and_remove_key("calreset", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 5447 {
whismanoid 34:a1993a1ee904 5448 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 5449 calibration_05_normValue_0_1[0] = 0.25; calibration_05_V[0] = 0.3;
whismanoid 34:a1993a1ee904 5450 calibration_05_normValue_0_1[1] = 0.25; calibration_05_V[1] = 0.3;
whismanoid 34:a1993a1ee904 5451 calibration_05_normValue_0_1[2] = 0.25; calibration_05_V[2] = 0.3;
whismanoid 34:a1993a1ee904 5452 calibration_05_normValue_0_1[3] = 0.25; calibration_05_V[3] = 0.3;
whismanoid 34:a1993a1ee904 5453 calibration_05_normValue_0_1[4] = 0.25; calibration_05_V[4] = 1.5;
whismanoid 34:a1993a1ee904 5454 calibration_05_normValue_0_1[5] = 0.25; calibration_05_V[5] = 1.5;
whismanoid 34:a1993a1ee904 5455 //
whismanoid 34:a1993a1ee904 5456 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 5457 calibration_95_normValue_0_1[0] = 0.75; calibration_95_V[0] = 0.9;
whismanoid 34:a1993a1ee904 5458 calibration_95_normValue_0_1[1] = 0.75; calibration_95_V[1] = 0.9;
whismanoid 34:a1993a1ee904 5459 calibration_95_normValue_0_1[2] = 0.75; calibration_95_V[2] = 0.9;
whismanoid 34:a1993a1ee904 5460 calibration_95_normValue_0_1[3] = 0.75; calibration_95_V[3] = 0.9;
whismanoid 34:a1993a1ee904 5461 calibration_95_normValue_0_1[4] = 0.75; calibration_95_V[4] = 4.5;
whismanoid 34:a1993a1ee904 5462 calibration_95_normValue_0_1[5] = 0.75; calibration_95_V[5] = 4.5;
whismanoid 34:a1993a1ee904 5463 //
whismanoid 34:a1993a1ee904 5464 }
whismanoid 34:a1993a1ee904 5465 }
whismanoid 34:a1993a1ee904 5466 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5467 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5468 // %A cal0n=0.02 cal0v=0.123 cal0n=0.938 cal0v=1.132 edit/import raw calibration values for any/all channels
whismanoid 35:c9549b5c01de 5469 // %A cal4n=0.135874882 cal4v=0.800000012V cal4n=0.286168128 cal4v=1.700000048V
whismanoid 34:a1993a1ee904 5470 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5471 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5472 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5473 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5474 {
whismanoid 34:a1993a1ee904 5475 double normValue_0_1, V;
whismanoid 34:a1993a1ee904 5476 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5477 {
whismanoid 34:a1993a1ee904 5478 static char key_can0n[8] = "cal0n__";
whismanoid 34:a1993a1ee904 5479 sprintf(key_can0n, "cal%1dn", ch);
whismanoid 34:a1993a1ee904 5480 static char key_cal0v[8] = "cal0v__";
whismanoid 34:a1993a1ee904 5481 sprintf(key_cal0v, "cal%1dv", ch);
whismanoid 35:c9549b5c01de 5482 // first point could be the 5% point or the 95% point
whismanoid 35:c9549b5c01de 5483 double norm_threshold = (calibration_05_normValue_0_1[ch] + calibration_95_normValue_0_1[ch]) / 2.0;
whismanoid 35:c9549b5c01de 5484 bool updated_05 = false;
whismanoid 35:c9549b5c01de 5485 //~ bool updated_95 = false;
whismanoid 35:c9549b5c01de 5486 if (cmdLine.parse_double(key_can0n, normValue_0_1)) {
whismanoid 34:a1993a1ee904 5487 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 34:a1993a1ee904 5488 {
whismanoid 35:c9549b5c01de 5489 if (normValue_0_1 < norm_threshold) {
whismanoid 35:c9549b5c01de 5490 // store first calibration point in the 5% slot
whismanoid 35:c9549b5c01de 5491 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 5492 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 5493 updated_05 = true;
whismanoid 34:a1993a1ee904 5494 }
whismanoid 34:a1993a1ee904 5495 else {
whismanoid 35:c9549b5c01de 5496 // store first calibration point in the 95% slot
whismanoid 35:c9549b5c01de 5497 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 5498 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 5499 //~ updated_95 = true;
whismanoid 34:a1993a1ee904 5500 }
whismanoid 34:a1993a1ee904 5501 }
whismanoid 35:c9549b5c01de 5502 }
whismanoid 35:c9549b5c01de 5503 // handle the optional second calibration point
whismanoid 35:c9549b5c01de 5504 if (cmdLine.parse_double(key_can0n, normValue_0_1))
whismanoid 35:c9549b5c01de 5505 {
whismanoid 35:c9549b5c01de 5506 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 35:c9549b5c01de 5507 {
whismanoid 35:c9549b5c01de 5508 if (updated_05) {
whismanoid 35:c9549b5c01de 5509 // we already stored the first point here
whismanoid 35:c9549b5c01de 5510 // calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5511 // calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 5512 // store the second point in the other slot
whismanoid 35:c9549b5c01de 5513 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5514 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 5515 }
whismanoid 35:c9549b5c01de 5516 else {
whismanoid 35:c9549b5c01de 5517 // we already stored the first point here
whismanoid 35:c9549b5c01de 5518 // calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5519 // calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 5520 // store the second point in the other slot
whismanoid 35:c9549b5c01de 5521 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5522 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 5523 }
whismanoid 35:c9549b5c01de 5524 }
whismanoid 35:c9549b5c01de 5525 }
whismanoid 38:fda80a0020d1 5526 // make sure calibration_05_normValue_0_1[ch] < calibration_95_normValue_0_1[ch]
whismanoid 38:fda80a0020d1 5527 if (calibration_05_normValue_0_1[ch] > calibration_95_normValue_0_1[ch])
whismanoid 38:fda80a0020d1 5528 {
whismanoid 38:fda80a0020d1 5529 // swap to make sure calibration_05_normValue_0_1[ch] < calibration_95_normValue_0_1[ch]
whismanoid 38:fda80a0020d1 5530 double n05 = calibration_95_normValue_0_1[ch];
whismanoid 38:fda80a0020d1 5531 double V05 = calibration_95_V[ch];
whismanoid 38:fda80a0020d1 5532 double n95 = calibration_05_normValue_0_1[ch];
whismanoid 38:fda80a0020d1 5533 double V95 = calibration_05_V[ch];
whismanoid 38:fda80a0020d1 5534 calibration_05_normValue_0_1[ch] = n05;
whismanoid 38:fda80a0020d1 5535 calibration_05_V[ch] = V05;
whismanoid 38:fda80a0020d1 5536 calibration_95_normValue_0_1[ch] = n95;
whismanoid 38:fda80a0020d1 5537 calibration_95_V[ch] = V95;
whismanoid 38:fda80a0020d1 5538 }
whismanoid 34:a1993a1ee904 5539 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5540 }
whismanoid 34:a1993a1ee904 5541 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5542 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5543 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 5544 // double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 5545 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5546 {
whismanoid 34:a1993a1ee904 5547 static char key_cal0test[12] = "cal0test__";
whismanoid 34:a1993a1ee904 5548 sprintf(key_cal0test, "cal%1dtest", ch);
whismanoid 34:a1993a1ee904 5549 double normValue_0_1, Vtest;
whismanoid 34:a1993a1ee904 5550 if (cmdLine.parse_double(key_cal0test, Vtest))
whismanoid 34:a1993a1ee904 5551 {
whismanoid 34:a1993a1ee904 5552 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 5553 normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 5554 //
whismanoid 34:a1993a1ee904 5555 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 5556 ch,
whismanoid 34:a1993a1ee904 5557 normValue_0_1,
whismanoid 34:a1993a1ee904 5558 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 5559 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5560 );
whismanoid 34:a1993a1ee904 5561 //
whismanoid 34:a1993a1ee904 5562 // sweep CalibratedNormValue argument
whismanoid 34:a1993a1ee904 5563 double normValue_0_1_start = -0.05;
whismanoid 34:a1993a1ee904 5564 double normValue_0_1_step = 0.05;
whismanoid 34:a1993a1ee904 5565 double normValue_0_1_end = 1.07;
whismanoid 34:a1993a1ee904 5566 for (normValue_0_1 = normValue_0_1_start;
whismanoid 34:a1993a1ee904 5567 normValue_0_1 <= normValue_0_1_end;
whismanoid 34:a1993a1ee904 5568 normValue_0_1 = normValue_0_1 + normValue_0_1_step)
whismanoid 34:a1993a1ee904 5569 {
whismanoid 34:a1993a1ee904 5570 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 5571 ch,
whismanoid 34:a1993a1ee904 5572 normValue_0_1,
whismanoid 34:a1993a1ee904 5573 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 5574 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5575 );
whismanoid 34:a1993a1ee904 5576 }
whismanoid 34:a1993a1ee904 5577 }
whismanoid 34:a1993a1ee904 5578 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5579 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5580 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5581 // %A v0cal=1.000V -- calibrate channel against a known input voltage
whismanoid 34:a1993a1ee904 5582 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5583 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5584 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5585 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5586 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5587 {
whismanoid 49:359a6b9df7c1 5588 // #350 MAX40108 %A vl#cal / vh#cal / v#copy=
whismanoid 49:359a6b9df7c1 5589 static char key_v0cal[10] = "v0cal__"; // v#cal=Vtest
whismanoid 49:359a6b9df7c1 5590 sprintf(key_v0cal, "v%1dcal", ch); // v#cal=Vtest
whismanoid 49:359a6b9df7c1 5591 static char key_vl0cal[10] = "vl0cal__"; // vl#cal=Vtest
whismanoid 49:359a6b9df7c1 5592 sprintf(key_vl0cal, "vl%1dcal", ch); // vl#cal=Vtest
whismanoid 49:359a6b9df7c1 5593 static char key_vh0cal[10] = "vh0cal__"; // vh#cal=Vtest
whismanoid 49:359a6b9df7c1 5594 sprintf(key_vh0cal, "vh%1dcal", ch); // vh#cal=Vtest
whismanoid 49:359a6b9df7c1 5595 static char key_v0copy[10] = "v0copy__"; // v#copy=srcChannel
whismanoid 49:359a6b9df7c1 5596 sprintf(key_v0copy, "v%1dcopy", ch); // v#copy=srcChannel
whismanoid 34:a1993a1ee904 5597 double Vtest;
whismanoid 49:359a6b9df7c1 5598 int srcChannel = 0;
whismanoid 49:359a6b9df7c1 5599 char calibration_command = '\0';
whismanoid 34:a1993a1ee904 5600 if (cmdLine.parse_double(key_v0cal, Vtest))
whismanoid 34:a1993a1ee904 5601 {
whismanoid 49:359a6b9df7c1 5602 // v#cal=Vtest: update calibration_05 or calibration_95
whismanoid 49:359a6b9df7c1 5603 calibration_command = 'V';
whismanoid 49:359a6b9df7c1 5604 }
whismanoid 49:359a6b9df7c1 5605 else if (cmdLine.parse_double(key_vl0cal, Vtest))
whismanoid 49:359a6b9df7c1 5606 {
whismanoid 49:359a6b9df7c1 5607 // vl#cal=Vtest: update calibration_05
whismanoid 49:359a6b9df7c1 5608 calibration_command = 'L';
whismanoid 49:359a6b9df7c1 5609 }
whismanoid 49:359a6b9df7c1 5610 else if (cmdLine.parse_double(key_vh0cal, Vtest))
whismanoid 49:359a6b9df7c1 5611 {
whismanoid 49:359a6b9df7c1 5612 // vh#cal=Vtest: update calibration_95
whismanoid 49:359a6b9df7c1 5613 calibration_command = 'H';
whismanoid 49:359a6b9df7c1 5614 }
whismanoid 49:359a6b9df7c1 5615 else if (cmdLine.parse_int_dec(key_v0copy, srcChannel))
whismanoid 49:359a6b9df7c1 5616 {
whismanoid 49:359a6b9df7c1 5617 // v#copy=srcChannel
whismanoid 49:359a6b9df7c1 5618 // update calibration_05 and calibration_95 from other channel
whismanoid 49:359a6b9df7c1 5619 calibration_command = '\0';
whismanoid 49:359a6b9df7c1 5620 calibration_05_normValue_0_1[ch] = calibration_05_normValue_0_1[srcChannel];
whismanoid 49:359a6b9df7c1 5621 calibration_05_V[ch] = calibration_05_V[srcChannel];
whismanoid 49:359a6b9df7c1 5622 calibration_95_normValue_0_1[ch] = calibration_95_normValue_0_1[srcChannel];
whismanoid 49:359a6b9df7c1 5623 calibration_95_V[ch] = calibration_95_V[srcChannel];
whismanoid 49:359a6b9df7c1 5624 // print updated calibration values
whismanoid 49:359a6b9df7c1 5625 cmdLine.serial().printf("\r\n");
whismanoid 49:359a6b9df7c1 5626 cmdLine.serial().printf(" %%A cal%dn=%1.9f cal%dv=%1.9fV cal%dn=%1.9f cal%dv=%1.9fV\r\n",
whismanoid 49:359a6b9df7c1 5627 ch, calibration_05_normValue_0_1[ch],
whismanoid 49:359a6b9df7c1 5628 ch, calibration_05_V[ch],
whismanoid 49:359a6b9df7c1 5629 ch, calibration_95_normValue_0_1[ch],
whismanoid 49:359a6b9df7c1 5630 ch, calibration_95_V[ch]
whismanoid 49:359a6b9df7c1 5631 );
whismanoid 49:359a6b9df7c1 5632 }
whismanoid 49:359a6b9df7c1 5633 if (calibration_command != '\0')
whismanoid 49:359a6b9df7c1 5634 {
whismanoid 34:a1993a1ee904 5635 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 5636 double Vtest_normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 5637 //
whismanoid 34:a1993a1ee904 5638 // %A v0cal=1.000 calibrate one channel by measuring against a known input voltage
whismanoid 34:a1993a1ee904 5639 //
whismanoid 34:a1993a1ee904 5640 cmdLine.serial().printf("\r\n Measuring against input voltage of %1.6fV...", Vtest);
whismanoid 37:3f369235e5bc 5641 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5642 const int numberOfMeasurements = 16 * Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5643 #else // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5644 const int numberOfMeasurements = 16;
whismanoid 37:3f369235e5bc 5645 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5646 double Sx_measure_normValue_0_1 = 0; // sum of values
whismanoid 34:a1993a1ee904 5647 double Sxx_measure_normValue_0_1 = 0; // sum of the squares of the values
whismanoid 34:a1993a1ee904 5648 for (int count = 0; count < numberOfMeasurements; count++)
whismanoid 34:a1993a1ee904 5649 {
whismanoid 34:a1993a1ee904 5650 double measure_normValue_0_1;
whismanoid 34:a1993a1ee904 5651 switch(ch)
whismanoid 34:a1993a1ee904 5652 {
whismanoid 34:a1993a1ee904 5653 case 0: measure_normValue_0_1 = analogIn0.read(); break;
whismanoid 34:a1993a1ee904 5654 case 1: measure_normValue_0_1 = analogIn1.read(); break;
whismanoid 34:a1993a1ee904 5655 case 2: measure_normValue_0_1 = analogIn2.read(); break;
whismanoid 34:a1993a1ee904 5656 case 3: measure_normValue_0_1 = analogIn3.read(); break;
whismanoid 34:a1993a1ee904 5657 case 4: measure_normValue_0_1 = analogIn4.read(); break;
whismanoid 34:a1993a1ee904 5658 case 5: measure_normValue_0_1 = analogIn5.read(); break;
whismanoid 34:a1993a1ee904 5659 }
whismanoid 34:a1993a1ee904 5660 Sx_measure_normValue_0_1 = Sx_measure_normValue_0_1 + measure_normValue_0_1;
whismanoid 34:a1993a1ee904 5661 Sxx_measure_normValue_0_1 = Sxx_measure_normValue_0_1 + (measure_normValue_0_1 * measure_normValue_0_1);
whismanoid 38:fda80a0020d1 5662 if ((count < 3) || (count >= numberOfMeasurements - 3)) {
whismanoid 38:fda80a0020d1 5663 cmdLine.serial().printf("\r\n raw: %7.6f%% = %1.6fV",
whismanoid 38:fda80a0020d1 5664 measure_normValue_0_1 * 100.0,
whismanoid 38:fda80a0020d1 5665 (measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 38:fda80a0020d1 5666 );
whismanoid 38:fda80a0020d1 5667 }
whismanoid 34:a1993a1ee904 5668 }
whismanoid 34:a1993a1ee904 5669 cmdLine.serial().printf("\r\n numberOfMeasurements = %d", numberOfMeasurements);
whismanoid 34:a1993a1ee904 5670 cmdLine.serial().printf("\r\n Sx_measure_normValue_0_1 = %1.6f", Sx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 5671 cmdLine.serial().printf("\r\n Sxx_measure_normValue_0_1 = %1.6f", Sxx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 5672 //
whismanoid 34:a1993a1ee904 5673 // calculate mean_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 5674 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 5675 double mean_measure_normValue_0_1 = Sx_measure_normValue_0_1 / numberOfMeasurements;
whismanoid 34:a1993a1ee904 5676 cmdLine.serial().printf("\r\n mean = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 5677 mean_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 5678 (mean_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5679 );
whismanoid 34:a1993a1ee904 5680 //
whismanoid 34:a1993a1ee904 5681 // TODO: calculate sample variance_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 5682 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 5683 // variance_measure_normValue_0_1 = (Sxx - ( Sx * Sx / nWords) ) / (nWords - 1);
whismanoid 34:a1993a1ee904 5684 double variance_measure_normValue_0_1 = (Sxx_measure_normValue_0_1 - ( Sx_measure_normValue_0_1 * Sx_measure_normValue_0_1 / numberOfMeasurements) ) / (numberOfMeasurements - 1);
whismanoid 34:a1993a1ee904 5685 cmdLine.serial().printf("\r\n variance = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 5686 variance_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 5687 (variance_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5688 );
whismanoid 34:a1993a1ee904 5689 //
whismanoid 34:a1993a1ee904 5690 // calculate sample stddev_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 5691 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 5692 double stddev_measure_normValue_0_1 = sqrt(variance_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 5693 cmdLine.serial().printf("\r\n stddev = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 5694 stddev_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 5695 (stddev_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5696 );
whismanoid 34:a1993a1ee904 5697 //
whismanoid 34:a1993a1ee904 5698 // Validate the measurements:
whismanoid 34:a1993a1ee904 5699 // is the mean near the expected value?
whismanoid 34:a1993a1ee904 5700 // is the standard deviation not too high?
whismanoid 34:a1993a1ee904 5701 bool isCalibrationValid = true;
whismanoid 34:a1993a1ee904 5702 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) > 0.1) {
whismanoid 34:a1993a1ee904 5703 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 5704 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 5705 }
whismanoid 34:a1993a1ee904 5706 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) < -0.1) {
whismanoid 34:a1993a1ee904 5707 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 5708 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 5709 }
whismanoid 34:a1993a1ee904 5710 if ((stddev_measure_normValue_0_1) > 10) {
whismanoid 34:a1993a1ee904 5711 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 5712 cmdLine.serial().printf(" stddev too high.\r\n");
whismanoid 34:a1993a1ee904 5713 }
whismanoid 34:a1993a1ee904 5714 if (isCalibrationValid)
whismanoid 34:a1993a1ee904 5715 {
whismanoid 34:a1993a1ee904 5716 // update calibration point (mean_measure_normValue_0_1, Vtest)
whismanoid 49:359a6b9df7c1 5717 // #350 MAX40108 %A vl#cal / vh#cal / v#copy=
whismanoid 49:359a6b9df7c1 5718 switch(calibration_command)
whismanoid 49:359a6b9df7c1 5719 {
whismanoid 49:359a6b9df7c1 5720 case 'V': // v#cal=Vtest: update calibration_05 or calibration_95
whismanoid 49:359a6b9df7c1 5721 if (Vtest_normValue_0_1 < 0.5) {
whismanoid 49:359a6b9df7c1 5722 calibration_05_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 49:359a6b9df7c1 5723 calibration_05_V[ch] = Vtest;
whismanoid 49:359a6b9df7c1 5724 } else {
whismanoid 49:359a6b9df7c1 5725 calibration_95_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 49:359a6b9df7c1 5726 calibration_95_V[ch] = Vtest;
whismanoid 49:359a6b9df7c1 5727 }
whismanoid 49:359a6b9df7c1 5728 break;
whismanoid 49:359a6b9df7c1 5729 case 'L': // vl#cal=Vtest: update calibration_05
whismanoid 49:359a6b9df7c1 5730 calibration_05_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 49:359a6b9df7c1 5731 calibration_05_V[ch] = Vtest;
whismanoid 49:359a6b9df7c1 5732 break;
whismanoid 49:359a6b9df7c1 5733 case 'H': // vh#cal=Vtest: update calibration_95
whismanoid 49:359a6b9df7c1 5734 calibration_95_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 49:359a6b9df7c1 5735 calibration_95_V[ch] = Vtest;
whismanoid 49:359a6b9df7c1 5736 break;
whismanoid 34:a1993a1ee904 5737 }
whismanoid 34:a1993a1ee904 5738 //
whismanoid 34:a1993a1ee904 5739 // print updated calibration values
whismanoid 34:a1993a1ee904 5740 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 5741 cmdLine.serial().printf(" %%A cal%dn=%1.9f cal%dv=%1.9fV cal%dn=%1.9f cal%dv=%1.9fV\r\n",
whismanoid 34:a1993a1ee904 5742 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 5743 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 5744 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 5745 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 5746 );
whismanoid 34:a1993a1ee904 5747 // print corrected value of mean of measurements (should be close to Vtest)
whismanoid 34:a1993a1ee904 5748 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV vs %1.6fV\r\n",
whismanoid 34:a1993a1ee904 5749 ch,
whismanoid 34:a1993a1ee904 5750 mean_measure_normValue_0_1,
whismanoid 34:a1993a1ee904 5751 CalibratedNormValue(ch, mean_measure_normValue_0_1),
whismanoid 34:a1993a1ee904 5752 (CalibratedNormValue(ch, mean_measure_normValue_0_1) * adc_full_scale_voltage[ch]),
whismanoid 34:a1993a1ee904 5753 Vtest
whismanoid 34:a1993a1ee904 5754 );
whismanoid 34:a1993a1ee904 5755 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 5756 else {
whismanoid 34:a1993a1ee904 5757 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 5758 cmdLine.serial().printf(" Measurement Error: Calibration will not be updated.\r\n");
whismanoid 34:a1993a1ee904 5759 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 5760 } // end if key_v0cal
whismanoid 34:a1993a1ee904 5761 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5762 #endif // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 5763 // %A -- report analog input voltages
whismanoid 37:3f369235e5bc 5764 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5765 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5766 #endif // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5767 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 5768 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 15:37c83ec50ea0 5769 for (int pinIndex = 0; pinIndex < 2; pinIndex++)
whismanoid 15:37c83ec50ea0 5770 {
whismanoid 15:37c83ec50ea0 5771 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 5772 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 5773 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 5774 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5775 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5776 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5777 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 5778 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5779 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 5780 }
whismanoid 37:3f369235e5bc 5781 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5782 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5783 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 5784 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5785 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5786 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5787 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 5788 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5789 //
whismanoid 15:37c83ec50ea0 5790 int pinIndexH = pinIndex + 4;
whismanoid 15:37c83ec50ea0 5791 int cPinIndexH = '0' + pinIndexH;
whismanoid 15:37c83ec50ea0 5792 AnalogIn& analogInPinH = find_analogInPin(cPinIndexH);
whismanoid 15:37c83ec50ea0 5793 float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH];
whismanoid 37:3f369235e5bc 5794 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5795 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5796 // float normValueH_0_1 = analogInPinH.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5797 float normValueH_0_1 = 0;
whismanoid 37:3f369235e5bc 5798 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5799 normValueH_0_1 = normValueH_0_1 + analogInPinH.read();
whismanoid 37:3f369235e5bc 5800 }
whismanoid 37:3f369235e5bc 5801 normValueH_0_1 = normValueH_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5802 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5803 float normValueH_0_1 = analogInPinH.read();
whismanoid 37:3f369235e5bc 5804 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5805 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5806 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5807 normValueH_0_1 = CalibratedNormValue(pinIndex, normValueH_0_1);
whismanoid 34:a1993a1ee904 5808 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5809 //
whismanoid 37:3f369235e5bc 5810 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV high range A%c = %7.3f%% = %1.3fV \r\n",
whismanoid 15:37c83ec50ea0 5811 cPinIndex,
whismanoid 15:37c83ec50ea0 5812 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5813 normValue_0_1 * adc_full_scale_voltage,
whismanoid 15:37c83ec50ea0 5814 cPinIndexH,
whismanoid 15:37c83ec50ea0 5815 normValueH_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5816 normValueH_0_1 * adc_full_scale_voltageH
whismanoid 15:37c83ec50ea0 5817 );
whismanoid 15:37c83ec50ea0 5818 }
whismanoid 15:37c83ec50ea0 5819 for (int pinIndex = 2; pinIndex < 4; pinIndex++)
whismanoid 15:37c83ec50ea0 5820 {
whismanoid 15:37c83ec50ea0 5821 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 5822 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 5823 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 5824 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5825 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5826 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5827 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 5828 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5829 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 5830 }
whismanoid 37:3f369235e5bc 5831 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5832 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5833 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 5834 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5835 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5836 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5837 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 5838 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5839 //
whismanoid 37:3f369235e5bc 5840 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 5841 cPinIndex,
whismanoid 15:37c83ec50ea0 5842 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5843 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 5844 );
whismanoid 15:37c83ec50ea0 5845 }
whismanoid 15:37c83ec50ea0 5846 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 5847 // Platform board uses simple analog inputs
whismanoid 15:37c83ec50ea0 5848 // assume standard Arduino analog inputs A0-A5
whismanoid 15:37c83ec50ea0 5849 for (int pinIndex = 0; pinIndex < 6; pinIndex++)
whismanoid 15:37c83ec50ea0 5850 {
whismanoid 15:37c83ec50ea0 5851 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 5852 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 5853 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 5854 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5855 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5856 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5857 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 5858 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5859 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 5860 }
whismanoid 37:3f369235e5bc 5861 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5862 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5863 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 5864 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5865 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5866 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5867 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 5868 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5869 //
whismanoid 37:3f369235e5bc 5870 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 5871 cPinIndex,
whismanoid 15:37c83ec50ea0 5872 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5873 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 5874 );
whismanoid 15:37c83ec50ea0 5875 }
whismanoid 15:37c83ec50ea0 5876 #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 5877 }
whismanoid 15:37c83ec50ea0 5878 break;
whismanoid 15:37c83ec50ea0 5879 #endif
whismanoid 15:37c83ec50ea0 5880 //
whismanoid 15:37c83ec50ea0 5881 #if HAS_SPI2_MAX541
whismanoid 15:37c83ec50ea0 5882 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 5883 {
whismanoid 15:37c83ec50ea0 5884 // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV)
whismanoid 15:37c83ec50ea0 5885 // MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 15:37c83ec50ea0 5886 float voltageV = max541.Get_Voltage();
whismanoid 15:37c83ec50ea0 5887 // if (cmdLine[2] == '+') {
whismanoid 15:37c83ec50ea0 5888 // // %D+
whismanoid 15:37c83ec50ea0 5889 // voltageV = voltageV * 1.25f;
whismanoid 15:37c83ec50ea0 5890 // if (voltageV >= max541.VRef) voltageV = max541.VRef;
whismanoid 15:37c83ec50ea0 5891 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5892 // }
whismanoid 15:37c83ec50ea0 5893 // else if (cmdLine[2] == '-') {
whismanoid 15:37c83ec50ea0 5894 // // %D-
whismanoid 15:37c83ec50ea0 5895 // voltageV = voltageV * 0.75f;
whismanoid 15:37c83ec50ea0 5896 // if (voltageV < 0.1f) voltageV = 0.1f;
whismanoid 15:37c83ec50ea0 5897 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5898 // }
whismanoid 15:37c83ec50ea0 5899 if (cmdLine.parse_float("V", voltageV))
whismanoid 15:37c83ec50ea0 5900 {
whismanoid 15:37c83ec50ea0 5901 // %D V=1.234 -- set voltage
whismanoid 15:37c83ec50ea0 5902 max541.Set_Voltage(voltageV);
whismanoid 15:37c83ec50ea0 5903 }
whismanoid 15:37c83ec50ea0 5904 else if (cmdLine.parse_float("TEST", voltageV))
whismanoid 15:37c83ec50ea0 5905 {
whismanoid 15:37c83ec50ea0 5906 // %D TEST=1.234 -- set voltage and compare with AIN0
whismanoid 15:37c83ec50ea0 5907 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5908 }
whismanoid 15:37c83ec50ea0 5909 else if (cmdLine.parse_float("CAL", voltageV))
whismanoid 15:37c83ec50ea0 5910 {
whismanoid 15:37c83ec50ea0 5911 // %D CAL=1.234 -- calibrate VRef and compare with AIN0
whismanoid 15:37c83ec50ea0 5912
whismanoid 15:37c83ec50ea0 5913 max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
whismanoid 15:37c83ec50ea0 5914 double max541_midscale_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 5915 const int average_count = 100;
whismanoid 15:37c83ec50ea0 5916 const double average_K = 0.25;
whismanoid 15:37c83ec50ea0 5917 for (int count = 0; count < average_count; count++) {
whismanoid 15:37c83ec50ea0 5918 double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 5919 max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
whismanoid 15:37c83ec50ea0 5920 }
whismanoid 15:37c83ec50ea0 5921 max541.VRef = 2.0 * max541_midscale_V;
whismanoid 15:37c83ec50ea0 5922 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5923 "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
whismanoid 15:37c83ec50ea0 5924 max541_midscale_V, max541.VRef);
whismanoid 15:37c83ec50ea0 5925 // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
whismanoid 15:37c83ec50ea0 5926 voltageV = 1.0f;
whismanoid 15:37c83ec50ea0 5927 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5928 }
whismanoid 15:37c83ec50ea0 5929 else {
whismanoid 15:37c83ec50ea0 5930 // %D -- print MAX541 DAC status
whismanoid 15:37c83ec50ea0 5931 cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n",
whismanoid 15:37c83ec50ea0 5932 max541.Get_Code(), max541.Get_Voltage(), max541.VRef);
whismanoid 15:37c83ec50ea0 5933 }
whismanoid 15:37c83ec50ea0 5934 }
whismanoid 15:37c83ec50ea0 5935 break;
whismanoid 15:37c83ec50ea0 5936 #endif
whismanoid 15:37c83ec50ea0 5937
whismanoid 15:37c83ec50ea0 5938 //
whismanoid 15:37c83ec50ea0 5939 #if HAS_I2C // SUPPORT_I2C
whismanoid 15:37c83ec50ea0 5940 case 'I': case 'i':
whismanoid 15:37c83ec50ea0 5941 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 5942 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 5943 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 5944 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 5945 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 5946 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 5947 // get next character
whismanoid 15:37c83ec50ea0 5948 // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7
whismanoid 15:37c83ec50ea0 5949 cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7);
whismanoid 15:37c83ec50ea0 5950 // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count
whismanoid 15:37c83ec50ea0 5951 g_I2C_read_count = 0; // read count must be reset every command
whismanoid 15:37c83ec50ea0 5952 cmdLine.parse_byte_dec("RD", g_I2C_read_count);
whismanoid 15:37c83ec50ea0 5953 // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress
whismanoid 15:37c83ec50ea0 5954 cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress);
whismanoid 15:37c83ec50ea0 5955 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 5956 {
whismanoid 15:37c83ec50ea0 5957 case 'P': case 'p':
whismanoid 15:37c83ec50ea0 5958 {
whismanoid 15:37c83ec50ea0 5959 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 5960 HuntAttachedI2CDevices(cmdLine, 0x03, 0x77);
whismanoid 15:37c83ec50ea0 5961 }
whismanoid 15:37c83ec50ea0 5962 break;
whismanoid 15:37c83ec50ea0 5963 case 'C': case 'c':
whismanoid 15:37c83ec50ea0 5964 {
whismanoid 15:37c83ec50ea0 5965 bool isUpdatedI2CConfig = false;
whismanoid 15:37c83ec50ea0 5966 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 5967 // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz
whismanoid 15:37c83ec50ea0 5968 if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz))
whismanoid 15:37c83ec50ea0 5969 {
whismanoid 15:37c83ec50ea0 5970 isUpdatedI2CConfig = true;
whismanoid 15:37c83ec50ea0 5971 // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 5972 if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 5973 {
whismanoid 15:37c83ec50ea0 5974 g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 5975 }
whismanoid 15:37c83ec50ea0 5976 if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 5977 {
whismanoid 15:37c83ec50ea0 5978 g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 5979 }
whismanoid 15:37c83ec50ea0 5980 }
whismanoid 15:37c83ec50ea0 5981 if (isUpdatedI2CConfig)
whismanoid 15:37c83ec50ea0 5982 {
whismanoid 15:37c83ec50ea0 5983 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 5984 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 5985 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5986 i2cMaster.start();
whismanoid 15:37c83ec50ea0 5987 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 5988 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5989 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5990 "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 15:37c83ec50ea0 5991 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 15:37c83ec50ea0 5992 (g_I2C_SCL_Hz / 1000.));
whismanoid 15:37c83ec50ea0 5993 i2cMaster.start();
whismanoid 15:37c83ec50ea0 5994 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 5995 }
whismanoid 15:37c83ec50ea0 5996 }
whismanoid 15:37c83ec50ea0 5997 break;
whismanoid 15:37c83ec50ea0 5998 case 'W': case 'w':
whismanoid 15:37c83ec50ea0 5999 {
whismanoid 15:37c83ec50ea0 6000 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 6001 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 6002 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 6003 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 6004 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 6005 #define MAX_I2C_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 6006 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 6007 static char mosiData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 6008 static char misoData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 6009 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 6010 MAX_I2C_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 6011 {
whismanoid 15:37c83ec50ea0 6012 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 6013 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 6014 "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->",
whismanoid 15:37c83ec50ea0 6015 g_I2C_deviceAddress7,
whismanoid 15:37c83ec50ea0 6016 (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count);
whismanoid 15:37c83ec50ea0 6017 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 6018 {
whismanoid 15:37c83ec50ea0 6019 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 6020 }
whismanoid 15:37c83ec50ea0 6021 //
whismanoid 15:37c83ec50ea0 6022 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 6023 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 6024 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 6025 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 6026 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 6027 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 6028 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 6029 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 6030 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 6031 // /* int */ i2cMaster.transfer (int addr8bit, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, const event_callback_t &callback, int event=I2C_EVENT_TRANSFER_COMPLETE, bool repeated=false) // Start nonblocking I2C transfer. More...
whismanoid 15:37c83ec50ea0 6032 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 6033 const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 6034 unsigned int misoLength = 0;
whismanoid 15:37c83ec50ea0 6035 bool repeated = (g_I2C_read_count > 0);
whismanoid 15:37c83ec50ea0 6036 //
whismanoid 15:37c83ec50ea0 6037 int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated);
whismanoid 15:37c83ec50ea0 6038 switch (writeStatus)
whismanoid 15:37c83ec50ea0 6039 {
whismanoid 15:37c83ec50ea0 6040 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 6041 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 6042 default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 6043 writeStatus);
whismanoid 15:37c83ec50ea0 6044 }
whismanoid 15:37c83ec50ea0 6045 if (repeated)
whismanoid 15:37c83ec50ea0 6046 {
whismanoid 15:37c83ec50ea0 6047 int readStatus =
whismanoid 15:37c83ec50ea0 6048 i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false);
whismanoid 15:37c83ec50ea0 6049 switch (readStatus)
whismanoid 15:37c83ec50ea0 6050 {
whismanoid 15:37c83ec50ea0 6051 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 6052 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 6053 default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 6054 readStatus);
whismanoid 15:37c83ec50ea0 6055 }
whismanoid 15:37c83ec50ea0 6056 }
whismanoid 15:37c83ec50ea0 6057 //
whismanoid 15:37c83ec50ea0 6058 if (misoLength > 0)
whismanoid 15:37c83ec50ea0 6059 {
whismanoid 15:37c83ec50ea0 6060 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 6061 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 6062 for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count;
whismanoid 15:37c83ec50ea0 6063 byteIndex++)
whismanoid 15:37c83ec50ea0 6064 {
whismanoid 15:37c83ec50ea0 6065 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 6066 }
whismanoid 15:37c83ec50ea0 6067 }
whismanoid 15:37c83ec50ea0 6068 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 6069 }
whismanoid 15:37c83ec50ea0 6070 }
whismanoid 15:37c83ec50ea0 6071 break;
whismanoid 15:37c83ec50ea0 6072 case 'R': case 'r':
whismanoid 15:37c83ec50ea0 6073 {
whismanoid 15:37c83ec50ea0 6074 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 6075 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 6076 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 6077 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 6078 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 6079 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 6080 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 6081 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 6082 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 6083 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 6084 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 6085 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 6086 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 6087 // /* int */ i2cMaster.transfer (int addr8bit, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, const event_callback_t &callback, int event=I2C_EVENT_TRANSFER_COMPLETE, bool repeated=false) // Start nonblocking I2C transfer. More...
whismanoid 15:37c83ec50ea0 6088 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 6089 }
whismanoid 15:37c83ec50ea0 6090 break;
whismanoid 15:37c83ec50ea0 6091 case '^':
whismanoid 15:37c83ec50ea0 6092 {
whismanoid 15:37c83ec50ea0 6093 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 6094 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 6095 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 6096 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 6097 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 6098 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 6099 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 6100 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 6101 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 6102 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 6103 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 6104 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 6105 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 6106 // /* int */ i2cMaster.transfer (int addr8bit, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, const event_callback_t &callback, int event=I2C_EVENT_TRANSFER_COMPLETE, bool repeated=false) // Start nonblocking I2C transfer. More...
whismanoid 15:37c83ec50ea0 6107 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 6108 }
whismanoid 15:37c83ec50ea0 6109 break;
whismanoid 15:37c83ec50ea0 6110 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 6111 break;
whismanoid 15:37c83ec50ea0 6112 #endif
whismanoid 15:37c83ec50ea0 6113 //
whismanoid 15:37c83ec50ea0 6114 #if HAS_SPI // SUPPORT_SPI
whismanoid 15:37c83ec50ea0 6115 case 'S': case 's':
whismanoid 15:37c83ec50ea0 6116 {
whismanoid 15:37c83ec50ea0 6117 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 6118 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 6119 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 6120 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 6121 //
whismanoid 15:37c83ec50ea0 6122 // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d
whismanoid 15:37c83ec50ea0 6123 bool isUpdatedSPIConfig = false;
whismanoid 15:37c83ec50ea0 6124 // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2
whismanoid 15:37c83ec50ea0 6125 // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1
whismanoid 15:37c83ec50ea0 6126 if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2))
whismanoid 15:37c83ec50ea0 6127 {
whismanoid 15:37c83ec50ea0 6128 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 6129 }
whismanoid 15:37c83ec50ea0 6130 if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1))
whismanoid 15:37c83ec50ea0 6131 {
whismanoid 15:37c83ec50ea0 6132 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 6133 }
whismanoid 15:37c83ec50ea0 6134 if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1))
whismanoid 15:37c83ec50ea0 6135 {
whismanoid 15:37c83ec50ea0 6136 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 6137 }
whismanoid 15:37c83ec50ea0 6138 // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz
whismanoid 15:37c83ec50ea0 6139 if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz))
whismanoid 15:37c83ec50ea0 6140 {
whismanoid 15:37c83ec50ea0 6141 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 6142 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 6143 if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 6144 {
whismanoid 15:37c83ec50ea0 6145 g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 6146 }
whismanoid 15:37c83ec50ea0 6147 if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 6148 {
whismanoid 15:37c83ec50ea0 6149 g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 6150 }
whismanoid 15:37c83ec50ea0 6151 }
whismanoid 15:37c83ec50ea0 6152 // Update SPI configuration
whismanoid 15:37c83ec50ea0 6153 if (isUpdatedSPIConfig)
whismanoid 15:37c83ec50ea0 6154 {
whismanoid 15:37c83ec50ea0 6155 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 6156 spi_cs = g_SPI_cs_state;
whismanoid 15:37c83ec50ea0 6157 spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0
whismanoid 15:37c83ec50ea0 6158 #if APPLICATION_MAX5715
whismanoid 15:37c83ec50ea0 6159 g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 6160 #elif APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 6161 g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 6162 #elif APPLICATION_MAX5171
whismanoid 15:37c83ec50ea0 6163 g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 6164 #elif APPLICATION_MAX11410
whismanoid 15:37c83ec50ea0 6165 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 6166 #elif APPLICATION_MAX12345
whismanoid 15:37c83ec50ea0 6167 g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 6168 #else
whismanoid 15:37c83ec50ea0 6169 spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 15:37c83ec50ea0 6170 #endif
whismanoid 15:37c83ec50ea0 6171 //
whismanoid 15:37c83ec50ea0 6172 double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 6173 int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate
whismanoid 15:37c83ec50ea0 6174 double actual_SCLK_Hz = SystemCoreClock / actual_divisor;
whismanoid 15:37c83ec50ea0 6175 //
whismanoid 15:37c83ec50ea0 6176 // fixed: mbed-os-5.11: [Warning] format '%d' expects argument of type 'int', but argument 6 has type 'uint32_t {aka long unsigned int}' [-Wformat=]
whismanoid 15:37c83ec50ea0 6177 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 6178 "\r\n %%SC CPOL=%d CPHA=%d CS=%d SCLK=%ld=%1.3fMHz (%1.1fMHz/%1.2f = actual %1.3fMHz) -- SPI config",
whismanoid 15:37c83ec50ea0 6179 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 15:37c83ec50ea0 6180 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0),
whismanoid 15:37c83ec50ea0 6181 g_SPI_cs_state,
whismanoid 15:37c83ec50ea0 6182 g_SPI_SCLK_Hz,
whismanoid 15:37c83ec50ea0 6183 (g_SPI_SCLK_Hz / 1000000.),
whismanoid 15:37c83ec50ea0 6184 ((double)(SystemCoreClock / 1000000.)),
whismanoid 15:37c83ec50ea0 6185 ideal_divisor,
whismanoid 15:37c83ec50ea0 6186 (actual_SCLK_Hz / 1000000.)
whismanoid 15:37c83ec50ea0 6187 );
whismanoid 15:37c83ec50ea0 6188 }
whismanoid 15:37c83ec50ea0 6189 // get next character
whismanoid 15:37c83ec50ea0 6190 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 6191 {
whismanoid 15:37c83ec50ea0 6192 case 'C': case 's':
whismanoid 15:37c83ec50ea0 6193 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 6194 break;
whismanoid 15:37c83ec50ea0 6195 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 6196 // %SD -- SPI diagnostic messages enable
whismanoid 15:37c83ec50ea0 6197 if (g_MAX5719_device.onSPIprint) {
whismanoid 15:37c83ec50ea0 6198 g_MAX5719_device.onSPIprint = NULL;
whismanoid 15:37c83ec50ea0 6199 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') != None is false
whismanoid 15:37c83ec50ea0 6200 }
whismanoid 15:37c83ec50ea0 6201 else {
whismanoid 15:37c83ec50ea0 6202 void onSPIprint_handler(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]);
whismanoid 15:37c83ec50ea0 6203 g_MAX5719_device.onSPIprint = onSPIprint_handler;
whismanoid 15:37c83ec50ea0 6204 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') is false
whismanoid 15:37c83ec50ea0 6205 }
whismanoid 15:37c83ec50ea0 6206 break;
whismanoid 15:37c83ec50ea0 6207 case 'W': case 'R': case 'w': case 'r':
whismanoid 15:37c83ec50ea0 6208 {
whismanoid 15:37c83ec50ea0 6209 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 6210 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 6211 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 6212 #define MAX_SPI_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 6213 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 6214 static char mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 6215 static char misoData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 6216 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 6217 MAX_SPI_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 6218 {
whismanoid 15:37c83ec50ea0 6219 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 6220 cmdLine.serial().printf("\r\nSPI");
whismanoid 15:37c83ec50ea0 6221 if (byteCount > 7) {
whismanoid 15:37c83ec50ea0 6222 cmdLine.serial().printf(" byteCount:%d", byteCount);
whismanoid 15:37c83ec50ea0 6223 }
whismanoid 15:37c83ec50ea0 6224 cmdLine.serial().printf(" MOSI->");
whismanoid 15:37c83ec50ea0 6225 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 6226 {
whismanoid 15:37c83ec50ea0 6227 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 6228 }
whismanoid 15:37c83ec50ea0 6229 spi_cs = 0;
whismanoid 15:37c83ec50ea0 6230 unsigned int numBytesTransferred =
whismanoid 15:37c83ec50ea0 6231 spi.write(mosiData, byteCount, misoData, byteCount);
whismanoid 15:37c83ec50ea0 6232 spi_cs = 1;
whismanoid 15:37c83ec50ea0 6233 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 6234 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 6235 for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred;
whismanoid 15:37c83ec50ea0 6236 byteIndex++)
whismanoid 15:37c83ec50ea0 6237 {
whismanoid 15:37c83ec50ea0 6238 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 6239 }
whismanoid 15:37c83ec50ea0 6240 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 6241 }
whismanoid 15:37c83ec50ea0 6242 }
whismanoid 15:37c83ec50ea0 6243 break;
whismanoid 15:37c83ec50ea0 6244 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 6245 } // case 'S': // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 6246 break;
whismanoid 15:37c83ec50ea0 6247 #endif
whismanoid 15:37c83ec50ea0 6248 //
whismanoid 15:37c83ec50ea0 6249 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 6250 } // switch(cmdLine[1])
whismanoid 15:37c83ec50ea0 6251 } // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 15:37c83ec50ea0 6252 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 15:37c83ec50ea0 6253
whismanoid 15:37c83ec50ea0 6254 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 6255 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 6256 void main_menu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 6257 {
whismanoid 9:45f98573eb6d 6258 // process command line
whismanoid 31:47eee7e0cc2d 6259 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 6260 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6261 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 6262 #endif // USE_DATALOGGER_CommandTable
whismanoid 48:18647e0516f2 6263 //~ cmdLine.serial().printf("\r\nCmdLine buf:\"%s\"\r\n", cmdLine.str());
whismanoid 45:74bf1fe021e5 6264 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6265 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 6266 #endif // USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6267 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 6268 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6269 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 6270 #endif // USE_DATALOGGER_CommandTable
whismanoid 45:74bf1fe021e5 6271 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6272 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 6273 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 6274
whismanoid 4:d9b05924ad4c 6275 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 31:47eee7e0cc2d 6276 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 6277 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6278 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 6279 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 6280 // If datalog is free running, halt on any possible received command
whismanoid 17:9397ea3ea7e9 6281 if (Datalogger_Trigger != trigger_Halt) {
whismanoid 4:d9b05924ad4c 6282 Datalogger_Trigger = trigger_Halt;
whismanoid 9:45f98573eb6d 6283 cmdLine.serial().printf("Datalog stopped by USB command input\r\n");
whismanoid 9:45f98573eb6d 6284 cmdLine.serial().printf("Restart datalog by sending LR\r\n");
whismanoid 4:d9b05924ad4c 6285 }
whismanoid 45:74bf1fe021e5 6286 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6287 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 6288 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 6289 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 6290
whismanoid 4:d9b05924ad4c 6291 // DIAGNOSTIC: print line buffer
whismanoid 4:d9b05924ad4c 6292 //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str());
whismanoid 4:d9b05924ad4c 6293 //
whismanoid 4:d9b05924ad4c 6294 switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 6295 {
whismanoid 4:d9b05924ad4c 6296 case '?':
whismanoid 4:d9b05924ad4c 6297 main_menu_status(cmdLine);
whismanoid 4:d9b05924ad4c 6298 main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 6299 // print command prompt
whismanoid 4:d9b05924ad4c 6300 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 6301 break;
whismanoid 4:d9b05924ad4c 6302 case '\r': case '\n': // ignore blank line
whismanoid 4:d9b05924ad4c 6303 case '\0': // ignore empty line
whismanoid 30:07197a430869 6304 main_menu_status(cmdLine);
whismanoid 30:07197a430869 6305 //~ main_menu_help(cmdLine);
whismanoid 30:07197a430869 6306 // print command prompt
whismanoid 30:07197a430869 6307 //cmdLine.serial().printf("\r\n>");
whismanoid 30:07197a430869 6308 break;
whismanoid 4:d9b05924ad4c 6309 case '#': // ignore comment line
whismanoid 4:d9b05924ad4c 6310 // # -- lines beginning with # are comments
whismanoid 30:07197a430869 6311 //
whismanoid 30:07197a430869 6312 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 6313 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in main_menu_onEOLcommandParser
whismanoid 30:07197a430869 6314 // # command handler update gstrRemarkText buffer instead of just ignoring the remark
whismanoid 30:07197a430869 6315 //
whismanoid 30:07197a430869 6316 // ignore extra spaces before the remark
whismanoid 30:07197a430869 6317 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 30:07197a430869 6318 int argIndex;
whismanoid 30:07197a430869 6319 for (argIndex = 1; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 6320 {
whismanoid 30:07197a430869 6321 if (cmdLine[argIndex] == ' ') break;
whismanoid 30:07197a430869 6322 }
whismanoid 30:07197a430869 6323 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 6324 {
whismanoid 30:07197a430869 6325 if (cmdLine[argIndex] != ' ') break;
whismanoid 30:07197a430869 6326 }
whismanoid 30:07197a430869 6327 //
whismanoid 30:07197a430869 6328 strncpy(gstrRemarkText, cmdLine.str()+argIndex, gstrRemarkTextLASTINDEX+1);
whismanoid 30:07197a430869 6329 // do not exceed string buffer limit; keep sentinel null character at end of buffer
whismanoid 30:07197a430869 6330 gstrRemarkText[gstrRemarkTextLASTINDEX] = '\0';
whismanoid 41:13a6a097502c 6331 for (unsigned int index = 0; index < gstrRemarkTextLASTINDEX; index++)
whismanoid 30:07197a430869 6332 {
whismanoid 30:07197a430869 6333 if ((gstrRemarkText[index]) == '\0') break; // null character at end of string
whismanoid 30:07197a430869 6334 if ((gstrRemarkText[index]) < 0x20) {
whismanoid 30:07197a430869 6335 // replace non-printing characters with _
whismanoid 30:07197a430869 6336 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 6337 continue;
whismanoid 30:07197a430869 6338 }
whismanoid 30:07197a430869 6339 if ((gstrRemarkText[index]) >= 0x7F) {
whismanoid 30:07197a430869 6340 // replace non-printing characters with _
whismanoid 30:07197a430869 6341 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 6342 continue;
whismanoid 30:07197a430869 6343 }
whismanoid 30:07197a430869 6344 switch(gstrRemarkText[index])
whismanoid 30:07197a430869 6345 {
whismanoid 30:07197a430869 6346 case ',':
whismanoid 30:07197a430869 6347 // replace , with ;
whismanoid 30:07197a430869 6348 gstrRemarkText[index] = ';';
whismanoid 30:07197a430869 6349 break;
whismanoid 30:07197a430869 6350 case '"':
whismanoid 30:07197a430869 6351 // replace " with '
whismanoid 30:07197a430869 6352 gstrRemarkText[index] = '\'';
whismanoid 30:07197a430869 6353 break;
whismanoid 30:07197a430869 6354 case '\\':
whismanoid 30:07197a430869 6355 // replace \ with /
whismanoid 30:07197a430869 6356 gstrRemarkText[index] = '/';
whismanoid 30:07197a430869 6357 break;
whismanoid 30:07197a430869 6358 }
whismanoid 30:07197a430869 6359 }
whismanoid 30:07197a430869 6360 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 6361 //
whismanoid 31:47eee7e0cc2d 6362 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 6363 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6364 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 6365 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 6366 main_menu_status(cmdLine);
whismanoid 45:74bf1fe021e5 6367 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6368 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 6369 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 6370 //~ main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 6371 // print command prompt
whismanoid 4:d9b05924ad4c 6372 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 6373 break;
whismanoid 4:d9b05924ad4c 6374 #if ECHO_EOF_ON_EOL
whismanoid 4:d9b05924ad4c 6375 case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file
whismanoid 4:d9b05924ad4c 6376 cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 6377 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 6378 break;
whismanoid 4:d9b05924ad4c 6379 case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file
whismanoid 4:d9b05924ad4c 6380 cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 6381 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 6382 break;
whismanoid 4:d9b05924ad4c 6383 #endif
whismanoid 10:04022a61b527 6384 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6385 case '!': // device init
whismanoid 10:04022a61b527 6386 {
whismanoid 10:04022a61b527 6387 cmdLine.serial().printf("Init");
whismanoid 10:04022a61b527 6388 // call function Init
whismanoid 10:04022a61b527 6389 uint8_t result = g_MAX11410_device.Init();
whismanoid 10:04022a61b527 6390 // cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 6391 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 6392 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 6393 // in command '!' device init, apply list of custom register writes after init
whismanoid 10:04022a61b527 6394 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 6395 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 10:04022a61b527 6396 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 10:04022a61b527 6397 uint32_t regData = custom_reg_init_data[index];
whismanoid 10:04022a61b527 6398 cmdLine.serial().printf("*%s=0x%06.6x",
whismanoid 10:04022a61b527 6399 g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress),
whismanoid 10:04022a61b527 6400 regData
whismanoid 10:04022a61b527 6401 );
whismanoid 10:04022a61b527 6402 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 10:04022a61b527 6403 }
whismanoid 10:04022a61b527 6404 #endif // USE_CUSTOM_REG_INIT
whismanoid 10:04022a61b527 6405 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 6406 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 6407 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 6408 }
whismanoid 10:04022a61b527 6409 break;
whismanoid 10:04022a61b527 6410 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 6411 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 6412 case '.':
whismanoid 4:d9b05924ad4c 6413 {
whismanoid 4:d9b05924ad4c 6414 // . -- SelfTest
whismanoid 4:d9b05924ad4c 6415 cmdLine.serial().printf("SelfTest()");
whismanoid 4:d9b05924ad4c 6416 SelfTest(cmdLine);
whismanoid 4:d9b05924ad4c 6417 }
whismanoid 4:d9b05924ad4c 6418 break;
whismanoid 4:d9b05924ad4c 6419 #endif // USE_SELFTEST
whismanoid 15:37c83ec50ea0 6420 #if 1 // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 6421 case '%':
whismanoid 4:d9b05924ad4c 6422 {
whismanoid 4:d9b05924ad4c 6423 pinsMonitor_submenu_onEOLcommandParser(cmdLine);
whismanoid 4:d9b05924ad4c 6424 }
whismanoid 4:d9b05924ad4c 6425 break; // case '%'
whismanoid 4:d9b05924ad4c 6426 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 9:45f98573eb6d 6427 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 6428 // reuse the Serial_Tester command *regName=regValue
whismanoid 10:04022a61b527 6429 // CODE GENERATOR: generate * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 6430 case '*':
whismanoid 10:04022a61b527 6431 {
whismanoid 10:04022a61b527 6432 // if buffer starts with a regName:
whismanoid 10:04022a61b527 6433 // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))):
whismanoid 10:04022a61b527 6434 // cmdLine.serial().printf(" scan RegName...\r\n");
whismanoid 10:04022a61b527 6435 }
whismanoid 10:04022a61b527 6436 break;
whismanoid 9:45f98573eb6d 6437 #endif // USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 6438 //
whismanoid 10:04022a61b527 6439 #if 1 // USE_AUX_SERIAL_CMD_FORWARDING && (HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL)
whismanoid 10:04022a61b527 6440 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_onEOLcommandParser
whismanoid 40:330b28116178 6441 case '>': case '<': // > send and receive; < receive without sending anything
whismanoid 10:04022a61b527 6442 {
whismanoid 10:04022a61b527 6443 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 6444 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 6445 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 6446 CmdLine& cmdLine_AuxSerial = cmdLine_AUXserial;
whismanoid 10:04022a61b527 6447 Serial& AuxSerial = AUXserial;
whismanoid 10:04022a61b527 6448 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6449 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 6450 CmdLine& cmdLine_AuxSerial = cmdLine_DAPLINKserial;
whismanoid 10:04022a61b527 6451 Serial& AuxSerial = DAPLINKserial;
whismanoid 10:04022a61b527 6452 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6453 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 6454 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6455 //
whismanoid 40:330b28116178 6456 int g_auxSerialCom_outgoing_string_cr = 1; // option to send CR after outgoing_string
whismanoid 40:330b28116178 6457 int g_auxSerialCom_outgoing_string_lf = 0; // option to send LF after outgoing_string (breaks remote datalogger LR!)
whismanoid 40:330b28116178 6458 int g_auxSerialCom_rx_string_verbose_crlf = 0; // option to display \r\n as "\\r\\n" in rx_string_buf
whismanoid 40:330b28116178 6459 int g_auxSerialCom_rx_string_verbose_ctrl = 1; // option to display control codes as \xXX
whismanoid 40:330b28116178 6460 const char* g_auxSerialCom_display_tx_prefix = "\r\n->|"; // "\r\n >";
whismanoid 40:330b28116178 6461 const char* g_auxSerialCom_display_rx_prefix = "\r\n<-|"; // "\r\n< ";
whismanoid 40:330b28116178 6462 //
whismanoid 40:330b28116178 6463 bool need_g_auxSerialCom_display_rx_prefix = 1; // temp
whismanoid 40:330b28116178 6464 //
whismanoid 10:04022a61b527 6465 // >> suppress key=value parsing
whismanoid 10:04022a61b527 6466 bool suppress_parsing = (cmdLine[1] == '>');
whismanoid 10:04022a61b527 6467 if (suppress_parsing == false) {
whismanoid 10:04022a61b527 6468 // int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 6469 if (cmdLine.parse_int_dec("baud", g_auxSerialCom_baud))
whismanoid 10:04022a61b527 6470 {
whismanoid 10:04022a61b527 6471 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- baud rate
whismanoid 10:04022a61b527 6472 cmdLine_AuxSerial.serial().printf("\r\n*** New Baud Rate %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6473 AuxSerial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6474 cmdLine_AuxSerial.serial().printf("\r\n*** Baud Rate was set to %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6475 }
whismanoid 10:04022a61b527 6476 #if 0
whismanoid 10:04022a61b527 6477 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 6478 if (cmdLine.parse_int_dec("tx_wait_echo", g_auxSerialCom_tx_wait_echo))
whismanoid 10:04022a61b527 6479 {
whismanoid 10:04022a61b527 6480 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_wait_echo
whismanoid 10:04022a61b527 6481 //~ cmdLine_AuxSerial.serial().printf("\r\n*** tx_wait_echo was set to %d ***\r\n", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 6482 cmdLine.serial().printf("\r\n tx_wait_echo=%d", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 6483 }
whismanoid 10:04022a61b527 6484 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 6485 if (cmdLine.parse_int_dec("tx_char_delay_ms", g_auxSerialCom_tx_char_delay_ms))
whismanoid 10:04022a61b527 6486 {
whismanoid 10:04022a61b527 6487 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_char_delay_ms
whismanoid 10:04022a61b527 6488 //~ cmdLine_AuxSerial.serial().printf("\r\n*** tx_char_delay_ms was set to %d ***\r\n", g_auxSerialCom_tx_char_delay_ms);
whismanoid 10:04022a61b527 6489 cmdLine.serial().printf("\r\n tx_char_delay_ms=%dms", g_auxSerialCom_tx_char_delay_ms);
whismanoid 10:04022a61b527 6490 }
whismanoid 10:04022a61b527 6491 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 6492 if (cmdLine.parse_int_dec("tx_line_delay_ms", g_auxSerialCom_tx_line_delay_ms))
whismanoid 10:04022a61b527 6493 {
whismanoid 10:04022a61b527 6494 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_line_delay_ms
whismanoid 10:04022a61b527 6495 //~ cmdLine_AuxSerial.serial().printf("\r\n*** tx_line_delay_ms was set to %d ***\r\n", g_auxSerialCom_tx_line_delay_ms);
whismanoid 10:04022a61b527 6496 cmdLine.serial().printf("\r\n tx_line_delay_ms=%dms", g_auxSerialCom_tx_line_delay_ms);
whismanoid 10:04022a61b527 6497 }
whismanoid 10:04022a61b527 6498 #endif
whismanoid 10:04022a61b527 6499 // int g_auxSerialCom_message_ms = 0; //!< capture RX until response timeout?
whismanoid 10:04022a61b527 6500 if (cmdLine.parse_int_dec("message_ms", g_auxSerialCom_message_ms))
whismanoid 10:04022a61b527 6501 {
whismanoid 10:04022a61b527 6502 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 10:04022a61b527 6503 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 6504 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 6505 }
whismanoid 10:04022a61b527 6506 // int g_auxSerialCom_rx_idle_ms = 0; //!< capture RX until idle timeout?
whismanoid 10:04022a61b527 6507 if (cmdLine.parse_int_dec("rx_idle_ms", g_auxSerialCom_rx_idle_ms))
whismanoid 10:04022a61b527 6508 {
whismanoid 10:04022a61b527 6509 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_idle_ms
whismanoid 10:04022a61b527 6510 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_idle_ms was set to %d ***\r\n", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 6511 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 6512 }
whismanoid 10:04022a61b527 6513 // int g_auxSerialCom_rx_max_count = 0; //!< capture RX until max character count?
whismanoid 10:04022a61b527 6514 if (cmdLine.parse_int_dec("rx_max_count", g_auxSerialCom_rx_max_count))
whismanoid 10:04022a61b527 6515 {
whismanoid 10:04022a61b527 6516 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_max_count
whismanoid 10:04022a61b527 6517 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_max_count was set to %d ***\r\n", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 6518 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 6519 }
whismanoid 10:04022a61b527 6520 // int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text char?
whismanoid 10:04022a61b527 6521 if (cmdLine.parse_int_dec("rx_eot", g_auxSerialCom_rx_eot))
whismanoid 10:04022a61b527 6522 {
whismanoid 10:04022a61b527 6523 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_eot
whismanoid 10:04022a61b527 6524 //~ cmdLine_AUXserial.serial().printf("\r\n*** rx_eot was set to %d ***\r\n", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 6525 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 6526 }
whismanoid 10:04022a61b527 6527 }
whismanoid 10:04022a61b527 6528 // Command forwarding to AUX serial TX/RX cmdLine_AuxSerial #257 -- send outgoing_string
whismanoid 41:13a6a097502c 6529 char* outgoing_string = ""; // warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
whismanoid 40:330b28116178 6530 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 6531 outgoing_string = (char*)cmdLine.str();
whismanoid 40:330b28116178 6532 // > use key=value parsing
whismanoid 40:330b28116178 6533 // >> suppress key=value parsing
whismanoid 40:330b28116178 6534 if (suppress_parsing) {
whismanoid 40:330b28116178 6535 cmdLine.serial().printf("\r\n suppress_parsing outgoing_string=\"%s\"", outgoing_string);
whismanoid 40:330b28116178 6536 outgoing_string++; // skip the first '>'
whismanoid 40:330b28116178 6537 outgoing_string++; // skip the second '>'
whismanoid 40:330b28116178 6538 } else {
whismanoid 40:330b28116178 6539 // TODO: after parsing, key=value pairs should be deleted, but outgoing_string=">xyzzy abc=def"
whismanoid 40:330b28116178 6540 cmdLine.serial().printf("\r\n after parsing, outgoing_string=\"%s\"", outgoing_string);
whismanoid 40:330b28116178 6541 outgoing_string++; // skip the first '>'
whismanoid 40:330b28116178 6542 }
whismanoid 40:330b28116178 6543 } // if (cmdLine[0] == '>')
whismanoid 10:04022a61b527 6544 static char rx_string_buf[RX_STRING_BUF_SIZE];
whismanoid 10:04022a61b527 6545 unsigned int rx_string_length = 0;
whismanoid 40:330b28116178 6546 //cmdLine.serial().printf("\r\n >%s\r\n <", outgoing_string);
whismanoid 40:330b28116178 6547 //char* g_auxSerialCom_display_tx_prefix = "\r\n >";
whismanoid 40:330b28116178 6548 //char* g_auxSerialCom_display_rx_prefix = "\r\n< ";
whismanoid 40:330b28116178 6549 cmdLine.serial().printf("%s%s%s",
whismanoid 40:330b28116178 6550 g_auxSerialCom_display_tx_prefix, // "\r\n >"
whismanoid 40:330b28116178 6551 outgoing_string,
whismanoid 40:330b28116178 6552 g_auxSerialCom_display_rx_prefix // "\r\n <"
whismanoid 40:330b28116178 6553 );
whismanoid 10:04022a61b527 6554 rx_string_buf[0] = '\0';
whismanoid 10:04022a61b527 6555 rx_string_length = 0;
whismanoid 10:04022a61b527 6556 //
whismanoid 10:04022a61b527 6557 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 6558 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 6559 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 6560 //
whismanoid 10:04022a61b527 6561 // int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 6562 // int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 6563 // int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 6564 // int g_auxSerialCom_rx_idle_ms = 2000; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 6565 // int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 6566 // int g_auxSerialCom_rx_eot = '\r'; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 6567 //~ cmdLine_AuxSerial.serial().printf("\r\n*** TODO forward %s ***\r\n", outgoing_string);
whismanoid 10:04022a61b527 6568 //
whismanoid 10:04022a61b527 6569 // TODO: send whole string or send character-by-character?
whismanoid 40:330b28116178 6570 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 6571 cmdLine_AuxSerial.serial().printf("%s", outgoing_string);
whismanoid 40:330b28116178 6572 //
whismanoid 40:330b28116178 6573 // TODO: send CRLF or just send CR line end?
whismanoid 40:330b28116178 6574 if (g_auxSerialCom_outgoing_string_cr) { cmdLine_AuxSerial.serial().printf("\r"); }
whismanoid 40:330b28116178 6575 if (g_auxSerialCom_outgoing_string_lf) { cmdLine_AuxSerial.serial().printf("\n"); }
whismanoid 40:330b28116178 6576 // cmdLine_AuxSerial.serial().printf("\r\n");
whismanoid 40:330b28116178 6577 } // if (cmdLine[0] == '>')
whismanoid 40:330b28116178 6578 //
whismanoid 10:04022a61b527 6579 g_auxSerialCom_Timer.start();
whismanoid 10:04022a61b527 6580 g_auxSerialCom_Timer_begin_message_ms = g_auxSerialCom_Timer.read_ms(); // start of message
whismanoid 10:04022a61b527 6581 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 6582 while (rx_string_length < (RX_STRING_BUF_SIZE-1)) {
whismanoid 10:04022a61b527 6583 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_message_ms) > g_auxSerialCom_message_ms) {
whismanoid 10:04022a61b527 6584 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 6585 break;
whismanoid 10:04022a61b527 6586 }
whismanoid 10:04022a61b527 6587 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_rx_idle_ms) > g_auxSerialCom_rx_idle_ms) {
whismanoid 10:04022a61b527 6588 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 6589 break;
whismanoid 10:04022a61b527 6590 }
whismanoid 41:13a6a097502c 6591 if ((int)rx_string_length >= g_auxSerialCom_rx_max_count) {
whismanoid 10:04022a61b527 6592 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 6593 break;
whismanoid 10:04022a61b527 6594 }
whismanoid 10:04022a61b527 6595 if (AuxSerial.readable()) {
whismanoid 10:04022a61b527 6596 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 6597 char ch = AuxSerial.getc();
whismanoid 10:04022a61b527 6598 rx_string_buf[rx_string_length++] = ch;
whismanoid 10:04022a61b527 6599 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 40:330b28116178 6600 //
whismanoid 40:330b28116178 6601 #if 1
whismanoid 40:330b28116178 6602 // immediate character echo
whismanoid 40:330b28116178 6603 for (char* cp = &(rx_string_buf[rx_string_length-1]); *cp != '\0'; cp++)
whismanoid 40:330b28116178 6604 {
whismanoid 40:330b28116178 6605 //cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 6606 if (need_g_auxSerialCom_display_rx_prefix) {
whismanoid 40:330b28116178 6607 cmdLine.serial().printf(g_auxSerialCom_display_rx_prefix); // "\r\n< " g_auxSerialCom_rx_string display prefix
whismanoid 40:330b28116178 6608 need_g_auxSerialCom_display_rx_prefix = 0;
whismanoid 40:330b28116178 6609 }
whismanoid 40:330b28116178 6610 if ((*cp) == '\r') {
whismanoid 40:330b28116178 6611 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\r"); }
whismanoid 40:330b28116178 6612 // if (*(cp+1) != '\n') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 6613 } else if ((*cp) == '\n') {
whismanoid 40:330b28116178 6614 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\n"); }
whismanoid 40:330b28116178 6615 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 6616 if (*(cp-1) != '\r') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 6617 } else if ((*cp) < 0x20) {
whismanoid 40:330b28116178 6618 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6619 } else if ((*cp) >= 0x7f) {
whismanoid 40:330b28116178 6620 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6621 } else {
whismanoid 40:330b28116178 6622 cmdLine.serial().printf("%c", *cp);
whismanoid 40:330b28116178 6623 }
whismanoid 40:330b28116178 6624 }
whismanoid 40:330b28116178 6625 #else
whismanoid 40:330b28116178 6626 // immediate character echo
whismanoid 40:330b28116178 6627 cmdLine.serial().printf("%s", &(rx_string_buf[rx_string_length-1]) );
whismanoid 40:330b28116178 6628 #endif
whismanoid 40:330b28116178 6629 //
whismanoid 10:04022a61b527 6630 if (g_auxSerialCom_rx_eot != aux_serial_cmd_forwarding_rx_eot_not_used) {
whismanoid 10:04022a61b527 6631 if (ch == g_auxSerialCom_rx_eot) {
whismanoid 10:04022a61b527 6632 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 6633 break;
whismanoid 10:04022a61b527 6634 }
whismanoid 10:04022a61b527 6635 }
whismanoid 10:04022a61b527 6636 }
whismanoid 10:04022a61b527 6637 } // end while (rx_string_length < (RX_STRING_BUF_SIZE-1))
whismanoid 40:330b28116178 6638 #if 0
whismanoid 10:04022a61b527 6639 // print summary. is this needed? we already print aux rx as it is received.
whismanoid 10:04022a61b527 6640 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 40:330b28116178 6641 # if 1 // support multi-line rx_string_buf response
whismanoid 40:330b28116178 6642 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 6643 cmdLine.serial().printf("%s%s", g_auxSerialCom_display_tx_prefix, outgoing_string);
whismanoid 40:330b28116178 6644 } // if (cmdLine[0] == '>')
whismanoid 40:330b28116178 6645 // cmdLine.serial().printf("\r\n <"); // prefix
whismanoid 40:330b28116178 6646 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 6647 for (char* cp = rx_string_buf; *cp != '\0'; cp++)
whismanoid 40:330b28116178 6648 {
whismanoid 40:330b28116178 6649 //cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 6650 if (need_g_auxSerialCom_display_rx_prefix) {
whismanoid 40:330b28116178 6651 cmdLine.serial().printf(g_auxSerialCom_display_rx_prefix); // "\r\n< " g_auxSerialCom_rx_string display prefix
whismanoid 40:330b28116178 6652 need_g_auxSerialCom_display_rx_prefix = 0;
whismanoid 40:330b28116178 6653 }
whismanoid 40:330b28116178 6654 if ((*cp) == '\r') {
whismanoid 40:330b28116178 6655 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\r"); }
whismanoid 40:330b28116178 6656 if (*(cp+1) != '\n') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 6657 } else if ((*cp) == '\n') {
whismanoid 40:330b28116178 6658 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\n"); }
whismanoid 40:330b28116178 6659 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 6660 } else if ((*cp) < 0x20) {
whismanoid 40:330b28116178 6661 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6662 } else if ((*cp) >= 0x7f) {
whismanoid 40:330b28116178 6663 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6664 } else {
whismanoid 40:330b28116178 6665 cmdLine.serial().printf("%c", *cp);
whismanoid 40:330b28116178 6666 }
whismanoid 40:330b28116178 6667 }
whismanoid 40:330b28116178 6668 cmdLine.serial().printf("\r\n");
whismanoid 40:330b28116178 6669 # else
whismanoid 10:04022a61b527 6670 cmdLine.serial().printf("\r\n >%s", outgoing_string);
whismanoid 10:04022a61b527 6671 cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 6672 # endif
whismanoid 10:04022a61b527 6673 #endif
whismanoid 10:04022a61b527 6674 //
whismanoid 10:04022a61b527 6675 }
whismanoid 10:04022a61b527 6676 break; // case '>'
whismanoid 10:04022a61b527 6677 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6678 //
whismanoid 4:d9b05924ad4c 6679 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 6680 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 6681 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 6682 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 6683 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible
whismanoid 9:45f98573eb6d 6684 case 'L': case 'l':
whismanoid 4:d9b05924ad4c 6685 {
whismanoid 4:d9b05924ad4c 6686 // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 6687 Datalogger_Trigger = trigger_Halt;
whismanoid 4:d9b05924ad4c 6688 switch (cmdLine[1])
whismanoid 4:d9b05924ad4c 6689 {
whismanoid 17:9397ea3ea7e9 6690 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 6691 case 'T': case 't':
whismanoid 17:9397ea3ea7e9 6692 {
whismanoid 17:9397ea3ea7e9 6693 // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 6694 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 6695 Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6696 g_timer_interval_counter = 0;
whismanoid 39:4d285e961435 6697 // get g_timer_interval_msec from cmdLine
whismanoid 17:9397ea3ea7e9 6698 // g_timer_interval_msec = 500;
whismanoid 17:9397ea3ea7e9 6699 // g_timer_interval_count = 10;
whismanoid 17:9397ea3ea7e9 6700 if (cmdLine.parse_int_dec("count", g_timer_interval_count))
whismanoid 17:9397ea3ea7e9 6701 {
whismanoid 32:80f3e5eb77d4 6702 if (g_timer_interval_count < 1) { g_timer_interval_count = 1; }
whismanoid 17:9397ea3ea7e9 6703 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 6704 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 6705 cmdLine.serial().printf("\r\n g_timer_interval_count=%d", g_timer_interval_count);
whismanoid 17:9397ea3ea7e9 6706 }
whismanoid 17:9397ea3ea7e9 6707 if (cmdLine.parse_int_dec("base", g_timer_interval_msec))
whismanoid 17:9397ea3ea7e9 6708 {
whismanoid 17:9397ea3ea7e9 6709 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 6710 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 6711 cmdLine.serial().printf("\r\n g_timer_interval_msec=%d", g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 6712 }
whismanoid 39:4d285e961435 6713 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 6714 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 6715 int int_timer_sleepmode = g_timer_sleepmode;
whismanoid 39:4d285e961435 6716 if (cmdLine.parse_int_dec("sleep", int_timer_sleepmode))
whismanoid 39:4d285e961435 6717 {
whismanoid 39:4d285e961435 6718 g_timer_sleepmode = (Datalogger_Sleep_enum_t)int_timer_sleepmode;
whismanoid 39:4d285e961435 6719 //~ if (g_timer_interval_count < 1) { g_timer_interval_count = 1; }
whismanoid 39:4d285e961435 6720 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 39:4d285e961435 6721 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 39:4d285e961435 6722 cmdLine.serial().printf("\r\n g_timer_sleepmode=%d", (int)g_timer_sleepmode);
whismanoid 39:4d285e961435 6723 }
whismanoid 39:4d285e961435 6724 #else // USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 6725 #endif // USE_DATALOGGER_SLEEP
whismanoid 17:9397ea3ea7e9 6726 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 17:9397ea3ea7e9 6727 }
whismanoid 17:9397ea3ea7e9 6728 break;
whismanoid 17:9397ea3ea7e9 6729 // LIH3 -- Datalog when input high D3
whismanoid 17:9397ea3ea7e9 6730 // LIL6 -- Datalog when input low D6
whismanoid 17:9397ea3ea7e9 6731 case 'I': case 'i':
whismanoid 17:9397ea3ea7e9 6732 {
whismanoid 17:9397ea3ea7e9 6733 // TODO: switch cmdLine[2] configure High or Low, configure input pin
whismanoid 17:9397ea3ea7e9 6734 }
whismanoid 17:9397ea3ea7e9 6735 break;
whismanoid 17:9397ea3ea7e9 6736 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 6737 // L$ count=10 base=500ms addr=xxx data=xxx mask=xxx -- Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 6738 case '$':
whismanoid 17:9397ea3ea7e9 6739 {
whismanoid 17:9397ea3ea7e9 6740 // TODO: scan cmdLine for regAddr, dataMask, testValue
whismanoid 17:9397ea3ea7e9 6741 }
whismanoid 17:9397ea3ea7e9 6742 break;
whismanoid 17:9397ea3ea7e9 6743 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6744 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6745 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6746 case '@':
whismanoid 17:9397ea3ea7e9 6747 {
whismanoid 17:9397ea3ea7e9 6748 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6749 int editRowIndex = 0;
whismanoid 17:9397ea3ea7e9 6750 int edit_action = (int)action_noop;
whismanoid 17:9397ea3ea7e9 6751 int edit_digitalOutPin = 0;
whismanoid 17:9397ea3ea7e9 6752 int edit_condition = (int)condition_always;
whismanoid 17:9397ea3ea7e9 6753 int edit_condition_channel = 0;
whismanoid 17:9397ea3ea7e9 6754 double edit_condition_threshold = 0;
whismanoid 17:9397ea3ea7e9 6755 //
whismanoid 17:9397ea3ea7e9 6756 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 17:9397ea3ea7e9 6757 {
whismanoid 17:9397ea3ea7e9 6758 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 17:9397ea3ea7e9 6759 }
whismanoid 17:9397ea3ea7e9 6760 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 17:9397ea3ea7e9 6761 {
whismanoid 17:9397ea3ea7e9 6762 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 17:9397ea3ea7e9 6763 }
whismanoid 17:9397ea3ea7e9 6764 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 17:9397ea3ea7e9 6765 {
whismanoid 17:9397ea3ea7e9 6766 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 17:9397ea3ea7e9 6767 }
whismanoid 17:9397ea3ea7e9 6768 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 17:9397ea3ea7e9 6769 {
whismanoid 17:9397ea3ea7e9 6770 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 17:9397ea3ea7e9 6771 }
whismanoid 17:9397ea3ea7e9 6772 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 17:9397ea3ea7e9 6773 {
whismanoid 17:9397ea3ea7e9 6774 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 17:9397ea3ea7e9 6775 }
whismanoid 17:9397ea3ea7e9 6776 //
whismanoid 17:9397ea3ea7e9 6777 // Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6778 switch (cmdLine[2]) // L@... -- Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6779 {
whismanoid 17:9397ea3ea7e9 6780 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 6781 case '0': case '1': case '2': case '3': case '4':
whismanoid 17:9397ea3ea7e9 6782 case '5': case '6': case '7': case '8': case '9':
whismanoid 17:9397ea3ea7e9 6783 // edit row data
whismanoid 30:07197a430869 6784 if (1) { // removed Datalogger_action_table_row_count > 0 -- support %L@nnn command add new row (even though this looks like a replace command) if and only if nnn==next new unassigned line number
whismanoid 17:9397ea3ea7e9 6785 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 6786 // get row number to edit from cmdLine[2]
whismanoid 17:9397ea3ea7e9 6787 editRowIndex = atoi(cmdLine.str()+2);
whismanoid 30:07197a430869 6788 if ((editRowIndex >= 0) && (editRowIndex < Datalogger_action_table_row_count)) {
whismanoid 30:07197a430869 6789 // update row
whismanoid 30:07197a430869 6790 cmdLine.serial().printf("\r\n replace row %d", editRowIndex);
whismanoid 30:07197a430869 6791 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 6792 edit_action = Datalogger_action_table[editRowIndex].action;
whismanoid 30:07197a430869 6793 edit_digitalOutPin = Datalogger_action_table[editRowIndex].digitalOutPin;
whismanoid 30:07197a430869 6794 edit_condition = Datalogger_action_table[editRowIndex].condition;
whismanoid 30:07197a430869 6795 edit_condition_channel = Datalogger_action_table[editRowIndex].condition_channel;
whismanoid 30:07197a430869 6796 edit_condition_threshold = Datalogger_action_table[editRowIndex].condition_threshold;
whismanoid 30:07197a430869 6797 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 6798 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 30:07197a430869 6799 {
whismanoid 30:07197a430869 6800 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 30:07197a430869 6801 }
whismanoid 30:07197a430869 6802 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 30:07197a430869 6803 {
whismanoid 30:07197a430869 6804 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 30:07197a430869 6805 }
whismanoid 30:07197a430869 6806 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 30:07197a430869 6807 {
whismanoid 30:07197a430869 6808 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 30:07197a430869 6809 }
whismanoid 30:07197a430869 6810 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 30:07197a430869 6811 {
whismanoid 30:07197a430869 6812 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 30:07197a430869 6813 }
whismanoid 30:07197a430869 6814 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 30:07197a430869 6815 {
whismanoid 30:07197a430869 6816 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 30:07197a430869 6817 }
whismanoid 30:07197a430869 6818 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 6819 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 6820 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 6821 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 6822 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 6823 }
whismanoid 30:07197a430869 6824 else if ((editRowIndex == Datalogger_action_table_row_count) && (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX)) {
whismanoid 30:07197a430869 6825 // %L@nnn command add new row (even though this looks like a replace command) if and only if nnn==next new unassigned line number
whismanoid 30:07197a430869 6826 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 6827 cmdLine.serial().printf("\r\n add next row %d", editRowIndex);
whismanoid 30:07197a430869 6828 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 6829 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 6830 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 6831 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 6832 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 30:07197a430869 6833 //
whismanoid 17:9397ea3ea7e9 6834 }
whismanoid 17:9397ea3ea7e9 6835 }
whismanoid 17:9397ea3ea7e9 6836 break;
whismanoid 17:9397ea3ea7e9 6837 case '+':
whismanoid 17:9397ea3ea7e9 6838 // add a new row at end of table
whismanoid 17:9397ea3ea7e9 6839 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 6840 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 6841 editRowIndex = Datalogger_action_table_row_count;
whismanoid 17:9397ea3ea7e9 6842 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 6843 cmdLine.serial().printf("\r\n add new row %d", editRowIndex);
whismanoid 17:9397ea3ea7e9 6844 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 17:9397ea3ea7e9 6845 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 17:9397ea3ea7e9 6846 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 17:9397ea3ea7e9 6847 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 17:9397ea3ea7e9 6848 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 6849 }
whismanoid 17:9397ea3ea7e9 6850 break;
whismanoid 17:9397ea3ea7e9 6851 case '-':
whismanoid 17:9397ea3ea7e9 6852 // delete row from table
whismanoid 17:9397ea3ea7e9 6853 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 6854 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 6855 if ((cmdLine[3] == '~') && (cmdLine[4] == '~') && (cmdLine[5] == '~')) {
whismanoid 17:9397ea3ea7e9 6856 // L@-~~~ -- delete all rows from table
whismanoid 30:07197a430869 6857 cmdLine.serial().printf("\r\n delete all rows");
whismanoid 17:9397ea3ea7e9 6858 Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 6859 break;
whismanoid 17:9397ea3ea7e9 6860 }
whismanoid 30:07197a430869 6861 else {
whismanoid 30:07197a430869 6862 editRowIndex = atoi(cmdLine.str()+3);
whismanoid 30:07197a430869 6863 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 30:07197a430869 6864 // delete row editRowIndex from Datalogger_action_table
whismanoid 30:07197a430869 6865 for (int i = editRowIndex; i < (Datalogger_action_table_row_count-1); i++)
whismanoid 30:07197a430869 6866 {
whismanoid 30:07197a430869 6867 // copy row i+1 into row i
whismanoid 30:07197a430869 6868 Datalogger_action_table[i].action = Datalogger_action_table[i+1].action;
whismanoid 30:07197a430869 6869 Datalogger_action_table[i].digitalOutPin = Datalogger_action_table[i+1].digitalOutPin;
whismanoid 30:07197a430869 6870 Datalogger_action_table[i].condition = Datalogger_action_table[i+1].condition;
whismanoid 30:07197a430869 6871 Datalogger_action_table[i].condition_channel = Datalogger_action_table[i+1].condition_channel;
whismanoid 30:07197a430869 6872 Datalogger_action_table[i].condition_threshold = Datalogger_action_table[i+1].condition_threshold;
whismanoid 30:07197a430869 6873 }
whismanoid 30:07197a430869 6874 Datalogger_action_table_row_count--;
whismanoid 17:9397ea3ea7e9 6875 }
whismanoid 17:9397ea3ea7e9 6876 }
whismanoid 17:9397ea3ea7e9 6877 break;
whismanoid 30:07197a430869 6878 case '.':
whismanoid 30:07197a430869 6879 // L@. pause the entire Log action table
whismanoid 30:07197a430869 6880 cmdLine.serial().printf("\r\n pause the entire Log action table");
whismanoid 17:9397ea3ea7e9 6881 Datalogger_action_table_enabled = false;
whismanoid 17:9397ea3ea7e9 6882 break;
whismanoid 17:9397ea3ea7e9 6883 case '@':
whismanoid 30:07197a430869 6884 // L@@ enable the entire Log action table
whismanoid 30:07197a430869 6885 cmdLine.serial().printf("\r\n enable the entire Log action table");
whismanoid 17:9397ea3ea7e9 6886 Datalogger_action_table_enabled = true;
whismanoid 17:9397ea3ea7e9 6887 break;
whismanoid 17:9397ea3ea7e9 6888 }
whismanoid 17:9397ea3ea7e9 6889 //
whismanoid 17:9397ea3ea7e9 6890 // Print the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6891 if (Datalogger_action_table_enabled) {
whismanoid 30:07197a430869 6892 // cmdLine.serial().printf("Log action table enabled; L@. to pause");
whismanoid 17:9397ea3ea7e9 6893 }
whismanoid 17:9397ea3ea7e9 6894 else {
whismanoid 30:07197a430869 6895 cmdLine.serial().printf("Log action table paused; L@@ to enable");
whismanoid 17:9397ea3ea7e9 6896 }
whismanoid 17:9397ea3ea7e9 6897 //~ cmdLine.serial().printf("\r\n Datalogger_action_table_row_count=%d", Datalogger_action_table_row_count);
whismanoid 17:9397ea3ea7e9 6898 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 6899 {
whismanoid 17:9397ea3ea7e9 6900 cmdLine.serial().printf("\r\n L@%d", i);
whismanoid 17:9397ea3ea7e9 6901 cmdLine.serial().printf(" act=%d", Datalogger_action_table[i].action);
whismanoid 17:9397ea3ea7e9 6902 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6903 {
whismanoid 17:9397ea3ea7e9 6904 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 6905 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 6906 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6907 break;
whismanoid 29:6a9edb6e973b 6908 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6909 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 6910 break;
whismanoid 17:9397ea3ea7e9 6911 default:
whismanoid 17:9397ea3ea7e9 6912 case action_noop:
whismanoid 17:9397ea3ea7e9 6913 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 6914 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 6915 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 6916 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 6917 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 6918 break;
whismanoid 17:9397ea3ea7e9 6919 }
whismanoid 17:9397ea3ea7e9 6920 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6921 {
whismanoid 17:9397ea3ea7e9 6922 case condition_always:
whismanoid 17:9397ea3ea7e9 6923 break;
whismanoid 17:9397ea3ea7e9 6924 default:
whismanoid 17:9397ea3ea7e9 6925 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 6926 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 6927 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 6928 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 6929 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 6930 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 6931 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 6932 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 6933 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 6934 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 6935 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 6936 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 6937 cmdLine.serial().printf(" if=%d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 6938 cmdLine.serial().printf(" ch=%d", Datalogger_action_table[i].condition_channel);
whismanoid 40:330b28116178 6939 // our voltage measurement is around 1mV at best
whismanoid 40:330b28116178 6940 cmdLine.serial().printf(" x=%1.4f", Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6941 break;
whismanoid 17:9397ea3ea7e9 6942 }
whismanoid 17:9397ea3ea7e9 6943 cmdLine.serial().printf(" -- ");
whismanoid 17:9397ea3ea7e9 6944 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6945 {
whismanoid 17:9397ea3ea7e9 6946 case action_noop:
whismanoid 17:9397ea3ea7e9 6947 cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 6948 break;
whismanoid 17:9397ea3ea7e9 6949 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 6950 cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 6951 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6952 break;
whismanoid 17:9397ea3ea7e9 6953 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 6954 cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 6955 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6956 break;
whismanoid 29:6a9edb6e973b 6957 case action_button: // pin = button index 1, 2, 3
whismanoid 40:330b28116178 6958 cmdLine.serial().printf("button %%B%d!", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 6959 break;
whismanoid 17:9397ea3ea7e9 6960 case action_trigger_Halt:
whismanoid 40:330b28116178 6961 cmdLine.serial().printf("Halt");
whismanoid 17:9397ea3ea7e9 6962 break;
whismanoid 17:9397ea3ea7e9 6963 case action_trigger_FreeRun:
whismanoid 40:330b28116178 6964 cmdLine.serial().printf("LR");
whismanoid 17:9397ea3ea7e9 6965 break;
whismanoid 17:9397ea3ea7e9 6966 case action_trigger_Timer:
whismanoid 45:74bf1fe021e5 6967 cmdLine.serial().printf("LT count=%d base=%dms", g_timer_interval_count, g_timer_interval_msec);
whismanoid 45:74bf1fe021e5 6968 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 6969 cmdLine.serial().printf(" sleep=%d", g_timer_sleepmode);
whismanoid 45:74bf1fe021e5 6970 #endif // USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 17:9397ea3ea7e9 6971 break;
whismanoid 17:9397ea3ea7e9 6972 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 6973 cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 6974 // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 6975 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 6976 break;
whismanoid 17:9397ea3ea7e9 6977 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 6978 cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 6979 // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6980 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 6981 break;
whismanoid 17:9397ea3ea7e9 6982 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6983 //~ cmdLine.serial().printf(" condition %d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 6984 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6985 {
whismanoid 17:9397ea3ea7e9 6986 case condition_always:
whismanoid 17:9397ea3ea7e9 6987 cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 6988 break;
whismanoid 17:9397ea3ea7e9 6989 case condition_if_An_gt_threshold:
whismanoid 40:330b28116178 6990 cmdLine.serial().printf(" if A%d > %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6991 break;
whismanoid 17:9397ea3ea7e9 6992 case condition_if_An_lt_threshold:
whismanoid 40:330b28116178 6993 cmdLine.serial().printf(" if A%d < %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6994 break;
whismanoid 17:9397ea3ea7e9 6995 case condition_if_An_eq_threshold:
whismanoid 40:330b28116178 6996 cmdLine.serial().printf(" if A%d == %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6997 break;
whismanoid 17:9397ea3ea7e9 6998 case condition_if_An_ge_threshold:
whismanoid 40:330b28116178 6999 cmdLine.serial().printf(" if A%d >= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7000 break;
whismanoid 17:9397ea3ea7e9 7001 case condition_if_An_le_threshold:
whismanoid 40:330b28116178 7002 cmdLine.serial().printf(" if A%d <= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7003 break;
whismanoid 17:9397ea3ea7e9 7004 case condition_if_An_ne_threshold:
whismanoid 40:330b28116178 7005 cmdLine.serial().printf(" if A%d != %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7006 break;
whismanoid 17:9397ea3ea7e9 7007 case condition_if_AINn_gt_threshold:
whismanoid 40:330b28116178 7008 cmdLine.serial().printf(" if AIN%d > %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7009 break;
whismanoid 17:9397ea3ea7e9 7010 case condition_if_AINn_lt_threshold:
whismanoid 40:330b28116178 7011 cmdLine.serial().printf(" if AIN%d < %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7012 break;
whismanoid 17:9397ea3ea7e9 7013 case condition_if_AINn_eq_threshold:
whismanoid 40:330b28116178 7014 cmdLine.serial().printf(" if AIN%d == %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7015 break;
whismanoid 17:9397ea3ea7e9 7016 case condition_if_AINn_ge_threshold:
whismanoid 40:330b28116178 7017 cmdLine.serial().printf(" if AIN%d >= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7018 break;
whismanoid 17:9397ea3ea7e9 7019 case condition_if_AINn_le_threshold:
whismanoid 40:330b28116178 7020 cmdLine.serial().printf(" if AIN%d <= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7021 break;
whismanoid 17:9397ea3ea7e9 7022 case condition_if_AINn_ne_threshold:
whismanoid 40:330b28116178 7023 cmdLine.serial().printf(" if AIN%d != %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7024 break;
whismanoid 17:9397ea3ea7e9 7025 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 7026 } // for ...Datalogger_action_table_row_count // Print the contents of Datalogger_action_table
whismanoid 30:07197a430869 7027 cmdLine.serial().printf("\r\n\r\nEdit Log action table (used %d/%d, %d free):",
whismanoid 30:07197a430869 7028 Datalogger_action_table_row_count,
whismanoid 30:07197a430869 7029 ACTION_TABLE_ROW_MAX,
whismanoid 30:07197a430869 7030 (ACTION_TABLE_ROW_MAX - Datalogger_action_table_row_count)
whismanoid 30:07197a430869 7031 );
whismanoid 17:9397ea3ea7e9 7032 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 7033 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 7034 cmdLine.serial().printf("\r\n L@+ act=4 if=1 ch=5 x=12345 -- add new entry at end of table");
whismanoid 17:9397ea3ea7e9 7035 }
whismanoid 17:9397ea3ea7e9 7036 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 7037 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 7038 cmdLine.serial().printf("\r\n L@%d act=4 if=1 ch=5 x=12345 -- edit row %d",
whismanoid 17:9397ea3ea7e9 7039 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 7040 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 7041 cmdLine.serial().printf("\r\n L@-%d -- delete row %d",
whismanoid 17:9397ea3ea7e9 7042 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 7043 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 7044 cmdLine.serial().printf("\r\n L@-~~~ -- delete all rows");
whismanoid 30:07197a430869 7045 if (Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@. -- pause entire Log action table");
whismanoid 30:07197a430869 7046 if (!Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@@ -- enable Log action table");
whismanoid 17:9397ea3ea7e9 7047 }
whismanoid 17:9397ea3ea7e9 7048 //
whismanoid 17:9397ea3ea7e9 7049 } // case L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 7050 break;
whismanoid 17:9397ea3ea7e9 7051 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 7052 // LR -- Datalog free run as fast as possible
whismanoid 4:d9b05924ad4c 7053 case 'R': case 'r':
whismanoid 4:d9b05924ad4c 7054 // free run as fast as possible
whismanoid 8:dffee7509bfb 7055 Datalogger_Trigger = trigger_FreeRun;
whismanoid 8:dffee7509bfb 7056 Datalogger_Need_PrintHeader = true;
whismanoid 4:d9b05924ad4c 7057 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 9:45f98573eb6d 7058 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 7059 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 7060 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 7061 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 7062 case 'S': case 's':
whismanoid 9:45f98573eb6d 7063 {
whismanoid 9:45f98573eb6d 7064 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 7065 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 7066 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 7067 )
whismanoid 9:45f98573eb6d 7068 {
whismanoid 9:45f98573eb6d 7069 // it's me
whismanoid 9:45f98573eb6d 7070 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 7071 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 7072 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 7073 {
whismanoid 9:45f98573eb6d 7074 case 'D': case 'd':
whismanoid 9:45f98573eb6d 7075 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Disable;
whismanoid 9:45f98573eb6d 7076 break;
whismanoid 9:45f98573eb6d 7077 case 'L': case 'l':
whismanoid 9:45f98573eb6d 7078 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 7079 break;
whismanoid 9:45f98573eb6d 7080 case 'V': case 'v':
whismanoid 9:45f98573eb6d 7081 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 7082 break;
whismanoid 9:45f98573eb6d 7083 //
whismanoid 9:45f98573eb6d 7084 //
whismanoid 9:45f98573eb6d 7085 // TODO: MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 7086 case 'C': case 'c':
whismanoid 9:45f98573eb6d 7087 {
whismanoid 9:45f98573eb6d 7088 uint8_t hexValue = 0;
whismanoid 9:45f98573eb6d 7089 hexValue = hexValueOfChar(cmdLine[5]) * 0x10 + hexValueOfChar(cmdLine[6]);
whismanoid 9:45f98573eb6d 7090 switch (cmdLine[4])
whismanoid 9:45f98573eb6d 7091 {
whismanoid 9:45f98573eb6d 7092 //
whismanoid 9:45f98573eb6d 7093 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 7094 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34"));
whismanoid 9:45f98573eb6d 7095 case 'F': case 'f':
whismanoid 9:45f98573eb6d 7096 SPI_AIN_Cfg_v_filter_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 7097 break;
whismanoid 9:45f98573eb6d 7098 //
whismanoid 9:45f98573eb6d 7099 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 7100 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 7101 case 'C': case 'c':
whismanoid 9:45f98573eb6d 7102 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 7103 break;
whismanoid 9:45f98573eb6d 7104 //
whismanoid 9:45f98573eb6d 7105 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 7106 // cmdLine.serial().print(F("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00"));
whismanoid 9:45f98573eb6d 7107 case 'P': case 'p':
whismanoid 9:45f98573eb6d 7108 SPI_AIN_Cfg_v_pga_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 7109 break;
whismanoid 9:45f98573eb6d 7110 //
whismanoid 9:45f98573eb6d 7111 // cmdLine.serial().print(F("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar"));
whismanoid 9:45f98573eb6d 7112 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 7113 case 'U': case 'u':
whismanoid 9:45f98573eb6d 7114 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] | 0x40;
whismanoid 9:45f98573eb6d 7115 break;
whismanoid 9:45f98573eb6d 7116 //
whismanoid 9:45f98573eb6d 7117 // cmdLine.serial().print(F("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar"));
whismanoid 9:45f98573eb6d 7118 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 7119 case 'B': case 'b':
whismanoid 9:45f98573eb6d 7120 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] &~ 0x40;
whismanoid 9:45f98573eb6d 7121 break;
whismanoid 9:45f98573eb6d 7122 }
whismanoid 9:45f98573eb6d 7123 break;
whismanoid 9:45f98573eb6d 7124 }
whismanoid 9:45f98573eb6d 7125 //
whismanoid 9:45f98573eb6d 7126 //
whismanoid 9:45f98573eb6d 7127 }
whismanoid 9:45f98573eb6d 7128 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 7129 } // end for channel_index
whismanoid 9:45f98573eb6d 7130 Datalogger_PrintHeader();
whismanoid 9:45f98573eb6d 7131 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 7132 }
whismanoid 9:45f98573eb6d 7133 break;
whismanoid 9:45f98573eb6d 7134 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 7135 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 7136 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 7137 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 7138 // verb: D for disable, V for Voltage, L for LSB
whismanoid 8:dffee7509bfb 7139 case 'A': case 'a':
whismanoid 9:45f98573eb6d 7140 {
whismanoid 9:45f98573eb6d 7141 // all-channel: loop through all valid channel_index, test cmdLine[2] 'is it me'?
whismanoid 9:45f98573eb6d 7142 // for channel_index loop through 0..NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 9:45f98573eb6d 7143 // if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 7144 // || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 7145 // ) {
whismanoid 9:45f98573eb6d 7146 // // it's me
whismanoid 9:45f98573eb6d 7147 // // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 7148 // // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 7149 // } end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 7150 // } end for channel_index
whismanoid 9:45f98573eb6d 7151 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 7152 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 7153 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 7154 )
whismanoid 9:45f98573eb6d 7155 {
whismanoid 9:45f98573eb6d 7156 // it's me
whismanoid 9:45f98573eb6d 7157 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 7158 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 7159 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 7160 {
whismanoid 9:45f98573eb6d 7161 case 'D': case 'd':
whismanoid 9:45f98573eb6d 7162 Platform_Enable_ch[channel_index] = Platform_AIN_Disable;
whismanoid 9:45f98573eb6d 7163 break;
whismanoid 9:45f98573eb6d 7164 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 7165 case 'L': case 'l':
whismanoid 9:45f98573eb6d 7166 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 7167 break;
whismanoid 9:45f98573eb6d 7168 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 7169 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 7170 case 'V': case 'v':
whismanoid 9:45f98573eb6d 7171 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 7172 break;
whismanoid 9:45f98573eb6d 7173 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 7174 }
whismanoid 9:45f98573eb6d 7175 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 7176 } // end for channel_index
whismanoid 10:04022a61b527 7177 // Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 7178 if (Datalogger_enable_serial) {
whismanoid 9:45f98573eb6d 7179 Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 7180 }
whismanoid 9:45f98573eb6d 7181 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 7182 if (Datalogger_enable_AUXserial) {
whismanoid 9:45f98573eb6d 7183 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 9:45f98573eb6d 7184 }
whismanoid 9:45f98573eb6d 7185 # endif // HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 7186 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 7187 if (Datalogger_enable_DAPLINKserial) {
whismanoid 9:45f98573eb6d 7188 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 9:45f98573eb6d 7189 }
whismanoid 9:45f98573eb6d 7190 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 7191 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 7192 }
whismanoid 8:dffee7509bfb 7193 break;
whismanoid 9:45f98573eb6d 7194 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 7195 case '>':
whismanoid 9:45f98573eb6d 7196 // L>A -- Datalogger_enable_AUXserial
whismanoid 9:45f98573eb6d 7197 // L>D -- Datalogger_enable_DAPLINKserial
whismanoid 9:45f98573eb6d 7198 // L>S -- Datalogger_enable_serial
whismanoid 9:45f98573eb6d 7199 switch (cmdLine[2])
whismanoid 9:45f98573eb6d 7200 {
whismanoid 9:45f98573eb6d 7201 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 7202 case 'A': case 'a':
whismanoid 9:45f98573eb6d 7203 Datalogger_enable_AUXserial = !Datalogger_enable_AUXserial;
whismanoid 9:45f98573eb6d 7204 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 7205 break;
whismanoid 8:dffee7509bfb 7206 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 7207 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 7208 case 'D': case 'd':
whismanoid 9:45f98573eb6d 7209 Datalogger_enable_DAPLINKserial = !Datalogger_enable_DAPLINKserial;
whismanoid 9:45f98573eb6d 7210 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 7211 break;
whismanoid 8:dffee7509bfb 7212 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 7213 case 'S': case 's':
whismanoid 9:45f98573eb6d 7214 Datalogger_enable_serial = !Datalogger_enable_serial;
whismanoid 9:45f98573eb6d 7215 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 7216 break;
whismanoid 9:45f98573eb6d 7217 }
whismanoid 9:45f98573eb6d 7218 break; // case '>' L>S serial enable toggle
whismanoid 28:a9a3a9db592b 7219 default:
whismanoid 28:a9a3a9db592b 7220 // TODO: L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 7221 //
whismanoid 28:a9a3a9db592b 7222 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 7223 #if 1 // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 7224 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 7225 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 7226 //
whismanoid 28:a9a3a9db592b 7227 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 28:a9a3a9db592b 7228 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 39:4d285e961435 7229 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 7230 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 7231 cmdLine.serial().printf("\r\n LT count=%d base=%dms sleep=%d -- Datalog timer",
whismanoid 39:4d285e961435 7232 g_timer_interval_count,
whismanoid 39:4d285e961435 7233 g_timer_interval_msec,
whismanoid 39:4d285e961435 7234 (int)g_timer_sleepmode
whismanoid 39:4d285e961435 7235 ); // trigger_Timer
whismanoid 39:4d285e961435 7236 #else // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 7237 cmdLine.serial().printf("\r\n LT count=%d base=%dms -- Datalog timer", g_timer_interval_count, g_timer_interval_msec); // trigger_Timer
whismanoid 39:4d285e961435 7238 #endif // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 7239 //
whismanoid 28:a9a3a9db592b 7240 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 28:a9a3a9db592b 7241 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 7242 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 7243 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 7244 //
whismanoid 28:a9a3a9db592b 7245 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 7246 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 28:a9a3a9db592b 7247 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 7248 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
whismanoid 28:a9a3a9db592b 7249 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 7250 //
whismanoid 28:a9a3a9db592b 7251 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 7252 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 7253 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 7254 //
whismanoid 28:a9a3a9db592b 7255 //
whismanoid 28:a9a3a9db592b 7256 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 7257 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 28:a9a3a9db592b 7258 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 7259 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 7260 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 28:a9a3a9db592b 7261 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 28:a9a3a9db592b 7262 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 28:a9a3a9db592b 7263 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 28:a9a3a9db592b 7264 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 28:a9a3a9db592b 7265 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 28:a9a3a9db592b 7266 //
whismanoid 28:a9a3a9db592b 7267 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 28:a9a3a9db592b 7268 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 28:a9a3a9db592b 7269 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 28:a9a3a9db592b 7270 //
whismanoid 28:a9a3a9db592b 7271 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 7272 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 28:a9a3a9db592b 7273 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 28:a9a3a9db592b 7274 //
whismanoid 28:a9a3a9db592b 7275 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 7276 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 28:a9a3a9db592b 7277 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 7278 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 28:a9a3a9db592b 7279 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 7280 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 28:a9a3a9db592b 7281 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 7282 //
whismanoid 28:a9a3a9db592b 7283 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 28:a9a3a9db592b 7284 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 28:a9a3a9db592b 7285 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 28:a9a3a9db592b 7286 //
whismanoid 28:a9a3a9db592b 7287 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 7288 //
whismanoid 28:a9a3a9db592b 7289 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 28:a9a3a9db592b 7290 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 28:a9a3a9db592b 7291 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 7292 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 7293 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 28:a9a3a9db592b 7294 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 7295 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 28:a9a3a9db592b 7296 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 7297 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 7298 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 28:a9a3a9db592b 7299 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 7300 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 28:a9a3a9db592b 7301 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 7302 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 28:a9a3a9db592b 7303 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 7304 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 7305 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 28:a9a3a9db592b 7306 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 7307 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 7308 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 7309 # if HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 7310 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 7311 # endif // HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 7312 # if HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 7313 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 7314 # endif // HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 7315 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 7316 //
whismanoid 28:a9a3a9db592b 7317 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 7318 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 7319 break;
whismanoid 17:9397ea3ea7e9 7320 } // switch (cmdLine[1]) inside case 'L'
whismanoid 4:d9b05924ad4c 7321 }
whismanoid 4:d9b05924ad4c 7322 break; // case 'L'
whismanoid 4:d9b05924ad4c 7323 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 7324 //
whismanoid 4:d9b05924ad4c 7325 // Application-specific commands here
whismanoid 4:d9b05924ad4c 7326 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 7327 //
whismanoid 4:d9b05924ad4c 7328 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 7329 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 7330
whismanoid 4:d9b05924ad4c 7331 //
whismanoid 4:d9b05924ad4c 7332 // TODO1: add new commands here
whismanoid 4:d9b05924ad4c 7333 //
whismanoid 4:d9b05924ad4c 7334 default:
whismanoid 4:d9b05924ad4c 7335 #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 7336 extern bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5715.cpp
whismanoid 4:d9b05924ad4c 7337 if (!MAX5715_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 7338 #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 7339 extern bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11131.cpp
whismanoid 4:d9b05924ad4c 7340 if (!MAX11131_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 7341 #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 7342 extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp
whismanoid 4:d9b05924ad4c 7343 if (!MAX5171_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 7344 #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 7345 extern bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp
whismanoid 4:d9b05924ad4c 7346 if (!MAX11410_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 7347 #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 7348 extern bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX12345.cpp
whismanoid 4:d9b05924ad4c 7349 if (!MAX12345_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 7350 #else
whismanoid 4:d9b05924ad4c 7351 if (0) // not_handled_by_device_submenu
whismanoid 4:d9b05924ad4c 7352 #endif
whismanoid 4:d9b05924ad4c 7353 {
whismanoid 4:d9b05924ad4c 7354 cmdLine.serial().printf("\r\n unknown command ");
whismanoid 4:d9b05924ad4c 7355 //~ cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 7356 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 7357 cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n",
whismanoid 4:d9b05924ad4c 7358 cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 7359 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7360 }
whismanoid 4:d9b05924ad4c 7361 } // switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 7362 //
whismanoid 31:47eee7e0cc2d 7363 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 7364 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 7365 // print command prompt
whismanoid 8:dffee7509bfb 7366 // print_command_prompt();
whismanoid 8:dffee7509bfb 7367 cmdLine.serial().printf("\r\n> ");
whismanoid 31:47eee7e0cc2d 7368 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 7369 }
whismanoid 4:d9b05924ad4c 7370 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 7371
whismanoid 4:d9b05924ad4c 7372 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 7373 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 7374 void Datalogger_PrintHeader(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 7375 {
whismanoid 37:3f369235e5bc 7376 #if MAX40108_DEMO // main_menu_status banner
whismanoid 37:3f369235e5bc 7377 cmdLine.serial().printf("\r\n\r\n\"MAX40108_U%d", MAX40108_DEMO);
whismanoid 37:3f369235e5bc 7378 #ifdef BOARD_SERIAL_NUMBER
whismanoid 37:3f369235e5bc 7379 // data unique to certain boards based on serial number
whismanoid 49:359a6b9df7c1 7380 cmdLine.serial().printf(" [s/n %ld]", g_board_serial_number);
whismanoid 37:3f369235e5bc 7381 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 7382 #ifdef FW_REV
whismanoid 37:3f369235e5bc 7383 cmdLine.serial().printf(" [FW_REV %d]", FW_REV);
whismanoid 37:3f369235e5bc 7384 #endif // FW_REV
whismanoid 37:3f369235e5bc 7385 cmdLine.serial().printf("\"\r\n");
whismanoid 37:3f369235e5bc 7386 #endif // MAX40108_DEMO
whismanoid 37:3f369235e5bc 7387
whismanoid 4:d9b05924ad4c 7388 // column header banner for csv data columns
whismanoid 4:d9b05924ad4c 7389 int field_index = 0;
whismanoid 4:d9b05924ad4c 7390 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 7391 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 7392 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 4:d9b05924ad4c 7393 continue;
whismanoid 4:d9b05924ad4c 7394 }
whismanoid 4:d9b05924ad4c 7395 // comma between fields
whismanoid 4:d9b05924ad4c 7396 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 7397 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 7398 }
whismanoid 10:04022a61b527 7399 field_index++;
whismanoid 4:d9b05924ad4c 7400 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 7401 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 7402 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 4:d9b05924ad4c 7403 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 4:d9b05924ad4c 7404 cmdLine.serial().printf("\"AIN%d-%d_BIP", channel_index, channel_index+1);
whismanoid 4:d9b05924ad4c 7405 }
whismanoid 4:d9b05924ad4c 7406 else {
whismanoid 4:d9b05924ad4c 7407 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 7408 }
whismanoid 4:d9b05924ad4c 7409 #else // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 7410 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 7411 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 7412 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_LSB) {
whismanoid 4:d9b05924ad4c 7413 // _LSB column header suffix
whismanoid 13:184a08909405 7414 cmdLine.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 7415 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7416 cmdLine_DAPLINKserial.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 7417 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7418 }
whismanoid 10:04022a61b527 7419 else if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_Volt) {
whismanoid 4:d9b05924ad4c 7420 // _V column header suffix
whismanoid 13:184a08909405 7421 cmdLine.serial().printf("_V");
whismanoid 4:d9b05924ad4c 7422 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7423 cmdLine_DAPLINKserial.serial().printf("_V");
whismanoid 4:d9b05924ad4c 7424 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7425 }
whismanoid 13:184a08909405 7426 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 7427 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 7428 if (SPI_AIN_customChannelHeader_ch[channel_index] && SPI_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 7429 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 7430 cmdLine.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 7431 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7432 cmdLine_DAPLINKserial.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 7433 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7434 } else {
whismanoid 13:184a08909405 7435 // no custom channel name for this channel
whismanoid 13:184a08909405 7436 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 7437 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7438 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 7439 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7440 }
whismanoid 13:184a08909405 7441 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 7442 // close quote
whismanoid 13:184a08909405 7443 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 7444 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7445 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 7446 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7447 }
whismanoid 4:d9b05924ad4c 7448
whismanoid 4:d9b05924ad4c 7449 #if VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 7450 // PART_ID field: Device ID Validation
whismanoid 4:d9b05924ad4c 7451 cmdLine.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 7452 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7453 cmdLine_DAPLINKserial.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 7454 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7455 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 7456 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 7457 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 7458 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 7459 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 7460 continue;
whismanoid 9:45f98573eb6d 7461 }
whismanoid 4:d9b05924ad4c 7462 // comma between fields
whismanoid 4:d9b05924ad4c 7463 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 7464 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 7465 }
whismanoid 9:45f98573eb6d 7466 field_index++;
whismanoid 4:d9b05924ad4c 7467 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 7468 cmdLine.serial().printf("\"A%d", channel_index);
whismanoid 9:45f98573eb6d 7469 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 9:45f98573eb6d 7470 // _LSB column header suffix
whismanoid 13:184a08909405 7471 cmdLine.serial().printf("_LSB");
whismanoid 9:45f98573eb6d 7472 }
whismanoid 9:45f98573eb6d 7473 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 7474 // _V column header suffix
whismanoid 13:184a08909405 7475 cmdLine.serial().printf("_V");
whismanoid 9:45f98573eb6d 7476 }
whismanoid 13:184a08909405 7477 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 7478 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 7479 if (Platform_AIN_customChannelHeader_ch[channel_index] && Platform_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 7480 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 7481 cmdLine.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 7482 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7483 cmdLine_DAPLINKserial.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 7484 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7485 } else {
whismanoid 13:184a08909405 7486 // no custom channel name for this channel
whismanoid 13:184a08909405 7487 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 7488 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7489 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 7490 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7491 }
whismanoid 13:184a08909405 7492 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 7493 // close quote
whismanoid 13:184a08909405 7494 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 7495 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7496 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 7497 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7498 }
whismanoid 4:d9b05924ad4c 7499 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 30:07197a430869 7500 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 7501 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in Datalogger_PrintHeader
whismanoid 30:07197a430869 7502 cmdLine.serial().printf(",\"%s\"", gstrRemarkHeader);
whismanoid 30:07197a430869 7503 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 4:d9b05924ad4c 7504 // end of column header line
whismanoid 4:d9b05924ad4c 7505 cmdLine.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 7506 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7507 cmdLine_DAPLINKserial.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 7508 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7509 } // void Datalogger_PrintHeader()
whismanoid 4:d9b05924ad4c 7510
whismanoid 5:aaf8b5f5fda1 7511 //--------------------------------------------------
whismanoid 5:aaf8b5f5fda1 7512 void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 7513 {
whismanoid 5:aaf8b5f5fda1 7514 // CODE GENERATOR: example code: has no member function ScanStandardExternalClock
whismanoid 5:aaf8b5f5fda1 7515 // CODE GENERATOR: example code: has no member function ReadAINcode
whismanoid 5:aaf8b5f5fda1 7516 // CODE GENERATOR: example code: member function Read_All_Voltages
whismanoid 5:aaf8b5f5fda1 7517 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7518 // Measure ADC channels in sequence from AIN0 to channelNumber_0_9.
whismanoid 5:aaf8b5f5fda1 7519 // @param[in] g_MAX11410_device.channelNumber_0_15: AIN Channel Number
whismanoid 5:aaf8b5f5fda1 7520 // @param[in] g_MAX11410_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
whismanoid 5:aaf8b5f5fda1 7521 // @param[in] g_MAX11410_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
whismanoid 10:04022a61b527 7522 //~ int channelId_0_9 = NUM_DUT_ANALOG_IN_CHANNELS-1+1;
whismanoid 5:aaf8b5f5fda1 7523 //g_MAX11410_device.channelNumber_0_15 = channelId_0_9;
whismanoid 5:aaf8b5f5fda1 7524 //g_MAX11410_device.PowerManagement_0_2 = 0;
whismanoid 5:aaf8b5f5fda1 7525 //g_MAX11410_device.chan_id_0_1 = 1;
whismanoid 5:aaf8b5f5fda1 7526 //----------------------------------------
whismanoid 5:aaf8b5f5fda1 7527 // scan AIN0..AIN9
whismanoid 5:aaf8b5f5fda1 7528 //
whismanoid 10:04022a61b527 7529 #if 1
whismanoid 10:04022a61b527 7530 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 7531 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 7532 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 7533 //
whismanoid 10:04022a61b527 7534 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7535 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc3); // GP1 = 0
whismanoid 10:04022a61b527 7536 //
whismanoid 10:04022a61b527 7537 int field_index = 0;
whismanoid 10:04022a61b527 7538 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 7539 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 10:04022a61b527 7540 continue;
whismanoid 10:04022a61b527 7541 }
whismanoid 10:04022a61b527 7542 field_index++;
whismanoid 10:04022a61b527 7543 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[channel_index];
whismanoid 10:04022a61b527 7544 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[channel_index];
whismanoid 10:04022a61b527 7545 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[channel_index];
whismanoid 10:04022a61b527 7546 //
whismanoid 10:04022a61b527 7547 // WIP SampleRate_of_FILTER_CONV_START() MAX11410EMC-FW slow ODR 10Sps #262
whismanoid 10:04022a61b527 7548 // adjust the MAX11410.loop_limit value if the sample rate is set to a value slower than 20sps
whismanoid 10:04022a61b527 7549 // SampleRate_of_FILTER_CONV_START(uint8_t FILTER_RegValue, uint8_t CONV_START_RegValue)
whismanoid 10:04022a61b527 7550 double SampleRate = g_MAX11410_device.SampleRate_of_FILTER_CONV_START(g_MAX11410_device.v_filter, MAX11410::MAX11410_CONV_TYPE_enum_t::CONV_TYPE_01_Continuous);
whismanoid 10:04022a61b527 7551 if (SampleRate < 20.0) {
whismanoid 10:04022a61b527 7552 g_MAX11410_device.loop_limit = 32767; // TODO: is this timeout long enough for the slow output data rates?
whismanoid 10:04022a61b527 7553 }
whismanoid 10:04022a61b527 7554 //
whismanoid 10:04022a61b527 7555 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7556 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc3); // GP0 = 0
whismanoid 10:04022a61b527 7557 //
whismanoid 10:04022a61b527 7558 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 7559 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 10:04022a61b527 7560 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 10:04022a61b527 7561 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 7562 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = (MAX11410::MAX11410_AINN_SEL_enum_t)(channel_index^1);
whismanoid 10:04022a61b527 7563 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 7564 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 7565 }
whismanoid 10:04022a61b527 7566 else {
whismanoid 10:04022a61b527 7567 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 7568 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = MAX11410::AINN_SEL_1010_GND;
whismanoid 10:04022a61b527 7569 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 7570 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 7571 }
whismanoid 10:04022a61b527 7572 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 7573 //
whismanoid 10:04022a61b527 7574 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7575 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc4); // GP0 = 1
whismanoid 10:04022a61b527 7576 //
whismanoid 10:04022a61b527 7577 }
whismanoid 10:04022a61b527 7578 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7579 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc4); // GP1 = 1
whismanoid 10:04022a61b527 7580 #else
whismanoid 5:aaf8b5f5fda1 7581 g_MAX11410_device.Read_All_Voltages();
whismanoid 10:04022a61b527 7582 #endif
whismanoid 10:04022a61b527 7583 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7584 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 7585 // mbed
whismanoid 5:aaf8b5f5fda1 7586 // Platform board uses simple analog inputs
whismanoid 5:aaf8b5f5fda1 7587 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 5:aaf8b5f5fda1 7588 Platform_LSB[0] = analogIn0.read();
whismanoid 5:aaf8b5f5fda1 7589 Platform_LSB[1] = analogIn1.read();
whismanoid 5:aaf8b5f5fda1 7590 Platform_LSB[2] = analogIn2.read();
whismanoid 5:aaf8b5f5fda1 7591 Platform_LSB[3] = analogIn3.read();
whismanoid 5:aaf8b5f5fda1 7592 Platform_LSB[4] = analogIn4.read();
whismanoid 5:aaf8b5f5fda1 7593 Platform_LSB[5] = analogIn5.read();
whismanoid 10:04022a61b527 7594 #endif
whismanoid 10:04022a61b527 7595 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 37:3f369235e5bc 7596 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 7597 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogIn012345.read()
whismanoid 37:3f369235e5bc 7598 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 7599 float analogIn0_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7600 float analogIn1_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7601 float analogIn2_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7602 float analogIn3_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7603 float analogIn4_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7604 float analogIn5_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7605 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 7606 analogIn0_normValue_0_1 = analogIn0_normValue_0_1 + analogIn0.read();
whismanoid 37:3f369235e5bc 7607 analogIn1_normValue_0_1 = analogIn1_normValue_0_1 + analogIn1.read();
whismanoid 37:3f369235e5bc 7608 analogIn2_normValue_0_1 = analogIn2_normValue_0_1 + analogIn2.read();
whismanoid 37:3f369235e5bc 7609 analogIn3_normValue_0_1 = analogIn3_normValue_0_1 + analogIn3.read();
whismanoid 37:3f369235e5bc 7610 analogIn4_normValue_0_1 = analogIn4_normValue_0_1 + analogIn4.read();
whismanoid 37:3f369235e5bc 7611 analogIn5_normValue_0_1 = analogIn5_normValue_0_1 + analogIn5.read();
whismanoid 37:3f369235e5bc 7612 }
whismanoid 37:3f369235e5bc 7613 analogIn0_normValue_0_1 = analogIn0_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7614 analogIn1_normValue_0_1 = analogIn1_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7615 analogIn2_normValue_0_1 = analogIn2_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7616 analogIn3_normValue_0_1 = analogIn3_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7617 analogIn4_normValue_0_1 = analogIn4_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7618 analogIn5_normValue_0_1 = analogIn5_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7619 #else // USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 7620 float analogIn0_normValue_0_1 = analogIn0.read();
whismanoid 37:3f369235e5bc 7621 float analogIn1_normValue_0_1 = analogIn1.read();
whismanoid 37:3f369235e5bc 7622 float analogIn2_normValue_0_1 = analogIn2.read();
whismanoid 37:3f369235e5bc 7623 float analogIn3_normValue_0_1 = analogIn3.read();
whismanoid 37:3f369235e5bc 7624 float analogIn4_normValue_0_1 = analogIn4.read();
whismanoid 37:3f369235e5bc 7625 float analogIn5_normValue_0_1 = analogIn5.read();
whismanoid 37:3f369235e5bc 7626 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 7627 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 7628 // apply calibration to normValue_0_1 value
whismanoid 37:3f369235e5bc 7629 Platform_Voltage[0] = CalibratedNormValue(0, analogIn0_normValue_0_1) * adc_full_scale_voltage[0];
whismanoid 37:3f369235e5bc 7630 Platform_Voltage[1] = CalibratedNormValue(1, analogIn1_normValue_0_1) * adc_full_scale_voltage[1];
whismanoid 37:3f369235e5bc 7631 Platform_Voltage[2] = CalibratedNormValue(2, analogIn2_normValue_0_1) * adc_full_scale_voltage[2];
whismanoid 37:3f369235e5bc 7632 Platform_Voltage[3] = CalibratedNormValue(3, analogIn3_normValue_0_1) * adc_full_scale_voltage[3];
whismanoid 37:3f369235e5bc 7633 Platform_Voltage[4] = CalibratedNormValue(4, analogIn4_normValue_0_1) * adc_full_scale_voltage[4];
whismanoid 37:3f369235e5bc 7634 Platform_Voltage[5] = CalibratedNormValue(5, analogIn5_normValue_0_1) * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 7635 #else // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 7636 Platform_Voltage[0] = analogIn0_normValue_0_1 * adc_full_scale_voltage[0];
whismanoid 37:3f369235e5bc 7637 Platform_Voltage[1] = analogIn1_normValue_0_1 * adc_full_scale_voltage[1];
whismanoid 37:3f369235e5bc 7638 Platform_Voltage[2] = analogIn2_normValue_0_1 * adc_full_scale_voltage[2];
whismanoid 37:3f369235e5bc 7639 Platform_Voltage[3] = analogIn3_normValue_0_1 * adc_full_scale_voltage[3];
whismanoid 37:3f369235e5bc 7640 Platform_Voltage[4] = analogIn4_normValue_0_1 * adc_full_scale_voltage[4];
whismanoid 37:3f369235e5bc 7641 Platform_Voltage[5] = analogIn5_normValue_0_1 * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 7642 #endif // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 7643 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 5:aaf8b5f5fda1 7644 #endif // defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 7645
whismanoid 5:aaf8b5f5fda1 7646 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7647 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 7648 const uint32_t part_id_expect = 0x000F02;
whismanoid 5:aaf8b5f5fda1 7649 uint32_t part_id_readback;
whismanoid 5:aaf8b5f5fda1 7650 g_MAX11410_device.RegRead(MAX11410::CMD_r001_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xddd_PART_ID, &part_id_readback);
whismanoid 5:aaf8b5f5fda1 7651 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7652 } // void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 7653
whismanoid 17:9397ea3ea7e9 7654 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 7655 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 7656 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 7657 void Datalogger_RunActionTable()
whismanoid 17:9397ea3ea7e9 7658 {
whismanoid 17:9397ea3ea7e9 7659 if (Datalogger_action_table_enabled == false) {
whismanoid 17:9397ea3ea7e9 7660 return;
whismanoid 17:9397ea3ea7e9 7661 }
whismanoid 17:9397ea3ea7e9 7662 // TODO: verbose Datalogger_RunActionTable() emit a csv column ,"Action"
whismanoid 17:9397ea3ea7e9 7663 // TODO: assert Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX
whismanoid 17:9397ea3ea7e9 7664 // for Datalogger_action_table[0..Datalogger_action_table_row_count]
whismanoid 17:9397ea3ea7e9 7665 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 7666 {
whismanoid 17:9397ea3ea7e9 7667 // skip if Datalogger_action_table[i].action == action_noop
whismanoid 17:9397ea3ea7e9 7668 if (Datalogger_action_table[i].action == action_noop) {
whismanoid 17:9397ea3ea7e9 7669 continue;
whismanoid 17:9397ea3ea7e9 7670 }
whismanoid 17:9397ea3ea7e9 7671 // TODO: test Datalogger_action_table[i].condition "if="
whismanoid 17:9397ea3ea7e9 7672 // TODO: Could the .condition field also distinguish Platform ADC from SPI ADC?
whismanoid 17:9397ea3ea7e9 7673 // That way we keep both sets of ADC channels in separate lists
whismanoid 17:9397ea3ea7e9 7674 // if=0 -- always
whismanoid 17:9397ea3ea7e9 7675 // if=1,2,3,4,5,6 -- Platform_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 7676 // if=7,8,9,10,11,12 -- SPI_AIN_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 7677 // also, are we comparing code or voltage?
whismanoid 17:9397ea3ea7e9 7678 // TODO: selected Datalogger_action_table[i].condition_channel
whismanoid 17:9397ea3ea7e9 7679 // Datalogger could have both platform ADC and external SPI ADC channels
whismanoid 17:9397ea3ea7e9 7680 // if SPI_ADC_DeviceName
whismanoid 17:9397ea3ea7e9 7681 // NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 7682 // SPI_AIN_Enable_ch[]
whismanoid 17:9397ea3ea7e9 7683 // SPI_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 7684 // SPI_AIN_Voltage[]
whismanoid 17:9397ea3ea7e9 7685 // if LOG_PLATFORM_AIN
whismanoid 17:9397ea3ea7e9 7686 // NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 7687 // analogInPin_fullScaleVoltage[]
whismanoid 17:9397ea3ea7e9 7688 // Platform_Enable_ch[]
whismanoid 17:9397ea3ea7e9 7689 // Platform_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 7690 // Platform_Voltage[]
whismanoid 17:9397ea3ea7e9 7691 // TODO: selected Datalogger_action_table[i].condition_threshold
whismanoid 17:9397ea3ea7e9 7692 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 7693 {
whismanoid 17:9397ea3ea7e9 7694 case condition_always:
whismanoid 17:9397ea3ea7e9 7695 //~ cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 7696 break;
whismanoid 17:9397ea3ea7e9 7697 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 7698 //~ cmdLine.serial().printf(" if A%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7699 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7700 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7701 continue;
whismanoid 17:9397ea3ea7e9 7702 }
whismanoid 17:9397ea3ea7e9 7703 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7704 break;
whismanoid 17:9397ea3ea7e9 7705 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 7706 //~ cmdLine.serial().printf(" if A%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7707 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7708 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7709 continue;
whismanoid 17:9397ea3ea7e9 7710 }
whismanoid 17:9397ea3ea7e9 7711 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7712 break;
whismanoid 17:9397ea3ea7e9 7713 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 7714 //~ cmdLine.serial().printf(" if A%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7715 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7716 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7717 continue;
whismanoid 17:9397ea3ea7e9 7718 }
whismanoid 17:9397ea3ea7e9 7719 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7720 break;
whismanoid 17:9397ea3ea7e9 7721 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 7722 //~ cmdLine.serial().printf(" if A%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7723 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7724 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7725 continue;
whismanoid 17:9397ea3ea7e9 7726 }
whismanoid 17:9397ea3ea7e9 7727 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7728 break;
whismanoid 17:9397ea3ea7e9 7729 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 7730 //~ cmdLine.serial().printf(" if A%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7731 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7732 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7733 continue;
whismanoid 17:9397ea3ea7e9 7734 }
whismanoid 17:9397ea3ea7e9 7735 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7736 break;
whismanoid 17:9397ea3ea7e9 7737 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 7738 //~ cmdLine.serial().printf(" if A%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7739 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7740 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7741 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7742 continue;
whismanoid 17:9397ea3ea7e9 7743 }
whismanoid 17:9397ea3ea7e9 7744 break;
whismanoid 17:9397ea3ea7e9 7745 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 7746 //~ cmdLine.serial().printf(" if AIN%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7747 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7748 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7749 continue;
whismanoid 17:9397ea3ea7e9 7750 }
whismanoid 17:9397ea3ea7e9 7751 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7752 break;
whismanoid 17:9397ea3ea7e9 7753 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 7754 //~ cmdLine.serial().printf(" if AIN%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7755 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7756 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7757 continue;
whismanoid 17:9397ea3ea7e9 7758 }
whismanoid 17:9397ea3ea7e9 7759 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7760 break;
whismanoid 17:9397ea3ea7e9 7761 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 7762 //~ cmdLine.serial().printf(" if AIN%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7763 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7764 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7765 continue;
whismanoid 17:9397ea3ea7e9 7766 }
whismanoid 17:9397ea3ea7e9 7767 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7768 break;
whismanoid 17:9397ea3ea7e9 7769 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 7770 //~ cmdLine.serial().printf(" if AIN%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7771 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7772 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7773 continue;
whismanoid 17:9397ea3ea7e9 7774 }
whismanoid 17:9397ea3ea7e9 7775 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7776 break;
whismanoid 17:9397ea3ea7e9 7777 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 7778 //~ cmdLine.serial().printf(" if AIN%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7779 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7780 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7781 continue;
whismanoid 17:9397ea3ea7e9 7782 }
whismanoid 17:9397ea3ea7e9 7783 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7784 break;
whismanoid 17:9397ea3ea7e9 7785 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 7786 //~ cmdLine.serial().printf(" if AIN%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7787 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7788 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7789 continue;
whismanoid 17:9397ea3ea7e9 7790 }
whismanoid 17:9397ea3ea7e9 7791 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7792 break;
whismanoid 17:9397ea3ea7e9 7793 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 7794 // selected Datalogger_action_table[i].digitalOutPin
whismanoid 17:9397ea3ea7e9 7795 // perform selected Datalogger_action_table[i].action
whismanoid 17:9397ea3ea7e9 7796 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 7797 {
whismanoid 17:9397ea3ea7e9 7798 case action_noop:
whismanoid 17:9397ea3ea7e9 7799 //~ cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 7800 break;
whismanoid 17:9397ea3ea7e9 7801 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 7802 {
whismanoid 17:9397ea3ea7e9 7803 //~ cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 7804 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 7805 // perform action digitalOutLow
whismanoid 17:9397ea3ea7e9 7806 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 7807 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 7808 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7809 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7810 #else
whismanoid 17:9397ea3ea7e9 7811 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 7812 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 7813 digitalInOutPin.write(0);
whismanoid 17:9397ea3ea7e9 7814 #endif
whismanoid 17:9397ea3ea7e9 7815 }
whismanoid 17:9397ea3ea7e9 7816 break;
whismanoid 17:9397ea3ea7e9 7817 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 7818 {
whismanoid 17:9397ea3ea7e9 7819 //~ cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 7820 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 7821 // perform action digitalOutHigh
whismanoid 17:9397ea3ea7e9 7822 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 7823 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 7824 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7825 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7826 #else
whismanoid 17:9397ea3ea7e9 7827 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 7828 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 7829 digitalInOutPin.write(1);
whismanoid 17:9397ea3ea7e9 7830 #endif
whismanoid 17:9397ea3ea7e9 7831 }
whismanoid 17:9397ea3ea7e9 7832 break;
whismanoid 29:6a9edb6e973b 7833 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 7834 {
whismanoid 30:07197a430869 7835 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 7836 Datalogger_Trigger_enum_t saved_Datalogger_Trigger = Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 7837 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7838 switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 7839 {
whismanoid 29:6a9edb6e973b 7840 case 1:
whismanoid 29:6a9edb6e973b 7841 onButton1FallingEdge();
whismanoid 29:6a9edb6e973b 7842 break;
whismanoid 29:6a9edb6e973b 7843 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7844 case 2:
whismanoid 29:6a9edb6e973b 7845 onButton2FallingEdge();
whismanoid 29:6a9edb6e973b 7846 break;
whismanoid 29:6a9edb6e973b 7847 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7848 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7849 case 3:
whismanoid 29:6a9edb6e973b 7850 onButton3FallingEdge();
whismanoid 29:6a9edb6e973b 7851 break;
whismanoid 29:6a9edb6e973b 7852 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7853 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7854 case 4:
whismanoid 29:6a9edb6e973b 7855 onButton4FallingEdge();
whismanoid 29:6a9edb6e973b 7856 break;
whismanoid 29:6a9edb6e973b 7857 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7858 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7859 case 5:
whismanoid 29:6a9edb6e973b 7860 onButton5FallingEdge();
whismanoid 29:6a9edb6e973b 7861 break;
whismanoid 29:6a9edb6e973b 7862 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7863 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7864 case 6:
whismanoid 29:6a9edb6e973b 7865 onButton6FallingEdge();
whismanoid 29:6a9edb6e973b 7866 break;
whismanoid 29:6a9edb6e973b 7867 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7868 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7869 case 7:
whismanoid 29:6a9edb6e973b 7870 onButton7FallingEdge();
whismanoid 29:6a9edb6e973b 7871 break;
whismanoid 29:6a9edb6e973b 7872 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7873 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7874 case 8:
whismanoid 29:6a9edb6e973b 7875 onButton8FallingEdge();
whismanoid 29:6a9edb6e973b 7876 break;
whismanoid 29:6a9edb6e973b 7877 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7878 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7879 case 9:
whismanoid 29:6a9edb6e973b 7880 onButton9FallingEdge();
whismanoid 29:6a9edb6e973b 7881 break;
whismanoid 29:6a9edb6e973b 7882 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7883 } // switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 7884 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 30:07197a430869 7885 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 7886 Datalogger_Trigger = saved_Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 7887 } // case action_button
whismanoid 29:6a9edb6e973b 7888 break;
whismanoid 17:9397ea3ea7e9 7889 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 7890 //~ cmdLine.serial().printf("trigger_Halt");
whismanoid 17:9397ea3ea7e9 7891 // perform action trigger_Halt
whismanoid 17:9397ea3ea7e9 7892 Datalogger_Trigger = trigger_Halt;
whismanoid 17:9397ea3ea7e9 7893 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7894 break;
whismanoid 17:9397ea3ea7e9 7895 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 7896 //~ cmdLine.serial().printf("trigger_FreeRun");
whismanoid 17:9397ea3ea7e9 7897 // perform action trigger_FreeRun
whismanoid 17:9397ea3ea7e9 7898 Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 7899 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7900 break;
whismanoid 17:9397ea3ea7e9 7901 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 7902 //~ cmdLine.serial().printf("trigger_Timer");
whismanoid 17:9397ea3ea7e9 7903 //~ // print configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 7904 //~ cmdLine.serial().printf("(%d x %dmsec)", g_timer_interval_count, g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 7905 // perform action trigger_Timer
whismanoid 17:9397ea3ea7e9 7906 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 7907 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7908 break;
whismanoid 17:9397ea3ea7e9 7909 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 7910 //~ cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 7911 //~ // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 7912 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 7913 // TODO: perform action action_trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 7914 Datalogger_Trigger = trigger_PlatformDigitalInput;
whismanoid 17:9397ea3ea7e9 7915 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7916 break;
whismanoid 17:9397ea3ea7e9 7917 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 7918 //~ cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 7919 //~ // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 7920 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 7921 // TODO: perform action action_trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 7922 Datalogger_Trigger = trigger_SPIDeviceRegRead;
whismanoid 17:9397ea3ea7e9 7923 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7924 break;
whismanoid 17:9397ea3ea7e9 7925 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 7926 // consider next row of action table
whismanoid 17:9397ea3ea7e9 7927 } // for ...Datalogger_action_table_row_count
whismanoid 17:9397ea3ea7e9 7928 }
whismanoid 17:9397ea3ea7e9 7929 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 7930
whismanoid 5:aaf8b5f5fda1 7931 //--------------------------------------------------
whismanoid 8:dffee7509bfb 7932 void Datalogger_PrintRow(CmdLine& cmdLine)
whismanoid 5:aaf8b5f5fda1 7933 {
whismanoid 5:aaf8b5f5fda1 7934 int field_index = 0;
whismanoid 5:aaf8b5f5fda1 7935 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 7936 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 7937 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 5:aaf8b5f5fda1 7938 continue;
whismanoid 5:aaf8b5f5fda1 7939 }
whismanoid 5:aaf8b5f5fda1 7940 // comma between fields
whismanoid 5:aaf8b5f5fda1 7941 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 7942 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 7943 }
whismanoid 10:04022a61b527 7944 field_index++;
whismanoid 10:04022a61b527 7945 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 10:04022a61b527 7946 cmdLine.serial().printf("%d", g_MAX11410_device.AINcode[channel_index]);
whismanoid 10:04022a61b527 7947 }
whismanoid 10:04022a61b527 7948 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 10:04022a61b527 7949 // TODO: report Voltage instead of LSB
whismanoid 10:04022a61b527 7950 // Serial.print(SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 7951 static char strOutLineBuffer[16];
whismanoid 10:04022a61b527 7952 cmdLine.serial().printf("%6.6f", SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 7953 }
whismanoid 5:aaf8b5f5fda1 7954 }
whismanoid 5:aaf8b5f5fda1 7955 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7956 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 7957 if (part_id_readback != part_id_expect) {
whismanoid 5:aaf8b5f5fda1 7958 cmdLine.serial().printf(",\"FAIL\"");
whismanoid 9:45f98573eb6d 7959 need_reinit = true;
whismanoid 5:aaf8b5f5fda1 7960 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7961 g_MAX11410_device.Init();
whismanoid 5:aaf8b5f5fda1 7962 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 5:aaf8b5f5fda1 7963 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 5:aaf8b5f5fda1 7964 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 5:aaf8b5f5fda1 7965 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7966 }
whismanoid 5:aaf8b5f5fda1 7967 else {
whismanoid 5:aaf8b5f5fda1 7968 cmdLine.serial().printf(",\"OK\"");
whismanoid 5:aaf8b5f5fda1 7969 }
whismanoid 5:aaf8b5f5fda1 7970 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7971 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7972 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 7973 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 7974 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 7975 continue;
whismanoid 9:45f98573eb6d 7976 }
whismanoid 5:aaf8b5f5fda1 7977 // comma between fields
whismanoid 5:aaf8b5f5fda1 7978 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 7979 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 7980 }
whismanoid 9:45f98573eb6d 7981 field_index++;
whismanoid 9:45f98573eb6d 7982 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 5:aaf8b5f5fda1 7983 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 7984 cmdLine.serial().printf("%u", Platform_LSB[channel_index]);
whismanoid 9:45f98573eb6d 7985 #endif
whismanoid 9:45f98573eb6d 7986 }
whismanoid 9:45f98573eb6d 7987 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 7988 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 11:2b8adc78618a 7989 // Datalog Volts omit V suffix from numbers #275
whismanoid 11:2b8adc78618a 7990 // because Excel graphs can't handle numbers that have a suffix.
whismanoid 11:2b8adc78618a 7991 cmdLine.serial().printf("%6.6f", Platform_Voltage[channel_index]);
whismanoid 9:45f98573eb6d 7992 #endif
whismanoid 9:45f98573eb6d 7993 }
whismanoid 5:aaf8b5f5fda1 7994 }
whismanoid 5:aaf8b5f5fda1 7995 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 7996 if (need_reinit) {
whismanoid 9:45f98573eb6d 7997 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 7998 if (g_MAX11410_device.Init() == 0) {
whismanoid 9:45f98573eb6d 7999 //~ cmdLine.serial().printf(",\"Init() failed\"");
whismanoid 9:45f98573eb6d 8000 } else {
whismanoid 9:45f98573eb6d 8001 //~ cmdLine.serial().printf(",\"Init() success\"");
whismanoid 9:45f98573eb6d 8002 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 8003 // in Datalogger_PrintRow(), when part_id test fails,
whismanoid 9:45f98573eb6d 8004 // apply list of custom register writes after re-init
whismanoid 9:45f98573eb6d 8005 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 8006 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 9:45f98573eb6d 8007 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 9:45f98573eb6d 8008 uint32_t regData = custom_reg_init_data[index];
whismanoid 9:45f98573eb6d 8009 cmdLine.serial().printf("*%s=0x%06.6x", g_MAX11410_device.RegName(regAddress), regData);
whismanoid 9:45f98573eb6d 8010 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 9:45f98573eb6d 8011 }
whismanoid 9:45f98573eb6d 8012 #endif // USE_CUSTOM_REG_INIT
whismanoid 9:45f98573eb6d 8013 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 9:45f98573eb6d 8014 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 9:45f98573eb6d 8015 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 9:45f98573eb6d 8016 need_reinit = false;
whismanoid 9:45f98573eb6d 8017 }
whismanoid 9:45f98573eb6d 8018 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 8019 need_reinit = false;
whismanoid 9:45f98573eb6d 8020 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 8021 }
whismanoid 30:07197a430869 8022 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 8023 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in void Datalogger_PrintRow()
whismanoid 30:07197a430869 8024 cmdLine.serial().printf(",\"%s\"", gstrRemarkText);
whismanoid 30:07197a430869 8025 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 5:aaf8b5f5fda1 8026 cmdLine.serial().printf("\r\n");
whismanoid 9:45f98573eb6d 8027 if (need_reinit) {
whismanoid 9:45f98573eb6d 8028 //~ delay(500); // platform_delay_ms 500ms timing delay function
whismanoid 9:45f98573eb6d 8029 }
whismanoid 5:aaf8b5f5fda1 8030 } // void Datalogger_PrintRow()
whismanoid 5:aaf8b5f5fda1 8031
whismanoid 0:cb44e2e9ec4c 8032 // example code main function
whismanoid 0:cb44e2e9ec4c 8033 int main()
whismanoid 0:cb44e2e9ec4c 8034 {
whismanoid 0:cb44e2e9ec4c 8035 // setup: put your setup code here, to run once
whismanoid 4:d9b05924ad4c 8036 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 8037 // Configure serial ports
whismanoid 4:d9b05924ad4c 8038 cmdLine.clear();
whismanoid 4:d9b05924ad4c 8039 //~ cmdLine.serial().printf("\r\n cmdLine.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 8040 cmdLine.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 8041 //~ cmdLine.diagnostic_led_EOF = diagnostic_led_EOF;
whismanoid 4:d9b05924ad4c 8042 /// CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21);
whismanoid 4:d9b05924ad4c 8043 //~ cmdLine.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 8044 //~ cmdLine.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 8045 //~ cmdLine.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 8046 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 8047 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 8048 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 8049 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 8050 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 8051 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 8052 # else
whismanoid 10:04022a61b527 8053 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 8054 DAPLINKserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 8055 # endif
whismanoid 10:04022a61b527 8056 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 8057 cmdLine_DAPLINKserial.clear();
whismanoid 4:d9b05924ad4c 8058 //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 8059 cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 8060 //~ cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 8061 //~ cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 8062 //~ cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 8063 # endif
whismanoid 6:f6d16658342b 8064 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 8065 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 10:04022a61b527 8066 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 8067 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 8068 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 8069 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 8070 AUXserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 8071 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 6:f6d16658342b 8072 cmdLine_AUXserial.clear();
whismanoid 6:f6d16658342b 8073 //~ cmdLine_AUXserial.serial().printf("\r\n cmdLine_AUXserial.serial().printf test\r\n");
whismanoid 6:f6d16658342b 8074 cmdLine_AUXserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 6:f6d16658342b 8075 //~ cmdLine_AUXserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 6:f6d16658342b 8076 //~ cmdLine_AUXserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 6:f6d16658342b 8077 //~ cmdLine_AUXserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 6:f6d16658342b 8078 # endif // HAS_AUX_SERIAL
whismanoid 4:d9b05924ad4c 8079 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 0:cb44e2e9ec4c 8080
whismanoid 0:cb44e2e9ec4c 8081 // example code: serial port banner message
whismanoid 0:cb44e2e9ec4c 8082 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 8083 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 8084 cmdLine.serial().printf("\r\nDataLogger_MAX11410\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 8085 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 8086 cmdLine.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 8087 # if HAS_DAPLINK_SERIAL
whismanoid 3:9055e17e181a 8088 cmdLine_DAPLINKserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 8089 # endif // HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 8090 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 8091 cmdLine_AUXserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 6:f6d16658342b 8092 # endif // HAS_AUX_SERIAL
whismanoid 3:9055e17e181a 8093 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 8094
whismanoid 1:747f1602abfc 8095 // CODE GENERATOR: get spi properties from device
whismanoid 3:9055e17e181a 8096 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 8097 if (g_SPI_SCLK_Hz > g_MAX11410_device.get_spi_frequency())
whismanoid 3:9055e17e181a 8098 { // Device limits SPI SCLK frequency
whismanoid 3:9055e17e181a 8099 g_SPI_SCLK_Hz = g_MAX11410_device.get_spi_frequency();
whismanoid 3:9055e17e181a 8100 cmdLine.serial().printf("\r\nMAX11410 limits SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 8101
whismanoid 3:9055e17e181a 8102 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 8103 }
whismanoid 3:9055e17e181a 8104 if (g_MAX11410_device.get_spi_frequency() > g_SPI_SCLK_Hz)
whismanoid 3:9055e17e181a 8105 { // Platform limits SPI SCLK frequency
whismanoid 3:9055e17e181a 8106 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 8107 cmdLine.serial().printf("\r\nPlatform limits MAX11410 SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 8108
whismanoid 3:9055e17e181a 8109 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 8110 }
whismanoid 0:cb44e2e9ec4c 8111 // g_SPI_dataMode = g_MAX11410_device.get_spi_dataMode();
whismanoid 3:9055e17e181a 8112 while (g_MAX11410_device.Init() == 0)
whismanoid 3:9055e17e181a 8113 {
whismanoid 3:9055e17e181a 8114 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 8115 cmdLine.serial().printf("\r\nMAX11410 Init failed; retry...\r\n");
whismanoid 3:9055e17e181a 8116
whismanoid 3:9055e17e181a 8117 }
whismanoid 0:cb44e2e9ec4c 8118
whismanoid 0:cb44e2e9ec4c 8119 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 3:9055e17e181a 8120 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 8121 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 3:9055e17e181a 8122 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 3:9055e17e181a 8123 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 3:9055e17e181a 8124 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 8125 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 3:9055e17e181a 8126 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 8127 // CODE GENERATOR: example code: has no member function REF
whismanoid 0:cb44e2e9ec4c 8128 // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line
whismanoid 0:cb44e2e9ec4c 8129 // CODE GENERATOR: ResolutionBits = 24
whismanoid 0:cb44e2e9ec4c 8130 // CODE GENERATOR: FScode = 0xffffff
whismanoid 0:cb44e2e9ec4c 8131 // CODE GENERATOR: NumChannels = 10
whismanoid 0:cb44e2e9ec4c 8132 // CODE GENERATOR: banner before DataLogHelloCppCodeList while(1)
whismanoid 3:9055e17e181a 8133 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 8134 cmdLine.serial().printf("v_filter = 0x%2.2x\r\n", g_MAX11410_device.v_filter);
whismanoid 0:cb44e2e9ec4c 8135
whismanoid 3:9055e17e181a 8136 cmdLine.serial().printf("v_pga = 0x%2.2x\r\n", g_MAX11410_device.v_pga);
whismanoid 0:cb44e2e9ec4c 8137
whismanoid 3:9055e17e181a 8138 cmdLine.serial().printf("v_ctrl = 0x%2.2x\r\n", g_MAX11410_device.v_ctrl);
whismanoid 3:9055e17e181a 8139
whismanoid 3:9055e17e181a 8140 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 8141
whismanoid 3:9055e17e181a 8142 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 8143 Datalogger_Need_PrintHeader = true;
whismanoid 10:04022a61b527 8144
whismanoid 12:2dfc1f2009e0 8145 #if USE_LEDS
whismanoid 12:2dfc1f2009e0 8146 #if defined(TARGET_MAX32630)
whismanoid 12:2dfc1f2009e0 8147 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 8148 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 8149 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 8150 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 8151 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 8152 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 8153 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 8154 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 8155 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 8156 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 8157 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 8158 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 8159 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 8160 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 8161 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 8162 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 19:5ff09c8e9daf 8163 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 12:2dfc1f2009e0 8164 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 8165 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 8166 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 8167 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 8168 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 8169 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 8170 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 8171 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 8172 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 8173 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 8174 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 8175 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 8176 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 8177 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 8178 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 8179 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 8180 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 12:2dfc1f2009e0 8181 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 8182 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 8183 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 8184 led4 = LED_OFF;
whismanoid 12:2dfc1f2009e0 8185 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 8186 //led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 8187 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 8188 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 8189 led1 = LED_OFF;
whismanoid 12:2dfc1f2009e0 8190 //led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 8191 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 8192 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 8193 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 8194 //led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 8195 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 8196 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 8197 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 8198 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 8199 //
whismanoid 12:2dfc1f2009e0 8200 #endif // target definition
whismanoid 12:2dfc1f2009e0 8201 #endif
whismanoid 12:2dfc1f2009e0 8202
whismanoid 12:2dfc1f2009e0 8203 if (led1.is_connected()) {
whismanoid 12:2dfc1f2009e0 8204 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 8205 }
whismanoid 12:2dfc1f2009e0 8206 if (led2.is_connected()) {
whismanoid 12:2dfc1f2009e0 8207 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 8208 }
whismanoid 12:2dfc1f2009e0 8209 if (led3.is_connected()) {
whismanoid 12:2dfc1f2009e0 8210 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 8211 }
whismanoid 12:2dfc1f2009e0 8212
whismanoid 46:469d0061df5d 8213 #if HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 8214 // WIP #312 load values from flash_page_configuration_back_up[] during init
whismanoid 48:18647e0516f2 8215 const uint32_t load_arg = load_arg_startup;
whismanoid 46:469d0061df5d 8216 Load_flash_page_configuration_back_up(cmdLine, load_arg);
whismanoid 46:469d0061df5d 8217 #endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 8218
whismanoid 4:d9b05924ad4c 8219 while(1) { // this code repeats forever
whismanoid 4:d9b05924ad4c 8220 // this code repeats forever
whismanoid 4:d9b05924ad4c 8221
whismanoid 21:ac062a97a71d 8222 #if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 8223 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 8224 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 8225 # if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 8226 static int button1_value_prev = 1;
whismanoid 21:ac062a97a71d 8227 static int button1_value_now = 1;
whismanoid 21:ac062a97a71d 8228 button1_value_prev = button1_value_now;
whismanoid 21:ac062a97a71d 8229 button1_value_now = button1.read();
whismanoid 21:ac062a97a71d 8230 if ((button1_value_prev - button1_value_now) == 1)
whismanoid 21:ac062a97a71d 8231 {
whismanoid 21:ac062a97a71d 8232 // on button1 falling edge (button1 press)
whismanoid 21:ac062a97a71d 8233 onButton1FallingEdge();
whismanoid 21:ac062a97a71d 8234 }
whismanoid 21:ac062a97a71d 8235 # endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 8236 # if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 8237 static int button2_value_prev = 1;
whismanoid 24:032f3683cb2a 8238 static int button2_value_now = 1;
whismanoid 24:032f3683cb2a 8239 button2_value_prev = button2_value_now;
whismanoid 24:032f3683cb2a 8240 button2_value_now = button2.read();
whismanoid 24:032f3683cb2a 8241 if ((button2_value_prev - button2_value_now) == 1)
whismanoid 24:032f3683cb2a 8242 {
whismanoid 24:032f3683cb2a 8243 // on button2 falling edge (button2 press)
whismanoid 24:032f3683cb2a 8244 onButton2FallingEdge();
whismanoid 24:032f3683cb2a 8245 }
whismanoid 24:032f3683cb2a 8246 # endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 8247 # if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 8248 static int button3_value_prev = 1;
whismanoid 24:032f3683cb2a 8249 static int button3_value_now = 1;
whismanoid 24:032f3683cb2a 8250 button3_value_prev = button3_value_now;
whismanoid 24:032f3683cb2a 8251 button3_value_now = button3.read();
whismanoid 24:032f3683cb2a 8252 if ((button3_value_prev - button3_value_now) == 1)
whismanoid 24:032f3683cb2a 8253 {
whismanoid 24:032f3683cb2a 8254 // on button3 falling edge (button3 press)
whismanoid 26:13cba69d88eb 8255 onButton3FallingEdge();
whismanoid 24:032f3683cb2a 8256 }
whismanoid 24:032f3683cb2a 8257 # endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 8258 #endif // HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 4:d9b05924ad4c 8259 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 8260 // TODO support CmdLine command menus (like on Serial_Tester); help and usual boilerplate
whismanoid 10:04022a61b527 8261 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 8262 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 8263 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 8264 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 8265 // Accept commands from Auxiliary serial port
whismanoid 6:f6d16658342b 8266 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 8267 if (AUXserial.readable()) {
whismanoid 6:f6d16658342b 8268 cmdLine_AUXserial.append(AUXserial.getc());
whismanoid 6:f6d16658342b 8269 }
whismanoid 6:f6d16658342b 8270 # endif // HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 8271 # if HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 8272 if (DAPLINKserial.readable()) {
whismanoid 6:f6d16658342b 8273 cmdLine_DAPLINKserial.append(DAPLINKserial.getc());
whismanoid 6:f6d16658342b 8274 }
whismanoid 6:f6d16658342b 8275 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 8276 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 8277 if (serial.readable()) {
whismanoid 4:d9b05924ad4c 8278 int c = serial.getc(); // instead of getc() or fgetc()
whismanoid 4:d9b05924ad4c 8279 cmdLine.append(c);
whismanoid 4:d9b05924ad4c 8280 // cmdLine.onEOLcommandParser handler implements menus
whismanoid 4:d9b05924ad4c 8281 } // if (Serial.available())
whismanoid 4:d9b05924ad4c 8282 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 8283
whismanoid 4:d9b05924ad4c 8284 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 32:80f3e5eb77d4 8285 // Datalog trigger
whismanoid 4:d9b05924ad4c 8286 if (Datalogger_Trigger == trigger_Halt) {
whismanoid 4:d9b05924ad4c 8287 // halt the datalogger; continue accepting commands
whismanoid 3:9055e17e181a 8288 continue;
whismanoid 3:9055e17e181a 8289 }
whismanoid 4:d9b05924ad4c 8290 if (Datalogger_Trigger == trigger_FreeRun) {
whismanoid 4:d9b05924ad4c 8291 // free run as fast as possible
whismanoid 3:9055e17e181a 8292 }
whismanoid 4:d9b05924ad4c 8293 if (Datalogger_Trigger == trigger_Timer) {
whismanoid 4:d9b05924ad4c 8294 // timer (configure interval)
whismanoid 32:80f3e5eb77d4 8295 // if Datalogger_Trigger == trigger_Timer sleep(g_timer_interval_msec)
whismanoid 39:4d285e961435 8296 //
whismanoid 39:4d285e961435 8297 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 8298 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 8299 // Sleep Mode vs Deep Sleep Mode
whismanoid 39:4d285e961435 8300 // See documentation https://os.mbed.com/docs/mbed-os/v5.15/apis/power-management-sleep.html
whismanoid 41:13a6a097502c 8301 // ThisThread::sleep_for(uint32_t millisec)
whismanoid 41:13a6a097502c 8302 // sleep_manager_can_deep_sleep() // tests whether deep_sleep is locked or not
whismanoid 41:13a6a097502c 8303 // sleep_manager_lock_deep_sleep() // begin section that prevents deep_sleep
whismanoid 41:13a6a097502c 8304 // sleep_manager_unlock_deep_sleep() // end section that prevents deep_sleep
whismanoid 39:4d285e961435 8305 switch(g_timer_sleepmode)
whismanoid 39:4d285e961435 8306 {
whismanoid 39:4d285e961435 8307 case datalogger_Sleep_LP0_Stop: // LT sleep = 0,
whismanoid 45:74bf1fe021e5 8308 // TODO: LP0 stop mode not supported; how would we wake up?
whismanoid 39:4d285e961435 8309 break;
whismanoid 39:4d285e961435 8310 case datalogger_Sleep_LP1_DeepSleep: // LT sleep = 1,
whismanoid 42:89607d5d4e6d 8311 //
whismanoid 45:74bf1fe021e5 8312 // In file mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\sleep.c
whismanoid 45:74bf1fe021e5 8313 // support function hal_deepsleep() just calls hal_sleep(),
whismanoid 45:74bf1fe021e5 8314 // so using LP1 Deep Sleep requires calling the low-level functions directly.
whismanoid 42:89607d5d4e6d 8315 //
whismanoid 41:13a6a097502c 8316 // sleep_manager_can_deep_sleep(); // tests whether deep_sleep is locked or not
whismanoid 41:13a6a097502c 8317 // mbed_file_handle(STDIN_FILENO)->enable_input(false); // (mbed-os-5.15) platform.stdio-buffered-serial prevents deep sleep
whismanoid 45:74bf1fe021e5 8318 #if MBED_VERSION >= MBED_ENCODE_VERSION(5, 15, 0)
whismanoid 41:13a6a097502c 8319 cmdLine.serial().enable_input(false); // (mbed-os-5.15) platform.stdio-buffered-serial prevents deep sleep
whismanoid 41:13a6a097502c 8320 // serial.enable_input(false); // (mbed-os-5.15) platform.stdio-buffered-serial prevents deep sleep
whismanoid 43:4c4733760d4c 8321
whismanoid 43:4c4733760d4c 8322 // configure RTC and start
whismanoid 43:4c4733760d4c 8323 // RTC_Setup();
whismanoid 43:4c4733760d4c 8324 {
whismanoid 43:4c4733760d4c 8325 rtc_cfg_t RTCconfig;
whismanoid 43:4c4733760d4c 8326 RTCconfig.compareCount[0] = 5;//5 second timer -- override with RTC_SetCompare(0,counts)
whismanoid 43:4c4733760d4c 8327 RTCconfig.compareCount[1] = 7;//7 second timer -- override with RTC_SetCompare(1,counts)
whismanoid 43:4c4733760d4c 8328 RTCconfig.prescaler = RTC_PRESCALE_DIV_2_12; //1Hz clock
whismanoid 43:4c4733760d4c 8329 RTCconfig.prescalerMask = RTC_PRESCALE_DIV_2_12;//used for prescaler compare
whismanoid 43:4c4733760d4c 8330 RTCconfig.snoozeCount = 0;
whismanoid 43:4c4733760d4c 8331 RTCconfig.snoozeMode = RTC_SNOOZE_DISABLE;
whismanoid 43:4c4733760d4c 8332 RTC_Init(&RTCconfig);
whismanoid 43:4c4733760d4c 8333 RTC_Start();
whismanoid 43:4c4733760d4c 8334
whismanoid 43:4c4733760d4c 8335 // Clear existing wake-up config
whismanoid 43:4c4733760d4c 8336 LP_ClearWakeUpConfig();
whismanoid 43:4c4733760d4c 8337
whismanoid 43:4c4733760d4c 8338 // Clear any event flags
whismanoid 43:4c4733760d4c 8339 LP_ClearWakeUpFlags();
whismanoid 43:4c4733760d4c 8340
whismanoid 43:4c4733760d4c 8341 // configure wake-up on RTC compare 1
whismanoid 43:4c4733760d4c 8342 // LP_ConfigRTCWakeUp(unsigned int comp0_en, unsigned int comp1_en, unsigned int prescale_cmp_en, unsigned int rollover_en);
whismanoid 43:4c4733760d4c 8343 LP_ConfigRTCWakeUp(0, 1, 0, 0);
whismanoid 43:4c4733760d4c 8344
whismanoid 44:84402faa8eb9 8345 // wait until UART_Busy indicates no ongoing transactions (both ports)
whismanoid 44:84402faa8eb9 8346 while (Console_PrepForSleep() != E_NO_ERROR);
whismanoid 44:84402faa8eb9 8347
whismanoid 43:4c4733760d4c 8348 // set RTC compare 1 value
whismanoid 43:4c4733760d4c 8349 // cmp = RTC_GetCount() + LP1_WakeTime;
whismanoid 43:4c4733760d4c 8350 uint32_t cmp = RTC_GetCount() + ((g_timer_interval_msec + 500.) / 1000.);
whismanoid 43:4c4733760d4c 8351 // RTC_SetCompare(uint8_t compareIndex, uint32_t counts)
whismanoid 43:4c4733760d4c 8352 RTC_SetCompare(1, cmp);
whismanoid 43:4c4733760d4c 8353
whismanoid 43:4c4733760d4c 8354 RTC_ClearFlags(MXC_F_RTC_FLAGS_COMP1);
whismanoid 43:4c4733760d4c 8355 }
whismanoid 43:4c4733760d4c 8356
whismanoid 43:4c4733760d4c 8357 //global disable interrupt
whismanoid 43:4c4733760d4c 8358 __disable_irq();
whismanoid 43:4c4733760d4c 8359
whismanoid 43:4c4733760d4c 8360 LP_EnterLP1();
whismanoid 43:4c4733760d4c 8361
whismanoid 43:4c4733760d4c 8362 //global enable interrupt
whismanoid 43:4c4733760d4c 8363 __enable_irq();
whismanoid 43:4c4733760d4c 8364
whismanoid 43:4c4733760d4c 8365 // stop waking on RTC
whismanoid 43:4c4733760d4c 8366 // LP_ConfigRTCWakeUp(unsigned int comp0_en, unsigned int comp1_en, unsigned int prescale_cmp_en, unsigned int rollover_en);
whismanoid 43:4c4733760d4c 8367 LP_ConfigRTCWakeUp(0, 0, 0, 0);
whismanoid 43:4c4733760d4c 8368
whismanoid 43:4c4733760d4c 8369 // Clear existing wake-up config
whismanoid 43:4c4733760d4c 8370 LP_ClearWakeUpConfig();
whismanoid 43:4c4733760d4c 8371
whismanoid 43:4c4733760d4c 8372 // Clear any event flags
whismanoid 43:4c4733760d4c 8373 LP_ClearWakeUpFlags();
whismanoid 45:74bf1fe021e5 8374
whismanoid 43:4c4733760d4c 8375 RTC_Stop();
whismanoid 43:4c4733760d4c 8376
whismanoid 41:13a6a097502c 8377 // mbed_file_handle(STDIN_FILENO)->enable_input(true); // (mbed-os-5.15)
whismanoid 41:13a6a097502c 8378 cmdLine.serial().enable_input(true); // (mbed-os-5.15)
whismanoid 41:13a6a097502c 8379 // serial.enable_input(true); // (mbed-os-5.15)
whismanoid 39:4d285e961435 8380 break;
whismanoid 45:74bf1fe021e5 8381 #endif // MBED_VERSION >= MBED_ENCODE_VERSION(5, 15, 0)
whismanoid 39:4d285e961435 8382 case datalogger_Sleep_LP2_Sleep: // LT sleep = 2,
whismanoid 41:13a6a097502c 8383 sleep_manager_lock_deep_sleep(); // begin section that prevents deep_sleep
whismanoid 41:13a6a097502c 8384 ThisThread::sleep_for(g_timer_interval_msec); // wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 41:13a6a097502c 8385 sleep_manager_unlock_deep_sleep(); // end section that prevents deep_sleep
whismanoid 39:4d285e961435 8386 break;
whismanoid 39:4d285e961435 8387 case datalogger_Sleep_LP3_Run: // LT sleep = 3,
whismanoid 45:74bf1fe021e5 8388 // TODO: USE_DATALOGGER_SLEEP -- ThisThread::sleep_for(uint32_t millisec) instead of wait_ms(g_timer_interval_msec)
whismanoid 41:13a6a097502c 8389 wait_ms(g_timer_interval_msec);
whismanoid 39:4d285e961435 8390 break;
whismanoid 39:4d285e961435 8391 }
whismanoid 39:4d285e961435 8392 #else // USE_DATALOGGER_SLEEP
whismanoid 17:9397ea3ea7e9 8393 wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 39:4d285e961435 8394 #endif // USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 8395 //
whismanoid 17:9397ea3ea7e9 8396 if (g_timer_interval_counter > 0) {
whismanoid 17:9397ea3ea7e9 8397 g_timer_interval_counter--;
whismanoid 17:9397ea3ea7e9 8398 continue;
whismanoid 17:9397ea3ea7e9 8399 }
whismanoid 17:9397ea3ea7e9 8400 // if time interval not yet reached, continue (continue accepting commands)
whismanoid 32:80f3e5eb77d4 8401 g_timer_interval_counter = g_timer_interval_count-1;
whismanoid 3:9055e17e181a 8402 }
whismanoid 4:d9b05924ad4c 8403 if (Datalogger_Trigger == trigger_PlatformDigitalInput) {
whismanoid 4:d9b05924ad4c 8404 // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 8405 // TODO: read selected input pin, test value
whismanoid 17:9397ea3ea7e9 8406 // TODO: if no match, continue (continue accepting commands)
whismanoid 3:9055e17e181a 8407 }
whismanoid 4:d9b05924ad4c 8408 if (Datalogger_Trigger == trigger_SPIDeviceRegRead) {
whismanoid 4:d9b05924ad4c 8409 // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 8410 // TODO: SPI transfer regAddr
whismanoid 17:9397ea3ea7e9 8411 // TODO: apply dataMask, compare with testValue
whismanoid 17:9397ea3ea7e9 8412 // TODO: if no match, continue (continue accepting commands)
whismanoid 4:d9b05924ad4c 8413 }
whismanoid 4:d9b05924ad4c 8414 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 0:cb44e2e9ec4c 8415
whismanoid 8:dffee7509bfb 8416 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 8417 if (Datalogger_Need_PrintHeader) {
whismanoid 8:dffee7509bfb 8418 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 8419 Datalogger_PrintHeader(cmdLine);
whismanoid 8:dffee7509bfb 8420 }
whismanoid 8:dffee7509bfb 8421 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 8422 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 8423 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 8424 }
whismanoid 8:dffee7509bfb 8425 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 8426 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 8427 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 8428 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 8429 }
whismanoid 8:dffee7509bfb 8430 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 8431 Datalogger_Need_PrintHeader = false;
whismanoid 8:dffee7509bfb 8432 }
whismanoid 5:aaf8b5f5fda1 8433 Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 8434 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 8435 // Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 8436 Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 8437 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 0:cb44e2e9ec4c 8438 // wait(3.0);
whismanoid 0:cb44e2e9ec4c 8439 // CODE GENERATOR: print conversion result
whismanoid 0:cb44e2e9ec4c 8440 // Use Arduino Serial Plotter to view output: Tools | Serial Plotter
whismanoid 8:dffee7509bfb 8441 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 8442 Datalogger_PrintRow(cmdLine);
whismanoid 8:dffee7509bfb 8443 }
whismanoid 8:dffee7509bfb 8444 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 8445 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 8446 Datalogger_PrintRow(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 8447 }
whismanoid 8:dffee7509bfb 8448 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 8449 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 8450 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 8451 Datalogger_PrintRow(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 8452 }
whismanoid 8:dffee7509bfb 8453 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:cb44e2e9ec4c 8454
whismanoid 0:cb44e2e9ec4c 8455 } // this code repeats forever
whismanoid 0:cb44e2e9ec4c 8456 }
whismanoid 0:cb44e2e9ec4c 8457 //---------- CODE GENERATOR: end DataLogHelloCppCodeList