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:
Wed Oct 27 22:00:21 2021 -0700
Revision:
46:469d0061df5d
Parent:
45:74bf1fe021e5
Child:
47:f1a56afb4aca
Configuration load/save in flash (%A cal? values); #312
HAS_FLASH_LOAD_SAVE=1 HAS_FLASH_PEEK=1 HAS_FLASH_POKE=1
%F peek=0x00014000 len=0x2000 -- hex dump
%F poke=0x00014000 ab cd ef 27 18 28 -- erase/write flash page
%F save=0xFF -- erase config; F save=0 -- save all config
%F load -- load all config
Feature based on Internal_Datalogger 54 (fda4b655a706)

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 36:e7aac874b8be 87 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 88 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 89 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 36:e7aac874b8be 90 //
whismanoid 36:e7aac874b8be 91 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 92 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 36:e7aac874b8be 93 //
whismanoid 36:e7aac874b8be 94 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 95 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 36:e7aac874b8be 96 //
whismanoid 36:e7aac874b8be 97 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 98 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 36:e7aac874b8be 99 //
whismanoid 36:e7aac874b8be 100 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 101 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 36:e7aac874b8be 102 //
whismanoid 36:e7aac874b8be 103 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 104 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 36:e7aac874b8be 105 //
whismanoid 36:e7aac874b8be 106 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 107 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 36:e7aac874b8be 108 //
whismanoid 36:e7aac874b8be 109 # else
whismanoid 36:e7aac874b8be 110 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 111 # endif
whismanoid 36:e7aac874b8be 112 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 113 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 114 //
whismanoid 36:e7aac874b8be 115 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 0:cb44e2e9ec4c 116 //---------- CODE GENERATOR: DataLogHelloCppCodeList
whismanoid 0:cb44e2e9ec4c 117 // CODE GENERATOR: example code includes
whismanoid 0:cb44e2e9ec4c 118
whismanoid 0:cb44e2e9ec4c 119 // example code includes
whismanoid 0:cb44e2e9ec4c 120 // standard include for target platform -- Platform_Include_Boilerplate
whismanoid 0:cb44e2e9ec4c 121 #include "mbed.h"
whismanoid 0:cb44e2e9ec4c 122 // Platforms:
whismanoid 0:cb44e2e9ec4c 123 // - MAX32625MBED
whismanoid 0:cb44e2e9ec4c 124 // - supports mbed-os-5.11, requires USBDevice library
whismanoid 0:cb44e2e9ec4c 125 // - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
whismanoid 0:cb44e2e9ec4c 126 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 127 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 128 // - MAX32600MBED
whismanoid 7:949ec8581f5e 129 // - Please note the last supported version is Mbed OS 6.3.
whismanoid 0:cb44e2e9ec4c 130 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 131 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 132 // - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board.
whismanoid 0:cb44e2e9ec4c 133 // - NUCLEO_F446RE
whismanoid 0:cb44e2e9ec4c 134 // - remove USBDevice library
whismanoid 0:cb44e2e9ec4c 135 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 136 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 137 // - NUCLEO_F401RE
whismanoid 0:cb44e2e9ec4c 138 // - remove USBDevice library
whismanoid 0:cb44e2e9ec4c 139 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 140 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 141 // - MAX32630FTHR
whismanoid 0:cb44e2e9ec4c 142 // - #include "max32630fthr.h"
whismanoid 7:949ec8581f5e 143 // - add http://developer.mbed.org/teams/MaximIntegrated/code/max32630fthr/
whismanoid 0:cb44e2e9ec4c 144 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 145 // - MAX32620FTHR
whismanoid 0:cb44e2e9ec4c 146 // - #include "MAX32620FTHR.h"
whismanoid 0:cb44e2e9ec4c 147 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 148 // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
whismanoid 0:cb44e2e9ec4c 149 // - not tested yet
whismanoid 0:cb44e2e9ec4c 150 // - MAX32625PICO
whismanoid 0:cb44e2e9ec4c 151 // - #include "max32625pico.h"
whismanoid 0:cb44e2e9ec4c 152 // - add https://os.mbed.com/users/switches/code/max32625pico/
whismanoid 0:cb44e2e9ec4c 153 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 154 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 155 // - not tested yet
whismanoid 0:cb44e2e9ec4c 156 // - see https://os.mbed.com/users/switches/code/max32625pico/
whismanoid 0:cb44e2e9ec4c 157 // - see https://os.mbed.com/users/switches/code/PICO_board_demo/
whismanoid 0:cb44e2e9ec4c 158 // - see https://os.mbed.com/users/switches/code/PICO_USB_I2C_SPI/
whismanoid 0:cb44e2e9ec4c 159 // - see https://os.mbed.com/users/switches/code/SerialInterface/
whismanoid 0:cb44e2e9ec4c 160 // - Note: To load the MAX32625PICO firmware, hold the button while
whismanoid 0:cb44e2e9ec4c 161 // connecting the USB cable, then copy firmware bin file
whismanoid 0:cb44e2e9ec4c 162 // to the MAINTENANCE drive.
whismanoid 0:cb44e2e9ec4c 163 // - see https://os.mbed.com/platforms/MAX32625PICO/
whismanoid 0:cb44e2e9ec4c 164 // - see https://os.mbed.com/teams/MaximIntegrated/wiki/MAX32625PICO-Firmware-Updates
whismanoid 41:13a6a097502c 165 // - update from mbed-os-5.11.5 to mbed-os-5.15 to support deep sleep
whismanoid 41:13a6a097502c 166 // - cd mbed-os ; mbed update mbed-os-5.15.7 ; cd .. ; mbed remove USBDevice ; mbed sync
whismanoid 41:13a6a097502c 167 // - (Internal_DataLogger_NoUSB_MAX32625PICO does not use USBDevice library anyway)
whismanoid 0:cb44e2e9ec4c 168 //
whismanoid 0:cb44e2e9ec4c 169 // end Platform_Include_Boilerplate
whismanoid 0:cb44e2e9ec4c 170
whismanoid 0:cb44e2e9ec4c 171 //--------------------------------------------------
whismanoid 46:469d0061df5d 172 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 173 #ifndef HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 174 #define HAS_FLASH_PEEK 1
whismanoid 46:469d0061df5d 175 // #undef HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 176 #endif
whismanoid 46:469d0061df5d 177 #ifndef HAS_FLASH_POKE
whismanoid 46:469d0061df5d 178 #define HAS_FLASH_POKE 0
whismanoid 46:469d0061df5d 179 // #undef HAS_FLASH_POKE
whismanoid 46:469d0061df5d 180 #endif
whismanoid 46:469d0061df5d 181 //--------------------------------------------------
whismanoid 46:469d0061df5d 182 // mbed interface to on-chip Flash
whismanoid 46:469d0061df5d 183 //--------------------------------------------------
whismanoid 46:469d0061df5d 184 #if defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 185 #if HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 186 #warning "info: using HAS_FLASH_PEEK supporting %F peek=addr len=..."
whismanoid 46:469d0061df5d 187 #endif
whismanoid 46:469d0061df5d 188 #if HAS_FLASH_POKE
whismanoid 46:469d0061df5d 189 #warning "info: using HAS_FLASH_POKE supporting %F poke=addr data... "
whismanoid 46:469d0061df5d 190 #endif
whismanoid 46:469d0061df5d 191 #if HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 192 #warning "info: using HAS_FLASH_LOAD_SAVE supporting %F save... and %F load... "
whismanoid 46:469d0061df5d 193 #endif
whismanoid 46:469d0061df5d 194 // Maxim MAX32625 flash interface flc.h not .\mbed-os\drivers\FlashIAP.h
whismanoid 46:469d0061df5d 195 // .\mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\mxc\flc.h
whismanoid 46:469d0061df5d 196 // .\mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\mxc\flc.c
whismanoid 46:469d0061df5d 197 // int FLC_Init(void);
whismanoid 46:469d0061df5d 198 // int FLC_PageErase(uint32_t address, uint8_t erase_code, uint8_t unlock_key);
whismanoid 46:469d0061df5d 199 // int FLC_Write(uint32_t address, const void *data, uint32_t length, uint8_t unlock_key);
whismanoid 46:469d0061df5d 200 // example see CommunicationHandler Interpreter.cpp
whismanoid 46:469d0061df5d 201 // https://os.mbed.com/users/MuratAslan/code/CommunicationHandler/
whismanoid 46:469d0061df5d 202 #include "flc.h"
whismanoid 46:469d0061df5d 203 //
whismanoid 46:469d0061df5d 204 // Other targets like STM use FlashIAP interface
whismanoid 46:469d0061df5d 205 // #if !DEVICE_FLASH
whismanoid 46:469d0061df5d 206 // #error [NOT_SUPPORTED] Flash API not supported for this target
whismanoid 46:469d0061df5d 207 // #else
whismanoid 46:469d0061df5d 208 // #warning "DEVICE_FLASH is defined, so FlashIAP Flash API is // supported for this target"
whismanoid 46:469d0061df5d 209 // #endif
whismanoid 46:469d0061df5d 210 // .\mbed-os\drivers\FlashIAP.h
whismanoid 46:469d0061df5d 211 // #warning "using FlashIAP.h"
whismanoid 46:469d0061df5d 212 // #include <FlashIAP.h>
whismanoid 46:469d0061df5d 213 // mbed interface to on-chip Flash
whismanoid 46:469d0061df5d 214 // FlashIAP flash;
whismanoid 46:469d0061df5d 215 // error: 'FlashIAP' does not name a type
whismanoid 46:469d0061df5d 216 //--------------------------------------------------
whismanoid 46:469d0061df5d 217 // MAX40108 calibration values assign absolute address
whismanoid 46:469d0061df5d 218 const char flash_page_configuration_back_up[8192] __attribute__((aligned(8192))) = {0};
whismanoid 46:469d0061df5d 219 // WIP #312 map values in flash_page_configuration_back_up[]
whismanoid 46:469d0061df5d 220 // such as board serial number, %A calibration values,
whismanoid 46:469d0061df5d 221 // business logic, button handlers, etc.
whismanoid 46:469d0061df5d 222 // Use some pattern that stands out in the hex file dump
whismanoid 46:469d0061df5d 223 // as well as in the flash dump... note the hex file is LE/LSbyte first,
whismanoid 46:469d0061df5d 224 // while the flash memory is BE/MSbyte first.
whismanoid 46:469d0061df5d 225 //
whismanoid 46:469d0061df5d 226 // I don't have control of where this ends up because "at" attribute
whismanoid 46:469d0061df5d 227 // is not supported, but at least flash_page_configuration_back_up
whismanoid 46:469d0061df5d 228 // is page-aligned and its address is printed in the help.
whismanoid 46:469d0061df5d 229 // Also use a pattern that should stand out in the hex dump.
whismanoid 46:469d0061df5d 230 // Note that in the .bin file, "32107654" is 33 32 31 30 37 36 35 34,
whismanoid 46:469d0061df5d 231 // but in the flash memory it will be 0x30313233 0x34353637
whismanoid 46:469d0061df5d 232 // Use free hex editor to find text in .bin file,
whismanoid 46:469d0061df5d 233 // then add base address 0x00010000 to get peek address.
whismanoid 46:469d0061df5d 234 // char* TestString1 = "UUUUUUUUUUUUUUUUUUUU""32107654BA98FEDC"" MAX32625 Calibration ....####@@@@""UUUUUUUUUUUUUUUUUUUU";
whismanoid 46:469d0061df5d 235 // > %F peek=0x000241f0 len=20
whismanoid 46:469d0061df5d 236 // FLASH 0x000241f0: 0x544c4f56 0x00454741 0x55555555 0x55555555
whismanoid 46:469d0061df5d 237 // FLASH 0x00024200: 0x55555555 0x55555555 0x55555555 0x30313233
whismanoid 46:469d0061df5d 238 // FLASH 0x00024210: 0x34353637 0x38394142 0x43444546 0x58414d20
whismanoid 46:469d0061df5d 239 // FLASH 0x00024220: 0x32363233 0x61432035 0x7262696c 0x6f697461
whismanoid 46:469d0061df5d 240 // FLASH 0x00024230: 0x2020206e 0x2e2e2e2e 0x23232323 0x40404040
whismanoid 46:469d0061df5d 241 // FLASH 0x00024240: 0x55555555 0x55555555 0x55555555 0x55555555
whismanoid 46:469d0061df5d 242 // FLASH 0x00024250: 0x55555555 0x00000000 0x00000000 0x00000000
whismanoid 46:469d0061df5d 243 // FLASH 0x00024260: 0x00013b1b 0x000140d1 0x00013d9f 0x00013e2d
whismanoid 46:469d0061df5d 244 //
whismanoid 46:469d0061df5d 245 // Why did it end up at that address? Here's the linker map report:
whismanoid 46:469d0061df5d 246 // .\BUILD\MAX32625PICO\GCC_ARM\Internal_DataLogger.map
whismanoid 46:469d0061df5d 247 // .text.startup._GLOBAL__sub_I_TestString1
whismanoid 46:469d0061df5d 248 // 0x0001374c 0x33c BUILD/MAX32625PICO/GCC_ARM/DataLogger_Internal.o
whismanoid 46:469d0061df5d 249 // .rodata._GLOBAL__sub_I_TestString1.str1.1
whismanoid 46:469d0061df5d 250 // 0x00022d64 0x12 BUILD/MAX32625PICO/GCC_ARM/DataLogger_Internal.o
whismanoid 46:469d0061df5d 251 // 0x19 (size before relaxing)
whismanoid 46:469d0061df5d 252 //
whismanoid 46:469d0061df5d 253 // For calibration purposes this could still be usable,
whismanoid 46:469d0061df5d 254 // as long as the firmware knows where its calibration constants live.
whismanoid 46:469d0061df5d 255 //
whismanoid 46:469d0061df5d 256 #if defined ( __GNUC__ )
whismanoid 46:469d0061df5d 257 __attribute__ ((section(".calibration_teststring")))
whismanoid 46:469d0061df5d 258 #endif
whismanoid 46:469d0061df5d 259 char* TestString1 = "UUUU" "UUUU" "UUUU" "UUUU"
whismanoid 46:469d0061df5d 260 "\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF"
whismanoid 46:469d0061df5d 261 "\x11\x22\x33\x44" "\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF"
whismanoid 46:469d0061df5d 262 "UUUUUUUUUUUUUUUUUUUU""32107654BA98FEDC"" MAX32625 Calibration ....####@@@@""UUUUUUUUUUUUUUUUUUUU";
whismanoid 46:469d0061df5d 263 //
whismanoid 46:469d0061df5d 264 // Limit the ranges where memory write operation will be allowed
whismanoid 46:469d0061df5d 265 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 266 // FLASH (rx) : ORIGIN = 0x00010000, LENGTH = 0x00070000
whismanoid 46:469d0061df5d 267 // RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00028000
whismanoid 46:469d0061df5d 268 typedef struct {
whismanoid 46:469d0061df5d 269 uint32_t addr_min; // lowest address of range
whismanoid 46:469d0061df5d 270 uint32_t addr_max; // highest address of range
whismanoid 46:469d0061df5d 271 char name[6]; // 5-character name, pad with spaces, null-terminated
whismanoid 46:469d0061df5d 272 char can_flash_write_read; // 8=end of list, 4=flashPoke, 2=ramPoke, 1=read
whismanoid 46:469d0061df5d 273 } poke_access_t;
whismanoid 46:469d0061df5d 274 poke_access_t poke_access_list[] = {
whismanoid 46:469d0061df5d 275 { 0x12345678, 0x12345678, "undef", 0 }, // first record: catch undefined ranges
whismanoid 46:469d0061df5d 276 // { 0x00000000, 0x0000FFFF, " BOOT", 1 }, // boot area is flash page 0-7, but don't allow flashPoke
whismanoid 46:469d0061df5d 277 { 0x00000000, 0x00001FFF, "BOOT0", 1 }, // flash page 0
whismanoid 46:469d0061df5d 278 { 0x00002000, 0x00003FFF, "BOOT1", 1 }, // flash page 1
whismanoid 46:469d0061df5d 279 { 0x00004000, 0x00005FFF, "BOOT2", 1 }, // flash page 2
whismanoid 46:469d0061df5d 280 { 0x00006000, 0x00007FFF, "BOOT3", 1 }, // flash page 3
whismanoid 46:469d0061df5d 281 { 0x00008000, 0x00009FFF, "BOOT4", 1 }, // flash page 4
whismanoid 46:469d0061df5d 282 { 0x0000A000, 0x0000BFFF, "BOOT5", 1 }, // flash page 5
whismanoid 46:469d0061df5d 283 { 0x0000C000, 0x0000DFFF, "BOOT6", 1 }, // flash page 6
whismanoid 46:469d0061df5d 284 { 0x0000E000, 0x0000FFFF, "BOOT7", 1 }, // flash page 7
whismanoid 46:469d0061df5d 285 //
whismanoid 46:469d0061df5d 286 //{ 0x00010000, 0x0007FFFF, "FLASH", 5 }, // flash pages 8-62
whismanoid 46:469d0061df5d 287 // Future: separate FLASH pages, allow flashPoke only on the calibration page
whismanoid 46:469d0061df5d 288 { 0x00010000, 0x00011FFF, "FLA08", 1 }, // flash page 8
whismanoid 46:469d0061df5d 289 { 0x00012000, 0x00013FFF, "FLA09", 1 }, // flash page 9
whismanoid 46:469d0061df5d 290 { 0x00014000, 0x00015FFF, "FLA10", 1 }, // flash page 10
whismanoid 46:469d0061df5d 291 { 0x00016000, 0x00017FFF, "FLA11", 1 }, // flash page 11
whismanoid 46:469d0061df5d 292 { 0x00018000, 0x00019FFF, "FLA12", 1 }, // flash page 12
whismanoid 46:469d0061df5d 293 { 0x0001A000, 0x0001BFFF, "FLA13", 1 }, // flash page 13
whismanoid 46:469d0061df5d 294 { 0x0001C000, 0x0001DFFF, "FLA14", 1 }, // flash page 14
whismanoid 46:469d0061df5d 295 { 0x0001E000, 0x0001FFFF, "FLA15", 1 }, // flash page 15
whismanoid 46:469d0061df5d 296 //
whismanoid 46:469d0061df5d 297 { 0x00020000, 0x00021FFF, "FLA16", 1 }, // flash page 16
whismanoid 46:469d0061df5d 298 { 0x00022000, 0x00023FFF, "FLA17", 1 }, // flash page 17
whismanoid 46:469d0061df5d 299 { 0x00024000, 0x00025FFF, "FLA18", 5 }, // flash page 18
whismanoid 46:469d0061df5d 300 { 0x00026000, 0x00027FFF, "FLA19", 5 }, // flash page 19
whismanoid 46:469d0061df5d 301 { 0x00028000, 0x00029FFF, "FLA20", 5 }, // flash page 20
whismanoid 46:469d0061df5d 302 { 0x0002A000, 0x0002BFFF, "FLA21", 5 }, // flash page 21
whismanoid 46:469d0061df5d 303 { 0x0002C000, 0x0002DFFF, "FLA22", 5 }, // flash page 22
whismanoid 46:469d0061df5d 304 { 0x0002E000, 0x0002FFFF, "FLA23", 5 }, // flash page 23
whismanoid 46:469d0061df5d 305 //
whismanoid 46:469d0061df5d 306 { 0x00030000, 0x00031FFF, "FLA24", 5 }, // flash page 24
whismanoid 46:469d0061df5d 307 { 0x00032000, 0x00033FFF, "FLA25", 5 }, // flash page 25
whismanoid 46:469d0061df5d 308 { 0x00034000, 0x00035FFF, "FLA26", 5 }, // flash page 26
whismanoid 46:469d0061df5d 309 { 0x00036000, 0x00037FFF, "FLA27", 5 }, // flash page 27
whismanoid 46:469d0061df5d 310 { 0x00038000, 0x00039FFF, "FLA28", 5 }, // flash page 28
whismanoid 46:469d0061df5d 311 { 0x0003A000, 0x0003BFFF, "FLA29", 5 }, // flash page 29
whismanoid 46:469d0061df5d 312 { 0x0003C000, 0x0003DFFF, "FLA30", 5 }, // flash page 30
whismanoid 46:469d0061df5d 313 { 0x0003E000, 0x0003FFFF, "FLA31", 5 }, // flash page 31
whismanoid 46:469d0061df5d 314 //
whismanoid 46:469d0061df5d 315 { 0x00040000, 0x00041FFF, "FLA32", 5 }, // flash page 32
whismanoid 46:469d0061df5d 316 { 0x00042000, 0x00043FFF, "FLA33", 5 }, // flash page 33
whismanoid 46:469d0061df5d 317 { 0x00044000, 0x00045FFF, "FLA34", 5 }, // flash page 34
whismanoid 46:469d0061df5d 318 { 0x00046000, 0x00047FFF, "FLA35", 5 }, // flash page 35
whismanoid 46:469d0061df5d 319 { 0x00048000, 0x00049FFF, "FLA36", 5 }, // flash page 36
whismanoid 46:469d0061df5d 320 { 0x0004A000, 0x0004BFFF, "FLA37", 5 }, // flash page 37
whismanoid 46:469d0061df5d 321 { 0x0004C000, 0x0004DFFF, "FLA38", 5 }, // flash page 38
whismanoid 46:469d0061df5d 322 { 0x0004E000, 0x0004FFFF, "FLA39", 5 }, // flash page 39
whismanoid 46:469d0061df5d 323 //
whismanoid 46:469d0061df5d 324 { 0x00050000, 0x00051FFF, "FLA40", 5 }, // flash page 40
whismanoid 46:469d0061df5d 325 { 0x00052000, 0x00053FFF, "FLA41", 5 }, // flash page 41
whismanoid 46:469d0061df5d 326 { 0x00054000, 0x00055FFF, "FLA42", 5 }, // flash page 42
whismanoid 46:469d0061df5d 327 { 0x00056000, 0x00057FFF, "FLA43", 5 }, // flash page 43
whismanoid 46:469d0061df5d 328 { 0x00058000, 0x00059FFF, "FLA44", 5 }, // flash page 44
whismanoid 46:469d0061df5d 329 { 0x0005A000, 0x0005BFFF, "FLA45", 5 }, // flash page 45
whismanoid 46:469d0061df5d 330 { 0x0005C000, 0x0005DFFF, "FLA46", 5 }, // flash page 46
whismanoid 46:469d0061df5d 331 { 0x0005E000, 0x0005FFFF, "FLA47", 5 }, // flash page 47
whismanoid 46:469d0061df5d 332 //
whismanoid 46:469d0061df5d 333 { 0x00060000, 0x00061FFF, "FLA48", 5 }, // flash page 48
whismanoid 46:469d0061df5d 334 { 0x00062000, 0x00063FFF, "FLA49", 5 }, // flash page 49
whismanoid 46:469d0061df5d 335 { 0x00064000, 0x00065FFF, "FLA50", 5 }, // flash page 50
whismanoid 46:469d0061df5d 336 { 0x00066000, 0x00067FFF, "FLA51", 5 }, // flash page 51
whismanoid 46:469d0061df5d 337 { 0x00068000, 0x00069FFF, "FLA52", 5 }, // flash page 52
whismanoid 46:469d0061df5d 338 { 0x0006A000, 0x0006BFFF, "FLA53", 5 }, // flash page 53
whismanoid 46:469d0061df5d 339 { 0x0006C000, 0x0006DFFF, "FLA54", 5 }, // flash page 54
whismanoid 46:469d0061df5d 340 { 0x0006E000, 0x0006FFFF, "FLA55", 5 }, // flash page 55
whismanoid 46:469d0061df5d 341 //
whismanoid 46:469d0061df5d 342 { 0x00070000, 0x00071FFF, "FLA56", 5 }, // flash page 56
whismanoid 46:469d0061df5d 343 { 0x00072000, 0x00073FFF, "FLA57", 5 }, // flash page 57
whismanoid 46:469d0061df5d 344 { 0x00074000, 0x00075FFF, "FLA58", 5 }, // flash page 58
whismanoid 46:469d0061df5d 345 { 0x00076000, 0x00077FFF, "FLA59", 5 }, // flash page 59
whismanoid 46:469d0061df5d 346 { 0x00078000, 0x00079FFF, "FLA60", 5 }, // flash page 60
whismanoid 46:469d0061df5d 347 { 0x0007A000, 0x0007BFFF, "FLA61", 5 }, // flash page 61
whismanoid 46:469d0061df5d 348 { 0x0007C000, 0x0007DFFF, "FLA62", 5 }, // flash page 62
whismanoid 46:469d0061df5d 349 { 0x0007E000, 0x0007FFFF, "FLA63", 5 }, // flash page 63
whismanoid 46:469d0061df5d 350 //
whismanoid 46:469d0061df5d 351 { 0x20000000, 0x20027FFF, " RAM", 3 }, // ramPoke + read
whismanoid 46:469d0061df5d 352 { 0x20028000, 0x2002FFFF, "skip ", 0 }, // don't read from this range
whismanoid 46:469d0061df5d 353 { 0x40000000, 0x400003FF, " SYS", 1 }, // read only
whismanoid 46:469d0061df5d 354 { 0x40000400, 0x400007FF, " CLK", 1 },
whismanoid 46:469d0061df5d 355 { 0x40000800, 0x400009FF, " PWR", 1 },
whismanoid 46:469d0061df5d 356 { 0x40000A00, 0x40000BFF, " RTC", 1 },
whismanoid 46:469d0061df5d 357 { 0x40000C00, 0x40001FFF, "IOMAN", 1 },
whismanoid 46:469d0061df5d 358 { 0x40002000, 0x40002FFF, " FLC", 1 },
whismanoid 46:469d0061df5d 359 { 0x40003000, 0x40003FFF, " ICC", 1 },
whismanoid 46:469d0061df5d 360 { 0x40004000, 0x40004FFF, " SPIX", 1 },
whismanoid 46:469d0061df5d 361 { 0x40005000, 0x40005FFF, " PMU", 1 },
whismanoid 46:469d0061df5d 362 { 0x40006000, 0x40006FFF, " CRC", 1 },
whismanoid 46:469d0061df5d 363 { 0x40007000, 0x40007FFF, " TPU", 1 },
whismanoid 46:469d0061df5d 364 { 0x40008000, 0x40008FFF, " WDT0", 1 },
whismanoid 46:469d0061df5d 365 { 0x40009000, 0x40009FFF, " WDT1", 1 },
whismanoid 46:469d0061df5d 366 { 0x4000A000, 0x4000AFFF, " GPIO", 1 },
whismanoid 46:469d0061df5d 367 { 0x4000B000, 0x4000FFFF, " TMR", 1 },
whismanoid 46:469d0061df5d 368 { 0x40011000, 0x4000FFFF, " PT", 1 },
whismanoid 46:469d0061df5d 369 { 0x40012000, 0x4000FFFF, " UART", 1 },
whismanoid 46:469d0061df5d 370 { 0x40016000, 0x4000FFFF, " I2CM", 1 },
whismanoid 46:469d0061df5d 371 { 0x40019000, 0x4000FFFF, " I2CS", 1 },
whismanoid 46:469d0061df5d 372 { 0x4001A000, 0x4000FFFF, " SPIM", 1 },
whismanoid 46:469d0061df5d 373 { 0x4001E000, 0x4000FFFF, " OWM", 1 },
whismanoid 46:469d0061df5d 374 { 0x4001F000, 0x4000FFFF, " ADC", 1 },
whismanoid 46:469d0061df5d 375 { 0x40020000, 0x40000FFF, " SPIS", 1 },
whismanoid 46:469d0061df5d 376 { 0x40100000, 0x40100FFF, " USB", 1 },
whismanoid 46:469d0061df5d 377 { 0x40101000, 0x40101FFF, " CRC", 1 },
whismanoid 46:469d0061df5d 378 { 0x40102000, 0x40102FFF, " TPU", 1 },
whismanoid 46:469d0061df5d 379 { 0x40103000, 0x40103FFF, "UART0", 1 },
whismanoid 46:469d0061df5d 380 { 0x40104000, 0x40104FFF, "UART1", 1 },
whismanoid 46:469d0061df5d 381 { 0x40105000, 0x40105FFF, "UART2", 1 },
whismanoid 46:469d0061df5d 382 //{ 0x40106000, 0x40106FFF, "_____", 1 }, // reserved
whismanoid 46:469d0061df5d 383 { 0x40107000, 0x40107FFF, "I2CM0", 1 }, // I2CM0 FIFOs
whismanoid 46:469d0061df5d 384 { 0x40108000, 0x40108FFF, "I2CM1", 1 }, // I2CM1 FIFOs
whismanoid 46:469d0061df5d 385 //{ 0x40109000, 0x40109FFF, "_____", 1 }, // reserved
whismanoid 46:469d0061df5d 386 { 0x4010A000, 0x4010AFFF, "SPIM0", 1 }, // SPIM0 FIFOs
whismanoid 46:469d0061df5d 387 { 0x4010B000, 0x4010BFFF, "SPIM1", 1 }, // SPIM1 FIFOs
whismanoid 46:469d0061df5d 388 { 0x4010C000, 0x4010CFFF, "SPIM2", 1 }, // SPIM2 FIFOs
whismanoid 46:469d0061df5d 389 //{ 0x4010D000, 0x4010DFFF, "_____", 1 }, // reserved
whismanoid 46:469d0061df5d 390 { 0x4010E000, 0x4010EFFF, " SPIS", 1 }, // SPIS FIFOs
whismanoid 46:469d0061df5d 391 //{ 0x4010F000, 0x4010FFFF, "_____", 1 }, // reserved
whismanoid 46:469d0061df5d 392 //
whismanoid 46:469d0061df5d 393 { 0x00000000, 0xFFFFFFFF, "last?", 8 }, // end of list can_flash_write_read=8, catch-all
whismanoid 46:469d0061df5d 394 };
whismanoid 46:469d0061df5d 395 int search_poke_access_list(uint32_t addr)
whismanoid 46:469d0061df5d 396 {
whismanoid 46:469d0061df5d 397 // scan poke_access_list[] for peek_addr
whismanoid 46:469d0061df5d 398 for (int i = 0; poke_access_list[i].can_flash_write_read != 8; i++)
whismanoid 46:469d0061df5d 399 {
whismanoid 46:469d0061df5d 400 if ((addr >= poke_access_list[i].addr_min) && (addr <= poke_access_list[i].addr_max))
whismanoid 46:469d0061df5d 401 {
whismanoid 46:469d0061df5d 402 return i;
whismanoid 46:469d0061df5d 403 }
whismanoid 46:469d0061df5d 404 }
whismanoid 46:469d0061df5d 405 return 0;
whismanoid 46:469d0061df5d 406 }
whismanoid 46:469d0061df5d 407 #endif // defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 408
whismanoid 46:469d0061df5d 409 //--------------------------------------------------
whismanoid 3:9055e17e181a 410 // Option to use SPI connected ADC
whismanoid 3:9055e17e181a 411 #ifndef SPI_ADC_DeviceName
whismanoid 9:45f98573eb6d 412 #define SPI_ADC_DeviceName MAX11410
whismanoid 3:9055e17e181a 413 #undef SPI_ADC_DeviceName
whismanoid 3:9055e17e181a 414 #endif
whismanoid 3:9055e17e181a 415 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 416 #include "MAX11410.h"
whismanoid 3:9055e17e181a 417 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 418
whismanoid 0:cb44e2e9ec4c 419 #if defined(TARGET)
whismanoid 0:cb44e2e9ec4c 420 // TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h
whismanoid 0:cb44e2e9ec4c 421 // Create a string definition for the TARGET
whismanoid 0:cb44e2e9ec4c 422 #define STRING_ARG(arg) #arg
whismanoid 0:cb44e2e9ec4c 423 #define STRING_NAME(name) STRING_ARG(name)
whismanoid 0:cb44e2e9ec4c 424 #define TARGET_NAME STRING_NAME(TARGET)
whismanoid 0:cb44e2e9ec4c 425 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 426 #define TARGET_NAME "MAX32600"
whismanoid 0:cb44e2e9ec4c 427 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 428 #define TARGET_NAME "LPC1768"
whismanoid 0:cb44e2e9ec4c 429 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 430 #define TARGET_NAME "NUCLEO_F446RE"
whismanoid 0:cb44e2e9ec4c 431 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 432 #define TARGET_NAME "NUCLEO_F401RE"
whismanoid 0:cb44e2e9ec4c 433 #else
whismanoid 0:cb44e2e9ec4c 434 #error TARGET NOT DEFINED
whismanoid 0:cb44e2e9ec4c 435 #endif
whismanoid 0:cb44e2e9ec4c 436 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 437 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 438 // TARGET=MAX32630FTHR ARM Cortex-M4F 96MHz 2048kB Flash 512kB SRAM
whismanoid 0:cb44e2e9ec4c 439 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 440 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 441 // ______ | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 442 // ______ | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 443 // ______ | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 444 // ______ | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 445 // analogIn0/4 | [a] AIN_0 1.2Vfs (bat) SYS [ ] | switched BAT+
whismanoid 0:cb44e2e9ec4c 446 // analogIn1/5 | [a] AIN_1 1.2Vfs PWR [ ] | external pwr btn
whismanoid 0:cb44e2e9ec4c 447 // analogIn2 | [a] AIN_2 1.2Vfs +5V VBUS [ ] | USB +5V power
whismanoid 0:cb44e2e9ec4c 448 // analogIn3 | [a] AIN_3 1.2Vfs 1-WIRE P4_0 [d] | D0 dig9
whismanoid 0:cb44e2e9ec4c 449 // (I2C2.SDA) | [d] P5_7 SDA2 SRN P5_6 [d] | D1 dig8
whismanoid 0:cb44e2e9ec4c 450 // (I2C2.SCL) | [d] P6_0 SCL2 SDIO3 P5_5 [d] | D2 dig7
whismanoid 0:cb44e2e9ec4c 451 // D13/SCLK | [s] P5_0 SCLK SDIO2 P5_4 [d] | D3 dig6
whismanoid 0:cb44e2e9ec4c 452 // D11/MOSI | [s] P5_1 MOSI SSEL P5_3 [d] | D4 dig5
whismanoid 0:cb44e2e9ec4c 453 // D12/MISO | [s] P5_2 MISO RTS P3_3 [d] | D5 dig4
whismanoid 0:cb44e2e9ec4c 454 // D10/CS | [s] P3_0 RX CTS P3_2 [d] | D6 dig3
whismanoid 0:cb44e2e9ec4c 455 // D9 dig0 | [d] P3_1 TX SCL P3_5 [d] | D7 dig2
whismanoid 0:cb44e2e9ec4c 456 // ______ | [ ] GND SDA P3_4 [d] | D8 dig1
whismanoid 0:cb44e2e9ec4c 457 // | |
whismanoid 0:cb44e2e9ec4c 458 // | XIP Flash MAX14690N |
whismanoid 0:cb44e2e9ec4c 459 // | XIP_SCLK P1_0 SDA2 P5_7 |
whismanoid 0:cb44e2e9ec4c 460 // | XIP_MOSI P1_1 SCL2 P6_0 |
whismanoid 0:cb44e2e9ec4c 461 // | XIP_MISO P1_2 PMIC_INIT P3_7 |
whismanoid 0:cb44e2e9ec4c 462 // | XIP_SSEL P1_3 MPC P2_7 |
whismanoid 0:cb44e2e9ec4c 463 // | XIP_DIO2 P1_4 MON AIN_0 |
whismanoid 0:cb44e2e9ec4c 464 // | XIP_DIO3 P1_5 |
whismanoid 0:cb44e2e9ec4c 465 // | |
whismanoid 0:cb44e2e9ec4c 466 // | PAN1326B MicroSD LED |
whismanoid 0:cb44e2e9ec4c 467 // | BT_RX P0_0 SD_SCLK P0_4 r P2_4 |
whismanoid 0:cb44e2e9ec4c 468 // | BT_TX P0_1 SD_MOSI P0_5 g P2_5 |
whismanoid 0:cb44e2e9ec4c 469 // | BT_CTS P0_2 SD_MISO P0_6 b P2_6 |
whismanoid 0:cb44e2e9ec4c 470 // | BT_RTS P0_3 SD_SSEL P0_7 |
whismanoid 0:cb44e2e9ec4c 471 // | BT_RST P1_6 DETECT P2_2 |
whismanoid 0:cb44e2e9ec4c 472 // | BT_CLK P1_7 SW2 P2_3 |
whismanoid 0:cb44e2e9ec4c 473 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 474 // 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 475 // 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 476 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 477 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 478 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 479 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 480 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 481 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 482 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 483 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 484 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 485 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 486 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 487 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 488 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 489 //
whismanoid 0:cb44e2e9ec4c 490 #include "max32630fthr.h"
whismanoid 0:cb44e2e9ec4c 491 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 492 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 493 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 494 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 495 // Arduino connector
whismanoid 0:cb44e2e9ec4c 496 #ifndef A0
whismanoid 0:cb44e2e9ec4c 497 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 498 #endif
whismanoid 0:cb44e2e9ec4c 499 #ifndef A1
whismanoid 0:cb44e2e9ec4c 500 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 501 #endif
whismanoid 0:cb44e2e9ec4c 502 #ifndef A2
whismanoid 0:cb44e2e9ec4c 503 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 504 #endif
whismanoid 0:cb44e2e9ec4c 505 #ifndef A3
whismanoid 0:cb44e2e9ec4c 506 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 507 #endif
whismanoid 0:cb44e2e9ec4c 508 #ifndef D0
whismanoid 0:cb44e2e9ec4c 509 #define D0 P4_0
whismanoid 0:cb44e2e9ec4c 510 #endif
whismanoid 0:cb44e2e9ec4c 511 #ifndef D1
whismanoid 0:cb44e2e9ec4c 512 #define D1 P5_6
whismanoid 0:cb44e2e9ec4c 513 #endif
whismanoid 0:cb44e2e9ec4c 514 #ifndef D2
whismanoid 0:cb44e2e9ec4c 515 #define D2 P5_5
whismanoid 0:cb44e2e9ec4c 516 #endif
whismanoid 0:cb44e2e9ec4c 517 #ifndef D3
whismanoid 0:cb44e2e9ec4c 518 #define D3 P5_4
whismanoid 0:cb44e2e9ec4c 519 #endif
whismanoid 0:cb44e2e9ec4c 520 #ifndef D4
whismanoid 0:cb44e2e9ec4c 521 #define D4 P5_3
whismanoid 0:cb44e2e9ec4c 522 #endif
whismanoid 0:cb44e2e9ec4c 523 #ifndef D5
whismanoid 0:cb44e2e9ec4c 524 #define D5 P3_3
whismanoid 0:cb44e2e9ec4c 525 #endif
whismanoid 0:cb44e2e9ec4c 526 #ifndef D6
whismanoid 0:cb44e2e9ec4c 527 #define D6 P3_2
whismanoid 0:cb44e2e9ec4c 528 #endif
whismanoid 0:cb44e2e9ec4c 529 #ifndef D7
whismanoid 0:cb44e2e9ec4c 530 #define D7 P3_5
whismanoid 0:cb44e2e9ec4c 531 #endif
whismanoid 0:cb44e2e9ec4c 532 #ifndef D8
whismanoid 0:cb44e2e9ec4c 533 #define D8 P3_4
whismanoid 0:cb44e2e9ec4c 534 #endif
whismanoid 0:cb44e2e9ec4c 535 #ifndef D9
whismanoid 0:cb44e2e9ec4c 536 #define D9 P3_1
whismanoid 0:cb44e2e9ec4c 537 #endif
whismanoid 0:cb44e2e9ec4c 538 #ifndef D10
whismanoid 0:cb44e2e9ec4c 539 #define D10 P3_0
whismanoid 0:cb44e2e9ec4c 540 #endif
whismanoid 0:cb44e2e9ec4c 541 #ifndef D11
whismanoid 0:cb44e2e9ec4c 542 #define D11 P5_1
whismanoid 0:cb44e2e9ec4c 543 #endif
whismanoid 0:cb44e2e9ec4c 544 #ifndef D12
whismanoid 0:cb44e2e9ec4c 545 #define D12 P5_2
whismanoid 0:cb44e2e9ec4c 546 #endif
whismanoid 0:cb44e2e9ec4c 547 #ifndef D13
whismanoid 0:cb44e2e9ec4c 548 #define D13 P5_0
whismanoid 0:cb44e2e9ec4c 549 #endif
whismanoid 0:cb44e2e9ec4c 550 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 551 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 552 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 553 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 554 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 555 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 556 // | |
whismanoid 0:cb44e2e9ec4c 557 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 558 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 559 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 560 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 561 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 562 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 563 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 564 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 565 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 566 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 567 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 568 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 569 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 570 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 571 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 572 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 573 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 574 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 575 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 576 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 577 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 578 // \_______________________/
whismanoid 0:cb44e2e9ec4c 579 //
whismanoid 0:cb44e2e9ec4c 580 // +------------------------+
whismanoid 0:cb44e2e9ec4c 581 // | |
whismanoid 0:cb44e2e9ec4c 582 // | MicroSD LED |
whismanoid 0:cb44e2e9ec4c 583 // | SD_SCLK P2_4 r P3_0 |
whismanoid 0:cb44e2e9ec4c 584 // | SD_MOSI P2_5 g P3_1 |
whismanoid 0:cb44e2e9ec4c 585 // | SD_MISO P2_6 b P3_2 |
whismanoid 0:cb44e2e9ec4c 586 // | SD_SSEL P2_7 y P3_3 |
whismanoid 0:cb44e2e9ec4c 587 // | |
whismanoid 0:cb44e2e9ec4c 588 // | DAPLINK BUTTONS |
whismanoid 0:cb44e2e9ec4c 589 // | TX P2_1 SW3 P2_3 |
whismanoid 0:cb44e2e9ec4c 590 // | RX P2_0 SW2 P2_2 |
whismanoid 0:cb44e2e9ec4c 591 // +------------------------+
whismanoid 0:cb44e2e9ec4c 592 //
whismanoid 0:cb44e2e9ec4c 593 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 594 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 595 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 596 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 597 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 598 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 599 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 600 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 601 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 602 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 603 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 604 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 605 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 606 //
whismanoid 0:cb44e2e9ec4c 607 //#include "max32625mbed.h" // ?
whismanoid 0:cb44e2e9ec4c 608 //MAX32625MBED mbed(MAX32625MBED::VIO_3V3); // ?
whismanoid 0:cb44e2e9ec4c 609 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 610 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 611 const float ADC_FULL_SCALE_VOLTAGE = 1.200; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 612 // Arduino connector
whismanoid 0:cb44e2e9ec4c 613 #ifndef A0
whismanoid 0:cb44e2e9ec4c 614 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 615 #endif
whismanoid 0:cb44e2e9ec4c 616 #ifndef A1
whismanoid 0:cb44e2e9ec4c 617 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 618 #endif
whismanoid 0:cb44e2e9ec4c 619 #ifndef A2
whismanoid 0:cb44e2e9ec4c 620 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 621 #endif
whismanoid 0:cb44e2e9ec4c 622 #ifndef A3
whismanoid 0:cb44e2e9ec4c 623 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 624 #endif
whismanoid 0:cb44e2e9ec4c 625 #ifndef D0
whismanoid 0:cb44e2e9ec4c 626 #define D0 P0_0
whismanoid 0:cb44e2e9ec4c 627 #endif
whismanoid 0:cb44e2e9ec4c 628 #ifndef D1
whismanoid 0:cb44e2e9ec4c 629 #define D1 P0_1
whismanoid 0:cb44e2e9ec4c 630 #endif
whismanoid 0:cb44e2e9ec4c 631 #ifndef D2
whismanoid 0:cb44e2e9ec4c 632 #define D2 P0_2
whismanoid 0:cb44e2e9ec4c 633 #endif
whismanoid 0:cb44e2e9ec4c 634 #ifndef D3
whismanoid 0:cb44e2e9ec4c 635 #define D3 P0_3
whismanoid 0:cb44e2e9ec4c 636 #endif
whismanoid 0:cb44e2e9ec4c 637 #ifndef D4
whismanoid 0:cb44e2e9ec4c 638 #define D4 P0_4
whismanoid 0:cb44e2e9ec4c 639 #endif
whismanoid 0:cb44e2e9ec4c 640 #ifndef D5
whismanoid 0:cb44e2e9ec4c 641 #define D5 P0_5
whismanoid 0:cb44e2e9ec4c 642 #endif
whismanoid 0:cb44e2e9ec4c 643 #ifndef D6
whismanoid 0:cb44e2e9ec4c 644 #define D6 P0_6
whismanoid 0:cb44e2e9ec4c 645 #endif
whismanoid 0:cb44e2e9ec4c 646 #ifndef D7
whismanoid 0:cb44e2e9ec4c 647 #define D7 P0_7
whismanoid 0:cb44e2e9ec4c 648 #endif
whismanoid 0:cb44e2e9ec4c 649 #ifndef D8
whismanoid 0:cb44e2e9ec4c 650 #define D8 P1_4
whismanoid 0:cb44e2e9ec4c 651 #endif
whismanoid 0:cb44e2e9ec4c 652 #ifndef D9
whismanoid 0:cb44e2e9ec4c 653 #define D9 P1_5
whismanoid 0:cb44e2e9ec4c 654 #endif
whismanoid 0:cb44e2e9ec4c 655 #ifndef D10
whismanoid 0:cb44e2e9ec4c 656 #define D10 P1_3
whismanoid 0:cb44e2e9ec4c 657 #endif
whismanoid 0:cb44e2e9ec4c 658 #ifndef D11
whismanoid 0:cb44e2e9ec4c 659 #define D11 P1_1
whismanoid 0:cb44e2e9ec4c 660 #endif
whismanoid 0:cb44e2e9ec4c 661 #ifndef D12
whismanoid 0:cb44e2e9ec4c 662 #define D12 P1_2
whismanoid 0:cb44e2e9ec4c 663 #endif
whismanoid 0:cb44e2e9ec4c 664 #ifndef D13
whismanoid 0:cb44e2e9ec4c 665 #define D13 P1_0
whismanoid 0:cb44e2e9ec4c 666 #endif
whismanoid 0:cb44e2e9ec4c 667 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 668 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 669 // target MAX32600
whismanoid 0:cb44e2e9ec4c 670 //
whismanoid 0:cb44e2e9ec4c 671 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 672 const float ADC_FULL_SCALE_VOLTAGE = 1.500;
whismanoid 0:cb44e2e9ec4c 673 //
whismanoid 0:cb44e2e9ec4c 674 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 675 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 676 #warning "TARGET_MAX32620FTHR not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 677 #include "MAX32620FTHR.h"
whismanoid 0:cb44e2e9ec4c 678 // Initialize I/O voltages on MAX32620FTHR board
whismanoid 0:cb44e2e9ec4c 679 MAX32620FTHR fthr(MAX32620FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 680 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 681 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 682 #warning "TARGET_MAX32620FTHR not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 683 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 684 //
whismanoid 0:cb44e2e9ec4c 685 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 686 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 15:37c83ec50ea0 687 // #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 688 #include "max32625pico.h"
whismanoid 0:cb44e2e9ec4c 689 // configure MAX32625PICO VDDIOH mode, and I/O voltages for DIP pins and SWD pins
whismanoid 0:cb44e2e9ec4c 690 MAX32625PICO pico(
whismanoid 13:184a08909405 691 // Select source of higher-voltage logic high supply VDDIOH
whismanoid 0:cb44e2e9ec4c 692 // vddioh_mode_t iohMode
whismanoid 0:cb44e2e9ec4c 693 //~ MAX32625PICO::IOH_OFF, // No connections to VDDIOH
whismanoid 0:cb44e2e9ec4c 694 //~ MAX32625PICO::IOH_DIP_IN, // VDDIOH input from DIP pin 1 (AIN0)
whismanoid 0:cb44e2e9ec4c 695 //~ MAX32625PICO::IOH_SWD_IN, // VDDIOH input from SWD pin 1
whismanoid 0:cb44e2e9ec4c 696 MAX32625PICO::IOH_3V3, // VDDIOH = 3.3V from local supply
whismanoid 0:cb44e2e9ec4c 697 //~ MAX32625PICO::IOH_DIP_OUT, // VDDIOH = 3.3V output to DIP pin 1
whismanoid 0:cb44e2e9ec4c 698 //~ MAX32625PICO::IOH_SWD_OUT, // VDDIOH = 3.3V output to SWD pin 1
whismanoid 0:cb44e2e9ec4c 699 //
whismanoid 13:184a08909405 700 // Digital I/O pin logic high voltage 1.8V or 3.3V
whismanoid 0:cb44e2e9ec4c 701 // vio_t dipVio = MAX32625PICO::VIO_1V8 or MAX32625PICO::VIO_IOH
whismanoid 13:184a08909405 702 MAX32625PICO::VIO_1V8, // 1.8V IO (local)
whismanoid 13:184a08909405 703 //~ MAX32625PICO::VIO_IOH, // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 704 //
whismanoid 13:184a08909405 705 // Software Debug logic high voltage (normally use VIO_IOH)
whismanoid 0:cb44e2e9ec4c 706 // vio_t swdVio
whismanoid 0:cb44e2e9ec4c 707 //~ MAX32625PICO::VIO_1V8 // 1.8V IO (local)
whismanoid 0:cb44e2e9ec4c 708 MAX32625PICO::VIO_IOH // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 709 );
whismanoid 0:cb44e2e9ec4c 710 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 711 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 15:37c83ec50ea0 712 // #warning "TARGET_MAX32625PICO not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 713 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 714 //
whismanoid 0:cb44e2e9ec4c 715 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 716 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 717 // TODO1: target NUCLEO_F446RE
whismanoid 0:cb44e2e9ec4c 718 //
whismanoid 0:cb44e2e9ec4c 719 // USER_BUTTON PC13
whismanoid 0:cb44e2e9ec4c 720 // LED1 is shared with SPI_SCK on NUCLEO_F446RE PA_5, so don't use LED1.
whismanoid 0:cb44e2e9ec4c 721 #define USE_LEDS 0
whismanoid 0:cb44e2e9ec4c 722 // SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
whismanoid 0:cb44e2e9ec4c 723 // Serial serial(SERIAL_TX, SERIAL_RX);
whismanoid 0:cb44e2e9ec4c 724 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 725 const float ADC_FULL_SCALE_VOLTAGE = 3.300; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 726 //
whismanoid 0:cb44e2e9ec4c 727 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 728 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 729 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 730 // TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM
whismanoid 0:cb44e2e9ec4c 731 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 732 // ______ | [ ] GND +3.3V VOUT [ ] | ______
whismanoid 0:cb44e2e9ec4c 733 // ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | ______
whismanoid 0:cb44e2e9ec4c 734 // ______ | [ ] VB USB.IF- [ ] | ______
whismanoid 0:cb44e2e9ec4c 735 // ______ | [ ] nR USB.IF+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 736 // digitalInOut0 | [ ] p5 MOSI ETHERNET.RD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 737 // digitalInOut1 | [ ] p6 MISO ETHERNET.RD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 738 // digitalInOut2 | [ ] p7 SCLK ETHERNET.TD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 739 // digitalInOut3 | [ ] p8 ETHERNET.TD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 740 // digitalInOut4 | [ ] p9 TX SDA USB.D- [ ] | ______
whismanoid 0:cb44e2e9ec4c 741 // digitalInOut5 | [ ] p10 RX SCL USB.D+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 742 // digitalInOut6 | [ ] p11 MOSI CAN-RD p30 [ ] | digitalInOut13
whismanoid 0:cb44e2e9ec4c 743 // digitalInOut7 | [ ] p12 MISO CAN-TD p29 [ ] | digitalInOut12
whismanoid 0:cb44e2e9ec4c 744 // digitalInOut8 | [ ] p13 TX SCLK SDA TX p28 [ ] | digitalInOut11
whismanoid 0:cb44e2e9ec4c 745 // digitalInOut9 | [ ] p14 RX SCL RX p27 [ ] | digitalInOut10
whismanoid 0:cb44e2e9ec4c 746 // analogIn0 | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1
whismanoid 0:cb44e2e9ec4c 747 // analogIn1 | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2
whismanoid 0:cb44e2e9ec4c 748 // analogIn2 | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3
whismanoid 0:cb44e2e9ec4c 749 // analogIn3 | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4
whismanoid 0:cb44e2e9ec4c 750 // analogIn4 | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5
whismanoid 0:cb44e2e9ec4c 751 // analogIn5 | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6
whismanoid 0:cb44e2e9ec4c 752 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 753 // AIN6 = P0.3 = TGT_SBL_RXD?
whismanoid 0:cb44e2e9ec4c 754 // AIN7 = P0.2 = TGT_SBL_TXD?
whismanoid 0:cb44e2e9ec4c 755 //
whismanoid 0:cb44e2e9ec4c 756 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 757 // LPC1768 board uses VREF = 3.300V +A3,3V thru L1 to bypass capacitor C14
whismanoid 0:cb44e2e9ec4c 758 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 759 const float ADC_FULL_SCALE_VOLTAGE = 3.300;
whismanoid 0:cb44e2e9ec4c 760 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 0:cb44e2e9ec4c 761 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 762 // unknown target
whismanoid 0:cb44e2e9ec4c 763 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 764 #endif // target definition
whismanoid 0:cb44e2e9ec4c 765
whismanoid 0:cb44e2e9ec4c 766
whismanoid 0:cb44e2e9ec4c 767
whismanoid 0:cb44e2e9ec4c 768
whismanoid 18:1235c17b451e 769 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 770 // move definiton of USE_LEDS earlier than find_digitalInOutPin()
whismanoid 18:1235c17b451e 771 //--------------------------------------------------
whismanoid 18:1235c17b451e 772 // Option to use LEDs to show status
whismanoid 18:1235c17b451e 773 #ifndef USE_LEDS
whismanoid 18:1235c17b451e 774 #define USE_LEDS 1
whismanoid 18:1235c17b451e 775 #endif
whismanoid 18:1235c17b451e 776 #if USE_LEDS
whismanoid 18:1235c17b451e 777 #if defined(TARGET_MAX32630)
whismanoid 18:1235c17b451e 778 # define LED_ON 0
whismanoid 18:1235c17b451e 779 # define LED_OFF 1
whismanoid 18:1235c17b451e 780 //--------------------------------------------------
whismanoid 18:1235c17b451e 781 #elif defined(TARGET_MAX32625MBED)
whismanoid 18:1235c17b451e 782 # define LED_ON 0
whismanoid 18:1235c17b451e 783 # define LED_OFF 1
whismanoid 19:5ff09c8e9daf 784 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 18:1235c17b451e 785 # define LED_ON 0
whismanoid 18:1235c17b451e 786 # define LED_OFF 1
whismanoid 18:1235c17b451e 787 //--------------------------------------------------
whismanoid 18:1235c17b451e 788 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 18:1235c17b451e 789 #elif defined(TARGET_LPC1768)
whismanoid 18:1235c17b451e 790 # define LED_ON 1
whismanoid 18:1235c17b451e 791 # define LED_OFF 0
whismanoid 18:1235c17b451e 792 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 18:1235c17b451e 793 // USE_LEDS with some platform other than MAX32630, MAX32625MBED, LPC1768
whismanoid 18:1235c17b451e 794 // bugfix for MAX32600MBED LED blink pattern: check if LED_ON/LED_OFF already defined
whismanoid 18:1235c17b451e 795 # ifndef LED_ON
whismanoid 18:1235c17b451e 796 # define LED_ON 0
whismanoid 18:1235c17b451e 797 # endif
whismanoid 18:1235c17b451e 798 # ifndef LED_OFF
whismanoid 18:1235c17b451e 799 # define LED_OFF 1
whismanoid 18:1235c17b451e 800 # endif
whismanoid 18:1235c17b451e 801 //# define LED_ON 1
whismanoid 18:1235c17b451e 802 //# define LED_OFF 0
whismanoid 18:1235c17b451e 803 #endif // target definition
whismanoid 18:1235c17b451e 804 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 805 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 806 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 807 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 808 // change led1/2/3/4 from DigitalOut to DigitalInOut
whismanoid 18:1235c17b451e 809 DigitalInOut led1(LED1, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED1 = LED_RED
whismanoid 18:1235c17b451e 810 DigitalInOut led2(LED2, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN
whismanoid 18:1235c17b451e 811 DigitalInOut led3(LED3, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE
whismanoid 18:1235c17b451e 812 DigitalInOut led4(LED4, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 813 #else // USE_LEDS=0
whismanoid 18:1235c17b451e 814 // issue #41 support Nucleo_F446RE
whismanoid 18:1235c17b451e 815 // there are no LED indicators on the board, LED1 interferes with SPI;
whismanoid 18:1235c17b451e 816 // but we still need placeholders led1 led2 led3 led4.
whismanoid 18:1235c17b451e 817 // Declare DigitalInOut led1 led2 led3 led4 targeting safe pins.
whismanoid 18:1235c17b451e 818 // PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false
whismanoid 18:1235c17b451e 819 # define LED_ON 0
whismanoid 18:1235c17b451e 820 # define LED_OFF 1
whismanoid 18:1235c17b451e 821 // change led1/2/3/4 from DigitalOut to DigitalInOut
whismanoid 18:1235c17b451e 822 DigitalInOut led1(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 823 DigitalInOut led2(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 824 DigitalInOut led3(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 825 DigitalInOut led4(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 826 #endif // USE_LEDS
whismanoid 18:1235c17b451e 827 #define led1_RFailLED led1
whismanoid 18:1235c17b451e 828 #define led2_GPassLED led2
whismanoid 18:1235c17b451e 829 #define led3_BBusyLED led3
whismanoid 18:1235c17b451e 830
whismanoid 21:ac062a97a71d 831 //--------------------------------------------------
whismanoid 21:ac062a97a71d 832 // use BUTTON1 trigger some action
whismanoid 46:469d0061df5d 833 // support for commands %B1! .. %B9!
whismanoid 21:ac062a97a71d 834 #if defined(TARGET_MAX32630)
whismanoid 21:ac062a97a71d 835 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 836 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 837 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 838 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 25:8a61cb34191d 839 // #warning "TARGET_MAX32625PICO not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 840 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 24:032f3683cb2a 841 #if MAX40108_DEMO
whismanoid 25:8a61cb34191d 842 #if HAS_I2C
whismanoid 25:8a61cb34191d 843 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 844 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 24:032f3683cb2a 845 #define BUTTON2 P3_7
whismanoid 25:8a61cb34191d 846 #else // HAS_I2C
whismanoid 25:8a61cb34191d 847 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 848 // 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 849 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 850 #define BUTTON2 P1_7
whismanoid 25:8a61cb34191d 851 #endif // HAS_I2C
whismanoid 24:032f3683cb2a 852 #define HAS_BUTTON2_DEMO 0
whismanoid 24:032f3683cb2a 853 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 25:8a61cb34191d 854 #if HAS_I2C
whismanoid 25:8a61cb34191d 855 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 856 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 24:032f3683cb2a 857 #define BUTTON3 P3_6
whismanoid 25:8a61cb34191d 858 #else // HAS_I2C
whismanoid 25:8a61cb34191d 859 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 860 // 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 861 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 862 #define BUTTON3 P1_6
whismanoid 25:8a61cb34191d 863 #endif // HAS_I2C
whismanoid 24:032f3683cb2a 864 #define HAS_BUTTON3_DEMO 0
whismanoid 24:032f3683cb2a 865 #define HAS_BUTTON3_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 866 // additional buttons are assigned to unused/unaccessible pins to avoid conflicts
whismanoid 29:6a9edb6e973b 867 // activate using %B4! or action_button pin=4
whismanoid 29:6a9edb6e973b 868 #define BUTTON4 P1_5
whismanoid 29:6a9edb6e973b 869 #define HAS_BUTTON4_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 870 #define BUTTON5 P1_4
whismanoid 29:6a9edb6e973b 871 #define HAS_BUTTON5_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 872 #define BUTTON6 P1_3
whismanoid 29:6a9edb6e973b 873 #define HAS_BUTTON6_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 874 #define BUTTON7 P1_2
whismanoid 29:6a9edb6e973b 875 #define HAS_BUTTON7_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 876 #define BUTTON8 P1_1
whismanoid 29:6a9edb6e973b 877 #define HAS_BUTTON8_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 878 #define BUTTON9 P1_0
whismanoid 29:6a9edb6e973b 879 #define HAS_BUTTON9_DEMO_INTERRUPT 1
whismanoid 24:032f3683cb2a 880 #else // MAX40108_DEMO
whismanoid 21:ac062a97a71d 881 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 882 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 29:6a9edb6e973b 883 #endif // MAX40108_DEMO ---------------------------------
whismanoid 21:ac062a97a71d 884 #elif defined(TARGET_MAX32625)
whismanoid 21:ac062a97a71d 885 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 886 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 887 #elif defined(TARGET_MAX32620FTHR)
whismanoid 21:ac062a97a71d 888 #warning "TARGET_MAX32620FTHR not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 889 #define BUTTON1 SW1
whismanoid 21:ac062a97a71d 890 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 891 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 892 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 893 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 21:ac062a97a71d 894 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 895 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 896 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 21:ac062a97a71d 897 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 898 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 899 #else
whismanoid 21:ac062a97a71d 900 #warning "target not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 901 #endif
whismanoid 21:ac062a97a71d 902 //
whismanoid 21:ac062a97a71d 903 #ifndef HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 904 #define HAS_BUTTON1_DEMO 0
whismanoid 21:ac062a97a71d 905 #endif
whismanoid 21:ac062a97a71d 906 #ifndef HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 907 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 908 #endif
whismanoid 24:032f3683cb2a 909 #ifndef HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 910 #define HAS_BUTTON3_DEMO 0
whismanoid 24:032f3683cb2a 911 #endif
whismanoid 21:ac062a97a71d 912 //
whismanoid 21:ac062a97a71d 913 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 914 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 915 #ifndef HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 916 #define HAS_BUTTON1_DEMO_INTERRUPT_POLLING 1
whismanoid 21:ac062a97a71d 917 #endif
whismanoid 21:ac062a97a71d 918 //
whismanoid 21:ac062a97a71d 919 #ifndef HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 920 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 921 #endif
whismanoid 21:ac062a97a71d 922 #ifndef HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 923 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 924 #endif
whismanoid 21:ac062a97a71d 925 //
whismanoid 21:ac062a97a71d 926 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 927 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 928 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 929 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 930 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 931 # else
whismanoid 21:ac062a97a71d 932 InterruptIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 933 # endif
whismanoid 21:ac062a97a71d 934 #elif HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 935 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 936 #endif
whismanoid 21:ac062a97a71d 937 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 938 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 939 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 940 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 941 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 942 # else
whismanoid 21:ac062a97a71d 943 InterruptIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 944 # endif
whismanoid 21:ac062a97a71d 945 #elif HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 946 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 947 #endif
whismanoid 24:032f3683cb2a 948 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 949 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 24:032f3683cb2a 950 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 24:032f3683cb2a 951 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 24:032f3683cb2a 952 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 953 # else
whismanoid 24:032f3683cb2a 954 InterruptIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 955 # endif
whismanoid 24:032f3683cb2a 956 #elif HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 957 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 958 #endif
whismanoid 21:ac062a97a71d 959
whismanoid 0:cb44e2e9ec4c 960 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 961 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 962 // Declare the DigitalInOut GPIO pins
whismanoid 0:cb44e2e9ec4c 963 // Optional digitalInOut support. If there is only one it should be digitalInOut1.
whismanoid 0:cb44e2e9ec4c 964 // D) Digital High/Low/Input Pin
whismanoid 0:cb44e2e9ec4c 965 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 966 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 967 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 968 // | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 969 // | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 970 // | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 971 // | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 972 // | [ ] AIN_0 1.2Vfs (bat) SYS [ ] |
whismanoid 0:cb44e2e9ec4c 973 // | [ ] AIN_1 1.2Vfs PWR [ ] |
whismanoid 0:cb44e2e9ec4c 974 // | [ ] AIN_2 1.2Vfs +5V VBUS [ ] |
whismanoid 0:cb44e2e9ec4c 975 // | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9
whismanoid 0:cb44e2e9ec4c 976 // dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8
whismanoid 0:cb44e2e9ec4c 977 // dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7
whismanoid 0:cb44e2e9ec4c 978 // dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6
whismanoid 0:cb44e2e9ec4c 979 // dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5
whismanoid 0:cb44e2e9ec4c 980 // dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4
whismanoid 0:cb44e2e9ec4c 981 // dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3
whismanoid 0:cb44e2e9ec4c 982 // dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2
whismanoid 0:cb44e2e9ec4c 983 // | [ ] GND SDA P3_4 [x] | dig1
whismanoid 0:cb44e2e9ec4c 984 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 985 #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 986 #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 987 #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 988 #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 989 #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 990 #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 991 #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 992 #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 993 #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 994 #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 995 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 996 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 997 #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 998 #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 999 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1000 #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 1001 #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 1002 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1003 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 1004 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1005 #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 1006 #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 1007 #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 1008 #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 1009 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1010 #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 1011 #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 1012 #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 1013 #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 1014 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1015 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1016 DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 1017 #endif
whismanoid 0:cb44e2e9ec4c 1018 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1019 DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 1020 #endif
whismanoid 0:cb44e2e9ec4c 1021 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1022 DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 1023 #endif
whismanoid 0:cb44e2e9ec4c 1024 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1025 DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 1026 #endif
whismanoid 0:cb44e2e9ec4c 1027 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1028 DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 1029 #endif
whismanoid 0:cb44e2e9ec4c 1030 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1031 DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 1032 #endif
whismanoid 0:cb44e2e9ec4c 1033 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1034 DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 1035 #endif
whismanoid 0:cb44e2e9ec4c 1036 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1037 DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 1038 #endif
whismanoid 0:cb44e2e9ec4c 1039 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1040 DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 1041 #endif
whismanoid 0:cb44e2e9ec4c 1042 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1043 DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 1044 #endif
whismanoid 0:cb44e2e9ec4c 1045 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1046 DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 1047 #endif
whismanoid 0:cb44e2e9ec4c 1048 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1049 DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 1050 #endif
whismanoid 0:cb44e2e9ec4c 1051 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1052 DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 1053 #endif
whismanoid 0:cb44e2e9ec4c 1054 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1055 DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 1056 #endif
whismanoid 0:cb44e2e9ec4c 1057 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1058 DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 1059 #endif
whismanoid 0:cb44e2e9ec4c 1060 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1061 DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 1062 #endif
whismanoid 0:cb44e2e9ec4c 1063 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1064 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 1065 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 1066 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 1067 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 1068 // | |
whismanoid 0:cb44e2e9ec4c 1069 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 1070 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 1071 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 1072 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 1073 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 1074 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 1075 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 1076 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 1077 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 1078 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 1079 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 1080 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 1081 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 1082 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 1083 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 1084 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 1085 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 1086 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 1087 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 1088 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 1089 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 1090 // \_______________________/
whismanoid 0:cb44e2e9ec4c 1091 //
whismanoid 0:cb44e2e9ec4c 1092 #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 1093 #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 1094 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1095 #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 1096 #else
whismanoid 0:cb44e2e9ec4c 1097 #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 1098 #endif
whismanoid 0:cb44e2e9ec4c 1099 #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 1100 #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 1101 #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 1102 #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 1103 #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 1104 #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 1105 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1106 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 1107 #else
whismanoid 0:cb44e2e9ec4c 1108 #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 1109 #endif
whismanoid 0:cb44e2e9ec4c 1110 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 1111 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1112 #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 1113 #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 1114 #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 1115 #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 1116 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1117 #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 1118 #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 1119 #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 1120 #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 1121 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1122 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 1123 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1124 #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1125 #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1126 #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1127 #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1128 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1129 #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1130 #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1131 #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1132 #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1133 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1134 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1135 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 1136 #endif
whismanoid 0:cb44e2e9ec4c 1137 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1138 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 1139 #endif
whismanoid 0:cb44e2e9ec4c 1140 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1141 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 1142 #endif
whismanoid 0:cb44e2e9ec4c 1143 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1144 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 1145 #endif
whismanoid 0:cb44e2e9ec4c 1146 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1147 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 1148 #endif
whismanoid 0:cb44e2e9ec4c 1149 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1150 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 1151 #endif
whismanoid 0:cb44e2e9ec4c 1152 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1153 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 1154 #endif
whismanoid 0:cb44e2e9ec4c 1155 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1156 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 1157 #endif
whismanoid 0:cb44e2e9ec4c 1158 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1159 DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 1160 #endif
whismanoid 0:cb44e2e9ec4c 1161 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1162 DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 1163 #endif
whismanoid 0:cb44e2e9ec4c 1164 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1165 DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 1166 #endif
whismanoid 0:cb44e2e9ec4c 1167 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1168 DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 1169 #endif
whismanoid 0:cb44e2e9ec4c 1170 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1171 DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 1172 #endif
whismanoid 0:cb44e2e9ec4c 1173 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1174 DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 1175 #endif
whismanoid 0:cb44e2e9ec4c 1176 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1177 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 1178 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 1179 DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1180 #endif
whismanoid 0:cb44e2e9ec4c 1181 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1182 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 1183 DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1184 #endif
whismanoid 0:cb44e2e9ec4c 1185 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1186 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 1187 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 1188 // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V
whismanoid 0:cb44e2e9ec4c 1189 DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1190 #endif
whismanoid 0:cb44e2e9ec4c 1191 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1192 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 1193 DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1194 #endif
whismanoid 0:cb44e2e9ec4c 1195 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 1196 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 15:37c83ec50ea0 1197 // TARGET=MAX32625PICO ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 15:37c83ec50ea0 1198 // +-------------[microUSB]-------------+
whismanoid 15:37c83ec50ea0 1199 // | [27]D+ D-[26] |
whismanoid 15:37c83ec50ea0 1200 // | |
whismanoid 15:37c83ec50ea0 1201 // | [BUTTON P2_7] |
whismanoid 15:37c83ec50ea0 1202 // | P2_4 LED_R P2_5 LED_G P2_6 LED_B |
whismanoid 15:37c83ec50ea0 1203 // | |
whismanoid 15:37c83ec50ea0 1204 // 1V8 | [11] 1.8V MAX32625PICO GND [10] | GND
whismanoid 15:37c83ec50ea0 1205 // 3V3 | [12] 3.3V +5V [09] | 5V0
whismanoid 15:37c83ec50ea0 1206 // SPI CS D7 | [13] P0_7 CS s-ssel P4_7 [08] | D15
whismanoid 15:37c83ec50ea0 1207 // SPI MISO D6 | [14] P0_6 MISO s-miso P4_6 [07] | D14
whismanoid 15:37c83ec50ea0 1208 // SPI MOSI D5 | [15] P0_5 MOSI s-mosi P4_5 [06] | D13
whismanoid 15:37c83ec50ea0 1209 // SPI SCLK D4 | [16] P0_4 SCLK s-sclk P4_4 [05] | D12
whismanoid 15:37c83ec50ea0 1210 // D3 | [17] P0_3 RTS SCL P1_7 [04] | SCL/D17
whismanoid 15:37c83ec50ea0 1211 // D2 | [18] P0_2 CTS SDA P1_6 [03] | SDA/D16
whismanoid 15:37c83ec50ea0 1212 // TX/D1 | [19] P0_1 TX0 AIN_2 [02] | A2
whismanoid 15:37c83ec50ea0 1213 // RX/D0 | [20] P0_0 RX0 AIN_0 [01] | A0/A4
whismanoid 15:37c83ec50ea0 1214 // | |
whismanoid 15:37c83ec50ea0 1215 // | DAPLINK |
whismanoid 15:37c83ec50ea0 1216 // | J3 p3_3 p3_2 p3_0 p3_1 p3_7 |
whismanoid 15:37c83ec50ea0 1217 // | DAP [ ] [ ] [RX2][TX2][ ] |
whismanoid 15:37c83ec50ea0 1218 // | TOP [ ] [ ] [ ] [ ] [ ] |
whismanoid 15:37c83ec50ea0 1219 // | AIN1/A5 gnd gnd nc AIN3 |
whismanoid 15:37c83ec50ea0 1220 // | IOH 1-wire |
whismanoid 15:37c83ec50ea0 1221 // | |
whismanoid 15:37c83ec50ea0 1222 // |NO USE RST P2_0 P2_1 |
whismanoid 15:37c83ec50ea0 1223 // |BOTTOM [ ] [ ] [RX1][ ] [TX1] |
whismanoid 15:37c83ec50ea0 1224 // | RST SWC GND SWD 1V8 |
whismanoid 15:37c83ec50ea0 1225 // |BOTTOM [21] [22] [23] [24] [25] |
whismanoid 15:37c83ec50ea0 1226 // +------------------------------------+
whismanoid 15:37c83ec50ea0 1227 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 1228 // MAX40108 demo p2: D0..D7 = P0_0..P0_7; D8..15 = P4_0..P4_7; D16/D17=I2C
whismanoid 15:37c83ec50ea0 1229 #endif
whismanoid 15:37c83ec50ea0 1230 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1231 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1232 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1233 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1234 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 1235 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 1236 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 1237 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1238 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 1239 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 15:37c83ec50ea0 1240 // AIN_10 = x undefined?
whismanoid 15:37c83ec50ea0 1241 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 1242 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 1243 //
whismanoid 15:37c83ec50ea0 1244 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 1245 // avoid resource conflict D0,D1 alternate function as RX/TX
whismanoid 15:37c83ec50ea0 1246 #define HAS_digitalInOut0 0
whismanoid 15:37c83ec50ea0 1247 #define HAS_digitalInOut1 0
whismanoid 15:37c83ec50ea0 1248 #else
whismanoid 15:37c83ec50ea0 1249 #define HAS_digitalInOut0 1
whismanoid 19:5ff09c8e9daf 1250 #define HAS_digitalInOut1 1
whismanoid 19:5ff09c8e9daf 1251 // P0_1 TARGET_MAX32625PICO D1
whismanoid 15:37c83ec50ea0 1252 #endif
whismanoid 15:37c83ec50ea0 1253 #if APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 1254 // avoid resource conflict D2 alternate function as interrupt input
whismanoid 15:37c83ec50ea0 1255 #define HAS_digitalInOut2 0
whismanoid 15:37c83ec50ea0 1256 #else
whismanoid 15:37c83ec50ea0 1257 #define HAS_digitalInOut2 1
whismanoid 15:37c83ec50ea0 1258 #endif
whismanoid 15:37c83ec50ea0 1259 #define HAS_digitalInOut3 1
whismanoid 15:37c83ec50ea0 1260 #define HAS_digitalInOut4 1
whismanoid 15:37c83ec50ea0 1261 #define HAS_digitalInOut5 1
whismanoid 15:37c83ec50ea0 1262 #define HAS_digitalInOut6 1
whismanoid 15:37c83ec50ea0 1263 #define HAS_digitalInOut7 1
whismanoid 15:37c83ec50ea0 1264 //
whismanoid 15:37c83ec50ea0 1265 #define HAS_digitalInOut8 1
whismanoid 15:37c83ec50ea0 1266 #define HAS_digitalInOut9 1
whismanoid 15:37c83ec50ea0 1267 #define HAS_digitalInOut10 1
whismanoid 15:37c83ec50ea0 1268 #define HAS_digitalInOut11 1
whismanoid 15:37c83ec50ea0 1269 #define HAS_digitalInOut12 1
whismanoid 15:37c83ec50ea0 1270 #define HAS_digitalInOut13 1
whismanoid 15:37c83ec50ea0 1271 #define HAS_digitalInOut14 1
whismanoid 15:37c83ec50ea0 1272 #define HAS_digitalInOut15 1
whismanoid 15:37c83ec50ea0 1273 #if HAS_I2C
whismanoid 25:8a61cb34191d 1274 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 1275 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 25:8a61cb34191d 1276 // #define BUTTON2 P3_7
whismanoid 25:8a61cb34191d 1277 // avoid resource conflict between I2C and DigitalInOut
whismanoid 25:8a61cb34191d 1278 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1279 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 1280 #else // HAS_I2C
whismanoid 25:8a61cb34191d 1281 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 1282 // 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 1283 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1284 // #define BUTTON2 P1_7
whismanoid 25:8a61cb34191d 1285 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1286 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1287 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1288 #else // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1289 #define HAS_digitalInOut16 1 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1290 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1291 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1292 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1293 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1294 #else // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1295 #define HAS_digitalInOut17 1 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1296 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 15:37c83ec50ea0 1297 #endif // HAS_I2C
whismanoid 15:37c83ec50ea0 1298 #if HAS_digitalInOut0
whismanoid 25:8a61cb34191d 1299 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D0
whismanoid 15:37c83ec50ea0 1300 #endif
whismanoid 15:37c83ec50ea0 1301 #if HAS_digitalInOut1
whismanoid 25:8a61cb34191d 1302 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D1
whismanoid 15:37c83ec50ea0 1303 #endif
whismanoid 15:37c83ec50ea0 1304 #if HAS_digitalInOut2
whismanoid 25:8a61cb34191d 1305 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D2
whismanoid 15:37c83ec50ea0 1306 #endif
whismanoid 15:37c83ec50ea0 1307 #if HAS_digitalInOut3
whismanoid 25:8a61cb34191d 1308 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D3
whismanoid 15:37c83ec50ea0 1309 #endif
whismanoid 15:37c83ec50ea0 1310 #if HAS_digitalInOut4
whismanoid 25:8a61cb34191d 1311 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D4
whismanoid 15:37c83ec50ea0 1312 #endif
whismanoid 15:37c83ec50ea0 1313 #if HAS_digitalInOut5
whismanoid 25:8a61cb34191d 1314 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D5
whismanoid 15:37c83ec50ea0 1315 #endif
whismanoid 15:37c83ec50ea0 1316 #if HAS_digitalInOut6
whismanoid 25:8a61cb34191d 1317 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D6
whismanoid 15:37c83ec50ea0 1318 #endif
whismanoid 15:37c83ec50ea0 1319 #if HAS_digitalInOut7
whismanoid 25:8a61cb34191d 1320 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D7
whismanoid 15:37c83ec50ea0 1321 #endif
whismanoid 15:37c83ec50ea0 1322 #if HAS_digitalInOut8
whismanoid 25:8a61cb34191d 1323 DigitalInOut digitalInOut8(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX40108DEMOP2U9 D8
whismanoid 15:37c83ec50ea0 1324 #endif
whismanoid 15:37c83ec50ea0 1325 #if HAS_digitalInOut9
whismanoid 25:8a61cb34191d 1326 DigitalInOut digitalInOut9(P4_1, PIN_INPUT, PullUp, 1); // P4_1 TARGET_MAX40108DEMOP2U9 D9
whismanoid 15:37c83ec50ea0 1327 #endif
whismanoid 15:37c83ec50ea0 1328 #if HAS_digitalInOut10
whismanoid 25:8a61cb34191d 1329 DigitalInOut digitalInOut10(P4_2, PIN_INPUT, PullUp, 1); // P4_2 TARGET_MAX40108DEMOP2U9 D10
whismanoid 15:37c83ec50ea0 1330 #endif
whismanoid 15:37c83ec50ea0 1331 #if HAS_digitalInOut11
whismanoid 25:8a61cb34191d 1332 DigitalInOut digitalInOut11(P4_3, PIN_INPUT, PullUp, 1); // P4_3 TARGET_MAX40108DEMOP2U9 D11
whismanoid 15:37c83ec50ea0 1333 #endif
whismanoid 15:37c83ec50ea0 1334 #if HAS_digitalInOut12
whismanoid 25:8a61cb34191d 1335 DigitalInOut digitalInOut12(P4_4, PIN_INPUT, PullUp, 1); // P4_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D12
whismanoid 15:37c83ec50ea0 1336 #endif
whismanoid 15:37c83ec50ea0 1337 #if HAS_digitalInOut13
whismanoid 25:8a61cb34191d 1338 DigitalInOut digitalInOut13(P4_5, PIN_INPUT, PullUp, 1); // P4_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D13
whismanoid 15:37c83ec50ea0 1339 #endif
whismanoid 15:37c83ec50ea0 1340 #if HAS_digitalInOut14
whismanoid 25:8a61cb34191d 1341 DigitalInOut digitalInOut14(P4_6, PIN_INPUT, PullUp, 1); // P4_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D14
whismanoid 15:37c83ec50ea0 1342 #endif
whismanoid 15:37c83ec50ea0 1343 #if HAS_digitalInOut15
whismanoid 25:8a61cb34191d 1344 DigitalInOut digitalInOut15(P4_7, PIN_INPUT, PullUp, 1); // P4_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D15
whismanoid 15:37c83ec50ea0 1345 #endif
whismanoid 15:37c83ec50ea0 1346 #if HAS_digitalInOut16
whismanoid 15:37c83ec50ea0 1347 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 15:37c83ec50ea0 1348 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 25:8a61cb34191d 1349 DigitalInOut digitalInOut16(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 15:37c83ec50ea0 1350 #endif
whismanoid 15:37c83ec50ea0 1351 #if HAS_digitalInOut17
whismanoid 15:37c83ec50ea0 1352 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 25:8a61cb34191d 1353 DigitalInOut digitalInOut17(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 1354 #endif
whismanoid 15:37c83ec50ea0 1355 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1356 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1357 #define HAS_digitalInOut0 0
whismanoid 0:cb44e2e9ec4c 1358 #define HAS_digitalInOut1 0
whismanoid 0:cb44e2e9ec4c 1359 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1360 // D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 1361 #define HAS_digitalInOut2 0
whismanoid 0:cb44e2e9ec4c 1362 #else
whismanoid 0:cb44e2e9ec4c 1363 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1364 #endif
whismanoid 0:cb44e2e9ec4c 1365 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1366 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1367 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1368 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1369 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1370 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1371 // D8 -- MAX5715 CLRb DigitalOut
whismanoid 0:cb44e2e9ec4c 1372 #define HAS_digitalInOut8 0
whismanoid 0:cb44e2e9ec4c 1373 #else
whismanoid 0:cb44e2e9ec4c 1374 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1375 #endif
whismanoid 0:cb44e2e9ec4c 1376 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1377 // D9 -- MAX5715 LDACb DigitalOut
whismanoid 0:cb44e2e9ec4c 1378 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1379 #elif APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1380 // D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 1381 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1382 #else
whismanoid 0:cb44e2e9ec4c 1383 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1384 #endif
whismanoid 0:cb44e2e9ec4c 1385 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 1386 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1387 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1388 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1389 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1390 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1391 #define HAS_digitalInOut10 0
whismanoid 0:cb44e2e9ec4c 1392 #define HAS_digitalInOut11 0
whismanoid 0:cb44e2e9ec4c 1393 #define HAS_digitalInOut12 0
whismanoid 0:cb44e2e9ec4c 1394 #define HAS_digitalInOut13 0
whismanoid 0:cb44e2e9ec4c 1395 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1396 #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1397 #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1398 #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1399 #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1400 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1401 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 1402 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1403 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1404 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1405 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1406 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1407 #define HAS_digitalInOut14 0
whismanoid 0:cb44e2e9ec4c 1408 #define HAS_digitalInOut15 0
whismanoid 0:cb44e2e9ec4c 1409 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1410 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1411 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1412 #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1413 #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1414 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1415 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1416 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1417 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1418 DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1419 #endif
whismanoid 0:cb44e2e9ec4c 1420 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1421 DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1422 #endif
whismanoid 0:cb44e2e9ec4c 1423 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1424 DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1425 #endif
whismanoid 0:cb44e2e9ec4c 1426 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1427 DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1428 #endif
whismanoid 0:cb44e2e9ec4c 1429 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1430 DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1431 #endif
whismanoid 0:cb44e2e9ec4c 1432 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1433 DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1434 #endif
whismanoid 0:cb44e2e9ec4c 1435 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1436 DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1437 #endif
whismanoid 0:cb44e2e9ec4c 1438 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1439 DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1440 #endif
whismanoid 0:cb44e2e9ec4c 1441 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1442 DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1443 #endif
whismanoid 0:cb44e2e9ec4c 1444 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1445 DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1446 #endif
whismanoid 0:cb44e2e9ec4c 1447 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1448 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1449 DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1450 #endif
whismanoid 0:cb44e2e9ec4c 1451 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1452 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1453 DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1454 #endif
whismanoid 0:cb44e2e9ec4c 1455 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1456 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1457 DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1458 #endif
whismanoid 0:cb44e2e9ec4c 1459 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1460 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1461 DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1462 #endif
whismanoid 0:cb44e2e9ec4c 1463 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1464 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1465 DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1466 #endif
whismanoid 0:cb44e2e9ec4c 1467 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1468 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1469 DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1470 #endif
whismanoid 0:cb44e2e9ec4c 1471 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1472 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1473 DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1474 #endif
whismanoid 0:cb44e2e9ec4c 1475 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1476 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1477 DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1478 #endif
whismanoid 0:cb44e2e9ec4c 1479 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1480 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1481 #define HAS_digitalInOut0 1
whismanoid 0:cb44e2e9ec4c 1482 #define HAS_digitalInOut1 1
whismanoid 0:cb44e2e9ec4c 1483 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1484 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1485 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1486 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1487 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1488 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1489 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1490 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1491 // #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1492 // #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1493 // #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1494 // #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1495 // #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1496 // #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1497 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1498 DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3
whismanoid 0:cb44e2e9ec4c 1499 #endif
whismanoid 0:cb44e2e9ec4c 1500 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1501 DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2
whismanoid 0:cb44e2e9ec4c 1502 #endif
whismanoid 0:cb44e2e9ec4c 1503 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1504 DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1
whismanoid 0:cb44e2e9ec4c 1505 #endif
whismanoid 0:cb44e2e9ec4c 1506 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1507 DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0
whismanoid 0:cb44e2e9ec4c 1508 #endif
whismanoid 0:cb44e2e9ec4c 1509 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1510 DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1
whismanoid 0:cb44e2e9ec4c 1511 #endif
whismanoid 0:cb44e2e9ec4c 1512 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1513 DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1
whismanoid 0:cb44e2e9ec4c 1514 #endif
whismanoid 0:cb44e2e9ec4c 1515 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1516 DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1
whismanoid 0:cb44e2e9ec4c 1517 #endif
whismanoid 0:cb44e2e9ec4c 1518 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1519 DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO
whismanoid 0:cb44e2e9ec4c 1520 #endif
whismanoid 0:cb44e2e9ec4c 1521 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1522 DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK
whismanoid 0:cb44e2e9ec4c 1523 #endif
whismanoid 0:cb44e2e9ec4c 1524 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1525 DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL
whismanoid 0:cb44e2e9ec4c 1526 #endif
whismanoid 0:cb44e2e9ec4c 1527 //
whismanoid 0:cb44e2e9ec4c 1528 // these pins support analog input analogIn0 .. analogIn5
whismanoid 0:cb44e2e9ec4c 1529 //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1530 //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1531 //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1532 //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1533 //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1534 //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1535 //
whismanoid 0:cb44e2e9ec4c 1536 // these pins support PWM pwmDriver1 .. pwmDriver6
whismanoid 0:cb44e2e9ec4c 1537 //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0
whismanoid 0:cb44e2e9ec4c 1538 //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1
whismanoid 0:cb44e2e9ec4c 1539 //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2
whismanoid 0:cb44e2e9ec4c 1540 //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3
whismanoid 0:cb44e2e9ec4c 1541 //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1
whismanoid 0:cb44e2e9ec4c 1542 //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK
whismanoid 0:cb44e2e9ec4c 1543 //
whismanoid 0:cb44e2e9ec4c 1544 // these could be additional digitalInOut pins
whismanoid 0:cb44e2e9ec4c 1545 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1546 DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1
whismanoid 0:cb44e2e9ec4c 1547 #endif
whismanoid 0:cb44e2e9ec4c 1548 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1549 DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0
whismanoid 0:cb44e2e9ec4c 1550 #endif
whismanoid 0:cb44e2e9ec4c 1551 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1552 DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1
whismanoid 0:cb44e2e9ec4c 1553 #endif
whismanoid 0:cb44e2e9ec4c 1554 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1555 DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0
whismanoid 0:cb44e2e9ec4c 1556 #endif
whismanoid 0:cb44e2e9ec4c 1557 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1558 DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1559 #endif
whismanoid 0:cb44e2e9ec4c 1560 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1561 DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1562 #endif
whismanoid 0:cb44e2e9ec4c 1563 #else
whismanoid 0:cb44e2e9ec4c 1564 // unknown target
whismanoid 0:cb44e2e9ec4c 1565 #endif
whismanoid 0:cb44e2e9ec4c 1566 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1567 #if HAS_digitalInOut0 || HAS_digitalInOut1 \
whismanoid 0:cb44e2e9ec4c 1568 || HAS_digitalInOut2 || HAS_digitalInOut3 \
whismanoid 0:cb44e2e9ec4c 1569 || HAS_digitalInOut4 || HAS_digitalInOut5 \
whismanoid 0:cb44e2e9ec4c 1570 || HAS_digitalInOut6 || HAS_digitalInOut7 \
whismanoid 0:cb44e2e9ec4c 1571 || HAS_digitalInOut8 || HAS_digitalInOut9 \
whismanoid 0:cb44e2e9ec4c 1572 || HAS_digitalInOut10 || HAS_digitalInOut11 \
whismanoid 0:cb44e2e9ec4c 1573 || HAS_digitalInOut12 || HAS_digitalInOut13 \
whismanoid 0:cb44e2e9ec4c 1574 || HAS_digitalInOut14 || HAS_digitalInOut15 \
whismanoid 0:cb44e2e9ec4c 1575 || HAS_digitalInOut16 || HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1576 #define HAS_digitalInOuts 1
whismanoid 0:cb44e2e9ec4c 1577 #else
whismanoid 0:cb44e2e9ec4c 1578 #warning "Note: There are no digitalInOut resources defined"
whismanoid 0:cb44e2e9ec4c 1579 #endif
whismanoid 0:cb44e2e9ec4c 1580
whismanoid 0:cb44e2e9ec4c 1581 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 1582 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1583 // Declare the AnalogIn driver
whismanoid 0:cb44e2e9ec4c 1584 // Optional analogIn support. If there is only one it should be analogIn1.
whismanoid 0:cb44e2e9ec4c 1585 // A) analog input
whismanoid 0:cb44e2e9ec4c 1586 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1587 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1588 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1589 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1590 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1591 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1592 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1593 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1594 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1595 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1596 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1597 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1598 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1599 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1600 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1601 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1602 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1603 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1604 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1605 #endif
whismanoid 0:cb44e2e9ec4c 1606 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1607 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1608 #endif
whismanoid 0:cb44e2e9ec4c 1609 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1610 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1611 #endif
whismanoid 0:cb44e2e9ec4c 1612 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1613 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1614 #endif
whismanoid 0:cb44e2e9ec4c 1615 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1616 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1617 #endif
whismanoid 0:cb44e2e9ec4c 1618 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1619 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1620 #endif
whismanoid 0:cb44e2e9ec4c 1621 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1622 AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1623 #endif
whismanoid 0:cb44e2e9ec4c 1624 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1625 AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1626 #endif
whismanoid 0:cb44e2e9ec4c 1627 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1628 AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1629 #endif
whismanoid 0:cb44e2e9ec4c 1630 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1631 AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1632 #endif
whismanoid 0:cb44e2e9ec4c 1633 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1634 AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1635 #endif
whismanoid 0:cb44e2e9ec4c 1636 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1637 AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1638 #endif
whismanoid 0:cb44e2e9ec4c 1639 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1640 AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1641 #endif
whismanoid 0:cb44e2e9ec4c 1642 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1643 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1644 #endif
whismanoid 0:cb44e2e9ec4c 1645 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1646 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1647 #endif
whismanoid 0:cb44e2e9ec4c 1648 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1649 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1650 #endif
whismanoid 0:cb44e2e9ec4c 1651 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1652 #elif defined(TARGET_MAX32625MBED)
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 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1660 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1661 #endif
whismanoid 0:cb44e2e9ec4c 1662 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1663 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1664 #endif
whismanoid 0:cb44e2e9ec4c 1665 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1666 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1667 #endif
whismanoid 0:cb44e2e9ec4c 1668 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1669 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1670 #endif
whismanoid 0:cb44e2e9ec4c 1671 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1672 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1673 #endif
whismanoid 0:cb44e2e9ec4c 1674 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1675 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1676 #endif
whismanoid 0:cb44e2e9ec4c 1677 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1678 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 1679 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1680 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1681 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1682 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1683 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1684 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1685 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1686 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1687 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1688 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1689 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1690 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1691 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1692 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1693 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1694 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1695 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1696 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1697 AnalogIn analogIn0(AIN_0); // TARGET_MAX32620FTHR J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1698 #endif
whismanoid 0:cb44e2e9ec4c 1699 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1700 AnalogIn analogIn1(AIN_1); // TARGET_MAX32620FTHR J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1701 #endif
whismanoid 0:cb44e2e9ec4c 1702 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1703 AnalogIn analogIn2(AIN_2); // TARGET_MAX32620FTHR J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1704 #endif
whismanoid 0:cb44e2e9ec4c 1705 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1706 AnalogIn analogIn3(AIN_3); // TARGET_MAX32620FTHR J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1707 #endif
whismanoid 0:cb44e2e9ec4c 1708 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1709 AnalogIn analogIn4(AIN_4); // TARGET_MAX32620FTHR J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1710 #endif
whismanoid 0:cb44e2e9ec4c 1711 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1712 AnalogIn analogIn5(AIN_5); // TARGET_MAX32620FTHR J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1713 #endif
whismanoid 0:cb44e2e9ec4c 1714 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1715 AnalogIn analogIn6(AIN_6); // TARGET_MAX32620FTHR AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1716 #endif
whismanoid 0:cb44e2e9ec4c 1717 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1718 AnalogIn analogIn7(AIN_7); // TARGET_MAX32620FTHR AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1719 #endif
whismanoid 0:cb44e2e9ec4c 1720 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1721 AnalogIn analogIn8(AIN_8); // TARGET_MAX32620FTHR AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1722 #endif
whismanoid 0:cb44e2e9ec4c 1723 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1724 AnalogIn analogIn9(AIN_9); // TARGET_MAX32620FTHR AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1725 #endif
whismanoid 0:cb44e2e9ec4c 1726 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1727 AnalogIn analogIn10(____); // TARGET_MAX32620FTHR AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1728 #endif
whismanoid 0:cb44e2e9ec4c 1729 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1730 AnalogIn analogIn11(____); // TARGET_MAX32620FTHR AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1731 #endif
whismanoid 0:cb44e2e9ec4c 1732 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1733 AnalogIn analogIn12(____); // TARGET_MAX32620FTHR AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1734 #endif
whismanoid 0:cb44e2e9ec4c 1735 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1736 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1737 #endif
whismanoid 0:cb44e2e9ec4c 1738 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1739 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1740 #endif
whismanoid 0:cb44e2e9ec4c 1741 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1742 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1743 #endif
whismanoid 0:cb44e2e9ec4c 1744 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 1745 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 37:3f369235e5bc 1746 // #warning "TARGET_MAX32625PICO not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1747 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1748 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1749 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1750 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1751 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1752 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1753 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1754 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1755 #endif
whismanoid 0:cb44e2e9ec4c 1756 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1757 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1758 #endif
whismanoid 0:cb44e2e9ec4c 1759 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1760 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1761 #endif
whismanoid 0:cb44e2e9ec4c 1762 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1763 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1764 #endif
whismanoid 0:cb44e2e9ec4c 1765 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1766 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1767 #endif
whismanoid 0:cb44e2e9ec4c 1768 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1769 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1770 #endif
whismanoid 0:cb44e2e9ec4c 1771 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1772 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 1773 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1774 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1775 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1776 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1777 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1778 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1779 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1780 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1781 #endif
whismanoid 0:cb44e2e9ec4c 1782 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1783 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1784 #endif
whismanoid 0:cb44e2e9ec4c 1785 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1786 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1787 #endif
whismanoid 0:cb44e2e9ec4c 1788 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1789 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1790 #endif
whismanoid 0:cb44e2e9ec4c 1791 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1792 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1793 #endif
whismanoid 0:cb44e2e9ec4c 1794 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1795 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1796 #endif
whismanoid 0:cb44e2e9ec4c 1797 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1798 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 1799 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1800 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1801 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1802 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1803 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1804 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1805 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1806 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1807 #endif
whismanoid 0:cb44e2e9ec4c 1808 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1809 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1810 #endif
whismanoid 0:cb44e2e9ec4c 1811 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1812 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1813 #endif
whismanoid 0:cb44e2e9ec4c 1814 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1815 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1816 #endif
whismanoid 0:cb44e2e9ec4c 1817 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1818 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1819 #endif
whismanoid 0:cb44e2e9ec4c 1820 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1821 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1822 #endif
whismanoid 0:cb44e2e9ec4c 1823 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1824 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1825 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1826 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1827 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1828 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1829 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1830 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1831 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1832 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1833 #endif
whismanoid 0:cb44e2e9ec4c 1834 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1835 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1836 #endif
whismanoid 0:cb44e2e9ec4c 1837 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1838 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1839 #endif
whismanoid 0:cb44e2e9ec4c 1840 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1841 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1842 #endif
whismanoid 0:cb44e2e9ec4c 1843 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1844 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1845 #endif
whismanoid 0:cb44e2e9ec4c 1846 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1847 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1848 #endif
whismanoid 0:cb44e2e9ec4c 1849 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1850 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 1851 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1852 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1853 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1854 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1855 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1856 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1857 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1858 // #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1859 // #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1860 // #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1861 // #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1862 // #define HAS_analogIn10 1
whismanoid 0:cb44e2e9ec4c 1863 // #define HAS_analogIn11 1
whismanoid 0:cb44e2e9ec4c 1864 // #define HAS_analogIn12 1
whismanoid 0:cb44e2e9ec4c 1865 // #define HAS_analogIn13 1
whismanoid 0:cb44e2e9ec4c 1866 // #define HAS_analogIn14 1
whismanoid 0:cb44e2e9ec4c 1867 // #define HAS_analogIn15 1
whismanoid 0:cb44e2e9ec4c 1868 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1869 AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1870 #endif
whismanoid 0:cb44e2e9ec4c 1871 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1872 AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1873 #endif
whismanoid 0:cb44e2e9ec4c 1874 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1875 AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1876 #endif
whismanoid 0:cb44e2e9ec4c 1877 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1878 AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1879 #endif
whismanoid 0:cb44e2e9ec4c 1880 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1881 AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1882 #endif
whismanoid 0:cb44e2e9ec4c 1883 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1884 AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1885 #endif
whismanoid 0:cb44e2e9ec4c 1886 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1887 AnalogIn analogIn6(____);
whismanoid 0:cb44e2e9ec4c 1888 #endif
whismanoid 0:cb44e2e9ec4c 1889 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1890 AnalogIn analogIn7(____);
whismanoid 0:cb44e2e9ec4c 1891 #endif
whismanoid 0:cb44e2e9ec4c 1892 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1893 AnalogIn analogIn8(____);
whismanoid 0:cb44e2e9ec4c 1894 #endif
whismanoid 0:cb44e2e9ec4c 1895 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1896 AnalogIn analogIn9(____);
whismanoid 0:cb44e2e9ec4c 1897 #endif
whismanoid 0:cb44e2e9ec4c 1898 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1899 AnalogIn analogIn10(____);
whismanoid 0:cb44e2e9ec4c 1900 #endif
whismanoid 0:cb44e2e9ec4c 1901 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1902 AnalogIn analogIn11(____);
whismanoid 0:cb44e2e9ec4c 1903 #endif
whismanoid 0:cb44e2e9ec4c 1904 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1905 AnalogIn analogIn12(____);
whismanoid 0:cb44e2e9ec4c 1906 #endif
whismanoid 0:cb44e2e9ec4c 1907 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1908 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1909 #endif
whismanoid 0:cb44e2e9ec4c 1910 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1911 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1912 #endif
whismanoid 0:cb44e2e9ec4c 1913 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1914 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1915 #endif
whismanoid 0:cb44e2e9ec4c 1916 #else
whismanoid 0:cb44e2e9ec4c 1917 // unknown target
whismanoid 0:cb44e2e9ec4c 1918 #endif
whismanoid 0:cb44e2e9ec4c 1919 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1920 #if HAS_analogIn0 || HAS_analogIn1 \
whismanoid 0:cb44e2e9ec4c 1921 || HAS_analogIn2 || HAS_analogIn3 \
whismanoid 0:cb44e2e9ec4c 1922 || HAS_analogIn4 || HAS_analogIn5 \
whismanoid 0:cb44e2e9ec4c 1923 || HAS_analogIn6 || HAS_analogIn7 \
whismanoid 0:cb44e2e9ec4c 1924 || HAS_analogIn8 || HAS_analogIn9 \
whismanoid 0:cb44e2e9ec4c 1925 || HAS_analogIn10 || HAS_analogIn11 \
whismanoid 0:cb44e2e9ec4c 1926 || HAS_analogIn12 || HAS_analogIn13 \
whismanoid 0:cb44e2e9ec4c 1927 || HAS_analogIn14 || HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1928 #define HAS_analogIns 1
whismanoid 0:cb44e2e9ec4c 1929 #else
whismanoid 0:cb44e2e9ec4c 1930 #warning "Note: There are no analogIn resources defined"
whismanoid 0:cb44e2e9ec4c 1931 #endif
whismanoid 0:cb44e2e9ec4c 1932
whismanoid 0:cb44e2e9ec4c 1933 // DigitalInOut pin resource: print the pin index names to serial
whismanoid 0:cb44e2e9ec4c 1934 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 1935 void list_digitalInOutPins(Stream& serialStream)
whismanoid 0:cb44e2e9ec4c 1936 {
whismanoid 0:cb44e2e9ec4c 1937 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1938 serialStream.printf(" 0");
whismanoid 0:cb44e2e9ec4c 1939 #endif
whismanoid 0:cb44e2e9ec4c 1940 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1941 serialStream.printf(" 1");
whismanoid 0:cb44e2e9ec4c 1942 #endif
whismanoid 0:cb44e2e9ec4c 1943 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1944 serialStream.printf(" 2");
whismanoid 0:cb44e2e9ec4c 1945 #endif
whismanoid 0:cb44e2e9ec4c 1946 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1947 serialStream.printf(" 3");
whismanoid 0:cb44e2e9ec4c 1948 #endif
whismanoid 0:cb44e2e9ec4c 1949 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1950 serialStream.printf(" 4");
whismanoid 0:cb44e2e9ec4c 1951 #endif
whismanoid 0:cb44e2e9ec4c 1952 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1953 serialStream.printf(" 5");
whismanoid 0:cb44e2e9ec4c 1954 #endif
whismanoid 0:cb44e2e9ec4c 1955 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1956 serialStream.printf(" 6");
whismanoid 0:cb44e2e9ec4c 1957 #endif
whismanoid 0:cb44e2e9ec4c 1958 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1959 serialStream.printf(" 7");
whismanoid 0:cb44e2e9ec4c 1960 #endif
whismanoid 0:cb44e2e9ec4c 1961 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1962 serialStream.printf(" 8");
whismanoid 0:cb44e2e9ec4c 1963 #endif
whismanoid 0:cb44e2e9ec4c 1964 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1965 serialStream.printf(" 9");
whismanoid 0:cb44e2e9ec4c 1966 #endif
whismanoid 0:cb44e2e9ec4c 1967 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1968 serialStream.printf(" 10");
whismanoid 0:cb44e2e9ec4c 1969 #endif
whismanoid 0:cb44e2e9ec4c 1970 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1971 serialStream.printf(" 11");
whismanoid 0:cb44e2e9ec4c 1972 #endif
whismanoid 0:cb44e2e9ec4c 1973 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1974 serialStream.printf(" 12");
whismanoid 0:cb44e2e9ec4c 1975 #endif
whismanoid 0:cb44e2e9ec4c 1976 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1977 serialStream.printf(" 13");
whismanoid 0:cb44e2e9ec4c 1978 #endif
whismanoid 0:cb44e2e9ec4c 1979 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1980 serialStream.printf(" 14");
whismanoid 0:cb44e2e9ec4c 1981 #endif
whismanoid 0:cb44e2e9ec4c 1982 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1983 serialStream.printf(" 15");
whismanoid 0:cb44e2e9ec4c 1984 #endif
whismanoid 0:cb44e2e9ec4c 1985 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1986 serialStream.printf(" 16");
whismanoid 0:cb44e2e9ec4c 1987 #endif
whismanoid 0:cb44e2e9ec4c 1988 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1989 serialStream.printf(" 17");
whismanoid 0:cb44e2e9ec4c 1990 #endif
whismanoid 18:1235c17b451e 1991 #if USE_LEDS
whismanoid 18:1235c17b451e 1992 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 1993 // support list_digitalInOutPins() listing buttons and leds as pin numbers 90/91/92/93
whismanoid 18:1235c17b451e 1994 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 1995 //~ serialStream.printf(" 90");
whismanoid 18:1235c17b451e 1996 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 1997 serialStream.printf(" 91");
whismanoid 18:1235c17b451e 1998 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 1999 serialStream.printf(" 92");
whismanoid 18:1235c17b451e 2000 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 2001 serialStream.printf(" 93");
whismanoid 18:1235c17b451e 2002 #else // USE_LEDS
whismanoid 18:1235c17b451e 2003 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 2004 }
whismanoid 0:cb44e2e9ec4c 2005 #endif
whismanoid 0:cb44e2e9ec4c 2006
whismanoid 0:cb44e2e9ec4c 2007
whismanoid 0:cb44e2e9ec4c 2008 // DigitalInOut pin resource: search index
whismanoid 0:cb44e2e9ec4c 2009 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 2010 DigitalInOut& find_digitalInOutPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 2011 {
whismanoid 0:cb44e2e9ec4c 2012 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 2013 {
whismanoid 0:cb44e2e9ec4c 2014 default: // default to the first defined digitalInOut pin
whismanoid 0:cb44e2e9ec4c 2015 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 2016 case '0': case 0x00: return digitalInOut0;
whismanoid 0:cb44e2e9ec4c 2017 #endif
whismanoid 0:cb44e2e9ec4c 2018 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 2019 case '1': case 0x01: return digitalInOut1;
whismanoid 0:cb44e2e9ec4c 2020 #endif
whismanoid 0:cb44e2e9ec4c 2021 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 2022 case '2': case 0x02: return digitalInOut2;
whismanoid 0:cb44e2e9ec4c 2023 #endif
whismanoid 0:cb44e2e9ec4c 2024 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 2025 case '3': case 0x03: return digitalInOut3;
whismanoid 0:cb44e2e9ec4c 2026 #endif
whismanoid 0:cb44e2e9ec4c 2027 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 2028 case '4': case 0x04: return digitalInOut4;
whismanoid 0:cb44e2e9ec4c 2029 #endif
whismanoid 0:cb44e2e9ec4c 2030 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 2031 case '5': case 0x05: return digitalInOut5;
whismanoid 0:cb44e2e9ec4c 2032 #endif
whismanoid 0:cb44e2e9ec4c 2033 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 2034 case '6': case 0x06: return digitalInOut6;
whismanoid 0:cb44e2e9ec4c 2035 #endif
whismanoid 0:cb44e2e9ec4c 2036 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 2037 case '7': case 0x07: return digitalInOut7;
whismanoid 0:cb44e2e9ec4c 2038 #endif
whismanoid 0:cb44e2e9ec4c 2039 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 2040 case '8': case 0x08: return digitalInOut8;
whismanoid 0:cb44e2e9ec4c 2041 #endif
whismanoid 0:cb44e2e9ec4c 2042 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 2043 case '9': case 0x09: return digitalInOut9;
whismanoid 0:cb44e2e9ec4c 2044 #endif
whismanoid 0:cb44e2e9ec4c 2045 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 2046 case 'a': case 0x0a: return digitalInOut10;
whismanoid 0:cb44e2e9ec4c 2047 #endif
whismanoid 0:cb44e2e9ec4c 2048 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 2049 case 'b': case 0x0b: return digitalInOut11;
whismanoid 0:cb44e2e9ec4c 2050 #endif
whismanoid 0:cb44e2e9ec4c 2051 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 2052 case 'c': case 0x0c: return digitalInOut12;
whismanoid 0:cb44e2e9ec4c 2053 #endif
whismanoid 0:cb44e2e9ec4c 2054 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 2055 case 'd': case 0x0d: return digitalInOut13;
whismanoid 0:cb44e2e9ec4c 2056 #endif
whismanoid 0:cb44e2e9ec4c 2057 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 2058 case 'e': case 0x0e: return digitalInOut14;
whismanoid 0:cb44e2e9ec4c 2059 #endif
whismanoid 0:cb44e2e9ec4c 2060 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 2061 case 'f': case 0x0f: return digitalInOut15;
whismanoid 0:cb44e2e9ec4c 2062 #endif
whismanoid 0:cb44e2e9ec4c 2063 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 2064 case 'g': case 0x10: return digitalInOut16;
whismanoid 0:cb44e2e9ec4c 2065 #endif
whismanoid 0:cb44e2e9ec4c 2066 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 2067 case 'h': case 0x11: return digitalInOut17;
whismanoid 0:cb44e2e9ec4c 2068 #endif
whismanoid 18:1235c17b451e 2069 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 2070 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 2071 //~ case 90: return button1;
whismanoid 18:1235c17b451e 2072 #if USE_LEDS
whismanoid 18:1235c17b451e 2073 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 2074 case 91: return led1_RFailLED;
whismanoid 18:1235c17b451e 2075 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 2076 case 92: return led2_GPassLED;
whismanoid 18:1235c17b451e 2077 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 2078 case 93: return led3_BBusyLED;
whismanoid 18:1235c17b451e 2079 #else // USE_LEDS
whismanoid 18:1235c17b451e 2080 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 2081 }
whismanoid 0:cb44e2e9ec4c 2082 }
whismanoid 0:cb44e2e9ec4c 2083 #endif
whismanoid 0:cb44e2e9ec4c 2084
whismanoid 0:cb44e2e9ec4c 2085
whismanoid 0:cb44e2e9ec4c 2086 // AnalogIn pin resource: search index
whismanoid 0:cb44e2e9ec4c 2087 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 2088 AnalogIn& find_analogInPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 2089 {
whismanoid 0:cb44e2e9ec4c 2090 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 2091 {
whismanoid 0:cb44e2e9ec4c 2092 default: // default to the first defined analogIn pin
whismanoid 0:cb44e2e9ec4c 2093 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 2094 case '0': case 0x00: return analogIn0;
whismanoid 0:cb44e2e9ec4c 2095 #endif
whismanoid 0:cb44e2e9ec4c 2096 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 2097 case '1': case 0x01: return analogIn1;
whismanoid 0:cb44e2e9ec4c 2098 #endif
whismanoid 0:cb44e2e9ec4c 2099 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 2100 case '2': case 0x02: return analogIn2;
whismanoid 0:cb44e2e9ec4c 2101 #endif
whismanoid 0:cb44e2e9ec4c 2102 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 2103 case '3': case 0x03: return analogIn3;
whismanoid 0:cb44e2e9ec4c 2104 #endif
whismanoid 0:cb44e2e9ec4c 2105 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 2106 case '4': case 0x04: return analogIn4;
whismanoid 0:cb44e2e9ec4c 2107 #endif
whismanoid 0:cb44e2e9ec4c 2108 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 2109 case '5': case 0x05: return analogIn5;
whismanoid 0:cb44e2e9ec4c 2110 #endif
whismanoid 0:cb44e2e9ec4c 2111 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 2112 case '6': case 0x06: return analogIn6;
whismanoid 0:cb44e2e9ec4c 2113 #endif
whismanoid 0:cb44e2e9ec4c 2114 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 2115 case '7': case 0x07: return analogIn7;
whismanoid 0:cb44e2e9ec4c 2116 #endif
whismanoid 0:cb44e2e9ec4c 2117 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 2118 case '8': case 0x08: return analogIn8;
whismanoid 0:cb44e2e9ec4c 2119 #endif
whismanoid 0:cb44e2e9ec4c 2120 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 2121 case '9': case 0x09: return analogIn9;
whismanoid 0:cb44e2e9ec4c 2122 #endif
whismanoid 0:cb44e2e9ec4c 2123 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 2124 case 'a': case 0x0a: return analogIn10;
whismanoid 0:cb44e2e9ec4c 2125 #endif
whismanoid 0:cb44e2e9ec4c 2126 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 2127 case 'b': case 0x0b: return analogIn11;
whismanoid 0:cb44e2e9ec4c 2128 #endif
whismanoid 0:cb44e2e9ec4c 2129 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 2130 case 'c': case 0x0c: return analogIn12;
whismanoid 0:cb44e2e9ec4c 2131 #endif
whismanoid 0:cb44e2e9ec4c 2132 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 2133 case 'd': case 0x0d: return analogIn13;
whismanoid 0:cb44e2e9ec4c 2134 #endif
whismanoid 0:cb44e2e9ec4c 2135 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 2136 case 'e': case 0x0e: return analogIn14;
whismanoid 0:cb44e2e9ec4c 2137 #endif
whismanoid 0:cb44e2e9ec4c 2138 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 2139 case 'f': case 0x0f: return analogIn15;
whismanoid 0:cb44e2e9ec4c 2140 #endif
whismanoid 0:cb44e2e9ec4c 2141 }
whismanoid 0:cb44e2e9ec4c 2142 }
whismanoid 0:cb44e2e9ec4c 2143 #endif
whismanoid 0:cb44e2e9ec4c 2144
whismanoid 0:cb44e2e9ec4c 2145 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 2146 const float analogInPin_fullScaleVoltage[] = {
whismanoid 0:cb44e2e9ec4c 2147 # if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 2148 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 2149 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 2150 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 2151 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 2152 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2153 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2154 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2155 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2156 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2157 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 2158 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 2159 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2160 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2161 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2162 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2163 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2164 # elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 2165 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 2166 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 2167 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 2168 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 2169 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 2170 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2171 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2172 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2173 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2174 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2175 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 2176 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 2177 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2178 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2179 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2180 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2181 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 19:5ff09c8e9daf 2182 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 2183 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2184 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2185 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2186 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2187 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2188 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 2189 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2190 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2191 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 2192 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 2193 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 2194 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2195 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 2196 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2197 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2198 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2199 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 2200 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 2201 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 2202 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 2203 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 2204 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 2205 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 2206 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 2207 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 2208 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 2209 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 2210 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 2211 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 2212 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 2213 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2214 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2215 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2216 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 2217 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 2218 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 2219 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 2220 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 2221 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 2222 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 2223 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 2224 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 2225 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 2226 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 2227 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 2228 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 2229 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 2230 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2231 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2232 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2233 //#elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 2234 #else
whismanoid 0:cb44e2e9ec4c 2235 // unknown target
whismanoid 0:cb44e2e9ec4c 2236 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 2237 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 2238 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 2239 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 2240 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 2241 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 2242 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 2243 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 2244 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 2245 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 2246 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 2247 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 2248 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 2249 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2250 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2251 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2252 # endif
whismanoid 0:cb44e2e9ec4c 2253 };
whismanoid 0:cb44e2e9ec4c 2254 #endif
whismanoid 0:cb44e2e9ec4c 2255
whismanoid 0:cb44e2e9ec4c 2256
whismanoid 0:cb44e2e9ec4c 2257
whismanoid 0:cb44e2e9ec4c 2258
whismanoid 0:cb44e2e9ec4c 2259 //--------------------------------------------------
whismanoid 45:74bf1fe021e5 2260 // support CmdLine command menus (like on Serial_Tester)
whismanoid 4:d9b05924ad4c 2261 #ifndef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 2262 #define USE_CMDLINE_MENUS 1
whismanoid 4:d9b05924ad4c 2263 //~ #undef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 2264 #endif
whismanoid 4:d9b05924ad4c 2265 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2266 #include "CmdLine.h"
whismanoid 4:d9b05924ad4c 2267 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2268 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2269 extern CmdLine cmdLine; // declared later
whismanoid 4:d9b05924ad4c 2270 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2271
whismanoid 4:d9b05924ad4c 2272 //--------------------------------------------------
whismanoid 39:4d285e961435 2273 // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2274 #ifndef USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 2275 #define USE_DATALOGGER_SLEEP 1
whismanoid 39:4d285e961435 2276 //~ #undef USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 2277 #endif
whismanoid 39:4d285e961435 2278 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 2279 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 2280 // USE_DATALOGGER_SLEEP -- #include "lp.h" -- LP_EnterLP1()
whismanoid 42:89607d5d4e6d 2281 #include "lp.h"
whismanoid 43:4c4733760d4c 2282 #include "rtc.h"
whismanoid 39:4d285e961435 2283 #endif
whismanoid 39:4d285e961435 2284 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 44:84402faa8eb9 2285 // wait until UART_Busy indicates no ongoing transactions (both ports)
whismanoid 44:84402faa8eb9 2286 #include "uart.h"
whismanoid 44:84402faa8eb9 2287 int Console_PrepForSleep(void)
whismanoid 44:84402faa8eb9 2288 {
whismanoid 44:84402faa8eb9 2289 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 44:84402faa8eb9 2290 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK)
whismanoid 44:84402faa8eb9 2291 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 44:84402faa8eb9 2292 return (
whismanoid 44:84402faa8eb9 2293 (UART_PrepForSleep(MXC_UART_GET_UART(0)) == E_NO_ERROR)
whismanoid 44:84402faa8eb9 2294 && (UART_PrepForSleep(MXC_UART_GET_UART(1)) == E_NO_ERROR)
whismanoid 44:84402faa8eb9 2295 )
whismanoid 44:84402faa8eb9 2296 ? E_NO_ERROR
whismanoid 44:84402faa8eb9 2297 : E_BUSY;
whismanoid 44:84402faa8eb9 2298 }
whismanoid 44:84402faa8eb9 2299 #endif // USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 44:84402faa8eb9 2300 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2301 typedef enum Datalogger_Sleep_enum_t {
whismanoid 39:4d285e961435 2302 datalogger_Sleep_LP0_Stop = 0,
whismanoid 39:4d285e961435 2303 datalogger_Sleep_LP1_DeepSleep = 1,
whismanoid 39:4d285e961435 2304 datalogger_Sleep_LP2_Sleep = 2,
whismanoid 39:4d285e961435 2305 datalogger_Sleep_LP3_Run = 3,
whismanoid 39:4d285e961435 2306 } Datalogger_Sleep_enum_t;
whismanoid 45:74bf1fe021e5 2307 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 2308 Datalogger_Sleep_enum_t g_timer_sleepmode = datalogger_Sleep_LP1_DeepSleep;
whismanoid 39:4d285e961435 2309 #endif
whismanoid 39:4d285e961435 2310
whismanoid 39:4d285e961435 2311 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2312 // Datalog trigger types
whismanoid 4:d9b05924ad4c 2313 #ifndef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 2314 #define USE_DATALOGGER_TRIGGER 1
whismanoid 4:d9b05924ad4c 2315 //~ #undef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 2316 #endif
whismanoid 4:d9b05924ad4c 2317 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 2318 typedef enum Datalogger_Trigger_enum_t {
whismanoid 4:d9b05924ad4c 2319 trigger_Halt = 0, //!< halt
whismanoid 4:d9b05924ad4c 2320 trigger_FreeRun = 1, //!< free run as fast as possible
whismanoid 4:d9b05924ad4c 2321 trigger_Timer = 2, //!< timer (configure interval)
whismanoid 4:d9b05924ad4c 2322 trigger_PlatformDigitalInput, //!< platform digital input (configure digital input pin reference)
whismanoid 4:d9b05924ad4c 2323 trigger_SPIDeviceRegRead, //!< SPI device register read (configure regaddr, mask value, match value)
whismanoid 4:d9b05924ad4c 2324 } Datalogger_Trigger_enum_t;
whismanoid 4:d9b05924ad4c 2325 Datalogger_Trigger_enum_t Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 2326 //
whismanoid 17:9397ea3ea7e9 2327 // configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 2328 int g_timer_interval_msec = 500; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2329 int g_timer_interval_count = 10; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2330 int g_timer_interval_counter = 0; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2331 //
whismanoid 17:9397ea3ea7e9 2332 // TODO: configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 2333 //
whismanoid 17:9397ea3ea7e9 2334 // TODO: configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2335 //
whismanoid 4:d9b05924ad4c 2336 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 2337
whismanoid 4:d9b05924ad4c 2338 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2339 // support trigger_SPIDeviceRegRead: Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 2340 #ifndef USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2341 #define USE_DATALOGGER_SPIDeviceRegRead 0
whismanoid 17:9397ea3ea7e9 2342 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2343 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2344 // TODO: uint16_t regAddr;
whismanoid 17:9397ea3ea7e9 2345 // TODO: uint16_t regDataMask;
whismanoid 17:9397ea3ea7e9 2346 // TODO: uint16_t regDataTest;
whismanoid 17:9397ea3ea7e9 2347 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2348
whismanoid 17:9397ea3ea7e9 2349 //--------------------------------------------------
whismanoid 30:07197a430869 2350 // support Datalogger_PrintRow() print gstrRemarkText field from recent #remark
whismanoid 30:07197a430869 2351 #ifndef USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2352 #define USE_DATALOGGER_REMARK_FIELD 1
whismanoid 30:07197a430869 2353 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2354 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2355 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark
whismanoid 30:07197a430869 2356 const size_t gstrRemarkTextLASTINDEX = 40; // gstrRemarkText buffer size - 1
whismanoid 30:07197a430869 2357 char gstrRemarkText[gstrRemarkTextLASTINDEX+1] = "";
whismanoid 30:07197a430869 2358 char gstrRemarkHeader[] = "comment"; // comment or remark?
whismanoid 30:07197a430869 2359 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2360
whismanoid 30:07197a430869 2361 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2362 // Datalogger_RunActionTable() supported actions
whismanoid 45:74bf1fe021e5 2363 // support command L@
whismanoid 45:74bf1fe021e5 2364 // configurable "business logic" for the data log
whismanoid 17:9397ea3ea7e9 2365 #ifndef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2366 #define USE_DATALOGGER_ActionTable 1
whismanoid 17:9397ea3ea7e9 2367 //~ #undef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2368 #endif
whismanoid 17:9397ea3ea7e9 2369 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2370 //
whismanoid 17:9397ea3ea7e9 2371 // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2372 typedef enum action_type_enum_t {
whismanoid 17:9397ea3ea7e9 2373 action_noop = 0, // no operation
whismanoid 30:07197a430869 2374 action_digitalOutLow = 1, // pin = low if condition
whismanoid 30:07197a430869 2375 action_digitalOutHigh = 2, // pin = high if condition
whismanoid 30:07197a430869 2376 action_button = 3, // pin = button event index 1, 2, 3
whismanoid 30:07197a430869 2377 action_trigger_Halt = 4,
whismanoid 30:07197a430869 2378 action_trigger_FreeRun = 5,
whismanoid 30:07197a430869 2379 action_trigger_Timer = 6,
whismanoid 30:07197a430869 2380 action_trigger_PlatformDigitalInput = 7,
whismanoid 30:07197a430869 2381 action_trigger_SPIDeviceRegRead = 8,
whismanoid 17:9397ea3ea7e9 2382 } action_type_enum_t;
whismanoid 17:9397ea3ea7e9 2383 //
whismanoid 17:9397ea3ea7e9 2384 // Datalogger_RunActionTable() supported conditions
whismanoid 17:9397ea3ea7e9 2385 typedef enum action_condition_enum_t {
whismanoid 17:9397ea3ea7e9 2386 condition_always = 0, // ( true )
whismanoid 17:9397ea3ea7e9 2387 condition_if_An_gt_threshold, // (Platform_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2388 condition_if_An_lt_threshold, // (Platform_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2389 condition_if_An_eq_threshold, // (Platform_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2390 condition_if_An_ge_threshold, // (Platform_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2391 condition_if_An_le_threshold, // (Platform_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2392 condition_if_An_ne_threshold, // (Platform_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2393 condition_if_AINn_gt_threshold, // (SPI_AIN_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2394 condition_if_AINn_lt_threshold, // (SPI_AIN_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2395 condition_if_AINn_eq_threshold, // (SPI_AIN_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2396 condition_if_AINn_ge_threshold, // (SPI_AIN_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2397 condition_if_AINn_le_threshold, // (SPI_AIN_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2398 condition_if_AINn_ne_threshold, // (SPI_AIN_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2399 } condition_enum_t;
whismanoid 17:9397ea3ea7e9 2400 //
whismanoid 17:9397ea3ea7e9 2401 // Datalogger_RunActionTable() structure
whismanoid 17:9397ea3ea7e9 2402 typedef struct action_table_row_t {
whismanoid 17:9397ea3ea7e9 2403 action_type_enum_t action;
whismanoid 17:9397ea3ea7e9 2404 int digitalOutPin;
whismanoid 17:9397ea3ea7e9 2405 action_condition_enum_t condition;
whismanoid 17:9397ea3ea7e9 2406 int condition_channel;
whismanoid 17:9397ea3ea7e9 2407 double condition_threshold;
whismanoid 17:9397ea3ea7e9 2408 } action_table_row_t;
whismanoid 17:9397ea3ea7e9 2409 #if MAX40108_DEMO
whismanoid 39:4d285e961435 2410 # ifdef BOARD_SERIAL_NUMBER
whismanoid 39:4d285e961435 2411 // data unique to certain boards based on serial number
whismanoid 39:4d285e961435 2412 // channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 39:4d285e961435 2413 # if (BOARD_SERIAL_NUMBER) == 1
whismanoid 39:4d285e961435 2414 #warning "(BOARD_SERIAL_NUMBER) == 1 -- logic uses A3(CE) instead of A2(WE)"
whismanoid 39:4d285e961435 2415 const int channel_WE = 3; // use channel_CE instead on proto board s/n 1 for diagnostics; easier to sweep values
whismanoid 39:4d285e961435 2416 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 39:4d285e961435 2417 #warning "(BOARD_SERIAL_NUMBER) == 5 -- logic uses A3(CE) instead of A2(WE)"
whismanoid 39:4d285e961435 2418 const int channel_WE = 3; // use channel_CE instead on proto board s/n 1 for diagnostics; easier to sweep values
whismanoid 39:4d285e961435 2419 # else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 17:9397ea3ea7e9 2420 const int channel_WE = 2;
whismanoid 39:4d285e961435 2421 # endif
whismanoid 39:4d285e961435 2422 # endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 17:9397ea3ea7e9 2423 const double threshold_WE_0V5 = 0.5;
whismanoid 17:9397ea3ea7e9 2424 const double threshold_WE_0V6 = 0.6;
whismanoid 17:9397ea3ea7e9 2425 const double threshold_WE_0V7 = 0.7;
whismanoid 18:1235c17b451e 2426 const int pin_LED_1 = 91; // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 2427 const int pin_LED_2 = 92; // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 2428 const int pin_LED_3 = 93; // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 17:9397ea3ea7e9 2429 #endif
whismanoid 17:9397ea3ea7e9 2430 const int ACTION_TABLE_ROW_MAX = 20;
whismanoid 17:9397ea3ea7e9 2431 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2432 bool Datalogger_action_table_enabled = true;
whismanoid 45:74bf1fe021e5 2433 int Datalogger_action_table_row_count = 10; // assert (Datalogger_action_table_row_count <= ACTION_TABLE_ROW_MAX)
whismanoid 17:9397ea3ea7e9 2434 #else // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2435 int Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 2436 #endif // MAX40108_DEMO
whismanoid 45:74bf1fe021e5 2437 // configurable "business logic" for the data log
whismanoid 17:9397ea3ea7e9 2438 action_table_row_t Datalogger_action_table[ACTION_TABLE_ROW_MAX] = {
whismanoid 17:9397ea3ea7e9 2439 #if MAX40108_DEMO
whismanoid 45:74bf1fe021e5 2440 //
whismanoid 45:74bf1fe021e5 2441 // LED1 indicator on if (WE > 0.85V)
whismanoid 45:74bf1fe021e5 2442 // L@0 act=1 pin=91 if=1 ch=3 x=0.8500 -- digitalOutLow D91 if A3 > 0.85
whismanoid 45:74bf1fe021e5 2443 {action_digitalOutLow, pin_LED_1, condition_if_An_gt_threshold, channel_WE, 0.85},
whismanoid 45:74bf1fe021e5 2444 //
whismanoid 45:74bf1fe021e5 2445 // LED1 indicator off if (WE < 0.80V)
whismanoid 45:74bf1fe021e5 2446 // L@1 act=2 pin=91 if=2 ch=3 x=0.8000 -- digitalOutHigh D91 if A3 < 0.80
whismanoid 45:74bf1fe021e5 2447 {action_digitalOutHigh, pin_LED_1, condition_if_An_lt_threshold, channel_WE, 0.80},
whismanoid 45:74bf1fe021e5 2448 //
whismanoid 45:74bf1fe021e5 2449 // LED2 indicator on if (WE > 0.75V)
whismanoid 45:74bf1fe021e5 2450 // L@2 act=1 pin=92 if=1 ch=3 x=0.7500 -- digitalOutLow D92 if A3 > 0.75
whismanoid 45:74bf1fe021e5 2451 {action_digitalOutLow, pin_LED_2, condition_if_An_gt_threshold, channel_WE, 0.75},
whismanoid 17:9397ea3ea7e9 2452 //
whismanoid 45:74bf1fe021e5 2453 // LED2 indicator off if (WE < 0.70V)
whismanoid 45:74bf1fe021e5 2454 // L@3 act=2 pin=92 if=2 ch=3 x=0.7000 -- digitalOutHigh D92 if A3 < 0.70
whismanoid 45:74bf1fe021e5 2455 {action_digitalOutHigh, pin_LED_2, condition_if_An_lt_threshold, channel_WE, 0.70},
whismanoid 17:9397ea3ea7e9 2456 //
whismanoid 45:74bf1fe021e5 2457 // LED3 indicator on if (WE > 0.65V)
whismanoid 45:74bf1fe021e5 2458 // L@4 act=1 pin=93 if=1 ch=3 x=0.6500 -- digitalOutLow D93 if A3 > 0.65
whismanoid 45:74bf1fe021e5 2459 {action_digitalOutLow, pin_LED_3, condition_if_An_gt_threshold, channel_WE, 0.65},
whismanoid 45:74bf1fe021e5 2460 //
whismanoid 45:74bf1fe021e5 2461 // LED3 indicator off if (WE < 0.60V)
whismanoid 45:74bf1fe021e5 2462 // L@5 act=2 pin=93 if=2 ch=3 x=0.6000 -- digitalOutHigh D93 if A3 < 0.60
whismanoid 45:74bf1fe021e5 2463 {action_digitalOutHigh, pin_LED_3, condition_if_An_lt_threshold, channel_WE, 0.60},
whismanoid 45:74bf1fe021e5 2464 //
whismanoid 45:74bf1fe021e5 2465 // Free run if (WE > 0.70V)
whismanoid 45:74bf1fe021e5 2466 // L@6 act=5 if=1 ch=3 x=0.7000 -- LR if A3 > 0.70
whismanoid 17:9397ea3ea7e9 2467 {action_trigger_FreeRun, 0, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 17:9397ea3ea7e9 2468 //
whismanoid 45:74bf1fe021e5 2469 // Deep Sleep if (WE < 0.60V)
whismanoid 45:74bf1fe021e5 2470 // 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 2471 {action_trigger_Timer, 0, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 18:1235c17b451e 2472 //
whismanoid 45:74bf1fe021e5 2473 // Free run if (WE > 0.70V)
whismanoid 45:74bf1fe021e5 2474 // L@8 act=3 pin=4 if=1 ch=3 x=0.7000 -- button %B4! if A3 > 0.70
whismanoid 30:07197a430869 2475 {action_button, 4, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 29:6a9edb6e973b 2476 //
whismanoid 45:74bf1fe021e5 2477 // Deep Sleep if (WE < 0.60V)
whismanoid 45:74bf1fe021e5 2478 // L@9 act=3 pin=5 if=2 ch=3 x=0.6000 -- button %B5! if A3 < 0.60
whismanoid 30:07197a430869 2479 {action_button, 5, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 29:6a9edb6e973b 2480 //
whismanoid 17:9397ea3ea7e9 2481 #endif // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2482 //
whismanoid 17:9397ea3ea7e9 2483 {action_noop, 0, condition_always, 0, 0},
whismanoid 17:9397ea3ea7e9 2484 };
whismanoid 17:9397ea3ea7e9 2485 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2486
whismanoid 17:9397ea3ea7e9 2487 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2488 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 2489 uint8_t Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 2490 uint8_t need_reinit = true;
whismanoid 8:dffee7509bfb 2491 void Datalogger_PrintHeader(CmdLine& cmdLine);
whismanoid 5:aaf8b5f5fda1 2492 void Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 2493 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2494 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 2495 void Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 2496 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 8:dffee7509bfb 2497 void Datalogger_PrintRow(CmdLine& cmdLine);
whismanoid 4:d9b05924ad4c 2498
whismanoid 4:d9b05924ad4c 2499 //--------------------------------------------------
whismanoid 46:469d0061df5d 2500 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 2501 #if HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 2502 // WIP #312 flash_page_configuration_back_up[] records map to variables
whismanoid 46:469d0061df5d 2503 typedef struct {
whismanoid 46:469d0061df5d 2504 uint32_t recordType; // unique record type for each variable, 0 end of list, -1 blank record
whismanoid 46:469d0061df5d 2505 void* addr;
whismanoid 46:469d0061df5d 2506 uint32_t length_bytes;
whismanoid 46:469d0061df5d 2507 const char* name;
whismanoid 46:469d0061df5d 2508 } configuration_back_up_t;
whismanoid 46:469d0061df5d 2509 configuration_back_up_t configuration_back_up_list[] = {
whismanoid 46:469d0061df5d 2510 { 0xFFFFFFFF, NULL, 0, "blank" }, // Ignore 0xFFFFFFFF blank records
whismanoid 46:469d0061df5d 2511 { 0x08001053, &calibration_05_V[0], sizeof(calibration_05_V[0] ), "calibration_05_V[0]" },
whismanoid 46:469d0061df5d 2512 { 0x08001153, &calibration_05_V[1], sizeof(calibration_05_V[1] ), "calibration_05_V[1]" },
whismanoid 46:469d0061df5d 2513 { 0x08001253, &calibration_05_V[2], sizeof(calibration_05_V[2] ), "calibration_05_V[2]" },
whismanoid 46:469d0061df5d 2514 { 0x08001353, &calibration_05_V[3], sizeof(calibration_05_V[3] ), "calibration_05_V[3]" },
whismanoid 46:469d0061df5d 2515 { 0x08001453, &calibration_05_V[4], sizeof(calibration_05_V[4] ), "calibration_05_V[4]" },
whismanoid 46:469d0061df5d 2516 { 0x08001553, &calibration_05_V[5], sizeof(calibration_05_V[5] ), "calibration_05_V[5]" },
whismanoid 46:469d0061df5d 2517 { 0x08002053, &calibration_05_normValue_0_1[0], sizeof(calibration_05_normValue_0_1[0] ), "calibration_05_normValue_0_1[0]" },
whismanoid 46:469d0061df5d 2518 { 0x08002153, &calibration_05_normValue_0_1[1], sizeof(calibration_05_normValue_0_1[1] ), "calibration_05_normValue_0_1[1]" },
whismanoid 46:469d0061df5d 2519 { 0x08002253, &calibration_05_normValue_0_1[2], sizeof(calibration_05_normValue_0_1[2] ), "calibration_05_normValue_0_1[2]" },
whismanoid 46:469d0061df5d 2520 { 0x08002353, &calibration_05_normValue_0_1[3], sizeof(calibration_05_normValue_0_1[3] ), "calibration_05_normValue_0_1[3]" },
whismanoid 46:469d0061df5d 2521 { 0x08002453, &calibration_05_normValue_0_1[4], sizeof(calibration_05_normValue_0_1[4] ), "calibration_05_normValue_0_1[4]" },
whismanoid 46:469d0061df5d 2522 { 0x08002553, &calibration_05_normValue_0_1[5], sizeof(calibration_05_normValue_0_1[5] ), "calibration_05_normValue_0_1[5]" },
whismanoid 46:469d0061df5d 2523 { 0x08003053, &calibration_95_V[0], sizeof(calibration_95_V[0] ), "calibration_95_V[0]" },
whismanoid 46:469d0061df5d 2524 { 0x08003153, &calibration_95_V[1], sizeof(calibration_95_V[1] ), "calibration_95_V[1]" },
whismanoid 46:469d0061df5d 2525 { 0x08003253, &calibration_95_V[2], sizeof(calibration_95_V[2] ), "calibration_95_V[2]" },
whismanoid 46:469d0061df5d 2526 { 0x08003353, &calibration_95_V[3], sizeof(calibration_95_V[3] ), "calibration_95_V[3]" },
whismanoid 46:469d0061df5d 2527 { 0x08003453, &calibration_95_V[4], sizeof(calibration_95_V[4] ), "calibration_95_V[4]" },
whismanoid 46:469d0061df5d 2528 { 0x08003553, &calibration_95_V[5], sizeof(calibration_95_V[5] ), "calibration_95_V[5]" },
whismanoid 46:469d0061df5d 2529 { 0x08004053, &calibration_95_normValue_0_1[0], sizeof(calibration_95_normValue_0_1[0] ), "calibration_95_normValue_0_1[0]" },
whismanoid 46:469d0061df5d 2530 { 0x08004153, &calibration_95_normValue_0_1[1], sizeof(calibration_95_normValue_0_1[1] ), "calibration_95_normValue_0_1[1]" },
whismanoid 46:469d0061df5d 2531 { 0x08004253, &calibration_95_normValue_0_1[2], sizeof(calibration_95_normValue_0_1[2] ), "calibration_95_normValue_0_1[2]" },
whismanoid 46:469d0061df5d 2532 { 0x08004353, &calibration_95_normValue_0_1[3], sizeof(calibration_95_normValue_0_1[3] ), "calibration_95_normValue_0_1[3]" },
whismanoid 46:469d0061df5d 2533 { 0x08004453, &calibration_95_normValue_0_1[4], sizeof(calibration_95_normValue_0_1[4] ), "calibration_95_normValue_0_1[4]" },
whismanoid 46:469d0061df5d 2534 { 0x08004553, &calibration_95_normValue_0_1[5], sizeof(calibration_95_normValue_0_1[5] ), "calibration_95_normValue_0_1[5]" },
whismanoid 46:469d0061df5d 2535 // WIP #312 @L Datalogger_action_table_row_count
whismanoid 46:469d0061df5d 2536 // WIP #312 @L Datalogger_action_table_enabled
whismanoid 46:469d0061df5d 2537 // WIP #312 @L Datalogger_action_table[0] __ bytes
whismanoid 46:469d0061df5d 2538 // WIP #312 @L Datalogger_action_table[0] __ bytes
whismanoid 46:469d0061df5d 2539 // WIP #312 %B onButton1_command_table[0] __ bytes
whismanoid 46:469d0061df5d 2540 // WIP #312 %B onButton9_command_table[0] __ bytes
whismanoid 46:469d0061df5d 2541 { 0x00000000, NULL, 0, "wiped" }, // Ignore 0x00000000 wiped records; end of table
whismanoid 46:469d0061df5d 2542 };
whismanoid 46:469d0061df5d 2543 // WIP #312 store values into flash_page_configuration_back_up[] from calibration_05_V[] etc. Default save everything.
whismanoid 46:469d0061df5d 2544 // @param[in] save_arg 0x000000FF = erase flash file before saving values; 0xFFFFFF00 = filter items to save
whismanoid 46:469d0061df5d 2545 int Save_flash_page_configuration_back_up(CmdLine& cmdLine, uint32_t save_arg)
whismanoid 46:469d0061df5d 2546 {
whismanoid 46:469d0061df5d 2547 cmdLine.serial().printf("\r\nSave_flash_page_configuration_back_up(0x%8.8lx)...", save_arg);
whismanoid 46:469d0061df5d 2548 // WIP #312 %F save=save_arg could filter which items to append to flash file
whismanoid 46:469d0061df5d 2549 // initialize flash memory interface
whismanoid 46:469d0061df5d 2550 // FlashIAP: FlashIAP flash; flash.init();
whismanoid 46:469d0061df5d 2551 // int FLC_Init(void);
whismanoid 46:469d0061df5d 2552 // returns E_NO_ERROR or E_BUSY or E_UNKNOWN
whismanoid 46:469d0061df5d 2553 cmdLine.serial().printf("FLC_Init ");
whismanoid 46:469d0061df5d 2554 if (FLC_Init() != E_NO_ERROR)
whismanoid 46:469d0061df5d 2555 {
whismanoid 46:469d0061df5d 2556 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 2557 return 1; // can't perform the command
whismanoid 46:469d0061df5d 2558 }
whismanoid 46:469d0061df5d 2559 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 2560 //
whismanoid 46:469d0061df5d 2561
whismanoid 46:469d0061df5d 2562 uint32_t file_addr = (uint32_t)&flash_page_configuration_back_up[0];
whismanoid 46:469d0061df5d 2563 // uint32_t file_addr_end = file_addr + 8192 - 4;
whismanoid 46:469d0061df5d 2564 uint32_t file_addr_end = file_addr + 256 - 4; // development: reduce listing size
whismanoid 46:469d0061df5d 2565
whismanoid 46:469d0061df5d 2566 int poke_access_list_index = search_poke_access_list(file_addr);
whismanoid 46:469d0061df5d 2567 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 46:469d0061df5d 2568 poke_access_list_index,
whismanoid 46:469d0061df5d 2569 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 2570 poke_access_list[poke_access_list_index].addr_min,
whismanoid 46:469d0061df5d 2571 poke_access_list[poke_access_list_index].addr_max,
whismanoid 46:469d0061df5d 2572 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 46:469d0061df5d 2573 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 46:469d0061df5d 2574
whismanoid 46:469d0061df5d 2575 if ((save_arg & 0x000000FF) == 0xFF)
whismanoid 46:469d0061df5d 2576 {
whismanoid 46:469d0061df5d 2577 // erase flash file before saving configuration
whismanoid 46:469d0061df5d 2578 //
whismanoid 46:469d0061df5d 2579 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: erase page ...",
whismanoid 46:469d0061df5d 2580 poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 46:469d0061df5d 2581 // page erase using flash.erase(addr, flash.get_sector_size(addr));
whismanoid 46:469d0061df5d 2582 // int FLC_PageErase(uint32_t address, MXC_V_FLC_ERASE_CODE_PAGE_ERASE, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 2583 // @param address Address of the page to be erased.
whismanoid 46:469d0061df5d 2584 // @param erase_code Flash erase code; defined as
whismanoid 46:469d0061df5d 2585 // #MXC_V_FLC_ERASE_CODE_PAGE_ERASE for page erase
whismanoid 46:469d0061df5d 2586 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 2587 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 2588 if (FLC_PageErase(file_addr, MXC_V_FLC_ERASE_CODE_PAGE_ERASE,
whismanoid 46:469d0061df5d 2589 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 2590 {
whismanoid 46:469d0061df5d 2591 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 2592 return 1; // can't perform the command
whismanoid 46:469d0061df5d 2593 }
whismanoid 46:469d0061df5d 2594 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 2595 }
whismanoid 46:469d0061df5d 2596 // WIP #312: save_arg 0xFFFFFF00 = filter items to save
whismanoid 46:469d0061df5d 2597 // if (save_arg & 0xFFFFFF00 == _____)
whismanoid 46:469d0061df5d 2598 // {
whismanoid 46:469d0061df5d 2599 // }
whismanoid 46:469d0061df5d 2600
whismanoid 46:469d0061df5d 2601 // scan configuration_back_up_list[] for recordType
whismanoid 46:469d0061df5d 2602 for (int i = 0; configuration_back_up_list[i].recordType != 0x00000000; i++)
whismanoid 46:469d0061df5d 2603 {
whismanoid 46:469d0061df5d 2604 if (configuration_back_up_list[i].recordType == 0xFFFFFFFF) continue;
whismanoid 46:469d0061df5d 2605 //
whismanoid 46:469d0061df5d 2606 // configuration_back_up_list[i].recordType
whismanoid 46:469d0061df5d 2607 // configuration_back_up_list[i].addr
whismanoid 46:469d0061df5d 2608 // configuration_back_up_list[i].length_bytes
whismanoid 46:469d0061df5d 2609 // configuration_back_up_list[i].name
whismanoid 46:469d0061df5d 2610 // WIP #312 %F save=save_arg could filter which items to append to flash file
whismanoid 46:469d0061df5d 2611 //
whismanoid 46:469d0061df5d 2612 cmdLine.serial().printf("\r\n save 0x%8.8lx %s address 0x%8.8lx length 0x%lx bytes",
whismanoid 46:469d0061df5d 2613 configuration_back_up_list[i].recordType,
whismanoid 46:469d0061df5d 2614 configuration_back_up_list[i].name,
whismanoid 46:469d0061df5d 2615 (uint32_t)configuration_back_up_list[i].addr,
whismanoid 46:469d0061df5d 2616 configuration_back_up_list[i].length_bytes);
whismanoid 46:469d0061df5d 2617 //
whismanoid 46:469d0061df5d 2618 // find next free space to store record in flash file
whismanoid 46:469d0061df5d 2619 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 46:469d0061df5d 2620 cmdLine.serial().printf("0x%8.8lx ", *((uint32_t*)file_addr));
whismanoid 46:469d0061df5d 2621 while (*((uint32_t*)file_addr) != 0xFFFFFFFF)
whismanoid 46:469d0061df5d 2622 {
whismanoid 46:469d0061df5d 2623 if (file_addr >= file_addr_end)
whismanoid 46:469d0061df5d 2624 {
whismanoid 46:469d0061df5d 2625 return 1; // fail: no room to write file
whismanoid 46:469d0061df5d 2626 }
whismanoid 46:469d0061df5d 2627 file_addr = file_addr + 4;
whismanoid 46:469d0061df5d 2628 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx ",
whismanoid 46:469d0061df5d 2629 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 2630 file_addr,
whismanoid 46:469d0061df5d 2631 *((uint32_t*)file_addr)
whismanoid 46:469d0061df5d 2632 );
whismanoid 46:469d0061df5d 2633 }
whismanoid 46:469d0061df5d 2634 //
whismanoid 46:469d0061df5d 2635 // copy data from RAM into flash file
whismanoid 46:469d0061df5d 2636 // not_memcpy(file_addr + 4, configuration_back_up_list[i].addr, configuration_back_up_list[i].length_bytes);
whismanoid 46:469d0061df5d 2637 // pageBuf[0..3] = configuration_back_up_list[i].recordType;
whismanoid 46:469d0061df5d 2638 // pageBuf[4...] = configuration_back_up_list[i].addr, configuration_back_up_list[i].length_bytes
whismanoid 46:469d0061df5d 2639 // WIP #312: FLC_Write(...) in Save_flash_page_configuration_back_up
whismanoid 46:469d0061df5d 2640 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: write page buffer ...",
whismanoid 46:469d0061df5d 2641 poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 46:469d0061df5d 2642 // page write using flash.program(page_buffer, addr, page_size);
whismanoid 46:469d0061df5d 2643 // int FLC_Write(uint32_t address, const void *data, uint32_t length, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 2644 // @param address Start address for desired write. @note This address
whismanoid 46:469d0061df5d 2645 // must be 32-bit word aligned
whismanoid 46:469d0061df5d 2646 // @param data A pointer to the buffer containing the data to write.
whismanoid 46:469d0061df5d 2647 // @param length Size of the data to write in bytes. @note The length
whismanoid 46:469d0061df5d 2648 // must be in 32-bit multiples.
whismanoid 46:469d0061df5d 2649 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 2650 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 2651 if (FLC_Write(file_addr,
whismanoid 46:469d0061df5d 2652 (uint32_t*)(&configuration_back_up_list[i].recordType),
whismanoid 46:469d0061df5d 2653 sizeof(uint32_t),
whismanoid 46:469d0061df5d 2654 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 2655 {
whismanoid 46:469d0061df5d 2656 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 2657 break; // can't perform the command
whismanoid 46:469d0061df5d 2658 }
whismanoid 46:469d0061df5d 2659 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 2660 if (FLC_Write(file_addr + 4,
whismanoid 46:469d0061df5d 2661 (uint32_t*)(configuration_back_up_list[i].addr),
whismanoid 46:469d0061df5d 2662 configuration_back_up_list[i].length_bytes,
whismanoid 46:469d0061df5d 2663 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 2664 {
whismanoid 46:469d0061df5d 2665 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 2666 break; // can't perform the command
whismanoid 46:469d0061df5d 2667 }
whismanoid 46:469d0061df5d 2668 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 2669 // advance to next 16-byte-aligned record start address
whismanoid 46:469d0061df5d 2670 file_addr = (file_addr + configuration_back_up_list[i].length_bytes + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 2671 } // end for each configuration_back_up_list[...]
whismanoid 46:469d0061df5d 2672 return 0;
whismanoid 46:469d0061df5d 2673 } // end Save_flash_page_configuration_back_up
whismanoid 46:469d0061df5d 2674 // WIP #312 load values from flash_page_configuration_back_up[] into calibration_05_V[] etc. Default load everything.
whismanoid 46:469d0061df5d 2675 int Load_flash_page_configuration_back_up(CmdLine& cmdLine, uint32_t load_arg)
whismanoid 46:469d0061df5d 2676 {
whismanoid 46:469d0061df5d 2677 cmdLine.serial().printf("\r\nLoad_flash_page_configuration_back_up(0x%8.8lx)...", load_arg);
whismanoid 46:469d0061df5d 2678 // WIP #312 %F load=load_arg could filter which items to accept from flash file
whismanoid 46:469d0061df5d 2679
whismanoid 46:469d0061df5d 2680 uint32_t file_addr = (uint32_t)&flash_page_configuration_back_up[0];
whismanoid 46:469d0061df5d 2681 // uint32_t file_addr_end = file_addr + 8192 - 4; // last record at 0x00027ff0
whismanoid 46:469d0061df5d 2682 // uint32_t file_addr_end = file_addr + 256 - 4; // development: reduce listing size -- last record at 0x000260f0
whismanoid 46:469d0061df5d 2683 uint32_t file_addr_end = file_addr + 512 - 4; // development: reduce listing size -- last record at 0x000261f0
whismanoid 46:469d0061df5d 2684
whismanoid 46:469d0061df5d 2685 // diagnostic print
whismanoid 46:469d0061df5d 2686 int poke_access_list_index = search_poke_access_list(file_addr);
whismanoid 46:469d0061df5d 2687 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 46:469d0061df5d 2688 poke_access_list_index,
whismanoid 46:469d0061df5d 2689 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 2690 poke_access_list[poke_access_list_index].addr_min,
whismanoid 46:469d0061df5d 2691 poke_access_list[poke_access_list_index].addr_max,
whismanoid 46:469d0061df5d 2692 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 46:469d0061df5d 2693 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, file_addr);
whismanoid 46:469d0061df5d 2694
whismanoid 46:469d0061df5d 2695 // Scan backup configuration file
whismanoid 46:469d0061df5d 2696 while (file_addr < file_addr_end)
whismanoid 46:469d0061df5d 2697 {
whismanoid 46:469d0061df5d 2698 // diagnostic print
whismanoid 46:469d0061df5d 2699 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx ",
whismanoid 46:469d0061df5d 2700 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 2701 file_addr,
whismanoid 46:469d0061df5d 2702 *((uint32_t*)file_addr));
whismanoid 46:469d0061df5d 2703
whismanoid 46:469d0061df5d 2704 // address of next 16-byte-aligned record start address
whismanoid 46:469d0061df5d 2705 uint32_t file_addr_next = (file_addr + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 2706
whismanoid 46:469d0061df5d 2707 // scan configuration_back_up_list[] to decode recordType
whismanoid 46:469d0061df5d 2708 for (int i = 0; configuration_back_up_list[i].recordType != 0x00000000; i++)
whismanoid 46:469d0061df5d 2709 {
whismanoid 46:469d0061df5d 2710 // configuration_back_up_list[i].recordType
whismanoid 46:469d0061df5d 2711 // configuration_back_up_list[i].addr
whismanoid 46:469d0061df5d 2712 // configuration_back_up_list[i].length_bytes
whismanoid 46:469d0061df5d 2713 // configuration_back_up_list[i].name
whismanoid 46:469d0061df5d 2714 //
whismanoid 46:469d0061df5d 2715 uint32_t file_addr_recordType = file_addr;
whismanoid 46:469d0061df5d 2716 uint32_t file_addr_recordData = file_addr + 1;
whismanoid 46:469d0061df5d 2717 // uint32_t file_addr_recordNext = (file_addr + configuration_back_up_list[i].length_bytes) & ______;
whismanoid 46:469d0061df5d 2718 if (configuration_back_up_list[i].recordType == *((uint32_t*)file_addr_recordType))
whismanoid 46:469d0061df5d 2719 {
whismanoid 46:469d0061df5d 2720 if ((configuration_back_up_list[i].addr == 0) ||
whismanoid 46:469d0061df5d 2721 (configuration_back_up_list[i].length_bytes==0))
whismanoid 46:469d0061df5d 2722 {
whismanoid 46:469d0061df5d 2723 break; // Ignore blank record, stop searching
whismanoid 46:469d0061df5d 2724 }
whismanoid 46:469d0061df5d 2725 // found a matching recordHeader
whismanoid 46:469d0061df5d 2726 // diagnostic print
whismanoid 46:469d0061df5d 2727 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx load %s",
whismanoid 46:469d0061df5d 2728 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 2729 file_addr,
whismanoid 46:469d0061df5d 2730 *((uint32_t*)file_addr),
whismanoid 46:469d0061df5d 2731 configuration_back_up_list[i].name
whismanoid 46:469d0061df5d 2732 );
whismanoid 46:469d0061df5d 2733 for (int j = 0; j <= configuration_back_up_list[i].length_bytes; j += 4)
whismanoid 46:469d0061df5d 2734 {
whismanoid 46:469d0061df5d 2735 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: 0x%8.8lx",
whismanoid 46:469d0061df5d 2736 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 2737 (file_addr + 4 + j),
whismanoid 46:469d0061df5d 2738 *((uint32_t*)(file_addr + 4 + j))
whismanoid 46:469d0061df5d 2739 );
whismanoid 46:469d0061df5d 2740 }
whismanoid 46:469d0061df5d 2741 // cmdLine.serial().printf("\r\n load %s 0x%8.8lx length 0x%lx address 0x%8.8lx",
whismanoid 46:469d0061df5d 2742 // configuration_back_up_list[i].name,
whismanoid 46:469d0061df5d 2743 // configuration_back_up_list[i].recordType,
whismanoid 46:469d0061df5d 2744 // configuration_back_up_list[i].length_bytes,
whismanoid 46:469d0061df5d 2745 // (uint32_t)configuration_back_up_list[i].addr,
whismanoid 46:469d0061df5d 2746 // );
whismanoid 46:469d0061df5d 2747 // cmdLine.serial().printf("\r\n load %s 0x%8.8lx length 0x%lx address 0x%8.8lx",
whismanoid 46:469d0061df5d 2748 // configuration_back_up_list[i].name,
whismanoid 46:469d0061df5d 2749 // configuration_back_up_list[i].recordType,
whismanoid 46:469d0061df5d 2750 // configuration_back_up_list[i].length_bytes,
whismanoid 46:469d0061df5d 2751 // (uint32_t)configuration_back_up_list[i].addr,
whismanoid 46:469d0061df5d 2752 // );
whismanoid 46:469d0061df5d 2753 //
whismanoid 46:469d0061df5d 2754 // WIP #312: copy data from flash file into RAM in Load_flash_page_configuration_back_up
whismanoid 46:469d0061df5d 2755 memcpy(configuration_back_up_list[i].addr,
whismanoid 46:469d0061df5d 2756 (const void *)(file_addr + 4),
whismanoid 46:469d0061df5d 2757 configuration_back_up_list[i].length_bytes);
whismanoid 46:469d0061df5d 2758 //
whismanoid 46:469d0061df5d 2759 // advance to next 16-byte-aligned record start address
whismanoid 46:469d0061df5d 2760 file_addr_next = (file_addr + configuration_back_up_list[i].length_bytes + 16) &~ 0x0000000F;
whismanoid 46:469d0061df5d 2761 break; // stop searching
whismanoid 46:469d0061df5d 2762 } // end if match recordType
whismanoid 46:469d0061df5d 2763 } // end for each configuration_back_up_list[...]
whismanoid 46:469d0061df5d 2764 // advance to next 16-byte-aligned record start address
whismanoid 46:469d0061df5d 2765 file_addr = file_addr_next;
whismanoid 46:469d0061df5d 2766 } // end while (file_addr < file_addr_end)
whismanoid 46:469d0061df5d 2767 return 0;
whismanoid 46:469d0061df5d 2768 } // end Load_flash_page_configuration_back_up
whismanoid 46:469d0061df5d 2769 #endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 2770
whismanoid 46:469d0061df5d 2771 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 2772 // Option to validate SPI link by reading PART_ID register
whismanoid 0:cb44e2e9ec4c 2773 #ifndef VERIFY_PART_ID_IN_LOOP
whismanoid 3:9055e17e181a 2774 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 2775 #define VERIFY_PART_ID_IN_LOOP 1
whismanoid 3:9055e17e181a 2776 #else
whismanoid 0:cb44e2e9ec4c 2777 #define VERIFY_PART_ID_IN_LOOP 0
whismanoid 3:9055e17e181a 2778 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2779 #endif
whismanoid 0:cb44e2e9ec4c 2780
whismanoid 3:9055e17e181a 2781 //--------------------------------------------------
whismanoid 3:9055e17e181a 2782 #define NUM_DUT_ANALOG_IN_CHANNELS 10
whismanoid 3:9055e17e181a 2783
whismanoid 3:9055e17e181a 2784 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 2785 // MAX11410 individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 3:9055e17e181a 2786 typedef enum SPI_AIN_Enable_t {
whismanoid 10:04022a61b527 2787 SPI_AIN_Disable = 0,
whismanoid 10:04022a61b527 2788 SPI_AIN_Enable_LSB = 1,
whismanoid 10:04022a61b527 2789 SPI_AIN_Enable_Volt = 2,
whismanoid 3:9055e17e181a 2790 } SPI_AIN_Enable_t;
whismanoid 3:9055e17e181a 2791 uint8_t SPI_AIN_Enable_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 2792 SPI_AIN_Enable_LSB, // AIN0 1=LSB
whismanoid 10:04022a61b527 2793 SPI_AIN_Enable_LSB, // AIN1 1=LSB
whismanoid 10:04022a61b527 2794 SPI_AIN_Enable_LSB, // AIN2 1=LSB
whismanoid 10:04022a61b527 2795 SPI_AIN_Enable_LSB, // AIN3 1=LSB
whismanoid 10:04022a61b527 2796 SPI_AIN_Enable_LSB, // AIN4 1=LSB
whismanoid 10:04022a61b527 2797 SPI_AIN_Enable_LSB, // AIN5 1=LSB
whismanoid 10:04022a61b527 2798 SPI_AIN_Enable_LSB, // AIN6 1=LSB
whismanoid 10:04022a61b527 2799 SPI_AIN_Enable_LSB, // AIN7 1=LSB
whismanoid 10:04022a61b527 2800 SPI_AIN_Enable_LSB, // AIN8 1=LSB
whismanoid 10:04022a61b527 2801 SPI_AIN_Enable_LSB, // AIN9 1=LSB
whismanoid 3:9055e17e181a 2802 };
whismanoid 3:9055e17e181a 2803 //
whismanoid 10:04022a61b527 2804 double SPI_AIN_Voltage[NUM_DUT_ANALOG_IN_CHANNELS];
whismanoid 13:184a08909405 2805 // Optional custom per-channel header suffix
whismanoid 45:74bf1fe021e5 2806 // This could be used to identify external hardware attached to each input
whismanoid 13:184a08909405 2807 #ifndef HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 2808 #define HAS_SPI_AIN_customChannelHeader 0
whismanoid 13:184a08909405 2809 #endif
whismanoid 13:184a08909405 2810 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2811 const char* const SPI_AIN_customChannelHeader_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 2812 "", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 2813 "", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 2814 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 2815 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 2816 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 2817 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 2818 };
whismanoid 13:184a08909405 2819 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 3:9055e17e181a 2820 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2821 // ---------- Measure_Voltage_custom_props in Measure_Voltage @pre and in class properties ----------
whismanoid 3:9055e17e181a 2822 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 2823 // MAX11410 specific per-channel config register v_filter
whismanoid 3:9055e17e181a 2824 uint8_t SPI_AIN_Cfg_v_filter_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2825 0x34, // AIN0 @ v_filter=0x34
whismanoid 3:9055e17e181a 2826 0x34, // AIN1 @ v_filter=0x34
whismanoid 3:9055e17e181a 2827 0x34, // AIN2 @ v_filter=0x34
whismanoid 3:9055e17e181a 2828 0x34, // AIN3 @ v_filter=0x34
whismanoid 3:9055e17e181a 2829 0x34, // AIN4 @ v_filter=0x34
whismanoid 3:9055e17e181a 2830 0x34, // AIN5 @ v_filter=0x34
whismanoid 3:9055e17e181a 2831 0x34, // AIN6 @ v_filter=0x34
whismanoid 3:9055e17e181a 2832 0x34, // AIN7 @ v_filter=0x34
whismanoid 3:9055e17e181a 2833 0x34, // AIN8 @ v_filter=0x34
whismanoid 3:9055e17e181a 2834 0x34, // AIN9 @ v_filter=0x34
whismanoid 3:9055e17e181a 2835 };
whismanoid 3:9055e17e181a 2836 //
whismanoid 4:d9b05924ad4c 2837 // MAX11410 specific per-channel config register v_ctrl
whismanoid 3:9055e17e181a 2838 uint8_t SPI_AIN_Cfg_v_ctrl_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2839 0x42, // AIN0 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2840 0x42, // AIN1 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2841 0x42, // AIN2 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2842 0x42, // AIN3 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2843 0x42, // AIN4 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2844 0x42, // AIN5 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2845 0x42, // AIN6 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2846 0x42, // AIN7 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2847 0x42, // AIN8 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2848 0x42, // AIN9 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2849 };
whismanoid 3:9055e17e181a 2850 //
whismanoid 4:d9b05924ad4c 2851 // MAX11410 specific per-channel config register v_pga
whismanoid 3:9055e17e181a 2852 uint8_t SPI_AIN_Cfg_v_pga_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2853 0x00, // AIN0 @ v_pga=0x00
whismanoid 3:9055e17e181a 2854 0x00, // AIN1 @ v_pga=0x00
whismanoid 3:9055e17e181a 2855 0x00, // AIN2 @ v_pga=0x00
whismanoid 3:9055e17e181a 2856 0x00, // AIN3 @ v_pga=0x00
whismanoid 3:9055e17e181a 2857 0x00, // AIN4 @ v_pga=0x00
whismanoid 3:9055e17e181a 2858 0x00, // AIN5 @ v_pga=0x00
whismanoid 3:9055e17e181a 2859 0x00, // AIN6 @ v_pga=0x00
whismanoid 3:9055e17e181a 2860 0x00, // AIN7 @ v_pga=0x00
whismanoid 3:9055e17e181a 2861 0x00, // AIN8 @ v_pga=0x00
whismanoid 3:9055e17e181a 2862 0x00, // AIN9 @ v_pga=0x00
whismanoid 3:9055e17e181a 2863 };
whismanoid 3:9055e17e181a 2864 //
whismanoid 3:9055e17e181a 2865 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2866 // ---------- Measure_Voltage_custom_props ----------
whismanoid 0:cb44e2e9ec4c 2867 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2868 // filter register configuration in Measure_Voltage and Read_All_Voltages CONV_TYPE_01_Continuous
whismanoid 0:cb44e2e9ec4c 2869 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 2870 //~ const uint8_t custom_v_filter = 0x00; // @ v_filter=0x00 -- LINEF_00_50Hz_60Hz_FIR RATE_0000 | 1.1SPS
whismanoid 0:cb44e2e9ec4c 2871 //~ const uint8_t custom_v_filter = 0x01; // @ v_filter=0x01 -- LINEF_00_50Hz_60Hz_FIR RATE_0001 | 2.1SPS
whismanoid 0:cb44e2e9ec4c 2872 //~ const uint8_t custom_v_filter = 0x02; // @ v_filter=0x02 -- LINEF_00_50Hz_60Hz_FIR RATE_0010 | 4.2SPS
whismanoid 0:cb44e2e9ec4c 2873 //~ const uint8_t custom_v_filter = 0x03; // @ v_filter=0x03 -- LINEF_00_50Hz_60Hz_FIR RATE_0011 | 8.4SPS
whismanoid 0:cb44e2e9ec4c 2874 //~ const uint8_t custom_v_filter = 0x04; // @ v_filter=0x04 -- LINEF_00_50Hz_60Hz_FIR RATE_0100 | 16.8SPS
whismanoid 0:cb44e2e9ec4c 2875 //~ const uint8_t custom_v_filter = 0x10; // @ v_filter=0x10 -- LINEF_01_50Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 2876 //~ const uint8_t custom_v_filter = 0x11; // @ v_filter=0x11 -- LINEF_01_50Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 2877 //~ const uint8_t custom_v_filter = 0x12; // @ v_filter=0x12 -- LINEF_01_50Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 2878 //~ const uint8_t custom_v_filter = 0x13; // @ v_filter=0x13 -- LINEF_01_50Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 2879 //~ const uint8_t custom_v_filter = 0x14; // @ v_filter=0x14 -- LINEF_01_50Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 2880 //~ const uint8_t custom_v_filter = 0x15; // @ v_filter=0x15 -- LINEF_01_50Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 2881 //~ const uint8_t custom_v_filter = 0x20; // @ v_filter=0x20 -- LINEF_10_60Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 2882 //~ const uint8_t custom_v_filter = 0x21; // @ v_filter=0x21 -- LINEF_10_60Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 2883 //~ const uint8_t custom_v_filter = 0x22; // @ v_filter=0x22 -- LINEF_10_60Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 2884 //~ const uint8_t custom_v_filter = 0x23; // @ v_filter=0x23 -- LINEF_10_60Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 2885 //~ const uint8_t custom_v_filter = 0x24; // @ v_filter=0x24 -- LINEF_10_60Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 2886 //~ const uint8_t custom_v_filter = 0x25; // @ v_filter=0x25 -- LINEF_10_60Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 2887 //~ const uint8_t custom_v_filter = 0x30; // @ v_filter=0x30 -- LINEF_11_SINC4 RATE_0000 | 4SPS
whismanoid 0:cb44e2e9ec4c 2888 //~ const uint8_t custom_v_filter = 0x31; // @ v_filter=0x31 -- LINEF_11_SINC4 RATE_0001 | 10SPS
whismanoid 0:cb44e2e9ec4c 2889 //~ const uint8_t custom_v_filter = 0x32; // @ v_filter=0x32 -- LINEF_11_SINC4 RATE_0010 | 20SPS
whismanoid 0:cb44e2e9ec4c 2890 //~ const uint8_t custom_v_filter = 0x33; // @ v_filter=0x33 -- LINEF_11_SINC4 RATE_0011 | 40SPS
whismanoid 0:cb44e2e9ec4c 2891 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 2892 //~ const uint8_t custom_v_filter = 0x35; // @ v_filter=0x35 -- LINEF_11_SINC4 RATE_0101 | 120SPS
whismanoid 0:cb44e2e9ec4c 2893 //~ const uint8_t custom_v_filter = 0x36; // @ v_filter=0x36 -- LINEF_11_SINC4 RATE_0110 | 240SPS
whismanoid 0:cb44e2e9ec4c 2894 //~ const uint8_t custom_v_filter = 0x37; // @ v_filter=0x37 -- LINEF_11_SINC4 RATE_0111 | 480SPS
whismanoid 0:cb44e2e9ec4c 2895 //~ const uint8_t custom_v_filter = 0x38; // @ v_filter=0x38 -- LINEF_11_SINC4 RATE_1000 | 960SPS
whismanoid 0:cb44e2e9ec4c 2896 //~ const uint8_t custom_v_filter = 0x39; // @ v_filter=0x39 -- LINEF_11_SINC4 RATE_1001 | 1920SPS
whismanoid 0:cb44e2e9ec4c 2897 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2898 //
whismanoid 0:cb44e2e9ec4c 2899 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2900 // pga register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 0:cb44e2e9ec4c 2901 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 2902 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 2903 //~ const uint8_t custom_v_pga = 0x10; // @ v_pga=0x10 -- 0x10 SIG_PATH_01_BYPASS
whismanoid 0:cb44e2e9ec4c 2904 //~ const uint8_t custom_v_pga = 0x20; // @ v_pga=0x20 -- 0x20 SIG_PATH_10_PGA GAIN_000_1
whismanoid 0:cb44e2e9ec4c 2905 //~ const uint8_t custom_v_pga = 0x21; // @ v_pga=0x21 --*0x21 SIG_PATH_10_PGA GAIN_001_2
whismanoid 0:cb44e2e9ec4c 2906 //~ const uint8_t custom_v_pga = 0x22; // @ v_pga=0x22 -- 0x22 SIG_PATH_10_PGA GAIN_010_4
whismanoid 0:cb44e2e9ec4c 2907 //~ const uint8_t custom_v_pga = 0x23; // @ v_pga=0x23 -- 0x23 SIG_PATH_10_PGA GAIN_011_8
whismanoid 0:cb44e2e9ec4c 2908 //~ const uint8_t custom_v_pga = 0x24; // @ v_pga=0x24 -- 0x24 SIG_PATH_10_PGA GAIN_100_16
whismanoid 0:cb44e2e9ec4c 2909 //~ const uint8_t custom_v_pga = 0x25; // @ v_pga=0x25 -- 0x25 SIG_PATH_10_PGA GAIN_101_32
whismanoid 0:cb44e2e9ec4c 2910 //~ const uint8_t custom_v_pga = 0x26; // @ v_pga=0x26 -- 0x26 SIG_PATH_10_PGA GAIN_110_64
whismanoid 0:cb44e2e9ec4c 2911 //~ const uint8_t custom_v_pga = 0x27; // @ v_pga=0x27 -- 0x27 SIG_PATH_10_PGA GAIN_111_128
whismanoid 0:cb44e2e9ec4c 2912 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2913 //
whismanoid 0:cb44e2e9ec4c 2914 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2915 // ctrl register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 3:9055e17e181a 2916 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2917 //~ const uint8_t custom_v_ctrl = 0x40; // @ v_ctrl=0x40 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1
whismanoid 0:cb44e2e9ec4c 2918 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 2919 //~ const uint8_t custom_v_ctrl = 0x58; // @ v_ctrl=0x58 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 2920 //
whismanoid 0:cb44e2e9ec4c 2921 //~ const uint8_t custom_v_ctrl = 0x41; // @ v_ctrl=0x41 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N
whismanoid 0:cb44e2e9ec4c 2922 //~ const uint8_t custom_v_ctrl = 0x45; // @ v_ctrl=0x45 -- 0x40 unipolar, 0x05 REF_SEL_101_REF1P_AGND
whismanoid 0:cb44e2e9ec4c 2923 //~ const uint8_t custom_v_ctrl = 0x59; // @ v_ctrl=0x59 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 2924 //
whismanoid 0:cb44e2e9ec4c 2925 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2926 //~ const uint8_t custom_v_ctrl = 0x46; // @ v_ctrl=0x46 -- 0x40 unipolar, 0x06 REF_SEL_110_REF2P_AGND
whismanoid 0:cb44e2e9ec4c 2927 //~ const uint8_t custom_v_ctrl = 0x22; // @ v_ctrl=0x22 -- 0x20 bipolar offset binary, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2928 //~ const uint8_t custom_v_ctrl = 0x02; // @ v_ctrl=0x02 -- 0x00 bipolar 2's complement, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2929 //
whismanoid 0:cb44e2e9ec4c 2930 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 2931 //~ const uint8_t custom_v_ctrl = 0x47; // @ v_ctrl=0x47 -- 0x40 unipolar, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2932 //~ const uint8_t custom_v_ctrl = 0x27; // @ v_ctrl=0x27 -- 0x20 bipolar offset binary, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2933 //~ const uint8_t custom_v_ctrl = 0x07; // @ v_ctrl=0x07 -- 0x00 bipolar 2's complement, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2934 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2935
whismanoid 3:9055e17e181a 2936 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2937 // example code declare SPI interface (GPIO controlled CS)
whismanoid 0:cb44e2e9ec4c 2938 #if defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 2939 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 2940 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
whismanoid 19:5ff09c8e9daf 2941 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 2942 #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 2943 SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625PICO: pin P0_5 P0_6 P0_4
whismanoid 0:cb44e2e9ec4c 2944 DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32625PICO: pin P0_7
whismanoid 0:cb44e2e9ec4c 2945 #elif defined(TARGET_MAX32600MBED)
whismanoid 0:cb44e2e9ec4c 2946 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 0:cb44e2e9ec4c 2947 DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2948 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 2949 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 2950 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:cb44e2e9ec4c 2951 //
whismanoid 0:cb44e2e9ec4c 2952 // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses.
whismanoid 0:cb44e2e9ec4c 2953 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 2954 DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2955 //
whismanoid 0:cb44e2e9ec4c 2956 #else
whismanoid 3:9055e17e181a 2957 SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 3:9055e17e181a 2958 DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2959 #endif
whismanoid 0:cb44e2e9ec4c 2960
whismanoid 0:cb44e2e9ec4c 2961 // example code declare GPIO interface pins
whismanoid 0:cb44e2e9ec4c 2962 // example code declare device instance
whismanoid 3:9055e17e181a 2963 MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC);
whismanoid 3:9055e17e181a 2964 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2965
whismanoid 1:747f1602abfc 2966 //--------------------------------------------------
whismanoid 3:9055e17e181a 2967 // Option to Datalog Arduino platform analog inputs
whismanoid 3:9055e17e181a 2968 #ifndef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 2969 #define LOG_PLATFORM_AIN 6
whismanoid 3:9055e17e181a 2970 //~ #undef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 2971 #endif
whismanoid 3:9055e17e181a 2972 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 1:747f1602abfc 2973 //#ifndef NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 1:747f1602abfc 2974 //#define NUM_PLATFORM_ANALOG_IN_CHANNELS 6
whismanoid 1:747f1602abfc 2975 //#endif
whismanoid 1:747f1602abfc 2976 const int NUM_PLATFORM_ANALOG_IN_CHANNELS = 6;
whismanoid 1:747f1602abfc 2977 const double adc_full_scale_voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 2978 analogInPin_fullScaleVoltage[0], // 1.2,
whismanoid 10:04022a61b527 2979 analogInPin_fullScaleVoltage[1], // 1.2,
whismanoid 10:04022a61b527 2980 analogInPin_fullScaleVoltage[2], // 1.2,
whismanoid 10:04022a61b527 2981 analogInPin_fullScaleVoltage[3], // 1.2,
whismanoid 10:04022a61b527 2982 analogInPin_fullScaleVoltage[4], // 6.0
whismanoid 10:04022a61b527 2983 analogInPin_fullScaleVoltage[5], // 6.0
whismanoid 0:cb44e2e9ec4c 2984 };
whismanoid 9:45f98573eb6d 2985 // Platform ADC individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 9:45f98573eb6d 2986 typedef enum Platform_AIN_Enable_t {
whismanoid 9:45f98573eb6d 2987 Platform_AIN_Disable = 0,
whismanoid 9:45f98573eb6d 2988 Platform_AIN_Enable_LSB = 1,
whismanoid 9:45f98573eb6d 2989 Platform_AIN_Enable_Volt = 2,
whismanoid 9:45f98573eb6d 2990 } Platform_AIN_Enable_t;
whismanoid 13:184a08909405 2991 uint8_t Platform_Enable_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 9:45f98573eb6d 2992 Platform_AIN_Enable_Volt, // AIN0 2=Volt
whismanoid 9:45f98573eb6d 2993 Platform_AIN_Enable_Volt, // AIN1 2=Volt
whismanoid 9:45f98573eb6d 2994 Platform_AIN_Enable_Volt, // AIN2 2=Volt
whismanoid 9:45f98573eb6d 2995 Platform_AIN_Enable_Volt, // AIN3 2=Volt
whismanoid 9:45f98573eb6d 2996 Platform_AIN_Enable_Volt, // AIN4 2=Volt
whismanoid 9:45f98573eb6d 2997 Platform_AIN_Enable_Volt, // AIN5 2=Volt
whismanoid 9:45f98573eb6d 2998 };
whismanoid 37:3f369235e5bc 2999 // Option to report average value of Arduino platform analog inputs
whismanoid 37:3f369235e5bc 3000 #ifndef USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3001 #define USE_Platform_AIN_Average 1
whismanoid 37:3f369235e5bc 3002 //~ #undef USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3003 #endif
whismanoid 37:3f369235e5bc 3004 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3005 #endif // USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3006 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3007 int Platform_AIN_Average_N = 16;
whismanoid 37:3f369235e5bc 3008 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 3009 // Option to apply calibration to Arduino platform analog inputs
whismanoid 34:a1993a1ee904 3010 #ifndef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3011 #define HAS_Platform_AIN_Calibration 1
whismanoid 34:a1993a1ee904 3012 //~ #undef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3013 #endif
whismanoid 34:a1993a1ee904 3014 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3015 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 3016 // Calibration is between two points for each channel, defined by
whismanoid 34:a1993a1ee904 3017 // a normalized value between 0% and 100%, and the corresponding voltage.
whismanoid 34:a1993a1ee904 3018 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 3019 // calibration_05_normValue_0_1, calibration_05_V should be around 5% or 25%
whismanoid 42:89607d5d4e6d 3020 extern double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 42:89607d5d4e6d 3021 extern double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 34:a1993a1ee904 3022 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 3023 // calibration_95_normValue_0_1, calibration_95_V should be around 95% or 75%
whismanoid 42:89607d5d4e6d 3024 extern double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 42:89607d5d4e6d 3025 extern double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 34:a1993a1ee904 3026 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3027 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3028 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1)
whismanoid 34:a1993a1ee904 3029 {
whismanoid 34:a1993a1ee904 3030 // TODO: return corrected normValue_0_1 using two-point linear calibration
whismanoid 34:a1993a1ee904 3031 // point 1: calibration_05_normValue_0_1[ch], calibration_05_V[ch]
whismanoid 34:a1993a1ee904 3032 // point 2: calibration_95_normValue_0_1[ch], calibration_95_V[ch]
whismanoid 34:a1993a1ee904 3033 // validate that there is enough span to get sensible results
whismanoid 34:a1993a1ee904 3034 //
whismanoid 34:a1993a1ee904 3035 int ch = channel_0_5;
whismanoid 34:a1993a1ee904 3036 // 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 3037 // ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 3038 // ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 3039 // ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 3040 // ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 3041 // );
whismanoid 34:a1993a1ee904 3042 // cmdLine.serial().printf("\r\n adc_full_scale_voltage[%d] = %1.6fV",
whismanoid 34:a1993a1ee904 3043 // ch,
whismanoid 34:a1993a1ee904 3044 // adc_full_scale_voltage[ch]
whismanoid 34:a1993a1ee904 3045 // );
whismanoid 34:a1993a1ee904 3046 // raw normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 3047 double raw_05_normValue = calibration_05_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 3048 double raw_95_normValue = calibration_95_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 3049 // calibrated normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 3050 // divide V/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 3051 double cal_05_normValue = calibration_05_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 3052 double cal_95_normValue = calibration_95_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 3053 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_05_normValue = %1.6f",
whismanoid 34:a1993a1ee904 3054 // ch,
whismanoid 34:a1993a1ee904 3055 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3056 // cal_05_normValue
whismanoid 34:a1993a1ee904 3057 // );
whismanoid 34:a1993a1ee904 3058 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_95_normValue = %1.6f",
whismanoid 34:a1993a1ee904 3059 // ch,
whismanoid 34:a1993a1ee904 3060 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3061 // cal_95_normValue
whismanoid 34:a1993a1ee904 3062 // );
whismanoid 34:a1993a1ee904 3063 //
whismanoid 34:a1993a1ee904 3064 double span_raw = raw_95_normValue - raw_05_normValue;
whismanoid 34:a1993a1ee904 3065 double span_cal = cal_95_normValue - cal_05_normValue;
whismanoid 34:a1993a1ee904 3066 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_raw = %1.6f",
whismanoid 34:a1993a1ee904 3067 // ch,
whismanoid 34:a1993a1ee904 3068 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3069 // span_raw
whismanoid 34:a1993a1ee904 3070 // );
whismanoid 34:a1993a1ee904 3071 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_cal = %1.6f",
whismanoid 34:a1993a1ee904 3072 // ch,
whismanoid 34:a1993a1ee904 3073 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3074 // span_cal
whismanoid 34:a1993a1ee904 3075 // );
whismanoid 34:a1993a1ee904 3076 // if calibration is not valid, return unmodified normValue_0_1 and print a warning
whismanoid 34:a1993a1ee904 3077 if (span_raw < 0.001) {
whismanoid 34:a1993a1ee904 3078 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_raw = %1.6f",
whismanoid 34:a1993a1ee904 3079 ch,
whismanoid 34:a1993a1ee904 3080 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3081 span_raw
whismanoid 34:a1993a1ee904 3082 );
whismanoid 34:a1993a1ee904 3083 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 3084 }
whismanoid 34:a1993a1ee904 3085 if (span_cal < 0.001) {
whismanoid 34:a1993a1ee904 3086 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_cal = %1.6f",
whismanoid 34:a1993a1ee904 3087 ch,
whismanoid 34:a1993a1ee904 3088 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3089 span_cal
whismanoid 34:a1993a1ee904 3090 );
whismanoid 34:a1993a1ee904 3091 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 3092 }
whismanoid 34:a1993a1ee904 3093 double slope_correction = span_cal / span_raw;
whismanoid 34:a1993a1ee904 3094 double corrected_normValue_0_1 = cal_05_normValue + ((raw_normValue_0_1 - raw_05_normValue) * slope_correction);
whismanoid 34:a1993a1ee904 3095 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) slope_correction = %1.6f",
whismanoid 34:a1993a1ee904 3096 // ch,
whismanoid 34:a1993a1ee904 3097 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3098 // slope_correction
whismanoid 34:a1993a1ee904 3099 // );
whismanoid 34:a1993a1ee904 3100 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) corrected_normValue_0_1 = %1.6f\r\n",
whismanoid 34:a1993a1ee904 3101 // ch,
whismanoid 34:a1993a1ee904 3102 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 3103 // corrected_normValue_0_1
whismanoid 34:a1993a1ee904 3104 // );
whismanoid 34:a1993a1ee904 3105 return corrected_normValue_0_1;
whismanoid 34:a1993a1ee904 3106 }
whismanoid 34:a1993a1ee904 3107 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3108 // Option to customize channel names in datalog header line
whismanoid 45:74bf1fe021e5 3109 // This could be used to identify external hardware attached to each input
whismanoid 13:184a08909405 3110 #ifndef HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 3111 #define HAS_Platform_AIN_customChannelHeader 1
whismanoid 13:184a08909405 3112 #endif
whismanoid 13:184a08909405 3113 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 3114 const char* const Platform_AIN_customChannelHeader_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 3115 "=AIN4", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 3116 "=AIN5", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 3117 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 3118 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 3119 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 3120 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 3121 };
whismanoid 13:184a08909405 3122 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 1:747f1602abfc 3123 //--------------------------------------------------
whismanoid 1:747f1602abfc 3124 // Option to log platform analog inputs as raw LSB code
whismanoid 1:747f1602abfc 3125 #ifndef LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 3126 #define LOG_PLATFORM_ANALOG_IN_LSB 0
whismanoid 1:747f1602abfc 3127 #endif
whismanoid 1:747f1602abfc 3128 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 3129 int Platform_LSB[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 3130 #endif
whismanoid 1:747f1602abfc 3131
whismanoid 1:747f1602abfc 3132 //--------------------------------------------------
whismanoid 1:747f1602abfc 3133 // Option to use platform analog inputs as Voltage
whismanoid 1:747f1602abfc 3134 #ifndef LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 3135 #define LOG_PLATFORM_ANALOG_IN_VOLTS 1
whismanoid 1:747f1602abfc 3136 #endif
whismanoid 1:747f1602abfc 3137 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 3138 double Platform_Voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 3139 #endif
whismanoid 3:9055e17e181a 3140 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 0:cb44e2e9ec4c 3141
whismanoid 10:04022a61b527 3142 //--------------------------------------------------
whismanoid 10:04022a61b527 3143 // Option to use Command forwarding to Auxiliary serial port
whismanoid 10:04022a61b527 3144 // Command forwarding to Auxiliary serial port TX/RX
whismanoid 10:04022a61b527 3145 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial
whismanoid 10:04022a61b527 3146 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial
whismanoid 10:04022a61b527 3147 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3148 #ifndef USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3149 #define USE_AUX_SERIAL_CMD_FORWARDING 1
whismanoid 10:04022a61b527 3150 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3151 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3152 // Command forwarding to Auxiliary serial port TX/RX #257 -- global parameters
whismanoid 10:04022a61b527 3153 const size_t RX_STRING_BUF_SIZE = 1000;
whismanoid 10:04022a61b527 3154 int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 3155 // transmit command string by AUX TX
whismanoid 10:04022a61b527 3156 #if 0
whismanoid 10:04022a61b527 3157 int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 3158 int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 3159 int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 3160 #endif
whismanoid 10:04022a61b527 3161 // capture received string from AUX RX
whismanoid 10:04022a61b527 3162 Timer g_auxSerialCom_Timer;
whismanoid 10:04022a61b527 3163 int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 3164 int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 3165 int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 3166 int g_auxSerialCom_rx_idle_ms = 500; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 3167 int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 3168 const int aux_serial_cmd_forwarding_rx_eot_not_used = 'x';
whismanoid 10:04022a61b527 3169 int g_auxSerialCom_rx_eot = aux_serial_cmd_forwarding_rx_eot_not_used; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 3170 //~ int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text string?
whismanoid 10:04022a61b527 3171 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3172 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3173 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257
whismanoid 10:04022a61b527 3174 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3175 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3176 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3177 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3178 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3179 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3180 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 3181 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3182 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3183 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3184 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3185 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3186 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3187 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3188 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3189
whismanoid 8:dffee7509bfb 3190 // CODE GENERATOR: example code for ADC: serial port declaration
whismanoid 8:dffee7509bfb 3191 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3192 // Declare the Serial driver
whismanoid 8:dffee7509bfb 3193 // default baud rate settings are 9600 8N1
whismanoid 8:dffee7509bfb 3194 // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
whismanoid 8:dffee7509bfb 3195 // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
whismanoid 8:dffee7509bfb 3196 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3197 #if defined(TARGET_MAX32630)
whismanoid 8:dffee7509bfb 3198 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 3199 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3200 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3201 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 3202 //
whismanoid 8:dffee7509bfb 3203 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3204 Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3205 //Serial J3AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 3206 //Serial BTAUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 3207 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3208 //
whismanoid 8:dffee7509bfb 3209 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3210 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3211 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3212 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3213 //
whismanoid 8:dffee7509bfb 3214 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3215 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3216 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3217 USBSerial serial;
whismanoid 8:dffee7509bfb 3218 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3219 #elif defined(TARGET_MAX32625MBED)
whismanoid 8:dffee7509bfb 3220 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625MBED: P0_1,P0_0 (Arduino D1,D0)
whismanoid 8:dffee7509bfb 3221 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3222 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625MBED: P3_1,P3_0 (J15-LEDgreen,LEDred)
whismanoid 8:dffee7509bfb 3223 //
whismanoid 8:dffee7509bfb 3224 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3225 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3226 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3227 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3228 //
whismanoid 8:dffee7509bfb 3229 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3230 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3231 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3232 USBSerial serial;
whismanoid 8:dffee7509bfb 3233 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 3234 #elif defined(TARGET_MAX32625PICO)
whismanoid 8:dffee7509bfb 3235 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 3236 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625PICO: P2_1,P2_0 (underside?)
whismanoid 8:dffee7509bfb 3237 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3238 //
whismanoid 8:dffee7509bfb 3239 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3240 Serial AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 3241 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3242 //
whismanoid 8:dffee7509bfb 3243 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3244 Serial DAPLINKserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3245 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3246 //
whismanoid 8:dffee7509bfb 3247 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3248 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3249 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3250 USBSerial serial;
whismanoid 22:d6dc8a85f435 3251 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 3252 #elif defined(TARGET_MAX40108DEMOP2U9)
whismanoid 22:d6dc8a85f435 3253 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 3254 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK)
whismanoid 22:d6dc8a85f435 3255 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 3256 //
whismanoid 22:d6dc8a85f435 3257 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial is used as main serial port in MAX40108 Demo board
whismanoid 22:d6dc8a85f435 3258 Serial serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 3259 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 3260 //
whismanoid 22:d6dc8a85f435 3261 // Hardware serial port over DAPLink
whismanoid 22:d6dc8a85f435 3262 // connection to external MAX32625PICO(DAPLINK) needed TX/RX swap in firmware.
whismanoid 22:d6dc8a85f435 3263 // MAX32625PICO(DAPLINK) drives DAPLINK.8, listens on DAPLINK.6.
whismanoid 22:d6dc8a85f435 3264 // See AN6350 MAX32625 Users Guide 7.5.2.3.1 TX and RX Pin Mapping for UART 1 -- Mapping Option B
whismanoid 39:4d285e961435 3265 #ifdef BOARD_SERIAL_NUMBER
whismanoid 39:4d285e961435 3266 // data unique to certain boards based on serial number
whismanoid 39:4d285e961435 3267 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 39:4d285e961435 3268 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 39:4d285e961435 3269 // s/n 0 is not really a MAX40108 board, it's actually a MAX32625PICO used for early development. So no swap.
whismanoid 39:4d285e961435 3270 Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 39:4d285e961435 3271 //Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 39:4d285e961435 3272 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3273 //
whismanoid 39:4d285e961435 3274 // # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 39:4d285e961435 3275 // #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 39:4d285e961435 3276 // //
whismanoid 39:4d285e961435 3277 // # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 39:4d285e961435 3278 // #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 39:4d285e961435 3279 // //
whismanoid 39:4d285e961435 3280 // # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 39:4d285e961435 3281 // #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 39:4d285e961435 3282 // //
whismanoid 39:4d285e961435 3283 // # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 39:4d285e961435 3284 // #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 39:4d285e961435 3285 // //
whismanoid 39:4d285e961435 3286 // # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 39:4d285e961435 3287 // #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 39:4d285e961435 3288 // //
whismanoid 39:4d285e961435 3289 // # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 39:4d285e961435 3290 // #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 39:4d285e961435 3291 // //
whismanoid 39:4d285e961435 3292 # else
whismanoid 39:4d285e961435 3293 // #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 22:d6dc8a85f435 3294 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 22:d6dc8a85f435 3295 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 22:d6dc8a85f435 3296 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3297 # endif
whismanoid 39:4d285e961435 3298 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 39:4d285e961435 3299 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 39:4d285e961435 3300 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 39:4d285e961435 3301 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 39:4d285e961435 3302 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3303 //
whismanoid 39:4d285e961435 3304 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 22:d6dc8a85f435 3305 //
whismanoid 22:d6dc8a85f435 3306 // Serial AUXserial(UART1_TX,UART1_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 3307 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 3308 //
whismanoid 22:d6dc8a85f435 3309 // Virtual serial port over USB
whismanoid 22:d6dc8a85f435 3310 // #include "USBSerial.h"
whismanoid 22:d6dc8a85f435 3311 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 22:d6dc8a85f435 3312 //USBSerial serial;
whismanoid 8:dffee7509bfb 3313 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3314 #elif defined(TARGET_MAX32620FTHR)
whismanoid 8:dffee7509bfb 3315 #warning "TARGET_MAX32620FTHR not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3316 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3317 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32620FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3318 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3319 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3320 //
whismanoid 8:dffee7509bfb 3321 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3322 Serial serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3323 //Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3324 Serial AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3325 //Serial PMOD0AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3326 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3327 //
whismanoid 8:dffee7509bfb 3328 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3329 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3330 Serial DAPLINKserial(USBTX, USBRX); // tx,rx MAX32620FTHR: P2_1,P2_0
whismanoid 8:dffee7509bfb 3331 //Serial DAPLINKserial(STDIO_UART_TX, STDIO_UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3332 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3333 //
whismanoid 8:dffee7509bfb 3334 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3335 // #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3336 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3337 //USBSerial serial; // MAX32620FTHR: USBSerial crash??
whismanoid 8:dffee7509bfb 3338 #warning "TARGET_MAX32620FTHR not previously tested; USBSerial crash?"
whismanoid 8:dffee7509bfb 3339 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3340 #elif defined(TARGET_MAX32600)
whismanoid 8:dffee7509bfb 3341 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3342 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART2 MAX32625MBED: P1_3,P1_2 (Arduino D3,D2)
whismanoid 8:dffee7509bfb 3343 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART1 MAX32625MBED: P7_3,P7_2 ( ?? )
whismanoid 8:dffee7509bfb 3344 //
whismanoid 8:dffee7509bfb 3345 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3346 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3347 Serial DAPLINKserial(P1_1,P1_0); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3348 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3349 //
whismanoid 8:dffee7509bfb 3350 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3351 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3352 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3353 USBSerial serial;
whismanoid 8:dffee7509bfb 3354 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3355 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 8:dffee7509bfb 3356 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3357 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3358 #else
whismanoid 8:dffee7509bfb 3359 #if defined(SERIAL_TX)
whismanoid 8:dffee7509bfb 3360 #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..."
whismanoid 8:dffee7509bfb 3361 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3362 #elif defined(USBTX)
whismanoid 8:dffee7509bfb 3363 #warning "target not previously tested; guess serial pins are USBTX, USBRX..."
whismanoid 8:dffee7509bfb 3364 Serial serial(USBTX, USBRX); // tx, rx
whismanoid 8:dffee7509bfb 3365 #elif defined(UART_TX)
whismanoid 8:dffee7509bfb 3366 #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..."
whismanoid 8:dffee7509bfb 3367 Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3368 #else
whismanoid 8:dffee7509bfb 3369 #warning "target not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3370 #endif
whismanoid 8:dffee7509bfb 3371 #endif
whismanoid 8:dffee7509bfb 3372 //
whismanoid 8:dffee7509bfb 3373 #include "CmdLine.h"
whismanoid 8:dffee7509bfb 3374
whismanoid 8:dffee7509bfb 3375 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3376 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3377 CmdLine cmdLine_AUXserial(AUXserial, "AUXserial");
whismanoid 10:04022a61b527 3378 uint8_t Datalogger_enable_AUXserial = {
whismanoid 10:04022a61b527 3379 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3380 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 3381 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 3382 false
whismanoid 10:04022a61b527 3383 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3384 true
whismanoid 10:04022a61b527 3385 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3386 };
whismanoid 8:dffee7509bfb 3387 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3388 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3389 CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK");
whismanoid 8:dffee7509bfb 3390 uint8_t Datalogger_enable_DAPLINKserial = true;
whismanoid 8:dffee7509bfb 3391 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3392 CmdLine cmdLine(serial, "serial");
whismanoid 8:dffee7509bfb 3393 uint8_t Datalogger_enable_serial = true;
whismanoid 8:dffee7509bfb 3394 // CODE GENERATOR: example code for ADC: serial port declaration (end)
whismanoid 8:dffee7509bfb 3395
whismanoid 21:ac062a97a71d 3396
whismanoid 21:ac062a97a71d 3397 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3398 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3399 // support for commands %B1! .. %B9!
whismanoid 23:c6c652bef4b9 3400 #ifndef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3401 #define USE_DATALOGGER_CommandTable 1
whismanoid 23:c6c652bef4b9 3402 //~ #undef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3403 #endif
whismanoid 23:c6c652bef4b9 3404 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3405 const int COMMAND_TABLE_ROW_MAX = 10;
whismanoid 23:c6c652bef4b9 3406 const int COMMAND_TABLE_COL_MAX = 40;
whismanoid 23:c6c652bef4b9 3407 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3408 //
whismanoid 23:c6c652bef4b9 3409 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3410 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3411 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3412 // onButton1_command_table[] supports command %B1! -- run, %B1@ -- edit
whismanoid 45:74bf1fe021e5 3413 // MAX40108p2 hardware pin P2_7 button SW1 active low
whismanoid 45:74bf1fe021e5 3414 //........................................................12345678901234567890
whismanoid 45:74bf1fe021e5 3415 char onButton1_command_table_00[COMMAND_TABLE_COL_MAX] = "# SW1 event";
whismanoid 45:74bf1fe021e5 3416 char onButton1_command_table_01[COMMAND_TABLE_COL_MAX] = ">>SW1=LP1 deep sleep 10 sec";
whismanoid 45:74bf1fe021e5 3417 char onButton1_command_table_02[COMMAND_TABLE_COL_MAX] = "%H91"; // LED off
whismanoid 45:74bf1fe021e5 3418 char onButton1_command_table_03[COMMAND_TABLE_COL_MAX] = "%H92"; // LED off
whismanoid 45:74bf1fe021e5 3419 char onButton1_command_table_04[COMMAND_TABLE_COL_MAX] = "%H93"; // LED off
whismanoid 45:74bf1fe021e5 3420 char onButton1_command_table_05[COMMAND_TABLE_COL_MAX] = "%H9"; // diagnostic pulse D9
whismanoid 45:74bf1fe021e5 3421 char onButton1_command_table_06[COMMAND_TABLE_COL_MAX] = "LT count=10 base=1000 sleep=1";
whismanoid 45:74bf1fe021e5 3422 char onButton1_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3423 char onButton1_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3424 char onButton1_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3425 static char* onButton1_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3426 onButton1_command_table_00,
whismanoid 23:c6c652bef4b9 3427 onButton1_command_table_01,
whismanoid 23:c6c652bef4b9 3428 onButton1_command_table_02,
whismanoid 23:c6c652bef4b9 3429 onButton1_command_table_03,
whismanoid 23:c6c652bef4b9 3430 onButton1_command_table_04,
whismanoid 23:c6c652bef4b9 3431 onButton1_command_table_05,
whismanoid 23:c6c652bef4b9 3432 onButton1_command_table_06,
whismanoid 23:c6c652bef4b9 3433 onButton1_command_table_07,
whismanoid 23:c6c652bef4b9 3434 onButton1_command_table_08,
whismanoid 23:c6c652bef4b9 3435 onButton1_command_table_09,
whismanoid 23:c6c652bef4b9 3436 };
whismanoid 23:c6c652bef4b9 3437 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3438 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3439 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3440 // onButton2_command_table[] supports command %B2! -- run, %B2@ -- edit
whismanoid 45:74bf1fe021e5 3441 // MAX40108p2 hardware pin P1_7 connector J91.3 active low
whismanoid 45:74bf1fe021e5 3442 //........................................................12345678901234567890
whismanoid 45:74bf1fe021e5 3443 char onButton2_command_table_00[COMMAND_TABLE_COL_MAX] = "# J91.3=Halt"; // remark
whismanoid 45:74bf1fe021e5 3444 char onButton2_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91"; // LED on
whismanoid 45:74bf1fe021e5 3445 char onButton2_command_table_02[COMMAND_TABLE_COL_MAX] = "L"; // halts data logging
whismanoid 45:74bf1fe021e5 3446 char onButton2_command_table_03[COMMAND_TABLE_COL_MAX] = "%H92"; // LED off
whismanoid 45:74bf1fe021e5 3447 char onButton2_command_table_04[COMMAND_TABLE_COL_MAX] = "%L93"; // LED on
whismanoid 45:74bf1fe021e5 3448 char onButton2_command_table_05[COMMAND_TABLE_COL_MAX] = ">>J91.2=Halt"; // to DAPLINK comms
whismanoid 23:c6c652bef4b9 3449 char onButton2_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3450 char onButton2_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3451 char onButton2_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3452 char onButton2_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3453 static char* onButton2_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3454 onButton2_command_table_00,
whismanoid 23:c6c652bef4b9 3455 onButton2_command_table_01,
whismanoid 23:c6c652bef4b9 3456 onButton2_command_table_02,
whismanoid 23:c6c652bef4b9 3457 onButton2_command_table_03,
whismanoid 23:c6c652bef4b9 3458 onButton2_command_table_04,
whismanoid 23:c6c652bef4b9 3459 onButton2_command_table_05,
whismanoid 23:c6c652bef4b9 3460 onButton2_command_table_06,
whismanoid 23:c6c652bef4b9 3461 onButton2_command_table_07,
whismanoid 23:c6c652bef4b9 3462 onButton2_command_table_08,
whismanoid 23:c6c652bef4b9 3463 onButton2_command_table_09,
whismanoid 23:c6c652bef4b9 3464 };
whismanoid 23:c6c652bef4b9 3465 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3466 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3467 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3468 // onButton3_command_table[] supports command %B3! -- run, %B3@ -- edit
whismanoid 45:74bf1fe021e5 3469 // MAX40108p2 hardware pin P1_6 connector J91.2 active low
whismanoid 45:74bf1fe021e5 3470 //........................................................12345678901234567890
whismanoid 45:74bf1fe021e5 3471 char onButton3_command_table_00[COMMAND_TABLE_COL_MAX] = "# J91.2 event";
whismanoid 45:74bf1fe021e5 3472 char onButton3_command_table_01[COMMAND_TABLE_COL_MAX] = ">>J91.2 event";
whismanoid 45:74bf1fe021e5 3473 char onButton3_command_table_02[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 45:74bf1fe021e5 3474 char onButton3_command_table_03[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 45:74bf1fe021e5 3475 char onButton3_command_table_04[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 45:74bf1fe021e5 3476 char onButton3_command_table_05[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 45:74bf1fe021e5 3477 char onButton3_command_table_06[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 45:74bf1fe021e5 3478 char onButton3_command_table_07[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 45:74bf1fe021e5 3479 char onButton3_command_table_08[COMMAND_TABLE_COL_MAX] = ">>LR -- run full speed";
whismanoid 45:74bf1fe021e5 3480 char onButton3_command_table_09[COMMAND_TABLE_COL_MAX] = "LR";
whismanoid 24:032f3683cb2a 3481 static char* onButton3_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 24:032f3683cb2a 3482 onButton3_command_table_00,
whismanoid 24:032f3683cb2a 3483 onButton3_command_table_01,
whismanoid 24:032f3683cb2a 3484 onButton3_command_table_02,
whismanoid 24:032f3683cb2a 3485 onButton3_command_table_03,
whismanoid 24:032f3683cb2a 3486 onButton3_command_table_04,
whismanoid 24:032f3683cb2a 3487 onButton3_command_table_05,
whismanoid 24:032f3683cb2a 3488 onButton3_command_table_06,
whismanoid 24:032f3683cb2a 3489 onButton3_command_table_07,
whismanoid 24:032f3683cb2a 3490 onButton3_command_table_08,
whismanoid 24:032f3683cb2a 3491 onButton3_command_table_09,
whismanoid 24:032f3683cb2a 3492 };
whismanoid 24:032f3683cb2a 3493 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3494 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3495 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3496 // onButton4_command_table[] supports command %B4! -- run, %B4@ -- edit
whismanoid 45:74bf1fe021e5 3497 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3498 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3499 char onButton4_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button4 event";
whismanoid 30:07197a430869 3500 char onButton4_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE>0.7:active";
whismanoid 29:6a9edb6e973b 3501 char onButton4_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3502 char onButton4_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3503 char onButton4_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3504 char onButton4_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3505 char onButton4_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3506 char onButton4_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3507 char onButton4_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3508 char onButton4_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3509 static char* onButton4_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3510 onButton4_command_table_00,
whismanoid 29:6a9edb6e973b 3511 onButton4_command_table_01,
whismanoid 29:6a9edb6e973b 3512 onButton4_command_table_02,
whismanoid 29:6a9edb6e973b 3513 onButton4_command_table_03,
whismanoid 29:6a9edb6e973b 3514 onButton4_command_table_04,
whismanoid 29:6a9edb6e973b 3515 onButton4_command_table_05,
whismanoid 29:6a9edb6e973b 3516 onButton4_command_table_06,
whismanoid 29:6a9edb6e973b 3517 onButton4_command_table_07,
whismanoid 29:6a9edb6e973b 3518 onButton4_command_table_08,
whismanoid 29:6a9edb6e973b 3519 onButton4_command_table_09,
whismanoid 29:6a9edb6e973b 3520 };
whismanoid 29:6a9edb6e973b 3521 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3522 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3523 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3524 // onButton5_command_table[] supports command %B5! -- run, %B5@ -- edit
whismanoid 45:74bf1fe021e5 3525 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3526 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3527 char onButton5_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button5 event";
whismanoid 30:07197a430869 3528 char onButton5_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE<0.6:sleep";
whismanoid 29:6a9edb6e973b 3529 char onButton5_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3530 char onButton5_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3531 char onButton5_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3532 char onButton5_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3533 char onButton5_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3534 char onButton5_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3535 char onButton5_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3536 char onButton5_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3537 static char* onButton5_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3538 onButton5_command_table_00,
whismanoid 29:6a9edb6e973b 3539 onButton5_command_table_01,
whismanoid 29:6a9edb6e973b 3540 onButton5_command_table_02,
whismanoid 29:6a9edb6e973b 3541 onButton5_command_table_03,
whismanoid 29:6a9edb6e973b 3542 onButton5_command_table_04,
whismanoid 29:6a9edb6e973b 3543 onButton5_command_table_05,
whismanoid 29:6a9edb6e973b 3544 onButton5_command_table_06,
whismanoid 29:6a9edb6e973b 3545 onButton5_command_table_07,
whismanoid 29:6a9edb6e973b 3546 onButton5_command_table_08,
whismanoid 29:6a9edb6e973b 3547 onButton5_command_table_09,
whismanoid 29:6a9edb6e973b 3548 };
whismanoid 29:6a9edb6e973b 3549 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3550 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3551 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3552 // onButton6_command_table[] supports command %B6! -- run, %B6@ -- edit
whismanoid 45:74bf1fe021e5 3553 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3554 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3555 char onButton6_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button6 event";
whismanoid 29:6a9edb6e973b 3556 char onButton6_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3557 char onButton6_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3558 char onButton6_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3559 char onButton6_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3560 char onButton6_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3561 char onButton6_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3562 char onButton6_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3563 char onButton6_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3564 char onButton6_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3565 static char* onButton6_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3566 onButton6_command_table_00,
whismanoid 29:6a9edb6e973b 3567 onButton6_command_table_01,
whismanoid 29:6a9edb6e973b 3568 onButton6_command_table_02,
whismanoid 29:6a9edb6e973b 3569 onButton6_command_table_03,
whismanoid 29:6a9edb6e973b 3570 onButton6_command_table_04,
whismanoid 29:6a9edb6e973b 3571 onButton6_command_table_05,
whismanoid 29:6a9edb6e973b 3572 onButton6_command_table_06,
whismanoid 29:6a9edb6e973b 3573 onButton6_command_table_07,
whismanoid 29:6a9edb6e973b 3574 onButton6_command_table_08,
whismanoid 29:6a9edb6e973b 3575 onButton6_command_table_09,
whismanoid 29:6a9edb6e973b 3576 };
whismanoid 29:6a9edb6e973b 3577 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3578 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3579 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3580 // onButton7_command_table[] supports command %B7! -- run, %B7@ -- edit
whismanoid 45:74bf1fe021e5 3581 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3582 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3583 char onButton7_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button7 event";
whismanoid 29:6a9edb6e973b 3584 char onButton7_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3585 char onButton7_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3586 char onButton7_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3587 char onButton7_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3588 char onButton7_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3589 char onButton7_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3590 char onButton7_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3591 char onButton7_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3592 char onButton7_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3593 static char* onButton7_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3594 onButton7_command_table_00,
whismanoid 29:6a9edb6e973b 3595 onButton7_command_table_01,
whismanoid 29:6a9edb6e973b 3596 onButton7_command_table_02,
whismanoid 29:6a9edb6e973b 3597 onButton7_command_table_03,
whismanoid 29:6a9edb6e973b 3598 onButton7_command_table_04,
whismanoid 29:6a9edb6e973b 3599 onButton7_command_table_05,
whismanoid 29:6a9edb6e973b 3600 onButton7_command_table_06,
whismanoid 29:6a9edb6e973b 3601 onButton7_command_table_07,
whismanoid 29:6a9edb6e973b 3602 onButton7_command_table_08,
whismanoid 29:6a9edb6e973b 3603 onButton7_command_table_09,
whismanoid 29:6a9edb6e973b 3604 };
whismanoid 29:6a9edb6e973b 3605 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3606 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3607 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3608 // onButton8_command_table[] supports command %B8! -- run, %B8@ -- edit
whismanoid 45:74bf1fe021e5 3609 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3610 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3611 char onButton8_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button8 event";
whismanoid 29:6a9edb6e973b 3612 char onButton8_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3613 char onButton8_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3614 char onButton8_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3615 char onButton8_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3616 char onButton8_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3617 char onButton8_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3618 char onButton8_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3619 char onButton8_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3620 char onButton8_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3621 static char* onButton8_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3622 onButton8_command_table_00,
whismanoid 29:6a9edb6e973b 3623 onButton8_command_table_01,
whismanoid 29:6a9edb6e973b 3624 onButton8_command_table_02,
whismanoid 29:6a9edb6e973b 3625 onButton8_command_table_03,
whismanoid 29:6a9edb6e973b 3626 onButton8_command_table_04,
whismanoid 29:6a9edb6e973b 3627 onButton8_command_table_05,
whismanoid 29:6a9edb6e973b 3628 onButton8_command_table_06,
whismanoid 29:6a9edb6e973b 3629 onButton8_command_table_07,
whismanoid 29:6a9edb6e973b 3630 onButton8_command_table_08,
whismanoid 29:6a9edb6e973b 3631 onButton8_command_table_09,
whismanoid 29:6a9edb6e973b 3632 };
whismanoid 29:6a9edb6e973b 3633 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3634 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3635 // command_table: list of commands to perform on button press
whismanoid 45:74bf1fe021e5 3636 // onButton9_command_table[] supports command %B9! -- run, %B9@ -- edit
whismanoid 45:74bf1fe021e5 3637 // no hardware pin available, but useful for containing "# remark" labels for action table
whismanoid 45:74bf1fe021e5 3638 //........................................................12345678901234567890
whismanoid 29:6a9edb6e973b 3639 char onButton9_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button9 event";
whismanoid 29:6a9edb6e973b 3640 char onButton9_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3641 char onButton9_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3642 char onButton9_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3643 char onButton9_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3644 char onButton9_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3645 char onButton9_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3646 char onButton9_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3647 char onButton9_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3648 char onButton9_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3649 static char* onButton9_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3650 onButton9_command_table_00,
whismanoid 29:6a9edb6e973b 3651 onButton9_command_table_01,
whismanoid 29:6a9edb6e973b 3652 onButton9_command_table_02,
whismanoid 29:6a9edb6e973b 3653 onButton9_command_table_03,
whismanoid 29:6a9edb6e973b 3654 onButton9_command_table_04,
whismanoid 29:6a9edb6e973b 3655 onButton9_command_table_05,
whismanoid 29:6a9edb6e973b 3656 onButton9_command_table_06,
whismanoid 29:6a9edb6e973b 3657 onButton9_command_table_07,
whismanoid 29:6a9edb6e973b 3658 onButton9_command_table_08,
whismanoid 29:6a9edb6e973b 3659 onButton9_command_table_09,
whismanoid 29:6a9edb6e973b 3660 };
whismanoid 29:6a9edb6e973b 3661 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3662 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3663 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3664 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 3665 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3666 bool g_Run_command_table_running = false;
whismanoid 23:c6c652bef4b9 3667 void Run_command_table(char* command_table[])
whismanoid 23:c6c652bef4b9 3668 {
whismanoid 23:c6c652bef4b9 3669 // command_table: perform list of commands
whismanoid 31:47eee7e0cc2d 3670 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3671 if (g_Run_command_table_running) {
whismanoid 31:47eee7e0cc2d 3672 // TODO: button event chaining is not supported at this time
whismanoid 31:47eee7e0cc2d 3673 } // if (g_Run_command_table_running)
whismanoid 31:47eee7e0cc2d 3674 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3675 g_Run_command_table_running = true;
whismanoid 23:c6c652bef4b9 3676 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 3677 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 3678 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 23:c6c652bef4b9 3679 cmdLine.clear();
whismanoid 31:47eee7e0cc2d 3680 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3681 //~ char* strIndex = command_table[lineIndex];
whismanoid 23:c6c652bef4b9 3682 for (char* strIndex = command_table[lineIndex]; *strIndex != '\0'; strIndex++)
whismanoid 23:c6c652bef4b9 3683 {
whismanoid 23:c6c652bef4b9 3684 cmdLine.append(*strIndex);
whismanoid 23:c6c652bef4b9 3685 }
whismanoid 23:c6c652bef4b9 3686 cmdLine.append('\r'); // append \r invokes onEOLcommandParser to handle command
whismanoid 23:c6c652bef4b9 3687 }
whismanoid 31:47eee7e0cc2d 3688 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3689 g_Run_command_table_running = false;
whismanoid 31:47eee7e0cc2d 3690 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3691 }
whismanoid 23:c6c652bef4b9 3692 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3693 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3694 // When user presses button BUTTON1, perform actions
whismanoid 21:ac062a97a71d 3695 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3696 void onButton1FallingEdge(void)
whismanoid 21:ac062a97a71d 3697 {
whismanoid 21:ac062a97a71d 3698 //~ void SelfTest(CmdLine & cmdLine);
whismanoid 21:ac062a97a71d 3699 //~ SelfTest(cmdLine_serial);
whismanoid 22:d6dc8a85f435 3700 //
whismanoid 23:c6c652bef4b9 3701 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3702 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3703 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3704 Run_command_table(onButton1_command_table);
whismanoid 23:c6c652bef4b9 3705 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3706 }
whismanoid 21:ac062a97a71d 3707 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3708
whismanoid 21:ac062a97a71d 3709 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3710 // When user presses button BUTTON2, perform actions
whismanoid 21:ac062a97a71d 3711 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3712 void onButton2FallingEdge(void)
whismanoid 21:ac062a97a71d 3713 {
whismanoid 21:ac062a97a71d 3714 // TBD demo configuration
whismanoid 21:ac062a97a71d 3715 // TODO diagnostic LED
whismanoid 21:ac062a97a71d 3716 // led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 22:d6dc8a85f435 3717 //
whismanoid 23:c6c652bef4b9 3718 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3719 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3720 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3721 Run_command_table(onButton2_command_table);
whismanoid 23:c6c652bef4b9 3722 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3723 }
whismanoid 21:ac062a97a71d 3724 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3725
whismanoid 24:032f3683cb2a 3726 //--------------------------------------------------
whismanoid 29:6a9edb6e973b 3727 // When user presses button BUTTON3, perform actions
whismanoid 24:032f3683cb2a 3728 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3729 void onButton3FallingEdge(void)
whismanoid 24:032f3683cb2a 3730 {
whismanoid 24:032f3683cb2a 3731 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 24:032f3683cb2a 3732 // command_table: list of commands to perform on button press
whismanoid 24:032f3683cb2a 3733 // command_table: perform list of commands
whismanoid 24:032f3683cb2a 3734 Run_command_table(onButton3_command_table);
whismanoid 24:032f3683cb2a 3735 #endif // USE_DATALOGGER_CommandTable
whismanoid 24:032f3683cb2a 3736 }
whismanoid 24:032f3683cb2a 3737 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3738 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3739 void onButton4FallingEdge(void)
whismanoid 29:6a9edb6e973b 3740 {
whismanoid 29:6a9edb6e973b 3741 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3742 Run_command_table(onButton4_command_table);
whismanoid 29:6a9edb6e973b 3743 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3744 }
whismanoid 29:6a9edb6e973b 3745 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3746 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3747 void onButton5FallingEdge(void)
whismanoid 29:6a9edb6e973b 3748 {
whismanoid 29:6a9edb6e973b 3749 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3750 Run_command_table(onButton5_command_table);
whismanoid 29:6a9edb6e973b 3751 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3752 }
whismanoid 29:6a9edb6e973b 3753 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3754 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3755 void onButton6FallingEdge(void)
whismanoid 29:6a9edb6e973b 3756 {
whismanoid 29:6a9edb6e973b 3757 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3758 Run_command_table(onButton6_command_table);
whismanoid 29:6a9edb6e973b 3759 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3760 }
whismanoid 29:6a9edb6e973b 3761 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3762 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3763 void onButton7FallingEdge(void)
whismanoid 29:6a9edb6e973b 3764 {
whismanoid 29:6a9edb6e973b 3765 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3766 Run_command_table(onButton7_command_table);
whismanoid 29:6a9edb6e973b 3767 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3768 }
whismanoid 29:6a9edb6e973b 3769 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3770 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3771 void onButton8FallingEdge(void)
whismanoid 29:6a9edb6e973b 3772 {
whismanoid 29:6a9edb6e973b 3773 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3774 Run_command_table(onButton8_command_table);
whismanoid 29:6a9edb6e973b 3775 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3776 }
whismanoid 29:6a9edb6e973b 3777 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3778 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3779 void onButton9FallingEdge(void)
whismanoid 29:6a9edb6e973b 3780 {
whismanoid 29:6a9edb6e973b 3781 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3782 Run_command_table(onButton9_command_table);
whismanoid 29:6a9edb6e973b 3783 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3784 }
whismanoid 29:6a9edb6e973b 3785 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3786
whismanoid 4:d9b05924ad4c 3787 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3788 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3789 inline void print_command_prompt()
whismanoid 4:d9b05924ad4c 3790 {
whismanoid 4:d9b05924ad4c 3791 //~ Serial.println(F(">"));
whismanoid 4:d9b05924ad4c 3792 cmdLine.serial().printf("\r\n> ");
whismanoid 4:d9b05924ad4c 3793 }
whismanoid 4:d9b05924ad4c 3794 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3795
whismanoid 4:d9b05924ad4c 3796 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3797 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3798 void main_menu_status(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 3799 {
whismanoid 4:d9b05924ad4c 3800 cmdLine.serial().printf("\r\nMain menu");
whismanoid 4:d9b05924ad4c 3801 #if APPLICATION_MAX5715 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3802 cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC");
whismanoid 4:d9b05924ad4c 3803 #elif APPLICATION_MAX11131 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3804 cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC");
whismanoid 4:d9b05924ad4c 3805 #elif APPLICATION_MAX5171 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3806 cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC");
whismanoid 4:d9b05924ad4c 3807 #elif APPLICATION_MAX11410 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3808 cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC");
whismanoid 4:d9b05924ad4c 3809 #elif APPLICATION_MAX12345 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3810 cmdLine.serial().printf(" MAX12345");
whismanoid 16:819c5aaf5271 3811 #elif MAX40108_DEMO // main_menu_status banner
whismanoid 17:9397ea3ea7e9 3812 cmdLine.serial().printf(" MAX40108_U%d", MAX40108_DEMO);
whismanoid 36:e7aac874b8be 3813 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 3814 // data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 3815 cmdLine.serial().printf(" [s/n %d]", BOARD_SERIAL_NUMBER);
whismanoid 36:e7aac874b8be 3816 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 3817 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 3818 //
whismanoid 36:e7aac874b8be 3819 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 3820 #ifdef FW_REV
whismanoid 37:3f369235e5bc 3821 cmdLine.serial().printf(" [FW_REV %d]", FW_REV);
whismanoid 37:3f369235e5bc 3822 #endif // FW_REV
whismanoid 4:d9b05924ad4c 3823 #else
whismanoid 4:d9b05924ad4c 3824 //cmdLine.serial().printf(" ");
whismanoid 4:d9b05924ad4c 3825 #endif
whismanoid 4:d9b05924ad4c 3826 //cmdLine.serial().printf(" %s", TARGET_NAME);
whismanoid 4:d9b05924ad4c 3827 if (cmdLine.nameStr())
whismanoid 4:d9b05924ad4c 3828 {
whismanoid 4:d9b05924ad4c 3829 cmdLine.serial().printf(" [%s]", cmdLine.nameStr());
whismanoid 4:d9b05924ad4c 3830 }
whismanoid 4:d9b05924ad4c 3831 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3832 cmdLine.serial().printf(" [Button1");
whismanoid 4:d9b05924ad4c 3833 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3834 cmdLine.serial().printf("2");
whismanoid 24:032f3683cb2a 3835 #endif
whismanoid 24:032f3683cb2a 3836 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3837 cmdLine.serial().printf("3");
whismanoid 29:6a9edb6e973b 3838 #endif
whismanoid 29:6a9edb6e973b 3839 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3840 cmdLine.serial().printf("4");
whismanoid 29:6a9edb6e973b 3841 #endif
whismanoid 29:6a9edb6e973b 3842 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3843 cmdLine.serial().printf("5");
whismanoid 29:6a9edb6e973b 3844 #endif
whismanoid 29:6a9edb6e973b 3845 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3846 cmdLine.serial().printf("6");
whismanoid 29:6a9edb6e973b 3847 #endif
whismanoid 29:6a9edb6e973b 3848 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3849 cmdLine.serial().printf("7");
whismanoid 29:6a9edb6e973b 3850 #endif
whismanoid 29:6a9edb6e973b 3851 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3852 cmdLine.serial().printf("8");
whismanoid 29:6a9edb6e973b 3853 #endif
whismanoid 29:6a9edb6e973b 3854 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3855 cmdLine.serial().printf("9");
whismanoid 29:6a9edb6e973b 3856 #endif
whismanoid 29:6a9edb6e973b 3857 cmdLine.serial().printf("]");
whismanoid 29:6a9edb6e973b 3858 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 4:d9b05924ad4c 3859 #if HAS_BUTTON1_DEMO
whismanoid 4:d9b05924ad4c 3860 // print BUTTON1 status
whismanoid 4:d9b05924ad4c 3861 cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read());
whismanoid 4:d9b05924ad4c 3862 #endif
whismanoid 4:d9b05924ad4c 3863 #if HAS_BUTTON2_DEMO
whismanoid 24:032f3683cb2a 3864 // print BUTTON2 status
whismanoid 4:d9b05924ad4c 3865 cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read());
whismanoid 4:d9b05924ad4c 3866 #endif
whismanoid 24:032f3683cb2a 3867 #if HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 3868 // print BUTTON3 status
whismanoid 24:032f3683cb2a 3869 cmdLine.serial().printf("\r\n BUTTON3 = %d", button3.read());
whismanoid 24:032f3683cb2a 3870 #endif
whismanoid 4:d9b05924ad4c 3871 cmdLine.serial().printf("\r\n ? -- help");
whismanoid 4:d9b05924ad4c 3872 }
whismanoid 4:d9b05924ad4c 3873 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3874
whismanoid 28:a9a3a9db592b 3875 //--------------------------------------------------
whismanoid 28:a9a3a9db592b 3876 #ifndef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3877 #define USE_DATALOGGER_TRIGGER_HELP_BRIEF 1
whismanoid 28:a9a3a9db592b 3878 //~ #undef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3879 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3880
whismanoid 4:d9b05924ad4c 3881 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3882 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3883 void main_menu_help(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 3884 {
whismanoid 4:d9b05924ad4c 3885 // ? -- help
whismanoid 4:d9b05924ad4c 3886 //~ cmdLine.serial().printf("\r\nMenu:");
whismanoid 10:04022a61b527 3887 //
whismanoid 4:d9b05924ad4c 3888 cmdLine.serial().printf("\r\n # -- lines beginning with # are comments");
whismanoid 10:04022a61b527 3889 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 3890 cmdLine.serial().printf("\r\n ! -- Init");
whismanoid 10:04022a61b527 3891 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 3892 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 3893 cmdLine.serial().printf("\r\n . -- SelfTest");
whismanoid 4:d9b05924ad4c 3894 #endif // USE_SELFTEST
whismanoid 9:45f98573eb6d 3895 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 9:45f98573eb6d 3896 // CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register
whismanoid 9:45f98573eb6d 3897 cmdLine.serial().printf("\r\n * -- read core registers\r\n *regname? -- read register\r\n *regname=regvalue -- write register");
whismanoid 9:45f98573eb6d 3898 // cmdLine.serial().printf("\r\n 01 23 45 67 89 ab cd ef -- write and read raw hex codes");
whismanoid 10:04022a61b527 3899 #endif // USE_STAR_REG_READWRITE
whismanoid 10:04022a61b527 3900 //
whismanoid 10:04022a61b527 3901 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3902 // Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_help
whismanoid 10:04022a61b527 3903 //~ cmdLine.serial().printf("\r\n > -- auxiliary UART port");
whismanoid 10:04022a61b527 3904 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3905 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3906 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3907 if (cmdLine_AUXserial.nameStr())
whismanoid 10:04022a61b527 3908 {
whismanoid 10:04022a61b527 3909 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_AUXserial.nameStr());
whismanoid 10:04022a61b527 3910 }
whismanoid 10:04022a61b527 3911 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3912 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3913 if (cmdLine_DAPLINKserial.nameStr())
whismanoid 10:04022a61b527 3914 {
whismanoid 10:04022a61b527 3915 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_DAPLINKserial.nameStr());
whismanoid 10:04022a61b527 3916 }
whismanoid 10:04022a61b527 3917 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3918 # if HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3919 // WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3920 cmdLine.serial().printf("\r\n >xyzzy -- Forward command/data 'xyzzy' to aux TX/RX");
whismanoid 10:04022a61b527 3921 cmdLine.serial().printf("\r\n >>xyzzy -- Forward 'xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 3922 cmdLine.serial().printf("\r\n >>>xyzzy -- Forward '>xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 3923 #if 0
whismanoid 10:04022a61b527 3924 cmdLine.serial().printf("\r\n >tx_wait_echo=%d -- configure TX wait for each character echo", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 3925 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 3926 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 3927 #endif
whismanoid 20:78ef670955d4 3928 #if 1 // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 3929 cmdLine.serial().printf("\r\n >baud=%d message_ms=%d rx_idle_ms=%d rx_max_count=%d rx_eot=%d",
whismanoid 20:78ef670955d4 3930 g_auxSerialCom_baud,
whismanoid 20:78ef670955d4 3931 g_auxSerialCom_message_ms,
whismanoid 20:78ef670955d4 3932 g_auxSerialCom_rx_idle_ms,
whismanoid 20:78ef670955d4 3933 g_auxSerialCom_rx_max_count,
whismanoid 20:78ef670955d4 3934 g_auxSerialCom_rx_eot);
whismanoid 20:78ef670955d4 3935 #else // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 3936 cmdLine.serial().printf("\r\n >baud=%d -- configure aux TX/RX port", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 3937 cmdLine.serial().printf("\r\n >message_ms=%d -- maximum RX message total response time", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 3938 cmdLine.serial().printf("\r\n >rx_idle_ms=%d -- maximum RX message idle time between characters", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 3939 cmdLine.serial().printf("\r\n >rx_max_count=%d -- maximum RX message total length", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 3940 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 3941 #endif // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 10:04022a61b527 3942 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3943 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3944 //
whismanoid 4:d9b05924ad4c 3945 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 3946 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3947 // Datalog trigger menu
whismanoid 28:a9a3a9db592b 3948 // brief toplevel heading for datalog help L
whismanoid 28:a9a3a9db592b 3949 // L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 3950 cmdLine.serial().printf("\r\n L -- halt the datalogger; show more commands");
whismanoid 28:a9a3a9db592b 3951 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 28:a9a3a9db592b 3952 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 28:a9a3a9db592b 3953 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 28:a9a3a9db592b 3954 //
whismanoid 28:a9a3a9db592b 3955 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 3956 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 3957 //
whismanoid 39:4d285e961435 3958 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 3959 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 3960 cmdLine.serial().printf("\r\n LT count=%d base=%dms sleep=%d -- Datalog timer",
whismanoid 39:4d285e961435 3961 g_timer_interval_count,
whismanoid 39:4d285e961435 3962 g_timer_interval_msec,
whismanoid 39:4d285e961435 3963 (int)g_timer_sleepmode
whismanoid 39:4d285e961435 3964 ); // trigger_Timer
whismanoid 39:4d285e961435 3965 #else // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 3966 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 3967 #endif // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 3968 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3969 //~ cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 3970 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3971 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 3972 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 3973 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 3974 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 9:45f98573eb6d 3975 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 9:45f98573eb6d 3976 //
whismanoid 17:9397ea3ea7e9 3977 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 4:d9b05924ad4c 3978 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 9:45f98573eb6d 3979 //
whismanoid 17:9397ea3ea7e9 3980 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 3981 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 17:9397ea3ea7e9 3982 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 3983 //
whismanoid 9:45f98573eb6d 3984 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 3985 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 3986 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 3987 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 9:45f98573eb6d 3988 //
whismanoid 17:9397ea3ea7e9 3989 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 9:45f98573eb6d 3990 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 3991 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 3992 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 3993 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 3994 //
whismanoid 17:9397ea3ea7e9 3995 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3996 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 17:9397ea3ea7e9 3997 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 9:45f98573eb6d 3998 //
whismanoid 9:45f98573eb6d 3999 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 4000 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 4001 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 4002 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 4003 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 9:45f98573eb6d 4004 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 9:45f98573eb6d 4005 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 9:45f98573eb6d 4006 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 9:45f98573eb6d 4007 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 9:45f98573eb6d 4008 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 9:45f98573eb6d 4009 //
whismanoid 9:45f98573eb6d 4010 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 4011 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 9:45f98573eb6d 4012 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 9:45f98573eb6d 4013 //
whismanoid 9:45f98573eb6d 4014 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 4015 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 4016 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 9:45f98573eb6d 4017 //
whismanoid 9:45f98573eb6d 4018 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 4019 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 9:45f98573eb6d 4020 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 4021 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 9:45f98573eb6d 4022 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 4023 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 9:45f98573eb6d 4024 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 4025 //
whismanoid 9:45f98573eb6d 4026 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 4027 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 9:45f98573eb6d 4028 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 9:45f98573eb6d 4029 //
whismanoid 9:45f98573eb6d 4030 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 4031 //
whismanoid 9:45f98573eb6d 4032 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 4033 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 4034 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 4035 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 4036 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 9:45f98573eb6d 4037 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4038 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 9:45f98573eb6d 4039 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4040 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4041 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 9:45f98573eb6d 4042 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4043 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 9:45f98573eb6d 4044 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4045 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 9:45f98573eb6d 4046 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4047 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4048 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 9:45f98573eb6d 4049 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4050 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 4051 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 4052 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 4053 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 4054 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 4055 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 4056 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 4057 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 4058 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 4059 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 4060 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 4061 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 4062 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 4063 //
whismanoid 4:d9b05924ad4c 4064 //cmdLine.serial().print(F("\r\n ! -- Initial Configuration"));
whismanoid 4:d9b05924ad4c 4065 //
whismanoid 4:d9b05924ad4c 4066 // % standardize diagnostic commands
whismanoid 4:d9b05924ad4c 4067 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 4068 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 4069 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 4070 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 4071 // %Ppin df=xx -- pwm output
whismanoid 4:d9b05924ad4c 4072 // %Wpin -- measure high pulsewidth input in usec
whismanoid 4:d9b05924ad4c 4073 // %wpin -- measure low pulsewidth input in usec
whismanoid 4:d9b05924ad4c 4074 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 4075 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 4076 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 4077 // %IW ADDR=? cmd=? data,data,data -- write
whismanoid 4:d9b05924ad4c 4078 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 4079 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4080 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 4081 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 4082 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 4083 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 4084 // A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 4085 //
whismanoid 23:c6c652bef4b9 4086 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 4087 #if USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4088 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 4089 // TODO: %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 4090 // TODO: future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 4091 // TODO: future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 4092 // TODO: %B1@ view command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 4093 // TODO: %B1@+ command add new row (if there is room to add) (ignore one space before command)
whismanoid 23:c6c652bef4b9 4094 // TODO: %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 4095 // TODO: %B1@-~~~ clear entire command table
whismanoid 23:c6c652bef4b9 4096 // TODO: %B1@nnn command replace row number nnn (ignore one space before command)
whismanoid 23:c6c652bef4b9 4097 // TODO: %B1@! disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 4098 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 4099 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 45:74bf1fe021e5 4100 // cmdLine.serial().printf("\r\n %%B1! trigger Button1 event; %%B1@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4101 cmdLine.serial().printf("\r\n %%B1! trigger Button1 event;");
whismanoid 45:74bf1fe021e5 4102 // print maximum index for %B1 submenu
whismanoid 45:74bf1fe021e5 4103 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4104 cmdLine.serial().printf(" %%B9@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4105 #elif HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4106 cmdLine.serial().printf(" %%B8@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4107 #elif HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4108 cmdLine.serial().printf(" %%B7@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4109 #elif HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4110 cmdLine.serial().printf(" %%B6@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4111 #elif HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4112 cmdLine.serial().printf(" %%B5@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4113 #elif HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4114 cmdLine.serial().printf(" %%B4@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4115 #elif HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4116 cmdLine.serial().printf(" %%B3@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4117 #elif HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4118 cmdLine.serial().printf(" %%B2@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4119 #elif HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4120 cmdLine.serial().printf(" %%B1@ -- view/edit command table");
whismanoid 45:74bf1fe021e5 4121 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 45:74bf1fe021e5 4122
whismanoid 45:74bf1fe021e5 4123
whismanoid 23:c6c652bef4b9 4124 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4125 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 4126 #if HAS_digitalInOuts
whismanoid 4:d9b05924ad4c 4127 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 4128 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 4129 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 4130 cmdLine.serial().printf("\r\n %%Hn {pin:");
whismanoid 4:d9b05924ad4c 4131 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 4132 cmdLine.serial().printf("} -- High Output");
whismanoid 4:d9b05924ad4c 4133 cmdLine.serial().printf("\r\n %%Ln {pin:");
whismanoid 4:d9b05924ad4c 4134 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 4135 cmdLine.serial().printf("} -- Low Output");
whismanoid 4:d9b05924ad4c 4136 cmdLine.serial().printf("\r\n %%?n {pin:");
whismanoid 4:d9b05924ad4c 4137 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 4138 cmdLine.serial().printf("} -- Input");
whismanoid 4:d9b05924ad4c 4139 #endif
whismanoid 4:d9b05924ad4c 4140
whismanoid 4:d9b05924ad4c 4141 #if HAS_analogIns
whismanoid 4:d9b05924ad4c 4142 // Menu A) analogRead A0..7
whismanoid 4:d9b05924ad4c 4143 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 4144 // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0)
whismanoid 37:3f369235e5bc 4145 cmdLine.serial().printf("\r\n %%A -- analogRead");
whismanoid 37:3f369235e5bc 4146 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4147 // %A avg=%d -- help string display Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 4148 cmdLine.serial().printf("; %%A avg=%d -- average", Platform_AIN_Average_N);
whismanoid 37:3f369235e5bc 4149 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4150 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4151 // %A cal? view/export raw calibration values for all channels
whismanoid 37:3f369235e5bc 4152 cmdLine.serial().printf("; %%A cal? -- calibration");
whismanoid 34:a1993a1ee904 4153 #endif // HAS_Platform_AIN_Calibration
whismanoid 4:d9b05924ad4c 4154 #endif
whismanoid 4:d9b05924ad4c 4155
whismanoid 4:d9b05924ad4c 4156 #if HAS_SPI2_MAX541
whismanoid 4:d9b05924ad4c 4157 // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 4:d9b05924ad4c 4158 cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)");
whismanoid 4:d9b05924ad4c 4159 #endif
whismanoid 4:d9b05924ad4c 4160
whismanoid 46:469d0061df5d 4161 //--------------------------------------------------
whismanoid 46:469d0061df5d 4162 #if defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 4163 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 4164 // cmdLine.serial().printf("\r\n %%F -- flash support");
whismanoid 46:469d0061df5d 4165 # if HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4166 // flash peek memory %F peek=0x0007ff00 len=0x0100 -- hex dump
whismanoid 46:469d0061df5d 4167 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 4168 # endif // HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4169 # if HAS_FLASH_POKE
whismanoid 46:469d0061df5d 4170 // flash poke memory %F poke=0x0007ff00 0xab 0xcd 0xef 0x27 0x18 0x28 -- erase/write flash page
whismanoid 46:469d0061df5d 4171 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 4172 # endif // HAS_FLASH_POKE
whismanoid 46:469d0061df5d 4173 # if HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 4174 cmdLine.serial().printf("\r\n %%F save=0xFF -- erase config; %%F save=0 -- save all config");
whismanoid 46:469d0061df5d 4175 cmdLine.serial().printf("\r\n %%F load -- load all config");
whismanoid 46:469d0061df5d 4176 # endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 4177 #endif
whismanoid 46:469d0061df5d 4178
whismanoid 4:d9b05924ad4c 4179 #if HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4180 // TODO: support I2C HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4181 // VERIFY: I2C utility commands SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4182 // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz);
whismanoid 4:d9b05924ad4c 4183 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 4184 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 4185 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 4186 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 4:d9b05924ad4c 4187 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 4188 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4189 //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope
whismanoid 4:d9b05924ad4c 4190 cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 4:d9b05924ad4c 4191 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 4:d9b05924ad4c 4192 (g_I2C_SCL_Hz / 1000.));
whismanoid 4:d9b05924ad4c 4193 cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read",
whismanoid 4:d9b05924ad4c 4194 g_I2C_deviceAddress7);
whismanoid 4:d9b05924ad4c 4195 //
whismanoid 4:d9b05924ad4c 4196 #if SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4197 // Menu ^ cmd=?) i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4198 cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data");
whismanoid 4:d9b05924ad4c 4199 // test low-level I2C i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 4200 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4201 //cmdLine.serial().printf(" H) Hunt for attached I2C devices");
whismanoid 4:d9b05924ad4c 4202 cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices");
whismanoid 4:d9b05924ad4c 4203 // cmdLine.serial().printf(" s) search i2c address");
whismanoid 4:d9b05924ad4c 4204 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 4205
whismanoid 4:d9b05924ad4c 4206 #if HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 4207 // TODO: support SPI HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 4208 // SPI test command S (mosiData)+
whismanoid 4:d9b05924ad4c 4209 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 4210 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 4211 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 4212 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 4213 // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 4:d9b05924ad4c 4214 // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 4:d9b05924ad4c 4215 // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 4:d9b05924ad4c 4216 // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 4:d9b05924ad4c 4217 // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 4:d9b05924ad4c 4218 // mode | POL PHA
whismanoid 4:d9b05924ad4c 4219 // -----+--------
whismanoid 4:d9b05924ad4c 4220 // 0 | 0 0
whismanoid 4:d9b05924ad4c 4221 // 1 | 0 1
whismanoid 4:d9b05924ad4c 4222 // 2 | 1 0
whismanoid 4:d9b05924ad4c 4223 // 3 | 1 1
whismanoid 4:d9b05924ad4c 4224 //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0");
whismanoid 4:d9b05924ad4c 4225 // 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 4226 cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config",
whismanoid 4:d9b05924ad4c 4227 g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.),
whismanoid 4:d9b05924ad4c 4228 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 4:d9b05924ad4c 4229 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0));
whismanoid 4:d9b05924ad4c 4230 cmdLine.serial().printf("\r\n %%SD -- SPI diagnostic messages ");
whismanoid 4:d9b05924ad4c 4231 if (g_MAX11410_device.onSPIprint) {
whismanoid 4:d9b05924ad4c 4232 cmdLine.serial().printf("hide");
whismanoid 4:d9b05924ad4c 4233 }
whismanoid 4:d9b05924ad4c 4234 else {
whismanoid 4:d9b05924ad4c 4235 cmdLine.serial().printf("show");
whismanoid 4:d9b05924ad4c 4236 }
whismanoid 4:d9b05924ad4c 4237 cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes");
whismanoid 4:d9b05924ad4c 4238 // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0
whismanoid 4:d9b05924ad4c 4239 #endif // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 4240 //
whismanoid 4:d9b05924ad4c 4241 // Application-specific commands (help text) here
whismanoid 4:d9b05924ad4c 4242 //
whismanoid 4:d9b05924ad4c 4243 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 4244 cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 4245 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 4246 //
whismanoid 4:d9b05924ad4c 4247
whismanoid 4:d9b05924ad4c 4248 //~ extern void MAX11410_menu_help(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp\n
whismanoid 4:d9b05924ad4c 4249 //~ MAX11410_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 4250 }
whismanoid 4:d9b05924ad4c 4251 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 4252
whismanoid 4:d9b05924ad4c 4253 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 15:37c83ec50ea0 4254
whismanoid 15:37c83ec50ea0 4255 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 4256 void pinsMonitor_submenu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 15:37c83ec50ea0 4257 {
whismanoid 15:37c83ec50ea0 4258 // % diagnostic commands submenu
whismanoid 15:37c83ec50ea0 4259 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 4260 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 4261 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 4262 // %A %Apin -- analog input
whismanoid 15:37c83ec50ea0 4263 // %Ppin df=xx -- pwm output
whismanoid 15:37c83ec50ea0 4264 // %Wpin -- measure high pulsewidth input in usec
whismanoid 15:37c83ec50ea0 4265 // %wpin -- measure low pulsewidth input in usec
whismanoid 15:37c83ec50ea0 4266 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 4267 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 4268 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 4269 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 4270 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 4271 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 4272 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 4273 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 4274 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 4275 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 4276 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 4277 //
whismanoid 15:37c83ec50ea0 4278 char strPinIndex[3];
whismanoid 15:37c83ec50ea0 4279 strPinIndex[0] = cmdLine[2];
whismanoid 15:37c83ec50ea0 4280 strPinIndex[1] = cmdLine[3];
whismanoid 15:37c83ec50ea0 4281 strPinIndex[2] = '\0';
whismanoid 15:37c83ec50ea0 4282 int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 15:37c83ec50ea0 4283 //cmdLine.serial().printf(" pinIndex=%d ", pinIndex);
whismanoid 15:37c83ec50ea0 4284 //
whismanoid 15:37c83ec50ea0 4285 // get next character
whismanoid 15:37c83ec50ea0 4286 switch (cmdLine[1])
whismanoid 15:37c83ec50ea0 4287 {
whismanoid 23:c6c652bef4b9 4288 //--------------------------------------------------
whismanoid 46:469d0061df5d 4289 #if defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 4290 // MAX32625 flash peek/poke support (MAX40108 demo) #312
whismanoid 46:469d0061df5d 4291 case 'F': case 'f':
whismanoid 46:469d0061df5d 4292 {
whismanoid 46:469d0061df5d 4293 # if HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4294 // Limit the ranges where memory write operation will be allowed
whismanoid 46:469d0061df5d 4295 // FLASH (rx) : ORIGIN = 0x00010000, LENGTH = 0x00070000
whismanoid 46:469d0061df5d 4296 //~ const uint32_t poke_flash_min = 0x00010000;
whismanoid 46:469d0061df5d 4297 //~ const uint32_t poke_flash_max = 0x0007FFFF;
whismanoid 46:469d0061df5d 4298 // RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00028000
whismanoid 46:469d0061df5d 4299 //~ const uint32_t poke_ram_min = 0x20000000;
whismanoid 46:469d0061df5d 4300 //~ const uint32_t poke_ram_max = 0x20027FFF;
whismanoid 46:469d0061df5d 4301 //
whismanoid 46:469d0061df5d 4302 // flash peek memory %F peek=0x0007ff00 len=0x0100 -- hex dump
whismanoid 46:469d0061df5d 4303 // get "len" keyword, default 1
whismanoid 46:469d0061df5d 4304 uint32_t peek_len = 1;
whismanoid 46:469d0061df5d 4305 if (cmdLine.parse_uint32_hex("len", peek_len))
whismanoid 46:469d0061df5d 4306 {
whismanoid 46:469d0061df5d 4307 }
whismanoid 46:469d0061df5d 4308 // get "peek" keyword, do peek operation if keyword is present
whismanoid 46:469d0061df5d 4309 uint32_t peek_addr = 0x00010000;
whismanoid 46:469d0061df5d 4310 if (cmdLine.parse_uint32_hex("peek", peek_addr))
whismanoid 46:469d0061df5d 4311 {
whismanoid 46:469d0061df5d 4312 // #312 hex dump memory from peek_addr length peek_len
whismanoid 46:469d0061df5d 4313 peek_addr = peek_addr &~ 0x00000003; // 32-bit word align
whismanoid 46:469d0061df5d 4314 //
whismanoid 46:469d0061df5d 4315 // scan poke_access_list[] for peek_addr
whismanoid 46:469d0061df5d 4316 int poke_access_list_index = search_poke_access_list(peek_addr);
whismanoid 46:469d0061df5d 4317 // post: poke_access_list[poke_access_list_index].addr_min is lowest address of range
whismanoid 46:469d0061df5d 4318 // post: poke_access_list[poke_access_list_index].addr_max is highest address of range
whismanoid 46:469d0061df5d 4319 // post: poke_access_list[poke_access_list_index].name
whismanoid 46:469d0061df5d 4320 // 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 4321 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 46:469d0061df5d 4322 poke_access_list_index,
whismanoid 46:469d0061df5d 4323 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 4324 poke_access_list[poke_access_list_index].addr_min,
whismanoid 46:469d0061df5d 4325 poke_access_list[poke_access_list_index].addr_max,
whismanoid 46:469d0061df5d 4326 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 46:469d0061df5d 4327 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x04)
whismanoid 46:469d0061df5d 4328 {
whismanoid 46:469d0061df5d 4329 cmdLine.serial().printf("flashPoke ");
whismanoid 46:469d0061df5d 4330 }
whismanoid 46:469d0061df5d 4331 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x02)
whismanoid 46:469d0061df5d 4332 {
whismanoid 46:469d0061df5d 4333 cmdLine.serial().printf("ramPoke ");
whismanoid 46:469d0061df5d 4334 }
whismanoid 46:469d0061df5d 4335 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x01)
whismanoid 46:469d0061df5d 4336 {
whismanoid 46:469d0061df5d 4337 cmdLine.serial().printf("read ");
whismanoid 46:469d0061df5d 4338 }
whismanoid 46:469d0061df5d 4339 //
whismanoid 46:469d0061df5d 4340 //~ cmdLine.serial().printf("\r\n0x%8.8lx: ", peek_addr);
whismanoid 46:469d0061df5d 4341 if ((peek_addr & 0x0F) != 0)
whismanoid 46:469d0061df5d 4342 {
whismanoid 46:469d0061df5d 4343 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4344 }
whismanoid 46:469d0061df5d 4345 while (peek_len > 0)
whismanoid 46:469d0061df5d 4346 {
whismanoid 46:469d0061df5d 4347 if ((peek_addr & 0x0F) == 0)
whismanoid 46:469d0061df5d 4348 {
whismanoid 46:469d0061df5d 4349 poke_access_list_index = search_poke_access_list(peek_addr);
whismanoid 46:469d0061df5d 4350 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4351 }
whismanoid 46:469d0061df5d 4352 if (poke_access_list[poke_access_list_index].can_flash_write_read & 1)
whismanoid 46:469d0061df5d 4353 {
whismanoid 46:469d0061df5d 4354 // read memory by using peek_addr as a uint32_t pointer
whismanoid 46:469d0061df5d 4355 cmdLine.serial().printf("0x%8.8lx ", *((uint32_t*)peek_addr));
whismanoid 46:469d0061df5d 4356 }
whismanoid 46:469d0061df5d 4357 else
whismanoid 46:469d0061df5d 4358 {
whismanoid 46:469d0061df5d 4359 // read operation is forbidden in this address range
whismanoid 46:469d0061df5d 4360 cmdLine.serial().printf("__________ ");
whismanoid 46:469d0061df5d 4361 }
whismanoid 46:469d0061df5d 4362 peek_addr += 4;
whismanoid 46:469d0061df5d 4363 peek_len--;
whismanoid 46:469d0061df5d 4364 }
whismanoid 46:469d0061df5d 4365 }
whismanoid 46:469d0061df5d 4366 # endif // HAS_FLASH_PEEK
whismanoid 46:469d0061df5d 4367 # if HAS_FLASH_POKE
whismanoid 46:469d0061df5d 4368 // flash poke memory %F poke=0x0007ff00 0xab 0xcd 0xef 0x27 0x18 0x28 -- erase/write flash page
whismanoid 46:469d0061df5d 4369 // get "poke" keyword, do poke operation if keyword is present
whismanoid 46:469d0061df5d 4370 uint32_t poke_addr = 0x20000000;
whismanoid 46:469d0061df5d 4371 if (cmdLine.parse_uint32_hex("poke", poke_addr))
whismanoid 46:469d0061df5d 4372 {
whismanoid 46:469d0061df5d 4373 size_t byteCount = 0;
whismanoid 46:469d0061df5d 4374 uint8_t pokeDataBuf[16];
whismanoid 46:469d0061df5d 4375 // get list of bytes after processing keywords
whismanoid 46:469d0061df5d 4376 // bool parse_byteCount_byteList_hex(size_t& byteCount, char *mosiDataBuf, size_t mosiDataBufSize);
whismanoid 46:469d0061df5d 4377 if (cmdLine.parse_byteCount_byteList_hex(byteCount, ((char *)pokeDataBuf), sizeof(pokeDataBuf)))
whismanoid 46:469d0061df5d 4378 {
whismanoid 46:469d0061df5d 4379 // #312 write memory at poke_addr
whismanoid 46:469d0061df5d 4380 poke_addr = poke_addr &~ 0x00000003; // 32-bit word align
whismanoid 46:469d0061df5d 4381 //
whismanoid 46:469d0061df5d 4382 // scan poke_access_list[] for poke_addr
whismanoid 46:469d0061df5d 4383 int poke_access_list_index = search_poke_access_list(poke_addr);
whismanoid 46:469d0061df5d 4384 // post: poke_access_list[poke_access_list_index].addr_min is lowest address of range
whismanoid 46:469d0061df5d 4385 // post: poke_access_list[poke_access_list_index].addr_max is highest address of range
whismanoid 46:469d0061df5d 4386 // post: poke_access_list[poke_access_list_index].name
whismanoid 46:469d0061df5d 4387 // 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 4388 cmdLine.serial().printf("\r\npoke_access_list[%d] %5s 0x%8.8lx - 0x%8.8lx access %x ",
whismanoid 46:469d0061df5d 4389 poke_access_list_index,
whismanoid 46:469d0061df5d 4390 poke_access_list[poke_access_list_index].name,
whismanoid 46:469d0061df5d 4391 poke_access_list[poke_access_list_index].addr_min,
whismanoid 46:469d0061df5d 4392 poke_access_list[poke_access_list_index].addr_max,
whismanoid 46:469d0061df5d 4393 poke_access_list[poke_access_list_index].can_flash_write_read);
whismanoid 46:469d0061df5d 4394 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x04)
whismanoid 46:469d0061df5d 4395 {
whismanoid 46:469d0061df5d 4396 cmdLine.serial().printf("flashPoke ");
whismanoid 46:469d0061df5d 4397 }
whismanoid 46:469d0061df5d 4398 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x02)
whismanoid 46:469d0061df5d 4399 {
whismanoid 46:469d0061df5d 4400 cmdLine.serial().printf("ramPoke ");
whismanoid 46:469d0061df5d 4401 }
whismanoid 46:469d0061df5d 4402 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x01)
whismanoid 46:469d0061df5d 4403 {
whismanoid 46:469d0061df5d 4404 cmdLine.serial().printf("read ");
whismanoid 46:469d0061df5d 4405 }
whismanoid 46:469d0061df5d 4406 //
whismanoid 46:469d0061df5d 4407 if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x0004)
whismanoid 46:469d0061df5d 4408 {
whismanoid 46:469d0061df5d 4409 //------------------------------
whismanoid 46:469d0061df5d 4410 // mbed interface to on-chip Flash
whismanoid 46:469d0061df5d 4411 // FlashIAP flash;
whismanoid 46:469d0061df5d 4412 // Maxim MAX32625 flash interface flc.h not .\mbed-os\drivers\FlashIAP.h
whismanoid 46:469d0061df5d 4413 // .\mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\mxc\flc.h
whismanoid 46:469d0061df5d 4414 // .\mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\mxc\flc.c
whismanoid 46:469d0061df5d 4415 //
whismanoid 46:469d0061df5d 4416 // MAX32625IWY+ Flash 512Kbyte in 64 pages of 8Kbyte per page
whismanoid 46:469d0061df5d 4417 static uint8_t pageBuf[8192];
whismanoid 46:469d0061df5d 4418 uint32_t pageBuf_addr = poke_addr &~ 0x1FFF; // 32-bit word align, 8Kbyte page boundary
whismanoid 46:469d0061df5d 4419 //
whismanoid 46:469d0061df5d 4420 // poke_addr is in FLASH address range, there's more steps
whismanoid 46:469d0061df5d 4421 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: flashPoke ...",
whismanoid 46:469d0061df5d 4422 poke_access_list[poke_access_list_index].name, poke_addr);
whismanoid 46:469d0061df5d 4423 // initialize flash memory interface
whismanoid 46:469d0061df5d 4424 // FlashIAP: FlashIAP flash; flash.init();
whismanoid 46:469d0061df5d 4425 // int FLC_Init(void);
whismanoid 46:469d0061df5d 4426 // returns E_NO_ERROR or E_BUSY or E_UNKNOWN
whismanoid 46:469d0061df5d 4427 cmdLine.serial().printf("FLC_Init ");
whismanoid 46:469d0061df5d 4428 if (FLC_Init() != E_NO_ERROR)
whismanoid 46:469d0061df5d 4429 {
whismanoid 46:469d0061df5d 4430 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4431 break; // can't perform the command
whismanoid 46:469d0061df5d 4432 }
whismanoid 46:469d0061df5d 4433 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4434 //
whismanoid 46:469d0061df5d 4435 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: start of 8KByte page containing 0x%8.8lx...",
whismanoid 46:469d0061df5d 4436 poke_access_list[poke_access_list_index].name, pageBuf_addr, poke_addr);
whismanoid 46:469d0061df5d 4437 //
whismanoid 46:469d0061df5d 4438 // page read, update buffer from command line bytes, page erase, page write
whismanoid 46:469d0061df5d 4439 cmdLine.serial().printf("\r\nPgBuf 0x%8.8lx: copy page buffer, len=0x%x words = 0x%x bytes...",
whismanoid 46:469d0061df5d 4440 pageBuf_addr, sizeof(pageBuf)/4, sizeof(pageBuf));
whismanoid 46:469d0061df5d 4441 // memcpy(uint32_t *out, uint32_t *in, unsigned int count)
whismanoid 46:469d0061df5d 4442 memcpy(&pageBuf[0], (uint32_t*)pageBuf_addr, sizeof(pageBuf));
whismanoid 46:469d0061df5d 4443 //
whismanoid 46:469d0061df5d 4444 cmdLine.serial().printf("\r\nPgBuf 0x%8.8lx: udpate page buffer ...", poke_addr);
whismanoid 46:469d0061df5d 4445 // update buffer from command line bytes using my cmdline lib
whismanoid 46:469d0061df5d 4446 // ignore pokeDataBuf[0], its 0x0F because this is command F. :(
whismanoid 46:469d0061df5d 4447 for (size_t byteIndex = 1; byteIndex < byteCount; byteIndex += 4)
whismanoid 46:469d0061df5d 4448 {
whismanoid 46:469d0061df5d 4449 // How to handle big-endian vs little-endian?
whismanoid 46:469d0061df5d 4450 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 0] = pokeDataBuf[byteIndex + 3];
whismanoid 46:469d0061df5d 4451 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 1] = pokeDataBuf[byteIndex + 2];
whismanoid 46:469d0061df5d 4452 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 2] = pokeDataBuf[byteIndex + 1];
whismanoid 46:469d0061df5d 4453 pageBuf[(poke_addr - pageBuf_addr + byteIndex-1) + 3] = pokeDataBuf[byteIndex + 0];
whismanoid 46:469d0061df5d 4454 // seems 0x12 0x34 0x56 0x78 becomes 0x78563412
whismanoid 46:469d0061df5d 4455 uint32_t wordbuf = 0
whismanoid 46:469d0061df5d 4456 | ((uint32_t)pokeDataBuf[byteIndex + 0] << 24)
whismanoid 46:469d0061df5d 4457 | ((uint32_t)pokeDataBuf[byteIndex + 1] << 16)
whismanoid 46:469d0061df5d 4458 | ((uint32_t)pokeDataBuf[byteIndex + 2] << 8)
whismanoid 46:469d0061df5d 4459 | ((uint32_t)pokeDataBuf[byteIndex + 3] << 0)
whismanoid 46:469d0061df5d 4460 ;
whismanoid 46:469d0061df5d 4461 cmdLine.serial().printf("\r\nPgBuf[0x%8.8lx] = FLASH 0x%8.8lx: ",
whismanoid 46:469d0061df5d 4462 (poke_addr - pageBuf_addr + byteIndex-1), (poke_addr + byteIndex-1));
whismanoid 46:469d0061df5d 4463 cmdLine.serial().printf("0x%8.8lx ", wordbuf);
whismanoid 46:469d0061df5d 4464 // poke_addr += 4;
whismanoid 46:469d0061df5d 4465 }
whismanoid 46:469d0061df5d 4466 //
whismanoid 46:469d0061df5d 4467 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: erase page ...",
whismanoid 46:469d0061df5d 4468 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 4469 // page erase using flash.erase(addr, flash.get_sector_size(addr));
whismanoid 46:469d0061df5d 4470 // int FLC_PageErase(uint32_t address, MXC_V_FLC_ERASE_CODE_PAGE_ERASE, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 4471 // @param address Address of the page to be erased.
whismanoid 46:469d0061df5d 4472 // @param erase_code Flash erase code; defined as
whismanoid 46:469d0061df5d 4473 // #MXC_V_FLC_ERASE_CODE_PAGE_ERASE for page erase
whismanoid 46:469d0061df5d 4474 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 4475 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 4476 if (FLC_PageErase(pageBuf_addr, MXC_V_FLC_ERASE_CODE_PAGE_ERASE,
whismanoid 46:469d0061df5d 4477 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 4478 {
whismanoid 46:469d0061df5d 4479 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4480 break; // can't perform the command
whismanoid 46:469d0061df5d 4481 }
whismanoid 46:469d0061df5d 4482 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4483 //
whismanoid 46:469d0061df5d 4484 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: write page buffer ...",
whismanoid 46:469d0061df5d 4485 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 4486 // page write using flash.program(page_buffer, addr, page_size);
whismanoid 46:469d0061df5d 4487 // int FLC_Write(uint32_t address, const void *data, uint32_t length, MXC_V_FLC_FLSH_UNLOCK_KEY);
whismanoid 46:469d0061df5d 4488 // @param address Start address for desired write. @note This address
whismanoid 46:469d0061df5d 4489 // must be 32-bit word aligned
whismanoid 46:469d0061df5d 4490 // @param data A pointer to the buffer containing the data to write.
whismanoid 46:469d0061df5d 4491 // @param length Size of the data to write in bytes. @note The length
whismanoid 46:469d0061df5d 4492 // must be in 32-bit multiples.
whismanoid 46:469d0061df5d 4493 // @param unlock_key Unlock key, #MXC_V_FLC_FLSH_UNLOCK_KEY.
whismanoid 46:469d0061df5d 4494 // returns E_NO_ERROR or else
whismanoid 46:469d0061df5d 4495 if (FLC_Write(pageBuf_addr, (uint32_t*)&pageBuf[0], sizeof(pageBuf),
whismanoid 46:469d0061df5d 4496 MXC_V_FLC_FLSH_UNLOCK_KEY) != E_NO_ERROR)
whismanoid 46:469d0061df5d 4497 {
whismanoid 46:469d0061df5d 4498 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4499 break; // can't perform the command
whismanoid 46:469d0061df5d 4500 }
whismanoid 46:469d0061df5d 4501 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4502 //
whismanoid 46:469d0061df5d 4503 // FlashIAP: close flash memory interface flash.deinit();
whismanoid 46:469d0061df5d 4504 //
whismanoid 46:469d0061df5d 4505 // verify buffer matches flash page, or fail
whismanoid 46:469d0061df5d 4506 // for verification, perform %F peek=(poke_addr) len=(from byteCount)
whismanoid 46:469d0061df5d 4507 // hex dump memory from peek_addr length peek_len
whismanoid 46:469d0061df5d 4508 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: verify page buffer ...",
whismanoid 46:469d0061df5d 4509 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 4510 int verify_failed = 0;
whismanoid 46:469d0061df5d 4511 peek_addr = poke_addr;
whismanoid 46:469d0061df5d 4512 peek_len = (byteCount - 1)/4;
whismanoid 46:469d0061df5d 4513 //~ cmdLine.serial().printf("\r\n0x%8.8lx: ", peek_addr);
whismanoid 46:469d0061df5d 4514 if ((peek_addr & 0x0F) != 0)
whismanoid 46:469d0061df5d 4515 {
whismanoid 46:469d0061df5d 4516 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4517 }
whismanoid 46:469d0061df5d 4518 while (peek_len > 0)
whismanoid 46:469d0061df5d 4519 {
whismanoid 46:469d0061df5d 4520 if ((peek_addr & 0x0F) == 0)
whismanoid 46:469d0061df5d 4521 {
whismanoid 46:469d0061df5d 4522 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ", poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4523 }
whismanoid 46:469d0061df5d 4524 // read memory by using peek_addr as a uint32_t pointer
whismanoid 46:469d0061df5d 4525 // cmdLine.serial().printf("0x%8.8lx ", *((uint32_t*)peek_addr));
whismanoid 46:469d0061df5d 4526 // #312 %F peek verify, report fail if mismatch page buffer
whismanoid 46:469d0061df5d 4527 uint32_t expect_data = 0
whismanoid 46:469d0061df5d 4528 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 3] << 24)
whismanoid 46:469d0061df5d 4529 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 2] << 16)
whismanoid 46:469d0061df5d 4530 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 1] << 8)
whismanoid 46:469d0061df5d 4531 | ((uint32_t)pageBuf[peek_addr - pageBuf_addr + 0] << 0)
whismanoid 46:469d0061df5d 4532 ;
whismanoid 46:469d0061df5d 4533 uint32_t actual_data = *((uint32_t*)peek_addr);
whismanoid 46:469d0061df5d 4534 if (actual_data == expect_data)
whismanoid 46:469d0061df5d 4535 {
whismanoid 46:469d0061df5d 4536 // this word matches
whismanoid 46:469d0061df5d 4537 cmdLine.serial().printf("=0x%8.8lx ", actual_data);
whismanoid 46:469d0061df5d 4538 }
whismanoid 46:469d0061df5d 4539 else
whismanoid 46:469d0061df5d 4540 {
whismanoid 46:469d0061df5d 4541 // mismatch, verification failed
whismanoid 46:469d0061df5d 4542 cmdLine.serial().printf("#0x%8.8lx(expected 0x%8.8lx)\r\n%5s 0x%8.8lx: ",
whismanoid 46:469d0061df5d 4543 actual_data, expect_data,
whismanoid 46:469d0061df5d 4544 poke_access_list[poke_access_list_index].name, peek_addr);
whismanoid 46:469d0061df5d 4545 verify_failed++;
whismanoid 46:469d0061df5d 4546 }
whismanoid 46:469d0061df5d 4547 //
whismanoid 46:469d0061df5d 4548 peek_addr += 4;
whismanoid 46:469d0061df5d 4549 peek_len--;
whismanoid 46:469d0061df5d 4550 }
whismanoid 46:469d0061df5d 4551 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: verify page buffer ",
whismanoid 46:469d0061df5d 4552 poke_access_list[poke_access_list_index].name, pageBuf_addr);
whismanoid 46:469d0061df5d 4553 if (verify_failed)
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 } // end of flashPoke operation
whismanoid 46:469d0061df5d 4561 else if (poke_access_list[poke_access_list_index].can_flash_write_read & 0x0002)
whismanoid 46:469d0061df5d 4562 {
whismanoid 46:469d0061df5d 4563 // poke_addr is in RAM address range, write directly
whismanoid 46:469d0061df5d 4564 cmdLine.serial().printf("\r\n%5s 0x%8.8lx: ramPoke ", poke_access_list[poke_access_list_index].name, poke_addr);
whismanoid 46:469d0061df5d 4565 // ignore pokeDataBuf[0], its 0x0F because this is command F. :(
whismanoid 46:469d0061df5d 4566 for (size_t byteIndex = 1; byteIndex < byteCount; byteIndex += 4)
whismanoid 46:469d0061df5d 4567 {
whismanoid 46:469d0061df5d 4568 // How to handle big-endian vs little-endian?
whismanoid 46:469d0061df5d 4569 // seems 0x12 0x34 0x56 0x78 becomes 0x78563412
whismanoid 46:469d0061df5d 4570 poke_addr += 4;
whismanoid 46:469d0061df5d 4571 uint32_t wordbuf = 0
whismanoid 46:469d0061df5d 4572 | ((uint32_t)pokeDataBuf[byteIndex + 0] << 24)
whismanoid 46:469d0061df5d 4573 | ((uint32_t)pokeDataBuf[byteIndex + 1] << 16)
whismanoid 46:469d0061df5d 4574 | ((uint32_t)pokeDataBuf[byteIndex + 2] << 8)
whismanoid 46:469d0061df5d 4575 | ((uint32_t)pokeDataBuf[byteIndex + 3] << 0)
whismanoid 46:469d0061df5d 4576 ;
whismanoid 46:469d0061df5d 4577 cmdLine.serial().printf("0x%8.8lx ", wordbuf);
whismanoid 46:469d0061df5d 4578 //
whismanoid 46:469d0061df5d 4579 // write RAM by using poke_addr as a uint32_t pointer
whismanoid 46:469d0061df5d 4580 *((uint32_t*)poke_addr) = wordbuf;
whismanoid 46:469d0061df5d 4581 //
whismanoid 46:469d0061df5d 4582 // verify?
whismanoid 46:469d0061df5d 4583 if (*((uint32_t*)poke_addr) == wordbuf)
whismanoid 46:469d0061df5d 4584 {
whismanoid 46:469d0061df5d 4585 cmdLine.serial().printf("PASS ");
whismanoid 46:469d0061df5d 4586 }
whismanoid 46:469d0061df5d 4587 else
whismanoid 46:469d0061df5d 4588 {
whismanoid 46:469d0061df5d 4589 cmdLine.serial().printf("FAIL ");
whismanoid 46:469d0061df5d 4590 }
whismanoid 46:469d0061df5d 4591 }
whismanoid 46:469d0061df5d 4592 } // end of ramPoke operation
whismanoid 46:469d0061df5d 4593 else
whismanoid 46:469d0061df5d 4594 {
whismanoid 46:469d0061df5d 4595 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 4596 }
whismanoid 46:469d0061df5d 4597 }
whismanoid 46:469d0061df5d 4598 }
whismanoid 46:469d0061df5d 4599 # endif // HAS_FLASH_POKE
whismanoid 46:469d0061df5d 4600 # if HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 4601 uint32_t save_arg = 0;
whismanoid 46:469d0061df5d 4602 if (cmdLine.parse_uint32_hex("save", save_arg))
whismanoid 46:469d0061df5d 4603 {
whismanoid 46:469d0061df5d 4604 Save_flash_page_configuration_back_up(cmdLine, save_arg);
whismanoid 46:469d0061df5d 4605 }
whismanoid 46:469d0061df5d 4606 uint32_t load_arg = 0;
whismanoid 46:469d0061df5d 4607 if (cmdLine.parse_uint32_hex("load", load_arg))
whismanoid 46:469d0061df5d 4608 {
whismanoid 46:469d0061df5d 4609 Load_flash_page_configuration_back_up(cmdLine, load_arg);
whismanoid 46:469d0061df5d 4610 }
whismanoid 46:469d0061df5d 4611 # endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 4612 }
whismanoid 46:469d0061df5d 4613 break;
whismanoid 46:469d0061df5d 4614 #endif // defined(HAS_FLASH_PEEK) || defined(HAS_FLASH_POKE)
whismanoid 46:469d0061df5d 4615 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 4616 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 4617 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 4618 case 'B': case 'b':
whismanoid 23:c6c652bef4b9 4619 {
whismanoid 24:032f3683cb2a 4620 int command_table_button_index = 1;
whismanoid 23:c6c652bef4b9 4621 // %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 4622 // future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 4623 // future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 4624 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 4625 // cmdLine[2] == '1' selects onButton1_command_table
whismanoid 23:c6c652bef4b9 4626 char** command_table = onButton1_command_table;
whismanoid 23:c6c652bef4b9 4627 #endif
whismanoid 24:032f3683cb2a 4628 switch(cmdLine[2])
whismanoid 24:032f3683cb2a 4629 {
whismanoid 24:032f3683cb2a 4630 default:
whismanoid 24:032f3683cb2a 4631 case '1': case 'A': case 'a': case '!':
whismanoid 24:032f3683cb2a 4632 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4633 command_table_button_index = 1;
whismanoid 24:032f3683cb2a 4634 command_table = onButton1_command_table;
whismanoid 24:032f3683cb2a 4635 #endif
whismanoid 24:032f3683cb2a 4636 break;
whismanoid 24:032f3683cb2a 4637 case '2': case 'B': case 'b': case '@':
whismanoid 23:c6c652bef4b9 4638 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4639 command_table_button_index = 2;
whismanoid 24:032f3683cb2a 4640 command_table = onButton2_command_table;
whismanoid 24:032f3683cb2a 4641 #endif
whismanoid 24:032f3683cb2a 4642 break;
whismanoid 24:032f3683cb2a 4643 case '3': case 'C': case 'c': case '#':
whismanoid 23:c6c652bef4b9 4644 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4645 command_table_button_index = 3;
whismanoid 24:032f3683cb2a 4646 command_table = onButton3_command_table;
whismanoid 24:032f3683cb2a 4647 #endif
whismanoid 24:032f3683cb2a 4648 break;
whismanoid 29:6a9edb6e973b 4649 case '4':
whismanoid 29:6a9edb6e973b 4650 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4651 command_table_button_index = 4;
whismanoid 29:6a9edb6e973b 4652 command_table = onButton4_command_table;
whismanoid 29:6a9edb6e973b 4653 #endif
whismanoid 29:6a9edb6e973b 4654 break;
whismanoid 29:6a9edb6e973b 4655 case '5':
whismanoid 29:6a9edb6e973b 4656 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4657 command_table_button_index = 5;
whismanoid 29:6a9edb6e973b 4658 command_table = onButton5_command_table;
whismanoid 29:6a9edb6e973b 4659 #endif
whismanoid 29:6a9edb6e973b 4660 break;
whismanoid 29:6a9edb6e973b 4661 case '6':
whismanoid 29:6a9edb6e973b 4662 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4663 command_table_button_index = 6;
whismanoid 29:6a9edb6e973b 4664 command_table = onButton6_command_table;
whismanoid 29:6a9edb6e973b 4665 #endif
whismanoid 29:6a9edb6e973b 4666 break;
whismanoid 29:6a9edb6e973b 4667 case '7':
whismanoid 29:6a9edb6e973b 4668 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4669 command_table_button_index = 7;
whismanoid 29:6a9edb6e973b 4670 command_table = onButton7_command_table;
whismanoid 29:6a9edb6e973b 4671 #endif
whismanoid 29:6a9edb6e973b 4672 break;
whismanoid 29:6a9edb6e973b 4673 case '8':
whismanoid 29:6a9edb6e973b 4674 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4675 command_table_button_index = 8;
whismanoid 29:6a9edb6e973b 4676 command_table = onButton8_command_table;
whismanoid 29:6a9edb6e973b 4677 #endif
whismanoid 29:6a9edb6e973b 4678 break;
whismanoid 29:6a9edb6e973b 4679 case '9':
whismanoid 29:6a9edb6e973b 4680 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4681 command_table_button_index = 9;
whismanoid 29:6a9edb6e973b 4682 command_table = onButton9_command_table;
whismanoid 29:6a9edb6e973b 4683 #endif
whismanoid 29:6a9edb6e973b 4684 break;
whismanoid 24:032f3683cb2a 4685 }
whismanoid 24:032f3683cb2a 4686 //
whismanoid 23:c6c652bef4b9 4687 switch(cmdLine[3])
whismanoid 23:c6c652bef4b9 4688 {
whismanoid 23:c6c652bef4b9 4689 case '@':
whismanoid 23:c6c652bef4b9 4690 {
whismanoid 23:c6c652bef4b9 4691 // %B1@ view/edit command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 4692 int editRowIndex = 0;
whismanoid 23:c6c652bef4b9 4693 int command_table_row_count = 0;
whismanoid 23:c6c652bef4b9 4694 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 4695 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 4696 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 4697 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 4698 }
whismanoid 24:032f3683cb2a 4699 //
whismanoid 24:032f3683cb2a 4700 // ignore extra spaces before the command
whismanoid 24:032f3683cb2a 4701 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 24:032f3683cb2a 4702 int argIndex;
whismanoid 24:032f3683cb2a 4703 for (argIndex = 5; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 4704 {
whismanoid 24:032f3683cb2a 4705 if (cmdLine[argIndex] == ' ') break;
whismanoid 24:032f3683cb2a 4706 }
whismanoid 24:032f3683cb2a 4707 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 4708 {
whismanoid 24:032f3683cb2a 4709 if (cmdLine[argIndex] != ' ') break;
whismanoid 23:c6c652bef4b9 4710 }
whismanoid 23:c6c652bef4b9 4711 //
whismanoid 23:c6c652bef4b9 4712 // Edit the contents of command_table
whismanoid 23:c6c652bef4b9 4713 switch (cmdLine[4]) // %B1@... -- Edit the contents of command_table
whismanoid 23:c6c652bef4b9 4714 {
whismanoid 23:c6c652bef4b9 4715 case '0': case '1': case '2': case '3': case '4':
whismanoid 23:c6c652bef4b9 4716 case '5': case '6': case '7': case '8': case '9':
whismanoid 24:032f3683cb2a 4717 // %B1@nnn command replace row number nnn
whismanoid 23:c6c652bef4b9 4718 // edit row data
whismanoid 33:70a28cfe9e01 4719 // get row number to edit from cmdLine[4]
whismanoid 33:70a28cfe9e01 4720 editRowIndex = atoi(cmdLine.str()+4);
whismanoid 23:c6c652bef4b9 4721 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4722 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 4723 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 28:a9a3a9db592b 4724 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 4725 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 4726 cmdLine.serial().printf("\r\n cannot replace row %d with nothing",
whismanoid 28:a9a3a9db592b 4727 editRowIndex);
whismanoid 28:a9a3a9db592b 4728 }
whismanoid 28:a9a3a9db592b 4729 else
whismanoid 28:a9a3a9db592b 4730 {
whismanoid 28:a9a3a9db592b 4731 // update row
whismanoid 28:a9a3a9db592b 4732 cmdLine.serial().printf("\r\n replace row %d with \"%s\"",
whismanoid 28:a9a3a9db592b 4733 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 4734 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4735 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 4736 }
whismanoid 24:032f3683cb2a 4737 }
whismanoid 33:70a28cfe9e01 4738 } // end if (command_table_row_count > 0)
whismanoid 33:70a28cfe9e01 4739 if ((editRowIndex == command_table_row_count) && (command_table_row_count < COMMAND_TABLE_ROW_MAX)) {
whismanoid 33:70a28cfe9e01 4740 // %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 4741 //
whismanoid 33:70a28cfe9e01 4742 command_table_row_count++;
whismanoid 33:70a28cfe9e01 4743 cmdLine.serial().printf("\r\n add next row %d containing \"%s\"",
whismanoid 33:70a28cfe9e01 4744 editRowIndex, cmdLine.str()+argIndex);
whismanoid 33:70a28cfe9e01 4745 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 33:70a28cfe9e01 4746 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 33:70a28cfe9e01 4747 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 33:70a28cfe9e01 4748 //
whismanoid 23:c6c652bef4b9 4749 }
whismanoid 33:70a28cfe9e01 4750 //
whismanoid 23:c6c652bef4b9 4751 break;
whismanoid 23:c6c652bef4b9 4752 case '+':
whismanoid 24:032f3683cb2a 4753 // %B1@+ command add new row (if there is room to add)
whismanoid 23:c6c652bef4b9 4754 // add a new row at end of table
whismanoid 23:c6c652bef4b9 4755 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 4756 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 23:c6c652bef4b9 4757 editRowIndex = command_table_row_count;
whismanoid 28:a9a3a9db592b 4758 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 4759 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 4760 cmdLine.serial().printf("\r\n cannot add new row %d containing nothing",
whismanoid 28:a9a3a9db592b 4761 editRowIndex);
whismanoid 28:a9a3a9db592b 4762 }
whismanoid 28:a9a3a9db592b 4763 else
whismanoid 28:a9a3a9db592b 4764 {
whismanoid 28:a9a3a9db592b 4765 command_table_row_count++;
whismanoid 28:a9a3a9db592b 4766 cmdLine.serial().printf("\r\n add new row %d containing \"%s\"",
whismanoid 28:a9a3a9db592b 4767 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 4768 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4769 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 4770 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 28:a9a3a9db592b 4771 }
whismanoid 23:c6c652bef4b9 4772 }
whismanoid 23:c6c652bef4b9 4773 break;
whismanoid 23:c6c652bef4b9 4774 case '-':
whismanoid 24:032f3683cb2a 4775 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 4776 // delete row from table
whismanoid 23:c6c652bef4b9 4777 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4778 // if command_table_row_count == 0 then the table is empty
whismanoid 23:c6c652bef4b9 4779 if ((cmdLine[5] == '~') && (cmdLine[6] == '~') && (cmdLine[7] == '~')) {
whismanoid 23:c6c652bef4b9 4780 // %B1@-~~~ clear entire command table
whismanoid 24:032f3683cb2a 4781 cmdLine.serial().printf("\r\n clear entire command table");
whismanoid 23:c6c652bef4b9 4782 command_table_row_count = 0;
whismanoid 28:a9a3a9db592b 4783 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 23:c6c652bef4b9 4784 break;
whismanoid 23:c6c652bef4b9 4785 }
whismanoid 24:032f3683cb2a 4786 else
whismanoid 23:c6c652bef4b9 4787 {
whismanoid 24:032f3683cb2a 4788 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 24:032f3683cb2a 4789 editRowIndex = atoi(cmdLine.str()+5);
whismanoid 24:032f3683cb2a 4790 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 24:032f3683cb2a 4791 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 24:032f3683cb2a 4792 // delete row editRowIndex from Datalogger_action_table
whismanoid 24:032f3683cb2a 4793 for (int i = editRowIndex; i < (command_table_row_count-1); i++)
whismanoid 24:032f3683cb2a 4794 {
whismanoid 24:032f3683cb2a 4795 // copy row i+1 into row i
whismanoid 24:032f3683cb2a 4796 cmdLine.serial().printf("\r\n copy row %d into row %d: \"%s\"",
whismanoid 24:032f3683cb2a 4797 i+1, i, command_table[i+1]);
whismanoid 24:032f3683cb2a 4798 strncpy(command_table[i], command_table[i+1], COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4799 command_table[i][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 24:032f3683cb2a 4800 }
whismanoid 24:032f3683cb2a 4801 command_table_row_count--;
whismanoid 28:a9a3a9db592b 4802 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 24:032f3683cb2a 4803 }
whismanoid 23:c6c652bef4b9 4804 }
whismanoid 23:c6c652bef4b9 4805 }
whismanoid 23:c6c652bef4b9 4806 break;
whismanoid 30:07197a430869 4807 case '.': // something other than ! because %B1! means trigger event
whismanoid 30:07197a430869 4808 // pause the button event
whismanoid 30:07197a430869 4809 // TODO: %B1@. disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 4810 //~ Datalogger_action_table_enabled = false;
whismanoid 23:c6c652bef4b9 4811 break;
whismanoid 23:c6c652bef4b9 4812 case '@':
whismanoid 30:07197a430869 4813 // enable the button event
whismanoid 23:c6c652bef4b9 4814 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 4815 //~ Datalogger_action_table_enabled = true;
whismanoid 23:c6c652bef4b9 4816 break;
whismanoid 23:c6c652bef4b9 4817 }
whismanoid 23:c6c652bef4b9 4818 //
whismanoid 23:c6c652bef4b9 4819 // Print the contents of command_table
whismanoid 23:c6c652bef4b9 4820 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 4821 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 4822 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 4823 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 4824 cmdLine.serial().printf("\r\n %%B%1d@%d %s",
whismanoid 24:032f3683cb2a 4825 command_table_button_index,
whismanoid 24:032f3683cb2a 4826 lineIndex,
whismanoid 24:032f3683cb2a 4827 command_table[lineIndex]);
whismanoid 23:c6c652bef4b9 4828 }
whismanoid 30:07197a430869 4829 //~ cmdLine.serial().printf("\r\n command_table_row_count = %d/%d",
whismanoid 30:07197a430869 4830 //~ command_table_row_count, COMMAND_TABLE_ROW_MAX);
whismanoid 30:07197a430869 4831 cmdLine.serial().printf("\r\n\r\nEdit Button%d event (used %d/%d, %d free):",
whismanoid 30:07197a430869 4832 command_table_button_index,
whismanoid 30:07197a430869 4833 command_table_row_count,
whismanoid 30:07197a430869 4834 COMMAND_TABLE_ROW_MAX,
whismanoid 30:07197a430869 4835 (COMMAND_TABLE_ROW_MAX - command_table_row_count)
whismanoid 30:07197a430869 4836 );
whismanoid 23:c6c652bef4b9 4837 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 4838 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 24:032f3683cb2a 4839 cmdLine.serial().printf("\r\n %%B%1d@+ command -- add new row %d at end of table",
whismanoid 24:032f3683cb2a 4840 command_table_button_index,
whismanoid 24:032f3683cb2a 4841 command_table_row_count);
whismanoid 23:c6c652bef4b9 4842 }
whismanoid 23:c6c652bef4b9 4843 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4844 // if command_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 4845 cmdLine.serial().printf("\r\n %%B%1d@%d command -- replace row %d",
whismanoid 24:032f3683cb2a 4846 command_table_button_index,
whismanoid 23:c6c652bef4b9 4847 command_table_row_count-1,
whismanoid 23:c6c652bef4b9 4848 command_table_row_count-1);
whismanoid 24:032f3683cb2a 4849 cmdLine.serial().printf("\r\n %%B%1d@-%d -- delete row %d",
whismanoid 24:032f3683cb2a 4850 command_table_button_index,
whismanoid 24:032f3683cb2a 4851 command_table_row_count-1,
whismanoid 24:032f3683cb2a 4852 command_table_row_count-1);
whismanoid 24:032f3683cb2a 4853 cmdLine.serial().printf("\r\n %%B%1d@-~~~ -- delete all rows",
whismanoid 24:032f3683cb2a 4854 command_table_button_index);
whismanoid 30:07197a430869 4855 //~ cmdLine.serial().printf("\r\n %%B%1d@. -- pause entire command table",
whismanoid 30:07197a430869 4856 //~ command_table_button_index);
whismanoid 30:07197a430869 4857 //~ cmdLine.serial().printf("\r\n %%B%1d@@ -- enable command table",
whismanoid 30:07197a430869 4858 //~ command_table_button_index);
whismanoid 30:07197a430869 4859 cmdLine.serial().printf("\r\n %%B%1d! -- trigger Button%d event",
whismanoid 30:07197a430869 4860 command_table_button_index,
whismanoid 24:032f3683cb2a 4861 command_table_button_index);
whismanoid 23:c6c652bef4b9 4862 }
whismanoid 23:c6c652bef4b9 4863 //
whismanoid 23:c6c652bef4b9 4864 } // case '@' -- %B1@ view/edit command table
whismanoid 23:c6c652bef4b9 4865 break;
whismanoid 23:c6c652bef4b9 4866 case '!':
whismanoid 23:c6c652bef4b9 4867 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 23:c6c652bef4b9 4868 Run_command_table(command_table);
whismanoid 23:c6c652bef4b9 4869 break;
whismanoid 23:c6c652bef4b9 4870 }
whismanoid 23:c6c652bef4b9 4871 }
whismanoid 23:c6c652bef4b9 4872 break;
whismanoid 23:c6c652bef4b9 4873 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4874 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 4875 #if HAS_digitalInOuts
whismanoid 15:37c83ec50ea0 4876 case 'H': case 'h':
whismanoid 15:37c83ec50ea0 4877 {
whismanoid 15:37c83ec50ea0 4878 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 4879 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4880 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4881 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4882 #else
whismanoid 15:37c83ec50ea0 4883 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4884 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 4885 digitalInOutPin.write(1);
whismanoid 15:37c83ec50ea0 4886 #endif
whismanoid 15:37c83ec50ea0 4887 cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex);
whismanoid 15:37c83ec50ea0 4888 }
whismanoid 15:37c83ec50ea0 4889 break;
whismanoid 15:37c83ec50ea0 4890 case 'L': case 'l':
whismanoid 15:37c83ec50ea0 4891 {
whismanoid 15:37c83ec50ea0 4892 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 4893 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4894 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4895 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4896 #else
whismanoid 15:37c83ec50ea0 4897 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4898 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 4899 digitalInOutPin.write(0);
whismanoid 15:37c83ec50ea0 4900 #endif
whismanoid 15:37c83ec50ea0 4901 cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex);
whismanoid 15:37c83ec50ea0 4902 }
whismanoid 15:37c83ec50ea0 4903 break;
whismanoid 15:37c83ec50ea0 4904 case '?':
whismanoid 15:37c83ec50ea0 4905 {
whismanoid 15:37c83ec50ea0 4906 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 4907 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4908 pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4909 #else
whismanoid 15:37c83ec50ea0 4910 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4911 digitalInOutPin.input();
whismanoid 15:37c83ec50ea0 4912 #endif
whismanoid 15:37c83ec50ea0 4913 serial.printf(" digitalInOutPin %d Input ", pinIndex);
whismanoid 15:37c83ec50ea0 4914 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4915 int value = digitalRead(pinIndex);
whismanoid 15:37c83ec50ea0 4916 #else
whismanoid 15:37c83ec50ea0 4917 int value = digitalInOutPin.read();
whismanoid 15:37c83ec50ea0 4918 #endif
whismanoid 15:37c83ec50ea0 4919 cmdLine.serial().printf("%d ", value);
whismanoid 15:37c83ec50ea0 4920 }
whismanoid 15:37c83ec50ea0 4921 break;
whismanoid 15:37c83ec50ea0 4922 #endif
whismanoid 15:37c83ec50ea0 4923 //
whismanoid 15:37c83ec50ea0 4924 #if HAS_analogIns
whismanoid 15:37c83ec50ea0 4925 case 'A': case 'a':
whismanoid 15:37c83ec50ea0 4926 {
whismanoid 15:37c83ec50ea0 4927 // %A %Apin -- analog input
whismanoid 37:3f369235e5bc 4928 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4929 // %A avg= -- set Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 4930 if (cmdLine.parse_int_dec("avg", Platform_AIN_Average_N))
whismanoid 37:3f369235e5bc 4931 {
whismanoid 37:3f369235e5bc 4932 // Platform_AIN_Average_N was updated
whismanoid 37:3f369235e5bc 4933 }
whismanoid 37:3f369235e5bc 4934 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4935 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4936 // %A cal? view/export raw calibration values for all channels
whismanoid 34:a1993a1ee904 4937 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4938 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4939 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4940 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4941 {
whismanoid 34:a1993a1ee904 4942 char valueBuf[16];
whismanoid 34:a1993a1ee904 4943 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 4944 if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 4945 {
whismanoid 34:a1993a1ee904 4946 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4947 {
whismanoid 34:a1993a1ee904 4948 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 4949 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4950 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 4951 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4952 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 4953 );
whismanoid 34:a1993a1ee904 4954 }
whismanoid 34:a1993a1ee904 4955 //
whismanoid 34:a1993a1ee904 4956 // print extended help for %A
whismanoid 34:a1993a1ee904 4957 // %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 4958 //~ cmdLine.serial().printf("\r\n %%A cal0n=0.02 cal0v=0.123 cal0n=0.938 cal0v=1.132 -- update calibration");
whismanoid 34:a1993a1ee904 4959 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 4960 cmdLine.serial().printf(" %%A cal0test=0.5 -- calculate voltage at 50%% of full scale");
whismanoid 34:a1993a1ee904 4961 cmdLine.serial().printf("\r\n %%A v0cal=1.000V -- calibrate channel against a known input voltage");
whismanoid 34:a1993a1ee904 4962 // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 4963 // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 4964 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 4965 cmdLine.serial().printf("\r\n %%A calreset -- reset all calibration data");
whismanoid 37:3f369235e5bc 4966 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4967 // %A avg=%d -- help string display Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 4968 cmdLine.serial().printf("\r\n %%A avg=%d -- average", Platform_AIN_Average_N);
whismanoid 37:3f369235e5bc 4969 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4970 cmdLine.serial().printf("\r\n\r\n");
whismanoid 34:a1993a1ee904 4971 //
whismanoid 34:a1993a1ee904 4972 } // end if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 4973 }
whismanoid 34:a1993a1ee904 4974 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4975 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4976 {
whismanoid 34:a1993a1ee904 4977 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 4978 char valueBuf[16];
whismanoid 34:a1993a1ee904 4979 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 4980 if (cmdLine.parse_and_remove_key("calreset", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 4981 {
whismanoid 34:a1993a1ee904 4982 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 4983 calibration_05_normValue_0_1[0] = 0.25; calibration_05_V[0] = 0.3;
whismanoid 34:a1993a1ee904 4984 calibration_05_normValue_0_1[1] = 0.25; calibration_05_V[1] = 0.3;
whismanoid 34:a1993a1ee904 4985 calibration_05_normValue_0_1[2] = 0.25; calibration_05_V[2] = 0.3;
whismanoid 34:a1993a1ee904 4986 calibration_05_normValue_0_1[3] = 0.25; calibration_05_V[3] = 0.3;
whismanoid 34:a1993a1ee904 4987 calibration_05_normValue_0_1[4] = 0.25; calibration_05_V[4] = 1.5;
whismanoid 34:a1993a1ee904 4988 calibration_05_normValue_0_1[5] = 0.25; calibration_05_V[5] = 1.5;
whismanoid 34:a1993a1ee904 4989 //
whismanoid 34:a1993a1ee904 4990 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 4991 calibration_95_normValue_0_1[0] = 0.75; calibration_95_V[0] = 0.9;
whismanoid 34:a1993a1ee904 4992 calibration_95_normValue_0_1[1] = 0.75; calibration_95_V[1] = 0.9;
whismanoid 34:a1993a1ee904 4993 calibration_95_normValue_0_1[2] = 0.75; calibration_95_V[2] = 0.9;
whismanoid 34:a1993a1ee904 4994 calibration_95_normValue_0_1[3] = 0.75; calibration_95_V[3] = 0.9;
whismanoid 34:a1993a1ee904 4995 calibration_95_normValue_0_1[4] = 0.75; calibration_95_V[4] = 4.5;
whismanoid 34:a1993a1ee904 4996 calibration_95_normValue_0_1[5] = 0.75; calibration_95_V[5] = 4.5;
whismanoid 34:a1993a1ee904 4997 //
whismanoid 34:a1993a1ee904 4998 }
whismanoid 34:a1993a1ee904 4999 }
whismanoid 34:a1993a1ee904 5000 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5001 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5002 // %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 5003 // %A cal4n=0.135874882 cal4v=0.800000012V cal4n=0.286168128 cal4v=1.700000048V
whismanoid 34:a1993a1ee904 5004 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5005 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5006 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5007 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5008 {
whismanoid 34:a1993a1ee904 5009 double normValue_0_1, V;
whismanoid 34:a1993a1ee904 5010 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5011 {
whismanoid 34:a1993a1ee904 5012 static char key_can0n[8] = "cal0n__";
whismanoid 34:a1993a1ee904 5013 sprintf(key_can0n, "cal%1dn", ch);
whismanoid 34:a1993a1ee904 5014 static char key_cal0v[8] = "cal0v__";
whismanoid 34:a1993a1ee904 5015 sprintf(key_cal0v, "cal%1dv", ch);
whismanoid 35:c9549b5c01de 5016 // first point could be the 5% point or the 95% point
whismanoid 35:c9549b5c01de 5017 double norm_threshold = (calibration_05_normValue_0_1[ch] + calibration_95_normValue_0_1[ch]) / 2.0;
whismanoid 35:c9549b5c01de 5018 bool updated_05 = false;
whismanoid 35:c9549b5c01de 5019 //~ bool updated_95 = false;
whismanoid 35:c9549b5c01de 5020 if (cmdLine.parse_double(key_can0n, normValue_0_1)) {
whismanoid 34:a1993a1ee904 5021 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 34:a1993a1ee904 5022 {
whismanoid 35:c9549b5c01de 5023 if (normValue_0_1 < norm_threshold) {
whismanoid 35:c9549b5c01de 5024 // store first calibration point in the 5% slot
whismanoid 35:c9549b5c01de 5025 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 5026 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 5027 updated_05 = true;
whismanoid 34:a1993a1ee904 5028 }
whismanoid 34:a1993a1ee904 5029 else {
whismanoid 35:c9549b5c01de 5030 // store first calibration point in the 95% slot
whismanoid 35:c9549b5c01de 5031 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 5032 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 5033 //~ updated_95 = true;
whismanoid 34:a1993a1ee904 5034 }
whismanoid 34:a1993a1ee904 5035 }
whismanoid 35:c9549b5c01de 5036 }
whismanoid 35:c9549b5c01de 5037 // handle the optional second calibration point
whismanoid 35:c9549b5c01de 5038 if (cmdLine.parse_double(key_can0n, normValue_0_1))
whismanoid 35:c9549b5c01de 5039 {
whismanoid 35:c9549b5c01de 5040 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 35:c9549b5c01de 5041 {
whismanoid 35:c9549b5c01de 5042 if (updated_05) {
whismanoid 35:c9549b5c01de 5043 // we already stored the first point here
whismanoid 35:c9549b5c01de 5044 // calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5045 // calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 5046 // store the second point in the other slot
whismanoid 35:c9549b5c01de 5047 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5048 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 5049 }
whismanoid 35:c9549b5c01de 5050 else {
whismanoid 35:c9549b5c01de 5051 // we already stored the first point here
whismanoid 35:c9549b5c01de 5052 // calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5053 // calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 5054 // store the second point in the other slot
whismanoid 35:c9549b5c01de 5055 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 5056 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 5057 }
whismanoid 35:c9549b5c01de 5058 }
whismanoid 35:c9549b5c01de 5059 }
whismanoid 38:fda80a0020d1 5060 // make sure calibration_05_normValue_0_1[ch] < calibration_95_normValue_0_1[ch]
whismanoid 38:fda80a0020d1 5061 if (calibration_05_normValue_0_1[ch] > calibration_95_normValue_0_1[ch])
whismanoid 38:fda80a0020d1 5062 {
whismanoid 38:fda80a0020d1 5063 // swap to make sure calibration_05_normValue_0_1[ch] < calibration_95_normValue_0_1[ch]
whismanoid 38:fda80a0020d1 5064 double n05 = calibration_95_normValue_0_1[ch];
whismanoid 38:fda80a0020d1 5065 double V05 = calibration_95_V[ch];
whismanoid 38:fda80a0020d1 5066 double n95 = calibration_05_normValue_0_1[ch];
whismanoid 38:fda80a0020d1 5067 double V95 = calibration_05_V[ch];
whismanoid 38:fda80a0020d1 5068 calibration_05_normValue_0_1[ch] = n05;
whismanoid 38:fda80a0020d1 5069 calibration_05_V[ch] = V05;
whismanoid 38:fda80a0020d1 5070 calibration_95_normValue_0_1[ch] = n95;
whismanoid 38:fda80a0020d1 5071 calibration_95_V[ch] = V95;
whismanoid 38:fda80a0020d1 5072 }
whismanoid 34:a1993a1ee904 5073 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5074 }
whismanoid 34:a1993a1ee904 5075 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5076 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5077 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 5078 // double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 5079 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5080 {
whismanoid 34:a1993a1ee904 5081 static char key_cal0test[12] = "cal0test__";
whismanoid 34:a1993a1ee904 5082 sprintf(key_cal0test, "cal%1dtest", ch);
whismanoid 34:a1993a1ee904 5083 double normValue_0_1, Vtest;
whismanoid 34:a1993a1ee904 5084 if (cmdLine.parse_double(key_cal0test, Vtest))
whismanoid 34:a1993a1ee904 5085 {
whismanoid 34:a1993a1ee904 5086 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 5087 normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 5088 //
whismanoid 34:a1993a1ee904 5089 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 5090 ch,
whismanoid 34:a1993a1ee904 5091 normValue_0_1,
whismanoid 34:a1993a1ee904 5092 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 5093 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5094 );
whismanoid 34:a1993a1ee904 5095 //
whismanoid 34:a1993a1ee904 5096 // sweep CalibratedNormValue argument
whismanoid 34:a1993a1ee904 5097 double normValue_0_1_start = -0.05;
whismanoid 34:a1993a1ee904 5098 double normValue_0_1_step = 0.05;
whismanoid 34:a1993a1ee904 5099 double normValue_0_1_end = 1.07;
whismanoid 34:a1993a1ee904 5100 for (normValue_0_1 = normValue_0_1_start;
whismanoid 34:a1993a1ee904 5101 normValue_0_1 <= normValue_0_1_end;
whismanoid 34:a1993a1ee904 5102 normValue_0_1 = normValue_0_1 + normValue_0_1_step)
whismanoid 34:a1993a1ee904 5103 {
whismanoid 34:a1993a1ee904 5104 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 5105 ch,
whismanoid 34:a1993a1ee904 5106 normValue_0_1,
whismanoid 34:a1993a1ee904 5107 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 5108 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5109 );
whismanoid 34:a1993a1ee904 5110 }
whismanoid 34:a1993a1ee904 5111 }
whismanoid 34:a1993a1ee904 5112 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5113 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5114 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5115 // %A v0cal=1.000V -- calibrate channel against a known input voltage
whismanoid 34:a1993a1ee904 5116 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5117 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5118 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5119 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 5120 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5121 {
whismanoid 34:a1993a1ee904 5122 static char key_v0cal[10] = "v0cal__";
whismanoid 34:a1993a1ee904 5123 sprintf(key_v0cal, "v%1dcal", ch);
whismanoid 34:a1993a1ee904 5124 double Vtest;
whismanoid 34:a1993a1ee904 5125 if (cmdLine.parse_double(key_v0cal, Vtest))
whismanoid 34:a1993a1ee904 5126 {
whismanoid 34:a1993a1ee904 5127 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 5128 double Vtest_normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 5129 //
whismanoid 34:a1993a1ee904 5130 // %A v0cal=1.000 calibrate one channel by measuring against a known input voltage
whismanoid 34:a1993a1ee904 5131 //
whismanoid 34:a1993a1ee904 5132 cmdLine.serial().printf("\r\n Measuring against input voltage of %1.6fV...", Vtest);
whismanoid 37:3f369235e5bc 5133 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5134 const int numberOfMeasurements = 16 * Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5135 #else // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5136 const int numberOfMeasurements = 16;
whismanoid 37:3f369235e5bc 5137 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5138 double Sx_measure_normValue_0_1 = 0; // sum of values
whismanoid 34:a1993a1ee904 5139 double Sxx_measure_normValue_0_1 = 0; // sum of the squares of the values
whismanoid 34:a1993a1ee904 5140 for (int count = 0; count < numberOfMeasurements; count++)
whismanoid 34:a1993a1ee904 5141 {
whismanoid 34:a1993a1ee904 5142 double measure_normValue_0_1;
whismanoid 34:a1993a1ee904 5143 switch(ch)
whismanoid 34:a1993a1ee904 5144 {
whismanoid 34:a1993a1ee904 5145 case 0: measure_normValue_0_1 = analogIn0.read(); break;
whismanoid 34:a1993a1ee904 5146 case 1: measure_normValue_0_1 = analogIn1.read(); break;
whismanoid 34:a1993a1ee904 5147 case 2: measure_normValue_0_1 = analogIn2.read(); break;
whismanoid 34:a1993a1ee904 5148 case 3: measure_normValue_0_1 = analogIn3.read(); break;
whismanoid 34:a1993a1ee904 5149 case 4: measure_normValue_0_1 = analogIn4.read(); break;
whismanoid 34:a1993a1ee904 5150 case 5: measure_normValue_0_1 = analogIn5.read(); break;
whismanoid 34:a1993a1ee904 5151 }
whismanoid 34:a1993a1ee904 5152 Sx_measure_normValue_0_1 = Sx_measure_normValue_0_1 + measure_normValue_0_1;
whismanoid 34:a1993a1ee904 5153 Sxx_measure_normValue_0_1 = Sxx_measure_normValue_0_1 + (measure_normValue_0_1 * measure_normValue_0_1);
whismanoid 38:fda80a0020d1 5154 if ((count < 3) || (count >= numberOfMeasurements - 3)) {
whismanoid 38:fda80a0020d1 5155 cmdLine.serial().printf("\r\n raw: %7.6f%% = %1.6fV",
whismanoid 38:fda80a0020d1 5156 measure_normValue_0_1 * 100.0,
whismanoid 38:fda80a0020d1 5157 (measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 38:fda80a0020d1 5158 );
whismanoid 38:fda80a0020d1 5159 }
whismanoid 34:a1993a1ee904 5160 }
whismanoid 34:a1993a1ee904 5161 cmdLine.serial().printf("\r\n numberOfMeasurements = %d", numberOfMeasurements);
whismanoid 34:a1993a1ee904 5162 cmdLine.serial().printf("\r\n Sx_measure_normValue_0_1 = %1.6f", Sx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 5163 cmdLine.serial().printf("\r\n Sxx_measure_normValue_0_1 = %1.6f", Sxx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 5164 //
whismanoid 34:a1993a1ee904 5165 // calculate mean_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 5166 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 5167 double mean_measure_normValue_0_1 = Sx_measure_normValue_0_1 / numberOfMeasurements;
whismanoid 34:a1993a1ee904 5168 cmdLine.serial().printf("\r\n mean = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 5169 mean_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 5170 (mean_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5171 );
whismanoid 34:a1993a1ee904 5172 //
whismanoid 34:a1993a1ee904 5173 // TODO: calculate sample variance_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 5174 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 5175 // variance_measure_normValue_0_1 = (Sxx - ( Sx * Sx / nWords) ) / (nWords - 1);
whismanoid 34:a1993a1ee904 5176 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 5177 cmdLine.serial().printf("\r\n variance = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 5178 variance_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 5179 (variance_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5180 );
whismanoid 34:a1993a1ee904 5181 //
whismanoid 34:a1993a1ee904 5182 // calculate sample stddev_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 5183 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 5184 double stddev_measure_normValue_0_1 = sqrt(variance_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 5185 cmdLine.serial().printf("\r\n stddev = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 5186 stddev_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 5187 (stddev_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 5188 );
whismanoid 34:a1993a1ee904 5189 //
whismanoid 34:a1993a1ee904 5190 // Validate the measurements:
whismanoid 34:a1993a1ee904 5191 // is the mean near the expected value?
whismanoid 34:a1993a1ee904 5192 // is the standard deviation not too high?
whismanoid 34:a1993a1ee904 5193 bool isCalibrationValid = true;
whismanoid 34:a1993a1ee904 5194 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) > 0.1) {
whismanoid 34:a1993a1ee904 5195 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 5196 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 5197 }
whismanoid 34:a1993a1ee904 5198 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) < -0.1) {
whismanoid 34:a1993a1ee904 5199 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 5200 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 5201 }
whismanoid 34:a1993a1ee904 5202 if ((stddev_measure_normValue_0_1) > 10) {
whismanoid 34:a1993a1ee904 5203 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 5204 cmdLine.serial().printf(" stddev too high.\r\n");
whismanoid 34:a1993a1ee904 5205 }
whismanoid 34:a1993a1ee904 5206 if (isCalibrationValid)
whismanoid 34:a1993a1ee904 5207 {
whismanoid 34:a1993a1ee904 5208 // update calibration point (mean_measure_normValue_0_1, Vtest)
whismanoid 34:a1993a1ee904 5209 if (Vtest_normValue_0_1 < 0.5) {
whismanoid 34:a1993a1ee904 5210 calibration_05_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 5211 calibration_05_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 5212 } else {
whismanoid 34:a1993a1ee904 5213 calibration_95_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 5214 calibration_95_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 5215 }
whismanoid 34:a1993a1ee904 5216 //
whismanoid 34:a1993a1ee904 5217 // print updated calibration values
whismanoid 34:a1993a1ee904 5218 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 5219 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 5220 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 5221 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 5222 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 5223 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 5224 );
whismanoid 34:a1993a1ee904 5225 // print corrected value of mean of measurements (should be close to Vtest)
whismanoid 34:a1993a1ee904 5226 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV vs %1.6fV\r\n",
whismanoid 34:a1993a1ee904 5227 ch,
whismanoid 34:a1993a1ee904 5228 mean_measure_normValue_0_1,
whismanoid 34:a1993a1ee904 5229 CalibratedNormValue(ch, mean_measure_normValue_0_1),
whismanoid 34:a1993a1ee904 5230 (CalibratedNormValue(ch, mean_measure_normValue_0_1) * adc_full_scale_voltage[ch]),
whismanoid 34:a1993a1ee904 5231 Vtest
whismanoid 34:a1993a1ee904 5232 );
whismanoid 34:a1993a1ee904 5233 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 5234 else {
whismanoid 34:a1993a1ee904 5235 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 5236 cmdLine.serial().printf(" Measurement Error: Calibration will not be updated.\r\n");
whismanoid 34:a1993a1ee904 5237 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 5238 } // end if key_v0cal
whismanoid 34:a1993a1ee904 5239 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 5240 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5241 #if HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 5242 // // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 37:3f369235e5bc 5243 // {
whismanoid 37:3f369235e5bc 5244 // char valueBuf[16];
whismanoid 37:3f369235e5bc 5245 // // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 37:3f369235e5bc 5246 // if (cmdLine.parse_and_remove_key("__TBD_saveCal__", valueBuf, sizeof(valueBuf)))
whismanoid 37:3f369235e5bc 5247 // {
whismanoid 37:3f369235e5bc 5248 // // handle %A __TBD_saveCal__ -- command
whismanoid 37:3f369235e5bc 5249 // }
whismanoid 37:3f369235e5bc 5250 // }
whismanoid 34:a1993a1ee904 5251 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5252 #if HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 5253 // // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 37:3f369235e5bc 5254 // {
whismanoid 37:3f369235e5bc 5255 // char valueBuf[16];
whismanoid 37:3f369235e5bc 5256 // // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 37:3f369235e5bc 5257 // if (cmdLine.parse_and_remove_key("__TBD_loadCal__", valueBuf, sizeof(valueBuf)))
whismanoid 37:3f369235e5bc 5258 // {
whismanoid 37:3f369235e5bc 5259 // // handle %A __TBD_loadCal__ -- command
whismanoid 37:3f369235e5bc 5260 // }
whismanoid 37:3f369235e5bc 5261 // }
whismanoid 34:a1993a1ee904 5262 #endif // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 5263 // %A -- report analog input voltages
whismanoid 37:3f369235e5bc 5264 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5265 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5266 #endif // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5267 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 5268 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 15:37c83ec50ea0 5269 for (int pinIndex = 0; pinIndex < 2; pinIndex++)
whismanoid 15:37c83ec50ea0 5270 {
whismanoid 15:37c83ec50ea0 5271 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 5272 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 5273 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 5274 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5275 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5276 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5277 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 5278 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5279 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 5280 }
whismanoid 37:3f369235e5bc 5281 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5282 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5283 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 5284 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5285 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5286 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5287 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 5288 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5289 //
whismanoid 15:37c83ec50ea0 5290 int pinIndexH = pinIndex + 4;
whismanoid 15:37c83ec50ea0 5291 int cPinIndexH = '0' + pinIndexH;
whismanoid 15:37c83ec50ea0 5292 AnalogIn& analogInPinH = find_analogInPin(cPinIndexH);
whismanoid 15:37c83ec50ea0 5293 float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH];
whismanoid 37:3f369235e5bc 5294 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5295 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5296 // float normValueH_0_1 = analogInPinH.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5297 float normValueH_0_1 = 0;
whismanoid 37:3f369235e5bc 5298 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5299 normValueH_0_1 = normValueH_0_1 + analogInPinH.read();
whismanoid 37:3f369235e5bc 5300 }
whismanoid 37:3f369235e5bc 5301 normValueH_0_1 = normValueH_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5302 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5303 float normValueH_0_1 = analogInPinH.read();
whismanoid 37:3f369235e5bc 5304 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5305 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5306 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5307 normValueH_0_1 = CalibratedNormValue(pinIndex, normValueH_0_1);
whismanoid 34:a1993a1ee904 5308 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5309 //
whismanoid 37:3f369235e5bc 5310 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV high range A%c = %7.3f%% = %1.3fV \r\n",
whismanoid 15:37c83ec50ea0 5311 cPinIndex,
whismanoid 15:37c83ec50ea0 5312 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5313 normValue_0_1 * adc_full_scale_voltage,
whismanoid 15:37c83ec50ea0 5314 cPinIndexH,
whismanoid 15:37c83ec50ea0 5315 normValueH_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5316 normValueH_0_1 * adc_full_scale_voltageH
whismanoid 15:37c83ec50ea0 5317 );
whismanoid 15:37c83ec50ea0 5318 }
whismanoid 15:37c83ec50ea0 5319 for (int pinIndex = 2; pinIndex < 4; pinIndex++)
whismanoid 15:37c83ec50ea0 5320 {
whismanoid 15:37c83ec50ea0 5321 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 5322 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 5323 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 5324 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5325 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5326 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5327 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 5328 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5329 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 5330 }
whismanoid 37:3f369235e5bc 5331 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5332 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5333 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 5334 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5335 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5336 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5337 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 5338 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5339 //
whismanoid 37:3f369235e5bc 5340 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 5341 cPinIndex,
whismanoid 15:37c83ec50ea0 5342 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5343 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 5344 );
whismanoid 15:37c83ec50ea0 5345 }
whismanoid 15:37c83ec50ea0 5346 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 5347 // Platform board uses simple analog inputs
whismanoid 15:37c83ec50ea0 5348 // assume standard Arduino analog inputs A0-A5
whismanoid 15:37c83ec50ea0 5349 for (int pinIndex = 0; pinIndex < 6; pinIndex++)
whismanoid 15:37c83ec50ea0 5350 {
whismanoid 15:37c83ec50ea0 5351 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 5352 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 5353 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 5354 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 5355 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 5356 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 5357 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 5358 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 5359 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 5360 }
whismanoid 37:3f369235e5bc 5361 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 5362 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 5363 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 5364 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 5365 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5366 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5367 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 5368 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 5369 //
whismanoid 37:3f369235e5bc 5370 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 5371 cPinIndex,
whismanoid 15:37c83ec50ea0 5372 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 5373 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 5374 );
whismanoid 15:37c83ec50ea0 5375 }
whismanoid 15:37c83ec50ea0 5376 #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 5377 }
whismanoid 15:37c83ec50ea0 5378 break;
whismanoid 15:37c83ec50ea0 5379 #endif
whismanoid 15:37c83ec50ea0 5380 //
whismanoid 15:37c83ec50ea0 5381 #if HAS_SPI2_MAX541
whismanoid 15:37c83ec50ea0 5382 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 5383 {
whismanoid 15:37c83ec50ea0 5384 // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV)
whismanoid 15:37c83ec50ea0 5385 // MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 15:37c83ec50ea0 5386 float voltageV = max541.Get_Voltage();
whismanoid 15:37c83ec50ea0 5387 // if (cmdLine[2] == '+') {
whismanoid 15:37c83ec50ea0 5388 // // %D+
whismanoid 15:37c83ec50ea0 5389 // voltageV = voltageV * 1.25f;
whismanoid 15:37c83ec50ea0 5390 // if (voltageV >= max541.VRef) voltageV = max541.VRef;
whismanoid 15:37c83ec50ea0 5391 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5392 // }
whismanoid 15:37c83ec50ea0 5393 // else if (cmdLine[2] == '-') {
whismanoid 15:37c83ec50ea0 5394 // // %D-
whismanoid 15:37c83ec50ea0 5395 // voltageV = voltageV * 0.75f;
whismanoid 15:37c83ec50ea0 5396 // if (voltageV < 0.1f) voltageV = 0.1f;
whismanoid 15:37c83ec50ea0 5397 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5398 // }
whismanoid 15:37c83ec50ea0 5399 if (cmdLine.parse_float("V", voltageV))
whismanoid 15:37c83ec50ea0 5400 {
whismanoid 15:37c83ec50ea0 5401 // %D V=1.234 -- set voltage
whismanoid 15:37c83ec50ea0 5402 max541.Set_Voltage(voltageV);
whismanoid 15:37c83ec50ea0 5403 }
whismanoid 15:37c83ec50ea0 5404 else if (cmdLine.parse_float("TEST", voltageV))
whismanoid 15:37c83ec50ea0 5405 {
whismanoid 15:37c83ec50ea0 5406 // %D TEST=1.234 -- set voltage and compare with AIN0
whismanoid 15:37c83ec50ea0 5407 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5408 }
whismanoid 15:37c83ec50ea0 5409 else if (cmdLine.parse_float("CAL", voltageV))
whismanoid 15:37c83ec50ea0 5410 {
whismanoid 15:37c83ec50ea0 5411 // %D CAL=1.234 -- calibrate VRef and compare with AIN0
whismanoid 15:37c83ec50ea0 5412
whismanoid 15:37c83ec50ea0 5413 max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
whismanoid 15:37c83ec50ea0 5414 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 5415 const int average_count = 100;
whismanoid 15:37c83ec50ea0 5416 const double average_K = 0.25;
whismanoid 15:37c83ec50ea0 5417 for (int count = 0; count < average_count; count++) {
whismanoid 15:37c83ec50ea0 5418 double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 5419 max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
whismanoid 15:37c83ec50ea0 5420 }
whismanoid 15:37c83ec50ea0 5421 max541.VRef = 2.0 * max541_midscale_V;
whismanoid 15:37c83ec50ea0 5422 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5423 "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
whismanoid 15:37c83ec50ea0 5424 max541_midscale_V, max541.VRef);
whismanoid 15:37c83ec50ea0 5425 // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
whismanoid 15:37c83ec50ea0 5426 voltageV = 1.0f;
whismanoid 15:37c83ec50ea0 5427 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 5428 }
whismanoid 15:37c83ec50ea0 5429 else {
whismanoid 15:37c83ec50ea0 5430 // %D -- print MAX541 DAC status
whismanoid 15:37c83ec50ea0 5431 cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n",
whismanoid 15:37c83ec50ea0 5432 max541.Get_Code(), max541.Get_Voltage(), max541.VRef);
whismanoid 15:37c83ec50ea0 5433 }
whismanoid 15:37c83ec50ea0 5434 }
whismanoid 15:37c83ec50ea0 5435 break;
whismanoid 15:37c83ec50ea0 5436 #endif
whismanoid 15:37c83ec50ea0 5437
whismanoid 15:37c83ec50ea0 5438 //
whismanoid 15:37c83ec50ea0 5439 #if HAS_I2C // SUPPORT_I2C
whismanoid 15:37c83ec50ea0 5440 case 'I': case 'i':
whismanoid 15:37c83ec50ea0 5441 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 5442 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 5443 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 5444 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 5445 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 5446 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 5447 // get next character
whismanoid 15:37c83ec50ea0 5448 // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7
whismanoid 15:37c83ec50ea0 5449 cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7);
whismanoid 15:37c83ec50ea0 5450 // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count
whismanoid 15:37c83ec50ea0 5451 g_I2C_read_count = 0; // read count must be reset every command
whismanoid 15:37c83ec50ea0 5452 cmdLine.parse_byte_dec("RD", g_I2C_read_count);
whismanoid 15:37c83ec50ea0 5453 // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress
whismanoid 15:37c83ec50ea0 5454 cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress);
whismanoid 15:37c83ec50ea0 5455 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 5456 {
whismanoid 15:37c83ec50ea0 5457 case 'P': case 'p':
whismanoid 15:37c83ec50ea0 5458 {
whismanoid 15:37c83ec50ea0 5459 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 5460 HuntAttachedI2CDevices(cmdLine, 0x03, 0x77);
whismanoid 15:37c83ec50ea0 5461 }
whismanoid 15:37c83ec50ea0 5462 break;
whismanoid 15:37c83ec50ea0 5463 case 'C': case 'c':
whismanoid 15:37c83ec50ea0 5464 {
whismanoid 15:37c83ec50ea0 5465 bool isUpdatedI2CConfig = false;
whismanoid 15:37c83ec50ea0 5466 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 5467 // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz
whismanoid 15:37c83ec50ea0 5468 if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz))
whismanoid 15:37c83ec50ea0 5469 {
whismanoid 15:37c83ec50ea0 5470 isUpdatedI2CConfig = true;
whismanoid 15:37c83ec50ea0 5471 // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 5472 if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 5473 {
whismanoid 15:37c83ec50ea0 5474 g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 5475 }
whismanoid 15:37c83ec50ea0 5476 if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 5477 {
whismanoid 15:37c83ec50ea0 5478 g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 5479 }
whismanoid 15:37c83ec50ea0 5480 }
whismanoid 15:37c83ec50ea0 5481 if (isUpdatedI2CConfig)
whismanoid 15:37c83ec50ea0 5482 {
whismanoid 15:37c83ec50ea0 5483 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 5484 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 5485 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5486 i2cMaster.start();
whismanoid 15:37c83ec50ea0 5487 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 5488 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5489 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5490 "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 15:37c83ec50ea0 5491 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 15:37c83ec50ea0 5492 (g_I2C_SCL_Hz / 1000.));
whismanoid 15:37c83ec50ea0 5493 i2cMaster.start();
whismanoid 15:37c83ec50ea0 5494 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 5495 }
whismanoid 15:37c83ec50ea0 5496 }
whismanoid 15:37c83ec50ea0 5497 break;
whismanoid 15:37c83ec50ea0 5498 case 'W': case 'w':
whismanoid 15:37c83ec50ea0 5499 {
whismanoid 15:37c83ec50ea0 5500 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 5501 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 5502 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5503 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 5504 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5505 #define MAX_I2C_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 5506 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 5507 static char mosiData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5508 static char misoData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5509 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 5510 MAX_I2C_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 5511 {
whismanoid 15:37c83ec50ea0 5512 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5513 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5514 "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->",
whismanoid 15:37c83ec50ea0 5515 g_I2C_deviceAddress7,
whismanoid 15:37c83ec50ea0 5516 (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count);
whismanoid 15:37c83ec50ea0 5517 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 5518 {
whismanoid 15:37c83ec50ea0 5519 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 5520 }
whismanoid 15:37c83ec50ea0 5521 //
whismanoid 15:37c83ec50ea0 5522 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 5523 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 5524 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 5525 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 5526 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 5527 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 5528 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 5529 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5530 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5531 // /* 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 5532 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 5533 const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 5534 unsigned int misoLength = 0;
whismanoid 15:37c83ec50ea0 5535 bool repeated = (g_I2C_read_count > 0);
whismanoid 15:37c83ec50ea0 5536 //
whismanoid 15:37c83ec50ea0 5537 int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated);
whismanoid 15:37c83ec50ea0 5538 switch (writeStatus)
whismanoid 15:37c83ec50ea0 5539 {
whismanoid 15:37c83ec50ea0 5540 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 5541 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 5542 default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 5543 writeStatus);
whismanoid 15:37c83ec50ea0 5544 }
whismanoid 15:37c83ec50ea0 5545 if (repeated)
whismanoid 15:37c83ec50ea0 5546 {
whismanoid 15:37c83ec50ea0 5547 int readStatus =
whismanoid 15:37c83ec50ea0 5548 i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false);
whismanoid 15:37c83ec50ea0 5549 switch (readStatus)
whismanoid 15:37c83ec50ea0 5550 {
whismanoid 15:37c83ec50ea0 5551 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 5552 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 5553 default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 5554 readStatus);
whismanoid 15:37c83ec50ea0 5555 }
whismanoid 15:37c83ec50ea0 5556 }
whismanoid 15:37c83ec50ea0 5557 //
whismanoid 15:37c83ec50ea0 5558 if (misoLength > 0)
whismanoid 15:37c83ec50ea0 5559 {
whismanoid 15:37c83ec50ea0 5560 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5561 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 5562 for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count;
whismanoid 15:37c83ec50ea0 5563 byteIndex++)
whismanoid 15:37c83ec50ea0 5564 {
whismanoid 15:37c83ec50ea0 5565 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 5566 }
whismanoid 15:37c83ec50ea0 5567 }
whismanoid 15:37c83ec50ea0 5568 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 5569 }
whismanoid 15:37c83ec50ea0 5570 }
whismanoid 15:37c83ec50ea0 5571 break;
whismanoid 15:37c83ec50ea0 5572 case 'R': case 'r':
whismanoid 15:37c83ec50ea0 5573 {
whismanoid 15:37c83ec50ea0 5574 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 5575 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 5576 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5577 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 5578 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 5579 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 5580 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 5581 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 5582 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 5583 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 5584 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 5585 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5586 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5587 // /* 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 5588 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 5589 }
whismanoid 15:37c83ec50ea0 5590 break;
whismanoid 15:37c83ec50ea0 5591 case '^':
whismanoid 15:37c83ec50ea0 5592 {
whismanoid 15:37c83ec50ea0 5593 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 5594 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 5595 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 5596 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 5597 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 5598 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 5599 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 5600 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 5601 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 5602 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 5603 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 5604 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5605 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5606 // /* 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 5607 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 5608 }
whismanoid 15:37c83ec50ea0 5609 break;
whismanoid 15:37c83ec50ea0 5610 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 5611 break;
whismanoid 15:37c83ec50ea0 5612 #endif
whismanoid 15:37c83ec50ea0 5613 //
whismanoid 15:37c83ec50ea0 5614 #if HAS_SPI // SUPPORT_SPI
whismanoid 15:37c83ec50ea0 5615 case 'S': case 's':
whismanoid 15:37c83ec50ea0 5616 {
whismanoid 15:37c83ec50ea0 5617 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 5618 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 5619 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 5620 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 5621 //
whismanoid 15:37c83ec50ea0 5622 // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d
whismanoid 15:37c83ec50ea0 5623 bool isUpdatedSPIConfig = false;
whismanoid 15:37c83ec50ea0 5624 // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2
whismanoid 15:37c83ec50ea0 5625 // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1
whismanoid 15:37c83ec50ea0 5626 if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2))
whismanoid 15:37c83ec50ea0 5627 {
whismanoid 15:37c83ec50ea0 5628 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5629 }
whismanoid 15:37c83ec50ea0 5630 if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1))
whismanoid 15:37c83ec50ea0 5631 {
whismanoid 15:37c83ec50ea0 5632 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5633 }
whismanoid 15:37c83ec50ea0 5634 if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1))
whismanoid 15:37c83ec50ea0 5635 {
whismanoid 15:37c83ec50ea0 5636 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5637 }
whismanoid 15:37c83ec50ea0 5638 // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz
whismanoid 15:37c83ec50ea0 5639 if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz))
whismanoid 15:37c83ec50ea0 5640 {
whismanoid 15:37c83ec50ea0 5641 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5642 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 5643 if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 5644 {
whismanoid 15:37c83ec50ea0 5645 g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 5646 }
whismanoid 15:37c83ec50ea0 5647 if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 5648 {
whismanoid 15:37c83ec50ea0 5649 g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 5650 }
whismanoid 15:37c83ec50ea0 5651 }
whismanoid 15:37c83ec50ea0 5652 // Update SPI configuration
whismanoid 15:37c83ec50ea0 5653 if (isUpdatedSPIConfig)
whismanoid 15:37c83ec50ea0 5654 {
whismanoid 15:37c83ec50ea0 5655 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 5656 spi_cs = g_SPI_cs_state;
whismanoid 15:37c83ec50ea0 5657 spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0
whismanoid 15:37c83ec50ea0 5658 #if APPLICATION_MAX5715
whismanoid 15:37c83ec50ea0 5659 g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5660 #elif APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 5661 g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5662 #elif APPLICATION_MAX5171
whismanoid 15:37c83ec50ea0 5663 g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5664 #elif APPLICATION_MAX11410
whismanoid 15:37c83ec50ea0 5665 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5666 #elif APPLICATION_MAX12345
whismanoid 15:37c83ec50ea0 5667 g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5668 #else
whismanoid 15:37c83ec50ea0 5669 spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 15:37c83ec50ea0 5670 #endif
whismanoid 15:37c83ec50ea0 5671 //
whismanoid 15:37c83ec50ea0 5672 double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 5673 int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate
whismanoid 15:37c83ec50ea0 5674 double actual_SCLK_Hz = SystemCoreClock / actual_divisor;
whismanoid 15:37c83ec50ea0 5675 //
whismanoid 15:37c83ec50ea0 5676 // 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 5677 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5678 "\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 5679 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 15:37c83ec50ea0 5680 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0),
whismanoid 15:37c83ec50ea0 5681 g_SPI_cs_state,
whismanoid 15:37c83ec50ea0 5682 g_SPI_SCLK_Hz,
whismanoid 15:37c83ec50ea0 5683 (g_SPI_SCLK_Hz / 1000000.),
whismanoid 15:37c83ec50ea0 5684 ((double)(SystemCoreClock / 1000000.)),
whismanoid 15:37c83ec50ea0 5685 ideal_divisor,
whismanoid 15:37c83ec50ea0 5686 (actual_SCLK_Hz / 1000000.)
whismanoid 15:37c83ec50ea0 5687 );
whismanoid 15:37c83ec50ea0 5688 }
whismanoid 15:37c83ec50ea0 5689 // get next character
whismanoid 15:37c83ec50ea0 5690 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 5691 {
whismanoid 15:37c83ec50ea0 5692 case 'C': case 's':
whismanoid 15:37c83ec50ea0 5693 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 5694 break;
whismanoid 15:37c83ec50ea0 5695 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 5696 // %SD -- SPI diagnostic messages enable
whismanoid 15:37c83ec50ea0 5697 if (g_MAX5719_device.onSPIprint) {
whismanoid 15:37c83ec50ea0 5698 g_MAX5719_device.onSPIprint = NULL;
whismanoid 15:37c83ec50ea0 5699 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') != None is false
whismanoid 15:37c83ec50ea0 5700 }
whismanoid 15:37c83ec50ea0 5701 else {
whismanoid 15:37c83ec50ea0 5702 void onSPIprint_handler(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]);
whismanoid 15:37c83ec50ea0 5703 g_MAX5719_device.onSPIprint = onSPIprint_handler;
whismanoid 15:37c83ec50ea0 5704 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') is false
whismanoid 15:37c83ec50ea0 5705 }
whismanoid 15:37c83ec50ea0 5706 break;
whismanoid 15:37c83ec50ea0 5707 case 'W': case 'R': case 'w': case 'r':
whismanoid 15:37c83ec50ea0 5708 {
whismanoid 15:37c83ec50ea0 5709 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 5710 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 5711 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5712 #define MAX_SPI_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 5713 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 5714 static char mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5715 static char misoData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5716 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 5717 MAX_SPI_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 5718 {
whismanoid 15:37c83ec50ea0 5719 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5720 cmdLine.serial().printf("\r\nSPI");
whismanoid 15:37c83ec50ea0 5721 if (byteCount > 7) {
whismanoid 15:37c83ec50ea0 5722 cmdLine.serial().printf(" byteCount:%d", byteCount);
whismanoid 15:37c83ec50ea0 5723 }
whismanoid 15:37c83ec50ea0 5724 cmdLine.serial().printf(" MOSI->");
whismanoid 15:37c83ec50ea0 5725 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 5726 {
whismanoid 15:37c83ec50ea0 5727 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 5728 }
whismanoid 15:37c83ec50ea0 5729 spi_cs = 0;
whismanoid 15:37c83ec50ea0 5730 unsigned int numBytesTransferred =
whismanoid 15:37c83ec50ea0 5731 spi.write(mosiData, byteCount, misoData, byteCount);
whismanoid 15:37c83ec50ea0 5732 spi_cs = 1;
whismanoid 15:37c83ec50ea0 5733 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5734 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 5735 for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred;
whismanoid 15:37c83ec50ea0 5736 byteIndex++)
whismanoid 15:37c83ec50ea0 5737 {
whismanoid 15:37c83ec50ea0 5738 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 5739 }
whismanoid 15:37c83ec50ea0 5740 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 5741 }
whismanoid 15:37c83ec50ea0 5742 }
whismanoid 15:37c83ec50ea0 5743 break;
whismanoid 15:37c83ec50ea0 5744 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 5745 } // case 'S': // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 5746 break;
whismanoid 15:37c83ec50ea0 5747 #endif
whismanoid 15:37c83ec50ea0 5748 //
whismanoid 15:37c83ec50ea0 5749 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 5750 } // switch(cmdLine[1])
whismanoid 15:37c83ec50ea0 5751 } // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 15:37c83ec50ea0 5752 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 15:37c83ec50ea0 5753
whismanoid 15:37c83ec50ea0 5754 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 5755 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 5756 void main_menu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 5757 {
whismanoid 9:45f98573eb6d 5758 // process command line
whismanoid 31:47eee7e0cc2d 5759 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 5760 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5761 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 5762 #endif // USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5763 cmdLine.serial().printf("\r\nCmdLine buf:\"%s\"\r\n", cmdLine.str());
whismanoid 45:74bf1fe021e5 5764 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5765 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 5766 #endif // USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5767 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 5768 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5769 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 5770 #endif // USE_DATALOGGER_CommandTable
whismanoid 45:74bf1fe021e5 5771 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5772 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 5773 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 5774
whismanoid 4:d9b05924ad4c 5775 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 31:47eee7e0cc2d 5776 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 5777 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5778 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 5779 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 5780 // If datalog is free running, halt on any possible received command
whismanoid 17:9397ea3ea7e9 5781 if (Datalogger_Trigger != trigger_Halt) {
whismanoid 4:d9b05924ad4c 5782 Datalogger_Trigger = trigger_Halt;
whismanoid 9:45f98573eb6d 5783 cmdLine.serial().printf("Datalog stopped by USB command input\r\n");
whismanoid 9:45f98573eb6d 5784 cmdLine.serial().printf("Restart datalog by sending LR\r\n");
whismanoid 4:d9b05924ad4c 5785 }
whismanoid 45:74bf1fe021e5 5786 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5787 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 5788 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 5789 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 5790
whismanoid 4:d9b05924ad4c 5791 // DIAGNOSTIC: print line buffer
whismanoid 4:d9b05924ad4c 5792 //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str());
whismanoid 4:d9b05924ad4c 5793 //
whismanoid 4:d9b05924ad4c 5794 switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 5795 {
whismanoid 4:d9b05924ad4c 5796 case '?':
whismanoid 4:d9b05924ad4c 5797 main_menu_status(cmdLine);
whismanoid 4:d9b05924ad4c 5798 main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 5799 // print command prompt
whismanoid 4:d9b05924ad4c 5800 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 5801 break;
whismanoid 4:d9b05924ad4c 5802 case '\r': case '\n': // ignore blank line
whismanoid 4:d9b05924ad4c 5803 case '\0': // ignore empty line
whismanoid 30:07197a430869 5804 main_menu_status(cmdLine);
whismanoid 30:07197a430869 5805 //~ main_menu_help(cmdLine);
whismanoid 30:07197a430869 5806 // print command prompt
whismanoid 30:07197a430869 5807 //cmdLine.serial().printf("\r\n>");
whismanoid 30:07197a430869 5808 break;
whismanoid 4:d9b05924ad4c 5809 case '#': // ignore comment line
whismanoid 4:d9b05924ad4c 5810 // # -- lines beginning with # are comments
whismanoid 30:07197a430869 5811 //
whismanoid 30:07197a430869 5812 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 5813 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in main_menu_onEOLcommandParser
whismanoid 30:07197a430869 5814 // # command handler update gstrRemarkText buffer instead of just ignoring the remark
whismanoid 30:07197a430869 5815 //
whismanoid 30:07197a430869 5816 // ignore extra spaces before the remark
whismanoid 30:07197a430869 5817 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 30:07197a430869 5818 int argIndex;
whismanoid 30:07197a430869 5819 for (argIndex = 1; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 5820 {
whismanoid 30:07197a430869 5821 if (cmdLine[argIndex] == ' ') break;
whismanoid 30:07197a430869 5822 }
whismanoid 30:07197a430869 5823 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 5824 {
whismanoid 30:07197a430869 5825 if (cmdLine[argIndex] != ' ') break;
whismanoid 30:07197a430869 5826 }
whismanoid 30:07197a430869 5827 //
whismanoid 30:07197a430869 5828 strncpy(gstrRemarkText, cmdLine.str()+argIndex, gstrRemarkTextLASTINDEX+1);
whismanoid 30:07197a430869 5829 // do not exceed string buffer limit; keep sentinel null character at end of buffer
whismanoid 30:07197a430869 5830 gstrRemarkText[gstrRemarkTextLASTINDEX] = '\0';
whismanoid 41:13a6a097502c 5831 for (unsigned int index = 0; index < gstrRemarkTextLASTINDEX; index++)
whismanoid 30:07197a430869 5832 {
whismanoid 30:07197a430869 5833 if ((gstrRemarkText[index]) == '\0') break; // null character at end of string
whismanoid 30:07197a430869 5834 if ((gstrRemarkText[index]) < 0x20) {
whismanoid 30:07197a430869 5835 // replace non-printing characters with _
whismanoid 30:07197a430869 5836 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 5837 continue;
whismanoid 30:07197a430869 5838 }
whismanoid 30:07197a430869 5839 if ((gstrRemarkText[index]) >= 0x7F) {
whismanoid 30:07197a430869 5840 // replace non-printing characters with _
whismanoid 30:07197a430869 5841 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 5842 continue;
whismanoid 30:07197a430869 5843 }
whismanoid 30:07197a430869 5844 switch(gstrRemarkText[index])
whismanoid 30:07197a430869 5845 {
whismanoid 30:07197a430869 5846 case ',':
whismanoid 30:07197a430869 5847 // replace , with ;
whismanoid 30:07197a430869 5848 gstrRemarkText[index] = ';';
whismanoid 30:07197a430869 5849 break;
whismanoid 30:07197a430869 5850 case '"':
whismanoid 30:07197a430869 5851 // replace " with '
whismanoid 30:07197a430869 5852 gstrRemarkText[index] = '\'';
whismanoid 30:07197a430869 5853 break;
whismanoid 30:07197a430869 5854 case '\\':
whismanoid 30:07197a430869 5855 // replace \ with /
whismanoid 30:07197a430869 5856 gstrRemarkText[index] = '/';
whismanoid 30:07197a430869 5857 break;
whismanoid 30:07197a430869 5858 }
whismanoid 30:07197a430869 5859 }
whismanoid 30:07197a430869 5860 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 5861 //
whismanoid 31:47eee7e0cc2d 5862 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 45:74bf1fe021e5 5863 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5864 if (g_Run_command_table_running == false) {
whismanoid 45:74bf1fe021e5 5865 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 5866 main_menu_status(cmdLine);
whismanoid 45:74bf1fe021e5 5867 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 5868 } // if (g_Run_command_table_running)
whismanoid 45:74bf1fe021e5 5869 #endif // USE_DATALOGGER_CommandTable
whismanoid 4:d9b05924ad4c 5870 //~ main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 5871 // print command prompt
whismanoid 4:d9b05924ad4c 5872 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 5873 break;
whismanoid 4:d9b05924ad4c 5874 #if ECHO_EOF_ON_EOL
whismanoid 4:d9b05924ad4c 5875 case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file
whismanoid 4:d9b05924ad4c 5876 cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 5877 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 5878 break;
whismanoid 4:d9b05924ad4c 5879 case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file
whismanoid 4:d9b05924ad4c 5880 cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 5881 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 5882 break;
whismanoid 4:d9b05924ad4c 5883 #endif
whismanoid 10:04022a61b527 5884 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 5885 case '!': // device init
whismanoid 10:04022a61b527 5886 {
whismanoid 10:04022a61b527 5887 cmdLine.serial().printf("Init");
whismanoid 10:04022a61b527 5888 // call function Init
whismanoid 10:04022a61b527 5889 uint8_t result = g_MAX11410_device.Init();
whismanoid 10:04022a61b527 5890 // cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 5891 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 5892 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 5893 // in command '!' device init, apply list of custom register writes after init
whismanoid 10:04022a61b527 5894 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 5895 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 10:04022a61b527 5896 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 10:04022a61b527 5897 uint32_t regData = custom_reg_init_data[index];
whismanoid 10:04022a61b527 5898 cmdLine.serial().printf("*%s=0x%06.6x",
whismanoid 10:04022a61b527 5899 g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress),
whismanoid 10:04022a61b527 5900 regData
whismanoid 10:04022a61b527 5901 );
whismanoid 10:04022a61b527 5902 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 10:04022a61b527 5903 }
whismanoid 10:04022a61b527 5904 #endif // USE_CUSTOM_REG_INIT
whismanoid 10:04022a61b527 5905 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 5906 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 5907 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 5908 }
whismanoid 10:04022a61b527 5909 break;
whismanoid 10:04022a61b527 5910 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 5911 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 5912 case '.':
whismanoid 4:d9b05924ad4c 5913 {
whismanoid 4:d9b05924ad4c 5914 // . -- SelfTest
whismanoid 4:d9b05924ad4c 5915 cmdLine.serial().printf("SelfTest()");
whismanoid 4:d9b05924ad4c 5916 SelfTest(cmdLine);
whismanoid 4:d9b05924ad4c 5917 }
whismanoid 4:d9b05924ad4c 5918 break;
whismanoid 4:d9b05924ad4c 5919 #endif // USE_SELFTEST
whismanoid 15:37c83ec50ea0 5920 #if 1 // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 5921 case '%':
whismanoid 4:d9b05924ad4c 5922 {
whismanoid 4:d9b05924ad4c 5923 pinsMonitor_submenu_onEOLcommandParser(cmdLine);
whismanoid 4:d9b05924ad4c 5924 }
whismanoid 4:d9b05924ad4c 5925 break; // case '%'
whismanoid 4:d9b05924ad4c 5926 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 9:45f98573eb6d 5927 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 5928 // reuse the Serial_Tester command *regName=regValue
whismanoid 10:04022a61b527 5929 // CODE GENERATOR: generate * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 5930 case '*':
whismanoid 10:04022a61b527 5931 {
whismanoid 10:04022a61b527 5932 // if buffer starts with a regName:
whismanoid 10:04022a61b527 5933 // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))):
whismanoid 10:04022a61b527 5934 // cmdLine.serial().printf(" scan RegName...\r\n");
whismanoid 10:04022a61b527 5935 }
whismanoid 10:04022a61b527 5936 break;
whismanoid 9:45f98573eb6d 5937 #endif // USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 5938 //
whismanoid 10:04022a61b527 5939 #if 1 // USE_AUX_SERIAL_CMD_FORWARDING && (HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL)
whismanoid 10:04022a61b527 5940 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_onEOLcommandParser
whismanoid 40:330b28116178 5941 case '>': case '<': // > send and receive; < receive without sending anything
whismanoid 10:04022a61b527 5942 {
whismanoid 10:04022a61b527 5943 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 5944 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 5945 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 5946 CmdLine& cmdLine_AuxSerial = cmdLine_AUXserial;
whismanoid 10:04022a61b527 5947 Serial& AuxSerial = AUXserial;
whismanoid 10:04022a61b527 5948 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5949 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 5950 CmdLine& cmdLine_AuxSerial = cmdLine_DAPLINKserial;
whismanoid 10:04022a61b527 5951 Serial& AuxSerial = DAPLINKserial;
whismanoid 10:04022a61b527 5952 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5953 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 5954 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5955 //
whismanoid 40:330b28116178 5956 int g_auxSerialCom_outgoing_string_cr = 1; // option to send CR after outgoing_string
whismanoid 40:330b28116178 5957 int g_auxSerialCom_outgoing_string_lf = 0; // option to send LF after outgoing_string (breaks remote datalogger LR!)
whismanoid 40:330b28116178 5958 int g_auxSerialCom_rx_string_verbose_crlf = 0; // option to display \r\n as "\\r\\n" in rx_string_buf
whismanoid 40:330b28116178 5959 int g_auxSerialCom_rx_string_verbose_ctrl = 1; // option to display control codes as \xXX
whismanoid 40:330b28116178 5960 const char* g_auxSerialCom_display_tx_prefix = "\r\n->|"; // "\r\n >";
whismanoid 40:330b28116178 5961 const char* g_auxSerialCom_display_rx_prefix = "\r\n<-|"; // "\r\n< ";
whismanoid 40:330b28116178 5962 //
whismanoid 40:330b28116178 5963 bool need_g_auxSerialCom_display_rx_prefix = 1; // temp
whismanoid 40:330b28116178 5964 //
whismanoid 10:04022a61b527 5965 // >> suppress key=value parsing
whismanoid 10:04022a61b527 5966 bool suppress_parsing = (cmdLine[1] == '>');
whismanoid 10:04022a61b527 5967 if (suppress_parsing == false) {
whismanoid 10:04022a61b527 5968 // int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 5969 if (cmdLine.parse_int_dec("baud", g_auxSerialCom_baud))
whismanoid 10:04022a61b527 5970 {
whismanoid 10:04022a61b527 5971 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- baud rate
whismanoid 10:04022a61b527 5972 cmdLine_AuxSerial.serial().printf("\r\n*** New Baud Rate %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5973 AuxSerial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5974 cmdLine_AuxSerial.serial().printf("\r\n*** Baud Rate was set to %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5975 }
whismanoid 10:04022a61b527 5976 #if 0
whismanoid 10:04022a61b527 5977 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 5978 if (cmdLine.parse_int_dec("tx_wait_echo", g_auxSerialCom_tx_wait_echo))
whismanoid 10:04022a61b527 5979 {
whismanoid 10:04022a61b527 5980 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_wait_echo
whismanoid 10:04022a61b527 5981 //~ cmdLine_AuxSerial.serial().printf("\r\n*** tx_wait_echo was set to %d ***\r\n", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 5982 cmdLine.serial().printf("\r\n tx_wait_echo=%d", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 5983 }
whismanoid 10:04022a61b527 5984 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 5985 if (cmdLine.parse_int_dec("tx_char_delay_ms", g_auxSerialCom_tx_char_delay_ms))
whismanoid 10:04022a61b527 5986 {
whismanoid 10:04022a61b527 5987 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_char_delay_ms
whismanoid 10:04022a61b527 5988 //~ 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 5989 cmdLine.serial().printf("\r\n tx_char_delay_ms=%dms", g_auxSerialCom_tx_char_delay_ms);
whismanoid 10:04022a61b527 5990 }
whismanoid 10:04022a61b527 5991 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 5992 if (cmdLine.parse_int_dec("tx_line_delay_ms", g_auxSerialCom_tx_line_delay_ms))
whismanoid 10:04022a61b527 5993 {
whismanoid 10:04022a61b527 5994 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_line_delay_ms
whismanoid 10:04022a61b527 5995 //~ 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 5996 cmdLine.serial().printf("\r\n tx_line_delay_ms=%dms", g_auxSerialCom_tx_line_delay_ms);
whismanoid 10:04022a61b527 5997 }
whismanoid 10:04022a61b527 5998 #endif
whismanoid 10:04022a61b527 5999 // int g_auxSerialCom_message_ms = 0; //!< capture RX until response timeout?
whismanoid 10:04022a61b527 6000 if (cmdLine.parse_int_dec("message_ms", g_auxSerialCom_message_ms))
whismanoid 10:04022a61b527 6001 {
whismanoid 10:04022a61b527 6002 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 10:04022a61b527 6003 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 6004 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 6005 }
whismanoid 10:04022a61b527 6006 // int g_auxSerialCom_rx_idle_ms = 0; //!< capture RX until idle timeout?
whismanoid 10:04022a61b527 6007 if (cmdLine.parse_int_dec("rx_idle_ms", g_auxSerialCom_rx_idle_ms))
whismanoid 10:04022a61b527 6008 {
whismanoid 10:04022a61b527 6009 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_idle_ms
whismanoid 10:04022a61b527 6010 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_idle_ms was set to %d ***\r\n", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 6011 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 6012 }
whismanoid 10:04022a61b527 6013 // int g_auxSerialCom_rx_max_count = 0; //!< capture RX until max character count?
whismanoid 10:04022a61b527 6014 if (cmdLine.parse_int_dec("rx_max_count", g_auxSerialCom_rx_max_count))
whismanoid 10:04022a61b527 6015 {
whismanoid 10:04022a61b527 6016 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_max_count
whismanoid 10:04022a61b527 6017 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_max_count was set to %d ***\r\n", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 6018 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 6019 }
whismanoid 10:04022a61b527 6020 // int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text char?
whismanoid 10:04022a61b527 6021 if (cmdLine.parse_int_dec("rx_eot", g_auxSerialCom_rx_eot))
whismanoid 10:04022a61b527 6022 {
whismanoid 10:04022a61b527 6023 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_eot
whismanoid 10:04022a61b527 6024 //~ cmdLine_AUXserial.serial().printf("\r\n*** rx_eot was set to %d ***\r\n", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 6025 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 6026 }
whismanoid 10:04022a61b527 6027 }
whismanoid 10:04022a61b527 6028 // Command forwarding to AUX serial TX/RX cmdLine_AuxSerial #257 -- send outgoing_string
whismanoid 41:13a6a097502c 6029 char* outgoing_string = ""; // warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
whismanoid 40:330b28116178 6030 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 6031 outgoing_string = (char*)cmdLine.str();
whismanoid 40:330b28116178 6032 // > use key=value parsing
whismanoid 40:330b28116178 6033 // >> suppress key=value parsing
whismanoid 40:330b28116178 6034 if (suppress_parsing) {
whismanoid 40:330b28116178 6035 cmdLine.serial().printf("\r\n suppress_parsing outgoing_string=\"%s\"", outgoing_string);
whismanoid 40:330b28116178 6036 outgoing_string++; // skip the first '>'
whismanoid 40:330b28116178 6037 outgoing_string++; // skip the second '>'
whismanoid 40:330b28116178 6038 } else {
whismanoid 40:330b28116178 6039 // TODO: after parsing, key=value pairs should be deleted, but outgoing_string=">xyzzy abc=def"
whismanoid 40:330b28116178 6040 cmdLine.serial().printf("\r\n after parsing, outgoing_string=\"%s\"", outgoing_string);
whismanoid 40:330b28116178 6041 outgoing_string++; // skip the first '>'
whismanoid 40:330b28116178 6042 }
whismanoid 40:330b28116178 6043 } // if (cmdLine[0] == '>')
whismanoid 10:04022a61b527 6044 static char rx_string_buf[RX_STRING_BUF_SIZE];
whismanoid 10:04022a61b527 6045 unsigned int rx_string_length = 0;
whismanoid 40:330b28116178 6046 //cmdLine.serial().printf("\r\n >%s\r\n <", outgoing_string);
whismanoid 40:330b28116178 6047 //char* g_auxSerialCom_display_tx_prefix = "\r\n >";
whismanoid 40:330b28116178 6048 //char* g_auxSerialCom_display_rx_prefix = "\r\n< ";
whismanoid 40:330b28116178 6049 cmdLine.serial().printf("%s%s%s",
whismanoid 40:330b28116178 6050 g_auxSerialCom_display_tx_prefix, // "\r\n >"
whismanoid 40:330b28116178 6051 outgoing_string,
whismanoid 40:330b28116178 6052 g_auxSerialCom_display_rx_prefix // "\r\n <"
whismanoid 40:330b28116178 6053 );
whismanoid 10:04022a61b527 6054 rx_string_buf[0] = '\0';
whismanoid 10:04022a61b527 6055 rx_string_length = 0;
whismanoid 10:04022a61b527 6056 //
whismanoid 10:04022a61b527 6057 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 6058 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 6059 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 6060 //
whismanoid 10:04022a61b527 6061 // int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 6062 // int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 6063 // int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 6064 // int g_auxSerialCom_rx_idle_ms = 2000; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 6065 // int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 6066 // int g_auxSerialCom_rx_eot = '\r'; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 6067 //~ cmdLine_AuxSerial.serial().printf("\r\n*** TODO forward %s ***\r\n", outgoing_string);
whismanoid 10:04022a61b527 6068 //
whismanoid 10:04022a61b527 6069 // TODO: send whole string or send character-by-character?
whismanoid 40:330b28116178 6070 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 6071 cmdLine_AuxSerial.serial().printf("%s", outgoing_string);
whismanoid 40:330b28116178 6072 //
whismanoid 40:330b28116178 6073 // TODO: send CRLF or just send CR line end?
whismanoid 40:330b28116178 6074 if (g_auxSerialCom_outgoing_string_cr) { cmdLine_AuxSerial.serial().printf("\r"); }
whismanoid 40:330b28116178 6075 if (g_auxSerialCom_outgoing_string_lf) { cmdLine_AuxSerial.serial().printf("\n"); }
whismanoid 40:330b28116178 6076 // cmdLine_AuxSerial.serial().printf("\r\n");
whismanoid 40:330b28116178 6077 } // if (cmdLine[0] == '>')
whismanoid 40:330b28116178 6078 //
whismanoid 10:04022a61b527 6079 g_auxSerialCom_Timer.start();
whismanoid 10:04022a61b527 6080 g_auxSerialCom_Timer_begin_message_ms = g_auxSerialCom_Timer.read_ms(); // start of message
whismanoid 10:04022a61b527 6081 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 6082 while (rx_string_length < (RX_STRING_BUF_SIZE-1)) {
whismanoid 10:04022a61b527 6083 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_message_ms) > g_auxSerialCom_message_ms) {
whismanoid 10:04022a61b527 6084 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 6085 break;
whismanoid 10:04022a61b527 6086 }
whismanoid 10:04022a61b527 6087 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_rx_idle_ms) > g_auxSerialCom_rx_idle_ms) {
whismanoid 10:04022a61b527 6088 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 6089 break;
whismanoid 10:04022a61b527 6090 }
whismanoid 41:13a6a097502c 6091 if ((int)rx_string_length >= g_auxSerialCom_rx_max_count) {
whismanoid 10:04022a61b527 6092 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 6093 break;
whismanoid 10:04022a61b527 6094 }
whismanoid 10:04022a61b527 6095 if (AuxSerial.readable()) {
whismanoid 10:04022a61b527 6096 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 6097 char ch = AuxSerial.getc();
whismanoid 10:04022a61b527 6098 rx_string_buf[rx_string_length++] = ch;
whismanoid 10:04022a61b527 6099 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 40:330b28116178 6100 //
whismanoid 40:330b28116178 6101 #if 1
whismanoid 40:330b28116178 6102 // immediate character echo
whismanoid 40:330b28116178 6103 for (char* cp = &(rx_string_buf[rx_string_length-1]); *cp != '\0'; cp++)
whismanoid 40:330b28116178 6104 {
whismanoid 40:330b28116178 6105 //cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 6106 if (need_g_auxSerialCom_display_rx_prefix) {
whismanoid 40:330b28116178 6107 cmdLine.serial().printf(g_auxSerialCom_display_rx_prefix); // "\r\n< " g_auxSerialCom_rx_string display prefix
whismanoid 40:330b28116178 6108 need_g_auxSerialCom_display_rx_prefix = 0;
whismanoid 40:330b28116178 6109 }
whismanoid 40:330b28116178 6110 if ((*cp) == '\r') {
whismanoid 40:330b28116178 6111 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\r"); }
whismanoid 40:330b28116178 6112 // if (*(cp+1) != '\n') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 6113 } else if ((*cp) == '\n') {
whismanoid 40:330b28116178 6114 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\n"); }
whismanoid 40:330b28116178 6115 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 6116 if (*(cp-1) != '\r') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 6117 } else if ((*cp) < 0x20) {
whismanoid 40:330b28116178 6118 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6119 } else if ((*cp) >= 0x7f) {
whismanoid 40:330b28116178 6120 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6121 } else {
whismanoid 40:330b28116178 6122 cmdLine.serial().printf("%c", *cp);
whismanoid 40:330b28116178 6123 }
whismanoid 40:330b28116178 6124 }
whismanoid 40:330b28116178 6125 #else
whismanoid 40:330b28116178 6126 // immediate character echo
whismanoid 40:330b28116178 6127 cmdLine.serial().printf("%s", &(rx_string_buf[rx_string_length-1]) );
whismanoid 40:330b28116178 6128 #endif
whismanoid 40:330b28116178 6129 //
whismanoid 10:04022a61b527 6130 if (g_auxSerialCom_rx_eot != aux_serial_cmd_forwarding_rx_eot_not_used) {
whismanoid 10:04022a61b527 6131 if (ch == g_auxSerialCom_rx_eot) {
whismanoid 10:04022a61b527 6132 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 6133 break;
whismanoid 10:04022a61b527 6134 }
whismanoid 10:04022a61b527 6135 }
whismanoid 10:04022a61b527 6136 }
whismanoid 10:04022a61b527 6137 } // end while (rx_string_length < (RX_STRING_BUF_SIZE-1))
whismanoid 40:330b28116178 6138 #if 0
whismanoid 10:04022a61b527 6139 // print summary. is this needed? we already print aux rx as it is received.
whismanoid 10:04022a61b527 6140 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 40:330b28116178 6141 # if 1 // support multi-line rx_string_buf response
whismanoid 40:330b28116178 6142 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 6143 cmdLine.serial().printf("%s%s", g_auxSerialCom_display_tx_prefix, outgoing_string);
whismanoid 40:330b28116178 6144 } // if (cmdLine[0] == '>')
whismanoid 40:330b28116178 6145 // cmdLine.serial().printf("\r\n <"); // prefix
whismanoid 40:330b28116178 6146 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 6147 for (char* cp = rx_string_buf; *cp != '\0'; cp++)
whismanoid 40:330b28116178 6148 {
whismanoid 40:330b28116178 6149 //cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 6150 if (need_g_auxSerialCom_display_rx_prefix) {
whismanoid 40:330b28116178 6151 cmdLine.serial().printf(g_auxSerialCom_display_rx_prefix); // "\r\n< " g_auxSerialCom_rx_string display prefix
whismanoid 40:330b28116178 6152 need_g_auxSerialCom_display_rx_prefix = 0;
whismanoid 40:330b28116178 6153 }
whismanoid 40:330b28116178 6154 if ((*cp) == '\r') {
whismanoid 40:330b28116178 6155 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\r"); }
whismanoid 40:330b28116178 6156 if (*(cp+1) != '\n') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 6157 } else if ((*cp) == '\n') {
whismanoid 40:330b28116178 6158 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\n"); }
whismanoid 40:330b28116178 6159 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 6160 } else if ((*cp) < 0x20) {
whismanoid 40:330b28116178 6161 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6162 } else if ((*cp) >= 0x7f) {
whismanoid 40:330b28116178 6163 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 6164 } else {
whismanoid 40:330b28116178 6165 cmdLine.serial().printf("%c", *cp);
whismanoid 40:330b28116178 6166 }
whismanoid 40:330b28116178 6167 }
whismanoid 40:330b28116178 6168 cmdLine.serial().printf("\r\n");
whismanoid 40:330b28116178 6169 # else
whismanoid 10:04022a61b527 6170 cmdLine.serial().printf("\r\n >%s", outgoing_string);
whismanoid 10:04022a61b527 6171 cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 6172 # endif
whismanoid 10:04022a61b527 6173 #endif
whismanoid 10:04022a61b527 6174 //
whismanoid 10:04022a61b527 6175 }
whismanoid 10:04022a61b527 6176 break; // case '>'
whismanoid 10:04022a61b527 6177 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6178 //
whismanoid 4:d9b05924ad4c 6179 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 6180 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 6181 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 6182 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 6183 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible
whismanoid 9:45f98573eb6d 6184 case 'L': case 'l':
whismanoid 4:d9b05924ad4c 6185 {
whismanoid 4:d9b05924ad4c 6186 // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 6187 Datalogger_Trigger = trigger_Halt;
whismanoid 4:d9b05924ad4c 6188 switch (cmdLine[1])
whismanoid 4:d9b05924ad4c 6189 {
whismanoid 17:9397ea3ea7e9 6190 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 6191 case 'T': case 't':
whismanoid 17:9397ea3ea7e9 6192 {
whismanoid 17:9397ea3ea7e9 6193 // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 6194 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 6195 Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6196 g_timer_interval_counter = 0;
whismanoid 39:4d285e961435 6197 // get g_timer_interval_msec from cmdLine
whismanoid 17:9397ea3ea7e9 6198 // g_timer_interval_msec = 500;
whismanoid 17:9397ea3ea7e9 6199 // g_timer_interval_count = 10;
whismanoid 17:9397ea3ea7e9 6200 if (cmdLine.parse_int_dec("count", g_timer_interval_count))
whismanoid 17:9397ea3ea7e9 6201 {
whismanoid 32:80f3e5eb77d4 6202 if (g_timer_interval_count < 1) { g_timer_interval_count = 1; }
whismanoid 17:9397ea3ea7e9 6203 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 6204 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 6205 cmdLine.serial().printf("\r\n g_timer_interval_count=%d", g_timer_interval_count);
whismanoid 17:9397ea3ea7e9 6206 }
whismanoid 17:9397ea3ea7e9 6207 if (cmdLine.parse_int_dec("base", g_timer_interval_msec))
whismanoid 17:9397ea3ea7e9 6208 {
whismanoid 17:9397ea3ea7e9 6209 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 6210 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 6211 cmdLine.serial().printf("\r\n g_timer_interval_msec=%d", g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 6212 }
whismanoid 39:4d285e961435 6213 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 6214 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 6215 int int_timer_sleepmode = g_timer_sleepmode;
whismanoid 39:4d285e961435 6216 if (cmdLine.parse_int_dec("sleep", int_timer_sleepmode))
whismanoid 39:4d285e961435 6217 {
whismanoid 39:4d285e961435 6218 g_timer_sleepmode = (Datalogger_Sleep_enum_t)int_timer_sleepmode;
whismanoid 39:4d285e961435 6219 //~ if (g_timer_interval_count < 1) { g_timer_interval_count = 1; }
whismanoid 39:4d285e961435 6220 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 39:4d285e961435 6221 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 39:4d285e961435 6222 cmdLine.serial().printf("\r\n g_timer_sleepmode=%d", (int)g_timer_sleepmode);
whismanoid 39:4d285e961435 6223 }
whismanoid 39:4d285e961435 6224 #else // USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 6225 #endif // USE_DATALOGGER_SLEEP
whismanoid 17:9397ea3ea7e9 6226 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 17:9397ea3ea7e9 6227 }
whismanoid 17:9397ea3ea7e9 6228 break;
whismanoid 17:9397ea3ea7e9 6229 // LIH3 -- Datalog when input high D3
whismanoid 17:9397ea3ea7e9 6230 // LIL6 -- Datalog when input low D6
whismanoid 17:9397ea3ea7e9 6231 case 'I': case 'i':
whismanoid 17:9397ea3ea7e9 6232 {
whismanoid 17:9397ea3ea7e9 6233 // TODO: switch cmdLine[2] configure High or Low, configure input pin
whismanoid 17:9397ea3ea7e9 6234 }
whismanoid 17:9397ea3ea7e9 6235 break;
whismanoid 17:9397ea3ea7e9 6236 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 6237 // L$ count=10 base=500ms addr=xxx data=xxx mask=xxx -- Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 6238 case '$':
whismanoid 17:9397ea3ea7e9 6239 {
whismanoid 17:9397ea3ea7e9 6240 // TODO: scan cmdLine for regAddr, dataMask, testValue
whismanoid 17:9397ea3ea7e9 6241 }
whismanoid 17:9397ea3ea7e9 6242 break;
whismanoid 17:9397ea3ea7e9 6243 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6244 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6245 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6246 case '@':
whismanoid 17:9397ea3ea7e9 6247 {
whismanoid 17:9397ea3ea7e9 6248 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6249 int editRowIndex = 0;
whismanoid 17:9397ea3ea7e9 6250 int edit_action = (int)action_noop;
whismanoid 17:9397ea3ea7e9 6251 int edit_digitalOutPin = 0;
whismanoid 17:9397ea3ea7e9 6252 int edit_condition = (int)condition_always;
whismanoid 17:9397ea3ea7e9 6253 int edit_condition_channel = 0;
whismanoid 17:9397ea3ea7e9 6254 double edit_condition_threshold = 0;
whismanoid 17:9397ea3ea7e9 6255 //
whismanoid 17:9397ea3ea7e9 6256 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 17:9397ea3ea7e9 6257 {
whismanoid 17:9397ea3ea7e9 6258 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 17:9397ea3ea7e9 6259 }
whismanoid 17:9397ea3ea7e9 6260 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 17:9397ea3ea7e9 6261 {
whismanoid 17:9397ea3ea7e9 6262 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 17:9397ea3ea7e9 6263 }
whismanoid 17:9397ea3ea7e9 6264 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 17:9397ea3ea7e9 6265 {
whismanoid 17:9397ea3ea7e9 6266 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 17:9397ea3ea7e9 6267 }
whismanoid 17:9397ea3ea7e9 6268 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 17:9397ea3ea7e9 6269 {
whismanoid 17:9397ea3ea7e9 6270 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 17:9397ea3ea7e9 6271 }
whismanoid 17:9397ea3ea7e9 6272 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 17:9397ea3ea7e9 6273 {
whismanoid 17:9397ea3ea7e9 6274 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 17:9397ea3ea7e9 6275 }
whismanoid 17:9397ea3ea7e9 6276 //
whismanoid 17:9397ea3ea7e9 6277 // Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6278 switch (cmdLine[2]) // L@... -- Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6279 {
whismanoid 17:9397ea3ea7e9 6280 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 6281 case '0': case '1': case '2': case '3': case '4':
whismanoid 17:9397ea3ea7e9 6282 case '5': case '6': case '7': case '8': case '9':
whismanoid 17:9397ea3ea7e9 6283 // edit row data
whismanoid 30:07197a430869 6284 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 6285 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 6286 // get row number to edit from cmdLine[2]
whismanoid 17:9397ea3ea7e9 6287 editRowIndex = atoi(cmdLine.str()+2);
whismanoid 30:07197a430869 6288 if ((editRowIndex >= 0) && (editRowIndex < Datalogger_action_table_row_count)) {
whismanoid 30:07197a430869 6289 // update row
whismanoid 30:07197a430869 6290 cmdLine.serial().printf("\r\n replace row %d", editRowIndex);
whismanoid 30:07197a430869 6291 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 6292 edit_action = Datalogger_action_table[editRowIndex].action;
whismanoid 30:07197a430869 6293 edit_digitalOutPin = Datalogger_action_table[editRowIndex].digitalOutPin;
whismanoid 30:07197a430869 6294 edit_condition = Datalogger_action_table[editRowIndex].condition;
whismanoid 30:07197a430869 6295 edit_condition_channel = Datalogger_action_table[editRowIndex].condition_channel;
whismanoid 30:07197a430869 6296 edit_condition_threshold = Datalogger_action_table[editRowIndex].condition_threshold;
whismanoid 30:07197a430869 6297 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 6298 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 30:07197a430869 6299 {
whismanoid 30:07197a430869 6300 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 30:07197a430869 6301 }
whismanoid 30:07197a430869 6302 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 30:07197a430869 6303 {
whismanoid 30:07197a430869 6304 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 30:07197a430869 6305 }
whismanoid 30:07197a430869 6306 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 30:07197a430869 6307 {
whismanoid 30:07197a430869 6308 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 30:07197a430869 6309 }
whismanoid 30:07197a430869 6310 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 30:07197a430869 6311 {
whismanoid 30:07197a430869 6312 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 30:07197a430869 6313 }
whismanoid 30:07197a430869 6314 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 30:07197a430869 6315 {
whismanoid 30:07197a430869 6316 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 30:07197a430869 6317 }
whismanoid 30:07197a430869 6318 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 6319 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 6320 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 6321 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 6322 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 6323 }
whismanoid 30:07197a430869 6324 else if ((editRowIndex == Datalogger_action_table_row_count) && (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX)) {
whismanoid 30:07197a430869 6325 // %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 6326 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 6327 cmdLine.serial().printf("\r\n add next row %d", editRowIndex);
whismanoid 30:07197a430869 6328 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 6329 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 6330 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 6331 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 6332 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 30:07197a430869 6333 //
whismanoid 17:9397ea3ea7e9 6334 }
whismanoid 17:9397ea3ea7e9 6335 }
whismanoid 17:9397ea3ea7e9 6336 break;
whismanoid 17:9397ea3ea7e9 6337 case '+':
whismanoid 17:9397ea3ea7e9 6338 // add a new row at end of table
whismanoid 17:9397ea3ea7e9 6339 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 6340 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 6341 editRowIndex = Datalogger_action_table_row_count;
whismanoid 17:9397ea3ea7e9 6342 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 6343 cmdLine.serial().printf("\r\n add new row %d", editRowIndex);
whismanoid 17:9397ea3ea7e9 6344 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 17:9397ea3ea7e9 6345 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 17:9397ea3ea7e9 6346 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 17:9397ea3ea7e9 6347 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 17:9397ea3ea7e9 6348 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 6349 }
whismanoid 17:9397ea3ea7e9 6350 break;
whismanoid 17:9397ea3ea7e9 6351 case '-':
whismanoid 17:9397ea3ea7e9 6352 // delete row from table
whismanoid 17:9397ea3ea7e9 6353 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 6354 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 6355 if ((cmdLine[3] == '~') && (cmdLine[4] == '~') && (cmdLine[5] == '~')) {
whismanoid 17:9397ea3ea7e9 6356 // L@-~~~ -- delete all rows from table
whismanoid 30:07197a430869 6357 cmdLine.serial().printf("\r\n delete all rows");
whismanoid 17:9397ea3ea7e9 6358 Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 6359 break;
whismanoid 17:9397ea3ea7e9 6360 }
whismanoid 30:07197a430869 6361 else {
whismanoid 30:07197a430869 6362 editRowIndex = atoi(cmdLine.str()+3);
whismanoid 30:07197a430869 6363 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 30:07197a430869 6364 // delete row editRowIndex from Datalogger_action_table
whismanoid 30:07197a430869 6365 for (int i = editRowIndex; i < (Datalogger_action_table_row_count-1); i++)
whismanoid 30:07197a430869 6366 {
whismanoid 30:07197a430869 6367 // copy row i+1 into row i
whismanoid 30:07197a430869 6368 Datalogger_action_table[i].action = Datalogger_action_table[i+1].action;
whismanoid 30:07197a430869 6369 Datalogger_action_table[i].digitalOutPin = Datalogger_action_table[i+1].digitalOutPin;
whismanoid 30:07197a430869 6370 Datalogger_action_table[i].condition = Datalogger_action_table[i+1].condition;
whismanoid 30:07197a430869 6371 Datalogger_action_table[i].condition_channel = Datalogger_action_table[i+1].condition_channel;
whismanoid 30:07197a430869 6372 Datalogger_action_table[i].condition_threshold = Datalogger_action_table[i+1].condition_threshold;
whismanoid 30:07197a430869 6373 }
whismanoid 30:07197a430869 6374 Datalogger_action_table_row_count--;
whismanoid 17:9397ea3ea7e9 6375 }
whismanoid 17:9397ea3ea7e9 6376 }
whismanoid 17:9397ea3ea7e9 6377 break;
whismanoid 30:07197a430869 6378 case '.':
whismanoid 30:07197a430869 6379 // L@. pause the entire Log action table
whismanoid 30:07197a430869 6380 cmdLine.serial().printf("\r\n pause the entire Log action table");
whismanoid 17:9397ea3ea7e9 6381 Datalogger_action_table_enabled = false;
whismanoid 17:9397ea3ea7e9 6382 break;
whismanoid 17:9397ea3ea7e9 6383 case '@':
whismanoid 30:07197a430869 6384 // L@@ enable the entire Log action table
whismanoid 30:07197a430869 6385 cmdLine.serial().printf("\r\n enable the entire Log action table");
whismanoid 17:9397ea3ea7e9 6386 Datalogger_action_table_enabled = true;
whismanoid 17:9397ea3ea7e9 6387 break;
whismanoid 17:9397ea3ea7e9 6388 }
whismanoid 17:9397ea3ea7e9 6389 //
whismanoid 17:9397ea3ea7e9 6390 // Print the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6391 if (Datalogger_action_table_enabled) {
whismanoid 30:07197a430869 6392 // cmdLine.serial().printf("Log action table enabled; L@. to pause");
whismanoid 17:9397ea3ea7e9 6393 }
whismanoid 17:9397ea3ea7e9 6394 else {
whismanoid 30:07197a430869 6395 cmdLine.serial().printf("Log action table paused; L@@ to enable");
whismanoid 17:9397ea3ea7e9 6396 }
whismanoid 17:9397ea3ea7e9 6397 //~ cmdLine.serial().printf("\r\n Datalogger_action_table_row_count=%d", Datalogger_action_table_row_count);
whismanoid 17:9397ea3ea7e9 6398 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 6399 {
whismanoid 17:9397ea3ea7e9 6400 cmdLine.serial().printf("\r\n L@%d", i);
whismanoid 17:9397ea3ea7e9 6401 cmdLine.serial().printf(" act=%d", Datalogger_action_table[i].action);
whismanoid 17:9397ea3ea7e9 6402 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6403 {
whismanoid 17:9397ea3ea7e9 6404 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 6405 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 6406 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6407 break;
whismanoid 29:6a9edb6e973b 6408 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6409 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 6410 break;
whismanoid 17:9397ea3ea7e9 6411 default:
whismanoid 17:9397ea3ea7e9 6412 case action_noop:
whismanoid 17:9397ea3ea7e9 6413 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 6414 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 6415 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 6416 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 6417 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 6418 break;
whismanoid 17:9397ea3ea7e9 6419 }
whismanoid 17:9397ea3ea7e9 6420 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6421 {
whismanoid 17:9397ea3ea7e9 6422 case condition_always:
whismanoid 17:9397ea3ea7e9 6423 break;
whismanoid 17:9397ea3ea7e9 6424 default:
whismanoid 17:9397ea3ea7e9 6425 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 6426 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 6427 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 6428 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 6429 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 6430 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 6431 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 6432 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 6433 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 6434 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 6435 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 6436 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 6437 cmdLine.serial().printf(" if=%d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 6438 cmdLine.serial().printf(" ch=%d", Datalogger_action_table[i].condition_channel);
whismanoid 40:330b28116178 6439 // our voltage measurement is around 1mV at best
whismanoid 40:330b28116178 6440 cmdLine.serial().printf(" x=%1.4f", Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6441 break;
whismanoid 17:9397ea3ea7e9 6442 }
whismanoid 17:9397ea3ea7e9 6443 cmdLine.serial().printf(" -- ");
whismanoid 17:9397ea3ea7e9 6444 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6445 {
whismanoid 17:9397ea3ea7e9 6446 case action_noop:
whismanoid 17:9397ea3ea7e9 6447 cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 6448 break;
whismanoid 17:9397ea3ea7e9 6449 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 6450 cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 6451 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6452 break;
whismanoid 17:9397ea3ea7e9 6453 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 6454 cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 6455 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6456 break;
whismanoid 29:6a9edb6e973b 6457 case action_button: // pin = button index 1, 2, 3
whismanoid 40:330b28116178 6458 cmdLine.serial().printf("button %%B%d!", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 6459 break;
whismanoid 17:9397ea3ea7e9 6460 case action_trigger_Halt:
whismanoid 40:330b28116178 6461 cmdLine.serial().printf("Halt");
whismanoid 17:9397ea3ea7e9 6462 break;
whismanoid 17:9397ea3ea7e9 6463 case action_trigger_FreeRun:
whismanoid 40:330b28116178 6464 cmdLine.serial().printf("LR");
whismanoid 17:9397ea3ea7e9 6465 break;
whismanoid 17:9397ea3ea7e9 6466 case action_trigger_Timer:
whismanoid 45:74bf1fe021e5 6467 cmdLine.serial().printf("LT count=%d base=%dms", g_timer_interval_count, g_timer_interval_msec);
whismanoid 45:74bf1fe021e5 6468 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 6469 cmdLine.serial().printf(" sleep=%d", g_timer_sleepmode);
whismanoid 45:74bf1fe021e5 6470 #endif // USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 17:9397ea3ea7e9 6471 break;
whismanoid 17:9397ea3ea7e9 6472 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 6473 cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 6474 // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 6475 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 6476 break;
whismanoid 17:9397ea3ea7e9 6477 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 6478 cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 6479 // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6480 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 6481 break;
whismanoid 17:9397ea3ea7e9 6482 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6483 //~ cmdLine.serial().printf(" condition %d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 6484 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6485 {
whismanoid 17:9397ea3ea7e9 6486 case condition_always:
whismanoid 17:9397ea3ea7e9 6487 cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 6488 break;
whismanoid 17:9397ea3ea7e9 6489 case condition_if_An_gt_threshold:
whismanoid 40:330b28116178 6490 cmdLine.serial().printf(" if A%d > %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6491 break;
whismanoid 17:9397ea3ea7e9 6492 case condition_if_An_lt_threshold:
whismanoid 40:330b28116178 6493 cmdLine.serial().printf(" if A%d < %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6494 break;
whismanoid 17:9397ea3ea7e9 6495 case condition_if_An_eq_threshold:
whismanoid 40:330b28116178 6496 cmdLine.serial().printf(" if A%d == %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6497 break;
whismanoid 17:9397ea3ea7e9 6498 case condition_if_An_ge_threshold:
whismanoid 40:330b28116178 6499 cmdLine.serial().printf(" if A%d >= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6500 break;
whismanoid 17:9397ea3ea7e9 6501 case condition_if_An_le_threshold:
whismanoid 40:330b28116178 6502 cmdLine.serial().printf(" if A%d <= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6503 break;
whismanoid 17:9397ea3ea7e9 6504 case condition_if_An_ne_threshold:
whismanoid 40:330b28116178 6505 cmdLine.serial().printf(" if A%d != %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6506 break;
whismanoid 17:9397ea3ea7e9 6507 case condition_if_AINn_gt_threshold:
whismanoid 40:330b28116178 6508 cmdLine.serial().printf(" if AIN%d > %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6509 break;
whismanoid 17:9397ea3ea7e9 6510 case condition_if_AINn_lt_threshold:
whismanoid 40:330b28116178 6511 cmdLine.serial().printf(" if AIN%d < %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6512 break;
whismanoid 17:9397ea3ea7e9 6513 case condition_if_AINn_eq_threshold:
whismanoid 40:330b28116178 6514 cmdLine.serial().printf(" if AIN%d == %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6515 break;
whismanoid 17:9397ea3ea7e9 6516 case condition_if_AINn_ge_threshold:
whismanoid 40:330b28116178 6517 cmdLine.serial().printf(" if AIN%d >= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6518 break;
whismanoid 17:9397ea3ea7e9 6519 case condition_if_AINn_le_threshold:
whismanoid 40:330b28116178 6520 cmdLine.serial().printf(" if AIN%d <= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6521 break;
whismanoid 17:9397ea3ea7e9 6522 case condition_if_AINn_ne_threshold:
whismanoid 40:330b28116178 6523 cmdLine.serial().printf(" if AIN%d != %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6524 break;
whismanoid 17:9397ea3ea7e9 6525 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6526 } // for ...Datalogger_action_table_row_count // Print the contents of Datalogger_action_table
whismanoid 30:07197a430869 6527 cmdLine.serial().printf("\r\n\r\nEdit Log action table (used %d/%d, %d free):",
whismanoid 30:07197a430869 6528 Datalogger_action_table_row_count,
whismanoid 30:07197a430869 6529 ACTION_TABLE_ROW_MAX,
whismanoid 30:07197a430869 6530 (ACTION_TABLE_ROW_MAX - Datalogger_action_table_row_count)
whismanoid 30:07197a430869 6531 );
whismanoid 17:9397ea3ea7e9 6532 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 6533 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 6534 cmdLine.serial().printf("\r\n L@+ act=4 if=1 ch=5 x=12345 -- add new entry at end of table");
whismanoid 17:9397ea3ea7e9 6535 }
whismanoid 17:9397ea3ea7e9 6536 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 6537 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 6538 cmdLine.serial().printf("\r\n L@%d act=4 if=1 ch=5 x=12345 -- edit row %d",
whismanoid 17:9397ea3ea7e9 6539 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 6540 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 6541 cmdLine.serial().printf("\r\n L@-%d -- delete row %d",
whismanoid 17:9397ea3ea7e9 6542 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 6543 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 6544 cmdLine.serial().printf("\r\n L@-~~~ -- delete all rows");
whismanoid 30:07197a430869 6545 if (Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@. -- pause entire Log action table");
whismanoid 30:07197a430869 6546 if (!Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@@ -- enable Log action table");
whismanoid 17:9397ea3ea7e9 6547 }
whismanoid 17:9397ea3ea7e9 6548 //
whismanoid 17:9397ea3ea7e9 6549 } // case L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 6550 break;
whismanoid 17:9397ea3ea7e9 6551 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6552 // LR -- Datalog free run as fast as possible
whismanoid 4:d9b05924ad4c 6553 case 'R': case 'r':
whismanoid 4:d9b05924ad4c 6554 // free run as fast as possible
whismanoid 8:dffee7509bfb 6555 Datalogger_Trigger = trigger_FreeRun;
whismanoid 8:dffee7509bfb 6556 Datalogger_Need_PrintHeader = true;
whismanoid 4:d9b05924ad4c 6557 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 9:45f98573eb6d 6558 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6559 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 6560 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 6561 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 6562 case 'S': case 's':
whismanoid 9:45f98573eb6d 6563 {
whismanoid 9:45f98573eb6d 6564 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6565 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 6566 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 6567 )
whismanoid 9:45f98573eb6d 6568 {
whismanoid 9:45f98573eb6d 6569 // it's me
whismanoid 9:45f98573eb6d 6570 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 6571 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 6572 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 6573 {
whismanoid 9:45f98573eb6d 6574 case 'D': case 'd':
whismanoid 9:45f98573eb6d 6575 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Disable;
whismanoid 9:45f98573eb6d 6576 break;
whismanoid 9:45f98573eb6d 6577 case 'L': case 'l':
whismanoid 9:45f98573eb6d 6578 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 6579 break;
whismanoid 9:45f98573eb6d 6580 case 'V': case 'v':
whismanoid 9:45f98573eb6d 6581 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 6582 break;
whismanoid 9:45f98573eb6d 6583 //
whismanoid 9:45f98573eb6d 6584 //
whismanoid 9:45f98573eb6d 6585 // TODO: MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 6586 case 'C': case 'c':
whismanoid 9:45f98573eb6d 6587 {
whismanoid 9:45f98573eb6d 6588 uint8_t hexValue = 0;
whismanoid 9:45f98573eb6d 6589 hexValue = hexValueOfChar(cmdLine[5]) * 0x10 + hexValueOfChar(cmdLine[6]);
whismanoid 9:45f98573eb6d 6590 switch (cmdLine[4])
whismanoid 9:45f98573eb6d 6591 {
whismanoid 9:45f98573eb6d 6592 //
whismanoid 9:45f98573eb6d 6593 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 6594 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34"));
whismanoid 9:45f98573eb6d 6595 case 'F': case 'f':
whismanoid 9:45f98573eb6d 6596 SPI_AIN_Cfg_v_filter_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 6597 break;
whismanoid 9:45f98573eb6d 6598 //
whismanoid 9:45f98573eb6d 6599 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 6600 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 6601 case 'C': case 'c':
whismanoid 9:45f98573eb6d 6602 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 6603 break;
whismanoid 9:45f98573eb6d 6604 //
whismanoid 9:45f98573eb6d 6605 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 6606 // cmdLine.serial().print(F("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00"));
whismanoid 9:45f98573eb6d 6607 case 'P': case 'p':
whismanoid 9:45f98573eb6d 6608 SPI_AIN_Cfg_v_pga_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 6609 break;
whismanoid 9:45f98573eb6d 6610 //
whismanoid 9:45f98573eb6d 6611 // cmdLine.serial().print(F("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar"));
whismanoid 9:45f98573eb6d 6612 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 6613 case 'U': case 'u':
whismanoid 9:45f98573eb6d 6614 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] | 0x40;
whismanoid 9:45f98573eb6d 6615 break;
whismanoid 9:45f98573eb6d 6616 //
whismanoid 9:45f98573eb6d 6617 // cmdLine.serial().print(F("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar"));
whismanoid 9:45f98573eb6d 6618 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 6619 case 'B': case 'b':
whismanoid 9:45f98573eb6d 6620 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] &~ 0x40;
whismanoid 9:45f98573eb6d 6621 break;
whismanoid 9:45f98573eb6d 6622 }
whismanoid 9:45f98573eb6d 6623 break;
whismanoid 9:45f98573eb6d 6624 }
whismanoid 9:45f98573eb6d 6625 //
whismanoid 9:45f98573eb6d 6626 //
whismanoid 9:45f98573eb6d 6627 }
whismanoid 9:45f98573eb6d 6628 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 6629 } // end for channel_index
whismanoid 9:45f98573eb6d 6630 Datalogger_PrintHeader();
whismanoid 9:45f98573eb6d 6631 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6632 }
whismanoid 9:45f98573eb6d 6633 break;
whismanoid 9:45f98573eb6d 6634 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6635 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 6636 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 6637 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 6638 // verb: D for disable, V for Voltage, L for LSB
whismanoid 8:dffee7509bfb 6639 case 'A': case 'a':
whismanoid 9:45f98573eb6d 6640 {
whismanoid 9:45f98573eb6d 6641 // all-channel: loop through all valid channel_index, test cmdLine[2] 'is it me'?
whismanoid 9:45f98573eb6d 6642 // for channel_index loop through 0..NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 9:45f98573eb6d 6643 // if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 6644 // || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 6645 // ) {
whismanoid 9:45f98573eb6d 6646 // // it's me
whismanoid 9:45f98573eb6d 6647 // // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 6648 // // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 6649 // } end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 6650 // } end for channel_index
whismanoid 9:45f98573eb6d 6651 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6652 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 6653 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 6654 )
whismanoid 9:45f98573eb6d 6655 {
whismanoid 9:45f98573eb6d 6656 // it's me
whismanoid 9:45f98573eb6d 6657 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 6658 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 6659 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 6660 {
whismanoid 9:45f98573eb6d 6661 case 'D': case 'd':
whismanoid 9:45f98573eb6d 6662 Platform_Enable_ch[channel_index] = Platform_AIN_Disable;
whismanoid 9:45f98573eb6d 6663 break;
whismanoid 9:45f98573eb6d 6664 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 6665 case 'L': case 'l':
whismanoid 9:45f98573eb6d 6666 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 6667 break;
whismanoid 9:45f98573eb6d 6668 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 6669 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 6670 case 'V': case 'v':
whismanoid 9:45f98573eb6d 6671 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 6672 break;
whismanoid 9:45f98573eb6d 6673 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 6674 }
whismanoid 9:45f98573eb6d 6675 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 6676 } // end for channel_index
whismanoid 10:04022a61b527 6677 // Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 6678 if (Datalogger_enable_serial) {
whismanoid 9:45f98573eb6d 6679 Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 6680 }
whismanoid 9:45f98573eb6d 6681 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 6682 if (Datalogger_enable_AUXserial) {
whismanoid 9:45f98573eb6d 6683 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 9:45f98573eb6d 6684 }
whismanoid 9:45f98573eb6d 6685 # endif // HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 6686 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6687 if (Datalogger_enable_DAPLINKserial) {
whismanoid 9:45f98573eb6d 6688 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 9:45f98573eb6d 6689 }
whismanoid 9:45f98573eb6d 6690 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6691 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6692 }
whismanoid 8:dffee7509bfb 6693 break;
whismanoid 9:45f98573eb6d 6694 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 6695 case '>':
whismanoid 9:45f98573eb6d 6696 // L>A -- Datalogger_enable_AUXserial
whismanoid 9:45f98573eb6d 6697 // L>D -- Datalogger_enable_DAPLINKserial
whismanoid 9:45f98573eb6d 6698 // L>S -- Datalogger_enable_serial
whismanoid 9:45f98573eb6d 6699 switch (cmdLine[2])
whismanoid 9:45f98573eb6d 6700 {
whismanoid 9:45f98573eb6d 6701 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 6702 case 'A': case 'a':
whismanoid 9:45f98573eb6d 6703 Datalogger_enable_AUXserial = !Datalogger_enable_AUXserial;
whismanoid 9:45f98573eb6d 6704 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6705 break;
whismanoid 8:dffee7509bfb 6706 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6707 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6708 case 'D': case 'd':
whismanoid 9:45f98573eb6d 6709 Datalogger_enable_DAPLINKserial = !Datalogger_enable_DAPLINKserial;
whismanoid 9:45f98573eb6d 6710 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6711 break;
whismanoid 8:dffee7509bfb 6712 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6713 case 'S': case 's':
whismanoid 9:45f98573eb6d 6714 Datalogger_enable_serial = !Datalogger_enable_serial;
whismanoid 9:45f98573eb6d 6715 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6716 break;
whismanoid 9:45f98573eb6d 6717 }
whismanoid 9:45f98573eb6d 6718 break; // case '>' L>S serial enable toggle
whismanoid 28:a9a3a9db592b 6719 default:
whismanoid 28:a9a3a9db592b 6720 // TODO: L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 6721 //
whismanoid 28:a9a3a9db592b 6722 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 6723 #if 1 // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 6724 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 6725 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 6726 //
whismanoid 28:a9a3a9db592b 6727 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 28:a9a3a9db592b 6728 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 39:4d285e961435 6729 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 6730 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 6731 cmdLine.serial().printf("\r\n LT count=%d base=%dms sleep=%d -- Datalog timer",
whismanoid 39:4d285e961435 6732 g_timer_interval_count,
whismanoid 39:4d285e961435 6733 g_timer_interval_msec,
whismanoid 39:4d285e961435 6734 (int)g_timer_sleepmode
whismanoid 39:4d285e961435 6735 ); // trigger_Timer
whismanoid 39:4d285e961435 6736 #else // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 6737 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 6738 #endif // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 6739 //
whismanoid 28:a9a3a9db592b 6740 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 28:a9a3a9db592b 6741 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 6742 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 6743 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 6744 //
whismanoid 28:a9a3a9db592b 6745 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 6746 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 28:a9a3a9db592b 6747 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 6748 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 6749 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 6750 //
whismanoid 28:a9a3a9db592b 6751 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 6752 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 6753 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 6754 //
whismanoid 28:a9a3a9db592b 6755 //
whismanoid 28:a9a3a9db592b 6756 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 6757 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 28:a9a3a9db592b 6758 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 6759 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 6760 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 28:a9a3a9db592b 6761 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 28:a9a3a9db592b 6762 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 28:a9a3a9db592b 6763 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 28:a9a3a9db592b 6764 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 28:a9a3a9db592b 6765 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 28:a9a3a9db592b 6766 //
whismanoid 28:a9a3a9db592b 6767 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 28:a9a3a9db592b 6768 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 28:a9a3a9db592b 6769 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 28:a9a3a9db592b 6770 //
whismanoid 28:a9a3a9db592b 6771 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 6772 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 28:a9a3a9db592b 6773 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 28:a9a3a9db592b 6774 //
whismanoid 28:a9a3a9db592b 6775 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 6776 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 28:a9a3a9db592b 6777 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 6778 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 28:a9a3a9db592b 6779 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 6780 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 28:a9a3a9db592b 6781 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 6782 //
whismanoid 28:a9a3a9db592b 6783 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 28:a9a3a9db592b 6784 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 28:a9a3a9db592b 6785 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 28:a9a3a9db592b 6786 //
whismanoid 28:a9a3a9db592b 6787 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 6788 //
whismanoid 28:a9a3a9db592b 6789 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 28:a9a3a9db592b 6790 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 28:a9a3a9db592b 6791 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 6792 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 6793 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 28:a9a3a9db592b 6794 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6795 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 28:a9a3a9db592b 6796 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6797 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6798 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 28:a9a3a9db592b 6799 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6800 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 28:a9a3a9db592b 6801 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6802 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 28:a9a3a9db592b 6803 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6804 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6805 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 28:a9a3a9db592b 6806 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6807 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 6808 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 6809 # if HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 6810 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 6811 # endif // HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 6812 # if HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 6813 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 6814 # endif // HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 6815 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 6816 //
whismanoid 28:a9a3a9db592b 6817 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 6818 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 6819 break;
whismanoid 17:9397ea3ea7e9 6820 } // switch (cmdLine[1]) inside case 'L'
whismanoid 4:d9b05924ad4c 6821 }
whismanoid 4:d9b05924ad4c 6822 break; // case 'L'
whismanoid 4:d9b05924ad4c 6823 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 6824 //
whismanoid 4:d9b05924ad4c 6825 // Application-specific commands here
whismanoid 4:d9b05924ad4c 6826 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 6827 //
whismanoid 4:d9b05924ad4c 6828 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 6829 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 6830
whismanoid 4:d9b05924ad4c 6831 //
whismanoid 4:d9b05924ad4c 6832 // TODO1: add new commands here
whismanoid 4:d9b05924ad4c 6833 //
whismanoid 4:d9b05924ad4c 6834 default:
whismanoid 4:d9b05924ad4c 6835 #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6836 extern bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5715.cpp
whismanoid 4:d9b05924ad4c 6837 if (!MAX5715_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6838 #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6839 extern bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11131.cpp
whismanoid 4:d9b05924ad4c 6840 if (!MAX11131_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6841 #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6842 extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp
whismanoid 4:d9b05924ad4c 6843 if (!MAX5171_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6844 #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6845 extern bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp
whismanoid 4:d9b05924ad4c 6846 if (!MAX11410_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6847 #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6848 extern bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX12345.cpp
whismanoid 4:d9b05924ad4c 6849 if (!MAX12345_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6850 #else
whismanoid 4:d9b05924ad4c 6851 if (0) // not_handled_by_device_submenu
whismanoid 4:d9b05924ad4c 6852 #endif
whismanoid 4:d9b05924ad4c 6853 {
whismanoid 4:d9b05924ad4c 6854 cmdLine.serial().printf("\r\n unknown command ");
whismanoid 4:d9b05924ad4c 6855 //~ cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 6856 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 6857 cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n",
whismanoid 4:d9b05924ad4c 6858 cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 6859 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6860 }
whismanoid 4:d9b05924ad4c 6861 } // switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 6862 //
whismanoid 31:47eee7e0cc2d 6863 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 6864 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 6865 // print command prompt
whismanoid 8:dffee7509bfb 6866 // print_command_prompt();
whismanoid 8:dffee7509bfb 6867 cmdLine.serial().printf("\r\n> ");
whismanoid 31:47eee7e0cc2d 6868 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 6869 }
whismanoid 4:d9b05924ad4c 6870 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 6871
whismanoid 4:d9b05924ad4c 6872 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 6873 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 6874 void Datalogger_PrintHeader(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 6875 {
whismanoid 37:3f369235e5bc 6876 #if MAX40108_DEMO // main_menu_status banner
whismanoid 37:3f369235e5bc 6877 cmdLine.serial().printf("\r\n\r\n\"MAX40108_U%d", MAX40108_DEMO);
whismanoid 37:3f369235e5bc 6878 #ifdef BOARD_SERIAL_NUMBER
whismanoid 37:3f369235e5bc 6879 // data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 6880 cmdLine.serial().printf(" [s/n %d]", BOARD_SERIAL_NUMBER);
whismanoid 37:3f369235e5bc 6881 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 6882 #ifdef FW_REV
whismanoid 37:3f369235e5bc 6883 cmdLine.serial().printf(" [FW_REV %d]", FW_REV);
whismanoid 37:3f369235e5bc 6884 #endif // FW_REV
whismanoid 37:3f369235e5bc 6885 cmdLine.serial().printf("\"\r\n");
whismanoid 37:3f369235e5bc 6886 #endif // MAX40108_DEMO
whismanoid 37:3f369235e5bc 6887
whismanoid 4:d9b05924ad4c 6888 // column header banner for csv data columns
whismanoid 4:d9b05924ad4c 6889 int field_index = 0;
whismanoid 4:d9b05924ad4c 6890 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6891 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 6892 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 4:d9b05924ad4c 6893 continue;
whismanoid 4:d9b05924ad4c 6894 }
whismanoid 4:d9b05924ad4c 6895 // comma between fields
whismanoid 4:d9b05924ad4c 6896 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 6897 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 6898 }
whismanoid 10:04022a61b527 6899 field_index++;
whismanoid 4:d9b05924ad4c 6900 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 6901 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 6902 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 4:d9b05924ad4c 6903 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 4:d9b05924ad4c 6904 cmdLine.serial().printf("\"AIN%d-%d_BIP", channel_index, channel_index+1);
whismanoid 4:d9b05924ad4c 6905 }
whismanoid 4:d9b05924ad4c 6906 else {
whismanoid 4:d9b05924ad4c 6907 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 6908 }
whismanoid 4:d9b05924ad4c 6909 #else // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 6910 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 6911 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 6912 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_LSB) {
whismanoid 4:d9b05924ad4c 6913 // _LSB column header suffix
whismanoid 13:184a08909405 6914 cmdLine.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 6915 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6916 cmdLine_DAPLINKserial.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 6917 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6918 }
whismanoid 10:04022a61b527 6919 else if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_Volt) {
whismanoid 4:d9b05924ad4c 6920 // _V column header suffix
whismanoid 13:184a08909405 6921 cmdLine.serial().printf("_V");
whismanoid 4:d9b05924ad4c 6922 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6923 cmdLine_DAPLINKserial.serial().printf("_V");
whismanoid 4:d9b05924ad4c 6924 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6925 }
whismanoid 13:184a08909405 6926 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6927 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6928 if (SPI_AIN_customChannelHeader_ch[channel_index] && SPI_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 6929 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 6930 cmdLine.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6931 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6932 cmdLine_DAPLINKserial.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6933 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6934 } else {
whismanoid 13:184a08909405 6935 // no custom channel name for this channel
whismanoid 13:184a08909405 6936 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 6937 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6938 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 6939 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6940 }
whismanoid 13:184a08909405 6941 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 6942 // close quote
whismanoid 13:184a08909405 6943 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 6944 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6945 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 6946 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6947 }
whismanoid 4:d9b05924ad4c 6948
whismanoid 4:d9b05924ad4c 6949 #if VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 6950 // PART_ID field: Device ID Validation
whismanoid 4:d9b05924ad4c 6951 cmdLine.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 6952 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6953 cmdLine_DAPLINKserial.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 6954 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6955 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 6956 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 6957 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 6958 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6959 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 6960 continue;
whismanoid 9:45f98573eb6d 6961 }
whismanoid 4:d9b05924ad4c 6962 // comma between fields
whismanoid 4:d9b05924ad4c 6963 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 6964 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 6965 }
whismanoid 9:45f98573eb6d 6966 field_index++;
whismanoid 4:d9b05924ad4c 6967 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 6968 cmdLine.serial().printf("\"A%d", channel_index);
whismanoid 9:45f98573eb6d 6969 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 9:45f98573eb6d 6970 // _LSB column header suffix
whismanoid 13:184a08909405 6971 cmdLine.serial().printf("_LSB");
whismanoid 9:45f98573eb6d 6972 }
whismanoid 9:45f98573eb6d 6973 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 6974 // _V column header suffix
whismanoid 13:184a08909405 6975 cmdLine.serial().printf("_V");
whismanoid 9:45f98573eb6d 6976 }
whismanoid 13:184a08909405 6977 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6978 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6979 if (Platform_AIN_customChannelHeader_ch[channel_index] && Platform_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 6980 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 6981 cmdLine.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6982 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6983 cmdLine_DAPLINKserial.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6984 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6985 } else {
whismanoid 13:184a08909405 6986 // no custom channel name for this channel
whismanoid 13:184a08909405 6987 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 6988 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6989 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 6990 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6991 }
whismanoid 13:184a08909405 6992 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 6993 // close quote
whismanoid 13:184a08909405 6994 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 6995 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6996 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 6997 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6998 }
whismanoid 4:d9b05924ad4c 6999 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 30:07197a430869 7000 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 7001 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in Datalogger_PrintHeader
whismanoid 30:07197a430869 7002 cmdLine.serial().printf(",\"%s\"", gstrRemarkHeader);
whismanoid 30:07197a430869 7003 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 4:d9b05924ad4c 7004 // end of column header line
whismanoid 4:d9b05924ad4c 7005 cmdLine.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 7006 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7007 cmdLine_DAPLINKserial.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 7008 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 7009 } // void Datalogger_PrintHeader()
whismanoid 4:d9b05924ad4c 7010
whismanoid 5:aaf8b5f5fda1 7011 //--------------------------------------------------
whismanoid 5:aaf8b5f5fda1 7012 void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 7013 {
whismanoid 5:aaf8b5f5fda1 7014 // CODE GENERATOR: example code: has no member function ScanStandardExternalClock
whismanoid 5:aaf8b5f5fda1 7015 // CODE GENERATOR: example code: has no member function ReadAINcode
whismanoid 5:aaf8b5f5fda1 7016 // CODE GENERATOR: example code: member function Read_All_Voltages
whismanoid 5:aaf8b5f5fda1 7017 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7018 // Measure ADC channels in sequence from AIN0 to channelNumber_0_9.
whismanoid 5:aaf8b5f5fda1 7019 // @param[in] g_MAX11410_device.channelNumber_0_15: AIN Channel Number
whismanoid 5:aaf8b5f5fda1 7020 // @param[in] g_MAX11410_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
whismanoid 5:aaf8b5f5fda1 7021 // @param[in] g_MAX11410_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
whismanoid 10:04022a61b527 7022 //~ int channelId_0_9 = NUM_DUT_ANALOG_IN_CHANNELS-1+1;
whismanoid 5:aaf8b5f5fda1 7023 //g_MAX11410_device.channelNumber_0_15 = channelId_0_9;
whismanoid 5:aaf8b5f5fda1 7024 //g_MAX11410_device.PowerManagement_0_2 = 0;
whismanoid 5:aaf8b5f5fda1 7025 //g_MAX11410_device.chan_id_0_1 = 1;
whismanoid 5:aaf8b5f5fda1 7026 //----------------------------------------
whismanoid 5:aaf8b5f5fda1 7027 // scan AIN0..AIN9
whismanoid 5:aaf8b5f5fda1 7028 //
whismanoid 10:04022a61b527 7029 #if 1
whismanoid 10:04022a61b527 7030 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 7031 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 7032 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 7033 //
whismanoid 10:04022a61b527 7034 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7035 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc3); // GP1 = 0
whismanoid 10:04022a61b527 7036 //
whismanoid 10:04022a61b527 7037 int field_index = 0;
whismanoid 10:04022a61b527 7038 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 7039 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 10:04022a61b527 7040 continue;
whismanoid 10:04022a61b527 7041 }
whismanoid 10:04022a61b527 7042 field_index++;
whismanoid 10:04022a61b527 7043 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[channel_index];
whismanoid 10:04022a61b527 7044 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[channel_index];
whismanoid 10:04022a61b527 7045 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[channel_index];
whismanoid 10:04022a61b527 7046 //
whismanoid 10:04022a61b527 7047 // WIP SampleRate_of_FILTER_CONV_START() MAX11410EMC-FW slow ODR 10Sps #262
whismanoid 10:04022a61b527 7048 // adjust the MAX11410.loop_limit value if the sample rate is set to a value slower than 20sps
whismanoid 10:04022a61b527 7049 // SampleRate_of_FILTER_CONV_START(uint8_t FILTER_RegValue, uint8_t CONV_START_RegValue)
whismanoid 10:04022a61b527 7050 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 7051 if (SampleRate < 20.0) {
whismanoid 10:04022a61b527 7052 g_MAX11410_device.loop_limit = 32767; // TODO: is this timeout long enough for the slow output data rates?
whismanoid 10:04022a61b527 7053 }
whismanoid 10:04022a61b527 7054 //
whismanoid 10:04022a61b527 7055 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7056 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc3); // GP0 = 0
whismanoid 10:04022a61b527 7057 //
whismanoid 10:04022a61b527 7058 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 7059 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 10:04022a61b527 7060 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 10:04022a61b527 7061 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 7062 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = (MAX11410::MAX11410_AINN_SEL_enum_t)(channel_index^1);
whismanoid 10:04022a61b527 7063 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 7064 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 7065 }
whismanoid 10:04022a61b527 7066 else {
whismanoid 10:04022a61b527 7067 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 7068 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = MAX11410::AINN_SEL_1010_GND;
whismanoid 10:04022a61b527 7069 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 7070 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 7071 }
whismanoid 10:04022a61b527 7072 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 7073 //
whismanoid 10:04022a61b527 7074 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7075 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc4); // GP0 = 1
whismanoid 10:04022a61b527 7076 //
whismanoid 10:04022a61b527 7077 }
whismanoid 10:04022a61b527 7078 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 7079 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc4); // GP1 = 1
whismanoid 10:04022a61b527 7080 #else
whismanoid 5:aaf8b5f5fda1 7081 g_MAX11410_device.Read_All_Voltages();
whismanoid 10:04022a61b527 7082 #endif
whismanoid 10:04022a61b527 7083 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7084 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 7085 // mbed
whismanoid 5:aaf8b5f5fda1 7086 // Platform board uses simple analog inputs
whismanoid 5:aaf8b5f5fda1 7087 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 5:aaf8b5f5fda1 7088 Platform_LSB[0] = analogIn0.read();
whismanoid 5:aaf8b5f5fda1 7089 Platform_LSB[1] = analogIn1.read();
whismanoid 5:aaf8b5f5fda1 7090 Platform_LSB[2] = analogIn2.read();
whismanoid 5:aaf8b5f5fda1 7091 Platform_LSB[3] = analogIn3.read();
whismanoid 5:aaf8b5f5fda1 7092 Platform_LSB[4] = analogIn4.read();
whismanoid 5:aaf8b5f5fda1 7093 Platform_LSB[5] = analogIn5.read();
whismanoid 10:04022a61b527 7094 #endif
whismanoid 10:04022a61b527 7095 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 37:3f369235e5bc 7096 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 7097 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogIn012345.read()
whismanoid 37:3f369235e5bc 7098 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 7099 float analogIn0_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7100 float analogIn1_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7101 float analogIn2_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7102 float analogIn3_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7103 float analogIn4_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7104 float analogIn5_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 7105 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 7106 analogIn0_normValue_0_1 = analogIn0_normValue_0_1 + analogIn0.read();
whismanoid 37:3f369235e5bc 7107 analogIn1_normValue_0_1 = analogIn1_normValue_0_1 + analogIn1.read();
whismanoid 37:3f369235e5bc 7108 analogIn2_normValue_0_1 = analogIn2_normValue_0_1 + analogIn2.read();
whismanoid 37:3f369235e5bc 7109 analogIn3_normValue_0_1 = analogIn3_normValue_0_1 + analogIn3.read();
whismanoid 37:3f369235e5bc 7110 analogIn4_normValue_0_1 = analogIn4_normValue_0_1 + analogIn4.read();
whismanoid 37:3f369235e5bc 7111 analogIn5_normValue_0_1 = analogIn5_normValue_0_1 + analogIn5.read();
whismanoid 37:3f369235e5bc 7112 }
whismanoid 37:3f369235e5bc 7113 analogIn0_normValue_0_1 = analogIn0_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7114 analogIn1_normValue_0_1 = analogIn1_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7115 analogIn2_normValue_0_1 = analogIn2_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7116 analogIn3_normValue_0_1 = analogIn3_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7117 analogIn4_normValue_0_1 = analogIn4_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7118 analogIn5_normValue_0_1 = analogIn5_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 7119 #else // USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 7120 float analogIn0_normValue_0_1 = analogIn0.read();
whismanoid 37:3f369235e5bc 7121 float analogIn1_normValue_0_1 = analogIn1.read();
whismanoid 37:3f369235e5bc 7122 float analogIn2_normValue_0_1 = analogIn2.read();
whismanoid 37:3f369235e5bc 7123 float analogIn3_normValue_0_1 = analogIn3.read();
whismanoid 37:3f369235e5bc 7124 float analogIn4_normValue_0_1 = analogIn4.read();
whismanoid 37:3f369235e5bc 7125 float analogIn5_normValue_0_1 = analogIn5.read();
whismanoid 37:3f369235e5bc 7126 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 7127 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 7128 // apply calibration to normValue_0_1 value
whismanoid 37:3f369235e5bc 7129 Platform_Voltage[0] = CalibratedNormValue(0, analogIn0_normValue_0_1) * adc_full_scale_voltage[0];
whismanoid 37:3f369235e5bc 7130 Platform_Voltage[1] = CalibratedNormValue(1, analogIn1_normValue_0_1) * adc_full_scale_voltage[1];
whismanoid 37:3f369235e5bc 7131 Platform_Voltage[2] = CalibratedNormValue(2, analogIn2_normValue_0_1) * adc_full_scale_voltage[2];
whismanoid 37:3f369235e5bc 7132 Platform_Voltage[3] = CalibratedNormValue(3, analogIn3_normValue_0_1) * adc_full_scale_voltage[3];
whismanoid 37:3f369235e5bc 7133 Platform_Voltage[4] = CalibratedNormValue(4, analogIn4_normValue_0_1) * adc_full_scale_voltage[4];
whismanoid 37:3f369235e5bc 7134 Platform_Voltage[5] = CalibratedNormValue(5, analogIn5_normValue_0_1) * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 7135 #else // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 7136 Platform_Voltage[0] = analogIn0_normValue_0_1 * adc_full_scale_voltage[0];
whismanoid 37:3f369235e5bc 7137 Platform_Voltage[1] = analogIn1_normValue_0_1 * adc_full_scale_voltage[1];
whismanoid 37:3f369235e5bc 7138 Platform_Voltage[2] = analogIn2_normValue_0_1 * adc_full_scale_voltage[2];
whismanoid 37:3f369235e5bc 7139 Platform_Voltage[3] = analogIn3_normValue_0_1 * adc_full_scale_voltage[3];
whismanoid 37:3f369235e5bc 7140 Platform_Voltage[4] = analogIn4_normValue_0_1 * adc_full_scale_voltage[4];
whismanoid 37:3f369235e5bc 7141 Platform_Voltage[5] = analogIn5_normValue_0_1 * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 7142 #endif // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 7143 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 5:aaf8b5f5fda1 7144 #endif // defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 7145
whismanoid 5:aaf8b5f5fda1 7146 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7147 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 7148 const uint32_t part_id_expect = 0x000F02;
whismanoid 5:aaf8b5f5fda1 7149 uint32_t part_id_readback;
whismanoid 5:aaf8b5f5fda1 7150 g_MAX11410_device.RegRead(MAX11410::CMD_r001_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xddd_PART_ID, &part_id_readback);
whismanoid 5:aaf8b5f5fda1 7151 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7152 } // void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 7153
whismanoid 17:9397ea3ea7e9 7154 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 7155 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 7156 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 7157 void Datalogger_RunActionTable()
whismanoid 17:9397ea3ea7e9 7158 {
whismanoid 17:9397ea3ea7e9 7159 if (Datalogger_action_table_enabled == false) {
whismanoid 17:9397ea3ea7e9 7160 return;
whismanoid 17:9397ea3ea7e9 7161 }
whismanoid 17:9397ea3ea7e9 7162 // TODO: verbose Datalogger_RunActionTable() emit a csv column ,"Action"
whismanoid 17:9397ea3ea7e9 7163 // TODO: assert Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX
whismanoid 17:9397ea3ea7e9 7164 // for Datalogger_action_table[0..Datalogger_action_table_row_count]
whismanoid 17:9397ea3ea7e9 7165 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 7166 {
whismanoid 17:9397ea3ea7e9 7167 // skip if Datalogger_action_table[i].action == action_noop
whismanoid 17:9397ea3ea7e9 7168 if (Datalogger_action_table[i].action == action_noop) {
whismanoid 17:9397ea3ea7e9 7169 continue;
whismanoid 17:9397ea3ea7e9 7170 }
whismanoid 17:9397ea3ea7e9 7171 // TODO: test Datalogger_action_table[i].condition "if="
whismanoid 17:9397ea3ea7e9 7172 // TODO: Could the .condition field also distinguish Platform ADC from SPI ADC?
whismanoid 17:9397ea3ea7e9 7173 // That way we keep both sets of ADC channels in separate lists
whismanoid 17:9397ea3ea7e9 7174 // if=0 -- always
whismanoid 17:9397ea3ea7e9 7175 // if=1,2,3,4,5,6 -- Platform_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 7176 // if=7,8,9,10,11,12 -- SPI_AIN_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 7177 // also, are we comparing code or voltage?
whismanoid 17:9397ea3ea7e9 7178 // TODO: selected Datalogger_action_table[i].condition_channel
whismanoid 17:9397ea3ea7e9 7179 // Datalogger could have both platform ADC and external SPI ADC channels
whismanoid 17:9397ea3ea7e9 7180 // if SPI_ADC_DeviceName
whismanoid 17:9397ea3ea7e9 7181 // NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 7182 // SPI_AIN_Enable_ch[]
whismanoid 17:9397ea3ea7e9 7183 // SPI_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 7184 // SPI_AIN_Voltage[]
whismanoid 17:9397ea3ea7e9 7185 // if LOG_PLATFORM_AIN
whismanoid 17:9397ea3ea7e9 7186 // NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 7187 // analogInPin_fullScaleVoltage[]
whismanoid 17:9397ea3ea7e9 7188 // Platform_Enable_ch[]
whismanoid 17:9397ea3ea7e9 7189 // Platform_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 7190 // Platform_Voltage[]
whismanoid 17:9397ea3ea7e9 7191 // TODO: selected Datalogger_action_table[i].condition_threshold
whismanoid 17:9397ea3ea7e9 7192 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 7193 {
whismanoid 17:9397ea3ea7e9 7194 case condition_always:
whismanoid 17:9397ea3ea7e9 7195 //~ cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 7196 break;
whismanoid 17:9397ea3ea7e9 7197 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 7198 //~ cmdLine.serial().printf(" if A%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7199 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7200 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7201 continue;
whismanoid 17:9397ea3ea7e9 7202 }
whismanoid 17:9397ea3ea7e9 7203 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7204 break;
whismanoid 17:9397ea3ea7e9 7205 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 7206 //~ cmdLine.serial().printf(" if A%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7207 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7208 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7209 continue;
whismanoid 17:9397ea3ea7e9 7210 }
whismanoid 17:9397ea3ea7e9 7211 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7212 break;
whismanoid 17:9397ea3ea7e9 7213 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 7214 //~ cmdLine.serial().printf(" if A%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7215 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7216 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7217 continue;
whismanoid 17:9397ea3ea7e9 7218 }
whismanoid 17:9397ea3ea7e9 7219 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7220 break;
whismanoid 17:9397ea3ea7e9 7221 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 7222 //~ cmdLine.serial().printf(" if A%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7223 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7224 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7225 continue;
whismanoid 17:9397ea3ea7e9 7226 }
whismanoid 17:9397ea3ea7e9 7227 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7228 break;
whismanoid 17:9397ea3ea7e9 7229 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 7230 //~ cmdLine.serial().printf(" if A%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7231 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7232 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7233 continue;
whismanoid 17:9397ea3ea7e9 7234 }
whismanoid 17:9397ea3ea7e9 7235 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7236 break;
whismanoid 17:9397ea3ea7e9 7237 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 7238 //~ cmdLine.serial().printf(" if A%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7239 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 7240 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 7241 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7242 continue;
whismanoid 17:9397ea3ea7e9 7243 }
whismanoid 17:9397ea3ea7e9 7244 break;
whismanoid 17:9397ea3ea7e9 7245 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 7246 //~ cmdLine.serial().printf(" if AIN%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7247 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7248 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7249 continue;
whismanoid 17:9397ea3ea7e9 7250 }
whismanoid 17:9397ea3ea7e9 7251 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7252 break;
whismanoid 17:9397ea3ea7e9 7253 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 7254 //~ cmdLine.serial().printf(" if AIN%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7255 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7256 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7257 continue;
whismanoid 17:9397ea3ea7e9 7258 }
whismanoid 17:9397ea3ea7e9 7259 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7260 break;
whismanoid 17:9397ea3ea7e9 7261 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 7262 //~ cmdLine.serial().printf(" if AIN%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7263 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7264 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7265 continue;
whismanoid 17:9397ea3ea7e9 7266 }
whismanoid 17:9397ea3ea7e9 7267 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7268 break;
whismanoid 17:9397ea3ea7e9 7269 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 7270 //~ cmdLine.serial().printf(" if AIN%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7271 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7272 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7273 continue;
whismanoid 17:9397ea3ea7e9 7274 }
whismanoid 17:9397ea3ea7e9 7275 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7276 break;
whismanoid 17:9397ea3ea7e9 7277 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 7278 //~ cmdLine.serial().printf(" if AIN%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7279 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7280 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7281 continue;
whismanoid 17:9397ea3ea7e9 7282 }
whismanoid 17:9397ea3ea7e9 7283 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7284 break;
whismanoid 17:9397ea3ea7e9 7285 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 7286 //~ cmdLine.serial().printf(" if AIN%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 7287 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7288 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 7289 continue;
whismanoid 17:9397ea3ea7e9 7290 }
whismanoid 17:9397ea3ea7e9 7291 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 7292 break;
whismanoid 17:9397ea3ea7e9 7293 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 7294 // selected Datalogger_action_table[i].digitalOutPin
whismanoid 17:9397ea3ea7e9 7295 // perform selected Datalogger_action_table[i].action
whismanoid 17:9397ea3ea7e9 7296 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 7297 {
whismanoid 17:9397ea3ea7e9 7298 case action_noop:
whismanoid 17:9397ea3ea7e9 7299 //~ cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 7300 break;
whismanoid 17:9397ea3ea7e9 7301 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 7302 {
whismanoid 17:9397ea3ea7e9 7303 //~ cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 7304 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 7305 // perform action digitalOutLow
whismanoid 17:9397ea3ea7e9 7306 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 7307 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 7308 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7309 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7310 #else
whismanoid 17:9397ea3ea7e9 7311 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 7312 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 7313 digitalInOutPin.write(0);
whismanoid 17:9397ea3ea7e9 7314 #endif
whismanoid 17:9397ea3ea7e9 7315 }
whismanoid 17:9397ea3ea7e9 7316 break;
whismanoid 17:9397ea3ea7e9 7317 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 7318 {
whismanoid 17:9397ea3ea7e9 7319 //~ cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 7320 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 7321 // perform action digitalOutHigh
whismanoid 17:9397ea3ea7e9 7322 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 7323 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 7324 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7325 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 7326 #else
whismanoid 17:9397ea3ea7e9 7327 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 7328 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 7329 digitalInOutPin.write(1);
whismanoid 17:9397ea3ea7e9 7330 #endif
whismanoid 17:9397ea3ea7e9 7331 }
whismanoid 17:9397ea3ea7e9 7332 break;
whismanoid 29:6a9edb6e973b 7333 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 7334 {
whismanoid 30:07197a430869 7335 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 7336 Datalogger_Trigger_enum_t saved_Datalogger_Trigger = Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 7337 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7338 switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 7339 {
whismanoid 29:6a9edb6e973b 7340 case 1:
whismanoid 29:6a9edb6e973b 7341 onButton1FallingEdge();
whismanoid 29:6a9edb6e973b 7342 break;
whismanoid 29:6a9edb6e973b 7343 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7344 case 2:
whismanoid 29:6a9edb6e973b 7345 onButton2FallingEdge();
whismanoid 29:6a9edb6e973b 7346 break;
whismanoid 29:6a9edb6e973b 7347 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7348 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7349 case 3:
whismanoid 29:6a9edb6e973b 7350 onButton3FallingEdge();
whismanoid 29:6a9edb6e973b 7351 break;
whismanoid 29:6a9edb6e973b 7352 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7353 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7354 case 4:
whismanoid 29:6a9edb6e973b 7355 onButton4FallingEdge();
whismanoid 29:6a9edb6e973b 7356 break;
whismanoid 29:6a9edb6e973b 7357 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7358 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7359 case 5:
whismanoid 29:6a9edb6e973b 7360 onButton5FallingEdge();
whismanoid 29:6a9edb6e973b 7361 break;
whismanoid 29:6a9edb6e973b 7362 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7363 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7364 case 6:
whismanoid 29:6a9edb6e973b 7365 onButton6FallingEdge();
whismanoid 29:6a9edb6e973b 7366 break;
whismanoid 29:6a9edb6e973b 7367 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7368 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7369 case 7:
whismanoid 29:6a9edb6e973b 7370 onButton7FallingEdge();
whismanoid 29:6a9edb6e973b 7371 break;
whismanoid 29:6a9edb6e973b 7372 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7373 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7374 case 8:
whismanoid 29:6a9edb6e973b 7375 onButton8FallingEdge();
whismanoid 29:6a9edb6e973b 7376 break;
whismanoid 29:6a9edb6e973b 7377 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7378 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7379 case 9:
whismanoid 29:6a9edb6e973b 7380 onButton9FallingEdge();
whismanoid 29:6a9edb6e973b 7381 break;
whismanoid 29:6a9edb6e973b 7382 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 7383 } // switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 7384 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 30:07197a430869 7385 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 7386 Datalogger_Trigger = saved_Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 7387 } // case action_button
whismanoid 29:6a9edb6e973b 7388 break;
whismanoid 17:9397ea3ea7e9 7389 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 7390 //~ cmdLine.serial().printf("trigger_Halt");
whismanoid 17:9397ea3ea7e9 7391 // perform action trigger_Halt
whismanoid 17:9397ea3ea7e9 7392 Datalogger_Trigger = trigger_Halt;
whismanoid 17:9397ea3ea7e9 7393 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7394 break;
whismanoid 17:9397ea3ea7e9 7395 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 7396 //~ cmdLine.serial().printf("trigger_FreeRun");
whismanoid 17:9397ea3ea7e9 7397 // perform action trigger_FreeRun
whismanoid 17:9397ea3ea7e9 7398 Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 7399 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7400 break;
whismanoid 17:9397ea3ea7e9 7401 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 7402 //~ cmdLine.serial().printf("trigger_Timer");
whismanoid 17:9397ea3ea7e9 7403 //~ // print configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 7404 //~ cmdLine.serial().printf("(%d x %dmsec)", g_timer_interval_count, g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 7405 // perform action trigger_Timer
whismanoid 17:9397ea3ea7e9 7406 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 7407 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7408 break;
whismanoid 17:9397ea3ea7e9 7409 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 7410 //~ cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 7411 //~ // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 7412 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 7413 // TODO: perform action action_trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 7414 Datalogger_Trigger = trigger_PlatformDigitalInput;
whismanoid 17:9397ea3ea7e9 7415 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7416 break;
whismanoid 17:9397ea3ea7e9 7417 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 7418 //~ cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 7419 //~ // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 7420 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 7421 // TODO: perform action action_trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 7422 Datalogger_Trigger = trigger_SPIDeviceRegRead;
whismanoid 17:9397ea3ea7e9 7423 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 7424 break;
whismanoid 17:9397ea3ea7e9 7425 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 7426 // consider next row of action table
whismanoid 17:9397ea3ea7e9 7427 } // for ...Datalogger_action_table_row_count
whismanoid 17:9397ea3ea7e9 7428 }
whismanoid 17:9397ea3ea7e9 7429 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 7430
whismanoid 5:aaf8b5f5fda1 7431 //--------------------------------------------------
whismanoid 8:dffee7509bfb 7432 void Datalogger_PrintRow(CmdLine& cmdLine)
whismanoid 5:aaf8b5f5fda1 7433 {
whismanoid 5:aaf8b5f5fda1 7434 int field_index = 0;
whismanoid 5:aaf8b5f5fda1 7435 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 7436 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 7437 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 5:aaf8b5f5fda1 7438 continue;
whismanoid 5:aaf8b5f5fda1 7439 }
whismanoid 5:aaf8b5f5fda1 7440 // comma between fields
whismanoid 5:aaf8b5f5fda1 7441 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 7442 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 7443 }
whismanoid 10:04022a61b527 7444 field_index++;
whismanoid 10:04022a61b527 7445 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 10:04022a61b527 7446 cmdLine.serial().printf("%d", g_MAX11410_device.AINcode[channel_index]);
whismanoid 10:04022a61b527 7447 }
whismanoid 10:04022a61b527 7448 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 10:04022a61b527 7449 // TODO: report Voltage instead of LSB
whismanoid 10:04022a61b527 7450 // Serial.print(SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 7451 static char strOutLineBuffer[16];
whismanoid 10:04022a61b527 7452 cmdLine.serial().printf("%6.6f", SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 7453 }
whismanoid 5:aaf8b5f5fda1 7454 }
whismanoid 5:aaf8b5f5fda1 7455 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7456 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 7457 if (part_id_readback != part_id_expect) {
whismanoid 5:aaf8b5f5fda1 7458 cmdLine.serial().printf(",\"FAIL\"");
whismanoid 9:45f98573eb6d 7459 need_reinit = true;
whismanoid 5:aaf8b5f5fda1 7460 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7461 g_MAX11410_device.Init();
whismanoid 5:aaf8b5f5fda1 7462 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 5:aaf8b5f5fda1 7463 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 5:aaf8b5f5fda1 7464 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 5:aaf8b5f5fda1 7465 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7466 }
whismanoid 5:aaf8b5f5fda1 7467 else {
whismanoid 5:aaf8b5f5fda1 7468 cmdLine.serial().printf(",\"OK\"");
whismanoid 5:aaf8b5f5fda1 7469 }
whismanoid 5:aaf8b5f5fda1 7470 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 7471 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 7472 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 7473 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 7474 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 7475 continue;
whismanoid 9:45f98573eb6d 7476 }
whismanoid 5:aaf8b5f5fda1 7477 // comma between fields
whismanoid 5:aaf8b5f5fda1 7478 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 7479 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 7480 }
whismanoid 9:45f98573eb6d 7481 field_index++;
whismanoid 9:45f98573eb6d 7482 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 5:aaf8b5f5fda1 7483 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 7484 cmdLine.serial().printf("%u", Platform_LSB[channel_index]);
whismanoid 9:45f98573eb6d 7485 #endif
whismanoid 9:45f98573eb6d 7486 }
whismanoid 9:45f98573eb6d 7487 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 7488 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 11:2b8adc78618a 7489 // Datalog Volts omit V suffix from numbers #275
whismanoid 11:2b8adc78618a 7490 // because Excel graphs can't handle numbers that have a suffix.
whismanoid 11:2b8adc78618a 7491 cmdLine.serial().printf("%6.6f", Platform_Voltage[channel_index]);
whismanoid 9:45f98573eb6d 7492 #endif
whismanoid 9:45f98573eb6d 7493 }
whismanoid 5:aaf8b5f5fda1 7494 }
whismanoid 5:aaf8b5f5fda1 7495 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 7496 if (need_reinit) {
whismanoid 9:45f98573eb6d 7497 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 7498 if (g_MAX11410_device.Init() == 0) {
whismanoid 9:45f98573eb6d 7499 //~ cmdLine.serial().printf(",\"Init() failed\"");
whismanoid 9:45f98573eb6d 7500 } else {
whismanoid 9:45f98573eb6d 7501 //~ cmdLine.serial().printf(",\"Init() success\"");
whismanoid 9:45f98573eb6d 7502 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 7503 // in Datalogger_PrintRow(), when part_id test fails,
whismanoid 9:45f98573eb6d 7504 // apply list of custom register writes after re-init
whismanoid 9:45f98573eb6d 7505 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 7506 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 9:45f98573eb6d 7507 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 9:45f98573eb6d 7508 uint32_t regData = custom_reg_init_data[index];
whismanoid 9:45f98573eb6d 7509 cmdLine.serial().printf("*%s=0x%06.6x", g_MAX11410_device.RegName(regAddress), regData);
whismanoid 9:45f98573eb6d 7510 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 9:45f98573eb6d 7511 }
whismanoid 9:45f98573eb6d 7512 #endif // USE_CUSTOM_REG_INIT
whismanoid 9:45f98573eb6d 7513 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 9:45f98573eb6d 7514 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 9:45f98573eb6d 7515 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 9:45f98573eb6d 7516 need_reinit = false;
whismanoid 9:45f98573eb6d 7517 }
whismanoid 9:45f98573eb6d 7518 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 7519 need_reinit = false;
whismanoid 9:45f98573eb6d 7520 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 7521 }
whismanoid 30:07197a430869 7522 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 7523 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in void Datalogger_PrintRow()
whismanoid 30:07197a430869 7524 cmdLine.serial().printf(",\"%s\"", gstrRemarkText);
whismanoid 30:07197a430869 7525 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 5:aaf8b5f5fda1 7526 cmdLine.serial().printf("\r\n");
whismanoid 9:45f98573eb6d 7527 if (need_reinit) {
whismanoid 9:45f98573eb6d 7528 //~ delay(500); // platform_delay_ms 500ms timing delay function
whismanoid 9:45f98573eb6d 7529 }
whismanoid 5:aaf8b5f5fda1 7530 } // void Datalogger_PrintRow()
whismanoid 5:aaf8b5f5fda1 7531
whismanoid 0:cb44e2e9ec4c 7532 // example code main function
whismanoid 0:cb44e2e9ec4c 7533 int main()
whismanoid 0:cb44e2e9ec4c 7534 {
whismanoid 0:cb44e2e9ec4c 7535 // setup: put your setup code here, to run once
whismanoid 4:d9b05924ad4c 7536 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 7537 // Configure serial ports
whismanoid 4:d9b05924ad4c 7538 cmdLine.clear();
whismanoid 4:d9b05924ad4c 7539 //~ cmdLine.serial().printf("\r\n cmdLine.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 7540 cmdLine.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 7541 //~ cmdLine.diagnostic_led_EOF = diagnostic_led_EOF;
whismanoid 4:d9b05924ad4c 7542 /// CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21);
whismanoid 4:d9b05924ad4c 7543 //~ cmdLine.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 7544 //~ cmdLine.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 7545 //~ cmdLine.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 7546 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 7547 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 7548 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 7549 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 7550 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 7551 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 7552 # else
whismanoid 10:04022a61b527 7553 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 7554 DAPLINKserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 7555 # endif
whismanoid 10:04022a61b527 7556 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 7557 cmdLine_DAPLINKserial.clear();
whismanoid 4:d9b05924ad4c 7558 //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 7559 cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 7560 //~ cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 7561 //~ cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 7562 //~ cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 7563 # endif
whismanoid 6:f6d16658342b 7564 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 7565 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 10:04022a61b527 7566 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 7567 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 7568 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 7569 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 7570 AUXserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 7571 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 6:f6d16658342b 7572 cmdLine_AUXserial.clear();
whismanoid 6:f6d16658342b 7573 //~ cmdLine_AUXserial.serial().printf("\r\n cmdLine_AUXserial.serial().printf test\r\n");
whismanoid 6:f6d16658342b 7574 cmdLine_AUXserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 6:f6d16658342b 7575 //~ cmdLine_AUXserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 6:f6d16658342b 7576 //~ cmdLine_AUXserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 6:f6d16658342b 7577 //~ cmdLine_AUXserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 6:f6d16658342b 7578 # endif // HAS_AUX_SERIAL
whismanoid 4:d9b05924ad4c 7579 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 0:cb44e2e9ec4c 7580
whismanoid 0:cb44e2e9ec4c 7581 // example code: serial port banner message
whismanoid 0:cb44e2e9ec4c 7582 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 7583 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 7584 cmdLine.serial().printf("\r\nDataLogger_MAX11410\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 7585 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7586 cmdLine.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 7587 # if HAS_DAPLINK_SERIAL
whismanoid 3:9055e17e181a 7588 cmdLine_DAPLINKserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 7589 # endif // HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 7590 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 7591 cmdLine_AUXserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 6:f6d16658342b 7592 # endif // HAS_AUX_SERIAL
whismanoid 3:9055e17e181a 7593 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 7594
whismanoid 1:747f1602abfc 7595 // CODE GENERATOR: get spi properties from device
whismanoid 3:9055e17e181a 7596 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 7597 if (g_SPI_SCLK_Hz > g_MAX11410_device.get_spi_frequency())
whismanoid 3:9055e17e181a 7598 { // Device limits SPI SCLK frequency
whismanoid 3:9055e17e181a 7599 g_SPI_SCLK_Hz = g_MAX11410_device.get_spi_frequency();
whismanoid 3:9055e17e181a 7600 cmdLine.serial().printf("\r\nMAX11410 limits SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 7601
whismanoid 3:9055e17e181a 7602 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 7603 }
whismanoid 3:9055e17e181a 7604 if (g_MAX11410_device.get_spi_frequency() > g_SPI_SCLK_Hz)
whismanoid 3:9055e17e181a 7605 { // Platform limits SPI SCLK frequency
whismanoid 3:9055e17e181a 7606 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 7607 cmdLine.serial().printf("\r\nPlatform limits MAX11410 SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 7608
whismanoid 3:9055e17e181a 7609 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 7610 }
whismanoid 0:cb44e2e9ec4c 7611 // g_SPI_dataMode = g_MAX11410_device.get_spi_dataMode();
whismanoid 3:9055e17e181a 7612 while (g_MAX11410_device.Init() == 0)
whismanoid 3:9055e17e181a 7613 {
whismanoid 3:9055e17e181a 7614 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 7615 cmdLine.serial().printf("\r\nMAX11410 Init failed; retry...\r\n");
whismanoid 3:9055e17e181a 7616
whismanoid 3:9055e17e181a 7617 }
whismanoid 0:cb44e2e9ec4c 7618
whismanoid 0:cb44e2e9ec4c 7619 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 3:9055e17e181a 7620 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 7621 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 3:9055e17e181a 7622 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 3:9055e17e181a 7623 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 3:9055e17e181a 7624 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7625 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 3:9055e17e181a 7626 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7627 // CODE GENERATOR: example code: has no member function REF
whismanoid 0:cb44e2e9ec4c 7628 // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line
whismanoid 0:cb44e2e9ec4c 7629 // CODE GENERATOR: ResolutionBits = 24
whismanoid 0:cb44e2e9ec4c 7630 // CODE GENERATOR: FScode = 0xffffff
whismanoid 0:cb44e2e9ec4c 7631 // CODE GENERATOR: NumChannels = 10
whismanoid 0:cb44e2e9ec4c 7632 // CODE GENERATOR: banner before DataLogHelloCppCodeList while(1)
whismanoid 3:9055e17e181a 7633 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 7634 cmdLine.serial().printf("v_filter = 0x%2.2x\r\n", g_MAX11410_device.v_filter);
whismanoid 0:cb44e2e9ec4c 7635
whismanoid 3:9055e17e181a 7636 cmdLine.serial().printf("v_pga = 0x%2.2x\r\n", g_MAX11410_device.v_pga);
whismanoid 0:cb44e2e9ec4c 7637
whismanoid 3:9055e17e181a 7638 cmdLine.serial().printf("v_ctrl = 0x%2.2x\r\n", g_MAX11410_device.v_ctrl);
whismanoid 3:9055e17e181a 7639
whismanoid 3:9055e17e181a 7640 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7641
whismanoid 3:9055e17e181a 7642 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 7643 Datalogger_Need_PrintHeader = true;
whismanoid 10:04022a61b527 7644
whismanoid 12:2dfc1f2009e0 7645 #if USE_LEDS
whismanoid 12:2dfc1f2009e0 7646 #if defined(TARGET_MAX32630)
whismanoid 12:2dfc1f2009e0 7647 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 7648 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7649 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 7650 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7651 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 7652 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7653 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 7654 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7655 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 7656 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7657 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 7658 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7659 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 7660 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7661 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 7662 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 19:5ff09c8e9daf 7663 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 12:2dfc1f2009e0 7664 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 7665 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7666 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 7667 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7668 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 7669 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7670 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 7671 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7672 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 7673 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7674 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 7675 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7676 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 7677 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7678 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 7679 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7680 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 12:2dfc1f2009e0 7681 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 7682 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7683 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7684 led4 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7685 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7686 //led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 7687 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 7688 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7689 led1 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7690 //led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 7691 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 7692 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7693 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7694 //led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 7695 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 7696 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7697 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7698 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 7699 //
whismanoid 12:2dfc1f2009e0 7700 #endif // target definition
whismanoid 12:2dfc1f2009e0 7701 #endif
whismanoid 12:2dfc1f2009e0 7702
whismanoid 12:2dfc1f2009e0 7703 if (led1.is_connected()) {
whismanoid 12:2dfc1f2009e0 7704 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 7705 }
whismanoid 12:2dfc1f2009e0 7706 if (led2.is_connected()) {
whismanoid 12:2dfc1f2009e0 7707 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 7708 }
whismanoid 12:2dfc1f2009e0 7709 if (led3.is_connected()) {
whismanoid 12:2dfc1f2009e0 7710 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 7711 }
whismanoid 12:2dfc1f2009e0 7712
whismanoid 46:469d0061df5d 7713 #if HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 7714 // WIP #312 load values from flash_page_configuration_back_up[] during init
whismanoid 46:469d0061df5d 7715 const uint32_t load_arg = 1;
whismanoid 46:469d0061df5d 7716 Load_flash_page_configuration_back_up(cmdLine, load_arg);
whismanoid 46:469d0061df5d 7717 #endif // HAS_FLASH_LOAD_SAVE
whismanoid 46:469d0061df5d 7718
whismanoid 4:d9b05924ad4c 7719 while(1) { // this code repeats forever
whismanoid 4:d9b05924ad4c 7720 // this code repeats forever
whismanoid 4:d9b05924ad4c 7721
whismanoid 21:ac062a97a71d 7722 #if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 7723 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 7724 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 7725 # if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 7726 static int button1_value_prev = 1;
whismanoid 21:ac062a97a71d 7727 static int button1_value_now = 1;
whismanoid 21:ac062a97a71d 7728 button1_value_prev = button1_value_now;
whismanoid 21:ac062a97a71d 7729 button1_value_now = button1.read();
whismanoid 21:ac062a97a71d 7730 if ((button1_value_prev - button1_value_now) == 1)
whismanoid 21:ac062a97a71d 7731 {
whismanoid 21:ac062a97a71d 7732 // on button1 falling edge (button1 press)
whismanoid 21:ac062a97a71d 7733 onButton1FallingEdge();
whismanoid 21:ac062a97a71d 7734 }
whismanoid 21:ac062a97a71d 7735 # endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7736 # if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7737 static int button2_value_prev = 1;
whismanoid 24:032f3683cb2a 7738 static int button2_value_now = 1;
whismanoid 24:032f3683cb2a 7739 button2_value_prev = button2_value_now;
whismanoid 24:032f3683cb2a 7740 button2_value_now = button2.read();
whismanoid 24:032f3683cb2a 7741 if ((button2_value_prev - button2_value_now) == 1)
whismanoid 24:032f3683cb2a 7742 {
whismanoid 24:032f3683cb2a 7743 // on button2 falling edge (button2 press)
whismanoid 24:032f3683cb2a 7744 onButton2FallingEdge();
whismanoid 24:032f3683cb2a 7745 }
whismanoid 24:032f3683cb2a 7746 # endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7747 # if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7748 static int button3_value_prev = 1;
whismanoid 24:032f3683cb2a 7749 static int button3_value_now = 1;
whismanoid 24:032f3683cb2a 7750 button3_value_prev = button3_value_now;
whismanoid 24:032f3683cb2a 7751 button3_value_now = button3.read();
whismanoid 24:032f3683cb2a 7752 if ((button3_value_prev - button3_value_now) == 1)
whismanoid 24:032f3683cb2a 7753 {
whismanoid 24:032f3683cb2a 7754 // on button3 falling edge (button3 press)
whismanoid 26:13cba69d88eb 7755 onButton3FallingEdge();
whismanoid 24:032f3683cb2a 7756 }
whismanoid 24:032f3683cb2a 7757 # endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 7758 #endif // HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 4:d9b05924ad4c 7759 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 7760 // TODO support CmdLine command menus (like on Serial_Tester); help and usual boilerplate
whismanoid 10:04022a61b527 7761 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 7762 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 7763 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 7764 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 7765 // Accept commands from Auxiliary serial port
whismanoid 6:f6d16658342b 7766 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 7767 if (AUXserial.readable()) {
whismanoid 6:f6d16658342b 7768 cmdLine_AUXserial.append(AUXserial.getc());
whismanoid 6:f6d16658342b 7769 }
whismanoid 6:f6d16658342b 7770 # endif // HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 7771 # if HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 7772 if (DAPLINKserial.readable()) {
whismanoid 6:f6d16658342b 7773 cmdLine_DAPLINKserial.append(DAPLINKserial.getc());
whismanoid 6:f6d16658342b 7774 }
whismanoid 6:f6d16658342b 7775 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 7776 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 7777 if (serial.readable()) {
whismanoid 4:d9b05924ad4c 7778 int c = serial.getc(); // instead of getc() or fgetc()
whismanoid 4:d9b05924ad4c 7779 cmdLine.append(c);
whismanoid 4:d9b05924ad4c 7780 // cmdLine.onEOLcommandParser handler implements menus
whismanoid 4:d9b05924ad4c 7781 } // if (Serial.available())
whismanoid 4:d9b05924ad4c 7782 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 7783
whismanoid 4:d9b05924ad4c 7784 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 32:80f3e5eb77d4 7785 // Datalog trigger
whismanoid 4:d9b05924ad4c 7786 if (Datalogger_Trigger == trigger_Halt) {
whismanoid 4:d9b05924ad4c 7787 // halt the datalogger; continue accepting commands
whismanoid 3:9055e17e181a 7788 continue;
whismanoid 3:9055e17e181a 7789 }
whismanoid 4:d9b05924ad4c 7790 if (Datalogger_Trigger == trigger_FreeRun) {
whismanoid 4:d9b05924ad4c 7791 // free run as fast as possible
whismanoid 3:9055e17e181a 7792 }
whismanoid 4:d9b05924ad4c 7793 if (Datalogger_Trigger == trigger_Timer) {
whismanoid 4:d9b05924ad4c 7794 // timer (configure interval)
whismanoid 32:80f3e5eb77d4 7795 // if Datalogger_Trigger == trigger_Timer sleep(g_timer_interval_msec)
whismanoid 39:4d285e961435 7796 //
whismanoid 39:4d285e961435 7797 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 7798 // USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 45:74bf1fe021e5 7799 // Sleep Mode vs Deep Sleep Mode
whismanoid 39:4d285e961435 7800 // See documentation https://os.mbed.com/docs/mbed-os/v5.15/apis/power-management-sleep.html
whismanoid 41:13a6a097502c 7801 // ThisThread::sleep_for(uint32_t millisec)
whismanoid 41:13a6a097502c 7802 // sleep_manager_can_deep_sleep() // tests whether deep_sleep is locked or not
whismanoid 41:13a6a097502c 7803 // sleep_manager_lock_deep_sleep() // begin section that prevents deep_sleep
whismanoid 41:13a6a097502c 7804 // sleep_manager_unlock_deep_sleep() // end section that prevents deep_sleep
whismanoid 39:4d285e961435 7805 switch(g_timer_sleepmode)
whismanoid 39:4d285e961435 7806 {
whismanoid 39:4d285e961435 7807 case datalogger_Sleep_LP0_Stop: // LT sleep = 0,
whismanoid 45:74bf1fe021e5 7808 // TODO: LP0 stop mode not supported; how would we wake up?
whismanoid 39:4d285e961435 7809 break;
whismanoid 39:4d285e961435 7810 case datalogger_Sleep_LP1_DeepSleep: // LT sleep = 1,
whismanoid 42:89607d5d4e6d 7811 //
whismanoid 45:74bf1fe021e5 7812 // In file mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\sleep.c
whismanoid 45:74bf1fe021e5 7813 // support function hal_deepsleep() just calls hal_sleep(),
whismanoid 45:74bf1fe021e5 7814 // so using LP1 Deep Sleep requires calling the low-level functions directly.
whismanoid 42:89607d5d4e6d 7815 //
whismanoid 41:13a6a097502c 7816 // sleep_manager_can_deep_sleep(); // tests whether deep_sleep is locked or not
whismanoid 41:13a6a097502c 7817 // mbed_file_handle(STDIN_FILENO)->enable_input(false); // (mbed-os-5.15) platform.stdio-buffered-serial prevents deep sleep
whismanoid 45:74bf1fe021e5 7818 #if MBED_VERSION >= MBED_ENCODE_VERSION(5, 15, 0)
whismanoid 41:13a6a097502c 7819 cmdLine.serial().enable_input(false); // (mbed-os-5.15) platform.stdio-buffered-serial prevents deep sleep
whismanoid 41:13a6a097502c 7820 // serial.enable_input(false); // (mbed-os-5.15) platform.stdio-buffered-serial prevents deep sleep
whismanoid 43:4c4733760d4c 7821
whismanoid 43:4c4733760d4c 7822 // configure RTC and start
whismanoid 43:4c4733760d4c 7823 // RTC_Setup();
whismanoid 43:4c4733760d4c 7824 {
whismanoid 43:4c4733760d4c 7825 rtc_cfg_t RTCconfig;
whismanoid 43:4c4733760d4c 7826 RTCconfig.compareCount[0] = 5;//5 second timer -- override with RTC_SetCompare(0,counts)
whismanoid 43:4c4733760d4c 7827 RTCconfig.compareCount[1] = 7;//7 second timer -- override with RTC_SetCompare(1,counts)
whismanoid 43:4c4733760d4c 7828 RTCconfig.prescaler = RTC_PRESCALE_DIV_2_12; //1Hz clock
whismanoid 43:4c4733760d4c 7829 RTCconfig.prescalerMask = RTC_PRESCALE_DIV_2_12;//used for prescaler compare
whismanoid 43:4c4733760d4c 7830 RTCconfig.snoozeCount = 0;
whismanoid 43:4c4733760d4c 7831 RTCconfig.snoozeMode = RTC_SNOOZE_DISABLE;
whismanoid 43:4c4733760d4c 7832 RTC_Init(&RTCconfig);
whismanoid 43:4c4733760d4c 7833 RTC_Start();
whismanoid 43:4c4733760d4c 7834
whismanoid 43:4c4733760d4c 7835 // Clear existing wake-up config
whismanoid 43:4c4733760d4c 7836 LP_ClearWakeUpConfig();
whismanoid 43:4c4733760d4c 7837
whismanoid 43:4c4733760d4c 7838 // Clear any event flags
whismanoid 43:4c4733760d4c 7839 LP_ClearWakeUpFlags();
whismanoid 43:4c4733760d4c 7840
whismanoid 43:4c4733760d4c 7841 // configure wake-up on RTC compare 1
whismanoid 43:4c4733760d4c 7842 // LP_ConfigRTCWakeUp(unsigned int comp0_en, unsigned int comp1_en, unsigned int prescale_cmp_en, unsigned int rollover_en);
whismanoid 43:4c4733760d4c 7843 LP_ConfigRTCWakeUp(0, 1, 0, 0);
whismanoid 43:4c4733760d4c 7844
whismanoid 44:84402faa8eb9 7845 // wait until UART_Busy indicates no ongoing transactions (both ports)
whismanoid 44:84402faa8eb9 7846 while (Console_PrepForSleep() != E_NO_ERROR);
whismanoid 44:84402faa8eb9 7847
whismanoid 43:4c4733760d4c 7848 // set RTC compare 1 value
whismanoid 43:4c4733760d4c 7849 // cmp = RTC_GetCount() + LP1_WakeTime;
whismanoid 43:4c4733760d4c 7850 uint32_t cmp = RTC_GetCount() + ((g_timer_interval_msec + 500.) / 1000.);
whismanoid 43:4c4733760d4c 7851 // RTC_SetCompare(uint8_t compareIndex, uint32_t counts)
whismanoid 43:4c4733760d4c 7852 RTC_SetCompare(1, cmp);
whismanoid 43:4c4733760d4c 7853
whismanoid 43:4c4733760d4c 7854 RTC_ClearFlags(MXC_F_RTC_FLAGS_COMP1);
whismanoid 43:4c4733760d4c 7855 }
whismanoid 43:4c4733760d4c 7856
whismanoid 43:4c4733760d4c 7857 //global disable interrupt
whismanoid 43:4c4733760d4c 7858 __disable_irq();
whismanoid 43:4c4733760d4c 7859
whismanoid 43:4c4733760d4c 7860 LP_EnterLP1();
whismanoid 43:4c4733760d4c 7861
whismanoid 43:4c4733760d4c 7862 //global enable interrupt
whismanoid 43:4c4733760d4c 7863 __enable_irq();
whismanoid 43:4c4733760d4c 7864
whismanoid 43:4c4733760d4c 7865 // stop waking on RTC
whismanoid 43:4c4733760d4c 7866 // LP_ConfigRTCWakeUp(unsigned int comp0_en, unsigned int comp1_en, unsigned int prescale_cmp_en, unsigned int rollover_en);
whismanoid 43:4c4733760d4c 7867 LP_ConfigRTCWakeUp(0, 0, 0, 0);
whismanoid 43:4c4733760d4c 7868
whismanoid 43:4c4733760d4c 7869 // Clear existing wake-up config
whismanoid 43:4c4733760d4c 7870 LP_ClearWakeUpConfig();
whismanoid 43:4c4733760d4c 7871
whismanoid 43:4c4733760d4c 7872 // Clear any event flags
whismanoid 43:4c4733760d4c 7873 LP_ClearWakeUpFlags();
whismanoid 45:74bf1fe021e5 7874
whismanoid 43:4c4733760d4c 7875 RTC_Stop();
whismanoid 43:4c4733760d4c 7876
whismanoid 41:13a6a097502c 7877 // mbed_file_handle(STDIN_FILENO)->enable_input(true); // (mbed-os-5.15)
whismanoid 41:13a6a097502c 7878 cmdLine.serial().enable_input(true); // (mbed-os-5.15)
whismanoid 41:13a6a097502c 7879 // serial.enable_input(true); // (mbed-os-5.15)
whismanoid 39:4d285e961435 7880 break;
whismanoid 45:74bf1fe021e5 7881 #endif // MBED_VERSION >= MBED_ENCODE_VERSION(5, 15, 0)
whismanoid 39:4d285e961435 7882 case datalogger_Sleep_LP2_Sleep: // LT sleep = 2,
whismanoid 41:13a6a097502c 7883 sleep_manager_lock_deep_sleep(); // begin section that prevents deep_sleep
whismanoid 41:13a6a097502c 7884 ThisThread::sleep_for(g_timer_interval_msec); // wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 41:13a6a097502c 7885 sleep_manager_unlock_deep_sleep(); // end section that prevents deep_sleep
whismanoid 39:4d285e961435 7886 break;
whismanoid 39:4d285e961435 7887 case datalogger_Sleep_LP3_Run: // LT sleep = 3,
whismanoid 45:74bf1fe021e5 7888 // TODO: USE_DATALOGGER_SLEEP -- ThisThread::sleep_for(uint32_t millisec) instead of wait_ms(g_timer_interval_msec)
whismanoid 41:13a6a097502c 7889 wait_ms(g_timer_interval_msec);
whismanoid 39:4d285e961435 7890 break;
whismanoid 39:4d285e961435 7891 }
whismanoid 39:4d285e961435 7892 #else // USE_DATALOGGER_SLEEP
whismanoid 17:9397ea3ea7e9 7893 wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 39:4d285e961435 7894 #endif // USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 7895 //
whismanoid 17:9397ea3ea7e9 7896 if (g_timer_interval_counter > 0) {
whismanoid 17:9397ea3ea7e9 7897 g_timer_interval_counter--;
whismanoid 17:9397ea3ea7e9 7898 continue;
whismanoid 17:9397ea3ea7e9 7899 }
whismanoid 17:9397ea3ea7e9 7900 // if time interval not yet reached, continue (continue accepting commands)
whismanoid 32:80f3e5eb77d4 7901 g_timer_interval_counter = g_timer_interval_count-1;
whismanoid 3:9055e17e181a 7902 }
whismanoid 4:d9b05924ad4c 7903 if (Datalogger_Trigger == trigger_PlatformDigitalInput) {
whismanoid 4:d9b05924ad4c 7904 // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 7905 // TODO: read selected input pin, test value
whismanoid 17:9397ea3ea7e9 7906 // TODO: if no match, continue (continue accepting commands)
whismanoid 3:9055e17e181a 7907 }
whismanoid 4:d9b05924ad4c 7908 if (Datalogger_Trigger == trigger_SPIDeviceRegRead) {
whismanoid 4:d9b05924ad4c 7909 // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 7910 // TODO: SPI transfer regAddr
whismanoid 17:9397ea3ea7e9 7911 // TODO: apply dataMask, compare with testValue
whismanoid 17:9397ea3ea7e9 7912 // TODO: if no match, continue (continue accepting commands)
whismanoid 4:d9b05924ad4c 7913 }
whismanoid 4:d9b05924ad4c 7914 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 0:cb44e2e9ec4c 7915
whismanoid 8:dffee7509bfb 7916 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 7917 if (Datalogger_Need_PrintHeader) {
whismanoid 8:dffee7509bfb 7918 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 7919 Datalogger_PrintHeader(cmdLine);
whismanoid 8:dffee7509bfb 7920 }
whismanoid 8:dffee7509bfb 7921 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 7922 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 7923 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 7924 }
whismanoid 8:dffee7509bfb 7925 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 7926 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 7927 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 7928 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 7929 }
whismanoid 8:dffee7509bfb 7930 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 7931 Datalogger_Need_PrintHeader = false;
whismanoid 8:dffee7509bfb 7932 }
whismanoid 5:aaf8b5f5fda1 7933 Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 7934 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 7935 // Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 7936 Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 7937 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 0:cb44e2e9ec4c 7938 // wait(3.0);
whismanoid 0:cb44e2e9ec4c 7939 // CODE GENERATOR: print conversion result
whismanoid 0:cb44e2e9ec4c 7940 // Use Arduino Serial Plotter to view output: Tools | Serial Plotter
whismanoid 8:dffee7509bfb 7941 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 7942 Datalogger_PrintRow(cmdLine);
whismanoid 8:dffee7509bfb 7943 }
whismanoid 8:dffee7509bfb 7944 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 7945 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 7946 Datalogger_PrintRow(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 7947 }
whismanoid 8:dffee7509bfb 7948 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 7949 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 7950 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 7951 Datalogger_PrintRow(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 7952 }
whismanoid 8:dffee7509bfb 7953 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:cb44e2e9ec4c 7954
whismanoid 0:cb44e2e9ec4c 7955 } // this code repeats forever
whismanoid 0:cb44e2e9ec4c 7956 }
whismanoid 0:cb44e2e9ec4c 7957 //---------- CODE GENERATOR: end DataLogHelloCppCodeList