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

Dependencies:   max32625pico CmdLine

Committer:
whismanoid
Date:
Fri Oct 29 23:05:44 2021 -0700
Revision:
47:f1a56afb4aca
Parent:
46:469d0061df5d
Child:
48:18647e0516f2
Configuration load/save in flash (%A cal? values); #312
default values in flash_page_configuration_back_up, including board serial number

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 46:469d0061df5d 2619 // WIP #312 store values into flash_page_configuration_back_up[] from calibration_05_V[] etc. Default save everything.
whismanoid 46:469d0061df5d 2620 // @param[in] save_arg 0x000000FF = erase flash file before saving values; 0xFFFFFF00 = filter items to save
whismanoid 46:469d0061df5d 2621 int Save_flash_page_configuration_back_up(CmdLine& cmdLine, uint32_t save_arg)
whismanoid 46:469d0061df5d 2622 {
whismanoid 46:469d0061df5d 2623 cmdLine.serial().printf("\r\nSave_flash_page_configuration_back_up(0x%8.8lx)...", save_arg);
whismanoid 46:469d0061df5d 2624 // WIP #312 %F save=save_arg could filter which items to append to flash file
whismanoid 46:469d0061df5d 2625 // initialize flash memory interface
whismanoid 46:469d0061df5d 2626 // FlashIAP: FlashIAP flash; flash.init();
whismanoid 46:469d0061df5d 2627 // int FLC_Init(void);
whismanoid 46:469d0061df5d 2628 // returns E_NO_ERROR or E_BUSY or E_UNKNOWN
whismanoid 46:469d0061df5d 2629 cmdLine.serial().printf("FLC_Init ");
whismanoid 46:469d0061df5d 2630 if (FLC_Init() != E_NO_ERROR)
whismanoid 46:469d0061df5d 2631 {
whismanoid 46:469d0061df5d 2632 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 2633 return 1; // can't perform the command
whismanoid 46:469d0061df5d 2634 }
whismanoid 46:469d0061df5d 2635 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 2636 //
whismanoid 46:469d0061df5d 2637
whismanoid 46:469d0061df5d 2638 uint32_t file_addr = (uint32_t)&flash_page_configuration_back_up[0];
whismanoid 46:469d0061df5d 2639 // uint32_t file_addr_end = file_addr + 8192 - 4;
whismanoid 46:469d0061df5d 2640 uint32_t file_addr_end = file_addr + 256 - 4; // development: reduce listing size
whismanoid 46:469d0061df5d 2641
whismanoid 46:469d0061df5d 2642 int poke_access_list_index = search_poke_access_list(file_addr);
whismanoid 46:469d0061df5d 2643 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 46:469d0061df5d 2644 poke_access_list_index,
whismanoid 46:469d0061df5d 2645 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 2646 poke_access_list[poke_access_list_index].addr_min,
whismanoid 46:469d0061df5d 2647 poke_access_list[poke_access_list_index].addr_max,
whismanoid 46:469d0061df5d 2648 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 46:469d0061df5d 2649 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 46:469d0061df5d 2650
whismanoid 46:469d0061df5d 2651 if ((save_arg & 0x000000FF) == 0xFF)
whismanoid 46:469d0061df5d 2652 {
whismanoid 46:469d0061df5d 2653 // erase flash file before saving configuration
whismanoid 46:469d0061df5d 2654 //
whismanoid 46:469d0061df5d 2655 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: erase page ...",
whismanoid 46:469d0061df5d 2656 poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 46:469d0061df5d 2657 // page erase using flash.erase(addr, flash.get_sector_size(addr));
whismanoid 46:469d0061df5d 2658 // int FLC_PageErase(uint32_t address, MXC_V_FLC_ERASE_CODE_PAGE_ERASE, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 2659 // @param address Address of the page to be erased.
whismanoid 46:469d0061df5d 2660 // @param erase_code Flash erase code; defined as
whismanoid 46:469d0061df5d 2661 // #MXC_V_FLC_ERASE_CODE_PAGE_ERASE for page erase
whismanoid 46:469d0061df5d 2662 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 2663 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 2664 if (FLC_PageErase(file_addr, MXC_V_FLC_ERASE_CODE_PAGE_ERASE,
whismanoid 46:469d0061df5d 2665 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 2666 {
whismanoid 46:469d0061df5d 2667 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 2668 return 1; // can't perform the command
whismanoid 46:469d0061df5d 2669 }
whismanoid 46:469d0061df5d 2670 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 2671 }
whismanoid 46:469d0061df5d 2672 // WIP #312: save_arg 0xFFFFFF00 = filter items to save
whismanoid 46:469d0061df5d 2673 // if (save_arg & 0xFFFFFF00 == _____)
whismanoid 46:469d0061df5d 2674 // {
whismanoid 46:469d0061df5d 2675 // }
whismanoid 46:469d0061df5d 2676
whismanoid 46:469d0061df5d 2677 // scan configuration_back_up_list[] for recordType
whismanoid 46:469d0061df5d 2678 for (int i = 0; configuration_back_up_list[i].recordType != 0x00000000; i++)
whismanoid 46:469d0061df5d 2679 {
whismanoid 46:469d0061df5d 2680 if (configuration_back_up_list[i].recordType == 0xFFFFFFFF) continue;
whismanoid 46:469d0061df5d 2681 //
whismanoid 46:469d0061df5d 2682 // configuration_back_up_list[i].recordType
whismanoid 46:469d0061df5d 2683 // configuration_back_up_list[i].addr
whismanoid 46:469d0061df5d 2684 // configuration_back_up_list[i].length_bytes
whismanoid 46:469d0061df5d 2685 // configuration_back_up_list[i].name
whismanoid 46:469d0061df5d 2686 // WIP #312 %F save=save_arg could filter which items to append to flash file
whismanoid 46:469d0061df5d 2687 //
whismanoid 46:469d0061df5d 2688 cmdLine.serial().printf("\r\n save 0x%8.8lx %s address 0x%8.8lx length 0x%lx bytes",
whismanoid 46:469d0061df5d 2689 configuration_back_up_list[i].recordType,
whismanoid 46:469d0061df5d 2690 configuration_back_up_list[i].name,
whismanoid 46:469d0061df5d 2691 (uint32_t)configuration_back_up_list[i].addr,
whismanoid 46:469d0061df5d 2692 configuration_back_up_list[i].length_bytes);
whismanoid 46:469d0061df5d 2693 //
whismanoid 46:469d0061df5d 2694 // find next free space to store record in flash file
whismanoid 46:469d0061df5d 2695 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 46:469d0061df5d 2696 cmdLine.serial().printf("0x%8.8lx ", *((uint32_t*)file_addr));
whismanoid 46:469d0061df5d 2697 while (*((uint32_t*)file_addr) != 0xFFFFFFFF)
whismanoid 46:469d0061df5d 2698 {
whismanoid 46:469d0061df5d 2699 if (file_addr >= file_addr_end)
whismanoid 46:469d0061df5d 2700 {
whismanoid 46:469d0061df5d 2701 return 1; // fail: no room to write file
whismanoid 46:469d0061df5d 2702 }
whismanoid 46:469d0061df5d 2703 file_addr = file_addr + 4;
whismanoid 46:469d0061df5d 2704 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx ",
whismanoid 46:469d0061df5d 2705 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 2706 file_addr,
whismanoid 46:469d0061df5d 2707 *((uint32_t*)file_addr)
whismanoid 46:469d0061df5d 2708 );
whismanoid 46:469d0061df5d 2709 }
whismanoid 46:469d0061df5d 2710 //
whismanoid 46:469d0061df5d 2711 // copy data from RAM into flash file
whismanoid 46:469d0061df5d 2712 // not_memcpy(file_addr + 4, configuration_back_up_list[i].addr, configuration_back_up_list[i].length_bytes);
whismanoid 46:469d0061df5d 2713 // pageBuf[0..3] = configuration_back_up_list[i].recordType;
whismanoid 46:469d0061df5d 2714 // pageBuf[4...] = configuration_back_up_list[i].addr, configuration_back_up_list[i].length_bytes
whismanoid 46:469d0061df5d 2715 // WIP #312: FLC_Write(...) in Save_flash_page_configuration_back_up
whismanoid 46:469d0061df5d 2716 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: write page buffer ...",
whismanoid 46:469d0061df5d 2717 poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 46:469d0061df5d 2718 // page write using flash.program(page_buffer, addr, page_size);
whismanoid 46:469d0061df5d 2719 // int FLC_Write(uint32_t address, const void *data, uint32_t length, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 2720 // @param address Start address for desired write. @note This address
whismanoid 46:469d0061df5d 2721 // must be 32-bit word aligned
whismanoid 46:469d0061df5d 2722 // @param data A pointer to the buffer containing the data to write.
whismanoid 46:469d0061df5d 2723 // @param length Size of the data to write in bytes. @note The length
whismanoid 46:469d0061df5d 2724 // must be in 32-bit multiples.
whismanoid 46:469d0061df5d 2725 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 2726 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 2727 if (FLC_Write(file_addr,
whismanoid 46:469d0061df5d 2728 (uint32_t*)(&configuration_back_up_list[i].recordType),
whismanoid 46:469d0061df5d 2729 sizeof(uint32_t),
whismanoid 46:469d0061df5d 2730 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 2731 {
whismanoid 46:469d0061df5d 2732 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 2733 break; // can't perform the command
whismanoid 46:469d0061df5d 2734 }
whismanoid 46:469d0061df5d 2735 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 2736 if (FLC_Write(file_addr + 4,
whismanoid 46:469d0061df5d 2737 (uint32_t*)(configuration_back_up_list[i].addr),
whismanoid 46:469d0061df5d 2738 configuration_back_up_list[i].length_bytes,
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 break; // can't perform the command
whismanoid 46:469d0061df5d 2743 }
whismanoid 46:469d0061df5d 2744 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 2745 // advance to next 16-byte-aligned record start address
whismanoid 46:469d0061df5d 2746 file_addr = (file_addr + configuration_back_up_list[i].length_bytes + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 2747 } // end for each configuration_back_up_list[...]
whismanoid 46:469d0061df5d 2748 return 0;
whismanoid 46:469d0061df5d 2749 } // end Save_flash_page_configuration_back_up
whismanoid 46:469d0061df5d 2750 // WIP #312 load values from flash_page_configuration_back_up[] into calibration_05_V[] etc. Default load everything.
whismanoid 46:469d0061df5d 2751 int Load_flash_page_configuration_back_up(CmdLine& cmdLine, uint32_t load_arg)
whismanoid 46:469d0061df5d 2752 {
whismanoid 46:469d0061df5d 2753 cmdLine.serial().printf("\r\nLoad_flash_page_configuration_back_up(0x%8.8lx)...", load_arg);
whismanoid 46:469d0061df5d 2754 // WIP #312 %F load=load_arg could filter which items to accept from flash file
whismanoid 46:469d0061df5d 2755
whismanoid 46:469d0061df5d 2756 uint32_t file_addr = (uint32_t)&flash_page_configuration_back_up[0];
whismanoid 46:469d0061df5d 2757 // uint32_t file_addr_end = file_addr + 8192 - 4; // last record at 0x00027ff0
whismanoid 46:469d0061df5d 2758 // uint32_t file_addr_end = file_addr + 256 - 4; // development: reduce listing size -- last record at 0x000260f0
whismanoid 46:469d0061df5d 2759 uint32_t file_addr_end = file_addr + 512 - 4; // development: reduce listing size -- last record at 0x000261f0
whismanoid 46:469d0061df5d 2760
whismanoid 46:469d0061df5d 2761 // diagnostic print
whismanoid 46:469d0061df5d 2762 int poke_access_list_index = search_poke_access_list(file_addr);
whismanoid 46:469d0061df5d 2763 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 46:469d0061df5d 2764 poke_access_list_index,
whismanoid 46:469d0061df5d 2765 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 2766 poke_access_list[poke_access_list_index].addr_min,
whismanoid 46:469d0061df5d 2767 poke_access_list[poke_access_list_index].addr_max,
whismanoid 46:469d0061df5d 2768 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 46:469d0061df5d 2769 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 46:469d0061df5d 2770
whismanoid 46:469d0061df5d 2771 // Scan backup configuration file
whismanoid 46:469d0061df5d 2772 while (file_addr < file_addr_end)
whismanoid 46:469d0061df5d 2773 {
whismanoid 46:469d0061df5d 2774 // diagnostic print
whismanoid 46:469d0061df5d 2775 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx ",
whismanoid 46:469d0061df5d 2776 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 2777 file_addr,
whismanoid 46:469d0061df5d 2778 *((uint32_t*)file_addr));
whismanoid 46:469d0061df5d 2779
whismanoid 46:469d0061df5d 2780 // address of next 16-byte-aligned record start address
whismanoid 46:469d0061df5d 2781 uint32_t file_addr_next = (file_addr + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 2782
whismanoid 46:469d0061df5d 2783 // scan configuration_back_up_list[] to decode recordType
whismanoid 46:469d0061df5d 2784 for (int i = 0; configuration_back_up_list[i].recordType != 0x00000000; i++)
whismanoid 46:469d0061df5d 2785 {
whismanoid 46:469d0061df5d 2786 // configuration_back_up_list[i].recordType
whismanoid 46:469d0061df5d 2787 // configuration_back_up_list[i].addr
whismanoid 46:469d0061df5d 2788 // configuration_back_up_list[i].length_bytes
whismanoid 46:469d0061df5d 2789 // configuration_back_up_list[i].name
whismanoid 46:469d0061df5d 2790 //
whismanoid 46:469d0061df5d 2791 uint32_t file_addr_recordType = file_addr;
whismanoid 46:469d0061df5d 2792 uint32_t file_addr_recordData = file_addr + 1;
whismanoid 46:469d0061df5d 2793 // uint32_t file_addr_recordNext = (file_addr + configuration_back_up_list[i].length_bytes) & ______;
whismanoid 46:469d0061df5d 2794 if (configuration_back_up_list[i].recordType == *((uint32_t*)file_addr_recordType))
whismanoid 46:469d0061df5d 2795 {
whismanoid 46:469d0061df5d 2796 if ((configuration_back_up_list[i].addr == 0) ||
whismanoid 46:469d0061df5d 2797 (configuration_back_up_list[i].length_bytes==0))
whismanoid 46:469d0061df5d 2798 {
whismanoid 46:469d0061df5d 2799 break; // Ignore blank record, stop searching
whismanoid 46:469d0061df5d 2800 }
whismanoid 46:469d0061df5d 2801 // found a matching recordHeader
whismanoid 46:469d0061df5d 2802 // diagnostic print
whismanoid 46:469d0061df5d 2803 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx load %s",
whismanoid 46:469d0061df5d 2804 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 2805 file_addr,
whismanoid 46:469d0061df5d 2806 *((uint32_t*)file_addr),
whismanoid 46:469d0061df5d 2807 configuration_back_up_list[i].name
whismanoid 46:469d0061df5d 2808 );
whismanoid 46:469d0061df5d 2809 for (int j = 0; j <= configuration_back_up_list[i].length_bytes; j += 4)
whismanoid 46:469d0061df5d 2810 {
whismanoid 46:469d0061df5d 2811 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx",
whismanoid 46:469d0061df5d 2812 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 2813 (file_addr + 4 + j),
whismanoid 46:469d0061df5d 2814 *((uint32_t*)(file_addr + 4 + j))
whismanoid 46:469d0061df5d 2815 );
whismanoid 46:469d0061df5d 2816 }
whismanoid 46:469d0061df5d 2817 // cmdLine.serial().printf("\r\n load %s 0x%8.8lx length 0x%lx address 0x%8.8lx",
whismanoid 46:469d0061df5d 2818 // configuration_back_up_list[i].name,
whismanoid 46:469d0061df5d 2819 // configuration_back_up_list[i].recordType,
whismanoid 46:469d0061df5d 2820 // configuration_back_up_list[i].length_bytes,
whismanoid 46:469d0061df5d 2821 // (uint32_t)configuration_back_up_list[i].addr,
whismanoid 46:469d0061df5d 2822 // );
whismanoid 46:469d0061df5d 2823 // cmdLine.serial().printf("\r\n load %s 0x%8.8lx length 0x%lx address 0x%8.8lx",
whismanoid 46:469d0061df5d 2824 // configuration_back_up_list[i].name,
whismanoid 46:469d0061df5d 2825 // configuration_back_up_list[i].recordType,
whismanoid 46:469d0061df5d 2826 // configuration_back_up_list[i].length_bytes,
whismanoid 46:469d0061df5d 2827 // (uint32_t)configuration_back_up_list[i].addr,
whismanoid 46:469d0061df5d 2828 // );
whismanoid 46:469d0061df5d 2829 //
whismanoid 46:469d0061df5d 2830 // WIP #312: copy data from flash file into RAM in Load_flash_page_configuration_back_up
whismanoid 46:469d0061df5d 2831 memcpy(configuration_back_up_list[i].addr,
whismanoid 46:469d0061df5d 2832 (const void *)(file_addr + 4),
whismanoid 46:469d0061df5d 2833 configuration_back_up_list[i].length_bytes);
whismanoid 46:469d0061df5d 2834 //
whismanoid 46:469d0061df5d 2835 // advance to next 16-byte-aligned record start address
whismanoid 46:469d0061df5d 2836 file_addr_next = (file_addr + configuration_back_up_list[i].length_bytes + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 2837 break; // stop searching
whismanoid 46:469d0061df5d 2838 } // end if match recordType
whismanoid 46:469d0061df5d 2839 } // end for each configuration_back_up_list[...]
whismanoid 46:469d0061df5d 2840 // advance to next 16-byte-aligned record start address
whismanoid 46:469d0061df5d 2841 file_addr = file_addr_next;
whismanoid 46:469d0061df5d 2842 } // end while (file_addr < file_addr_end)
whismanoid 46:469d0061df5d 2843 return 0;
whismanoid 46:469d0061df5d 2844 } // end Load_flash_page_configuration_back_up
whismanoid 46:469d0061df5d 2845 #endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 2846
whismanoid 46:469d0061df5d 2847 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 2848 // Option to validate SPI link by reading PART_ID register
whismanoid 0:cb44e2e9ec4c 2849 #ifndef VERIFY_PART_ID_IN_LOOP
whismanoid 3:9055e17e181a 2850 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 2851 #define VERIFY_PART_ID_IN_LOOP 1
whismanoid 3:9055e17e181a 2852 #else
whismanoid 0:cb44e2e9ec4c 2853 #define VERIFY_PART_ID_IN_LOOP 0
whismanoid 3:9055e17e181a 2854 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2855 #endif
whismanoid 0:cb44e2e9ec4c 2856
whismanoid 3:9055e17e181a 2857 //--------------------------------------------------
whismanoid 3:9055e17e181a 2858 #define NUM_DUT_ANALOG_IN_CHANNELS 10
whismanoid 3:9055e17e181a 2859
whismanoid 3:9055e17e181a 2860 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 2861 // MAX11410 individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 3:9055e17e181a 2862 typedef enum SPI_AIN_Enable_t {
whismanoid 10:04022a61b527 2863 SPI_AIN_Disable = 0,
whismanoid 10:04022a61b527 2864 SPI_AIN_Enable_LSB = 1,
whismanoid 10:04022a61b527 2865 SPI_AIN_Enable_Volt = 2,
whismanoid 3:9055e17e181a 2866 } SPI_AIN_Enable_t;
whismanoid 3:9055e17e181a 2867 uint8_t SPI_AIN_Enable_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 2868 SPI_AIN_Enable_LSB, // AIN0 1=LSB
whismanoid 10:04022a61b527 2869 SPI_AIN_Enable_LSB, // AIN1 1=LSB
whismanoid 10:04022a61b527 2870 SPI_AIN_Enable_LSB, // AIN2 1=LSB
whismanoid 10:04022a61b527 2871 SPI_AIN_Enable_LSB, // AIN3 1=LSB
whismanoid 10:04022a61b527 2872 SPI_AIN_Enable_LSB, // AIN4 1=LSB
whismanoid 10:04022a61b527 2873 SPI_AIN_Enable_LSB, // AIN5 1=LSB
whismanoid 10:04022a61b527 2874 SPI_AIN_Enable_LSB, // AIN6 1=LSB
whismanoid 10:04022a61b527 2875 SPI_AIN_Enable_LSB, // AIN7 1=LSB
whismanoid 10:04022a61b527 2876 SPI_AIN_Enable_LSB, // AIN8 1=LSB
whismanoid 10:04022a61b527 2877 SPI_AIN_Enable_LSB, // AIN9 1=LSB
whismanoid 3:9055e17e181a 2878 };
whismanoid 3:9055e17e181a 2879 //
whismanoid 10:04022a61b527 2880 double SPI_AIN_Voltage[NUM_DUT_ANALOG_IN_CHANNELS];
whismanoid 13:184a08909405 2881 // Optional custom per-channel header suffix
whismanoid 45:74bf1fe021e5 2882 // This could be used to identify external hardware attached to each input
whismanoid 13:184a08909405 2883 #ifndef HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 2884 #define HAS_SPI_AIN_customChannelHeader 0
whismanoid 13:184a08909405 2885 #endif
whismanoid 13:184a08909405 2886 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2887 const char* const SPI_AIN_customChannelHeader_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 2888 "", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 2889 "", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 2890 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 2891 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 2892 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 2893 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 2894 };
whismanoid 13:184a08909405 2895 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 3:9055e17e181a 2896 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2897 // ---------- Measure_Voltage_custom_props in Measure_Voltage @pre and in class properties ----------
whismanoid 3:9055e17e181a 2898 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 2899 // MAX11410 specific per-channel config register v_filter
whismanoid 3:9055e17e181a 2900 uint8_t SPI_AIN_Cfg_v_filter_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2901 0x34, // AIN0 @ v_filter=0x34
whismanoid 3:9055e17e181a 2902 0x34, // AIN1 @ v_filter=0x34
whismanoid 3:9055e17e181a 2903 0x34, // AIN2 @ v_filter=0x34
whismanoid 3:9055e17e181a 2904 0x34, // AIN3 @ v_filter=0x34
whismanoid 3:9055e17e181a 2905 0x34, // AIN4 @ v_filter=0x34
whismanoid 3:9055e17e181a 2906 0x34, // AIN5 @ v_filter=0x34
whismanoid 3:9055e17e181a 2907 0x34, // AIN6 @ v_filter=0x34
whismanoid 3:9055e17e181a 2908 0x34, // AIN7 @ v_filter=0x34
whismanoid 3:9055e17e181a 2909 0x34, // AIN8 @ v_filter=0x34
whismanoid 3:9055e17e181a 2910 0x34, // AIN9 @ v_filter=0x34
whismanoid 3:9055e17e181a 2911 };
whismanoid 3:9055e17e181a 2912 //
whismanoid 4:d9b05924ad4c 2913 // MAX11410 specific per-channel config register v_ctrl
whismanoid 3:9055e17e181a 2914 uint8_t SPI_AIN_Cfg_v_ctrl_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2915 0x42, // AIN0 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2916 0x42, // AIN1 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2917 0x42, // AIN2 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2918 0x42, // AIN3 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2919 0x42, // AIN4 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2920 0x42, // AIN5 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2921 0x42, // AIN6 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2922 0x42, // AIN7 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2923 0x42, // AIN8 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2924 0x42, // AIN9 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2925 };
whismanoid 3:9055e17e181a 2926 //
whismanoid 4:d9b05924ad4c 2927 // MAX11410 specific per-channel config register v_pga
whismanoid 3:9055e17e181a 2928 uint8_t SPI_AIN_Cfg_v_pga_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2929 0x00, // AIN0 @ v_pga=0x00
whismanoid 3:9055e17e181a 2930 0x00, // AIN1 @ v_pga=0x00
whismanoid 3:9055e17e181a 2931 0x00, // AIN2 @ v_pga=0x00
whismanoid 3:9055e17e181a 2932 0x00, // AIN3 @ v_pga=0x00
whismanoid 3:9055e17e181a 2933 0x00, // AIN4 @ v_pga=0x00
whismanoid 3:9055e17e181a 2934 0x00, // AIN5 @ v_pga=0x00
whismanoid 3:9055e17e181a 2935 0x00, // AIN6 @ v_pga=0x00
whismanoid 3:9055e17e181a 2936 0x00, // AIN7 @ v_pga=0x00
whismanoid 3:9055e17e181a 2937 0x00, // AIN8 @ v_pga=0x00
whismanoid 3:9055e17e181a 2938 0x00, // AIN9 @ v_pga=0x00
whismanoid 3:9055e17e181a 2939 };
whismanoid 3:9055e17e181a 2940 //
whismanoid 3:9055e17e181a 2941 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2942 // ---------- Measure_Voltage_custom_props ----------
whismanoid 0:cb44e2e9ec4c 2943 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2944 // filter register configuration in Measure_Voltage and Read_All_Voltages CONV_TYPE_01_Continuous
whismanoid 0:cb44e2e9ec4c 2945 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 2946 //~ const uint8_t custom_v_filter = 0x00; // @ v_filter=0x00 -- LINEF_00_50Hz_60Hz_FIR RATE_0000 | 1.1SPS
whismanoid 0:cb44e2e9ec4c 2947 //~ const uint8_t custom_v_filter = 0x01; // @ v_filter=0x01 -- LINEF_00_50Hz_60Hz_FIR RATE_0001 | 2.1SPS
whismanoid 0:cb44e2e9ec4c 2948 //~ const uint8_t custom_v_filter = 0x02; // @ v_filter=0x02 -- LINEF_00_50Hz_60Hz_FIR RATE_0010 | 4.2SPS
whismanoid 0:cb44e2e9ec4c 2949 //~ const uint8_t custom_v_filter = 0x03; // @ v_filter=0x03 -- LINEF_00_50Hz_60Hz_FIR RATE_0011 | 8.4SPS
whismanoid 0:cb44e2e9ec4c 2950 //~ const uint8_t custom_v_filter = 0x04; // @ v_filter=0x04 -- LINEF_00_50Hz_60Hz_FIR RATE_0100 | 16.8SPS
whismanoid 0:cb44e2e9ec4c 2951 //~ const uint8_t custom_v_filter = 0x10; // @ v_filter=0x10 -- LINEF_01_50Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 2952 //~ const uint8_t custom_v_filter = 0x11; // @ v_filter=0x11 -- LINEF_01_50Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 2953 //~ const uint8_t custom_v_filter = 0x12; // @ v_filter=0x12 -- LINEF_01_50Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 2954 //~ const uint8_t custom_v_filter = 0x13; // @ v_filter=0x13 -- LINEF_01_50Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 2955 //~ const uint8_t custom_v_filter = 0x14; // @ v_filter=0x14 -- LINEF_01_50Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 2956 //~ const uint8_t custom_v_filter = 0x15; // @ v_filter=0x15 -- LINEF_01_50Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 2957 //~ const uint8_t custom_v_filter = 0x20; // @ v_filter=0x20 -- LINEF_10_60Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 2958 //~ const uint8_t custom_v_filter = 0x21; // @ v_filter=0x21 -- LINEF_10_60Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 2959 //~ const uint8_t custom_v_filter = 0x22; // @ v_filter=0x22 -- LINEF_10_60Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 2960 //~ const uint8_t custom_v_filter = 0x23; // @ v_filter=0x23 -- LINEF_10_60Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 2961 //~ const uint8_t custom_v_filter = 0x24; // @ v_filter=0x24 -- LINEF_10_60Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 2962 //~ const uint8_t custom_v_filter = 0x25; // @ v_filter=0x25 -- LINEF_10_60Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 2963 //~ const uint8_t custom_v_filter = 0x30; // @ v_filter=0x30 -- LINEF_11_SINC4 RATE_0000 | 4SPS
whismanoid 0:cb44e2e9ec4c 2964 //~ const uint8_t custom_v_filter = 0x31; // @ v_filter=0x31 -- LINEF_11_SINC4 RATE_0001 | 10SPS
whismanoid 0:cb44e2e9ec4c 2965 //~ const uint8_t custom_v_filter = 0x32; // @ v_filter=0x32 -- LINEF_11_SINC4 RATE_0010 | 20SPS
whismanoid 0:cb44e2e9ec4c 2966 //~ const uint8_t custom_v_filter = 0x33; // @ v_filter=0x33 -- LINEF_11_SINC4 RATE_0011 | 40SPS
whismanoid 0:cb44e2e9ec4c 2967 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 2968 //~ const uint8_t custom_v_filter = 0x35; // @ v_filter=0x35 -- LINEF_11_SINC4 RATE_0101 | 120SPS
whismanoid 0:cb44e2e9ec4c 2969 //~ const uint8_t custom_v_filter = 0x36; // @ v_filter=0x36 -- LINEF_11_SINC4 RATE_0110 | 240SPS
whismanoid 0:cb44e2e9ec4c 2970 //~ const uint8_t custom_v_filter = 0x37; // @ v_filter=0x37 -- LINEF_11_SINC4 RATE_0111 | 480SPS
whismanoid 0:cb44e2e9ec4c 2971 //~ const uint8_t custom_v_filter = 0x38; // @ v_filter=0x38 -- LINEF_11_SINC4 RATE_1000 | 960SPS
whismanoid 0:cb44e2e9ec4c 2972 //~ const uint8_t custom_v_filter = 0x39; // @ v_filter=0x39 -- LINEF_11_SINC4 RATE_1001 | 1920SPS
whismanoid 0:cb44e2e9ec4c 2973 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2974 //
whismanoid 0:cb44e2e9ec4c 2975 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2976 // pga register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 0:cb44e2e9ec4c 2977 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 2978 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 2979 //~ const uint8_t custom_v_pga = 0x10; // @ v_pga=0x10 -- 0x10 SIG_PATH_01_BYPASS
whismanoid 0:cb44e2e9ec4c 2980 //~ const uint8_t custom_v_pga = 0x20; // @ v_pga=0x20 -- 0x20 SIG_PATH_10_PGA GAIN_000_1
whismanoid 0:cb44e2e9ec4c 2981 //~ const uint8_t custom_v_pga = 0x21; // @ v_pga=0x21 --*0x21 SIG_PATH_10_PGA GAIN_001_2
whismanoid 0:cb44e2e9ec4c 2982 //~ const uint8_t custom_v_pga = 0x22; // @ v_pga=0x22 -- 0x22 SIG_PATH_10_PGA GAIN_010_4
whismanoid 0:cb44e2e9ec4c 2983 //~ const uint8_t custom_v_pga = 0x23; // @ v_pga=0x23 -- 0x23 SIG_PATH_10_PGA GAIN_011_8
whismanoid 0:cb44e2e9ec4c 2984 //~ const uint8_t custom_v_pga = 0x24; // @ v_pga=0x24 -- 0x24 SIG_PATH_10_PGA GAIN_100_16
whismanoid 0:cb44e2e9ec4c 2985 //~ const uint8_t custom_v_pga = 0x25; // @ v_pga=0x25 -- 0x25 SIG_PATH_10_PGA GAIN_101_32
whismanoid 0:cb44e2e9ec4c 2986 //~ const uint8_t custom_v_pga = 0x26; // @ v_pga=0x26 -- 0x26 SIG_PATH_10_PGA GAIN_110_64
whismanoid 0:cb44e2e9ec4c 2987 //~ const uint8_t custom_v_pga = 0x27; // @ v_pga=0x27 -- 0x27 SIG_PATH_10_PGA GAIN_111_128
whismanoid 0:cb44e2e9ec4c 2988 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2989 //
whismanoid 0:cb44e2e9ec4c 2990 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2991 // ctrl register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 3:9055e17e181a 2992 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2993 //~ const uint8_t custom_v_ctrl = 0x40; // @ v_ctrl=0x40 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1
whismanoid 0:cb44e2e9ec4c 2994 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 2995 //~ const uint8_t custom_v_ctrl = 0x58; // @ v_ctrl=0x58 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 2996 //
whismanoid 0:cb44e2e9ec4c 2997 //~ const uint8_t custom_v_ctrl = 0x41; // @ v_ctrl=0x41 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N
whismanoid 0:cb44e2e9ec4c 2998 //~ const uint8_t custom_v_ctrl = 0x45; // @ v_ctrl=0x45 -- 0x40 unipolar, 0x05 REF_SEL_101_REF1P_AGND
whismanoid 0:cb44e2e9ec4c 2999 //~ const uint8_t custom_v_ctrl = 0x59; // @ v_ctrl=0x59 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 3000 //
whismanoid 0:cb44e2e9ec4c 3001 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 3002 //~ const uint8_t custom_v_ctrl = 0x46; // @ v_ctrl=0x46 -- 0x40 unipolar, 0x06 REF_SEL_110_REF2P_AGND
whismanoid 0:cb44e2e9ec4c 3003 //~ const uint8_t custom_v_ctrl = 0x22; // @ v_ctrl=0x22 -- 0x20 bipolar offset binary, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 3004 //~ const uint8_t custom_v_ctrl = 0x02; // @ v_ctrl=0x02 -- 0x00 bipolar 2's complement, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 3005 //
whismanoid 0:cb44e2e9ec4c 3006 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 3007 //~ const uint8_t custom_v_ctrl = 0x47; // @ v_ctrl=0x47 -- 0x40 unipolar, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 3008 //~ const uint8_t custom_v_ctrl = 0x27; // @ v_ctrl=0x27 -- 0x20 bipolar offset binary, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 3009 //~ const uint8_t custom_v_ctrl = 0x07; // @ v_ctrl=0x07 -- 0x00 bipolar 2's complement, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 3010 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 3011
whismanoid 3:9055e17e181a 3012 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3013 // example code declare SPI interface (GPIO controlled CS)
whismanoid 0:cb44e2e9ec4c 3014 #if defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 3015 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 3016 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
whismanoid 19:5ff09c8e9daf 3017 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 3018 #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 3019 SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625PICO: pin P0_5 P0_6 P0_4
whismanoid 0:cb44e2e9ec4c 3020 DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32625PICO: pin P0_7
whismanoid 0:cb44e2e9ec4c 3021 #elif defined(TARGET_MAX32600MBED)
whismanoid 0:cb44e2e9ec4c 3022 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 0:cb44e2e9ec4c 3023 DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 3024 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 3025 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 3026 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:cb44e2e9ec4c 3027 //
whismanoid 0:cb44e2e9ec4c 3028 // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses.
whismanoid 0:cb44e2e9ec4c 3029 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 3030 DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 3031 //
whismanoid 0:cb44e2e9ec4c 3032 #else
whismanoid 3:9055e17e181a 3033 SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 3:9055e17e181a 3034 DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 3035 #endif
whismanoid 0:cb44e2e9ec4c 3036
whismanoid 0:cb44e2e9ec4c 3037 // example code declare GPIO interface pins
whismanoid 0:cb44e2e9ec4c 3038 // example code declare device instance
whismanoid 3:9055e17e181a 3039 MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC);
whismanoid 3:9055e17e181a 3040 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3041
whismanoid 1:747f1602abfc 3042 //--------------------------------------------------
whismanoid 3:9055e17e181a 3043 // Option to Datalog Arduino platform analog inputs
whismanoid 3:9055e17e181a 3044 #ifndef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 3045 #define LOG_PLATFORM_AIN 6
whismanoid 3:9055e17e181a 3046 //~ #undef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 3047 #endif
whismanoid 3:9055e17e181a 3048 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 1:747f1602abfc 3049 //#ifndef NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 1:747f1602abfc 3050 //#define NUM_PLATFORM_ANALOG_IN_CHANNELS 6
whismanoid 1:747f1602abfc 3051 //#endif
whismanoid 1:747f1602abfc 3052 const int NUM_PLATFORM_ANALOG_IN_CHANNELS = 6;
whismanoid 1:747f1602abfc 3053 const double adc_full_scale_voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 3054 analogInPin_fullScaleVoltage[0], // 1.2,
whismanoid 10:04022a61b527 3055 analogInPin_fullScaleVoltage[1], // 1.2,
whismanoid 10:04022a61b527 3056 analogInPin_fullScaleVoltage[2], // 1.2,
whismanoid 10:04022a61b527 3057 analogInPin_fullScaleVoltage[3], // 1.2,
whismanoid 10:04022a61b527 3058 analogInPin_fullScaleVoltage[4], // 6.0
whismanoid 10:04022a61b527 3059 analogInPin_fullScaleVoltage[5], // 6.0
whismanoid 0:cb44e2e9ec4c 3060 };
whismanoid 9:45f98573eb6d 3061 // Platform ADC individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 9:45f98573eb6d 3062 typedef enum Platform_AIN_Enable_t {
whismanoid 9:45f98573eb6d 3063 Platform_AIN_Disable = 0,
whismanoid 9:45f98573eb6d 3064 Platform_AIN_Enable_LSB = 1,
whismanoid 9:45f98573eb6d 3065 Platform_AIN_Enable_Volt = 2,
whismanoid 9:45f98573eb6d 3066 } Platform_AIN_Enable_t;
whismanoid 13:184a08909405 3067 uint8_t Platform_Enable_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 9:45f98573eb6d 3068 Platform_AIN_Enable_Volt, // AIN0 2=Volt
whismanoid 9:45f98573eb6d 3069 Platform_AIN_Enable_Volt, // AIN1 2=Volt
whismanoid 9:45f98573eb6d 3070 Platform_AIN_Enable_Volt, // AIN2 2=Volt
whismanoid 9:45f98573eb6d 3071 Platform_AIN_Enable_Volt, // AIN3 2=Volt
whismanoid 9:45f98573eb6d 3072 Platform_AIN_Enable_Volt, // AIN4 2=Volt
whismanoid 9:45f98573eb6d 3073 Platform_AIN_Enable_Volt, // AIN5 2=Volt
whismanoid 9:45f98573eb6d 3074 };
whismanoid 37:3f369235e5bc 3075 // Option to report average value of Arduino platform analog inputs
whismanoid 37:3f369235e5bc 3076 #ifndef USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3077 #define USE_Platform_AIN_Average 1
whismanoid 37:3f369235e5bc 3078 //~ #undef USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3079 #endif
whismanoid 37:3f369235e5bc 3080 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3081 #endif // USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3082 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3083 int Platform_AIN_Average_N = 16;
whismanoid 37:3f369235e5bc 3084 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 3085 // Option to apply calibration to Arduino platform analog inputs
whismanoid 34:a1993a1ee904 3086 #ifndef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3087 #define HAS_Platform_AIN_Calibration 1
whismanoid 34:a1993a1ee904 3088 //~ #undef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3089 #endif
whismanoid 34:a1993a1ee904 3090 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3091 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 3092 // Calibration is between two points for each channel, defined by
whismanoid 34:a1993a1ee904 3093 // a normalized value between 0% and 100%, and the corresponding voltage.
whismanoid 34:a1993a1ee904 3094 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 3095 // calibration_05_normValue_0_1, calibration_05_V should be around 5% or 25%
whismanoid 42:89607d5d4e6d 3096 extern double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 42:89607d5d4e6d 3097 extern double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 34:a1993a1ee904 3098 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 3099 // calibration_95_normValue_0_1, calibration_95_V should be around 95% or 75%
whismanoid 42:89607d5d4e6d 3100 extern double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 42:89607d5d4e6d 3101 extern double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 34:a1993a1ee904 3102 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3103 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3104 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1)
whismanoid 34:a1993a1ee904 3105 {
whismanoid 34:a1993a1ee904 3106 // TODO: return corrected normValue_0_1 using two-point linear calibration
whismanoid 34:a1993a1ee904 3107 // point 1: calibration_05_normValue_0_1[ch], calibration_05_V[ch]
whismanoid 34:a1993a1ee904 3108 // point 2: calibration_95_normValue_0_1[ch], calibration_95_V[ch]
whismanoid 34:a1993a1ee904 3109 // validate that there is enough span to get sensible results
whismanoid 34:a1993a1ee904 3110 //
whismanoid 34:a1993a1ee904 3111 int ch = channel_0_5;
whismanoid 34:a1993a1ee904 3112 // 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 3113 // ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 3114 // ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 3115 // ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 3116 // ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 3117 // );
whismanoid 34:a1993a1ee904 3118 // cmdLine.serial().printf("\r\n adc_full_scale_voltage[%d] = %1.6fV",
whismanoid 34:a1993a1ee904 3119 // ch,
whismanoid 34:a1993a1ee904 3120 // adc_full_scale_voltage[ch]
whismanoid 34:a1993a1ee904 3121 // );
whismanoid 34:a1993a1ee904 3122 // raw normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 3123 double raw_05_normValue = calibration_05_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 3124 double raw_95_normValue = calibration_95_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 3125 // calibrated normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 3126 // divide V/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 3127 double cal_05_normValue = calibration_05_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 3128 double cal_95_normValue = calibration_95_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 3129 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_05_normValue = %1.6f",
whismanoid 34:a1993a1ee904 3130 // ch,
whismanoid 34:a1993a1ee904 3131 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3132 // cal_05_normValue
whismanoid 34:a1993a1ee904 3133 // );
whismanoid 34:a1993a1ee904 3134 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_95_normValue = %1.6f",
whismanoid 34:a1993a1ee904 3135 // ch,
whismanoid 34:a1993a1ee904 3136 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3137 // cal_95_normValue
whismanoid 34:a1993a1ee904 3138 // );
whismanoid 34:a1993a1ee904 3139 //
whismanoid 34:a1993a1ee904 3140 double span_raw = raw_95_normValue - raw_05_normValue;
whismanoid 34:a1993a1ee904 3141 double span_cal = cal_95_normValue - cal_05_normValue;
whismanoid 34:a1993a1ee904 3142 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_raw = %1.6f",
whismanoid 34:a1993a1ee904 3143 // ch,
whismanoid 34:a1993a1ee904 3144 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3145 // span_raw
whismanoid 34:a1993a1ee904 3146 // );
whismanoid 34:a1993a1ee904 3147 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_cal = %1.6f",
whismanoid 34:a1993a1ee904 3148 // ch,
whismanoid 34:a1993a1ee904 3149 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3150 // span_cal
whismanoid 34:a1993a1ee904 3151 // );
whismanoid 34:a1993a1ee904 3152 // if calibration is not valid, return unmodified normValue_0_1 and print a warning
whismanoid 34:a1993a1ee904 3153 if (span_raw < 0.001) {
whismanoid 34:a1993a1ee904 3154 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_raw = %1.6f",
whismanoid 34:a1993a1ee904 3155 ch,
whismanoid 34:a1993a1ee904 3156 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3157 span_raw
whismanoid 34:a1993a1ee904 3158 );
whismanoid 34:a1993a1ee904 3159 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 3160 }
whismanoid 34:a1993a1ee904 3161 if (span_cal < 0.001) {
whismanoid 34:a1993a1ee904 3162 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_cal = %1.6f",
whismanoid 34:a1993a1ee904 3163 ch,
whismanoid 34:a1993a1ee904 3164 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3165 span_cal
whismanoid 34:a1993a1ee904 3166 );
whismanoid 34:a1993a1ee904 3167 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 3168 }
whismanoid 34:a1993a1ee904 3169 double slope_correction = span_cal / span_raw;
whismanoid 34:a1993a1ee904 3170 double corrected_normValue_0_1 = cal_05_normValue + ((raw_normValue_0_1 - raw_05_normValue) * slope_correction);
whismanoid 34:a1993a1ee904 3171 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) slope_correction = %1.6f",
whismanoid 34:a1993a1ee904 3172 // ch,
whismanoid 34:a1993a1ee904 3173 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3174 // slope_correction
whismanoid 34:a1993a1ee904 3175 // );
whismanoid 34:a1993a1ee904 3176 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) corrected_normValue_0_1 = %1.6f\r\n",
whismanoid 34:a1993a1ee904 3177 // ch,
whismanoid 34:a1993a1ee904 3178 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3179 // corrected_normValue_0_1
whismanoid 34:a1993a1ee904 3180 // );
whismanoid 34:a1993a1ee904 3181 return corrected_normValue_0_1;
whismanoid 34:a1993a1ee904 3182 }
whismanoid 34:a1993a1ee904 3183 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3184 // Option to customize channel names in datalog header line
whismanoid 45:74bf1fe021e5 3185 // This could be used to identify external hardware attached to each input
whismanoid 13:184a08909405 3186 #ifndef HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 3187 #define HAS_Platform_AIN_customChannelHeader 1
whismanoid 13:184a08909405 3188 #endif
whismanoid 13:184a08909405 3189 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 3190 const char* const Platform_AIN_customChannelHeader_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 3191 "=AIN4", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 3192 "=AIN5", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 3193 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 3194 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 3195 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 3196 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 3197 };
whismanoid 13:184a08909405 3198 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 1:747f1602abfc 3199 //--------------------------------------------------
whismanoid 1:747f1602abfc 3200 // Option to log platform analog inputs as raw LSB code
whismanoid 1:747f1602abfc 3201 #ifndef LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 3202 #define LOG_PLATFORM_ANALOG_IN_LSB 0
whismanoid 1:747f1602abfc 3203 #endif
whismanoid 1:747f1602abfc 3204 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 3205 int Platform_LSB[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 3206 #endif
whismanoid 1:747f1602abfc 3207
whismanoid 1:747f1602abfc 3208 //--------------------------------------------------
whismanoid 1:747f1602abfc 3209 // Option to use platform analog inputs as Voltage
whismanoid 1:747f1602abfc 3210 #ifndef LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 3211 #define LOG_PLATFORM_ANALOG_IN_VOLTS 1
whismanoid 1:747f1602abfc 3212 #endif
whismanoid 1:747f1602abfc 3213 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 3214 double Platform_Voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 3215 #endif
whismanoid 3:9055e17e181a 3216 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 0:cb44e2e9ec4c 3217
whismanoid 10:04022a61b527 3218 //--------------------------------------------------
whismanoid 10:04022a61b527 3219 // Option to use Command forwarding to Auxiliary serial port
whismanoid 10:04022a61b527 3220 // Command forwarding to Auxiliary serial port TX/RX
whismanoid 10:04022a61b527 3221 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial
whismanoid 10:04022a61b527 3222 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial
whismanoid 10:04022a61b527 3223 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3224 #ifndef USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3225 #define USE_AUX_SERIAL_CMD_FORWARDING 1
whismanoid 10:04022a61b527 3226 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3227 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3228 // Command forwarding to Auxiliary serial port TX/RX #257 -- global parameters
whismanoid 10:04022a61b527 3229 const size_t RX_STRING_BUF_SIZE = 1000;
whismanoid 10:04022a61b527 3230 int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 3231 // transmit command string by AUX TX
whismanoid 10:04022a61b527 3232 #if 0
whismanoid 10:04022a61b527 3233 int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 3234 int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 3235 int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 3236 #endif
whismanoid 10:04022a61b527 3237 // capture received string from AUX RX
whismanoid 10:04022a61b527 3238 Timer g_auxSerialCom_Timer;
whismanoid 10:04022a61b527 3239 int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 3240 int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 3241 int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 3242 int g_auxSerialCom_rx_idle_ms = 500; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 3243 int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 3244 const int aux_serial_cmd_forwarding_rx_eot_not_used = 'x';
whismanoid 10:04022a61b527 3245 int g_auxSerialCom_rx_eot = aux_serial_cmd_forwarding_rx_eot_not_used; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 3246 //~ int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text string?
whismanoid 10:04022a61b527 3247 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3248 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3249 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257
whismanoid 10:04022a61b527 3250 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3251 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3252 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3253 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3254 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3255 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3256 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 3257 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3258 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3259 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3260 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3261 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3262 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3263 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3264 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3265
whismanoid 8:dffee7509bfb 3266 // CODE GENERATOR: example code for ADC: serial port declaration
whismanoid 8:dffee7509bfb 3267 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3268 // Declare the Serial driver
whismanoid 8:dffee7509bfb 3269 // default baud rate settings are 9600 8N1
whismanoid 8:dffee7509bfb 3270 // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
whismanoid 8:dffee7509bfb 3271 // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
whismanoid 8:dffee7509bfb 3272 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3273 #if defined(TARGET_MAX32630)
whismanoid 8:dffee7509bfb 3274 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 3275 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3276 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3277 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 3278 //
whismanoid 8:dffee7509bfb 3279 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3280 Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3281 //Serial J3AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 3282 //Serial BTAUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 3283 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3284 //
whismanoid 8:dffee7509bfb 3285 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3286 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3287 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3288 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3289 //
whismanoid 8:dffee7509bfb 3290 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3291 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3292 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3293 USBSerial serial;
whismanoid 8:dffee7509bfb 3294 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3295 #elif defined(TARGET_MAX32625MBED)
whismanoid 8:dffee7509bfb 3296 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625MBED: P0_1,P0_0 (Arduino D1,D0)
whismanoid 8:dffee7509bfb 3297 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3298 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625MBED: P3_1,P3_0 (J15-LEDgreen,LEDred)
whismanoid 8:dffee7509bfb 3299 //
whismanoid 8:dffee7509bfb 3300 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3301 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3302 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3303 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3304 //
whismanoid 8:dffee7509bfb 3305 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3306 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3307 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3308 USBSerial serial;
whismanoid 8:dffee7509bfb 3309 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 3310 #elif defined(TARGET_MAX32625PICO)
whismanoid 8:dffee7509bfb 3311 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 3312 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625PICO: P2_1,P2_0 (underside?)
whismanoid 8:dffee7509bfb 3313 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3314 //
whismanoid 8:dffee7509bfb 3315 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3316 Serial AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 3317 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3318 //
whismanoid 8:dffee7509bfb 3319 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3320 Serial DAPLINKserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3321 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3322 //
whismanoid 8:dffee7509bfb 3323 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3324 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3325 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3326 USBSerial serial;
whismanoid 22:d6dc8a85f435 3327 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 3328 #elif defined(TARGET_MAX40108DEMOP2U9)
whismanoid 22:d6dc8a85f435 3329 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 3330 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK)
whismanoid 22:d6dc8a85f435 3331 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 3332 //
whismanoid 22:d6dc8a85f435 3333 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial is used as main serial port in MAX40108 Demo board
whismanoid 22:d6dc8a85f435 3334 Serial serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 3335 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 3336 //
whismanoid 22:d6dc8a85f435 3337 // Hardware serial port over DAPLink
whismanoid 22:d6dc8a85f435 3338 // connection to external MAX32625PICO(DAPLINK) needed TX/RX swap in firmware.
whismanoid 22:d6dc8a85f435 3339 // MAX32625PICO(DAPLINK) drives DAPLINK.8, listens on DAPLINK.6.
whismanoid 22:d6dc8a85f435 3340 // See AN6350 MAX32625 Users Guide 7.5.2.3.1 TX and RX Pin Mapping for UART 1 -- Mapping Option B
whismanoid 39:4d285e961435 3341 #ifdef BOARD_SERIAL_NUMBER
whismanoid 39:4d285e961435 3342 // data unique to certain boards based on serial number
whismanoid 39:4d285e961435 3343 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 39:4d285e961435 3344 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 39:4d285e961435 3345 // s/n 0 is not really a MAX40108 board, it's actually a MAX32625PICO used for early development. So no swap.
whismanoid 39:4d285e961435 3346 Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 39:4d285e961435 3347 //Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 39:4d285e961435 3348 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3349 //
whismanoid 39:4d285e961435 3350 // # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 39:4d285e961435 3351 // #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 39:4d285e961435 3352 // //
whismanoid 39:4d285e961435 3353 // # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 39:4d285e961435 3354 // #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 39:4d285e961435 3355 // //
whismanoid 39:4d285e961435 3356 // # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 39:4d285e961435 3357 // #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 39:4d285e961435 3358 // //
whismanoid 39:4d285e961435 3359 // # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 39:4d285e961435 3360 // #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 39:4d285e961435 3361 // //
whismanoid 39:4d285e961435 3362 // # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 39:4d285e961435 3363 // #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 39:4d285e961435 3364 // //
whismanoid 39:4d285e961435 3365 // # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 39:4d285e961435 3366 // #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 39:4d285e961435 3367 // //
whismanoid 39:4d285e961435 3368 # else
whismanoid 39:4d285e961435 3369 // #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 22:d6dc8a85f435 3370 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 22:d6dc8a85f435 3371 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 22:d6dc8a85f435 3372 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3373 # endif
whismanoid 39:4d285e961435 3374 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 39:4d285e961435 3375 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 39:4d285e961435 3376 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 39:4d285e961435 3377 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 39:4d285e961435 3378 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3379 //
whismanoid 39:4d285e961435 3380 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 22:d6dc8a85f435 3381 //
whismanoid 22:d6dc8a85f435 3382 // Serial AUXserial(UART1_TX,UART1_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 3383 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 3384 //
whismanoid 22:d6dc8a85f435 3385 // Virtual serial port over USB
whismanoid 22:d6dc8a85f435 3386 // #include "USBSerial.h"
whismanoid 22:d6dc8a85f435 3387 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 22:d6dc8a85f435 3388 //USBSerial serial;
whismanoid 8:dffee7509bfb 3389 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3390 #elif defined(TARGET_MAX32620FTHR)
whismanoid 8:dffee7509bfb 3391 #warning "TARGET_MAX32620FTHR not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3392 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3393 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32620FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3394 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3395 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3396 //
whismanoid 8:dffee7509bfb 3397 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3398 Serial serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3399 //Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3400 Serial AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3401 //Serial PMOD0AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3402 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3403 //
whismanoid 8:dffee7509bfb 3404 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3405 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3406 Serial DAPLINKserial(USBTX, USBRX); // tx,rx MAX32620FTHR: P2_1,P2_0
whismanoid 8:dffee7509bfb 3407 //Serial DAPLINKserial(STDIO_UART_TX, STDIO_UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3408 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3409 //
whismanoid 8:dffee7509bfb 3410 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3411 // #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3412 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3413 //USBSerial serial; // MAX32620FTHR: USBSerial crash??
whismanoid 8:dffee7509bfb 3414 #warning "TARGET_MAX32620FTHR not previously tested; USBSerial crash?"
whismanoid 8:dffee7509bfb 3415 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3416 #elif defined(TARGET_MAX32600)
whismanoid 8:dffee7509bfb 3417 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3418 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART2 MAX32625MBED: P1_3,P1_2 (Arduino D3,D2)
whismanoid 8:dffee7509bfb 3419 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART1 MAX32625MBED: P7_3,P7_2 ( ?? )
whismanoid 8:dffee7509bfb 3420 //
whismanoid 8:dffee7509bfb 3421 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3422 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3423 Serial DAPLINKserial(P1_1,P1_0); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3424 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3425 //
whismanoid 8:dffee7509bfb 3426 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3427 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3428 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3429 USBSerial serial;
whismanoid 8:dffee7509bfb 3430 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3431 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 8:dffee7509bfb 3432 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3433 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3434 #else
whismanoid 8:dffee7509bfb 3435 #if defined(SERIAL_TX)
whismanoid 8:dffee7509bfb 3436 #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..."
whismanoid 8:dffee7509bfb 3437 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3438 #elif defined(USBTX)
whismanoid 8:dffee7509bfb 3439 #warning "target not previously tested; guess serial pins are USBTX, USBRX..."
whismanoid 8:dffee7509bfb 3440 Serial serial(USBTX, USBRX); // tx, rx
whismanoid 8:dffee7509bfb 3441 #elif defined(UART_TX)
whismanoid 8:dffee7509bfb 3442 #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..."
whismanoid 8:dffee7509bfb 3443 Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3444 #else
whismanoid 8:dffee7509bfb 3445 #warning "target not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3446 #endif
whismanoid 8:dffee7509bfb 3447 #endif
whismanoid 8:dffee7509bfb 3448 //
whismanoid 8:dffee7509bfb 3449 #include "CmdLine.h"
whismanoid 8:dffee7509bfb 3450
whismanoid 8:dffee7509bfb 3451 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3452 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3453 CmdLine cmdLine_AUXserial(AUXserial, "AUXserial");
whismanoid 10:04022a61b527 3454 uint8_t Datalogger_enable_AUXserial = {
whismanoid 10:04022a61b527 3455 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3456 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 3457 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 3458 false
whismanoid 10:04022a61b527 3459 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3460 true
whismanoid 10:04022a61b527 3461 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3462 };
whismanoid 8:dffee7509bfb 3463 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3464 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3465 CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK");
whismanoid 8:dffee7509bfb 3466 uint8_t Datalogger_enable_DAPLINKserial = true;
whismanoid 8:dffee7509bfb 3467 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3468 CmdLine cmdLine(serial, "serial");
whismanoid 8:dffee7509bfb 3469 uint8_t Datalogger_enable_serial = true;
whismanoid 8:dffee7509bfb 3470 // CODE GENERATOR: example code for ADC: serial port declaration (end)
whismanoid 8:dffee7509bfb 3471
whismanoid 21:ac062a97a71d 3472
whismanoid 21:ac062a97a71d 3473 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3474 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3475 // support for commands %B1! .. %B9!
whismanoid 23:c6c652bef4b9 3476 #ifndef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3477 #define USE_DATALOGGER_CommandTable 1
whismanoid 23:c6c652bef4b9 3478 //~ #undef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3479 #endif
whismanoid 23:c6c652bef4b9 3480 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3481 const int COMMAND_TABLE_ROW_MAX = 10;
whismanoid 23:c6c652bef4b9 3482 const int COMMAND_TABLE_COL_MAX = 40;
whismanoid 23:c6c652bef4b9 3483 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3484 //
whismanoid 23:c6c652bef4b9 3485 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3486 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3487 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3488 // onButton1_command_table[] supports command %B1! -- run, %B1@ -- edit
whismanoid 45:74bf1fe021e5 3489 // MAX40108p2 hardware pin P2_7 button SW1 active low
whismanoid 45:74bf1fe021e5 3490 //........................................................12345678901234567890
whismanoid 45:74bf1fe021e5 3491 char onButton1_command_table_00[COMMAND_TABLE_COL_MAX] = "# SW1 event";
whismanoid 45:74bf1fe021e5 3492 char onButton1_command_table_01[COMMAND_TABLE_COL_MAX] = ">>SW1=LP1 deep sleep 10 sec";
whismanoid 45:74bf1fe021e5 3493 char onButton1_command_table_02[COMMAND_TABLE_COL_MAX] = "%H91"; // LED off
whismanoid 45:74bf1fe021e5 3494 char onButton1_command_table_03[COMMAND_TABLE_COL_MAX] = "%H92"; // LED off
whismanoid 45:74bf1fe021e5 3495 char onButton1_command_table_04[COMMAND_TABLE_COL_MAX] = "%H93"; // LED off
whismanoid 45:74bf1fe021e5 3496 char onButton1_command_table_05[COMMAND_TABLE_COL_MAX] = "%H9"; // diagnostic pulse D9
whismanoid 45:74bf1fe021e5 3497 char onButton1_command_table_06[COMMAND_TABLE_COL_MAX] = "LT count=10 base=1000 sleep=1";
whismanoid 45:74bf1fe021e5 3498 char onButton1_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3499 char onButton1_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3500 char onButton1_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3501 static char* onButton1_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3502 onButton1_command_table_00,
whismanoid 23:c6c652bef4b9 3503 onButton1_command_table_01,
whismanoid 23:c6c652bef4b9 3504 onButton1_command_table_02,
whismanoid 23:c6c652bef4b9 3505 onButton1_command_table_03,
whismanoid 23:c6c652bef4b9 3506 onButton1_command_table_04,
whismanoid 23:c6c652bef4b9 3507 onButton1_command_table_05,
whismanoid 23:c6c652bef4b9 3508 onButton1_command_table_06,
whismanoid 23:c6c652bef4b9 3509 onButton1_command_table_07,
whismanoid 23:c6c652bef4b9 3510 onButton1_command_table_08,
whismanoid 23:c6c652bef4b9 3511 onButton1_command_table_09,
whismanoid 23:c6c652bef4b9 3512 };
whismanoid 23:c6c652bef4b9 3513 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3514 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3515 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3516 // onButton2_command_table[] supports command %B2! -- run, %B2@ -- edit
whismanoid 45:74bf1fe021e5 3517 // MAX40108p2 hardware pin P1_7 connector J91.3 active low
whismanoid 45:74bf1fe021e5 3518 //........................................................12345678901234567890
whismanoid 45:74bf1fe021e5 3519 char onButton2_command_table_00[COMMAND_TABLE_COL_MAX] = "# J91.3=Halt"; // remark
whismanoid 45:74bf1fe021e5 3520 char onButton2_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91"; // LED on
whismanoid 45:74bf1fe021e5 3521 char onButton2_command_table_02[COMMAND_TABLE_COL_MAX] = "L"; // halts data logging
whismanoid 45:74bf1fe021e5 3522 char onButton2_command_table_03[COMMAND_TABLE_COL_MAX] = "%H92"; // LED off
whismanoid 45:74bf1fe021e5 3523 char onButton2_command_table_04[COMMAND_TABLE_COL_MAX] = "%L93"; // LED on
whismanoid 45:74bf1fe021e5 3524 char onButton2_command_table_05[COMMAND_TABLE_COL_MAX] = ">>J91.2=Halt"; // to DAPLINK comms
whismanoid 23:c6c652bef4b9 3525 char onButton2_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3526 char onButton2_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3527 char onButton2_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3528 char onButton2_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3529 static char* onButton2_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3530 onButton2_command_table_00,
whismanoid 23:c6c652bef4b9 3531 onButton2_command_table_01,
whismanoid 23:c6c652bef4b9 3532 onButton2_command_table_02,
whismanoid 23:c6c652bef4b9 3533 onButton2_command_table_03,
whismanoid 23:c6c652bef4b9 3534 onButton2_command_table_04,
whismanoid 23:c6c652bef4b9 3535 onButton2_command_table_05,
whismanoid 23:c6c652bef4b9 3536 onButton2_command_table_06,
whismanoid 23:c6c652bef4b9 3537 onButton2_command_table_07,
whismanoid 23:c6c652bef4b9 3538 onButton2_command_table_08,
whismanoid 23:c6c652bef4b9 3539 onButton2_command_table_09,
whismanoid 23:c6c652bef4b9 3540 };
whismanoid 23:c6c652bef4b9 3541 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3542 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3543 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3544 // onButton3_command_table[] supports command %B3! -- run, %B3@ -- edit
whismanoid 45:74bf1fe021e5 3545 // MAX40108p2 hardware pin P1_6 connector J91.2 active low
whismanoid 45:74bf1fe021e5 3546 //........................................................12345678901234567890
whismanoid 45:74bf1fe021e5 3547 char onButton3_command_table_00[COMMAND_TABLE_COL_MAX] = "# J91.2 event";
whismanoid 45:74bf1fe021e5 3548 char onButton3_command_table_01[COMMAND_TABLE_COL_MAX] = ">>J91.2 event";
whismanoid 45:74bf1fe021e5 3549 char onButton3_command_table_02[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 45:74bf1fe021e5 3550 char onButton3_command_table_03[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 45:74bf1fe021e5 3551 char onButton3_command_table_04[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 45:74bf1fe021e5 3552 char onButton3_command_table_05[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 45:74bf1fe021e5 3553 char onButton3_command_table_06[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 45:74bf1fe021e5 3554 char onButton3_command_table_07[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 45:74bf1fe021e5 3555 char onButton3_command_table_08[COMMAND_TABLE_COL_MAX] = ">>LR -- run full speed";
whismanoid 45:74bf1fe021e5 3556 char onButton3_command_table_09[COMMAND_TABLE_COL_MAX] = "LR";
whismanoid 24:032f3683cb2a 3557 static char* onButton3_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 24:032f3683cb2a 3558 onButton3_command_table_00,
whismanoid 24:032f3683cb2a 3559 onButton3_command_table_01,
whismanoid 24:032f3683cb2a 3560 onButton3_command_table_02,
whismanoid 24:032f3683cb2a 3561 onButton3_command_table_03,
whismanoid 24:032f3683cb2a 3562 onButton3_command_table_04,
whismanoid 24:032f3683cb2a 3563 onButton3_command_table_05,
whismanoid 24:032f3683cb2a 3564 onButton3_command_table_06,
whismanoid 24:032f3683cb2a 3565 onButton3_command_table_07,
whismanoid 24:032f3683cb2a 3566 onButton3_command_table_08,
whismanoid 24:032f3683cb2a 3567 onButton3_command_table_09,
whismanoid 24:032f3683cb2a 3568 };
whismanoid 24:032f3683cb2a 3569 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3570 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3571 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3572 // onButton4_command_table[] supports command %B4! -- run, %B4@ -- edit
whismanoid 45:74bf1fe021e5 3573 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3574 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3575 char onButton4_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button4 event";
whismanoid 30:07197a430869 3576 char onButton4_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE>0.7:active";
whismanoid 29:6a9edb6e973b 3577 char onButton4_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3578 char onButton4_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3579 char onButton4_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3580 char onButton4_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3581 char onButton4_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3582 char onButton4_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3583 char onButton4_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3584 char onButton4_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3585 static char* onButton4_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3586 onButton4_command_table_00,
whismanoid 29:6a9edb6e973b 3587 onButton4_command_table_01,
whismanoid 29:6a9edb6e973b 3588 onButton4_command_table_02,
whismanoid 29:6a9edb6e973b 3589 onButton4_command_table_03,
whismanoid 29:6a9edb6e973b 3590 onButton4_command_table_04,
whismanoid 29:6a9edb6e973b 3591 onButton4_command_table_05,
whismanoid 29:6a9edb6e973b 3592 onButton4_command_table_06,
whismanoid 29:6a9edb6e973b 3593 onButton4_command_table_07,
whismanoid 29:6a9edb6e973b 3594 onButton4_command_table_08,
whismanoid 29:6a9edb6e973b 3595 onButton4_command_table_09,
whismanoid 29:6a9edb6e973b 3596 };
whismanoid 29:6a9edb6e973b 3597 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3598 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3599 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3600 // onButton5_command_table[] supports command %B5! -- run, %B5@ -- edit
whismanoid 45:74bf1fe021e5 3601 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3602 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3603 char onButton5_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button5 event";
whismanoid 30:07197a430869 3604 char onButton5_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE<0.6:sleep";
whismanoid 29:6a9edb6e973b 3605 char onButton5_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3606 char onButton5_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3607 char onButton5_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3608 char onButton5_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3609 char onButton5_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3610 char onButton5_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3611 char onButton5_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3612 char onButton5_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3613 static char* onButton5_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3614 onButton5_command_table_00,
whismanoid 29:6a9edb6e973b 3615 onButton5_command_table_01,
whismanoid 29:6a9edb6e973b 3616 onButton5_command_table_02,
whismanoid 29:6a9edb6e973b 3617 onButton5_command_table_03,
whismanoid 29:6a9edb6e973b 3618 onButton5_command_table_04,
whismanoid 29:6a9edb6e973b 3619 onButton5_command_table_05,
whismanoid 29:6a9edb6e973b 3620 onButton5_command_table_06,
whismanoid 29:6a9edb6e973b 3621 onButton5_command_table_07,
whismanoid 29:6a9edb6e973b 3622 onButton5_command_table_08,
whismanoid 29:6a9edb6e973b 3623 onButton5_command_table_09,
whismanoid 29:6a9edb6e973b 3624 };
whismanoid 29:6a9edb6e973b 3625 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3626 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3627 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3628 // onButton6_command_table[] supports command %B6! -- run, %B6@ -- edit
whismanoid 45:74bf1fe021e5 3629 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3630 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3631 char onButton6_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button6 event";
whismanoid 29:6a9edb6e973b 3632 char onButton6_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3633 char onButton6_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3634 char onButton6_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3635 char onButton6_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3636 char onButton6_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3637 char onButton6_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3638 char onButton6_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3639 char onButton6_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3640 char onButton6_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3641 static char* onButton6_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3642 onButton6_command_table_00,
whismanoid 29:6a9edb6e973b 3643 onButton6_command_table_01,
whismanoid 29:6a9edb6e973b 3644 onButton6_command_table_02,
whismanoid 29:6a9edb6e973b 3645 onButton6_command_table_03,
whismanoid 29:6a9edb6e973b 3646 onButton6_command_table_04,
whismanoid 29:6a9edb6e973b 3647 onButton6_command_table_05,
whismanoid 29:6a9edb6e973b 3648 onButton6_command_table_06,
whismanoid 29:6a9edb6e973b 3649 onButton6_command_table_07,
whismanoid 29:6a9edb6e973b 3650 onButton6_command_table_08,
whismanoid 29:6a9edb6e973b 3651 onButton6_command_table_09,
whismanoid 29:6a9edb6e973b 3652 };
whismanoid 29:6a9edb6e973b 3653 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3654 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3655 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3656 // onButton7_command_table[] supports command %B7! -- run, %B7@ -- edit
whismanoid 45:74bf1fe021e5 3657 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3658 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3659 char onButton7_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button7 event";
whismanoid 29:6a9edb6e973b 3660 char onButton7_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3661 char onButton7_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3662 char onButton7_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3663 char onButton7_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3664 char onButton7_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3665 char onButton7_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3666 char onButton7_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3667 char onButton7_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3668 char onButton7_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3669 static char* onButton7_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3670 onButton7_command_table_00,
whismanoid 29:6a9edb6e973b 3671 onButton7_command_table_01,
whismanoid 29:6a9edb6e973b 3672 onButton7_command_table_02,
whismanoid 29:6a9edb6e973b 3673 onButton7_command_table_03,
whismanoid 29:6a9edb6e973b 3674 onButton7_command_table_04,
whismanoid 29:6a9edb6e973b 3675 onButton7_command_table_05,
whismanoid 29:6a9edb6e973b 3676 onButton7_command_table_06,
whismanoid 29:6a9edb6e973b 3677 onButton7_command_table_07,
whismanoid 29:6a9edb6e973b 3678 onButton7_command_table_08,
whismanoid 29:6a9edb6e973b 3679 onButton7_command_table_09,
whismanoid 29:6a9edb6e973b 3680 };
whismanoid 29:6a9edb6e973b 3681 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3682 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3683 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3684 // onButton8_command_table[] supports command %B8! -- run, %B8@ -- edit
whismanoid 45:74bf1fe021e5 3685 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3686 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3687 char onButton8_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button8 event";
whismanoid 29:6a9edb6e973b 3688 char onButton8_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3689 char onButton8_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3690 char onButton8_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3691 char onButton8_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3692 char onButton8_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3693 char onButton8_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3694 char onButton8_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3695 char onButton8_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3696 char onButton8_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3697 static char* onButton8_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3698 onButton8_command_table_00,
whismanoid 29:6a9edb6e973b 3699 onButton8_command_table_01,
whismanoid 29:6a9edb6e973b 3700 onButton8_command_table_02,
whismanoid 29:6a9edb6e973b 3701 onButton8_command_table_03,
whismanoid 29:6a9edb6e973b 3702 onButton8_command_table_04,
whismanoid 29:6a9edb6e973b 3703 onButton8_command_table_05,
whismanoid 29:6a9edb6e973b 3704 onButton8_command_table_06,
whismanoid 29:6a9edb6e973b 3705 onButton8_command_table_07,
whismanoid 29:6a9edb6e973b 3706 onButton8_command_table_08,
whismanoid 29:6a9edb6e973b 3707 onButton8_command_table_09,
whismanoid 29:6a9edb6e973b 3708 };
whismanoid 29:6a9edb6e973b 3709 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3710 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3711 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3712 // onButton9_command_table[] supports command %B9! -- run, %B9@ -- edit
whismanoid 45:74bf1fe021e5 3713 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3714 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3715 char onButton9_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button9 event";
whismanoid 29:6a9edb6e973b 3716 char onButton9_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3717 char onButton9_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3718 char onButton9_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3719 char onButton9_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3720 char onButton9_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3721 char onButton9_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3722 char onButton9_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3723 char onButton9_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3724 char onButton9_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3725 static char* onButton9_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3726 onButton9_command_table_00,
whismanoid 29:6a9edb6e973b 3727 onButton9_command_table_01,
whismanoid 29:6a9edb6e973b 3728 onButton9_command_table_02,
whismanoid 29:6a9edb6e973b 3729 onButton9_command_table_03,
whismanoid 29:6a9edb6e973b 3730 onButton9_command_table_04,
whismanoid 29:6a9edb6e973b 3731 onButton9_command_table_05,
whismanoid 29:6a9edb6e973b 3732 onButton9_command_table_06,
whismanoid 29:6a9edb6e973b 3733 onButton9_command_table_07,
whismanoid 29:6a9edb6e973b 3734 onButton9_command_table_08,
whismanoid 29:6a9edb6e973b 3735 onButton9_command_table_09,
whismanoid 29:6a9edb6e973b 3736 };
whismanoid 29:6a9edb6e973b 3737 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3738 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3739 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3740 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 3741 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3742 bool g_Run_command_table_running = false;
whismanoid 23:c6c652bef4b9 3743 void Run_command_table(char* command_table[])
whismanoid 23:c6c652bef4b9 3744 {
whismanoid 23:c6c652bef4b9 3745 // command_table: perform list of commands
whismanoid 31:47eee7e0cc2d 3746 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3747 if (g_Run_command_table_running) {
whismanoid 31:47eee7e0cc2d 3748 // TODO: button event chaining is not supported at this time
whismanoid 31:47eee7e0cc2d 3749 } // if (g_Run_command_table_running)
whismanoid 31:47eee7e0cc2d 3750 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3751 g_Run_command_table_running = true;
whismanoid 23:c6c652bef4b9 3752 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 3753 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 3754 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 23:c6c652bef4b9 3755 cmdLine.clear();
whismanoid 31:47eee7e0cc2d 3756 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3757 //~ char* strIndex = command_table[lineIndex];
whismanoid 23:c6c652bef4b9 3758 for (char* strIndex = command_table[lineIndex]; *strIndex != '\0'; strIndex++)
whismanoid 23:c6c652bef4b9 3759 {
whismanoid 23:c6c652bef4b9 3760 cmdLine.append(*strIndex);
whismanoid 23:c6c652bef4b9 3761 }
whismanoid 23:c6c652bef4b9 3762 cmdLine.append('\r'); // append \r invokes onEOLcommandParser to handle command
whismanoid 23:c6c652bef4b9 3763 }
whismanoid 31:47eee7e0cc2d 3764 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3765 g_Run_command_table_running = false;
whismanoid 31:47eee7e0cc2d 3766 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3767 }
whismanoid 23:c6c652bef4b9 3768 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3769 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3770 // When user presses button BUTTON1, perform actions
whismanoid 21:ac062a97a71d 3771 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3772 void onButton1FallingEdge(void)
whismanoid 21:ac062a97a71d 3773 {
whismanoid 21:ac062a97a71d 3774 //~ void SelfTest(CmdLine & cmdLine);
whismanoid 21:ac062a97a71d 3775 //~ SelfTest(cmdLine_serial);
whismanoid 22:d6dc8a85f435 3776 //
whismanoid 23:c6c652bef4b9 3777 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3778 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3779 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3780 Run_command_table(onButton1_command_table);
whismanoid 23:c6c652bef4b9 3781 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3782 }
whismanoid 21:ac062a97a71d 3783 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3784
whismanoid 21:ac062a97a71d 3785 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3786 // When user presses button BUTTON2, perform actions
whismanoid 21:ac062a97a71d 3787 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3788 void onButton2FallingEdge(void)
whismanoid 21:ac062a97a71d 3789 {
whismanoid 21:ac062a97a71d 3790 // TBD demo configuration
whismanoid 21:ac062a97a71d 3791 // TODO diagnostic LED
whismanoid 21:ac062a97a71d 3792 // led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 22:d6dc8a85f435 3793 //
whismanoid 23:c6c652bef4b9 3794 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3795 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3796 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3797 Run_command_table(onButton2_command_table);
whismanoid 23:c6c652bef4b9 3798 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3799 }
whismanoid 21:ac062a97a71d 3800 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3801
whismanoid 24:032f3683cb2a 3802 //--------------------------------------------------
whismanoid 29:6a9edb6e973b 3803 // When user presses button BUTTON3, perform actions
whismanoid 24:032f3683cb2a 3804 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3805 void onButton3FallingEdge(void)
whismanoid 24:032f3683cb2a 3806 {
whismanoid 24:032f3683cb2a 3807 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 24:032f3683cb2a 3808 // command_table: list of commands to perform on button press
whismanoid 24:032f3683cb2a 3809 // command_table: perform list of commands
whismanoid 24:032f3683cb2a 3810 Run_command_table(onButton3_command_table);
whismanoid 24:032f3683cb2a 3811 #endif // USE_DATALOGGER_CommandTable
whismanoid 24:032f3683cb2a 3812 }
whismanoid 24:032f3683cb2a 3813 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3814 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3815 void onButton4FallingEdge(void)
whismanoid 29:6a9edb6e973b 3816 {
whismanoid 29:6a9edb6e973b 3817 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3818 Run_command_table(onButton4_command_table);
whismanoid 29:6a9edb6e973b 3819 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3820 }
whismanoid 29:6a9edb6e973b 3821 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3822 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3823 void onButton5FallingEdge(void)
whismanoid 29:6a9edb6e973b 3824 {
whismanoid 29:6a9edb6e973b 3825 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3826 Run_command_table(onButton5_command_table);
whismanoid 29:6a9edb6e973b 3827 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3828 }
whismanoid 29:6a9edb6e973b 3829 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3830 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3831 void onButton6FallingEdge(void)
whismanoid 29:6a9edb6e973b 3832 {
whismanoid 29:6a9edb6e973b 3833 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3834 Run_command_table(onButton6_command_table);
whismanoid 29:6a9edb6e973b 3835 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3836 }
whismanoid 29:6a9edb6e973b 3837 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3838 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3839 void onButton7FallingEdge(void)
whismanoid 29:6a9edb6e973b 3840 {
whismanoid 29:6a9edb6e973b 3841 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3842 Run_command_table(onButton7_command_table);
whismanoid 29:6a9edb6e973b 3843 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3844 }
whismanoid 29:6a9edb6e973b 3845 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3846 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3847 void onButton8FallingEdge(void)
whismanoid 29:6a9edb6e973b 3848 {
whismanoid 29:6a9edb6e973b 3849 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3850 Run_command_table(onButton8_command_table);
whismanoid 29:6a9edb6e973b 3851 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3852 }
whismanoid 29:6a9edb6e973b 3853 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3854 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3855 void onButton9FallingEdge(void)
whismanoid 29:6a9edb6e973b 3856 {
whismanoid 29:6a9edb6e973b 3857 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3858 Run_command_table(onButton9_command_table);
whismanoid 29:6a9edb6e973b 3859 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3860 }
whismanoid 29:6a9edb6e973b 3861 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3862
whismanoid 4:d9b05924ad4c 3863 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3864 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3865 inline void print_command_prompt()
whismanoid 4:d9b05924ad4c 3866 {
whismanoid 4:d9b05924ad4c 3867 //~ Serial.println(F(">"));
whismanoid 4:d9b05924ad4c 3868 cmdLine.serial().printf("\r\n> ");
whismanoid 4:d9b05924ad4c 3869 }
whismanoid 4:d9b05924ad4c 3870 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3871
whismanoid 4:d9b05924ad4c 3872 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3873 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3874 void main_menu_status(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 3875 {
whismanoid 4:d9b05924ad4c 3876 cmdLine.serial().printf("\r\nMain menu");
whismanoid 4:d9b05924ad4c 3877 #if APPLICATION_MAX5715 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3878 cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC");
whismanoid 4:d9b05924ad4c 3879 #elif APPLICATION_MAX11131 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3880 cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC");
whismanoid 4:d9b05924ad4c 3881 #elif APPLICATION_MAX5171 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3882 cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC");
whismanoid 4:d9b05924ad4c 3883 #elif APPLICATION_MAX11410 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3884 cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC");
whismanoid 4:d9b05924ad4c 3885 #elif APPLICATION_MAX12345 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3886 cmdLine.serial().printf(" MAX12345");
whismanoid 16:819c5aaf5271 3887 #elif MAX40108_DEMO // main_menu_status banner
whismanoid 17:9397ea3ea7e9 3888 cmdLine.serial().printf(" MAX40108_U%d", MAX40108_DEMO);
whismanoid 36:e7aac874b8be 3889 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 3890 // data unique to certain boards based on serial number
whismanoid 47:f1a56afb4aca 3891 cmdLine.serial().printf(" [s/n %d]", g_board_serial_number);
whismanoid 36:e7aac874b8be 3892 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 3893 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 3894 //
whismanoid 36:e7aac874b8be 3895 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 3896 #ifdef FW_REV
whismanoid 37:3f369235e5bc 3897 cmdLine.serial().printf(" [FW_REV %d]", FW_REV);
whismanoid 37:3f369235e5bc 3898 #endif // FW_REV
whismanoid 4:d9b05924ad4c 3899 #else
whismanoid 4:d9b05924ad4c 3900 //cmdLine.serial().printf(" ");
whismanoid 4:d9b05924ad4c 3901 #endif
whismanoid 4:d9b05924ad4c 3902 //cmdLine.serial().printf(" %s", TARGET_NAME);
whismanoid 4:d9b05924ad4c 3903 if (cmdLine.nameStr())
whismanoid 4:d9b05924ad4c 3904 {
whismanoid 4:d9b05924ad4c 3905 cmdLine.serial().printf(" [%s]", cmdLine.nameStr());
whismanoid 4:d9b05924ad4c 3906 }
whismanoid 4:d9b05924ad4c 3907 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3908 cmdLine.serial().printf(" [Button1");
whismanoid 4:d9b05924ad4c 3909 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3910 cmdLine.serial().printf("2");
whismanoid 24:032f3683cb2a 3911 #endif
whismanoid 24:032f3683cb2a 3912 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3913 cmdLine.serial().printf("3");
whismanoid 29:6a9edb6e973b 3914 #endif
whismanoid 29:6a9edb6e973b 3915 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3916 cmdLine.serial().printf("4");
whismanoid 29:6a9edb6e973b 3917 #endif
whismanoid 29:6a9edb6e973b 3918 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3919 cmdLine.serial().printf("5");
whismanoid 29:6a9edb6e973b 3920 #endif
whismanoid 29:6a9edb6e973b 3921 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3922 cmdLine.serial().printf("6");
whismanoid 29:6a9edb6e973b 3923 #endif
whismanoid 29:6a9edb6e973b 3924 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3925 cmdLine.serial().printf("7");
whismanoid 29:6a9edb6e973b 3926 #endif
whismanoid 29:6a9edb6e973b 3927 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3928 cmdLine.serial().printf("8");
whismanoid 29:6a9edb6e973b 3929 #endif
whismanoid 29:6a9edb6e973b 3930 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3931 cmdLine.serial().printf("9");
whismanoid 29:6a9edb6e973b 3932 #endif
whismanoid 29:6a9edb6e973b 3933 cmdLine.serial().printf("]");
whismanoid 29:6a9edb6e973b 3934 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 4:d9b05924ad4c 3935 #if HAS_BUTTON1_DEMO
whismanoid 4:d9b05924ad4c 3936 // print BUTTON1 status
whismanoid 4:d9b05924ad4c 3937 cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read());
whismanoid 4:d9b05924ad4c 3938 #endif
whismanoid 4:d9b05924ad4c 3939 #if HAS_BUTTON2_DEMO
whismanoid 24:032f3683cb2a 3940 // print BUTTON2 status
whismanoid 4:d9b05924ad4c 3941 cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read());
whismanoid 4:d9b05924ad4c 3942 #endif
whismanoid 24:032f3683cb2a 3943 #if HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 3944 // print BUTTON3 status
whismanoid 24:032f3683cb2a 3945 cmdLine.serial().printf("\r\n BUTTON3 = %d", button3.read());
whismanoid 24:032f3683cb2a 3946 #endif
whismanoid 4:d9b05924ad4c 3947 cmdLine.serial().printf("\r\n ? -- help");
whismanoid 4:d9b05924ad4c 3948 }
whismanoid 4:d9b05924ad4c 3949 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3950
whismanoid 28:a9a3a9db592b 3951 //--------------------------------------------------
whismanoid 28:a9a3a9db592b 3952 #ifndef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3953 #define USE_DATALOGGER_TRIGGER_HELP_BRIEF 1
whismanoid 28:a9a3a9db592b 3954 //~ #undef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3955 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3956
whismanoid 4:d9b05924ad4c 3957 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3958 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3959 void main_menu_help(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 3960 {
whismanoid 4:d9b05924ad4c 3961 // ? -- help
whismanoid 4:d9b05924ad4c 3962 //~ cmdLine.serial().printf("\r\nMenu:");
whismanoid 10:04022a61b527 3963 //
whismanoid 4:d9b05924ad4c 3964 cmdLine.serial().printf("\r\n # -- lines beginning with # are comments");
whismanoid 10:04022a61b527 3965 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 3966 cmdLine.serial().printf("\r\n ! -- Init");
whismanoid 10:04022a61b527 3967 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 3968 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 3969 cmdLine.serial().printf("\r\n . -- SelfTest");
whismanoid 4:d9b05924ad4c 3970 #endif // USE_SELFTEST
whismanoid 9:45f98573eb6d 3971 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 9:45f98573eb6d 3972 // CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register
whismanoid 9:45f98573eb6d 3973 cmdLine.serial().printf("\r\n * -- read core registers\r\n *regname? -- read register\r\n *regname=regvalue -- write register");
whismanoid 9:45f98573eb6d 3974 // cmdLine.serial().printf("\r\n 01 23 45 67 89 ab cd ef -- write and read raw hex codes");
whismanoid 10:04022a61b527 3975 #endif // USE_STAR_REG_READWRITE
whismanoid 10:04022a61b527 3976 //
whismanoid 10:04022a61b527 3977 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3978 // Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_help
whismanoid 10:04022a61b527 3979 //~ cmdLine.serial().printf("\r\n > -- auxiliary UART port");
whismanoid 10:04022a61b527 3980 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3981 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3982 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3983 if (cmdLine_AUXserial.nameStr())
whismanoid 10:04022a61b527 3984 {
whismanoid 10:04022a61b527 3985 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_AUXserial.nameStr());
whismanoid 10:04022a61b527 3986 }
whismanoid 10:04022a61b527 3987 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3988 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3989 if (cmdLine_DAPLINKserial.nameStr())
whismanoid 10:04022a61b527 3990 {
whismanoid 10:04022a61b527 3991 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_DAPLINKserial.nameStr());
whismanoid 10:04022a61b527 3992 }
whismanoid 10:04022a61b527 3993 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3994 # if HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3995 // WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3996 cmdLine.serial().printf("\r\n >xyzzy -- Forward command/data 'xyzzy' to aux TX/RX");
whismanoid 10:04022a61b527 3997 cmdLine.serial().printf("\r\n >>xyzzy -- Forward 'xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 3998 cmdLine.serial().printf("\r\n >>>xyzzy -- Forward '>xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 3999 #if 0
whismanoid 10:04022a61b527 4000 cmdLine.serial().printf("\r\n >tx_wait_echo=%d -- configure TX wait for each character echo", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 4001 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 4002 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 4003 #endif
whismanoid 20:78ef670955d4 4004 #if 1 // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 4005 cmdLine.serial().printf("\r\n >baud=%d message_ms=%d rx_idle_ms=%d rx_max_count=%d rx_eot=%d",
whismanoid 20:78ef670955d4 4006 g_auxSerialCom_baud,
whismanoid 20:78ef670955d4 4007 g_auxSerialCom_message_ms,
whismanoid 20:78ef670955d4 4008 g_auxSerialCom_rx_idle_ms,
whismanoid 20:78ef670955d4 4009 g_auxSerialCom_rx_max_count,
whismanoid 20:78ef670955d4 4010 g_auxSerialCom_rx_eot);
whismanoid 20:78ef670955d4 4011 #else // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 4012 cmdLine.serial().printf("\r\n >baud=%d -- configure aux TX/RX port", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 4013 cmdLine.serial().printf("\r\n >message_ms=%d -- maximum RX message total response time", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 4014 cmdLine.serial().printf("\r\n >rx_idle_ms=%d -- maximum RX message idle time between characters", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 4015 cmdLine.serial().printf("\r\n >rx_max_count=%d -- maximum RX message total length", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 4016 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 4017 #endif // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 10:04022a61b527 4018 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 4019 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 4020 //
whismanoid 4:d9b05924ad4c 4021 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 4022 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 4023 // Datalog trigger menu
whismanoid 28:a9a3a9db592b 4024 // brief toplevel heading for datalog help L
whismanoid 28:a9a3a9db592b 4025 // L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 4026 cmdLine.serial().printf("\r\n L -- halt the datalogger; show more commands");
whismanoid 28:a9a3a9db592b 4027 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 28:a9a3a9db592b 4028 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 28:a9a3a9db592b 4029 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 28:a9a3a9db592b 4030 //
whismanoid 28:a9a3a9db592b 4031 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 4032 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 4033 //
whismanoid 39:4d285e961435 4034 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 4035 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 4036 cmdLine.serial().printf("\r\n LT count=%d base=%dms sleep=%d -- Datalog timer",
whismanoid 39:4d285e961435 4037 g_timer_interval_count,
whismanoid 39:4d285e961435 4038 g_timer_interval_msec,
whismanoid 39:4d285e961435 4039 (int)g_timer_sleepmode
whismanoid 39:4d285e961435 4040 ); // trigger_Timer
whismanoid 39:4d285e961435 4041 #else // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 4042 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 4043 #endif // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 4044 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 4045 //~ cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 4046 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 4047 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 4048 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 4049 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 4050 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 9:45f98573eb6d 4051 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 9:45f98573eb6d 4052 //
whismanoid 17:9397ea3ea7e9 4053 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 4:d9b05924ad4c 4054 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 9:45f98573eb6d 4055 //
whismanoid 17:9397ea3ea7e9 4056 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 4057 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 17:9397ea3ea7e9 4058 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 4059 //
whismanoid 9:45f98573eb6d 4060 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 4061 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 4062 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 4063 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 9:45f98573eb6d 4064 //
whismanoid 17:9397ea3ea7e9 4065 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 9:45f98573eb6d 4066 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 4067 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 4068 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 4069 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 4070 //
whismanoid 17:9397ea3ea7e9 4071 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 4072 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 17:9397ea3ea7e9 4073 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 9:45f98573eb6d 4074 //
whismanoid 9:45f98573eb6d 4075 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 4076 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 4077 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 4078 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 4079 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 9:45f98573eb6d 4080 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 9:45f98573eb6d 4081 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 9:45f98573eb6d 4082 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 9:45f98573eb6d 4083 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 9:45f98573eb6d 4084 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 9:45f98573eb6d 4085 //
whismanoid 9:45f98573eb6d 4086 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 4087 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 9:45f98573eb6d 4088 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 9:45f98573eb6d 4089 //
whismanoid 9:45f98573eb6d 4090 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 4091 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 4092 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 9:45f98573eb6d 4093 //
whismanoid 9:45f98573eb6d 4094 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 4095 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 9:45f98573eb6d 4096 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 4097 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 9:45f98573eb6d 4098 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 4099 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 9:45f98573eb6d 4100 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 4101 //
whismanoid 9:45f98573eb6d 4102 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 4103 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 9:45f98573eb6d 4104 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 9:45f98573eb6d 4105 //
whismanoid 9:45f98573eb6d 4106 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 4107 //
whismanoid 9:45f98573eb6d 4108 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 4109 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 4110 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 4111 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 4112 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 9:45f98573eb6d 4113 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4114 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 9:45f98573eb6d 4115 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4116 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4117 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 9:45f98573eb6d 4118 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4119 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 9:45f98573eb6d 4120 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4121 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 9:45f98573eb6d 4122 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4123 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4124 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 9:45f98573eb6d 4125 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4126 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 4127 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 4128 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 4129 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 4130 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 4131 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 4132 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 4133 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 4134 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 4135 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 4136 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 4137 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 4138 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 4139 //
whismanoid 4:d9b05924ad4c 4140 //cmdLine.serial().print(F("\r\n ! -- Initial Configuration"));
whismanoid 4:d9b05924ad4c 4141 //
whismanoid 4:d9b05924ad4c 4142 // % standardize diagnostic commands
whismanoid 4:d9b05924ad4c 4143 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 4144 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 4145 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 4146 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 4147 // %Ppin df=xx -- pwm output
whismanoid 4:d9b05924ad4c 4148 // %Wpin -- measure high pulsewidth input in usec
whismanoid 4:d9b05924ad4c 4149 // %wpin -- measure low pulsewidth input in usec
whismanoid 4:d9b05924ad4c 4150 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 4151 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 4152 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 4153 // %IW ADDR=? cmd=? data,data,data -- write
whismanoid 4:d9b05924ad4c 4154 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 4155 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4156 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 4157 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 4158 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 4159 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 4160 // A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 4161 //
whismanoid 23:c6c652bef4b9 4162 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 4163 #if USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4164 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 4165 // TODO: %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 4166 // TODO: future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 4167 // TODO: future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 4168 // TODO: %B1@ view command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 4169 // TODO: %B1@+ command add new row (if there is room to add) (ignore one space before command)
whismanoid 23:c6c652bef4b9 4170 // TODO: %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 4171 // TODO: %B1@-~~~ clear entire command table
whismanoid 23:c6c652bef4b9 4172 // TODO: %B1@nnn command replace row number nnn (ignore one space before command)
whismanoid 23:c6c652bef4b9 4173 // TODO: %B1@! disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 4174 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 4175 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 45:74bf1fe021e5 4176 // cmdLine.serial().printf("\r\n %%B1! trigger Button1 event; %%B1@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4177 cmdLine.serial().printf("\r\n %%B1! trigger Button1 event;");
whismanoid 45:74bf1fe021e5 4178 // print maximum index for %B1 submenu
whismanoid 45:74bf1fe021e5 4179 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4180 cmdLine.serial().printf(" %%B9@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4181 #elif HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4182 cmdLine.serial().printf(" %%B8@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4183 #elif HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4184 cmdLine.serial().printf(" %%B7@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4185 #elif HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4186 cmdLine.serial().printf(" %%B6@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4187 #elif HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4188 cmdLine.serial().printf(" %%B5@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4189 #elif HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4190 cmdLine.serial().printf(" %%B4@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4191 #elif HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4192 cmdLine.serial().printf(" %%B3@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4193 #elif HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4194 cmdLine.serial().printf(" %%B2@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4195 #elif HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4196 cmdLine.serial().printf(" %%B1@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4197 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4198
whismanoid 45:74bf1fe021e5 4199
whismanoid 23:c6c652bef4b9 4200 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4201 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 4202 #if HAS_digitalInOuts
whismanoid 4:d9b05924ad4c 4203 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 4204 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 4205 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 4206 cmdLine.serial().printf("\r\n %%Hn {pin:");
whismanoid 4:d9b05924ad4c 4207 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 4208 cmdLine.serial().printf("} -- High Output");
whismanoid 4:d9b05924ad4c 4209 cmdLine.serial().printf("\r\n %%Ln {pin:");
whismanoid 4:d9b05924ad4c 4210 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 4211 cmdLine.serial().printf("} -- Low Output");
whismanoid 4:d9b05924ad4c 4212 cmdLine.serial().printf("\r\n %%?n {pin:");
whismanoid 4:d9b05924ad4c 4213 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 4214 cmdLine.serial().printf("} -- Input");
whismanoid 4:d9b05924ad4c 4215 #endif
whismanoid 4:d9b05924ad4c 4216
whismanoid 4:d9b05924ad4c 4217 #if HAS_analogIns
whismanoid 4:d9b05924ad4c 4218 // Menu A) analogRead A0..7
whismanoid 4:d9b05924ad4c 4219 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 4220 // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0)
whismanoid 37:3f369235e5bc 4221 cmdLine.serial().printf("\r\n %%A -- analogRead");
whismanoid 37:3f369235e5bc 4222 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4223 // %A avg=%d -- help string display Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 4224 cmdLine.serial().printf("; %%A avg=%d -- average", Platform_AIN_Average_N);
whismanoid 37:3f369235e5bc 4225 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4226 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4227 // %A cal? view/export raw calibration values for all channels
whismanoid 37:3f369235e5bc 4228 cmdLine.serial().printf("; %%A cal? -- calibration");
whismanoid 34:a1993a1ee904 4229 #endif // HAS_Platform_AIN_Calibration
whismanoid 4:d9b05924ad4c 4230 #endif
whismanoid 4:d9b05924ad4c 4231
whismanoid 4:d9b05924ad4c 4232 #if HAS_SPI2_MAX541
whismanoid 4:d9b05924ad4c 4233 // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 4:d9b05924ad4c 4234 cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)");
whismanoid 4:d9b05924ad4c 4235 #endif
whismanoid 4:d9b05924ad4c 4236
whismanoid 46:469d0061df5d 4237 //--------------------------------------------------
whismanoid 46:469d0061df5d 4238 #if defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 4239 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 4240 // cmdLine.serial().printf("\r\n %%F -- flash support");
whismanoid 46:469d0061df5d 4241 # if HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4242 // flash peek memory %F peek=0x0007ff00 len=0x0100 -- hex dump
whismanoid 46:469d0061df5d 4243 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 4244 # endif // HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4245 # if HAS_FLASH_POKE
whismanoid 46:469d0061df5d 4246 // flash poke memory %F poke=0x0007ff00 0xab 0xcd 0xef 0x27 0x18 0x28 -- erase/write flash page
whismanoid 46:469d0061df5d 4247 cmdLine.serial().printf("\r\n %%F poke=0x%8.8lx ab cd ef 27 18 28 -- erase/write flash page", (uint32_t)&flash_page_configuration_back_up[0]);
whismanoid 46:469d0061df5d 4248 # endif // HAS_FLASH_POKE
whismanoid 46:469d0061df5d 4249 # if HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 4250 cmdLine.serial().printf("\r\n %%F save=0xFF -- erase config; %%F save=0 -- save all config");
whismanoid 46:469d0061df5d 4251 cmdLine.serial().printf("\r\n %%F load -- load all config");
whismanoid 46:469d0061df5d 4252 # endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 4253 #endif
whismanoid 46:469d0061df5d 4254
whismanoid 4:d9b05924ad4c 4255 #if HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4256 // TODO: support I2C HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4257 // VERIFY: I2C utility commands SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4258 // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz);
whismanoid 4:d9b05924ad4c 4259 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 4260 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 4261 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 4262 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 4:d9b05924ad4c 4263 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 4264 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4265 //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope
whismanoid 4:d9b05924ad4c 4266 cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 4:d9b05924ad4c 4267 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 4:d9b05924ad4c 4268 (g_I2C_SCL_Hz / 1000.));
whismanoid 4:d9b05924ad4c 4269 cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read",
whismanoid 4:d9b05924ad4c 4270 g_I2C_deviceAddress7);
whismanoid 4:d9b05924ad4c 4271 //
whismanoid 4:d9b05924ad4c 4272 #if SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4273 // Menu ^ cmd=?) i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4274 cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data");
whismanoid 4:d9b05924ad4c 4275 // test low-level I2C i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4276 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4277 //cmdLine.serial().printf(" H) Hunt for attached I2C devices");
whismanoid 4:d9b05924ad4c 4278 cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices");
whismanoid 4:d9b05924ad4c 4279 // cmdLine.serial().printf(" s) search i2c address");
whismanoid 4:d9b05924ad4c 4280 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4281
whismanoid 4:d9b05924ad4c 4282 #if HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 4283 // TODO: support SPI HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 4284 // SPI test command S (mosiData)+
whismanoid 4:d9b05924ad4c 4285 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 4286 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 4287 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 4288 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 4289 // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 4:d9b05924ad4c 4290 // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 4:d9b05924ad4c 4291 // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 4:d9b05924ad4c 4292 // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 4:d9b05924ad4c 4293 // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 4:d9b05924ad4c 4294 // mode | POL PHA
whismanoid 4:d9b05924ad4c 4295 // -----+--------
whismanoid 4:d9b05924ad4c 4296 // 0 | 0 0
whismanoid 4:d9b05924ad4c 4297 // 1 | 0 1
whismanoid 4:d9b05924ad4c 4298 // 2 | 1 0
whismanoid 4:d9b05924ad4c 4299 // 3 | 1 1
whismanoid 4:d9b05924ad4c 4300 //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0");
whismanoid 4:d9b05924ad4c 4301 // 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 4302 cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config",
whismanoid 4:d9b05924ad4c 4303 g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.),
whismanoid 4:d9b05924ad4c 4304 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 4:d9b05924ad4c 4305 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0));
whismanoid 4:d9b05924ad4c 4306 cmdLine.serial().printf("\r\n %%SD -- SPI diagnostic messages ");
whismanoid 4:d9b05924ad4c 4307 if (g_MAX11410_device.onSPIprint) {
whismanoid 4:d9b05924ad4c 4308 cmdLine.serial().printf("hide");
whismanoid 4:d9b05924ad4c 4309 }
whismanoid 4:d9b05924ad4c 4310 else {
whismanoid 4:d9b05924ad4c 4311 cmdLine.serial().printf("show");
whismanoid 4:d9b05924ad4c 4312 }
whismanoid 4:d9b05924ad4c 4313 cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes");
whismanoid 4:d9b05924ad4c 4314 // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0
whismanoid 4:d9b05924ad4c 4315 #endif // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 4316 //
whismanoid 4:d9b05924ad4c 4317 // Application-specific commands (help text) here
whismanoid 4:d9b05924ad4c 4318 //
whismanoid 4:d9b05924ad4c 4319 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 4320 cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 4321 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 4322 //
whismanoid 4:d9b05924ad4c 4323
whismanoid 4:d9b05924ad4c 4324 //~ extern void MAX11410_menu_help(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp\n
whismanoid 4:d9b05924ad4c 4325 //~ MAX11410_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 4326 }
whismanoid 4:d9b05924ad4c 4327 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 4328
whismanoid 4:d9b05924ad4c 4329 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 15:37c83ec50ea0 4330
whismanoid 15:37c83ec50ea0 4331 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 4332 void pinsMonitor_submenu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 15:37c83ec50ea0 4333 {
whismanoid 15:37c83ec50ea0 4334 // % diagnostic commands submenu
whismanoid 15:37c83ec50ea0 4335 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 4336 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 4337 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 4338 // %A %Apin -- analog input
whismanoid 15:37c83ec50ea0 4339 // %Ppin df=xx -- pwm output
whismanoid 15:37c83ec50ea0 4340 // %Wpin -- measure high pulsewidth input in usec
whismanoid 15:37c83ec50ea0 4341 // %wpin -- measure low pulsewidth input in usec
whismanoid 15:37c83ec50ea0 4342 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 4343 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 4344 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 4345 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 4346 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 4347 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 4348 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 4349 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 4350 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 4351 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 4352 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 4353 //
whismanoid 15:37c83ec50ea0 4354 char strPinIndex[3];
whismanoid 15:37c83ec50ea0 4355 strPinIndex[0] = cmdLine[2];
whismanoid 15:37c83ec50ea0 4356 strPinIndex[1] = cmdLine[3];
whismanoid 15:37c83ec50ea0 4357 strPinIndex[2] = '\0';
whismanoid 15:37c83ec50ea0 4358 int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 15:37c83ec50ea0 4359 //cmdLine.serial().printf(" pinIndex=%d ", pinIndex);
whismanoid 15:37c83ec50ea0 4360 //
whismanoid 15:37c83ec50ea0 4361 // get next character
whismanoid 15:37c83ec50ea0 4362 switch (cmdLine[1])
whismanoid 15:37c83ec50ea0 4363 {
whismanoid 23:c6c652bef4b9 4364 //--------------------------------------------------
whismanoid 46:469d0061df5d 4365 #if defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 4366 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 4367 case 'F': case 'f':
whismanoid 46:469d0061df5d 4368 {
whismanoid 46:469d0061df5d 4369 # if HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4370 // Limit the ranges where memory write operation will be allowed
whismanoid 46:469d0061df5d 4371 // FLASH (rx) : ORIGIN = 0x00010000, LENGTH = 0x00070000
whismanoid 46:469d0061df5d 4372 //~ const uint32_t poke_flash_min = 0x00010000;
whismanoid 46:469d0061df5d 4373 //~ const uint32_t poke_flash_max = 0x0007FFFF;
whismanoid 46:469d0061df5d 4374 // RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00028000
whismanoid 46:469d0061df5d 4375 //~ const uint32_t poke_ram_min = 0x20000000;
whismanoid 46:469d0061df5d 4376 //~ const uint32_t poke_ram_max = 0x20027FFF;
whismanoid 46:469d0061df5d 4377 //
whismanoid 46:469d0061df5d 4378 // flash peek memory %F peek=0x0007ff00 len=0x0100 -- hex dump
whismanoid 46:469d0061df5d 4379 // get "len" keyword, default 1
whismanoid 46:469d0061df5d 4380 uint32_t peek_len = 1;
whismanoid 46:469d0061df5d 4381 if (cmdLine.parse_uint32_hex("len", peek_len))
whismanoid 46:469d0061df5d 4382 {
whismanoid 46:469d0061df5d 4383 }
whismanoid 46:469d0061df5d 4384 // get "peek" keyword, do peek operation if keyword is present
whismanoid 46:469d0061df5d 4385 uint32_t peek_addr = 0x00010000;
whismanoid 46:469d0061df5d 4386 if (cmdLine.parse_uint32_hex("peek", peek_addr))
whismanoid 46:469d0061df5d 4387 {
whismanoid 46:469d0061df5d 4388 // #312 hex dump memory from peek_addr length peek_len
whismanoid 46:469d0061df5d 4389 peek_addr = peek_addr &~ 0x00000003; // 32-bit word align
whismanoid 46:469d0061df5d 4390 //
whismanoid 46:469d0061df5d 4391 // scan poke_access_list[] for peek_addr
whismanoid 46:469d0061df5d 4392 int poke_access_list_index = search_poke_access_list(peek_addr);
whismanoid 46:469d0061df5d 4393 // post: poke_access_list[poke_access_list_index].addr_min is lowest address of range
whismanoid 46:469d0061df5d 4394 // post: poke_access_list[poke_access_list_index].addr_max is highest address of range
whismanoid 46:469d0061df5d 4395 // post: poke_access_list[poke_access_list_index].name
whismanoid 46:469d0061df5d 4396 // 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 4397 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 46:469d0061df5d 4398 poke_access_list_index,
whismanoid 46:469d0061df5d 4399 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 4400 poke_access_list[poke_access_list_index].addr_min,
whismanoid 46:469d0061df5d 4401 poke_access_list[poke_access_list_index].addr_max,
whismanoid 46:469d0061df5d 4402 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 46:469d0061df5d 4403 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x04)
whismanoid 46:469d0061df5d 4404 {
whismanoid 46:469d0061df5d 4405 cmdLine.serial().printf("flashPoke ");
whismanoid 46:469d0061df5d 4406 }
whismanoid 46:469d0061df5d 4407 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x02)
whismanoid 46:469d0061df5d 4408 {
whismanoid 46:469d0061df5d 4409 cmdLine.serial().printf("ramPoke ");
whismanoid 46:469d0061df5d 4410 }
whismanoid 46:469d0061df5d 4411 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x01)
whismanoid 46:469d0061df5d 4412 {
whismanoid 46:469d0061df5d 4413 cmdLine.serial().printf("read ");
whismanoid 46:469d0061df5d 4414 }
whismanoid 46:469d0061df5d 4415 //
whismanoid 46:469d0061df5d 4416 //~ cmdLine.serial().printf("\r\n0x%8.8lx: ", peek_addr);
whismanoid 46:469d0061df5d 4417 if ((peek_addr & 0x0F) != 0)
whismanoid 46:469d0061df5d 4418 {
whismanoid 46:469d0061df5d 4419 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4420 }
whismanoid 46:469d0061df5d 4421 while (peek_len > 0)
whismanoid 46:469d0061df5d 4422 {
whismanoid 46:469d0061df5d 4423 if ((peek_addr & 0x0F) == 0)
whismanoid 46:469d0061df5d 4424 {
whismanoid 46:469d0061df5d 4425 poke_access_list_index = search_poke_access_list(peek_addr);
whismanoid 46:469d0061df5d 4426 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4427 }
whismanoid 46:469d0061df5d 4428 if (poke_access_list[poke_access_list_index].can_flash_write_read & 1)
whismanoid 46:469d0061df5d 4429 {
whismanoid 46:469d0061df5d 4430 // read memory by using peek_addr as a uint32_t pointer
whismanoid 46:469d0061df5d 4431 cmdLine.serial().printf("0x%8.8lx ", *((uint32_t*)peek_addr));
whismanoid 46:469d0061df5d 4432 }
whismanoid 46:469d0061df5d 4433 else
whismanoid 46:469d0061df5d 4434 {
whismanoid 46:469d0061df5d 4435 // read operation is forbidden in this address range
whismanoid 46:469d0061df5d 4436 cmdLine.serial().printf("__________ ");
whismanoid 46:469d0061df5d 4437 }
whismanoid 46:469d0061df5d 4438 peek_addr += 4;
whismanoid 46:469d0061df5d 4439 peek_len--;
whismanoid 46:469d0061df5d 4440 }
whismanoid 46:469d0061df5d 4441 }
whismanoid 46:469d0061df5d 4442 # endif // HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4443 # if HAS_FLASH_POKE
whismanoid 46:469d0061df5d 4444 // flash poke memory %F poke=0x0007ff00 0xab 0xcd 0xef 0x27 0x18 0x28 -- erase/write flash page
whismanoid 46:469d0061df5d 4445 // get "poke" keyword, do poke operation if keyword is present
whismanoid 46:469d0061df5d 4446 uint32_t poke_addr = 0x20000000;
whismanoid 46:469d0061df5d 4447 if (cmdLine.parse_uint32_hex("poke", poke_addr))
whismanoid 46:469d0061df5d 4448 {
whismanoid 46:469d0061df5d 4449 size_t byteCount = 0;
whismanoid 46:469d0061df5d 4450 uint8_t pokeDataBuf[16];
whismanoid 46:469d0061df5d 4451 // get list of bytes after processing keywords
whismanoid 46:469d0061df5d 4452 // bool parse_byteCount_byteList_hex(size_t& byteCount, char *mosiDataBuf, size_t mosiDataBufSize);
whismanoid 46:469d0061df5d 4453 if (cmdLine.parse_byteCount_byteList_hex(byteCount, ((char *)pokeDataBuf), sizeof(pokeDataBuf)))
whismanoid 46:469d0061df5d 4454 {
whismanoid 46:469d0061df5d 4455 // #312 write memory at poke_addr
whismanoid 46:469d0061df5d 4456 poke_addr = poke_addr &~ 0x00000003; // 32-bit word align
whismanoid 46:469d0061df5d 4457 //
whismanoid 46:469d0061df5d 4458 // scan poke_access_list[] for poke_addr
whismanoid 46:469d0061df5d 4459 int poke_access_list_index = search_poke_access_list(poke_addr);
whismanoid 46:469d0061df5d 4460 // post: poke_access_list[poke_access_list_index].addr_min is lowest address of range
whismanoid 46:469d0061df5d 4461 // post: poke_access_list[poke_access_list_index].addr_max is highest address of range
whismanoid 46:469d0061df5d 4462 // post: poke_access_list[poke_access_list_index].name
whismanoid 46:469d0061df5d 4463 // 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 4464 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 46:469d0061df5d 4465 poke_access_list_index,
whismanoid 46:469d0061df5d 4466 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 4467 poke_access_list[poke_access_list_index].addr_min,
whismanoid 46:469d0061df5d 4468 poke_access_list[poke_access_list_index].addr_max,
whismanoid 46:469d0061df5d 4469 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 46:469d0061df5d 4470 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x04)
whismanoid 46:469d0061df5d 4471 {
whismanoid 46:469d0061df5d 4472 cmdLine.serial().printf("flashPoke ");
whismanoid 46:469d0061df5d 4473 }
whismanoid 46:469d0061df5d 4474 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x02)
whismanoid 46:469d0061df5d 4475 {
whismanoid 46:469d0061df5d 4476 cmdLine.serial().printf("ramPoke ");
whismanoid 46:469d0061df5d 4477 }
whismanoid 46:469d0061df5d 4478 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x01)
whismanoid 46:469d0061df5d 4479 {
whismanoid 46:469d0061df5d 4480 cmdLine.serial().printf("read ");
whismanoid 46:469d0061df5d 4481 }
whismanoid 46:469d0061df5d 4482 //
whismanoid 46:469d0061df5d 4483 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x0004)
whismanoid 46:469d0061df5d 4484 {
whismanoid 46:469d0061df5d 4485 //------------------------------
whismanoid 46:469d0061df5d 4486 // mbed interface to on-chip Flash
whismanoid 46:469d0061df5d 4487 // FlashIAP flash;
whismanoid 46:469d0061df5d 4488 // Maxim MAX32625 flash interface flc.h not .\mbed-os\drivers\FlashIAP.h
whismanoid 46:469d0061df5d 4489 // .\mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\mxc\flc.h
whismanoid 46:469d0061df5d 4490 // .\mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\mxc\flc.c
whismanoid 46:469d0061df5d 4491 //
whismanoid 46:469d0061df5d 4492 // MAX32625IWY+ Flash 512Kbyte in 64 pages of 8Kbyte per page
whismanoid 46:469d0061df5d 4493 static uint8_t pageBuf[8192];
whismanoid 46:469d0061df5d 4494 uint32_t pageBuf_addr = poke_addr &~ 0x1FFF; // 32-bit word align, 8Kbyte page boundary
whismanoid 46:469d0061df5d 4495 //
whismanoid 46:469d0061df5d 4496 // poke_addr is in FLASH address range, there's more steps
whismanoid 46:469d0061df5d 4497 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: flashPoke ...",
whismanoid 46:469d0061df5d 4498 poke_access_list[poke_access_list_index].name, poke_addr);
whismanoid 46:469d0061df5d 4499 // initialize flash memory interface
whismanoid 46:469d0061df5d 4500 // FlashIAP: FlashIAP flash; flash.init();
whismanoid 46:469d0061df5d 4501 // int FLC_Init(void);
whismanoid 46:469d0061df5d 4502 // returns E_NO_ERROR or E_BUSY or E_UNKNOWN
whismanoid 46:469d0061df5d 4503 cmdLine.serial().printf("FLC_Init ");
whismanoid 46:469d0061df5d 4504 if (FLC_Init() != E_NO_ERROR)
whismanoid 46:469d0061df5d 4505 {
whismanoid 46:469d0061df5d 4506 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4507 break; // can't perform the command
whismanoid 46:469d0061df5d 4508 }
whismanoid 46:469d0061df5d 4509 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4510 //
whismanoid 46:469d0061df5d 4511 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: start of 8KByte page containing 0x%8.8lx...",
whismanoid 46:469d0061df5d 4512 poke_access_list[poke_access_list_index].name, pageBuf_addr, poke_addr);
whismanoid 46:469d0061df5d 4513 //
whismanoid 46:469d0061df5d 4514 // page read, update buffer from command line bytes, page erase, page write
whismanoid 46:469d0061df5d 4515 cmdLine.serial().printf("\r\nPgBuf 0x%8.8lx: copy page buffer, len=0x%x words = 0x%x bytes...",
whismanoid 46:469d0061df5d 4516 pageBuf_addr, sizeof(pageBuf)/4, sizeof(pageBuf));
whismanoid 46:469d0061df5d 4517 // memcpy(uint32_t *out, uint32_t *in, unsigned int count)
whismanoid 46:469d0061df5d 4518 memcpy(&pageBuf[0], (uint32_t*)pageBuf_addr, sizeof(pageBuf));
whismanoid 46:469d0061df5d 4519 //
whismanoid 46:469d0061df5d 4520 cmdLine.serial().printf("\r\nPgBuf 0x%8.8lx: udpate page buffer ...", poke_addr);
whismanoid 46:469d0061df5d 4521 // update buffer from command line bytes using my cmdline lib
whismanoid 46:469d0061df5d 4522 // ignore pokeDataBuf[0], its 0x0F because this is command F. :(
whismanoid 46:469d0061df5d 4523 for (size_t byteIndex = 1; byteIndex < byteCount; byteIndex += 4)
whismanoid 46:469d0061df5d 4524 {
whismanoid 46:469d0061df5d 4525 // How to handle big-endian vs little-endian?
whismanoid 46:469d0061df5d 4526 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 0] = pokeDataBuf[byteIndex + 3];
whismanoid 46:469d0061df5d 4527 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 1] = pokeDataBuf[byteIndex + 2];
whismanoid 46:469d0061df5d 4528 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 2] = pokeDataBuf[byteIndex + 1];
whismanoid 46:469d0061df5d 4529 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 3] = pokeDataBuf[byteIndex + 0];
whismanoid 46:469d0061df5d 4530 // seems 0x12 0x34 0x56 0x78 becomes 0x78563412
whismanoid 46:469d0061df5d 4531 uint32_t wordbuf = 0
whismanoid 46:469d0061df5d 4532 | ((uint32_t)pokeDataBuf[byteIndex + 0] << 24)
whismanoid 46:469d0061df5d 4533 | ((uint32_t)pokeDataBuf[byteIndex + 1] << 16)
whismanoid 46:469d0061df5d 4534 | ((uint32_t)pokeDataBuf[byteIndex + 2] << 8)
whismanoid 46:469d0061df5d 4535 | ((uint32_t)pokeDataBuf[byteIndex + 3] << 0)
whismanoid 46:469d0061df5d 4536 ;
whismanoid 46:469d0061df5d 4537 cmdLine.serial().printf("\r\nPgBuf[0x%8.8lx] = FLASH 0x%8.8lx: ",
whismanoid 46:469d0061df5d 4538 (poke_addr - pageBuf_addr + byteIndex-1), (poke_addr + byteIndex-1));
whismanoid 46:469d0061df5d 4539 cmdLine.serial().printf("0x%8.8lx ", wordbuf);
whismanoid 46:469d0061df5d 4540 // poke_addr += 4;
whismanoid 46:469d0061df5d 4541 }
whismanoid 46:469d0061df5d 4542 //
whismanoid 46:469d0061df5d 4543 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: erase page ...",
whismanoid 46:469d0061df5d 4544 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 4545 // page erase using flash.erase(addr, flash.get_sector_size(addr));
whismanoid 46:469d0061df5d 4546 // int FLC_PageErase(uint32_t address, MXC_V_FLC_ERASE_CODE_PAGE_ERASE, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 4547 // @param address Address of the page to be erased.
whismanoid 46:469d0061df5d 4548 // @param erase_code Flash erase code; defined as
whismanoid 46:469d0061df5d 4549 // #MXC_V_FLC_ERASE_CODE_PAGE_ERASE for page erase
whismanoid 46:469d0061df5d 4550 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 4551 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 4552 if (FLC_PageErase(pageBuf_addr, MXC_V_FLC_ERASE_CODE_PAGE_ERASE,
whismanoid 46:469d0061df5d 4553 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 4554 {
whismanoid 46:469d0061df5d 4555 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4556 break; // can't perform the command
whismanoid 46:469d0061df5d 4557 }
whismanoid 46:469d0061df5d 4558 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4559 //
whismanoid 46:469d0061df5d 4560 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: write page buffer ...",
whismanoid 46:469d0061df5d 4561 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 4562 // page write using flash.program(page_buffer, addr, page_size);
whismanoid 46:469d0061df5d 4563 // int FLC_Write(uint32_t address, const void *data, uint32_t length, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 4564 // @param address Start address for desired write. @note This address
whismanoid 46:469d0061df5d 4565 // must be 32-bit word aligned
whismanoid 46:469d0061df5d 4566 // @param data A pointer to the buffer containing the data to write.
whismanoid 46:469d0061df5d 4567 // @param length Size of the data to write in bytes. @note The length
whismanoid 46:469d0061df5d 4568 // must be in 32-bit multiples.
whismanoid 46:469d0061df5d 4569 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 4570 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 4571 if (FLC_Write(pageBuf_addr, (uint32_t*)&pageBuf[0], sizeof(pageBuf),
whismanoid 46:469d0061df5d 4572 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 4573 {
whismanoid 46:469d0061df5d 4574 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4575 break; // can't perform the command
whismanoid 46:469d0061df5d 4576 }
whismanoid 46:469d0061df5d 4577 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4578 //
whismanoid 46:469d0061df5d 4579 // FlashIAP: close flash memory interface flash.deinit();
whismanoid 46:469d0061df5d 4580 //
whismanoid 46:469d0061df5d 4581 // verify buffer matches flash page, or fail
whismanoid 46:469d0061df5d 4582 // for verification, perform %F peek=(poke_addr) len=(from byteCount)
whismanoid 46:469d0061df5d 4583 // hex dump memory from peek_addr length peek_len
whismanoid 46:469d0061df5d 4584 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: verify page buffer ...",
whismanoid 46:469d0061df5d 4585 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 4586 int verify_failed = 0;
whismanoid 46:469d0061df5d 4587 peek_addr = poke_addr;
whismanoid 46:469d0061df5d 4588 peek_len = (byteCount - 1)/4;
whismanoid 46:469d0061df5d 4589 //~ cmdLine.serial().printf("\r\n0x%8.8lx: ", peek_addr);
whismanoid 46:469d0061df5d 4590 if ((peek_addr & 0x0F) != 0)
whismanoid 46:469d0061df5d 4591 {
whismanoid 46:469d0061df5d 4592 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4593 }
whismanoid 46:469d0061df5d 4594 while (peek_len > 0)
whismanoid 46:469d0061df5d 4595 {
whismanoid 46:469d0061df5d 4596 if ((peek_addr & 0x0F) == 0)
whismanoid 46:469d0061df5d 4597 {
whismanoid 46:469d0061df5d 4598 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4599 }
whismanoid 46:469d0061df5d 4600 // read memory by using peek_addr as a uint32_t pointer
whismanoid 46:469d0061df5d 4601 // cmdLine.serial().printf("0x%8.8lx ", *((uint32_t*)peek_addr));
whismanoid 46:469d0061df5d 4602 // #312 %F peek verify, report fail if mismatch page buffer
whismanoid 46:469d0061df5d 4603 uint32_t expect_data = 0
whismanoid 46:469d0061df5d 4604 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 3] << 24)
whismanoid 46:469d0061df5d 4605 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 2] << 16)
whismanoid 46:469d0061df5d 4606 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 1] << 8)
whismanoid 46:469d0061df5d 4607 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 0] << 0)
whismanoid 46:469d0061df5d 4608 ;
whismanoid 46:469d0061df5d 4609 uint32_t actual_data = *((uint32_t*)peek_addr);
whismanoid 46:469d0061df5d 4610 if (actual_data == expect_data)
whismanoid 46:469d0061df5d 4611 {
whismanoid 46:469d0061df5d 4612 // this word matches
whismanoid 46:469d0061df5d 4613 cmdLine.serial().printf("=0x%8.8lx ", actual_data);
whismanoid 46:469d0061df5d 4614 }
whismanoid 46:469d0061df5d 4615 else
whismanoid 46:469d0061df5d 4616 {
whismanoid 46:469d0061df5d 4617 // mismatch, verification failed
whismanoid 46:469d0061df5d 4618 cmdLine.serial().printf("#0x%8.8lx(expected 0x%8.8lx)\r\n%5s 0x%8.8lx: ",
whismanoid 46:469d0061df5d 4619 actual_data, expect_data,
whismanoid 46:469d0061df5d 4620 poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4621 verify_failed++;
whismanoid 46:469d0061df5d 4622 }
whismanoid 46:469d0061df5d 4623 //
whismanoid 46:469d0061df5d 4624 peek_addr += 4;
whismanoid 46:469d0061df5d 4625 peek_len--;
whismanoid 46:469d0061df5d 4626 }
whismanoid 46:469d0061df5d 4627 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: verify page buffer ",
whismanoid 46:469d0061df5d 4628 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 4629 if (verify_failed)
whismanoid 46:469d0061df5d 4630 {
whismanoid 46:469d0061df5d 4631 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4632 break; // can't perform the command
whismanoid 46:469d0061df5d 4633 }
whismanoid 46:469d0061df5d 4634 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4635 //
whismanoid 46:469d0061df5d 4636 } // end of flashPoke operation
whismanoid 46:469d0061df5d 4637 else if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x0002)
whismanoid 46:469d0061df5d 4638 {
whismanoid 46:469d0061df5d 4639 // poke_addr is in RAM address range, write directly
whismanoid 46:469d0061df5d 4640 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ramPoke ", poke_access_list[poke_access_list_index].name, poke_addr);
whismanoid 46:469d0061df5d 4641 // ignore pokeDataBuf[0], its 0x0F because this is command F. :(
whismanoid 46:469d0061df5d 4642 for (size_t byteIndex = 1; byteIndex < byteCount; byteIndex += 4)
whismanoid 46:469d0061df5d 4643 {
whismanoid 46:469d0061df5d 4644 // How to handle big-endian vs little-endian?
whismanoid 46:469d0061df5d 4645 // seems 0x12 0x34 0x56 0x78 becomes 0x78563412
whismanoid 46:469d0061df5d 4646 poke_addr += 4;
whismanoid 46:469d0061df5d 4647 uint32_t wordbuf = 0
whismanoid 46:469d0061df5d 4648 | ((uint32_t)pokeDataBuf[byteIndex + 0] << 24)
whismanoid 46:469d0061df5d 4649 | ((uint32_t)pokeDataBuf[byteIndex + 1] << 16)
whismanoid 46:469d0061df5d 4650 | ((uint32_t)pokeDataBuf[byteIndex + 2] << 8)
whismanoid 46:469d0061df5d 4651 | ((uint32_t)pokeDataBuf[byteIndex + 3] << 0)
whismanoid 46:469d0061df5d 4652 ;
whismanoid 46:469d0061df5d 4653 cmdLine.serial().printf("0x%8.8lx ", wordbuf);
whismanoid 46:469d0061df5d 4654 //
whismanoid 46:469d0061df5d 4655 // write RAM by using poke_addr as a uint32_t pointer
whismanoid 46:469d0061df5d 4656 *((uint32_t*)poke_addr) = wordbuf;
whismanoid 46:469d0061df5d 4657 //
whismanoid 46:469d0061df5d 4658 // verify?
whismanoid 46:469d0061df5d 4659 if (*((uint32_t*)poke_addr) == wordbuf)
whismanoid 46:469d0061df5d 4660 {
whismanoid 46:469d0061df5d 4661 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4662 }
whismanoid 46:469d0061df5d 4663 else
whismanoid 46:469d0061df5d 4664 {
whismanoid 46:469d0061df5d 4665 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4666 }
whismanoid 46:469d0061df5d 4667 }
whismanoid 46:469d0061df5d 4668 } // end of ramPoke operation
whismanoid 46:469d0061df5d 4669 else
whismanoid 46:469d0061df5d 4670 {
whismanoid 46:469d0061df5d 4671 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 4672 }
whismanoid 46:469d0061df5d 4673 }
whismanoid 46:469d0061df5d 4674 }
whismanoid 46:469d0061df5d 4675 # endif // HAS_FLASH_POKE
whismanoid 46:469d0061df5d 4676 # if HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 4677 uint32_t save_arg = 0;
whismanoid 46:469d0061df5d 4678 if (cmdLine.parse_uint32_hex("save", save_arg))
whismanoid 46:469d0061df5d 4679 {
whismanoid 46:469d0061df5d 4680 Save_flash_page_configuration_back_up(cmdLine, save_arg);
whismanoid 46:469d0061df5d 4681 }
whismanoid 46:469d0061df5d 4682 uint32_t load_arg = 0;
whismanoid 46:469d0061df5d 4683 if (cmdLine.parse_uint32_hex("load", load_arg))
whismanoid 46:469d0061df5d 4684 {
whismanoid 46:469d0061df5d 4685 Load_flash_page_configuration_back_up(cmdLine, load_arg);
whismanoid 46:469d0061df5d 4686 }
whismanoid 46:469d0061df5d 4687 # endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 4688 }
whismanoid 46:469d0061df5d 4689 break;
whismanoid 46:469d0061df5d 4690 #endif // defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 4691 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 4692 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 4693 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 4694 case 'B': case 'b':
whismanoid 23:c6c652bef4b9 4695 {
whismanoid 24:032f3683cb2a 4696 int command_table_button_index = 1;
whismanoid 23:c6c652bef4b9 4697 // %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 4698 // future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 4699 // future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 4700 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 4701 // cmdLine[2] == '1' selects onButton1_command_table
whismanoid 23:c6c652bef4b9 4702 char** command_table = onButton1_command_table;
whismanoid 23:c6c652bef4b9 4703 #endif
whismanoid 24:032f3683cb2a 4704 switch(cmdLine[2])
whismanoid 24:032f3683cb2a 4705 {
whismanoid 24:032f3683cb2a 4706 default:
whismanoid 24:032f3683cb2a 4707 case '1': case 'A': case 'a': case '!':
whismanoid 24:032f3683cb2a 4708 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4709 command_table_button_index = 1;
whismanoid 24:032f3683cb2a 4710 command_table = onButton1_command_table;
whismanoid 24:032f3683cb2a 4711 #endif
whismanoid 24:032f3683cb2a 4712 break;
whismanoid 24:032f3683cb2a 4713 case '2': case 'B': case 'b': case '@':
whismanoid 23:c6c652bef4b9 4714 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4715 command_table_button_index = 2;
whismanoid 24:032f3683cb2a 4716 command_table = onButton2_command_table;
whismanoid 24:032f3683cb2a 4717 #endif
whismanoid 24:032f3683cb2a 4718 break;
whismanoid 24:032f3683cb2a 4719 case '3': case 'C': case 'c': case '#':
whismanoid 23:c6c652bef4b9 4720 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4721 command_table_button_index = 3;
whismanoid 24:032f3683cb2a 4722 command_table = onButton3_command_table;
whismanoid 24:032f3683cb2a 4723 #endif
whismanoid 24:032f3683cb2a 4724 break;
whismanoid 29:6a9edb6e973b 4725 case '4':
whismanoid 29:6a9edb6e973b 4726 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4727 command_table_button_index = 4;
whismanoid 29:6a9edb6e973b 4728 command_table = onButton4_command_table;
whismanoid 29:6a9edb6e973b 4729 #endif
whismanoid 29:6a9edb6e973b 4730 break;
whismanoid 29:6a9edb6e973b 4731 case '5':
whismanoid 29:6a9edb6e973b 4732 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4733 command_table_button_index = 5;
whismanoid 29:6a9edb6e973b 4734 command_table = onButton5_command_table;
whismanoid 29:6a9edb6e973b 4735 #endif
whismanoid 29:6a9edb6e973b 4736 break;
whismanoid 29:6a9edb6e973b 4737 case '6':
whismanoid 29:6a9edb6e973b 4738 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4739 command_table_button_index = 6;
whismanoid 29:6a9edb6e973b 4740 command_table = onButton6_command_table;
whismanoid 29:6a9edb6e973b 4741 #endif
whismanoid 29:6a9edb6e973b 4742 break;
whismanoid 29:6a9edb6e973b 4743 case '7':
whismanoid 29:6a9edb6e973b 4744 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4745 command_table_button_index = 7;
whismanoid 29:6a9edb6e973b 4746 command_table = onButton7_command_table;
whismanoid 29:6a9edb6e973b 4747 #endif
whismanoid 29:6a9edb6e973b 4748 break;
whismanoid 29:6a9edb6e973b 4749 case '8':
whismanoid 29:6a9edb6e973b 4750 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4751 command_table_button_index = 8;
whismanoid 29:6a9edb6e973b 4752 command_table = onButton8_command_table;
whismanoid 29:6a9edb6e973b 4753 #endif
whismanoid 29:6a9edb6e973b 4754 break;
whismanoid 29:6a9edb6e973b 4755 case '9':
whismanoid 29:6a9edb6e973b 4756 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4757 command_table_button_index = 9;
whismanoid 29:6a9edb6e973b 4758 command_table = onButton9_command_table;
whismanoid 29:6a9edb6e973b 4759 #endif
whismanoid 29:6a9edb6e973b 4760 break;
whismanoid 24:032f3683cb2a 4761 }
whismanoid 24:032f3683cb2a 4762 //
whismanoid 23:c6c652bef4b9 4763 switch(cmdLine[3])
whismanoid 23:c6c652bef4b9 4764 {
whismanoid 23:c6c652bef4b9 4765 case '@':
whismanoid 23:c6c652bef4b9 4766 {
whismanoid 23:c6c652bef4b9 4767 // %B1@ view/edit command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 4768 int editRowIndex = 0;
whismanoid 23:c6c652bef4b9 4769 int command_table_row_count = 0;
whismanoid 23:c6c652bef4b9 4770 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 4771 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 4772 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 4773 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 4774 }
whismanoid 24:032f3683cb2a 4775 //
whismanoid 24:032f3683cb2a 4776 // ignore extra spaces before the command
whismanoid 24:032f3683cb2a 4777 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 24:032f3683cb2a 4778 int argIndex;
whismanoid 24:032f3683cb2a 4779 for (argIndex = 5; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 4780 {
whismanoid 24:032f3683cb2a 4781 if (cmdLine[argIndex] == ' ') break;
whismanoid 24:032f3683cb2a 4782 }
whismanoid 24:032f3683cb2a 4783 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 4784 {
whismanoid 24:032f3683cb2a 4785 if (cmdLine[argIndex] != ' ') break;
whismanoid 23:c6c652bef4b9 4786 }
whismanoid 23:c6c652bef4b9 4787 //
whismanoid 23:c6c652bef4b9 4788 // Edit the contents of command_table
whismanoid 23:c6c652bef4b9 4789 switch (cmdLine[4]) // %B1@... -- Edit the contents of command_table
whismanoid 23:c6c652bef4b9 4790 {
whismanoid 23:c6c652bef4b9 4791 case '0': case '1': case '2': case '3': case '4':
whismanoid 23:c6c652bef4b9 4792 case '5': case '6': case '7': case '8': case '9':
whismanoid 24:032f3683cb2a 4793 // %B1@nnn command replace row number nnn
whismanoid 23:c6c652bef4b9 4794 // edit row data
whismanoid 33:70a28cfe9e01 4795 // get row number to edit from cmdLine[4]
whismanoid 33:70a28cfe9e01 4796 editRowIndex = atoi(cmdLine.str()+4);
whismanoid 23:c6c652bef4b9 4797 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4798 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 4799 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 28:a9a3a9db592b 4800 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 4801 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 4802 cmdLine.serial().printf("\r\n cannot replace row %d with nothing",
whismanoid 28:a9a3a9db592b 4803 editRowIndex);
whismanoid 28:a9a3a9db592b 4804 }
whismanoid 28:a9a3a9db592b 4805 else
whismanoid 28:a9a3a9db592b 4806 {
whismanoid 28:a9a3a9db592b 4807 // update row
whismanoid 28:a9a3a9db592b 4808 cmdLine.serial().printf("\r\n replace row %d with \"%s\"",
whismanoid 28:a9a3a9db592b 4809 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 4810 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4811 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 4812 }
whismanoid 24:032f3683cb2a 4813 }
whismanoid 33:70a28cfe9e01 4814 } // end if (command_table_row_count > 0)
whismanoid 33:70a28cfe9e01 4815 if ((editRowIndex == command_table_row_count) && (command_table_row_count < COMMAND_TABLE_ROW_MAX)) {
whismanoid 33:70a28cfe9e01 4816 // %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 4817 //
whismanoid 33:70a28cfe9e01 4818 command_table_row_count++;
whismanoid 33:70a28cfe9e01 4819 cmdLine.serial().printf("\r\n add next row %d containing \"%s\"",
whismanoid 33:70a28cfe9e01 4820 editRowIndex, cmdLine.str()+argIndex);
whismanoid 33:70a28cfe9e01 4821 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 33:70a28cfe9e01 4822 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 33:70a28cfe9e01 4823 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 33:70a28cfe9e01 4824 //
whismanoid 23:c6c652bef4b9 4825 }
whismanoid 33:70a28cfe9e01 4826 //
whismanoid 23:c6c652bef4b9 4827 break;
whismanoid 23:c6c652bef4b9 4828 case '+':
whismanoid 24:032f3683cb2a 4829 // %B1@+ command add new row (if there is room to add)
whismanoid 23:c6c652bef4b9 4830 // add a new row at end of table
whismanoid 23:c6c652bef4b9 4831 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 4832 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 23:c6c652bef4b9 4833 editRowIndex = command_table_row_count;
whismanoid 28:a9a3a9db592b 4834 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 4835 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 4836 cmdLine.serial().printf("\r\n cannot add new row %d containing nothing",
whismanoid 28:a9a3a9db592b 4837 editRowIndex);
whismanoid 28:a9a3a9db592b 4838 }
whismanoid 28:a9a3a9db592b 4839 else
whismanoid 28:a9a3a9db592b 4840 {
whismanoid 28:a9a3a9db592b 4841 command_table_row_count++;
whismanoid 28:a9a3a9db592b 4842 cmdLine.serial().printf("\r\n add new row %d containing \"%s\"",
whismanoid 28:a9a3a9db592b 4843 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 4844 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4845 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 4846 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 28:a9a3a9db592b 4847 }
whismanoid 23:c6c652bef4b9 4848 }
whismanoid 23:c6c652bef4b9 4849 break;
whismanoid 23:c6c652bef4b9 4850 case '-':
whismanoid 24:032f3683cb2a 4851 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 4852 // delete row from table
whismanoid 23:c6c652bef4b9 4853 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4854 // if command_table_row_count == 0 then the table is empty
whismanoid 23:c6c652bef4b9 4855 if ((cmdLine[5] == '~') && (cmdLine[6] == '~') && (cmdLine[7] == '~')) {
whismanoid 23:c6c652bef4b9 4856 // %B1@-~~~ clear entire command table
whismanoid 24:032f3683cb2a 4857 cmdLine.serial().printf("\r\n clear entire command table");
whismanoid 23:c6c652bef4b9 4858 command_table_row_count = 0;
whismanoid 28:a9a3a9db592b 4859 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 23:c6c652bef4b9 4860 break;
whismanoid 23:c6c652bef4b9 4861 }
whismanoid 24:032f3683cb2a 4862 else
whismanoid 23:c6c652bef4b9 4863 {
whismanoid 24:032f3683cb2a 4864 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 24:032f3683cb2a 4865 editRowIndex = atoi(cmdLine.str()+5);
whismanoid 24:032f3683cb2a 4866 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 24:032f3683cb2a 4867 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 24:032f3683cb2a 4868 // delete row editRowIndex from Datalogger_action_table
whismanoid 24:032f3683cb2a 4869 for (int i = editRowIndex; i < (command_table_row_count-1); i++)
whismanoid 24:032f3683cb2a 4870 {
whismanoid 24:032f3683cb2a 4871 // copy row i+1 into row i
whismanoid 24:032f3683cb2a 4872 cmdLine.serial().printf("\r\n copy row %d into row %d: \"%s\"",
whismanoid 24:032f3683cb2a 4873 i+1, i, command_table[i+1]);
whismanoid 24:032f3683cb2a 4874 strncpy(command_table[i], command_table[i+1], COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4875 command_table[i][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 24:032f3683cb2a 4876 }
whismanoid 24:032f3683cb2a 4877 command_table_row_count--;
whismanoid 28:a9a3a9db592b 4878 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 24:032f3683cb2a 4879 }
whismanoid 23:c6c652bef4b9 4880 }
whismanoid 23:c6c652bef4b9 4881 }
whismanoid 23:c6c652bef4b9 4882 break;
whismanoid 30:07197a430869 4883 case '.': // something other than ! because %B1! means trigger event
whismanoid 30:07197a430869 4884 // pause the button event
whismanoid 30:07197a430869 4885 // TODO: %B1@. disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 4886 //~ Datalogger_action_table_enabled = false;
whismanoid 23:c6c652bef4b9 4887 break;
whismanoid 23:c6c652bef4b9 4888 case '@':
whismanoid 30:07197a430869 4889 // enable the button event
whismanoid 23:c6c652bef4b9 4890 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 4891 //~ Datalogger_action_table_enabled = true;
whismanoid 23:c6c652bef4b9 4892 break;
whismanoid 23:c6c652bef4b9 4893 }
whismanoid 23:c6c652bef4b9 4894 //
whismanoid 23:c6c652bef4b9 4895 // Print the contents of command_table
whismanoid 23:c6c652bef4b9 4896 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 4897 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 4898 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 4899 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 4900 cmdLine.serial().printf("\r\n %%B%1d@%d %s",
whismanoid 24:032f3683cb2a 4901 command_table_button_index,
whismanoid 24:032f3683cb2a 4902 lineIndex,
whismanoid 24:032f3683cb2a 4903 command_table[lineIndex]);
whismanoid 23:c6c652bef4b9 4904 }
whismanoid 30:07197a430869 4905 //~ cmdLine.serial().printf("\r\n command_table_row_count = %d/%d",
whismanoid 30:07197a430869 4906 //~ command_table_row_count, COMMAND_TABLE_ROW_MAX);
whismanoid 30:07197a430869 4907 cmdLine.serial().printf("\r\n\r\nEdit Button%d event (used %d/%d, %d free):",
whismanoid 30:07197a430869 4908 command_table_button_index,
whismanoid 30:07197a430869 4909 command_table_row_count,
whismanoid 30:07197a430869 4910 COMMAND_TABLE_ROW_MAX,
whismanoid 30:07197a430869 4911 (COMMAND_TABLE_ROW_MAX - command_table_row_count)
whismanoid 30:07197a430869 4912 );
whismanoid 23:c6c652bef4b9 4913 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 4914 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 24:032f3683cb2a 4915 cmdLine.serial().printf("\r\n %%B%1d@+ command -- add new row %d at end of table",
whismanoid 24:032f3683cb2a 4916 command_table_button_index,
whismanoid 24:032f3683cb2a 4917 command_table_row_count);
whismanoid 23:c6c652bef4b9 4918 }
whismanoid 23:c6c652bef4b9 4919 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4920 // if command_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 4921 cmdLine.serial().printf("\r\n %%B%1d@%d command -- replace row %d",
whismanoid 24:032f3683cb2a 4922 command_table_button_index,
whismanoid 23:c6c652bef4b9 4923 command_table_row_count-1,
whismanoid 23:c6c652bef4b9 4924 command_table_row_count-1);
whismanoid 24:032f3683cb2a 4925 cmdLine.serial().printf("\r\n %%B%1d@-%d -- delete row %d",
whismanoid 24:032f3683cb2a 4926 command_table_button_index,
whismanoid 24:032f3683cb2a 4927 command_table_row_count-1,
whismanoid 24:032f3683cb2a 4928 command_table_row_count-1);
whismanoid 24:032f3683cb2a 4929 cmdLine.serial().printf("\r\n %%B%1d@-~~~ -- delete all rows",
whismanoid 24:032f3683cb2a 4930 command_table_button_index);
whismanoid 30:07197a430869 4931 //~ cmdLine.serial().printf("\r\n %%B%1d@. -- pause entire command table",
whismanoid 30:07197a430869 4932 //~ command_table_button_index);
whismanoid 30:07197a430869 4933 //~ cmdLine.serial().printf("\r\n %%B%1d@@ -- enable command table",
whismanoid 30:07197a430869 4934 //~ command_table_button_index);
whismanoid 30:07197a430869 4935 cmdLine.serial().printf("\r\n %%B%1d! -- trigger Button%d event",
whismanoid 30:07197a430869 4936 command_table_button_index,
whismanoid 24:032f3683cb2a 4937 command_table_button_index);
whismanoid 23:c6c652bef4b9 4938 }
whismanoid 23:c6c652bef4b9 4939 //
whismanoid 23:c6c652bef4b9 4940 } // case '@' -- %B1@ view/edit command table
whismanoid 23:c6c652bef4b9 4941 break;
whismanoid 23:c6c652bef4b9 4942 case '!':
whismanoid 23:c6c652bef4b9 4943 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 23:c6c652bef4b9 4944 Run_command_table(command_table);
whismanoid 23:c6c652bef4b9 4945 break;
whismanoid 23:c6c652bef4b9 4946 }
whismanoid 23:c6c652bef4b9 4947 }
whismanoid 23:c6c652bef4b9 4948 break;
whismanoid 23:c6c652bef4b9 4949 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4950 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 4951 #if HAS_digitalInOuts
whismanoid 15:37c83ec50ea0 4952 case 'H': case 'h':
whismanoid 15:37c83ec50ea0 4953 {
whismanoid 15:37c83ec50ea0 4954 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 4955 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4956 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4957 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4958 #else
whismanoid 15:37c83ec50ea0 4959 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4960 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 4961 digitalInOutPin.write(1);
whismanoid 15:37c83ec50ea0 4962 #endif
whismanoid 15:37c83ec50ea0 4963 cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex);
whismanoid 15:37c83ec50ea0 4964 }
whismanoid 15:37c83ec50ea0 4965 break;
whismanoid 15:37c83ec50ea0 4966 case 'L': case 'l':
whismanoid 15:37c83ec50ea0 4967 {
whismanoid 15:37c83ec50ea0 4968 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 4969 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4970 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4971 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4972 #else
whismanoid 15:37c83ec50ea0 4973 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4974 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 4975 digitalInOutPin.write(0);
whismanoid 15:37c83ec50ea0 4976 #endif
whismanoid 15:37c83ec50ea0 4977 cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex);
whismanoid 15:37c83ec50ea0 4978 }
whismanoid 15:37c83ec50ea0 4979 break;
whismanoid 15:37c83ec50ea0 4980 case '?':
whismanoid 15:37c83ec50ea0 4981 {
whismanoid 15:37c83ec50ea0 4982 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 4983 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4984 pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4985 #else
whismanoid 15:37c83ec50ea0 4986 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4987 digitalInOutPin.input();
whismanoid 15:37c83ec50ea0 4988 #endif
whismanoid 15:37c83ec50ea0 4989 serial.printf(" digitalInOutPin %d Input ", pinIndex);
whismanoid 15:37c83ec50ea0 4990 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4991 int value = digitalRead(pinIndex);
whismanoid 15:37c83ec50ea0 4992 #else
whismanoid 15:37c83ec50ea0 4993 int value = digitalInOutPin.read();
whismanoid 15:37c83ec50ea0 4994 #endif
whismanoid 15:37c83ec50ea0 4995 cmdLine.serial().printf("%d ", value);
whismanoid 15:37c83ec50ea0 4996 }
whismanoid 15:37c83ec50ea0 4997 break;
whismanoid 15:37c83ec50ea0 4998 #endif
whismanoid 15:37c83ec50ea0 4999 //
whismanoid 15:37c83ec50ea0 5000 #if HAS_analogIns
whismanoid 15:37c83ec50ea0 5001 case 'A': case 'a':
whismanoid 15:37c83ec50ea0 5002 {
whismanoid 15:37c83ec50ea0 5003 // %A %Apin -- analog input
whismanoid 37:3f369235e5bc 5004 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5005 // %A avg= -- set Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 5006 if (cmdLine.parse_int_dec("avg", Platform_AIN_Average_N))
whismanoid 37:3f369235e5bc 5007 {
whismanoid 37:3f369235e5bc 5008 // Platform_AIN_Average_N was updated
whismanoid 37:3f369235e5bc 5009 }
whismanoid 37:3f369235e5bc 5010 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5011 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5012 // %A cal? view/export raw calibration values for all channels
whismanoid 34:a1993a1ee904 5013 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5014 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5015 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5016 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5017 {
whismanoid 34:a1993a1ee904 5018 char valueBuf[16];
whismanoid 34:a1993a1ee904 5019 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 5020 if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 5021 {
whismanoid 34:a1993a1ee904 5022 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5023 {
whismanoid 34:a1993a1ee904 5024 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 5025 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 5026 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 5027 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 5028 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 5029 );
whismanoid 34:a1993a1ee904 5030 }
whismanoid 34:a1993a1ee904 5031 //
whismanoid 34:a1993a1ee904 5032 // print extended help for %A
whismanoid 34:a1993a1ee904 5033 // %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 5034 //~ cmdLine.serial().printf("\r\n %%A cal0n=0.02 cal0v=0.123 cal0n=0.938 cal0v=1.132 -- update calibration");
whismanoid 34:a1993a1ee904 5035 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 5036 cmdLine.serial().printf(" %%A cal0test=0.5 -- calculate voltage at 50%% of full scale");
whismanoid 34:a1993a1ee904 5037 cmdLine.serial().printf("\r\n %%A v0cal=1.000V -- calibrate channel against a known input voltage");
whismanoid 34:a1993a1ee904 5038 // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 5039 // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 5040 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 5041 cmdLine.serial().printf("\r\n %%A calreset -- reset all calibration data");
whismanoid 37:3f369235e5bc 5042 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5043 // %A avg=%d -- help string display Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 5044 cmdLine.serial().printf("\r\n %%A avg=%d -- average", Platform_AIN_Average_N);
whismanoid 37:3f369235e5bc 5045 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5046 cmdLine.serial().printf("\r\n\r\n");
whismanoid 34:a1993a1ee904 5047 //
whismanoid 34:a1993a1ee904 5048 } // end if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 5049 }
whismanoid 34:a1993a1ee904 5050 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5051 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5052 {
whismanoid 34:a1993a1ee904 5053 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 5054 char valueBuf[16];
whismanoid 34:a1993a1ee904 5055 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 5056 if (cmdLine.parse_and_remove_key("calreset", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 5057 {
whismanoid 34:a1993a1ee904 5058 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 5059 calibration_05_normValue_0_1[0] = 0.25; calibration_05_V[0] = 0.3;
whismanoid 34:a1993a1ee904 5060 calibration_05_normValue_0_1[1] = 0.25; calibration_05_V[1] = 0.3;
whismanoid 34:a1993a1ee904 5061 calibration_05_normValue_0_1[2] = 0.25; calibration_05_V[2] = 0.3;
whismanoid 34:a1993a1ee904 5062 calibration_05_normValue_0_1[3] = 0.25; calibration_05_V[3] = 0.3;
whismanoid 34:a1993a1ee904 5063 calibration_05_normValue_0_1[4] = 0.25; calibration_05_V[4] = 1.5;
whismanoid 34:a1993a1ee904 5064 calibration_05_normValue_0_1[5] = 0.25; calibration_05_V[5] = 1.5;
whismanoid 34:a1993a1ee904 5065 //
whismanoid 34:a1993a1ee904 5066 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 5067 calibration_95_normValue_0_1[0] = 0.75; calibration_95_V[0] = 0.9;
whismanoid 34:a1993a1ee904 5068 calibration_95_normValue_0_1[1] = 0.75; calibration_95_V[1] = 0.9;
whismanoid 34:a1993a1ee904 5069 calibration_95_normValue_0_1[2] = 0.75; calibration_95_V[2] = 0.9;
whismanoid 34:a1993a1ee904 5070 calibration_95_normValue_0_1[3] = 0.75; calibration_95_V[3] = 0.9;
whismanoid 34:a1993a1ee904 5071 calibration_95_normValue_0_1[4] = 0.75; calibration_95_V[4] = 4.5;
whismanoid 34:a1993a1ee904 5072 calibration_95_normValue_0_1[5] = 0.75; calibration_95_V[5] = 4.5;
whismanoid 34:a1993a1ee904 5073 //
whismanoid 34:a1993a1ee904 5074 }
whismanoid 34:a1993a1ee904 5075 }
whismanoid 34:a1993a1ee904 5076 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5077 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5078 // %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 5079 // %A cal4n=0.135874882 cal4v=0.800000012V cal4n=0.286168128 cal4v=1.700000048V
whismanoid 34:a1993a1ee904 5080 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5081 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5082 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5083 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5084 {
whismanoid 34:a1993a1ee904 5085 double normValue_0_1, V;
whismanoid 34:a1993a1ee904 5086 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5087 {
whismanoid 34:a1993a1ee904 5088 static char key_can0n[8] = "cal0n__";
whismanoid 34:a1993a1ee904 5089 sprintf(key_can0n, "cal%1dn", ch);
whismanoid 34:a1993a1ee904 5090 static char key_cal0v[8] = "cal0v__";
whismanoid 34:a1993a1ee904 5091 sprintf(key_cal0v, "cal%1dv", ch);
whismanoid 35:c9549b5c01de 5092 // first point could be the 5% point or the 95% point
whismanoid 35:c9549b5c01de 5093 double norm_threshold = (calibration_05_normValue_0_1[ch] + calibration_95_normValue_0_1[ch]) / 2.0;
whismanoid 35:c9549b5c01de 5094 bool updated_05 = false;
whismanoid 35:c9549b5c01de 5095 //~ bool updated_95 = false;
whismanoid 35:c9549b5c01de 5096 if (cmdLine.parse_double(key_can0n, normValue_0_1)) {
whismanoid 34:a1993a1ee904 5097 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 34:a1993a1ee904 5098 {
whismanoid 35:c9549b5c01de 5099 if (normValue_0_1 < norm_threshold) {
whismanoid 35:c9549b5c01de 5100 // store first calibration point in the 5% slot
whismanoid 35:c9549b5c01de 5101 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 5102 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 5103 updated_05 = true;
whismanoid 34:a1993a1ee904 5104 }
whismanoid 34:a1993a1ee904 5105 else {
whismanoid 35:c9549b5c01de 5106 // store first calibration point in the 95% slot
whismanoid 35:c9549b5c01de 5107 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 5108 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 5109 //~ updated_95 = true;
whismanoid 34:a1993a1ee904 5110 }
whismanoid 34:a1993a1ee904 5111 }
whismanoid 35:c9549b5c01de 5112 }
whismanoid 35:c9549b5c01de 5113 // handle the optional second calibration point
whismanoid 35:c9549b5c01de 5114 if (cmdLine.parse_double(key_can0n, normValue_0_1))
whismanoid 35:c9549b5c01de 5115 {
whismanoid 35:c9549b5c01de 5116 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 35:c9549b5c01de 5117 {
whismanoid 35:c9549b5c01de 5118 if (updated_05) {
whismanoid 35:c9549b5c01de 5119 // we already stored the first point here
whismanoid 35:c9549b5c01de 5120 // calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5121 // calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 5122 // store the second point in the other slot
whismanoid 35:c9549b5c01de 5123 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5124 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 5125 }
whismanoid 35:c9549b5c01de 5126 else {
whismanoid 35:c9549b5c01de 5127 // we already stored the first point here
whismanoid 35:c9549b5c01de 5128 // calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5129 // calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 5130 // store the second point in the other slot
whismanoid 35:c9549b5c01de 5131 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5132 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 5133 }
whismanoid 35:c9549b5c01de 5134 }
whismanoid 35:c9549b5c01de 5135 }
whismanoid 38:fda80a0020d1 5136 // make sure calibration_05_normValue_0_1[ch] < calibration_95_normValue_0_1[ch]
whismanoid 38:fda80a0020d1 5137 if (calibration_05_normValue_0_1[ch] > calibration_95_normValue_0_1[ch])
whismanoid 38:fda80a0020d1 5138 {
whismanoid 38:fda80a0020d1 5139 // swap to make sure calibration_05_normValue_0_1[ch] < calibration_95_normValue_0_1[ch]
whismanoid 38:fda80a0020d1 5140 double n05 = calibration_95_normValue_0_1[ch];
whismanoid 38:fda80a0020d1 5141 double V05 = calibration_95_V[ch];
whismanoid 38:fda80a0020d1 5142 double n95 = calibration_05_normValue_0_1[ch];
whismanoid 38:fda80a0020d1 5143 double V95 = calibration_05_V[ch];
whismanoid 38:fda80a0020d1 5144 calibration_05_normValue_0_1[ch] = n05;
whismanoid 38:fda80a0020d1 5145 calibration_05_V[ch] = V05;
whismanoid 38:fda80a0020d1 5146 calibration_95_normValue_0_1[ch] = n95;
whismanoid 38:fda80a0020d1 5147 calibration_95_V[ch] = V95;
whismanoid 38:fda80a0020d1 5148 }
whismanoid 34:a1993a1ee904 5149 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5150 }
whismanoid 34:a1993a1ee904 5151 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5152 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5153 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 5154 // double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 5155 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5156 {
whismanoid 34:a1993a1ee904 5157 static char key_cal0test[12] = "cal0test__";
whismanoid 34:a1993a1ee904 5158 sprintf(key_cal0test, "cal%1dtest", ch);
whismanoid 34:a1993a1ee904 5159 double normValue_0_1, Vtest;
whismanoid 34:a1993a1ee904 5160 if (cmdLine.parse_double(key_cal0test, Vtest))
whismanoid 34:a1993a1ee904 5161 {
whismanoid 34:a1993a1ee904 5162 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 5163 normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 5164 //
whismanoid 34:a1993a1ee904 5165 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 5166 ch,
whismanoid 34:a1993a1ee904 5167 normValue_0_1,
whismanoid 34:a1993a1ee904 5168 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 5169 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5170 );
whismanoid 34:a1993a1ee904 5171 //
whismanoid 34:a1993a1ee904 5172 // sweep CalibratedNormValue argument
whismanoid 34:a1993a1ee904 5173 double normValue_0_1_start = -0.05;
whismanoid 34:a1993a1ee904 5174 double normValue_0_1_step = 0.05;
whismanoid 34:a1993a1ee904 5175 double normValue_0_1_end = 1.07;
whismanoid 34:a1993a1ee904 5176 for (normValue_0_1 = normValue_0_1_start;
whismanoid 34:a1993a1ee904 5177 normValue_0_1 <= normValue_0_1_end;
whismanoid 34:a1993a1ee904 5178 normValue_0_1 = normValue_0_1 + normValue_0_1_step)
whismanoid 34:a1993a1ee904 5179 {
whismanoid 34:a1993a1ee904 5180 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 5181 ch,
whismanoid 34:a1993a1ee904 5182 normValue_0_1,
whismanoid 34:a1993a1ee904 5183 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 5184 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5185 );
whismanoid 34:a1993a1ee904 5186 }
whismanoid 34:a1993a1ee904 5187 }
whismanoid 34:a1993a1ee904 5188 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5189 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5190 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5191 // %A v0cal=1.000V -- calibrate channel against a known input voltage
whismanoid 34:a1993a1ee904 5192 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5193 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5194 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5195 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5196 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5197 {
whismanoid 34:a1993a1ee904 5198 static char key_v0cal[10] = "v0cal__";
whismanoid 34:a1993a1ee904 5199 sprintf(key_v0cal, "v%1dcal", ch);
whismanoid 34:a1993a1ee904 5200 double Vtest;
whismanoid 34:a1993a1ee904 5201 if (cmdLine.parse_double(key_v0cal, Vtest))
whismanoid 34:a1993a1ee904 5202 {
whismanoid 34:a1993a1ee904 5203 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 5204 double Vtest_normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 5205 //
whismanoid 34:a1993a1ee904 5206 // %A v0cal=1.000 calibrate one channel by measuring against a known input voltage
whismanoid 34:a1993a1ee904 5207 //
whismanoid 34:a1993a1ee904 5208 cmdLine.serial().printf("\r\n Measuring against input voltage of %1.6fV...", Vtest);
whismanoid 37:3f369235e5bc 5209 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5210 const int numberOfMeasurements = 16 * Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5211 #else // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5212 const int numberOfMeasurements = 16;
whismanoid 37:3f369235e5bc 5213 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5214 double Sx_measure_normValue_0_1 = 0; // sum of values
whismanoid 34:a1993a1ee904 5215 double Sxx_measure_normValue_0_1 = 0; // sum of the squares of the values
whismanoid 34:a1993a1ee904 5216 for (int count = 0; count < numberOfMeasurements; count++)
whismanoid 34:a1993a1ee904 5217 {
whismanoid 34:a1993a1ee904 5218 double measure_normValue_0_1;
whismanoid 34:a1993a1ee904 5219 switch(ch)
whismanoid 34:a1993a1ee904 5220 {
whismanoid 34:a1993a1ee904 5221 case 0: measure_normValue_0_1 = analogIn0.read(); break;
whismanoid 34:a1993a1ee904 5222 case 1: measure_normValue_0_1 = analogIn1.read(); break;
whismanoid 34:a1993a1ee904 5223 case 2: measure_normValue_0_1 = analogIn2.read(); break;
whismanoid 34:a1993a1ee904 5224 case 3: measure_normValue_0_1 = analogIn3.read(); break;
whismanoid 34:a1993a1ee904 5225 case 4: measure_normValue_0_1 = analogIn4.read(); break;
whismanoid 34:a1993a1ee904 5226 case 5: measure_normValue_0_1 = analogIn5.read(); break;
whismanoid 34:a1993a1ee904 5227 }
whismanoid 34:a1993a1ee904 5228 Sx_measure_normValue_0_1 = Sx_measure_normValue_0_1 + measure_normValue_0_1;
whismanoid 34:a1993a1ee904 5229 Sxx_measure_normValue_0_1 = Sxx_measure_normValue_0_1 + (measure_normValue_0_1 * measure_normValue_0_1);
whismanoid 38:fda80a0020d1 5230 if ((count < 3) || (count >= numberOfMeasurements - 3)) {
whismanoid 38:fda80a0020d1 5231 cmdLine.serial().printf("\r\n raw: %7.6f%% = %1.6fV",
whismanoid 38:fda80a0020d1 5232 measure_normValue_0_1 * 100.0,
whismanoid 38:fda80a0020d1 5233 (measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 38:fda80a0020d1 5234 );
whismanoid 38:fda80a0020d1 5235 }
whismanoid 34:a1993a1ee904 5236 }
whismanoid 34:a1993a1ee904 5237 cmdLine.serial().printf("\r\n numberOfMeasurements = %d", numberOfMeasurements);
whismanoid 34:a1993a1ee904 5238 cmdLine.serial().printf("\r\n Sx_measure_normValue_0_1 = %1.6f", Sx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 5239 cmdLine.serial().printf("\r\n Sxx_measure_normValue_0_1 = %1.6f", Sxx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 5240 //
whismanoid 34:a1993a1ee904 5241 // calculate mean_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 5242 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 5243 double mean_measure_normValue_0_1 = Sx_measure_normValue_0_1 / numberOfMeasurements;
whismanoid 34:a1993a1ee904 5244 cmdLine.serial().printf("\r\n mean = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 5245 mean_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 5246 (mean_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5247 );
whismanoid 34:a1993a1ee904 5248 //
whismanoid 34:a1993a1ee904 5249 // TODO: calculate sample variance_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 5250 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 5251 // variance_measure_normValue_0_1 = (Sxx - ( Sx * Sx / nWords) ) / (nWords - 1);
whismanoid 34:a1993a1ee904 5252 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 5253 cmdLine.serial().printf("\r\n variance = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 5254 variance_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 5255 (variance_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5256 );
whismanoid 34:a1993a1ee904 5257 //
whismanoid 34:a1993a1ee904 5258 // calculate sample stddev_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 5259 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 5260 double stddev_measure_normValue_0_1 = sqrt(variance_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 5261 cmdLine.serial().printf("\r\n stddev = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 5262 stddev_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 5263 (stddev_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5264 );
whismanoid 34:a1993a1ee904 5265 //
whismanoid 34:a1993a1ee904 5266 // Validate the measurements:
whismanoid 34:a1993a1ee904 5267 // is the mean near the expected value?
whismanoid 34:a1993a1ee904 5268 // is the standard deviation not too high?
whismanoid 34:a1993a1ee904 5269 bool isCalibrationValid = true;
whismanoid 34:a1993a1ee904 5270 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) > 0.1) {
whismanoid 34:a1993a1ee904 5271 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 5272 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 5273 }
whismanoid 34:a1993a1ee904 5274 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) < -0.1) {
whismanoid 34:a1993a1ee904 5275 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 5276 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 5277 }
whismanoid 34:a1993a1ee904 5278 if ((stddev_measure_normValue_0_1) > 10) {
whismanoid 34:a1993a1ee904 5279 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 5280 cmdLine.serial().printf(" stddev too high.\r\n");
whismanoid 34:a1993a1ee904 5281 }
whismanoid 34:a1993a1ee904 5282 if (isCalibrationValid)
whismanoid 34:a1993a1ee904 5283 {
whismanoid 34:a1993a1ee904 5284 // update calibration point (mean_measure_normValue_0_1, Vtest)
whismanoid 34:a1993a1ee904 5285 if (Vtest_normValue_0_1 < 0.5) {
whismanoid 34:a1993a1ee904 5286 calibration_05_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 5287 calibration_05_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 5288 } else {
whismanoid 34:a1993a1ee904 5289 calibration_95_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 5290 calibration_95_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 5291 }
whismanoid 34:a1993a1ee904 5292 //
whismanoid 34:a1993a1ee904 5293 // print updated calibration values
whismanoid 34:a1993a1ee904 5294 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 5295 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 5296 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 5297 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 5298 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 5299 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 5300 );
whismanoid 34:a1993a1ee904 5301 // print corrected value of mean of measurements (should be close to Vtest)
whismanoid 34:a1993a1ee904 5302 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV vs %1.6fV\r\n",
whismanoid 34:a1993a1ee904 5303 ch,
whismanoid 34:a1993a1ee904 5304 mean_measure_normValue_0_1,
whismanoid 34:a1993a1ee904 5305 CalibratedNormValue(ch, mean_measure_normValue_0_1),
whismanoid 34:a1993a1ee904 5306 (CalibratedNormValue(ch, mean_measure_normValue_0_1) * adc_full_scale_voltage[ch]),
whismanoid 34:a1993a1ee904 5307 Vtest
whismanoid 34:a1993a1ee904 5308 );
whismanoid 34:a1993a1ee904 5309 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 5310 else {
whismanoid 34:a1993a1ee904 5311 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 5312 cmdLine.serial().printf(" Measurement Error: Calibration will not be updated.\r\n");
whismanoid 34:a1993a1ee904 5313 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 5314 } // end if key_v0cal
whismanoid 34:a1993a1ee904 5315 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5316 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5317 #if HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 5318 // // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 37:3f369235e5bc 5319 // {
whismanoid 37:3f369235e5bc 5320 // char valueBuf[16];
whismanoid 37:3f369235e5bc 5321 // // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 37:3f369235e5bc 5322 // if (cmdLine.parse_and_remove_key("__TBD_saveCal__", valueBuf, sizeof(valueBuf)))
whismanoid 37:3f369235e5bc 5323 // {
whismanoid 37:3f369235e5bc 5324 // // handle %A __TBD_saveCal__ -- command
whismanoid 37:3f369235e5bc 5325 // }
whismanoid 37:3f369235e5bc 5326 // }
whismanoid 34:a1993a1ee904 5327 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5328 #if HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 5329 // // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 37:3f369235e5bc 5330 // {
whismanoid 37:3f369235e5bc 5331 // char valueBuf[16];
whismanoid 37:3f369235e5bc 5332 // // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 37:3f369235e5bc 5333 // if (cmdLine.parse_and_remove_key("__TBD_loadCal__", valueBuf, sizeof(valueBuf)))
whismanoid 37:3f369235e5bc 5334 // {
whismanoid 37:3f369235e5bc 5335 // // handle %A __TBD_loadCal__ -- command
whismanoid 37:3f369235e5bc 5336 // }
whismanoid 37:3f369235e5bc 5337 // }
whismanoid 34:a1993a1ee904 5338 #endif // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 5339 // %A -- report analog input voltages
whismanoid 37:3f369235e5bc 5340 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5341 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5342 #endif // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5343 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 5344 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 15:37c83ec50ea0 5345 for (int pinIndex = 0; pinIndex < 2; pinIndex++)
whismanoid 15:37c83ec50ea0 5346 {
whismanoid 15:37c83ec50ea0 5347 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 5348 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 5349 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 5350 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5351 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5352 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5353 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 5354 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5355 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 5356 }
whismanoid 37:3f369235e5bc 5357 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5358 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5359 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 5360 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5361 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5362 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5363 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 5364 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5365 //
whismanoid 15:37c83ec50ea0 5366 int pinIndexH = pinIndex + 4;
whismanoid 15:37c83ec50ea0 5367 int cPinIndexH = '0' + pinIndexH;
whismanoid 15:37c83ec50ea0 5368 AnalogIn& analogInPinH = find_analogInPin(cPinIndexH);
whismanoid 15:37c83ec50ea0 5369 float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH];
whismanoid 37:3f369235e5bc 5370 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5371 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5372 // float normValueH_0_1 = analogInPinH.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5373 float normValueH_0_1 = 0;
whismanoid 37:3f369235e5bc 5374 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5375 normValueH_0_1 = normValueH_0_1 + analogInPinH.read();
whismanoid 37:3f369235e5bc 5376 }
whismanoid 37:3f369235e5bc 5377 normValueH_0_1 = normValueH_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5378 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5379 float normValueH_0_1 = analogInPinH.read();
whismanoid 37:3f369235e5bc 5380 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5381 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5382 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5383 normValueH_0_1 = CalibratedNormValue(pinIndex, normValueH_0_1);
whismanoid 34:a1993a1ee904 5384 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5385 //
whismanoid 37:3f369235e5bc 5386 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV high range A%c = %7.3f%% = %1.3fV \r\n",
whismanoid 15:37c83ec50ea0 5387 cPinIndex,
whismanoid 15:37c83ec50ea0 5388 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5389 normValue_0_1 * adc_full_scale_voltage,
whismanoid 15:37c83ec50ea0 5390 cPinIndexH,
whismanoid 15:37c83ec50ea0 5391 normValueH_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5392 normValueH_0_1 * adc_full_scale_voltageH
whismanoid 15:37c83ec50ea0 5393 );
whismanoid 15:37c83ec50ea0 5394 }
whismanoid 15:37c83ec50ea0 5395 for (int pinIndex = 2; pinIndex < 4; pinIndex++)
whismanoid 15:37c83ec50ea0 5396 {
whismanoid 15:37c83ec50ea0 5397 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 5398 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 5399 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 5400 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5401 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5402 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5403 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 5404 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5405 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 5406 }
whismanoid 37:3f369235e5bc 5407 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5408 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5409 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 5410 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5411 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5412 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5413 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 5414 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5415 //
whismanoid 37:3f369235e5bc 5416 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 5417 cPinIndex,
whismanoid 15:37c83ec50ea0 5418 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5419 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 5420 );
whismanoid 15:37c83ec50ea0 5421 }
whismanoid 15:37c83ec50ea0 5422 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 5423 // Platform board uses simple analog inputs
whismanoid 15:37c83ec50ea0 5424 // assume standard Arduino analog inputs A0-A5
whismanoid 15:37c83ec50ea0 5425 for (int pinIndex = 0; pinIndex < 6; pinIndex++)
whismanoid 15:37c83ec50ea0 5426 {
whismanoid 15:37c83ec50ea0 5427 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 5428 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 5429 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 5430 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5431 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5432 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5433 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 5434 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5435 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 5436 }
whismanoid 37:3f369235e5bc 5437 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5438 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5439 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 5440 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5441 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5442 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5443 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 5444 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5445 //
whismanoid 37:3f369235e5bc 5446 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 5447 cPinIndex,
whismanoid 15:37c83ec50ea0 5448 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5449 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 5450 );
whismanoid 15:37c83ec50ea0 5451 }
whismanoid 15:37c83ec50ea0 5452 #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 5453 }
whismanoid 15:37c83ec50ea0 5454 break;
whismanoid 15:37c83ec50ea0 5455 #endif
whismanoid 15:37c83ec50ea0 5456 //
whismanoid 15:37c83ec50ea0 5457 #if HAS_SPI2_MAX541
whismanoid 15:37c83ec50ea0 5458 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 5459 {
whismanoid 15:37c83ec50ea0 5460 // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV)
whismanoid 15:37c83ec50ea0 5461 // MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 15:37c83ec50ea0 5462 float voltageV = max541.Get_Voltage();
whismanoid 15:37c83ec50ea0 5463 // if (cmdLine[2] == '+') {
whismanoid 15:37c83ec50ea0 5464 // // %D+
whismanoid 15:37c83ec50ea0 5465 // voltageV = voltageV * 1.25f;
whismanoid 15:37c83ec50ea0 5466 // if (voltageV >= max541.VRef) voltageV = max541.VRef;
whismanoid 15:37c83ec50ea0 5467 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5468 // }
whismanoid 15:37c83ec50ea0 5469 // else if (cmdLine[2] == '-') {
whismanoid 15:37c83ec50ea0 5470 // // %D-
whismanoid 15:37c83ec50ea0 5471 // voltageV = voltageV * 0.75f;
whismanoid 15:37c83ec50ea0 5472 // if (voltageV < 0.1f) voltageV = 0.1f;
whismanoid 15:37c83ec50ea0 5473 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5474 // }
whismanoid 15:37c83ec50ea0 5475 if (cmdLine.parse_float("V", voltageV))
whismanoid 15:37c83ec50ea0 5476 {
whismanoid 15:37c83ec50ea0 5477 // %D V=1.234 -- set voltage
whismanoid 15:37c83ec50ea0 5478 max541.Set_Voltage(voltageV);
whismanoid 15:37c83ec50ea0 5479 }
whismanoid 15:37c83ec50ea0 5480 else if (cmdLine.parse_float("TEST", voltageV))
whismanoid 15:37c83ec50ea0 5481 {
whismanoid 15:37c83ec50ea0 5482 // %D TEST=1.234 -- set voltage and compare with AIN0
whismanoid 15:37c83ec50ea0 5483 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5484 }
whismanoid 15:37c83ec50ea0 5485 else if (cmdLine.parse_float("CAL", voltageV))
whismanoid 15:37c83ec50ea0 5486 {
whismanoid 15:37c83ec50ea0 5487 // %D CAL=1.234 -- calibrate VRef and compare with AIN0
whismanoid 15:37c83ec50ea0 5488
whismanoid 15:37c83ec50ea0 5489 max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
whismanoid 15:37c83ec50ea0 5490 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 5491 const int average_count = 100;
whismanoid 15:37c83ec50ea0 5492 const double average_K = 0.25;
whismanoid 15:37c83ec50ea0 5493 for (int count = 0; count < average_count; count++) {
whismanoid 15:37c83ec50ea0 5494 double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 5495 max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
whismanoid 15:37c83ec50ea0 5496 }
whismanoid 15:37c83ec50ea0 5497 max541.VRef = 2.0 * max541_midscale_V;
whismanoid 15:37c83ec50ea0 5498 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5499 "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
whismanoid 15:37c83ec50ea0 5500 max541_midscale_V, max541.VRef);
whismanoid 15:37c83ec50ea0 5501 // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
whismanoid 15:37c83ec50ea0 5502 voltageV = 1.0f;
whismanoid 15:37c83ec50ea0 5503 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5504 }
whismanoid 15:37c83ec50ea0 5505 else {
whismanoid 15:37c83ec50ea0 5506 // %D -- print MAX541 DAC status
whismanoid 15:37c83ec50ea0 5507 cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n",
whismanoid 15:37c83ec50ea0 5508 max541.Get_Code(), max541.Get_Voltage(), max541.VRef);
whismanoid 15:37c83ec50ea0 5509 }
whismanoid 15:37c83ec50ea0 5510 }
whismanoid 15:37c83ec50ea0 5511 break;
whismanoid 15:37c83ec50ea0 5512 #endif
whismanoid 15:37c83ec50ea0 5513
whismanoid 15:37c83ec50ea0 5514 //
whismanoid 15:37c83ec50ea0 5515 #if HAS_I2C // SUPPORT_I2C
whismanoid 15:37c83ec50ea0 5516 case 'I': case 'i':
whismanoid 15:37c83ec50ea0 5517 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 5518 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 5519 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 5520 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 5521 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 5522 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 5523 // get next character
whismanoid 15:37c83ec50ea0 5524 // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7
whismanoid 15:37c83ec50ea0 5525 cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7);
whismanoid 15:37c83ec50ea0 5526 // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count
whismanoid 15:37c83ec50ea0 5527 g_I2C_read_count = 0; // read count must be reset every command
whismanoid 15:37c83ec50ea0 5528 cmdLine.parse_byte_dec("RD", g_I2C_read_count);
whismanoid 15:37c83ec50ea0 5529 // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress
whismanoid 15:37c83ec50ea0 5530 cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress);
whismanoid 15:37c83ec50ea0 5531 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 5532 {
whismanoid 15:37c83ec50ea0 5533 case 'P': case 'p':
whismanoid 15:37c83ec50ea0 5534 {
whismanoid 15:37c83ec50ea0 5535 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 5536 HuntAttachedI2CDevices(cmdLine, 0x03, 0x77);
whismanoid 15:37c83ec50ea0 5537 }
whismanoid 15:37c83ec50ea0 5538 break;
whismanoid 15:37c83ec50ea0 5539 case 'C': case 'c':
whismanoid 15:37c83ec50ea0 5540 {
whismanoid 15:37c83ec50ea0 5541 bool isUpdatedI2CConfig = false;
whismanoid 15:37c83ec50ea0 5542 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 5543 // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz
whismanoid 15:37c83ec50ea0 5544 if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz))
whismanoid 15:37c83ec50ea0 5545 {
whismanoid 15:37c83ec50ea0 5546 isUpdatedI2CConfig = true;
whismanoid 15:37c83ec50ea0 5547 // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 5548 if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 5549 {
whismanoid 15:37c83ec50ea0 5550 g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 5551 }
whismanoid 15:37c83ec50ea0 5552 if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 5553 {
whismanoid 15:37c83ec50ea0 5554 g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 5555 }
whismanoid 15:37c83ec50ea0 5556 }
whismanoid 15:37c83ec50ea0 5557 if (isUpdatedI2CConfig)
whismanoid 15:37c83ec50ea0 5558 {
whismanoid 15:37c83ec50ea0 5559 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 5560 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 5561 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5562 i2cMaster.start();
whismanoid 15:37c83ec50ea0 5563 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 5564 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5565 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5566 "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 15:37c83ec50ea0 5567 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 15:37c83ec50ea0 5568 (g_I2C_SCL_Hz / 1000.));
whismanoid 15:37c83ec50ea0 5569 i2cMaster.start();
whismanoid 15:37c83ec50ea0 5570 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 5571 }
whismanoid 15:37c83ec50ea0 5572 }
whismanoid 15:37c83ec50ea0 5573 break;
whismanoid 15:37c83ec50ea0 5574 case 'W': case 'w':
whismanoid 15:37c83ec50ea0 5575 {
whismanoid 15:37c83ec50ea0 5576 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 5577 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 5578 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5579 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 5580 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5581 #define MAX_I2C_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 5582 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 5583 static char mosiData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5584 static char misoData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5585 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 5586 MAX_I2C_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 5587 {
whismanoid 15:37c83ec50ea0 5588 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5589 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5590 "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->",
whismanoid 15:37c83ec50ea0 5591 g_I2C_deviceAddress7,
whismanoid 15:37c83ec50ea0 5592 (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count);
whismanoid 15:37c83ec50ea0 5593 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 5594 {
whismanoid 15:37c83ec50ea0 5595 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 5596 }
whismanoid 15:37c83ec50ea0 5597 //
whismanoid 15:37c83ec50ea0 5598 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 5599 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 5600 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 5601 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 5602 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 5603 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 5604 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 5605 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5606 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5607 // /* 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 5608 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 5609 const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 5610 unsigned int misoLength = 0;
whismanoid 15:37c83ec50ea0 5611 bool repeated = (g_I2C_read_count > 0);
whismanoid 15:37c83ec50ea0 5612 //
whismanoid 15:37c83ec50ea0 5613 int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated);
whismanoid 15:37c83ec50ea0 5614 switch (writeStatus)
whismanoid 15:37c83ec50ea0 5615 {
whismanoid 15:37c83ec50ea0 5616 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 5617 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 5618 default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 5619 writeStatus);
whismanoid 15:37c83ec50ea0 5620 }
whismanoid 15:37c83ec50ea0 5621 if (repeated)
whismanoid 15:37c83ec50ea0 5622 {
whismanoid 15:37c83ec50ea0 5623 int readStatus =
whismanoid 15:37c83ec50ea0 5624 i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false);
whismanoid 15:37c83ec50ea0 5625 switch (readStatus)
whismanoid 15:37c83ec50ea0 5626 {
whismanoid 15:37c83ec50ea0 5627 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 5628 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 5629 default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 5630 readStatus);
whismanoid 15:37c83ec50ea0 5631 }
whismanoid 15:37c83ec50ea0 5632 }
whismanoid 15:37c83ec50ea0 5633 //
whismanoid 15:37c83ec50ea0 5634 if (misoLength > 0)
whismanoid 15:37c83ec50ea0 5635 {
whismanoid 15:37c83ec50ea0 5636 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5637 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 5638 for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count;
whismanoid 15:37c83ec50ea0 5639 byteIndex++)
whismanoid 15:37c83ec50ea0 5640 {
whismanoid 15:37c83ec50ea0 5641 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 5642 }
whismanoid 15:37c83ec50ea0 5643 }
whismanoid 15:37c83ec50ea0 5644 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 5645 }
whismanoid 15:37c83ec50ea0 5646 }
whismanoid 15:37c83ec50ea0 5647 break;
whismanoid 15:37c83ec50ea0 5648 case 'R': case 'r':
whismanoid 15:37c83ec50ea0 5649 {
whismanoid 15:37c83ec50ea0 5650 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 5651 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 5652 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5653 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 5654 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 5655 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 5656 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 5657 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 5658 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 5659 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 5660 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 5661 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5662 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5663 // /* 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 5664 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 5665 }
whismanoid 15:37c83ec50ea0 5666 break;
whismanoid 15:37c83ec50ea0 5667 case '^':
whismanoid 15:37c83ec50ea0 5668 {
whismanoid 15:37c83ec50ea0 5669 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 5670 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 5671 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5672 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 5673 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 5674 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 5675 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 5676 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 5677 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 5678 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 5679 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 5680 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5681 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5682 // /* 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 5683 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 5684 }
whismanoid 15:37c83ec50ea0 5685 break;
whismanoid 15:37c83ec50ea0 5686 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 5687 break;
whismanoid 15:37c83ec50ea0 5688 #endif
whismanoid 15:37c83ec50ea0 5689 //
whismanoid 15:37c83ec50ea0 5690 #if HAS_SPI // SUPPORT_SPI
whismanoid 15:37c83ec50ea0 5691 case 'S': case 's':
whismanoid 15:37c83ec50ea0 5692 {
whismanoid 15:37c83ec50ea0 5693 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 5694 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 5695 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 5696 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 5697 //
whismanoid 15:37c83ec50ea0 5698 // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d
whismanoid 15:37c83ec50ea0 5699 bool isUpdatedSPIConfig = false;
whismanoid 15:37c83ec50ea0 5700 // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2
whismanoid 15:37c83ec50ea0 5701 // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1
whismanoid 15:37c83ec50ea0 5702 if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2))
whismanoid 15:37c83ec50ea0 5703 {
whismanoid 15:37c83ec50ea0 5704 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5705 }
whismanoid 15:37c83ec50ea0 5706 if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1))
whismanoid 15:37c83ec50ea0 5707 {
whismanoid 15:37c83ec50ea0 5708 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5709 }
whismanoid 15:37c83ec50ea0 5710 if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1))
whismanoid 15:37c83ec50ea0 5711 {
whismanoid 15:37c83ec50ea0 5712 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5713 }
whismanoid 15:37c83ec50ea0 5714 // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz
whismanoid 15:37c83ec50ea0 5715 if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz))
whismanoid 15:37c83ec50ea0 5716 {
whismanoid 15:37c83ec50ea0 5717 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5718 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 5719 if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 5720 {
whismanoid 15:37c83ec50ea0 5721 g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 5722 }
whismanoid 15:37c83ec50ea0 5723 if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 5724 {
whismanoid 15:37c83ec50ea0 5725 g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 5726 }
whismanoid 15:37c83ec50ea0 5727 }
whismanoid 15:37c83ec50ea0 5728 // Update SPI configuration
whismanoid 15:37c83ec50ea0 5729 if (isUpdatedSPIConfig)
whismanoid 15:37c83ec50ea0 5730 {
whismanoid 15:37c83ec50ea0 5731 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 5732 spi_cs = g_SPI_cs_state;
whismanoid 15:37c83ec50ea0 5733 spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0
whismanoid 15:37c83ec50ea0 5734 #if APPLICATION_MAX5715
whismanoid 15:37c83ec50ea0 5735 g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5736 #elif APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 5737 g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5738 #elif APPLICATION_MAX5171
whismanoid 15:37c83ec50ea0 5739 g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5740 #elif APPLICATION_MAX11410
whismanoid 15:37c83ec50ea0 5741 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5742 #elif APPLICATION_MAX12345
whismanoid 15:37c83ec50ea0 5743 g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5744 #else
whismanoid 15:37c83ec50ea0 5745 spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 15:37c83ec50ea0 5746 #endif
whismanoid 15:37c83ec50ea0 5747 //
whismanoid 15:37c83ec50ea0 5748 double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 5749 int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate
whismanoid 15:37c83ec50ea0 5750 double actual_SCLK_Hz = SystemCoreClock / actual_divisor;
whismanoid 15:37c83ec50ea0 5751 //
whismanoid 15:37c83ec50ea0 5752 // 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 5753 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5754 "\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 5755 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 15:37c83ec50ea0 5756 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0),
whismanoid 15:37c83ec50ea0 5757 g_SPI_cs_state,
whismanoid 15:37c83ec50ea0 5758 g_SPI_SCLK_Hz,
whismanoid 15:37c83ec50ea0 5759 (g_SPI_SCLK_Hz / 1000000.),
whismanoid 15:37c83ec50ea0 5760 ((double)(SystemCoreClock / 1000000.)),
whismanoid 15:37c83ec50ea0 5761 ideal_divisor,
whismanoid 15:37c83ec50ea0 5762 (actual_SCLK_Hz / 1000000.)
whismanoid 15:37c83ec50ea0 5763 );
whismanoid 15:37c83ec50ea0 5764 }
whismanoid 15:37c83ec50ea0 5765 // get next character
whismanoid 15:37c83ec50ea0 5766 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 5767 {
whismanoid 15:37c83ec50ea0 5768 case 'C': case 's':
whismanoid 15:37c83ec50ea0 5769 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 5770 break;
whismanoid 15:37c83ec50ea0 5771 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 5772 // %SD -- SPI diagnostic messages enable
whismanoid 15:37c83ec50ea0 5773 if (g_MAX5719_device.onSPIprint) {
whismanoid 15:37c83ec50ea0 5774 g_MAX5719_device.onSPIprint = NULL;
whismanoid 15:37c83ec50ea0 5775 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') != None is false
whismanoid 15:37c83ec50ea0 5776 }
whismanoid 15:37c83ec50ea0 5777 else {
whismanoid 15:37c83ec50ea0 5778 void onSPIprint_handler(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]);
whismanoid 15:37c83ec50ea0 5779 g_MAX5719_device.onSPIprint = onSPIprint_handler;
whismanoid 15:37c83ec50ea0 5780 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') is false
whismanoid 15:37c83ec50ea0 5781 }
whismanoid 15:37c83ec50ea0 5782 break;
whismanoid 15:37c83ec50ea0 5783 case 'W': case 'R': case 'w': case 'r':
whismanoid 15:37c83ec50ea0 5784 {
whismanoid 15:37c83ec50ea0 5785 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 5786 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 5787 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5788 #define MAX_SPI_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 5789 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 5790 static char mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5791 static char misoData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5792 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 5793 MAX_SPI_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 5794 {
whismanoid 15:37c83ec50ea0 5795 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5796 cmdLine.serial().printf("\r\nSPI");
whismanoid 15:37c83ec50ea0 5797 if (byteCount > 7) {
whismanoid 15:37c83ec50ea0 5798 cmdLine.serial().printf(" byteCount:%d", byteCount);
whismanoid 15:37c83ec50ea0 5799 }
whismanoid 15:37c83ec50ea0 5800 cmdLine.serial().printf(" MOSI->");
whismanoid 15:37c83ec50ea0 5801 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 5802 {
whismanoid 15:37c83ec50ea0 5803 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 5804 }
whismanoid 15:37c83ec50ea0 5805 spi_cs = 0;
whismanoid 15:37c83ec50ea0 5806 unsigned int numBytesTransferred =
whismanoid 15:37c83ec50ea0 5807 spi.write(mosiData, byteCount, misoData, byteCount);
whismanoid 15:37c83ec50ea0 5808 spi_cs = 1;
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 < numBytesTransferred;
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 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 5817 }
whismanoid 15:37c83ec50ea0 5818 }
whismanoid 15:37c83ec50ea0 5819 break;
whismanoid 15:37c83ec50ea0 5820 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 5821 } // case 'S': // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 5822 break;
whismanoid 15:37c83ec50ea0 5823 #endif
whismanoid 15:37c83ec50ea0 5824 //
whismanoid 15:37c83ec50ea0 5825 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 5826 } // switch(cmdLine[1])
whismanoid 15:37c83ec50ea0 5827 } // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 15:37c83ec50ea0 5828 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 15:37c83ec50ea0 5829
whismanoid 15:37c83ec50ea0 5830 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 5831 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 5832 void main_menu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 5833 {
whismanoid 9:45f98573eb6d 5834 // process command line
whismanoid 31:47eee7e0cc2d 5835 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 5836 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5837 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 5838 #endif // USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5839 cmdLine.serial().printf("\r\nCmdLine buf:\"%s\"\r\n", cmdLine.str());
whismanoid 45:74bf1fe021e5 5840 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5841 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 5842 #endif // USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5843 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 5844 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5845 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 5846 #endif // USE_DATALOGGER_CommandTable
whismanoid 45:74bf1fe021e5 5847 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5848 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 5849 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 5850
whismanoid 4:d9b05924ad4c 5851 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 31:47eee7e0cc2d 5852 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 5853 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5854 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 5855 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 5856 // If datalog is free running, halt on any possible received command
whismanoid 17:9397ea3ea7e9 5857 if (Datalogger_Trigger != trigger_Halt) {
whismanoid 4:d9b05924ad4c 5858 Datalogger_Trigger = trigger_Halt;
whismanoid 9:45f98573eb6d 5859 cmdLine.serial().printf("Datalog stopped by USB command input\r\n");
whismanoid 9:45f98573eb6d 5860 cmdLine.serial().printf("Restart datalog by sending LR\r\n");
whismanoid 4:d9b05924ad4c 5861 }
whismanoid 45:74bf1fe021e5 5862 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5863 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 5864 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 5865 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 5866
whismanoid 4:d9b05924ad4c 5867 // DIAGNOSTIC: print line buffer
whismanoid 4:d9b05924ad4c 5868 //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str());
whismanoid 4:d9b05924ad4c 5869 //
whismanoid 4:d9b05924ad4c 5870 switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 5871 {
whismanoid 4:d9b05924ad4c 5872 case '?':
whismanoid 4:d9b05924ad4c 5873 main_menu_status(cmdLine);
whismanoid 4:d9b05924ad4c 5874 main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 5875 // print command prompt
whismanoid 4:d9b05924ad4c 5876 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 5877 break;
whismanoid 4:d9b05924ad4c 5878 case '\r': case '\n': // ignore blank line
whismanoid 4:d9b05924ad4c 5879 case '\0': // ignore empty line
whismanoid 30:07197a430869 5880 main_menu_status(cmdLine);
whismanoid 30:07197a430869 5881 //~ main_menu_help(cmdLine);
whismanoid 30:07197a430869 5882 // print command prompt
whismanoid 30:07197a430869 5883 //cmdLine.serial().printf("\r\n>");
whismanoid 30:07197a430869 5884 break;
whismanoid 4:d9b05924ad4c 5885 case '#': // ignore comment line
whismanoid 4:d9b05924ad4c 5886 // # -- lines beginning with # are comments
whismanoid 30:07197a430869 5887 //
whismanoid 30:07197a430869 5888 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 5889 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in main_menu_onEOLcommandParser
whismanoid 30:07197a430869 5890 // # command handler update gstrRemarkText buffer instead of just ignoring the remark
whismanoid 30:07197a430869 5891 //
whismanoid 30:07197a430869 5892 // ignore extra spaces before the remark
whismanoid 30:07197a430869 5893 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 30:07197a430869 5894 int argIndex;
whismanoid 30:07197a430869 5895 for (argIndex = 1; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 5896 {
whismanoid 30:07197a430869 5897 if (cmdLine[argIndex] == ' ') break;
whismanoid 30:07197a430869 5898 }
whismanoid 30:07197a430869 5899 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 5900 {
whismanoid 30:07197a430869 5901 if (cmdLine[argIndex] != ' ') break;
whismanoid 30:07197a430869 5902 }
whismanoid 30:07197a430869 5903 //
whismanoid 30:07197a430869 5904 strncpy(gstrRemarkText, cmdLine.str()+argIndex, gstrRemarkTextLASTINDEX+1);
whismanoid 30:07197a430869 5905 // do not exceed string buffer limit; keep sentinel null character at end of buffer
whismanoid 30:07197a430869 5906 gstrRemarkText[gstrRemarkTextLASTINDEX] = '\0';
whismanoid 41:13a6a097502c 5907 for (unsigned int index = 0; index < gstrRemarkTextLASTINDEX; index++)
whismanoid 30:07197a430869 5908 {
whismanoid 30:07197a430869 5909 if ((gstrRemarkText[index]) == '\0') break; // null character at end of string
whismanoid 30:07197a430869 5910 if ((gstrRemarkText[index]) < 0x20) {
whismanoid 30:07197a430869 5911 // replace non-printing characters with _
whismanoid 30:07197a430869 5912 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 5913 continue;
whismanoid 30:07197a430869 5914 }
whismanoid 30:07197a430869 5915 if ((gstrRemarkText[index]) >= 0x7F) {
whismanoid 30:07197a430869 5916 // replace non-printing characters with _
whismanoid 30:07197a430869 5917 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 5918 continue;
whismanoid 30:07197a430869 5919 }
whismanoid 30:07197a430869 5920 switch(gstrRemarkText[index])
whismanoid 30:07197a430869 5921 {
whismanoid 30:07197a430869 5922 case ',':
whismanoid 30:07197a430869 5923 // replace , with ;
whismanoid 30:07197a430869 5924 gstrRemarkText[index] = ';';
whismanoid 30:07197a430869 5925 break;
whismanoid 30:07197a430869 5926 case '"':
whismanoid 30:07197a430869 5927 // replace " with '
whismanoid 30:07197a430869 5928 gstrRemarkText[index] = '\'';
whismanoid 30:07197a430869 5929 break;
whismanoid 30:07197a430869 5930 case '\\':
whismanoid 30:07197a430869 5931 // replace \ with /
whismanoid 30:07197a430869 5932 gstrRemarkText[index] = '/';
whismanoid 30:07197a430869 5933 break;
whismanoid 30:07197a430869 5934 }
whismanoid 30:07197a430869 5935 }
whismanoid 30:07197a430869 5936 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 5937 //
whismanoid 31:47eee7e0cc2d 5938 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 5939 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5940 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 5941 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 5942 main_menu_status(cmdLine);
whismanoid 45:74bf1fe021e5 5943 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5944 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 5945 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 5946 //~ main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 5947 // print command prompt
whismanoid 4:d9b05924ad4c 5948 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 5949 break;
whismanoid 4:d9b05924ad4c 5950 #if ECHO_EOF_ON_EOL
whismanoid 4:d9b05924ad4c 5951 case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file
whismanoid 4:d9b05924ad4c 5952 cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 5953 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 5954 break;
whismanoid 4:d9b05924ad4c 5955 case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file
whismanoid 4:d9b05924ad4c 5956 cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 5957 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 5958 break;
whismanoid 4:d9b05924ad4c 5959 #endif
whismanoid 10:04022a61b527 5960 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 5961 case '!': // device init
whismanoid 10:04022a61b527 5962 {
whismanoid 10:04022a61b527 5963 cmdLine.serial().printf("Init");
whismanoid 10:04022a61b527 5964 // call function Init
whismanoid 10:04022a61b527 5965 uint8_t result = g_MAX11410_device.Init();
whismanoid 10:04022a61b527 5966 // cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 5967 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 5968 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 5969 // in command '!' device init, apply list of custom register writes after init
whismanoid 10:04022a61b527 5970 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 5971 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 10:04022a61b527 5972 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 10:04022a61b527 5973 uint32_t regData = custom_reg_init_data[index];
whismanoid 10:04022a61b527 5974 cmdLine.serial().printf("*%s=0x%06.6x",
whismanoid 10:04022a61b527 5975 g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress),
whismanoid 10:04022a61b527 5976 regData
whismanoid 10:04022a61b527 5977 );
whismanoid 10:04022a61b527 5978 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 10:04022a61b527 5979 }
whismanoid 10:04022a61b527 5980 #endif // USE_CUSTOM_REG_INIT
whismanoid 10:04022a61b527 5981 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 5982 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 5983 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 5984 }
whismanoid 10:04022a61b527 5985 break;
whismanoid 10:04022a61b527 5986 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 5987 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 5988 case '.':
whismanoid 4:d9b05924ad4c 5989 {
whismanoid 4:d9b05924ad4c 5990 // . -- SelfTest
whismanoid 4:d9b05924ad4c 5991 cmdLine.serial().printf("SelfTest()");
whismanoid 4:d9b05924ad4c 5992 SelfTest(cmdLine);
whismanoid 4:d9b05924ad4c 5993 }
whismanoid 4:d9b05924ad4c 5994 break;
whismanoid 4:d9b05924ad4c 5995 #endif // USE_SELFTEST
whismanoid 15:37c83ec50ea0 5996 #if 1 // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 5997 case '%':
whismanoid 4:d9b05924ad4c 5998 {
whismanoid 4:d9b05924ad4c 5999 pinsMonitor_submenu_onEOLcommandParser(cmdLine);
whismanoid 4:d9b05924ad4c 6000 }
whismanoid 4:d9b05924ad4c 6001 break; // case '%'
whismanoid 4:d9b05924ad4c 6002 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 9:45f98573eb6d 6003 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 6004 // reuse the Serial_Tester command *regName=regValue
whismanoid 10:04022a61b527 6005 // CODE GENERATOR: generate * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 6006 case '*':
whismanoid 10:04022a61b527 6007 {
whismanoid 10:04022a61b527 6008 // if buffer starts with a regName:
whismanoid 10:04022a61b527 6009 // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))):
whismanoid 10:04022a61b527 6010 // cmdLine.serial().printf(" scan RegName...\r\n");
whismanoid 10:04022a61b527 6011 }
whismanoid 10:04022a61b527 6012 break;
whismanoid 9:45f98573eb6d 6013 #endif // USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 6014 //
whismanoid 10:04022a61b527 6015 #if 1 // USE_AUX_SERIAL_CMD_FORWARDING && (HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL)
whismanoid 10:04022a61b527 6016 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_onEOLcommandParser
whismanoid 40:330b28116178 6017 case '>': case '<': // > send and receive; < receive without sending anything
whismanoid 10:04022a61b527 6018 {
whismanoid 10:04022a61b527 6019 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 6020 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 6021 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 6022 CmdLine& cmdLine_AuxSerial = cmdLine_AUXserial;
whismanoid 10:04022a61b527 6023 Serial& AuxSerial = AUXserial;
whismanoid 10:04022a61b527 6024 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6025 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 6026 CmdLine& cmdLine_AuxSerial = cmdLine_DAPLINKserial;
whismanoid 10:04022a61b527 6027 Serial& AuxSerial = DAPLINKserial;
whismanoid 10:04022a61b527 6028 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6029 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 6030 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6031 //
whismanoid 40:330b28116178 6032 int g_auxSerialCom_outgoing_string_cr = 1; // option to send CR after outgoing_string
whismanoid 40:330b28116178 6033 int g_auxSerialCom_outgoing_string_lf = 0; // option to send LF after outgoing_string (breaks remote datalogger LR!)
whismanoid 40:330b28116178 6034 int g_auxSerialCom_rx_string_verbose_crlf = 0; // option to display \r\n as "\\r\\n" in rx_string_buf
whismanoid 40:330b28116178 6035 int g_auxSerialCom_rx_string_verbose_ctrl = 1; // option to display control codes as \xXX
whismanoid 40:330b28116178 6036 const char* g_auxSerialCom_display_tx_prefix = "\r\n->|"; // "\r\n >";
whismanoid 40:330b28116178 6037 const char* g_auxSerialCom_display_rx_prefix = "\r\n<-|"; // "\r\n< ";
whismanoid 40:330b28116178 6038 //
whismanoid 40:330b28116178 6039 bool need_g_auxSerialCom_display_rx_prefix = 1; // temp
whismanoid 40:330b28116178 6040 //
whismanoid 10:04022a61b527 6041 // >> suppress key=value parsing
whismanoid 10:04022a61b527 6042 bool suppress_parsing = (cmdLine[1] == '>');
whismanoid 10:04022a61b527 6043 if (suppress_parsing == false) {
whismanoid 10:04022a61b527 6044 // int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 6045 if (cmdLine.parse_int_dec("baud", g_auxSerialCom_baud))
whismanoid 10:04022a61b527 6046 {
whismanoid 10:04022a61b527 6047 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- baud rate
whismanoid 10:04022a61b527 6048 cmdLine_AuxSerial.serial().printf("\r\n*** New Baud Rate %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6049 AuxSerial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6050 cmdLine_AuxSerial.serial().printf("\r\n*** Baud Rate was set to %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6051 }
whismanoid 10:04022a61b527 6052 #if 0
whismanoid 10:04022a61b527 6053 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 6054 if (cmdLine.parse_int_dec("tx_wait_echo", g_auxSerialCom_tx_wait_echo))
whismanoid 10:04022a61b527 6055 {
whismanoid 10:04022a61b527 6056 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_wait_echo
whismanoid 10:04022a61b527 6057 //~ cmdLine_AuxSerial.serial().printf("\r\n*** tx_wait_echo was set to %d ***\r\n", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 6058 cmdLine.serial().printf("\r\n tx_wait_echo=%d", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 6059 }
whismanoid 10:04022a61b527 6060 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 6061 if (cmdLine.parse_int_dec("tx_char_delay_ms", g_auxSerialCom_tx_char_delay_ms))
whismanoid 10:04022a61b527 6062 {
whismanoid 10:04022a61b527 6063 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_char_delay_ms
whismanoid 10:04022a61b527 6064 //~ 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 6065 cmdLine.serial().printf("\r\n tx_char_delay_ms=%dms", g_auxSerialCom_tx_char_delay_ms);
whismanoid 10:04022a61b527 6066 }
whismanoid 10:04022a61b527 6067 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 6068 if (cmdLine.parse_int_dec("tx_line_delay_ms", g_auxSerialCom_tx_line_delay_ms))
whismanoid 10:04022a61b527 6069 {
whismanoid 10:04022a61b527 6070 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_line_delay_ms
whismanoid 10:04022a61b527 6071 //~ 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 6072 cmdLine.serial().printf("\r\n tx_line_delay_ms=%dms", g_auxSerialCom_tx_line_delay_ms);
whismanoid 10:04022a61b527 6073 }
whismanoid 10:04022a61b527 6074 #endif
whismanoid 10:04022a61b527 6075 // int g_auxSerialCom_message_ms = 0; //!< capture RX until response timeout?
whismanoid 10:04022a61b527 6076 if (cmdLine.parse_int_dec("message_ms", g_auxSerialCom_message_ms))
whismanoid 10:04022a61b527 6077 {
whismanoid 10:04022a61b527 6078 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 10:04022a61b527 6079 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 6080 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 6081 }
whismanoid 10:04022a61b527 6082 // int g_auxSerialCom_rx_idle_ms = 0; //!< capture RX until idle timeout?
whismanoid 10:04022a61b527 6083 if (cmdLine.parse_int_dec("rx_idle_ms", g_auxSerialCom_rx_idle_ms))
whismanoid 10:04022a61b527 6084 {
whismanoid 10:04022a61b527 6085 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_idle_ms
whismanoid 10:04022a61b527 6086 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_idle_ms was set to %d ***\r\n", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 6087 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 6088 }
whismanoid 10:04022a61b527 6089 // int g_auxSerialCom_rx_max_count = 0; //!< capture RX until max character count?
whismanoid 10:04022a61b527 6090 if (cmdLine.parse_int_dec("rx_max_count", g_auxSerialCom_rx_max_count))
whismanoid 10:04022a61b527 6091 {
whismanoid 10:04022a61b527 6092 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_max_count
whismanoid 10:04022a61b527 6093 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_max_count was set to %d ***\r\n", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 6094 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 6095 }
whismanoid 10:04022a61b527 6096 // int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text char?
whismanoid 10:04022a61b527 6097 if (cmdLine.parse_int_dec("rx_eot", g_auxSerialCom_rx_eot))
whismanoid 10:04022a61b527 6098 {
whismanoid 10:04022a61b527 6099 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_eot
whismanoid 10:04022a61b527 6100 //~ cmdLine_AUXserial.serial().printf("\r\n*** rx_eot was set to %d ***\r\n", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 6101 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 6102 }
whismanoid 10:04022a61b527 6103 }
whismanoid 10:04022a61b527 6104 // Command forwarding to AUX serial TX/RX cmdLine_AuxSerial #257 -- send outgoing_string
whismanoid 41:13a6a097502c 6105 char* outgoing_string = ""; // warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
whismanoid 40:330b28116178 6106 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 6107 outgoing_string = (char*)cmdLine.str();
whismanoid 40:330b28116178 6108 // > use key=value parsing
whismanoid 40:330b28116178 6109 // >> suppress key=value parsing
whismanoid 40:330b28116178 6110 if (suppress_parsing) {
whismanoid 40:330b28116178 6111 cmdLine.serial().printf("\r\n suppress_parsing outgoing_string=\"%s\"", outgoing_string);
whismanoid 40:330b28116178 6112 outgoing_string++; // skip the first '>'
whismanoid 40:330b28116178 6113 outgoing_string++; // skip the second '>'
whismanoid 40:330b28116178 6114 } else {
whismanoid 40:330b28116178 6115 // TODO: after parsing, key=value pairs should be deleted, but outgoing_string=">xyzzy abc=def"
whismanoid 40:330b28116178 6116 cmdLine.serial().printf("\r\n after parsing, outgoing_string=\"%s\"", outgoing_string);
whismanoid 40:330b28116178 6117 outgoing_string++; // skip the first '>'
whismanoid 40:330b28116178 6118 }
whismanoid 40:330b28116178 6119 } // if (cmdLine[0] == '>')
whismanoid 10:04022a61b527 6120 static char rx_string_buf[RX_STRING_BUF_SIZE];
whismanoid 10:04022a61b527 6121 unsigned int rx_string_length = 0;
whismanoid 40:330b28116178 6122 //cmdLine.serial().printf("\r\n >%s\r\n <", outgoing_string);
whismanoid 40:330b28116178 6123 //char* g_auxSerialCom_display_tx_prefix = "\r\n >";
whismanoid 40:330b28116178 6124 //char* g_auxSerialCom_display_rx_prefix = "\r\n< ";
whismanoid 40:330b28116178 6125 cmdLine.serial().printf("%s%s%s",
whismanoid 40:330b28116178 6126 g_auxSerialCom_display_tx_prefix, // "\r\n >"
whismanoid 40:330b28116178 6127 outgoing_string,
whismanoid 40:330b28116178 6128 g_auxSerialCom_display_rx_prefix // "\r\n <"
whismanoid 40:330b28116178 6129 );
whismanoid 10:04022a61b527 6130 rx_string_buf[0] = '\0';
whismanoid 10:04022a61b527 6131 rx_string_length = 0;
whismanoid 10:04022a61b527 6132 //
whismanoid 10:04022a61b527 6133 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 6134 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 6135 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 6136 //
whismanoid 10:04022a61b527 6137 // int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 6138 // int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 6139 // int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 6140 // int g_auxSerialCom_rx_idle_ms = 2000; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 6141 // int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 6142 // int g_auxSerialCom_rx_eot = '\r'; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 6143 //~ cmdLine_AuxSerial.serial().printf("\r\n*** TODO forward %s ***\r\n", outgoing_string);
whismanoid 10:04022a61b527 6144 //
whismanoid 10:04022a61b527 6145 // TODO: send whole string or send character-by-character?
whismanoid 40:330b28116178 6146 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 6147 cmdLine_AuxSerial.serial().printf("%s", outgoing_string);
whismanoid 40:330b28116178 6148 //
whismanoid 40:330b28116178 6149 // TODO: send CRLF or just send CR line end?
whismanoid 40:330b28116178 6150 if (g_auxSerialCom_outgoing_string_cr) { cmdLine_AuxSerial.serial().printf("\r"); }
whismanoid 40:330b28116178 6151 if (g_auxSerialCom_outgoing_string_lf) { cmdLine_AuxSerial.serial().printf("\n"); }
whismanoid 40:330b28116178 6152 // cmdLine_AuxSerial.serial().printf("\r\n");
whismanoid 40:330b28116178 6153 } // if (cmdLine[0] == '>')
whismanoid 40:330b28116178 6154 //
whismanoid 10:04022a61b527 6155 g_auxSerialCom_Timer.start();
whismanoid 10:04022a61b527 6156 g_auxSerialCom_Timer_begin_message_ms = g_auxSerialCom_Timer.read_ms(); // start of message
whismanoid 10:04022a61b527 6157 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 6158 while (rx_string_length < (RX_STRING_BUF_SIZE-1)) {
whismanoid 10:04022a61b527 6159 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_message_ms) > g_auxSerialCom_message_ms) {
whismanoid 10:04022a61b527 6160 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 6161 break;
whismanoid 10:04022a61b527 6162 }
whismanoid 10:04022a61b527 6163 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_rx_idle_ms) > g_auxSerialCom_rx_idle_ms) {
whismanoid 10:04022a61b527 6164 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 6165 break;
whismanoid 10:04022a61b527 6166 }
whismanoid 41:13a6a097502c 6167 if ((int)rx_string_length >= g_auxSerialCom_rx_max_count) {
whismanoid 10:04022a61b527 6168 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 6169 break;
whismanoid 10:04022a61b527 6170 }
whismanoid 10:04022a61b527 6171 if (AuxSerial.readable()) {
whismanoid 10:04022a61b527 6172 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 6173 char ch = AuxSerial.getc();
whismanoid 10:04022a61b527 6174 rx_string_buf[rx_string_length++] = ch;
whismanoid 10:04022a61b527 6175 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 40:330b28116178 6176 //
whismanoid 40:330b28116178 6177 #if 1
whismanoid 40:330b28116178 6178 // immediate character echo
whismanoid 40:330b28116178 6179 for (char* cp = &(rx_string_buf[rx_string_length-1]); *cp != '\0'; cp++)
whismanoid 40:330b28116178 6180 {
whismanoid 40:330b28116178 6181 //cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 6182 if (need_g_auxSerialCom_display_rx_prefix) {
whismanoid 40:330b28116178 6183 cmdLine.serial().printf(g_auxSerialCom_display_rx_prefix); // "\r\n< " g_auxSerialCom_rx_string display prefix
whismanoid 40:330b28116178 6184 need_g_auxSerialCom_display_rx_prefix = 0;
whismanoid 40:330b28116178 6185 }
whismanoid 40:330b28116178 6186 if ((*cp) == '\r') {
whismanoid 40:330b28116178 6187 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\r"); }
whismanoid 40:330b28116178 6188 // if (*(cp+1) != '\n') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 6189 } else if ((*cp) == '\n') {
whismanoid 40:330b28116178 6190 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\n"); }
whismanoid 40:330b28116178 6191 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 6192 if (*(cp-1) != '\r') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 6193 } else if ((*cp) < 0x20) {
whismanoid 40:330b28116178 6194 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6195 } else if ((*cp) >= 0x7f) {
whismanoid 40:330b28116178 6196 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6197 } else {
whismanoid 40:330b28116178 6198 cmdLine.serial().printf("%c", *cp);
whismanoid 40:330b28116178 6199 }
whismanoid 40:330b28116178 6200 }
whismanoid 40:330b28116178 6201 #else
whismanoid 40:330b28116178 6202 // immediate character echo
whismanoid 40:330b28116178 6203 cmdLine.serial().printf("%s", &(rx_string_buf[rx_string_length-1]) );
whismanoid 40:330b28116178 6204 #endif
whismanoid 40:330b28116178 6205 //
whismanoid 10:04022a61b527 6206 if (g_auxSerialCom_rx_eot != aux_serial_cmd_forwarding_rx_eot_not_used) {
whismanoid 10:04022a61b527 6207 if (ch == g_auxSerialCom_rx_eot) {
whismanoid 10:04022a61b527 6208 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 6209 break;
whismanoid 10:04022a61b527 6210 }
whismanoid 10:04022a61b527 6211 }
whismanoid 10:04022a61b527 6212 }
whismanoid 10:04022a61b527 6213 } // end while (rx_string_length < (RX_STRING_BUF_SIZE-1))
whismanoid 40:330b28116178 6214 #if 0
whismanoid 10:04022a61b527 6215 // print summary. is this needed? we already print aux rx as it is received.
whismanoid 10:04022a61b527 6216 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 40:330b28116178 6217 # if 1 // support multi-line rx_string_buf response
whismanoid 40:330b28116178 6218 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 6219 cmdLine.serial().printf("%s%s", g_auxSerialCom_display_tx_prefix, outgoing_string);
whismanoid 40:330b28116178 6220 } // if (cmdLine[0] == '>')
whismanoid 40:330b28116178 6221 // cmdLine.serial().printf("\r\n <"); // prefix
whismanoid 40:330b28116178 6222 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 6223 for (char* cp = rx_string_buf; *cp != '\0'; cp++)
whismanoid 40:330b28116178 6224 {
whismanoid 40:330b28116178 6225 //cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 6226 if (need_g_auxSerialCom_display_rx_prefix) {
whismanoid 40:330b28116178 6227 cmdLine.serial().printf(g_auxSerialCom_display_rx_prefix); // "\r\n< " g_auxSerialCom_rx_string display prefix
whismanoid 40:330b28116178 6228 need_g_auxSerialCom_display_rx_prefix = 0;
whismanoid 40:330b28116178 6229 }
whismanoid 40:330b28116178 6230 if ((*cp) == '\r') {
whismanoid 40:330b28116178 6231 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\r"); }
whismanoid 40:330b28116178 6232 if (*(cp+1) != '\n') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 6233 } else if ((*cp) == '\n') {
whismanoid 40:330b28116178 6234 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\n"); }
whismanoid 40:330b28116178 6235 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 6236 } else if ((*cp) < 0x20) {
whismanoid 40:330b28116178 6237 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6238 } else if ((*cp) >= 0x7f) {
whismanoid 40:330b28116178 6239 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6240 } else {
whismanoid 40:330b28116178 6241 cmdLine.serial().printf("%c", *cp);
whismanoid 40:330b28116178 6242 }
whismanoid 40:330b28116178 6243 }
whismanoid 40:330b28116178 6244 cmdLine.serial().printf("\r\n");
whismanoid 40:330b28116178 6245 # else
whismanoid 10:04022a61b527 6246 cmdLine.serial().printf("\r\n >%s", outgoing_string);
whismanoid 10:04022a61b527 6247 cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 6248 # endif
whismanoid 10:04022a61b527 6249 #endif
whismanoid 10:04022a61b527 6250 //
whismanoid 10:04022a61b527 6251 }
whismanoid 10:04022a61b527 6252 break; // case '>'
whismanoid 10:04022a61b527 6253 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6254 //
whismanoid 4:d9b05924ad4c 6255 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 6256 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 6257 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 6258 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 6259 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible
whismanoid 9:45f98573eb6d 6260 case 'L': case 'l':
whismanoid 4:d9b05924ad4c 6261 {
whismanoid 4:d9b05924ad4c 6262 // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 6263 Datalogger_Trigger = trigger_Halt;
whismanoid 4:d9b05924ad4c 6264 switch (cmdLine[1])
whismanoid 4:d9b05924ad4c 6265 {
whismanoid 17:9397ea3ea7e9 6266 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 6267 case 'T': case 't':
whismanoid 17:9397ea3ea7e9 6268 {
whismanoid 17:9397ea3ea7e9 6269 // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 6270 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 6271 Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6272 g_timer_interval_counter = 0;
whismanoid 39:4d285e961435 6273 // get g_timer_interval_msec from cmdLine
whismanoid 17:9397ea3ea7e9 6274 // g_timer_interval_msec = 500;
whismanoid 17:9397ea3ea7e9 6275 // g_timer_interval_count = 10;
whismanoid 17:9397ea3ea7e9 6276 if (cmdLine.parse_int_dec("count", g_timer_interval_count))
whismanoid 17:9397ea3ea7e9 6277 {
whismanoid 32:80f3e5eb77d4 6278 if (g_timer_interval_count < 1) { g_timer_interval_count = 1; }
whismanoid 17:9397ea3ea7e9 6279 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 6280 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 6281 cmdLine.serial().printf("\r\n g_timer_interval_count=%d", g_timer_interval_count);
whismanoid 17:9397ea3ea7e9 6282 }
whismanoid 17:9397ea3ea7e9 6283 if (cmdLine.parse_int_dec("base", g_timer_interval_msec))
whismanoid 17:9397ea3ea7e9 6284 {
whismanoid 17:9397ea3ea7e9 6285 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 6286 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 6287 cmdLine.serial().printf("\r\n g_timer_interval_msec=%d", g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 6288 }
whismanoid 39:4d285e961435 6289 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 6290 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 6291 int int_timer_sleepmode = g_timer_sleepmode;
whismanoid 39:4d285e961435 6292 if (cmdLine.parse_int_dec("sleep", int_timer_sleepmode))
whismanoid 39:4d285e961435 6293 {
whismanoid 39:4d285e961435 6294 g_timer_sleepmode = (Datalogger_Sleep_enum_t)int_timer_sleepmode;
whismanoid 39:4d285e961435 6295 //~ if (g_timer_interval_count < 1) { g_timer_interval_count = 1; }
whismanoid 39:4d285e961435 6296 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 39:4d285e961435 6297 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 39:4d285e961435 6298 cmdLine.serial().printf("\r\n g_timer_sleepmode=%d", (int)g_timer_sleepmode);
whismanoid 39:4d285e961435 6299 }
whismanoid 39:4d285e961435 6300 #else // USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 6301 #endif // USE_DATALOGGER_SLEEP
whismanoid 17:9397ea3ea7e9 6302 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 17:9397ea3ea7e9 6303 }
whismanoid 17:9397ea3ea7e9 6304 break;
whismanoid 17:9397ea3ea7e9 6305 // LIH3 -- Datalog when input high D3
whismanoid 17:9397ea3ea7e9 6306 // LIL6 -- Datalog when input low D6
whismanoid 17:9397ea3ea7e9 6307 case 'I': case 'i':
whismanoid 17:9397ea3ea7e9 6308 {
whismanoid 17:9397ea3ea7e9 6309 // TODO: switch cmdLine[2] configure High or Low, configure input pin
whismanoid 17:9397ea3ea7e9 6310 }
whismanoid 17:9397ea3ea7e9 6311 break;
whismanoid 17:9397ea3ea7e9 6312 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 6313 // L$ count=10 base=500ms addr=xxx data=xxx mask=xxx -- Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 6314 case '$':
whismanoid 17:9397ea3ea7e9 6315 {
whismanoid 17:9397ea3ea7e9 6316 // TODO: scan cmdLine for regAddr, dataMask, testValue
whismanoid 17:9397ea3ea7e9 6317 }
whismanoid 17:9397ea3ea7e9 6318 break;
whismanoid 17:9397ea3ea7e9 6319 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6320 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6321 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6322 case '@':
whismanoid 17:9397ea3ea7e9 6323 {
whismanoid 17:9397ea3ea7e9 6324 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6325 int editRowIndex = 0;
whismanoid 17:9397ea3ea7e9 6326 int edit_action = (int)action_noop;
whismanoid 17:9397ea3ea7e9 6327 int edit_digitalOutPin = 0;
whismanoid 17:9397ea3ea7e9 6328 int edit_condition = (int)condition_always;
whismanoid 17:9397ea3ea7e9 6329 int edit_condition_channel = 0;
whismanoid 17:9397ea3ea7e9 6330 double edit_condition_threshold = 0;
whismanoid 17:9397ea3ea7e9 6331 //
whismanoid 17:9397ea3ea7e9 6332 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 17:9397ea3ea7e9 6333 {
whismanoid 17:9397ea3ea7e9 6334 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 17:9397ea3ea7e9 6335 }
whismanoid 17:9397ea3ea7e9 6336 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 17:9397ea3ea7e9 6337 {
whismanoid 17:9397ea3ea7e9 6338 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 17:9397ea3ea7e9 6339 }
whismanoid 17:9397ea3ea7e9 6340 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 17:9397ea3ea7e9 6341 {
whismanoid 17:9397ea3ea7e9 6342 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 17:9397ea3ea7e9 6343 }
whismanoid 17:9397ea3ea7e9 6344 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 17:9397ea3ea7e9 6345 {
whismanoid 17:9397ea3ea7e9 6346 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 17:9397ea3ea7e9 6347 }
whismanoid 17:9397ea3ea7e9 6348 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 17:9397ea3ea7e9 6349 {
whismanoid 17:9397ea3ea7e9 6350 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 17:9397ea3ea7e9 6351 }
whismanoid 17:9397ea3ea7e9 6352 //
whismanoid 17:9397ea3ea7e9 6353 // Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6354 switch (cmdLine[2]) // L@... -- Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6355 {
whismanoid 17:9397ea3ea7e9 6356 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 6357 case '0': case '1': case '2': case '3': case '4':
whismanoid 17:9397ea3ea7e9 6358 case '5': case '6': case '7': case '8': case '9':
whismanoid 17:9397ea3ea7e9 6359 // edit row data
whismanoid 30:07197a430869 6360 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 6361 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 6362 // get row number to edit from cmdLine[2]
whismanoid 17:9397ea3ea7e9 6363 editRowIndex = atoi(cmdLine.str()+2);
whismanoid 30:07197a430869 6364 if ((editRowIndex >= 0) && (editRowIndex < Datalogger_action_table_row_count)) {
whismanoid 30:07197a430869 6365 // update row
whismanoid 30:07197a430869 6366 cmdLine.serial().printf("\r\n replace row %d", editRowIndex);
whismanoid 30:07197a430869 6367 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 6368 edit_action = Datalogger_action_table[editRowIndex].action;
whismanoid 30:07197a430869 6369 edit_digitalOutPin = Datalogger_action_table[editRowIndex].digitalOutPin;
whismanoid 30:07197a430869 6370 edit_condition = Datalogger_action_table[editRowIndex].condition;
whismanoid 30:07197a430869 6371 edit_condition_channel = Datalogger_action_table[editRowIndex].condition_channel;
whismanoid 30:07197a430869 6372 edit_condition_threshold = Datalogger_action_table[editRowIndex].condition_threshold;
whismanoid 30:07197a430869 6373 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 6374 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 30:07197a430869 6375 {
whismanoid 30:07197a430869 6376 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 30:07197a430869 6377 }
whismanoid 30:07197a430869 6378 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 30:07197a430869 6379 {
whismanoid 30:07197a430869 6380 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 30:07197a430869 6381 }
whismanoid 30:07197a430869 6382 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 30:07197a430869 6383 {
whismanoid 30:07197a430869 6384 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 30:07197a430869 6385 }
whismanoid 30:07197a430869 6386 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 30:07197a430869 6387 {
whismanoid 30:07197a430869 6388 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 30:07197a430869 6389 }
whismanoid 30:07197a430869 6390 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 30:07197a430869 6391 {
whismanoid 30:07197a430869 6392 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 30:07197a430869 6393 }
whismanoid 30:07197a430869 6394 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 6395 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 6396 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 6397 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 6398 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 6399 }
whismanoid 30:07197a430869 6400 else if ((editRowIndex == Datalogger_action_table_row_count) && (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX)) {
whismanoid 30:07197a430869 6401 // %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 6402 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 6403 cmdLine.serial().printf("\r\n add next row %d", editRowIndex);
whismanoid 30:07197a430869 6404 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 6405 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 6406 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 6407 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 6408 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 30:07197a430869 6409 //
whismanoid 17:9397ea3ea7e9 6410 }
whismanoid 17:9397ea3ea7e9 6411 }
whismanoid 17:9397ea3ea7e9 6412 break;
whismanoid 17:9397ea3ea7e9 6413 case '+':
whismanoid 17:9397ea3ea7e9 6414 // add a new row at end of table
whismanoid 17:9397ea3ea7e9 6415 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 6416 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 6417 editRowIndex = Datalogger_action_table_row_count;
whismanoid 17:9397ea3ea7e9 6418 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 6419 cmdLine.serial().printf("\r\n add new row %d", editRowIndex);
whismanoid 17:9397ea3ea7e9 6420 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 17:9397ea3ea7e9 6421 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 17:9397ea3ea7e9 6422 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 17:9397ea3ea7e9 6423 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 17:9397ea3ea7e9 6424 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 6425 }
whismanoid 17:9397ea3ea7e9 6426 break;
whismanoid 17:9397ea3ea7e9 6427 case '-':
whismanoid 17:9397ea3ea7e9 6428 // delete row from table
whismanoid 17:9397ea3ea7e9 6429 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 6430 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 6431 if ((cmdLine[3] == '~') && (cmdLine[4] == '~') && (cmdLine[5] == '~')) {
whismanoid 17:9397ea3ea7e9 6432 // L@-~~~ -- delete all rows from table
whismanoid 30:07197a430869 6433 cmdLine.serial().printf("\r\n delete all rows");
whismanoid 17:9397ea3ea7e9 6434 Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 6435 break;
whismanoid 17:9397ea3ea7e9 6436 }
whismanoid 30:07197a430869 6437 else {
whismanoid 30:07197a430869 6438 editRowIndex = atoi(cmdLine.str()+3);
whismanoid 30:07197a430869 6439 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 30:07197a430869 6440 // delete row editRowIndex from Datalogger_action_table
whismanoid 30:07197a430869 6441 for (int i = editRowIndex; i < (Datalogger_action_table_row_count-1); i++)
whismanoid 30:07197a430869 6442 {
whismanoid 30:07197a430869 6443 // copy row i+1 into row i
whismanoid 30:07197a430869 6444 Datalogger_action_table[i].action = Datalogger_action_table[i+1].action;
whismanoid 30:07197a430869 6445 Datalogger_action_table[i].digitalOutPin = Datalogger_action_table[i+1].digitalOutPin;
whismanoid 30:07197a430869 6446 Datalogger_action_table[i].condition = Datalogger_action_table[i+1].condition;
whismanoid 30:07197a430869 6447 Datalogger_action_table[i].condition_channel = Datalogger_action_table[i+1].condition_channel;
whismanoid 30:07197a430869 6448 Datalogger_action_table[i].condition_threshold = Datalogger_action_table[i+1].condition_threshold;
whismanoid 30:07197a430869 6449 }
whismanoid 30:07197a430869 6450 Datalogger_action_table_row_count--;
whismanoid 17:9397ea3ea7e9 6451 }
whismanoid 17:9397ea3ea7e9 6452 }
whismanoid 17:9397ea3ea7e9 6453 break;
whismanoid 30:07197a430869 6454 case '.':
whismanoid 30:07197a430869 6455 // L@. pause the entire Log action table
whismanoid 30:07197a430869 6456 cmdLine.serial().printf("\r\n pause the entire Log action table");
whismanoid 17:9397ea3ea7e9 6457 Datalogger_action_table_enabled = false;
whismanoid 17:9397ea3ea7e9 6458 break;
whismanoid 17:9397ea3ea7e9 6459 case '@':
whismanoid 30:07197a430869 6460 // L@@ enable the entire Log action table
whismanoid 30:07197a430869 6461 cmdLine.serial().printf("\r\n enable the entire Log action table");
whismanoid 17:9397ea3ea7e9 6462 Datalogger_action_table_enabled = true;
whismanoid 17:9397ea3ea7e9 6463 break;
whismanoid 17:9397ea3ea7e9 6464 }
whismanoid 17:9397ea3ea7e9 6465 //
whismanoid 17:9397ea3ea7e9 6466 // Print the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6467 if (Datalogger_action_table_enabled) {
whismanoid 30:07197a430869 6468 // cmdLine.serial().printf("Log action table enabled; L@. to pause");
whismanoid 17:9397ea3ea7e9 6469 }
whismanoid 17:9397ea3ea7e9 6470 else {
whismanoid 30:07197a430869 6471 cmdLine.serial().printf("Log action table paused; L@@ to enable");
whismanoid 17:9397ea3ea7e9 6472 }
whismanoid 17:9397ea3ea7e9 6473 //~ cmdLine.serial().printf("\r\n Datalogger_action_table_row_count=%d", Datalogger_action_table_row_count);
whismanoid 17:9397ea3ea7e9 6474 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 6475 {
whismanoid 17:9397ea3ea7e9 6476 cmdLine.serial().printf("\r\n L@%d", i);
whismanoid 17:9397ea3ea7e9 6477 cmdLine.serial().printf(" act=%d", Datalogger_action_table[i].action);
whismanoid 17:9397ea3ea7e9 6478 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6479 {
whismanoid 17:9397ea3ea7e9 6480 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 6481 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 6482 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6483 break;
whismanoid 29:6a9edb6e973b 6484 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6485 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 6486 break;
whismanoid 17:9397ea3ea7e9 6487 default:
whismanoid 17:9397ea3ea7e9 6488 case action_noop:
whismanoid 17:9397ea3ea7e9 6489 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 6490 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 6491 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 6492 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 6493 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 6494 break;
whismanoid 17:9397ea3ea7e9 6495 }
whismanoid 17:9397ea3ea7e9 6496 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6497 {
whismanoid 17:9397ea3ea7e9 6498 case condition_always:
whismanoid 17:9397ea3ea7e9 6499 break;
whismanoid 17:9397ea3ea7e9 6500 default:
whismanoid 17:9397ea3ea7e9 6501 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 6502 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 6503 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 6504 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 6505 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 6506 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 6507 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 6508 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 6509 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 6510 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 6511 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 6512 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 6513 cmdLine.serial().printf(" if=%d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 6514 cmdLine.serial().printf(" ch=%d", Datalogger_action_table[i].condition_channel);
whismanoid 40:330b28116178 6515 // our voltage measurement is around 1mV at best
whismanoid 40:330b28116178 6516 cmdLine.serial().printf(" x=%1.4f", Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6517 break;
whismanoid 17:9397ea3ea7e9 6518 }
whismanoid 17:9397ea3ea7e9 6519 cmdLine.serial().printf(" -- ");
whismanoid 17:9397ea3ea7e9 6520 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6521 {
whismanoid 17:9397ea3ea7e9 6522 case action_noop:
whismanoid 17:9397ea3ea7e9 6523 cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 6524 break;
whismanoid 17:9397ea3ea7e9 6525 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 6526 cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 6527 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6528 break;
whismanoid 17:9397ea3ea7e9 6529 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 6530 cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 6531 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6532 break;
whismanoid 29:6a9edb6e973b 6533 case action_button: // pin = button index 1, 2, 3
whismanoid 40:330b28116178 6534 cmdLine.serial().printf("button %%B%d!", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 6535 break;
whismanoid 17:9397ea3ea7e9 6536 case action_trigger_Halt:
whismanoid 40:330b28116178 6537 cmdLine.serial().printf("Halt");
whismanoid 17:9397ea3ea7e9 6538 break;
whismanoid 17:9397ea3ea7e9 6539 case action_trigger_FreeRun:
whismanoid 40:330b28116178 6540 cmdLine.serial().printf("LR");
whismanoid 17:9397ea3ea7e9 6541 break;
whismanoid 17:9397ea3ea7e9 6542 case action_trigger_Timer:
whismanoid 45:74bf1fe021e5 6543 cmdLine.serial().printf("LT count=%d base=%dms", g_timer_interval_count, g_timer_interval_msec);
whismanoid 45:74bf1fe021e5 6544 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 6545 cmdLine.serial().printf(" sleep=%d", g_timer_sleepmode);
whismanoid 45:74bf1fe021e5 6546 #endif // USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 17:9397ea3ea7e9 6547 break;
whismanoid 17:9397ea3ea7e9 6548 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 6549 cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 6550 // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 6551 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 6552 break;
whismanoid 17:9397ea3ea7e9 6553 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 6554 cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 6555 // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6556 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 6557 break;
whismanoid 17:9397ea3ea7e9 6558 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6559 //~ cmdLine.serial().printf(" condition %d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 6560 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6561 {
whismanoid 17:9397ea3ea7e9 6562 case condition_always:
whismanoid 17:9397ea3ea7e9 6563 cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 6564 break;
whismanoid 17:9397ea3ea7e9 6565 case condition_if_An_gt_threshold:
whismanoid 40:330b28116178 6566 cmdLine.serial().printf(" if A%d > %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6567 break;
whismanoid 17:9397ea3ea7e9 6568 case condition_if_An_lt_threshold:
whismanoid 40:330b28116178 6569 cmdLine.serial().printf(" if A%d < %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6570 break;
whismanoid 17:9397ea3ea7e9 6571 case condition_if_An_eq_threshold:
whismanoid 40:330b28116178 6572 cmdLine.serial().printf(" if A%d == %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6573 break;
whismanoid 17:9397ea3ea7e9 6574 case condition_if_An_ge_threshold:
whismanoid 40:330b28116178 6575 cmdLine.serial().printf(" if A%d >= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6576 break;
whismanoid 17:9397ea3ea7e9 6577 case condition_if_An_le_threshold:
whismanoid 40:330b28116178 6578 cmdLine.serial().printf(" if A%d <= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6579 break;
whismanoid 17:9397ea3ea7e9 6580 case condition_if_An_ne_threshold:
whismanoid 40:330b28116178 6581 cmdLine.serial().printf(" if A%d != %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6582 break;
whismanoid 17:9397ea3ea7e9 6583 case condition_if_AINn_gt_threshold:
whismanoid 40:330b28116178 6584 cmdLine.serial().printf(" if AIN%d > %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6585 break;
whismanoid 17:9397ea3ea7e9 6586 case condition_if_AINn_lt_threshold:
whismanoid 40:330b28116178 6587 cmdLine.serial().printf(" if AIN%d < %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6588 break;
whismanoid 17:9397ea3ea7e9 6589 case condition_if_AINn_eq_threshold:
whismanoid 40:330b28116178 6590 cmdLine.serial().printf(" if AIN%d == %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6591 break;
whismanoid 17:9397ea3ea7e9 6592 case condition_if_AINn_ge_threshold:
whismanoid 40:330b28116178 6593 cmdLine.serial().printf(" if AIN%d >= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6594 break;
whismanoid 17:9397ea3ea7e9 6595 case condition_if_AINn_le_threshold:
whismanoid 40:330b28116178 6596 cmdLine.serial().printf(" if AIN%d <= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6597 break;
whismanoid 17:9397ea3ea7e9 6598 case condition_if_AINn_ne_threshold:
whismanoid 40:330b28116178 6599 cmdLine.serial().printf(" if AIN%d != %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6600 break;
whismanoid 17:9397ea3ea7e9 6601 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6602 } // for ...Datalogger_action_table_row_count // Print the contents of Datalogger_action_table
whismanoid 30:07197a430869 6603 cmdLine.serial().printf("\r\n\r\nEdit Log action table (used %d/%d, %d free):",
whismanoid 30:07197a430869 6604 Datalogger_action_table_row_count,
whismanoid 30:07197a430869 6605 ACTION_TABLE_ROW_MAX,
whismanoid 30:07197a430869 6606 (ACTION_TABLE_ROW_MAX - Datalogger_action_table_row_count)
whismanoid 30:07197a430869 6607 );
whismanoid 17:9397ea3ea7e9 6608 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 6609 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 6610 cmdLine.serial().printf("\r\n L@+ act=4 if=1 ch=5 x=12345 -- add new entry at end of table");
whismanoid 17:9397ea3ea7e9 6611 }
whismanoid 17:9397ea3ea7e9 6612 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 6613 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 6614 cmdLine.serial().printf("\r\n L@%d act=4 if=1 ch=5 x=12345 -- edit row %d",
whismanoid 17:9397ea3ea7e9 6615 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 6616 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 6617 cmdLine.serial().printf("\r\n L@-%d -- delete row %d",
whismanoid 17:9397ea3ea7e9 6618 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 6619 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 6620 cmdLine.serial().printf("\r\n L@-~~~ -- delete all rows");
whismanoid 30:07197a430869 6621 if (Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@. -- pause entire Log action table");
whismanoid 30:07197a430869 6622 if (!Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@@ -- enable Log action table");
whismanoid 17:9397ea3ea7e9 6623 }
whismanoid 17:9397ea3ea7e9 6624 //
whismanoid 17:9397ea3ea7e9 6625 } // case L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6626 break;
whismanoid 17:9397ea3ea7e9 6627 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6628 // LR -- Datalog free run as fast as possible
whismanoid 4:d9b05924ad4c 6629 case 'R': case 'r':
whismanoid 4:d9b05924ad4c 6630 // free run as fast as possible
whismanoid 8:dffee7509bfb 6631 Datalogger_Trigger = trigger_FreeRun;
whismanoid 8:dffee7509bfb 6632 Datalogger_Need_PrintHeader = true;
whismanoid 4:d9b05924ad4c 6633 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 9:45f98573eb6d 6634 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6635 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 6636 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 6637 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 6638 case 'S': case 's':
whismanoid 9:45f98573eb6d 6639 {
whismanoid 9:45f98573eb6d 6640 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6641 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 6642 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 6643 )
whismanoid 9:45f98573eb6d 6644 {
whismanoid 9:45f98573eb6d 6645 // it's me
whismanoid 9:45f98573eb6d 6646 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 6647 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 6648 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 6649 {
whismanoid 9:45f98573eb6d 6650 case 'D': case 'd':
whismanoid 9:45f98573eb6d 6651 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Disable;
whismanoid 9:45f98573eb6d 6652 break;
whismanoid 9:45f98573eb6d 6653 case 'L': case 'l':
whismanoid 9:45f98573eb6d 6654 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 6655 break;
whismanoid 9:45f98573eb6d 6656 case 'V': case 'v':
whismanoid 9:45f98573eb6d 6657 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 6658 break;
whismanoid 9:45f98573eb6d 6659 //
whismanoid 9:45f98573eb6d 6660 //
whismanoid 9:45f98573eb6d 6661 // TODO: MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 6662 case 'C': case 'c':
whismanoid 9:45f98573eb6d 6663 {
whismanoid 9:45f98573eb6d 6664 uint8_t hexValue = 0;
whismanoid 9:45f98573eb6d 6665 hexValue = hexValueOfChar(cmdLine[5]) * 0x10 + hexValueOfChar(cmdLine[6]);
whismanoid 9:45f98573eb6d 6666 switch (cmdLine[4])
whismanoid 9:45f98573eb6d 6667 {
whismanoid 9:45f98573eb6d 6668 //
whismanoid 9:45f98573eb6d 6669 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 6670 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34"));
whismanoid 9:45f98573eb6d 6671 case 'F': case 'f':
whismanoid 9:45f98573eb6d 6672 SPI_AIN_Cfg_v_filter_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 6673 break;
whismanoid 9:45f98573eb6d 6674 //
whismanoid 9:45f98573eb6d 6675 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 6676 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 6677 case 'C': case 'c':
whismanoid 9:45f98573eb6d 6678 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 6679 break;
whismanoid 9:45f98573eb6d 6680 //
whismanoid 9:45f98573eb6d 6681 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 6682 // cmdLine.serial().print(F("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00"));
whismanoid 9:45f98573eb6d 6683 case 'P': case 'p':
whismanoid 9:45f98573eb6d 6684 SPI_AIN_Cfg_v_pga_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 6685 break;
whismanoid 9:45f98573eb6d 6686 //
whismanoid 9:45f98573eb6d 6687 // cmdLine.serial().print(F("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar"));
whismanoid 9:45f98573eb6d 6688 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 6689 case 'U': case 'u':
whismanoid 9:45f98573eb6d 6690 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] | 0x40;
whismanoid 9:45f98573eb6d 6691 break;
whismanoid 9:45f98573eb6d 6692 //
whismanoid 9:45f98573eb6d 6693 // cmdLine.serial().print(F("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar"));
whismanoid 9:45f98573eb6d 6694 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 6695 case 'B': case 'b':
whismanoid 9:45f98573eb6d 6696 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] &~ 0x40;
whismanoid 9:45f98573eb6d 6697 break;
whismanoid 9:45f98573eb6d 6698 }
whismanoid 9:45f98573eb6d 6699 break;
whismanoid 9:45f98573eb6d 6700 }
whismanoid 9:45f98573eb6d 6701 //
whismanoid 9:45f98573eb6d 6702 //
whismanoid 9:45f98573eb6d 6703 }
whismanoid 9:45f98573eb6d 6704 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 6705 } // end for channel_index
whismanoid 9:45f98573eb6d 6706 Datalogger_PrintHeader();
whismanoid 9:45f98573eb6d 6707 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6708 }
whismanoid 9:45f98573eb6d 6709 break;
whismanoid 9:45f98573eb6d 6710 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6711 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 6712 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 6713 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 6714 // verb: D for disable, V for Voltage, L for LSB
whismanoid 8:dffee7509bfb 6715 case 'A': case 'a':
whismanoid 9:45f98573eb6d 6716 {
whismanoid 9:45f98573eb6d 6717 // all-channel: loop through all valid channel_index, test cmdLine[2] 'is it me'?
whismanoid 9:45f98573eb6d 6718 // for channel_index loop through 0..NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 9:45f98573eb6d 6719 // if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 6720 // || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 6721 // ) {
whismanoid 9:45f98573eb6d 6722 // // it's me
whismanoid 9:45f98573eb6d 6723 // // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 6724 // // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 6725 // } end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 6726 // } end for channel_index
whismanoid 9:45f98573eb6d 6727 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6728 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 6729 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 6730 )
whismanoid 9:45f98573eb6d 6731 {
whismanoid 9:45f98573eb6d 6732 // it's me
whismanoid 9:45f98573eb6d 6733 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 6734 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 6735 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 6736 {
whismanoid 9:45f98573eb6d 6737 case 'D': case 'd':
whismanoid 9:45f98573eb6d 6738 Platform_Enable_ch[channel_index] = Platform_AIN_Disable;
whismanoid 9:45f98573eb6d 6739 break;
whismanoid 9:45f98573eb6d 6740 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 6741 case 'L': case 'l':
whismanoid 9:45f98573eb6d 6742 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 6743 break;
whismanoid 9:45f98573eb6d 6744 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 6745 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 6746 case 'V': case 'v':
whismanoid 9:45f98573eb6d 6747 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 6748 break;
whismanoid 9:45f98573eb6d 6749 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 6750 }
whismanoid 9:45f98573eb6d 6751 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 6752 } // end for channel_index
whismanoid 10:04022a61b527 6753 // Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 6754 if (Datalogger_enable_serial) {
whismanoid 9:45f98573eb6d 6755 Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 6756 }
whismanoid 9:45f98573eb6d 6757 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 6758 if (Datalogger_enable_AUXserial) {
whismanoid 9:45f98573eb6d 6759 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 9:45f98573eb6d 6760 }
whismanoid 9:45f98573eb6d 6761 # endif // HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 6762 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6763 if (Datalogger_enable_DAPLINKserial) {
whismanoid 9:45f98573eb6d 6764 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 9:45f98573eb6d 6765 }
whismanoid 9:45f98573eb6d 6766 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6767 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6768 }
whismanoid 8:dffee7509bfb 6769 break;
whismanoid 9:45f98573eb6d 6770 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 6771 case '>':
whismanoid 9:45f98573eb6d 6772 // L>A -- Datalogger_enable_AUXserial
whismanoid 9:45f98573eb6d 6773 // L>D -- Datalogger_enable_DAPLINKserial
whismanoid 9:45f98573eb6d 6774 // L>S -- Datalogger_enable_serial
whismanoid 9:45f98573eb6d 6775 switch (cmdLine[2])
whismanoid 9:45f98573eb6d 6776 {
whismanoid 9:45f98573eb6d 6777 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 6778 case 'A': case 'a':
whismanoid 9:45f98573eb6d 6779 Datalogger_enable_AUXserial = !Datalogger_enable_AUXserial;
whismanoid 9:45f98573eb6d 6780 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6781 break;
whismanoid 8:dffee7509bfb 6782 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6783 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6784 case 'D': case 'd':
whismanoid 9:45f98573eb6d 6785 Datalogger_enable_DAPLINKserial = !Datalogger_enable_DAPLINKserial;
whismanoid 9:45f98573eb6d 6786 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6787 break;
whismanoid 8:dffee7509bfb 6788 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6789 case 'S': case 's':
whismanoid 9:45f98573eb6d 6790 Datalogger_enable_serial = !Datalogger_enable_serial;
whismanoid 9:45f98573eb6d 6791 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6792 break;
whismanoid 9:45f98573eb6d 6793 }
whismanoid 9:45f98573eb6d 6794 break; // case '>' L>S serial enable toggle
whismanoid 28:a9a3a9db592b 6795 default:
whismanoid 28:a9a3a9db592b 6796 // TODO: L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 6797 //
whismanoid 28:a9a3a9db592b 6798 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 6799 #if 1 // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 6800 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 6801 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 6802 //
whismanoid 28:a9a3a9db592b 6803 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 28:a9a3a9db592b 6804 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 39:4d285e961435 6805 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 6806 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 6807 cmdLine.serial().printf("\r\n LT count=%d base=%dms sleep=%d -- Datalog timer",
whismanoid 39:4d285e961435 6808 g_timer_interval_count,
whismanoid 39:4d285e961435 6809 g_timer_interval_msec,
whismanoid 39:4d285e961435 6810 (int)g_timer_sleepmode
whismanoid 39:4d285e961435 6811 ); // trigger_Timer
whismanoid 39:4d285e961435 6812 #else // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 6813 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 6814 #endif // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 6815 //
whismanoid 28:a9a3a9db592b 6816 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 28:a9a3a9db592b 6817 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 6818 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 6819 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 6820 //
whismanoid 28:a9a3a9db592b 6821 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 6822 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 28:a9a3a9db592b 6823 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 6824 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 6825 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 6826 //
whismanoid 28:a9a3a9db592b 6827 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 6828 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 6829 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 6830 //
whismanoid 28:a9a3a9db592b 6831 //
whismanoid 28:a9a3a9db592b 6832 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 6833 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 28:a9a3a9db592b 6834 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 6835 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 6836 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 28:a9a3a9db592b 6837 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 28:a9a3a9db592b 6838 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 28:a9a3a9db592b 6839 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 28:a9a3a9db592b 6840 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 28:a9a3a9db592b 6841 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 28:a9a3a9db592b 6842 //
whismanoid 28:a9a3a9db592b 6843 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 28:a9a3a9db592b 6844 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 28:a9a3a9db592b 6845 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 28:a9a3a9db592b 6846 //
whismanoid 28:a9a3a9db592b 6847 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 6848 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 28:a9a3a9db592b 6849 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 28:a9a3a9db592b 6850 //
whismanoid 28:a9a3a9db592b 6851 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 6852 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 28:a9a3a9db592b 6853 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 6854 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 28:a9a3a9db592b 6855 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 6856 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 28:a9a3a9db592b 6857 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 6858 //
whismanoid 28:a9a3a9db592b 6859 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 28:a9a3a9db592b 6860 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 28:a9a3a9db592b 6861 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 28:a9a3a9db592b 6862 //
whismanoid 28:a9a3a9db592b 6863 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 6864 //
whismanoid 28:a9a3a9db592b 6865 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 28:a9a3a9db592b 6866 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 28:a9a3a9db592b 6867 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 6868 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 6869 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 28:a9a3a9db592b 6870 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6871 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 28:a9a3a9db592b 6872 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6873 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6874 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 28:a9a3a9db592b 6875 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6876 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 28:a9a3a9db592b 6877 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6878 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 28:a9a3a9db592b 6879 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6880 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6881 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 28:a9a3a9db592b 6882 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6883 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 6884 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 6885 # if HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 6886 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 6887 # endif // HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 6888 # if HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 6889 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 6890 # endif // HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 6891 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 6892 //
whismanoid 28:a9a3a9db592b 6893 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 6894 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 6895 break;
whismanoid 17:9397ea3ea7e9 6896 } // switch (cmdLine[1]) inside case 'L'
whismanoid 4:d9b05924ad4c 6897 }
whismanoid 4:d9b05924ad4c 6898 break; // case 'L'
whismanoid 4:d9b05924ad4c 6899 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 6900 //
whismanoid 4:d9b05924ad4c 6901 // Application-specific commands here
whismanoid 4:d9b05924ad4c 6902 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 6903 //
whismanoid 4:d9b05924ad4c 6904 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 6905 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 6906
whismanoid 4:d9b05924ad4c 6907 //
whismanoid 4:d9b05924ad4c 6908 // TODO1: add new commands here
whismanoid 4:d9b05924ad4c 6909 //
whismanoid 4:d9b05924ad4c 6910 default:
whismanoid 4:d9b05924ad4c 6911 #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6912 extern bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5715.cpp
whismanoid 4:d9b05924ad4c 6913 if (!MAX5715_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6914 #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6915 extern bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11131.cpp
whismanoid 4:d9b05924ad4c 6916 if (!MAX11131_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6917 #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6918 extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp
whismanoid 4:d9b05924ad4c 6919 if (!MAX5171_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6920 #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6921 extern bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp
whismanoid 4:d9b05924ad4c 6922 if (!MAX11410_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6923 #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6924 extern bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX12345.cpp
whismanoid 4:d9b05924ad4c 6925 if (!MAX12345_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6926 #else
whismanoid 4:d9b05924ad4c 6927 if (0) // not_handled_by_device_submenu
whismanoid 4:d9b05924ad4c 6928 #endif
whismanoid 4:d9b05924ad4c 6929 {
whismanoid 4:d9b05924ad4c 6930 cmdLine.serial().printf("\r\n unknown command ");
whismanoid 4:d9b05924ad4c 6931 //~ cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 6932 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 6933 cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n",
whismanoid 4:d9b05924ad4c 6934 cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 6935 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6936 }
whismanoid 4:d9b05924ad4c 6937 } // switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 6938 //
whismanoid 31:47eee7e0cc2d 6939 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 6940 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 6941 // print command prompt
whismanoid 8:dffee7509bfb 6942 // print_command_prompt();
whismanoid 8:dffee7509bfb 6943 cmdLine.serial().printf("\r\n> ");
whismanoid 31:47eee7e0cc2d 6944 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 6945 }
whismanoid 4:d9b05924ad4c 6946 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 6947
whismanoid 4:d9b05924ad4c 6948 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 6949 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 6950 void Datalogger_PrintHeader(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 6951 {
whismanoid 37:3f369235e5bc 6952 #if MAX40108_DEMO // main_menu_status banner
whismanoid 37:3f369235e5bc 6953 cmdLine.serial().printf("\r\n\r\n\"MAX40108_U%d", MAX40108_DEMO);
whismanoid 37:3f369235e5bc 6954 #ifdef BOARD_SERIAL_NUMBER
whismanoid 37:3f369235e5bc 6955 // data unique to certain boards based on serial number
whismanoid 47:f1a56afb4aca 6956 cmdLine.serial().printf(" [s/n %d]", g_board_serial_number);
whismanoid 37:3f369235e5bc 6957 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 6958 #ifdef FW_REV
whismanoid 37:3f369235e5bc 6959 cmdLine.serial().printf(" [FW_REV %d]", FW_REV);
whismanoid 37:3f369235e5bc 6960 #endif // FW_REV
whismanoid 37:3f369235e5bc 6961 cmdLine.serial().printf("\"\r\n");
whismanoid 37:3f369235e5bc 6962 #endif // MAX40108_DEMO
whismanoid 37:3f369235e5bc 6963
whismanoid 4:d9b05924ad4c 6964 // column header banner for csv data columns
whismanoid 4:d9b05924ad4c 6965 int field_index = 0;
whismanoid 4:d9b05924ad4c 6966 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6967 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 6968 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 4:d9b05924ad4c 6969 continue;
whismanoid 4:d9b05924ad4c 6970 }
whismanoid 4:d9b05924ad4c 6971 // comma between fields
whismanoid 4:d9b05924ad4c 6972 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 6973 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 6974 }
whismanoid 10:04022a61b527 6975 field_index++;
whismanoid 4:d9b05924ad4c 6976 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 6977 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 6978 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 4:d9b05924ad4c 6979 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 4:d9b05924ad4c 6980 cmdLine.serial().printf("\"AIN%d-%d_BIP", channel_index, channel_index+1);
whismanoid 4:d9b05924ad4c 6981 }
whismanoid 4:d9b05924ad4c 6982 else {
whismanoid 4:d9b05924ad4c 6983 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 6984 }
whismanoid 4:d9b05924ad4c 6985 #else // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 6986 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 6987 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 6988 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_LSB) {
whismanoid 4:d9b05924ad4c 6989 // _LSB column header suffix
whismanoid 13:184a08909405 6990 cmdLine.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 6991 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6992 cmdLine_DAPLINKserial.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 6993 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6994 }
whismanoid 10:04022a61b527 6995 else if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_Volt) {
whismanoid 4:d9b05924ad4c 6996 // _V column header suffix
whismanoid 13:184a08909405 6997 cmdLine.serial().printf("_V");
whismanoid 4:d9b05924ad4c 6998 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6999 cmdLine_DAPLINKserial.serial().printf("_V");
whismanoid 4:d9b05924ad4c 7000 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7001 }
whismanoid 13:184a08909405 7002 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 7003 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 7004 if (SPI_AIN_customChannelHeader_ch[channel_index] && SPI_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 7005 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 7006 cmdLine.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 7007 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7008 cmdLine_DAPLINKserial.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 7009 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7010 } else {
whismanoid 13:184a08909405 7011 // no custom channel name for this channel
whismanoid 13:184a08909405 7012 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 7013 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7014 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 7015 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7016 }
whismanoid 13:184a08909405 7017 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 7018 // close quote
whismanoid 13:184a08909405 7019 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 7020 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7021 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 7022 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7023 }
whismanoid 4:d9b05924ad4c 7024
whismanoid 4:d9b05924ad4c 7025 #if VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 7026 // PART_ID field: Device ID Validation
whismanoid 4:d9b05924ad4c 7027 cmdLine.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 7028 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7029 cmdLine_DAPLINKserial.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 7030 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7031 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 7032 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 7033 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 7034 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 7035 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 7036 continue;
whismanoid 9:45f98573eb6d 7037 }
whismanoid 4:d9b05924ad4c 7038 // comma between fields
whismanoid 4:d9b05924ad4c 7039 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 7040 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 7041 }
whismanoid 9:45f98573eb6d 7042 field_index++;
whismanoid 4:d9b05924ad4c 7043 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 7044 cmdLine.serial().printf("\"A%d", channel_index);
whismanoid 9:45f98573eb6d 7045 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 9:45f98573eb6d 7046 // _LSB column header suffix
whismanoid 13:184a08909405 7047 cmdLine.serial().printf("_LSB");
whismanoid 9:45f98573eb6d 7048 }
whismanoid 9:45f98573eb6d 7049 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 7050 // _V column header suffix
whismanoid 13:184a08909405 7051 cmdLine.serial().printf("_V");
whismanoid 9:45f98573eb6d 7052 }
whismanoid 13:184a08909405 7053 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 7054 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 7055 if (Platform_AIN_customChannelHeader_ch[channel_index] && Platform_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 7056 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 7057 cmdLine.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 7058 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7059 cmdLine_DAPLINKserial.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 7060 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7061 } else {
whismanoid 13:184a08909405 7062 // no custom channel name for this channel
whismanoid 13:184a08909405 7063 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 7064 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7065 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 7066 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7067 }
whismanoid 13:184a08909405 7068 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 7069 // close quote
whismanoid 13:184a08909405 7070 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 7071 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 7072 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 7073 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7074 }
whismanoid 4:d9b05924ad4c 7075 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 30:07197a430869 7076 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 7077 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in Datalogger_PrintHeader
whismanoid 30:07197a430869 7078 cmdLine.serial().printf(",\"%s\"", gstrRemarkHeader);
whismanoid 30:07197a430869 7079 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 4:d9b05924ad4c 7080 // end of column header line
whismanoid 4:d9b05924ad4c 7081 cmdLine.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 7082 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7083 cmdLine_DAPLINKserial.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 7084 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7085 } // void Datalogger_PrintHeader()
whismanoid 4:d9b05924ad4c 7086
whismanoid 5:aaf8b5f5fda1 7087 //--------------------------------------------------
whismanoid 5:aaf8b5f5fda1 7088 void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 7089 {
whismanoid 5:aaf8b5f5fda1 7090 // CODE GENERATOR: example code: has no member function ScanStandardExternalClock
whismanoid 5:aaf8b5f5fda1 7091 // CODE GENERATOR: example code: has no member function ReadAINcode
whismanoid 5:aaf8b5f5fda1 7092 // CODE GENERATOR: example code: member function Read_All_Voltages
whismanoid 5:aaf8b5f5fda1 7093 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7094 // Measure ADC channels in sequence from AIN0 to channelNumber_0_9.
whismanoid 5:aaf8b5f5fda1 7095 // @param[in] g_MAX11410_device.channelNumber_0_15: AIN Channel Number
whismanoid 5:aaf8b5f5fda1 7096 // @param[in] g_MAX11410_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
whismanoid 5:aaf8b5f5fda1 7097 // @param[in] g_MAX11410_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
whismanoid 10:04022a61b527 7098 //~ int channelId_0_9 = NUM_DUT_ANALOG_IN_CHANNELS-1+1;
whismanoid 5:aaf8b5f5fda1 7099 //g_MAX11410_device.channelNumber_0_15 = channelId_0_9;
whismanoid 5:aaf8b5f5fda1 7100 //g_MAX11410_device.PowerManagement_0_2 = 0;
whismanoid 5:aaf8b5f5fda1 7101 //g_MAX11410_device.chan_id_0_1 = 1;
whismanoid 5:aaf8b5f5fda1 7102 //----------------------------------------
whismanoid 5:aaf8b5f5fda1 7103 // scan AIN0..AIN9
whismanoid 5:aaf8b5f5fda1 7104 //
whismanoid 10:04022a61b527 7105 #if 1
whismanoid 10:04022a61b527 7106 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 7107 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 7108 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 7109 //
whismanoid 10:04022a61b527 7110 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7111 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc3); // GP1 = 0
whismanoid 10:04022a61b527 7112 //
whismanoid 10:04022a61b527 7113 int field_index = 0;
whismanoid 10:04022a61b527 7114 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 7115 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 10:04022a61b527 7116 continue;
whismanoid 10:04022a61b527 7117 }
whismanoid 10:04022a61b527 7118 field_index++;
whismanoid 10:04022a61b527 7119 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[channel_index];
whismanoid 10:04022a61b527 7120 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[channel_index];
whismanoid 10:04022a61b527 7121 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[channel_index];
whismanoid 10:04022a61b527 7122 //
whismanoid 10:04022a61b527 7123 // WIP SampleRate_of_FILTER_CONV_START() MAX11410EMC-FW slow ODR 10Sps #262
whismanoid 10:04022a61b527 7124 // adjust the MAX11410.loop_limit value if the sample rate is set to a value slower than 20sps
whismanoid 10:04022a61b527 7125 // SampleRate_of_FILTER_CONV_START(uint8_t FILTER_RegValue, uint8_t CONV_START_RegValue)
whismanoid 10:04022a61b527 7126 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 7127 if (SampleRate < 20.0) {
whismanoid 10:04022a61b527 7128 g_MAX11410_device.loop_limit = 32767; // TODO: is this timeout long enough for the slow output data rates?
whismanoid 10:04022a61b527 7129 }
whismanoid 10:04022a61b527 7130 //
whismanoid 10:04022a61b527 7131 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7132 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc3); // GP0 = 0
whismanoid 10:04022a61b527 7133 //
whismanoid 10:04022a61b527 7134 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 7135 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 10:04022a61b527 7136 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 10:04022a61b527 7137 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 7138 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = (MAX11410::MAX11410_AINN_SEL_enum_t)(channel_index^1);
whismanoid 10:04022a61b527 7139 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 7140 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 7141 }
whismanoid 10:04022a61b527 7142 else {
whismanoid 10:04022a61b527 7143 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 7144 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = MAX11410::AINN_SEL_1010_GND;
whismanoid 10:04022a61b527 7145 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 7146 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 7147 }
whismanoid 10:04022a61b527 7148 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 7149 //
whismanoid 10:04022a61b527 7150 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7151 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc4); // GP0 = 1
whismanoid 10:04022a61b527 7152 //
whismanoid 10:04022a61b527 7153 }
whismanoid 10:04022a61b527 7154 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7155 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc4); // GP1 = 1
whismanoid 10:04022a61b527 7156 #else
whismanoid 5:aaf8b5f5fda1 7157 g_MAX11410_device.Read_All_Voltages();
whismanoid 10:04022a61b527 7158 #endif
whismanoid 10:04022a61b527 7159 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7160 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 7161 // mbed
whismanoid 5:aaf8b5f5fda1 7162 // Platform board uses simple analog inputs
whismanoid 5:aaf8b5f5fda1 7163 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 5:aaf8b5f5fda1 7164 Platform_LSB[0] = analogIn0.read();
whismanoid 5:aaf8b5f5fda1 7165 Platform_LSB[1] = analogIn1.read();
whismanoid 5:aaf8b5f5fda1 7166 Platform_LSB[2] = analogIn2.read();
whismanoid 5:aaf8b5f5fda1 7167 Platform_LSB[3] = analogIn3.read();
whismanoid 5:aaf8b5f5fda1 7168 Platform_LSB[4] = analogIn4.read();
whismanoid 5:aaf8b5f5fda1 7169 Platform_LSB[5] = analogIn5.read();
whismanoid 10:04022a61b527 7170 #endif
whismanoid 10:04022a61b527 7171 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 37:3f369235e5bc 7172 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 7173 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogIn012345.read()
whismanoid 37:3f369235e5bc 7174 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 7175 float analogIn0_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7176 float analogIn1_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7177 float analogIn2_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7178 float analogIn3_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7179 float analogIn4_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7180 float analogIn5_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7181 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 7182 analogIn0_normValue_0_1 = analogIn0_normValue_0_1 + analogIn0.read();
whismanoid 37:3f369235e5bc 7183 analogIn1_normValue_0_1 = analogIn1_normValue_0_1 + analogIn1.read();
whismanoid 37:3f369235e5bc 7184 analogIn2_normValue_0_1 = analogIn2_normValue_0_1 + analogIn2.read();
whismanoid 37:3f369235e5bc 7185 analogIn3_normValue_0_1 = analogIn3_normValue_0_1 + analogIn3.read();
whismanoid 37:3f369235e5bc 7186 analogIn4_normValue_0_1 = analogIn4_normValue_0_1 + analogIn4.read();
whismanoid 37:3f369235e5bc 7187 analogIn5_normValue_0_1 = analogIn5_normValue_0_1 + analogIn5.read();
whismanoid 37:3f369235e5bc 7188 }
whismanoid 37:3f369235e5bc 7189 analogIn0_normValue_0_1 = analogIn0_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7190 analogIn1_normValue_0_1 = analogIn1_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7191 analogIn2_normValue_0_1 = analogIn2_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7192 analogIn3_normValue_0_1 = analogIn3_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7193 analogIn4_normValue_0_1 = analogIn4_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7194 analogIn5_normValue_0_1 = analogIn5_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7195 #else // USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 7196 float analogIn0_normValue_0_1 = analogIn0.read();
whismanoid 37:3f369235e5bc 7197 float analogIn1_normValue_0_1 = analogIn1.read();
whismanoid 37:3f369235e5bc 7198 float analogIn2_normValue_0_1 = analogIn2.read();
whismanoid 37:3f369235e5bc 7199 float analogIn3_normValue_0_1 = analogIn3.read();
whismanoid 37:3f369235e5bc 7200 float analogIn4_normValue_0_1 = analogIn4.read();
whismanoid 37:3f369235e5bc 7201 float analogIn5_normValue_0_1 = analogIn5.read();
whismanoid 37:3f369235e5bc 7202 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 7203 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 7204 // apply calibration to normValue_0_1 value
whismanoid 37:3f369235e5bc 7205 Platform_Voltage[0] = CalibratedNormValue(0, analogIn0_normValue_0_1) * adc_full_scale_voltage[0];
whismanoid 37:3f369235e5bc 7206 Platform_Voltage[1] = CalibratedNormValue(1, analogIn1_normValue_0_1) * adc_full_scale_voltage[1];
whismanoid 37:3f369235e5bc 7207 Platform_Voltage[2] = CalibratedNormValue(2, analogIn2_normValue_0_1) * adc_full_scale_voltage[2];
whismanoid 37:3f369235e5bc 7208 Platform_Voltage[3] = CalibratedNormValue(3, analogIn3_normValue_0_1) * adc_full_scale_voltage[3];
whismanoid 37:3f369235e5bc 7209 Platform_Voltage[4] = CalibratedNormValue(4, analogIn4_normValue_0_1) * adc_full_scale_voltage[4];
whismanoid 37:3f369235e5bc 7210 Platform_Voltage[5] = CalibratedNormValue(5, analogIn5_normValue_0_1) * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 7211 #else // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 7212 Platform_Voltage[0] = analogIn0_normValue_0_1 * adc_full_scale_voltage[0];
whismanoid 37:3f369235e5bc 7213 Platform_Voltage[1] = analogIn1_normValue_0_1 * adc_full_scale_voltage[1];
whismanoid 37:3f369235e5bc 7214 Platform_Voltage[2] = analogIn2_normValue_0_1 * adc_full_scale_voltage[2];
whismanoid 37:3f369235e5bc 7215 Platform_Voltage[3] = analogIn3_normValue_0_1 * adc_full_scale_voltage[3];
whismanoid 37:3f369235e5bc 7216 Platform_Voltage[4] = analogIn4_normValue_0_1 * adc_full_scale_voltage[4];
whismanoid 37:3f369235e5bc 7217 Platform_Voltage[5] = analogIn5_normValue_0_1 * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 7218 #endif // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 7219 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 5:aaf8b5f5fda1 7220 #endif // defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 7221
whismanoid 5:aaf8b5f5fda1 7222 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7223 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 7224 const uint32_t part_id_expect = 0x000F02;
whismanoid 5:aaf8b5f5fda1 7225 uint32_t part_id_readback;
whismanoid 5:aaf8b5f5fda1 7226 g_MAX11410_device.RegRead(MAX11410::CMD_r001_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xddd_PART_ID, &part_id_readback);
whismanoid 5:aaf8b5f5fda1 7227 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7228 } // void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 7229
whismanoid 17:9397ea3ea7e9 7230 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 7231 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 7232 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 7233 void Datalogger_RunActionTable()
whismanoid 17:9397ea3ea7e9 7234 {
whismanoid 17:9397ea3ea7e9 7235 if (Datalogger_action_table_enabled == false) {
whismanoid 17:9397ea3ea7e9 7236 return;
whismanoid 17:9397ea3ea7e9 7237 }
whismanoid 17:9397ea3ea7e9 7238 // TODO: verbose Datalogger_RunActionTable() emit a csv column ,"Action"
whismanoid 17:9397ea3ea7e9 7239 // TODO: assert Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX
whismanoid 17:9397ea3ea7e9 7240 // for Datalogger_action_table[0..Datalogger_action_table_row_count]
whismanoid 17:9397ea3ea7e9 7241 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 7242 {
whismanoid 17:9397ea3ea7e9 7243 // skip if Datalogger_action_table[i].action == action_noop
whismanoid 17:9397ea3ea7e9 7244 if (Datalogger_action_table[i].action == action_noop) {
whismanoid 17:9397ea3ea7e9 7245 continue;
whismanoid 17:9397ea3ea7e9 7246 }
whismanoid 17:9397ea3ea7e9 7247 // TODO: test Datalogger_action_table[i].condition "if="
whismanoid 17:9397ea3ea7e9 7248 // TODO: Could the .condition field also distinguish Platform ADC from SPI ADC?
whismanoid 17:9397ea3ea7e9 7249 // That way we keep both sets of ADC channels in separate lists
whismanoid 17:9397ea3ea7e9 7250 // if=0 -- always
whismanoid 17:9397ea3ea7e9 7251 // if=1,2,3,4,5,6 -- Platform_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 7252 // if=7,8,9,10,11,12 -- SPI_AIN_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 7253 // also, are we comparing code or voltage?
whismanoid 17:9397ea3ea7e9 7254 // TODO: selected Datalogger_action_table[i].condition_channel
whismanoid 17:9397ea3ea7e9 7255 // Datalogger could have both platform ADC and external SPI ADC channels
whismanoid 17:9397ea3ea7e9 7256 // if SPI_ADC_DeviceName
whismanoid 17:9397ea3ea7e9 7257 // NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 7258 // SPI_AIN_Enable_ch[]
whismanoid 17:9397ea3ea7e9 7259 // SPI_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 7260 // SPI_AIN_Voltage[]
whismanoid 17:9397ea3ea7e9 7261 // if LOG_PLATFORM_AIN
whismanoid 17:9397ea3ea7e9 7262 // NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 7263 // analogInPin_fullScaleVoltage[]
whismanoid 17:9397ea3ea7e9 7264 // Platform_Enable_ch[]
whismanoid 17:9397ea3ea7e9 7265 // Platform_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 7266 // Platform_Voltage[]
whismanoid 17:9397ea3ea7e9 7267 // TODO: selected Datalogger_action_table[i].condition_threshold
whismanoid 17:9397ea3ea7e9 7268 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 7269 {
whismanoid 17:9397ea3ea7e9 7270 case condition_always:
whismanoid 17:9397ea3ea7e9 7271 //~ cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 7272 break;
whismanoid 17:9397ea3ea7e9 7273 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 7274 //~ cmdLine.serial().printf(" if A%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7275 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7276 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7277 continue;
whismanoid 17:9397ea3ea7e9 7278 }
whismanoid 17:9397ea3ea7e9 7279 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7280 break;
whismanoid 17:9397ea3ea7e9 7281 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 7282 //~ cmdLine.serial().printf(" if A%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7283 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7284 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7285 continue;
whismanoid 17:9397ea3ea7e9 7286 }
whismanoid 17:9397ea3ea7e9 7287 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7288 break;
whismanoid 17:9397ea3ea7e9 7289 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 7290 //~ cmdLine.serial().printf(" if A%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7291 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7292 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7293 continue;
whismanoid 17:9397ea3ea7e9 7294 }
whismanoid 17:9397ea3ea7e9 7295 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7296 break;
whismanoid 17:9397ea3ea7e9 7297 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 7298 //~ cmdLine.serial().printf(" if A%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7299 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7300 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7301 continue;
whismanoid 17:9397ea3ea7e9 7302 }
whismanoid 17:9397ea3ea7e9 7303 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7304 break;
whismanoid 17:9397ea3ea7e9 7305 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 7306 //~ cmdLine.serial().printf(" if A%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7307 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7308 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7309 continue;
whismanoid 17:9397ea3ea7e9 7310 }
whismanoid 17:9397ea3ea7e9 7311 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7312 break;
whismanoid 17:9397ea3ea7e9 7313 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 7314 //~ cmdLine.serial().printf(" if A%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7315 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7316 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7317 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7318 continue;
whismanoid 17:9397ea3ea7e9 7319 }
whismanoid 17:9397ea3ea7e9 7320 break;
whismanoid 17:9397ea3ea7e9 7321 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 7322 //~ cmdLine.serial().printf(" if AIN%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7323 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7324 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7325 continue;
whismanoid 17:9397ea3ea7e9 7326 }
whismanoid 17:9397ea3ea7e9 7327 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7328 break;
whismanoid 17:9397ea3ea7e9 7329 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 7330 //~ cmdLine.serial().printf(" if AIN%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7331 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7332 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7333 continue;
whismanoid 17:9397ea3ea7e9 7334 }
whismanoid 17:9397ea3ea7e9 7335 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7336 break;
whismanoid 17:9397ea3ea7e9 7337 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 7338 //~ cmdLine.serial().printf(" if AIN%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7339 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7340 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7341 continue;
whismanoid 17:9397ea3ea7e9 7342 }
whismanoid 17:9397ea3ea7e9 7343 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7344 break;
whismanoid 17:9397ea3ea7e9 7345 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 7346 //~ cmdLine.serial().printf(" if AIN%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7347 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7348 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7349 continue;
whismanoid 17:9397ea3ea7e9 7350 }
whismanoid 17:9397ea3ea7e9 7351 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7352 break;
whismanoid 17:9397ea3ea7e9 7353 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 7354 //~ cmdLine.serial().printf(" if AIN%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7355 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7356 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7357 continue;
whismanoid 17:9397ea3ea7e9 7358 }
whismanoid 17:9397ea3ea7e9 7359 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7360 break;
whismanoid 17:9397ea3ea7e9 7361 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 7362 //~ cmdLine.serial().printf(" if AIN%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7363 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7364 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7365 continue;
whismanoid 17:9397ea3ea7e9 7366 }
whismanoid 17:9397ea3ea7e9 7367 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7368 break;
whismanoid 17:9397ea3ea7e9 7369 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 7370 // selected Datalogger_action_table[i].digitalOutPin
whismanoid 17:9397ea3ea7e9 7371 // perform selected Datalogger_action_table[i].action
whismanoid 17:9397ea3ea7e9 7372 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 7373 {
whismanoid 17:9397ea3ea7e9 7374 case action_noop:
whismanoid 17:9397ea3ea7e9 7375 //~ cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 7376 break;
whismanoid 17:9397ea3ea7e9 7377 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 7378 {
whismanoid 17:9397ea3ea7e9 7379 //~ cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 7380 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 7381 // perform action digitalOutLow
whismanoid 17:9397ea3ea7e9 7382 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 7383 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 7384 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7385 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7386 #else
whismanoid 17:9397ea3ea7e9 7387 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 7388 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 7389 digitalInOutPin.write(0);
whismanoid 17:9397ea3ea7e9 7390 #endif
whismanoid 17:9397ea3ea7e9 7391 }
whismanoid 17:9397ea3ea7e9 7392 break;
whismanoid 17:9397ea3ea7e9 7393 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 7394 {
whismanoid 17:9397ea3ea7e9 7395 //~ cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 7396 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 7397 // perform action digitalOutHigh
whismanoid 17:9397ea3ea7e9 7398 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 7399 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 7400 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7401 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7402 #else
whismanoid 17:9397ea3ea7e9 7403 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 7404 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 7405 digitalInOutPin.write(1);
whismanoid 17:9397ea3ea7e9 7406 #endif
whismanoid 17:9397ea3ea7e9 7407 }
whismanoid 17:9397ea3ea7e9 7408 break;
whismanoid 29:6a9edb6e973b 7409 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 7410 {
whismanoid 30:07197a430869 7411 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 7412 Datalogger_Trigger_enum_t saved_Datalogger_Trigger = Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 7413 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7414 switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 7415 {
whismanoid 29:6a9edb6e973b 7416 case 1:
whismanoid 29:6a9edb6e973b 7417 onButton1FallingEdge();
whismanoid 29:6a9edb6e973b 7418 break;
whismanoid 29:6a9edb6e973b 7419 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7420 case 2:
whismanoid 29:6a9edb6e973b 7421 onButton2FallingEdge();
whismanoid 29:6a9edb6e973b 7422 break;
whismanoid 29:6a9edb6e973b 7423 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7424 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7425 case 3:
whismanoid 29:6a9edb6e973b 7426 onButton3FallingEdge();
whismanoid 29:6a9edb6e973b 7427 break;
whismanoid 29:6a9edb6e973b 7428 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7429 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7430 case 4:
whismanoid 29:6a9edb6e973b 7431 onButton4FallingEdge();
whismanoid 29:6a9edb6e973b 7432 break;
whismanoid 29:6a9edb6e973b 7433 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7434 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7435 case 5:
whismanoid 29:6a9edb6e973b 7436 onButton5FallingEdge();
whismanoid 29:6a9edb6e973b 7437 break;
whismanoid 29:6a9edb6e973b 7438 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7439 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7440 case 6:
whismanoid 29:6a9edb6e973b 7441 onButton6FallingEdge();
whismanoid 29:6a9edb6e973b 7442 break;
whismanoid 29:6a9edb6e973b 7443 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7444 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7445 case 7:
whismanoid 29:6a9edb6e973b 7446 onButton7FallingEdge();
whismanoid 29:6a9edb6e973b 7447 break;
whismanoid 29:6a9edb6e973b 7448 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7449 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7450 case 8:
whismanoid 29:6a9edb6e973b 7451 onButton8FallingEdge();
whismanoid 29:6a9edb6e973b 7452 break;
whismanoid 29:6a9edb6e973b 7453 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7454 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7455 case 9:
whismanoid 29:6a9edb6e973b 7456 onButton9FallingEdge();
whismanoid 29:6a9edb6e973b 7457 break;
whismanoid 29:6a9edb6e973b 7458 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7459 } // switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 7460 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 30:07197a430869 7461 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 7462 Datalogger_Trigger = saved_Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 7463 } // case action_button
whismanoid 29:6a9edb6e973b 7464 break;
whismanoid 17:9397ea3ea7e9 7465 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 7466 //~ cmdLine.serial().printf("trigger_Halt");
whismanoid 17:9397ea3ea7e9 7467 // perform action trigger_Halt
whismanoid 17:9397ea3ea7e9 7468 Datalogger_Trigger = trigger_Halt;
whismanoid 17:9397ea3ea7e9 7469 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7470 break;
whismanoid 17:9397ea3ea7e9 7471 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 7472 //~ cmdLine.serial().printf("trigger_FreeRun");
whismanoid 17:9397ea3ea7e9 7473 // perform action trigger_FreeRun
whismanoid 17:9397ea3ea7e9 7474 Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 7475 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7476 break;
whismanoid 17:9397ea3ea7e9 7477 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 7478 //~ cmdLine.serial().printf("trigger_Timer");
whismanoid 17:9397ea3ea7e9 7479 //~ // print configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 7480 //~ cmdLine.serial().printf("(%d x %dmsec)", g_timer_interval_count, g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 7481 // perform action trigger_Timer
whismanoid 17:9397ea3ea7e9 7482 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 7483 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7484 break;
whismanoid 17:9397ea3ea7e9 7485 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 7486 //~ cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 7487 //~ // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 7488 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 7489 // TODO: perform action action_trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 7490 Datalogger_Trigger = trigger_PlatformDigitalInput;
whismanoid 17:9397ea3ea7e9 7491 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7492 break;
whismanoid 17:9397ea3ea7e9 7493 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 7494 //~ cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 7495 //~ // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 7496 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 7497 // TODO: perform action action_trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 7498 Datalogger_Trigger = trigger_SPIDeviceRegRead;
whismanoid 17:9397ea3ea7e9 7499 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7500 break;
whismanoid 17:9397ea3ea7e9 7501 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 7502 // consider next row of action table
whismanoid 17:9397ea3ea7e9 7503 } // for ...Datalogger_action_table_row_count
whismanoid 17:9397ea3ea7e9 7504 }
whismanoid 17:9397ea3ea7e9 7505 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 7506
whismanoid 5:aaf8b5f5fda1 7507 //--------------------------------------------------
whismanoid 8:dffee7509bfb 7508 void Datalogger_PrintRow(CmdLine& cmdLine)
whismanoid 5:aaf8b5f5fda1 7509 {
whismanoid 5:aaf8b5f5fda1 7510 int field_index = 0;
whismanoid 5:aaf8b5f5fda1 7511 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 7512 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 7513 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 5:aaf8b5f5fda1 7514 continue;
whismanoid 5:aaf8b5f5fda1 7515 }
whismanoid 5:aaf8b5f5fda1 7516 // comma between fields
whismanoid 5:aaf8b5f5fda1 7517 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 7518 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 7519 }
whismanoid 10:04022a61b527 7520 field_index++;
whismanoid 10:04022a61b527 7521 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 10:04022a61b527 7522 cmdLine.serial().printf("%d", g_MAX11410_device.AINcode[channel_index]);
whismanoid 10:04022a61b527 7523 }
whismanoid 10:04022a61b527 7524 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 10:04022a61b527 7525 // TODO: report Voltage instead of LSB
whismanoid 10:04022a61b527 7526 // Serial.print(SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 7527 static char strOutLineBuffer[16];
whismanoid 10:04022a61b527 7528 cmdLine.serial().printf("%6.6f", SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 7529 }
whismanoid 5:aaf8b5f5fda1 7530 }
whismanoid 5:aaf8b5f5fda1 7531 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7532 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 7533 if (part_id_readback != part_id_expect) {
whismanoid 5:aaf8b5f5fda1 7534 cmdLine.serial().printf(",\"FAIL\"");
whismanoid 9:45f98573eb6d 7535 need_reinit = true;
whismanoid 5:aaf8b5f5fda1 7536 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7537 g_MAX11410_device.Init();
whismanoid 5:aaf8b5f5fda1 7538 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 5:aaf8b5f5fda1 7539 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 5:aaf8b5f5fda1 7540 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 5:aaf8b5f5fda1 7541 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7542 }
whismanoid 5:aaf8b5f5fda1 7543 else {
whismanoid 5:aaf8b5f5fda1 7544 cmdLine.serial().printf(",\"OK\"");
whismanoid 5:aaf8b5f5fda1 7545 }
whismanoid 5:aaf8b5f5fda1 7546 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7547 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7548 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 7549 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 7550 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 7551 continue;
whismanoid 9:45f98573eb6d 7552 }
whismanoid 5:aaf8b5f5fda1 7553 // comma between fields
whismanoid 5:aaf8b5f5fda1 7554 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 7555 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 7556 }
whismanoid 9:45f98573eb6d 7557 field_index++;
whismanoid 9:45f98573eb6d 7558 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 5:aaf8b5f5fda1 7559 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 7560 cmdLine.serial().printf("%u", Platform_LSB[channel_index]);
whismanoid 9:45f98573eb6d 7561 #endif
whismanoid 9:45f98573eb6d 7562 }
whismanoid 9:45f98573eb6d 7563 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 7564 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 11:2b8adc78618a 7565 // Datalog Volts omit V suffix from numbers #275
whismanoid 11:2b8adc78618a 7566 // because Excel graphs can't handle numbers that have a suffix.
whismanoid 11:2b8adc78618a 7567 cmdLine.serial().printf("%6.6f", Platform_Voltage[channel_index]);
whismanoid 9:45f98573eb6d 7568 #endif
whismanoid 9:45f98573eb6d 7569 }
whismanoid 5:aaf8b5f5fda1 7570 }
whismanoid 5:aaf8b5f5fda1 7571 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 7572 if (need_reinit) {
whismanoid 9:45f98573eb6d 7573 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 7574 if (g_MAX11410_device.Init() == 0) {
whismanoid 9:45f98573eb6d 7575 //~ cmdLine.serial().printf(",\"Init() failed\"");
whismanoid 9:45f98573eb6d 7576 } else {
whismanoid 9:45f98573eb6d 7577 //~ cmdLine.serial().printf(",\"Init() success\"");
whismanoid 9:45f98573eb6d 7578 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 7579 // in Datalogger_PrintRow(), when part_id test fails,
whismanoid 9:45f98573eb6d 7580 // apply list of custom register writes after re-init
whismanoid 9:45f98573eb6d 7581 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 7582 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 9:45f98573eb6d 7583 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 9:45f98573eb6d 7584 uint32_t regData = custom_reg_init_data[index];
whismanoid 9:45f98573eb6d 7585 cmdLine.serial().printf("*%s=0x%06.6x", g_MAX11410_device.RegName(regAddress), regData);
whismanoid 9:45f98573eb6d 7586 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 9:45f98573eb6d 7587 }
whismanoid 9:45f98573eb6d 7588 #endif // USE_CUSTOM_REG_INIT
whismanoid 9:45f98573eb6d 7589 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 9:45f98573eb6d 7590 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 9:45f98573eb6d 7591 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 9:45f98573eb6d 7592 need_reinit = false;
whismanoid 9:45f98573eb6d 7593 }
whismanoid 9:45f98573eb6d 7594 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 7595 need_reinit = false;
whismanoid 9:45f98573eb6d 7596 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 7597 }
whismanoid 30:07197a430869 7598 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 7599 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in void Datalogger_PrintRow()
whismanoid 30:07197a430869 7600 cmdLine.serial().printf(",\"%s\"", gstrRemarkText);
whismanoid 30:07197a430869 7601 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 5:aaf8b5f5fda1 7602 cmdLine.serial().printf("\r\n");
whismanoid 9:45f98573eb6d 7603 if (need_reinit) {
whismanoid 9:45f98573eb6d 7604 //~ delay(500); // platform_delay_ms 500ms timing delay function
whismanoid 9:45f98573eb6d 7605 }
whismanoid 5:aaf8b5f5fda1 7606 } // void Datalogger_PrintRow()
whismanoid 5:aaf8b5f5fda1 7607
whismanoid 0:cb44e2e9ec4c 7608 // example code main function
whismanoid 0:cb44e2e9ec4c 7609 int main()
whismanoid 0:cb44e2e9ec4c 7610 {
whismanoid 0:cb44e2e9ec4c 7611 // setup: put your setup code here, to run once
whismanoid 4:d9b05924ad4c 7612 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 7613 // Configure serial ports
whismanoid 4:d9b05924ad4c 7614 cmdLine.clear();
whismanoid 4:d9b05924ad4c 7615 //~ cmdLine.serial().printf("\r\n cmdLine.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 7616 cmdLine.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 7617 //~ cmdLine.diagnostic_led_EOF = diagnostic_led_EOF;
whismanoid 4:d9b05924ad4c 7618 /// CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21);
whismanoid 4:d9b05924ad4c 7619 //~ cmdLine.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 7620 //~ cmdLine.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 7621 //~ cmdLine.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 7622 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 7623 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 7624 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 7625 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 7626 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 7627 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 7628 # else
whismanoid 10:04022a61b527 7629 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 7630 DAPLINKserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 7631 # endif
whismanoid 10:04022a61b527 7632 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 7633 cmdLine_DAPLINKserial.clear();
whismanoid 4:d9b05924ad4c 7634 //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 7635 cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 7636 //~ cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 7637 //~ cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 7638 //~ cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 7639 # endif
whismanoid 6:f6d16658342b 7640 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 7641 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 10:04022a61b527 7642 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 7643 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 7644 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 7645 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 7646 AUXserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 7647 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 6:f6d16658342b 7648 cmdLine_AUXserial.clear();
whismanoid 6:f6d16658342b 7649 //~ cmdLine_AUXserial.serial().printf("\r\n cmdLine_AUXserial.serial().printf test\r\n");
whismanoid 6:f6d16658342b 7650 cmdLine_AUXserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 6:f6d16658342b 7651 //~ cmdLine_AUXserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 6:f6d16658342b 7652 //~ cmdLine_AUXserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 6:f6d16658342b 7653 //~ cmdLine_AUXserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 6:f6d16658342b 7654 # endif // HAS_AUX_SERIAL
whismanoid 4:d9b05924ad4c 7655 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 0:cb44e2e9ec4c 7656
whismanoid 0:cb44e2e9ec4c 7657 // example code: serial port banner message
whismanoid 0:cb44e2e9ec4c 7658 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 7659 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 7660 cmdLine.serial().printf("\r\nDataLogger_MAX11410\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 7661 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7662 cmdLine.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 7663 # if HAS_DAPLINK_SERIAL
whismanoid 3:9055e17e181a 7664 cmdLine_DAPLINKserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 7665 # endif // HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 7666 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 7667 cmdLine_AUXserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 6:f6d16658342b 7668 # endif // HAS_AUX_SERIAL
whismanoid 3:9055e17e181a 7669 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 7670
whismanoid 1:747f1602abfc 7671 // CODE GENERATOR: get spi properties from device
whismanoid 3:9055e17e181a 7672 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 7673 if (g_SPI_SCLK_Hz > g_MAX11410_device.get_spi_frequency())
whismanoid 3:9055e17e181a 7674 { // Device limits SPI SCLK frequency
whismanoid 3:9055e17e181a 7675 g_SPI_SCLK_Hz = g_MAX11410_device.get_spi_frequency();
whismanoid 3:9055e17e181a 7676 cmdLine.serial().printf("\r\nMAX11410 limits SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 7677
whismanoid 3:9055e17e181a 7678 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 7679 }
whismanoid 3:9055e17e181a 7680 if (g_MAX11410_device.get_spi_frequency() > g_SPI_SCLK_Hz)
whismanoid 3:9055e17e181a 7681 { // Platform limits SPI SCLK frequency
whismanoid 3:9055e17e181a 7682 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 7683 cmdLine.serial().printf("\r\nPlatform limits MAX11410 SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 7684
whismanoid 3:9055e17e181a 7685 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 7686 }
whismanoid 0:cb44e2e9ec4c 7687 // g_SPI_dataMode = g_MAX11410_device.get_spi_dataMode();
whismanoid 3:9055e17e181a 7688 while (g_MAX11410_device.Init() == 0)
whismanoid 3:9055e17e181a 7689 {
whismanoid 3:9055e17e181a 7690 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 7691 cmdLine.serial().printf("\r\nMAX11410 Init failed; retry...\r\n");
whismanoid 3:9055e17e181a 7692
whismanoid 3:9055e17e181a 7693 }
whismanoid 0:cb44e2e9ec4c 7694
whismanoid 0:cb44e2e9ec4c 7695 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 3:9055e17e181a 7696 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 7697 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 3:9055e17e181a 7698 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 3:9055e17e181a 7699 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 3:9055e17e181a 7700 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7701 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 3:9055e17e181a 7702 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7703 // CODE GENERATOR: example code: has no member function REF
whismanoid 0:cb44e2e9ec4c 7704 // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line
whismanoid 0:cb44e2e9ec4c 7705 // CODE GENERATOR: ResolutionBits = 24
whismanoid 0:cb44e2e9ec4c 7706 // CODE GENERATOR: FScode = 0xffffff
whismanoid 0:cb44e2e9ec4c 7707 // CODE GENERATOR: NumChannels = 10
whismanoid 0:cb44e2e9ec4c 7708 // CODE GENERATOR: banner before DataLogHelloCppCodeList while(1)
whismanoid 3:9055e17e181a 7709 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 7710 cmdLine.serial().printf("v_filter = 0x%2.2x\r\n", g_MAX11410_device.v_filter);
whismanoid 0:cb44e2e9ec4c 7711
whismanoid 3:9055e17e181a 7712 cmdLine.serial().printf("v_pga = 0x%2.2x\r\n", g_MAX11410_device.v_pga);
whismanoid 0:cb44e2e9ec4c 7713
whismanoid 3:9055e17e181a 7714 cmdLine.serial().printf("v_ctrl = 0x%2.2x\r\n", g_MAX11410_device.v_ctrl);
whismanoid 3:9055e17e181a 7715
whismanoid 3:9055e17e181a 7716 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7717
whismanoid 3:9055e17e181a 7718 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 7719 Datalogger_Need_PrintHeader = true;
whismanoid 10:04022a61b527 7720
whismanoid 12:2dfc1f2009e0 7721 #if USE_LEDS
whismanoid 12:2dfc1f2009e0 7722 #if defined(TARGET_MAX32630)
whismanoid 12:2dfc1f2009e0 7723 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 7724 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7725 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 7726 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7727 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 7728 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7729 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 7730 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7731 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 7732 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7733 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 7734 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7735 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 7736 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7737 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 7738 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 19:5ff09c8e9daf 7739 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 12:2dfc1f2009e0 7740 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 7741 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7742 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 7743 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7744 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 7745 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7746 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 7747 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7748 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 7749 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7750 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 7751 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7752 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 7753 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7754 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 7755 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7756 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 12:2dfc1f2009e0 7757 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 7758 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7759 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7760 led4 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7761 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7762 //led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 7763 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 7764 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7765 led1 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7766 //led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 7767 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 7768 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7769 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7770 //led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 7771 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 7772 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7773 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7774 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 7775 //
whismanoid 12:2dfc1f2009e0 7776 #endif // target definition
whismanoid 12:2dfc1f2009e0 7777 #endif
whismanoid 12:2dfc1f2009e0 7778
whismanoid 12:2dfc1f2009e0 7779 if (led1.is_connected()) {
whismanoid 12:2dfc1f2009e0 7780 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 7781 }
whismanoid 12:2dfc1f2009e0 7782 if (led2.is_connected()) {
whismanoid 12:2dfc1f2009e0 7783 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 7784 }
whismanoid 12:2dfc1f2009e0 7785 if (led3.is_connected()) {
whismanoid 12:2dfc1f2009e0 7786 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 7787 }
whismanoid 12:2dfc1f2009e0 7788
whismanoid 46:469d0061df5d 7789 #if HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 7790 // WIP #312 load values from flash_page_configuration_back_up[] during init
whismanoid 46:469d0061df5d 7791 const uint32_t load_arg = 1;
whismanoid 46:469d0061df5d 7792 Load_flash_page_configuration_back_up(cmdLine, load_arg);
whismanoid 46:469d0061df5d 7793 #endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 7794
whismanoid 4:d9b05924ad4c 7795 while(1) { // this code repeats forever
whismanoid 4:d9b05924ad4c 7796 // this code repeats forever
whismanoid 4:d9b05924ad4c 7797
whismanoid 21:ac062a97a71d 7798 #if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 7799 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 7800 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 7801 # if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 7802 static int button1_value_prev = 1;
whismanoid 21:ac062a97a71d 7803 static int button1_value_now = 1;
whismanoid 21:ac062a97a71d 7804 button1_value_prev = button1_value_now;
whismanoid 21:ac062a97a71d 7805 button1_value_now = button1.read();
whismanoid 21:ac062a97a71d 7806 if ((button1_value_prev - button1_value_now) == 1)
whismanoid 21:ac062a97a71d 7807 {
whismanoid 21:ac062a97a71d 7808 // on button1 falling edge (button1 press)
whismanoid 21:ac062a97a71d 7809 onButton1FallingEdge();
whismanoid 21:ac062a97a71d 7810 }
whismanoid 21:ac062a97a71d 7811 # endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7812 # if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7813 static int button2_value_prev = 1;
whismanoid 24:032f3683cb2a 7814 static int button2_value_now = 1;
whismanoid 24:032f3683cb2a 7815 button2_value_prev = button2_value_now;
whismanoid 24:032f3683cb2a 7816 button2_value_now = button2.read();
whismanoid 24:032f3683cb2a 7817 if ((button2_value_prev - button2_value_now) == 1)
whismanoid 24:032f3683cb2a 7818 {
whismanoid 24:032f3683cb2a 7819 // on button2 falling edge (button2 press)
whismanoid 24:032f3683cb2a 7820 onButton2FallingEdge();
whismanoid 24:032f3683cb2a 7821 }
whismanoid 24:032f3683cb2a 7822 # endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7823 # if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7824 static int button3_value_prev = 1;
whismanoid 24:032f3683cb2a 7825 static int button3_value_now = 1;
whismanoid 24:032f3683cb2a 7826 button3_value_prev = button3_value_now;
whismanoid 24:032f3683cb2a 7827 button3_value_now = button3.read();
whismanoid 24:032f3683cb2a 7828 if ((button3_value_prev - button3_value_now) == 1)
whismanoid 24:032f3683cb2a 7829 {
whismanoid 24:032f3683cb2a 7830 // on button3 falling edge (button3 press)
whismanoid 26:13cba69d88eb 7831 onButton3FallingEdge();
whismanoid 24:032f3683cb2a 7832 }
whismanoid 24:032f3683cb2a 7833 # endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 7834 #endif // HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 4:d9b05924ad4c 7835 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 7836 // TODO support CmdLine command menus (like on Serial_Tester); help and usual boilerplate
whismanoid 10:04022a61b527 7837 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 7838 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 7839 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 7840 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 7841 // Accept commands from Auxiliary serial port
whismanoid 6:f6d16658342b 7842 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 7843 if (AUXserial.readable()) {
whismanoid 6:f6d16658342b 7844 cmdLine_AUXserial.append(AUXserial.getc());
whismanoid 6:f6d16658342b 7845 }
whismanoid 6:f6d16658342b 7846 # endif // HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 7847 # if HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 7848 if (DAPLINKserial.readable()) {
whismanoid 6:f6d16658342b 7849 cmdLine_DAPLINKserial.append(DAPLINKserial.getc());
whismanoid 6:f6d16658342b 7850 }
whismanoid 6:f6d16658342b 7851 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 7852 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 7853 if (serial.readable()) {
whismanoid 4:d9b05924ad4c 7854 int c = serial.getc(); // instead of getc() or fgetc()
whismanoid 4:d9b05924ad4c 7855 cmdLine.append(c);
whismanoid 4:d9b05924ad4c 7856 // cmdLine.onEOLcommandParser handler implements menus
whismanoid 4:d9b05924ad4c 7857 } // if (Serial.available())
whismanoid 4:d9b05924ad4c 7858 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 7859
whismanoid 4:d9b05924ad4c 7860 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 32:80f3e5eb77d4 7861 // Datalog trigger
whismanoid 4:d9b05924ad4c 7862 if (Datalogger_Trigger == trigger_Halt) {
whismanoid 4:d9b05924ad4c 7863 // halt the datalogger; continue accepting commands
whismanoid 3:9055e17e181a 7864 continue;
whismanoid 3:9055e17e181a 7865 }
whismanoid 4:d9b05924ad4c 7866 if (Datalogger_Trigger == trigger_FreeRun) {
whismanoid 4:d9b05924ad4c 7867 // free run as fast as possible
whismanoid 3:9055e17e181a 7868 }
whismanoid 4:d9b05924ad4c 7869 if (Datalogger_Trigger == trigger_Timer) {
whismanoid 4:d9b05924ad4c 7870 // timer (configure interval)
whismanoid 32:80f3e5eb77d4 7871 // if Datalogger_Trigger == trigger_Timer sleep(g_timer_interval_msec)
whismanoid 39:4d285e961435 7872 //
whismanoid 39:4d285e961435 7873 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 7874 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 7875 // Sleep Mode vs Deep Sleep Mode
whismanoid 39:4d285e961435 7876 // See documentation https://os.mbed.com/docs/mbed-os/v5.15/apis/power-management-sleep.html
whismanoid 41:13a6a097502c 7877 // ThisThread::sleep_for(uint32_t millisec)
whismanoid 41:13a6a097502c 7878 // sleep_manager_can_deep_sleep() // tests whether deep_sleep is locked or not
whismanoid 41:13a6a097502c 7879 // sleep_manager_lock_deep_sleep() // begin section that prevents deep_sleep
whismanoid 41:13a6a097502c 7880 // sleep_manager_unlock_deep_sleep() // end section that prevents deep_sleep
whismanoid 39:4d285e961435 7881 switch(g_timer_sleepmode)
whismanoid 39:4d285e961435 7882 {
whismanoid 39:4d285e961435 7883 case datalogger_Sleep_LP0_Stop: // LT sleep = 0,
whismanoid 45:74bf1fe021e5 7884 // TODO: LP0 stop mode not supported; how would we wake up?
whismanoid 39:4d285e961435 7885 break;
whismanoid 39:4d285e961435 7886 case datalogger_Sleep_LP1_DeepSleep: // LT sleep = 1,
whismanoid 42:89607d5d4e6d 7887 //
whismanoid 45:74bf1fe021e5 7888 // In file mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\sleep.c
whismanoid 45:74bf1fe021e5 7889 // support function hal_deepsleep() just calls hal_sleep(),
whismanoid 45:74bf1fe021e5 7890 // so using LP1 Deep Sleep requires calling the low-level functions directly.
whismanoid 42:89607d5d4e6d 7891 //
whismanoid 41:13a6a097502c 7892 // sleep_manager_can_deep_sleep(); // tests whether deep_sleep is locked or not
whismanoid 41:13a6a097502c 7893 // mbed_file_handle(STDIN_FILENO)->enable_input(false); // (mbed-os-5.15) platform.stdio-buffered-serial prevents deep sleep
whismanoid 45:74bf1fe021e5 7894 #if MBED_VERSION >= MBED_ENCODE_VERSION(5, 15, 0)
whismanoid 41:13a6a097502c 7895 cmdLine.serial().enable_input(false); // (mbed-os-5.15) platform.stdio-buffered-serial prevents deep sleep
whismanoid 41:13a6a097502c 7896 // serial.enable_input(false); // (mbed-os-5.15) platform.stdio-buffered-serial prevents deep sleep
whismanoid 43:4c4733760d4c 7897
whismanoid 43:4c4733760d4c 7898 // configure RTC and start
whismanoid 43:4c4733760d4c 7899 // RTC_Setup();
whismanoid 43:4c4733760d4c 7900 {
whismanoid 43:4c4733760d4c 7901 rtc_cfg_t RTCconfig;
whismanoid 43:4c4733760d4c 7902 RTCconfig.compareCount[0] = 5;//5 second timer -- override with RTC_SetCompare(0,counts)
whismanoid 43:4c4733760d4c 7903 RTCconfig.compareCount[1] = 7;//7 second timer -- override with RTC_SetCompare(1,counts)
whismanoid 43:4c4733760d4c 7904 RTCconfig.prescaler = RTC_PRESCALE_DIV_2_12; //1Hz clock
whismanoid 43:4c4733760d4c 7905 RTCconfig.prescalerMask = RTC_PRESCALE_DIV_2_12;//used for prescaler compare
whismanoid 43:4c4733760d4c 7906 RTCconfig.snoozeCount = 0;
whismanoid 43:4c4733760d4c 7907 RTCconfig.snoozeMode = RTC_SNOOZE_DISABLE;
whismanoid 43:4c4733760d4c 7908 RTC_Init(&RTCconfig);
whismanoid 43:4c4733760d4c 7909 RTC_Start();
whismanoid 43:4c4733760d4c 7910
whismanoid 43:4c4733760d4c 7911 // Clear existing wake-up config
whismanoid 43:4c4733760d4c 7912 LP_ClearWakeUpConfig();
whismanoid 43:4c4733760d4c 7913
whismanoid 43:4c4733760d4c 7914 // Clear any event flags
whismanoid 43:4c4733760d4c 7915 LP_ClearWakeUpFlags();
whismanoid 43:4c4733760d4c 7916
whismanoid 43:4c4733760d4c 7917 // configure wake-up on RTC compare 1
whismanoid 43:4c4733760d4c 7918 // LP_ConfigRTCWakeUp(unsigned int comp0_en, unsigned int comp1_en, unsigned int prescale_cmp_en, unsigned int rollover_en);
whismanoid 43:4c4733760d4c 7919 LP_ConfigRTCWakeUp(0, 1, 0, 0);
whismanoid 43:4c4733760d4c 7920
whismanoid 44:84402faa8eb9 7921 // wait until UART_Busy indicates no ongoing transactions (both ports)
whismanoid 44:84402faa8eb9 7922 while (Console_PrepForSleep() != E_NO_ERROR);
whismanoid 44:84402faa8eb9 7923
whismanoid 43:4c4733760d4c 7924 // set RTC compare 1 value
whismanoid 43:4c4733760d4c 7925 // cmp = RTC_GetCount() + LP1_WakeTime;
whismanoid 43:4c4733760d4c 7926 uint32_t cmp = RTC_GetCount() + ((g_timer_interval_msec + 500.) / 1000.);
whismanoid 43:4c4733760d4c 7927 // RTC_SetCompare(uint8_t compareIndex, uint32_t counts)
whismanoid 43:4c4733760d4c 7928 RTC_SetCompare(1, cmp);
whismanoid 43:4c4733760d4c 7929
whismanoid 43:4c4733760d4c 7930 RTC_ClearFlags(MXC_F_RTC_FLAGS_COMP1);
whismanoid 43:4c4733760d4c 7931 }
whismanoid 43:4c4733760d4c 7932
whismanoid 43:4c4733760d4c 7933 //global disable interrupt
whismanoid 43:4c4733760d4c 7934 __disable_irq();
whismanoid 43:4c4733760d4c 7935
whismanoid 43:4c4733760d4c 7936 LP_EnterLP1();
whismanoid 43:4c4733760d4c 7937
whismanoid 43:4c4733760d4c 7938 //global enable interrupt
whismanoid 43:4c4733760d4c 7939 __enable_irq();
whismanoid 43:4c4733760d4c 7940
whismanoid 43:4c4733760d4c 7941 // stop waking on RTC
whismanoid 43:4c4733760d4c 7942 // LP_ConfigRTCWakeUp(unsigned int comp0_en, unsigned int comp1_en, unsigned int prescale_cmp_en, unsigned int rollover_en);
whismanoid 43:4c4733760d4c 7943 LP_ConfigRTCWakeUp(0, 0, 0, 0);
whismanoid 43:4c4733760d4c 7944
whismanoid 43:4c4733760d4c 7945 // Clear existing wake-up config
whismanoid 43:4c4733760d4c 7946 LP_ClearWakeUpConfig();
whismanoid 43:4c4733760d4c 7947
whismanoid 43:4c4733760d4c 7948 // Clear any event flags
whismanoid 43:4c4733760d4c 7949 LP_ClearWakeUpFlags();
whismanoid 45:74bf1fe021e5 7950
whismanoid 43:4c4733760d4c 7951 RTC_Stop();
whismanoid 43:4c4733760d4c 7952
whismanoid 41:13a6a097502c 7953 // mbed_file_handle(STDIN_FILENO)->enable_input(true); // (mbed-os-5.15)
whismanoid 41:13a6a097502c 7954 cmdLine.serial().enable_input(true); // (mbed-os-5.15)
whismanoid 41:13a6a097502c 7955 // serial.enable_input(true); // (mbed-os-5.15)
whismanoid 39:4d285e961435 7956 break;
whismanoid 45:74bf1fe021e5 7957 #endif // MBED_VERSION >= MBED_ENCODE_VERSION(5, 15, 0)
whismanoid 39:4d285e961435 7958 case datalogger_Sleep_LP2_Sleep: // LT sleep = 2,
whismanoid 41:13a6a097502c 7959 sleep_manager_lock_deep_sleep(); // begin section that prevents deep_sleep
whismanoid 41:13a6a097502c 7960 ThisThread::sleep_for(g_timer_interval_msec); // wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 41:13a6a097502c 7961 sleep_manager_unlock_deep_sleep(); // end section that prevents deep_sleep
whismanoid 39:4d285e961435 7962 break;
whismanoid 39:4d285e961435 7963 case datalogger_Sleep_LP3_Run: // LT sleep = 3,
whismanoid 45:74bf1fe021e5 7964 // TODO: USE_DATALOGGER_SLEEP -- ThisThread::sleep_for(uint32_t millisec) instead of wait_ms(g_timer_interval_msec)
whismanoid 41:13a6a097502c 7965 wait_ms(g_timer_interval_msec);
whismanoid 39:4d285e961435 7966 break;
whismanoid 39:4d285e961435 7967 }
whismanoid 39:4d285e961435 7968 #else // USE_DATALOGGER_SLEEP
whismanoid 17:9397ea3ea7e9 7969 wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 39:4d285e961435 7970 #endif // USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 7971 //
whismanoid 17:9397ea3ea7e9 7972 if (g_timer_interval_counter > 0) {
whismanoid 17:9397ea3ea7e9 7973 g_timer_interval_counter--;
whismanoid 17:9397ea3ea7e9 7974 continue;
whismanoid 17:9397ea3ea7e9 7975 }
whismanoid 17:9397ea3ea7e9 7976 // if time interval not yet reached, continue (continue accepting commands)
whismanoid 32:80f3e5eb77d4 7977 g_timer_interval_counter = g_timer_interval_count-1;
whismanoid 3:9055e17e181a 7978 }
whismanoid 4:d9b05924ad4c 7979 if (Datalogger_Trigger == trigger_PlatformDigitalInput) {
whismanoid 4:d9b05924ad4c 7980 // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 7981 // TODO: read selected input pin, test value
whismanoid 17:9397ea3ea7e9 7982 // TODO: if no match, continue (continue accepting commands)
whismanoid 3:9055e17e181a 7983 }
whismanoid 4:d9b05924ad4c 7984 if (Datalogger_Trigger == trigger_SPIDeviceRegRead) {
whismanoid 4:d9b05924ad4c 7985 // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 7986 // TODO: SPI transfer regAddr
whismanoid 17:9397ea3ea7e9 7987 // TODO: apply dataMask, compare with testValue
whismanoid 17:9397ea3ea7e9 7988 // TODO: if no match, continue (continue accepting commands)
whismanoid 4:d9b05924ad4c 7989 }
whismanoid 4:d9b05924ad4c 7990 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 0:cb44e2e9ec4c 7991
whismanoid 8:dffee7509bfb 7992 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 7993 if (Datalogger_Need_PrintHeader) {
whismanoid 8:dffee7509bfb 7994 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 7995 Datalogger_PrintHeader(cmdLine);
whismanoid 8:dffee7509bfb 7996 }
whismanoid 8:dffee7509bfb 7997 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 7998 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 7999 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 8000 }
whismanoid 8:dffee7509bfb 8001 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 8002 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 8003 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 8004 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 8005 }
whismanoid 8:dffee7509bfb 8006 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 8007 Datalogger_Need_PrintHeader = false;
whismanoid 8:dffee7509bfb 8008 }
whismanoid 5:aaf8b5f5fda1 8009 Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 8010 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 8011 // Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 8012 Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 8013 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 0:cb44e2e9ec4c 8014 // wait(3.0);
whismanoid 0:cb44e2e9ec4c 8015 // CODE GENERATOR: print conversion result
whismanoid 0:cb44e2e9ec4c 8016 // Use Arduino Serial Plotter to view output: Tools | Serial Plotter
whismanoid 8:dffee7509bfb 8017 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 8018 Datalogger_PrintRow(cmdLine);
whismanoid 8:dffee7509bfb 8019 }
whismanoid 8:dffee7509bfb 8020 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 8021 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 8022 Datalogger_PrintRow(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 8023 }
whismanoid 8:dffee7509bfb 8024 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 8025 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 8026 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 8027 Datalogger_PrintRow(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 8028 }
whismanoid 8:dffee7509bfb 8029 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:cb44e2e9ec4c 8030
whismanoid 0:cb44e2e9ec4c 8031 } // this code repeats forever
whismanoid 0:cb44e2e9ec4c 8032 }
whismanoid 0:cb44e2e9ec4c 8033 //---------- CODE GENERATOR: end DataLogHelloCppCodeList