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:
Sun Oct 31 22:40:15 2021 -0700
Revision:
48:18647e0516f2
Parent:
47:f1a56afb4aca
Child:
49:359a6b9df7c1
Configuration load/save in flash (%A cal? values); #312
default values in flash_page_configuration_back_up, including board serial number
default load/save arg, verbose/brief; %A sn=1234

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 46:469d0061df5d 219 // MAX40108 calibration values assign absolute address
whismanoid 47:f1a56afb4aca 220 const char flash_page_configuration_back_up[8192] __attribute__((aligned(8192))) = {
whismanoid 47:f1a56afb4aca 221 // 0x04000053, 0xffffffff, 0xffffffff, 0xffffffff, // g_board_serial_number is blank 0xFFFFFFFF
whismanoid 47:f1a56afb4aca 222 0x53, 0x00, 0x00, 0x04, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 0x04000053 g_board_serial_number is blank 0xFFFFFFFF
whismanoid 47:f1a56afb4aca 223 0x53, 0x10, 0x00, 0x08, 0x21, 0xbc, 0x15, 0x40, 0x33, 0x33, 0xd3, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08001053 calibration_05_V[0]
whismanoid 47:f1a56afb4aca 224 0x53, 0x11, 0x00, 0x08, 0x21, 0xbc, 0x15, 0x40, 0x33, 0x33, 0xd3, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08001153 calibration_05_V[1]
whismanoid 47:f1a56afb4aca 225 0x53, 0x12, 0x00, 0x08, 0x21, 0xbc, 0x15, 0x40, 0x33, 0x33, 0xd3, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08001253 calibration_05_V[2]
whismanoid 47:f1a56afb4aca 226 0x53, 0x13, 0x00, 0x08, 0x21, 0xbc, 0x15, 0x40, 0x33, 0x33, 0xd3, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08001353 calibration_05_V[3]
whismanoid 47:f1a56afb4aca 227 0x53, 0x14, 0x00, 0x08, 0xdf, 0x43, 0xea, 0xbf, 0xcc, 0xcc, 0xec, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08001453 calibration_05_V[4]
whismanoid 47:f1a56afb4aca 228 0x53, 0x15, 0x00, 0x08, 0xdf, 0x43, 0xea, 0xbf, 0xcc, 0xcc, 0xec, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08001553 calibration_05_V[5]
whismanoid 47:f1a56afb4aca 229 0x53, 0x20, 0x00, 0x08, 0x06, 0xb8, 0x11, 0x30, 0x69, 0x15, 0xd0, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08002053 calibration_05_normValue_0_1[0]
whismanoid 47:f1a56afb4aca 230 0x53, 0x21, 0x00, 0x08, 0x06, 0xb8, 0x11, 0x30, 0x69, 0x15, 0xd0, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08002153 calibration_05_normValue_0_1[1]
whismanoid 47:f1a56afb4aca 231 0x53, 0x22, 0x00, 0x08, 0x06, 0xb8, 0x11, 0x30, 0x69, 0x15, 0xd0, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08002253 calibration_05_normValue_0_1[2]
whismanoid 47:f1a56afb4aca 232 0x53, 0x23, 0x00, 0x08, 0x06, 0xb8, 0x11, 0x30, 0x69, 0x15, 0xd0, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08002353 calibration_05_normValue_0_1[3]
whismanoid 47:f1a56afb4aca 233 0x53, 0x24, 0x00, 0x08, 0x3d, 0x1e, 0xac, 0x5f, 0xe6, 0x84, 0xc3, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08002453 calibration_05_normValue_0_1[4]
whismanoid 47:f1a56afb4aca 234 0x53, 0x25, 0x00, 0x08, 0x3d, 0x1e, 0xac, 0x5f, 0xe6, 0x84, 0xc3, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08002553 calibration_05_normValue_0_1[5]
whismanoid 47:f1a56afb4aca 235 0x53, 0x30, 0x00, 0x08, 0xdf, 0x43, 0xea, 0xbf, 0xcc, 0xcc, 0xec, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08003053 calibration_95_V[0]
whismanoid 47:f1a56afb4aca 236 0x53, 0x31, 0x00, 0x08, 0xdf, 0x43, 0xea, 0xbf, 0xcc, 0xcc, 0xec, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08003153 calibration_95_V[1]
whismanoid 47:f1a56afb4aca 237 0x53, 0x32, 0x00, 0x08, 0xdf, 0x43, 0xea, 0xbf, 0xcc, 0xcc, 0xec, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08003253 calibration_95_V[2]
whismanoid 47:f1a56afb4aca 238 0x53, 0x33, 0x00, 0x08, 0xdf, 0x43, 0xea, 0xbf, 0xcc, 0xcc, 0xec, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08003353 calibration_95_V[3]
whismanoid 47:f1a56afb4aca 239 0x53, 0x34, 0x00, 0x08, 0xef, 0x21, 0xf5, 0x5f, 0x66, 0x66, 0x0a, 0x40, 0xff, 0xff, 0xff, 0xff, // 0x08003453 calibration_95_V[4]
whismanoid 47:f1a56afb4aca 240 0x53, 0x35, 0x00, 0x08, 0xef, 0x21, 0xf5, 0x5f, 0x66, 0x66, 0x0a, 0x40, 0xff, 0xff, 0xff, 0xff, // 0x08003553 calibration_95_V[5]
whismanoid 47:f1a56afb4aca 241 0x53, 0x40, 0x00, 0x08, 0xc2, 0xe5, 0x37, 0xa0, 0x33, 0x16, 0xe8, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08004053 calibration_95_normValue_0_1[0]
whismanoid 47:f1a56afb4aca 242 0x53, 0x41, 0x00, 0x08, 0xc2, 0xe5, 0x37, 0xa0, 0x33, 0x16, 0xe8, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08004153 calibration_95_normValue_0_1[1]
whismanoid 47:f1a56afb4aca 243 0x53, 0x42, 0x00, 0x08, 0xc2, 0xe5, 0x37, 0xa0, 0x33, 0x16, 0xe8, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08004253 calibration_95_normValue_0_1[2]
whismanoid 47:f1a56afb4aca 244 0x53, 0x43, 0x00, 0x08, 0xc2, 0xe5, 0x37, 0xa0, 0x33, 0x16, 0xe8, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08004353 calibration_95_normValue_0_1[3]
whismanoid 47:f1a56afb4aca 245 0x53, 0x44, 0x00, 0x08, 0xe5, 0xc8, 0xf8, 0x67, 0x6e, 0xb4, 0xe1, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08004453 calibration_95_normValue_0_1[4]
whismanoid 47:f1a56afb4aca 246 0x53, 0x45, 0x00, 0x08, 0xe5, 0xc8, 0xf8, 0x67, 0x6e, 0xb4, 0xe1, 0x3f, 0xff, 0xff, 0xff, 0xff, // 0x08004553 calibration_95_normValue_0_1[5]
whismanoid 47:f1a56afb4aca 247 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 248 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 249 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
whismanoid 47:f1a56afb4aca 250 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
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 };
whismanoid 46:469d0061df5d 285 // WIP #312 map values in flash_page_configuration_back_up[]
whismanoid 46:469d0061df5d 286 // such as board serial number, %A calibration values,
whismanoid 46:469d0061df5d 287 // business logic, button handlers, etc.
whismanoid 46:469d0061df5d 288 // Use some pattern that stands out in the hex file dump
whismanoid 46:469d0061df5d 289 // as well as in the flash dump... note the hex file is LE/LSbyte first,
whismanoid 46:469d0061df5d 290 // while the flash memory is BE/MSbyte first.
whismanoid 46:469d0061df5d 291 //
whismanoid 46:469d0061df5d 292 // I don't have control of where this ends up because "at" attribute
whismanoid 46:469d0061df5d 293 // is not supported, but at least flash_page_configuration_back_up
whismanoid 46:469d0061df5d 294 // is page-aligned and its address is printed in the help.
whismanoid 46:469d0061df5d 295 // Also use a pattern that should stand out in the hex dump.
whismanoid 46:469d0061df5d 296 // Note that in the .bin file, "32107654" is 33 32 31 30 37 36 35 34,
whismanoid 46:469d0061df5d 297 // but in the flash memory it will be 0x30313233 0x34353637
whismanoid 46:469d0061df5d 298 // Use free hex editor to find text in .bin file,
whismanoid 46:469d0061df5d 299 // then add base address 0x00010000 to get peek address.
whismanoid 46:469d0061df5d 300 // char* TestString1 = "UUUUUUUUUUUUUUUUUUUU""32107654BA98FEDC"" MAX32625 Calibration ....####@@@@""UUUUUUUUUUUUUUUUUUUU";
whismanoid 46:469d0061df5d 301 // > %F peek=0x000241f0 len=20
whismanoid 46:469d0061df5d 302 // FLASH 0x000241f0: 0x544c4f56 0x00454741 0x55555555 0x55555555
whismanoid 46:469d0061df5d 303 // FLASH 0x00024200: 0x55555555 0x55555555 0x55555555 0x30313233
whismanoid 46:469d0061df5d 304 // FLASH 0x00024210: 0x34353637 0x38394142 0x43444546 0x58414d20
whismanoid 46:469d0061df5d 305 // FLASH 0x00024220: 0x32363233 0x61432035 0x7262696c 0x6f697461
whismanoid 46:469d0061df5d 306 // FLASH 0x00024230: 0x2020206e 0x2e2e2e2e 0x23232323 0x40404040
whismanoid 46:469d0061df5d 307 // FLASH 0x00024240: 0x55555555 0x55555555 0x55555555 0x55555555
whismanoid 46:469d0061df5d 308 // FLASH 0x00024250: 0x55555555 0x00000000 0x00000000 0x00000000
whismanoid 46:469d0061df5d 309 // FLASH 0x00024260: 0x00013b1b 0x000140d1 0x00013d9f 0x00013e2d
whismanoid 46:469d0061df5d 310 //
whismanoid 46:469d0061df5d 311 // Why did it end up at that address? Here's the linker map report:
whismanoid 46:469d0061df5d 312 // .\BUILD\MAX32625PICO\GCC_ARM\Internal_DataLogger.map
whismanoid 46:469d0061df5d 313 // .text.startup._GLOBAL__sub_I_TestString1
whismanoid 46:469d0061df5d 314 // 0x0001374c 0x33c BUILD/MAX32625PICO/GCC_ARM/DataLogger_Internal.o
whismanoid 46:469d0061df5d 315 // .rodata._GLOBAL__sub_I_TestString1.str1.1
whismanoid 46:469d0061df5d 316 // 0x00022d64 0x12 BUILD/MAX32625PICO/GCC_ARM/DataLogger_Internal.o
whismanoid 46:469d0061df5d 317 // 0x19 (size before relaxing)
whismanoid 46:469d0061df5d 318 //
whismanoid 46:469d0061df5d 319 // For calibration purposes this could still be usable,
whismanoid 46:469d0061df5d 320 // as long as the firmware knows where its calibration constants live.
whismanoid 46:469d0061df5d 321 //
whismanoid 46:469d0061df5d 322 #if defined ( __GNUC__ )
whismanoid 46:469d0061df5d 323 __attribute__ ((section(".calibration_teststring")))
whismanoid 46:469d0061df5d 324 #endif
whismanoid 46:469d0061df5d 325 char* TestString1 = "UUUU" "UUUU" "UUUU" "UUUU"
whismanoid 46:469d0061df5d 326 "\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF"
whismanoid 46:469d0061df5d 327 "\x11\x22\x33\x44" "\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF"
whismanoid 46:469d0061df5d 328 "UUUUUUUUUUUUUUUUUUUU""32107654BA98FEDC"" MAX32625 Calibration ....####@@@@""UUUUUUUUUUUUUUUUUUUU";
whismanoid 46:469d0061df5d 329 //
whismanoid 46:469d0061df5d 330 // Limit the ranges where memory write operation will be allowed
whismanoid 46:469d0061df5d 331 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 332 // FLASH (rx) : ORIGIN = 0x00010000, LENGTH = 0x00070000
whismanoid 46:469d0061df5d 333 // RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00028000
whismanoid 46:469d0061df5d 334 typedef struct {
whismanoid 46:469d0061df5d 335 uint32_t addr_min; // lowest address of range
whismanoid 46:469d0061df5d 336 uint32_t addr_max; // highest address of range
whismanoid 46:469d0061df5d 337 char name[6]; // 5-character name, pad with spaces, null-terminated
whismanoid 46:469d0061df5d 338 char can_flash_write_read; // 8=end of list, 4=flashPoke, 2=ramPoke, 1=read
whismanoid 46:469d0061df5d 339 } poke_access_t;
whismanoid 46:469d0061df5d 340 poke_access_t poke_access_list[] = {
whismanoid 46:469d0061df5d 341 { 0x12345678, 0x12345678, "undef", 0 }, // first record: catch undefined ranges
whismanoid 46:469d0061df5d 342 // { 0x00000000, 0x0000FFFF, " BOOT", 1 }, // boot area is flash page 0-7, but don't allow flashPoke
whismanoid 46:469d0061df5d 343 { 0x00000000, 0x00001FFF, "BOOT0", 1 }, // flash page 0
whismanoid 46:469d0061df5d 344 { 0x00002000, 0x00003FFF, "BOOT1", 1 }, // flash page 1
whismanoid 46:469d0061df5d 345 { 0x00004000, 0x00005FFF, "BOOT2", 1 }, // flash page 2
whismanoid 46:469d0061df5d 346 { 0x00006000, 0x00007FFF, "BOOT3", 1 }, // flash page 3
whismanoid 46:469d0061df5d 347 { 0x00008000, 0x00009FFF, "BOOT4", 1 }, // flash page 4
whismanoid 46:469d0061df5d 348 { 0x0000A000, 0x0000BFFF, "BOOT5", 1 }, // flash page 5
whismanoid 46:469d0061df5d 349 { 0x0000C000, 0x0000DFFF, "BOOT6", 1 }, // flash page 6
whismanoid 46:469d0061df5d 350 { 0x0000E000, 0x0000FFFF, "BOOT7", 1 }, // flash page 7
whismanoid 46:469d0061df5d 351 //
whismanoid 46:469d0061df5d 352 //{ 0x00010000, 0x0007FFFF, "FLASH", 5 }, // flash pages 8-62
whismanoid 46:469d0061df5d 353 // Future: separate FLASH pages, allow flashPoke only on the calibration page
whismanoid 47:f1a56afb4aca 354 { 0x00010000, 0x00011FFF, "FLA08", 5 }, // flash page 8
whismanoid 47:f1a56afb4aca 355 { 0x00012000, 0x00013FFF, "FLA09", 5 }, // flash page 9
whismanoid 47:f1a56afb4aca 356 { 0x00014000, 0x00015FFF, "FLA10", 5 }, // flash page 10
whismanoid 47:f1a56afb4aca 357 { 0x00016000, 0x00017FFF, "FLA11", 5 }, // flash page 11
whismanoid 47:f1a56afb4aca 358 { 0x00018000, 0x00019FFF, "FLA12", 5 }, // flash page 12
whismanoid 47:f1a56afb4aca 359 { 0x0001A000, 0x0001BFFF, "FLA13", 5 }, // flash page 13
whismanoid 47:f1a56afb4aca 360 { 0x0001C000, 0x0001DFFF, "FLA14", 5 }, // flash page 14
whismanoid 47:f1a56afb4aca 361 { 0x0001E000, 0x0001FFFF, "FLA15", 5 }, // flash page 15
whismanoid 46:469d0061df5d 362 //
whismanoid 47:f1a56afb4aca 363 { 0x00020000, 0x00021FFF, "FLA16", 5 }, // flash page 16
whismanoid 47:f1a56afb4aca 364 { 0x00022000, 0x00023FFF, "FLA17", 5 }, // flash page 17
whismanoid 46:469d0061df5d 365 { 0x00024000, 0x00025FFF, "FLA18", 5 }, // flash page 18
whismanoid 46:469d0061df5d 366 { 0x00026000, 0x00027FFF, "FLA19", 5 }, // flash page 19
whismanoid 46:469d0061df5d 367 { 0x00028000, 0x00029FFF, "FLA20", 5 }, // flash page 20
whismanoid 46:469d0061df5d 368 { 0x0002A000, 0x0002BFFF, "FLA21", 5 }, // flash page 21
whismanoid 46:469d0061df5d 369 { 0x0002C000, 0x0002DFFF, "FLA22", 5 }, // flash page 22
whismanoid 46:469d0061df5d 370 { 0x0002E000, 0x0002FFFF, "FLA23", 5 }, // flash page 23
whismanoid 46:469d0061df5d 371 //
whismanoid 46:469d0061df5d 372 { 0x00030000, 0x00031FFF, "FLA24", 5 }, // flash page 24
whismanoid 46:469d0061df5d 373 { 0x00032000, 0x00033FFF, "FLA25", 5 }, // flash page 25
whismanoid 46:469d0061df5d 374 { 0x00034000, 0x00035FFF, "FLA26", 5 }, // flash page 26
whismanoid 46:469d0061df5d 375 { 0x00036000, 0x00037FFF, "FLA27", 5 }, // flash page 27
whismanoid 46:469d0061df5d 376 { 0x00038000, 0x00039FFF, "FLA28", 5 }, // flash page 28
whismanoid 46:469d0061df5d 377 { 0x0003A000, 0x0003BFFF, "FLA29", 5 }, // flash page 29
whismanoid 46:469d0061df5d 378 { 0x0003C000, 0x0003DFFF, "FLA30", 5 }, // flash page 30
whismanoid 46:469d0061df5d 379 { 0x0003E000, 0x0003FFFF, "FLA31", 5 }, // flash page 31
whismanoid 46:469d0061df5d 380 //
whismanoid 46:469d0061df5d 381 { 0x00040000, 0x00041FFF, "FLA32", 5 }, // flash page 32
whismanoid 46:469d0061df5d 382 { 0x00042000, 0x00043FFF, "FLA33", 5 }, // flash page 33
whismanoid 46:469d0061df5d 383 { 0x00044000, 0x00045FFF, "FLA34", 5 }, // flash page 34
whismanoid 46:469d0061df5d 384 { 0x00046000, 0x00047FFF, "FLA35", 5 }, // flash page 35
whismanoid 46:469d0061df5d 385 { 0x00048000, 0x00049FFF, "FLA36", 5 }, // flash page 36
whismanoid 46:469d0061df5d 386 { 0x0004A000, 0x0004BFFF, "FLA37", 5 }, // flash page 37
whismanoid 46:469d0061df5d 387 { 0x0004C000, 0x0004DFFF, "FLA38", 5 }, // flash page 38
whismanoid 46:469d0061df5d 388 { 0x0004E000, 0x0004FFFF, "FLA39", 5 }, // flash page 39
whismanoid 46:469d0061df5d 389 //
whismanoid 46:469d0061df5d 390 { 0x00050000, 0x00051FFF, "FLA40", 5 }, // flash page 40
whismanoid 46:469d0061df5d 391 { 0x00052000, 0x00053FFF, "FLA41", 5 }, // flash page 41
whismanoid 46:469d0061df5d 392 { 0x00054000, 0x00055FFF, "FLA42", 5 }, // flash page 42
whismanoid 46:469d0061df5d 393 { 0x00056000, 0x00057FFF, "FLA43", 5 }, // flash page 43
whismanoid 46:469d0061df5d 394 { 0x00058000, 0x00059FFF, "FLA44", 5 }, // flash page 44
whismanoid 46:469d0061df5d 395 { 0x0005A000, 0x0005BFFF, "FLA45", 5 }, // flash page 45
whismanoid 46:469d0061df5d 396 { 0x0005C000, 0x0005DFFF, "FLA46", 5 }, // flash page 46
whismanoid 46:469d0061df5d 397 { 0x0005E000, 0x0005FFFF, "FLA47", 5 }, // flash page 47
whismanoid 46:469d0061df5d 398 //
whismanoid 46:469d0061df5d 399 { 0x00060000, 0x00061FFF, "FLA48", 5 }, // flash page 48
whismanoid 46:469d0061df5d 400 { 0x00062000, 0x00063FFF, "FLA49", 5 }, // flash page 49
whismanoid 46:469d0061df5d 401 { 0x00064000, 0x00065FFF, "FLA50", 5 }, // flash page 50
whismanoid 46:469d0061df5d 402 { 0x00066000, 0x00067FFF, "FLA51", 5 }, // flash page 51
whismanoid 46:469d0061df5d 403 { 0x00068000, 0x00069FFF, "FLA52", 5 }, // flash page 52
whismanoid 46:469d0061df5d 404 { 0x0006A000, 0x0006BFFF, "FLA53", 5 }, // flash page 53
whismanoid 46:469d0061df5d 405 { 0x0006C000, 0x0006DFFF, "FLA54", 5 }, // flash page 54
whismanoid 46:469d0061df5d 406 { 0x0006E000, 0x0006FFFF, "FLA55", 5 }, // flash page 55
whismanoid 46:469d0061df5d 407 //
whismanoid 46:469d0061df5d 408 { 0x00070000, 0x00071FFF, "FLA56", 5 }, // flash page 56
whismanoid 46:469d0061df5d 409 { 0x00072000, 0x00073FFF, "FLA57", 5 }, // flash page 57
whismanoid 46:469d0061df5d 410 { 0x00074000, 0x00075FFF, "FLA58", 5 }, // flash page 58
whismanoid 46:469d0061df5d 411 { 0x00076000, 0x00077FFF, "FLA59", 5 }, // flash page 59
whismanoid 46:469d0061df5d 412 { 0x00078000, 0x00079FFF, "FLA60", 5 }, // flash page 60
whismanoid 46:469d0061df5d 413 { 0x0007A000, 0x0007BFFF, "FLA61", 5 }, // flash page 61
whismanoid 46:469d0061df5d 414 { 0x0007C000, 0x0007DFFF, "FLA62", 5 }, // flash page 62
whismanoid 46:469d0061df5d 415 { 0x0007E000, 0x0007FFFF, "FLA63", 5 }, // flash page 63
whismanoid 46:469d0061df5d 416 //
whismanoid 46:469d0061df5d 417 { 0x20000000, 0x20027FFF, " RAM", 3 }, // ramPoke + read
whismanoid 46:469d0061df5d 418 { 0x20028000, 0x2002FFFF, "skip ", 0 }, // don't read from this range
whismanoid 46:469d0061df5d 419 { 0x40000000, 0x400003FF, " SYS", 1 }, // read only
whismanoid 46:469d0061df5d 420 { 0x40000400, 0x400007FF, " CLK", 1 },
whismanoid 46:469d0061df5d 421 { 0x40000800, 0x400009FF, " PWR", 1 },
whismanoid 46:469d0061df5d 422 { 0x40000A00, 0x40000BFF, " RTC", 1 },
whismanoid 46:469d0061df5d 423 { 0x40000C00, 0x40001FFF, "IOMAN", 1 },
whismanoid 46:469d0061df5d 424 { 0x40002000, 0x40002FFF, " FLC", 1 },
whismanoid 46:469d0061df5d 425 { 0x40003000, 0x40003FFF, " ICC", 1 },
whismanoid 46:469d0061df5d 426 { 0x40004000, 0x40004FFF, " SPIX", 1 },
whismanoid 46:469d0061df5d 427 { 0x40005000, 0x40005FFF, " PMU", 1 },
whismanoid 46:469d0061df5d 428 { 0x40006000, 0x40006FFF, " CRC", 1 },
whismanoid 46:469d0061df5d 429 { 0x40007000, 0x40007FFF, " TPU", 1 },
whismanoid 46:469d0061df5d 430 { 0x40008000, 0x40008FFF, " WDT0", 1 },
whismanoid 46:469d0061df5d 431 { 0x40009000, 0x40009FFF, " WDT1", 1 },
whismanoid 46:469d0061df5d 432 { 0x4000A000, 0x4000AFFF, " GPIO", 1 },
whismanoid 46:469d0061df5d 433 { 0x4000B000, 0x4000FFFF, " TMR", 1 },
whismanoid 46:469d0061df5d 434 { 0x40011000, 0x4000FFFF, " PT", 1 },
whismanoid 46:469d0061df5d 435 { 0x40012000, 0x4000FFFF, " UART", 1 },
whismanoid 46:469d0061df5d 436 { 0x40016000, 0x4000FFFF, " I2CM", 1 },
whismanoid 46:469d0061df5d 437 { 0x40019000, 0x4000FFFF, " I2CS", 1 },
whismanoid 46:469d0061df5d 438 { 0x4001A000, 0x4000FFFF, " SPIM", 1 },
whismanoid 46:469d0061df5d 439 { 0x4001E000, 0x4000FFFF, " OWM", 1 },
whismanoid 46:469d0061df5d 440 { 0x4001F000, 0x4000FFFF, " ADC", 1 },
whismanoid 46:469d0061df5d 441 { 0x40020000, 0x40000FFF, " SPIS", 1 },
whismanoid 46:469d0061df5d 442 { 0x40100000, 0x40100FFF, " USB", 1 },
whismanoid 46:469d0061df5d 443 { 0x40101000, 0x40101FFF, " CRC", 1 },
whismanoid 46:469d0061df5d 444 { 0x40102000, 0x40102FFF, " TPU", 1 },
whismanoid 46:469d0061df5d 445 { 0x40103000, 0x40103FFF, "UART0", 1 },
whismanoid 46:469d0061df5d 446 { 0x40104000, 0x40104FFF, "UART1", 1 },
whismanoid 46:469d0061df5d 447 { 0x40105000, 0x40105FFF, "UART2", 1 },
whismanoid 46:469d0061df5d 448 //{ 0x40106000, 0x40106FFF, "_____", 1 }, // reserved
whismanoid 46:469d0061df5d 449 { 0x40107000, 0x40107FFF, "I2CM0", 1 }, // I2CM0 FIFOs
whismanoid 46:469d0061df5d 450 { 0x40108000, 0x40108FFF, "I2CM1", 1 }, // I2CM1 FIFOs
whismanoid 46:469d0061df5d 451 //{ 0x40109000, 0x40109FFF, "_____", 1 }, // reserved
whismanoid 46:469d0061df5d 452 { 0x4010A000, 0x4010AFFF, "SPIM0", 1 }, // SPIM0 FIFOs
whismanoid 46:469d0061df5d 453 { 0x4010B000, 0x4010BFFF, "SPIM1", 1 }, // SPIM1 FIFOs
whismanoid 46:469d0061df5d 454 { 0x4010C000, 0x4010CFFF, "SPIM2", 1 }, // SPIM2 FIFOs
whismanoid 46:469d0061df5d 455 //{ 0x4010D000, 0x4010DFFF, "_____", 1 }, // reserved
whismanoid 46:469d0061df5d 456 { 0x4010E000, 0x4010EFFF, " SPIS", 1 }, // SPIS FIFOs
whismanoid 46:469d0061df5d 457 //{ 0x4010F000, 0x4010FFFF, "_____", 1 }, // reserved
whismanoid 46:469d0061df5d 458 //
whismanoid 46:469d0061df5d 459 { 0x00000000, 0xFFFFFFFF, "last?", 8 }, // end of list can_flash_write_read=8, catch-all
whismanoid 46:469d0061df5d 460 };
whismanoid 46:469d0061df5d 461 int search_poke_access_list(uint32_t addr)
whismanoid 46:469d0061df5d 462 {
whismanoid 46:469d0061df5d 463 // scan poke_access_list[] for peek_addr
whismanoid 46:469d0061df5d 464 for (int i = 0; poke_access_list[i].can_flash_write_read != 8; i++)
whismanoid 46:469d0061df5d 465 {
whismanoid 46:469d0061df5d 466 if ((addr >= poke_access_list[i].addr_min) && (addr <= poke_access_list[i].addr_max))
whismanoid 46:469d0061df5d 467 {
whismanoid 46:469d0061df5d 468 return i;
whismanoid 46:469d0061df5d 469 }
whismanoid 46:469d0061df5d 470 }
whismanoid 46:469d0061df5d 471 return 0;
whismanoid 46:469d0061df5d 472 }
whismanoid 46:469d0061df5d 473 #endif // defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 474
whismanoid 46:469d0061df5d 475 //--------------------------------------------------
whismanoid 3:9055e17e181a 476 // Option to use SPI connected ADC
whismanoid 3:9055e17e181a 477 #ifndef SPI_ADC_DeviceName
whismanoid 9:45f98573eb6d 478 #define SPI_ADC_DeviceName MAX11410
whismanoid 3:9055e17e181a 479 #undef SPI_ADC_DeviceName
whismanoid 3:9055e17e181a 480 #endif
whismanoid 3:9055e17e181a 481 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 482 #include "MAX11410.h"
whismanoid 3:9055e17e181a 483 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 484
whismanoid 0:cb44e2e9ec4c 485 #if defined(TARGET)
whismanoid 0:cb44e2e9ec4c 486 // TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h
whismanoid 0:cb44e2e9ec4c 487 // Create a string definition for the TARGET
whismanoid 0:cb44e2e9ec4c 488 #define STRING_ARG(arg) #arg
whismanoid 0:cb44e2e9ec4c 489 #define STRING_NAME(name) STRING_ARG(name)
whismanoid 0:cb44e2e9ec4c 490 #define TARGET_NAME STRING_NAME(TARGET)
whismanoid 0:cb44e2e9ec4c 491 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 492 #define TARGET_NAME "MAX32600"
whismanoid 0:cb44e2e9ec4c 493 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 494 #define TARGET_NAME "LPC1768"
whismanoid 0:cb44e2e9ec4c 495 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 496 #define TARGET_NAME "NUCLEO_F446RE"
whismanoid 0:cb44e2e9ec4c 497 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 498 #define TARGET_NAME "NUCLEO_F401RE"
whismanoid 0:cb44e2e9ec4c 499 #else
whismanoid 0:cb44e2e9ec4c 500 #error TARGET NOT DEFINED
whismanoid 0:cb44e2e9ec4c 501 #endif
whismanoid 0:cb44e2e9ec4c 502 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 503 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 504 // TARGET=MAX32630FTHR ARM Cortex-M4F 96MHz 2048kB Flash 512kB SRAM
whismanoid 0:cb44e2e9ec4c 505 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 506 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 507 // ______ | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 508 // ______ | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 509 // ______ | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 510 // ______ | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 511 // analogIn0/4 | [a] AIN_0 1.2Vfs (bat) SYS [ ] | switched BAT+
whismanoid 0:cb44e2e9ec4c 512 // analogIn1/5 | [a] AIN_1 1.2Vfs PWR [ ] | external pwr btn
whismanoid 0:cb44e2e9ec4c 513 // analogIn2 | [a] AIN_2 1.2Vfs +5V VBUS [ ] | USB +5V power
whismanoid 0:cb44e2e9ec4c 514 // analogIn3 | [a] AIN_3 1.2Vfs 1-WIRE P4_0 [d] | D0 dig9
whismanoid 0:cb44e2e9ec4c 515 // (I2C2.SDA) | [d] P5_7 SDA2 SRN P5_6 [d] | D1 dig8
whismanoid 0:cb44e2e9ec4c 516 // (I2C2.SCL) | [d] P6_0 SCL2 SDIO3 P5_5 [d] | D2 dig7
whismanoid 0:cb44e2e9ec4c 517 // D13/SCLK | [s] P5_0 SCLK SDIO2 P5_4 [d] | D3 dig6
whismanoid 0:cb44e2e9ec4c 518 // D11/MOSI | [s] P5_1 MOSI SSEL P5_3 [d] | D4 dig5
whismanoid 0:cb44e2e9ec4c 519 // D12/MISO | [s] P5_2 MISO RTS P3_3 [d] | D5 dig4
whismanoid 0:cb44e2e9ec4c 520 // D10/CS | [s] P3_0 RX CTS P3_2 [d] | D6 dig3
whismanoid 0:cb44e2e9ec4c 521 // D9 dig0 | [d] P3_1 TX SCL P3_5 [d] | D7 dig2
whismanoid 0:cb44e2e9ec4c 522 // ______ | [ ] GND SDA P3_4 [d] | D8 dig1
whismanoid 0:cb44e2e9ec4c 523 // | |
whismanoid 0:cb44e2e9ec4c 524 // | XIP Flash MAX14690N |
whismanoid 0:cb44e2e9ec4c 525 // | XIP_SCLK P1_0 SDA2 P5_7 |
whismanoid 0:cb44e2e9ec4c 526 // | XIP_MOSI P1_1 SCL2 P6_0 |
whismanoid 0:cb44e2e9ec4c 527 // | XIP_MISO P1_2 PMIC_INIT P3_7 |
whismanoid 0:cb44e2e9ec4c 528 // | XIP_SSEL P1_3 MPC P2_7 |
whismanoid 0:cb44e2e9ec4c 529 // | XIP_DIO2 P1_4 MON AIN_0 |
whismanoid 0:cb44e2e9ec4c 530 // | XIP_DIO3 P1_5 |
whismanoid 0:cb44e2e9ec4c 531 // | |
whismanoid 0:cb44e2e9ec4c 532 // | PAN1326B MicroSD LED |
whismanoid 0:cb44e2e9ec4c 533 // | BT_RX P0_0 SD_SCLK P0_4 r P2_4 |
whismanoid 0:cb44e2e9ec4c 534 // | BT_TX P0_1 SD_MOSI P0_5 g P2_5 |
whismanoid 0:cb44e2e9ec4c 535 // | BT_CTS P0_2 SD_MISO P0_6 b P2_6 |
whismanoid 0:cb44e2e9ec4c 536 // | BT_RTS P0_3 SD_SSEL P0_7 |
whismanoid 0:cb44e2e9ec4c 537 // | BT_RST P1_6 DETECT P2_2 |
whismanoid 0:cb44e2e9ec4c 538 // | BT_CLK P1_7 SW2 P2_3 |
whismanoid 0:cb44e2e9ec4c 539 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 540 // 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 541 // 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 542 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 543 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 544 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 545 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 546 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 547 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 548 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 549 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 550 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 551 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 552 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 553 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 554 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 555 //
whismanoid 0:cb44e2e9ec4c 556 #include "max32630fthr.h"
whismanoid 0:cb44e2e9ec4c 557 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 558 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 559 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 560 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 561 // Arduino connector
whismanoid 0:cb44e2e9ec4c 562 #ifndef A0
whismanoid 0:cb44e2e9ec4c 563 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 564 #endif
whismanoid 0:cb44e2e9ec4c 565 #ifndef A1
whismanoid 0:cb44e2e9ec4c 566 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 567 #endif
whismanoid 0:cb44e2e9ec4c 568 #ifndef A2
whismanoid 0:cb44e2e9ec4c 569 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 570 #endif
whismanoid 0:cb44e2e9ec4c 571 #ifndef A3
whismanoid 0:cb44e2e9ec4c 572 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 573 #endif
whismanoid 0:cb44e2e9ec4c 574 #ifndef D0
whismanoid 0:cb44e2e9ec4c 575 #define D0 P4_0
whismanoid 0:cb44e2e9ec4c 576 #endif
whismanoid 0:cb44e2e9ec4c 577 #ifndef D1
whismanoid 0:cb44e2e9ec4c 578 #define D1 P5_6
whismanoid 0:cb44e2e9ec4c 579 #endif
whismanoid 0:cb44e2e9ec4c 580 #ifndef D2
whismanoid 0:cb44e2e9ec4c 581 #define D2 P5_5
whismanoid 0:cb44e2e9ec4c 582 #endif
whismanoid 0:cb44e2e9ec4c 583 #ifndef D3
whismanoid 0:cb44e2e9ec4c 584 #define D3 P5_4
whismanoid 0:cb44e2e9ec4c 585 #endif
whismanoid 0:cb44e2e9ec4c 586 #ifndef D4
whismanoid 0:cb44e2e9ec4c 587 #define D4 P5_3
whismanoid 0:cb44e2e9ec4c 588 #endif
whismanoid 0:cb44e2e9ec4c 589 #ifndef D5
whismanoid 0:cb44e2e9ec4c 590 #define D5 P3_3
whismanoid 0:cb44e2e9ec4c 591 #endif
whismanoid 0:cb44e2e9ec4c 592 #ifndef D6
whismanoid 0:cb44e2e9ec4c 593 #define D6 P3_2
whismanoid 0:cb44e2e9ec4c 594 #endif
whismanoid 0:cb44e2e9ec4c 595 #ifndef D7
whismanoid 0:cb44e2e9ec4c 596 #define D7 P3_5
whismanoid 0:cb44e2e9ec4c 597 #endif
whismanoid 0:cb44e2e9ec4c 598 #ifndef D8
whismanoid 0:cb44e2e9ec4c 599 #define D8 P3_4
whismanoid 0:cb44e2e9ec4c 600 #endif
whismanoid 0:cb44e2e9ec4c 601 #ifndef D9
whismanoid 0:cb44e2e9ec4c 602 #define D9 P3_1
whismanoid 0:cb44e2e9ec4c 603 #endif
whismanoid 0:cb44e2e9ec4c 604 #ifndef D10
whismanoid 0:cb44e2e9ec4c 605 #define D10 P3_0
whismanoid 0:cb44e2e9ec4c 606 #endif
whismanoid 0:cb44e2e9ec4c 607 #ifndef D11
whismanoid 0:cb44e2e9ec4c 608 #define D11 P5_1
whismanoid 0:cb44e2e9ec4c 609 #endif
whismanoid 0:cb44e2e9ec4c 610 #ifndef D12
whismanoid 0:cb44e2e9ec4c 611 #define D12 P5_2
whismanoid 0:cb44e2e9ec4c 612 #endif
whismanoid 0:cb44e2e9ec4c 613 #ifndef D13
whismanoid 0:cb44e2e9ec4c 614 #define D13 P5_0
whismanoid 0:cb44e2e9ec4c 615 #endif
whismanoid 0:cb44e2e9ec4c 616 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 617 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 618 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 619 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 620 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 621 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 622 // | |
whismanoid 0:cb44e2e9ec4c 623 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 624 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 625 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 626 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 627 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 628 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 629 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 630 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 631 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 632 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 633 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 634 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 635 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 636 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 637 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 638 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 639 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 640 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 641 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 642 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 643 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 644 // \_______________________/
whismanoid 0:cb44e2e9ec4c 645 //
whismanoid 0:cb44e2e9ec4c 646 // +------------------------+
whismanoid 0:cb44e2e9ec4c 647 // | |
whismanoid 0:cb44e2e9ec4c 648 // | MicroSD LED |
whismanoid 0:cb44e2e9ec4c 649 // | SD_SCLK P2_4 r P3_0 |
whismanoid 0:cb44e2e9ec4c 650 // | SD_MOSI P2_5 g P3_1 |
whismanoid 0:cb44e2e9ec4c 651 // | SD_MISO P2_6 b P3_2 |
whismanoid 0:cb44e2e9ec4c 652 // | SD_SSEL P2_7 y P3_3 |
whismanoid 0:cb44e2e9ec4c 653 // | |
whismanoid 0:cb44e2e9ec4c 654 // | DAPLINK BUTTONS |
whismanoid 0:cb44e2e9ec4c 655 // | TX P2_1 SW3 P2_3 |
whismanoid 0:cb44e2e9ec4c 656 // | RX P2_0 SW2 P2_2 |
whismanoid 0:cb44e2e9ec4c 657 // +------------------------+
whismanoid 0:cb44e2e9ec4c 658 //
whismanoid 0:cb44e2e9ec4c 659 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 660 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 661 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 662 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 663 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 664 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 665 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 666 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 667 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 668 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 669 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 670 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 671 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 672 //
whismanoid 0:cb44e2e9ec4c 673 //#include "max32625mbed.h" // ?
whismanoid 0:cb44e2e9ec4c 674 //MAX32625MBED mbed(MAX32625MBED::VIO_3V3); // ?
whismanoid 0:cb44e2e9ec4c 675 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 676 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 677 const float ADC_FULL_SCALE_VOLTAGE = 1.200; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 678 // Arduino connector
whismanoid 0:cb44e2e9ec4c 679 #ifndef A0
whismanoid 0:cb44e2e9ec4c 680 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 681 #endif
whismanoid 0:cb44e2e9ec4c 682 #ifndef A1
whismanoid 0:cb44e2e9ec4c 683 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 684 #endif
whismanoid 0:cb44e2e9ec4c 685 #ifndef A2
whismanoid 0:cb44e2e9ec4c 686 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 687 #endif
whismanoid 0:cb44e2e9ec4c 688 #ifndef A3
whismanoid 0:cb44e2e9ec4c 689 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 690 #endif
whismanoid 0:cb44e2e9ec4c 691 #ifndef D0
whismanoid 0:cb44e2e9ec4c 692 #define D0 P0_0
whismanoid 0:cb44e2e9ec4c 693 #endif
whismanoid 0:cb44e2e9ec4c 694 #ifndef D1
whismanoid 0:cb44e2e9ec4c 695 #define D1 P0_1
whismanoid 0:cb44e2e9ec4c 696 #endif
whismanoid 0:cb44e2e9ec4c 697 #ifndef D2
whismanoid 0:cb44e2e9ec4c 698 #define D2 P0_2
whismanoid 0:cb44e2e9ec4c 699 #endif
whismanoid 0:cb44e2e9ec4c 700 #ifndef D3
whismanoid 0:cb44e2e9ec4c 701 #define D3 P0_3
whismanoid 0:cb44e2e9ec4c 702 #endif
whismanoid 0:cb44e2e9ec4c 703 #ifndef D4
whismanoid 0:cb44e2e9ec4c 704 #define D4 P0_4
whismanoid 0:cb44e2e9ec4c 705 #endif
whismanoid 0:cb44e2e9ec4c 706 #ifndef D5
whismanoid 0:cb44e2e9ec4c 707 #define D5 P0_5
whismanoid 0:cb44e2e9ec4c 708 #endif
whismanoid 0:cb44e2e9ec4c 709 #ifndef D6
whismanoid 0:cb44e2e9ec4c 710 #define D6 P0_6
whismanoid 0:cb44e2e9ec4c 711 #endif
whismanoid 0:cb44e2e9ec4c 712 #ifndef D7
whismanoid 0:cb44e2e9ec4c 713 #define D7 P0_7
whismanoid 0:cb44e2e9ec4c 714 #endif
whismanoid 0:cb44e2e9ec4c 715 #ifndef D8
whismanoid 0:cb44e2e9ec4c 716 #define D8 P1_4
whismanoid 0:cb44e2e9ec4c 717 #endif
whismanoid 0:cb44e2e9ec4c 718 #ifndef D9
whismanoid 0:cb44e2e9ec4c 719 #define D9 P1_5
whismanoid 0:cb44e2e9ec4c 720 #endif
whismanoid 0:cb44e2e9ec4c 721 #ifndef D10
whismanoid 0:cb44e2e9ec4c 722 #define D10 P1_3
whismanoid 0:cb44e2e9ec4c 723 #endif
whismanoid 0:cb44e2e9ec4c 724 #ifndef D11
whismanoid 0:cb44e2e9ec4c 725 #define D11 P1_1
whismanoid 0:cb44e2e9ec4c 726 #endif
whismanoid 0:cb44e2e9ec4c 727 #ifndef D12
whismanoid 0:cb44e2e9ec4c 728 #define D12 P1_2
whismanoid 0:cb44e2e9ec4c 729 #endif
whismanoid 0:cb44e2e9ec4c 730 #ifndef D13
whismanoid 0:cb44e2e9ec4c 731 #define D13 P1_0
whismanoid 0:cb44e2e9ec4c 732 #endif
whismanoid 0:cb44e2e9ec4c 733 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 734 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 735 // target MAX32600
whismanoid 0:cb44e2e9ec4c 736 //
whismanoid 0:cb44e2e9ec4c 737 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 738 const float ADC_FULL_SCALE_VOLTAGE = 1.500;
whismanoid 0:cb44e2e9ec4c 739 //
whismanoid 0:cb44e2e9ec4c 740 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 741 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 742 #warning "TARGET_MAX32620FTHR not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 743 #include "MAX32620FTHR.h"
whismanoid 0:cb44e2e9ec4c 744 // Initialize I/O voltages on MAX32620FTHR board
whismanoid 0:cb44e2e9ec4c 745 MAX32620FTHR fthr(MAX32620FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 746 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 747 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 748 #warning "TARGET_MAX32620FTHR not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 749 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 750 //
whismanoid 0:cb44e2e9ec4c 751 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 752 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 15:37c83ec50ea0 753 // #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 754 #include "max32625pico.h"
whismanoid 0:cb44e2e9ec4c 755 // configure MAX32625PICO VDDIOH mode, and I/O voltages for DIP pins and SWD pins
whismanoid 0:cb44e2e9ec4c 756 MAX32625PICO pico(
whismanoid 13:184a08909405 757 // Select source of higher-voltage logic high supply VDDIOH
whismanoid 0:cb44e2e9ec4c 758 // vddioh_mode_t iohMode
whismanoid 0:cb44e2e9ec4c 759 //~ MAX32625PICO::IOH_OFF, // No connections to VDDIOH
whismanoid 0:cb44e2e9ec4c 760 //~ MAX32625PICO::IOH_DIP_IN, // VDDIOH input from DIP pin 1 (AIN0)
whismanoid 0:cb44e2e9ec4c 761 //~ MAX32625PICO::IOH_SWD_IN, // VDDIOH input from SWD pin 1
whismanoid 0:cb44e2e9ec4c 762 MAX32625PICO::IOH_3V3, // VDDIOH = 3.3V from local supply
whismanoid 0:cb44e2e9ec4c 763 //~ MAX32625PICO::IOH_DIP_OUT, // VDDIOH = 3.3V output to DIP pin 1
whismanoid 0:cb44e2e9ec4c 764 //~ MAX32625PICO::IOH_SWD_OUT, // VDDIOH = 3.3V output to SWD pin 1
whismanoid 0:cb44e2e9ec4c 765 //
whismanoid 13:184a08909405 766 // Digital I/O pin logic high voltage 1.8V or 3.3V
whismanoid 0:cb44e2e9ec4c 767 // vio_t dipVio = MAX32625PICO::VIO_1V8 or MAX32625PICO::VIO_IOH
whismanoid 13:184a08909405 768 MAX32625PICO::VIO_1V8, // 1.8V IO (local)
whismanoid 13:184a08909405 769 //~ MAX32625PICO::VIO_IOH, // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 770 //
whismanoid 13:184a08909405 771 // Software Debug logic high voltage (normally use VIO_IOH)
whismanoid 0:cb44e2e9ec4c 772 // vio_t swdVio
whismanoid 0:cb44e2e9ec4c 773 //~ MAX32625PICO::VIO_1V8 // 1.8V IO (local)
whismanoid 0:cb44e2e9ec4c 774 MAX32625PICO::VIO_IOH // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 775 );
whismanoid 0:cb44e2e9ec4c 776 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 777 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 15:37c83ec50ea0 778 // #warning "TARGET_MAX32625PICO not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 779 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 780 //
whismanoid 0:cb44e2e9ec4c 781 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 782 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 783 // TODO1: target NUCLEO_F446RE
whismanoid 0:cb44e2e9ec4c 784 //
whismanoid 0:cb44e2e9ec4c 785 // USER_BUTTON PC13
whismanoid 0:cb44e2e9ec4c 786 // LED1 is shared with SPI_SCK on NUCLEO_F446RE PA_5, so don't use LED1.
whismanoid 0:cb44e2e9ec4c 787 #define USE_LEDS 0
whismanoid 0:cb44e2e9ec4c 788 // SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
whismanoid 0:cb44e2e9ec4c 789 // Serial serial(SERIAL_TX, SERIAL_RX);
whismanoid 0:cb44e2e9ec4c 790 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 791 const float ADC_FULL_SCALE_VOLTAGE = 3.300; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 792 //
whismanoid 0:cb44e2e9ec4c 793 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 794 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 795 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 796 // TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM
whismanoid 0:cb44e2e9ec4c 797 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 798 // ______ | [ ] GND +3.3V VOUT [ ] | ______
whismanoid 0:cb44e2e9ec4c 799 // ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | ______
whismanoid 0:cb44e2e9ec4c 800 // ______ | [ ] VB USB.IF- [ ] | ______
whismanoid 0:cb44e2e9ec4c 801 // ______ | [ ] nR USB.IF+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 802 // digitalInOut0 | [ ] p5 MOSI ETHERNET.RD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 803 // digitalInOut1 | [ ] p6 MISO ETHERNET.RD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 804 // digitalInOut2 | [ ] p7 SCLK ETHERNET.TD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 805 // digitalInOut3 | [ ] p8 ETHERNET.TD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 806 // digitalInOut4 | [ ] p9 TX SDA USB.D- [ ] | ______
whismanoid 0:cb44e2e9ec4c 807 // digitalInOut5 | [ ] p10 RX SCL USB.D+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 808 // digitalInOut6 | [ ] p11 MOSI CAN-RD p30 [ ] | digitalInOut13
whismanoid 0:cb44e2e9ec4c 809 // digitalInOut7 | [ ] p12 MISO CAN-TD p29 [ ] | digitalInOut12
whismanoid 0:cb44e2e9ec4c 810 // digitalInOut8 | [ ] p13 TX SCLK SDA TX p28 [ ] | digitalInOut11
whismanoid 0:cb44e2e9ec4c 811 // digitalInOut9 | [ ] p14 RX SCL RX p27 [ ] | digitalInOut10
whismanoid 0:cb44e2e9ec4c 812 // analogIn0 | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1
whismanoid 0:cb44e2e9ec4c 813 // analogIn1 | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2
whismanoid 0:cb44e2e9ec4c 814 // analogIn2 | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3
whismanoid 0:cb44e2e9ec4c 815 // analogIn3 | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4
whismanoid 0:cb44e2e9ec4c 816 // analogIn4 | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5
whismanoid 0:cb44e2e9ec4c 817 // analogIn5 | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6
whismanoid 0:cb44e2e9ec4c 818 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 819 // AIN6 = P0.3 = TGT_SBL_RXD?
whismanoid 0:cb44e2e9ec4c 820 // AIN7 = P0.2 = TGT_SBL_TXD?
whismanoid 0:cb44e2e9ec4c 821 //
whismanoid 0:cb44e2e9ec4c 822 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 823 // LPC1768 board uses VREF = 3.300V +A3,3V thru L1 to bypass capacitor C14
whismanoid 0:cb44e2e9ec4c 824 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 825 const float ADC_FULL_SCALE_VOLTAGE = 3.300;
whismanoid 0:cb44e2e9ec4c 826 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 0:cb44e2e9ec4c 827 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 828 // unknown target
whismanoid 0:cb44e2e9ec4c 829 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 830 #endif // target definition
whismanoid 0:cb44e2e9ec4c 831
whismanoid 0:cb44e2e9ec4c 832
whismanoid 0:cb44e2e9ec4c 833
whismanoid 0:cb44e2e9ec4c 834
whismanoid 18:1235c17b451e 835 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 836 // move definiton of USE_LEDS earlier than find_digitalInOutPin()
whismanoid 18:1235c17b451e 837 //--------------------------------------------------
whismanoid 18:1235c17b451e 838 // Option to use LEDs to show status
whismanoid 18:1235c17b451e 839 #ifndef USE_LEDS
whismanoid 18:1235c17b451e 840 #define USE_LEDS 1
whismanoid 18:1235c17b451e 841 #endif
whismanoid 18:1235c17b451e 842 #if USE_LEDS
whismanoid 18:1235c17b451e 843 #if defined(TARGET_MAX32630)
whismanoid 18:1235c17b451e 844 # define LED_ON 0
whismanoid 18:1235c17b451e 845 # define LED_OFF 1
whismanoid 18:1235c17b451e 846 //--------------------------------------------------
whismanoid 18:1235c17b451e 847 #elif defined(TARGET_MAX32625MBED)
whismanoid 18:1235c17b451e 848 # define LED_ON 0
whismanoid 18:1235c17b451e 849 # define LED_OFF 1
whismanoid 19:5ff09c8e9daf 850 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 18:1235c17b451e 851 # define LED_ON 0
whismanoid 18:1235c17b451e 852 # define LED_OFF 1
whismanoid 18:1235c17b451e 853 //--------------------------------------------------
whismanoid 18:1235c17b451e 854 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 18:1235c17b451e 855 #elif defined(TARGET_LPC1768)
whismanoid 18:1235c17b451e 856 # define LED_ON 1
whismanoid 18:1235c17b451e 857 # define LED_OFF 0
whismanoid 18:1235c17b451e 858 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 18:1235c17b451e 859 // USE_LEDS with some platform other than MAX32630, MAX32625MBED, LPC1768
whismanoid 18:1235c17b451e 860 // bugfix for MAX32600MBED LED blink pattern: check if LED_ON/LED_OFF already defined
whismanoid 18:1235c17b451e 861 # ifndef LED_ON
whismanoid 18:1235c17b451e 862 # define LED_ON 0
whismanoid 18:1235c17b451e 863 # endif
whismanoid 18:1235c17b451e 864 # ifndef LED_OFF
whismanoid 18:1235c17b451e 865 # define LED_OFF 1
whismanoid 18:1235c17b451e 866 # endif
whismanoid 18:1235c17b451e 867 //# define LED_ON 1
whismanoid 18:1235c17b451e 868 //# define LED_OFF 0
whismanoid 18:1235c17b451e 869 #endif // target definition
whismanoid 18:1235c17b451e 870 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 871 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 872 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 873 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 874 // change led1/2/3/4 from DigitalOut to DigitalInOut
whismanoid 18:1235c17b451e 875 DigitalInOut led1(LED1, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED1 = LED_RED
whismanoid 18:1235c17b451e 876 DigitalInOut led2(LED2, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN
whismanoid 18:1235c17b451e 877 DigitalInOut led3(LED3, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE
whismanoid 18:1235c17b451e 878 DigitalInOut led4(LED4, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 879 #else // USE_LEDS=0
whismanoid 18:1235c17b451e 880 // issue #41 support Nucleo_F446RE
whismanoid 18:1235c17b451e 881 // there are no LED indicators on the board, LED1 interferes with SPI;
whismanoid 18:1235c17b451e 882 // but we still need placeholders led1 led2 led3 led4.
whismanoid 18:1235c17b451e 883 // Declare DigitalInOut led1 led2 led3 led4 targeting safe pins.
whismanoid 18:1235c17b451e 884 // PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false
whismanoid 18:1235c17b451e 885 # define LED_ON 0
whismanoid 18:1235c17b451e 886 # define LED_OFF 1
whismanoid 18:1235c17b451e 887 // change led1/2/3/4 from DigitalOut to DigitalInOut
whismanoid 18:1235c17b451e 888 DigitalInOut led1(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 889 DigitalInOut led2(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 890 DigitalInOut led3(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 891 DigitalInOut led4(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 892 #endif // USE_LEDS
whismanoid 18:1235c17b451e 893 #define led1_RFailLED led1
whismanoid 18:1235c17b451e 894 #define led2_GPassLED led2
whismanoid 18:1235c17b451e 895 #define led3_BBusyLED led3
whismanoid 18:1235c17b451e 896
whismanoid 21:ac062a97a71d 897 //--------------------------------------------------
whismanoid 21:ac062a97a71d 898 // use BUTTON1 trigger some action
whismanoid 46:469d0061df5d 899 // support for commands %B1! .. %B9!
whismanoid 21:ac062a97a71d 900 #if defined(TARGET_MAX32630)
whismanoid 21:ac062a97a71d 901 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 902 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 903 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 904 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 25:8a61cb34191d 905 // #warning "TARGET_MAX32625PICO not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 906 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 24:032f3683cb2a 907 #if MAX40108_DEMO
whismanoid 25:8a61cb34191d 908 #if HAS_I2C
whismanoid 25:8a61cb34191d 909 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 910 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 24:032f3683cb2a 911 #define BUTTON2 P3_7
whismanoid 25:8a61cb34191d 912 #else // HAS_I2C
whismanoid 25:8a61cb34191d 913 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 914 // 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 915 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 916 #define BUTTON2 P1_7
whismanoid 25:8a61cb34191d 917 #endif // HAS_I2C
whismanoid 24:032f3683cb2a 918 #define HAS_BUTTON2_DEMO 0
whismanoid 24:032f3683cb2a 919 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 25:8a61cb34191d 920 #if HAS_I2C
whismanoid 25:8a61cb34191d 921 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 922 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 24:032f3683cb2a 923 #define BUTTON3 P3_6
whismanoid 25:8a61cb34191d 924 #else // HAS_I2C
whismanoid 25:8a61cb34191d 925 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 926 // 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 927 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 928 #define BUTTON3 P1_6
whismanoid 25:8a61cb34191d 929 #endif // HAS_I2C
whismanoid 24:032f3683cb2a 930 #define HAS_BUTTON3_DEMO 0
whismanoid 24:032f3683cb2a 931 #define HAS_BUTTON3_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 932 // additional buttons are assigned to unused/unaccessible pins to avoid conflicts
whismanoid 29:6a9edb6e973b 933 // activate using %B4! or action_button pin=4
whismanoid 29:6a9edb6e973b 934 #define BUTTON4 P1_5
whismanoid 29:6a9edb6e973b 935 #define HAS_BUTTON4_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 936 #define BUTTON5 P1_4
whismanoid 29:6a9edb6e973b 937 #define HAS_BUTTON5_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 938 #define BUTTON6 P1_3
whismanoid 29:6a9edb6e973b 939 #define HAS_BUTTON6_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 940 #define BUTTON7 P1_2
whismanoid 29:6a9edb6e973b 941 #define HAS_BUTTON7_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 942 #define BUTTON8 P1_1
whismanoid 29:6a9edb6e973b 943 #define HAS_BUTTON8_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 944 #define BUTTON9 P1_0
whismanoid 29:6a9edb6e973b 945 #define HAS_BUTTON9_DEMO_INTERRUPT 1
whismanoid 24:032f3683cb2a 946 #else // MAX40108_DEMO
whismanoid 21:ac062a97a71d 947 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 948 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 29:6a9edb6e973b 949 #endif // MAX40108_DEMO ---------------------------------
whismanoid 21:ac062a97a71d 950 #elif defined(TARGET_MAX32625)
whismanoid 21:ac062a97a71d 951 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 952 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 953 #elif defined(TARGET_MAX32620FTHR)
whismanoid 21:ac062a97a71d 954 #warning "TARGET_MAX32620FTHR not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 955 #define BUTTON1 SW1
whismanoid 21:ac062a97a71d 956 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 957 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 958 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 959 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 21:ac062a97a71d 960 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 961 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 962 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 21:ac062a97a71d 963 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 964 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 965 #else
whismanoid 21:ac062a97a71d 966 #warning "target not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 967 #endif
whismanoid 21:ac062a97a71d 968 //
whismanoid 21:ac062a97a71d 969 #ifndef HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 970 #define HAS_BUTTON1_DEMO 0
whismanoid 21:ac062a97a71d 971 #endif
whismanoid 21:ac062a97a71d 972 #ifndef HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 973 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 974 #endif
whismanoid 24:032f3683cb2a 975 #ifndef HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 976 #define HAS_BUTTON3_DEMO 0
whismanoid 24:032f3683cb2a 977 #endif
whismanoid 21:ac062a97a71d 978 //
whismanoid 21:ac062a97a71d 979 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 980 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 981 #ifndef HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 982 #define HAS_BUTTON1_DEMO_INTERRUPT_POLLING 1
whismanoid 21:ac062a97a71d 983 #endif
whismanoid 21:ac062a97a71d 984 //
whismanoid 21:ac062a97a71d 985 #ifndef HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 986 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 987 #endif
whismanoid 21:ac062a97a71d 988 #ifndef HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 989 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 990 #endif
whismanoid 21:ac062a97a71d 991 //
whismanoid 21:ac062a97a71d 992 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 993 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 994 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 995 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 996 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 997 # else
whismanoid 21:ac062a97a71d 998 InterruptIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 999 # endif
whismanoid 21:ac062a97a71d 1000 #elif HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 1001 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 1002 #endif
whismanoid 21:ac062a97a71d 1003 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 1004 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 1005 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 1006 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 1007 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 1008 # else
whismanoid 21:ac062a97a71d 1009 InterruptIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 1010 # endif
whismanoid 21:ac062a97a71d 1011 #elif HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 1012 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 1013 #endif
whismanoid 24:032f3683cb2a 1014 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 1015 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 24:032f3683cb2a 1016 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 24:032f3683cb2a 1017 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 24:032f3683cb2a 1018 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 1019 # else
whismanoid 24:032f3683cb2a 1020 InterruptIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 1021 # endif
whismanoid 24:032f3683cb2a 1022 #elif HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 1023 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 1024 #endif
whismanoid 21:ac062a97a71d 1025
whismanoid 0:cb44e2e9ec4c 1026 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 1027 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1028 // Declare the DigitalInOut GPIO pins
whismanoid 0:cb44e2e9ec4c 1029 // Optional digitalInOut support. If there is only one it should be digitalInOut1.
whismanoid 0:cb44e2e9ec4c 1030 // D) Digital High/Low/Input Pin
whismanoid 0:cb44e2e9ec4c 1031 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1032 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 1033 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 1034 // | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 1035 // | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 1036 // | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 1037 // | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 1038 // | [ ] AIN_0 1.2Vfs (bat) SYS [ ] |
whismanoid 0:cb44e2e9ec4c 1039 // | [ ] AIN_1 1.2Vfs PWR [ ] |
whismanoid 0:cb44e2e9ec4c 1040 // | [ ] AIN_2 1.2Vfs +5V VBUS [ ] |
whismanoid 0:cb44e2e9ec4c 1041 // | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9
whismanoid 0:cb44e2e9ec4c 1042 // dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8
whismanoid 0:cb44e2e9ec4c 1043 // dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7
whismanoid 0:cb44e2e9ec4c 1044 // dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6
whismanoid 0:cb44e2e9ec4c 1045 // dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5
whismanoid 0:cb44e2e9ec4c 1046 // dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4
whismanoid 0:cb44e2e9ec4c 1047 // dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3
whismanoid 0:cb44e2e9ec4c 1048 // dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2
whismanoid 0:cb44e2e9ec4c 1049 // | [ ] GND SDA P3_4 [x] | dig1
whismanoid 0:cb44e2e9ec4c 1050 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 1051 #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 1052 #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 1053 #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 1054 #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 1055 #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 1056 #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 1057 #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 1058 #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 1059 #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 1060 #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 1061 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 1062 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1063 #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 1064 #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 1065 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1066 #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 1067 #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 1068 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1069 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 1070 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1071 #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 1072 #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 1073 #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 1074 #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 1075 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1076 #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 1077 #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 1078 #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 1079 #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 1080 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1081 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1082 DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 1083 #endif
whismanoid 0:cb44e2e9ec4c 1084 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1085 DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 1086 #endif
whismanoid 0:cb44e2e9ec4c 1087 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1088 DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 1089 #endif
whismanoid 0:cb44e2e9ec4c 1090 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1091 DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 1092 #endif
whismanoid 0:cb44e2e9ec4c 1093 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1094 DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 1095 #endif
whismanoid 0:cb44e2e9ec4c 1096 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1097 DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 1098 #endif
whismanoid 0:cb44e2e9ec4c 1099 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1100 DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 1101 #endif
whismanoid 0:cb44e2e9ec4c 1102 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1103 DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 1104 #endif
whismanoid 0:cb44e2e9ec4c 1105 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1106 DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 1107 #endif
whismanoid 0:cb44e2e9ec4c 1108 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1109 DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 1110 #endif
whismanoid 0:cb44e2e9ec4c 1111 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1112 DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 1113 #endif
whismanoid 0:cb44e2e9ec4c 1114 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1115 DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 1116 #endif
whismanoid 0:cb44e2e9ec4c 1117 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1118 DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 1119 #endif
whismanoid 0:cb44e2e9ec4c 1120 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1121 DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 1122 #endif
whismanoid 0:cb44e2e9ec4c 1123 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1124 DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 1125 #endif
whismanoid 0:cb44e2e9ec4c 1126 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1127 DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 1128 #endif
whismanoid 0:cb44e2e9ec4c 1129 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1130 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 1131 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 1132 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 1133 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 1134 // | |
whismanoid 0:cb44e2e9ec4c 1135 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 1136 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 1137 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 1138 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 1139 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 1140 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 1141 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 1142 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 1143 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 1144 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 1145 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 1146 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 1147 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 1148 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 1149 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 1150 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 1151 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 1152 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 1153 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 1154 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 1155 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 1156 // \_______________________/
whismanoid 0:cb44e2e9ec4c 1157 //
whismanoid 0:cb44e2e9ec4c 1158 #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 1159 #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 1160 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1161 #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 1162 #else
whismanoid 0:cb44e2e9ec4c 1163 #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 1164 #endif
whismanoid 0:cb44e2e9ec4c 1165 #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 1166 #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 1167 #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 1168 #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 1169 #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 1170 #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 1171 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1172 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 1173 #else
whismanoid 0:cb44e2e9ec4c 1174 #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 1175 #endif
whismanoid 0:cb44e2e9ec4c 1176 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 1177 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1178 #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 1179 #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 1180 #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 1181 #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 1182 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1183 #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 1184 #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 1185 #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 1186 #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 1187 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1188 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 1189 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1190 #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1191 #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1192 #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1193 #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1194 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1195 #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1196 #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1197 #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1198 #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1199 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1200 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1201 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 1202 #endif
whismanoid 0:cb44e2e9ec4c 1203 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1204 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 1205 #endif
whismanoid 0:cb44e2e9ec4c 1206 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1207 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 1208 #endif
whismanoid 0:cb44e2e9ec4c 1209 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1210 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 1211 #endif
whismanoid 0:cb44e2e9ec4c 1212 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1213 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 1214 #endif
whismanoid 0:cb44e2e9ec4c 1215 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1216 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 1217 #endif
whismanoid 0:cb44e2e9ec4c 1218 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1219 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 1220 #endif
whismanoid 0:cb44e2e9ec4c 1221 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1222 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 1223 #endif
whismanoid 0:cb44e2e9ec4c 1224 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1225 DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 1226 #endif
whismanoid 0:cb44e2e9ec4c 1227 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1228 DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 1229 #endif
whismanoid 0:cb44e2e9ec4c 1230 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1231 DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 1232 #endif
whismanoid 0:cb44e2e9ec4c 1233 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1234 DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 1235 #endif
whismanoid 0:cb44e2e9ec4c 1236 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1237 DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 1238 #endif
whismanoid 0:cb44e2e9ec4c 1239 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1240 DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 1241 #endif
whismanoid 0:cb44e2e9ec4c 1242 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1243 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 1244 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 1245 DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1246 #endif
whismanoid 0:cb44e2e9ec4c 1247 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1248 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 1249 DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1250 #endif
whismanoid 0:cb44e2e9ec4c 1251 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1252 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 1253 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 1254 // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V
whismanoid 0:cb44e2e9ec4c 1255 DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1256 #endif
whismanoid 0:cb44e2e9ec4c 1257 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1258 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 1259 DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1260 #endif
whismanoid 0:cb44e2e9ec4c 1261 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 1262 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 15:37c83ec50ea0 1263 // TARGET=MAX32625PICO ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 15:37c83ec50ea0 1264 // +-------------[microUSB]-------------+
whismanoid 15:37c83ec50ea0 1265 // | [27]D+ D-[26] |
whismanoid 15:37c83ec50ea0 1266 // | |
whismanoid 15:37c83ec50ea0 1267 // | [BUTTON P2_7] |
whismanoid 15:37c83ec50ea0 1268 // | P2_4 LED_R P2_5 LED_G P2_6 LED_B |
whismanoid 15:37c83ec50ea0 1269 // | |
whismanoid 15:37c83ec50ea0 1270 // 1V8 | [11] 1.8V MAX32625PICO GND [10] | GND
whismanoid 15:37c83ec50ea0 1271 // 3V3 | [12] 3.3V +5V [09] | 5V0
whismanoid 15:37c83ec50ea0 1272 // SPI CS D7 | [13] P0_7 CS s-ssel P4_7 [08] | D15
whismanoid 15:37c83ec50ea0 1273 // SPI MISO D6 | [14] P0_6 MISO s-miso P4_6 [07] | D14
whismanoid 15:37c83ec50ea0 1274 // SPI MOSI D5 | [15] P0_5 MOSI s-mosi P4_5 [06] | D13
whismanoid 15:37c83ec50ea0 1275 // SPI SCLK D4 | [16] P0_4 SCLK s-sclk P4_4 [05] | D12
whismanoid 15:37c83ec50ea0 1276 // D3 | [17] P0_3 RTS SCL P1_7 [04] | SCL/D17
whismanoid 15:37c83ec50ea0 1277 // D2 | [18] P0_2 CTS SDA P1_6 [03] | SDA/D16
whismanoid 15:37c83ec50ea0 1278 // TX/D1 | [19] P0_1 TX0 AIN_2 [02] | A2
whismanoid 15:37c83ec50ea0 1279 // RX/D0 | [20] P0_0 RX0 AIN_0 [01] | A0/A4
whismanoid 15:37c83ec50ea0 1280 // | |
whismanoid 15:37c83ec50ea0 1281 // | DAPLINK |
whismanoid 15:37c83ec50ea0 1282 // | J3 p3_3 p3_2 p3_0 p3_1 p3_7 |
whismanoid 15:37c83ec50ea0 1283 // | DAP [ ] [ ] [RX2][TX2][ ] |
whismanoid 15:37c83ec50ea0 1284 // | TOP [ ] [ ] [ ] [ ] [ ] |
whismanoid 15:37c83ec50ea0 1285 // | AIN1/A5 gnd gnd nc AIN3 |
whismanoid 15:37c83ec50ea0 1286 // | IOH 1-wire |
whismanoid 15:37c83ec50ea0 1287 // | |
whismanoid 15:37c83ec50ea0 1288 // |NO USE RST P2_0 P2_1 |
whismanoid 15:37c83ec50ea0 1289 // |BOTTOM [ ] [ ] [RX1][ ] [TX1] |
whismanoid 15:37c83ec50ea0 1290 // | RST SWC GND SWD 1V8 |
whismanoid 15:37c83ec50ea0 1291 // |BOTTOM [21] [22] [23] [24] [25] |
whismanoid 15:37c83ec50ea0 1292 // +------------------------------------+
whismanoid 15:37c83ec50ea0 1293 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 1294 // MAX40108 demo p2: D0..D7 = P0_0..P0_7; D8..15 = P4_0..P4_7; D16/D17=I2C
whismanoid 15:37c83ec50ea0 1295 #endif
whismanoid 15:37c83ec50ea0 1296 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1297 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1298 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1299 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1300 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 1301 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 1302 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 1303 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1304 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1305 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 15:37c83ec50ea0 1306 // AIN_10 = x undefined?
whismanoid 15:37c83ec50ea0 1307 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 1308 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 1309 //
whismanoid 15:37c83ec50ea0 1310 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 1311 // avoid resource conflict D0,D1 alternate function as RX/TX
whismanoid 15:37c83ec50ea0 1312 #define HAS_digitalInOut0 0
whismanoid 15:37c83ec50ea0 1313 #define HAS_digitalInOut1 0
whismanoid 15:37c83ec50ea0 1314 #else
whismanoid 15:37c83ec50ea0 1315 #define HAS_digitalInOut0 1
whismanoid 19:5ff09c8e9daf 1316 #define HAS_digitalInOut1 1
whismanoid 19:5ff09c8e9daf 1317 // P0_1 TARGET_MAX32625PICO D1
whismanoid 15:37c83ec50ea0 1318 #endif
whismanoid 15:37c83ec50ea0 1319 #if APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 1320 // avoid resource conflict D2 alternate function as interrupt input
whismanoid 15:37c83ec50ea0 1321 #define HAS_digitalInOut2 0
whismanoid 15:37c83ec50ea0 1322 #else
whismanoid 15:37c83ec50ea0 1323 #define HAS_digitalInOut2 1
whismanoid 15:37c83ec50ea0 1324 #endif
whismanoid 15:37c83ec50ea0 1325 #define HAS_digitalInOut3 1
whismanoid 15:37c83ec50ea0 1326 #define HAS_digitalInOut4 1
whismanoid 15:37c83ec50ea0 1327 #define HAS_digitalInOut5 1
whismanoid 15:37c83ec50ea0 1328 #define HAS_digitalInOut6 1
whismanoid 15:37c83ec50ea0 1329 #define HAS_digitalInOut7 1
whismanoid 15:37c83ec50ea0 1330 //
whismanoid 15:37c83ec50ea0 1331 #define HAS_digitalInOut8 1
whismanoid 15:37c83ec50ea0 1332 #define HAS_digitalInOut9 1
whismanoid 15:37c83ec50ea0 1333 #define HAS_digitalInOut10 1
whismanoid 15:37c83ec50ea0 1334 #define HAS_digitalInOut11 1
whismanoid 15:37c83ec50ea0 1335 #define HAS_digitalInOut12 1
whismanoid 15:37c83ec50ea0 1336 #define HAS_digitalInOut13 1
whismanoid 15:37c83ec50ea0 1337 #define HAS_digitalInOut14 1
whismanoid 15:37c83ec50ea0 1338 #define HAS_digitalInOut15 1
whismanoid 15:37c83ec50ea0 1339 #if HAS_I2C
whismanoid 25:8a61cb34191d 1340 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 1341 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 25:8a61cb34191d 1342 // #define BUTTON2 P3_7
whismanoid 25:8a61cb34191d 1343 // avoid resource conflict between I2C and DigitalInOut
whismanoid 25:8a61cb34191d 1344 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1345 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 1346 #else // HAS_I2C
whismanoid 25:8a61cb34191d 1347 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 1348 // 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 1349 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1350 // #define BUTTON2 P1_7
whismanoid 25:8a61cb34191d 1351 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1352 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1353 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1354 #else // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1355 #define HAS_digitalInOut16 1 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1356 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1357 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1358 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1359 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1360 #else // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1361 #define HAS_digitalInOut17 1 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1362 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 15:37c83ec50ea0 1363 #endif // HAS_I2C
whismanoid 15:37c83ec50ea0 1364 #if HAS_digitalInOut0
whismanoid 25:8a61cb34191d 1365 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D0
whismanoid 15:37c83ec50ea0 1366 #endif
whismanoid 15:37c83ec50ea0 1367 #if HAS_digitalInOut1
whismanoid 25:8a61cb34191d 1368 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D1
whismanoid 15:37c83ec50ea0 1369 #endif
whismanoid 15:37c83ec50ea0 1370 #if HAS_digitalInOut2
whismanoid 25:8a61cb34191d 1371 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D2
whismanoid 15:37c83ec50ea0 1372 #endif
whismanoid 15:37c83ec50ea0 1373 #if HAS_digitalInOut3
whismanoid 25:8a61cb34191d 1374 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D3
whismanoid 15:37c83ec50ea0 1375 #endif
whismanoid 15:37c83ec50ea0 1376 #if HAS_digitalInOut4
whismanoid 25:8a61cb34191d 1377 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D4
whismanoid 15:37c83ec50ea0 1378 #endif
whismanoid 15:37c83ec50ea0 1379 #if HAS_digitalInOut5
whismanoid 25:8a61cb34191d 1380 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D5
whismanoid 15:37c83ec50ea0 1381 #endif
whismanoid 15:37c83ec50ea0 1382 #if HAS_digitalInOut6
whismanoid 25:8a61cb34191d 1383 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D6
whismanoid 15:37c83ec50ea0 1384 #endif
whismanoid 15:37c83ec50ea0 1385 #if HAS_digitalInOut7
whismanoid 25:8a61cb34191d 1386 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D7
whismanoid 15:37c83ec50ea0 1387 #endif
whismanoid 15:37c83ec50ea0 1388 #if HAS_digitalInOut8
whismanoid 25:8a61cb34191d 1389 DigitalInOut digitalInOut8(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX40108DEMOP2U9 D8
whismanoid 15:37c83ec50ea0 1390 #endif
whismanoid 15:37c83ec50ea0 1391 #if HAS_digitalInOut9
whismanoid 25:8a61cb34191d 1392 DigitalInOut digitalInOut9(P4_1, PIN_INPUT, PullUp, 1); // P4_1 TARGET_MAX40108DEMOP2U9 D9
whismanoid 15:37c83ec50ea0 1393 #endif
whismanoid 15:37c83ec50ea0 1394 #if HAS_digitalInOut10
whismanoid 25:8a61cb34191d 1395 DigitalInOut digitalInOut10(P4_2, PIN_INPUT, PullUp, 1); // P4_2 TARGET_MAX40108DEMOP2U9 D10
whismanoid 15:37c83ec50ea0 1396 #endif
whismanoid 15:37c83ec50ea0 1397 #if HAS_digitalInOut11
whismanoid 25:8a61cb34191d 1398 DigitalInOut digitalInOut11(P4_3, PIN_INPUT, PullUp, 1); // P4_3 TARGET_MAX40108DEMOP2U9 D11
whismanoid 15:37c83ec50ea0 1399 #endif
whismanoid 15:37c83ec50ea0 1400 #if HAS_digitalInOut12
whismanoid 25:8a61cb34191d 1401 DigitalInOut digitalInOut12(P4_4, PIN_INPUT, PullUp, 1); // P4_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D12
whismanoid 15:37c83ec50ea0 1402 #endif
whismanoid 15:37c83ec50ea0 1403 #if HAS_digitalInOut13
whismanoid 25:8a61cb34191d 1404 DigitalInOut digitalInOut13(P4_5, PIN_INPUT, PullUp, 1); // P4_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D13
whismanoid 15:37c83ec50ea0 1405 #endif
whismanoid 15:37c83ec50ea0 1406 #if HAS_digitalInOut14
whismanoid 25:8a61cb34191d 1407 DigitalInOut digitalInOut14(P4_6, PIN_INPUT, PullUp, 1); // P4_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D14
whismanoid 15:37c83ec50ea0 1408 #endif
whismanoid 15:37c83ec50ea0 1409 #if HAS_digitalInOut15
whismanoid 25:8a61cb34191d 1410 DigitalInOut digitalInOut15(P4_7, PIN_INPUT, PullUp, 1); // P4_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D15
whismanoid 15:37c83ec50ea0 1411 #endif
whismanoid 15:37c83ec50ea0 1412 #if HAS_digitalInOut16
whismanoid 15:37c83ec50ea0 1413 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 15:37c83ec50ea0 1414 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 25:8a61cb34191d 1415 DigitalInOut digitalInOut16(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 15:37c83ec50ea0 1416 #endif
whismanoid 15:37c83ec50ea0 1417 #if HAS_digitalInOut17
whismanoid 15:37c83ec50ea0 1418 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 25:8a61cb34191d 1419 DigitalInOut digitalInOut17(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 1420 #endif
whismanoid 15:37c83ec50ea0 1421 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1422 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1423 #define HAS_digitalInOut0 0
whismanoid 0:cb44e2e9ec4c 1424 #define HAS_digitalInOut1 0
whismanoid 0:cb44e2e9ec4c 1425 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1426 // D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 1427 #define HAS_digitalInOut2 0
whismanoid 0:cb44e2e9ec4c 1428 #else
whismanoid 0:cb44e2e9ec4c 1429 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1430 #endif
whismanoid 0:cb44e2e9ec4c 1431 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1432 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1433 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1434 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1435 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1436 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1437 // D8 -- MAX5715 CLRb DigitalOut
whismanoid 0:cb44e2e9ec4c 1438 #define HAS_digitalInOut8 0
whismanoid 0:cb44e2e9ec4c 1439 #else
whismanoid 0:cb44e2e9ec4c 1440 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1441 #endif
whismanoid 0:cb44e2e9ec4c 1442 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1443 // D9 -- MAX5715 LDACb DigitalOut
whismanoid 0:cb44e2e9ec4c 1444 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1445 #elif APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1446 // D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 1447 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1448 #else
whismanoid 0:cb44e2e9ec4c 1449 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1450 #endif
whismanoid 0:cb44e2e9ec4c 1451 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 1452 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1453 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1454 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1455 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1456 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1457 #define HAS_digitalInOut10 0
whismanoid 0:cb44e2e9ec4c 1458 #define HAS_digitalInOut11 0
whismanoid 0:cb44e2e9ec4c 1459 #define HAS_digitalInOut12 0
whismanoid 0:cb44e2e9ec4c 1460 #define HAS_digitalInOut13 0
whismanoid 0:cb44e2e9ec4c 1461 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1462 #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1463 #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1464 #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1465 #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1466 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1467 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 1468 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1469 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1470 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1471 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1472 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1473 #define HAS_digitalInOut14 0
whismanoid 0:cb44e2e9ec4c 1474 #define HAS_digitalInOut15 0
whismanoid 0:cb44e2e9ec4c 1475 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1476 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1477 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1478 #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1479 #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1480 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1481 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1482 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1483 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1484 DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1485 #endif
whismanoid 0:cb44e2e9ec4c 1486 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1487 DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1488 #endif
whismanoid 0:cb44e2e9ec4c 1489 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1490 DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1491 #endif
whismanoid 0:cb44e2e9ec4c 1492 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1493 DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1494 #endif
whismanoid 0:cb44e2e9ec4c 1495 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1496 DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1497 #endif
whismanoid 0:cb44e2e9ec4c 1498 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1499 DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1500 #endif
whismanoid 0:cb44e2e9ec4c 1501 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1502 DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1503 #endif
whismanoid 0:cb44e2e9ec4c 1504 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1505 DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1506 #endif
whismanoid 0:cb44e2e9ec4c 1507 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1508 DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1509 #endif
whismanoid 0:cb44e2e9ec4c 1510 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1511 DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1512 #endif
whismanoid 0:cb44e2e9ec4c 1513 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1514 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1515 DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1516 #endif
whismanoid 0:cb44e2e9ec4c 1517 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1518 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1519 DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1520 #endif
whismanoid 0:cb44e2e9ec4c 1521 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1522 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1523 DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1524 #endif
whismanoid 0:cb44e2e9ec4c 1525 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1526 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1527 DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1528 #endif
whismanoid 0:cb44e2e9ec4c 1529 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1530 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1531 DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1532 #endif
whismanoid 0:cb44e2e9ec4c 1533 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1534 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1535 DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1536 #endif
whismanoid 0:cb44e2e9ec4c 1537 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1538 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1539 DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1540 #endif
whismanoid 0:cb44e2e9ec4c 1541 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1542 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1543 DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1544 #endif
whismanoid 0:cb44e2e9ec4c 1545 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1546 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1547 #define HAS_digitalInOut0 1
whismanoid 0:cb44e2e9ec4c 1548 #define HAS_digitalInOut1 1
whismanoid 0:cb44e2e9ec4c 1549 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1550 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1551 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1552 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1553 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1554 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1555 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1556 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1557 // #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1558 // #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1559 // #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1560 // #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1561 // #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1562 // #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1563 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1564 DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3
whismanoid 0:cb44e2e9ec4c 1565 #endif
whismanoid 0:cb44e2e9ec4c 1566 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1567 DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2
whismanoid 0:cb44e2e9ec4c 1568 #endif
whismanoid 0:cb44e2e9ec4c 1569 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1570 DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1
whismanoid 0:cb44e2e9ec4c 1571 #endif
whismanoid 0:cb44e2e9ec4c 1572 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1573 DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0
whismanoid 0:cb44e2e9ec4c 1574 #endif
whismanoid 0:cb44e2e9ec4c 1575 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1576 DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1
whismanoid 0:cb44e2e9ec4c 1577 #endif
whismanoid 0:cb44e2e9ec4c 1578 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1579 DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1
whismanoid 0:cb44e2e9ec4c 1580 #endif
whismanoid 0:cb44e2e9ec4c 1581 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1582 DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1
whismanoid 0:cb44e2e9ec4c 1583 #endif
whismanoid 0:cb44e2e9ec4c 1584 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1585 DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO
whismanoid 0:cb44e2e9ec4c 1586 #endif
whismanoid 0:cb44e2e9ec4c 1587 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1588 DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK
whismanoid 0:cb44e2e9ec4c 1589 #endif
whismanoid 0:cb44e2e9ec4c 1590 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1591 DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL
whismanoid 0:cb44e2e9ec4c 1592 #endif
whismanoid 0:cb44e2e9ec4c 1593 //
whismanoid 0:cb44e2e9ec4c 1594 // these pins support analog input analogIn0 .. analogIn5
whismanoid 0:cb44e2e9ec4c 1595 //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1596 //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1597 //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1598 //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1599 //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1600 //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1601 //
whismanoid 0:cb44e2e9ec4c 1602 // these pins support PWM pwmDriver1 .. pwmDriver6
whismanoid 0:cb44e2e9ec4c 1603 //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0
whismanoid 0:cb44e2e9ec4c 1604 //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1
whismanoid 0:cb44e2e9ec4c 1605 //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2
whismanoid 0:cb44e2e9ec4c 1606 //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3
whismanoid 0:cb44e2e9ec4c 1607 //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1
whismanoid 0:cb44e2e9ec4c 1608 //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK
whismanoid 0:cb44e2e9ec4c 1609 //
whismanoid 0:cb44e2e9ec4c 1610 // these could be additional digitalInOut pins
whismanoid 0:cb44e2e9ec4c 1611 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1612 DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1
whismanoid 0:cb44e2e9ec4c 1613 #endif
whismanoid 0:cb44e2e9ec4c 1614 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1615 DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0
whismanoid 0:cb44e2e9ec4c 1616 #endif
whismanoid 0:cb44e2e9ec4c 1617 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1618 DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1
whismanoid 0:cb44e2e9ec4c 1619 #endif
whismanoid 0:cb44e2e9ec4c 1620 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1621 DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0
whismanoid 0:cb44e2e9ec4c 1622 #endif
whismanoid 0:cb44e2e9ec4c 1623 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1624 DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1625 #endif
whismanoid 0:cb44e2e9ec4c 1626 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1627 DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1628 #endif
whismanoid 0:cb44e2e9ec4c 1629 #else
whismanoid 0:cb44e2e9ec4c 1630 // unknown target
whismanoid 0:cb44e2e9ec4c 1631 #endif
whismanoid 0:cb44e2e9ec4c 1632 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1633 #if HAS_digitalInOut0 || HAS_digitalInOut1 \
whismanoid 0:cb44e2e9ec4c 1634 || HAS_digitalInOut2 || HAS_digitalInOut3 \
whismanoid 0:cb44e2e9ec4c 1635 || HAS_digitalInOut4 || HAS_digitalInOut5 \
whismanoid 0:cb44e2e9ec4c 1636 || HAS_digitalInOut6 || HAS_digitalInOut7 \
whismanoid 0:cb44e2e9ec4c 1637 || HAS_digitalInOut8 || HAS_digitalInOut9 \
whismanoid 0:cb44e2e9ec4c 1638 || HAS_digitalInOut10 || HAS_digitalInOut11 \
whismanoid 0:cb44e2e9ec4c 1639 || HAS_digitalInOut12 || HAS_digitalInOut13 \
whismanoid 0:cb44e2e9ec4c 1640 || HAS_digitalInOut14 || HAS_digitalInOut15 \
whismanoid 0:cb44e2e9ec4c 1641 || HAS_digitalInOut16 || HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1642 #define HAS_digitalInOuts 1
whismanoid 0:cb44e2e9ec4c 1643 #else
whismanoid 0:cb44e2e9ec4c 1644 #warning "Note: There are no digitalInOut resources defined"
whismanoid 0:cb44e2e9ec4c 1645 #endif
whismanoid 0:cb44e2e9ec4c 1646
whismanoid 0:cb44e2e9ec4c 1647 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 1648 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1649 // Declare the AnalogIn driver
whismanoid 0:cb44e2e9ec4c 1650 // Optional analogIn support. If there is only one it should be analogIn1.
whismanoid 0:cb44e2e9ec4c 1651 // A) analog input
whismanoid 0:cb44e2e9ec4c 1652 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1653 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1654 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1655 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1656 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1657 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1658 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1659 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1660 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1661 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1662 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1663 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1664 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1665 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1666 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1667 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1668 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1669 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1670 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1671 #endif
whismanoid 0:cb44e2e9ec4c 1672 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1673 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1674 #endif
whismanoid 0:cb44e2e9ec4c 1675 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1676 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1677 #endif
whismanoid 0:cb44e2e9ec4c 1678 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1679 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1680 #endif
whismanoid 0:cb44e2e9ec4c 1681 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1682 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1683 #endif
whismanoid 0:cb44e2e9ec4c 1684 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1685 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1686 #endif
whismanoid 0:cb44e2e9ec4c 1687 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1688 AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1689 #endif
whismanoid 0:cb44e2e9ec4c 1690 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1691 AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1692 #endif
whismanoid 0:cb44e2e9ec4c 1693 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1694 AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1695 #endif
whismanoid 0:cb44e2e9ec4c 1696 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1697 AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1698 #endif
whismanoid 0:cb44e2e9ec4c 1699 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1700 AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1701 #endif
whismanoid 0:cb44e2e9ec4c 1702 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1703 AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1704 #endif
whismanoid 0:cb44e2e9ec4c 1705 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1706 AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1707 #endif
whismanoid 0:cb44e2e9ec4c 1708 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1709 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1710 #endif
whismanoid 0:cb44e2e9ec4c 1711 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1712 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1713 #endif
whismanoid 0:cb44e2e9ec4c 1714 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1715 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1716 #endif
whismanoid 0:cb44e2e9ec4c 1717 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1718 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 1719 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1720 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1721 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1722 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1723 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1724 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1725 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1726 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1727 #endif
whismanoid 0:cb44e2e9ec4c 1728 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1729 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1730 #endif
whismanoid 0:cb44e2e9ec4c 1731 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1732 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1733 #endif
whismanoid 0:cb44e2e9ec4c 1734 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1735 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1736 #endif
whismanoid 0:cb44e2e9ec4c 1737 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1738 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1739 #endif
whismanoid 0:cb44e2e9ec4c 1740 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1741 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1742 #endif
whismanoid 0:cb44e2e9ec4c 1743 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1744 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 1745 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1746 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1747 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1748 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1749 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1750 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1751 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1752 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1753 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1754 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1755 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1756 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1757 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1758 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1759 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1760 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1761 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1762 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1763 AnalogIn analogIn0(AIN_0); // TARGET_MAX32620FTHR J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1764 #endif
whismanoid 0:cb44e2e9ec4c 1765 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1766 AnalogIn analogIn1(AIN_1); // TARGET_MAX32620FTHR J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1767 #endif
whismanoid 0:cb44e2e9ec4c 1768 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1769 AnalogIn analogIn2(AIN_2); // TARGET_MAX32620FTHR J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1770 #endif
whismanoid 0:cb44e2e9ec4c 1771 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1772 AnalogIn analogIn3(AIN_3); // TARGET_MAX32620FTHR J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1773 #endif
whismanoid 0:cb44e2e9ec4c 1774 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1775 AnalogIn analogIn4(AIN_4); // TARGET_MAX32620FTHR J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1776 #endif
whismanoid 0:cb44e2e9ec4c 1777 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1778 AnalogIn analogIn5(AIN_5); // TARGET_MAX32620FTHR J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1779 #endif
whismanoid 0:cb44e2e9ec4c 1780 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1781 AnalogIn analogIn6(AIN_6); // TARGET_MAX32620FTHR AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1782 #endif
whismanoid 0:cb44e2e9ec4c 1783 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1784 AnalogIn analogIn7(AIN_7); // TARGET_MAX32620FTHR AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1785 #endif
whismanoid 0:cb44e2e9ec4c 1786 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1787 AnalogIn analogIn8(AIN_8); // TARGET_MAX32620FTHR AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1788 #endif
whismanoid 0:cb44e2e9ec4c 1789 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1790 AnalogIn analogIn9(AIN_9); // TARGET_MAX32620FTHR AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1791 #endif
whismanoid 0:cb44e2e9ec4c 1792 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1793 AnalogIn analogIn10(____); // TARGET_MAX32620FTHR AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1794 #endif
whismanoid 0:cb44e2e9ec4c 1795 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1796 AnalogIn analogIn11(____); // TARGET_MAX32620FTHR AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1797 #endif
whismanoid 0:cb44e2e9ec4c 1798 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1799 AnalogIn analogIn12(____); // TARGET_MAX32620FTHR AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1800 #endif
whismanoid 0:cb44e2e9ec4c 1801 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1802 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1803 #endif
whismanoid 0:cb44e2e9ec4c 1804 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1805 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1806 #endif
whismanoid 0:cb44e2e9ec4c 1807 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1808 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1809 #endif
whismanoid 0:cb44e2e9ec4c 1810 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 1811 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 37:3f369235e5bc 1812 // #warning "TARGET_MAX32625PICO not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1813 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1814 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1815 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1816 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1817 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1818 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1819 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1820 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1821 #endif
whismanoid 0:cb44e2e9ec4c 1822 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1823 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1824 #endif
whismanoid 0:cb44e2e9ec4c 1825 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1826 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1827 #endif
whismanoid 0:cb44e2e9ec4c 1828 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1829 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1830 #endif
whismanoid 0:cb44e2e9ec4c 1831 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1832 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1833 #endif
whismanoid 0:cb44e2e9ec4c 1834 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1835 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1836 #endif
whismanoid 0:cb44e2e9ec4c 1837 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1838 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 1839 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1840 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1841 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1842 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1843 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1844 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1845 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1846 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1847 #endif
whismanoid 0:cb44e2e9ec4c 1848 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1849 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1850 #endif
whismanoid 0:cb44e2e9ec4c 1851 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1852 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1853 #endif
whismanoid 0:cb44e2e9ec4c 1854 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1855 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1856 #endif
whismanoid 0:cb44e2e9ec4c 1857 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1858 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1859 #endif
whismanoid 0:cb44e2e9ec4c 1860 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1861 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1862 #endif
whismanoid 0:cb44e2e9ec4c 1863 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1864 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 1865 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1866 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1867 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1868 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1869 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1870 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1871 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1872 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1873 #endif
whismanoid 0:cb44e2e9ec4c 1874 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1875 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1876 #endif
whismanoid 0:cb44e2e9ec4c 1877 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1878 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1879 #endif
whismanoid 0:cb44e2e9ec4c 1880 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1881 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1882 #endif
whismanoid 0:cb44e2e9ec4c 1883 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1884 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1885 #endif
whismanoid 0:cb44e2e9ec4c 1886 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1887 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1888 #endif
whismanoid 0:cb44e2e9ec4c 1889 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1890 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1891 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1892 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1893 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1894 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1895 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1896 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1897 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1898 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1899 #endif
whismanoid 0:cb44e2e9ec4c 1900 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1901 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1902 #endif
whismanoid 0:cb44e2e9ec4c 1903 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1904 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1905 #endif
whismanoid 0:cb44e2e9ec4c 1906 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1907 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1908 #endif
whismanoid 0:cb44e2e9ec4c 1909 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1910 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1911 #endif
whismanoid 0:cb44e2e9ec4c 1912 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1913 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1914 #endif
whismanoid 0:cb44e2e9ec4c 1915 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1916 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 1917 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1918 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1919 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1920 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1921 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1922 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1923 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1924 // #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1925 // #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1926 // #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1927 // #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1928 // #define HAS_analogIn10 1
whismanoid 0:cb44e2e9ec4c 1929 // #define HAS_analogIn11 1
whismanoid 0:cb44e2e9ec4c 1930 // #define HAS_analogIn12 1
whismanoid 0:cb44e2e9ec4c 1931 // #define HAS_analogIn13 1
whismanoid 0:cb44e2e9ec4c 1932 // #define HAS_analogIn14 1
whismanoid 0:cb44e2e9ec4c 1933 // #define HAS_analogIn15 1
whismanoid 0:cb44e2e9ec4c 1934 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1935 AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1936 #endif
whismanoid 0:cb44e2e9ec4c 1937 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1938 AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1939 #endif
whismanoid 0:cb44e2e9ec4c 1940 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1941 AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1942 #endif
whismanoid 0:cb44e2e9ec4c 1943 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1944 AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1945 #endif
whismanoid 0:cb44e2e9ec4c 1946 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1947 AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1948 #endif
whismanoid 0:cb44e2e9ec4c 1949 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1950 AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1951 #endif
whismanoid 0:cb44e2e9ec4c 1952 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1953 AnalogIn analogIn6(____);
whismanoid 0:cb44e2e9ec4c 1954 #endif
whismanoid 0:cb44e2e9ec4c 1955 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1956 AnalogIn analogIn7(____);
whismanoid 0:cb44e2e9ec4c 1957 #endif
whismanoid 0:cb44e2e9ec4c 1958 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1959 AnalogIn analogIn8(____);
whismanoid 0:cb44e2e9ec4c 1960 #endif
whismanoid 0:cb44e2e9ec4c 1961 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1962 AnalogIn analogIn9(____);
whismanoid 0:cb44e2e9ec4c 1963 #endif
whismanoid 0:cb44e2e9ec4c 1964 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1965 AnalogIn analogIn10(____);
whismanoid 0:cb44e2e9ec4c 1966 #endif
whismanoid 0:cb44e2e9ec4c 1967 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1968 AnalogIn analogIn11(____);
whismanoid 0:cb44e2e9ec4c 1969 #endif
whismanoid 0:cb44e2e9ec4c 1970 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1971 AnalogIn analogIn12(____);
whismanoid 0:cb44e2e9ec4c 1972 #endif
whismanoid 0:cb44e2e9ec4c 1973 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1974 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1975 #endif
whismanoid 0:cb44e2e9ec4c 1976 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1977 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1978 #endif
whismanoid 0:cb44e2e9ec4c 1979 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1980 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1981 #endif
whismanoid 0:cb44e2e9ec4c 1982 #else
whismanoid 0:cb44e2e9ec4c 1983 // unknown target
whismanoid 0:cb44e2e9ec4c 1984 #endif
whismanoid 0:cb44e2e9ec4c 1985 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1986 #if HAS_analogIn0 || HAS_analogIn1 \
whismanoid 0:cb44e2e9ec4c 1987 || HAS_analogIn2 || HAS_analogIn3 \
whismanoid 0:cb44e2e9ec4c 1988 || HAS_analogIn4 || HAS_analogIn5 \
whismanoid 0:cb44e2e9ec4c 1989 || HAS_analogIn6 || HAS_analogIn7 \
whismanoid 0:cb44e2e9ec4c 1990 || HAS_analogIn8 || HAS_analogIn9 \
whismanoid 0:cb44e2e9ec4c 1991 || HAS_analogIn10 || HAS_analogIn11 \
whismanoid 0:cb44e2e9ec4c 1992 || HAS_analogIn12 || HAS_analogIn13 \
whismanoid 0:cb44e2e9ec4c 1993 || HAS_analogIn14 || HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1994 #define HAS_analogIns 1
whismanoid 0:cb44e2e9ec4c 1995 #else
whismanoid 0:cb44e2e9ec4c 1996 #warning "Note: There are no analogIn resources defined"
whismanoid 0:cb44e2e9ec4c 1997 #endif
whismanoid 0:cb44e2e9ec4c 1998
whismanoid 0:cb44e2e9ec4c 1999 // DigitalInOut pin resource: print the pin index names to serial
whismanoid 0:cb44e2e9ec4c 2000 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 2001 void list_digitalInOutPins(Stream& serialStream)
whismanoid 0:cb44e2e9ec4c 2002 {
whismanoid 0:cb44e2e9ec4c 2003 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 2004 serialStream.printf(" 0");
whismanoid 0:cb44e2e9ec4c 2005 #endif
whismanoid 0:cb44e2e9ec4c 2006 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 2007 serialStream.printf(" 1");
whismanoid 0:cb44e2e9ec4c 2008 #endif
whismanoid 0:cb44e2e9ec4c 2009 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 2010 serialStream.printf(" 2");
whismanoid 0:cb44e2e9ec4c 2011 #endif
whismanoid 0:cb44e2e9ec4c 2012 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 2013 serialStream.printf(" 3");
whismanoid 0:cb44e2e9ec4c 2014 #endif
whismanoid 0:cb44e2e9ec4c 2015 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 2016 serialStream.printf(" 4");
whismanoid 0:cb44e2e9ec4c 2017 #endif
whismanoid 0:cb44e2e9ec4c 2018 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 2019 serialStream.printf(" 5");
whismanoid 0:cb44e2e9ec4c 2020 #endif
whismanoid 0:cb44e2e9ec4c 2021 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 2022 serialStream.printf(" 6");
whismanoid 0:cb44e2e9ec4c 2023 #endif
whismanoid 0:cb44e2e9ec4c 2024 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 2025 serialStream.printf(" 7");
whismanoid 0:cb44e2e9ec4c 2026 #endif
whismanoid 0:cb44e2e9ec4c 2027 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 2028 serialStream.printf(" 8");
whismanoid 0:cb44e2e9ec4c 2029 #endif
whismanoid 0:cb44e2e9ec4c 2030 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 2031 serialStream.printf(" 9");
whismanoid 0:cb44e2e9ec4c 2032 #endif
whismanoid 0:cb44e2e9ec4c 2033 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 2034 serialStream.printf(" 10");
whismanoid 0:cb44e2e9ec4c 2035 #endif
whismanoid 0:cb44e2e9ec4c 2036 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 2037 serialStream.printf(" 11");
whismanoid 0:cb44e2e9ec4c 2038 #endif
whismanoid 0:cb44e2e9ec4c 2039 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 2040 serialStream.printf(" 12");
whismanoid 0:cb44e2e9ec4c 2041 #endif
whismanoid 0:cb44e2e9ec4c 2042 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 2043 serialStream.printf(" 13");
whismanoid 0:cb44e2e9ec4c 2044 #endif
whismanoid 0:cb44e2e9ec4c 2045 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 2046 serialStream.printf(" 14");
whismanoid 0:cb44e2e9ec4c 2047 #endif
whismanoid 0:cb44e2e9ec4c 2048 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 2049 serialStream.printf(" 15");
whismanoid 0:cb44e2e9ec4c 2050 #endif
whismanoid 0:cb44e2e9ec4c 2051 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 2052 serialStream.printf(" 16");
whismanoid 0:cb44e2e9ec4c 2053 #endif
whismanoid 0:cb44e2e9ec4c 2054 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 2055 serialStream.printf(" 17");
whismanoid 0:cb44e2e9ec4c 2056 #endif
whismanoid 18:1235c17b451e 2057 #if USE_LEDS
whismanoid 18:1235c17b451e 2058 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 2059 // support list_digitalInOutPins() listing buttons and leds as pin numbers 90/91/92/93
whismanoid 18:1235c17b451e 2060 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 2061 //~ serialStream.printf(" 90");
whismanoid 18:1235c17b451e 2062 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 2063 serialStream.printf(" 91");
whismanoid 18:1235c17b451e 2064 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 2065 serialStream.printf(" 92");
whismanoid 18:1235c17b451e 2066 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 2067 serialStream.printf(" 93");
whismanoid 18:1235c17b451e 2068 #else // USE_LEDS
whismanoid 18:1235c17b451e 2069 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 2070 }
whismanoid 0:cb44e2e9ec4c 2071 #endif
whismanoid 0:cb44e2e9ec4c 2072
whismanoid 0:cb44e2e9ec4c 2073
whismanoid 0:cb44e2e9ec4c 2074 // DigitalInOut pin resource: search index
whismanoid 0:cb44e2e9ec4c 2075 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 2076 DigitalInOut& find_digitalInOutPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 2077 {
whismanoid 0:cb44e2e9ec4c 2078 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 2079 {
whismanoid 0:cb44e2e9ec4c 2080 default: // default to the first defined digitalInOut pin
whismanoid 0:cb44e2e9ec4c 2081 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 2082 case '0': case 0x00: return digitalInOut0;
whismanoid 0:cb44e2e9ec4c 2083 #endif
whismanoid 0:cb44e2e9ec4c 2084 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 2085 case '1': case 0x01: return digitalInOut1;
whismanoid 0:cb44e2e9ec4c 2086 #endif
whismanoid 0:cb44e2e9ec4c 2087 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 2088 case '2': case 0x02: return digitalInOut2;
whismanoid 0:cb44e2e9ec4c 2089 #endif
whismanoid 0:cb44e2e9ec4c 2090 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 2091 case '3': case 0x03: return digitalInOut3;
whismanoid 0:cb44e2e9ec4c 2092 #endif
whismanoid 0:cb44e2e9ec4c 2093 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 2094 case '4': case 0x04: return digitalInOut4;
whismanoid 0:cb44e2e9ec4c 2095 #endif
whismanoid 0:cb44e2e9ec4c 2096 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 2097 case '5': case 0x05: return digitalInOut5;
whismanoid 0:cb44e2e9ec4c 2098 #endif
whismanoid 0:cb44e2e9ec4c 2099 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 2100 case '6': case 0x06: return digitalInOut6;
whismanoid 0:cb44e2e9ec4c 2101 #endif
whismanoid 0:cb44e2e9ec4c 2102 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 2103 case '7': case 0x07: return digitalInOut7;
whismanoid 0:cb44e2e9ec4c 2104 #endif
whismanoid 0:cb44e2e9ec4c 2105 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 2106 case '8': case 0x08: return digitalInOut8;
whismanoid 0:cb44e2e9ec4c 2107 #endif
whismanoid 0:cb44e2e9ec4c 2108 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 2109 case '9': case 0x09: return digitalInOut9;
whismanoid 0:cb44e2e9ec4c 2110 #endif
whismanoid 0:cb44e2e9ec4c 2111 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 2112 case 'a': case 0x0a: return digitalInOut10;
whismanoid 0:cb44e2e9ec4c 2113 #endif
whismanoid 0:cb44e2e9ec4c 2114 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 2115 case 'b': case 0x0b: return digitalInOut11;
whismanoid 0:cb44e2e9ec4c 2116 #endif
whismanoid 0:cb44e2e9ec4c 2117 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 2118 case 'c': case 0x0c: return digitalInOut12;
whismanoid 0:cb44e2e9ec4c 2119 #endif
whismanoid 0:cb44e2e9ec4c 2120 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 2121 case 'd': case 0x0d: return digitalInOut13;
whismanoid 0:cb44e2e9ec4c 2122 #endif
whismanoid 0:cb44e2e9ec4c 2123 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 2124 case 'e': case 0x0e: return digitalInOut14;
whismanoid 0:cb44e2e9ec4c 2125 #endif
whismanoid 0:cb44e2e9ec4c 2126 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 2127 case 'f': case 0x0f: return digitalInOut15;
whismanoid 0:cb44e2e9ec4c 2128 #endif
whismanoid 0:cb44e2e9ec4c 2129 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 2130 case 'g': case 0x10: return digitalInOut16;
whismanoid 0:cb44e2e9ec4c 2131 #endif
whismanoid 0:cb44e2e9ec4c 2132 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 2133 case 'h': case 0x11: return digitalInOut17;
whismanoid 0:cb44e2e9ec4c 2134 #endif
whismanoid 18:1235c17b451e 2135 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 2136 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 2137 //~ case 90: return button1;
whismanoid 18:1235c17b451e 2138 #if USE_LEDS
whismanoid 18:1235c17b451e 2139 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 2140 case 91: return led1_RFailLED;
whismanoid 18:1235c17b451e 2141 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 2142 case 92: return led2_GPassLED;
whismanoid 18:1235c17b451e 2143 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 2144 case 93: return led3_BBusyLED;
whismanoid 18:1235c17b451e 2145 #else // USE_LEDS
whismanoid 18:1235c17b451e 2146 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 2147 }
whismanoid 0:cb44e2e9ec4c 2148 }
whismanoid 0:cb44e2e9ec4c 2149 #endif
whismanoid 0:cb44e2e9ec4c 2150
whismanoid 0:cb44e2e9ec4c 2151
whismanoid 0:cb44e2e9ec4c 2152 // AnalogIn pin resource: search index
whismanoid 0:cb44e2e9ec4c 2153 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 2154 AnalogIn& find_analogInPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 2155 {
whismanoid 0:cb44e2e9ec4c 2156 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 2157 {
whismanoid 0:cb44e2e9ec4c 2158 default: // default to the first defined analogIn pin
whismanoid 0:cb44e2e9ec4c 2159 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 2160 case '0': case 0x00: return analogIn0;
whismanoid 0:cb44e2e9ec4c 2161 #endif
whismanoid 0:cb44e2e9ec4c 2162 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 2163 case '1': case 0x01: return analogIn1;
whismanoid 0:cb44e2e9ec4c 2164 #endif
whismanoid 0:cb44e2e9ec4c 2165 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 2166 case '2': case 0x02: return analogIn2;
whismanoid 0:cb44e2e9ec4c 2167 #endif
whismanoid 0:cb44e2e9ec4c 2168 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 2169 case '3': case 0x03: return analogIn3;
whismanoid 0:cb44e2e9ec4c 2170 #endif
whismanoid 0:cb44e2e9ec4c 2171 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 2172 case '4': case 0x04: return analogIn4;
whismanoid 0:cb44e2e9ec4c 2173 #endif
whismanoid 0:cb44e2e9ec4c 2174 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 2175 case '5': case 0x05: return analogIn5;
whismanoid 0:cb44e2e9ec4c 2176 #endif
whismanoid 0:cb44e2e9ec4c 2177 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 2178 case '6': case 0x06: return analogIn6;
whismanoid 0:cb44e2e9ec4c 2179 #endif
whismanoid 0:cb44e2e9ec4c 2180 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 2181 case '7': case 0x07: return analogIn7;
whismanoid 0:cb44e2e9ec4c 2182 #endif
whismanoid 0:cb44e2e9ec4c 2183 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 2184 case '8': case 0x08: return analogIn8;
whismanoid 0:cb44e2e9ec4c 2185 #endif
whismanoid 0:cb44e2e9ec4c 2186 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 2187 case '9': case 0x09: return analogIn9;
whismanoid 0:cb44e2e9ec4c 2188 #endif
whismanoid 0:cb44e2e9ec4c 2189 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 2190 case 'a': case 0x0a: return analogIn10;
whismanoid 0:cb44e2e9ec4c 2191 #endif
whismanoid 0:cb44e2e9ec4c 2192 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 2193 case 'b': case 0x0b: return analogIn11;
whismanoid 0:cb44e2e9ec4c 2194 #endif
whismanoid 0:cb44e2e9ec4c 2195 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 2196 case 'c': case 0x0c: return analogIn12;
whismanoid 0:cb44e2e9ec4c 2197 #endif
whismanoid 0:cb44e2e9ec4c 2198 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 2199 case 'd': case 0x0d: return analogIn13;
whismanoid 0:cb44e2e9ec4c 2200 #endif
whismanoid 0:cb44e2e9ec4c 2201 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 2202 case 'e': case 0x0e: return analogIn14;
whismanoid 0:cb44e2e9ec4c 2203 #endif
whismanoid 0:cb44e2e9ec4c 2204 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 2205 case 'f': case 0x0f: return analogIn15;
whismanoid 0:cb44e2e9ec4c 2206 #endif
whismanoid 0:cb44e2e9ec4c 2207 }
whismanoid 0:cb44e2e9ec4c 2208 }
whismanoid 0:cb44e2e9ec4c 2209 #endif
whismanoid 0:cb44e2e9ec4c 2210
whismanoid 0:cb44e2e9ec4c 2211 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 2212 const float analogInPin_fullScaleVoltage[] = {
whismanoid 0:cb44e2e9ec4c 2213 # if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 2214 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 2215 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 2216 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 2217 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 2218 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2219 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2220 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2221 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2222 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2223 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 2224 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 2225 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2226 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2227 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2228 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2229 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2230 # elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 2231 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 2232 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 2233 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 2234 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 2235 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 2236 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2237 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2238 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2239 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2240 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2241 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 2242 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 2243 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2244 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2245 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2246 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2247 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 19:5ff09c8e9daf 2248 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 2249 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2250 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2251 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2252 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2253 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2254 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2255 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2256 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2257 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2258 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 2259 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 2260 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2261 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2262 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2263 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2264 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2265 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 2266 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 2267 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 2268 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 2269 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 2270 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 2271 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 2272 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 2273 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 2274 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 2275 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 2276 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 2277 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 2278 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 2279 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2280 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2281 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2282 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 2283 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 2284 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 2285 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 2286 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 2287 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 2288 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 2289 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 2290 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 2291 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 2292 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 2293 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 2294 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 2295 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 2296 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2297 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2298 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2299 //#elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 2300 #else
whismanoid 0:cb44e2e9ec4c 2301 // unknown target
whismanoid 0:cb44e2e9ec4c 2302 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 2303 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 2304 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 2305 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 2306 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 2307 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 2308 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 2309 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 2310 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 2311 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 2312 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 2313 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 2314 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 2315 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2316 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2317 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2318 # endif
whismanoid 0:cb44e2e9ec4c 2319 };
whismanoid 0:cb44e2e9ec4c 2320 #endif
whismanoid 0:cb44e2e9ec4c 2321
whismanoid 0:cb44e2e9ec4c 2322
whismanoid 0:cb44e2e9ec4c 2323
whismanoid 0:cb44e2e9ec4c 2324
whismanoid 0:cb44e2e9ec4c 2325 //--------------------------------------------------
whismanoid 45:74bf1fe021e5 2326 // support CmdLine command menus (like on Serial_Tester)
whismanoid 4:d9b05924ad4c 2327 #ifndef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 2328 #define USE_CMDLINE_MENUS 1
whismanoid 4:d9b05924ad4c 2329 //~ #undef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 2330 #endif
whismanoid 4:d9b05924ad4c 2331 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2332 #include "CmdLine.h"
whismanoid 4:d9b05924ad4c 2333 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2334 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2335 extern CmdLine cmdLine; // declared later
whismanoid 4:d9b05924ad4c 2336 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2337
whismanoid 4:d9b05924ad4c 2338 //--------------------------------------------------
whismanoid 39:4d285e961435 2339 // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2340 #ifndef USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 2341 #define USE_DATALOGGER_SLEEP 1
whismanoid 39:4d285e961435 2342 //~ #undef USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 2343 #endif
whismanoid 39:4d285e961435 2344 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 2345 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 2346 // USE_DATALOGGER_SLEEP -- #include "lp.h" -- LP_EnterLP1()
whismanoid 42:89607d5d4e6d 2347 #include "lp.h"
whismanoid 43:4c4733760d4c 2348 #include "rtc.h"
whismanoid 39:4d285e961435 2349 #endif
whismanoid 39:4d285e961435 2350 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 44:84402faa8eb9 2351 // wait until UART_Busy indicates no ongoing transactions (both ports)
whismanoid 44:84402faa8eb9 2352 #include "uart.h"
whismanoid 44:84402faa8eb9 2353 int Console_PrepForSleep(void)
whismanoid 44:84402faa8eb9 2354 {
whismanoid 44:84402faa8eb9 2355 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 44:84402faa8eb9 2356 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK)
whismanoid 44:84402faa8eb9 2357 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 44:84402faa8eb9 2358 return (
whismanoid 44:84402faa8eb9 2359 (UART_PrepForSleep(MXC_UART_GET_UART(0)) == E_NO_ERROR)
whismanoid 44:84402faa8eb9 2360 && (UART_PrepForSleep(MXC_UART_GET_UART(1)) == E_NO_ERROR)
whismanoid 44:84402faa8eb9 2361 )
whismanoid 44:84402faa8eb9 2362 ? E_NO_ERROR
whismanoid 44:84402faa8eb9 2363 : E_BUSY;
whismanoid 44:84402faa8eb9 2364 }
whismanoid 44:84402faa8eb9 2365 #endif // USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 44:84402faa8eb9 2366 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2367 typedef enum Datalogger_Sleep_enum_t {
whismanoid 39:4d285e961435 2368 datalogger_Sleep_LP0_Stop = 0,
whismanoid 39:4d285e961435 2369 datalogger_Sleep_LP1_DeepSleep = 1,
whismanoid 39:4d285e961435 2370 datalogger_Sleep_LP2_Sleep = 2,
whismanoid 39:4d285e961435 2371 datalogger_Sleep_LP3_Run = 3,
whismanoid 39:4d285e961435 2372 } Datalogger_Sleep_enum_t;
whismanoid 45:74bf1fe021e5 2373 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 2374 Datalogger_Sleep_enum_t g_timer_sleepmode = datalogger_Sleep_LP1_DeepSleep;
whismanoid 39:4d285e961435 2375 #endif
whismanoid 39:4d285e961435 2376
whismanoid 39:4d285e961435 2377 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2378 // Datalog trigger types
whismanoid 4:d9b05924ad4c 2379 #ifndef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 2380 #define USE_DATALOGGER_TRIGGER 1
whismanoid 4:d9b05924ad4c 2381 //~ #undef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 2382 #endif
whismanoid 4:d9b05924ad4c 2383 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 2384 typedef enum Datalogger_Trigger_enum_t {
whismanoid 4:d9b05924ad4c 2385 trigger_Halt = 0, //!< halt
whismanoid 4:d9b05924ad4c 2386 trigger_FreeRun = 1, //!< free run as fast as possible
whismanoid 4:d9b05924ad4c 2387 trigger_Timer = 2, //!< timer (configure interval)
whismanoid 4:d9b05924ad4c 2388 trigger_PlatformDigitalInput, //!< platform digital input (configure digital input pin reference)
whismanoid 4:d9b05924ad4c 2389 trigger_SPIDeviceRegRead, //!< SPI device register read (configure regaddr, mask value, match value)
whismanoid 4:d9b05924ad4c 2390 } Datalogger_Trigger_enum_t;
whismanoid 4:d9b05924ad4c 2391 Datalogger_Trigger_enum_t Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 2392 //
whismanoid 17:9397ea3ea7e9 2393 // configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 2394 int g_timer_interval_msec = 500; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2395 int g_timer_interval_count = 10; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2396 int g_timer_interval_counter = 0; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2397 //
whismanoid 17:9397ea3ea7e9 2398 // TODO: configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 2399 //
whismanoid 17:9397ea3ea7e9 2400 // TODO: configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2401 //
whismanoid 4:d9b05924ad4c 2402 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 2403
whismanoid 4:d9b05924ad4c 2404 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2405 // support trigger_SPIDeviceRegRead: Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 2406 #ifndef USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2407 #define USE_DATALOGGER_SPIDeviceRegRead 0
whismanoid 17:9397ea3ea7e9 2408 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2409 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2410 // TODO: uint16_t regAddr;
whismanoid 17:9397ea3ea7e9 2411 // TODO: uint16_t regDataMask;
whismanoid 17:9397ea3ea7e9 2412 // TODO: uint16_t regDataTest;
whismanoid 17:9397ea3ea7e9 2413 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2414
whismanoid 17:9397ea3ea7e9 2415 //--------------------------------------------------
whismanoid 30:07197a430869 2416 // support Datalogger_PrintRow() print gstrRemarkText field from recent #remark
whismanoid 30:07197a430869 2417 #ifndef USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2418 #define USE_DATALOGGER_REMARK_FIELD 1
whismanoid 30:07197a430869 2419 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2420 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2421 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark
whismanoid 30:07197a430869 2422 const size_t gstrRemarkTextLASTINDEX = 40; // gstrRemarkText buffer size - 1
whismanoid 30:07197a430869 2423 char gstrRemarkText[gstrRemarkTextLASTINDEX+1] = "";
whismanoid 30:07197a430869 2424 char gstrRemarkHeader[] = "comment"; // comment or remark?
whismanoid 30:07197a430869 2425 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2426
whismanoid 30:07197a430869 2427 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2428 // Datalogger_RunActionTable() supported actions
whismanoid 45:74bf1fe021e5 2429 // support command L@
whismanoid 45:74bf1fe021e5 2430 // configurable "business logic" for the data log
whismanoid 17:9397ea3ea7e9 2431 #ifndef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2432 #define USE_DATALOGGER_ActionTable 1
whismanoid 17:9397ea3ea7e9 2433 //~ #undef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2434 #endif
whismanoid 17:9397ea3ea7e9 2435 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2436 //
whismanoid 17:9397ea3ea7e9 2437 // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2438 typedef enum action_type_enum_t {
whismanoid 17:9397ea3ea7e9 2439 action_noop = 0, // no operation
whismanoid 30:07197a430869 2440 action_digitalOutLow = 1, // pin = low if condition
whismanoid 30:07197a430869 2441 action_digitalOutHigh = 2, // pin = high if condition
whismanoid 30:07197a430869 2442 action_button = 3, // pin = button event index 1, 2, 3
whismanoid 30:07197a430869 2443 action_trigger_Halt = 4,
whismanoid 30:07197a430869 2444 action_trigger_FreeRun = 5,
whismanoid 30:07197a430869 2445 action_trigger_Timer = 6,
whismanoid 30:07197a430869 2446 action_trigger_PlatformDigitalInput = 7,
whismanoid 30:07197a430869 2447 action_trigger_SPIDeviceRegRead = 8,
whismanoid 17:9397ea3ea7e9 2448 } action_type_enum_t;
whismanoid 17:9397ea3ea7e9 2449 //
whismanoid 17:9397ea3ea7e9 2450 // Datalogger_RunActionTable() supported conditions
whismanoid 17:9397ea3ea7e9 2451 typedef enum action_condition_enum_t {
whismanoid 17:9397ea3ea7e9 2452 condition_always = 0, // ( true )
whismanoid 17:9397ea3ea7e9 2453 condition_if_An_gt_threshold, // (Platform_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2454 condition_if_An_lt_threshold, // (Platform_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2455 condition_if_An_eq_threshold, // (Platform_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2456 condition_if_An_ge_threshold, // (Platform_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2457 condition_if_An_le_threshold, // (Platform_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2458 condition_if_An_ne_threshold, // (Platform_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2459 condition_if_AINn_gt_threshold, // (SPI_AIN_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2460 condition_if_AINn_lt_threshold, // (SPI_AIN_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2461 condition_if_AINn_eq_threshold, // (SPI_AIN_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2462 condition_if_AINn_ge_threshold, // (SPI_AIN_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2463 condition_if_AINn_le_threshold, // (SPI_AIN_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2464 condition_if_AINn_ne_threshold, // (SPI_AIN_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2465 } condition_enum_t;
whismanoid 17:9397ea3ea7e9 2466 //
whismanoid 17:9397ea3ea7e9 2467 // Datalogger_RunActionTable() structure
whismanoid 17:9397ea3ea7e9 2468 typedef struct action_table_row_t {
whismanoid 17:9397ea3ea7e9 2469 action_type_enum_t action;
whismanoid 17:9397ea3ea7e9 2470 int digitalOutPin;
whismanoid 17:9397ea3ea7e9 2471 action_condition_enum_t condition;
whismanoid 17:9397ea3ea7e9 2472 int condition_channel;
whismanoid 17:9397ea3ea7e9 2473 double condition_threshold;
whismanoid 17:9397ea3ea7e9 2474 } action_table_row_t;
whismanoid 17:9397ea3ea7e9 2475 #if MAX40108_DEMO
whismanoid 39:4d285e961435 2476 # ifdef BOARD_SERIAL_NUMBER
whismanoid 39:4d285e961435 2477 // data unique to certain boards based on serial number
whismanoid 39:4d285e961435 2478 // channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 39:4d285e961435 2479 # if (BOARD_SERIAL_NUMBER) == 1
whismanoid 39:4d285e961435 2480 #warning "(BOARD_SERIAL_NUMBER) == 1 -- logic uses A3(CE) instead of A2(WE)"
whismanoid 39:4d285e961435 2481 const int channel_WE = 3; // use channel_CE instead on proto board s/n 1 for diagnostics; easier to sweep values
whismanoid 39:4d285e961435 2482 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 39:4d285e961435 2483 #warning "(BOARD_SERIAL_NUMBER) == 5 -- logic uses A3(CE) instead of A2(WE)"
whismanoid 39:4d285e961435 2484 const int channel_WE = 3; // use channel_CE instead on proto board s/n 1 for diagnostics; easier to sweep values
whismanoid 39:4d285e961435 2485 # else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 17:9397ea3ea7e9 2486 const int channel_WE = 2;
whismanoid 39:4d285e961435 2487 # endif
whismanoid 39:4d285e961435 2488 # endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 17:9397ea3ea7e9 2489 const double threshold_WE_0V5 = 0.5;
whismanoid 17:9397ea3ea7e9 2490 const double threshold_WE_0V6 = 0.6;
whismanoid 17:9397ea3ea7e9 2491 const double threshold_WE_0V7 = 0.7;
whismanoid 18:1235c17b451e 2492 const int pin_LED_1 = 91; // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 2493 const int pin_LED_2 = 92; // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 2494 const int pin_LED_3 = 93; // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 17:9397ea3ea7e9 2495 #endif
whismanoid 17:9397ea3ea7e9 2496 const int ACTION_TABLE_ROW_MAX = 20;
whismanoid 17:9397ea3ea7e9 2497 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2498 bool Datalogger_action_table_enabled = true;
whismanoid 45:74bf1fe021e5 2499 int Datalogger_action_table_row_count = 10; // assert (Datalogger_action_table_row_count <= ACTION_TABLE_ROW_MAX)
whismanoid 17:9397ea3ea7e9 2500 #else // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2501 int Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 2502 #endif // MAX40108_DEMO
whismanoid 45:74bf1fe021e5 2503 // configurable "business logic" for the data log
whismanoid 17:9397ea3ea7e9 2504 action_table_row_t Datalogger_action_table[ACTION_TABLE_ROW_MAX] = {
whismanoid 17:9397ea3ea7e9 2505 #if MAX40108_DEMO
whismanoid 45:74bf1fe021e5 2506 //
whismanoid 45:74bf1fe021e5 2507 // LED1 indicator on if (WE > 0.85V)
whismanoid 45:74bf1fe021e5 2508 // L@0 act=1 pin=91 if=1 ch=3 x=0.8500 -- digitalOutLow D91 if A3 > 0.85
whismanoid 45:74bf1fe021e5 2509 {action_digitalOutLow, pin_LED_1, condition_if_An_gt_threshold, channel_WE, 0.85},
whismanoid 45:74bf1fe021e5 2510 //
whismanoid 45:74bf1fe021e5 2511 // LED1 indicator off if (WE < 0.80V)
whismanoid 45:74bf1fe021e5 2512 // L@1 act=2 pin=91 if=2 ch=3 x=0.8000 -- digitalOutHigh D91 if A3 < 0.80
whismanoid 45:74bf1fe021e5 2513 {action_digitalOutHigh, pin_LED_1, condition_if_An_lt_threshold, channel_WE, 0.80},
whismanoid 45:74bf1fe021e5 2514 //
whismanoid 45:74bf1fe021e5 2515 // LED2 indicator on if (WE > 0.75V)
whismanoid 45:74bf1fe021e5 2516 // L@2 act=1 pin=92 if=1 ch=3 x=0.7500 -- digitalOutLow D92 if A3 > 0.75
whismanoid 45:74bf1fe021e5 2517 {action_digitalOutLow, pin_LED_2, condition_if_An_gt_threshold, channel_WE, 0.75},
whismanoid 17:9397ea3ea7e9 2518 //
whismanoid 45:74bf1fe021e5 2519 // LED2 indicator off if (WE < 0.70V)
whismanoid 45:74bf1fe021e5 2520 // L@3 act=2 pin=92 if=2 ch=3 x=0.7000 -- digitalOutHigh D92 if A3 < 0.70
whismanoid 45:74bf1fe021e5 2521 {action_digitalOutHigh, pin_LED_2, condition_if_An_lt_threshold, channel_WE, 0.70},
whismanoid 17:9397ea3ea7e9 2522 //
whismanoid 45:74bf1fe021e5 2523 // LED3 indicator on if (WE > 0.65V)
whismanoid 45:74bf1fe021e5 2524 // L@4 act=1 pin=93 if=1 ch=3 x=0.6500 -- digitalOutLow D93 if A3 > 0.65
whismanoid 45:74bf1fe021e5 2525 {action_digitalOutLow, pin_LED_3, condition_if_An_gt_threshold, channel_WE, 0.65},
whismanoid 45:74bf1fe021e5 2526 //
whismanoid 45:74bf1fe021e5 2527 // LED3 indicator off if (WE < 0.60V)
whismanoid 45:74bf1fe021e5 2528 // L@5 act=2 pin=93 if=2 ch=3 x=0.6000 -- digitalOutHigh D93 if A3 < 0.60
whismanoid 45:74bf1fe021e5 2529 {action_digitalOutHigh, pin_LED_3, condition_if_An_lt_threshold, channel_WE, 0.60},
whismanoid 45:74bf1fe021e5 2530 //
whismanoid 45:74bf1fe021e5 2531 // Free run if (WE > 0.70V)
whismanoid 45:74bf1fe021e5 2532 // L@6 act=5 if=1 ch=3 x=0.7000 -- LR if A3 > 0.70
whismanoid 17:9397ea3ea7e9 2533 {action_trigger_FreeRun, 0, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 17:9397ea3ea7e9 2534 //
whismanoid 45:74bf1fe021e5 2535 // Deep Sleep if (WE < 0.60V)
whismanoid 45:74bf1fe021e5 2536 // 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 2537 {action_trigger_Timer, 0, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 18:1235c17b451e 2538 //
whismanoid 45:74bf1fe021e5 2539 // Free run if (WE > 0.70V)
whismanoid 45:74bf1fe021e5 2540 // L@8 act=3 pin=4 if=1 ch=3 x=0.7000 -- button %B4! if A3 > 0.70
whismanoid 30:07197a430869 2541 {action_button, 4, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 29:6a9edb6e973b 2542 //
whismanoid 45:74bf1fe021e5 2543 // Deep Sleep if (WE < 0.60V)
whismanoid 45:74bf1fe021e5 2544 // L@9 act=3 pin=5 if=2 ch=3 x=0.6000 -- button %B5! if A3 < 0.60
whismanoid 30:07197a430869 2545 {action_button, 5, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 29:6a9edb6e973b 2546 //
whismanoid 17:9397ea3ea7e9 2547 #endif // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2548 //
whismanoid 17:9397ea3ea7e9 2549 {action_noop, 0, condition_always, 0, 0},
whismanoid 17:9397ea3ea7e9 2550 };
whismanoid 17:9397ea3ea7e9 2551 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2552
whismanoid 17:9397ea3ea7e9 2553 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2554 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 2555 uint8_t Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 2556 uint8_t need_reinit = true;
whismanoid 8:dffee7509bfb 2557 void Datalogger_PrintHeader(CmdLine& cmdLine);
whismanoid 5:aaf8b5f5fda1 2558 void Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 2559 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2560 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 2561 void Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 2562 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 8:dffee7509bfb 2563 void Datalogger_PrintRow(CmdLine& cmdLine);
whismanoid 4:d9b05924ad4c 2564
whismanoid 4:d9b05924ad4c 2565 //--------------------------------------------------
whismanoid 46:469d0061df5d 2566 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 2567 #if HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 2568 // WIP #312 flash_page_configuration_back_up[] records map to variables
whismanoid 46:469d0061df5d 2569 typedef struct {
whismanoid 46:469d0061df5d 2570 uint32_t recordType; // unique record type for each variable, 0 end of list, -1 blank record
whismanoid 46:469d0061df5d 2571 void* addr;
whismanoid 46:469d0061df5d 2572 uint32_t length_bytes;
whismanoid 46:469d0061df5d 2573 const char* name;
whismanoid 46:469d0061df5d 2574 } configuration_back_up_t;
whismanoid 46:469d0061df5d 2575 configuration_back_up_t configuration_back_up_list[] = {
whismanoid 46:469d0061df5d 2576 { 0xFFFFFFFF, NULL, 0, "blank" }, // Ignore 0xFFFFFFFF blank records
whismanoid 47:f1a56afb4aca 2577 //
whismanoid 47:f1a56afb4aca 2578 #ifdef BOARD_SERIAL_NUMBER
whismanoid 47:f1a56afb4aca 2579 // WIP #312 flash load/save g_board_serial_number BOARD_SERIAL_NUMBER
whismanoid 47:f1a56afb4aca 2580 { 0x04000053, &g_board_serial_number, sizeof(g_board_serial_number ), "g_board_serial_number" },
whismanoid 47:f1a56afb4aca 2581 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 47:f1a56afb4aca 2582 // WIP #312 flash load/save board ID string message
whismanoid 47:f1a56afb4aca 2583 //
whismanoid 46:469d0061df5d 2584 { 0x08001053, &calibration_05_V[0], sizeof(calibration_05_V[0] ), "calibration_05_V[0]" },
whismanoid 46:469d0061df5d 2585 { 0x08001153, &calibration_05_V[1], sizeof(calibration_05_V[1] ), "calibration_05_V[1]" },
whismanoid 46:469d0061df5d 2586 { 0x08001253, &calibration_05_V[2], sizeof(calibration_05_V[2] ), "calibration_05_V[2]" },
whismanoid 46:469d0061df5d 2587 { 0x08001353, &calibration_05_V[3], sizeof(calibration_05_V[3] ), "calibration_05_V[3]" },
whismanoid 46:469d0061df5d 2588 { 0x08001453, &calibration_05_V[4], sizeof(calibration_05_V[4] ), "calibration_05_V[4]" },
whismanoid 46:469d0061df5d 2589 { 0x08001553, &calibration_05_V[5], sizeof(calibration_05_V[5] ), "calibration_05_V[5]" },
whismanoid 46:469d0061df5d 2590 { 0x08002053, &calibration_05_normValue_0_1[0], sizeof(calibration_05_normValue_0_1[0] ), "calibration_05_normValue_0_1[0]" },
whismanoid 46:469d0061df5d 2591 { 0x08002153, &calibration_05_normValue_0_1[1], sizeof(calibration_05_normValue_0_1[1] ), "calibration_05_normValue_0_1[1]" },
whismanoid 46:469d0061df5d 2592 { 0x08002253, &calibration_05_normValue_0_1[2], sizeof(calibration_05_normValue_0_1[2] ), "calibration_05_normValue_0_1[2]" },
whismanoid 46:469d0061df5d 2593 { 0x08002353, &calibration_05_normValue_0_1[3], sizeof(calibration_05_normValue_0_1[3] ), "calibration_05_normValue_0_1[3]" },
whismanoid 46:469d0061df5d 2594 { 0x08002453, &calibration_05_normValue_0_1[4], sizeof(calibration_05_normValue_0_1[4] ), "calibration_05_normValue_0_1[4]" },
whismanoid 46:469d0061df5d 2595 { 0x08002553, &calibration_05_normValue_0_1[5], sizeof(calibration_05_normValue_0_1[5] ), "calibration_05_normValue_0_1[5]" },
whismanoid 46:469d0061df5d 2596 { 0x08003053, &calibration_95_V[0], sizeof(calibration_95_V[0] ), "calibration_95_V[0]" },
whismanoid 46:469d0061df5d 2597 { 0x08003153, &calibration_95_V[1], sizeof(calibration_95_V[1] ), "calibration_95_V[1]" },
whismanoid 46:469d0061df5d 2598 { 0x08003253, &calibration_95_V[2], sizeof(calibration_95_V[2] ), "calibration_95_V[2]" },
whismanoid 46:469d0061df5d 2599 { 0x08003353, &calibration_95_V[3], sizeof(calibration_95_V[3] ), "calibration_95_V[3]" },
whismanoid 46:469d0061df5d 2600 { 0x08003453, &calibration_95_V[4], sizeof(calibration_95_V[4] ), "calibration_95_V[4]" },
whismanoid 46:469d0061df5d 2601 { 0x08003553, &calibration_95_V[5], sizeof(calibration_95_V[5] ), "calibration_95_V[5]" },
whismanoid 46:469d0061df5d 2602 { 0x08004053, &calibration_95_normValue_0_1[0], sizeof(calibration_95_normValue_0_1[0] ), "calibration_95_normValue_0_1[0]" },
whismanoid 46:469d0061df5d 2603 { 0x08004153, &calibration_95_normValue_0_1[1], sizeof(calibration_95_normValue_0_1[1] ), "calibration_95_normValue_0_1[1]" },
whismanoid 46:469d0061df5d 2604 { 0x08004253, &calibration_95_normValue_0_1[2], sizeof(calibration_95_normValue_0_1[2] ), "calibration_95_normValue_0_1[2]" },
whismanoid 46:469d0061df5d 2605 { 0x08004353, &calibration_95_normValue_0_1[3], sizeof(calibration_95_normValue_0_1[3] ), "calibration_95_normValue_0_1[3]" },
whismanoid 46:469d0061df5d 2606 { 0x08004453, &calibration_95_normValue_0_1[4], sizeof(calibration_95_normValue_0_1[4] ), "calibration_95_normValue_0_1[4]" },
whismanoid 46:469d0061df5d 2607 { 0x08004553, &calibration_95_normValue_0_1[5], sizeof(calibration_95_normValue_0_1[5] ), "calibration_95_normValue_0_1[5]" },
whismanoid 47:f1a56afb4aca 2608 //
whismanoid 46:469d0061df5d 2609 // WIP #312 @L Datalogger_action_table_row_count
whismanoid 46:469d0061df5d 2610 // WIP #312 @L Datalogger_action_table_enabled
whismanoid 46:469d0061df5d 2611 // WIP #312 @L Datalogger_action_table[0] __ bytes
whismanoid 46:469d0061df5d 2612 // WIP #312 @L Datalogger_action_table[0] __ bytes
whismanoid 47:f1a56afb4aca 2613 //
whismanoid 46:469d0061df5d 2614 // WIP #312 %B onButton1_command_table[0] __ bytes
whismanoid 46:469d0061df5d 2615 // WIP #312 %B onButton9_command_table[0] __ bytes
whismanoid 47:f1a56afb4aca 2616 //
whismanoid 46:469d0061df5d 2617 { 0x00000000, NULL, 0, "wiped" }, // Ignore 0x00000000 wiped records; end of table
whismanoid 46:469d0061df5d 2618 };
whismanoid 48:18647e0516f2 2619 const uint32_t save_arg_01_pageErase = 0x00000001; // page erase and rewrite
whismanoid 48:18647e0516f2 2620 const uint32_t load_arg_01_brief = 0x00000001; // brief list loaded values
whismanoid 48:18647e0516f2 2621 const uint32_t save_arg_02_verbose = 0x00000002; // verbose diagnostic messages
whismanoid 48:18647e0516f2 2622 const uint32_t save_arg_04_reserved = 0x00000004; // reserved
whismanoid 48:18647e0516f2 2623 const uint32_t save_arg_08_reserved = 0x00000008; // reserved
whismanoid 48:18647e0516f2 2624 const uint32_t save_arg_10_calibration = 0x00000010; // save board ID and calibration
whismanoid 48:18647e0516f2 2625 const uint32_t save_arg_20_action_table = 0x00000020; // save Datalogger_action_table
whismanoid 48:18647e0516f2 2626 const uint32_t save_arg_40_command_table = 0x00000040; // save onButtonX_command_table
whismanoid 48:18647e0516f2 2627 const uint32_t save_arg_80_reserved = 0x00000080; // reserved
whismanoid 48:18647e0516f2 2628 const uint32_t save_arg_default = 0
whismanoid 48:18647e0516f2 2629 | save_arg_01_pageErase
whismanoid 48:18647e0516f2 2630 // | save_arg_02_verbose
whismanoid 48:18647e0516f2 2631 // | save_arg_04_reserved
whismanoid 48:18647e0516f2 2632 // | save_arg_08_reserved
whismanoid 48:18647e0516f2 2633 | save_arg_10_calibration
whismanoid 48:18647e0516f2 2634 | save_arg_20_action_table
whismanoid 48:18647e0516f2 2635 | save_arg_40_command_table
whismanoid 48:18647e0516f2 2636 // | save_arg_80_reserved
whismanoid 48:18647e0516f2 2637 ;
whismanoid 48:18647e0516f2 2638 const uint32_t load_arg_default = 0
whismanoid 48:18647e0516f2 2639 | load_arg_01_brief
whismanoid 48:18647e0516f2 2640 | save_arg_02_verbose
whismanoid 48:18647e0516f2 2641 // | save_arg_04_reserved
whismanoid 48:18647e0516f2 2642 // | save_arg_08_reserved
whismanoid 48:18647e0516f2 2643 | save_arg_10_calibration
whismanoid 48:18647e0516f2 2644 | save_arg_20_action_table
whismanoid 48:18647e0516f2 2645 | save_arg_40_command_table
whismanoid 48:18647e0516f2 2646 // | save_arg_80_reserved
whismanoid 48:18647e0516f2 2647 ;
whismanoid 48:18647e0516f2 2648 const uint32_t load_arg_startup = 0
whismanoid 48:18647e0516f2 2649 | load_arg_01_brief
whismanoid 48:18647e0516f2 2650 // | save_arg_02_verbose
whismanoid 48:18647e0516f2 2651 // | save_arg_04_reserved
whismanoid 48:18647e0516f2 2652 // | save_arg_08_reserved
whismanoid 48:18647e0516f2 2653 | save_arg_10_calibration
whismanoid 48:18647e0516f2 2654 | save_arg_20_action_table
whismanoid 48:18647e0516f2 2655 | save_arg_40_command_table
whismanoid 48:18647e0516f2 2656 // | save_arg_80_reserved
whismanoid 48:18647e0516f2 2657 ;
whismanoid 46:469d0061df5d 2658 // WIP #312 store values into flash_page_configuration_back_up[] from calibration_05_V[] etc. Default save everything.
whismanoid 48:18647e0516f2 2659 // @param[in] save_arg %F save=0x00000001 = page erase and rewrite, else append in next available blank space within page
whismanoid 48:18647e0516f2 2660 // @param[in] save_arg %F save=0x00000002 = verbose diagnostic messages
whismanoid 48:18647e0516f2 2661 // @param[in] save_arg %F save=0x00000004 = reserved
whismanoid 48:18647e0516f2 2662 // @param[in] save_arg %F save=0x00000008 = reserved
whismanoid 48:18647e0516f2 2663 // @param[in] save_arg %F save=0x00000010 = save board ID and calibration
whismanoid 48:18647e0516f2 2664 // @param[in] save_arg %F save=0x00000020 = save Datalogger_action_table
whismanoid 48:18647e0516f2 2665 // @param[in] save_arg %F save=0x00000040 = save onButtonX_command_table
whismanoid 48:18647e0516f2 2666 // @param[in] save_arg %F save=0x00000080 = reserved
whismanoid 46:469d0061df5d 2667 int Save_flash_page_configuration_back_up(CmdLine& cmdLine, uint32_t save_arg)
whismanoid 46:469d0061df5d 2668 {
whismanoid 48:18647e0516f2 2669 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2670 {
whismanoid 48:18647e0516f2 2671 cmdLine.serial().printf("\r\nSave_flash_page_configuration_back_up(0x%8.8lx)...", save_arg);
whismanoid 48:18647e0516f2 2672 }
whismanoid 48:18647e0516f2 2673 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2674 {
whismanoid 48:18647e0516f2 2675 // @param[in] save_arg %F save=0x00000002 = verbose diagnostic messages
whismanoid 48:18647e0516f2 2676 if ((save_arg & save_arg_01_pageErase) != 0) { cmdLine.serial().printf("\r\n 0x%x: save_arg_01_pageErase", save_arg_01_pageErase); }
whismanoid 48:18647e0516f2 2677 if ((save_arg & save_arg_02_verbose) != 0) { cmdLine.serial().printf("\r\n 0x%x: save_arg_02_verbose", save_arg_02_verbose); }
whismanoid 48:18647e0516f2 2678 if ((save_arg & save_arg_04_reserved) != 0) { cmdLine.serial().printf("\r\n 0x%x: save_arg_04_reserved", save_arg_04_reserved); }
whismanoid 48:18647e0516f2 2679 if ((save_arg & save_arg_08_reserved) != 0) { cmdLine.serial().printf("\r\n 0x%x: save_arg_08_reserved", save_arg_08_reserved); }
whismanoid 48:18647e0516f2 2680 if ((save_arg & save_arg_10_calibration) != 0) { cmdLine.serial().printf("\r\n 0x%x: save_arg_10_calibration", save_arg_10_calibration); }
whismanoid 48:18647e0516f2 2681 if ((save_arg & save_arg_20_action_table) != 0) { cmdLine.serial().printf("\r\n 0x%x: save_arg_20_action_table", save_arg_20_action_table); }
whismanoid 48:18647e0516f2 2682 if ((save_arg & save_arg_40_command_table) != 0) { cmdLine.serial().printf("\r\n 0x%x: save_arg_40_command_table", save_arg_40_command_table); }
whismanoid 48:18647e0516f2 2683 if ((save_arg & save_arg_80_reserved) != 0) { cmdLine.serial().printf("\r\n 0x%x: save_arg_80_reserved", save_arg_80_reserved); }
whismanoid 48:18647e0516f2 2684 }
whismanoid 46:469d0061df5d 2685 // WIP #312 %F save=save_arg could filter which items to append to flash file
whismanoid 46:469d0061df5d 2686 // initialize flash memory interface
whismanoid 46:469d0061df5d 2687 // FlashIAP: FlashIAP flash; flash.init();
whismanoid 46:469d0061df5d 2688 // int FLC_Init(void);
whismanoid 46:469d0061df5d 2689 // returns E_NO_ERROR or E_BUSY or E_UNKNOWN
whismanoid 48:18647e0516f2 2690 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2691 {
whismanoid 48:18647e0516f2 2692 cmdLine.serial().printf("FLC_Init ");
whismanoid 48:18647e0516f2 2693 }
whismanoid 46:469d0061df5d 2694 if (FLC_Init() != E_NO_ERROR)
whismanoid 46:469d0061df5d 2695 {
whismanoid 48:18647e0516f2 2696 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2697 {
whismanoid 48:18647e0516f2 2698 cmdLine.serial().printf("FAIL ");
whismanoid 48:18647e0516f2 2699 }
whismanoid 46:469d0061df5d 2700 return 1; // can't perform the command
whismanoid 46:469d0061df5d 2701 }
whismanoid 48:18647e0516f2 2702 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2703 {
whismanoid 48:18647e0516f2 2704 cmdLine.serial().printf("PASS ");
whismanoid 48:18647e0516f2 2705 }
whismanoid 46:469d0061df5d 2706 //
whismanoid 46:469d0061df5d 2707
whismanoid 46:469d0061df5d 2708 uint32_t file_addr = (uint32_t)&flash_page_configuration_back_up[0];
whismanoid 46:469d0061df5d 2709 // uint32_t file_addr_end = file_addr + 8192 - 4;
whismanoid 46:469d0061df5d 2710 uint32_t file_addr_end = file_addr + 256 - 4; // development: reduce listing size
whismanoid 46:469d0061df5d 2711
whismanoid 46:469d0061df5d 2712 int poke_access_list_index = search_poke_access_list(file_addr);
whismanoid 48:18647e0516f2 2713 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2714 {
whismanoid 48:18647e0516f2 2715 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 48:18647e0516f2 2716 poke_access_list_index,
whismanoid 48:18647e0516f2 2717 poke_access_list[poke_access_list_index].name,
whismanoid 48:18647e0516f2 2718 poke_access_list[poke_access_list_index].addr_min,
whismanoid 48:18647e0516f2 2719 poke_access_list[poke_access_list_index].addr_max,
whismanoid 48:18647e0516f2 2720 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 48:18647e0516f2 2721 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 48:18647e0516f2 2722 }
whismanoid 46:469d0061df5d 2723
whismanoid 48:18647e0516f2 2724 if ((save_arg & save_arg_01_pageErase) != 0)
whismanoid 46:469d0061df5d 2725 {
whismanoid 48:18647e0516f2 2726 // @param[in] save_arg %F save=0x00000001 = page erase and rewrite, else append in next available blank space within page
whismanoid 46:469d0061df5d 2727 // erase flash file before saving configuration
whismanoid 46:469d0061df5d 2728 //
whismanoid 46:469d0061df5d 2729 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: erase page ...",
whismanoid 46:469d0061df5d 2730 poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 46:469d0061df5d 2731 // page erase using flash.erase(addr, flash.get_sector_size(addr));
whismanoid 46:469d0061df5d 2732 // int FLC_PageErase(uint32_t address, MXC_V_FLC_ERASE_CODE_PAGE_ERASE, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 2733 // @param address Address of the page to be erased.
whismanoid 46:469d0061df5d 2734 // @param erase_code Flash erase code; defined as
whismanoid 46:469d0061df5d 2735 // #MXC_V_FLC_ERASE_CODE_PAGE_ERASE for page erase
whismanoid 46:469d0061df5d 2736 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 2737 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 2738 if (FLC_PageErase(file_addr, MXC_V_FLC_ERASE_CODE_PAGE_ERASE,
whismanoid 46:469d0061df5d 2739 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 2740 {
whismanoid 46:469d0061df5d 2741 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 2742 return 1; // can't perform the command
whismanoid 46:469d0061df5d 2743 }
whismanoid 46:469d0061df5d 2744 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 2745 }
whismanoid 48:18647e0516f2 2746 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2747 {
whismanoid 48:18647e0516f2 2748 // @param[in] save_arg %F save=0x00000002 = verbose diagnostic messages
whismanoid 48:18647e0516f2 2749 }
whismanoid 48:18647e0516f2 2750 if ((save_arg & save_arg_04_reserved) != 0)
whismanoid 48:18647e0516f2 2751 {
whismanoid 48:18647e0516f2 2752 // @param[in] save_arg %F save=0x00000004 = reserved
whismanoid 48:18647e0516f2 2753 }
whismanoid 48:18647e0516f2 2754 if ((save_arg & save_arg_08_reserved) != 0)
whismanoid 48:18647e0516f2 2755 {
whismanoid 48:18647e0516f2 2756 // @param[in] save_arg %F save=0x00000008 = reserved
whismanoid 48:18647e0516f2 2757 }
whismanoid 48:18647e0516f2 2758 if ((save_arg & save_arg_10_calibration) != 0)
whismanoid 48:18647e0516f2 2759 {
whismanoid 48:18647e0516f2 2760 // @param[in] save_arg %F save=0x00000010 = save board ID and calibration
whismanoid 48:18647e0516f2 2761 }
whismanoid 48:18647e0516f2 2762 if ((save_arg & save_arg_20_action_table) != 0)
whismanoid 48:18647e0516f2 2763 {
whismanoid 48:18647e0516f2 2764 // @param[in] save_arg %F save=0x00000020 = save Datalogger_action_table
whismanoid 48:18647e0516f2 2765 }
whismanoid 48:18647e0516f2 2766 if ((save_arg & save_arg_40_command_table) != 0)
whismanoid 48:18647e0516f2 2767 {
whismanoid 48:18647e0516f2 2768 // @param[in] save_arg %F save=0x00000040 = save onButtonX_command_table
whismanoid 48:18647e0516f2 2769 }
whismanoid 48:18647e0516f2 2770 if ((save_arg & save_arg_80_reserved) != 0)
whismanoid 48:18647e0516f2 2771 {
whismanoid 48:18647e0516f2 2772 // @param[in] save_arg %F save=0x00000080 = reserved
whismanoid 48:18647e0516f2 2773 }
whismanoid 48:18647e0516f2 2774
whismanoid 48:18647e0516f2 2775 // address of next 16-byte-aligned record start address
whismanoid 48:18647e0516f2 2776 uint32_t file_addr_next = (file_addr + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 2777
whismanoid 46:469d0061df5d 2778 // scan configuration_back_up_list[] for recordType
whismanoid 46:469d0061df5d 2779 for (int i = 0; configuration_back_up_list[i].recordType != 0x00000000; i++)
whismanoid 46:469d0061df5d 2780 {
whismanoid 48:18647e0516f2 2781 file_addr_next = (file_addr + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 2782 if (configuration_back_up_list[i].recordType == 0xFFFFFFFF) continue;
whismanoid 46:469d0061df5d 2783 //
whismanoid 46:469d0061df5d 2784 // configuration_back_up_list[i].recordType
whismanoid 46:469d0061df5d 2785 // configuration_back_up_list[i].addr
whismanoid 46:469d0061df5d 2786 // configuration_back_up_list[i].length_bytes
whismanoid 46:469d0061df5d 2787 // configuration_back_up_list[i].name
whismanoid 46:469d0061df5d 2788 // WIP #312 %F save=save_arg could filter which items to append to flash file
whismanoid 46:469d0061df5d 2789 //
whismanoid 48:18647e0516f2 2790 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2791 {
whismanoid 48:18647e0516f2 2792 cmdLine.serial().printf("\r\n save 0x%8.8lx %s address 0x%8.8lx length 0x%lx bytes",
whismanoid 48:18647e0516f2 2793 configuration_back_up_list[i].recordType,
whismanoid 48:18647e0516f2 2794 configuration_back_up_list[i].name,
whismanoid 48:18647e0516f2 2795 (uint32_t)configuration_back_up_list[i].addr,
whismanoid 48:18647e0516f2 2796 configuration_back_up_list[i].length_bytes);
whismanoid 48:18647e0516f2 2797 }
whismanoid 46:469d0061df5d 2798 //
whismanoid 46:469d0061df5d 2799 // find next free space to store record in flash file
whismanoid 46:469d0061df5d 2800 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 46:469d0061df5d 2801 cmdLine.serial().printf("0x%8.8lx ", *((uint32_t*)file_addr));
whismanoid 46:469d0061df5d 2802 while (*((uint32_t*)file_addr) != 0xFFFFFFFF)
whismanoid 46:469d0061df5d 2803 {
whismanoid 46:469d0061df5d 2804 if (file_addr >= file_addr_end)
whismanoid 46:469d0061df5d 2805 {
whismanoid 46:469d0061df5d 2806 return 1; // fail: no room to write file
whismanoid 46:469d0061df5d 2807 }
whismanoid 48:18647e0516f2 2808 file_addr_next = (file_addr + 16) &~ 0x0000000F;
whismanoid 48:18647e0516f2 2809 file_addr = file_addr_next;
whismanoid 46:469d0061df5d 2810 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx ",
whismanoid 46:469d0061df5d 2811 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 2812 file_addr,
whismanoid 46:469d0061df5d 2813 *((uint32_t*)file_addr)
whismanoid 46:469d0061df5d 2814 );
whismanoid 46:469d0061df5d 2815 }
whismanoid 48:18647e0516f2 2816 file_addr_next = (file_addr + configuration_back_up_list[i].length_bytes + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 2817 //
whismanoid 46:469d0061df5d 2818 // copy data from RAM into flash file
whismanoid 46:469d0061df5d 2819 // not_memcpy(file_addr + 4, configuration_back_up_list[i].addr, configuration_back_up_list[i].length_bytes);
whismanoid 46:469d0061df5d 2820 // pageBuf[0..3] = configuration_back_up_list[i].recordType;
whismanoid 46:469d0061df5d 2821 // pageBuf[4...] = configuration_back_up_list[i].addr, configuration_back_up_list[i].length_bytes
whismanoid 46:469d0061df5d 2822 // WIP #312: FLC_Write(...) in Save_flash_page_configuration_back_up
whismanoid 48:18647e0516f2 2823 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2824 {
whismanoid 48:18647e0516f2 2825 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: write page buffer ...",
whismanoid 48:18647e0516f2 2826 poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 48:18647e0516f2 2827 }
whismanoid 46:469d0061df5d 2828 // page write using flash.program(page_buffer, addr, page_size);
whismanoid 46:469d0061df5d 2829 // int FLC_Write(uint32_t address, const void *data, uint32_t length, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 2830 // @param address Start address for desired write. @note This address
whismanoid 46:469d0061df5d 2831 // must be 32-bit word aligned
whismanoid 46:469d0061df5d 2832 // @param data A pointer to the buffer containing the data to write.
whismanoid 46:469d0061df5d 2833 // @param length Size of the data to write in bytes. @note The length
whismanoid 46:469d0061df5d 2834 // must be in 32-bit multiples.
whismanoid 46:469d0061df5d 2835 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 2836 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 2837 if (FLC_Write(file_addr,
whismanoid 46:469d0061df5d 2838 (uint32_t*)(&configuration_back_up_list[i].recordType),
whismanoid 46:469d0061df5d 2839 sizeof(uint32_t),
whismanoid 46:469d0061df5d 2840 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 2841 {
whismanoid 48:18647e0516f2 2842 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2843 {
whismanoid 48:18647e0516f2 2844 cmdLine.serial().printf("FAIL ");
whismanoid 48:18647e0516f2 2845 }
whismanoid 46:469d0061df5d 2846 break; // can't perform the command
whismanoid 46:469d0061df5d 2847 }
whismanoid 48:18647e0516f2 2848 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2849 {
whismanoid 48:18647e0516f2 2850 cmdLine.serial().printf("PASS ");
whismanoid 48:18647e0516f2 2851 }
whismanoid 46:469d0061df5d 2852 if (FLC_Write(file_addr + 4,
whismanoid 46:469d0061df5d 2853 (uint32_t*)(configuration_back_up_list[i].addr),
whismanoid 46:469d0061df5d 2854 configuration_back_up_list[i].length_bytes,
whismanoid 46:469d0061df5d 2855 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 2856 {
whismanoid 48:18647e0516f2 2857 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2858 {
whismanoid 48:18647e0516f2 2859 cmdLine.serial().printf("FAIL ");
whismanoid 48:18647e0516f2 2860 }
whismanoid 46:469d0061df5d 2861 break; // can't perform the command
whismanoid 46:469d0061df5d 2862 }
whismanoid 48:18647e0516f2 2863 if ((save_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2864 {
whismanoid 48:18647e0516f2 2865 cmdLine.serial().printf("PASS ");
whismanoid 48:18647e0516f2 2866 }
whismanoid 46:469d0061df5d 2867 // advance to next 16-byte-aligned record start address
whismanoid 48:18647e0516f2 2868 file_addr = file_addr_next;
whismanoid 46:469d0061df5d 2869 } // end for each configuration_back_up_list[...]
whismanoid 46:469d0061df5d 2870 return 0;
whismanoid 46:469d0061df5d 2871 } // end Save_flash_page_configuration_back_up
whismanoid 46:469d0061df5d 2872 // WIP #312 load values from flash_page_configuration_back_up[] into calibration_05_V[] etc. Default load everything.
whismanoid 46:469d0061df5d 2873 int Load_flash_page_configuration_back_up(CmdLine& cmdLine, uint32_t load_arg)
whismanoid 46:469d0061df5d 2874 {
whismanoid 48:18647e0516f2 2875 if ((load_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2876 {
whismanoid 48:18647e0516f2 2877 cmdLine.serial().printf("\r\nLoad_flash_page_configuration_back_up(0x%8.8lx)...", load_arg);
whismanoid 48:18647e0516f2 2878 }
whismanoid 48:18647e0516f2 2879 if ((load_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2880 {
whismanoid 48:18647e0516f2 2881 // @param[in] save_arg %F save=0x00000002 = verbose diagnostic messages
whismanoid 48:18647e0516f2 2882 if ((load_arg & load_arg_01_brief) != 0) { cmdLine.serial().printf("\r\n 0x%x: load_arg_01_brief", load_arg_01_brief); }
whismanoid 48:18647e0516f2 2883 if ((load_arg & save_arg_02_verbose) != 0) { cmdLine.serial().printf("\r\n 0x%x: save_arg_02_verbose", save_arg_02_verbose); }
whismanoid 48:18647e0516f2 2884 if ((load_arg & save_arg_04_reserved) != 0) { cmdLine.serial().printf("\r\n 0x%x: save_arg_04_reserved", save_arg_04_reserved); }
whismanoid 48:18647e0516f2 2885 if ((load_arg & save_arg_08_reserved) != 0) { cmdLine.serial().printf("\r\n 0x%x: save_arg_08_reserved", save_arg_08_reserved); }
whismanoid 48:18647e0516f2 2886 if ((load_arg & save_arg_10_calibration) != 0) { cmdLine.serial().printf("\r\n 0x%x: save_arg_10_calibration", save_arg_10_calibration); }
whismanoid 48:18647e0516f2 2887 if ((load_arg & save_arg_20_action_table) != 0) { cmdLine.serial().printf("\r\n 0x%x: save_arg_20_action_table", save_arg_20_action_table); }
whismanoid 48:18647e0516f2 2888 if ((load_arg & save_arg_40_command_table) != 0) { cmdLine.serial().printf("\r\n 0x%x: save_arg_40_command_table", save_arg_40_command_table); }
whismanoid 48:18647e0516f2 2889 if ((load_arg & save_arg_80_reserved) != 0) { cmdLine.serial().printf("\r\n 0x%x: save_arg_80_reserved", save_arg_80_reserved); }
whismanoid 48:18647e0516f2 2890 }
whismanoid 46:469d0061df5d 2891 // WIP #312 %F load=load_arg could filter which items to accept from flash file
whismanoid 46:469d0061df5d 2892
whismanoid 46:469d0061df5d 2893 uint32_t file_addr = (uint32_t)&flash_page_configuration_back_up[0];
whismanoid 46:469d0061df5d 2894 // uint32_t file_addr_end = file_addr + 8192 - 4; // last record at 0x00027ff0
whismanoid 46:469d0061df5d 2895 // uint32_t file_addr_end = file_addr + 256 - 4; // development: reduce listing size -- last record at 0x000260f0
whismanoid 46:469d0061df5d 2896 uint32_t file_addr_end = file_addr + 512 - 4; // development: reduce listing size -- last record at 0x000261f0
whismanoid 46:469d0061df5d 2897
whismanoid 46:469d0061df5d 2898 // diagnostic print
whismanoid 46:469d0061df5d 2899 int poke_access_list_index = search_poke_access_list(file_addr);
whismanoid 48:18647e0516f2 2900 if ((load_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2901 {
whismanoid 48:18647e0516f2 2902 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 48:18647e0516f2 2903 poke_access_list_index,
whismanoid 48:18647e0516f2 2904 poke_access_list[poke_access_list_index].name,
whismanoid 48:18647e0516f2 2905 poke_access_list[poke_access_list_index].addr_min,
whismanoid 48:18647e0516f2 2906 poke_access_list[poke_access_list_index].addr_max,
whismanoid 48:18647e0516f2 2907 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 48:18647e0516f2 2908 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 48:18647e0516f2 2909 }
whismanoid 46:469d0061df5d 2910
whismanoid 46:469d0061df5d 2911 // Scan backup configuration file
whismanoid 46:469d0061df5d 2912 while (file_addr < file_addr_end)
whismanoid 46:469d0061df5d 2913 {
whismanoid 48:18647e0516f2 2914 if ((load_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2915 {
whismanoid 48:18647e0516f2 2916 // diagnostic print
whismanoid 48:18647e0516f2 2917 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx ",
whismanoid 48:18647e0516f2 2918 poke_access_list[poke_access_list_index].name,
whismanoid 48:18647e0516f2 2919 file_addr,
whismanoid 48:18647e0516f2 2920 *((uint32_t*)file_addr));
whismanoid 48:18647e0516f2 2921 }
whismanoid 46:469d0061df5d 2922
whismanoid 46:469d0061df5d 2923 // address of next 16-byte-aligned record start address
whismanoid 46:469d0061df5d 2924 uint32_t file_addr_next = (file_addr + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 2925
whismanoid 46:469d0061df5d 2926 // scan configuration_back_up_list[] to decode recordType
whismanoid 46:469d0061df5d 2927 for (int i = 0; configuration_back_up_list[i].recordType != 0x00000000; i++)
whismanoid 46:469d0061df5d 2928 {
whismanoid 46:469d0061df5d 2929 // configuration_back_up_list[i].recordType
whismanoid 46:469d0061df5d 2930 // configuration_back_up_list[i].addr
whismanoid 46:469d0061df5d 2931 // configuration_back_up_list[i].length_bytes
whismanoid 46:469d0061df5d 2932 // configuration_back_up_list[i].name
whismanoid 46:469d0061df5d 2933 //
whismanoid 46:469d0061df5d 2934 uint32_t file_addr_recordType = file_addr;
whismanoid 46:469d0061df5d 2935 uint32_t file_addr_recordData = file_addr + 1;
whismanoid 46:469d0061df5d 2936 // uint32_t file_addr_recordNext = (file_addr + configuration_back_up_list[i].length_bytes) & ______;
whismanoid 46:469d0061df5d 2937 if (configuration_back_up_list[i].recordType == *((uint32_t*)file_addr_recordType))
whismanoid 46:469d0061df5d 2938 {
whismanoid 46:469d0061df5d 2939 if ((configuration_back_up_list[i].addr == 0) ||
whismanoid 46:469d0061df5d 2940 (configuration_back_up_list[i].length_bytes==0))
whismanoid 46:469d0061df5d 2941 {
whismanoid 46:469d0061df5d 2942 break; // Ignore blank record, stop searching
whismanoid 46:469d0061df5d 2943 }
whismanoid 46:469d0061df5d 2944 // found a matching recordHeader
whismanoid 48:18647e0516f2 2945 if ((load_arg & load_arg_01_brief) != 0)
whismanoid 46:469d0061df5d 2946 {
whismanoid 48:18647e0516f2 2947 // diagnostic print
whismanoid 48:18647e0516f2 2948 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx load %s",
whismanoid 46:469d0061df5d 2949 poke_access_list[poke_access_list_index].name,
whismanoid 48:18647e0516f2 2950 file_addr,
whismanoid 48:18647e0516f2 2951 *((uint32_t*)file_addr),
whismanoid 48:18647e0516f2 2952 configuration_back_up_list[i].name
whismanoid 46:469d0061df5d 2953 );
whismanoid 46:469d0061df5d 2954 }
whismanoid 48:18647e0516f2 2955 if ((load_arg & save_arg_02_verbose) != 0)
whismanoid 48:18647e0516f2 2956 {
whismanoid 48:18647e0516f2 2957
whismanoid 48:18647e0516f2 2958 for (int j = 0; j <= configuration_back_up_list[i].length_bytes; j += 4)
whismanoid 48:18647e0516f2 2959 {
whismanoid 48:18647e0516f2 2960 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx",
whismanoid 48:18647e0516f2 2961 poke_access_list[poke_access_list_index].name,
whismanoid 48:18647e0516f2 2962 (file_addr + 4 + j),
whismanoid 48:18647e0516f2 2963 *((uint32_t*)(file_addr + 4 + j))
whismanoid 48:18647e0516f2 2964 );
whismanoid 48:18647e0516f2 2965 }
whismanoid 48:18647e0516f2 2966 }
whismanoid 46:469d0061df5d 2967 // cmdLine.serial().printf("\r\n load %s 0x%8.8lx length 0x%lx address 0x%8.8lx",
whismanoid 46:469d0061df5d 2968 // configuration_back_up_list[i].name,
whismanoid 46:469d0061df5d 2969 // configuration_back_up_list[i].recordType,
whismanoid 46:469d0061df5d 2970 // configuration_back_up_list[i].length_bytes,
whismanoid 46:469d0061df5d 2971 // (uint32_t)configuration_back_up_list[i].addr,
whismanoid 46:469d0061df5d 2972 // );
whismanoid 46:469d0061df5d 2973 // cmdLine.serial().printf("\r\n load %s 0x%8.8lx length 0x%lx address 0x%8.8lx",
whismanoid 46:469d0061df5d 2974 // configuration_back_up_list[i].name,
whismanoid 46:469d0061df5d 2975 // configuration_back_up_list[i].recordType,
whismanoid 46:469d0061df5d 2976 // configuration_back_up_list[i].length_bytes,
whismanoid 46:469d0061df5d 2977 // (uint32_t)configuration_back_up_list[i].addr,
whismanoid 46:469d0061df5d 2978 // );
whismanoid 46:469d0061df5d 2979 //
whismanoid 46:469d0061df5d 2980 // WIP #312: copy data from flash file into RAM in Load_flash_page_configuration_back_up
whismanoid 46:469d0061df5d 2981 memcpy(configuration_back_up_list[i].addr,
whismanoid 46:469d0061df5d 2982 (const void *)(file_addr + 4),
whismanoid 46:469d0061df5d 2983 configuration_back_up_list[i].length_bytes);
whismanoid 46:469d0061df5d 2984 //
whismanoid 46:469d0061df5d 2985 // advance to next 16-byte-aligned record start address
whismanoid 46:469d0061df5d 2986 file_addr_next = (file_addr + configuration_back_up_list[i].length_bytes + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 2987 break; // stop searching
whismanoid 46:469d0061df5d 2988 } // end if match recordType
whismanoid 46:469d0061df5d 2989 } // end for each configuration_back_up_list[...]
whismanoid 46:469d0061df5d 2990 // advance to next 16-byte-aligned record start address
whismanoid 46:469d0061df5d 2991 file_addr = file_addr_next;
whismanoid 46:469d0061df5d 2992 } // end while (file_addr < file_addr_end)
whismanoid 46:469d0061df5d 2993 return 0;
whismanoid 46:469d0061df5d 2994 } // end Load_flash_page_configuration_back_up
whismanoid 46:469d0061df5d 2995 #endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 2996
whismanoid 46:469d0061df5d 2997 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 2998 // Option to validate SPI link by reading PART_ID register
whismanoid 0:cb44e2e9ec4c 2999 #ifndef VERIFY_PART_ID_IN_LOOP
whismanoid 3:9055e17e181a 3000 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 3001 #define VERIFY_PART_ID_IN_LOOP 1
whismanoid 3:9055e17e181a 3002 #else
whismanoid 0:cb44e2e9ec4c 3003 #define VERIFY_PART_ID_IN_LOOP 0
whismanoid 3:9055e17e181a 3004 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3005 #endif
whismanoid 0:cb44e2e9ec4c 3006
whismanoid 3:9055e17e181a 3007 //--------------------------------------------------
whismanoid 3:9055e17e181a 3008 #define NUM_DUT_ANALOG_IN_CHANNELS 10
whismanoid 3:9055e17e181a 3009
whismanoid 3:9055e17e181a 3010 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 3011 // MAX11410 individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 3:9055e17e181a 3012 typedef enum SPI_AIN_Enable_t {
whismanoid 10:04022a61b527 3013 SPI_AIN_Disable = 0,
whismanoid 10:04022a61b527 3014 SPI_AIN_Enable_LSB = 1,
whismanoid 10:04022a61b527 3015 SPI_AIN_Enable_Volt = 2,
whismanoid 3:9055e17e181a 3016 } SPI_AIN_Enable_t;
whismanoid 3:9055e17e181a 3017 uint8_t SPI_AIN_Enable_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 3018 SPI_AIN_Enable_LSB, // AIN0 1=LSB
whismanoid 10:04022a61b527 3019 SPI_AIN_Enable_LSB, // AIN1 1=LSB
whismanoid 10:04022a61b527 3020 SPI_AIN_Enable_LSB, // AIN2 1=LSB
whismanoid 10:04022a61b527 3021 SPI_AIN_Enable_LSB, // AIN3 1=LSB
whismanoid 10:04022a61b527 3022 SPI_AIN_Enable_LSB, // AIN4 1=LSB
whismanoid 10:04022a61b527 3023 SPI_AIN_Enable_LSB, // AIN5 1=LSB
whismanoid 10:04022a61b527 3024 SPI_AIN_Enable_LSB, // AIN6 1=LSB
whismanoid 10:04022a61b527 3025 SPI_AIN_Enable_LSB, // AIN7 1=LSB
whismanoid 10:04022a61b527 3026 SPI_AIN_Enable_LSB, // AIN8 1=LSB
whismanoid 10:04022a61b527 3027 SPI_AIN_Enable_LSB, // AIN9 1=LSB
whismanoid 3:9055e17e181a 3028 };
whismanoid 3:9055e17e181a 3029 //
whismanoid 10:04022a61b527 3030 double SPI_AIN_Voltage[NUM_DUT_ANALOG_IN_CHANNELS];
whismanoid 13:184a08909405 3031 // Optional custom per-channel header suffix
whismanoid 45:74bf1fe021e5 3032 // This could be used to identify external hardware attached to each input
whismanoid 13:184a08909405 3033 #ifndef HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 3034 #define HAS_SPI_AIN_customChannelHeader 0
whismanoid 13:184a08909405 3035 #endif
whismanoid 13:184a08909405 3036 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 3037 const char* const SPI_AIN_customChannelHeader_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 3038 "", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 3039 "", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 3040 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 3041 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 3042 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 3043 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 3044 };
whismanoid 13:184a08909405 3045 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 3:9055e17e181a 3046 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3047 // ---------- Measure_Voltage_custom_props in Measure_Voltage @pre and in class properties ----------
whismanoid 3:9055e17e181a 3048 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 3049 // MAX11410 specific per-channel config register v_filter
whismanoid 3:9055e17e181a 3050 uint8_t SPI_AIN_Cfg_v_filter_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 3051 0x34, // AIN0 @ v_filter=0x34
whismanoid 3:9055e17e181a 3052 0x34, // AIN1 @ v_filter=0x34
whismanoid 3:9055e17e181a 3053 0x34, // AIN2 @ v_filter=0x34
whismanoid 3:9055e17e181a 3054 0x34, // AIN3 @ v_filter=0x34
whismanoid 3:9055e17e181a 3055 0x34, // AIN4 @ v_filter=0x34
whismanoid 3:9055e17e181a 3056 0x34, // AIN5 @ v_filter=0x34
whismanoid 3:9055e17e181a 3057 0x34, // AIN6 @ v_filter=0x34
whismanoid 3:9055e17e181a 3058 0x34, // AIN7 @ v_filter=0x34
whismanoid 3:9055e17e181a 3059 0x34, // AIN8 @ v_filter=0x34
whismanoid 3:9055e17e181a 3060 0x34, // AIN9 @ v_filter=0x34
whismanoid 3:9055e17e181a 3061 };
whismanoid 3:9055e17e181a 3062 //
whismanoid 4:d9b05924ad4c 3063 // MAX11410 specific per-channel config register v_ctrl
whismanoid 3:9055e17e181a 3064 uint8_t SPI_AIN_Cfg_v_ctrl_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 3065 0x42, // AIN0 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3066 0x42, // AIN1 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3067 0x42, // AIN2 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3068 0x42, // AIN3 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3069 0x42, // AIN4 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3070 0x42, // AIN5 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3071 0x42, // AIN6 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3072 0x42, // AIN7 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3073 0x42, // AIN8 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3074 0x42, // AIN9 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 3075 };
whismanoid 3:9055e17e181a 3076 //
whismanoid 4:d9b05924ad4c 3077 // MAX11410 specific per-channel config register v_pga
whismanoid 3:9055e17e181a 3078 uint8_t SPI_AIN_Cfg_v_pga_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 3079 0x00, // AIN0 @ v_pga=0x00
whismanoid 3:9055e17e181a 3080 0x00, // AIN1 @ v_pga=0x00
whismanoid 3:9055e17e181a 3081 0x00, // AIN2 @ v_pga=0x00
whismanoid 3:9055e17e181a 3082 0x00, // AIN3 @ v_pga=0x00
whismanoid 3:9055e17e181a 3083 0x00, // AIN4 @ v_pga=0x00
whismanoid 3:9055e17e181a 3084 0x00, // AIN5 @ v_pga=0x00
whismanoid 3:9055e17e181a 3085 0x00, // AIN6 @ v_pga=0x00
whismanoid 3:9055e17e181a 3086 0x00, // AIN7 @ v_pga=0x00
whismanoid 3:9055e17e181a 3087 0x00, // AIN8 @ v_pga=0x00
whismanoid 3:9055e17e181a 3088 0x00, // AIN9 @ v_pga=0x00
whismanoid 3:9055e17e181a 3089 };
whismanoid 3:9055e17e181a 3090 //
whismanoid 3:9055e17e181a 3091 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3092 // ---------- Measure_Voltage_custom_props ----------
whismanoid 0:cb44e2e9ec4c 3093 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 3094 // filter register configuration in Measure_Voltage and Read_All_Voltages CONV_TYPE_01_Continuous
whismanoid 0:cb44e2e9ec4c 3095 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 3096 //~ const uint8_t custom_v_filter = 0x00; // @ v_filter=0x00 -- LINEF_00_50Hz_60Hz_FIR RATE_0000 | 1.1SPS
whismanoid 0:cb44e2e9ec4c 3097 //~ const uint8_t custom_v_filter = 0x01; // @ v_filter=0x01 -- LINEF_00_50Hz_60Hz_FIR RATE_0001 | 2.1SPS
whismanoid 0:cb44e2e9ec4c 3098 //~ const uint8_t custom_v_filter = 0x02; // @ v_filter=0x02 -- LINEF_00_50Hz_60Hz_FIR RATE_0010 | 4.2SPS
whismanoid 0:cb44e2e9ec4c 3099 //~ const uint8_t custom_v_filter = 0x03; // @ v_filter=0x03 -- LINEF_00_50Hz_60Hz_FIR RATE_0011 | 8.4SPS
whismanoid 0:cb44e2e9ec4c 3100 //~ const uint8_t custom_v_filter = 0x04; // @ v_filter=0x04 -- LINEF_00_50Hz_60Hz_FIR RATE_0100 | 16.8SPS
whismanoid 0:cb44e2e9ec4c 3101 //~ const uint8_t custom_v_filter = 0x10; // @ v_filter=0x10 -- LINEF_01_50Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 3102 //~ const uint8_t custom_v_filter = 0x11; // @ v_filter=0x11 -- LINEF_01_50Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 3103 //~ const uint8_t custom_v_filter = 0x12; // @ v_filter=0x12 -- LINEF_01_50Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 3104 //~ const uint8_t custom_v_filter = 0x13; // @ v_filter=0x13 -- LINEF_01_50Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 3105 //~ const uint8_t custom_v_filter = 0x14; // @ v_filter=0x14 -- LINEF_01_50Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 3106 //~ const uint8_t custom_v_filter = 0x15; // @ v_filter=0x15 -- LINEF_01_50Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 3107 //~ const uint8_t custom_v_filter = 0x20; // @ v_filter=0x20 -- LINEF_10_60Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 3108 //~ const uint8_t custom_v_filter = 0x21; // @ v_filter=0x21 -- LINEF_10_60Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 3109 //~ const uint8_t custom_v_filter = 0x22; // @ v_filter=0x22 -- LINEF_10_60Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 3110 //~ const uint8_t custom_v_filter = 0x23; // @ v_filter=0x23 -- LINEF_10_60Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 3111 //~ const uint8_t custom_v_filter = 0x24; // @ v_filter=0x24 -- LINEF_10_60Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 3112 //~ const uint8_t custom_v_filter = 0x25; // @ v_filter=0x25 -- LINEF_10_60Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 3113 //~ const uint8_t custom_v_filter = 0x30; // @ v_filter=0x30 -- LINEF_11_SINC4 RATE_0000 | 4SPS
whismanoid 0:cb44e2e9ec4c 3114 //~ const uint8_t custom_v_filter = 0x31; // @ v_filter=0x31 -- LINEF_11_SINC4 RATE_0001 | 10SPS
whismanoid 0:cb44e2e9ec4c 3115 //~ const uint8_t custom_v_filter = 0x32; // @ v_filter=0x32 -- LINEF_11_SINC4 RATE_0010 | 20SPS
whismanoid 0:cb44e2e9ec4c 3116 //~ const uint8_t custom_v_filter = 0x33; // @ v_filter=0x33 -- LINEF_11_SINC4 RATE_0011 | 40SPS
whismanoid 0:cb44e2e9ec4c 3117 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 3118 //~ const uint8_t custom_v_filter = 0x35; // @ v_filter=0x35 -- LINEF_11_SINC4 RATE_0101 | 120SPS
whismanoid 0:cb44e2e9ec4c 3119 //~ const uint8_t custom_v_filter = 0x36; // @ v_filter=0x36 -- LINEF_11_SINC4 RATE_0110 | 240SPS
whismanoid 0:cb44e2e9ec4c 3120 //~ const uint8_t custom_v_filter = 0x37; // @ v_filter=0x37 -- LINEF_11_SINC4 RATE_0111 | 480SPS
whismanoid 0:cb44e2e9ec4c 3121 //~ const uint8_t custom_v_filter = 0x38; // @ v_filter=0x38 -- LINEF_11_SINC4 RATE_1000 | 960SPS
whismanoid 0:cb44e2e9ec4c 3122 //~ const uint8_t custom_v_filter = 0x39; // @ v_filter=0x39 -- LINEF_11_SINC4 RATE_1001 | 1920SPS
whismanoid 0:cb44e2e9ec4c 3123 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 3124 //
whismanoid 0:cb44e2e9ec4c 3125 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 3126 // pga register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 0:cb44e2e9ec4c 3127 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 3128 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 3129 //~ const uint8_t custom_v_pga = 0x10; // @ v_pga=0x10 -- 0x10 SIG_PATH_01_BYPASS
whismanoid 0:cb44e2e9ec4c 3130 //~ const uint8_t custom_v_pga = 0x20; // @ v_pga=0x20 -- 0x20 SIG_PATH_10_PGA GAIN_000_1
whismanoid 0:cb44e2e9ec4c 3131 //~ const uint8_t custom_v_pga = 0x21; // @ v_pga=0x21 --*0x21 SIG_PATH_10_PGA GAIN_001_2
whismanoid 0:cb44e2e9ec4c 3132 //~ const uint8_t custom_v_pga = 0x22; // @ v_pga=0x22 -- 0x22 SIG_PATH_10_PGA GAIN_010_4
whismanoid 0:cb44e2e9ec4c 3133 //~ const uint8_t custom_v_pga = 0x23; // @ v_pga=0x23 -- 0x23 SIG_PATH_10_PGA GAIN_011_8
whismanoid 0:cb44e2e9ec4c 3134 //~ const uint8_t custom_v_pga = 0x24; // @ v_pga=0x24 -- 0x24 SIG_PATH_10_PGA GAIN_100_16
whismanoid 0:cb44e2e9ec4c 3135 //~ const uint8_t custom_v_pga = 0x25; // @ v_pga=0x25 -- 0x25 SIG_PATH_10_PGA GAIN_101_32
whismanoid 0:cb44e2e9ec4c 3136 //~ const uint8_t custom_v_pga = 0x26; // @ v_pga=0x26 -- 0x26 SIG_PATH_10_PGA GAIN_110_64
whismanoid 0:cb44e2e9ec4c 3137 //~ const uint8_t custom_v_pga = 0x27; // @ v_pga=0x27 -- 0x27 SIG_PATH_10_PGA GAIN_111_128
whismanoid 0:cb44e2e9ec4c 3138 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 3139 //
whismanoid 0:cb44e2e9ec4c 3140 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 3141 // ctrl register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 3:9055e17e181a 3142 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 3143 //~ const uint8_t custom_v_ctrl = 0x40; // @ v_ctrl=0x40 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1
whismanoid 0:cb44e2e9ec4c 3144 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 3145 //~ const uint8_t custom_v_ctrl = 0x58; // @ v_ctrl=0x58 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 3146 //
whismanoid 0:cb44e2e9ec4c 3147 //~ const uint8_t custom_v_ctrl = 0x41; // @ v_ctrl=0x41 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N
whismanoid 0:cb44e2e9ec4c 3148 //~ const uint8_t custom_v_ctrl = 0x45; // @ v_ctrl=0x45 -- 0x40 unipolar, 0x05 REF_SEL_101_REF1P_AGND
whismanoid 0:cb44e2e9ec4c 3149 //~ const uint8_t custom_v_ctrl = 0x59; // @ v_ctrl=0x59 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 3150 //
whismanoid 0:cb44e2e9ec4c 3151 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 3152 //~ const uint8_t custom_v_ctrl = 0x46; // @ v_ctrl=0x46 -- 0x40 unipolar, 0x06 REF_SEL_110_REF2P_AGND
whismanoid 0:cb44e2e9ec4c 3153 //~ const uint8_t custom_v_ctrl = 0x22; // @ v_ctrl=0x22 -- 0x20 bipolar offset binary, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 3154 //~ const uint8_t custom_v_ctrl = 0x02; // @ v_ctrl=0x02 -- 0x00 bipolar 2's complement, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 3155 //
whismanoid 0:cb44e2e9ec4c 3156 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 3157 //~ const uint8_t custom_v_ctrl = 0x47; // @ v_ctrl=0x47 -- 0x40 unipolar, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 3158 //~ const uint8_t custom_v_ctrl = 0x27; // @ v_ctrl=0x27 -- 0x20 bipolar offset binary, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 3159 //~ const uint8_t custom_v_ctrl = 0x07; // @ v_ctrl=0x07 -- 0x00 bipolar 2's complement, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 3160 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 3161
whismanoid 3:9055e17e181a 3162 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3163 // example code declare SPI interface (GPIO controlled CS)
whismanoid 0:cb44e2e9ec4c 3164 #if defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 3165 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 3166 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
whismanoid 19:5ff09c8e9daf 3167 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 3168 #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 3169 SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625PICO: pin P0_5 P0_6 P0_4
whismanoid 0:cb44e2e9ec4c 3170 DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32625PICO: pin P0_7
whismanoid 0:cb44e2e9ec4c 3171 #elif defined(TARGET_MAX32600MBED)
whismanoid 0:cb44e2e9ec4c 3172 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 0:cb44e2e9ec4c 3173 DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 3174 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 3175 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 3176 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:cb44e2e9ec4c 3177 //
whismanoid 0:cb44e2e9ec4c 3178 // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses.
whismanoid 0:cb44e2e9ec4c 3179 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 3180 DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 3181 //
whismanoid 0:cb44e2e9ec4c 3182 #else
whismanoid 3:9055e17e181a 3183 SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 3:9055e17e181a 3184 DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 3185 #endif
whismanoid 0:cb44e2e9ec4c 3186
whismanoid 0:cb44e2e9ec4c 3187 // example code declare GPIO interface pins
whismanoid 0:cb44e2e9ec4c 3188 // example code declare device instance
whismanoid 3:9055e17e181a 3189 MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC);
whismanoid 3:9055e17e181a 3190 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3191
whismanoid 1:747f1602abfc 3192 //--------------------------------------------------
whismanoid 3:9055e17e181a 3193 // Option to Datalog Arduino platform analog inputs
whismanoid 3:9055e17e181a 3194 #ifndef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 3195 #define LOG_PLATFORM_AIN 6
whismanoid 3:9055e17e181a 3196 //~ #undef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 3197 #endif
whismanoid 3:9055e17e181a 3198 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 1:747f1602abfc 3199 //#ifndef NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 1:747f1602abfc 3200 //#define NUM_PLATFORM_ANALOG_IN_CHANNELS 6
whismanoid 1:747f1602abfc 3201 //#endif
whismanoid 1:747f1602abfc 3202 const int NUM_PLATFORM_ANALOG_IN_CHANNELS = 6;
whismanoid 1:747f1602abfc 3203 const double adc_full_scale_voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 3204 analogInPin_fullScaleVoltage[0], // 1.2,
whismanoid 10:04022a61b527 3205 analogInPin_fullScaleVoltage[1], // 1.2,
whismanoid 10:04022a61b527 3206 analogInPin_fullScaleVoltage[2], // 1.2,
whismanoid 10:04022a61b527 3207 analogInPin_fullScaleVoltage[3], // 1.2,
whismanoid 10:04022a61b527 3208 analogInPin_fullScaleVoltage[4], // 6.0
whismanoid 10:04022a61b527 3209 analogInPin_fullScaleVoltage[5], // 6.0
whismanoid 0:cb44e2e9ec4c 3210 };
whismanoid 9:45f98573eb6d 3211 // Platform ADC individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 9:45f98573eb6d 3212 typedef enum Platform_AIN_Enable_t {
whismanoid 9:45f98573eb6d 3213 Platform_AIN_Disable = 0,
whismanoid 9:45f98573eb6d 3214 Platform_AIN_Enable_LSB = 1,
whismanoid 9:45f98573eb6d 3215 Platform_AIN_Enable_Volt = 2,
whismanoid 9:45f98573eb6d 3216 } Platform_AIN_Enable_t;
whismanoid 13:184a08909405 3217 uint8_t Platform_Enable_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 9:45f98573eb6d 3218 Platform_AIN_Enable_Volt, // AIN0 2=Volt
whismanoid 9:45f98573eb6d 3219 Platform_AIN_Enable_Volt, // AIN1 2=Volt
whismanoid 9:45f98573eb6d 3220 Platform_AIN_Enable_Volt, // AIN2 2=Volt
whismanoid 9:45f98573eb6d 3221 Platform_AIN_Enable_Volt, // AIN3 2=Volt
whismanoid 9:45f98573eb6d 3222 Platform_AIN_Enable_Volt, // AIN4 2=Volt
whismanoid 9:45f98573eb6d 3223 Platform_AIN_Enable_Volt, // AIN5 2=Volt
whismanoid 9:45f98573eb6d 3224 };
whismanoid 37:3f369235e5bc 3225 // Option to report average value of Arduino platform analog inputs
whismanoid 37:3f369235e5bc 3226 #ifndef USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3227 #define USE_Platform_AIN_Average 1
whismanoid 37:3f369235e5bc 3228 //~ #undef USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3229 #endif
whismanoid 37:3f369235e5bc 3230 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3231 #endif // USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3232 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3233 int Platform_AIN_Average_N = 16;
whismanoid 37:3f369235e5bc 3234 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 3235 // Option to apply calibration to Arduino platform analog inputs
whismanoid 34:a1993a1ee904 3236 #ifndef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3237 #define HAS_Platform_AIN_Calibration 1
whismanoid 34:a1993a1ee904 3238 //~ #undef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3239 #endif
whismanoid 34:a1993a1ee904 3240 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3241 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 3242 // Calibration is between two points for each channel, defined by
whismanoid 34:a1993a1ee904 3243 // a normalized value between 0% and 100%, and the corresponding voltage.
whismanoid 34:a1993a1ee904 3244 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 3245 // calibration_05_normValue_0_1, calibration_05_V should be around 5% or 25%
whismanoid 42:89607d5d4e6d 3246 extern double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 42:89607d5d4e6d 3247 extern double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 34:a1993a1ee904 3248 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 3249 // calibration_95_normValue_0_1, calibration_95_V should be around 95% or 75%
whismanoid 42:89607d5d4e6d 3250 extern double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 42:89607d5d4e6d 3251 extern double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 34:a1993a1ee904 3252 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3253 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3254 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1)
whismanoid 34:a1993a1ee904 3255 {
whismanoid 34:a1993a1ee904 3256 // TODO: return corrected normValue_0_1 using two-point linear calibration
whismanoid 34:a1993a1ee904 3257 // point 1: calibration_05_normValue_0_1[ch], calibration_05_V[ch]
whismanoid 34:a1993a1ee904 3258 // point 2: calibration_95_normValue_0_1[ch], calibration_95_V[ch]
whismanoid 34:a1993a1ee904 3259 // validate that there is enough span to get sensible results
whismanoid 34:a1993a1ee904 3260 //
whismanoid 34:a1993a1ee904 3261 int ch = channel_0_5;
whismanoid 34:a1993a1ee904 3262 // 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 3263 // ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 3264 // ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 3265 // ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 3266 // ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 3267 // );
whismanoid 34:a1993a1ee904 3268 // cmdLine.serial().printf("\r\n adc_full_scale_voltage[%d] = %1.6fV",
whismanoid 34:a1993a1ee904 3269 // ch,
whismanoid 34:a1993a1ee904 3270 // adc_full_scale_voltage[ch]
whismanoid 34:a1993a1ee904 3271 // );
whismanoid 34:a1993a1ee904 3272 // raw normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 3273 double raw_05_normValue = calibration_05_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 3274 double raw_95_normValue = calibration_95_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 3275 // calibrated normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 3276 // divide V/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 3277 double cal_05_normValue = calibration_05_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 3278 double cal_95_normValue = calibration_95_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 3279 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_05_normValue = %1.6f",
whismanoid 34:a1993a1ee904 3280 // ch,
whismanoid 34:a1993a1ee904 3281 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3282 // cal_05_normValue
whismanoid 34:a1993a1ee904 3283 // );
whismanoid 34:a1993a1ee904 3284 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_95_normValue = %1.6f",
whismanoid 34:a1993a1ee904 3285 // ch,
whismanoid 34:a1993a1ee904 3286 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3287 // cal_95_normValue
whismanoid 34:a1993a1ee904 3288 // );
whismanoid 34:a1993a1ee904 3289 //
whismanoid 34:a1993a1ee904 3290 double span_raw = raw_95_normValue - raw_05_normValue;
whismanoid 34:a1993a1ee904 3291 double span_cal = cal_95_normValue - cal_05_normValue;
whismanoid 34:a1993a1ee904 3292 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_raw = %1.6f",
whismanoid 34:a1993a1ee904 3293 // ch,
whismanoid 34:a1993a1ee904 3294 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3295 // span_raw
whismanoid 34:a1993a1ee904 3296 // );
whismanoid 34:a1993a1ee904 3297 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_cal = %1.6f",
whismanoid 34:a1993a1ee904 3298 // ch,
whismanoid 34:a1993a1ee904 3299 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3300 // span_cal
whismanoid 34:a1993a1ee904 3301 // );
whismanoid 34:a1993a1ee904 3302 // if calibration is not valid, return unmodified normValue_0_1 and print a warning
whismanoid 34:a1993a1ee904 3303 if (span_raw < 0.001) {
whismanoid 34:a1993a1ee904 3304 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_raw = %1.6f",
whismanoid 34:a1993a1ee904 3305 ch,
whismanoid 34:a1993a1ee904 3306 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3307 span_raw
whismanoid 34:a1993a1ee904 3308 );
whismanoid 34:a1993a1ee904 3309 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 3310 }
whismanoid 34:a1993a1ee904 3311 if (span_cal < 0.001) {
whismanoid 34:a1993a1ee904 3312 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_cal = %1.6f",
whismanoid 34:a1993a1ee904 3313 ch,
whismanoid 34:a1993a1ee904 3314 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3315 span_cal
whismanoid 34:a1993a1ee904 3316 );
whismanoid 34:a1993a1ee904 3317 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 3318 }
whismanoid 34:a1993a1ee904 3319 double slope_correction = span_cal / span_raw;
whismanoid 34:a1993a1ee904 3320 double corrected_normValue_0_1 = cal_05_normValue + ((raw_normValue_0_1 - raw_05_normValue) * slope_correction);
whismanoid 34:a1993a1ee904 3321 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) slope_correction = %1.6f",
whismanoid 34:a1993a1ee904 3322 // ch,
whismanoid 34:a1993a1ee904 3323 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3324 // slope_correction
whismanoid 34:a1993a1ee904 3325 // );
whismanoid 34:a1993a1ee904 3326 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) corrected_normValue_0_1 = %1.6f\r\n",
whismanoid 34:a1993a1ee904 3327 // ch,
whismanoid 34:a1993a1ee904 3328 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3329 // corrected_normValue_0_1
whismanoid 34:a1993a1ee904 3330 // );
whismanoid 34:a1993a1ee904 3331 return corrected_normValue_0_1;
whismanoid 34:a1993a1ee904 3332 }
whismanoid 34:a1993a1ee904 3333 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3334 // Option to customize channel names in datalog header line
whismanoid 45:74bf1fe021e5 3335 // This could be used to identify external hardware attached to each input
whismanoid 13:184a08909405 3336 #ifndef HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 3337 #define HAS_Platform_AIN_customChannelHeader 1
whismanoid 13:184a08909405 3338 #endif
whismanoid 13:184a08909405 3339 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 3340 const char* const Platform_AIN_customChannelHeader_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 3341 "=AIN4", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 3342 "=AIN5", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 3343 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 3344 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 3345 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 3346 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 3347 };
whismanoid 13:184a08909405 3348 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 1:747f1602abfc 3349 //--------------------------------------------------
whismanoid 1:747f1602abfc 3350 // Option to log platform analog inputs as raw LSB code
whismanoid 1:747f1602abfc 3351 #ifndef LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 3352 #define LOG_PLATFORM_ANALOG_IN_LSB 0
whismanoid 1:747f1602abfc 3353 #endif
whismanoid 1:747f1602abfc 3354 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 3355 int Platform_LSB[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 3356 #endif
whismanoid 1:747f1602abfc 3357
whismanoid 1:747f1602abfc 3358 //--------------------------------------------------
whismanoid 1:747f1602abfc 3359 // Option to use platform analog inputs as Voltage
whismanoid 1:747f1602abfc 3360 #ifndef LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 3361 #define LOG_PLATFORM_ANALOG_IN_VOLTS 1
whismanoid 1:747f1602abfc 3362 #endif
whismanoid 1:747f1602abfc 3363 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 3364 double Platform_Voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 3365 #endif
whismanoid 3:9055e17e181a 3366 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 0:cb44e2e9ec4c 3367
whismanoid 10:04022a61b527 3368 //--------------------------------------------------
whismanoid 10:04022a61b527 3369 // Option to use Command forwarding to Auxiliary serial port
whismanoid 10:04022a61b527 3370 // Command forwarding to Auxiliary serial port TX/RX
whismanoid 10:04022a61b527 3371 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial
whismanoid 10:04022a61b527 3372 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial
whismanoid 10:04022a61b527 3373 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3374 #ifndef USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3375 #define USE_AUX_SERIAL_CMD_FORWARDING 1
whismanoid 10:04022a61b527 3376 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3377 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3378 // Command forwarding to Auxiliary serial port TX/RX #257 -- global parameters
whismanoid 10:04022a61b527 3379 const size_t RX_STRING_BUF_SIZE = 1000;
whismanoid 10:04022a61b527 3380 int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 3381 // transmit command string by AUX TX
whismanoid 10:04022a61b527 3382 #if 0
whismanoid 10:04022a61b527 3383 int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 3384 int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 3385 int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 3386 #endif
whismanoid 10:04022a61b527 3387 // capture received string from AUX RX
whismanoid 10:04022a61b527 3388 Timer g_auxSerialCom_Timer;
whismanoid 10:04022a61b527 3389 int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 3390 int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 3391 int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 3392 int g_auxSerialCom_rx_idle_ms = 500; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 3393 int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 3394 const int aux_serial_cmd_forwarding_rx_eot_not_used = 'x';
whismanoid 10:04022a61b527 3395 int g_auxSerialCom_rx_eot = aux_serial_cmd_forwarding_rx_eot_not_used; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 3396 //~ int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text string?
whismanoid 10:04022a61b527 3397 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3398 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3399 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257
whismanoid 10:04022a61b527 3400 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3401 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3402 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3403 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3404 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3405 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3406 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 3407 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3408 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3409 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3410 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3411 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3412 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3413 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3414 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3415
whismanoid 8:dffee7509bfb 3416 // CODE GENERATOR: example code for ADC: serial port declaration
whismanoid 8:dffee7509bfb 3417 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3418 // Declare the Serial driver
whismanoid 8:dffee7509bfb 3419 // default baud rate settings are 9600 8N1
whismanoid 8:dffee7509bfb 3420 // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
whismanoid 8:dffee7509bfb 3421 // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
whismanoid 8:dffee7509bfb 3422 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3423 #if defined(TARGET_MAX32630)
whismanoid 8:dffee7509bfb 3424 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 3425 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3426 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3427 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 3428 //
whismanoid 8:dffee7509bfb 3429 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3430 Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3431 //Serial J3AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 3432 //Serial BTAUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 3433 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3434 //
whismanoid 8:dffee7509bfb 3435 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3436 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3437 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3438 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3439 //
whismanoid 8:dffee7509bfb 3440 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3441 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3442 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3443 USBSerial serial;
whismanoid 8:dffee7509bfb 3444 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3445 #elif defined(TARGET_MAX32625MBED)
whismanoid 8:dffee7509bfb 3446 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625MBED: P0_1,P0_0 (Arduino D1,D0)
whismanoid 8:dffee7509bfb 3447 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3448 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625MBED: P3_1,P3_0 (J15-LEDgreen,LEDred)
whismanoid 8:dffee7509bfb 3449 //
whismanoid 8:dffee7509bfb 3450 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3451 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3452 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3453 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3454 //
whismanoid 8:dffee7509bfb 3455 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3456 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3457 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3458 USBSerial serial;
whismanoid 8:dffee7509bfb 3459 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 3460 #elif defined(TARGET_MAX32625PICO)
whismanoid 8:dffee7509bfb 3461 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 3462 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625PICO: P2_1,P2_0 (underside?)
whismanoid 8:dffee7509bfb 3463 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3464 //
whismanoid 8:dffee7509bfb 3465 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3466 Serial AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 3467 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3468 //
whismanoid 8:dffee7509bfb 3469 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3470 Serial DAPLINKserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3471 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3472 //
whismanoid 8:dffee7509bfb 3473 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3474 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3475 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3476 USBSerial serial;
whismanoid 22:d6dc8a85f435 3477 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 3478 #elif defined(TARGET_MAX40108DEMOP2U9)
whismanoid 22:d6dc8a85f435 3479 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 3480 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK)
whismanoid 22:d6dc8a85f435 3481 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 3482 //
whismanoid 22:d6dc8a85f435 3483 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial is used as main serial port in MAX40108 Demo board
whismanoid 22:d6dc8a85f435 3484 Serial serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 3485 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 3486 //
whismanoid 22:d6dc8a85f435 3487 // Hardware serial port over DAPLink
whismanoid 22:d6dc8a85f435 3488 // connection to external MAX32625PICO(DAPLINK) needed TX/RX swap in firmware.
whismanoid 22:d6dc8a85f435 3489 // MAX32625PICO(DAPLINK) drives DAPLINK.8, listens on DAPLINK.6.
whismanoid 22:d6dc8a85f435 3490 // See AN6350 MAX32625 Users Guide 7.5.2.3.1 TX and RX Pin Mapping for UART 1 -- Mapping Option B
whismanoid 39:4d285e961435 3491 #ifdef BOARD_SERIAL_NUMBER
whismanoid 39:4d285e961435 3492 // data unique to certain boards based on serial number
whismanoid 39:4d285e961435 3493 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 39:4d285e961435 3494 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 39:4d285e961435 3495 // s/n 0 is not really a MAX40108 board, it's actually a MAX32625PICO used for early development. So no swap.
whismanoid 39:4d285e961435 3496 Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 39:4d285e961435 3497 //Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 39:4d285e961435 3498 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3499 //
whismanoid 39:4d285e961435 3500 // # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 39:4d285e961435 3501 // #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 39:4d285e961435 3502 // //
whismanoid 39:4d285e961435 3503 // # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 39:4d285e961435 3504 // #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 39:4d285e961435 3505 // //
whismanoid 39:4d285e961435 3506 // # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 39:4d285e961435 3507 // #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 39:4d285e961435 3508 // //
whismanoid 39:4d285e961435 3509 // # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 39:4d285e961435 3510 // #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 39:4d285e961435 3511 // //
whismanoid 39:4d285e961435 3512 // # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 39:4d285e961435 3513 // #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 39:4d285e961435 3514 // //
whismanoid 39:4d285e961435 3515 // # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 39:4d285e961435 3516 // #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 39:4d285e961435 3517 // //
whismanoid 39:4d285e961435 3518 # else
whismanoid 39:4d285e961435 3519 // #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 22:d6dc8a85f435 3520 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 22:d6dc8a85f435 3521 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 22:d6dc8a85f435 3522 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3523 # endif
whismanoid 39:4d285e961435 3524 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 39:4d285e961435 3525 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 39:4d285e961435 3526 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 39:4d285e961435 3527 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 39:4d285e961435 3528 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3529 //
whismanoid 39:4d285e961435 3530 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 22:d6dc8a85f435 3531 //
whismanoid 22:d6dc8a85f435 3532 // Serial AUXserial(UART1_TX,UART1_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 3533 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 3534 //
whismanoid 22:d6dc8a85f435 3535 // Virtual serial port over USB
whismanoid 22:d6dc8a85f435 3536 // #include "USBSerial.h"
whismanoid 22:d6dc8a85f435 3537 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 22:d6dc8a85f435 3538 //USBSerial serial;
whismanoid 8:dffee7509bfb 3539 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3540 #elif defined(TARGET_MAX32620FTHR)
whismanoid 8:dffee7509bfb 3541 #warning "TARGET_MAX32620FTHR not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3542 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3543 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32620FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3544 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3545 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3546 //
whismanoid 8:dffee7509bfb 3547 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3548 Serial serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3549 //Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3550 Serial AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3551 //Serial PMOD0AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3552 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3553 //
whismanoid 8:dffee7509bfb 3554 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3555 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3556 Serial DAPLINKserial(USBTX, USBRX); // tx,rx MAX32620FTHR: P2_1,P2_0
whismanoid 8:dffee7509bfb 3557 //Serial DAPLINKserial(STDIO_UART_TX, STDIO_UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3558 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3559 //
whismanoid 8:dffee7509bfb 3560 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3561 // #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3562 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3563 //USBSerial serial; // MAX32620FTHR: USBSerial crash??
whismanoid 8:dffee7509bfb 3564 #warning "TARGET_MAX32620FTHR not previously tested; USBSerial crash?"
whismanoid 8:dffee7509bfb 3565 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3566 #elif defined(TARGET_MAX32600)
whismanoid 8:dffee7509bfb 3567 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3568 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART2 MAX32625MBED: P1_3,P1_2 (Arduino D3,D2)
whismanoid 8:dffee7509bfb 3569 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART1 MAX32625MBED: P7_3,P7_2 ( ?? )
whismanoid 8:dffee7509bfb 3570 //
whismanoid 8:dffee7509bfb 3571 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3572 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3573 Serial DAPLINKserial(P1_1,P1_0); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3574 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3575 //
whismanoid 8:dffee7509bfb 3576 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3577 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3578 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3579 USBSerial serial;
whismanoid 8:dffee7509bfb 3580 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3581 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 8:dffee7509bfb 3582 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3583 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3584 #else
whismanoid 8:dffee7509bfb 3585 #if defined(SERIAL_TX)
whismanoid 8:dffee7509bfb 3586 #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..."
whismanoid 8:dffee7509bfb 3587 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3588 #elif defined(USBTX)
whismanoid 8:dffee7509bfb 3589 #warning "target not previously tested; guess serial pins are USBTX, USBRX..."
whismanoid 8:dffee7509bfb 3590 Serial serial(USBTX, USBRX); // tx, rx
whismanoid 8:dffee7509bfb 3591 #elif defined(UART_TX)
whismanoid 8:dffee7509bfb 3592 #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..."
whismanoid 8:dffee7509bfb 3593 Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3594 #else
whismanoid 8:dffee7509bfb 3595 #warning "target not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3596 #endif
whismanoid 8:dffee7509bfb 3597 #endif
whismanoid 8:dffee7509bfb 3598 //
whismanoid 8:dffee7509bfb 3599 #include "CmdLine.h"
whismanoid 8:dffee7509bfb 3600
whismanoid 8:dffee7509bfb 3601 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3602 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3603 CmdLine cmdLine_AUXserial(AUXserial, "AUXserial");
whismanoid 10:04022a61b527 3604 uint8_t Datalogger_enable_AUXserial = {
whismanoid 10:04022a61b527 3605 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3606 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 3607 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 3608 false
whismanoid 10:04022a61b527 3609 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3610 true
whismanoid 10:04022a61b527 3611 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3612 };
whismanoid 8:dffee7509bfb 3613 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3614 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3615 CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK");
whismanoid 8:dffee7509bfb 3616 uint8_t Datalogger_enable_DAPLINKserial = true;
whismanoid 8:dffee7509bfb 3617 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3618 CmdLine cmdLine(serial, "serial");
whismanoid 8:dffee7509bfb 3619 uint8_t Datalogger_enable_serial = true;
whismanoid 8:dffee7509bfb 3620 // CODE GENERATOR: example code for ADC: serial port declaration (end)
whismanoid 8:dffee7509bfb 3621
whismanoid 21:ac062a97a71d 3622
whismanoid 21:ac062a97a71d 3623 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3624 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3625 // support for commands %B1! .. %B9!
whismanoid 23:c6c652bef4b9 3626 #ifndef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3627 #define USE_DATALOGGER_CommandTable 1
whismanoid 23:c6c652bef4b9 3628 //~ #undef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3629 #endif
whismanoid 23:c6c652bef4b9 3630 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3631 const int COMMAND_TABLE_ROW_MAX = 10;
whismanoid 23:c6c652bef4b9 3632 const int COMMAND_TABLE_COL_MAX = 40;
whismanoid 23:c6c652bef4b9 3633 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3634 //
whismanoid 23:c6c652bef4b9 3635 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3636 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3637 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3638 // onButton1_command_table[] supports command %B1! -- run, %B1@ -- edit
whismanoid 45:74bf1fe021e5 3639 // MAX40108p2 hardware pin P2_7 button SW1 active low
whismanoid 45:74bf1fe021e5 3640 //........................................................12345678901234567890
whismanoid 45:74bf1fe021e5 3641 char onButton1_command_table_00[COMMAND_TABLE_COL_MAX] = "# SW1 event";
whismanoid 45:74bf1fe021e5 3642 char onButton1_command_table_01[COMMAND_TABLE_COL_MAX] = ">>SW1=LP1 deep sleep 10 sec";
whismanoid 45:74bf1fe021e5 3643 char onButton1_command_table_02[COMMAND_TABLE_COL_MAX] = "%H91"; // LED off
whismanoid 45:74bf1fe021e5 3644 char onButton1_command_table_03[COMMAND_TABLE_COL_MAX] = "%H92"; // LED off
whismanoid 45:74bf1fe021e5 3645 char onButton1_command_table_04[COMMAND_TABLE_COL_MAX] = "%H93"; // LED off
whismanoid 45:74bf1fe021e5 3646 char onButton1_command_table_05[COMMAND_TABLE_COL_MAX] = "%H9"; // diagnostic pulse D9
whismanoid 45:74bf1fe021e5 3647 char onButton1_command_table_06[COMMAND_TABLE_COL_MAX] = "LT count=10 base=1000 sleep=1";
whismanoid 45:74bf1fe021e5 3648 char onButton1_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3649 char onButton1_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3650 char onButton1_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3651 static char* onButton1_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3652 onButton1_command_table_00,
whismanoid 23:c6c652bef4b9 3653 onButton1_command_table_01,
whismanoid 23:c6c652bef4b9 3654 onButton1_command_table_02,
whismanoid 23:c6c652bef4b9 3655 onButton1_command_table_03,
whismanoid 23:c6c652bef4b9 3656 onButton1_command_table_04,
whismanoid 23:c6c652bef4b9 3657 onButton1_command_table_05,
whismanoid 23:c6c652bef4b9 3658 onButton1_command_table_06,
whismanoid 23:c6c652bef4b9 3659 onButton1_command_table_07,
whismanoid 23:c6c652bef4b9 3660 onButton1_command_table_08,
whismanoid 23:c6c652bef4b9 3661 onButton1_command_table_09,
whismanoid 23:c6c652bef4b9 3662 };
whismanoid 23:c6c652bef4b9 3663 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3664 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3665 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3666 // onButton2_command_table[] supports command %B2! -- run, %B2@ -- edit
whismanoid 45:74bf1fe021e5 3667 // MAX40108p2 hardware pin P1_7 connector J91.3 active low
whismanoid 45:74bf1fe021e5 3668 //........................................................12345678901234567890
whismanoid 45:74bf1fe021e5 3669 char onButton2_command_table_00[COMMAND_TABLE_COL_MAX] = "# J91.3=Halt"; // remark
whismanoid 45:74bf1fe021e5 3670 char onButton2_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91"; // LED on
whismanoid 45:74bf1fe021e5 3671 char onButton2_command_table_02[COMMAND_TABLE_COL_MAX] = "L"; // halts data logging
whismanoid 45:74bf1fe021e5 3672 char onButton2_command_table_03[COMMAND_TABLE_COL_MAX] = "%H92"; // LED off
whismanoid 45:74bf1fe021e5 3673 char onButton2_command_table_04[COMMAND_TABLE_COL_MAX] = "%L93"; // LED on
whismanoid 45:74bf1fe021e5 3674 char onButton2_command_table_05[COMMAND_TABLE_COL_MAX] = ">>J91.2=Halt"; // to DAPLINK comms
whismanoid 23:c6c652bef4b9 3675 char onButton2_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3676 char onButton2_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3677 char onButton2_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3678 char onButton2_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3679 static char* onButton2_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3680 onButton2_command_table_00,
whismanoid 23:c6c652bef4b9 3681 onButton2_command_table_01,
whismanoid 23:c6c652bef4b9 3682 onButton2_command_table_02,
whismanoid 23:c6c652bef4b9 3683 onButton2_command_table_03,
whismanoid 23:c6c652bef4b9 3684 onButton2_command_table_04,
whismanoid 23:c6c652bef4b9 3685 onButton2_command_table_05,
whismanoid 23:c6c652bef4b9 3686 onButton2_command_table_06,
whismanoid 23:c6c652bef4b9 3687 onButton2_command_table_07,
whismanoid 23:c6c652bef4b9 3688 onButton2_command_table_08,
whismanoid 23:c6c652bef4b9 3689 onButton2_command_table_09,
whismanoid 23:c6c652bef4b9 3690 };
whismanoid 23:c6c652bef4b9 3691 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3692 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3693 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3694 // onButton3_command_table[] supports command %B3! -- run, %B3@ -- edit
whismanoid 45:74bf1fe021e5 3695 // MAX40108p2 hardware pin P1_6 connector J91.2 active low
whismanoid 45:74bf1fe021e5 3696 //........................................................12345678901234567890
whismanoid 45:74bf1fe021e5 3697 char onButton3_command_table_00[COMMAND_TABLE_COL_MAX] = "# J91.2 event";
whismanoid 45:74bf1fe021e5 3698 char onButton3_command_table_01[COMMAND_TABLE_COL_MAX] = ">>J91.2 event";
whismanoid 45:74bf1fe021e5 3699 char onButton3_command_table_02[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 45:74bf1fe021e5 3700 char onButton3_command_table_03[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 45:74bf1fe021e5 3701 char onButton3_command_table_04[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 45:74bf1fe021e5 3702 char onButton3_command_table_05[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 45:74bf1fe021e5 3703 char onButton3_command_table_06[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 45:74bf1fe021e5 3704 char onButton3_command_table_07[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 45:74bf1fe021e5 3705 char onButton3_command_table_08[COMMAND_TABLE_COL_MAX] = ">>LR -- run full speed";
whismanoid 45:74bf1fe021e5 3706 char onButton3_command_table_09[COMMAND_TABLE_COL_MAX] = "LR";
whismanoid 24:032f3683cb2a 3707 static char* onButton3_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 24:032f3683cb2a 3708 onButton3_command_table_00,
whismanoid 24:032f3683cb2a 3709 onButton3_command_table_01,
whismanoid 24:032f3683cb2a 3710 onButton3_command_table_02,
whismanoid 24:032f3683cb2a 3711 onButton3_command_table_03,
whismanoid 24:032f3683cb2a 3712 onButton3_command_table_04,
whismanoid 24:032f3683cb2a 3713 onButton3_command_table_05,
whismanoid 24:032f3683cb2a 3714 onButton3_command_table_06,
whismanoid 24:032f3683cb2a 3715 onButton3_command_table_07,
whismanoid 24:032f3683cb2a 3716 onButton3_command_table_08,
whismanoid 24:032f3683cb2a 3717 onButton3_command_table_09,
whismanoid 24:032f3683cb2a 3718 };
whismanoid 24:032f3683cb2a 3719 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3720 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3721 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3722 // onButton4_command_table[] supports command %B4! -- run, %B4@ -- edit
whismanoid 45:74bf1fe021e5 3723 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3724 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3725 char onButton4_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button4 event";
whismanoid 30:07197a430869 3726 char onButton4_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE>0.7:active";
whismanoid 29:6a9edb6e973b 3727 char onButton4_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3728 char onButton4_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3729 char onButton4_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3730 char onButton4_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3731 char onButton4_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3732 char onButton4_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3733 char onButton4_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3734 char onButton4_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3735 static char* onButton4_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3736 onButton4_command_table_00,
whismanoid 29:6a9edb6e973b 3737 onButton4_command_table_01,
whismanoid 29:6a9edb6e973b 3738 onButton4_command_table_02,
whismanoid 29:6a9edb6e973b 3739 onButton4_command_table_03,
whismanoid 29:6a9edb6e973b 3740 onButton4_command_table_04,
whismanoid 29:6a9edb6e973b 3741 onButton4_command_table_05,
whismanoid 29:6a9edb6e973b 3742 onButton4_command_table_06,
whismanoid 29:6a9edb6e973b 3743 onButton4_command_table_07,
whismanoid 29:6a9edb6e973b 3744 onButton4_command_table_08,
whismanoid 29:6a9edb6e973b 3745 onButton4_command_table_09,
whismanoid 29:6a9edb6e973b 3746 };
whismanoid 29:6a9edb6e973b 3747 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3748 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3749 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3750 // onButton5_command_table[] supports command %B5! -- run, %B5@ -- edit
whismanoid 45:74bf1fe021e5 3751 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3752 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3753 char onButton5_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button5 event";
whismanoid 30:07197a430869 3754 char onButton5_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE<0.6:sleep";
whismanoid 29:6a9edb6e973b 3755 char onButton5_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3756 char onButton5_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3757 char onButton5_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3758 char onButton5_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3759 char onButton5_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3760 char onButton5_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3761 char onButton5_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3762 char onButton5_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3763 static char* onButton5_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3764 onButton5_command_table_00,
whismanoid 29:6a9edb6e973b 3765 onButton5_command_table_01,
whismanoid 29:6a9edb6e973b 3766 onButton5_command_table_02,
whismanoid 29:6a9edb6e973b 3767 onButton5_command_table_03,
whismanoid 29:6a9edb6e973b 3768 onButton5_command_table_04,
whismanoid 29:6a9edb6e973b 3769 onButton5_command_table_05,
whismanoid 29:6a9edb6e973b 3770 onButton5_command_table_06,
whismanoid 29:6a9edb6e973b 3771 onButton5_command_table_07,
whismanoid 29:6a9edb6e973b 3772 onButton5_command_table_08,
whismanoid 29:6a9edb6e973b 3773 onButton5_command_table_09,
whismanoid 29:6a9edb6e973b 3774 };
whismanoid 29:6a9edb6e973b 3775 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3776 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3777 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3778 // onButton6_command_table[] supports command %B6! -- run, %B6@ -- edit
whismanoid 45:74bf1fe021e5 3779 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3780 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3781 char onButton6_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button6 event";
whismanoid 29:6a9edb6e973b 3782 char onButton6_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3783 char onButton6_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3784 char onButton6_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3785 char onButton6_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3786 char onButton6_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3787 char onButton6_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3788 char onButton6_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3789 char onButton6_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3790 char onButton6_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3791 static char* onButton6_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3792 onButton6_command_table_00,
whismanoid 29:6a9edb6e973b 3793 onButton6_command_table_01,
whismanoid 29:6a9edb6e973b 3794 onButton6_command_table_02,
whismanoid 29:6a9edb6e973b 3795 onButton6_command_table_03,
whismanoid 29:6a9edb6e973b 3796 onButton6_command_table_04,
whismanoid 29:6a9edb6e973b 3797 onButton6_command_table_05,
whismanoid 29:6a9edb6e973b 3798 onButton6_command_table_06,
whismanoid 29:6a9edb6e973b 3799 onButton6_command_table_07,
whismanoid 29:6a9edb6e973b 3800 onButton6_command_table_08,
whismanoid 29:6a9edb6e973b 3801 onButton6_command_table_09,
whismanoid 29:6a9edb6e973b 3802 };
whismanoid 29:6a9edb6e973b 3803 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3804 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3805 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3806 // onButton7_command_table[] supports command %B7! -- run, %B7@ -- edit
whismanoid 45:74bf1fe021e5 3807 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3808 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3809 char onButton7_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button7 event";
whismanoid 29:6a9edb6e973b 3810 char onButton7_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3811 char onButton7_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3812 char onButton7_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3813 char onButton7_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3814 char onButton7_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3815 char onButton7_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3816 char onButton7_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3817 char onButton7_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3818 char onButton7_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3819 static char* onButton7_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3820 onButton7_command_table_00,
whismanoid 29:6a9edb6e973b 3821 onButton7_command_table_01,
whismanoid 29:6a9edb6e973b 3822 onButton7_command_table_02,
whismanoid 29:6a9edb6e973b 3823 onButton7_command_table_03,
whismanoid 29:6a9edb6e973b 3824 onButton7_command_table_04,
whismanoid 29:6a9edb6e973b 3825 onButton7_command_table_05,
whismanoid 29:6a9edb6e973b 3826 onButton7_command_table_06,
whismanoid 29:6a9edb6e973b 3827 onButton7_command_table_07,
whismanoid 29:6a9edb6e973b 3828 onButton7_command_table_08,
whismanoid 29:6a9edb6e973b 3829 onButton7_command_table_09,
whismanoid 29:6a9edb6e973b 3830 };
whismanoid 29:6a9edb6e973b 3831 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3832 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3833 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3834 // onButton8_command_table[] supports command %B8! -- run, %B8@ -- edit
whismanoid 45:74bf1fe021e5 3835 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3836 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3837 char onButton8_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button8 event";
whismanoid 29:6a9edb6e973b 3838 char onButton8_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3839 char onButton8_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3840 char onButton8_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3841 char onButton8_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3842 char onButton8_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3843 char onButton8_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3844 char onButton8_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3845 char onButton8_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3846 char onButton8_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3847 static char* onButton8_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3848 onButton8_command_table_00,
whismanoid 29:6a9edb6e973b 3849 onButton8_command_table_01,
whismanoid 29:6a9edb6e973b 3850 onButton8_command_table_02,
whismanoid 29:6a9edb6e973b 3851 onButton8_command_table_03,
whismanoid 29:6a9edb6e973b 3852 onButton8_command_table_04,
whismanoid 29:6a9edb6e973b 3853 onButton8_command_table_05,
whismanoid 29:6a9edb6e973b 3854 onButton8_command_table_06,
whismanoid 29:6a9edb6e973b 3855 onButton8_command_table_07,
whismanoid 29:6a9edb6e973b 3856 onButton8_command_table_08,
whismanoid 29:6a9edb6e973b 3857 onButton8_command_table_09,
whismanoid 29:6a9edb6e973b 3858 };
whismanoid 29:6a9edb6e973b 3859 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3860 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3861 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3862 // onButton9_command_table[] supports command %B9! -- run, %B9@ -- edit
whismanoid 45:74bf1fe021e5 3863 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3864 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3865 char onButton9_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button9 event";
whismanoid 29:6a9edb6e973b 3866 char onButton9_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3867 char onButton9_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3868 char onButton9_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3869 char onButton9_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3870 char onButton9_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3871 char onButton9_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3872 char onButton9_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3873 char onButton9_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3874 char onButton9_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3875 static char* onButton9_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3876 onButton9_command_table_00,
whismanoid 29:6a9edb6e973b 3877 onButton9_command_table_01,
whismanoid 29:6a9edb6e973b 3878 onButton9_command_table_02,
whismanoid 29:6a9edb6e973b 3879 onButton9_command_table_03,
whismanoid 29:6a9edb6e973b 3880 onButton9_command_table_04,
whismanoid 29:6a9edb6e973b 3881 onButton9_command_table_05,
whismanoid 29:6a9edb6e973b 3882 onButton9_command_table_06,
whismanoid 29:6a9edb6e973b 3883 onButton9_command_table_07,
whismanoid 29:6a9edb6e973b 3884 onButton9_command_table_08,
whismanoid 29:6a9edb6e973b 3885 onButton9_command_table_09,
whismanoid 29:6a9edb6e973b 3886 };
whismanoid 29:6a9edb6e973b 3887 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3888 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3889 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3890 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 3891 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3892 bool g_Run_command_table_running = false;
whismanoid 23:c6c652bef4b9 3893 void Run_command_table(char* command_table[])
whismanoid 23:c6c652bef4b9 3894 {
whismanoid 23:c6c652bef4b9 3895 // command_table: perform list of commands
whismanoid 31:47eee7e0cc2d 3896 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3897 if (g_Run_command_table_running) {
whismanoid 31:47eee7e0cc2d 3898 // TODO: button event chaining is not supported at this time
whismanoid 31:47eee7e0cc2d 3899 } // if (g_Run_command_table_running)
whismanoid 31:47eee7e0cc2d 3900 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3901 g_Run_command_table_running = true;
whismanoid 23:c6c652bef4b9 3902 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 3903 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 3904 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 23:c6c652bef4b9 3905 cmdLine.clear();
whismanoid 31:47eee7e0cc2d 3906 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3907 //~ char* strIndex = command_table[lineIndex];
whismanoid 23:c6c652bef4b9 3908 for (char* strIndex = command_table[lineIndex]; *strIndex != '\0'; strIndex++)
whismanoid 23:c6c652bef4b9 3909 {
whismanoid 23:c6c652bef4b9 3910 cmdLine.append(*strIndex);
whismanoid 23:c6c652bef4b9 3911 }
whismanoid 23:c6c652bef4b9 3912 cmdLine.append('\r'); // append \r invokes onEOLcommandParser to handle command
whismanoid 23:c6c652bef4b9 3913 }
whismanoid 31:47eee7e0cc2d 3914 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3915 g_Run_command_table_running = false;
whismanoid 31:47eee7e0cc2d 3916 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3917 }
whismanoid 23:c6c652bef4b9 3918 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3919 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3920 // When user presses button BUTTON1, perform actions
whismanoid 21:ac062a97a71d 3921 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3922 void onButton1FallingEdge(void)
whismanoid 21:ac062a97a71d 3923 {
whismanoid 21:ac062a97a71d 3924 //~ void SelfTest(CmdLine & cmdLine);
whismanoid 21:ac062a97a71d 3925 //~ SelfTest(cmdLine_serial);
whismanoid 22:d6dc8a85f435 3926 //
whismanoid 23:c6c652bef4b9 3927 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3928 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3929 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3930 Run_command_table(onButton1_command_table);
whismanoid 23:c6c652bef4b9 3931 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3932 }
whismanoid 21:ac062a97a71d 3933 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3934
whismanoid 21:ac062a97a71d 3935 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3936 // When user presses button BUTTON2, perform actions
whismanoid 21:ac062a97a71d 3937 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3938 void onButton2FallingEdge(void)
whismanoid 21:ac062a97a71d 3939 {
whismanoid 21:ac062a97a71d 3940 // TBD demo configuration
whismanoid 21:ac062a97a71d 3941 // TODO diagnostic LED
whismanoid 21:ac062a97a71d 3942 // led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 22:d6dc8a85f435 3943 //
whismanoid 23:c6c652bef4b9 3944 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3945 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3946 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3947 Run_command_table(onButton2_command_table);
whismanoid 23:c6c652bef4b9 3948 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3949 }
whismanoid 21:ac062a97a71d 3950 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3951
whismanoid 24:032f3683cb2a 3952 //--------------------------------------------------
whismanoid 29:6a9edb6e973b 3953 // When user presses button BUTTON3, perform actions
whismanoid 24:032f3683cb2a 3954 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3955 void onButton3FallingEdge(void)
whismanoid 24:032f3683cb2a 3956 {
whismanoid 24:032f3683cb2a 3957 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 24:032f3683cb2a 3958 // command_table: list of commands to perform on button press
whismanoid 24:032f3683cb2a 3959 // command_table: perform list of commands
whismanoid 24:032f3683cb2a 3960 Run_command_table(onButton3_command_table);
whismanoid 24:032f3683cb2a 3961 #endif // USE_DATALOGGER_CommandTable
whismanoid 24:032f3683cb2a 3962 }
whismanoid 24:032f3683cb2a 3963 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3964 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3965 void onButton4FallingEdge(void)
whismanoid 29:6a9edb6e973b 3966 {
whismanoid 29:6a9edb6e973b 3967 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3968 Run_command_table(onButton4_command_table);
whismanoid 29:6a9edb6e973b 3969 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3970 }
whismanoid 29:6a9edb6e973b 3971 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3972 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3973 void onButton5FallingEdge(void)
whismanoid 29:6a9edb6e973b 3974 {
whismanoid 29:6a9edb6e973b 3975 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3976 Run_command_table(onButton5_command_table);
whismanoid 29:6a9edb6e973b 3977 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3978 }
whismanoid 29:6a9edb6e973b 3979 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3980 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3981 void onButton6FallingEdge(void)
whismanoid 29:6a9edb6e973b 3982 {
whismanoid 29:6a9edb6e973b 3983 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3984 Run_command_table(onButton6_command_table);
whismanoid 29:6a9edb6e973b 3985 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3986 }
whismanoid 29:6a9edb6e973b 3987 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3988 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3989 void onButton7FallingEdge(void)
whismanoid 29:6a9edb6e973b 3990 {
whismanoid 29:6a9edb6e973b 3991 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3992 Run_command_table(onButton7_command_table);
whismanoid 29:6a9edb6e973b 3993 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3994 }
whismanoid 29:6a9edb6e973b 3995 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3996 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3997 void onButton8FallingEdge(void)
whismanoid 29:6a9edb6e973b 3998 {
whismanoid 29:6a9edb6e973b 3999 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4000 Run_command_table(onButton8_command_table);
whismanoid 29:6a9edb6e973b 4001 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4002 }
whismanoid 29:6a9edb6e973b 4003 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4004 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4005 void onButton9FallingEdge(void)
whismanoid 29:6a9edb6e973b 4006 {
whismanoid 29:6a9edb6e973b 4007 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4008 Run_command_table(onButton9_command_table);
whismanoid 29:6a9edb6e973b 4009 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 4010 }
whismanoid 29:6a9edb6e973b 4011 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4012
whismanoid 4:d9b05924ad4c 4013 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 4014 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 4015 inline void print_command_prompt()
whismanoid 4:d9b05924ad4c 4016 {
whismanoid 4:d9b05924ad4c 4017 //~ Serial.println(F(">"));
whismanoid 4:d9b05924ad4c 4018 cmdLine.serial().printf("\r\n> ");
whismanoid 4:d9b05924ad4c 4019 }
whismanoid 4:d9b05924ad4c 4020 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 4021
whismanoid 4:d9b05924ad4c 4022 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 4023 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 4024 void main_menu_status(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 4025 {
whismanoid 4:d9b05924ad4c 4026 cmdLine.serial().printf("\r\nMain menu");
whismanoid 4:d9b05924ad4c 4027 #if APPLICATION_MAX5715 // main_menu_status banner
whismanoid 4:d9b05924ad4c 4028 cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC");
whismanoid 4:d9b05924ad4c 4029 #elif APPLICATION_MAX11131 // main_menu_status banner
whismanoid 4:d9b05924ad4c 4030 cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC");
whismanoid 4:d9b05924ad4c 4031 #elif APPLICATION_MAX5171 // main_menu_status banner
whismanoid 4:d9b05924ad4c 4032 cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC");
whismanoid 4:d9b05924ad4c 4033 #elif APPLICATION_MAX11410 // main_menu_status banner
whismanoid 4:d9b05924ad4c 4034 cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC");
whismanoid 4:d9b05924ad4c 4035 #elif APPLICATION_MAX12345 // main_menu_status banner
whismanoid 4:d9b05924ad4c 4036 cmdLine.serial().printf(" MAX12345");
whismanoid 16:819c5aaf5271 4037 #elif MAX40108_DEMO // main_menu_status banner
whismanoid 17:9397ea3ea7e9 4038 cmdLine.serial().printf(" MAX40108_U%d", MAX40108_DEMO);
whismanoid 36:e7aac874b8be 4039 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 4040 // data unique to certain boards based on serial number
whismanoid 47:f1a56afb4aca 4041 cmdLine.serial().printf(" [s/n %d]", g_board_serial_number);
whismanoid 36:e7aac874b8be 4042 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 4043 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 4044 //
whismanoid 36:e7aac874b8be 4045 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 4046 #ifdef FW_REV
whismanoid 37:3f369235e5bc 4047 cmdLine.serial().printf(" [FW_REV %d]", FW_REV);
whismanoid 37:3f369235e5bc 4048 #endif // FW_REV
whismanoid 4:d9b05924ad4c 4049 #else
whismanoid 4:d9b05924ad4c 4050 //cmdLine.serial().printf(" ");
whismanoid 4:d9b05924ad4c 4051 #endif
whismanoid 4:d9b05924ad4c 4052 //cmdLine.serial().printf(" %s", TARGET_NAME);
whismanoid 4:d9b05924ad4c 4053 if (cmdLine.nameStr())
whismanoid 4:d9b05924ad4c 4054 {
whismanoid 4:d9b05924ad4c 4055 cmdLine.serial().printf(" [%s]", cmdLine.nameStr());
whismanoid 4:d9b05924ad4c 4056 }
whismanoid 4:d9b05924ad4c 4057 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4058 cmdLine.serial().printf(" [Button1");
whismanoid 4:d9b05924ad4c 4059 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4060 cmdLine.serial().printf("2");
whismanoid 24:032f3683cb2a 4061 #endif
whismanoid 24:032f3683cb2a 4062 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4063 cmdLine.serial().printf("3");
whismanoid 29:6a9edb6e973b 4064 #endif
whismanoid 29:6a9edb6e973b 4065 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4066 cmdLine.serial().printf("4");
whismanoid 29:6a9edb6e973b 4067 #endif
whismanoid 29:6a9edb6e973b 4068 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4069 cmdLine.serial().printf("5");
whismanoid 29:6a9edb6e973b 4070 #endif
whismanoid 29:6a9edb6e973b 4071 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4072 cmdLine.serial().printf("6");
whismanoid 29:6a9edb6e973b 4073 #endif
whismanoid 29:6a9edb6e973b 4074 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4075 cmdLine.serial().printf("7");
whismanoid 29:6a9edb6e973b 4076 #endif
whismanoid 29:6a9edb6e973b 4077 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4078 cmdLine.serial().printf("8");
whismanoid 29:6a9edb6e973b 4079 #endif
whismanoid 29:6a9edb6e973b 4080 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4081 cmdLine.serial().printf("9");
whismanoid 29:6a9edb6e973b 4082 #endif
whismanoid 29:6a9edb6e973b 4083 cmdLine.serial().printf("]");
whismanoid 29:6a9edb6e973b 4084 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 4:d9b05924ad4c 4085 #if HAS_BUTTON1_DEMO
whismanoid 4:d9b05924ad4c 4086 // print BUTTON1 status
whismanoid 4:d9b05924ad4c 4087 cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read());
whismanoid 4:d9b05924ad4c 4088 #endif
whismanoid 4:d9b05924ad4c 4089 #if HAS_BUTTON2_DEMO
whismanoid 24:032f3683cb2a 4090 // print BUTTON2 status
whismanoid 4:d9b05924ad4c 4091 cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read());
whismanoid 4:d9b05924ad4c 4092 #endif
whismanoid 24:032f3683cb2a 4093 #if HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 4094 // print BUTTON3 status
whismanoid 24:032f3683cb2a 4095 cmdLine.serial().printf("\r\n BUTTON3 = %d", button3.read());
whismanoid 24:032f3683cb2a 4096 #endif
whismanoid 4:d9b05924ad4c 4097 cmdLine.serial().printf("\r\n ? -- help");
whismanoid 4:d9b05924ad4c 4098 }
whismanoid 4:d9b05924ad4c 4099 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 4100
whismanoid 28:a9a3a9db592b 4101 //--------------------------------------------------
whismanoid 28:a9a3a9db592b 4102 #ifndef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 4103 #define USE_DATALOGGER_TRIGGER_HELP_BRIEF 1
whismanoid 28:a9a3a9db592b 4104 //~ #undef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 4105 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 4106
whismanoid 4:d9b05924ad4c 4107 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 4108 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 4109 void main_menu_help(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 4110 {
whismanoid 4:d9b05924ad4c 4111 // ? -- help
whismanoid 4:d9b05924ad4c 4112 //~ cmdLine.serial().printf("\r\nMenu:");
whismanoid 10:04022a61b527 4113 //
whismanoid 4:d9b05924ad4c 4114 cmdLine.serial().printf("\r\n # -- lines beginning with # are comments");
whismanoid 10:04022a61b527 4115 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 4116 cmdLine.serial().printf("\r\n ! -- Init");
whismanoid 10:04022a61b527 4117 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 4118 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 4119 cmdLine.serial().printf("\r\n . -- SelfTest");
whismanoid 4:d9b05924ad4c 4120 #endif // USE_SELFTEST
whismanoid 9:45f98573eb6d 4121 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 9:45f98573eb6d 4122 // CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register
whismanoid 9:45f98573eb6d 4123 cmdLine.serial().printf("\r\n * -- read core registers\r\n *regname? -- read register\r\n *regname=regvalue -- write register");
whismanoid 9:45f98573eb6d 4124 // cmdLine.serial().printf("\r\n 01 23 45 67 89 ab cd ef -- write and read raw hex codes");
whismanoid 10:04022a61b527 4125 #endif // USE_STAR_REG_READWRITE
whismanoid 10:04022a61b527 4126 //
whismanoid 10:04022a61b527 4127 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 4128 // Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_help
whismanoid 10:04022a61b527 4129 //~ cmdLine.serial().printf("\r\n > -- auxiliary UART port");
whismanoid 10:04022a61b527 4130 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 4131 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 4132 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 4133 if (cmdLine_AUXserial.nameStr())
whismanoid 10:04022a61b527 4134 {
whismanoid 10:04022a61b527 4135 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_AUXserial.nameStr());
whismanoid 10:04022a61b527 4136 }
whismanoid 10:04022a61b527 4137 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 4138 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 4139 if (cmdLine_DAPLINKserial.nameStr())
whismanoid 10:04022a61b527 4140 {
whismanoid 10:04022a61b527 4141 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_DAPLINKserial.nameStr());
whismanoid 10:04022a61b527 4142 }
whismanoid 10:04022a61b527 4143 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 4144 # if HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 4145 // WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 4146 cmdLine.serial().printf("\r\n >xyzzy -- Forward command/data 'xyzzy' to aux TX/RX");
whismanoid 10:04022a61b527 4147 cmdLine.serial().printf("\r\n >>xyzzy -- Forward 'xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 4148 cmdLine.serial().printf("\r\n >>>xyzzy -- Forward '>xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 4149 #if 0
whismanoid 10:04022a61b527 4150 cmdLine.serial().printf("\r\n >tx_wait_echo=%d -- configure TX wait for each character echo", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 4151 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 4152 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 4153 #endif
whismanoid 20:78ef670955d4 4154 #if 1 // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 4155 cmdLine.serial().printf("\r\n >baud=%d message_ms=%d rx_idle_ms=%d rx_max_count=%d rx_eot=%d",
whismanoid 20:78ef670955d4 4156 g_auxSerialCom_baud,
whismanoid 20:78ef670955d4 4157 g_auxSerialCom_message_ms,
whismanoid 20:78ef670955d4 4158 g_auxSerialCom_rx_idle_ms,
whismanoid 20:78ef670955d4 4159 g_auxSerialCom_rx_max_count,
whismanoid 20:78ef670955d4 4160 g_auxSerialCom_rx_eot);
whismanoid 20:78ef670955d4 4161 #else // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 4162 cmdLine.serial().printf("\r\n >baud=%d -- configure aux TX/RX port", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 4163 cmdLine.serial().printf("\r\n >message_ms=%d -- maximum RX message total response time", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 4164 cmdLine.serial().printf("\r\n >rx_idle_ms=%d -- maximum RX message idle time between characters", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 4165 cmdLine.serial().printf("\r\n >rx_max_count=%d -- maximum RX message total length", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 4166 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 4167 #endif // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 10:04022a61b527 4168 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 4169 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 4170 //
whismanoid 4:d9b05924ad4c 4171 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 4172 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 4173 // Datalog trigger menu
whismanoid 28:a9a3a9db592b 4174 // brief toplevel heading for datalog help L
whismanoid 28:a9a3a9db592b 4175 // L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 4176 cmdLine.serial().printf("\r\n L -- halt the datalogger; show more commands");
whismanoid 28:a9a3a9db592b 4177 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 28:a9a3a9db592b 4178 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 28:a9a3a9db592b 4179 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 28:a9a3a9db592b 4180 //
whismanoid 28:a9a3a9db592b 4181 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 4182 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 4183 //
whismanoid 39:4d285e961435 4184 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 4185 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 4186 cmdLine.serial().printf("\r\n LT count=%d base=%dms sleep=%d -- Datalog timer",
whismanoid 39:4d285e961435 4187 g_timer_interval_count,
whismanoid 39:4d285e961435 4188 g_timer_interval_msec,
whismanoid 39:4d285e961435 4189 (int)g_timer_sleepmode
whismanoid 39:4d285e961435 4190 ); // trigger_Timer
whismanoid 39:4d285e961435 4191 #else // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 4192 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 4193 #endif // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 4194 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 4195 //~ cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 4196 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 4197 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 4198 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 4199 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 4200 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 9:45f98573eb6d 4201 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 9:45f98573eb6d 4202 //
whismanoid 17:9397ea3ea7e9 4203 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 4:d9b05924ad4c 4204 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 9:45f98573eb6d 4205 //
whismanoid 17:9397ea3ea7e9 4206 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 4207 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 17:9397ea3ea7e9 4208 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 4209 //
whismanoid 9:45f98573eb6d 4210 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 4211 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 4212 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 4213 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 9:45f98573eb6d 4214 //
whismanoid 17:9397ea3ea7e9 4215 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 9:45f98573eb6d 4216 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 4217 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 4218 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 4219 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 4220 //
whismanoid 17:9397ea3ea7e9 4221 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 4222 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 17:9397ea3ea7e9 4223 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 9:45f98573eb6d 4224 //
whismanoid 9:45f98573eb6d 4225 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 4226 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 4227 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 4228 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 4229 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 9:45f98573eb6d 4230 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 9:45f98573eb6d 4231 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 9:45f98573eb6d 4232 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 9:45f98573eb6d 4233 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 9:45f98573eb6d 4234 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 9:45f98573eb6d 4235 //
whismanoid 9:45f98573eb6d 4236 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 4237 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 9:45f98573eb6d 4238 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 9:45f98573eb6d 4239 //
whismanoid 9:45f98573eb6d 4240 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 4241 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 4242 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 9:45f98573eb6d 4243 //
whismanoid 9:45f98573eb6d 4244 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 4245 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 9:45f98573eb6d 4246 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 4247 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 9:45f98573eb6d 4248 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 4249 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 9:45f98573eb6d 4250 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 4251 //
whismanoid 9:45f98573eb6d 4252 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 4253 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 9:45f98573eb6d 4254 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 9:45f98573eb6d 4255 //
whismanoid 9:45f98573eb6d 4256 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 4257 //
whismanoid 9:45f98573eb6d 4258 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 4259 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 4260 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 4261 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 4262 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 9:45f98573eb6d 4263 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4264 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 9:45f98573eb6d 4265 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4266 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4267 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 9:45f98573eb6d 4268 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4269 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 9:45f98573eb6d 4270 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4271 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 9:45f98573eb6d 4272 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4273 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4274 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 9:45f98573eb6d 4275 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4276 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 4277 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 4278 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 4279 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 4280 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 4281 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 4282 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 4283 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 4284 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 4285 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 4286 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 4287 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 4288 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 4289 //
whismanoid 4:d9b05924ad4c 4290 //cmdLine.serial().print(F("\r\n ! -- Initial Configuration"));
whismanoid 4:d9b05924ad4c 4291 //
whismanoid 4:d9b05924ad4c 4292 // % standardize diagnostic commands
whismanoid 4:d9b05924ad4c 4293 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 4294 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 4295 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 4296 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 4297 // %Ppin df=xx -- pwm output
whismanoid 4:d9b05924ad4c 4298 // %Wpin -- measure high pulsewidth input in usec
whismanoid 4:d9b05924ad4c 4299 // %wpin -- measure low pulsewidth input in usec
whismanoid 4:d9b05924ad4c 4300 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 4301 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 4302 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 4303 // %IW ADDR=? cmd=? data,data,data -- write
whismanoid 4:d9b05924ad4c 4304 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 4305 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4306 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 4307 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 4308 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 4309 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 4310 // A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 4311 //
whismanoid 23:c6c652bef4b9 4312 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 4313 #if USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4314 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 4315 // TODO: %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 4316 // TODO: future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 4317 // TODO: future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 4318 // TODO: %B1@ view command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 4319 // TODO: %B1@+ command add new row (if there is room to add) (ignore one space before command)
whismanoid 23:c6c652bef4b9 4320 // TODO: %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 4321 // TODO: %B1@-~~~ clear entire command table
whismanoid 23:c6c652bef4b9 4322 // TODO: %B1@nnn command replace row number nnn (ignore one space before command)
whismanoid 23:c6c652bef4b9 4323 // TODO: %B1@! disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 4324 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 4325 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 45:74bf1fe021e5 4326 // cmdLine.serial().printf("\r\n %%B1! trigger Button1 event; %%B1@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4327 cmdLine.serial().printf("\r\n %%B1! trigger Button1 event;");
whismanoid 45:74bf1fe021e5 4328 // print maximum index for %B1 submenu
whismanoid 45:74bf1fe021e5 4329 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4330 cmdLine.serial().printf(" %%B9@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4331 #elif HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4332 cmdLine.serial().printf(" %%B8@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4333 #elif HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4334 cmdLine.serial().printf(" %%B7@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4335 #elif HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4336 cmdLine.serial().printf(" %%B6@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4337 #elif HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4338 cmdLine.serial().printf(" %%B5@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4339 #elif HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4340 cmdLine.serial().printf(" %%B4@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4341 #elif HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4342 cmdLine.serial().printf(" %%B3@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4343 #elif HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4344 cmdLine.serial().printf(" %%B2@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4345 #elif HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4346 cmdLine.serial().printf(" %%B1@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4347 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4348
whismanoid 45:74bf1fe021e5 4349
whismanoid 23:c6c652bef4b9 4350 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4351 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 4352 #if HAS_digitalInOuts
whismanoid 4:d9b05924ad4c 4353 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 4354 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 4355 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 4356 cmdLine.serial().printf("\r\n %%Hn {pin:");
whismanoid 4:d9b05924ad4c 4357 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 4358 cmdLine.serial().printf("} -- High Output");
whismanoid 4:d9b05924ad4c 4359 cmdLine.serial().printf("\r\n %%Ln {pin:");
whismanoid 4:d9b05924ad4c 4360 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 4361 cmdLine.serial().printf("} -- Low Output");
whismanoid 4:d9b05924ad4c 4362 cmdLine.serial().printf("\r\n %%?n {pin:");
whismanoid 4:d9b05924ad4c 4363 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 4364 cmdLine.serial().printf("} -- Input");
whismanoid 4:d9b05924ad4c 4365 #endif
whismanoid 4:d9b05924ad4c 4366
whismanoid 4:d9b05924ad4c 4367 #if HAS_analogIns
whismanoid 4:d9b05924ad4c 4368 // Menu A) analogRead A0..7
whismanoid 4:d9b05924ad4c 4369 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 4370 // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0)
whismanoid 37:3f369235e5bc 4371 cmdLine.serial().printf("\r\n %%A -- analogRead");
whismanoid 37:3f369235e5bc 4372 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4373 // %A avg=%d -- help string display Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 4374 cmdLine.serial().printf("; %%A avg=%d -- average", Platform_AIN_Average_N);
whismanoid 37:3f369235e5bc 4375 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4376 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4377 // %A cal? view/export raw calibration values for all channels
whismanoid 37:3f369235e5bc 4378 cmdLine.serial().printf("; %%A cal? -- calibration");
whismanoid 34:a1993a1ee904 4379 #endif // HAS_Platform_AIN_Calibration
whismanoid 4:d9b05924ad4c 4380 #endif
whismanoid 4:d9b05924ad4c 4381
whismanoid 4:d9b05924ad4c 4382 #if HAS_SPI2_MAX541
whismanoid 4:d9b05924ad4c 4383 // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 4:d9b05924ad4c 4384 cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)");
whismanoid 4:d9b05924ad4c 4385 #endif
whismanoid 4:d9b05924ad4c 4386
whismanoid 46:469d0061df5d 4387 //--------------------------------------------------
whismanoid 46:469d0061df5d 4388 #if defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 4389 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 4390 // cmdLine.serial().printf("\r\n %%F -- flash support");
whismanoid 46:469d0061df5d 4391 # if HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4392 // flash peek memory %F peek=0x0007ff00 len=0x0100 -- hex dump
whismanoid 46:469d0061df5d 4393 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 4394 # endif // HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4395 # if HAS_FLASH_POKE
whismanoid 46:469d0061df5d 4396 // flash poke memory %F poke=0x0007ff00 0xab 0xcd 0xef 0x27 0x18 0x28 -- erase/write flash page
whismanoid 48:18647e0516f2 4397 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 4398 # endif // HAS_FLASH_POKE
whismanoid 46:469d0061df5d 4399 # if HAS_FLASH_LOAD_SAVE
whismanoid 48:18647e0516f2 4400 // cmdLine.serial().printf("\r\n %%F save=0xFF -- erase config; %%F save=0 -- save all config");
whismanoid 48:18647e0516f2 4401 // const uint32_t save_arg_01_pageErase = 0x00000001; // page erase and rewrite
whismanoid 48:18647e0516f2 4402 // const uint32_t save_arg_02_verbose = 0x00000002; // verbose diagnostic messages
whismanoid 48:18647e0516f2 4403 // const uint32_t save_arg_04_reserved = 0x00000004; // reserved
whismanoid 48:18647e0516f2 4404 // const uint32_t save_arg_08_reserved = 0x00000008; // reserved
whismanoid 48:18647e0516f2 4405 // const uint32_t save_arg_10_calibration = 0x00000010; // save board ID and calibration
whismanoid 48:18647e0516f2 4406 // const uint32_t save_arg_20_action_table = 0x00000020; // save Datalogger_action_table
whismanoid 48:18647e0516f2 4407 // const uint32_t save_arg_40_command_table = 0x00000040; // save onButtonX_command_table
whismanoid 48:18647e0516f2 4408 // const uint32_t save_arg_80_reserved = 0x00000080; // reserved
whismanoid 48:18647e0516f2 4409 cmdLine.serial().printf("\r\n %%F load=0x%x ; %%F save=0x%x -- calibration",
whismanoid 48:18647e0516f2 4410 (load_arg_default | save_arg_02_verbose), (save_arg_default | save_arg_02_verbose));
whismanoid 48:18647e0516f2 4411 //~ cmdLine.serial().printf("\r\n %%F save=0x11 -- erase; config; %%F save=0 -- save all config");
whismanoid 48:18647e0516f2 4412 //~ cmdLine.serial().printf("\r\n %%F load -- load all config");
whismanoid 46:469d0061df5d 4413 # endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 4414 #endif
whismanoid 46:469d0061df5d 4415
whismanoid 4:d9b05924ad4c 4416 #if HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4417 // TODO: support I2C HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4418 // VERIFY: I2C utility commands SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4419 // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz);
whismanoid 4:d9b05924ad4c 4420 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 4421 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 4422 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 4423 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 4:d9b05924ad4c 4424 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 4425 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4426 //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope
whismanoid 4:d9b05924ad4c 4427 cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 4:d9b05924ad4c 4428 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 4:d9b05924ad4c 4429 (g_I2C_SCL_Hz / 1000.));
whismanoid 4:d9b05924ad4c 4430 cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read",
whismanoid 4:d9b05924ad4c 4431 g_I2C_deviceAddress7);
whismanoid 4:d9b05924ad4c 4432 //
whismanoid 4:d9b05924ad4c 4433 #if SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4434 // Menu ^ cmd=?) i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4435 cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data");
whismanoid 4:d9b05924ad4c 4436 // test low-level I2C i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4437 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4438 //cmdLine.serial().printf(" H) Hunt for attached I2C devices");
whismanoid 4:d9b05924ad4c 4439 cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices");
whismanoid 4:d9b05924ad4c 4440 // cmdLine.serial().printf(" s) search i2c address");
whismanoid 4:d9b05924ad4c 4441 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4442
whismanoid 4:d9b05924ad4c 4443 #if HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 4444 // TODO: support SPI HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 4445 // SPI test command S (mosiData)+
whismanoid 4:d9b05924ad4c 4446 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 4447 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 4448 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 4449 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 4450 // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 4:d9b05924ad4c 4451 // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 4:d9b05924ad4c 4452 // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 4:d9b05924ad4c 4453 // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 4:d9b05924ad4c 4454 // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 4:d9b05924ad4c 4455 // mode | POL PHA
whismanoid 4:d9b05924ad4c 4456 // -----+--------
whismanoid 4:d9b05924ad4c 4457 // 0 | 0 0
whismanoid 4:d9b05924ad4c 4458 // 1 | 0 1
whismanoid 4:d9b05924ad4c 4459 // 2 | 1 0
whismanoid 4:d9b05924ad4c 4460 // 3 | 1 1
whismanoid 4:d9b05924ad4c 4461 //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0");
whismanoid 4:d9b05924ad4c 4462 // 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 4463 cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config",
whismanoid 4:d9b05924ad4c 4464 g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.),
whismanoid 4:d9b05924ad4c 4465 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 4:d9b05924ad4c 4466 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0));
whismanoid 4:d9b05924ad4c 4467 cmdLine.serial().printf("\r\n %%SD -- SPI diagnostic messages ");
whismanoid 4:d9b05924ad4c 4468 if (g_MAX11410_device.onSPIprint) {
whismanoid 4:d9b05924ad4c 4469 cmdLine.serial().printf("hide");
whismanoid 4:d9b05924ad4c 4470 }
whismanoid 4:d9b05924ad4c 4471 else {
whismanoid 4:d9b05924ad4c 4472 cmdLine.serial().printf("show");
whismanoid 4:d9b05924ad4c 4473 }
whismanoid 4:d9b05924ad4c 4474 cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes");
whismanoid 4:d9b05924ad4c 4475 // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0
whismanoid 4:d9b05924ad4c 4476 #endif // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 4477 //
whismanoid 4:d9b05924ad4c 4478 // Application-specific commands (help text) here
whismanoid 4:d9b05924ad4c 4479 //
whismanoid 4:d9b05924ad4c 4480 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 4481 cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 4482 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 4483 //
whismanoid 4:d9b05924ad4c 4484
whismanoid 4:d9b05924ad4c 4485 //~ extern void MAX11410_menu_help(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp\n
whismanoid 4:d9b05924ad4c 4486 //~ MAX11410_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 4487 }
whismanoid 4:d9b05924ad4c 4488 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 4489
whismanoid 4:d9b05924ad4c 4490 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 15:37c83ec50ea0 4491
whismanoid 15:37c83ec50ea0 4492 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 4493 void pinsMonitor_submenu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 15:37c83ec50ea0 4494 {
whismanoid 15:37c83ec50ea0 4495 // % diagnostic commands submenu
whismanoid 15:37c83ec50ea0 4496 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 4497 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 4498 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 4499 // %A %Apin -- analog input
whismanoid 15:37c83ec50ea0 4500 // %Ppin df=xx -- pwm output
whismanoid 15:37c83ec50ea0 4501 // %Wpin -- measure high pulsewidth input in usec
whismanoid 15:37c83ec50ea0 4502 // %wpin -- measure low pulsewidth input in usec
whismanoid 15:37c83ec50ea0 4503 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 4504 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 4505 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 4506 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 4507 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 4508 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 4509 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 4510 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 4511 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 4512 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 4513 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 4514 //
whismanoid 15:37c83ec50ea0 4515 char strPinIndex[3];
whismanoid 15:37c83ec50ea0 4516 strPinIndex[0] = cmdLine[2];
whismanoid 15:37c83ec50ea0 4517 strPinIndex[1] = cmdLine[3];
whismanoid 15:37c83ec50ea0 4518 strPinIndex[2] = '\0';
whismanoid 15:37c83ec50ea0 4519 int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 15:37c83ec50ea0 4520 //cmdLine.serial().printf(" pinIndex=%d ", pinIndex);
whismanoid 15:37c83ec50ea0 4521 //
whismanoid 15:37c83ec50ea0 4522 // get next character
whismanoid 15:37c83ec50ea0 4523 switch (cmdLine[1])
whismanoid 15:37c83ec50ea0 4524 {
whismanoid 23:c6c652bef4b9 4525 //--------------------------------------------------
whismanoid 46:469d0061df5d 4526 #if defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 4527 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 4528 case 'F': case 'f':
whismanoid 46:469d0061df5d 4529 {
whismanoid 46:469d0061df5d 4530 # if HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4531 // Limit the ranges where memory write operation will be allowed
whismanoid 46:469d0061df5d 4532 // FLASH (rx) : ORIGIN = 0x00010000, LENGTH = 0x00070000
whismanoid 46:469d0061df5d 4533 //~ const uint32_t poke_flash_min = 0x00010000;
whismanoid 46:469d0061df5d 4534 //~ const uint32_t poke_flash_max = 0x0007FFFF;
whismanoid 46:469d0061df5d 4535 // RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00028000
whismanoid 46:469d0061df5d 4536 //~ const uint32_t poke_ram_min = 0x20000000;
whismanoid 46:469d0061df5d 4537 //~ const uint32_t poke_ram_max = 0x20027FFF;
whismanoid 46:469d0061df5d 4538 //
whismanoid 46:469d0061df5d 4539 // flash peek memory %F peek=0x0007ff00 len=0x0100 -- hex dump
whismanoid 46:469d0061df5d 4540 // get "len" keyword, default 1
whismanoid 46:469d0061df5d 4541 uint32_t peek_len = 1;
whismanoid 46:469d0061df5d 4542 if (cmdLine.parse_uint32_hex("len", peek_len))
whismanoid 46:469d0061df5d 4543 {
whismanoid 46:469d0061df5d 4544 }
whismanoid 46:469d0061df5d 4545 // get "peek" keyword, do peek operation if keyword is present
whismanoid 46:469d0061df5d 4546 uint32_t peek_addr = 0x00010000;
whismanoid 46:469d0061df5d 4547 if (cmdLine.parse_uint32_hex("peek", peek_addr))
whismanoid 46:469d0061df5d 4548 {
whismanoid 46:469d0061df5d 4549 // #312 hex dump memory from peek_addr length peek_len
whismanoid 46:469d0061df5d 4550 peek_addr = peek_addr &~ 0x00000003; // 32-bit word align
whismanoid 46:469d0061df5d 4551 //
whismanoid 46:469d0061df5d 4552 // scan poke_access_list[] for peek_addr
whismanoid 46:469d0061df5d 4553 int poke_access_list_index = search_poke_access_list(peek_addr);
whismanoid 46:469d0061df5d 4554 // post: poke_access_list[poke_access_list_index].addr_min is lowest address of range
whismanoid 46:469d0061df5d 4555 // post: poke_access_list[poke_access_list_index].addr_max is highest address of range
whismanoid 46:469d0061df5d 4556 // post: poke_access_list[poke_access_list_index].name
whismanoid 46:469d0061df5d 4557 // 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 4558 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 46:469d0061df5d 4559 poke_access_list_index,
whismanoid 46:469d0061df5d 4560 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 4561 poke_access_list[poke_access_list_index].addr_min,
whismanoid 46:469d0061df5d 4562 poke_access_list[poke_access_list_index].addr_max,
whismanoid 46:469d0061df5d 4563 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 46:469d0061df5d 4564 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x04)
whismanoid 46:469d0061df5d 4565 {
whismanoid 46:469d0061df5d 4566 cmdLine.serial().printf("flashPoke ");
whismanoid 46:469d0061df5d 4567 }
whismanoid 46:469d0061df5d 4568 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x02)
whismanoid 46:469d0061df5d 4569 {
whismanoid 46:469d0061df5d 4570 cmdLine.serial().printf("ramPoke ");
whismanoid 46:469d0061df5d 4571 }
whismanoid 46:469d0061df5d 4572 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x01)
whismanoid 46:469d0061df5d 4573 {
whismanoid 46:469d0061df5d 4574 cmdLine.serial().printf("read ");
whismanoid 46:469d0061df5d 4575 }
whismanoid 46:469d0061df5d 4576 //
whismanoid 46:469d0061df5d 4577 //~ cmdLine.serial().printf("\r\n0x%8.8lx: ", peek_addr);
whismanoid 46:469d0061df5d 4578 if ((peek_addr & 0x0F) != 0)
whismanoid 46:469d0061df5d 4579 {
whismanoid 46:469d0061df5d 4580 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4581 }
whismanoid 46:469d0061df5d 4582 while (peek_len > 0)
whismanoid 46:469d0061df5d 4583 {
whismanoid 46:469d0061df5d 4584 if ((peek_addr & 0x0F) == 0)
whismanoid 46:469d0061df5d 4585 {
whismanoid 46:469d0061df5d 4586 poke_access_list_index = search_poke_access_list(peek_addr);
whismanoid 46:469d0061df5d 4587 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4588 }
whismanoid 46:469d0061df5d 4589 if (poke_access_list[poke_access_list_index].can_flash_write_read & 1)
whismanoid 46:469d0061df5d 4590 {
whismanoid 46:469d0061df5d 4591 // read memory by using peek_addr as a uint32_t pointer
whismanoid 46:469d0061df5d 4592 cmdLine.serial().printf("0x%8.8lx ", *((uint32_t*)peek_addr));
whismanoid 46:469d0061df5d 4593 }
whismanoid 46:469d0061df5d 4594 else
whismanoid 46:469d0061df5d 4595 {
whismanoid 46:469d0061df5d 4596 // read operation is forbidden in this address range
whismanoid 46:469d0061df5d 4597 cmdLine.serial().printf("__________ ");
whismanoid 46:469d0061df5d 4598 }
whismanoid 46:469d0061df5d 4599 peek_addr += 4;
whismanoid 46:469d0061df5d 4600 peek_len--;
whismanoid 46:469d0061df5d 4601 }
whismanoid 46:469d0061df5d 4602 }
whismanoid 46:469d0061df5d 4603 # endif // HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4604 # if HAS_FLASH_POKE
whismanoid 46:469d0061df5d 4605 // flash poke memory %F poke=0x0007ff00 0xab 0xcd 0xef 0x27 0x18 0x28 -- erase/write flash page
whismanoid 46:469d0061df5d 4606 // get "poke" keyword, do poke operation if keyword is present
whismanoid 46:469d0061df5d 4607 uint32_t poke_addr = 0x20000000;
whismanoid 46:469d0061df5d 4608 if (cmdLine.parse_uint32_hex("poke", poke_addr))
whismanoid 46:469d0061df5d 4609 {
whismanoid 46:469d0061df5d 4610 size_t byteCount = 0;
whismanoid 46:469d0061df5d 4611 uint8_t pokeDataBuf[16];
whismanoid 46:469d0061df5d 4612 // get list of bytes after processing keywords
whismanoid 46:469d0061df5d 4613 // bool parse_byteCount_byteList_hex(size_t& byteCount, char *mosiDataBuf, size_t mosiDataBufSize);
whismanoid 46:469d0061df5d 4614 if (cmdLine.parse_byteCount_byteList_hex(byteCount, ((char *)pokeDataBuf), sizeof(pokeDataBuf)))
whismanoid 46:469d0061df5d 4615 {
whismanoid 46:469d0061df5d 4616 // #312 write memory at poke_addr
whismanoid 46:469d0061df5d 4617 poke_addr = poke_addr &~ 0x00000003; // 32-bit word align
whismanoid 46:469d0061df5d 4618 //
whismanoid 46:469d0061df5d 4619 // scan poke_access_list[] for poke_addr
whismanoid 46:469d0061df5d 4620 int poke_access_list_index = search_poke_access_list(poke_addr);
whismanoid 46:469d0061df5d 4621 // post: poke_access_list[poke_access_list_index].addr_min is lowest address of range
whismanoid 46:469d0061df5d 4622 // post: poke_access_list[poke_access_list_index].addr_max is highest address of range
whismanoid 46:469d0061df5d 4623 // post: poke_access_list[poke_access_list_index].name
whismanoid 46:469d0061df5d 4624 // 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 4625 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 46:469d0061df5d 4626 poke_access_list_index,
whismanoid 46:469d0061df5d 4627 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 4628 poke_access_list[poke_access_list_index].addr_min,
whismanoid 46:469d0061df5d 4629 poke_access_list[poke_access_list_index].addr_max,
whismanoid 46:469d0061df5d 4630 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 46:469d0061df5d 4631 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x04)
whismanoid 46:469d0061df5d 4632 {
whismanoid 46:469d0061df5d 4633 cmdLine.serial().printf("flashPoke ");
whismanoid 46:469d0061df5d 4634 }
whismanoid 46:469d0061df5d 4635 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x02)
whismanoid 46:469d0061df5d 4636 {
whismanoid 46:469d0061df5d 4637 cmdLine.serial().printf("ramPoke ");
whismanoid 46:469d0061df5d 4638 }
whismanoid 46:469d0061df5d 4639 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x01)
whismanoid 46:469d0061df5d 4640 {
whismanoid 46:469d0061df5d 4641 cmdLine.serial().printf("read ");
whismanoid 46:469d0061df5d 4642 }
whismanoid 46:469d0061df5d 4643 //
whismanoid 46:469d0061df5d 4644 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x0004)
whismanoid 46:469d0061df5d 4645 {
whismanoid 46:469d0061df5d 4646 //------------------------------
whismanoid 46:469d0061df5d 4647 // mbed interface to on-chip Flash
whismanoid 46:469d0061df5d 4648 // FlashIAP flash;
whismanoid 46:469d0061df5d 4649 // Maxim MAX32625 flash interface flc.h not .\mbed-os\drivers\FlashIAP.h
whismanoid 46:469d0061df5d 4650 // .\mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\mxc\flc.h
whismanoid 46:469d0061df5d 4651 // .\mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\mxc\flc.c
whismanoid 46:469d0061df5d 4652 //
whismanoid 46:469d0061df5d 4653 // MAX32625IWY+ Flash 512Kbyte in 64 pages of 8Kbyte per page
whismanoid 46:469d0061df5d 4654 static uint8_t pageBuf[8192];
whismanoid 46:469d0061df5d 4655 uint32_t pageBuf_addr = poke_addr &~ 0x1FFF; // 32-bit word align, 8Kbyte page boundary
whismanoid 46:469d0061df5d 4656 //
whismanoid 46:469d0061df5d 4657 // poke_addr is in FLASH address range, there's more steps
whismanoid 46:469d0061df5d 4658 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: flashPoke ...",
whismanoid 46:469d0061df5d 4659 poke_access_list[poke_access_list_index].name, poke_addr);
whismanoid 46:469d0061df5d 4660 // initialize flash memory interface
whismanoid 46:469d0061df5d 4661 // FlashIAP: FlashIAP flash; flash.init();
whismanoid 46:469d0061df5d 4662 // int FLC_Init(void);
whismanoid 46:469d0061df5d 4663 // returns E_NO_ERROR or E_BUSY or E_UNKNOWN
whismanoid 46:469d0061df5d 4664 cmdLine.serial().printf("FLC_Init ");
whismanoid 46:469d0061df5d 4665 if (FLC_Init() != E_NO_ERROR)
whismanoid 46:469d0061df5d 4666 {
whismanoid 46:469d0061df5d 4667 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4668 break; // can't perform the command
whismanoid 46:469d0061df5d 4669 }
whismanoid 46:469d0061df5d 4670 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4671 //
whismanoid 46:469d0061df5d 4672 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: start of 8KByte page containing 0x%8.8lx...",
whismanoid 46:469d0061df5d 4673 poke_access_list[poke_access_list_index].name, pageBuf_addr, poke_addr);
whismanoid 46:469d0061df5d 4674 //
whismanoid 46:469d0061df5d 4675 // page read, update buffer from command line bytes, page erase, page write
whismanoid 46:469d0061df5d 4676 cmdLine.serial().printf("\r\nPgBuf 0x%8.8lx: copy page buffer, len=0x%x words = 0x%x bytes...",
whismanoid 46:469d0061df5d 4677 pageBuf_addr, sizeof(pageBuf)/4, sizeof(pageBuf));
whismanoid 46:469d0061df5d 4678 // memcpy(uint32_t *out, uint32_t *in, unsigned int count)
whismanoid 46:469d0061df5d 4679 memcpy(&pageBuf[0], (uint32_t*)pageBuf_addr, sizeof(pageBuf));
whismanoid 46:469d0061df5d 4680 //
whismanoid 46:469d0061df5d 4681 cmdLine.serial().printf("\r\nPgBuf 0x%8.8lx: udpate page buffer ...", poke_addr);
whismanoid 46:469d0061df5d 4682 // update buffer from command line bytes using my cmdline lib
whismanoid 46:469d0061df5d 4683 // ignore pokeDataBuf[0], its 0x0F because this is command F. :(
whismanoid 46:469d0061df5d 4684 for (size_t byteIndex = 1; byteIndex < byteCount; byteIndex += 4)
whismanoid 46:469d0061df5d 4685 {
whismanoid 46:469d0061df5d 4686 // How to handle big-endian vs little-endian?
whismanoid 46:469d0061df5d 4687 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 0] = pokeDataBuf[byteIndex + 3];
whismanoid 46:469d0061df5d 4688 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 1] = pokeDataBuf[byteIndex + 2];
whismanoid 46:469d0061df5d 4689 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 2] = pokeDataBuf[byteIndex + 1];
whismanoid 46:469d0061df5d 4690 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 3] = pokeDataBuf[byteIndex + 0];
whismanoid 46:469d0061df5d 4691 // seems 0x12 0x34 0x56 0x78 becomes 0x78563412
whismanoid 46:469d0061df5d 4692 uint32_t wordbuf = 0
whismanoid 46:469d0061df5d 4693 | ((uint32_t)pokeDataBuf[byteIndex + 0] << 24)
whismanoid 46:469d0061df5d 4694 | ((uint32_t)pokeDataBuf[byteIndex + 1] << 16)
whismanoid 46:469d0061df5d 4695 | ((uint32_t)pokeDataBuf[byteIndex + 2] << 8)
whismanoid 46:469d0061df5d 4696 | ((uint32_t)pokeDataBuf[byteIndex + 3] << 0)
whismanoid 46:469d0061df5d 4697 ;
whismanoid 46:469d0061df5d 4698 cmdLine.serial().printf("\r\nPgBuf[0x%8.8lx] = FLASH 0x%8.8lx: ",
whismanoid 46:469d0061df5d 4699 (poke_addr - pageBuf_addr + byteIndex-1), (poke_addr + byteIndex-1));
whismanoid 46:469d0061df5d 4700 cmdLine.serial().printf("0x%8.8lx ", wordbuf);
whismanoid 46:469d0061df5d 4701 // poke_addr += 4;
whismanoid 46:469d0061df5d 4702 }
whismanoid 46:469d0061df5d 4703 //
whismanoid 46:469d0061df5d 4704 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: erase page ...",
whismanoid 46:469d0061df5d 4705 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 4706 // page erase using flash.erase(addr, flash.get_sector_size(addr));
whismanoid 46:469d0061df5d 4707 // int FLC_PageErase(uint32_t address, MXC_V_FLC_ERASE_CODE_PAGE_ERASE, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 4708 // @param address Address of the page to be erased.
whismanoid 46:469d0061df5d 4709 // @param erase_code Flash erase code; defined as
whismanoid 46:469d0061df5d 4710 // #MXC_V_FLC_ERASE_CODE_PAGE_ERASE for page erase
whismanoid 46:469d0061df5d 4711 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 4712 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 4713 if (FLC_PageErase(pageBuf_addr, MXC_V_FLC_ERASE_CODE_PAGE_ERASE,
whismanoid 46:469d0061df5d 4714 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 4715 {
whismanoid 46:469d0061df5d 4716 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4717 break; // can't perform the command
whismanoid 46:469d0061df5d 4718 }
whismanoid 46:469d0061df5d 4719 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4720 //
whismanoid 46:469d0061df5d 4721 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: write page buffer ...",
whismanoid 46:469d0061df5d 4722 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 4723 // page write using flash.program(page_buffer, addr, page_size);
whismanoid 46:469d0061df5d 4724 // int FLC_Write(uint32_t address, const void *data, uint32_t length, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 4725 // @param address Start address for desired write. @note This address
whismanoid 46:469d0061df5d 4726 // must be 32-bit word aligned
whismanoid 46:469d0061df5d 4727 // @param data A pointer to the buffer containing the data to write.
whismanoid 46:469d0061df5d 4728 // @param length Size of the data to write in bytes. @note The length
whismanoid 46:469d0061df5d 4729 // must be in 32-bit multiples.
whismanoid 46:469d0061df5d 4730 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 4731 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 4732 if (FLC_Write(pageBuf_addr, (uint32_t*)&pageBuf[0], sizeof(pageBuf),
whismanoid 46:469d0061df5d 4733 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 4734 {
whismanoid 46:469d0061df5d 4735 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4736 break; // can't perform the command
whismanoid 46:469d0061df5d 4737 }
whismanoid 46:469d0061df5d 4738 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4739 //
whismanoid 46:469d0061df5d 4740 // FlashIAP: close flash memory interface flash.deinit();
whismanoid 46:469d0061df5d 4741 //
whismanoid 46:469d0061df5d 4742 // verify buffer matches flash page, or fail
whismanoid 46:469d0061df5d 4743 // for verification, perform %F peek=(poke_addr) len=(from byteCount)
whismanoid 46:469d0061df5d 4744 // hex dump memory from peek_addr length peek_len
whismanoid 46:469d0061df5d 4745 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: verify page buffer ...",
whismanoid 46:469d0061df5d 4746 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 4747 int verify_failed = 0;
whismanoid 46:469d0061df5d 4748 peek_addr = poke_addr;
whismanoid 46:469d0061df5d 4749 peek_len = (byteCount - 1)/4;
whismanoid 46:469d0061df5d 4750 //~ cmdLine.serial().printf("\r\n0x%8.8lx: ", peek_addr);
whismanoid 46:469d0061df5d 4751 if ((peek_addr & 0x0F) != 0)
whismanoid 46:469d0061df5d 4752 {
whismanoid 46:469d0061df5d 4753 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4754 }
whismanoid 46:469d0061df5d 4755 while (peek_len > 0)
whismanoid 46:469d0061df5d 4756 {
whismanoid 46:469d0061df5d 4757 if ((peek_addr & 0x0F) == 0)
whismanoid 46:469d0061df5d 4758 {
whismanoid 46:469d0061df5d 4759 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4760 }
whismanoid 46:469d0061df5d 4761 // read memory by using peek_addr as a uint32_t pointer
whismanoid 46:469d0061df5d 4762 // cmdLine.serial().printf("0x%8.8lx ", *((uint32_t*)peek_addr));
whismanoid 46:469d0061df5d 4763 // #312 %F peek verify, report fail if mismatch page buffer
whismanoid 46:469d0061df5d 4764 uint32_t expect_data = 0
whismanoid 46:469d0061df5d 4765 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 3] << 24)
whismanoid 46:469d0061df5d 4766 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 2] << 16)
whismanoid 46:469d0061df5d 4767 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 1] << 8)
whismanoid 46:469d0061df5d 4768 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 0] << 0)
whismanoid 46:469d0061df5d 4769 ;
whismanoid 46:469d0061df5d 4770 uint32_t actual_data = *((uint32_t*)peek_addr);
whismanoid 46:469d0061df5d 4771 if (actual_data == expect_data)
whismanoid 46:469d0061df5d 4772 {
whismanoid 46:469d0061df5d 4773 // this word matches
whismanoid 46:469d0061df5d 4774 cmdLine.serial().printf("=0x%8.8lx ", actual_data);
whismanoid 46:469d0061df5d 4775 }
whismanoid 46:469d0061df5d 4776 else
whismanoid 46:469d0061df5d 4777 {
whismanoid 46:469d0061df5d 4778 // mismatch, verification failed
whismanoid 46:469d0061df5d 4779 cmdLine.serial().printf("#0x%8.8lx(expected 0x%8.8lx)\r\n%5s 0x%8.8lx: ",
whismanoid 46:469d0061df5d 4780 actual_data, expect_data,
whismanoid 46:469d0061df5d 4781 poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4782 verify_failed++;
whismanoid 46:469d0061df5d 4783 }
whismanoid 46:469d0061df5d 4784 //
whismanoid 46:469d0061df5d 4785 peek_addr += 4;
whismanoid 46:469d0061df5d 4786 peek_len--;
whismanoid 46:469d0061df5d 4787 }
whismanoid 46:469d0061df5d 4788 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: verify page buffer ",
whismanoid 46:469d0061df5d 4789 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 4790 if (verify_failed)
whismanoid 46:469d0061df5d 4791 {
whismanoid 46:469d0061df5d 4792 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4793 break; // can't perform the command
whismanoid 46:469d0061df5d 4794 }
whismanoid 46:469d0061df5d 4795 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4796 //
whismanoid 46:469d0061df5d 4797 } // end of flashPoke operation
whismanoid 46:469d0061df5d 4798 else if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x0002)
whismanoid 46:469d0061df5d 4799 {
whismanoid 46:469d0061df5d 4800 // poke_addr is in RAM address range, write directly
whismanoid 46:469d0061df5d 4801 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ramPoke ", poke_access_list[poke_access_list_index].name, poke_addr);
whismanoid 46:469d0061df5d 4802 // ignore pokeDataBuf[0], its 0x0F because this is command F. :(
whismanoid 46:469d0061df5d 4803 for (size_t byteIndex = 1; byteIndex < byteCount; byteIndex += 4)
whismanoid 46:469d0061df5d 4804 {
whismanoid 46:469d0061df5d 4805 // How to handle big-endian vs little-endian?
whismanoid 46:469d0061df5d 4806 // seems 0x12 0x34 0x56 0x78 becomes 0x78563412
whismanoid 46:469d0061df5d 4807 poke_addr += 4;
whismanoid 46:469d0061df5d 4808 uint32_t wordbuf = 0
whismanoid 46:469d0061df5d 4809 | ((uint32_t)pokeDataBuf[byteIndex + 0] << 24)
whismanoid 46:469d0061df5d 4810 | ((uint32_t)pokeDataBuf[byteIndex + 1] << 16)
whismanoid 46:469d0061df5d 4811 | ((uint32_t)pokeDataBuf[byteIndex + 2] << 8)
whismanoid 46:469d0061df5d 4812 | ((uint32_t)pokeDataBuf[byteIndex + 3] << 0)
whismanoid 46:469d0061df5d 4813 ;
whismanoid 46:469d0061df5d 4814 cmdLine.serial().printf("0x%8.8lx ", wordbuf);
whismanoid 46:469d0061df5d 4815 //
whismanoid 46:469d0061df5d 4816 // write RAM by using poke_addr as a uint32_t pointer
whismanoid 46:469d0061df5d 4817 *((uint32_t*)poke_addr) = wordbuf;
whismanoid 46:469d0061df5d 4818 //
whismanoid 46:469d0061df5d 4819 // verify?
whismanoid 46:469d0061df5d 4820 if (*((uint32_t*)poke_addr) == wordbuf)
whismanoid 46:469d0061df5d 4821 {
whismanoid 46:469d0061df5d 4822 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4823 }
whismanoid 46:469d0061df5d 4824 else
whismanoid 46:469d0061df5d 4825 {
whismanoid 46:469d0061df5d 4826 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4827 }
whismanoid 46:469d0061df5d 4828 }
whismanoid 46:469d0061df5d 4829 } // end of ramPoke operation
whismanoid 46:469d0061df5d 4830 else
whismanoid 46:469d0061df5d 4831 {
whismanoid 46:469d0061df5d 4832 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 4833 }
whismanoid 46:469d0061df5d 4834 }
whismanoid 46:469d0061df5d 4835 }
whismanoid 46:469d0061df5d 4836 # endif // HAS_FLASH_POKE
whismanoid 46:469d0061df5d 4837 # if HAS_FLASH_LOAD_SAVE
whismanoid 48:18647e0516f2 4838 uint32_t save_arg = save_arg_default;
whismanoid 46:469d0061df5d 4839 if (cmdLine.parse_uint32_hex("save", save_arg))
whismanoid 46:469d0061df5d 4840 {
whismanoid 46:469d0061df5d 4841 Save_flash_page_configuration_back_up(cmdLine, save_arg);
whismanoid 46:469d0061df5d 4842 }
whismanoid 48:18647e0516f2 4843 uint32_t load_arg = load_arg_default;
whismanoid 46:469d0061df5d 4844 if (cmdLine.parse_uint32_hex("load", load_arg))
whismanoid 46:469d0061df5d 4845 {
whismanoid 46:469d0061df5d 4846 Load_flash_page_configuration_back_up(cmdLine, load_arg);
whismanoid 46:469d0061df5d 4847 }
whismanoid 46:469d0061df5d 4848 # endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 4849 }
whismanoid 46:469d0061df5d 4850 break;
whismanoid 46:469d0061df5d 4851 #endif // defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 4852 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 4853 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 4854 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 4855 case 'B': case 'b':
whismanoid 23:c6c652bef4b9 4856 {
whismanoid 24:032f3683cb2a 4857 int command_table_button_index = 1;
whismanoid 23:c6c652bef4b9 4858 // %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 4859 // future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 4860 // future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 4861 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 4862 // cmdLine[2] == '1' selects onButton1_command_table
whismanoid 23:c6c652bef4b9 4863 char** command_table = onButton1_command_table;
whismanoid 23:c6c652bef4b9 4864 #endif
whismanoid 24:032f3683cb2a 4865 switch(cmdLine[2])
whismanoid 24:032f3683cb2a 4866 {
whismanoid 24:032f3683cb2a 4867 default:
whismanoid 24:032f3683cb2a 4868 case '1': case 'A': case 'a': case '!':
whismanoid 24:032f3683cb2a 4869 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4870 command_table_button_index = 1;
whismanoid 24:032f3683cb2a 4871 command_table = onButton1_command_table;
whismanoid 24:032f3683cb2a 4872 #endif
whismanoid 24:032f3683cb2a 4873 break;
whismanoid 24:032f3683cb2a 4874 case '2': case 'B': case 'b': case '@':
whismanoid 23:c6c652bef4b9 4875 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4876 command_table_button_index = 2;
whismanoid 24:032f3683cb2a 4877 command_table = onButton2_command_table;
whismanoid 24:032f3683cb2a 4878 #endif
whismanoid 24:032f3683cb2a 4879 break;
whismanoid 24:032f3683cb2a 4880 case '3': case 'C': case 'c': case '#':
whismanoid 23:c6c652bef4b9 4881 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4882 command_table_button_index = 3;
whismanoid 24:032f3683cb2a 4883 command_table = onButton3_command_table;
whismanoid 24:032f3683cb2a 4884 #endif
whismanoid 24:032f3683cb2a 4885 break;
whismanoid 29:6a9edb6e973b 4886 case '4':
whismanoid 29:6a9edb6e973b 4887 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4888 command_table_button_index = 4;
whismanoid 29:6a9edb6e973b 4889 command_table = onButton4_command_table;
whismanoid 29:6a9edb6e973b 4890 #endif
whismanoid 29:6a9edb6e973b 4891 break;
whismanoid 29:6a9edb6e973b 4892 case '5':
whismanoid 29:6a9edb6e973b 4893 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4894 command_table_button_index = 5;
whismanoid 29:6a9edb6e973b 4895 command_table = onButton5_command_table;
whismanoid 29:6a9edb6e973b 4896 #endif
whismanoid 29:6a9edb6e973b 4897 break;
whismanoid 29:6a9edb6e973b 4898 case '6':
whismanoid 29:6a9edb6e973b 4899 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4900 command_table_button_index = 6;
whismanoid 29:6a9edb6e973b 4901 command_table = onButton6_command_table;
whismanoid 29:6a9edb6e973b 4902 #endif
whismanoid 29:6a9edb6e973b 4903 break;
whismanoid 29:6a9edb6e973b 4904 case '7':
whismanoid 29:6a9edb6e973b 4905 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4906 command_table_button_index = 7;
whismanoid 29:6a9edb6e973b 4907 command_table = onButton7_command_table;
whismanoid 29:6a9edb6e973b 4908 #endif
whismanoid 29:6a9edb6e973b 4909 break;
whismanoid 29:6a9edb6e973b 4910 case '8':
whismanoid 29:6a9edb6e973b 4911 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4912 command_table_button_index = 8;
whismanoid 29:6a9edb6e973b 4913 command_table = onButton8_command_table;
whismanoid 29:6a9edb6e973b 4914 #endif
whismanoid 29:6a9edb6e973b 4915 break;
whismanoid 29:6a9edb6e973b 4916 case '9':
whismanoid 29:6a9edb6e973b 4917 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4918 command_table_button_index = 9;
whismanoid 29:6a9edb6e973b 4919 command_table = onButton9_command_table;
whismanoid 29:6a9edb6e973b 4920 #endif
whismanoid 29:6a9edb6e973b 4921 break;
whismanoid 24:032f3683cb2a 4922 }
whismanoid 24:032f3683cb2a 4923 //
whismanoid 23:c6c652bef4b9 4924 switch(cmdLine[3])
whismanoid 23:c6c652bef4b9 4925 {
whismanoid 23:c6c652bef4b9 4926 case '@':
whismanoid 23:c6c652bef4b9 4927 {
whismanoid 23:c6c652bef4b9 4928 // %B1@ view/edit command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 4929 int editRowIndex = 0;
whismanoid 23:c6c652bef4b9 4930 int command_table_row_count = 0;
whismanoid 23:c6c652bef4b9 4931 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 4932 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 4933 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 4934 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 4935 }
whismanoid 24:032f3683cb2a 4936 //
whismanoid 24:032f3683cb2a 4937 // ignore extra spaces before the command
whismanoid 24:032f3683cb2a 4938 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 24:032f3683cb2a 4939 int argIndex;
whismanoid 24:032f3683cb2a 4940 for (argIndex = 5; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 4941 {
whismanoid 24:032f3683cb2a 4942 if (cmdLine[argIndex] == ' ') break;
whismanoid 24:032f3683cb2a 4943 }
whismanoid 24:032f3683cb2a 4944 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 4945 {
whismanoid 24:032f3683cb2a 4946 if (cmdLine[argIndex] != ' ') break;
whismanoid 23:c6c652bef4b9 4947 }
whismanoid 23:c6c652bef4b9 4948 //
whismanoid 23:c6c652bef4b9 4949 // Edit the contents of command_table
whismanoid 23:c6c652bef4b9 4950 switch (cmdLine[4]) // %B1@... -- Edit the contents of command_table
whismanoid 23:c6c652bef4b9 4951 {
whismanoid 23:c6c652bef4b9 4952 case '0': case '1': case '2': case '3': case '4':
whismanoid 23:c6c652bef4b9 4953 case '5': case '6': case '7': case '8': case '9':
whismanoid 24:032f3683cb2a 4954 // %B1@nnn command replace row number nnn
whismanoid 23:c6c652bef4b9 4955 // edit row data
whismanoid 33:70a28cfe9e01 4956 // get row number to edit from cmdLine[4]
whismanoid 33:70a28cfe9e01 4957 editRowIndex = atoi(cmdLine.str()+4);
whismanoid 23:c6c652bef4b9 4958 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4959 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 4960 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 28:a9a3a9db592b 4961 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 4962 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 4963 cmdLine.serial().printf("\r\n cannot replace row %d with nothing",
whismanoid 28:a9a3a9db592b 4964 editRowIndex);
whismanoid 28:a9a3a9db592b 4965 }
whismanoid 28:a9a3a9db592b 4966 else
whismanoid 28:a9a3a9db592b 4967 {
whismanoid 28:a9a3a9db592b 4968 // update row
whismanoid 28:a9a3a9db592b 4969 cmdLine.serial().printf("\r\n replace row %d with \"%s\"",
whismanoid 28:a9a3a9db592b 4970 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 4971 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4972 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 4973 }
whismanoid 24:032f3683cb2a 4974 }
whismanoid 33:70a28cfe9e01 4975 } // end if (command_table_row_count > 0)
whismanoid 33:70a28cfe9e01 4976 if ((editRowIndex == command_table_row_count) && (command_table_row_count < COMMAND_TABLE_ROW_MAX)) {
whismanoid 33:70a28cfe9e01 4977 // %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 4978 //
whismanoid 33:70a28cfe9e01 4979 command_table_row_count++;
whismanoid 33:70a28cfe9e01 4980 cmdLine.serial().printf("\r\n add next row %d containing \"%s\"",
whismanoid 33:70a28cfe9e01 4981 editRowIndex, cmdLine.str()+argIndex);
whismanoid 33:70a28cfe9e01 4982 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 33:70a28cfe9e01 4983 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 33:70a28cfe9e01 4984 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 33:70a28cfe9e01 4985 //
whismanoid 23:c6c652bef4b9 4986 }
whismanoid 33:70a28cfe9e01 4987 //
whismanoid 23:c6c652bef4b9 4988 break;
whismanoid 23:c6c652bef4b9 4989 case '+':
whismanoid 24:032f3683cb2a 4990 // %B1@+ command add new row (if there is room to add)
whismanoid 23:c6c652bef4b9 4991 // add a new row at end of table
whismanoid 23:c6c652bef4b9 4992 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 4993 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 23:c6c652bef4b9 4994 editRowIndex = command_table_row_count;
whismanoid 28:a9a3a9db592b 4995 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 4996 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 4997 cmdLine.serial().printf("\r\n cannot add new row %d containing nothing",
whismanoid 28:a9a3a9db592b 4998 editRowIndex);
whismanoid 28:a9a3a9db592b 4999 }
whismanoid 28:a9a3a9db592b 5000 else
whismanoid 28:a9a3a9db592b 5001 {
whismanoid 28:a9a3a9db592b 5002 command_table_row_count++;
whismanoid 28:a9a3a9db592b 5003 cmdLine.serial().printf("\r\n add new row %d containing \"%s\"",
whismanoid 28:a9a3a9db592b 5004 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 5005 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 5006 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 5007 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 28:a9a3a9db592b 5008 }
whismanoid 23:c6c652bef4b9 5009 }
whismanoid 23:c6c652bef4b9 5010 break;
whismanoid 23:c6c652bef4b9 5011 case '-':
whismanoid 24:032f3683cb2a 5012 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 5013 // delete row from table
whismanoid 23:c6c652bef4b9 5014 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 5015 // if command_table_row_count == 0 then the table is empty
whismanoid 23:c6c652bef4b9 5016 if ((cmdLine[5] == '~') && (cmdLine[6] == '~') && (cmdLine[7] == '~')) {
whismanoid 23:c6c652bef4b9 5017 // %B1@-~~~ clear entire command table
whismanoid 24:032f3683cb2a 5018 cmdLine.serial().printf("\r\n clear entire command table");
whismanoid 23:c6c652bef4b9 5019 command_table_row_count = 0;
whismanoid 28:a9a3a9db592b 5020 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 23:c6c652bef4b9 5021 break;
whismanoid 23:c6c652bef4b9 5022 }
whismanoid 24:032f3683cb2a 5023 else
whismanoid 23:c6c652bef4b9 5024 {
whismanoid 24:032f3683cb2a 5025 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 24:032f3683cb2a 5026 editRowIndex = atoi(cmdLine.str()+5);
whismanoid 24:032f3683cb2a 5027 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 24:032f3683cb2a 5028 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 24:032f3683cb2a 5029 // delete row editRowIndex from Datalogger_action_table
whismanoid 24:032f3683cb2a 5030 for (int i = editRowIndex; i < (command_table_row_count-1); i++)
whismanoid 24:032f3683cb2a 5031 {
whismanoid 24:032f3683cb2a 5032 // copy row i+1 into row i
whismanoid 24:032f3683cb2a 5033 cmdLine.serial().printf("\r\n copy row %d into row %d: \"%s\"",
whismanoid 24:032f3683cb2a 5034 i+1, i, command_table[i+1]);
whismanoid 24:032f3683cb2a 5035 strncpy(command_table[i], command_table[i+1], COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 5036 command_table[i][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 24:032f3683cb2a 5037 }
whismanoid 24:032f3683cb2a 5038 command_table_row_count--;
whismanoid 28:a9a3a9db592b 5039 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 24:032f3683cb2a 5040 }
whismanoid 23:c6c652bef4b9 5041 }
whismanoid 23:c6c652bef4b9 5042 }
whismanoid 23:c6c652bef4b9 5043 break;
whismanoid 30:07197a430869 5044 case '.': // something other than ! because %B1! means trigger event
whismanoid 30:07197a430869 5045 // pause the button event
whismanoid 30:07197a430869 5046 // TODO: %B1@. disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 5047 //~ Datalogger_action_table_enabled = false;
whismanoid 23:c6c652bef4b9 5048 break;
whismanoid 23:c6c652bef4b9 5049 case '@':
whismanoid 30:07197a430869 5050 // enable the button event
whismanoid 23:c6c652bef4b9 5051 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 5052 //~ Datalogger_action_table_enabled = true;
whismanoid 23:c6c652bef4b9 5053 break;
whismanoid 23:c6c652bef4b9 5054 }
whismanoid 23:c6c652bef4b9 5055 //
whismanoid 23:c6c652bef4b9 5056 // Print the contents of command_table
whismanoid 23:c6c652bef4b9 5057 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 5058 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 5059 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 5060 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 5061 cmdLine.serial().printf("\r\n %%B%1d@%d %s",
whismanoid 24:032f3683cb2a 5062 command_table_button_index,
whismanoid 24:032f3683cb2a 5063 lineIndex,
whismanoid 24:032f3683cb2a 5064 command_table[lineIndex]);
whismanoid 23:c6c652bef4b9 5065 }
whismanoid 30:07197a430869 5066 //~ cmdLine.serial().printf("\r\n command_table_row_count = %d/%d",
whismanoid 30:07197a430869 5067 //~ command_table_row_count, COMMAND_TABLE_ROW_MAX);
whismanoid 30:07197a430869 5068 cmdLine.serial().printf("\r\n\r\nEdit Button%d event (used %d/%d, %d free):",
whismanoid 30:07197a430869 5069 command_table_button_index,
whismanoid 30:07197a430869 5070 command_table_row_count,
whismanoid 30:07197a430869 5071 COMMAND_TABLE_ROW_MAX,
whismanoid 30:07197a430869 5072 (COMMAND_TABLE_ROW_MAX - command_table_row_count)
whismanoid 30:07197a430869 5073 );
whismanoid 23:c6c652bef4b9 5074 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 5075 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 24:032f3683cb2a 5076 cmdLine.serial().printf("\r\n %%B%1d@+ command -- add new row %d at end of table",
whismanoid 24:032f3683cb2a 5077 command_table_button_index,
whismanoid 24:032f3683cb2a 5078 command_table_row_count);
whismanoid 23:c6c652bef4b9 5079 }
whismanoid 23:c6c652bef4b9 5080 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 5081 // if command_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 5082 cmdLine.serial().printf("\r\n %%B%1d@%d command -- replace row %d",
whismanoid 24:032f3683cb2a 5083 command_table_button_index,
whismanoid 23:c6c652bef4b9 5084 command_table_row_count-1,
whismanoid 23:c6c652bef4b9 5085 command_table_row_count-1);
whismanoid 24:032f3683cb2a 5086 cmdLine.serial().printf("\r\n %%B%1d@-%d -- delete row %d",
whismanoid 24:032f3683cb2a 5087 command_table_button_index,
whismanoid 24:032f3683cb2a 5088 command_table_row_count-1,
whismanoid 24:032f3683cb2a 5089 command_table_row_count-1);
whismanoid 24:032f3683cb2a 5090 cmdLine.serial().printf("\r\n %%B%1d@-~~~ -- delete all rows",
whismanoid 24:032f3683cb2a 5091 command_table_button_index);
whismanoid 30:07197a430869 5092 //~ cmdLine.serial().printf("\r\n %%B%1d@. -- pause entire command table",
whismanoid 30:07197a430869 5093 //~ command_table_button_index);
whismanoid 30:07197a430869 5094 //~ cmdLine.serial().printf("\r\n %%B%1d@@ -- enable command table",
whismanoid 30:07197a430869 5095 //~ command_table_button_index);
whismanoid 30:07197a430869 5096 cmdLine.serial().printf("\r\n %%B%1d! -- trigger Button%d event",
whismanoid 30:07197a430869 5097 command_table_button_index,
whismanoid 24:032f3683cb2a 5098 command_table_button_index);
whismanoid 23:c6c652bef4b9 5099 }
whismanoid 23:c6c652bef4b9 5100 //
whismanoid 23:c6c652bef4b9 5101 } // case '@' -- %B1@ view/edit command table
whismanoid 23:c6c652bef4b9 5102 break;
whismanoid 23:c6c652bef4b9 5103 case '!':
whismanoid 23:c6c652bef4b9 5104 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 23:c6c652bef4b9 5105 Run_command_table(command_table);
whismanoid 23:c6c652bef4b9 5106 break;
whismanoid 23:c6c652bef4b9 5107 }
whismanoid 23:c6c652bef4b9 5108 }
whismanoid 23:c6c652bef4b9 5109 break;
whismanoid 23:c6c652bef4b9 5110 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 5111 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 5112 #if HAS_digitalInOuts
whismanoid 15:37c83ec50ea0 5113 case 'H': case 'h':
whismanoid 15:37c83ec50ea0 5114 {
whismanoid 15:37c83ec50ea0 5115 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 5116 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 5117 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 5118 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 5119 #else
whismanoid 15:37c83ec50ea0 5120 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 5121 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 5122 digitalInOutPin.write(1);
whismanoid 15:37c83ec50ea0 5123 #endif
whismanoid 15:37c83ec50ea0 5124 cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex);
whismanoid 15:37c83ec50ea0 5125 }
whismanoid 15:37c83ec50ea0 5126 break;
whismanoid 15:37c83ec50ea0 5127 case 'L': case 'l':
whismanoid 15:37c83ec50ea0 5128 {
whismanoid 15:37c83ec50ea0 5129 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 5130 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 5131 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 5132 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 5133 #else
whismanoid 15:37c83ec50ea0 5134 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 5135 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 5136 digitalInOutPin.write(0);
whismanoid 15:37c83ec50ea0 5137 #endif
whismanoid 15:37c83ec50ea0 5138 cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex);
whismanoid 15:37c83ec50ea0 5139 }
whismanoid 15:37c83ec50ea0 5140 break;
whismanoid 15:37c83ec50ea0 5141 case '?':
whismanoid 15:37c83ec50ea0 5142 {
whismanoid 15:37c83ec50ea0 5143 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 5144 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 5145 pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 5146 #else
whismanoid 15:37c83ec50ea0 5147 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 5148 digitalInOutPin.input();
whismanoid 15:37c83ec50ea0 5149 #endif
whismanoid 15:37c83ec50ea0 5150 serial.printf(" digitalInOutPin %d Input ", pinIndex);
whismanoid 15:37c83ec50ea0 5151 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 5152 int value = digitalRead(pinIndex);
whismanoid 15:37c83ec50ea0 5153 #else
whismanoid 15:37c83ec50ea0 5154 int value = digitalInOutPin.read();
whismanoid 15:37c83ec50ea0 5155 #endif
whismanoid 15:37c83ec50ea0 5156 cmdLine.serial().printf("%d ", value);
whismanoid 15:37c83ec50ea0 5157 }
whismanoid 15:37c83ec50ea0 5158 break;
whismanoid 15:37c83ec50ea0 5159 #endif
whismanoid 15:37c83ec50ea0 5160 //
whismanoid 15:37c83ec50ea0 5161 #if HAS_analogIns
whismanoid 15:37c83ec50ea0 5162 case 'A': case 'a':
whismanoid 15:37c83ec50ea0 5163 {
whismanoid 15:37c83ec50ea0 5164 // %A %Apin -- analog input
whismanoid 37:3f369235e5bc 5165 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5166 // %A avg= -- set Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 5167 if (cmdLine.parse_int_dec("avg", Platform_AIN_Average_N))
whismanoid 37:3f369235e5bc 5168 {
whismanoid 37:3f369235e5bc 5169 // Platform_AIN_Average_N was updated
whismanoid 37:3f369235e5bc 5170 }
whismanoid 37:3f369235e5bc 5171 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5172 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5173 // %A cal? view/export raw calibration values for all channels
whismanoid 34:a1993a1ee904 5174 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5175 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5176 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5177 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5178 {
whismanoid 34:a1993a1ee904 5179 char valueBuf[16];
whismanoid 34:a1993a1ee904 5180 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 5181 if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 5182 {
whismanoid 34:a1993a1ee904 5183 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5184 {
whismanoid 34:a1993a1ee904 5185 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 5186 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 5187 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 5188 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 5189 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 5190 );
whismanoid 34:a1993a1ee904 5191 }
whismanoid 34:a1993a1ee904 5192 //
whismanoid 34:a1993a1ee904 5193 // print extended help for %A
whismanoid 34:a1993a1ee904 5194 // %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 5195 //~ cmdLine.serial().printf("\r\n %%A cal0n=0.02 cal0v=0.123 cal0n=0.938 cal0v=1.132 -- update calibration");
whismanoid 34:a1993a1ee904 5196 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 5197 cmdLine.serial().printf(" %%A cal0test=0.5 -- calculate voltage at 50%% of full scale");
whismanoid 34:a1993a1ee904 5198 cmdLine.serial().printf("\r\n %%A v0cal=1.000V -- calibrate channel against a known input voltage");
whismanoid 34:a1993a1ee904 5199 // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 5200 // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 5201 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 5202 cmdLine.serial().printf("\r\n %%A calreset -- reset all calibration data");
whismanoid 37:3f369235e5bc 5203 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5204 // %A avg=%d -- help string display Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 5205 cmdLine.serial().printf("\r\n %%A avg=%d -- average", Platform_AIN_Average_N);
whismanoid 37:3f369235e5bc 5206 #endif // USE_Platform_AIN_Average
whismanoid 48:18647e0516f2 5207 #ifdef BOARD_SERIAL_NUMBER
whismanoid 48:18647e0516f2 5208 // %A sn= set g_board_serial_number ; use with %F save during calibration #312
whismanoid 48:18647e0516f2 5209 cmdLine.serial().printf("\r\n %%A sn=%d -- serial number", g_board_serial_number);
whismanoid 48:18647e0516f2 5210 #endif // BOARD_SERIAL_NUMBER
whismanoid 34:a1993a1ee904 5211 cmdLine.serial().printf("\r\n\r\n");
whismanoid 34:a1993a1ee904 5212 //
whismanoid 34:a1993a1ee904 5213 } // end if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 5214 }
whismanoid 34:a1993a1ee904 5215 #endif // HAS_Platform_AIN_Calibration
whismanoid 48:18647e0516f2 5216 #ifdef BOARD_SERIAL_NUMBER
whismanoid 48:18647e0516f2 5217 {
whismanoid 48:18647e0516f2 5218 // %A sn= set g_board_serial_number ; use with %F save during calibration #312
whismanoid 48:18647e0516f2 5219 if (cmdLine.parse_uint32_dec("sn", g_board_serial_number))
whismanoid 48:18647e0516f2 5220 {
whismanoid 48:18647e0516f2 5221 }
whismanoid 48:18647e0516f2 5222 }
whismanoid 48:18647e0516f2 5223 #endif // BOARD_SERIAL_NUMBER
whismanoid 34:a1993a1ee904 5224 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5225 {
whismanoid 34:a1993a1ee904 5226 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 5227 char valueBuf[16];
whismanoid 34:a1993a1ee904 5228 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 5229 if (cmdLine.parse_and_remove_key("calreset", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 5230 {
whismanoid 34:a1993a1ee904 5231 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 5232 calibration_05_normValue_0_1[0] = 0.25; calibration_05_V[0] = 0.3;
whismanoid 34:a1993a1ee904 5233 calibration_05_normValue_0_1[1] = 0.25; calibration_05_V[1] = 0.3;
whismanoid 34:a1993a1ee904 5234 calibration_05_normValue_0_1[2] = 0.25; calibration_05_V[2] = 0.3;
whismanoid 34:a1993a1ee904 5235 calibration_05_normValue_0_1[3] = 0.25; calibration_05_V[3] = 0.3;
whismanoid 34:a1993a1ee904 5236 calibration_05_normValue_0_1[4] = 0.25; calibration_05_V[4] = 1.5;
whismanoid 34:a1993a1ee904 5237 calibration_05_normValue_0_1[5] = 0.25; calibration_05_V[5] = 1.5;
whismanoid 34:a1993a1ee904 5238 //
whismanoid 34:a1993a1ee904 5239 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 5240 calibration_95_normValue_0_1[0] = 0.75; calibration_95_V[0] = 0.9;
whismanoid 34:a1993a1ee904 5241 calibration_95_normValue_0_1[1] = 0.75; calibration_95_V[1] = 0.9;
whismanoid 34:a1993a1ee904 5242 calibration_95_normValue_0_1[2] = 0.75; calibration_95_V[2] = 0.9;
whismanoid 34:a1993a1ee904 5243 calibration_95_normValue_0_1[3] = 0.75; calibration_95_V[3] = 0.9;
whismanoid 34:a1993a1ee904 5244 calibration_95_normValue_0_1[4] = 0.75; calibration_95_V[4] = 4.5;
whismanoid 34:a1993a1ee904 5245 calibration_95_normValue_0_1[5] = 0.75; calibration_95_V[5] = 4.5;
whismanoid 34:a1993a1ee904 5246 //
whismanoid 34:a1993a1ee904 5247 }
whismanoid 34:a1993a1ee904 5248 }
whismanoid 34:a1993a1ee904 5249 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5250 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5251 // %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 5252 // %A cal4n=0.135874882 cal4v=0.800000012V cal4n=0.286168128 cal4v=1.700000048V
whismanoid 34:a1993a1ee904 5253 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5254 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5255 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5256 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5257 {
whismanoid 34:a1993a1ee904 5258 double normValue_0_1, V;
whismanoid 34:a1993a1ee904 5259 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5260 {
whismanoid 34:a1993a1ee904 5261 static char key_can0n[8] = "cal0n__";
whismanoid 34:a1993a1ee904 5262 sprintf(key_can0n, "cal%1dn", ch);
whismanoid 34:a1993a1ee904 5263 static char key_cal0v[8] = "cal0v__";
whismanoid 34:a1993a1ee904 5264 sprintf(key_cal0v, "cal%1dv", ch);
whismanoid 35:c9549b5c01de 5265 // first point could be the 5% point or the 95% point
whismanoid 35:c9549b5c01de 5266 double norm_threshold = (calibration_05_normValue_0_1[ch] + calibration_95_normValue_0_1[ch]) / 2.0;
whismanoid 35:c9549b5c01de 5267 bool updated_05 = false;
whismanoid 35:c9549b5c01de 5268 //~ bool updated_95 = false;
whismanoid 35:c9549b5c01de 5269 if (cmdLine.parse_double(key_can0n, normValue_0_1)) {
whismanoid 34:a1993a1ee904 5270 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 34:a1993a1ee904 5271 {
whismanoid 35:c9549b5c01de 5272 if (normValue_0_1 < norm_threshold) {
whismanoid 35:c9549b5c01de 5273 // store first calibration point in the 5% slot
whismanoid 35:c9549b5c01de 5274 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 5275 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 5276 updated_05 = true;
whismanoid 34:a1993a1ee904 5277 }
whismanoid 34:a1993a1ee904 5278 else {
whismanoid 35:c9549b5c01de 5279 // store first calibration point in the 95% slot
whismanoid 35:c9549b5c01de 5280 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 5281 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 5282 //~ updated_95 = true;
whismanoid 34:a1993a1ee904 5283 }
whismanoid 34:a1993a1ee904 5284 }
whismanoid 35:c9549b5c01de 5285 }
whismanoid 35:c9549b5c01de 5286 // handle the optional second calibration point
whismanoid 35:c9549b5c01de 5287 if (cmdLine.parse_double(key_can0n, normValue_0_1))
whismanoid 35:c9549b5c01de 5288 {
whismanoid 35:c9549b5c01de 5289 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 35:c9549b5c01de 5290 {
whismanoid 35:c9549b5c01de 5291 if (updated_05) {
whismanoid 35:c9549b5c01de 5292 // we already stored the first point here
whismanoid 35:c9549b5c01de 5293 // calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5294 // calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 5295 // store the second point in the other slot
whismanoid 35:c9549b5c01de 5296 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5297 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 5298 }
whismanoid 35:c9549b5c01de 5299 else {
whismanoid 35:c9549b5c01de 5300 // we already stored the first point here
whismanoid 35:c9549b5c01de 5301 // calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5302 // calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 5303 // store the second point in the other slot
whismanoid 35:c9549b5c01de 5304 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5305 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 5306 }
whismanoid 35:c9549b5c01de 5307 }
whismanoid 35:c9549b5c01de 5308 }
whismanoid 38:fda80a0020d1 5309 // make sure calibration_05_normValue_0_1[ch] < calibration_95_normValue_0_1[ch]
whismanoid 38:fda80a0020d1 5310 if (calibration_05_normValue_0_1[ch] > calibration_95_normValue_0_1[ch])
whismanoid 38:fda80a0020d1 5311 {
whismanoid 38:fda80a0020d1 5312 // swap to make sure calibration_05_normValue_0_1[ch] < calibration_95_normValue_0_1[ch]
whismanoid 38:fda80a0020d1 5313 double n05 = calibration_95_normValue_0_1[ch];
whismanoid 38:fda80a0020d1 5314 double V05 = calibration_95_V[ch];
whismanoid 38:fda80a0020d1 5315 double n95 = calibration_05_normValue_0_1[ch];
whismanoid 38:fda80a0020d1 5316 double V95 = calibration_05_V[ch];
whismanoid 38:fda80a0020d1 5317 calibration_05_normValue_0_1[ch] = n05;
whismanoid 38:fda80a0020d1 5318 calibration_05_V[ch] = V05;
whismanoid 38:fda80a0020d1 5319 calibration_95_normValue_0_1[ch] = n95;
whismanoid 38:fda80a0020d1 5320 calibration_95_V[ch] = V95;
whismanoid 38:fda80a0020d1 5321 }
whismanoid 34:a1993a1ee904 5322 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5323 }
whismanoid 34:a1993a1ee904 5324 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5325 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5326 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 5327 // double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 5328 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5329 {
whismanoid 34:a1993a1ee904 5330 static char key_cal0test[12] = "cal0test__";
whismanoid 34:a1993a1ee904 5331 sprintf(key_cal0test, "cal%1dtest", ch);
whismanoid 34:a1993a1ee904 5332 double normValue_0_1, Vtest;
whismanoid 34:a1993a1ee904 5333 if (cmdLine.parse_double(key_cal0test, Vtest))
whismanoid 34:a1993a1ee904 5334 {
whismanoid 34:a1993a1ee904 5335 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 5336 normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 5337 //
whismanoid 34:a1993a1ee904 5338 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 5339 ch,
whismanoid 34:a1993a1ee904 5340 normValue_0_1,
whismanoid 34:a1993a1ee904 5341 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 5342 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5343 );
whismanoid 34:a1993a1ee904 5344 //
whismanoid 34:a1993a1ee904 5345 // sweep CalibratedNormValue argument
whismanoid 34:a1993a1ee904 5346 double normValue_0_1_start = -0.05;
whismanoid 34:a1993a1ee904 5347 double normValue_0_1_step = 0.05;
whismanoid 34:a1993a1ee904 5348 double normValue_0_1_end = 1.07;
whismanoid 34:a1993a1ee904 5349 for (normValue_0_1 = normValue_0_1_start;
whismanoid 34:a1993a1ee904 5350 normValue_0_1 <= normValue_0_1_end;
whismanoid 34:a1993a1ee904 5351 normValue_0_1 = normValue_0_1 + normValue_0_1_step)
whismanoid 34:a1993a1ee904 5352 {
whismanoid 34:a1993a1ee904 5353 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 5354 ch,
whismanoid 34:a1993a1ee904 5355 normValue_0_1,
whismanoid 34:a1993a1ee904 5356 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 5357 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5358 );
whismanoid 34:a1993a1ee904 5359 }
whismanoid 34:a1993a1ee904 5360 }
whismanoid 34:a1993a1ee904 5361 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5362 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5363 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5364 // %A v0cal=1.000V -- calibrate channel against a known input voltage
whismanoid 34:a1993a1ee904 5365 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5366 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5367 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5368 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5369 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5370 {
whismanoid 34:a1993a1ee904 5371 static char key_v0cal[10] = "v0cal__";
whismanoid 34:a1993a1ee904 5372 sprintf(key_v0cal, "v%1dcal", ch);
whismanoid 34:a1993a1ee904 5373 double Vtest;
whismanoid 34:a1993a1ee904 5374 if (cmdLine.parse_double(key_v0cal, Vtest))
whismanoid 34:a1993a1ee904 5375 {
whismanoid 34:a1993a1ee904 5376 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 5377 double Vtest_normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 5378 //
whismanoid 34:a1993a1ee904 5379 // %A v0cal=1.000 calibrate one channel by measuring against a known input voltage
whismanoid 34:a1993a1ee904 5380 //
whismanoid 34:a1993a1ee904 5381 cmdLine.serial().printf("\r\n Measuring against input voltage of %1.6fV...", Vtest);
whismanoid 37:3f369235e5bc 5382 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5383 const int numberOfMeasurements = 16 * Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5384 #else // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5385 const int numberOfMeasurements = 16;
whismanoid 37:3f369235e5bc 5386 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5387 double Sx_measure_normValue_0_1 = 0; // sum of values
whismanoid 34:a1993a1ee904 5388 double Sxx_measure_normValue_0_1 = 0; // sum of the squares of the values
whismanoid 34:a1993a1ee904 5389 for (int count = 0; count < numberOfMeasurements; count++)
whismanoid 34:a1993a1ee904 5390 {
whismanoid 34:a1993a1ee904 5391 double measure_normValue_0_1;
whismanoid 34:a1993a1ee904 5392 switch(ch)
whismanoid 34:a1993a1ee904 5393 {
whismanoid 34:a1993a1ee904 5394 case 0: measure_normValue_0_1 = analogIn0.read(); break;
whismanoid 34:a1993a1ee904 5395 case 1: measure_normValue_0_1 = analogIn1.read(); break;
whismanoid 34:a1993a1ee904 5396 case 2: measure_normValue_0_1 = analogIn2.read(); break;
whismanoid 34:a1993a1ee904 5397 case 3: measure_normValue_0_1 = analogIn3.read(); break;
whismanoid 34:a1993a1ee904 5398 case 4: measure_normValue_0_1 = analogIn4.read(); break;
whismanoid 34:a1993a1ee904 5399 case 5: measure_normValue_0_1 = analogIn5.read(); break;
whismanoid 34:a1993a1ee904 5400 }
whismanoid 34:a1993a1ee904 5401 Sx_measure_normValue_0_1 = Sx_measure_normValue_0_1 + measure_normValue_0_1;
whismanoid 34:a1993a1ee904 5402 Sxx_measure_normValue_0_1 = Sxx_measure_normValue_0_1 + (measure_normValue_0_1 * measure_normValue_0_1);
whismanoid 38:fda80a0020d1 5403 if ((count < 3) || (count >= numberOfMeasurements - 3)) {
whismanoid 38:fda80a0020d1 5404 cmdLine.serial().printf("\r\n raw: %7.6f%% = %1.6fV",
whismanoid 38:fda80a0020d1 5405 measure_normValue_0_1 * 100.0,
whismanoid 38:fda80a0020d1 5406 (measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 38:fda80a0020d1 5407 );
whismanoid 38:fda80a0020d1 5408 }
whismanoid 34:a1993a1ee904 5409 }
whismanoid 34:a1993a1ee904 5410 cmdLine.serial().printf("\r\n numberOfMeasurements = %d", numberOfMeasurements);
whismanoid 34:a1993a1ee904 5411 cmdLine.serial().printf("\r\n Sx_measure_normValue_0_1 = %1.6f", Sx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 5412 cmdLine.serial().printf("\r\n Sxx_measure_normValue_0_1 = %1.6f", Sxx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 5413 //
whismanoid 34:a1993a1ee904 5414 // calculate mean_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 5415 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 5416 double mean_measure_normValue_0_1 = Sx_measure_normValue_0_1 / numberOfMeasurements;
whismanoid 34:a1993a1ee904 5417 cmdLine.serial().printf("\r\n mean = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 5418 mean_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 5419 (mean_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5420 );
whismanoid 34:a1993a1ee904 5421 //
whismanoid 34:a1993a1ee904 5422 // TODO: calculate sample variance_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 5423 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 5424 // variance_measure_normValue_0_1 = (Sxx - ( Sx * Sx / nWords) ) / (nWords - 1);
whismanoid 34:a1993a1ee904 5425 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 5426 cmdLine.serial().printf("\r\n variance = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 5427 variance_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 5428 (variance_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5429 );
whismanoid 34:a1993a1ee904 5430 //
whismanoid 34:a1993a1ee904 5431 // calculate sample stddev_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 5432 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 5433 double stddev_measure_normValue_0_1 = sqrt(variance_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 5434 cmdLine.serial().printf("\r\n stddev = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 5435 stddev_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 5436 (stddev_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5437 );
whismanoid 34:a1993a1ee904 5438 //
whismanoid 34:a1993a1ee904 5439 // Validate the measurements:
whismanoid 34:a1993a1ee904 5440 // is the mean near the expected value?
whismanoid 34:a1993a1ee904 5441 // is the standard deviation not too high?
whismanoid 34:a1993a1ee904 5442 bool isCalibrationValid = true;
whismanoid 34:a1993a1ee904 5443 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) > 0.1) {
whismanoid 34:a1993a1ee904 5444 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 5445 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 5446 }
whismanoid 34:a1993a1ee904 5447 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) < -0.1) {
whismanoid 34:a1993a1ee904 5448 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 5449 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 5450 }
whismanoid 34:a1993a1ee904 5451 if ((stddev_measure_normValue_0_1) > 10) {
whismanoid 34:a1993a1ee904 5452 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 5453 cmdLine.serial().printf(" stddev too high.\r\n");
whismanoid 34:a1993a1ee904 5454 }
whismanoid 34:a1993a1ee904 5455 if (isCalibrationValid)
whismanoid 34:a1993a1ee904 5456 {
whismanoid 34:a1993a1ee904 5457 // update calibration point (mean_measure_normValue_0_1, Vtest)
whismanoid 34:a1993a1ee904 5458 if (Vtest_normValue_0_1 < 0.5) {
whismanoid 34:a1993a1ee904 5459 calibration_05_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 5460 calibration_05_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 5461 } else {
whismanoid 34:a1993a1ee904 5462 calibration_95_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 5463 calibration_95_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 5464 }
whismanoid 34:a1993a1ee904 5465 //
whismanoid 34:a1993a1ee904 5466 // print updated calibration values
whismanoid 34:a1993a1ee904 5467 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 5468 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 5469 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 5470 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 5471 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 5472 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 5473 );
whismanoid 34:a1993a1ee904 5474 // print corrected value of mean of measurements (should be close to Vtest)
whismanoid 34:a1993a1ee904 5475 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV vs %1.6fV\r\n",
whismanoid 34:a1993a1ee904 5476 ch,
whismanoid 34:a1993a1ee904 5477 mean_measure_normValue_0_1,
whismanoid 34:a1993a1ee904 5478 CalibratedNormValue(ch, mean_measure_normValue_0_1),
whismanoid 34:a1993a1ee904 5479 (CalibratedNormValue(ch, mean_measure_normValue_0_1) * adc_full_scale_voltage[ch]),
whismanoid 34:a1993a1ee904 5480 Vtest
whismanoid 34:a1993a1ee904 5481 );
whismanoid 34:a1993a1ee904 5482 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 5483 else {
whismanoid 34:a1993a1ee904 5484 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 5485 cmdLine.serial().printf(" Measurement Error: Calibration will not be updated.\r\n");
whismanoid 34:a1993a1ee904 5486 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 5487 } // end if key_v0cal
whismanoid 34:a1993a1ee904 5488 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5489 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5490 #if HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 5491 // // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 37:3f369235e5bc 5492 // {
whismanoid 37:3f369235e5bc 5493 // char valueBuf[16];
whismanoid 37:3f369235e5bc 5494 // // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 37:3f369235e5bc 5495 // if (cmdLine.parse_and_remove_key("__TBD_saveCal__", valueBuf, sizeof(valueBuf)))
whismanoid 37:3f369235e5bc 5496 // {
whismanoid 37:3f369235e5bc 5497 // // handle %A __TBD_saveCal__ -- command
whismanoid 37:3f369235e5bc 5498 // }
whismanoid 37:3f369235e5bc 5499 // }
whismanoid 34:a1993a1ee904 5500 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5501 #if HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 5502 // // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 37:3f369235e5bc 5503 // {
whismanoid 37:3f369235e5bc 5504 // char valueBuf[16];
whismanoid 37:3f369235e5bc 5505 // // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 37:3f369235e5bc 5506 // if (cmdLine.parse_and_remove_key("__TBD_loadCal__", valueBuf, sizeof(valueBuf)))
whismanoid 37:3f369235e5bc 5507 // {
whismanoid 37:3f369235e5bc 5508 // // handle %A __TBD_loadCal__ -- command
whismanoid 37:3f369235e5bc 5509 // }
whismanoid 37:3f369235e5bc 5510 // }
whismanoid 34:a1993a1ee904 5511 #endif // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 5512 // %A -- report analog input voltages
whismanoid 37:3f369235e5bc 5513 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5514 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5515 #endif // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5516 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 5517 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 15:37c83ec50ea0 5518 for (int pinIndex = 0; pinIndex < 2; pinIndex++)
whismanoid 15:37c83ec50ea0 5519 {
whismanoid 15:37c83ec50ea0 5520 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 5521 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 5522 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 5523 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5524 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5525 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5526 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 5527 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5528 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 5529 }
whismanoid 37:3f369235e5bc 5530 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5531 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5532 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 5533 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5534 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5535 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5536 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 5537 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5538 //
whismanoid 15:37c83ec50ea0 5539 int pinIndexH = pinIndex + 4;
whismanoid 15:37c83ec50ea0 5540 int cPinIndexH = '0' + pinIndexH;
whismanoid 15:37c83ec50ea0 5541 AnalogIn& analogInPinH = find_analogInPin(cPinIndexH);
whismanoid 15:37c83ec50ea0 5542 float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH];
whismanoid 37:3f369235e5bc 5543 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5544 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5545 // float normValueH_0_1 = analogInPinH.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5546 float normValueH_0_1 = 0;
whismanoid 37:3f369235e5bc 5547 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5548 normValueH_0_1 = normValueH_0_1 + analogInPinH.read();
whismanoid 37:3f369235e5bc 5549 }
whismanoid 37:3f369235e5bc 5550 normValueH_0_1 = normValueH_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5551 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5552 float normValueH_0_1 = analogInPinH.read();
whismanoid 37:3f369235e5bc 5553 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5554 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5555 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5556 normValueH_0_1 = CalibratedNormValue(pinIndex, normValueH_0_1);
whismanoid 34:a1993a1ee904 5557 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5558 //
whismanoid 37:3f369235e5bc 5559 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV high range A%c = %7.3f%% = %1.3fV \r\n",
whismanoid 15:37c83ec50ea0 5560 cPinIndex,
whismanoid 15:37c83ec50ea0 5561 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5562 normValue_0_1 * adc_full_scale_voltage,
whismanoid 15:37c83ec50ea0 5563 cPinIndexH,
whismanoid 15:37c83ec50ea0 5564 normValueH_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5565 normValueH_0_1 * adc_full_scale_voltageH
whismanoid 15:37c83ec50ea0 5566 );
whismanoid 15:37c83ec50ea0 5567 }
whismanoid 15:37c83ec50ea0 5568 for (int pinIndex = 2; pinIndex < 4; pinIndex++)
whismanoid 15:37c83ec50ea0 5569 {
whismanoid 15:37c83ec50ea0 5570 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 5571 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 5572 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 5573 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5574 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5575 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5576 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 5577 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5578 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 5579 }
whismanoid 37:3f369235e5bc 5580 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5581 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5582 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 5583 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5584 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5585 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5586 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 5587 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5588 //
whismanoid 37:3f369235e5bc 5589 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 5590 cPinIndex,
whismanoid 15:37c83ec50ea0 5591 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5592 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 5593 );
whismanoid 15:37c83ec50ea0 5594 }
whismanoid 15:37c83ec50ea0 5595 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 5596 // Platform board uses simple analog inputs
whismanoid 15:37c83ec50ea0 5597 // assume standard Arduino analog inputs A0-A5
whismanoid 15:37c83ec50ea0 5598 for (int pinIndex = 0; pinIndex < 6; pinIndex++)
whismanoid 15:37c83ec50ea0 5599 {
whismanoid 15:37c83ec50ea0 5600 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 5601 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 5602 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 5603 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5604 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5605 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5606 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 5607 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5608 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 5609 }
whismanoid 37:3f369235e5bc 5610 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5611 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5612 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 5613 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5614 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5615 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5616 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 5617 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5618 //
whismanoid 37:3f369235e5bc 5619 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 5620 cPinIndex,
whismanoid 15:37c83ec50ea0 5621 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5622 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 5623 );
whismanoid 15:37c83ec50ea0 5624 }
whismanoid 15:37c83ec50ea0 5625 #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 5626 }
whismanoid 15:37c83ec50ea0 5627 break;
whismanoid 15:37c83ec50ea0 5628 #endif
whismanoid 15:37c83ec50ea0 5629 //
whismanoid 15:37c83ec50ea0 5630 #if HAS_SPI2_MAX541
whismanoid 15:37c83ec50ea0 5631 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 5632 {
whismanoid 15:37c83ec50ea0 5633 // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV)
whismanoid 15:37c83ec50ea0 5634 // MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 15:37c83ec50ea0 5635 float voltageV = max541.Get_Voltage();
whismanoid 15:37c83ec50ea0 5636 // if (cmdLine[2] == '+') {
whismanoid 15:37c83ec50ea0 5637 // // %D+
whismanoid 15:37c83ec50ea0 5638 // voltageV = voltageV * 1.25f;
whismanoid 15:37c83ec50ea0 5639 // if (voltageV >= max541.VRef) voltageV = max541.VRef;
whismanoid 15:37c83ec50ea0 5640 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5641 // }
whismanoid 15:37c83ec50ea0 5642 // else if (cmdLine[2] == '-') {
whismanoid 15:37c83ec50ea0 5643 // // %D-
whismanoid 15:37c83ec50ea0 5644 // voltageV = voltageV * 0.75f;
whismanoid 15:37c83ec50ea0 5645 // if (voltageV < 0.1f) voltageV = 0.1f;
whismanoid 15:37c83ec50ea0 5646 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5647 // }
whismanoid 15:37c83ec50ea0 5648 if (cmdLine.parse_float("V", voltageV))
whismanoid 15:37c83ec50ea0 5649 {
whismanoid 15:37c83ec50ea0 5650 // %D V=1.234 -- set voltage
whismanoid 15:37c83ec50ea0 5651 max541.Set_Voltage(voltageV);
whismanoid 15:37c83ec50ea0 5652 }
whismanoid 15:37c83ec50ea0 5653 else if (cmdLine.parse_float("TEST", voltageV))
whismanoid 15:37c83ec50ea0 5654 {
whismanoid 15:37c83ec50ea0 5655 // %D TEST=1.234 -- set voltage and compare with AIN0
whismanoid 15:37c83ec50ea0 5656 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5657 }
whismanoid 15:37c83ec50ea0 5658 else if (cmdLine.parse_float("CAL", voltageV))
whismanoid 15:37c83ec50ea0 5659 {
whismanoid 15:37c83ec50ea0 5660 // %D CAL=1.234 -- calibrate VRef and compare with AIN0
whismanoid 15:37c83ec50ea0 5661
whismanoid 15:37c83ec50ea0 5662 max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
whismanoid 15:37c83ec50ea0 5663 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 5664 const int average_count = 100;
whismanoid 15:37c83ec50ea0 5665 const double average_K = 0.25;
whismanoid 15:37c83ec50ea0 5666 for (int count = 0; count < average_count; count++) {
whismanoid 15:37c83ec50ea0 5667 double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 5668 max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
whismanoid 15:37c83ec50ea0 5669 }
whismanoid 15:37c83ec50ea0 5670 max541.VRef = 2.0 * max541_midscale_V;
whismanoid 15:37c83ec50ea0 5671 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5672 "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
whismanoid 15:37c83ec50ea0 5673 max541_midscale_V, max541.VRef);
whismanoid 15:37c83ec50ea0 5674 // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
whismanoid 15:37c83ec50ea0 5675 voltageV = 1.0f;
whismanoid 15:37c83ec50ea0 5676 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5677 }
whismanoid 15:37c83ec50ea0 5678 else {
whismanoid 15:37c83ec50ea0 5679 // %D -- print MAX541 DAC status
whismanoid 15:37c83ec50ea0 5680 cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n",
whismanoid 15:37c83ec50ea0 5681 max541.Get_Code(), max541.Get_Voltage(), max541.VRef);
whismanoid 15:37c83ec50ea0 5682 }
whismanoid 15:37c83ec50ea0 5683 }
whismanoid 15:37c83ec50ea0 5684 break;
whismanoid 15:37c83ec50ea0 5685 #endif
whismanoid 15:37c83ec50ea0 5686
whismanoid 15:37c83ec50ea0 5687 //
whismanoid 15:37c83ec50ea0 5688 #if HAS_I2C // SUPPORT_I2C
whismanoid 15:37c83ec50ea0 5689 case 'I': case 'i':
whismanoid 15:37c83ec50ea0 5690 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 5691 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 5692 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 5693 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 5694 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 5695 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 5696 // get next character
whismanoid 15:37c83ec50ea0 5697 // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7
whismanoid 15:37c83ec50ea0 5698 cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7);
whismanoid 15:37c83ec50ea0 5699 // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count
whismanoid 15:37c83ec50ea0 5700 g_I2C_read_count = 0; // read count must be reset every command
whismanoid 15:37c83ec50ea0 5701 cmdLine.parse_byte_dec("RD", g_I2C_read_count);
whismanoid 15:37c83ec50ea0 5702 // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress
whismanoid 15:37c83ec50ea0 5703 cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress);
whismanoid 15:37c83ec50ea0 5704 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 5705 {
whismanoid 15:37c83ec50ea0 5706 case 'P': case 'p':
whismanoid 15:37c83ec50ea0 5707 {
whismanoid 15:37c83ec50ea0 5708 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 5709 HuntAttachedI2CDevices(cmdLine, 0x03, 0x77);
whismanoid 15:37c83ec50ea0 5710 }
whismanoid 15:37c83ec50ea0 5711 break;
whismanoid 15:37c83ec50ea0 5712 case 'C': case 'c':
whismanoid 15:37c83ec50ea0 5713 {
whismanoid 15:37c83ec50ea0 5714 bool isUpdatedI2CConfig = false;
whismanoid 15:37c83ec50ea0 5715 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 5716 // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz
whismanoid 15:37c83ec50ea0 5717 if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz))
whismanoid 15:37c83ec50ea0 5718 {
whismanoid 15:37c83ec50ea0 5719 isUpdatedI2CConfig = true;
whismanoid 15:37c83ec50ea0 5720 // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 5721 if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 5722 {
whismanoid 15:37c83ec50ea0 5723 g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 5724 }
whismanoid 15:37c83ec50ea0 5725 if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 5726 {
whismanoid 15:37c83ec50ea0 5727 g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 5728 }
whismanoid 15:37c83ec50ea0 5729 }
whismanoid 15:37c83ec50ea0 5730 if (isUpdatedI2CConfig)
whismanoid 15:37c83ec50ea0 5731 {
whismanoid 15:37c83ec50ea0 5732 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 5733 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 5734 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5735 i2cMaster.start();
whismanoid 15:37c83ec50ea0 5736 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 5737 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5738 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5739 "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 15:37c83ec50ea0 5740 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 15:37c83ec50ea0 5741 (g_I2C_SCL_Hz / 1000.));
whismanoid 15:37c83ec50ea0 5742 i2cMaster.start();
whismanoid 15:37c83ec50ea0 5743 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 5744 }
whismanoid 15:37c83ec50ea0 5745 }
whismanoid 15:37c83ec50ea0 5746 break;
whismanoid 15:37c83ec50ea0 5747 case 'W': case 'w':
whismanoid 15:37c83ec50ea0 5748 {
whismanoid 15:37c83ec50ea0 5749 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 5750 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 5751 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5752 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 5753 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5754 #define MAX_I2C_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 5755 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 5756 static char mosiData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5757 static char misoData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5758 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 5759 MAX_I2C_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 5760 {
whismanoid 15:37c83ec50ea0 5761 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5762 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5763 "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->",
whismanoid 15:37c83ec50ea0 5764 g_I2C_deviceAddress7,
whismanoid 15:37c83ec50ea0 5765 (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count);
whismanoid 15:37c83ec50ea0 5766 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 5767 {
whismanoid 15:37c83ec50ea0 5768 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 5769 }
whismanoid 15:37c83ec50ea0 5770 //
whismanoid 15:37c83ec50ea0 5771 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 5772 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 5773 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 5774 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 5775 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 5776 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 5777 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 5778 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5779 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5780 // /* 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 5781 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 5782 const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 5783 unsigned int misoLength = 0;
whismanoid 15:37c83ec50ea0 5784 bool repeated = (g_I2C_read_count > 0);
whismanoid 15:37c83ec50ea0 5785 //
whismanoid 15:37c83ec50ea0 5786 int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated);
whismanoid 15:37c83ec50ea0 5787 switch (writeStatus)
whismanoid 15:37c83ec50ea0 5788 {
whismanoid 15:37c83ec50ea0 5789 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 5790 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 5791 default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 5792 writeStatus);
whismanoid 15:37c83ec50ea0 5793 }
whismanoid 15:37c83ec50ea0 5794 if (repeated)
whismanoid 15:37c83ec50ea0 5795 {
whismanoid 15:37c83ec50ea0 5796 int readStatus =
whismanoid 15:37c83ec50ea0 5797 i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false);
whismanoid 15:37c83ec50ea0 5798 switch (readStatus)
whismanoid 15:37c83ec50ea0 5799 {
whismanoid 15:37c83ec50ea0 5800 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 5801 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 5802 default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 5803 readStatus);
whismanoid 15:37c83ec50ea0 5804 }
whismanoid 15:37c83ec50ea0 5805 }
whismanoid 15:37c83ec50ea0 5806 //
whismanoid 15:37c83ec50ea0 5807 if (misoLength > 0)
whismanoid 15:37c83ec50ea0 5808 {
whismanoid 15:37c83ec50ea0 5809 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5810 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 5811 for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count;
whismanoid 15:37c83ec50ea0 5812 byteIndex++)
whismanoid 15:37c83ec50ea0 5813 {
whismanoid 15:37c83ec50ea0 5814 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 5815 }
whismanoid 15:37c83ec50ea0 5816 }
whismanoid 15:37c83ec50ea0 5817 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 5818 }
whismanoid 15:37c83ec50ea0 5819 }
whismanoid 15:37c83ec50ea0 5820 break;
whismanoid 15:37c83ec50ea0 5821 case 'R': case 'r':
whismanoid 15:37c83ec50ea0 5822 {
whismanoid 15:37c83ec50ea0 5823 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 5824 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 5825 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5826 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 5827 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 5828 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 5829 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 5830 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 5831 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 5832 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 5833 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 5834 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5835 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5836 // /* 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 5837 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 5838 }
whismanoid 15:37c83ec50ea0 5839 break;
whismanoid 15:37c83ec50ea0 5840 case '^':
whismanoid 15:37c83ec50ea0 5841 {
whismanoid 15:37c83ec50ea0 5842 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 5843 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 5844 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5845 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 5846 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 5847 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 5848 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 5849 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 5850 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 5851 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 5852 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 5853 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5854 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5855 // /* 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 5856 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 5857 }
whismanoid 15:37c83ec50ea0 5858 break;
whismanoid 15:37c83ec50ea0 5859 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 5860 break;
whismanoid 15:37c83ec50ea0 5861 #endif
whismanoid 15:37c83ec50ea0 5862 //
whismanoid 15:37c83ec50ea0 5863 #if HAS_SPI // SUPPORT_SPI
whismanoid 15:37c83ec50ea0 5864 case 'S': case 's':
whismanoid 15:37c83ec50ea0 5865 {
whismanoid 15:37c83ec50ea0 5866 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 5867 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 5868 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 5869 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 5870 //
whismanoid 15:37c83ec50ea0 5871 // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d
whismanoid 15:37c83ec50ea0 5872 bool isUpdatedSPIConfig = false;
whismanoid 15:37c83ec50ea0 5873 // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2
whismanoid 15:37c83ec50ea0 5874 // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1
whismanoid 15:37c83ec50ea0 5875 if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2))
whismanoid 15:37c83ec50ea0 5876 {
whismanoid 15:37c83ec50ea0 5877 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5878 }
whismanoid 15:37c83ec50ea0 5879 if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1))
whismanoid 15:37c83ec50ea0 5880 {
whismanoid 15:37c83ec50ea0 5881 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5882 }
whismanoid 15:37c83ec50ea0 5883 if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1))
whismanoid 15:37c83ec50ea0 5884 {
whismanoid 15:37c83ec50ea0 5885 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5886 }
whismanoid 15:37c83ec50ea0 5887 // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz
whismanoid 15:37c83ec50ea0 5888 if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz))
whismanoid 15:37c83ec50ea0 5889 {
whismanoid 15:37c83ec50ea0 5890 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5891 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 5892 if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 5893 {
whismanoid 15:37c83ec50ea0 5894 g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 5895 }
whismanoid 15:37c83ec50ea0 5896 if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 5897 {
whismanoid 15:37c83ec50ea0 5898 g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 5899 }
whismanoid 15:37c83ec50ea0 5900 }
whismanoid 15:37c83ec50ea0 5901 // Update SPI configuration
whismanoid 15:37c83ec50ea0 5902 if (isUpdatedSPIConfig)
whismanoid 15:37c83ec50ea0 5903 {
whismanoid 15:37c83ec50ea0 5904 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 5905 spi_cs = g_SPI_cs_state;
whismanoid 15:37c83ec50ea0 5906 spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0
whismanoid 15:37c83ec50ea0 5907 #if APPLICATION_MAX5715
whismanoid 15:37c83ec50ea0 5908 g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5909 #elif APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 5910 g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5911 #elif APPLICATION_MAX5171
whismanoid 15:37c83ec50ea0 5912 g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5913 #elif APPLICATION_MAX11410
whismanoid 15:37c83ec50ea0 5914 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5915 #elif APPLICATION_MAX12345
whismanoid 15:37c83ec50ea0 5916 g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5917 #else
whismanoid 15:37c83ec50ea0 5918 spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 15:37c83ec50ea0 5919 #endif
whismanoid 15:37c83ec50ea0 5920 //
whismanoid 15:37c83ec50ea0 5921 double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 5922 int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate
whismanoid 15:37c83ec50ea0 5923 double actual_SCLK_Hz = SystemCoreClock / actual_divisor;
whismanoid 15:37c83ec50ea0 5924 //
whismanoid 15:37c83ec50ea0 5925 // 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 5926 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5927 "\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 5928 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 15:37c83ec50ea0 5929 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0),
whismanoid 15:37c83ec50ea0 5930 g_SPI_cs_state,
whismanoid 15:37c83ec50ea0 5931 g_SPI_SCLK_Hz,
whismanoid 15:37c83ec50ea0 5932 (g_SPI_SCLK_Hz / 1000000.),
whismanoid 15:37c83ec50ea0 5933 ((double)(SystemCoreClock / 1000000.)),
whismanoid 15:37c83ec50ea0 5934 ideal_divisor,
whismanoid 15:37c83ec50ea0 5935 (actual_SCLK_Hz / 1000000.)
whismanoid 15:37c83ec50ea0 5936 );
whismanoid 15:37c83ec50ea0 5937 }
whismanoid 15:37c83ec50ea0 5938 // get next character
whismanoid 15:37c83ec50ea0 5939 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 5940 {
whismanoid 15:37c83ec50ea0 5941 case 'C': case 's':
whismanoid 15:37c83ec50ea0 5942 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 5943 break;
whismanoid 15:37c83ec50ea0 5944 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 5945 // %SD -- SPI diagnostic messages enable
whismanoid 15:37c83ec50ea0 5946 if (g_MAX5719_device.onSPIprint) {
whismanoid 15:37c83ec50ea0 5947 g_MAX5719_device.onSPIprint = NULL;
whismanoid 15:37c83ec50ea0 5948 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') != None is false
whismanoid 15:37c83ec50ea0 5949 }
whismanoid 15:37c83ec50ea0 5950 else {
whismanoid 15:37c83ec50ea0 5951 void onSPIprint_handler(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]);
whismanoid 15:37c83ec50ea0 5952 g_MAX5719_device.onSPIprint = onSPIprint_handler;
whismanoid 15:37c83ec50ea0 5953 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') is false
whismanoid 15:37c83ec50ea0 5954 }
whismanoid 15:37c83ec50ea0 5955 break;
whismanoid 15:37c83ec50ea0 5956 case 'W': case 'R': case 'w': case 'r':
whismanoid 15:37c83ec50ea0 5957 {
whismanoid 15:37c83ec50ea0 5958 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 5959 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 5960 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5961 #define MAX_SPI_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 5962 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 5963 static char mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5964 static char misoData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5965 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 5966 MAX_SPI_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 5967 {
whismanoid 15:37c83ec50ea0 5968 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5969 cmdLine.serial().printf("\r\nSPI");
whismanoid 15:37c83ec50ea0 5970 if (byteCount > 7) {
whismanoid 15:37c83ec50ea0 5971 cmdLine.serial().printf(" byteCount:%d", byteCount);
whismanoid 15:37c83ec50ea0 5972 }
whismanoid 15:37c83ec50ea0 5973 cmdLine.serial().printf(" MOSI->");
whismanoid 15:37c83ec50ea0 5974 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 5975 {
whismanoid 15:37c83ec50ea0 5976 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 5977 }
whismanoid 15:37c83ec50ea0 5978 spi_cs = 0;
whismanoid 15:37c83ec50ea0 5979 unsigned int numBytesTransferred =
whismanoid 15:37c83ec50ea0 5980 spi.write(mosiData, byteCount, misoData, byteCount);
whismanoid 15:37c83ec50ea0 5981 spi_cs = 1;
whismanoid 15:37c83ec50ea0 5982 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5983 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 5984 for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred;
whismanoid 15:37c83ec50ea0 5985 byteIndex++)
whismanoid 15:37c83ec50ea0 5986 {
whismanoid 15:37c83ec50ea0 5987 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 5988 }
whismanoid 15:37c83ec50ea0 5989 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 5990 }
whismanoid 15:37c83ec50ea0 5991 }
whismanoid 15:37c83ec50ea0 5992 break;
whismanoid 15:37c83ec50ea0 5993 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 5994 } // case 'S': // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 5995 break;
whismanoid 15:37c83ec50ea0 5996 #endif
whismanoid 15:37c83ec50ea0 5997 //
whismanoid 15:37c83ec50ea0 5998 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 5999 } // switch(cmdLine[1])
whismanoid 15:37c83ec50ea0 6000 } // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 15:37c83ec50ea0 6001 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 15:37c83ec50ea0 6002
whismanoid 15:37c83ec50ea0 6003 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 6004 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 6005 void main_menu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 6006 {
whismanoid 9:45f98573eb6d 6007 // process command line
whismanoid 31:47eee7e0cc2d 6008 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 6009 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6010 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 6011 #endif // USE_DATALOGGER_CommandTable
whismanoid 48:18647e0516f2 6012 //~ cmdLine.serial().printf("\r\nCmdLine buf:\"%s\"\r\n", cmdLine.str());
whismanoid 45:74bf1fe021e5 6013 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6014 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 6015 #endif // USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6016 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 6017 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6018 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 6019 #endif // USE_DATALOGGER_CommandTable
whismanoid 45:74bf1fe021e5 6020 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6021 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 6022 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 6023
whismanoid 4:d9b05924ad4c 6024 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 31:47eee7e0cc2d 6025 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 6026 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6027 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 6028 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 6029 // If datalog is free running, halt on any possible received command
whismanoid 17:9397ea3ea7e9 6030 if (Datalogger_Trigger != trigger_Halt) {
whismanoid 4:d9b05924ad4c 6031 Datalogger_Trigger = trigger_Halt;
whismanoid 9:45f98573eb6d 6032 cmdLine.serial().printf("Datalog stopped by USB command input\r\n");
whismanoid 9:45f98573eb6d 6033 cmdLine.serial().printf("Restart datalog by sending LR\r\n");
whismanoid 4:d9b05924ad4c 6034 }
whismanoid 45:74bf1fe021e5 6035 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6036 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 6037 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 6038 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 6039
whismanoid 4:d9b05924ad4c 6040 // DIAGNOSTIC: print line buffer
whismanoid 4:d9b05924ad4c 6041 //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str());
whismanoid 4:d9b05924ad4c 6042 //
whismanoid 4:d9b05924ad4c 6043 switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 6044 {
whismanoid 4:d9b05924ad4c 6045 case '?':
whismanoid 4:d9b05924ad4c 6046 main_menu_status(cmdLine);
whismanoid 4:d9b05924ad4c 6047 main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 6048 // print command prompt
whismanoid 4:d9b05924ad4c 6049 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 6050 break;
whismanoid 4:d9b05924ad4c 6051 case '\r': case '\n': // ignore blank line
whismanoid 4:d9b05924ad4c 6052 case '\0': // ignore empty line
whismanoid 30:07197a430869 6053 main_menu_status(cmdLine);
whismanoid 30:07197a430869 6054 //~ main_menu_help(cmdLine);
whismanoid 30:07197a430869 6055 // print command prompt
whismanoid 30:07197a430869 6056 //cmdLine.serial().printf("\r\n>");
whismanoid 30:07197a430869 6057 break;
whismanoid 4:d9b05924ad4c 6058 case '#': // ignore comment line
whismanoid 4:d9b05924ad4c 6059 // # -- lines beginning with # are comments
whismanoid 30:07197a430869 6060 //
whismanoid 30:07197a430869 6061 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 6062 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in main_menu_onEOLcommandParser
whismanoid 30:07197a430869 6063 // # command handler update gstrRemarkText buffer instead of just ignoring the remark
whismanoid 30:07197a430869 6064 //
whismanoid 30:07197a430869 6065 // ignore extra spaces before the remark
whismanoid 30:07197a430869 6066 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 30:07197a430869 6067 int argIndex;
whismanoid 30:07197a430869 6068 for (argIndex = 1; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 6069 {
whismanoid 30:07197a430869 6070 if (cmdLine[argIndex] == ' ') break;
whismanoid 30:07197a430869 6071 }
whismanoid 30:07197a430869 6072 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 6073 {
whismanoid 30:07197a430869 6074 if (cmdLine[argIndex] != ' ') break;
whismanoid 30:07197a430869 6075 }
whismanoid 30:07197a430869 6076 //
whismanoid 30:07197a430869 6077 strncpy(gstrRemarkText, cmdLine.str()+argIndex, gstrRemarkTextLASTINDEX+1);
whismanoid 30:07197a430869 6078 // do not exceed string buffer limit; keep sentinel null character at end of buffer
whismanoid 30:07197a430869 6079 gstrRemarkText[gstrRemarkTextLASTINDEX] = '\0';
whismanoid 41:13a6a097502c 6080 for (unsigned int index = 0; index < gstrRemarkTextLASTINDEX; index++)
whismanoid 30:07197a430869 6081 {
whismanoid 30:07197a430869 6082 if ((gstrRemarkText[index]) == '\0') break; // null character at end of string
whismanoid 30:07197a430869 6083 if ((gstrRemarkText[index]) < 0x20) {
whismanoid 30:07197a430869 6084 // replace non-printing characters with _
whismanoid 30:07197a430869 6085 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 6086 continue;
whismanoid 30:07197a430869 6087 }
whismanoid 30:07197a430869 6088 if ((gstrRemarkText[index]) >= 0x7F) {
whismanoid 30:07197a430869 6089 // replace non-printing characters with _
whismanoid 30:07197a430869 6090 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 6091 continue;
whismanoid 30:07197a430869 6092 }
whismanoid 30:07197a430869 6093 switch(gstrRemarkText[index])
whismanoid 30:07197a430869 6094 {
whismanoid 30:07197a430869 6095 case ',':
whismanoid 30:07197a430869 6096 // replace , with ;
whismanoid 30:07197a430869 6097 gstrRemarkText[index] = ';';
whismanoid 30:07197a430869 6098 break;
whismanoid 30:07197a430869 6099 case '"':
whismanoid 30:07197a430869 6100 // replace " with '
whismanoid 30:07197a430869 6101 gstrRemarkText[index] = '\'';
whismanoid 30:07197a430869 6102 break;
whismanoid 30:07197a430869 6103 case '\\':
whismanoid 30:07197a430869 6104 // replace \ with /
whismanoid 30:07197a430869 6105 gstrRemarkText[index] = '/';
whismanoid 30:07197a430869 6106 break;
whismanoid 30:07197a430869 6107 }
whismanoid 30:07197a430869 6108 }
whismanoid 30:07197a430869 6109 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 6110 //
whismanoid 31:47eee7e0cc2d 6111 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 6112 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6113 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 6114 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 6115 main_menu_status(cmdLine);
whismanoid 45:74bf1fe021e5 6116 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 6117 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 6118 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 6119 //~ main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 6120 // print command prompt
whismanoid 4:d9b05924ad4c 6121 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 6122 break;
whismanoid 4:d9b05924ad4c 6123 #if ECHO_EOF_ON_EOL
whismanoid 4:d9b05924ad4c 6124 case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file
whismanoid 4:d9b05924ad4c 6125 cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 6126 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 6127 break;
whismanoid 4:d9b05924ad4c 6128 case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file
whismanoid 4:d9b05924ad4c 6129 cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 6130 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 6131 break;
whismanoid 4:d9b05924ad4c 6132 #endif
whismanoid 10:04022a61b527 6133 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6134 case '!': // device init
whismanoid 10:04022a61b527 6135 {
whismanoid 10:04022a61b527 6136 cmdLine.serial().printf("Init");
whismanoid 10:04022a61b527 6137 // call function Init
whismanoid 10:04022a61b527 6138 uint8_t result = g_MAX11410_device.Init();
whismanoid 10:04022a61b527 6139 // cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 6140 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 6141 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 6142 // in command '!' device init, apply list of custom register writes after init
whismanoid 10:04022a61b527 6143 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 6144 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 10:04022a61b527 6145 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 10:04022a61b527 6146 uint32_t regData = custom_reg_init_data[index];
whismanoid 10:04022a61b527 6147 cmdLine.serial().printf("*%s=0x%06.6x",
whismanoid 10:04022a61b527 6148 g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress),
whismanoid 10:04022a61b527 6149 regData
whismanoid 10:04022a61b527 6150 );
whismanoid 10:04022a61b527 6151 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 10:04022a61b527 6152 }
whismanoid 10:04022a61b527 6153 #endif // USE_CUSTOM_REG_INIT
whismanoid 10:04022a61b527 6154 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 6155 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 6156 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 6157 }
whismanoid 10:04022a61b527 6158 break;
whismanoid 10:04022a61b527 6159 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 6160 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 6161 case '.':
whismanoid 4:d9b05924ad4c 6162 {
whismanoid 4:d9b05924ad4c 6163 // . -- SelfTest
whismanoid 4:d9b05924ad4c 6164 cmdLine.serial().printf("SelfTest()");
whismanoid 4:d9b05924ad4c 6165 SelfTest(cmdLine);
whismanoid 4:d9b05924ad4c 6166 }
whismanoid 4:d9b05924ad4c 6167 break;
whismanoid 4:d9b05924ad4c 6168 #endif // USE_SELFTEST
whismanoid 15:37c83ec50ea0 6169 #if 1 // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 6170 case '%':
whismanoid 4:d9b05924ad4c 6171 {
whismanoid 4:d9b05924ad4c 6172 pinsMonitor_submenu_onEOLcommandParser(cmdLine);
whismanoid 4:d9b05924ad4c 6173 }
whismanoid 4:d9b05924ad4c 6174 break; // case '%'
whismanoid 4:d9b05924ad4c 6175 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 9:45f98573eb6d 6176 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 6177 // reuse the Serial_Tester command *regName=regValue
whismanoid 10:04022a61b527 6178 // CODE GENERATOR: generate * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 6179 case '*':
whismanoid 10:04022a61b527 6180 {
whismanoid 10:04022a61b527 6181 // if buffer starts with a regName:
whismanoid 10:04022a61b527 6182 // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))):
whismanoid 10:04022a61b527 6183 // cmdLine.serial().printf(" scan RegName...\r\n");
whismanoid 10:04022a61b527 6184 }
whismanoid 10:04022a61b527 6185 break;
whismanoid 9:45f98573eb6d 6186 #endif // USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 6187 //
whismanoid 10:04022a61b527 6188 #if 1 // USE_AUX_SERIAL_CMD_FORWARDING && (HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL)
whismanoid 10:04022a61b527 6189 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_onEOLcommandParser
whismanoid 40:330b28116178 6190 case '>': case '<': // > send and receive; < receive without sending anything
whismanoid 10:04022a61b527 6191 {
whismanoid 10:04022a61b527 6192 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 6193 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 6194 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 6195 CmdLine& cmdLine_AuxSerial = cmdLine_AUXserial;
whismanoid 10:04022a61b527 6196 Serial& AuxSerial = AUXserial;
whismanoid 10:04022a61b527 6197 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6198 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 6199 CmdLine& cmdLine_AuxSerial = cmdLine_DAPLINKserial;
whismanoid 10:04022a61b527 6200 Serial& AuxSerial = DAPLINKserial;
whismanoid 10:04022a61b527 6201 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6202 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 6203 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6204 //
whismanoid 40:330b28116178 6205 int g_auxSerialCom_outgoing_string_cr = 1; // option to send CR after outgoing_string
whismanoid 40:330b28116178 6206 int g_auxSerialCom_outgoing_string_lf = 0; // option to send LF after outgoing_string (breaks remote datalogger LR!)
whismanoid 40:330b28116178 6207 int g_auxSerialCom_rx_string_verbose_crlf = 0; // option to display \r\n as "\\r\\n" in rx_string_buf
whismanoid 40:330b28116178 6208 int g_auxSerialCom_rx_string_verbose_ctrl = 1; // option to display control codes as \xXX
whismanoid 40:330b28116178 6209 const char* g_auxSerialCom_display_tx_prefix = "\r\n->|"; // "\r\n >";
whismanoid 40:330b28116178 6210 const char* g_auxSerialCom_display_rx_prefix = "\r\n<-|"; // "\r\n< ";
whismanoid 40:330b28116178 6211 //
whismanoid 40:330b28116178 6212 bool need_g_auxSerialCom_display_rx_prefix = 1; // temp
whismanoid 40:330b28116178 6213 //
whismanoid 10:04022a61b527 6214 // >> suppress key=value parsing
whismanoid 10:04022a61b527 6215 bool suppress_parsing = (cmdLine[1] == '>');
whismanoid 10:04022a61b527 6216 if (suppress_parsing == false) {
whismanoid 10:04022a61b527 6217 // int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 6218 if (cmdLine.parse_int_dec("baud", g_auxSerialCom_baud))
whismanoid 10:04022a61b527 6219 {
whismanoid 10:04022a61b527 6220 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- baud rate
whismanoid 10:04022a61b527 6221 cmdLine_AuxSerial.serial().printf("\r\n*** New Baud Rate %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6222 AuxSerial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6223 cmdLine_AuxSerial.serial().printf("\r\n*** Baud Rate was set to %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6224 }
whismanoid 10:04022a61b527 6225 #if 0
whismanoid 10:04022a61b527 6226 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 6227 if (cmdLine.parse_int_dec("tx_wait_echo", g_auxSerialCom_tx_wait_echo))
whismanoid 10:04022a61b527 6228 {
whismanoid 10:04022a61b527 6229 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_wait_echo
whismanoid 10:04022a61b527 6230 //~ cmdLine_AuxSerial.serial().printf("\r\n*** tx_wait_echo was set to %d ***\r\n", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 6231 cmdLine.serial().printf("\r\n tx_wait_echo=%d", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 6232 }
whismanoid 10:04022a61b527 6233 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 6234 if (cmdLine.parse_int_dec("tx_char_delay_ms", g_auxSerialCom_tx_char_delay_ms))
whismanoid 10:04022a61b527 6235 {
whismanoid 10:04022a61b527 6236 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_char_delay_ms
whismanoid 10:04022a61b527 6237 //~ 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 6238 cmdLine.serial().printf("\r\n tx_char_delay_ms=%dms", g_auxSerialCom_tx_char_delay_ms);
whismanoid 10:04022a61b527 6239 }
whismanoid 10:04022a61b527 6240 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 6241 if (cmdLine.parse_int_dec("tx_line_delay_ms", g_auxSerialCom_tx_line_delay_ms))
whismanoid 10:04022a61b527 6242 {
whismanoid 10:04022a61b527 6243 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_line_delay_ms
whismanoid 10:04022a61b527 6244 //~ 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 6245 cmdLine.serial().printf("\r\n tx_line_delay_ms=%dms", g_auxSerialCom_tx_line_delay_ms);
whismanoid 10:04022a61b527 6246 }
whismanoid 10:04022a61b527 6247 #endif
whismanoid 10:04022a61b527 6248 // int g_auxSerialCom_message_ms = 0; //!< capture RX until response timeout?
whismanoid 10:04022a61b527 6249 if (cmdLine.parse_int_dec("message_ms", g_auxSerialCom_message_ms))
whismanoid 10:04022a61b527 6250 {
whismanoid 10:04022a61b527 6251 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 10:04022a61b527 6252 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 6253 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 6254 }
whismanoid 10:04022a61b527 6255 // int g_auxSerialCom_rx_idle_ms = 0; //!< capture RX until idle timeout?
whismanoid 10:04022a61b527 6256 if (cmdLine.parse_int_dec("rx_idle_ms", g_auxSerialCom_rx_idle_ms))
whismanoid 10:04022a61b527 6257 {
whismanoid 10:04022a61b527 6258 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_idle_ms
whismanoid 10:04022a61b527 6259 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_idle_ms was set to %d ***\r\n", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 6260 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 6261 }
whismanoid 10:04022a61b527 6262 // int g_auxSerialCom_rx_max_count = 0; //!< capture RX until max character count?
whismanoid 10:04022a61b527 6263 if (cmdLine.parse_int_dec("rx_max_count", g_auxSerialCom_rx_max_count))
whismanoid 10:04022a61b527 6264 {
whismanoid 10:04022a61b527 6265 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_max_count
whismanoid 10:04022a61b527 6266 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_max_count was set to %d ***\r\n", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 6267 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 6268 }
whismanoid 10:04022a61b527 6269 // int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text char?
whismanoid 10:04022a61b527 6270 if (cmdLine.parse_int_dec("rx_eot", g_auxSerialCom_rx_eot))
whismanoid 10:04022a61b527 6271 {
whismanoid 10:04022a61b527 6272 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_eot
whismanoid 10:04022a61b527 6273 //~ cmdLine_AUXserial.serial().printf("\r\n*** rx_eot was set to %d ***\r\n", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 6274 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 6275 }
whismanoid 10:04022a61b527 6276 }
whismanoid 10:04022a61b527 6277 // Command forwarding to AUX serial TX/RX cmdLine_AuxSerial #257 -- send outgoing_string
whismanoid 41:13a6a097502c 6278 char* outgoing_string = ""; // warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
whismanoid 40:330b28116178 6279 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 6280 outgoing_string = (char*)cmdLine.str();
whismanoid 40:330b28116178 6281 // > use key=value parsing
whismanoid 40:330b28116178 6282 // >> suppress key=value parsing
whismanoid 40:330b28116178 6283 if (suppress_parsing) {
whismanoid 40:330b28116178 6284 cmdLine.serial().printf("\r\n suppress_parsing outgoing_string=\"%s\"", outgoing_string);
whismanoid 40:330b28116178 6285 outgoing_string++; // skip the first '>'
whismanoid 40:330b28116178 6286 outgoing_string++; // skip the second '>'
whismanoid 40:330b28116178 6287 } else {
whismanoid 40:330b28116178 6288 // TODO: after parsing, key=value pairs should be deleted, but outgoing_string=">xyzzy abc=def"
whismanoid 40:330b28116178 6289 cmdLine.serial().printf("\r\n after parsing, outgoing_string=\"%s\"", outgoing_string);
whismanoid 40:330b28116178 6290 outgoing_string++; // skip the first '>'
whismanoid 40:330b28116178 6291 }
whismanoid 40:330b28116178 6292 } // if (cmdLine[0] == '>')
whismanoid 10:04022a61b527 6293 static char rx_string_buf[RX_STRING_BUF_SIZE];
whismanoid 10:04022a61b527 6294 unsigned int rx_string_length = 0;
whismanoid 40:330b28116178 6295 //cmdLine.serial().printf("\r\n >%s\r\n <", outgoing_string);
whismanoid 40:330b28116178 6296 //char* g_auxSerialCom_display_tx_prefix = "\r\n >";
whismanoid 40:330b28116178 6297 //char* g_auxSerialCom_display_rx_prefix = "\r\n< ";
whismanoid 40:330b28116178 6298 cmdLine.serial().printf("%s%s%s",
whismanoid 40:330b28116178 6299 g_auxSerialCom_display_tx_prefix, // "\r\n >"
whismanoid 40:330b28116178 6300 outgoing_string,
whismanoid 40:330b28116178 6301 g_auxSerialCom_display_rx_prefix // "\r\n <"
whismanoid 40:330b28116178 6302 );
whismanoid 10:04022a61b527 6303 rx_string_buf[0] = '\0';
whismanoid 10:04022a61b527 6304 rx_string_length = 0;
whismanoid 10:04022a61b527 6305 //
whismanoid 10:04022a61b527 6306 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 6307 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 6308 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 6309 //
whismanoid 10:04022a61b527 6310 // int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 6311 // int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 6312 // int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 6313 // int g_auxSerialCom_rx_idle_ms = 2000; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 6314 // int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 6315 // int g_auxSerialCom_rx_eot = '\r'; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 6316 //~ cmdLine_AuxSerial.serial().printf("\r\n*** TODO forward %s ***\r\n", outgoing_string);
whismanoid 10:04022a61b527 6317 //
whismanoid 10:04022a61b527 6318 // TODO: send whole string or send character-by-character?
whismanoid 40:330b28116178 6319 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 6320 cmdLine_AuxSerial.serial().printf("%s", outgoing_string);
whismanoid 40:330b28116178 6321 //
whismanoid 40:330b28116178 6322 // TODO: send CRLF or just send CR line end?
whismanoid 40:330b28116178 6323 if (g_auxSerialCom_outgoing_string_cr) { cmdLine_AuxSerial.serial().printf("\r"); }
whismanoid 40:330b28116178 6324 if (g_auxSerialCom_outgoing_string_lf) { cmdLine_AuxSerial.serial().printf("\n"); }
whismanoid 40:330b28116178 6325 // cmdLine_AuxSerial.serial().printf("\r\n");
whismanoid 40:330b28116178 6326 } // if (cmdLine[0] == '>')
whismanoid 40:330b28116178 6327 //
whismanoid 10:04022a61b527 6328 g_auxSerialCom_Timer.start();
whismanoid 10:04022a61b527 6329 g_auxSerialCom_Timer_begin_message_ms = g_auxSerialCom_Timer.read_ms(); // start of message
whismanoid 10:04022a61b527 6330 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 6331 while (rx_string_length < (RX_STRING_BUF_SIZE-1)) {
whismanoid 10:04022a61b527 6332 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_message_ms) > g_auxSerialCom_message_ms) {
whismanoid 10:04022a61b527 6333 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 6334 break;
whismanoid 10:04022a61b527 6335 }
whismanoid 10:04022a61b527 6336 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_rx_idle_ms) > g_auxSerialCom_rx_idle_ms) {
whismanoid 10:04022a61b527 6337 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 6338 break;
whismanoid 10:04022a61b527 6339 }
whismanoid 41:13a6a097502c 6340 if ((int)rx_string_length >= g_auxSerialCom_rx_max_count) {
whismanoid 10:04022a61b527 6341 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 6342 break;
whismanoid 10:04022a61b527 6343 }
whismanoid 10:04022a61b527 6344 if (AuxSerial.readable()) {
whismanoid 10:04022a61b527 6345 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 6346 char ch = AuxSerial.getc();
whismanoid 10:04022a61b527 6347 rx_string_buf[rx_string_length++] = ch;
whismanoid 10:04022a61b527 6348 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 40:330b28116178 6349 //
whismanoid 40:330b28116178 6350 #if 1
whismanoid 40:330b28116178 6351 // immediate character echo
whismanoid 40:330b28116178 6352 for (char* cp = &(rx_string_buf[rx_string_length-1]); *cp != '\0'; cp++)
whismanoid 40:330b28116178 6353 {
whismanoid 40:330b28116178 6354 //cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 6355 if (need_g_auxSerialCom_display_rx_prefix) {
whismanoid 40:330b28116178 6356 cmdLine.serial().printf(g_auxSerialCom_display_rx_prefix); // "\r\n< " g_auxSerialCom_rx_string display prefix
whismanoid 40:330b28116178 6357 need_g_auxSerialCom_display_rx_prefix = 0;
whismanoid 40:330b28116178 6358 }
whismanoid 40:330b28116178 6359 if ((*cp) == '\r') {
whismanoid 40:330b28116178 6360 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\r"); }
whismanoid 40:330b28116178 6361 // if (*(cp+1) != '\n') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 6362 } else if ((*cp) == '\n') {
whismanoid 40:330b28116178 6363 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\n"); }
whismanoid 40:330b28116178 6364 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 6365 if (*(cp-1) != '\r') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 6366 } else if ((*cp) < 0x20) {
whismanoid 40:330b28116178 6367 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6368 } else if ((*cp) >= 0x7f) {
whismanoid 40:330b28116178 6369 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6370 } else {
whismanoid 40:330b28116178 6371 cmdLine.serial().printf("%c", *cp);
whismanoid 40:330b28116178 6372 }
whismanoid 40:330b28116178 6373 }
whismanoid 40:330b28116178 6374 #else
whismanoid 40:330b28116178 6375 // immediate character echo
whismanoid 40:330b28116178 6376 cmdLine.serial().printf("%s", &(rx_string_buf[rx_string_length-1]) );
whismanoid 40:330b28116178 6377 #endif
whismanoid 40:330b28116178 6378 //
whismanoid 10:04022a61b527 6379 if (g_auxSerialCom_rx_eot != aux_serial_cmd_forwarding_rx_eot_not_used) {
whismanoid 10:04022a61b527 6380 if (ch == g_auxSerialCom_rx_eot) {
whismanoid 10:04022a61b527 6381 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 6382 break;
whismanoid 10:04022a61b527 6383 }
whismanoid 10:04022a61b527 6384 }
whismanoid 10:04022a61b527 6385 }
whismanoid 10:04022a61b527 6386 } // end while (rx_string_length < (RX_STRING_BUF_SIZE-1))
whismanoid 40:330b28116178 6387 #if 0
whismanoid 10:04022a61b527 6388 // print summary. is this needed? we already print aux rx as it is received.
whismanoid 10:04022a61b527 6389 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 40:330b28116178 6390 # if 1 // support multi-line rx_string_buf response
whismanoid 40:330b28116178 6391 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 6392 cmdLine.serial().printf("%s%s", g_auxSerialCom_display_tx_prefix, outgoing_string);
whismanoid 40:330b28116178 6393 } // if (cmdLine[0] == '>')
whismanoid 40:330b28116178 6394 // cmdLine.serial().printf("\r\n <"); // prefix
whismanoid 40:330b28116178 6395 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 6396 for (char* cp = rx_string_buf; *cp != '\0'; cp++)
whismanoid 40:330b28116178 6397 {
whismanoid 40:330b28116178 6398 //cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 6399 if (need_g_auxSerialCom_display_rx_prefix) {
whismanoid 40:330b28116178 6400 cmdLine.serial().printf(g_auxSerialCom_display_rx_prefix); // "\r\n< " g_auxSerialCom_rx_string display prefix
whismanoid 40:330b28116178 6401 need_g_auxSerialCom_display_rx_prefix = 0;
whismanoid 40:330b28116178 6402 }
whismanoid 40:330b28116178 6403 if ((*cp) == '\r') {
whismanoid 40:330b28116178 6404 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\r"); }
whismanoid 40:330b28116178 6405 if (*(cp+1) != '\n') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 6406 } else if ((*cp) == '\n') {
whismanoid 40:330b28116178 6407 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\n"); }
whismanoid 40:330b28116178 6408 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 6409 } else if ((*cp) < 0x20) {
whismanoid 40:330b28116178 6410 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6411 } else if ((*cp) >= 0x7f) {
whismanoid 40:330b28116178 6412 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6413 } else {
whismanoid 40:330b28116178 6414 cmdLine.serial().printf("%c", *cp);
whismanoid 40:330b28116178 6415 }
whismanoid 40:330b28116178 6416 }
whismanoid 40:330b28116178 6417 cmdLine.serial().printf("\r\n");
whismanoid 40:330b28116178 6418 # else
whismanoid 10:04022a61b527 6419 cmdLine.serial().printf("\r\n >%s", outgoing_string);
whismanoid 10:04022a61b527 6420 cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 6421 # endif
whismanoid 10:04022a61b527 6422 #endif
whismanoid 10:04022a61b527 6423 //
whismanoid 10:04022a61b527 6424 }
whismanoid 10:04022a61b527 6425 break; // case '>'
whismanoid 10:04022a61b527 6426 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6427 //
whismanoid 4:d9b05924ad4c 6428 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 6429 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 6430 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 6431 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 6432 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible
whismanoid 9:45f98573eb6d 6433 case 'L': case 'l':
whismanoid 4:d9b05924ad4c 6434 {
whismanoid 4:d9b05924ad4c 6435 // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 6436 Datalogger_Trigger = trigger_Halt;
whismanoid 4:d9b05924ad4c 6437 switch (cmdLine[1])
whismanoid 4:d9b05924ad4c 6438 {
whismanoid 17:9397ea3ea7e9 6439 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 6440 case 'T': case 't':
whismanoid 17:9397ea3ea7e9 6441 {
whismanoid 17:9397ea3ea7e9 6442 // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 6443 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 6444 Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6445 g_timer_interval_counter = 0;
whismanoid 39:4d285e961435 6446 // get g_timer_interval_msec from cmdLine
whismanoid 17:9397ea3ea7e9 6447 // g_timer_interval_msec = 500;
whismanoid 17:9397ea3ea7e9 6448 // g_timer_interval_count = 10;
whismanoid 17:9397ea3ea7e9 6449 if (cmdLine.parse_int_dec("count", g_timer_interval_count))
whismanoid 17:9397ea3ea7e9 6450 {
whismanoid 32:80f3e5eb77d4 6451 if (g_timer_interval_count < 1) { g_timer_interval_count = 1; }
whismanoid 17:9397ea3ea7e9 6452 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 6453 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 6454 cmdLine.serial().printf("\r\n g_timer_interval_count=%d", g_timer_interval_count);
whismanoid 17:9397ea3ea7e9 6455 }
whismanoid 17:9397ea3ea7e9 6456 if (cmdLine.parse_int_dec("base", g_timer_interval_msec))
whismanoid 17:9397ea3ea7e9 6457 {
whismanoid 17:9397ea3ea7e9 6458 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 6459 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 6460 cmdLine.serial().printf("\r\n g_timer_interval_msec=%d", g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 6461 }
whismanoid 39:4d285e961435 6462 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 6463 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 6464 int int_timer_sleepmode = g_timer_sleepmode;
whismanoid 39:4d285e961435 6465 if (cmdLine.parse_int_dec("sleep", int_timer_sleepmode))
whismanoid 39:4d285e961435 6466 {
whismanoid 39:4d285e961435 6467 g_timer_sleepmode = (Datalogger_Sleep_enum_t)int_timer_sleepmode;
whismanoid 39:4d285e961435 6468 //~ if (g_timer_interval_count < 1) { g_timer_interval_count = 1; }
whismanoid 39:4d285e961435 6469 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 39:4d285e961435 6470 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 39:4d285e961435 6471 cmdLine.serial().printf("\r\n g_timer_sleepmode=%d", (int)g_timer_sleepmode);
whismanoid 39:4d285e961435 6472 }
whismanoid 39:4d285e961435 6473 #else // USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 6474 #endif // USE_DATALOGGER_SLEEP
whismanoid 17:9397ea3ea7e9 6475 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 17:9397ea3ea7e9 6476 }
whismanoid 17:9397ea3ea7e9 6477 break;
whismanoid 17:9397ea3ea7e9 6478 // LIH3 -- Datalog when input high D3
whismanoid 17:9397ea3ea7e9 6479 // LIL6 -- Datalog when input low D6
whismanoid 17:9397ea3ea7e9 6480 case 'I': case 'i':
whismanoid 17:9397ea3ea7e9 6481 {
whismanoid 17:9397ea3ea7e9 6482 // TODO: switch cmdLine[2] configure High or Low, configure input pin
whismanoid 17:9397ea3ea7e9 6483 }
whismanoid 17:9397ea3ea7e9 6484 break;
whismanoid 17:9397ea3ea7e9 6485 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 6486 // L$ count=10 base=500ms addr=xxx data=xxx mask=xxx -- Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 6487 case '$':
whismanoid 17:9397ea3ea7e9 6488 {
whismanoid 17:9397ea3ea7e9 6489 // TODO: scan cmdLine for regAddr, dataMask, testValue
whismanoid 17:9397ea3ea7e9 6490 }
whismanoid 17:9397ea3ea7e9 6491 break;
whismanoid 17:9397ea3ea7e9 6492 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6493 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6494 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6495 case '@':
whismanoid 17:9397ea3ea7e9 6496 {
whismanoid 17:9397ea3ea7e9 6497 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6498 int editRowIndex = 0;
whismanoid 17:9397ea3ea7e9 6499 int edit_action = (int)action_noop;
whismanoid 17:9397ea3ea7e9 6500 int edit_digitalOutPin = 0;
whismanoid 17:9397ea3ea7e9 6501 int edit_condition = (int)condition_always;
whismanoid 17:9397ea3ea7e9 6502 int edit_condition_channel = 0;
whismanoid 17:9397ea3ea7e9 6503 double edit_condition_threshold = 0;
whismanoid 17:9397ea3ea7e9 6504 //
whismanoid 17:9397ea3ea7e9 6505 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 17:9397ea3ea7e9 6506 {
whismanoid 17:9397ea3ea7e9 6507 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 17:9397ea3ea7e9 6508 }
whismanoid 17:9397ea3ea7e9 6509 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 17:9397ea3ea7e9 6510 {
whismanoid 17:9397ea3ea7e9 6511 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 17:9397ea3ea7e9 6512 }
whismanoid 17:9397ea3ea7e9 6513 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 17:9397ea3ea7e9 6514 {
whismanoid 17:9397ea3ea7e9 6515 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 17:9397ea3ea7e9 6516 }
whismanoid 17:9397ea3ea7e9 6517 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 17:9397ea3ea7e9 6518 {
whismanoid 17:9397ea3ea7e9 6519 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 17:9397ea3ea7e9 6520 }
whismanoid 17:9397ea3ea7e9 6521 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 17:9397ea3ea7e9 6522 {
whismanoid 17:9397ea3ea7e9 6523 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 17:9397ea3ea7e9 6524 }
whismanoid 17:9397ea3ea7e9 6525 //
whismanoid 17:9397ea3ea7e9 6526 // Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6527 switch (cmdLine[2]) // L@... -- Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6528 {
whismanoid 17:9397ea3ea7e9 6529 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 6530 case '0': case '1': case '2': case '3': case '4':
whismanoid 17:9397ea3ea7e9 6531 case '5': case '6': case '7': case '8': case '9':
whismanoid 17:9397ea3ea7e9 6532 // edit row data
whismanoid 30:07197a430869 6533 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 6534 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 6535 // get row number to edit from cmdLine[2]
whismanoid 17:9397ea3ea7e9 6536 editRowIndex = atoi(cmdLine.str()+2);
whismanoid 30:07197a430869 6537 if ((editRowIndex >= 0) && (editRowIndex < Datalogger_action_table_row_count)) {
whismanoid 30:07197a430869 6538 // update row
whismanoid 30:07197a430869 6539 cmdLine.serial().printf("\r\n replace row %d", editRowIndex);
whismanoid 30:07197a430869 6540 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 6541 edit_action = Datalogger_action_table[editRowIndex].action;
whismanoid 30:07197a430869 6542 edit_digitalOutPin = Datalogger_action_table[editRowIndex].digitalOutPin;
whismanoid 30:07197a430869 6543 edit_condition = Datalogger_action_table[editRowIndex].condition;
whismanoid 30:07197a430869 6544 edit_condition_channel = Datalogger_action_table[editRowIndex].condition_channel;
whismanoid 30:07197a430869 6545 edit_condition_threshold = Datalogger_action_table[editRowIndex].condition_threshold;
whismanoid 30:07197a430869 6546 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 6547 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 30:07197a430869 6548 {
whismanoid 30:07197a430869 6549 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 30:07197a430869 6550 }
whismanoid 30:07197a430869 6551 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 30:07197a430869 6552 {
whismanoid 30:07197a430869 6553 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 30:07197a430869 6554 }
whismanoid 30:07197a430869 6555 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 30:07197a430869 6556 {
whismanoid 30:07197a430869 6557 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 30:07197a430869 6558 }
whismanoid 30:07197a430869 6559 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 30:07197a430869 6560 {
whismanoid 30:07197a430869 6561 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 30:07197a430869 6562 }
whismanoid 30:07197a430869 6563 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 30:07197a430869 6564 {
whismanoid 30:07197a430869 6565 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 30:07197a430869 6566 }
whismanoid 30:07197a430869 6567 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 6568 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 6569 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 6570 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 6571 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 6572 }
whismanoid 30:07197a430869 6573 else if ((editRowIndex == Datalogger_action_table_row_count) && (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX)) {
whismanoid 30:07197a430869 6574 // %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 6575 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 6576 cmdLine.serial().printf("\r\n add next row %d", editRowIndex);
whismanoid 30:07197a430869 6577 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 6578 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 6579 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 6580 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 6581 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 30:07197a430869 6582 //
whismanoid 17:9397ea3ea7e9 6583 }
whismanoid 17:9397ea3ea7e9 6584 }
whismanoid 17:9397ea3ea7e9 6585 break;
whismanoid 17:9397ea3ea7e9 6586 case '+':
whismanoid 17:9397ea3ea7e9 6587 // add a new row at end of table
whismanoid 17:9397ea3ea7e9 6588 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 6589 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 6590 editRowIndex = Datalogger_action_table_row_count;
whismanoid 17:9397ea3ea7e9 6591 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 6592 cmdLine.serial().printf("\r\n add new row %d", editRowIndex);
whismanoid 17:9397ea3ea7e9 6593 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 17:9397ea3ea7e9 6594 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 17:9397ea3ea7e9 6595 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 17:9397ea3ea7e9 6596 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 17:9397ea3ea7e9 6597 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 6598 }
whismanoid 17:9397ea3ea7e9 6599 break;
whismanoid 17:9397ea3ea7e9 6600 case '-':
whismanoid 17:9397ea3ea7e9 6601 // delete row from table
whismanoid 17:9397ea3ea7e9 6602 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 6603 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 6604 if ((cmdLine[3] == '~') && (cmdLine[4] == '~') && (cmdLine[5] == '~')) {
whismanoid 17:9397ea3ea7e9 6605 // L@-~~~ -- delete all rows from table
whismanoid 30:07197a430869 6606 cmdLine.serial().printf("\r\n delete all rows");
whismanoid 17:9397ea3ea7e9 6607 Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 6608 break;
whismanoid 17:9397ea3ea7e9 6609 }
whismanoid 30:07197a430869 6610 else {
whismanoid 30:07197a430869 6611 editRowIndex = atoi(cmdLine.str()+3);
whismanoid 30:07197a430869 6612 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 30:07197a430869 6613 // delete row editRowIndex from Datalogger_action_table
whismanoid 30:07197a430869 6614 for (int i = editRowIndex; i < (Datalogger_action_table_row_count-1); i++)
whismanoid 30:07197a430869 6615 {
whismanoid 30:07197a430869 6616 // copy row i+1 into row i
whismanoid 30:07197a430869 6617 Datalogger_action_table[i].action = Datalogger_action_table[i+1].action;
whismanoid 30:07197a430869 6618 Datalogger_action_table[i].digitalOutPin = Datalogger_action_table[i+1].digitalOutPin;
whismanoid 30:07197a430869 6619 Datalogger_action_table[i].condition = Datalogger_action_table[i+1].condition;
whismanoid 30:07197a430869 6620 Datalogger_action_table[i].condition_channel = Datalogger_action_table[i+1].condition_channel;
whismanoid 30:07197a430869 6621 Datalogger_action_table[i].condition_threshold = Datalogger_action_table[i+1].condition_threshold;
whismanoid 30:07197a430869 6622 }
whismanoid 30:07197a430869 6623 Datalogger_action_table_row_count--;
whismanoid 17:9397ea3ea7e9 6624 }
whismanoid 17:9397ea3ea7e9 6625 }
whismanoid 17:9397ea3ea7e9 6626 break;
whismanoid 30:07197a430869 6627 case '.':
whismanoid 30:07197a430869 6628 // L@. pause the entire Log action table
whismanoid 30:07197a430869 6629 cmdLine.serial().printf("\r\n pause the entire Log action table");
whismanoid 17:9397ea3ea7e9 6630 Datalogger_action_table_enabled = false;
whismanoid 17:9397ea3ea7e9 6631 break;
whismanoid 17:9397ea3ea7e9 6632 case '@':
whismanoid 30:07197a430869 6633 // L@@ enable the entire Log action table
whismanoid 30:07197a430869 6634 cmdLine.serial().printf("\r\n enable the entire Log action table");
whismanoid 17:9397ea3ea7e9 6635 Datalogger_action_table_enabled = true;
whismanoid 17:9397ea3ea7e9 6636 break;
whismanoid 17:9397ea3ea7e9 6637 }
whismanoid 17:9397ea3ea7e9 6638 //
whismanoid 17:9397ea3ea7e9 6639 // Print the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6640 if (Datalogger_action_table_enabled) {
whismanoid 30:07197a430869 6641 // cmdLine.serial().printf("Log action table enabled; L@. to pause");
whismanoid 17:9397ea3ea7e9 6642 }
whismanoid 17:9397ea3ea7e9 6643 else {
whismanoid 30:07197a430869 6644 cmdLine.serial().printf("Log action table paused; L@@ to enable");
whismanoid 17:9397ea3ea7e9 6645 }
whismanoid 17:9397ea3ea7e9 6646 //~ cmdLine.serial().printf("\r\n Datalogger_action_table_row_count=%d", Datalogger_action_table_row_count);
whismanoid 17:9397ea3ea7e9 6647 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 6648 {
whismanoid 17:9397ea3ea7e9 6649 cmdLine.serial().printf("\r\n L@%d", i);
whismanoid 17:9397ea3ea7e9 6650 cmdLine.serial().printf(" act=%d", Datalogger_action_table[i].action);
whismanoid 17:9397ea3ea7e9 6651 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6652 {
whismanoid 17:9397ea3ea7e9 6653 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 6654 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 6655 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6656 break;
whismanoid 29:6a9edb6e973b 6657 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6658 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 6659 break;
whismanoid 17:9397ea3ea7e9 6660 default:
whismanoid 17:9397ea3ea7e9 6661 case action_noop:
whismanoid 17:9397ea3ea7e9 6662 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 6663 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 6664 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 6665 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 6666 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 6667 break;
whismanoid 17:9397ea3ea7e9 6668 }
whismanoid 17:9397ea3ea7e9 6669 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6670 {
whismanoid 17:9397ea3ea7e9 6671 case condition_always:
whismanoid 17:9397ea3ea7e9 6672 break;
whismanoid 17:9397ea3ea7e9 6673 default:
whismanoid 17:9397ea3ea7e9 6674 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 6675 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 6676 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 6677 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 6678 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 6679 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 6680 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 6681 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 6682 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 6683 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 6684 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 6685 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 6686 cmdLine.serial().printf(" if=%d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 6687 cmdLine.serial().printf(" ch=%d", Datalogger_action_table[i].condition_channel);
whismanoid 40:330b28116178 6688 // our voltage measurement is around 1mV at best
whismanoid 40:330b28116178 6689 cmdLine.serial().printf(" x=%1.4f", Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6690 break;
whismanoid 17:9397ea3ea7e9 6691 }
whismanoid 17:9397ea3ea7e9 6692 cmdLine.serial().printf(" -- ");
whismanoid 17:9397ea3ea7e9 6693 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6694 {
whismanoid 17:9397ea3ea7e9 6695 case action_noop:
whismanoid 17:9397ea3ea7e9 6696 cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 6697 break;
whismanoid 17:9397ea3ea7e9 6698 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 6699 cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 6700 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6701 break;
whismanoid 17:9397ea3ea7e9 6702 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 6703 cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 6704 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6705 break;
whismanoid 29:6a9edb6e973b 6706 case action_button: // pin = button index 1, 2, 3
whismanoid 40:330b28116178 6707 cmdLine.serial().printf("button %%B%d!", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 6708 break;
whismanoid 17:9397ea3ea7e9 6709 case action_trigger_Halt:
whismanoid 40:330b28116178 6710 cmdLine.serial().printf("Halt");
whismanoid 17:9397ea3ea7e9 6711 break;
whismanoid 17:9397ea3ea7e9 6712 case action_trigger_FreeRun:
whismanoid 40:330b28116178 6713 cmdLine.serial().printf("LR");
whismanoid 17:9397ea3ea7e9 6714 break;
whismanoid 17:9397ea3ea7e9 6715 case action_trigger_Timer:
whismanoid 45:74bf1fe021e5 6716 cmdLine.serial().printf("LT count=%d base=%dms", g_timer_interval_count, g_timer_interval_msec);
whismanoid 45:74bf1fe021e5 6717 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 6718 cmdLine.serial().printf(" sleep=%d", g_timer_sleepmode);
whismanoid 45:74bf1fe021e5 6719 #endif // USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 17:9397ea3ea7e9 6720 break;
whismanoid 17:9397ea3ea7e9 6721 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 6722 cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 6723 // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 6724 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 6725 break;
whismanoid 17:9397ea3ea7e9 6726 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 6727 cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 6728 // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6729 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 6730 break;
whismanoid 17:9397ea3ea7e9 6731 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6732 //~ cmdLine.serial().printf(" condition %d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 6733 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6734 {
whismanoid 17:9397ea3ea7e9 6735 case condition_always:
whismanoid 17:9397ea3ea7e9 6736 cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 6737 break;
whismanoid 17:9397ea3ea7e9 6738 case condition_if_An_gt_threshold:
whismanoid 40:330b28116178 6739 cmdLine.serial().printf(" if A%d > %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6740 break;
whismanoid 17:9397ea3ea7e9 6741 case condition_if_An_lt_threshold:
whismanoid 40:330b28116178 6742 cmdLine.serial().printf(" if A%d < %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6743 break;
whismanoid 17:9397ea3ea7e9 6744 case condition_if_An_eq_threshold:
whismanoid 40:330b28116178 6745 cmdLine.serial().printf(" if A%d == %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6746 break;
whismanoid 17:9397ea3ea7e9 6747 case condition_if_An_ge_threshold:
whismanoid 40:330b28116178 6748 cmdLine.serial().printf(" if A%d >= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6749 break;
whismanoid 17:9397ea3ea7e9 6750 case condition_if_An_le_threshold:
whismanoid 40:330b28116178 6751 cmdLine.serial().printf(" if A%d <= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6752 break;
whismanoid 17:9397ea3ea7e9 6753 case condition_if_An_ne_threshold:
whismanoid 40:330b28116178 6754 cmdLine.serial().printf(" if A%d != %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6755 break;
whismanoid 17:9397ea3ea7e9 6756 case condition_if_AINn_gt_threshold:
whismanoid 40:330b28116178 6757 cmdLine.serial().printf(" if AIN%d > %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6758 break;
whismanoid 17:9397ea3ea7e9 6759 case condition_if_AINn_lt_threshold:
whismanoid 40:330b28116178 6760 cmdLine.serial().printf(" if AIN%d < %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6761 break;
whismanoid 17:9397ea3ea7e9 6762 case condition_if_AINn_eq_threshold:
whismanoid 40:330b28116178 6763 cmdLine.serial().printf(" if AIN%d == %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6764 break;
whismanoid 17:9397ea3ea7e9 6765 case condition_if_AINn_ge_threshold:
whismanoid 40:330b28116178 6766 cmdLine.serial().printf(" if AIN%d >= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6767 break;
whismanoid 17:9397ea3ea7e9 6768 case condition_if_AINn_le_threshold:
whismanoid 40:330b28116178 6769 cmdLine.serial().printf(" if AIN%d <= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6770 break;
whismanoid 17:9397ea3ea7e9 6771 case condition_if_AINn_ne_threshold:
whismanoid 40:330b28116178 6772 cmdLine.serial().printf(" if AIN%d != %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6773 break;
whismanoid 17:9397ea3ea7e9 6774 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6775 } // for ...Datalogger_action_table_row_count // Print the contents of Datalogger_action_table
whismanoid 30:07197a430869 6776 cmdLine.serial().printf("\r\n\r\nEdit Log action table (used %d/%d, %d free):",
whismanoid 30:07197a430869 6777 Datalogger_action_table_row_count,
whismanoid 30:07197a430869 6778 ACTION_TABLE_ROW_MAX,
whismanoid 30:07197a430869 6779 (ACTION_TABLE_ROW_MAX - Datalogger_action_table_row_count)
whismanoid 30:07197a430869 6780 );
whismanoid 17:9397ea3ea7e9 6781 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 6782 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 6783 cmdLine.serial().printf("\r\n L@+ act=4 if=1 ch=5 x=12345 -- add new entry at end of table");
whismanoid 17:9397ea3ea7e9 6784 }
whismanoid 17:9397ea3ea7e9 6785 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 6786 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 6787 cmdLine.serial().printf("\r\n L@%d act=4 if=1 ch=5 x=12345 -- edit row %d",
whismanoid 17:9397ea3ea7e9 6788 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 6789 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 6790 cmdLine.serial().printf("\r\n L@-%d -- delete row %d",
whismanoid 17:9397ea3ea7e9 6791 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 6792 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 6793 cmdLine.serial().printf("\r\n L@-~~~ -- delete all rows");
whismanoid 30:07197a430869 6794 if (Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@. -- pause entire Log action table");
whismanoid 30:07197a430869 6795 if (!Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@@ -- enable Log action table");
whismanoid 17:9397ea3ea7e9 6796 }
whismanoid 17:9397ea3ea7e9 6797 //
whismanoid 17:9397ea3ea7e9 6798 } // case L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6799 break;
whismanoid 17:9397ea3ea7e9 6800 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6801 // LR -- Datalog free run as fast as possible
whismanoid 4:d9b05924ad4c 6802 case 'R': case 'r':
whismanoid 4:d9b05924ad4c 6803 // free run as fast as possible
whismanoid 8:dffee7509bfb 6804 Datalogger_Trigger = trigger_FreeRun;
whismanoid 8:dffee7509bfb 6805 Datalogger_Need_PrintHeader = true;
whismanoid 4:d9b05924ad4c 6806 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 9:45f98573eb6d 6807 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6808 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 6809 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 6810 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 6811 case 'S': case 's':
whismanoid 9:45f98573eb6d 6812 {
whismanoid 9:45f98573eb6d 6813 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6814 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 6815 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 6816 )
whismanoid 9:45f98573eb6d 6817 {
whismanoid 9:45f98573eb6d 6818 // it's me
whismanoid 9:45f98573eb6d 6819 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 6820 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 6821 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 6822 {
whismanoid 9:45f98573eb6d 6823 case 'D': case 'd':
whismanoid 9:45f98573eb6d 6824 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Disable;
whismanoid 9:45f98573eb6d 6825 break;
whismanoid 9:45f98573eb6d 6826 case 'L': case 'l':
whismanoid 9:45f98573eb6d 6827 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 6828 break;
whismanoid 9:45f98573eb6d 6829 case 'V': case 'v':
whismanoid 9:45f98573eb6d 6830 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 6831 break;
whismanoid 9:45f98573eb6d 6832 //
whismanoid 9:45f98573eb6d 6833 //
whismanoid 9:45f98573eb6d 6834 // TODO: MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 6835 case 'C': case 'c':
whismanoid 9:45f98573eb6d 6836 {
whismanoid 9:45f98573eb6d 6837 uint8_t hexValue = 0;
whismanoid 9:45f98573eb6d 6838 hexValue = hexValueOfChar(cmdLine[5]) * 0x10 + hexValueOfChar(cmdLine[6]);
whismanoid 9:45f98573eb6d 6839 switch (cmdLine[4])
whismanoid 9:45f98573eb6d 6840 {
whismanoid 9:45f98573eb6d 6841 //
whismanoid 9:45f98573eb6d 6842 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 6843 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34"));
whismanoid 9:45f98573eb6d 6844 case 'F': case 'f':
whismanoid 9:45f98573eb6d 6845 SPI_AIN_Cfg_v_filter_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 6846 break;
whismanoid 9:45f98573eb6d 6847 //
whismanoid 9:45f98573eb6d 6848 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 6849 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 6850 case 'C': case 'c':
whismanoid 9:45f98573eb6d 6851 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 6852 break;
whismanoid 9:45f98573eb6d 6853 //
whismanoid 9:45f98573eb6d 6854 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 6855 // cmdLine.serial().print(F("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00"));
whismanoid 9:45f98573eb6d 6856 case 'P': case 'p':
whismanoid 9:45f98573eb6d 6857 SPI_AIN_Cfg_v_pga_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 6858 break;
whismanoid 9:45f98573eb6d 6859 //
whismanoid 9:45f98573eb6d 6860 // cmdLine.serial().print(F("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar"));
whismanoid 9:45f98573eb6d 6861 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 6862 case 'U': case 'u':
whismanoid 9:45f98573eb6d 6863 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] | 0x40;
whismanoid 9:45f98573eb6d 6864 break;
whismanoid 9:45f98573eb6d 6865 //
whismanoid 9:45f98573eb6d 6866 // cmdLine.serial().print(F("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar"));
whismanoid 9:45f98573eb6d 6867 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 6868 case 'B': case 'b':
whismanoid 9:45f98573eb6d 6869 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] &~ 0x40;
whismanoid 9:45f98573eb6d 6870 break;
whismanoid 9:45f98573eb6d 6871 }
whismanoid 9:45f98573eb6d 6872 break;
whismanoid 9:45f98573eb6d 6873 }
whismanoid 9:45f98573eb6d 6874 //
whismanoid 9:45f98573eb6d 6875 //
whismanoid 9:45f98573eb6d 6876 }
whismanoid 9:45f98573eb6d 6877 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 6878 } // end for channel_index
whismanoid 9:45f98573eb6d 6879 Datalogger_PrintHeader();
whismanoid 9:45f98573eb6d 6880 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6881 }
whismanoid 9:45f98573eb6d 6882 break;
whismanoid 9:45f98573eb6d 6883 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6884 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 6885 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 6886 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 6887 // verb: D for disable, V for Voltage, L for LSB
whismanoid 8:dffee7509bfb 6888 case 'A': case 'a':
whismanoid 9:45f98573eb6d 6889 {
whismanoid 9:45f98573eb6d 6890 // all-channel: loop through all valid channel_index, test cmdLine[2] 'is it me'?
whismanoid 9:45f98573eb6d 6891 // for channel_index loop through 0..NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 9:45f98573eb6d 6892 // if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 6893 // || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 6894 // ) {
whismanoid 9:45f98573eb6d 6895 // // it's me
whismanoid 9:45f98573eb6d 6896 // // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 6897 // // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 6898 // } end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 6899 // } end for channel_index
whismanoid 9:45f98573eb6d 6900 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6901 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 6902 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 6903 )
whismanoid 9:45f98573eb6d 6904 {
whismanoid 9:45f98573eb6d 6905 // it's me
whismanoid 9:45f98573eb6d 6906 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 6907 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 6908 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 6909 {
whismanoid 9:45f98573eb6d 6910 case 'D': case 'd':
whismanoid 9:45f98573eb6d 6911 Platform_Enable_ch[channel_index] = Platform_AIN_Disable;
whismanoid 9:45f98573eb6d 6912 break;
whismanoid 9:45f98573eb6d 6913 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 6914 case 'L': case 'l':
whismanoid 9:45f98573eb6d 6915 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 6916 break;
whismanoid 9:45f98573eb6d 6917 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 6918 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 6919 case 'V': case 'v':
whismanoid 9:45f98573eb6d 6920 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 6921 break;
whismanoid 9:45f98573eb6d 6922 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 6923 }
whismanoid 9:45f98573eb6d 6924 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 6925 } // end for channel_index
whismanoid 10:04022a61b527 6926 // Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 6927 if (Datalogger_enable_serial) {
whismanoid 9:45f98573eb6d 6928 Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 6929 }
whismanoid 9:45f98573eb6d 6930 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 6931 if (Datalogger_enable_AUXserial) {
whismanoid 9:45f98573eb6d 6932 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 9:45f98573eb6d 6933 }
whismanoid 9:45f98573eb6d 6934 # endif // HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 6935 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6936 if (Datalogger_enable_DAPLINKserial) {
whismanoid 9:45f98573eb6d 6937 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 9:45f98573eb6d 6938 }
whismanoid 9:45f98573eb6d 6939 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6940 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6941 }
whismanoid 8:dffee7509bfb 6942 break;
whismanoid 9:45f98573eb6d 6943 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 6944 case '>':
whismanoid 9:45f98573eb6d 6945 // L>A -- Datalogger_enable_AUXserial
whismanoid 9:45f98573eb6d 6946 // L>D -- Datalogger_enable_DAPLINKserial
whismanoid 9:45f98573eb6d 6947 // L>S -- Datalogger_enable_serial
whismanoid 9:45f98573eb6d 6948 switch (cmdLine[2])
whismanoid 9:45f98573eb6d 6949 {
whismanoid 9:45f98573eb6d 6950 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 6951 case 'A': case 'a':
whismanoid 9:45f98573eb6d 6952 Datalogger_enable_AUXserial = !Datalogger_enable_AUXserial;
whismanoid 9:45f98573eb6d 6953 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6954 break;
whismanoid 8:dffee7509bfb 6955 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6956 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6957 case 'D': case 'd':
whismanoid 9:45f98573eb6d 6958 Datalogger_enable_DAPLINKserial = !Datalogger_enable_DAPLINKserial;
whismanoid 9:45f98573eb6d 6959 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6960 break;
whismanoid 8:dffee7509bfb 6961 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6962 case 'S': case 's':
whismanoid 9:45f98573eb6d 6963 Datalogger_enable_serial = !Datalogger_enable_serial;
whismanoid 9:45f98573eb6d 6964 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6965 break;
whismanoid 9:45f98573eb6d 6966 }
whismanoid 9:45f98573eb6d 6967 break; // case '>' L>S serial enable toggle
whismanoid 28:a9a3a9db592b 6968 default:
whismanoid 28:a9a3a9db592b 6969 // TODO: L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 6970 //
whismanoid 28:a9a3a9db592b 6971 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 6972 #if 1 // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 6973 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 6974 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 6975 //
whismanoid 28:a9a3a9db592b 6976 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 28:a9a3a9db592b 6977 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 39:4d285e961435 6978 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 6979 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 6980 cmdLine.serial().printf("\r\n LT count=%d base=%dms sleep=%d -- Datalog timer",
whismanoid 39:4d285e961435 6981 g_timer_interval_count,
whismanoid 39:4d285e961435 6982 g_timer_interval_msec,
whismanoid 39:4d285e961435 6983 (int)g_timer_sleepmode
whismanoid 39:4d285e961435 6984 ); // trigger_Timer
whismanoid 39:4d285e961435 6985 #else // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 6986 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 6987 #endif // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 6988 //
whismanoid 28:a9a3a9db592b 6989 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 28:a9a3a9db592b 6990 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 6991 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 6992 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 6993 //
whismanoid 28:a9a3a9db592b 6994 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 6995 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 28:a9a3a9db592b 6996 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 6997 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 6998 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 6999 //
whismanoid 28:a9a3a9db592b 7000 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 7001 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 7002 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 7003 //
whismanoid 28:a9a3a9db592b 7004 //
whismanoid 28:a9a3a9db592b 7005 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 7006 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 28:a9a3a9db592b 7007 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 7008 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 7009 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 28:a9a3a9db592b 7010 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 28:a9a3a9db592b 7011 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 28:a9a3a9db592b 7012 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 28:a9a3a9db592b 7013 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 28:a9a3a9db592b 7014 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 28:a9a3a9db592b 7015 //
whismanoid 28:a9a3a9db592b 7016 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 28:a9a3a9db592b 7017 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 28:a9a3a9db592b 7018 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 28:a9a3a9db592b 7019 //
whismanoid 28:a9a3a9db592b 7020 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 7021 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 28:a9a3a9db592b 7022 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 28:a9a3a9db592b 7023 //
whismanoid 28:a9a3a9db592b 7024 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 7025 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 28:a9a3a9db592b 7026 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 7027 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 28:a9a3a9db592b 7028 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 7029 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 28:a9a3a9db592b 7030 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 7031 //
whismanoid 28:a9a3a9db592b 7032 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 28:a9a3a9db592b 7033 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 28:a9a3a9db592b 7034 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 28:a9a3a9db592b 7035 //
whismanoid 28:a9a3a9db592b 7036 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 7037 //
whismanoid 28:a9a3a9db592b 7038 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 28:a9a3a9db592b 7039 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 28:a9a3a9db592b 7040 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 7041 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 7042 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 28:a9a3a9db592b 7043 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 7044 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 28:a9a3a9db592b 7045 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 7046 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 7047 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 28:a9a3a9db592b 7048 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 7049 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 28:a9a3a9db592b 7050 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 7051 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 28:a9a3a9db592b 7052 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 7053 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 7054 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 28:a9a3a9db592b 7055 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 7056 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 7057 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 7058 # if HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 7059 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 7060 # endif // HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 7061 # if HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 7062 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 7063 # endif // HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 7064 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 7065 //
whismanoid 28:a9a3a9db592b 7066 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 7067 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 7068 break;
whismanoid 17:9397ea3ea7e9 7069 } // switch (cmdLine[1]) inside case 'L'
whismanoid 4:d9b05924ad4c 7070 }
whismanoid 4:d9b05924ad4c 7071 break; // case 'L'
whismanoid 4:d9b05924ad4c 7072 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 7073 //
whismanoid 4:d9b05924ad4c 7074 // Application-specific commands here
whismanoid 4:d9b05924ad4c 7075 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 7076 //
whismanoid 4:d9b05924ad4c 7077 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 7078 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 7079
whismanoid 4:d9b05924ad4c 7080 //
whismanoid 4:d9b05924ad4c 7081 // TODO1: add new commands here
whismanoid 4:d9b05924ad4c 7082 //
whismanoid 4:d9b05924ad4c 7083 default:
whismanoid 4:d9b05924ad4c 7084 #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 7085 extern bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5715.cpp
whismanoid 4:d9b05924ad4c 7086 if (!MAX5715_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 7087 #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 7088 extern bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11131.cpp
whismanoid 4:d9b05924ad4c 7089 if (!MAX11131_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 7090 #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 7091 extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp
whismanoid 4:d9b05924ad4c 7092 if (!MAX5171_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 7093 #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 7094 extern bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp
whismanoid 4:d9b05924ad4c 7095 if (!MAX11410_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 7096 #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 7097 extern bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX12345.cpp
whismanoid 4:d9b05924ad4c 7098 if (!MAX12345_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 7099 #else
whismanoid 4:d9b05924ad4c 7100 if (0) // not_handled_by_device_submenu
whismanoid 4:d9b05924ad4c 7101 #endif
whismanoid 4:d9b05924ad4c 7102 {
whismanoid 4:d9b05924ad4c 7103 cmdLine.serial().printf("\r\n unknown command ");
whismanoid 4:d9b05924ad4c 7104 //~ cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 7105 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 7106 cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n",
whismanoid 4:d9b05924ad4c 7107 cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 7108 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7109 }
whismanoid 4:d9b05924ad4c 7110 } // switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 7111 //
whismanoid 31:47eee7e0cc2d 7112 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 7113 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 7114 // print command prompt
whismanoid 8:dffee7509bfb 7115 // print_command_prompt();
whismanoid 8:dffee7509bfb 7116 cmdLine.serial().printf("\r\n> ");
whismanoid 31:47eee7e0cc2d 7117 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 7118 }
whismanoid 4:d9b05924ad4c 7119 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 7120
whismanoid 4:d9b05924ad4c 7121 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 7122 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 7123 void Datalogger_PrintHeader(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 7124 {
whismanoid 37:3f369235e5bc 7125 #if MAX40108_DEMO // main_menu_status banner
whismanoid 37:3f369235e5bc 7126 cmdLine.serial().printf("\r\n\r\n\"MAX40108_U%d", MAX40108_DEMO);
whismanoid 37:3f369235e5bc 7127 #ifdef BOARD_SERIAL_NUMBER
whismanoid 37:3f369235e5bc 7128 // data unique to certain boards based on serial number
whismanoid 47:f1a56afb4aca 7129 cmdLine.serial().printf(" [s/n %d]", g_board_serial_number);
whismanoid 37:3f369235e5bc 7130 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 7131 #ifdef FW_REV
whismanoid 37:3f369235e5bc 7132 cmdLine.serial().printf(" [FW_REV %d]", FW_REV);
whismanoid 37:3f369235e5bc 7133 #endif // FW_REV
whismanoid 37:3f369235e5bc 7134 cmdLine.serial().printf("\"\r\n");
whismanoid 37:3f369235e5bc 7135 #endif // MAX40108_DEMO
whismanoid 37:3f369235e5bc 7136
whismanoid 4:d9b05924ad4c 7137 // column header banner for csv data columns
whismanoid 4:d9b05924ad4c 7138 int field_index = 0;
whismanoid 4:d9b05924ad4c 7139 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 7140 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 7141 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 4:d9b05924ad4c 7142 continue;
whismanoid 4:d9b05924ad4c 7143 }
whismanoid 4:d9b05924ad4c 7144 // comma between fields
whismanoid 4:d9b05924ad4c 7145 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 7146 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 7147 }
whismanoid 10:04022a61b527 7148 field_index++;
whismanoid 4:d9b05924ad4c 7149 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 7150 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 7151 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 4:d9b05924ad4c 7152 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 4:d9b05924ad4c 7153 cmdLine.serial().printf("\"AIN%d-%d_BIP", channel_index, channel_index+1);
whismanoid 4:d9b05924ad4c 7154 }
whismanoid 4:d9b05924ad4c 7155 else {
whismanoid 4:d9b05924ad4c 7156 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 7157 }
whismanoid 4:d9b05924ad4c 7158 #else // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 7159 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 7160 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 7161 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_LSB) {
whismanoid 4:d9b05924ad4c 7162 // _LSB column header suffix
whismanoid 13:184a08909405 7163 cmdLine.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 7164 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7165 cmdLine_DAPLINKserial.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 7166 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7167 }
whismanoid 10:04022a61b527 7168 else if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_Volt) {
whismanoid 4:d9b05924ad4c 7169 // _V column header suffix
whismanoid 13:184a08909405 7170 cmdLine.serial().printf("_V");
whismanoid 4:d9b05924ad4c 7171 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7172 cmdLine_DAPLINKserial.serial().printf("_V");
whismanoid 4:d9b05924ad4c 7173 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7174 }
whismanoid 13:184a08909405 7175 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 7176 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 7177 if (SPI_AIN_customChannelHeader_ch[channel_index] && SPI_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 7178 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 7179 cmdLine.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 7180 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7181 cmdLine_DAPLINKserial.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 7182 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7183 } else {
whismanoid 13:184a08909405 7184 // no custom channel name for this channel
whismanoid 13:184a08909405 7185 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 7186 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7187 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 7188 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7189 }
whismanoid 13:184a08909405 7190 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 7191 // close quote
whismanoid 13:184a08909405 7192 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 7193 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7194 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 7195 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7196 }
whismanoid 4:d9b05924ad4c 7197
whismanoid 4:d9b05924ad4c 7198 #if VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 7199 // PART_ID field: Device ID Validation
whismanoid 4:d9b05924ad4c 7200 cmdLine.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 7201 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7202 cmdLine_DAPLINKserial.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 7203 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7204 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 7205 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 7206 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 7207 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 7208 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 7209 continue;
whismanoid 9:45f98573eb6d 7210 }
whismanoid 4:d9b05924ad4c 7211 // comma between fields
whismanoid 4:d9b05924ad4c 7212 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 7213 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 7214 }
whismanoid 9:45f98573eb6d 7215 field_index++;
whismanoid 4:d9b05924ad4c 7216 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 7217 cmdLine.serial().printf("\"A%d", channel_index);
whismanoid 9:45f98573eb6d 7218 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 9:45f98573eb6d 7219 // _LSB column header suffix
whismanoid 13:184a08909405 7220 cmdLine.serial().printf("_LSB");
whismanoid 9:45f98573eb6d 7221 }
whismanoid 9:45f98573eb6d 7222 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 7223 // _V column header suffix
whismanoid 13:184a08909405 7224 cmdLine.serial().printf("_V");
whismanoid 9:45f98573eb6d 7225 }
whismanoid 13:184a08909405 7226 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 7227 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 7228 if (Platform_AIN_customChannelHeader_ch[channel_index] && Platform_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 7229 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 7230 cmdLine.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 7231 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7232 cmdLine_DAPLINKserial.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 7233 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7234 } else {
whismanoid 13:184a08909405 7235 // no custom channel name for this channel
whismanoid 13:184a08909405 7236 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 7237 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7238 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 7239 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7240 }
whismanoid 13:184a08909405 7241 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 7242 // close quote
whismanoid 13:184a08909405 7243 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 7244 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7245 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 7246 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7247 }
whismanoid 4:d9b05924ad4c 7248 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 30:07197a430869 7249 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 7250 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in Datalogger_PrintHeader
whismanoid 30:07197a430869 7251 cmdLine.serial().printf(",\"%s\"", gstrRemarkHeader);
whismanoid 30:07197a430869 7252 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 4:d9b05924ad4c 7253 // end of column header line
whismanoid 4:d9b05924ad4c 7254 cmdLine.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 7255 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7256 cmdLine_DAPLINKserial.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 7257 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7258 } // void Datalogger_PrintHeader()
whismanoid 4:d9b05924ad4c 7259
whismanoid 5:aaf8b5f5fda1 7260 //--------------------------------------------------
whismanoid 5:aaf8b5f5fda1 7261 void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 7262 {
whismanoid 5:aaf8b5f5fda1 7263 // CODE GENERATOR: example code: has no member function ScanStandardExternalClock
whismanoid 5:aaf8b5f5fda1 7264 // CODE GENERATOR: example code: has no member function ReadAINcode
whismanoid 5:aaf8b5f5fda1 7265 // CODE GENERATOR: example code: member function Read_All_Voltages
whismanoid 5:aaf8b5f5fda1 7266 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7267 // Measure ADC channels in sequence from AIN0 to channelNumber_0_9.
whismanoid 5:aaf8b5f5fda1 7268 // @param[in] g_MAX11410_device.channelNumber_0_15: AIN Channel Number
whismanoid 5:aaf8b5f5fda1 7269 // @param[in] g_MAX11410_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
whismanoid 5:aaf8b5f5fda1 7270 // @param[in] g_MAX11410_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
whismanoid 10:04022a61b527 7271 //~ int channelId_0_9 = NUM_DUT_ANALOG_IN_CHANNELS-1+1;
whismanoid 5:aaf8b5f5fda1 7272 //g_MAX11410_device.channelNumber_0_15 = channelId_0_9;
whismanoid 5:aaf8b5f5fda1 7273 //g_MAX11410_device.PowerManagement_0_2 = 0;
whismanoid 5:aaf8b5f5fda1 7274 //g_MAX11410_device.chan_id_0_1 = 1;
whismanoid 5:aaf8b5f5fda1 7275 //----------------------------------------
whismanoid 5:aaf8b5f5fda1 7276 // scan AIN0..AIN9
whismanoid 5:aaf8b5f5fda1 7277 //
whismanoid 10:04022a61b527 7278 #if 1
whismanoid 10:04022a61b527 7279 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 7280 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 7281 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 7282 //
whismanoid 10:04022a61b527 7283 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7284 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc3); // GP1 = 0
whismanoid 10:04022a61b527 7285 //
whismanoid 10:04022a61b527 7286 int field_index = 0;
whismanoid 10:04022a61b527 7287 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 7288 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 10:04022a61b527 7289 continue;
whismanoid 10:04022a61b527 7290 }
whismanoid 10:04022a61b527 7291 field_index++;
whismanoid 10:04022a61b527 7292 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[channel_index];
whismanoid 10:04022a61b527 7293 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[channel_index];
whismanoid 10:04022a61b527 7294 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[channel_index];
whismanoid 10:04022a61b527 7295 //
whismanoid 10:04022a61b527 7296 // WIP SampleRate_of_FILTER_CONV_START() MAX11410EMC-FW slow ODR 10Sps #262
whismanoid 10:04022a61b527 7297 // adjust the MAX11410.loop_limit value if the sample rate is set to a value slower than 20sps
whismanoid 10:04022a61b527 7298 // SampleRate_of_FILTER_CONV_START(uint8_t FILTER_RegValue, uint8_t CONV_START_RegValue)
whismanoid 10:04022a61b527 7299 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 7300 if (SampleRate < 20.0) {
whismanoid 10:04022a61b527 7301 g_MAX11410_device.loop_limit = 32767; // TODO: is this timeout long enough for the slow output data rates?
whismanoid 10:04022a61b527 7302 }
whismanoid 10:04022a61b527 7303 //
whismanoid 10:04022a61b527 7304 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7305 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc3); // GP0 = 0
whismanoid 10:04022a61b527 7306 //
whismanoid 10:04022a61b527 7307 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 7308 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 10:04022a61b527 7309 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 10:04022a61b527 7310 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 7311 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = (MAX11410::MAX11410_AINN_SEL_enum_t)(channel_index^1);
whismanoid 10:04022a61b527 7312 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 7313 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 7314 }
whismanoid 10:04022a61b527 7315 else {
whismanoid 10:04022a61b527 7316 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 7317 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = MAX11410::AINN_SEL_1010_GND;
whismanoid 10:04022a61b527 7318 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 7319 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 7320 }
whismanoid 10:04022a61b527 7321 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 7322 //
whismanoid 10:04022a61b527 7323 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7324 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc4); // GP0 = 1
whismanoid 10:04022a61b527 7325 //
whismanoid 10:04022a61b527 7326 }
whismanoid 10:04022a61b527 7327 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7328 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc4); // GP1 = 1
whismanoid 10:04022a61b527 7329 #else
whismanoid 5:aaf8b5f5fda1 7330 g_MAX11410_device.Read_All_Voltages();
whismanoid 10:04022a61b527 7331 #endif
whismanoid 10:04022a61b527 7332 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7333 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 7334 // mbed
whismanoid 5:aaf8b5f5fda1 7335 // Platform board uses simple analog inputs
whismanoid 5:aaf8b5f5fda1 7336 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 5:aaf8b5f5fda1 7337 Platform_LSB[0] = analogIn0.read();
whismanoid 5:aaf8b5f5fda1 7338 Platform_LSB[1] = analogIn1.read();
whismanoid 5:aaf8b5f5fda1 7339 Platform_LSB[2] = analogIn2.read();
whismanoid 5:aaf8b5f5fda1 7340 Platform_LSB[3] = analogIn3.read();
whismanoid 5:aaf8b5f5fda1 7341 Platform_LSB[4] = analogIn4.read();
whismanoid 5:aaf8b5f5fda1 7342 Platform_LSB[5] = analogIn5.read();
whismanoid 10:04022a61b527 7343 #endif
whismanoid 10:04022a61b527 7344 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 37:3f369235e5bc 7345 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 7346 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogIn012345.read()
whismanoid 37:3f369235e5bc 7347 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 7348 float analogIn0_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7349 float analogIn1_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7350 float analogIn2_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7351 float analogIn3_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7352 float analogIn4_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7353 float analogIn5_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7354 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 7355 analogIn0_normValue_0_1 = analogIn0_normValue_0_1 + analogIn0.read();
whismanoid 37:3f369235e5bc 7356 analogIn1_normValue_0_1 = analogIn1_normValue_0_1 + analogIn1.read();
whismanoid 37:3f369235e5bc 7357 analogIn2_normValue_0_1 = analogIn2_normValue_0_1 + analogIn2.read();
whismanoid 37:3f369235e5bc 7358 analogIn3_normValue_0_1 = analogIn3_normValue_0_1 + analogIn3.read();
whismanoid 37:3f369235e5bc 7359 analogIn4_normValue_0_1 = analogIn4_normValue_0_1 + analogIn4.read();
whismanoid 37:3f369235e5bc 7360 analogIn5_normValue_0_1 = analogIn5_normValue_0_1 + analogIn5.read();
whismanoid 37:3f369235e5bc 7361 }
whismanoid 37:3f369235e5bc 7362 analogIn0_normValue_0_1 = analogIn0_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7363 analogIn1_normValue_0_1 = analogIn1_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7364 analogIn2_normValue_0_1 = analogIn2_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7365 analogIn3_normValue_0_1 = analogIn3_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7366 analogIn4_normValue_0_1 = analogIn4_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7367 analogIn5_normValue_0_1 = analogIn5_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7368 #else // USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 7369 float analogIn0_normValue_0_1 = analogIn0.read();
whismanoid 37:3f369235e5bc 7370 float analogIn1_normValue_0_1 = analogIn1.read();
whismanoid 37:3f369235e5bc 7371 float analogIn2_normValue_0_1 = analogIn2.read();
whismanoid 37:3f369235e5bc 7372 float analogIn3_normValue_0_1 = analogIn3.read();
whismanoid 37:3f369235e5bc 7373 float analogIn4_normValue_0_1 = analogIn4.read();
whismanoid 37:3f369235e5bc 7374 float analogIn5_normValue_0_1 = analogIn5.read();
whismanoid 37:3f369235e5bc 7375 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 7376 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 7377 // apply calibration to normValue_0_1 value
whismanoid 37:3f369235e5bc 7378 Platform_Voltage[0] = CalibratedNormValue(0, analogIn0_normValue_0_1) * adc_full_scale_voltage[0];
whismanoid 37:3f369235e5bc 7379 Platform_Voltage[1] = CalibratedNormValue(1, analogIn1_normValue_0_1) * adc_full_scale_voltage[1];
whismanoid 37:3f369235e5bc 7380 Platform_Voltage[2] = CalibratedNormValue(2, analogIn2_normValue_0_1) * adc_full_scale_voltage[2];
whismanoid 37:3f369235e5bc 7381 Platform_Voltage[3] = CalibratedNormValue(3, analogIn3_normValue_0_1) * adc_full_scale_voltage[3];
whismanoid 37:3f369235e5bc 7382 Platform_Voltage[4] = CalibratedNormValue(4, analogIn4_normValue_0_1) * adc_full_scale_voltage[4];
whismanoid 37:3f369235e5bc 7383 Platform_Voltage[5] = CalibratedNormValue(5, analogIn5_normValue_0_1) * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 7384 #else // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 7385 Platform_Voltage[0] = analogIn0_normValue_0_1 * adc_full_scale_voltage[0];
whismanoid 37:3f369235e5bc 7386 Platform_Voltage[1] = analogIn1_normValue_0_1 * adc_full_scale_voltage[1];
whismanoid 37:3f369235e5bc 7387 Platform_Voltage[2] = analogIn2_normValue_0_1 * adc_full_scale_voltage[2];
whismanoid 37:3f369235e5bc 7388 Platform_Voltage[3] = analogIn3_normValue_0_1 * adc_full_scale_voltage[3];
whismanoid 37:3f369235e5bc 7389 Platform_Voltage[4] = analogIn4_normValue_0_1 * adc_full_scale_voltage[4];
whismanoid 37:3f369235e5bc 7390 Platform_Voltage[5] = analogIn5_normValue_0_1 * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 7391 #endif // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 7392 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 5:aaf8b5f5fda1 7393 #endif // defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 7394
whismanoid 5:aaf8b5f5fda1 7395 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7396 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 7397 const uint32_t part_id_expect = 0x000F02;
whismanoid 5:aaf8b5f5fda1 7398 uint32_t part_id_readback;
whismanoid 5:aaf8b5f5fda1 7399 g_MAX11410_device.RegRead(MAX11410::CMD_r001_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xddd_PART_ID, &part_id_readback);
whismanoid 5:aaf8b5f5fda1 7400 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7401 } // void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 7402
whismanoid 17:9397ea3ea7e9 7403 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 7404 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 7405 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 7406 void Datalogger_RunActionTable()
whismanoid 17:9397ea3ea7e9 7407 {
whismanoid 17:9397ea3ea7e9 7408 if (Datalogger_action_table_enabled == false) {
whismanoid 17:9397ea3ea7e9 7409 return;
whismanoid 17:9397ea3ea7e9 7410 }
whismanoid 17:9397ea3ea7e9 7411 // TODO: verbose Datalogger_RunActionTable() emit a csv column ,"Action"
whismanoid 17:9397ea3ea7e9 7412 // TODO: assert Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX
whismanoid 17:9397ea3ea7e9 7413 // for Datalogger_action_table[0..Datalogger_action_table_row_count]
whismanoid 17:9397ea3ea7e9 7414 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 7415 {
whismanoid 17:9397ea3ea7e9 7416 // skip if Datalogger_action_table[i].action == action_noop
whismanoid 17:9397ea3ea7e9 7417 if (Datalogger_action_table[i].action == action_noop) {
whismanoid 17:9397ea3ea7e9 7418 continue;
whismanoid 17:9397ea3ea7e9 7419 }
whismanoid 17:9397ea3ea7e9 7420 // TODO: test Datalogger_action_table[i].condition "if="
whismanoid 17:9397ea3ea7e9 7421 // TODO: Could the .condition field also distinguish Platform ADC from SPI ADC?
whismanoid 17:9397ea3ea7e9 7422 // That way we keep both sets of ADC channels in separate lists
whismanoid 17:9397ea3ea7e9 7423 // if=0 -- always
whismanoid 17:9397ea3ea7e9 7424 // if=1,2,3,4,5,6 -- Platform_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 7425 // if=7,8,9,10,11,12 -- SPI_AIN_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 7426 // also, are we comparing code or voltage?
whismanoid 17:9397ea3ea7e9 7427 // TODO: selected Datalogger_action_table[i].condition_channel
whismanoid 17:9397ea3ea7e9 7428 // Datalogger could have both platform ADC and external SPI ADC channels
whismanoid 17:9397ea3ea7e9 7429 // if SPI_ADC_DeviceName
whismanoid 17:9397ea3ea7e9 7430 // NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 7431 // SPI_AIN_Enable_ch[]
whismanoid 17:9397ea3ea7e9 7432 // SPI_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 7433 // SPI_AIN_Voltage[]
whismanoid 17:9397ea3ea7e9 7434 // if LOG_PLATFORM_AIN
whismanoid 17:9397ea3ea7e9 7435 // NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 7436 // analogInPin_fullScaleVoltage[]
whismanoid 17:9397ea3ea7e9 7437 // Platform_Enable_ch[]
whismanoid 17:9397ea3ea7e9 7438 // Platform_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 7439 // Platform_Voltage[]
whismanoid 17:9397ea3ea7e9 7440 // TODO: selected Datalogger_action_table[i].condition_threshold
whismanoid 17:9397ea3ea7e9 7441 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 7442 {
whismanoid 17:9397ea3ea7e9 7443 case condition_always:
whismanoid 17:9397ea3ea7e9 7444 //~ cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 7445 break;
whismanoid 17:9397ea3ea7e9 7446 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 7447 //~ cmdLine.serial().printf(" if A%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7448 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7449 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7450 continue;
whismanoid 17:9397ea3ea7e9 7451 }
whismanoid 17:9397ea3ea7e9 7452 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7453 break;
whismanoid 17:9397ea3ea7e9 7454 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 7455 //~ cmdLine.serial().printf(" if A%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7456 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7457 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7458 continue;
whismanoid 17:9397ea3ea7e9 7459 }
whismanoid 17:9397ea3ea7e9 7460 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7461 break;
whismanoid 17:9397ea3ea7e9 7462 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 7463 //~ cmdLine.serial().printf(" if A%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7464 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7465 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7466 continue;
whismanoid 17:9397ea3ea7e9 7467 }
whismanoid 17:9397ea3ea7e9 7468 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7469 break;
whismanoid 17:9397ea3ea7e9 7470 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 7471 //~ cmdLine.serial().printf(" if A%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7472 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7473 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7474 continue;
whismanoid 17:9397ea3ea7e9 7475 }
whismanoid 17:9397ea3ea7e9 7476 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7477 break;
whismanoid 17:9397ea3ea7e9 7478 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 7479 //~ cmdLine.serial().printf(" if A%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7480 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7481 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7482 continue;
whismanoid 17:9397ea3ea7e9 7483 }
whismanoid 17:9397ea3ea7e9 7484 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7485 break;
whismanoid 17:9397ea3ea7e9 7486 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 7487 //~ cmdLine.serial().printf(" if A%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7488 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7489 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7490 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7491 continue;
whismanoid 17:9397ea3ea7e9 7492 }
whismanoid 17:9397ea3ea7e9 7493 break;
whismanoid 17:9397ea3ea7e9 7494 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 7495 //~ cmdLine.serial().printf(" if AIN%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7496 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7497 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7498 continue;
whismanoid 17:9397ea3ea7e9 7499 }
whismanoid 17:9397ea3ea7e9 7500 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7501 break;
whismanoid 17:9397ea3ea7e9 7502 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 7503 //~ cmdLine.serial().printf(" if AIN%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7504 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7505 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7506 continue;
whismanoid 17:9397ea3ea7e9 7507 }
whismanoid 17:9397ea3ea7e9 7508 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7509 break;
whismanoid 17:9397ea3ea7e9 7510 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 7511 //~ cmdLine.serial().printf(" if AIN%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7512 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7513 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7514 continue;
whismanoid 17:9397ea3ea7e9 7515 }
whismanoid 17:9397ea3ea7e9 7516 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7517 break;
whismanoid 17:9397ea3ea7e9 7518 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 7519 //~ cmdLine.serial().printf(" if AIN%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7520 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7521 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7522 continue;
whismanoid 17:9397ea3ea7e9 7523 }
whismanoid 17:9397ea3ea7e9 7524 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7525 break;
whismanoid 17:9397ea3ea7e9 7526 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 7527 //~ cmdLine.serial().printf(" if AIN%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7528 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7529 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7530 continue;
whismanoid 17:9397ea3ea7e9 7531 }
whismanoid 17:9397ea3ea7e9 7532 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7533 break;
whismanoid 17:9397ea3ea7e9 7534 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 7535 //~ cmdLine.serial().printf(" if AIN%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7536 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7537 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7538 continue;
whismanoid 17:9397ea3ea7e9 7539 }
whismanoid 17:9397ea3ea7e9 7540 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7541 break;
whismanoid 17:9397ea3ea7e9 7542 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 7543 // selected Datalogger_action_table[i].digitalOutPin
whismanoid 17:9397ea3ea7e9 7544 // perform selected Datalogger_action_table[i].action
whismanoid 17:9397ea3ea7e9 7545 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 7546 {
whismanoid 17:9397ea3ea7e9 7547 case action_noop:
whismanoid 17:9397ea3ea7e9 7548 //~ cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 7549 break;
whismanoid 17:9397ea3ea7e9 7550 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 7551 {
whismanoid 17:9397ea3ea7e9 7552 //~ cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 7553 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 7554 // perform action digitalOutLow
whismanoid 17:9397ea3ea7e9 7555 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 7556 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 7557 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7558 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7559 #else
whismanoid 17:9397ea3ea7e9 7560 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 7561 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 7562 digitalInOutPin.write(0);
whismanoid 17:9397ea3ea7e9 7563 #endif
whismanoid 17:9397ea3ea7e9 7564 }
whismanoid 17:9397ea3ea7e9 7565 break;
whismanoid 17:9397ea3ea7e9 7566 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 7567 {
whismanoid 17:9397ea3ea7e9 7568 //~ cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 7569 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 7570 // perform action digitalOutHigh
whismanoid 17:9397ea3ea7e9 7571 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 7572 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 7573 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7574 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7575 #else
whismanoid 17:9397ea3ea7e9 7576 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 7577 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 7578 digitalInOutPin.write(1);
whismanoid 17:9397ea3ea7e9 7579 #endif
whismanoid 17:9397ea3ea7e9 7580 }
whismanoid 17:9397ea3ea7e9 7581 break;
whismanoid 29:6a9edb6e973b 7582 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 7583 {
whismanoid 30:07197a430869 7584 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 7585 Datalogger_Trigger_enum_t saved_Datalogger_Trigger = Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 7586 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7587 switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 7588 {
whismanoid 29:6a9edb6e973b 7589 case 1:
whismanoid 29:6a9edb6e973b 7590 onButton1FallingEdge();
whismanoid 29:6a9edb6e973b 7591 break;
whismanoid 29:6a9edb6e973b 7592 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7593 case 2:
whismanoid 29:6a9edb6e973b 7594 onButton2FallingEdge();
whismanoid 29:6a9edb6e973b 7595 break;
whismanoid 29:6a9edb6e973b 7596 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7597 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7598 case 3:
whismanoid 29:6a9edb6e973b 7599 onButton3FallingEdge();
whismanoid 29:6a9edb6e973b 7600 break;
whismanoid 29:6a9edb6e973b 7601 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7602 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7603 case 4:
whismanoid 29:6a9edb6e973b 7604 onButton4FallingEdge();
whismanoid 29:6a9edb6e973b 7605 break;
whismanoid 29:6a9edb6e973b 7606 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7607 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7608 case 5:
whismanoid 29:6a9edb6e973b 7609 onButton5FallingEdge();
whismanoid 29:6a9edb6e973b 7610 break;
whismanoid 29:6a9edb6e973b 7611 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7612 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7613 case 6:
whismanoid 29:6a9edb6e973b 7614 onButton6FallingEdge();
whismanoid 29:6a9edb6e973b 7615 break;
whismanoid 29:6a9edb6e973b 7616 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7617 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7618 case 7:
whismanoid 29:6a9edb6e973b 7619 onButton7FallingEdge();
whismanoid 29:6a9edb6e973b 7620 break;
whismanoid 29:6a9edb6e973b 7621 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7622 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7623 case 8:
whismanoid 29:6a9edb6e973b 7624 onButton8FallingEdge();
whismanoid 29:6a9edb6e973b 7625 break;
whismanoid 29:6a9edb6e973b 7626 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7627 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7628 case 9:
whismanoid 29:6a9edb6e973b 7629 onButton9FallingEdge();
whismanoid 29:6a9edb6e973b 7630 break;
whismanoid 29:6a9edb6e973b 7631 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7632 } // switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 7633 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 30:07197a430869 7634 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 7635 Datalogger_Trigger = saved_Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 7636 } // case action_button
whismanoid 29:6a9edb6e973b 7637 break;
whismanoid 17:9397ea3ea7e9 7638 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 7639 //~ cmdLine.serial().printf("trigger_Halt");
whismanoid 17:9397ea3ea7e9 7640 // perform action trigger_Halt
whismanoid 17:9397ea3ea7e9 7641 Datalogger_Trigger = trigger_Halt;
whismanoid 17:9397ea3ea7e9 7642 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7643 break;
whismanoid 17:9397ea3ea7e9 7644 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 7645 //~ cmdLine.serial().printf("trigger_FreeRun");
whismanoid 17:9397ea3ea7e9 7646 // perform action trigger_FreeRun
whismanoid 17:9397ea3ea7e9 7647 Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 7648 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7649 break;
whismanoid 17:9397ea3ea7e9 7650 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 7651 //~ cmdLine.serial().printf("trigger_Timer");
whismanoid 17:9397ea3ea7e9 7652 //~ // print configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 7653 //~ cmdLine.serial().printf("(%d x %dmsec)", g_timer_interval_count, g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 7654 // perform action trigger_Timer
whismanoid 17:9397ea3ea7e9 7655 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 7656 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7657 break;
whismanoid 17:9397ea3ea7e9 7658 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 7659 //~ cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 7660 //~ // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 7661 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 7662 // TODO: perform action action_trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 7663 Datalogger_Trigger = trigger_PlatformDigitalInput;
whismanoid 17:9397ea3ea7e9 7664 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7665 break;
whismanoid 17:9397ea3ea7e9 7666 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 7667 //~ cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 7668 //~ // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 7669 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 7670 // TODO: perform action action_trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 7671 Datalogger_Trigger = trigger_SPIDeviceRegRead;
whismanoid 17:9397ea3ea7e9 7672 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7673 break;
whismanoid 17:9397ea3ea7e9 7674 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 7675 // consider next row of action table
whismanoid 17:9397ea3ea7e9 7676 } // for ...Datalogger_action_table_row_count
whismanoid 17:9397ea3ea7e9 7677 }
whismanoid 17:9397ea3ea7e9 7678 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 7679
whismanoid 5:aaf8b5f5fda1 7680 //--------------------------------------------------
whismanoid 8:dffee7509bfb 7681 void Datalogger_PrintRow(CmdLine& cmdLine)
whismanoid 5:aaf8b5f5fda1 7682 {
whismanoid 5:aaf8b5f5fda1 7683 int field_index = 0;
whismanoid 5:aaf8b5f5fda1 7684 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 7685 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 7686 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 5:aaf8b5f5fda1 7687 continue;
whismanoid 5:aaf8b5f5fda1 7688 }
whismanoid 5:aaf8b5f5fda1 7689 // comma between fields
whismanoid 5:aaf8b5f5fda1 7690 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 7691 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 7692 }
whismanoid 10:04022a61b527 7693 field_index++;
whismanoid 10:04022a61b527 7694 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 10:04022a61b527 7695 cmdLine.serial().printf("%d", g_MAX11410_device.AINcode[channel_index]);
whismanoid 10:04022a61b527 7696 }
whismanoid 10:04022a61b527 7697 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 10:04022a61b527 7698 // TODO: report Voltage instead of LSB
whismanoid 10:04022a61b527 7699 // Serial.print(SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 7700 static char strOutLineBuffer[16];
whismanoid 10:04022a61b527 7701 cmdLine.serial().printf("%6.6f", SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 7702 }
whismanoid 5:aaf8b5f5fda1 7703 }
whismanoid 5:aaf8b5f5fda1 7704 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7705 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 7706 if (part_id_readback != part_id_expect) {
whismanoid 5:aaf8b5f5fda1 7707 cmdLine.serial().printf(",\"FAIL\"");
whismanoid 9:45f98573eb6d 7708 need_reinit = true;
whismanoid 5:aaf8b5f5fda1 7709 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7710 g_MAX11410_device.Init();
whismanoid 5:aaf8b5f5fda1 7711 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 5:aaf8b5f5fda1 7712 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 5:aaf8b5f5fda1 7713 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 5:aaf8b5f5fda1 7714 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7715 }
whismanoid 5:aaf8b5f5fda1 7716 else {
whismanoid 5:aaf8b5f5fda1 7717 cmdLine.serial().printf(",\"OK\"");
whismanoid 5:aaf8b5f5fda1 7718 }
whismanoid 5:aaf8b5f5fda1 7719 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7720 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7721 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 7722 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 7723 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 7724 continue;
whismanoid 9:45f98573eb6d 7725 }
whismanoid 5:aaf8b5f5fda1 7726 // comma between fields
whismanoid 5:aaf8b5f5fda1 7727 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 7728 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 7729 }
whismanoid 9:45f98573eb6d 7730 field_index++;
whismanoid 9:45f98573eb6d 7731 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 5:aaf8b5f5fda1 7732 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 7733 cmdLine.serial().printf("%u", Platform_LSB[channel_index]);
whismanoid 9:45f98573eb6d 7734 #endif
whismanoid 9:45f98573eb6d 7735 }
whismanoid 9:45f98573eb6d 7736 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 7737 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 11:2b8adc78618a 7738 // Datalog Volts omit V suffix from numbers #275
whismanoid 11:2b8adc78618a 7739 // because Excel graphs can't handle numbers that have a suffix.
whismanoid 11:2b8adc78618a 7740 cmdLine.serial().printf("%6.6f", Platform_Voltage[channel_index]);
whismanoid 9:45f98573eb6d 7741 #endif
whismanoid 9:45f98573eb6d 7742 }
whismanoid 5:aaf8b5f5fda1 7743 }
whismanoid 5:aaf8b5f5fda1 7744 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 7745 if (need_reinit) {
whismanoid 9:45f98573eb6d 7746 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 7747 if (g_MAX11410_device.Init() == 0) {
whismanoid 9:45f98573eb6d 7748 //~ cmdLine.serial().printf(",\"Init() failed\"");
whismanoid 9:45f98573eb6d 7749 } else {
whismanoid 9:45f98573eb6d 7750 //~ cmdLine.serial().printf(",\"Init() success\"");
whismanoid 9:45f98573eb6d 7751 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 7752 // in Datalogger_PrintRow(), when part_id test fails,
whismanoid 9:45f98573eb6d 7753 // apply list of custom register writes after re-init
whismanoid 9:45f98573eb6d 7754 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 7755 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 9:45f98573eb6d 7756 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 9:45f98573eb6d 7757 uint32_t regData = custom_reg_init_data[index];
whismanoid 9:45f98573eb6d 7758 cmdLine.serial().printf("*%s=0x%06.6x", g_MAX11410_device.RegName(regAddress), regData);
whismanoid 9:45f98573eb6d 7759 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 9:45f98573eb6d 7760 }
whismanoid 9:45f98573eb6d 7761 #endif // USE_CUSTOM_REG_INIT
whismanoid 9:45f98573eb6d 7762 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 9:45f98573eb6d 7763 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 9:45f98573eb6d 7764 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 9:45f98573eb6d 7765 need_reinit = false;
whismanoid 9:45f98573eb6d 7766 }
whismanoid 9:45f98573eb6d 7767 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 7768 need_reinit = false;
whismanoid 9:45f98573eb6d 7769 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 7770 }
whismanoid 30:07197a430869 7771 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 7772 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in void Datalogger_PrintRow()
whismanoid 30:07197a430869 7773 cmdLine.serial().printf(",\"%s\"", gstrRemarkText);
whismanoid 30:07197a430869 7774 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 5:aaf8b5f5fda1 7775 cmdLine.serial().printf("\r\n");
whismanoid 9:45f98573eb6d 7776 if (need_reinit) {
whismanoid 9:45f98573eb6d 7777 //~ delay(500); // platform_delay_ms 500ms timing delay function
whismanoid 9:45f98573eb6d 7778 }
whismanoid 5:aaf8b5f5fda1 7779 } // void Datalogger_PrintRow()
whismanoid 5:aaf8b5f5fda1 7780
whismanoid 0:cb44e2e9ec4c 7781 // example code main function
whismanoid 0:cb44e2e9ec4c 7782 int main()
whismanoid 0:cb44e2e9ec4c 7783 {
whismanoid 0:cb44e2e9ec4c 7784 // setup: put your setup code here, to run once
whismanoid 4:d9b05924ad4c 7785 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 7786 // Configure serial ports
whismanoid 4:d9b05924ad4c 7787 cmdLine.clear();
whismanoid 4:d9b05924ad4c 7788 //~ cmdLine.serial().printf("\r\n cmdLine.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 7789 cmdLine.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 7790 //~ cmdLine.diagnostic_led_EOF = diagnostic_led_EOF;
whismanoid 4:d9b05924ad4c 7791 /// CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21);
whismanoid 4:d9b05924ad4c 7792 //~ cmdLine.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 7793 //~ cmdLine.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 7794 //~ cmdLine.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 7795 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 7796 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 7797 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 7798 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 7799 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 7800 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 7801 # else
whismanoid 10:04022a61b527 7802 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 7803 DAPLINKserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 7804 # endif
whismanoid 10:04022a61b527 7805 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 7806 cmdLine_DAPLINKserial.clear();
whismanoid 4:d9b05924ad4c 7807 //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 7808 cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 7809 //~ cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 7810 //~ cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 7811 //~ cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 7812 # endif
whismanoid 6:f6d16658342b 7813 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 7814 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 10:04022a61b527 7815 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 7816 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 7817 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 7818 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 7819 AUXserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 7820 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 6:f6d16658342b 7821 cmdLine_AUXserial.clear();
whismanoid 6:f6d16658342b 7822 //~ cmdLine_AUXserial.serial().printf("\r\n cmdLine_AUXserial.serial().printf test\r\n");
whismanoid 6:f6d16658342b 7823 cmdLine_AUXserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 6:f6d16658342b 7824 //~ cmdLine_AUXserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 6:f6d16658342b 7825 //~ cmdLine_AUXserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 6:f6d16658342b 7826 //~ cmdLine_AUXserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 6:f6d16658342b 7827 # endif // HAS_AUX_SERIAL
whismanoid 4:d9b05924ad4c 7828 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 0:cb44e2e9ec4c 7829
whismanoid 0:cb44e2e9ec4c 7830 // example code: serial port banner message
whismanoid 0:cb44e2e9ec4c 7831 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 7832 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 7833 cmdLine.serial().printf("\r\nDataLogger_MAX11410\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 7834 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7835 cmdLine.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 7836 # if HAS_DAPLINK_SERIAL
whismanoid 3:9055e17e181a 7837 cmdLine_DAPLINKserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 7838 # endif // HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 7839 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 7840 cmdLine_AUXserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 6:f6d16658342b 7841 # endif // HAS_AUX_SERIAL
whismanoid 3:9055e17e181a 7842 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 7843
whismanoid 1:747f1602abfc 7844 // CODE GENERATOR: get spi properties from device
whismanoid 3:9055e17e181a 7845 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 7846 if (g_SPI_SCLK_Hz > g_MAX11410_device.get_spi_frequency())
whismanoid 3:9055e17e181a 7847 { // Device limits SPI SCLK frequency
whismanoid 3:9055e17e181a 7848 g_SPI_SCLK_Hz = g_MAX11410_device.get_spi_frequency();
whismanoid 3:9055e17e181a 7849 cmdLine.serial().printf("\r\nMAX11410 limits SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 7850
whismanoid 3:9055e17e181a 7851 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 7852 }
whismanoid 3:9055e17e181a 7853 if (g_MAX11410_device.get_spi_frequency() > g_SPI_SCLK_Hz)
whismanoid 3:9055e17e181a 7854 { // Platform limits SPI SCLK frequency
whismanoid 3:9055e17e181a 7855 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 7856 cmdLine.serial().printf("\r\nPlatform limits MAX11410 SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 7857
whismanoid 3:9055e17e181a 7858 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 7859 }
whismanoid 0:cb44e2e9ec4c 7860 // g_SPI_dataMode = g_MAX11410_device.get_spi_dataMode();
whismanoid 3:9055e17e181a 7861 while (g_MAX11410_device.Init() == 0)
whismanoid 3:9055e17e181a 7862 {
whismanoid 3:9055e17e181a 7863 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 7864 cmdLine.serial().printf("\r\nMAX11410 Init failed; retry...\r\n");
whismanoid 3:9055e17e181a 7865
whismanoid 3:9055e17e181a 7866 }
whismanoid 0:cb44e2e9ec4c 7867
whismanoid 0:cb44e2e9ec4c 7868 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 3:9055e17e181a 7869 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 7870 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 3:9055e17e181a 7871 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 3:9055e17e181a 7872 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 3:9055e17e181a 7873 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7874 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 3:9055e17e181a 7875 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7876 // CODE GENERATOR: example code: has no member function REF
whismanoid 0:cb44e2e9ec4c 7877 // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line
whismanoid 0:cb44e2e9ec4c 7878 // CODE GENERATOR: ResolutionBits = 24
whismanoid 0:cb44e2e9ec4c 7879 // CODE GENERATOR: FScode = 0xffffff
whismanoid 0:cb44e2e9ec4c 7880 // CODE GENERATOR: NumChannels = 10
whismanoid 0:cb44e2e9ec4c 7881 // CODE GENERATOR: banner before DataLogHelloCppCodeList while(1)
whismanoid 3:9055e17e181a 7882 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 7883 cmdLine.serial().printf("v_filter = 0x%2.2x\r\n", g_MAX11410_device.v_filter);
whismanoid 0:cb44e2e9ec4c 7884
whismanoid 3:9055e17e181a 7885 cmdLine.serial().printf("v_pga = 0x%2.2x\r\n", g_MAX11410_device.v_pga);
whismanoid 0:cb44e2e9ec4c 7886
whismanoid 3:9055e17e181a 7887 cmdLine.serial().printf("v_ctrl = 0x%2.2x\r\n", g_MAX11410_device.v_ctrl);
whismanoid 3:9055e17e181a 7888
whismanoid 3:9055e17e181a 7889 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7890
whismanoid 3:9055e17e181a 7891 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 7892 Datalogger_Need_PrintHeader = true;
whismanoid 10:04022a61b527 7893
whismanoid 12:2dfc1f2009e0 7894 #if USE_LEDS
whismanoid 12:2dfc1f2009e0 7895 #if defined(TARGET_MAX32630)
whismanoid 12:2dfc1f2009e0 7896 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 7897 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7898 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 7899 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7900 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 7901 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7902 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 7903 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7904 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 7905 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7906 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 7907 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7908 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 7909 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7910 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 7911 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 19:5ff09c8e9daf 7912 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 12:2dfc1f2009e0 7913 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 7914 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7915 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 7916 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7917 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 7918 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7919 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 7920 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7921 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 7922 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7923 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 7924 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7925 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 7926 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7927 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 7928 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7929 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 12:2dfc1f2009e0 7930 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 7931 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7932 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7933 led4 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7934 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7935 //led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 7936 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 7937 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7938 led1 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7939 //led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 7940 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 7941 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7942 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7943 //led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 7944 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 7945 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7946 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7947 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 7948 //
whismanoid 12:2dfc1f2009e0 7949 #endif // target definition
whismanoid 12:2dfc1f2009e0 7950 #endif
whismanoid 12:2dfc1f2009e0 7951
whismanoid 12:2dfc1f2009e0 7952 if (led1.is_connected()) {
whismanoid 12:2dfc1f2009e0 7953 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 7954 }
whismanoid 12:2dfc1f2009e0 7955 if (led2.is_connected()) {
whismanoid 12:2dfc1f2009e0 7956 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 7957 }
whismanoid 12:2dfc1f2009e0 7958 if (led3.is_connected()) {
whismanoid 12:2dfc1f2009e0 7959 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 7960 }
whismanoid 12:2dfc1f2009e0 7961
whismanoid 46:469d0061df5d 7962 #if HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 7963 // WIP #312 load values from flash_page_configuration_back_up[] during init
whismanoid 48:18647e0516f2 7964 const uint32_t load_arg = load_arg_startup;
whismanoid 46:469d0061df5d 7965 Load_flash_page_configuration_back_up(cmdLine, load_arg);
whismanoid 46:469d0061df5d 7966 #endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 7967
whismanoid 4:d9b05924ad4c 7968 while(1) { // this code repeats forever
whismanoid 4:d9b05924ad4c 7969 // this code repeats forever
whismanoid 4:d9b05924ad4c 7970
whismanoid 21:ac062a97a71d 7971 #if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 7972 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 7973 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 7974 # if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 7975 static int button1_value_prev = 1;
whismanoid 21:ac062a97a71d 7976 static int button1_value_now = 1;
whismanoid 21:ac062a97a71d 7977 button1_value_prev = button1_value_now;
whismanoid 21:ac062a97a71d 7978 button1_value_now = button1.read();
whismanoid 21:ac062a97a71d 7979 if ((button1_value_prev - button1_value_now) == 1)
whismanoid 21:ac062a97a71d 7980 {
whismanoid 21:ac062a97a71d 7981 // on button1 falling edge (button1 press)
whismanoid 21:ac062a97a71d 7982 onButton1FallingEdge();
whismanoid 21:ac062a97a71d 7983 }
whismanoid 21:ac062a97a71d 7984 # endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7985 # if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7986 static int button2_value_prev = 1;
whismanoid 24:032f3683cb2a 7987 static int button2_value_now = 1;
whismanoid 24:032f3683cb2a 7988 button2_value_prev = button2_value_now;
whismanoid 24:032f3683cb2a 7989 button2_value_now = button2.read();
whismanoid 24:032f3683cb2a 7990 if ((button2_value_prev - button2_value_now) == 1)
whismanoid 24:032f3683cb2a 7991 {
whismanoid 24:032f3683cb2a 7992 // on button2 falling edge (button2 press)
whismanoid 24:032f3683cb2a 7993 onButton2FallingEdge();
whismanoid 24:032f3683cb2a 7994 }
whismanoid 24:032f3683cb2a 7995 # endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7996 # if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7997 static int button3_value_prev = 1;
whismanoid 24:032f3683cb2a 7998 static int button3_value_now = 1;
whismanoid 24:032f3683cb2a 7999 button3_value_prev = button3_value_now;
whismanoid 24:032f3683cb2a 8000 button3_value_now = button3.read();
whismanoid 24:032f3683cb2a 8001 if ((button3_value_prev - button3_value_now) == 1)
whismanoid 24:032f3683cb2a 8002 {
whismanoid 24:032f3683cb2a 8003 // on button3 falling edge (button3 press)
whismanoid 26:13cba69d88eb 8004 onButton3FallingEdge();
whismanoid 24:032f3683cb2a 8005 }
whismanoid 24:032f3683cb2a 8006 # endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 8007 #endif // HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 4:d9b05924ad4c 8008 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 8009 // TODO support CmdLine command menus (like on Serial_Tester); help and usual boilerplate
whismanoid 10:04022a61b527 8010 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 8011 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 8012 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 8013 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 8014 // Accept commands from Auxiliary serial port
whismanoid 6:f6d16658342b 8015 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 8016 if (AUXserial.readable()) {
whismanoid 6:f6d16658342b 8017 cmdLine_AUXserial.append(AUXserial.getc());
whismanoid 6:f6d16658342b 8018 }
whismanoid 6:f6d16658342b 8019 # endif // HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 8020 # if HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 8021 if (DAPLINKserial.readable()) {
whismanoid 6:f6d16658342b 8022 cmdLine_DAPLINKserial.append(DAPLINKserial.getc());
whismanoid 6:f6d16658342b 8023 }
whismanoid 6:f6d16658342b 8024 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 8025 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 8026 if (serial.readable()) {
whismanoid 4:d9b05924ad4c 8027 int c = serial.getc(); // instead of getc() or fgetc()
whismanoid 4:d9b05924ad4c 8028 cmdLine.append(c);
whismanoid 4:d9b05924ad4c 8029 // cmdLine.onEOLcommandParser handler implements menus
whismanoid 4:d9b05924ad4c 8030 } // if (Serial.available())
whismanoid 4:d9b05924ad4c 8031 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 8032
whismanoid 4:d9b05924ad4c 8033 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 32:80f3e5eb77d4 8034 // Datalog trigger
whismanoid 4:d9b05924ad4c 8035 if (Datalogger_Trigger == trigger_Halt) {
whismanoid 4:d9b05924ad4c 8036 // halt the datalogger; continue accepting commands
whismanoid 3:9055e17e181a 8037 continue;
whismanoid 3:9055e17e181a 8038 }
whismanoid 4:d9b05924ad4c 8039 if (Datalogger_Trigger == trigger_FreeRun) {
whismanoid 4:d9b05924ad4c 8040 // free run as fast as possible
whismanoid 3:9055e17e181a 8041 }
whismanoid 4:d9b05924ad4c 8042 if (Datalogger_Trigger == trigger_Timer) {
whismanoid 4:d9b05924ad4c 8043 // timer (configure interval)
whismanoid 32:80f3e5eb77d4 8044 // if Datalogger_Trigger == trigger_Timer sleep(g_timer_interval_msec)
whismanoid 39:4d285e961435 8045 //
whismanoid 39:4d285e961435 8046 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 8047 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 8048 // Sleep Mode vs Deep Sleep Mode
whismanoid 39:4d285e961435 8049 // See documentation https://os.mbed.com/docs/mbed-os/v5.15/apis/power-management-sleep.html
whismanoid 41:13a6a097502c 8050 // ThisThread::sleep_for(uint32_t millisec)
whismanoid 41:13a6a097502c 8051 // sleep_manager_can_deep_sleep() // tests whether deep_sleep is locked or not
whismanoid 41:13a6a097502c 8052 // sleep_manager_lock_deep_sleep() // begin section that prevents deep_sleep
whismanoid 41:13a6a097502c 8053 // sleep_manager_unlock_deep_sleep() // end section that prevents deep_sleep
whismanoid 39:4d285e961435 8054 switch(g_timer_sleepmode)
whismanoid 39:4d285e961435 8055 {
whismanoid 39:4d285e961435 8056 case datalogger_Sleep_LP0_Stop: // LT sleep = 0,
whismanoid 45:74bf1fe021e5 8057 // TODO: LP0 stop mode not supported; how would we wake up?
whismanoid 39:4d285e961435 8058 break;
whismanoid 39:4d285e961435 8059 case datalogger_Sleep_LP1_DeepSleep: // LT sleep = 1,
whismanoid 42:89607d5d4e6d 8060 //
whismanoid 45:74bf1fe021e5 8061 // In file mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\sleep.c
whismanoid 45:74bf1fe021e5 8062 // support function hal_deepsleep() just calls hal_sleep(),
whismanoid 45:74bf1fe021e5 8063 // so using LP1 Deep Sleep requires calling the low-level functions directly.
whismanoid 42:89607d5d4e6d 8064 //
whismanoid 41:13a6a097502c 8065 // sleep_manager_can_deep_sleep(); // tests whether deep_sleep is locked or not
whismanoid 41:13a6a097502c 8066 // mbed_file_handle(STDIN_FILENO)->enable_input(false); // (mbed-os-5.15) platform.stdio-buffered-serial prevents deep sleep
whismanoid 45:74bf1fe021e5 8067 #if MBED_VERSION >= MBED_ENCODE_VERSION(5, 15, 0)
whismanoid 41:13a6a097502c 8068 cmdLine.serial().enable_input(false); // (mbed-os-5.15) platform.stdio-buffered-serial prevents deep sleep
whismanoid 41:13a6a097502c 8069 // serial.enable_input(false); // (mbed-os-5.15) platform.stdio-buffered-serial prevents deep sleep
whismanoid 43:4c4733760d4c 8070
whismanoid 43:4c4733760d4c 8071 // configure RTC and start
whismanoid 43:4c4733760d4c 8072 // RTC_Setup();
whismanoid 43:4c4733760d4c 8073 {
whismanoid 43:4c4733760d4c 8074 rtc_cfg_t RTCconfig;
whismanoid 43:4c4733760d4c 8075 RTCconfig.compareCount[0] = 5;//5 second timer -- override with RTC_SetCompare(0,counts)
whismanoid 43:4c4733760d4c 8076 RTCconfig.compareCount[1] = 7;//7 second timer -- override with RTC_SetCompare(1,counts)
whismanoid 43:4c4733760d4c 8077 RTCconfig.prescaler = RTC_PRESCALE_DIV_2_12; //1Hz clock
whismanoid 43:4c4733760d4c 8078 RTCconfig.prescalerMask = RTC_PRESCALE_DIV_2_12;//used for prescaler compare
whismanoid 43:4c4733760d4c 8079 RTCconfig.snoozeCount = 0;
whismanoid 43:4c4733760d4c 8080 RTCconfig.snoozeMode = RTC_SNOOZE_DISABLE;
whismanoid 43:4c4733760d4c 8081 RTC_Init(&RTCconfig);
whismanoid 43:4c4733760d4c 8082 RTC_Start();
whismanoid 43:4c4733760d4c 8083
whismanoid 43:4c4733760d4c 8084 // Clear existing wake-up config
whismanoid 43:4c4733760d4c 8085 LP_ClearWakeUpConfig();
whismanoid 43:4c4733760d4c 8086
whismanoid 43:4c4733760d4c 8087 // Clear any event flags
whismanoid 43:4c4733760d4c 8088 LP_ClearWakeUpFlags();
whismanoid 43:4c4733760d4c 8089
whismanoid 43:4c4733760d4c 8090 // configure wake-up on RTC compare 1
whismanoid 43:4c4733760d4c 8091 // LP_ConfigRTCWakeUp(unsigned int comp0_en, unsigned int comp1_en, unsigned int prescale_cmp_en, unsigned int rollover_en);
whismanoid 43:4c4733760d4c 8092 LP_ConfigRTCWakeUp(0, 1, 0, 0);
whismanoid 43:4c4733760d4c 8093
whismanoid 44:84402faa8eb9 8094 // wait until UART_Busy indicates no ongoing transactions (both ports)
whismanoid 44:84402faa8eb9 8095 while (Console_PrepForSleep() != E_NO_ERROR);
whismanoid 44:84402faa8eb9 8096
whismanoid 43:4c4733760d4c 8097 // set RTC compare 1 value
whismanoid 43:4c4733760d4c 8098 // cmp = RTC_GetCount() + LP1_WakeTime;
whismanoid 43:4c4733760d4c 8099 uint32_t cmp = RTC_GetCount() + ((g_timer_interval_msec + 500.) / 1000.);
whismanoid 43:4c4733760d4c 8100 // RTC_SetCompare(uint8_t compareIndex, uint32_t counts)
whismanoid 43:4c4733760d4c 8101 RTC_SetCompare(1, cmp);
whismanoid 43:4c4733760d4c 8102
whismanoid 43:4c4733760d4c 8103 RTC_ClearFlags(MXC_F_RTC_FLAGS_COMP1);
whismanoid 43:4c4733760d4c 8104 }
whismanoid 43:4c4733760d4c 8105
whismanoid 43:4c4733760d4c 8106 //global disable interrupt
whismanoid 43:4c4733760d4c 8107 __disable_irq();
whismanoid 43:4c4733760d4c 8108
whismanoid 43:4c4733760d4c 8109 LP_EnterLP1();
whismanoid 43:4c4733760d4c 8110
whismanoid 43:4c4733760d4c 8111 //global enable interrupt
whismanoid 43:4c4733760d4c 8112 __enable_irq();
whismanoid 43:4c4733760d4c 8113
whismanoid 43:4c4733760d4c 8114 // stop waking on RTC
whismanoid 43:4c4733760d4c 8115 // LP_ConfigRTCWakeUp(unsigned int comp0_en, unsigned int comp1_en, unsigned int prescale_cmp_en, unsigned int rollover_en);
whismanoid 43:4c4733760d4c 8116 LP_ConfigRTCWakeUp(0, 0, 0, 0);
whismanoid 43:4c4733760d4c 8117
whismanoid 43:4c4733760d4c 8118 // Clear existing wake-up config
whismanoid 43:4c4733760d4c 8119 LP_ClearWakeUpConfig();
whismanoid 43:4c4733760d4c 8120
whismanoid 43:4c4733760d4c 8121 // Clear any event flags
whismanoid 43:4c4733760d4c 8122 LP_ClearWakeUpFlags();
whismanoid 45:74bf1fe021e5 8123
whismanoid 43:4c4733760d4c 8124 RTC_Stop();
whismanoid 43:4c4733760d4c 8125
whismanoid 41:13a6a097502c 8126 // mbed_file_handle(STDIN_FILENO)->enable_input(true); // (mbed-os-5.15)
whismanoid 41:13a6a097502c 8127 cmdLine.serial().enable_input(true); // (mbed-os-5.15)
whismanoid 41:13a6a097502c 8128 // serial.enable_input(true); // (mbed-os-5.15)
whismanoid 39:4d285e961435 8129 break;
whismanoid 45:74bf1fe021e5 8130 #endif // MBED_VERSION >= MBED_ENCODE_VERSION(5, 15, 0)
whismanoid 39:4d285e961435 8131 case datalogger_Sleep_LP2_Sleep: // LT sleep = 2,
whismanoid 41:13a6a097502c 8132 sleep_manager_lock_deep_sleep(); // begin section that prevents deep_sleep
whismanoid 41:13a6a097502c 8133 ThisThread::sleep_for(g_timer_interval_msec); // wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 41:13a6a097502c 8134 sleep_manager_unlock_deep_sleep(); // end section that prevents deep_sleep
whismanoid 39:4d285e961435 8135 break;
whismanoid 39:4d285e961435 8136 case datalogger_Sleep_LP3_Run: // LT sleep = 3,
whismanoid 45:74bf1fe021e5 8137 // TODO: USE_DATALOGGER_SLEEP -- ThisThread::sleep_for(uint32_t millisec) instead of wait_ms(g_timer_interval_msec)
whismanoid 41:13a6a097502c 8138 wait_ms(g_timer_interval_msec);
whismanoid 39:4d285e961435 8139 break;
whismanoid 39:4d285e961435 8140 }
whismanoid 39:4d285e961435 8141 #else // USE_DATALOGGER_SLEEP
whismanoid 17:9397ea3ea7e9 8142 wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 39:4d285e961435 8143 #endif // USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 8144 //
whismanoid 17:9397ea3ea7e9 8145 if (g_timer_interval_counter > 0) {
whismanoid 17:9397ea3ea7e9 8146 g_timer_interval_counter--;
whismanoid 17:9397ea3ea7e9 8147 continue;
whismanoid 17:9397ea3ea7e9 8148 }
whismanoid 17:9397ea3ea7e9 8149 // if time interval not yet reached, continue (continue accepting commands)
whismanoid 32:80f3e5eb77d4 8150 g_timer_interval_counter = g_timer_interval_count-1;
whismanoid 3:9055e17e181a 8151 }
whismanoid 4:d9b05924ad4c 8152 if (Datalogger_Trigger == trigger_PlatformDigitalInput) {
whismanoid 4:d9b05924ad4c 8153 // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 8154 // TODO: read selected input pin, test value
whismanoid 17:9397ea3ea7e9 8155 // TODO: if no match, continue (continue accepting commands)
whismanoid 3:9055e17e181a 8156 }
whismanoid 4:d9b05924ad4c 8157 if (Datalogger_Trigger == trigger_SPIDeviceRegRead) {
whismanoid 4:d9b05924ad4c 8158 // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 8159 // TODO: SPI transfer regAddr
whismanoid 17:9397ea3ea7e9 8160 // TODO: apply dataMask, compare with testValue
whismanoid 17:9397ea3ea7e9 8161 // TODO: if no match, continue (continue accepting commands)
whismanoid 4:d9b05924ad4c 8162 }
whismanoid 4:d9b05924ad4c 8163 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 0:cb44e2e9ec4c 8164
whismanoid 8:dffee7509bfb 8165 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 8166 if (Datalogger_Need_PrintHeader) {
whismanoid 8:dffee7509bfb 8167 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 8168 Datalogger_PrintHeader(cmdLine);
whismanoid 8:dffee7509bfb 8169 }
whismanoid 8:dffee7509bfb 8170 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 8171 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 8172 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 8173 }
whismanoid 8:dffee7509bfb 8174 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 8175 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 8176 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 8177 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 8178 }
whismanoid 8:dffee7509bfb 8179 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 8180 Datalogger_Need_PrintHeader = false;
whismanoid 8:dffee7509bfb 8181 }
whismanoid 5:aaf8b5f5fda1 8182 Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 8183 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 8184 // Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 8185 Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 8186 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 0:cb44e2e9ec4c 8187 // wait(3.0);
whismanoid 0:cb44e2e9ec4c 8188 // CODE GENERATOR: print conversion result
whismanoid 0:cb44e2e9ec4c 8189 // Use Arduino Serial Plotter to view output: Tools | Serial Plotter
whismanoid 8:dffee7509bfb 8190 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 8191 Datalogger_PrintRow(cmdLine);
whismanoid 8:dffee7509bfb 8192 }
whismanoid 8:dffee7509bfb 8193 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 8194 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 8195 Datalogger_PrintRow(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 8196 }
whismanoid 8:dffee7509bfb 8197 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 8198 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 8199 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 8200 Datalogger_PrintRow(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 8201 }
whismanoid 8:dffee7509bfb 8202 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:cb44e2e9ec4c 8203
whismanoid 0:cb44e2e9ec4c 8204 } // this code repeats forever
whismanoid 0:cb44e2e9ec4c 8205 }
whismanoid 0:cb44e2e9ec4c 8206 //---------- CODE GENERATOR: end DataLogHelloCppCodeList