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:
Mon May 03 18:06:18 2021 -0700
Revision:
37:3f369235e5bc
Parent:
36:e7aac874b8be
Child:
38:fda80a0020d1
%A avg=16 -- average; FW_REV macro

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 36:e7aac874b8be 82 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 83 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 84 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 85 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 36:e7aac874b8be 86 //
whismanoid 36:e7aac874b8be 87 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 88 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 36:e7aac874b8be 89 //
whismanoid 36:e7aac874b8be 90 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 91 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 36:e7aac874b8be 92 //
whismanoid 36:e7aac874b8be 93 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 94 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 36:e7aac874b8be 95 //
whismanoid 36:e7aac874b8be 96 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 97 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 36:e7aac874b8be 98 //
whismanoid 36:e7aac874b8be 99 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 100 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 36:e7aac874b8be 101 //
whismanoid 36:e7aac874b8be 102 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 103 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 36:e7aac874b8be 104 //
whismanoid 36:e7aac874b8be 105 # else
whismanoid 36:e7aac874b8be 106 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 107 # endif
whismanoid 36:e7aac874b8be 108 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 109 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 110 //
whismanoid 36:e7aac874b8be 111 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 0:cb44e2e9ec4c 112 //---------- CODE GENERATOR: DataLogHelloCppCodeList
whismanoid 0:cb44e2e9ec4c 113 // CODE GENERATOR: example code includes
whismanoid 0:cb44e2e9ec4c 114
whismanoid 0:cb44e2e9ec4c 115 // example code includes
whismanoid 0:cb44e2e9ec4c 116 // standard include for target platform -- Platform_Include_Boilerplate
whismanoid 0:cb44e2e9ec4c 117 #include "mbed.h"
whismanoid 0:cb44e2e9ec4c 118 // Platforms:
whismanoid 0:cb44e2e9ec4c 119 // - MAX32625MBED
whismanoid 0:cb44e2e9ec4c 120 // - supports mbed-os-5.11, requires USBDevice library
whismanoid 0:cb44e2e9ec4c 121 // - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
whismanoid 0:cb44e2e9ec4c 122 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 123 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 124 // - MAX32600MBED
whismanoid 7:949ec8581f5e 125 // - Please note the last supported version is Mbed OS 6.3.
whismanoid 0:cb44e2e9ec4c 126 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 127 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 128 // - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board.
whismanoid 0:cb44e2e9ec4c 129 // - NUCLEO_F446RE
whismanoid 0:cb44e2e9ec4c 130 // - remove USBDevice library
whismanoid 0:cb44e2e9ec4c 131 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 132 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 133 // - NUCLEO_F401RE
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 // - MAX32630FTHR
whismanoid 0:cb44e2e9ec4c 138 // - #include "max32630fthr.h"
whismanoid 7:949ec8581f5e 139 // - add http://developer.mbed.org/teams/MaximIntegrated/code/max32630fthr/
whismanoid 0:cb44e2e9ec4c 140 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 141 // - MAX32620FTHR
whismanoid 0:cb44e2e9ec4c 142 // - #include "MAX32620FTHR.h"
whismanoid 0:cb44e2e9ec4c 143 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 144 // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
whismanoid 0:cb44e2e9ec4c 145 // - not tested yet
whismanoid 0:cb44e2e9ec4c 146 // - MAX32625PICO
whismanoid 0:cb44e2e9ec4c 147 // - #include "max32625pico.h"
whismanoid 0:cb44e2e9ec4c 148 // - add https://os.mbed.com/users/switches/code/max32625pico/
whismanoid 0:cb44e2e9ec4c 149 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 150 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 151 // - not tested yet
whismanoid 0:cb44e2e9ec4c 152 // - see https://os.mbed.com/users/switches/code/max32625pico/
whismanoid 0:cb44e2e9ec4c 153 // - see https://os.mbed.com/users/switches/code/PICO_board_demo/
whismanoid 0:cb44e2e9ec4c 154 // - see https://os.mbed.com/users/switches/code/PICO_USB_I2C_SPI/
whismanoid 0:cb44e2e9ec4c 155 // - see https://os.mbed.com/users/switches/code/SerialInterface/
whismanoid 0:cb44e2e9ec4c 156 // - Note: To load the MAX32625PICO firmware, hold the button while
whismanoid 0:cb44e2e9ec4c 157 // connecting the USB cable, then copy firmware bin file
whismanoid 0:cb44e2e9ec4c 158 // to the MAINTENANCE drive.
whismanoid 0:cb44e2e9ec4c 159 // - see https://os.mbed.com/platforms/MAX32625PICO/
whismanoid 0:cb44e2e9ec4c 160 // - see https://os.mbed.com/teams/MaximIntegrated/wiki/MAX32625PICO-Firmware-Updates
whismanoid 0:cb44e2e9ec4c 161 //
whismanoid 0:cb44e2e9ec4c 162 // end Platform_Include_Boilerplate
whismanoid 0:cb44e2e9ec4c 163
whismanoid 0:cb44e2e9ec4c 164 //--------------------------------------------------
whismanoid 3:9055e17e181a 165 // Option to use SPI connected ADC
whismanoid 3:9055e17e181a 166 #ifndef SPI_ADC_DeviceName
whismanoid 9:45f98573eb6d 167 #define SPI_ADC_DeviceName MAX11410
whismanoid 3:9055e17e181a 168 #undef SPI_ADC_DeviceName
whismanoid 3:9055e17e181a 169 #endif
whismanoid 3:9055e17e181a 170 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 171 #include "MAX11410.h"
whismanoid 3:9055e17e181a 172 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 173
whismanoid 0:cb44e2e9ec4c 174 #if defined(TARGET)
whismanoid 0:cb44e2e9ec4c 175 // TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h
whismanoid 0:cb44e2e9ec4c 176 // Create a string definition for the TARGET
whismanoid 0:cb44e2e9ec4c 177 #define STRING_ARG(arg) #arg
whismanoid 0:cb44e2e9ec4c 178 #define STRING_NAME(name) STRING_ARG(name)
whismanoid 0:cb44e2e9ec4c 179 #define TARGET_NAME STRING_NAME(TARGET)
whismanoid 0:cb44e2e9ec4c 180 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 181 #define TARGET_NAME "MAX32600"
whismanoid 0:cb44e2e9ec4c 182 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 183 #define TARGET_NAME "LPC1768"
whismanoid 0:cb44e2e9ec4c 184 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 185 #define TARGET_NAME "NUCLEO_F446RE"
whismanoid 0:cb44e2e9ec4c 186 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 187 #define TARGET_NAME "NUCLEO_F401RE"
whismanoid 0:cb44e2e9ec4c 188 #else
whismanoid 0:cb44e2e9ec4c 189 #error TARGET NOT DEFINED
whismanoid 0:cb44e2e9ec4c 190 #endif
whismanoid 0:cb44e2e9ec4c 191 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 192 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 193 // TARGET=MAX32630FTHR ARM Cortex-M4F 96MHz 2048kB Flash 512kB SRAM
whismanoid 0:cb44e2e9ec4c 194 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 195 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 196 // ______ | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 197 // ______ | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 198 // ______ | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 199 // ______ | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 200 // analogIn0/4 | [a] AIN_0 1.2Vfs (bat) SYS [ ] | switched BAT+
whismanoid 0:cb44e2e9ec4c 201 // analogIn1/5 | [a] AIN_1 1.2Vfs PWR [ ] | external pwr btn
whismanoid 0:cb44e2e9ec4c 202 // analogIn2 | [a] AIN_2 1.2Vfs +5V VBUS [ ] | USB +5V power
whismanoid 0:cb44e2e9ec4c 203 // analogIn3 | [a] AIN_3 1.2Vfs 1-WIRE P4_0 [d] | D0 dig9
whismanoid 0:cb44e2e9ec4c 204 // (I2C2.SDA) | [d] P5_7 SDA2 SRN P5_6 [d] | D1 dig8
whismanoid 0:cb44e2e9ec4c 205 // (I2C2.SCL) | [d] P6_0 SCL2 SDIO3 P5_5 [d] | D2 dig7
whismanoid 0:cb44e2e9ec4c 206 // D13/SCLK | [s] P5_0 SCLK SDIO2 P5_4 [d] | D3 dig6
whismanoid 0:cb44e2e9ec4c 207 // D11/MOSI | [s] P5_1 MOSI SSEL P5_3 [d] | D4 dig5
whismanoid 0:cb44e2e9ec4c 208 // D12/MISO | [s] P5_2 MISO RTS P3_3 [d] | D5 dig4
whismanoid 0:cb44e2e9ec4c 209 // D10/CS | [s] P3_0 RX CTS P3_2 [d] | D6 dig3
whismanoid 0:cb44e2e9ec4c 210 // D9 dig0 | [d] P3_1 TX SCL P3_5 [d] | D7 dig2
whismanoid 0:cb44e2e9ec4c 211 // ______ | [ ] GND SDA P3_4 [d] | D8 dig1
whismanoid 0:cb44e2e9ec4c 212 // | |
whismanoid 0:cb44e2e9ec4c 213 // | XIP Flash MAX14690N |
whismanoid 0:cb44e2e9ec4c 214 // | XIP_SCLK P1_0 SDA2 P5_7 |
whismanoid 0:cb44e2e9ec4c 215 // | XIP_MOSI P1_1 SCL2 P6_0 |
whismanoid 0:cb44e2e9ec4c 216 // | XIP_MISO P1_2 PMIC_INIT P3_7 |
whismanoid 0:cb44e2e9ec4c 217 // | XIP_SSEL P1_3 MPC P2_7 |
whismanoid 0:cb44e2e9ec4c 218 // | XIP_DIO2 P1_4 MON AIN_0 |
whismanoid 0:cb44e2e9ec4c 219 // | XIP_DIO3 P1_5 |
whismanoid 0:cb44e2e9ec4c 220 // | |
whismanoid 0:cb44e2e9ec4c 221 // | PAN1326B MicroSD LED |
whismanoid 0:cb44e2e9ec4c 222 // | BT_RX P0_0 SD_SCLK P0_4 r P2_4 |
whismanoid 0:cb44e2e9ec4c 223 // | BT_TX P0_1 SD_MOSI P0_5 g P2_5 |
whismanoid 0:cb44e2e9ec4c 224 // | BT_CTS P0_2 SD_MISO P0_6 b P2_6 |
whismanoid 0:cb44e2e9ec4c 225 // | BT_RTS P0_3 SD_SSEL P0_7 |
whismanoid 0:cb44e2e9ec4c 226 // | BT_RST P1_6 DETECT P2_2 |
whismanoid 0:cb44e2e9ec4c 227 // | BT_CLK P1_7 SW2 P2_3 |
whismanoid 0:cb44e2e9ec4c 228 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 229 // 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 230 // 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 231 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 232 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 233 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 234 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 235 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 236 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 237 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 238 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 239 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 240 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 241 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 242 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 243 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 244 //
whismanoid 0:cb44e2e9ec4c 245 #include "max32630fthr.h"
whismanoid 0:cb44e2e9ec4c 246 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 247 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 248 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 249 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 250 // Arduino connector
whismanoid 0:cb44e2e9ec4c 251 #ifndef A0
whismanoid 0:cb44e2e9ec4c 252 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 253 #endif
whismanoid 0:cb44e2e9ec4c 254 #ifndef A1
whismanoid 0:cb44e2e9ec4c 255 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 256 #endif
whismanoid 0:cb44e2e9ec4c 257 #ifndef A2
whismanoid 0:cb44e2e9ec4c 258 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 259 #endif
whismanoid 0:cb44e2e9ec4c 260 #ifndef A3
whismanoid 0:cb44e2e9ec4c 261 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 262 #endif
whismanoid 0:cb44e2e9ec4c 263 #ifndef D0
whismanoid 0:cb44e2e9ec4c 264 #define D0 P4_0
whismanoid 0:cb44e2e9ec4c 265 #endif
whismanoid 0:cb44e2e9ec4c 266 #ifndef D1
whismanoid 0:cb44e2e9ec4c 267 #define D1 P5_6
whismanoid 0:cb44e2e9ec4c 268 #endif
whismanoid 0:cb44e2e9ec4c 269 #ifndef D2
whismanoid 0:cb44e2e9ec4c 270 #define D2 P5_5
whismanoid 0:cb44e2e9ec4c 271 #endif
whismanoid 0:cb44e2e9ec4c 272 #ifndef D3
whismanoid 0:cb44e2e9ec4c 273 #define D3 P5_4
whismanoid 0:cb44e2e9ec4c 274 #endif
whismanoid 0:cb44e2e9ec4c 275 #ifndef D4
whismanoid 0:cb44e2e9ec4c 276 #define D4 P5_3
whismanoid 0:cb44e2e9ec4c 277 #endif
whismanoid 0:cb44e2e9ec4c 278 #ifndef D5
whismanoid 0:cb44e2e9ec4c 279 #define D5 P3_3
whismanoid 0:cb44e2e9ec4c 280 #endif
whismanoid 0:cb44e2e9ec4c 281 #ifndef D6
whismanoid 0:cb44e2e9ec4c 282 #define D6 P3_2
whismanoid 0:cb44e2e9ec4c 283 #endif
whismanoid 0:cb44e2e9ec4c 284 #ifndef D7
whismanoid 0:cb44e2e9ec4c 285 #define D7 P3_5
whismanoid 0:cb44e2e9ec4c 286 #endif
whismanoid 0:cb44e2e9ec4c 287 #ifndef D8
whismanoid 0:cb44e2e9ec4c 288 #define D8 P3_4
whismanoid 0:cb44e2e9ec4c 289 #endif
whismanoid 0:cb44e2e9ec4c 290 #ifndef D9
whismanoid 0:cb44e2e9ec4c 291 #define D9 P3_1
whismanoid 0:cb44e2e9ec4c 292 #endif
whismanoid 0:cb44e2e9ec4c 293 #ifndef D10
whismanoid 0:cb44e2e9ec4c 294 #define D10 P3_0
whismanoid 0:cb44e2e9ec4c 295 #endif
whismanoid 0:cb44e2e9ec4c 296 #ifndef D11
whismanoid 0:cb44e2e9ec4c 297 #define D11 P5_1
whismanoid 0:cb44e2e9ec4c 298 #endif
whismanoid 0:cb44e2e9ec4c 299 #ifndef D12
whismanoid 0:cb44e2e9ec4c 300 #define D12 P5_2
whismanoid 0:cb44e2e9ec4c 301 #endif
whismanoid 0:cb44e2e9ec4c 302 #ifndef D13
whismanoid 0:cb44e2e9ec4c 303 #define D13 P5_0
whismanoid 0:cb44e2e9ec4c 304 #endif
whismanoid 0:cb44e2e9ec4c 305 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 306 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 307 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 308 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 309 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 310 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 311 // | |
whismanoid 0:cb44e2e9ec4c 312 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 313 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 314 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 315 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 316 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 317 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 318 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 319 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 320 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 321 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 322 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 323 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 324 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 325 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 326 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 327 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 328 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 329 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 330 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 331 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 332 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 333 // \_______________________/
whismanoid 0:cb44e2e9ec4c 334 //
whismanoid 0:cb44e2e9ec4c 335 // +------------------------+
whismanoid 0:cb44e2e9ec4c 336 // | |
whismanoid 0:cb44e2e9ec4c 337 // | MicroSD LED |
whismanoid 0:cb44e2e9ec4c 338 // | SD_SCLK P2_4 r P3_0 |
whismanoid 0:cb44e2e9ec4c 339 // | SD_MOSI P2_5 g P3_1 |
whismanoid 0:cb44e2e9ec4c 340 // | SD_MISO P2_6 b P3_2 |
whismanoid 0:cb44e2e9ec4c 341 // | SD_SSEL P2_7 y P3_3 |
whismanoid 0:cb44e2e9ec4c 342 // | |
whismanoid 0:cb44e2e9ec4c 343 // | DAPLINK BUTTONS |
whismanoid 0:cb44e2e9ec4c 344 // | TX P2_1 SW3 P2_3 |
whismanoid 0:cb44e2e9ec4c 345 // | RX P2_0 SW2 P2_2 |
whismanoid 0:cb44e2e9ec4c 346 // +------------------------+
whismanoid 0:cb44e2e9ec4c 347 //
whismanoid 0:cb44e2e9ec4c 348 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 349 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 350 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 351 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 352 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 353 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 354 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 355 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 356 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 357 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 358 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 359 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 360 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 361 //
whismanoid 0:cb44e2e9ec4c 362 //#include "max32625mbed.h" // ?
whismanoid 0:cb44e2e9ec4c 363 //MAX32625MBED mbed(MAX32625MBED::VIO_3V3); // ?
whismanoid 0:cb44e2e9ec4c 364 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 365 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 366 const float ADC_FULL_SCALE_VOLTAGE = 1.200; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 367 // Arduino connector
whismanoid 0:cb44e2e9ec4c 368 #ifndef A0
whismanoid 0:cb44e2e9ec4c 369 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 370 #endif
whismanoid 0:cb44e2e9ec4c 371 #ifndef A1
whismanoid 0:cb44e2e9ec4c 372 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 373 #endif
whismanoid 0:cb44e2e9ec4c 374 #ifndef A2
whismanoid 0:cb44e2e9ec4c 375 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 376 #endif
whismanoid 0:cb44e2e9ec4c 377 #ifndef A3
whismanoid 0:cb44e2e9ec4c 378 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 379 #endif
whismanoid 0:cb44e2e9ec4c 380 #ifndef D0
whismanoid 0:cb44e2e9ec4c 381 #define D0 P0_0
whismanoid 0:cb44e2e9ec4c 382 #endif
whismanoid 0:cb44e2e9ec4c 383 #ifndef D1
whismanoid 0:cb44e2e9ec4c 384 #define D1 P0_1
whismanoid 0:cb44e2e9ec4c 385 #endif
whismanoid 0:cb44e2e9ec4c 386 #ifndef D2
whismanoid 0:cb44e2e9ec4c 387 #define D2 P0_2
whismanoid 0:cb44e2e9ec4c 388 #endif
whismanoid 0:cb44e2e9ec4c 389 #ifndef D3
whismanoid 0:cb44e2e9ec4c 390 #define D3 P0_3
whismanoid 0:cb44e2e9ec4c 391 #endif
whismanoid 0:cb44e2e9ec4c 392 #ifndef D4
whismanoid 0:cb44e2e9ec4c 393 #define D4 P0_4
whismanoid 0:cb44e2e9ec4c 394 #endif
whismanoid 0:cb44e2e9ec4c 395 #ifndef D5
whismanoid 0:cb44e2e9ec4c 396 #define D5 P0_5
whismanoid 0:cb44e2e9ec4c 397 #endif
whismanoid 0:cb44e2e9ec4c 398 #ifndef D6
whismanoid 0:cb44e2e9ec4c 399 #define D6 P0_6
whismanoid 0:cb44e2e9ec4c 400 #endif
whismanoid 0:cb44e2e9ec4c 401 #ifndef D7
whismanoid 0:cb44e2e9ec4c 402 #define D7 P0_7
whismanoid 0:cb44e2e9ec4c 403 #endif
whismanoid 0:cb44e2e9ec4c 404 #ifndef D8
whismanoid 0:cb44e2e9ec4c 405 #define D8 P1_4
whismanoid 0:cb44e2e9ec4c 406 #endif
whismanoid 0:cb44e2e9ec4c 407 #ifndef D9
whismanoid 0:cb44e2e9ec4c 408 #define D9 P1_5
whismanoid 0:cb44e2e9ec4c 409 #endif
whismanoid 0:cb44e2e9ec4c 410 #ifndef D10
whismanoid 0:cb44e2e9ec4c 411 #define D10 P1_3
whismanoid 0:cb44e2e9ec4c 412 #endif
whismanoid 0:cb44e2e9ec4c 413 #ifndef D11
whismanoid 0:cb44e2e9ec4c 414 #define D11 P1_1
whismanoid 0:cb44e2e9ec4c 415 #endif
whismanoid 0:cb44e2e9ec4c 416 #ifndef D12
whismanoid 0:cb44e2e9ec4c 417 #define D12 P1_2
whismanoid 0:cb44e2e9ec4c 418 #endif
whismanoid 0:cb44e2e9ec4c 419 #ifndef D13
whismanoid 0:cb44e2e9ec4c 420 #define D13 P1_0
whismanoid 0:cb44e2e9ec4c 421 #endif
whismanoid 0:cb44e2e9ec4c 422 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 423 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 424 // target MAX32600
whismanoid 0:cb44e2e9ec4c 425 //
whismanoid 0:cb44e2e9ec4c 426 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 427 const float ADC_FULL_SCALE_VOLTAGE = 1.500;
whismanoid 0:cb44e2e9ec4c 428 //
whismanoid 0:cb44e2e9ec4c 429 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 430 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 431 #warning "TARGET_MAX32620FTHR not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 432 #include "MAX32620FTHR.h"
whismanoid 0:cb44e2e9ec4c 433 // Initialize I/O voltages on MAX32620FTHR board
whismanoid 0:cb44e2e9ec4c 434 MAX32620FTHR fthr(MAX32620FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 435 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 436 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 437 #warning "TARGET_MAX32620FTHR not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 438 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 439 //
whismanoid 0:cb44e2e9ec4c 440 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 441 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 15:37c83ec50ea0 442 // #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 443 #include "max32625pico.h"
whismanoid 0:cb44e2e9ec4c 444 // configure MAX32625PICO VDDIOH mode, and I/O voltages for DIP pins and SWD pins
whismanoid 0:cb44e2e9ec4c 445 MAX32625PICO pico(
whismanoid 13:184a08909405 446 // Select source of higher-voltage logic high supply VDDIOH
whismanoid 0:cb44e2e9ec4c 447 // vddioh_mode_t iohMode
whismanoid 0:cb44e2e9ec4c 448 //~ MAX32625PICO::IOH_OFF, // No connections to VDDIOH
whismanoid 0:cb44e2e9ec4c 449 //~ MAX32625PICO::IOH_DIP_IN, // VDDIOH input from DIP pin 1 (AIN0)
whismanoid 0:cb44e2e9ec4c 450 //~ MAX32625PICO::IOH_SWD_IN, // VDDIOH input from SWD pin 1
whismanoid 0:cb44e2e9ec4c 451 MAX32625PICO::IOH_3V3, // VDDIOH = 3.3V from local supply
whismanoid 0:cb44e2e9ec4c 452 //~ MAX32625PICO::IOH_DIP_OUT, // VDDIOH = 3.3V output to DIP pin 1
whismanoid 0:cb44e2e9ec4c 453 //~ MAX32625PICO::IOH_SWD_OUT, // VDDIOH = 3.3V output to SWD pin 1
whismanoid 0:cb44e2e9ec4c 454 //
whismanoid 13:184a08909405 455 // Digital I/O pin logic high voltage 1.8V or 3.3V
whismanoid 0:cb44e2e9ec4c 456 // vio_t dipVio = MAX32625PICO::VIO_1V8 or MAX32625PICO::VIO_IOH
whismanoid 13:184a08909405 457 MAX32625PICO::VIO_1V8, // 1.8V IO (local)
whismanoid 13:184a08909405 458 //~ MAX32625PICO::VIO_IOH, // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 459 //
whismanoid 13:184a08909405 460 // Software Debug logic high voltage (normally use VIO_IOH)
whismanoid 0:cb44e2e9ec4c 461 // vio_t swdVio
whismanoid 0:cb44e2e9ec4c 462 //~ MAX32625PICO::VIO_1V8 // 1.8V IO (local)
whismanoid 0:cb44e2e9ec4c 463 MAX32625PICO::VIO_IOH // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 464 );
whismanoid 0:cb44e2e9ec4c 465 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 466 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 15:37c83ec50ea0 467 // #warning "TARGET_MAX32625PICO not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 468 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 469 //
whismanoid 0:cb44e2e9ec4c 470 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 471 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 472 // TODO1: target NUCLEO_F446RE
whismanoid 0:cb44e2e9ec4c 473 //
whismanoid 0:cb44e2e9ec4c 474 // USER_BUTTON PC13
whismanoid 0:cb44e2e9ec4c 475 // LED1 is shared with SPI_SCK on NUCLEO_F446RE PA_5, so don't use LED1.
whismanoid 0:cb44e2e9ec4c 476 #define USE_LEDS 0
whismanoid 0:cb44e2e9ec4c 477 // SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
whismanoid 0:cb44e2e9ec4c 478 // Serial serial(SERIAL_TX, SERIAL_RX);
whismanoid 0:cb44e2e9ec4c 479 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 480 const float ADC_FULL_SCALE_VOLTAGE = 3.300; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 481 //
whismanoid 0:cb44e2e9ec4c 482 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 483 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 484 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 485 // TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM
whismanoid 0:cb44e2e9ec4c 486 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 487 // ______ | [ ] GND +3.3V VOUT [ ] | ______
whismanoid 0:cb44e2e9ec4c 488 // ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | ______
whismanoid 0:cb44e2e9ec4c 489 // ______ | [ ] VB USB.IF- [ ] | ______
whismanoid 0:cb44e2e9ec4c 490 // ______ | [ ] nR USB.IF+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 491 // digitalInOut0 | [ ] p5 MOSI ETHERNET.RD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 492 // digitalInOut1 | [ ] p6 MISO ETHERNET.RD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 493 // digitalInOut2 | [ ] p7 SCLK ETHERNET.TD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 494 // digitalInOut3 | [ ] p8 ETHERNET.TD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 495 // digitalInOut4 | [ ] p9 TX SDA USB.D- [ ] | ______
whismanoid 0:cb44e2e9ec4c 496 // digitalInOut5 | [ ] p10 RX SCL USB.D+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 497 // digitalInOut6 | [ ] p11 MOSI CAN-RD p30 [ ] | digitalInOut13
whismanoid 0:cb44e2e9ec4c 498 // digitalInOut7 | [ ] p12 MISO CAN-TD p29 [ ] | digitalInOut12
whismanoid 0:cb44e2e9ec4c 499 // digitalInOut8 | [ ] p13 TX SCLK SDA TX p28 [ ] | digitalInOut11
whismanoid 0:cb44e2e9ec4c 500 // digitalInOut9 | [ ] p14 RX SCL RX p27 [ ] | digitalInOut10
whismanoid 0:cb44e2e9ec4c 501 // analogIn0 | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1
whismanoid 0:cb44e2e9ec4c 502 // analogIn1 | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2
whismanoid 0:cb44e2e9ec4c 503 // analogIn2 | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3
whismanoid 0:cb44e2e9ec4c 504 // analogIn3 | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4
whismanoid 0:cb44e2e9ec4c 505 // analogIn4 | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5
whismanoid 0:cb44e2e9ec4c 506 // analogIn5 | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6
whismanoid 0:cb44e2e9ec4c 507 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 508 // AIN6 = P0.3 = TGT_SBL_RXD?
whismanoid 0:cb44e2e9ec4c 509 // AIN7 = P0.2 = TGT_SBL_TXD?
whismanoid 0:cb44e2e9ec4c 510 //
whismanoid 0:cb44e2e9ec4c 511 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 512 // LPC1768 board uses VREF = 3.300V +A3,3V thru L1 to bypass capacitor C14
whismanoid 0:cb44e2e9ec4c 513 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 514 const float ADC_FULL_SCALE_VOLTAGE = 3.300;
whismanoid 0:cb44e2e9ec4c 515 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 0:cb44e2e9ec4c 516 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 517 // unknown target
whismanoid 0:cb44e2e9ec4c 518 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 519 #endif // target definition
whismanoid 0:cb44e2e9ec4c 520
whismanoid 0:cb44e2e9ec4c 521
whismanoid 0:cb44e2e9ec4c 522
whismanoid 0:cb44e2e9ec4c 523
whismanoid 18:1235c17b451e 524 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 525 // move definiton of USE_LEDS earlier than find_digitalInOutPin()
whismanoid 18:1235c17b451e 526 //--------------------------------------------------
whismanoid 18:1235c17b451e 527 // Option to use LEDs to show status
whismanoid 18:1235c17b451e 528 #ifndef USE_LEDS
whismanoid 18:1235c17b451e 529 #define USE_LEDS 1
whismanoid 18:1235c17b451e 530 #endif
whismanoid 18:1235c17b451e 531 #if USE_LEDS
whismanoid 18:1235c17b451e 532 #if defined(TARGET_MAX32630)
whismanoid 18:1235c17b451e 533 # define LED_ON 0
whismanoid 18:1235c17b451e 534 # define LED_OFF 1
whismanoid 18:1235c17b451e 535 //--------------------------------------------------
whismanoid 18:1235c17b451e 536 #elif defined(TARGET_MAX32625MBED)
whismanoid 18:1235c17b451e 537 # define LED_ON 0
whismanoid 18:1235c17b451e 538 # define LED_OFF 1
whismanoid 19:5ff09c8e9daf 539 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 18:1235c17b451e 540 # define LED_ON 0
whismanoid 18:1235c17b451e 541 # define LED_OFF 1
whismanoid 18:1235c17b451e 542 //--------------------------------------------------
whismanoid 18:1235c17b451e 543 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 18:1235c17b451e 544 #elif defined(TARGET_LPC1768)
whismanoid 18:1235c17b451e 545 # define LED_ON 1
whismanoid 18:1235c17b451e 546 # define LED_OFF 0
whismanoid 18:1235c17b451e 547 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 18:1235c17b451e 548 // USE_LEDS with some platform other than MAX32630, MAX32625MBED, LPC1768
whismanoid 18:1235c17b451e 549 // bugfix for MAX32600MBED LED blink pattern: check if LED_ON/LED_OFF already defined
whismanoid 18:1235c17b451e 550 # ifndef LED_ON
whismanoid 18:1235c17b451e 551 # define LED_ON 0
whismanoid 18:1235c17b451e 552 # endif
whismanoid 18:1235c17b451e 553 # ifndef LED_OFF
whismanoid 18:1235c17b451e 554 # define LED_OFF 1
whismanoid 18:1235c17b451e 555 # endif
whismanoid 18:1235c17b451e 556 //# define LED_ON 1
whismanoid 18:1235c17b451e 557 //# define LED_OFF 0
whismanoid 18:1235c17b451e 558 #endif // target definition
whismanoid 18:1235c17b451e 559 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 560 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 561 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 562 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 563 // change led1/2/3/4 from DigitalOut to DigitalInOut
whismanoid 18:1235c17b451e 564 DigitalInOut led1(LED1, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED1 = LED_RED
whismanoid 18:1235c17b451e 565 DigitalInOut led2(LED2, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN
whismanoid 18:1235c17b451e 566 DigitalInOut led3(LED3, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE
whismanoid 18:1235c17b451e 567 DigitalInOut led4(LED4, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 568 #else // USE_LEDS=0
whismanoid 18:1235c17b451e 569 // issue #41 support Nucleo_F446RE
whismanoid 18:1235c17b451e 570 // there are no LED indicators on the board, LED1 interferes with SPI;
whismanoid 18:1235c17b451e 571 // but we still need placeholders led1 led2 led3 led4.
whismanoid 18:1235c17b451e 572 // Declare DigitalInOut led1 led2 led3 led4 targeting safe pins.
whismanoid 18:1235c17b451e 573 // PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false
whismanoid 18:1235c17b451e 574 # define LED_ON 0
whismanoid 18:1235c17b451e 575 # define LED_OFF 1
whismanoid 18:1235c17b451e 576 // change led1/2/3/4 from DigitalOut to DigitalInOut
whismanoid 18:1235c17b451e 577 DigitalInOut led1(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 578 DigitalInOut led2(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 579 DigitalInOut led3(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 580 DigitalInOut led4(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 581 #endif // USE_LEDS
whismanoid 18:1235c17b451e 582 #define led1_RFailLED led1
whismanoid 18:1235c17b451e 583 #define led2_GPassLED led2
whismanoid 18:1235c17b451e 584 #define led3_BBusyLED led3
whismanoid 18:1235c17b451e 585
whismanoid 21:ac062a97a71d 586 //--------------------------------------------------
whismanoid 21:ac062a97a71d 587 // use BUTTON1 trigger some action
whismanoid 21:ac062a97a71d 588 #if defined(TARGET_MAX32630)
whismanoid 21:ac062a97a71d 589 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 590 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 591 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 592 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 25:8a61cb34191d 593 // #warning "TARGET_MAX32625PICO not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 594 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 24:032f3683cb2a 595 #if MAX40108_DEMO
whismanoid 25:8a61cb34191d 596 #if HAS_I2C
whismanoid 25:8a61cb34191d 597 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 598 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 24:032f3683cb2a 599 #define BUTTON2 P3_7
whismanoid 25:8a61cb34191d 600 #else // HAS_I2C
whismanoid 25:8a61cb34191d 601 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 602 // 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 603 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 604 #define BUTTON2 P1_7
whismanoid 25:8a61cb34191d 605 #endif // HAS_I2C
whismanoid 24:032f3683cb2a 606 #define HAS_BUTTON2_DEMO 0
whismanoid 24:032f3683cb2a 607 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 25:8a61cb34191d 608 #if HAS_I2C
whismanoid 25:8a61cb34191d 609 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 610 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 24:032f3683cb2a 611 #define BUTTON3 P3_6
whismanoid 25:8a61cb34191d 612 #else // HAS_I2C
whismanoid 25:8a61cb34191d 613 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 614 // 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 615 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 616 #define BUTTON3 P1_6
whismanoid 25:8a61cb34191d 617 #endif // HAS_I2C
whismanoid 24:032f3683cb2a 618 #define HAS_BUTTON3_DEMO 0
whismanoid 24:032f3683cb2a 619 #define HAS_BUTTON3_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 620 // additional buttons are assigned to unused/unaccessible pins to avoid conflicts
whismanoid 29:6a9edb6e973b 621 // activate using %B4! or action_button pin=4
whismanoid 29:6a9edb6e973b 622 #define BUTTON4 P1_5
whismanoid 29:6a9edb6e973b 623 #define HAS_BUTTON4_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 624 #define BUTTON5 P1_4
whismanoid 29:6a9edb6e973b 625 #define HAS_BUTTON5_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 626 #define BUTTON6 P1_3
whismanoid 29:6a9edb6e973b 627 #define HAS_BUTTON6_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 628 #define BUTTON7 P1_2
whismanoid 29:6a9edb6e973b 629 #define HAS_BUTTON7_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 630 #define BUTTON8 P1_1
whismanoid 29:6a9edb6e973b 631 #define HAS_BUTTON8_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 632 #define BUTTON9 P1_0
whismanoid 29:6a9edb6e973b 633 #define HAS_BUTTON9_DEMO_INTERRUPT 1
whismanoid 24:032f3683cb2a 634 #else // MAX40108_DEMO
whismanoid 21:ac062a97a71d 635 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 636 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 29:6a9edb6e973b 637 #endif // MAX40108_DEMO ---------------------------------
whismanoid 21:ac062a97a71d 638 #elif defined(TARGET_MAX32625)
whismanoid 21:ac062a97a71d 639 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 640 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 641 #elif defined(TARGET_MAX32620FTHR)
whismanoid 21:ac062a97a71d 642 #warning "TARGET_MAX32620FTHR not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 643 #define BUTTON1 SW1
whismanoid 21:ac062a97a71d 644 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 645 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 646 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 647 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 21:ac062a97a71d 648 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 649 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 650 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 21:ac062a97a71d 651 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 652 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 653 #else
whismanoid 21:ac062a97a71d 654 #warning "target not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 655 #endif
whismanoid 21:ac062a97a71d 656 //
whismanoid 21:ac062a97a71d 657 #ifndef HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 658 #define HAS_BUTTON1_DEMO 0
whismanoid 21:ac062a97a71d 659 #endif
whismanoid 21:ac062a97a71d 660 #ifndef HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 661 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 662 #endif
whismanoid 24:032f3683cb2a 663 #ifndef HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 664 #define HAS_BUTTON3_DEMO 0
whismanoid 24:032f3683cb2a 665 #endif
whismanoid 21:ac062a97a71d 666 //
whismanoid 21:ac062a97a71d 667 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 668 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 669 #ifndef HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 670 #define HAS_BUTTON1_DEMO_INTERRUPT_POLLING 1
whismanoid 21:ac062a97a71d 671 #endif
whismanoid 21:ac062a97a71d 672 //
whismanoid 21:ac062a97a71d 673 #ifndef HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 674 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 675 #endif
whismanoid 21:ac062a97a71d 676 #ifndef HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 677 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 678 #endif
whismanoid 21:ac062a97a71d 679 //
whismanoid 21:ac062a97a71d 680 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 681 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 682 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 683 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 684 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 685 # else
whismanoid 21:ac062a97a71d 686 InterruptIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 687 # endif
whismanoid 21:ac062a97a71d 688 #elif HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 689 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 690 #endif
whismanoid 21:ac062a97a71d 691 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 692 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 693 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 694 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 695 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 696 # else
whismanoid 21:ac062a97a71d 697 InterruptIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 698 # endif
whismanoid 21:ac062a97a71d 699 #elif HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 700 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 701 #endif
whismanoid 24:032f3683cb2a 702 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 703 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 24:032f3683cb2a 704 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 24:032f3683cb2a 705 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 24:032f3683cb2a 706 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 707 # else
whismanoid 24:032f3683cb2a 708 InterruptIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 709 # endif
whismanoid 24:032f3683cb2a 710 #elif HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 711 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 712 #endif
whismanoid 21:ac062a97a71d 713
whismanoid 0:cb44e2e9ec4c 714 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 715 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 716 // Declare the DigitalInOut GPIO pins
whismanoid 0:cb44e2e9ec4c 717 // Optional digitalInOut support. If there is only one it should be digitalInOut1.
whismanoid 0:cb44e2e9ec4c 718 // D) Digital High/Low/Input Pin
whismanoid 0:cb44e2e9ec4c 719 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 720 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 721 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 722 // | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 723 // | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 724 // | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 725 // | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 726 // | [ ] AIN_0 1.2Vfs (bat) SYS [ ] |
whismanoid 0:cb44e2e9ec4c 727 // | [ ] AIN_1 1.2Vfs PWR [ ] |
whismanoid 0:cb44e2e9ec4c 728 // | [ ] AIN_2 1.2Vfs +5V VBUS [ ] |
whismanoid 0:cb44e2e9ec4c 729 // | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9
whismanoid 0:cb44e2e9ec4c 730 // dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8
whismanoid 0:cb44e2e9ec4c 731 // dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7
whismanoid 0:cb44e2e9ec4c 732 // dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6
whismanoid 0:cb44e2e9ec4c 733 // dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5
whismanoid 0:cb44e2e9ec4c 734 // dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4
whismanoid 0:cb44e2e9ec4c 735 // dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3
whismanoid 0:cb44e2e9ec4c 736 // dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2
whismanoid 0:cb44e2e9ec4c 737 // | [ ] GND SDA P3_4 [x] | dig1
whismanoid 0:cb44e2e9ec4c 738 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 739 #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 740 #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 741 #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 742 #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 743 #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 744 #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 745 #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 746 #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 747 #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 748 #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 749 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 750 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 751 #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 752 #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 753 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 754 #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 755 #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 756 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 757 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 758 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 759 #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 760 #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 761 #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 762 #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 763 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 764 #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 765 #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 766 #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 767 #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 768 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 769 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 770 DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 771 #endif
whismanoid 0:cb44e2e9ec4c 772 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 773 DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 774 #endif
whismanoid 0:cb44e2e9ec4c 775 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 776 DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 777 #endif
whismanoid 0:cb44e2e9ec4c 778 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 779 DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 780 #endif
whismanoid 0:cb44e2e9ec4c 781 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 782 DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 783 #endif
whismanoid 0:cb44e2e9ec4c 784 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 785 DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 786 #endif
whismanoid 0:cb44e2e9ec4c 787 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 788 DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 789 #endif
whismanoid 0:cb44e2e9ec4c 790 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 791 DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 792 #endif
whismanoid 0:cb44e2e9ec4c 793 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 794 DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 795 #endif
whismanoid 0:cb44e2e9ec4c 796 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 797 DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 798 #endif
whismanoid 0:cb44e2e9ec4c 799 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 800 DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 801 #endif
whismanoid 0:cb44e2e9ec4c 802 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 803 DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 804 #endif
whismanoid 0:cb44e2e9ec4c 805 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 806 DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 807 #endif
whismanoid 0:cb44e2e9ec4c 808 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 809 DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 810 #endif
whismanoid 0:cb44e2e9ec4c 811 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 812 DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 813 #endif
whismanoid 0:cb44e2e9ec4c 814 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 815 DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 816 #endif
whismanoid 0:cb44e2e9ec4c 817 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 818 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 819 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 820 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 821 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 822 // | |
whismanoid 0:cb44e2e9ec4c 823 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 824 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 825 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 826 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 827 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 828 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 829 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 830 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 831 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 832 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 833 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 834 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 835 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 836 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 837 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 838 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 839 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 840 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 841 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 842 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 843 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 844 // \_______________________/
whismanoid 0:cb44e2e9ec4c 845 //
whismanoid 0:cb44e2e9ec4c 846 #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 847 #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 848 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 849 #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 850 #else
whismanoid 0:cb44e2e9ec4c 851 #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 852 #endif
whismanoid 0:cb44e2e9ec4c 853 #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 854 #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 855 #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 856 #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 857 #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 858 #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 859 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 860 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 861 #else
whismanoid 0:cb44e2e9ec4c 862 #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 863 #endif
whismanoid 0:cb44e2e9ec4c 864 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 865 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 866 #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 867 #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 868 #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 869 #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 870 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 871 #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 872 #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 873 #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 874 #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 875 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 876 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 877 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 878 #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 879 #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 880 #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 881 #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 882 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 883 #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 884 #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 885 #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 886 #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 887 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 888 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 889 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 890 #endif
whismanoid 0:cb44e2e9ec4c 891 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 892 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 893 #endif
whismanoid 0:cb44e2e9ec4c 894 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 895 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 896 #endif
whismanoid 0:cb44e2e9ec4c 897 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 898 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 899 #endif
whismanoid 0:cb44e2e9ec4c 900 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 901 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 902 #endif
whismanoid 0:cb44e2e9ec4c 903 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 904 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 905 #endif
whismanoid 0:cb44e2e9ec4c 906 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 907 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 908 #endif
whismanoid 0:cb44e2e9ec4c 909 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 910 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 911 #endif
whismanoid 0:cb44e2e9ec4c 912 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 913 DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 914 #endif
whismanoid 0:cb44e2e9ec4c 915 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 916 DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 917 #endif
whismanoid 0:cb44e2e9ec4c 918 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 919 DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 920 #endif
whismanoid 0:cb44e2e9ec4c 921 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 922 DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 923 #endif
whismanoid 0:cb44e2e9ec4c 924 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 925 DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 926 #endif
whismanoid 0:cb44e2e9ec4c 927 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 928 DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 929 #endif
whismanoid 0:cb44e2e9ec4c 930 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 931 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 932 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 933 DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 934 #endif
whismanoid 0:cb44e2e9ec4c 935 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 936 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 937 DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 938 #endif
whismanoid 0:cb44e2e9ec4c 939 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 940 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 941 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 942 // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V
whismanoid 0:cb44e2e9ec4c 943 DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 944 #endif
whismanoid 0:cb44e2e9ec4c 945 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 946 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 947 DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 948 #endif
whismanoid 0:cb44e2e9ec4c 949 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 950 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 15:37c83ec50ea0 951 // TARGET=MAX32625PICO ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 15:37c83ec50ea0 952 // +-------------[microUSB]-------------+
whismanoid 15:37c83ec50ea0 953 // | [27]D+ D-[26] |
whismanoid 15:37c83ec50ea0 954 // | |
whismanoid 15:37c83ec50ea0 955 // | [BUTTON P2_7] |
whismanoid 15:37c83ec50ea0 956 // | P2_4 LED_R P2_5 LED_G P2_6 LED_B |
whismanoid 15:37c83ec50ea0 957 // | |
whismanoid 15:37c83ec50ea0 958 // 1V8 | [11] 1.8V MAX32625PICO GND [10] | GND
whismanoid 15:37c83ec50ea0 959 // 3V3 | [12] 3.3V +5V [09] | 5V0
whismanoid 15:37c83ec50ea0 960 // SPI CS D7 | [13] P0_7 CS s-ssel P4_7 [08] | D15
whismanoid 15:37c83ec50ea0 961 // SPI MISO D6 | [14] P0_6 MISO s-miso P4_6 [07] | D14
whismanoid 15:37c83ec50ea0 962 // SPI MOSI D5 | [15] P0_5 MOSI s-mosi P4_5 [06] | D13
whismanoid 15:37c83ec50ea0 963 // SPI SCLK D4 | [16] P0_4 SCLK s-sclk P4_4 [05] | D12
whismanoid 15:37c83ec50ea0 964 // D3 | [17] P0_3 RTS SCL P1_7 [04] | SCL/D17
whismanoid 15:37c83ec50ea0 965 // D2 | [18] P0_2 CTS SDA P1_6 [03] | SDA/D16
whismanoid 15:37c83ec50ea0 966 // TX/D1 | [19] P0_1 TX0 AIN_2 [02] | A2
whismanoid 15:37c83ec50ea0 967 // RX/D0 | [20] P0_0 RX0 AIN_0 [01] | A0/A4
whismanoid 15:37c83ec50ea0 968 // | |
whismanoid 15:37c83ec50ea0 969 // | DAPLINK |
whismanoid 15:37c83ec50ea0 970 // | J3 p3_3 p3_2 p3_0 p3_1 p3_7 |
whismanoid 15:37c83ec50ea0 971 // | DAP [ ] [ ] [RX2][TX2][ ] |
whismanoid 15:37c83ec50ea0 972 // | TOP [ ] [ ] [ ] [ ] [ ] |
whismanoid 15:37c83ec50ea0 973 // | AIN1/A5 gnd gnd nc AIN3 |
whismanoid 15:37c83ec50ea0 974 // | IOH 1-wire |
whismanoid 15:37c83ec50ea0 975 // | |
whismanoid 15:37c83ec50ea0 976 // |NO USE RST P2_0 P2_1 |
whismanoid 15:37c83ec50ea0 977 // |BOTTOM [ ] [ ] [RX1][ ] [TX1] |
whismanoid 15:37c83ec50ea0 978 // | RST SWC GND SWD 1V8 |
whismanoid 15:37c83ec50ea0 979 // |BOTTOM [21] [22] [23] [24] [25] |
whismanoid 15:37c83ec50ea0 980 // +------------------------------------+
whismanoid 15:37c83ec50ea0 981 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 982 // MAX40108 demo p2: D0..D7 = P0_0..P0_7; D8..15 = P4_0..P4_7; D16/D17=I2C
whismanoid 15:37c83ec50ea0 983 #endif
whismanoid 15:37c83ec50ea0 984 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 985 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 986 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 987 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 988 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 989 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 990 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 991 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 992 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 993 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 15:37c83ec50ea0 994 // AIN_10 = x undefined?
whismanoid 15:37c83ec50ea0 995 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 996 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 997 //
whismanoid 15:37c83ec50ea0 998 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 999 // avoid resource conflict D0,D1 alternate function as RX/TX
whismanoid 15:37c83ec50ea0 1000 #define HAS_digitalInOut0 0
whismanoid 15:37c83ec50ea0 1001 #define HAS_digitalInOut1 0
whismanoid 15:37c83ec50ea0 1002 #else
whismanoid 15:37c83ec50ea0 1003 #define HAS_digitalInOut0 1
whismanoid 19:5ff09c8e9daf 1004 #define HAS_digitalInOut1 1
whismanoid 19:5ff09c8e9daf 1005 // P0_1 TARGET_MAX32625PICO D1
whismanoid 15:37c83ec50ea0 1006 #endif
whismanoid 15:37c83ec50ea0 1007 #if APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 1008 // avoid resource conflict D2 alternate function as interrupt input
whismanoid 15:37c83ec50ea0 1009 #define HAS_digitalInOut2 0
whismanoid 15:37c83ec50ea0 1010 #else
whismanoid 15:37c83ec50ea0 1011 #define HAS_digitalInOut2 1
whismanoid 15:37c83ec50ea0 1012 #endif
whismanoid 15:37c83ec50ea0 1013 #define HAS_digitalInOut3 1
whismanoid 15:37c83ec50ea0 1014 #define HAS_digitalInOut4 1
whismanoid 15:37c83ec50ea0 1015 #define HAS_digitalInOut5 1
whismanoid 15:37c83ec50ea0 1016 #define HAS_digitalInOut6 1
whismanoid 15:37c83ec50ea0 1017 #define HAS_digitalInOut7 1
whismanoid 15:37c83ec50ea0 1018 //
whismanoid 15:37c83ec50ea0 1019 #define HAS_digitalInOut8 1
whismanoid 15:37c83ec50ea0 1020 #define HAS_digitalInOut9 1
whismanoid 15:37c83ec50ea0 1021 #define HAS_digitalInOut10 1
whismanoid 15:37c83ec50ea0 1022 #define HAS_digitalInOut11 1
whismanoid 15:37c83ec50ea0 1023 #define HAS_digitalInOut12 1
whismanoid 15:37c83ec50ea0 1024 #define HAS_digitalInOut13 1
whismanoid 15:37c83ec50ea0 1025 #define HAS_digitalInOut14 1
whismanoid 15:37c83ec50ea0 1026 #define HAS_digitalInOut15 1
whismanoid 15:37c83ec50ea0 1027 #if HAS_I2C
whismanoid 25:8a61cb34191d 1028 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 1029 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 25:8a61cb34191d 1030 // #define BUTTON2 P3_7
whismanoid 25:8a61cb34191d 1031 // avoid resource conflict between I2C and DigitalInOut
whismanoid 25:8a61cb34191d 1032 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1033 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 1034 #else // HAS_I2C
whismanoid 25:8a61cb34191d 1035 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 1036 // 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 1037 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1038 // #define BUTTON2 P1_7
whismanoid 25:8a61cb34191d 1039 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1040 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1041 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1042 #else // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1043 #define HAS_digitalInOut16 1 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1044 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1045 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1046 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1047 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1048 #else // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1049 #define HAS_digitalInOut17 1 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1050 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 15:37c83ec50ea0 1051 #endif // HAS_I2C
whismanoid 15:37c83ec50ea0 1052 #if HAS_digitalInOut0
whismanoid 25:8a61cb34191d 1053 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D0
whismanoid 15:37c83ec50ea0 1054 #endif
whismanoid 15:37c83ec50ea0 1055 #if HAS_digitalInOut1
whismanoid 25:8a61cb34191d 1056 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D1
whismanoid 15:37c83ec50ea0 1057 #endif
whismanoid 15:37c83ec50ea0 1058 #if HAS_digitalInOut2
whismanoid 25:8a61cb34191d 1059 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D2
whismanoid 15:37c83ec50ea0 1060 #endif
whismanoid 15:37c83ec50ea0 1061 #if HAS_digitalInOut3
whismanoid 25:8a61cb34191d 1062 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D3
whismanoid 15:37c83ec50ea0 1063 #endif
whismanoid 15:37c83ec50ea0 1064 #if HAS_digitalInOut4
whismanoid 25:8a61cb34191d 1065 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D4
whismanoid 15:37c83ec50ea0 1066 #endif
whismanoid 15:37c83ec50ea0 1067 #if HAS_digitalInOut5
whismanoid 25:8a61cb34191d 1068 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D5
whismanoid 15:37c83ec50ea0 1069 #endif
whismanoid 15:37c83ec50ea0 1070 #if HAS_digitalInOut6
whismanoid 25:8a61cb34191d 1071 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D6
whismanoid 15:37c83ec50ea0 1072 #endif
whismanoid 15:37c83ec50ea0 1073 #if HAS_digitalInOut7
whismanoid 25:8a61cb34191d 1074 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D7
whismanoid 15:37c83ec50ea0 1075 #endif
whismanoid 15:37c83ec50ea0 1076 #if HAS_digitalInOut8
whismanoid 25:8a61cb34191d 1077 DigitalInOut digitalInOut8(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX40108DEMOP2U9 D8
whismanoid 15:37c83ec50ea0 1078 #endif
whismanoid 15:37c83ec50ea0 1079 #if HAS_digitalInOut9
whismanoid 25:8a61cb34191d 1080 DigitalInOut digitalInOut9(P4_1, PIN_INPUT, PullUp, 1); // P4_1 TARGET_MAX40108DEMOP2U9 D9
whismanoid 15:37c83ec50ea0 1081 #endif
whismanoid 15:37c83ec50ea0 1082 #if HAS_digitalInOut10
whismanoid 25:8a61cb34191d 1083 DigitalInOut digitalInOut10(P4_2, PIN_INPUT, PullUp, 1); // P4_2 TARGET_MAX40108DEMOP2U9 D10
whismanoid 15:37c83ec50ea0 1084 #endif
whismanoid 15:37c83ec50ea0 1085 #if HAS_digitalInOut11
whismanoid 25:8a61cb34191d 1086 DigitalInOut digitalInOut11(P4_3, PIN_INPUT, PullUp, 1); // P4_3 TARGET_MAX40108DEMOP2U9 D11
whismanoid 15:37c83ec50ea0 1087 #endif
whismanoid 15:37c83ec50ea0 1088 #if HAS_digitalInOut12
whismanoid 25:8a61cb34191d 1089 DigitalInOut digitalInOut12(P4_4, PIN_INPUT, PullUp, 1); // P4_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D12
whismanoid 15:37c83ec50ea0 1090 #endif
whismanoid 15:37c83ec50ea0 1091 #if HAS_digitalInOut13
whismanoid 25:8a61cb34191d 1092 DigitalInOut digitalInOut13(P4_5, PIN_INPUT, PullUp, 1); // P4_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D13
whismanoid 15:37c83ec50ea0 1093 #endif
whismanoid 15:37c83ec50ea0 1094 #if HAS_digitalInOut14
whismanoid 25:8a61cb34191d 1095 DigitalInOut digitalInOut14(P4_6, PIN_INPUT, PullUp, 1); // P4_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D14
whismanoid 15:37c83ec50ea0 1096 #endif
whismanoid 15:37c83ec50ea0 1097 #if HAS_digitalInOut15
whismanoid 25:8a61cb34191d 1098 DigitalInOut digitalInOut15(P4_7, PIN_INPUT, PullUp, 1); // P4_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D15
whismanoid 15:37c83ec50ea0 1099 #endif
whismanoid 15:37c83ec50ea0 1100 #if HAS_digitalInOut16
whismanoid 15:37c83ec50ea0 1101 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 15:37c83ec50ea0 1102 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 25:8a61cb34191d 1103 DigitalInOut digitalInOut16(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 15:37c83ec50ea0 1104 #endif
whismanoid 15:37c83ec50ea0 1105 #if HAS_digitalInOut17
whismanoid 15:37c83ec50ea0 1106 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 25:8a61cb34191d 1107 DigitalInOut digitalInOut17(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 1108 #endif
whismanoid 15:37c83ec50ea0 1109 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1110 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1111 #define HAS_digitalInOut0 0
whismanoid 0:cb44e2e9ec4c 1112 #define HAS_digitalInOut1 0
whismanoid 0:cb44e2e9ec4c 1113 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1114 // D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 1115 #define HAS_digitalInOut2 0
whismanoid 0:cb44e2e9ec4c 1116 #else
whismanoid 0:cb44e2e9ec4c 1117 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1118 #endif
whismanoid 0:cb44e2e9ec4c 1119 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1120 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1121 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1122 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1123 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1124 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1125 // D8 -- MAX5715 CLRb DigitalOut
whismanoid 0:cb44e2e9ec4c 1126 #define HAS_digitalInOut8 0
whismanoid 0:cb44e2e9ec4c 1127 #else
whismanoid 0:cb44e2e9ec4c 1128 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1129 #endif
whismanoid 0:cb44e2e9ec4c 1130 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1131 // D9 -- MAX5715 LDACb DigitalOut
whismanoid 0:cb44e2e9ec4c 1132 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1133 #elif APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1134 // D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 1135 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1136 #else
whismanoid 0:cb44e2e9ec4c 1137 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1138 #endif
whismanoid 0:cb44e2e9ec4c 1139 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 1140 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1141 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1142 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1143 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1144 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1145 #define HAS_digitalInOut10 0
whismanoid 0:cb44e2e9ec4c 1146 #define HAS_digitalInOut11 0
whismanoid 0:cb44e2e9ec4c 1147 #define HAS_digitalInOut12 0
whismanoid 0:cb44e2e9ec4c 1148 #define HAS_digitalInOut13 0
whismanoid 0:cb44e2e9ec4c 1149 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1150 #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1151 #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1152 #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1153 #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1154 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1155 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 1156 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1157 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1158 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1159 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1160 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1161 #define HAS_digitalInOut14 0
whismanoid 0:cb44e2e9ec4c 1162 #define HAS_digitalInOut15 0
whismanoid 0:cb44e2e9ec4c 1163 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1164 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1165 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1166 #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1167 #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1168 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1169 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1170 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1171 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1172 DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1173 #endif
whismanoid 0:cb44e2e9ec4c 1174 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1175 DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1176 #endif
whismanoid 0:cb44e2e9ec4c 1177 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1178 DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1179 #endif
whismanoid 0:cb44e2e9ec4c 1180 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1181 DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1182 #endif
whismanoid 0:cb44e2e9ec4c 1183 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1184 DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1185 #endif
whismanoid 0:cb44e2e9ec4c 1186 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1187 DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1188 #endif
whismanoid 0:cb44e2e9ec4c 1189 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1190 DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1191 #endif
whismanoid 0:cb44e2e9ec4c 1192 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1193 DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1194 #endif
whismanoid 0:cb44e2e9ec4c 1195 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1196 DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1197 #endif
whismanoid 0:cb44e2e9ec4c 1198 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1199 DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1200 #endif
whismanoid 0:cb44e2e9ec4c 1201 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1202 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1203 DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1204 #endif
whismanoid 0:cb44e2e9ec4c 1205 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1206 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1207 DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1208 #endif
whismanoid 0:cb44e2e9ec4c 1209 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1210 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1211 DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1212 #endif
whismanoid 0:cb44e2e9ec4c 1213 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1214 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1215 DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1216 #endif
whismanoid 0:cb44e2e9ec4c 1217 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1218 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1219 DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1220 #endif
whismanoid 0:cb44e2e9ec4c 1221 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1222 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1223 DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1224 #endif
whismanoid 0:cb44e2e9ec4c 1225 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1226 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1227 DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1228 #endif
whismanoid 0:cb44e2e9ec4c 1229 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1230 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1231 DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1232 #endif
whismanoid 0:cb44e2e9ec4c 1233 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1234 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1235 #define HAS_digitalInOut0 1
whismanoid 0:cb44e2e9ec4c 1236 #define HAS_digitalInOut1 1
whismanoid 0:cb44e2e9ec4c 1237 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1238 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1239 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1240 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1241 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1242 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1243 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1244 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1245 // #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1246 // #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1247 // #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1248 // #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1249 // #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1250 // #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1251 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1252 DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3
whismanoid 0:cb44e2e9ec4c 1253 #endif
whismanoid 0:cb44e2e9ec4c 1254 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1255 DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2
whismanoid 0:cb44e2e9ec4c 1256 #endif
whismanoid 0:cb44e2e9ec4c 1257 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1258 DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1
whismanoid 0:cb44e2e9ec4c 1259 #endif
whismanoid 0:cb44e2e9ec4c 1260 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1261 DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0
whismanoid 0:cb44e2e9ec4c 1262 #endif
whismanoid 0:cb44e2e9ec4c 1263 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1264 DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1
whismanoid 0:cb44e2e9ec4c 1265 #endif
whismanoid 0:cb44e2e9ec4c 1266 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1267 DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1
whismanoid 0:cb44e2e9ec4c 1268 #endif
whismanoid 0:cb44e2e9ec4c 1269 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1270 DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1
whismanoid 0:cb44e2e9ec4c 1271 #endif
whismanoid 0:cb44e2e9ec4c 1272 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1273 DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO
whismanoid 0:cb44e2e9ec4c 1274 #endif
whismanoid 0:cb44e2e9ec4c 1275 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1276 DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK
whismanoid 0:cb44e2e9ec4c 1277 #endif
whismanoid 0:cb44e2e9ec4c 1278 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1279 DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL
whismanoid 0:cb44e2e9ec4c 1280 #endif
whismanoid 0:cb44e2e9ec4c 1281 //
whismanoid 0:cb44e2e9ec4c 1282 // these pins support analog input analogIn0 .. analogIn5
whismanoid 0:cb44e2e9ec4c 1283 //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1284 //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1285 //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1286 //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1287 //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1288 //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1289 //
whismanoid 0:cb44e2e9ec4c 1290 // these pins support PWM pwmDriver1 .. pwmDriver6
whismanoid 0:cb44e2e9ec4c 1291 //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0
whismanoid 0:cb44e2e9ec4c 1292 //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1
whismanoid 0:cb44e2e9ec4c 1293 //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2
whismanoid 0:cb44e2e9ec4c 1294 //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3
whismanoid 0:cb44e2e9ec4c 1295 //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1
whismanoid 0:cb44e2e9ec4c 1296 //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK
whismanoid 0:cb44e2e9ec4c 1297 //
whismanoid 0:cb44e2e9ec4c 1298 // these could be additional digitalInOut pins
whismanoid 0:cb44e2e9ec4c 1299 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1300 DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1
whismanoid 0:cb44e2e9ec4c 1301 #endif
whismanoid 0:cb44e2e9ec4c 1302 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1303 DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0
whismanoid 0:cb44e2e9ec4c 1304 #endif
whismanoid 0:cb44e2e9ec4c 1305 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1306 DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1
whismanoid 0:cb44e2e9ec4c 1307 #endif
whismanoid 0:cb44e2e9ec4c 1308 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1309 DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0
whismanoid 0:cb44e2e9ec4c 1310 #endif
whismanoid 0:cb44e2e9ec4c 1311 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1312 DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1313 #endif
whismanoid 0:cb44e2e9ec4c 1314 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1315 DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1316 #endif
whismanoid 0:cb44e2e9ec4c 1317 #else
whismanoid 0:cb44e2e9ec4c 1318 // unknown target
whismanoid 0:cb44e2e9ec4c 1319 #endif
whismanoid 0:cb44e2e9ec4c 1320 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1321 #if HAS_digitalInOut0 || HAS_digitalInOut1 \
whismanoid 0:cb44e2e9ec4c 1322 || HAS_digitalInOut2 || HAS_digitalInOut3 \
whismanoid 0:cb44e2e9ec4c 1323 || HAS_digitalInOut4 || HAS_digitalInOut5 \
whismanoid 0:cb44e2e9ec4c 1324 || HAS_digitalInOut6 || HAS_digitalInOut7 \
whismanoid 0:cb44e2e9ec4c 1325 || HAS_digitalInOut8 || HAS_digitalInOut9 \
whismanoid 0:cb44e2e9ec4c 1326 || HAS_digitalInOut10 || HAS_digitalInOut11 \
whismanoid 0:cb44e2e9ec4c 1327 || HAS_digitalInOut12 || HAS_digitalInOut13 \
whismanoid 0:cb44e2e9ec4c 1328 || HAS_digitalInOut14 || HAS_digitalInOut15 \
whismanoid 0:cb44e2e9ec4c 1329 || HAS_digitalInOut16 || HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1330 #define HAS_digitalInOuts 1
whismanoid 0:cb44e2e9ec4c 1331 #else
whismanoid 0:cb44e2e9ec4c 1332 #warning "Note: There are no digitalInOut resources defined"
whismanoid 0:cb44e2e9ec4c 1333 #endif
whismanoid 0:cb44e2e9ec4c 1334
whismanoid 0:cb44e2e9ec4c 1335 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 1336 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1337 // Declare the AnalogIn driver
whismanoid 0:cb44e2e9ec4c 1338 // Optional analogIn support. If there is only one it should be analogIn1.
whismanoid 0:cb44e2e9ec4c 1339 // A) analog input
whismanoid 0:cb44e2e9ec4c 1340 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1341 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1342 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1343 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1344 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1345 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1346 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1347 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1348 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1349 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1350 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1351 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1352 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1353 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1354 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1355 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1356 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1357 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1358 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1359 #endif
whismanoid 0:cb44e2e9ec4c 1360 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1361 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1362 #endif
whismanoid 0:cb44e2e9ec4c 1363 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1364 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1365 #endif
whismanoid 0:cb44e2e9ec4c 1366 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1367 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1368 #endif
whismanoid 0:cb44e2e9ec4c 1369 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1370 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1371 #endif
whismanoid 0:cb44e2e9ec4c 1372 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1373 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1374 #endif
whismanoid 0:cb44e2e9ec4c 1375 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1376 AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1377 #endif
whismanoid 0:cb44e2e9ec4c 1378 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1379 AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1380 #endif
whismanoid 0:cb44e2e9ec4c 1381 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1382 AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1383 #endif
whismanoid 0:cb44e2e9ec4c 1384 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1385 AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1386 #endif
whismanoid 0:cb44e2e9ec4c 1387 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1388 AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1389 #endif
whismanoid 0:cb44e2e9ec4c 1390 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1391 AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1392 #endif
whismanoid 0:cb44e2e9ec4c 1393 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1394 AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1395 #endif
whismanoid 0:cb44e2e9ec4c 1396 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1397 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1398 #endif
whismanoid 0:cb44e2e9ec4c 1399 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1400 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1401 #endif
whismanoid 0:cb44e2e9ec4c 1402 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1403 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1404 #endif
whismanoid 0:cb44e2e9ec4c 1405 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1406 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 1407 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1408 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1409 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1410 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1411 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1412 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1413 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1414 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1415 #endif
whismanoid 0:cb44e2e9ec4c 1416 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1417 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1418 #endif
whismanoid 0:cb44e2e9ec4c 1419 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1420 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1421 #endif
whismanoid 0:cb44e2e9ec4c 1422 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1423 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1424 #endif
whismanoid 0:cb44e2e9ec4c 1425 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1426 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1427 #endif
whismanoid 0:cb44e2e9ec4c 1428 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1429 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1430 #endif
whismanoid 0:cb44e2e9ec4c 1431 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1432 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 1433 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1434 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1435 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1436 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1437 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1438 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1439 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1440 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1441 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1442 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1443 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1444 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1445 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1446 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1447 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1448 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1449 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1450 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1451 AnalogIn analogIn0(AIN_0); // TARGET_MAX32620FTHR J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1452 #endif
whismanoid 0:cb44e2e9ec4c 1453 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1454 AnalogIn analogIn1(AIN_1); // TARGET_MAX32620FTHR J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1455 #endif
whismanoid 0:cb44e2e9ec4c 1456 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1457 AnalogIn analogIn2(AIN_2); // TARGET_MAX32620FTHR J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1458 #endif
whismanoid 0:cb44e2e9ec4c 1459 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1460 AnalogIn analogIn3(AIN_3); // TARGET_MAX32620FTHR J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1461 #endif
whismanoid 0:cb44e2e9ec4c 1462 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1463 AnalogIn analogIn4(AIN_4); // TARGET_MAX32620FTHR J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1464 #endif
whismanoid 0:cb44e2e9ec4c 1465 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1466 AnalogIn analogIn5(AIN_5); // TARGET_MAX32620FTHR J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1467 #endif
whismanoid 0:cb44e2e9ec4c 1468 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1469 AnalogIn analogIn6(AIN_6); // TARGET_MAX32620FTHR AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1470 #endif
whismanoid 0:cb44e2e9ec4c 1471 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1472 AnalogIn analogIn7(AIN_7); // TARGET_MAX32620FTHR AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1473 #endif
whismanoid 0:cb44e2e9ec4c 1474 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1475 AnalogIn analogIn8(AIN_8); // TARGET_MAX32620FTHR AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1476 #endif
whismanoid 0:cb44e2e9ec4c 1477 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1478 AnalogIn analogIn9(AIN_9); // TARGET_MAX32620FTHR AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1479 #endif
whismanoid 0:cb44e2e9ec4c 1480 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1481 AnalogIn analogIn10(____); // TARGET_MAX32620FTHR AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1482 #endif
whismanoid 0:cb44e2e9ec4c 1483 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1484 AnalogIn analogIn11(____); // TARGET_MAX32620FTHR AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1485 #endif
whismanoid 0:cb44e2e9ec4c 1486 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1487 AnalogIn analogIn12(____); // TARGET_MAX32620FTHR AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1488 #endif
whismanoid 0:cb44e2e9ec4c 1489 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1490 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1491 #endif
whismanoid 0:cb44e2e9ec4c 1492 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1493 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1494 #endif
whismanoid 0:cb44e2e9ec4c 1495 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1496 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1497 #endif
whismanoid 0:cb44e2e9ec4c 1498 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 1499 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 37:3f369235e5bc 1500 // #warning "TARGET_MAX32625PICO not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1501 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1502 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1503 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1504 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1505 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1506 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1507 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1508 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1509 #endif
whismanoid 0:cb44e2e9ec4c 1510 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1511 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1512 #endif
whismanoid 0:cb44e2e9ec4c 1513 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1514 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1515 #endif
whismanoid 0:cb44e2e9ec4c 1516 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1517 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1518 #endif
whismanoid 0:cb44e2e9ec4c 1519 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1520 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1521 #endif
whismanoid 0:cb44e2e9ec4c 1522 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1523 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1524 #endif
whismanoid 0:cb44e2e9ec4c 1525 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1526 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 1527 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1528 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1529 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1530 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1531 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1532 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1533 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1534 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1535 #endif
whismanoid 0:cb44e2e9ec4c 1536 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1537 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1538 #endif
whismanoid 0:cb44e2e9ec4c 1539 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1540 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1541 #endif
whismanoid 0:cb44e2e9ec4c 1542 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1543 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1544 #endif
whismanoid 0:cb44e2e9ec4c 1545 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1546 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1547 #endif
whismanoid 0:cb44e2e9ec4c 1548 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1549 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1550 #endif
whismanoid 0:cb44e2e9ec4c 1551 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1552 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 1553 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1554 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1555 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1556 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1557 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1558 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1559 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1560 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1561 #endif
whismanoid 0:cb44e2e9ec4c 1562 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1563 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1564 #endif
whismanoid 0:cb44e2e9ec4c 1565 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1566 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1567 #endif
whismanoid 0:cb44e2e9ec4c 1568 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1569 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1570 #endif
whismanoid 0:cb44e2e9ec4c 1571 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1572 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1573 #endif
whismanoid 0:cb44e2e9ec4c 1574 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1575 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1576 #endif
whismanoid 0:cb44e2e9ec4c 1577 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1578 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1579 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1580 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1581 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1582 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1583 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1584 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1585 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1586 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1587 #endif
whismanoid 0:cb44e2e9ec4c 1588 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1589 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1590 #endif
whismanoid 0:cb44e2e9ec4c 1591 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1592 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1593 #endif
whismanoid 0:cb44e2e9ec4c 1594 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1595 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1596 #endif
whismanoid 0:cb44e2e9ec4c 1597 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1598 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1599 #endif
whismanoid 0:cb44e2e9ec4c 1600 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1601 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1602 #endif
whismanoid 0:cb44e2e9ec4c 1603 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1604 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 1605 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1606 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1607 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1608 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1609 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1610 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1611 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1612 // #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1613 // #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1614 // #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1615 // #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1616 // #define HAS_analogIn10 1
whismanoid 0:cb44e2e9ec4c 1617 // #define HAS_analogIn11 1
whismanoid 0:cb44e2e9ec4c 1618 // #define HAS_analogIn12 1
whismanoid 0:cb44e2e9ec4c 1619 // #define HAS_analogIn13 1
whismanoid 0:cb44e2e9ec4c 1620 // #define HAS_analogIn14 1
whismanoid 0:cb44e2e9ec4c 1621 // #define HAS_analogIn15 1
whismanoid 0:cb44e2e9ec4c 1622 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1623 AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1624 #endif
whismanoid 0:cb44e2e9ec4c 1625 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1626 AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1627 #endif
whismanoid 0:cb44e2e9ec4c 1628 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1629 AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1630 #endif
whismanoid 0:cb44e2e9ec4c 1631 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1632 AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1633 #endif
whismanoid 0:cb44e2e9ec4c 1634 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1635 AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1636 #endif
whismanoid 0:cb44e2e9ec4c 1637 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1638 AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1639 #endif
whismanoid 0:cb44e2e9ec4c 1640 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1641 AnalogIn analogIn6(____);
whismanoid 0:cb44e2e9ec4c 1642 #endif
whismanoid 0:cb44e2e9ec4c 1643 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1644 AnalogIn analogIn7(____);
whismanoid 0:cb44e2e9ec4c 1645 #endif
whismanoid 0:cb44e2e9ec4c 1646 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1647 AnalogIn analogIn8(____);
whismanoid 0:cb44e2e9ec4c 1648 #endif
whismanoid 0:cb44e2e9ec4c 1649 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1650 AnalogIn analogIn9(____);
whismanoid 0:cb44e2e9ec4c 1651 #endif
whismanoid 0:cb44e2e9ec4c 1652 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1653 AnalogIn analogIn10(____);
whismanoid 0:cb44e2e9ec4c 1654 #endif
whismanoid 0:cb44e2e9ec4c 1655 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1656 AnalogIn analogIn11(____);
whismanoid 0:cb44e2e9ec4c 1657 #endif
whismanoid 0:cb44e2e9ec4c 1658 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1659 AnalogIn analogIn12(____);
whismanoid 0:cb44e2e9ec4c 1660 #endif
whismanoid 0:cb44e2e9ec4c 1661 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1662 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1663 #endif
whismanoid 0:cb44e2e9ec4c 1664 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1665 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1666 #endif
whismanoid 0:cb44e2e9ec4c 1667 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1668 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1669 #endif
whismanoid 0:cb44e2e9ec4c 1670 #else
whismanoid 0:cb44e2e9ec4c 1671 // unknown target
whismanoid 0:cb44e2e9ec4c 1672 #endif
whismanoid 0:cb44e2e9ec4c 1673 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1674 #if HAS_analogIn0 || HAS_analogIn1 \
whismanoid 0:cb44e2e9ec4c 1675 || HAS_analogIn2 || HAS_analogIn3 \
whismanoid 0:cb44e2e9ec4c 1676 || HAS_analogIn4 || HAS_analogIn5 \
whismanoid 0:cb44e2e9ec4c 1677 || HAS_analogIn6 || HAS_analogIn7 \
whismanoid 0:cb44e2e9ec4c 1678 || HAS_analogIn8 || HAS_analogIn9 \
whismanoid 0:cb44e2e9ec4c 1679 || HAS_analogIn10 || HAS_analogIn11 \
whismanoid 0:cb44e2e9ec4c 1680 || HAS_analogIn12 || HAS_analogIn13 \
whismanoid 0:cb44e2e9ec4c 1681 || HAS_analogIn14 || HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1682 #define HAS_analogIns 1
whismanoid 0:cb44e2e9ec4c 1683 #else
whismanoid 0:cb44e2e9ec4c 1684 #warning "Note: There are no analogIn resources defined"
whismanoid 0:cb44e2e9ec4c 1685 #endif
whismanoid 0:cb44e2e9ec4c 1686
whismanoid 0:cb44e2e9ec4c 1687 // DigitalInOut pin resource: print the pin index names to serial
whismanoid 0:cb44e2e9ec4c 1688 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 1689 void list_digitalInOutPins(Stream& serialStream)
whismanoid 0:cb44e2e9ec4c 1690 {
whismanoid 0:cb44e2e9ec4c 1691 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1692 serialStream.printf(" 0");
whismanoid 0:cb44e2e9ec4c 1693 #endif
whismanoid 0:cb44e2e9ec4c 1694 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1695 serialStream.printf(" 1");
whismanoid 0:cb44e2e9ec4c 1696 #endif
whismanoid 0:cb44e2e9ec4c 1697 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1698 serialStream.printf(" 2");
whismanoid 0:cb44e2e9ec4c 1699 #endif
whismanoid 0:cb44e2e9ec4c 1700 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1701 serialStream.printf(" 3");
whismanoid 0:cb44e2e9ec4c 1702 #endif
whismanoid 0:cb44e2e9ec4c 1703 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1704 serialStream.printf(" 4");
whismanoid 0:cb44e2e9ec4c 1705 #endif
whismanoid 0:cb44e2e9ec4c 1706 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1707 serialStream.printf(" 5");
whismanoid 0:cb44e2e9ec4c 1708 #endif
whismanoid 0:cb44e2e9ec4c 1709 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1710 serialStream.printf(" 6");
whismanoid 0:cb44e2e9ec4c 1711 #endif
whismanoid 0:cb44e2e9ec4c 1712 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1713 serialStream.printf(" 7");
whismanoid 0:cb44e2e9ec4c 1714 #endif
whismanoid 0:cb44e2e9ec4c 1715 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1716 serialStream.printf(" 8");
whismanoid 0:cb44e2e9ec4c 1717 #endif
whismanoid 0:cb44e2e9ec4c 1718 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1719 serialStream.printf(" 9");
whismanoid 0:cb44e2e9ec4c 1720 #endif
whismanoid 0:cb44e2e9ec4c 1721 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1722 serialStream.printf(" 10");
whismanoid 0:cb44e2e9ec4c 1723 #endif
whismanoid 0:cb44e2e9ec4c 1724 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1725 serialStream.printf(" 11");
whismanoid 0:cb44e2e9ec4c 1726 #endif
whismanoid 0:cb44e2e9ec4c 1727 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1728 serialStream.printf(" 12");
whismanoid 0:cb44e2e9ec4c 1729 #endif
whismanoid 0:cb44e2e9ec4c 1730 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1731 serialStream.printf(" 13");
whismanoid 0:cb44e2e9ec4c 1732 #endif
whismanoid 0:cb44e2e9ec4c 1733 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1734 serialStream.printf(" 14");
whismanoid 0:cb44e2e9ec4c 1735 #endif
whismanoid 0:cb44e2e9ec4c 1736 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1737 serialStream.printf(" 15");
whismanoid 0:cb44e2e9ec4c 1738 #endif
whismanoid 0:cb44e2e9ec4c 1739 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1740 serialStream.printf(" 16");
whismanoid 0:cb44e2e9ec4c 1741 #endif
whismanoid 0:cb44e2e9ec4c 1742 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1743 serialStream.printf(" 17");
whismanoid 0:cb44e2e9ec4c 1744 #endif
whismanoid 18:1235c17b451e 1745 #if USE_LEDS
whismanoid 18:1235c17b451e 1746 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 1747 // support list_digitalInOutPins() listing buttons and leds as pin numbers 90/91/92/93
whismanoid 18:1235c17b451e 1748 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 1749 //~ serialStream.printf(" 90");
whismanoid 18:1235c17b451e 1750 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 1751 serialStream.printf(" 91");
whismanoid 18:1235c17b451e 1752 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 1753 serialStream.printf(" 92");
whismanoid 18:1235c17b451e 1754 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 1755 serialStream.printf(" 93");
whismanoid 18:1235c17b451e 1756 #else // USE_LEDS
whismanoid 18:1235c17b451e 1757 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 1758 }
whismanoid 0:cb44e2e9ec4c 1759 #endif
whismanoid 0:cb44e2e9ec4c 1760
whismanoid 0:cb44e2e9ec4c 1761
whismanoid 0:cb44e2e9ec4c 1762 // DigitalInOut pin resource: search index
whismanoid 0:cb44e2e9ec4c 1763 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 1764 DigitalInOut& find_digitalInOutPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 1765 {
whismanoid 0:cb44e2e9ec4c 1766 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 1767 {
whismanoid 0:cb44e2e9ec4c 1768 default: // default to the first defined digitalInOut pin
whismanoid 0:cb44e2e9ec4c 1769 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1770 case '0': case 0x00: return digitalInOut0;
whismanoid 0:cb44e2e9ec4c 1771 #endif
whismanoid 0:cb44e2e9ec4c 1772 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1773 case '1': case 0x01: return digitalInOut1;
whismanoid 0:cb44e2e9ec4c 1774 #endif
whismanoid 0:cb44e2e9ec4c 1775 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1776 case '2': case 0x02: return digitalInOut2;
whismanoid 0:cb44e2e9ec4c 1777 #endif
whismanoid 0:cb44e2e9ec4c 1778 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1779 case '3': case 0x03: return digitalInOut3;
whismanoid 0:cb44e2e9ec4c 1780 #endif
whismanoid 0:cb44e2e9ec4c 1781 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1782 case '4': case 0x04: return digitalInOut4;
whismanoid 0:cb44e2e9ec4c 1783 #endif
whismanoid 0:cb44e2e9ec4c 1784 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1785 case '5': case 0x05: return digitalInOut5;
whismanoid 0:cb44e2e9ec4c 1786 #endif
whismanoid 0:cb44e2e9ec4c 1787 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1788 case '6': case 0x06: return digitalInOut6;
whismanoid 0:cb44e2e9ec4c 1789 #endif
whismanoid 0:cb44e2e9ec4c 1790 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1791 case '7': case 0x07: return digitalInOut7;
whismanoid 0:cb44e2e9ec4c 1792 #endif
whismanoid 0:cb44e2e9ec4c 1793 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1794 case '8': case 0x08: return digitalInOut8;
whismanoid 0:cb44e2e9ec4c 1795 #endif
whismanoid 0:cb44e2e9ec4c 1796 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1797 case '9': case 0x09: return digitalInOut9;
whismanoid 0:cb44e2e9ec4c 1798 #endif
whismanoid 0:cb44e2e9ec4c 1799 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1800 case 'a': case 0x0a: return digitalInOut10;
whismanoid 0:cb44e2e9ec4c 1801 #endif
whismanoid 0:cb44e2e9ec4c 1802 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1803 case 'b': case 0x0b: return digitalInOut11;
whismanoid 0:cb44e2e9ec4c 1804 #endif
whismanoid 0:cb44e2e9ec4c 1805 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1806 case 'c': case 0x0c: return digitalInOut12;
whismanoid 0:cb44e2e9ec4c 1807 #endif
whismanoid 0:cb44e2e9ec4c 1808 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1809 case 'd': case 0x0d: return digitalInOut13;
whismanoid 0:cb44e2e9ec4c 1810 #endif
whismanoid 0:cb44e2e9ec4c 1811 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1812 case 'e': case 0x0e: return digitalInOut14;
whismanoid 0:cb44e2e9ec4c 1813 #endif
whismanoid 0:cb44e2e9ec4c 1814 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1815 case 'f': case 0x0f: return digitalInOut15;
whismanoid 0:cb44e2e9ec4c 1816 #endif
whismanoid 0:cb44e2e9ec4c 1817 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1818 case 'g': case 0x10: return digitalInOut16;
whismanoid 0:cb44e2e9ec4c 1819 #endif
whismanoid 0:cb44e2e9ec4c 1820 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1821 case 'h': case 0x11: return digitalInOut17;
whismanoid 0:cb44e2e9ec4c 1822 #endif
whismanoid 18:1235c17b451e 1823 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 1824 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 1825 //~ case 90: return button1;
whismanoid 18:1235c17b451e 1826 #if USE_LEDS
whismanoid 18:1235c17b451e 1827 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 1828 case 91: return led1_RFailLED;
whismanoid 18:1235c17b451e 1829 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 1830 case 92: return led2_GPassLED;
whismanoid 18:1235c17b451e 1831 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 1832 case 93: return led3_BBusyLED;
whismanoid 18:1235c17b451e 1833 #else // USE_LEDS
whismanoid 18:1235c17b451e 1834 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 1835 }
whismanoid 0:cb44e2e9ec4c 1836 }
whismanoid 0:cb44e2e9ec4c 1837 #endif
whismanoid 0:cb44e2e9ec4c 1838
whismanoid 0:cb44e2e9ec4c 1839
whismanoid 0:cb44e2e9ec4c 1840 // AnalogIn pin resource: search index
whismanoid 0:cb44e2e9ec4c 1841 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 1842 AnalogIn& find_analogInPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 1843 {
whismanoid 0:cb44e2e9ec4c 1844 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 1845 {
whismanoid 0:cb44e2e9ec4c 1846 default: // default to the first defined analogIn pin
whismanoid 0:cb44e2e9ec4c 1847 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1848 case '0': case 0x00: return analogIn0;
whismanoid 0:cb44e2e9ec4c 1849 #endif
whismanoid 0:cb44e2e9ec4c 1850 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1851 case '1': case 0x01: return analogIn1;
whismanoid 0:cb44e2e9ec4c 1852 #endif
whismanoid 0:cb44e2e9ec4c 1853 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1854 case '2': case 0x02: return analogIn2;
whismanoid 0:cb44e2e9ec4c 1855 #endif
whismanoid 0:cb44e2e9ec4c 1856 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1857 case '3': case 0x03: return analogIn3;
whismanoid 0:cb44e2e9ec4c 1858 #endif
whismanoid 0:cb44e2e9ec4c 1859 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1860 case '4': case 0x04: return analogIn4;
whismanoid 0:cb44e2e9ec4c 1861 #endif
whismanoid 0:cb44e2e9ec4c 1862 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1863 case '5': case 0x05: return analogIn5;
whismanoid 0:cb44e2e9ec4c 1864 #endif
whismanoid 0:cb44e2e9ec4c 1865 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1866 case '6': case 0x06: return analogIn6;
whismanoid 0:cb44e2e9ec4c 1867 #endif
whismanoid 0:cb44e2e9ec4c 1868 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1869 case '7': case 0x07: return analogIn7;
whismanoid 0:cb44e2e9ec4c 1870 #endif
whismanoid 0:cb44e2e9ec4c 1871 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1872 case '8': case 0x08: return analogIn8;
whismanoid 0:cb44e2e9ec4c 1873 #endif
whismanoid 0:cb44e2e9ec4c 1874 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1875 case '9': case 0x09: return analogIn9;
whismanoid 0:cb44e2e9ec4c 1876 #endif
whismanoid 0:cb44e2e9ec4c 1877 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1878 case 'a': case 0x0a: return analogIn10;
whismanoid 0:cb44e2e9ec4c 1879 #endif
whismanoid 0:cb44e2e9ec4c 1880 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1881 case 'b': case 0x0b: return analogIn11;
whismanoid 0:cb44e2e9ec4c 1882 #endif
whismanoid 0:cb44e2e9ec4c 1883 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1884 case 'c': case 0x0c: return analogIn12;
whismanoid 0:cb44e2e9ec4c 1885 #endif
whismanoid 0:cb44e2e9ec4c 1886 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1887 case 'd': case 0x0d: return analogIn13;
whismanoid 0:cb44e2e9ec4c 1888 #endif
whismanoid 0:cb44e2e9ec4c 1889 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1890 case 'e': case 0x0e: return analogIn14;
whismanoid 0:cb44e2e9ec4c 1891 #endif
whismanoid 0:cb44e2e9ec4c 1892 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1893 case 'f': case 0x0f: return analogIn15;
whismanoid 0:cb44e2e9ec4c 1894 #endif
whismanoid 0:cb44e2e9ec4c 1895 }
whismanoid 0:cb44e2e9ec4c 1896 }
whismanoid 0:cb44e2e9ec4c 1897 #endif
whismanoid 0:cb44e2e9ec4c 1898
whismanoid 0:cb44e2e9ec4c 1899 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 1900 const float analogInPin_fullScaleVoltage[] = {
whismanoid 0:cb44e2e9ec4c 1901 # if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1902 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1903 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1904 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1905 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1906 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1907 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1908 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1909 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1910 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1911 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1912 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1913 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1914 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1915 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1916 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1917 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1918 # elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 1919 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1920 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1921 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1922 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1923 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1924 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1925 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1926 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1927 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1928 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1929 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1930 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1931 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1932 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1933 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1934 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1935 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 19:5ff09c8e9daf 1936 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 1937 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1938 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1939 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1940 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1941 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1942 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1943 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1944 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1945 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1946 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1947 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1948 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1949 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1950 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1951 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1952 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1953 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 1954 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1955 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1956 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1957 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1958 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1959 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1960 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1961 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1962 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1963 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 1964 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 1965 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 1966 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 1967 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1968 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1969 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1970 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1971 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1972 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1973 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1974 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1975 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1976 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1977 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1978 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1979 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1980 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 1981 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 1982 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 1983 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 1984 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1985 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1986 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1987 //#elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1988 #else
whismanoid 0:cb44e2e9ec4c 1989 // unknown target
whismanoid 0:cb44e2e9ec4c 1990 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1991 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1992 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1993 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1994 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1995 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1996 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1997 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1998 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1999 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 2000 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 2001 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 2002 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 2003 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2004 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2005 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2006 # endif
whismanoid 0:cb44e2e9ec4c 2007 };
whismanoid 0:cb44e2e9ec4c 2008 #endif
whismanoid 0:cb44e2e9ec4c 2009
whismanoid 0:cb44e2e9ec4c 2010
whismanoid 0:cb44e2e9ec4c 2011
whismanoid 0:cb44e2e9ec4c 2012
whismanoid 0:cb44e2e9ec4c 2013 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2014 // TODO support CmdLine command menus (like on Serial_Tester)
whismanoid 4:d9b05924ad4c 2015 #ifndef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 2016 #define USE_CMDLINE_MENUS 1
whismanoid 4:d9b05924ad4c 2017 //~ #undef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 2018 #endif
whismanoid 4:d9b05924ad4c 2019 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2020 #include "CmdLine.h"
whismanoid 4:d9b05924ad4c 2021 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2022 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2023 extern CmdLine cmdLine; // declared later
whismanoid 4:d9b05924ad4c 2024 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2025
whismanoid 4:d9b05924ad4c 2026 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2027 // Datalog trigger types
whismanoid 4:d9b05924ad4c 2028 #ifndef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 2029 #define USE_DATALOGGER_TRIGGER 1
whismanoid 4:d9b05924ad4c 2030 //~ #undef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 2031 #endif
whismanoid 4:d9b05924ad4c 2032 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 2033 typedef enum Datalogger_Trigger_enum_t {
whismanoid 4:d9b05924ad4c 2034 trigger_Halt = 0, //!< halt
whismanoid 4:d9b05924ad4c 2035 trigger_FreeRun = 1, //!< free run as fast as possible
whismanoid 4:d9b05924ad4c 2036 trigger_Timer = 2, //!< timer (configure interval)
whismanoid 4:d9b05924ad4c 2037 trigger_PlatformDigitalInput, //!< platform digital input (configure digital input pin reference)
whismanoid 4:d9b05924ad4c 2038 trigger_SPIDeviceRegRead, //!< SPI device register read (configure regaddr, mask value, match value)
whismanoid 4:d9b05924ad4c 2039 } Datalogger_Trigger_enum_t;
whismanoid 4:d9b05924ad4c 2040 Datalogger_Trigger_enum_t Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 2041 //
whismanoid 17:9397ea3ea7e9 2042 // configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 2043 int g_timer_interval_msec = 500; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2044 int g_timer_interval_count = 10; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2045 int g_timer_interval_counter = 0; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2046 //
whismanoid 17:9397ea3ea7e9 2047 // TODO: configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 2048 //
whismanoid 17:9397ea3ea7e9 2049 // TODO: configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2050 //
whismanoid 4:d9b05924ad4c 2051 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 2052
whismanoid 4:d9b05924ad4c 2053 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2054 // support trigger_SPIDeviceRegRead: Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 2055 #ifndef USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2056 #define USE_DATALOGGER_SPIDeviceRegRead 0
whismanoid 17:9397ea3ea7e9 2057 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2058 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2059 // TODO: uint16_t regAddr;
whismanoid 17:9397ea3ea7e9 2060 // TODO: uint16_t regDataMask;
whismanoid 17:9397ea3ea7e9 2061 // TODO: uint16_t regDataTest;
whismanoid 17:9397ea3ea7e9 2062 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2063
whismanoid 17:9397ea3ea7e9 2064 //--------------------------------------------------
whismanoid 30:07197a430869 2065 // support Datalogger_PrintRow() print gstrRemarkText field from recent #remark
whismanoid 30:07197a430869 2066 #ifndef USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2067 #define USE_DATALOGGER_REMARK_FIELD 1
whismanoid 30:07197a430869 2068 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2069 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2070 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark
whismanoid 30:07197a430869 2071 const size_t gstrRemarkTextLASTINDEX = 40; // gstrRemarkText buffer size - 1
whismanoid 30:07197a430869 2072 char gstrRemarkText[gstrRemarkTextLASTINDEX+1] = "";
whismanoid 30:07197a430869 2073 char gstrRemarkHeader[] = "comment"; // comment or remark?
whismanoid 30:07197a430869 2074 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2075
whismanoid 30:07197a430869 2076 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2077 // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2078 #ifndef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2079 #define USE_DATALOGGER_ActionTable 1
whismanoid 17:9397ea3ea7e9 2080 //~ #undef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2081 #endif
whismanoid 17:9397ea3ea7e9 2082 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2083 //
whismanoid 17:9397ea3ea7e9 2084 // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2085 typedef enum action_type_enum_t {
whismanoid 17:9397ea3ea7e9 2086 action_noop = 0, // no operation
whismanoid 30:07197a430869 2087 action_digitalOutLow = 1, // pin = low if condition
whismanoid 30:07197a430869 2088 action_digitalOutHigh = 2, // pin = high if condition
whismanoid 30:07197a430869 2089 action_button = 3, // pin = button event index 1, 2, 3
whismanoid 30:07197a430869 2090 action_trigger_Halt = 4,
whismanoid 30:07197a430869 2091 action_trigger_FreeRun = 5,
whismanoid 30:07197a430869 2092 action_trigger_Timer = 6,
whismanoid 30:07197a430869 2093 action_trigger_PlatformDigitalInput = 7,
whismanoid 30:07197a430869 2094 action_trigger_SPIDeviceRegRead = 8,
whismanoid 17:9397ea3ea7e9 2095 } action_type_enum_t;
whismanoid 17:9397ea3ea7e9 2096 //
whismanoid 17:9397ea3ea7e9 2097 // Datalogger_RunActionTable() supported conditions
whismanoid 17:9397ea3ea7e9 2098 typedef enum action_condition_enum_t {
whismanoid 17:9397ea3ea7e9 2099 condition_always = 0, // ( true )
whismanoid 17:9397ea3ea7e9 2100 condition_if_An_gt_threshold, // (Platform_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2101 condition_if_An_lt_threshold, // (Platform_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2102 condition_if_An_eq_threshold, // (Platform_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2103 condition_if_An_ge_threshold, // (Platform_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2104 condition_if_An_le_threshold, // (Platform_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2105 condition_if_An_ne_threshold, // (Platform_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2106 condition_if_AINn_gt_threshold, // (SPI_AIN_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2107 condition_if_AINn_lt_threshold, // (SPI_AIN_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2108 condition_if_AINn_eq_threshold, // (SPI_AIN_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2109 condition_if_AINn_ge_threshold, // (SPI_AIN_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2110 condition_if_AINn_le_threshold, // (SPI_AIN_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2111 condition_if_AINn_ne_threshold, // (SPI_AIN_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2112 } condition_enum_t;
whismanoid 17:9397ea3ea7e9 2113 //
whismanoid 17:9397ea3ea7e9 2114 // Datalogger_RunActionTable() structure
whismanoid 17:9397ea3ea7e9 2115 typedef struct action_table_row_t {
whismanoid 17:9397ea3ea7e9 2116 action_type_enum_t action;
whismanoid 17:9397ea3ea7e9 2117 int digitalOutPin;
whismanoid 17:9397ea3ea7e9 2118 action_condition_enum_t condition;
whismanoid 17:9397ea3ea7e9 2119 int condition_channel;
whismanoid 17:9397ea3ea7e9 2120 double condition_threshold;
whismanoid 17:9397ea3ea7e9 2121 } action_table_row_t;
whismanoid 17:9397ea3ea7e9 2122 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2123 const int channel_WE = 2;
whismanoid 17:9397ea3ea7e9 2124 const double threshold_WE_0V5 = 0.5;
whismanoid 17:9397ea3ea7e9 2125 const double threshold_WE_0V6 = 0.6;
whismanoid 17:9397ea3ea7e9 2126 const double threshold_WE_0V7 = 0.7;
whismanoid 18:1235c17b451e 2127 const int pin_LED_1 = 91; // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 2128 const int pin_LED_2 = 92; // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 2129 const int pin_LED_3 = 93; // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 17:9397ea3ea7e9 2130 #endif
whismanoid 17:9397ea3ea7e9 2131 const int ACTION_TABLE_ROW_MAX = 20;
whismanoid 17:9397ea3ea7e9 2132 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2133 bool Datalogger_action_table_enabled = true;
whismanoid 30:07197a430869 2134 int Datalogger_action_table_row_count = 8; // assert (Datalogger_action_table_row_count <= ACTION_TABLE_ROW_MAX)
whismanoid 17:9397ea3ea7e9 2135 #else // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2136 int Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 2137 #endif // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2138 action_table_row_t Datalogger_action_table[ACTION_TABLE_ROW_MAX] = {
whismanoid 17:9397ea3ea7e9 2139 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2140 // LED indicator show (WE > 0.5V)
whismanoid 18:1235c17b451e 2141 // L@0 act=1 pin=92 if=1 ch=2 x=0.500000 -- digitalOutLow D92 if A2 > 0.500000
whismanoid 18:1235c17b451e 2142 {action_digitalOutLow, pin_LED_2, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V5},
whismanoid 17:9397ea3ea7e9 2143 //
whismanoid 17:9397ea3ea7e9 2144 // LED indicator show (WE > 0.6V)
whismanoid 18:1235c17b451e 2145 // L@1 act=1 pin=93 if=1 ch=2 x=0.600000 -- digitalOutLow D93 if A2 > 0.600000
whismanoid 18:1235c17b451e 2146 {action_digitalOutLow, pin_LED_3, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 17:9397ea3ea7e9 2147 //
whismanoid 17:9397ea3ea7e9 2148 // switch to always-on mode `trigger_FreeRun` if (WE > 0.7V)
whismanoid 29:6a9edb6e973b 2149 // L@2 act=5 if=1 ch=2 x=0.700000 -- trigger_FreeRun if A2 > 0.700000
whismanoid 17:9397ea3ea7e9 2150 {action_trigger_FreeRun, 0, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 17:9397ea3ea7e9 2151 //
whismanoid 17:9397ea3ea7e9 2152 // switch to intermittent-sleep-mode `trigger_Timer` if (WE < 0.6V)
whismanoid 29:6a9edb6e973b 2153 // L@3 act=6 if=2 ch=2 x=0.600000 -- trigger_Timer(10 x 500msec) if A2 < 0.600000
whismanoid 17:9397ea3ea7e9 2154 {action_trigger_Timer, 0, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 18:1235c17b451e 2155 //
whismanoid 18:1235c17b451e 2156 // LED indicator show (`Datalogger_Trigger` == `trigger_FreeRun`)
whismanoid 18:1235c17b451e 2157 // {action_noop, 0, condition_always, 0, 0},
whismanoid 18:1235c17b451e 2158 // L@4 act=1 pin=91 if=1 ch=2 x=0.700000 -- digitalOutLow D91 if A2 > 0.700000
whismanoid 18:1235c17b451e 2159 {action_digitalOutLow, pin_LED_1, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 18:1235c17b451e 2160 //
whismanoid 18:1235c17b451e 2161 // L@5 act=2 pin=91 if=2 ch=2 x=0.600000 -- digitalOutHigh D91 if A2 < 0.600000
whismanoid 18:1235c17b451e 2162 {action_digitalOutHigh, pin_LED_1, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 18:1235c17b451e 2163 //
whismanoid 30:07197a430869 2164 // L@6 act=3 pin=4 if=1 ch=2 x=0.700000 -- button 4 event if A2 > 0.700000
whismanoid 30:07197a430869 2165 {action_button, 4, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 29:6a9edb6e973b 2166 //
whismanoid 30:07197a430869 2167 // L@7 act=3 pin=5 if=2 ch=2 x=0.600000 -- button 5 event if A2 < 0.600000
whismanoid 30:07197a430869 2168 {action_button, 5, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 29:6a9edb6e973b 2169 //
whismanoid 17:9397ea3ea7e9 2170 #endif // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2171 //
whismanoid 17:9397ea3ea7e9 2172 {action_noop, 0, condition_always, 0, 0},
whismanoid 17:9397ea3ea7e9 2173 };
whismanoid 17:9397ea3ea7e9 2174 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2175
whismanoid 17:9397ea3ea7e9 2176 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2177 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 2178 uint8_t Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 2179 uint8_t need_reinit = true;
whismanoid 8:dffee7509bfb 2180 void Datalogger_PrintHeader(CmdLine& cmdLine);
whismanoid 5:aaf8b5f5fda1 2181 void Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 2182 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2183 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 2184 void Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 2185 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 8:dffee7509bfb 2186 void Datalogger_PrintRow(CmdLine& cmdLine);
whismanoid 4:d9b05924ad4c 2187
whismanoid 4:d9b05924ad4c 2188 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 2189 // Option to validate SPI link by reading PART_ID register
whismanoid 0:cb44e2e9ec4c 2190 #ifndef VERIFY_PART_ID_IN_LOOP
whismanoid 3:9055e17e181a 2191 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 2192 #define VERIFY_PART_ID_IN_LOOP 1
whismanoid 3:9055e17e181a 2193 #else
whismanoid 0:cb44e2e9ec4c 2194 #define VERIFY_PART_ID_IN_LOOP 0
whismanoid 3:9055e17e181a 2195 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2196 #endif
whismanoid 0:cb44e2e9ec4c 2197
whismanoid 3:9055e17e181a 2198 //--------------------------------------------------
whismanoid 3:9055e17e181a 2199 #define NUM_DUT_ANALOG_IN_CHANNELS 10
whismanoid 3:9055e17e181a 2200
whismanoid 3:9055e17e181a 2201 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 2202 // MAX11410 individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 3:9055e17e181a 2203 typedef enum SPI_AIN_Enable_t {
whismanoid 10:04022a61b527 2204 SPI_AIN_Disable = 0,
whismanoid 10:04022a61b527 2205 SPI_AIN_Enable_LSB = 1,
whismanoid 10:04022a61b527 2206 SPI_AIN_Enable_Volt = 2,
whismanoid 3:9055e17e181a 2207 } SPI_AIN_Enable_t;
whismanoid 3:9055e17e181a 2208 uint8_t SPI_AIN_Enable_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 2209 SPI_AIN_Enable_LSB, // AIN0 1=LSB
whismanoid 10:04022a61b527 2210 SPI_AIN_Enable_LSB, // AIN1 1=LSB
whismanoid 10:04022a61b527 2211 SPI_AIN_Enable_LSB, // AIN2 1=LSB
whismanoid 10:04022a61b527 2212 SPI_AIN_Enable_LSB, // AIN3 1=LSB
whismanoid 10:04022a61b527 2213 SPI_AIN_Enable_LSB, // AIN4 1=LSB
whismanoid 10:04022a61b527 2214 SPI_AIN_Enable_LSB, // AIN5 1=LSB
whismanoid 10:04022a61b527 2215 SPI_AIN_Enable_LSB, // AIN6 1=LSB
whismanoid 10:04022a61b527 2216 SPI_AIN_Enable_LSB, // AIN7 1=LSB
whismanoid 10:04022a61b527 2217 SPI_AIN_Enable_LSB, // AIN8 1=LSB
whismanoid 10:04022a61b527 2218 SPI_AIN_Enable_LSB, // AIN9 1=LSB
whismanoid 3:9055e17e181a 2219 };
whismanoid 3:9055e17e181a 2220 //
whismanoid 10:04022a61b527 2221 double SPI_AIN_Voltage[NUM_DUT_ANALOG_IN_CHANNELS];
whismanoid 13:184a08909405 2222 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2223 #ifndef HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 2224 #define HAS_SPI_AIN_customChannelHeader 0
whismanoid 13:184a08909405 2225 #endif
whismanoid 13:184a08909405 2226 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2227 const char* const SPI_AIN_customChannelHeader_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 2228 "", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 2229 "", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 2230 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 2231 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 2232 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 2233 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 2234 };
whismanoid 13:184a08909405 2235 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 3:9055e17e181a 2236 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2237 // ---------- Measure_Voltage_custom_props in Measure_Voltage @pre and in class properties ----------
whismanoid 3:9055e17e181a 2238 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 2239 // MAX11410 specific per-channel config register v_filter
whismanoid 3:9055e17e181a 2240 uint8_t SPI_AIN_Cfg_v_filter_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2241 0x34, // AIN0 @ v_filter=0x34
whismanoid 3:9055e17e181a 2242 0x34, // AIN1 @ v_filter=0x34
whismanoid 3:9055e17e181a 2243 0x34, // AIN2 @ v_filter=0x34
whismanoid 3:9055e17e181a 2244 0x34, // AIN3 @ v_filter=0x34
whismanoid 3:9055e17e181a 2245 0x34, // AIN4 @ v_filter=0x34
whismanoid 3:9055e17e181a 2246 0x34, // AIN5 @ v_filter=0x34
whismanoid 3:9055e17e181a 2247 0x34, // AIN6 @ v_filter=0x34
whismanoid 3:9055e17e181a 2248 0x34, // AIN7 @ v_filter=0x34
whismanoid 3:9055e17e181a 2249 0x34, // AIN8 @ v_filter=0x34
whismanoid 3:9055e17e181a 2250 0x34, // AIN9 @ v_filter=0x34
whismanoid 3:9055e17e181a 2251 };
whismanoid 3:9055e17e181a 2252 //
whismanoid 4:d9b05924ad4c 2253 // MAX11410 specific per-channel config register v_ctrl
whismanoid 3:9055e17e181a 2254 uint8_t SPI_AIN_Cfg_v_ctrl_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2255 0x42, // AIN0 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2256 0x42, // AIN1 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2257 0x42, // AIN2 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2258 0x42, // AIN3 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2259 0x42, // AIN4 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2260 0x42, // AIN5 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2261 0x42, // AIN6 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2262 0x42, // AIN7 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2263 0x42, // AIN8 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2264 0x42, // AIN9 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2265 };
whismanoid 3:9055e17e181a 2266 //
whismanoid 4:d9b05924ad4c 2267 // MAX11410 specific per-channel config register v_pga
whismanoid 3:9055e17e181a 2268 uint8_t SPI_AIN_Cfg_v_pga_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2269 0x00, // AIN0 @ v_pga=0x00
whismanoid 3:9055e17e181a 2270 0x00, // AIN1 @ v_pga=0x00
whismanoid 3:9055e17e181a 2271 0x00, // AIN2 @ v_pga=0x00
whismanoid 3:9055e17e181a 2272 0x00, // AIN3 @ v_pga=0x00
whismanoid 3:9055e17e181a 2273 0x00, // AIN4 @ v_pga=0x00
whismanoid 3:9055e17e181a 2274 0x00, // AIN5 @ v_pga=0x00
whismanoid 3:9055e17e181a 2275 0x00, // AIN6 @ v_pga=0x00
whismanoid 3:9055e17e181a 2276 0x00, // AIN7 @ v_pga=0x00
whismanoid 3:9055e17e181a 2277 0x00, // AIN8 @ v_pga=0x00
whismanoid 3:9055e17e181a 2278 0x00, // AIN9 @ v_pga=0x00
whismanoid 3:9055e17e181a 2279 };
whismanoid 3:9055e17e181a 2280 //
whismanoid 3:9055e17e181a 2281 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2282 // ---------- Measure_Voltage_custom_props ----------
whismanoid 0:cb44e2e9ec4c 2283 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2284 // filter register configuration in Measure_Voltage and Read_All_Voltages CONV_TYPE_01_Continuous
whismanoid 0:cb44e2e9ec4c 2285 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 2286 //~ const uint8_t custom_v_filter = 0x00; // @ v_filter=0x00 -- LINEF_00_50Hz_60Hz_FIR RATE_0000 | 1.1SPS
whismanoid 0:cb44e2e9ec4c 2287 //~ const uint8_t custom_v_filter = 0x01; // @ v_filter=0x01 -- LINEF_00_50Hz_60Hz_FIR RATE_0001 | 2.1SPS
whismanoid 0:cb44e2e9ec4c 2288 //~ const uint8_t custom_v_filter = 0x02; // @ v_filter=0x02 -- LINEF_00_50Hz_60Hz_FIR RATE_0010 | 4.2SPS
whismanoid 0:cb44e2e9ec4c 2289 //~ const uint8_t custom_v_filter = 0x03; // @ v_filter=0x03 -- LINEF_00_50Hz_60Hz_FIR RATE_0011 | 8.4SPS
whismanoid 0:cb44e2e9ec4c 2290 //~ const uint8_t custom_v_filter = 0x04; // @ v_filter=0x04 -- LINEF_00_50Hz_60Hz_FIR RATE_0100 | 16.8SPS
whismanoid 0:cb44e2e9ec4c 2291 //~ const uint8_t custom_v_filter = 0x10; // @ v_filter=0x10 -- LINEF_01_50Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 2292 //~ const uint8_t custom_v_filter = 0x11; // @ v_filter=0x11 -- LINEF_01_50Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 2293 //~ const uint8_t custom_v_filter = 0x12; // @ v_filter=0x12 -- LINEF_01_50Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 2294 //~ const uint8_t custom_v_filter = 0x13; // @ v_filter=0x13 -- LINEF_01_50Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 2295 //~ const uint8_t custom_v_filter = 0x14; // @ v_filter=0x14 -- LINEF_01_50Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 2296 //~ const uint8_t custom_v_filter = 0x15; // @ v_filter=0x15 -- LINEF_01_50Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 2297 //~ const uint8_t custom_v_filter = 0x20; // @ v_filter=0x20 -- LINEF_10_60Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 2298 //~ const uint8_t custom_v_filter = 0x21; // @ v_filter=0x21 -- LINEF_10_60Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 2299 //~ const uint8_t custom_v_filter = 0x22; // @ v_filter=0x22 -- LINEF_10_60Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 2300 //~ const uint8_t custom_v_filter = 0x23; // @ v_filter=0x23 -- LINEF_10_60Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 2301 //~ const uint8_t custom_v_filter = 0x24; // @ v_filter=0x24 -- LINEF_10_60Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 2302 //~ const uint8_t custom_v_filter = 0x25; // @ v_filter=0x25 -- LINEF_10_60Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 2303 //~ const uint8_t custom_v_filter = 0x30; // @ v_filter=0x30 -- LINEF_11_SINC4 RATE_0000 | 4SPS
whismanoid 0:cb44e2e9ec4c 2304 //~ const uint8_t custom_v_filter = 0x31; // @ v_filter=0x31 -- LINEF_11_SINC4 RATE_0001 | 10SPS
whismanoid 0:cb44e2e9ec4c 2305 //~ const uint8_t custom_v_filter = 0x32; // @ v_filter=0x32 -- LINEF_11_SINC4 RATE_0010 | 20SPS
whismanoid 0:cb44e2e9ec4c 2306 //~ const uint8_t custom_v_filter = 0x33; // @ v_filter=0x33 -- LINEF_11_SINC4 RATE_0011 | 40SPS
whismanoid 0:cb44e2e9ec4c 2307 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 2308 //~ const uint8_t custom_v_filter = 0x35; // @ v_filter=0x35 -- LINEF_11_SINC4 RATE_0101 | 120SPS
whismanoid 0:cb44e2e9ec4c 2309 //~ const uint8_t custom_v_filter = 0x36; // @ v_filter=0x36 -- LINEF_11_SINC4 RATE_0110 | 240SPS
whismanoid 0:cb44e2e9ec4c 2310 //~ const uint8_t custom_v_filter = 0x37; // @ v_filter=0x37 -- LINEF_11_SINC4 RATE_0111 | 480SPS
whismanoid 0:cb44e2e9ec4c 2311 //~ const uint8_t custom_v_filter = 0x38; // @ v_filter=0x38 -- LINEF_11_SINC4 RATE_1000 | 960SPS
whismanoid 0:cb44e2e9ec4c 2312 //~ const uint8_t custom_v_filter = 0x39; // @ v_filter=0x39 -- LINEF_11_SINC4 RATE_1001 | 1920SPS
whismanoid 0:cb44e2e9ec4c 2313 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2314 //
whismanoid 0:cb44e2e9ec4c 2315 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2316 // pga register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 0:cb44e2e9ec4c 2317 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 2318 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 2319 //~ const uint8_t custom_v_pga = 0x10; // @ v_pga=0x10 -- 0x10 SIG_PATH_01_BYPASS
whismanoid 0:cb44e2e9ec4c 2320 //~ const uint8_t custom_v_pga = 0x20; // @ v_pga=0x20 -- 0x20 SIG_PATH_10_PGA GAIN_000_1
whismanoid 0:cb44e2e9ec4c 2321 //~ const uint8_t custom_v_pga = 0x21; // @ v_pga=0x21 --*0x21 SIG_PATH_10_PGA GAIN_001_2
whismanoid 0:cb44e2e9ec4c 2322 //~ const uint8_t custom_v_pga = 0x22; // @ v_pga=0x22 -- 0x22 SIG_PATH_10_PGA GAIN_010_4
whismanoid 0:cb44e2e9ec4c 2323 //~ const uint8_t custom_v_pga = 0x23; // @ v_pga=0x23 -- 0x23 SIG_PATH_10_PGA GAIN_011_8
whismanoid 0:cb44e2e9ec4c 2324 //~ const uint8_t custom_v_pga = 0x24; // @ v_pga=0x24 -- 0x24 SIG_PATH_10_PGA GAIN_100_16
whismanoid 0:cb44e2e9ec4c 2325 //~ const uint8_t custom_v_pga = 0x25; // @ v_pga=0x25 -- 0x25 SIG_PATH_10_PGA GAIN_101_32
whismanoid 0:cb44e2e9ec4c 2326 //~ const uint8_t custom_v_pga = 0x26; // @ v_pga=0x26 -- 0x26 SIG_PATH_10_PGA GAIN_110_64
whismanoid 0:cb44e2e9ec4c 2327 //~ const uint8_t custom_v_pga = 0x27; // @ v_pga=0x27 -- 0x27 SIG_PATH_10_PGA GAIN_111_128
whismanoid 0:cb44e2e9ec4c 2328 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2329 //
whismanoid 0:cb44e2e9ec4c 2330 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2331 // ctrl register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 3:9055e17e181a 2332 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2333 //~ const uint8_t custom_v_ctrl = 0x40; // @ v_ctrl=0x40 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1
whismanoid 0:cb44e2e9ec4c 2334 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 2335 //~ const uint8_t custom_v_ctrl = 0x58; // @ v_ctrl=0x58 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 2336 //
whismanoid 0:cb44e2e9ec4c 2337 //~ const uint8_t custom_v_ctrl = 0x41; // @ v_ctrl=0x41 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N
whismanoid 0:cb44e2e9ec4c 2338 //~ const uint8_t custom_v_ctrl = 0x45; // @ v_ctrl=0x45 -- 0x40 unipolar, 0x05 REF_SEL_101_REF1P_AGND
whismanoid 0:cb44e2e9ec4c 2339 //~ const uint8_t custom_v_ctrl = 0x59; // @ v_ctrl=0x59 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 2340 //
whismanoid 0:cb44e2e9ec4c 2341 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2342 //~ const uint8_t custom_v_ctrl = 0x46; // @ v_ctrl=0x46 -- 0x40 unipolar, 0x06 REF_SEL_110_REF2P_AGND
whismanoid 0:cb44e2e9ec4c 2343 //~ const uint8_t custom_v_ctrl = 0x22; // @ v_ctrl=0x22 -- 0x20 bipolar offset binary, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2344 //~ const uint8_t custom_v_ctrl = 0x02; // @ v_ctrl=0x02 -- 0x00 bipolar 2's complement, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2345 //
whismanoid 0:cb44e2e9ec4c 2346 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 2347 //~ const uint8_t custom_v_ctrl = 0x47; // @ v_ctrl=0x47 -- 0x40 unipolar, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2348 //~ const uint8_t custom_v_ctrl = 0x27; // @ v_ctrl=0x27 -- 0x20 bipolar offset binary, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2349 //~ const uint8_t custom_v_ctrl = 0x07; // @ v_ctrl=0x07 -- 0x00 bipolar 2's complement, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2350 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2351
whismanoid 3:9055e17e181a 2352 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2353 // example code declare SPI interface (GPIO controlled CS)
whismanoid 0:cb44e2e9ec4c 2354 #if defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 2355 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 2356 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
whismanoid 19:5ff09c8e9daf 2357 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 2358 #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 2359 SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625PICO: pin P0_5 P0_6 P0_4
whismanoid 0:cb44e2e9ec4c 2360 DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32625PICO: pin P0_7
whismanoid 0:cb44e2e9ec4c 2361 #elif defined(TARGET_MAX32600MBED)
whismanoid 0:cb44e2e9ec4c 2362 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 0:cb44e2e9ec4c 2363 DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2364 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 2365 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 2366 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:cb44e2e9ec4c 2367 //
whismanoid 0:cb44e2e9ec4c 2368 // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses.
whismanoid 0:cb44e2e9ec4c 2369 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 2370 DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2371 //
whismanoid 0:cb44e2e9ec4c 2372 #else
whismanoid 3:9055e17e181a 2373 SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 3:9055e17e181a 2374 DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2375 #endif
whismanoid 0:cb44e2e9ec4c 2376
whismanoid 0:cb44e2e9ec4c 2377 // example code declare GPIO interface pins
whismanoid 0:cb44e2e9ec4c 2378 // example code declare device instance
whismanoid 3:9055e17e181a 2379 MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC);
whismanoid 3:9055e17e181a 2380 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2381
whismanoid 1:747f1602abfc 2382 //--------------------------------------------------
whismanoid 3:9055e17e181a 2383 // Option to Datalog Arduino platform analog inputs
whismanoid 3:9055e17e181a 2384 #ifndef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 2385 #define LOG_PLATFORM_AIN 6
whismanoid 3:9055e17e181a 2386 //~ #undef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 2387 #endif
whismanoid 3:9055e17e181a 2388 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 1:747f1602abfc 2389 //#ifndef NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 1:747f1602abfc 2390 //#define NUM_PLATFORM_ANALOG_IN_CHANNELS 6
whismanoid 1:747f1602abfc 2391 //#endif
whismanoid 1:747f1602abfc 2392 const int NUM_PLATFORM_ANALOG_IN_CHANNELS = 6;
whismanoid 1:747f1602abfc 2393 const double adc_full_scale_voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 2394 analogInPin_fullScaleVoltage[0], // 1.2,
whismanoid 10:04022a61b527 2395 analogInPin_fullScaleVoltage[1], // 1.2,
whismanoid 10:04022a61b527 2396 analogInPin_fullScaleVoltage[2], // 1.2,
whismanoid 10:04022a61b527 2397 analogInPin_fullScaleVoltage[3], // 1.2,
whismanoid 10:04022a61b527 2398 analogInPin_fullScaleVoltage[4], // 6.0
whismanoid 10:04022a61b527 2399 analogInPin_fullScaleVoltage[5], // 6.0
whismanoid 0:cb44e2e9ec4c 2400 };
whismanoid 9:45f98573eb6d 2401 // Platform ADC individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 9:45f98573eb6d 2402 typedef enum Platform_AIN_Enable_t {
whismanoid 9:45f98573eb6d 2403 Platform_AIN_Disable = 0,
whismanoid 9:45f98573eb6d 2404 Platform_AIN_Enable_LSB = 1,
whismanoid 9:45f98573eb6d 2405 Platform_AIN_Enable_Volt = 2,
whismanoid 9:45f98573eb6d 2406 } Platform_AIN_Enable_t;
whismanoid 13:184a08909405 2407 uint8_t Platform_Enable_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 9:45f98573eb6d 2408 Platform_AIN_Enable_Volt, // AIN0 2=Volt
whismanoid 9:45f98573eb6d 2409 Platform_AIN_Enable_Volt, // AIN1 2=Volt
whismanoid 9:45f98573eb6d 2410 Platform_AIN_Enable_Volt, // AIN2 2=Volt
whismanoid 9:45f98573eb6d 2411 Platform_AIN_Enable_Volt, // AIN3 2=Volt
whismanoid 9:45f98573eb6d 2412 Platform_AIN_Enable_Volt, // AIN4 2=Volt
whismanoid 9:45f98573eb6d 2413 Platform_AIN_Enable_Volt, // AIN5 2=Volt
whismanoid 9:45f98573eb6d 2414 };
whismanoid 37:3f369235e5bc 2415 // Option to report average value of Arduino platform analog inputs
whismanoid 37:3f369235e5bc 2416 #ifndef USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 2417 #define USE_Platform_AIN_Average 1
whismanoid 37:3f369235e5bc 2418 //~ #undef USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 2419 #endif
whismanoid 37:3f369235e5bc 2420 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 2421 #endif // USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 2422 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 2423 int Platform_AIN_Average_N = 16;
whismanoid 37:3f369235e5bc 2424 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 2425 // Option to apply calibration to Arduino platform analog inputs
whismanoid 34:a1993a1ee904 2426 #ifndef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2427 #define HAS_Platform_AIN_Calibration 1
whismanoid 34:a1993a1ee904 2428 //~ #undef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2429 #endif
whismanoid 34:a1993a1ee904 2430 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2431 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 2432 // Calibration is between two points for each channel, defined by
whismanoid 34:a1993a1ee904 2433 // a normalized value between 0% and 100%, and the corresponding voltage.
whismanoid 34:a1993a1ee904 2434 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 2435 // calibration_05_normValue_0_1, calibration_05_V should be around 5% or 25%
whismanoid 34:a1993a1ee904 2436 double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2437 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2438 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2439 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2440 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 36:e7aac874b8be 2441 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2442 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2443 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2444 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2445 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2446 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2447 //
whismanoid 36:e7aac874b8be 2448 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2449 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 37:3f369235e5bc 2450 0.250000000, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 37:3f369235e5bc 2451 0.624736547, // %A cal1n=0.624736547 cal1v=0.748000026V cal1n=0.979754724 cal1v=1.167500019V
whismanoid 37:3f369235e5bc 2452 0.250000000, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 37:3f369235e5bc 2453 0.250000000, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 37:3f369235e5bc 2454 0.250000000, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 37:3f369235e5bc 2455 0.127252869, // %A cal5n=0.127252869 cal5v=0.748000026V cal5n=0.267205842 cal5v=1.578999996V
whismanoid 36:e7aac874b8be 2456 //
whismanoid 36:e7aac874b8be 2457 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2458 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 36:e7aac874b8be 2459 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2460 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2461 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2462 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2463 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2464 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2465 //
whismanoid 36:e7aac874b8be 2466 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2467 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 36:e7aac874b8be 2468 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2469 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2470 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2471 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2472 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2473 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2474 //
whismanoid 36:e7aac874b8be 2475 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2476 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 36:e7aac874b8be 2477 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2478 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2479 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2480 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2481 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2482 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2483 //
whismanoid 36:e7aac874b8be 2484 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2485 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 36:e7aac874b8be 2486 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2487 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2488 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2489 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2490 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2491 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2492 //
whismanoid 36:e7aac874b8be 2493 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2494 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 36:e7aac874b8be 2495 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2496 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2497 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2498 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2499 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2500 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2501 //
whismanoid 36:e7aac874b8be 2502 # else
whismanoid 36:e7aac874b8be 2503 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2504 # endif
whismanoid 36:e7aac874b8be 2505 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2506 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2507 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2508 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2509 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2510 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2511 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2512 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2513 //
whismanoid 36:e7aac874b8be 2514 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2515 };
whismanoid 34:a1993a1ee904 2516 double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2517 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2518 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2519 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2520 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 36:e7aac874b8be 2521 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2522 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2523 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2524 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2525 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2526 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2527 //
whismanoid 36:e7aac874b8be 2528 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2529 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 37:3f369235e5bc 2530 0.300000000, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 37:3f369235e5bc 2531 0.748000026, // %A cal1n=0.624736547 cal1v=0.748000026V cal1n=0.979754724 cal1v=1.167500019V
whismanoid 37:3f369235e5bc 2532 0.300000000, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 37:3f369235e5bc 2533 0.300000000, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 37:3f369235e5bc 2534 1.500000000, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 37:3f369235e5bc 2535 0.748000026, // %A cal5n=0.127252869 cal5v=0.748000026V cal5n=0.267205842 cal5v=1.578999996V
whismanoid 36:e7aac874b8be 2536 //
whismanoid 36:e7aac874b8be 2537 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2538 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 36:e7aac874b8be 2539 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2540 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2541 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2542 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2543 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2544 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2545 //
whismanoid 36:e7aac874b8be 2546 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2547 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 36:e7aac874b8be 2548 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2549 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2550 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2551 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2552 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2553 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2554 //
whismanoid 36:e7aac874b8be 2555 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2556 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 36:e7aac874b8be 2557 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2558 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2559 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2560 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2561 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2562 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2563 //
whismanoid 36:e7aac874b8be 2564 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2565 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 36:e7aac874b8be 2566 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2567 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2568 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2569 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2570 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2571 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2572 //
whismanoid 36:e7aac874b8be 2573 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2574 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 36:e7aac874b8be 2575 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2576 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2577 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2578 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2579 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2580 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2581 //
whismanoid 36:e7aac874b8be 2582 # else
whismanoid 36:e7aac874b8be 2583 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2584 # endif
whismanoid 36:e7aac874b8be 2585 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2586 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2587 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2588 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2589 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2590 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2591 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2592 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2593 //
whismanoid 36:e7aac874b8be 2594 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2595 };
whismanoid 34:a1993a1ee904 2596 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 2597 // calibration_95_normValue_0_1, calibration_95_V should be around 95% or 75%
whismanoid 34:a1993a1ee904 2598 double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2599 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2600 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2601 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2602 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 36:e7aac874b8be 2603 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2604 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2605 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2606 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2607 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2608 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2609 //
whismanoid 36:e7aac874b8be 2610 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2611 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 37:3f369235e5bc 2612 0.750000000, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 37:3f369235e5bc 2613 0.979754724, // %A cal1n=0.624736547 cal1v=0.748000026V cal1n=0.979754724 cal1v=1.167500019V
whismanoid 37:3f369235e5bc 2614 0.750000000, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 37:3f369235e5bc 2615 0.750000000, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 37:3f369235e5bc 2616 0.750000000, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 37:3f369235e5bc 2617 0.267205842, // %A cal5n=0.127252869 cal5v=0.748000026V cal5n=0.267205842 cal5v=1.578999996V
whismanoid 36:e7aac874b8be 2618 //
whismanoid 36:e7aac874b8be 2619 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2620 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 36:e7aac874b8be 2621 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2622 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2623 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2624 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2625 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2626 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2627 //
whismanoid 36:e7aac874b8be 2628 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2629 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 36:e7aac874b8be 2630 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2631 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2632 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2633 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2634 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2635 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2636 //
whismanoid 36:e7aac874b8be 2637 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2638 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 36:e7aac874b8be 2639 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2640 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2641 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2642 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2643 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2644 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2645 //
whismanoid 36:e7aac874b8be 2646 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2647 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 36:e7aac874b8be 2648 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2649 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2650 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2651 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2652 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2653 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2654 //
whismanoid 36:e7aac874b8be 2655 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2656 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 36:e7aac874b8be 2657 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2658 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2659 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2660 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2661 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2662 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2663 //
whismanoid 36:e7aac874b8be 2664 # else
whismanoid 36:e7aac874b8be 2665 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2666 # endif
whismanoid 36:e7aac874b8be 2667 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2668 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2669 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2670 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2671 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2672 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2673 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2674 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2675 //
whismanoid 36:e7aac874b8be 2676 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2677 };
whismanoid 34:a1993a1ee904 2678 double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2679 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2680 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2681 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2682 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 36:e7aac874b8be 2683 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2684 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2685 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2686 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2687 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2688 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2689 //
whismanoid 36:e7aac874b8be 2690 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2691 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 37:3f369235e5bc 2692 0.900000000, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 37:3f369235e5bc 2693 1.167500019, // %A cal1n=0.624736547 cal1v=0.748000026V cal1n=0.979754724 cal1v=1.167500019V
whismanoid 37:3f369235e5bc 2694 0.900000000, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 37:3f369235e5bc 2695 0.900000000, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 37:3f369235e5bc 2696 4.500000000, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 37:3f369235e5bc 2697 1.578999996, // %A cal5n=0.127252869 cal5v=0.748000026V cal5n=0.267205842 cal5v=1.578999996V
whismanoid 36:e7aac874b8be 2698 //
whismanoid 36:e7aac874b8be 2699 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2700 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 36:e7aac874b8be 2701 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2702 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2703 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2704 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2705 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2706 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2707 //
whismanoid 36:e7aac874b8be 2708 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2709 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 36:e7aac874b8be 2710 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2711 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2712 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2713 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2714 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2715 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2716 //
whismanoid 36:e7aac874b8be 2717 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2718 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 36:e7aac874b8be 2719 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2720 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2721 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2722 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2723 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2724 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2725 //
whismanoid 36:e7aac874b8be 2726 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2727 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 36:e7aac874b8be 2728 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2729 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2730 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2731 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2732 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2733 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2734 //
whismanoid 36:e7aac874b8be 2735 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2736 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 36:e7aac874b8be 2737 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2738 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2739 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2740 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2741 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2742 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2743 //
whismanoid 36:e7aac874b8be 2744 # else
whismanoid 36:e7aac874b8be 2745 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2746 # endif
whismanoid 36:e7aac874b8be 2747 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2748 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2749 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2750 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2751 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2752 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2753 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2754 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2755 //
whismanoid 36:e7aac874b8be 2756 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2757 };
whismanoid 34:a1993a1ee904 2758 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2759 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2760 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1)
whismanoid 34:a1993a1ee904 2761 {
whismanoid 34:a1993a1ee904 2762 // TODO: return corrected normValue_0_1 using two-point linear calibration
whismanoid 34:a1993a1ee904 2763 // point 1: calibration_05_normValue_0_1[ch], calibration_05_V[ch]
whismanoid 34:a1993a1ee904 2764 // point 2: calibration_95_normValue_0_1[ch], calibration_95_V[ch]
whismanoid 34:a1993a1ee904 2765 // validate that there is enough span to get sensible results
whismanoid 34:a1993a1ee904 2766 //
whismanoid 34:a1993a1ee904 2767 int ch = channel_0_5;
whismanoid 34:a1993a1ee904 2768 // 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 2769 // ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 2770 // ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 2771 // ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 2772 // ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 2773 // );
whismanoid 34:a1993a1ee904 2774 // cmdLine.serial().printf("\r\n adc_full_scale_voltage[%d] = %1.6fV",
whismanoid 34:a1993a1ee904 2775 // ch,
whismanoid 34:a1993a1ee904 2776 // adc_full_scale_voltage[ch]
whismanoid 34:a1993a1ee904 2777 // );
whismanoid 34:a1993a1ee904 2778 // raw normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 2779 double raw_05_normValue = calibration_05_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 2780 double raw_95_normValue = calibration_95_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 2781 // calibrated normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 2782 // divide V/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 2783 double cal_05_normValue = calibration_05_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 2784 double cal_95_normValue = calibration_95_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 2785 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_05_normValue = %1.6f",
whismanoid 34:a1993a1ee904 2786 // ch,
whismanoid 34:a1993a1ee904 2787 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2788 // cal_05_normValue
whismanoid 34:a1993a1ee904 2789 // );
whismanoid 34:a1993a1ee904 2790 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_95_normValue = %1.6f",
whismanoid 34:a1993a1ee904 2791 // ch,
whismanoid 34:a1993a1ee904 2792 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2793 // cal_95_normValue
whismanoid 34:a1993a1ee904 2794 // );
whismanoid 34:a1993a1ee904 2795 //
whismanoid 34:a1993a1ee904 2796 double span_raw = raw_95_normValue - raw_05_normValue;
whismanoid 34:a1993a1ee904 2797 double span_cal = cal_95_normValue - cal_05_normValue;
whismanoid 34:a1993a1ee904 2798 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_raw = %1.6f",
whismanoid 34:a1993a1ee904 2799 // ch,
whismanoid 34:a1993a1ee904 2800 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2801 // span_raw
whismanoid 34:a1993a1ee904 2802 // );
whismanoid 34:a1993a1ee904 2803 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_cal = %1.6f",
whismanoid 34:a1993a1ee904 2804 // ch,
whismanoid 34:a1993a1ee904 2805 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2806 // span_cal
whismanoid 34:a1993a1ee904 2807 // );
whismanoid 34:a1993a1ee904 2808 // if calibration is not valid, return unmodified normValue_0_1 and print a warning
whismanoid 34:a1993a1ee904 2809 if (span_raw < 0.001) {
whismanoid 34:a1993a1ee904 2810 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_raw = %1.6f",
whismanoid 34:a1993a1ee904 2811 ch,
whismanoid 34:a1993a1ee904 2812 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2813 span_raw
whismanoid 34:a1993a1ee904 2814 );
whismanoid 34:a1993a1ee904 2815 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 2816 }
whismanoid 34:a1993a1ee904 2817 if (span_cal < 0.001) {
whismanoid 34:a1993a1ee904 2818 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_cal = %1.6f",
whismanoid 34:a1993a1ee904 2819 ch,
whismanoid 34:a1993a1ee904 2820 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2821 span_cal
whismanoid 34:a1993a1ee904 2822 );
whismanoid 34:a1993a1ee904 2823 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 2824 }
whismanoid 34:a1993a1ee904 2825 double slope_correction = span_cal / span_raw;
whismanoid 34:a1993a1ee904 2826 double corrected_normValue_0_1 = cal_05_normValue + ((raw_normValue_0_1 - raw_05_normValue) * slope_correction);
whismanoid 34:a1993a1ee904 2827 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) slope_correction = %1.6f",
whismanoid 34:a1993a1ee904 2828 // ch,
whismanoid 34:a1993a1ee904 2829 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2830 // slope_correction
whismanoid 34:a1993a1ee904 2831 // );
whismanoid 34:a1993a1ee904 2832 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) corrected_normValue_0_1 = %1.6f\r\n",
whismanoid 34:a1993a1ee904 2833 // ch,
whismanoid 34:a1993a1ee904 2834 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2835 // corrected_normValue_0_1
whismanoid 34:a1993a1ee904 2836 // );
whismanoid 34:a1993a1ee904 2837 return corrected_normValue_0_1;
whismanoid 34:a1993a1ee904 2838 }
whismanoid 34:a1993a1ee904 2839 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2840 // Option to customize channel names in datalog header line
whismanoid 13:184a08909405 2841 #ifndef HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 2842 #define HAS_Platform_AIN_customChannelHeader 1
whismanoid 13:184a08909405 2843 #endif
whismanoid 13:184a08909405 2844 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2845 const char* const Platform_AIN_customChannelHeader_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 2846 "=AIN4", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 2847 "=AIN5", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 2848 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 2849 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 2850 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 2851 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 2852 };
whismanoid 13:184a08909405 2853 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 1:747f1602abfc 2854 //--------------------------------------------------
whismanoid 1:747f1602abfc 2855 // Option to log platform analog inputs as raw LSB code
whismanoid 1:747f1602abfc 2856 #ifndef LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 2857 #define LOG_PLATFORM_ANALOG_IN_LSB 0
whismanoid 1:747f1602abfc 2858 #endif
whismanoid 1:747f1602abfc 2859 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 2860 int Platform_LSB[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 2861 #endif
whismanoid 1:747f1602abfc 2862
whismanoid 1:747f1602abfc 2863 //--------------------------------------------------
whismanoid 1:747f1602abfc 2864 // Option to use platform analog inputs as Voltage
whismanoid 1:747f1602abfc 2865 #ifndef LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 2866 #define LOG_PLATFORM_ANALOG_IN_VOLTS 1
whismanoid 1:747f1602abfc 2867 #endif
whismanoid 1:747f1602abfc 2868 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 2869 double Platform_Voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 2870 #endif
whismanoid 3:9055e17e181a 2871 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 0:cb44e2e9ec4c 2872
whismanoid 10:04022a61b527 2873 //--------------------------------------------------
whismanoid 10:04022a61b527 2874 // Option to use Command forwarding to Auxiliary serial port
whismanoid 10:04022a61b527 2875 // Command forwarding to Auxiliary serial port TX/RX
whismanoid 10:04022a61b527 2876 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial
whismanoid 10:04022a61b527 2877 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial
whismanoid 10:04022a61b527 2878 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 2879 #ifndef USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2880 #define USE_AUX_SERIAL_CMD_FORWARDING 1
whismanoid 10:04022a61b527 2881 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2882 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2883 // Command forwarding to Auxiliary serial port TX/RX #257 -- global parameters
whismanoid 10:04022a61b527 2884 const size_t RX_STRING_BUF_SIZE = 1000;
whismanoid 10:04022a61b527 2885 int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 2886 // transmit command string by AUX TX
whismanoid 10:04022a61b527 2887 #if 0
whismanoid 10:04022a61b527 2888 int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 2889 int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 2890 int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 2891 #endif
whismanoid 10:04022a61b527 2892 // capture received string from AUX RX
whismanoid 10:04022a61b527 2893 Timer g_auxSerialCom_Timer;
whismanoid 10:04022a61b527 2894 int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 2895 int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 2896 int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 2897 int g_auxSerialCom_rx_idle_ms = 500; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 2898 int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 2899 const int aux_serial_cmd_forwarding_rx_eot_not_used = 'x';
whismanoid 10:04022a61b527 2900 int g_auxSerialCom_rx_eot = aux_serial_cmd_forwarding_rx_eot_not_used; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 2901 //~ int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text string?
whismanoid 10:04022a61b527 2902 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2903 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2904 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257
whismanoid 10:04022a61b527 2905 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 2906 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2907 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2908 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2909 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 2910 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2911 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 2912 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2913 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2914 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2915 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2916 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2917 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 2918 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2919 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2920
whismanoid 8:dffee7509bfb 2921 // CODE GENERATOR: example code for ADC: serial port declaration
whismanoid 8:dffee7509bfb 2922 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2923 // Declare the Serial driver
whismanoid 8:dffee7509bfb 2924 // default baud rate settings are 9600 8N1
whismanoid 8:dffee7509bfb 2925 // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
whismanoid 8:dffee7509bfb 2926 // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
whismanoid 8:dffee7509bfb 2927 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2928 #if defined(TARGET_MAX32630)
whismanoid 8:dffee7509bfb 2929 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 2930 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2931 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2932 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 2933 //
whismanoid 8:dffee7509bfb 2934 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2935 Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2936 //Serial J3AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 2937 //Serial BTAUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 2938 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 2939 //
whismanoid 8:dffee7509bfb 2940 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2941 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2942 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2943 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2944 //
whismanoid 8:dffee7509bfb 2945 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2946 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2947 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2948 USBSerial serial;
whismanoid 8:dffee7509bfb 2949 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2950 #elif defined(TARGET_MAX32625MBED)
whismanoid 8:dffee7509bfb 2951 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625MBED: P0_1,P0_0 (Arduino D1,D0)
whismanoid 8:dffee7509bfb 2952 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2953 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625MBED: P3_1,P3_0 (J15-LEDgreen,LEDred)
whismanoid 8:dffee7509bfb 2954 //
whismanoid 8:dffee7509bfb 2955 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2956 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2957 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2958 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2959 //
whismanoid 8:dffee7509bfb 2960 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2961 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2962 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2963 USBSerial serial;
whismanoid 8:dffee7509bfb 2964 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 2965 #elif defined(TARGET_MAX32625PICO)
whismanoid 8:dffee7509bfb 2966 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 2967 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625PICO: P2_1,P2_0 (underside?)
whismanoid 8:dffee7509bfb 2968 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2969 //
whismanoid 8:dffee7509bfb 2970 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2971 Serial AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 2972 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 2973 //
whismanoid 8:dffee7509bfb 2974 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2975 Serial DAPLINKserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2976 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2977 //
whismanoid 8:dffee7509bfb 2978 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2979 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2980 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2981 USBSerial serial;
whismanoid 22:d6dc8a85f435 2982 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 2983 #elif defined(TARGET_MAX40108DEMOP2U9)
whismanoid 22:d6dc8a85f435 2984 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 2985 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK)
whismanoid 22:d6dc8a85f435 2986 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 2987 //
whismanoid 22:d6dc8a85f435 2988 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial is used as main serial port in MAX40108 Demo board
whismanoid 22:d6dc8a85f435 2989 Serial serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 2990 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 2991 //
whismanoid 22:d6dc8a85f435 2992 // Hardware serial port over DAPLink
whismanoid 22:d6dc8a85f435 2993 // connection to external MAX32625PICO(DAPLINK) needed TX/RX swap in firmware.
whismanoid 22:d6dc8a85f435 2994 // MAX32625PICO(DAPLINK) drives DAPLINK.8, listens on DAPLINK.6.
whismanoid 22:d6dc8a85f435 2995 // See AN6350 MAX32625 Users Guide 7.5.2.3.1 TX and RX Pin Mapping for UART 1 -- Mapping Option B
whismanoid 22:d6dc8a85f435 2996 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 22:d6dc8a85f435 2997 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 22:d6dc8a85f435 2998 #define HAS_DAPLINK_SERIAL 1
whismanoid 22:d6dc8a85f435 2999 //
whismanoid 22:d6dc8a85f435 3000 // Serial AUXserial(UART1_TX,UART1_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 3001 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 3002 //
whismanoid 22:d6dc8a85f435 3003 // Virtual serial port over USB
whismanoid 22:d6dc8a85f435 3004 // #include "USBSerial.h"
whismanoid 22:d6dc8a85f435 3005 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 22:d6dc8a85f435 3006 //USBSerial serial;
whismanoid 8:dffee7509bfb 3007 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3008 #elif defined(TARGET_MAX32620FTHR)
whismanoid 8:dffee7509bfb 3009 #warning "TARGET_MAX32620FTHR not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3010 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3011 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32620FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3012 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3013 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3014 //
whismanoid 8:dffee7509bfb 3015 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3016 Serial serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3017 //Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3018 Serial AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3019 //Serial PMOD0AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3020 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3021 //
whismanoid 8:dffee7509bfb 3022 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3023 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3024 Serial DAPLINKserial(USBTX, USBRX); // tx,rx MAX32620FTHR: P2_1,P2_0
whismanoid 8:dffee7509bfb 3025 //Serial DAPLINKserial(STDIO_UART_TX, STDIO_UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3026 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3027 //
whismanoid 8:dffee7509bfb 3028 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3029 // #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3030 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3031 //USBSerial serial; // MAX32620FTHR: USBSerial crash??
whismanoid 8:dffee7509bfb 3032 #warning "TARGET_MAX32620FTHR not previously tested; USBSerial crash?"
whismanoid 8:dffee7509bfb 3033 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3034 #elif defined(TARGET_MAX32600)
whismanoid 8:dffee7509bfb 3035 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3036 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART2 MAX32625MBED: P1_3,P1_2 (Arduino D3,D2)
whismanoid 8:dffee7509bfb 3037 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART1 MAX32625MBED: P7_3,P7_2 ( ?? )
whismanoid 8:dffee7509bfb 3038 //
whismanoid 8:dffee7509bfb 3039 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3040 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3041 Serial DAPLINKserial(P1_1,P1_0); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3042 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3043 //
whismanoid 8:dffee7509bfb 3044 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3045 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3046 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3047 USBSerial serial;
whismanoid 8:dffee7509bfb 3048 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3049 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 8:dffee7509bfb 3050 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3051 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3052 #else
whismanoid 8:dffee7509bfb 3053 #if defined(SERIAL_TX)
whismanoid 8:dffee7509bfb 3054 #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..."
whismanoid 8:dffee7509bfb 3055 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3056 #elif defined(USBTX)
whismanoid 8:dffee7509bfb 3057 #warning "target not previously tested; guess serial pins are USBTX, USBRX..."
whismanoid 8:dffee7509bfb 3058 Serial serial(USBTX, USBRX); // tx, rx
whismanoid 8:dffee7509bfb 3059 #elif defined(UART_TX)
whismanoid 8:dffee7509bfb 3060 #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..."
whismanoid 8:dffee7509bfb 3061 Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3062 #else
whismanoid 8:dffee7509bfb 3063 #warning "target not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3064 #endif
whismanoid 8:dffee7509bfb 3065 #endif
whismanoid 8:dffee7509bfb 3066 //
whismanoid 8:dffee7509bfb 3067 #include "CmdLine.h"
whismanoid 8:dffee7509bfb 3068
whismanoid 8:dffee7509bfb 3069 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3070 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3071 CmdLine cmdLine_AUXserial(AUXserial, "AUXserial");
whismanoid 10:04022a61b527 3072 uint8_t Datalogger_enable_AUXserial = {
whismanoid 10:04022a61b527 3073 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3074 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 3075 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 3076 false
whismanoid 10:04022a61b527 3077 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3078 true
whismanoid 10:04022a61b527 3079 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3080 };
whismanoid 8:dffee7509bfb 3081 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3082 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3083 CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK");
whismanoid 8:dffee7509bfb 3084 uint8_t Datalogger_enable_DAPLINKserial = true;
whismanoid 8:dffee7509bfb 3085 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3086 CmdLine cmdLine(serial, "serial");
whismanoid 8:dffee7509bfb 3087 uint8_t Datalogger_enable_serial = true;
whismanoid 8:dffee7509bfb 3088 // CODE GENERATOR: example code for ADC: serial port declaration (end)
whismanoid 8:dffee7509bfb 3089
whismanoid 21:ac062a97a71d 3090
whismanoid 21:ac062a97a71d 3091 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3092 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 3093 #ifndef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3094 #define USE_DATALOGGER_CommandTable 1
whismanoid 23:c6c652bef4b9 3095 //~ #undef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3096 #endif
whismanoid 23:c6c652bef4b9 3097 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3098 const int COMMAND_TABLE_ROW_MAX = 10;
whismanoid 23:c6c652bef4b9 3099 const int COMMAND_TABLE_COL_MAX = 40;
whismanoid 23:c6c652bef4b9 3100 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3101 //
whismanoid 23:c6c652bef4b9 3102 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3103 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3104 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3105 char onButton1_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button1 event";
whismanoid 23:c6c652bef4b9 3106 char onButton1_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 23:c6c652bef4b9 3107 char onButton1_command_table_02[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 23:c6c652bef4b9 3108 char onButton1_command_table_03[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 23:c6c652bef4b9 3109 char onButton1_command_table_04[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 23:c6c652bef4b9 3110 char onButton1_command_table_05[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 23:c6c652bef4b9 3111 char onButton1_command_table_06[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 23:c6c652bef4b9 3112 char onButton1_command_table_07[COMMAND_TABLE_COL_MAX] = "LR";
whismanoid 23:c6c652bef4b9 3113 char onButton1_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3114 char onButton1_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3115 static char* onButton1_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3116 onButton1_command_table_00,
whismanoid 23:c6c652bef4b9 3117 onButton1_command_table_01,
whismanoid 23:c6c652bef4b9 3118 onButton1_command_table_02,
whismanoid 23:c6c652bef4b9 3119 onButton1_command_table_03,
whismanoid 23:c6c652bef4b9 3120 onButton1_command_table_04,
whismanoid 23:c6c652bef4b9 3121 onButton1_command_table_05,
whismanoid 23:c6c652bef4b9 3122 onButton1_command_table_06,
whismanoid 23:c6c652bef4b9 3123 onButton1_command_table_07,
whismanoid 23:c6c652bef4b9 3124 onButton1_command_table_08,
whismanoid 23:c6c652bef4b9 3125 onButton1_command_table_09,
whismanoid 23:c6c652bef4b9 3126 };
whismanoid 23:c6c652bef4b9 3127 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3128 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3129 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3130 char onButton2_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button2 event";
whismanoid 23:c6c652bef4b9 3131 char onButton2_command_table_01[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 23:c6c652bef4b9 3132 char onButton2_command_table_02[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 23:c6c652bef4b9 3133 char onButton2_command_table_03[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 23:c6c652bef4b9 3134 char onButton2_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3135 char onButton2_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3136 char onButton2_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3137 char onButton2_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3138 char onButton2_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3139 char onButton2_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3140 static char* onButton2_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3141 onButton2_command_table_00,
whismanoid 23:c6c652bef4b9 3142 onButton2_command_table_01,
whismanoid 23:c6c652bef4b9 3143 onButton2_command_table_02,
whismanoid 23:c6c652bef4b9 3144 onButton2_command_table_03,
whismanoid 23:c6c652bef4b9 3145 onButton2_command_table_04,
whismanoid 23:c6c652bef4b9 3146 onButton2_command_table_05,
whismanoid 23:c6c652bef4b9 3147 onButton2_command_table_06,
whismanoid 23:c6c652bef4b9 3148 onButton2_command_table_07,
whismanoid 23:c6c652bef4b9 3149 onButton2_command_table_08,
whismanoid 23:c6c652bef4b9 3150 onButton2_command_table_09,
whismanoid 23:c6c652bef4b9 3151 };
whismanoid 23:c6c652bef4b9 3152 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3153 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3154 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3155 char onButton3_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button3 event";
whismanoid 24:032f3683cb2a 3156 char onButton3_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 24:032f3683cb2a 3157 char onButton3_command_table_02[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 24:032f3683cb2a 3158 char onButton3_command_table_03[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 24:032f3683cb2a 3159 char onButton3_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3160 char onButton3_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3161 char onButton3_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3162 char onButton3_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3163 char onButton3_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3164 char onButton3_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3165 static char* onButton3_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 24:032f3683cb2a 3166 onButton3_command_table_00,
whismanoid 24:032f3683cb2a 3167 onButton3_command_table_01,
whismanoid 24:032f3683cb2a 3168 onButton3_command_table_02,
whismanoid 24:032f3683cb2a 3169 onButton3_command_table_03,
whismanoid 24:032f3683cb2a 3170 onButton3_command_table_04,
whismanoid 24:032f3683cb2a 3171 onButton3_command_table_05,
whismanoid 24:032f3683cb2a 3172 onButton3_command_table_06,
whismanoid 24:032f3683cb2a 3173 onButton3_command_table_07,
whismanoid 24:032f3683cb2a 3174 onButton3_command_table_08,
whismanoid 24:032f3683cb2a 3175 onButton3_command_table_09,
whismanoid 24:032f3683cb2a 3176 };
whismanoid 24:032f3683cb2a 3177 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3178 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3179 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3180 char onButton4_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button4 event";
whismanoid 30:07197a430869 3181 char onButton4_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE>0.7:active";
whismanoid 29:6a9edb6e973b 3182 char onButton4_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3183 char onButton4_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3184 char onButton4_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3185 char onButton4_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3186 char onButton4_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3187 char onButton4_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3188 char onButton4_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3189 char onButton4_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3190 static char* onButton4_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3191 onButton4_command_table_00,
whismanoid 29:6a9edb6e973b 3192 onButton4_command_table_01,
whismanoid 29:6a9edb6e973b 3193 onButton4_command_table_02,
whismanoid 29:6a9edb6e973b 3194 onButton4_command_table_03,
whismanoid 29:6a9edb6e973b 3195 onButton4_command_table_04,
whismanoid 29:6a9edb6e973b 3196 onButton4_command_table_05,
whismanoid 29:6a9edb6e973b 3197 onButton4_command_table_06,
whismanoid 29:6a9edb6e973b 3198 onButton4_command_table_07,
whismanoid 29:6a9edb6e973b 3199 onButton4_command_table_08,
whismanoid 29:6a9edb6e973b 3200 onButton4_command_table_09,
whismanoid 29:6a9edb6e973b 3201 };
whismanoid 29:6a9edb6e973b 3202 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3203 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3204 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3205 char onButton5_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button5 event";
whismanoid 30:07197a430869 3206 char onButton5_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE<0.6:sleep";
whismanoid 29:6a9edb6e973b 3207 char onButton5_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3208 char onButton5_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3209 char onButton5_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3210 char onButton5_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3211 char onButton5_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3212 char onButton5_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3213 char onButton5_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3214 char onButton5_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3215 static char* onButton5_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3216 onButton5_command_table_00,
whismanoid 29:6a9edb6e973b 3217 onButton5_command_table_01,
whismanoid 29:6a9edb6e973b 3218 onButton5_command_table_02,
whismanoid 29:6a9edb6e973b 3219 onButton5_command_table_03,
whismanoid 29:6a9edb6e973b 3220 onButton5_command_table_04,
whismanoid 29:6a9edb6e973b 3221 onButton5_command_table_05,
whismanoid 29:6a9edb6e973b 3222 onButton5_command_table_06,
whismanoid 29:6a9edb6e973b 3223 onButton5_command_table_07,
whismanoid 29:6a9edb6e973b 3224 onButton5_command_table_08,
whismanoid 29:6a9edb6e973b 3225 onButton5_command_table_09,
whismanoid 29:6a9edb6e973b 3226 };
whismanoid 29:6a9edb6e973b 3227 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3228 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3229 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3230 char onButton6_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button6 event";
whismanoid 29:6a9edb6e973b 3231 char onButton6_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3232 char onButton6_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3233 char onButton6_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3234 char onButton6_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3235 char onButton6_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3236 char onButton6_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3237 char onButton6_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3238 char onButton6_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3239 char onButton6_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3240 static char* onButton6_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3241 onButton6_command_table_00,
whismanoid 29:6a9edb6e973b 3242 onButton6_command_table_01,
whismanoid 29:6a9edb6e973b 3243 onButton6_command_table_02,
whismanoid 29:6a9edb6e973b 3244 onButton6_command_table_03,
whismanoid 29:6a9edb6e973b 3245 onButton6_command_table_04,
whismanoid 29:6a9edb6e973b 3246 onButton6_command_table_05,
whismanoid 29:6a9edb6e973b 3247 onButton6_command_table_06,
whismanoid 29:6a9edb6e973b 3248 onButton6_command_table_07,
whismanoid 29:6a9edb6e973b 3249 onButton6_command_table_08,
whismanoid 29:6a9edb6e973b 3250 onButton6_command_table_09,
whismanoid 29:6a9edb6e973b 3251 };
whismanoid 29:6a9edb6e973b 3252 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3253 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3254 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3255 char onButton7_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button7 event";
whismanoid 29:6a9edb6e973b 3256 char onButton7_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3257 char onButton7_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3258 char onButton7_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3259 char onButton7_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3260 char onButton7_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3261 char onButton7_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3262 char onButton7_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3263 char onButton7_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3264 char onButton7_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3265 static char* onButton7_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3266 onButton7_command_table_00,
whismanoid 29:6a9edb6e973b 3267 onButton7_command_table_01,
whismanoid 29:6a9edb6e973b 3268 onButton7_command_table_02,
whismanoid 29:6a9edb6e973b 3269 onButton7_command_table_03,
whismanoid 29:6a9edb6e973b 3270 onButton7_command_table_04,
whismanoid 29:6a9edb6e973b 3271 onButton7_command_table_05,
whismanoid 29:6a9edb6e973b 3272 onButton7_command_table_06,
whismanoid 29:6a9edb6e973b 3273 onButton7_command_table_07,
whismanoid 29:6a9edb6e973b 3274 onButton7_command_table_08,
whismanoid 29:6a9edb6e973b 3275 onButton7_command_table_09,
whismanoid 29:6a9edb6e973b 3276 };
whismanoid 29:6a9edb6e973b 3277 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3278 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3279 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3280 char onButton8_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button8 event";
whismanoid 29:6a9edb6e973b 3281 char onButton8_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3282 char onButton8_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3283 char onButton8_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3284 char onButton8_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3285 char onButton8_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3286 char onButton8_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3287 char onButton8_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3288 char onButton8_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3289 char onButton8_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3290 static char* onButton8_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3291 onButton8_command_table_00,
whismanoid 29:6a9edb6e973b 3292 onButton8_command_table_01,
whismanoid 29:6a9edb6e973b 3293 onButton8_command_table_02,
whismanoid 29:6a9edb6e973b 3294 onButton8_command_table_03,
whismanoid 29:6a9edb6e973b 3295 onButton8_command_table_04,
whismanoid 29:6a9edb6e973b 3296 onButton8_command_table_05,
whismanoid 29:6a9edb6e973b 3297 onButton8_command_table_06,
whismanoid 29:6a9edb6e973b 3298 onButton8_command_table_07,
whismanoid 29:6a9edb6e973b 3299 onButton8_command_table_08,
whismanoid 29:6a9edb6e973b 3300 onButton8_command_table_09,
whismanoid 29:6a9edb6e973b 3301 };
whismanoid 29:6a9edb6e973b 3302 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3303 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3304 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3305 char onButton9_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button9 event";
whismanoid 29:6a9edb6e973b 3306 char onButton9_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3307 char onButton9_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3308 char onButton9_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3309 char onButton9_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3310 char onButton9_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3311 char onButton9_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3312 char onButton9_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3313 char onButton9_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3314 char onButton9_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3315 static char* onButton9_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3316 onButton9_command_table_00,
whismanoid 29:6a9edb6e973b 3317 onButton9_command_table_01,
whismanoid 29:6a9edb6e973b 3318 onButton9_command_table_02,
whismanoid 29:6a9edb6e973b 3319 onButton9_command_table_03,
whismanoid 29:6a9edb6e973b 3320 onButton9_command_table_04,
whismanoid 29:6a9edb6e973b 3321 onButton9_command_table_05,
whismanoid 29:6a9edb6e973b 3322 onButton9_command_table_06,
whismanoid 29:6a9edb6e973b 3323 onButton9_command_table_07,
whismanoid 29:6a9edb6e973b 3324 onButton9_command_table_08,
whismanoid 29:6a9edb6e973b 3325 onButton9_command_table_09,
whismanoid 29:6a9edb6e973b 3326 };
whismanoid 29:6a9edb6e973b 3327 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3328 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3329 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3330 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 3331 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3332 bool g_Run_command_table_running = false;
whismanoid 23:c6c652bef4b9 3333 void Run_command_table(char* command_table[])
whismanoid 23:c6c652bef4b9 3334 {
whismanoid 23:c6c652bef4b9 3335 // command_table: perform list of commands
whismanoid 31:47eee7e0cc2d 3336 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3337 if (g_Run_command_table_running) {
whismanoid 31:47eee7e0cc2d 3338 // TODO: button event chaining is not supported at this time
whismanoid 31:47eee7e0cc2d 3339 } // if (g_Run_command_table_running)
whismanoid 31:47eee7e0cc2d 3340 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3341 g_Run_command_table_running = true;
whismanoid 23:c6c652bef4b9 3342 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 3343 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 3344 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 23:c6c652bef4b9 3345 cmdLine.clear();
whismanoid 31:47eee7e0cc2d 3346 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3347 //~ char* strIndex = command_table[lineIndex];
whismanoid 23:c6c652bef4b9 3348 for (char* strIndex = command_table[lineIndex]; *strIndex != '\0'; strIndex++)
whismanoid 23:c6c652bef4b9 3349 {
whismanoid 23:c6c652bef4b9 3350 cmdLine.append(*strIndex);
whismanoid 23:c6c652bef4b9 3351 }
whismanoid 23:c6c652bef4b9 3352 cmdLine.append('\r'); // append \r invokes onEOLcommandParser to handle command
whismanoid 23:c6c652bef4b9 3353 }
whismanoid 31:47eee7e0cc2d 3354 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3355 g_Run_command_table_running = false;
whismanoid 31:47eee7e0cc2d 3356 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3357 }
whismanoid 23:c6c652bef4b9 3358 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3359 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3360 // When user presses button BUTTON1, perform actions
whismanoid 21:ac062a97a71d 3361 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3362 void onButton1FallingEdge(void)
whismanoid 21:ac062a97a71d 3363 {
whismanoid 21:ac062a97a71d 3364 //~ void SelfTest(CmdLine & cmdLine);
whismanoid 21:ac062a97a71d 3365 //~ SelfTest(cmdLine_serial);
whismanoid 22:d6dc8a85f435 3366 //
whismanoid 23:c6c652bef4b9 3367 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3368 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3369 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3370 Run_command_table(onButton1_command_table);
whismanoid 23:c6c652bef4b9 3371 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3372 }
whismanoid 21:ac062a97a71d 3373 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3374
whismanoid 21:ac062a97a71d 3375 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3376 // When user presses button BUTTON2, perform actions
whismanoid 21:ac062a97a71d 3377 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3378 void onButton2FallingEdge(void)
whismanoid 21:ac062a97a71d 3379 {
whismanoid 21:ac062a97a71d 3380 // TBD demo configuration
whismanoid 21:ac062a97a71d 3381 // TODO diagnostic LED
whismanoid 21:ac062a97a71d 3382 // led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 22:d6dc8a85f435 3383 //
whismanoid 23:c6c652bef4b9 3384 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3385 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3386 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3387 Run_command_table(onButton2_command_table);
whismanoid 23:c6c652bef4b9 3388 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3389 }
whismanoid 21:ac062a97a71d 3390 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3391
whismanoid 24:032f3683cb2a 3392 //--------------------------------------------------
whismanoid 29:6a9edb6e973b 3393 // When user presses button BUTTON3, perform actions
whismanoid 24:032f3683cb2a 3394 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3395 void onButton3FallingEdge(void)
whismanoid 24:032f3683cb2a 3396 {
whismanoid 24:032f3683cb2a 3397 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 24:032f3683cb2a 3398 // command_table: list of commands to perform on button press
whismanoid 24:032f3683cb2a 3399 // command_table: perform list of commands
whismanoid 24:032f3683cb2a 3400 Run_command_table(onButton3_command_table);
whismanoid 24:032f3683cb2a 3401 #endif // USE_DATALOGGER_CommandTable
whismanoid 24:032f3683cb2a 3402 }
whismanoid 24:032f3683cb2a 3403 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3404 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3405 void onButton4FallingEdge(void)
whismanoid 29:6a9edb6e973b 3406 {
whismanoid 29:6a9edb6e973b 3407 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3408 Run_command_table(onButton4_command_table);
whismanoid 29:6a9edb6e973b 3409 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3410 }
whismanoid 29:6a9edb6e973b 3411 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3412 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3413 void onButton5FallingEdge(void)
whismanoid 29:6a9edb6e973b 3414 {
whismanoid 29:6a9edb6e973b 3415 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3416 Run_command_table(onButton5_command_table);
whismanoid 29:6a9edb6e973b 3417 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3418 }
whismanoid 29:6a9edb6e973b 3419 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3420 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3421 void onButton6FallingEdge(void)
whismanoid 29:6a9edb6e973b 3422 {
whismanoid 29:6a9edb6e973b 3423 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3424 Run_command_table(onButton6_command_table);
whismanoid 29:6a9edb6e973b 3425 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3426 }
whismanoid 29:6a9edb6e973b 3427 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3428 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3429 void onButton7FallingEdge(void)
whismanoid 29:6a9edb6e973b 3430 {
whismanoid 29:6a9edb6e973b 3431 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3432 Run_command_table(onButton7_command_table);
whismanoid 29:6a9edb6e973b 3433 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3434 }
whismanoid 29:6a9edb6e973b 3435 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3436 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3437 void onButton8FallingEdge(void)
whismanoid 29:6a9edb6e973b 3438 {
whismanoid 29:6a9edb6e973b 3439 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3440 Run_command_table(onButton8_command_table);
whismanoid 29:6a9edb6e973b 3441 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3442 }
whismanoid 29:6a9edb6e973b 3443 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3444 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3445 void onButton9FallingEdge(void)
whismanoid 29:6a9edb6e973b 3446 {
whismanoid 29:6a9edb6e973b 3447 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3448 Run_command_table(onButton9_command_table);
whismanoid 29:6a9edb6e973b 3449 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3450 }
whismanoid 29:6a9edb6e973b 3451 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3452
whismanoid 4:d9b05924ad4c 3453 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3454 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3455 inline void print_command_prompt()
whismanoid 4:d9b05924ad4c 3456 {
whismanoid 4:d9b05924ad4c 3457 //~ Serial.println(F(">"));
whismanoid 4:d9b05924ad4c 3458 cmdLine.serial().printf("\r\n> ");
whismanoid 4:d9b05924ad4c 3459 }
whismanoid 4:d9b05924ad4c 3460 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3461
whismanoid 4:d9b05924ad4c 3462 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3463 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3464 void main_menu_status(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 3465 {
whismanoid 4:d9b05924ad4c 3466 cmdLine.serial().printf("\r\nMain menu");
whismanoid 4:d9b05924ad4c 3467 #if APPLICATION_MAX5715 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3468 cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC");
whismanoid 4:d9b05924ad4c 3469 #elif APPLICATION_MAX11131 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3470 cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC");
whismanoid 4:d9b05924ad4c 3471 #elif APPLICATION_MAX5171 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3472 cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC");
whismanoid 4:d9b05924ad4c 3473 #elif APPLICATION_MAX11410 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3474 cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC");
whismanoid 4:d9b05924ad4c 3475 #elif APPLICATION_MAX12345 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3476 cmdLine.serial().printf(" MAX12345");
whismanoid 16:819c5aaf5271 3477 #elif MAX40108_DEMO // main_menu_status banner
whismanoid 17:9397ea3ea7e9 3478 cmdLine.serial().printf(" MAX40108_U%d", MAX40108_DEMO);
whismanoid 36:e7aac874b8be 3479 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 3480 // data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 3481 cmdLine.serial().printf(" [s/n %d]", BOARD_SERIAL_NUMBER);
whismanoid 36:e7aac874b8be 3482 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 3483 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 3484 //
whismanoid 36:e7aac874b8be 3485 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 3486 #ifdef FW_REV
whismanoid 37:3f369235e5bc 3487 cmdLine.serial().printf(" [FW_REV %d]", FW_REV);
whismanoid 37:3f369235e5bc 3488 #endif // FW_REV
whismanoid 4:d9b05924ad4c 3489 #else
whismanoid 4:d9b05924ad4c 3490 //cmdLine.serial().printf(" ");
whismanoid 4:d9b05924ad4c 3491 #endif
whismanoid 4:d9b05924ad4c 3492 //cmdLine.serial().printf(" %s", TARGET_NAME);
whismanoid 4:d9b05924ad4c 3493 if (cmdLine.nameStr())
whismanoid 4:d9b05924ad4c 3494 {
whismanoid 4:d9b05924ad4c 3495 cmdLine.serial().printf(" [%s]", cmdLine.nameStr());
whismanoid 4:d9b05924ad4c 3496 }
whismanoid 4:d9b05924ad4c 3497 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3498 cmdLine.serial().printf(" [Button1");
whismanoid 4:d9b05924ad4c 3499 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3500 cmdLine.serial().printf("2");
whismanoid 24:032f3683cb2a 3501 #endif
whismanoid 24:032f3683cb2a 3502 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3503 cmdLine.serial().printf("3");
whismanoid 29:6a9edb6e973b 3504 #endif
whismanoid 29:6a9edb6e973b 3505 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3506 cmdLine.serial().printf("4");
whismanoid 29:6a9edb6e973b 3507 #endif
whismanoid 29:6a9edb6e973b 3508 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3509 cmdLine.serial().printf("5");
whismanoid 29:6a9edb6e973b 3510 #endif
whismanoid 29:6a9edb6e973b 3511 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3512 cmdLine.serial().printf("6");
whismanoid 29:6a9edb6e973b 3513 #endif
whismanoid 29:6a9edb6e973b 3514 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3515 cmdLine.serial().printf("7");
whismanoid 29:6a9edb6e973b 3516 #endif
whismanoid 29:6a9edb6e973b 3517 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3518 cmdLine.serial().printf("8");
whismanoid 29:6a9edb6e973b 3519 #endif
whismanoid 29:6a9edb6e973b 3520 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3521 cmdLine.serial().printf("9");
whismanoid 29:6a9edb6e973b 3522 #endif
whismanoid 29:6a9edb6e973b 3523 cmdLine.serial().printf("]");
whismanoid 29:6a9edb6e973b 3524 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 4:d9b05924ad4c 3525 #if HAS_BUTTON1_DEMO
whismanoid 4:d9b05924ad4c 3526 // print BUTTON1 status
whismanoid 4:d9b05924ad4c 3527 cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read());
whismanoid 4:d9b05924ad4c 3528 #endif
whismanoid 4:d9b05924ad4c 3529 #if HAS_BUTTON2_DEMO
whismanoid 24:032f3683cb2a 3530 // print BUTTON2 status
whismanoid 4:d9b05924ad4c 3531 cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read());
whismanoid 4:d9b05924ad4c 3532 #endif
whismanoid 24:032f3683cb2a 3533 #if HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 3534 // print BUTTON3 status
whismanoid 24:032f3683cb2a 3535 cmdLine.serial().printf("\r\n BUTTON3 = %d", button3.read());
whismanoid 24:032f3683cb2a 3536 #endif
whismanoid 4:d9b05924ad4c 3537 cmdLine.serial().printf("\r\n ? -- help");
whismanoid 4:d9b05924ad4c 3538 }
whismanoid 4:d9b05924ad4c 3539 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3540
whismanoid 28:a9a3a9db592b 3541 //--------------------------------------------------
whismanoid 28:a9a3a9db592b 3542 #ifndef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3543 #define USE_DATALOGGER_TRIGGER_HELP_BRIEF 1
whismanoid 28:a9a3a9db592b 3544 //~ #undef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3545 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3546
whismanoid 4:d9b05924ad4c 3547 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3548 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3549 void main_menu_help(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 3550 {
whismanoid 4:d9b05924ad4c 3551 // ? -- help
whismanoid 4:d9b05924ad4c 3552 //~ cmdLine.serial().printf("\r\nMenu:");
whismanoid 10:04022a61b527 3553 //
whismanoid 4:d9b05924ad4c 3554 cmdLine.serial().printf("\r\n # -- lines beginning with # are comments");
whismanoid 10:04022a61b527 3555 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 3556 cmdLine.serial().printf("\r\n ! -- Init");
whismanoid 10:04022a61b527 3557 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 3558 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 3559 cmdLine.serial().printf("\r\n . -- SelfTest");
whismanoid 4:d9b05924ad4c 3560 #endif // USE_SELFTEST
whismanoid 9:45f98573eb6d 3561 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 9:45f98573eb6d 3562 // CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register
whismanoid 9:45f98573eb6d 3563 cmdLine.serial().printf("\r\n * -- read core registers\r\n *regname? -- read register\r\n *regname=regvalue -- write register");
whismanoid 9:45f98573eb6d 3564 // cmdLine.serial().printf("\r\n 01 23 45 67 89 ab cd ef -- write and read raw hex codes");
whismanoid 10:04022a61b527 3565 #endif // USE_STAR_REG_READWRITE
whismanoid 10:04022a61b527 3566 //
whismanoid 10:04022a61b527 3567 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3568 // Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_help
whismanoid 10:04022a61b527 3569 //~ cmdLine.serial().printf("\r\n > -- auxiliary UART port");
whismanoid 10:04022a61b527 3570 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3571 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3572 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3573 if (cmdLine_AUXserial.nameStr())
whismanoid 10:04022a61b527 3574 {
whismanoid 10:04022a61b527 3575 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_AUXserial.nameStr());
whismanoid 10:04022a61b527 3576 }
whismanoid 10:04022a61b527 3577 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3578 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3579 if (cmdLine_DAPLINKserial.nameStr())
whismanoid 10:04022a61b527 3580 {
whismanoid 10:04022a61b527 3581 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_DAPLINKserial.nameStr());
whismanoid 10:04022a61b527 3582 }
whismanoid 10:04022a61b527 3583 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3584 # if HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3585 // WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3586 cmdLine.serial().printf("\r\n >xyzzy -- Forward command/data 'xyzzy' to aux TX/RX");
whismanoid 10:04022a61b527 3587 cmdLine.serial().printf("\r\n >>xyzzy -- Forward 'xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 3588 cmdLine.serial().printf("\r\n >>>xyzzy -- Forward '>xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 3589 #if 0
whismanoid 10:04022a61b527 3590 cmdLine.serial().printf("\r\n >tx_wait_echo=%d -- configure TX wait for each character echo", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 3591 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 3592 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 3593 #endif
whismanoid 20:78ef670955d4 3594 #if 1 // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 3595 cmdLine.serial().printf("\r\n >baud=%d message_ms=%d rx_idle_ms=%d rx_max_count=%d rx_eot=%d",
whismanoid 20:78ef670955d4 3596 g_auxSerialCom_baud,
whismanoid 20:78ef670955d4 3597 g_auxSerialCom_message_ms,
whismanoid 20:78ef670955d4 3598 g_auxSerialCom_rx_idle_ms,
whismanoid 20:78ef670955d4 3599 g_auxSerialCom_rx_max_count,
whismanoid 20:78ef670955d4 3600 g_auxSerialCom_rx_eot);
whismanoid 20:78ef670955d4 3601 #else // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 3602 cmdLine.serial().printf("\r\n >baud=%d -- configure aux TX/RX port", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 3603 cmdLine.serial().printf("\r\n >message_ms=%d -- maximum RX message total response time", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 3604 cmdLine.serial().printf("\r\n >rx_idle_ms=%d -- maximum RX message idle time between characters", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 3605 cmdLine.serial().printf("\r\n >rx_max_count=%d -- maximum RX message total length", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 3606 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 3607 #endif // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 10:04022a61b527 3608 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3609 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3610 //
whismanoid 4:d9b05924ad4c 3611 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 3612 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3613 // Datalog trigger menu
whismanoid 28:a9a3a9db592b 3614 // brief toplevel heading for datalog help L
whismanoid 28:a9a3a9db592b 3615 // L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 3616 cmdLine.serial().printf("\r\n L -- halt the datalogger; show more commands");
whismanoid 28:a9a3a9db592b 3617 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 28:a9a3a9db592b 3618 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 28:a9a3a9db592b 3619 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 28:a9a3a9db592b 3620 //
whismanoid 28:a9a3a9db592b 3621 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 3622 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 3623 //
whismanoid 28:a9a3a9db592b 3624 cmdLine.serial().printf("\r\n LT count=%d base=%dms -- Datalog timer", g_timer_interval_count, g_timer_interval_msec); // trigger_Timer
whismanoid 28:a9a3a9db592b 3625 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3626 //~ cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 3627 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3628 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 3629 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 3630 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 3631 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 9:45f98573eb6d 3632 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 9:45f98573eb6d 3633 //
whismanoid 17:9397ea3ea7e9 3634 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 4:d9b05924ad4c 3635 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 9:45f98573eb6d 3636 //
whismanoid 17:9397ea3ea7e9 3637 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 3638 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 17:9397ea3ea7e9 3639 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 3640 //
whismanoid 9:45f98573eb6d 3641 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 3642 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 3643 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 3644 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 9:45f98573eb6d 3645 //
whismanoid 17:9397ea3ea7e9 3646 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 9:45f98573eb6d 3647 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 3648 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 3649 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 3650 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 3651 //
whismanoid 17:9397ea3ea7e9 3652 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3653 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 17:9397ea3ea7e9 3654 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 9:45f98573eb6d 3655 //
whismanoid 9:45f98573eb6d 3656 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 3657 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 3658 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 3659 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 3660 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 9:45f98573eb6d 3661 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 9:45f98573eb6d 3662 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 9:45f98573eb6d 3663 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 9:45f98573eb6d 3664 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 9:45f98573eb6d 3665 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 9:45f98573eb6d 3666 //
whismanoid 9:45f98573eb6d 3667 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 3668 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 9:45f98573eb6d 3669 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 9:45f98573eb6d 3670 //
whismanoid 9:45f98573eb6d 3671 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 3672 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 3673 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 9:45f98573eb6d 3674 //
whismanoid 9:45f98573eb6d 3675 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 3676 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 9:45f98573eb6d 3677 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 3678 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 9:45f98573eb6d 3679 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 3680 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 9:45f98573eb6d 3681 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 3682 //
whismanoid 9:45f98573eb6d 3683 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 3684 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 9:45f98573eb6d 3685 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 9:45f98573eb6d 3686 //
whismanoid 9:45f98573eb6d 3687 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 3688 //
whismanoid 9:45f98573eb6d 3689 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 3690 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 3691 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 3692 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 3693 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 9:45f98573eb6d 3694 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3695 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 9:45f98573eb6d 3696 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3697 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3698 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 9:45f98573eb6d 3699 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3700 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 9:45f98573eb6d 3701 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3702 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 9:45f98573eb6d 3703 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3704 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3705 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 9:45f98573eb6d 3706 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3707 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 3708 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 3709 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 3710 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3711 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 3712 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 3713 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 3714 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3715 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 3716 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 3717 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 3718 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 3719 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 3720 //
whismanoid 4:d9b05924ad4c 3721 //cmdLine.serial().print(F("\r\n ! -- Initial Configuration"));
whismanoid 4:d9b05924ad4c 3722 //
whismanoid 4:d9b05924ad4c 3723 // % standardize diagnostic commands
whismanoid 4:d9b05924ad4c 3724 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 3725 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 3726 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 3727 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 3728 // %Ppin df=xx -- pwm output
whismanoid 4:d9b05924ad4c 3729 // %Wpin -- measure high pulsewidth input in usec
whismanoid 4:d9b05924ad4c 3730 // %wpin -- measure low pulsewidth input in usec
whismanoid 4:d9b05924ad4c 3731 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 3732 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 3733 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 3734 // %IW ADDR=? cmd=? data,data,data -- write
whismanoid 4:d9b05924ad4c 3735 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 3736 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3737 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 3738 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 3739 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 3740 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 3741 // A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 3742 //
whismanoid 23:c6c652bef4b9 3743 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3744 #if USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3745 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 3746 // TODO: %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 3747 // TODO: future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 3748 // TODO: future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 3749 // TODO: %B1@ view command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 3750 // TODO: %B1@+ command add new row (if there is room to add) (ignore one space before command)
whismanoid 23:c6c652bef4b9 3751 // TODO: %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 3752 // TODO: %B1@-~~~ clear entire command table
whismanoid 23:c6c652bef4b9 3753 // TODO: %B1@nnn command replace row number nnn (ignore one space before command)
whismanoid 23:c6c652bef4b9 3754 // TODO: %B1@! disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 3755 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 3756 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 30:07197a430869 3757 cmdLine.serial().printf("\r\n %%B1! trigger Button1 event; %%B1@ -- view/edit command table");
whismanoid 23:c6c652bef4b9 3758 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3759 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3760 #if HAS_digitalInOuts
whismanoid 4:d9b05924ad4c 3761 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 3762 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 3763 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 3764 cmdLine.serial().printf("\r\n %%Hn {pin:");
whismanoid 4:d9b05924ad4c 3765 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3766 cmdLine.serial().printf("} -- High Output");
whismanoid 4:d9b05924ad4c 3767 cmdLine.serial().printf("\r\n %%Ln {pin:");
whismanoid 4:d9b05924ad4c 3768 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3769 cmdLine.serial().printf("} -- Low Output");
whismanoid 4:d9b05924ad4c 3770 cmdLine.serial().printf("\r\n %%?n {pin:");
whismanoid 4:d9b05924ad4c 3771 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3772 cmdLine.serial().printf("} -- Input");
whismanoid 4:d9b05924ad4c 3773 #endif
whismanoid 4:d9b05924ad4c 3774
whismanoid 4:d9b05924ad4c 3775 #if HAS_analogIns
whismanoid 4:d9b05924ad4c 3776 // Menu A) analogRead A0..7
whismanoid 4:d9b05924ad4c 3777 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 3778 // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0)
whismanoid 37:3f369235e5bc 3779 cmdLine.serial().printf("\r\n %%A -- analogRead");
whismanoid 37:3f369235e5bc 3780 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3781 // %A avg=%d -- help string display Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 3782 cmdLine.serial().printf("; %%A avg=%d -- average", Platform_AIN_Average_N);
whismanoid 37:3f369235e5bc 3783 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 3784 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3785 // %A cal? view/export raw calibration values for all channels
whismanoid 37:3f369235e5bc 3786 cmdLine.serial().printf("; %%A cal? -- calibration");
whismanoid 34:a1993a1ee904 3787 #endif // HAS_Platform_AIN_Calibration
whismanoid 4:d9b05924ad4c 3788 #endif
whismanoid 4:d9b05924ad4c 3789
whismanoid 4:d9b05924ad4c 3790 #if HAS_SPI2_MAX541
whismanoid 4:d9b05924ad4c 3791 // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 4:d9b05924ad4c 3792 cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)");
whismanoid 4:d9b05924ad4c 3793 #endif
whismanoid 4:d9b05924ad4c 3794
whismanoid 4:d9b05924ad4c 3795 #if HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3796 // TODO: support I2C HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3797 // VERIFY: I2C utility commands SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3798 // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz);
whismanoid 4:d9b05924ad4c 3799 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 3800 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 3801 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 3802 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 4:d9b05924ad4c 3803 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 3804 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3805 //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope
whismanoid 4:d9b05924ad4c 3806 cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 4:d9b05924ad4c 3807 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 4:d9b05924ad4c 3808 (g_I2C_SCL_Hz / 1000.));
whismanoid 4:d9b05924ad4c 3809 cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read",
whismanoid 4:d9b05924ad4c 3810 g_I2C_deviceAddress7);
whismanoid 4:d9b05924ad4c 3811 //
whismanoid 4:d9b05924ad4c 3812 #if SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3813 // Menu ^ cmd=?) i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3814 cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data");
whismanoid 4:d9b05924ad4c 3815 // test low-level I2C i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3816 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3817 //cmdLine.serial().printf(" H) Hunt for attached I2C devices");
whismanoid 4:d9b05924ad4c 3818 cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices");
whismanoid 4:d9b05924ad4c 3819 // cmdLine.serial().printf(" s) search i2c address");
whismanoid 4:d9b05924ad4c 3820 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3821
whismanoid 4:d9b05924ad4c 3822 #if HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3823 // TODO: support SPI HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3824 // SPI test command S (mosiData)+
whismanoid 4:d9b05924ad4c 3825 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 3826 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 3827 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 3828 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 3829 // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 4:d9b05924ad4c 3830 // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 4:d9b05924ad4c 3831 // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 4:d9b05924ad4c 3832 // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 4:d9b05924ad4c 3833 // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 4:d9b05924ad4c 3834 // mode | POL PHA
whismanoid 4:d9b05924ad4c 3835 // -----+--------
whismanoid 4:d9b05924ad4c 3836 // 0 | 0 0
whismanoid 4:d9b05924ad4c 3837 // 1 | 0 1
whismanoid 4:d9b05924ad4c 3838 // 2 | 1 0
whismanoid 4:d9b05924ad4c 3839 // 3 | 1 1
whismanoid 4:d9b05924ad4c 3840 //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0");
whismanoid 4:d9b05924ad4c 3841 // 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 3842 cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config",
whismanoid 4:d9b05924ad4c 3843 g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.),
whismanoid 4:d9b05924ad4c 3844 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 4:d9b05924ad4c 3845 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0));
whismanoid 4:d9b05924ad4c 3846 cmdLine.serial().printf("\r\n %%SD -- SPI diagnostic messages ");
whismanoid 4:d9b05924ad4c 3847 if (g_MAX11410_device.onSPIprint) {
whismanoid 4:d9b05924ad4c 3848 cmdLine.serial().printf("hide");
whismanoid 4:d9b05924ad4c 3849 }
whismanoid 4:d9b05924ad4c 3850 else {
whismanoid 4:d9b05924ad4c 3851 cmdLine.serial().printf("show");
whismanoid 4:d9b05924ad4c 3852 }
whismanoid 4:d9b05924ad4c 3853 cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes");
whismanoid 4:d9b05924ad4c 3854 // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0
whismanoid 4:d9b05924ad4c 3855 #endif // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3856 //
whismanoid 4:d9b05924ad4c 3857 // Application-specific commands (help text) here
whismanoid 4:d9b05924ad4c 3858 //
whismanoid 4:d9b05924ad4c 3859 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3860 cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3861 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3862 //
whismanoid 4:d9b05924ad4c 3863
whismanoid 4:d9b05924ad4c 3864 //~ extern void MAX11410_menu_help(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp\n
whismanoid 4:d9b05924ad4c 3865 //~ MAX11410_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 3866 }
whismanoid 4:d9b05924ad4c 3867 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3868
whismanoid 4:d9b05924ad4c 3869 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 15:37c83ec50ea0 3870
whismanoid 15:37c83ec50ea0 3871 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 3872 void pinsMonitor_submenu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 15:37c83ec50ea0 3873 {
whismanoid 15:37c83ec50ea0 3874 // % diagnostic commands submenu
whismanoid 15:37c83ec50ea0 3875 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 3876 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 3877 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 3878 // %A %Apin -- analog input
whismanoid 15:37c83ec50ea0 3879 // %Ppin df=xx -- pwm output
whismanoid 15:37c83ec50ea0 3880 // %Wpin -- measure high pulsewidth input in usec
whismanoid 15:37c83ec50ea0 3881 // %wpin -- measure low pulsewidth input in usec
whismanoid 15:37c83ec50ea0 3882 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 3883 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 3884 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 3885 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 3886 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 3887 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 3888 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 3889 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 3890 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 3891 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 3892 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 3893 //
whismanoid 15:37c83ec50ea0 3894 char strPinIndex[3];
whismanoid 15:37c83ec50ea0 3895 strPinIndex[0] = cmdLine[2];
whismanoid 15:37c83ec50ea0 3896 strPinIndex[1] = cmdLine[3];
whismanoid 15:37c83ec50ea0 3897 strPinIndex[2] = '\0';
whismanoid 15:37c83ec50ea0 3898 int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 15:37c83ec50ea0 3899 //cmdLine.serial().printf(" pinIndex=%d ", pinIndex);
whismanoid 15:37c83ec50ea0 3900 //
whismanoid 15:37c83ec50ea0 3901 // get next character
whismanoid 15:37c83ec50ea0 3902 switch (cmdLine[1])
whismanoid 15:37c83ec50ea0 3903 {
whismanoid 23:c6c652bef4b9 3904 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3905 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3906 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 3907 case 'B': case 'b':
whismanoid 23:c6c652bef4b9 3908 {
whismanoid 24:032f3683cb2a 3909 int command_table_button_index = 1;
whismanoid 23:c6c652bef4b9 3910 // %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 3911 // future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 3912 // future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 3913 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3914 // cmdLine[2] == '1' selects onButton1_command_table
whismanoid 23:c6c652bef4b9 3915 char** command_table = onButton1_command_table;
whismanoid 23:c6c652bef4b9 3916 #endif
whismanoid 24:032f3683cb2a 3917 switch(cmdLine[2])
whismanoid 24:032f3683cb2a 3918 {
whismanoid 24:032f3683cb2a 3919 default:
whismanoid 24:032f3683cb2a 3920 case '1': case 'A': case 'a': case '!':
whismanoid 24:032f3683cb2a 3921 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3922 command_table_button_index = 1;
whismanoid 24:032f3683cb2a 3923 command_table = onButton1_command_table;
whismanoid 24:032f3683cb2a 3924 #endif
whismanoid 24:032f3683cb2a 3925 break;
whismanoid 24:032f3683cb2a 3926 case '2': case 'B': case 'b': case '@':
whismanoid 23:c6c652bef4b9 3927 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3928 command_table_button_index = 2;
whismanoid 24:032f3683cb2a 3929 command_table = onButton2_command_table;
whismanoid 24:032f3683cb2a 3930 #endif
whismanoid 24:032f3683cb2a 3931 break;
whismanoid 24:032f3683cb2a 3932 case '3': case 'C': case 'c': case '#':
whismanoid 23:c6c652bef4b9 3933 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3934 command_table_button_index = 3;
whismanoid 24:032f3683cb2a 3935 command_table = onButton3_command_table;
whismanoid 24:032f3683cb2a 3936 #endif
whismanoid 24:032f3683cb2a 3937 break;
whismanoid 29:6a9edb6e973b 3938 case '4':
whismanoid 29:6a9edb6e973b 3939 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3940 command_table_button_index = 4;
whismanoid 29:6a9edb6e973b 3941 command_table = onButton4_command_table;
whismanoid 29:6a9edb6e973b 3942 #endif
whismanoid 29:6a9edb6e973b 3943 break;
whismanoid 29:6a9edb6e973b 3944 case '5':
whismanoid 29:6a9edb6e973b 3945 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3946 command_table_button_index = 5;
whismanoid 29:6a9edb6e973b 3947 command_table = onButton5_command_table;
whismanoid 29:6a9edb6e973b 3948 #endif
whismanoid 29:6a9edb6e973b 3949 break;
whismanoid 29:6a9edb6e973b 3950 case '6':
whismanoid 29:6a9edb6e973b 3951 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3952 command_table_button_index = 6;
whismanoid 29:6a9edb6e973b 3953 command_table = onButton6_command_table;
whismanoid 29:6a9edb6e973b 3954 #endif
whismanoid 29:6a9edb6e973b 3955 break;
whismanoid 29:6a9edb6e973b 3956 case '7':
whismanoid 29:6a9edb6e973b 3957 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3958 command_table_button_index = 7;
whismanoid 29:6a9edb6e973b 3959 command_table = onButton7_command_table;
whismanoid 29:6a9edb6e973b 3960 #endif
whismanoid 29:6a9edb6e973b 3961 break;
whismanoid 29:6a9edb6e973b 3962 case '8':
whismanoid 29:6a9edb6e973b 3963 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3964 command_table_button_index = 8;
whismanoid 29:6a9edb6e973b 3965 command_table = onButton8_command_table;
whismanoid 29:6a9edb6e973b 3966 #endif
whismanoid 29:6a9edb6e973b 3967 break;
whismanoid 29:6a9edb6e973b 3968 case '9':
whismanoid 29:6a9edb6e973b 3969 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3970 command_table_button_index = 9;
whismanoid 29:6a9edb6e973b 3971 command_table = onButton9_command_table;
whismanoid 29:6a9edb6e973b 3972 #endif
whismanoid 29:6a9edb6e973b 3973 break;
whismanoid 24:032f3683cb2a 3974 }
whismanoid 24:032f3683cb2a 3975 //
whismanoid 23:c6c652bef4b9 3976 switch(cmdLine[3])
whismanoid 23:c6c652bef4b9 3977 {
whismanoid 23:c6c652bef4b9 3978 case '@':
whismanoid 23:c6c652bef4b9 3979 {
whismanoid 23:c6c652bef4b9 3980 // %B1@ view/edit command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 3981 int editRowIndex = 0;
whismanoid 23:c6c652bef4b9 3982 int command_table_row_count = 0;
whismanoid 23:c6c652bef4b9 3983 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 3984 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 3985 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 3986 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 3987 }
whismanoid 24:032f3683cb2a 3988 //
whismanoid 24:032f3683cb2a 3989 // ignore extra spaces before the command
whismanoid 24:032f3683cb2a 3990 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 24:032f3683cb2a 3991 int argIndex;
whismanoid 24:032f3683cb2a 3992 for (argIndex = 5; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 3993 {
whismanoid 24:032f3683cb2a 3994 if (cmdLine[argIndex] == ' ') break;
whismanoid 24:032f3683cb2a 3995 }
whismanoid 24:032f3683cb2a 3996 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 3997 {
whismanoid 24:032f3683cb2a 3998 if (cmdLine[argIndex] != ' ') break;
whismanoid 23:c6c652bef4b9 3999 }
whismanoid 23:c6c652bef4b9 4000 //
whismanoid 23:c6c652bef4b9 4001 // Edit the contents of command_table
whismanoid 23:c6c652bef4b9 4002 switch (cmdLine[4]) // %B1@... -- Edit the contents of command_table
whismanoid 23:c6c652bef4b9 4003 {
whismanoid 23:c6c652bef4b9 4004 case '0': case '1': case '2': case '3': case '4':
whismanoid 23:c6c652bef4b9 4005 case '5': case '6': case '7': case '8': case '9':
whismanoid 24:032f3683cb2a 4006 // %B1@nnn command replace row number nnn
whismanoid 23:c6c652bef4b9 4007 // edit row data
whismanoid 33:70a28cfe9e01 4008 // get row number to edit from cmdLine[4]
whismanoid 33:70a28cfe9e01 4009 editRowIndex = atoi(cmdLine.str()+4);
whismanoid 23:c6c652bef4b9 4010 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4011 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 4012 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 28:a9a3a9db592b 4013 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 4014 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 4015 cmdLine.serial().printf("\r\n cannot replace row %d with nothing",
whismanoid 28:a9a3a9db592b 4016 editRowIndex);
whismanoid 28:a9a3a9db592b 4017 }
whismanoid 28:a9a3a9db592b 4018 else
whismanoid 28:a9a3a9db592b 4019 {
whismanoid 28:a9a3a9db592b 4020 // update row
whismanoid 28:a9a3a9db592b 4021 cmdLine.serial().printf("\r\n replace row %d with \"%s\"",
whismanoid 28:a9a3a9db592b 4022 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 4023 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4024 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 4025 }
whismanoid 24:032f3683cb2a 4026 }
whismanoid 33:70a28cfe9e01 4027 } // end if (command_table_row_count > 0)
whismanoid 33:70a28cfe9e01 4028 if ((editRowIndex == command_table_row_count) && (command_table_row_count < COMMAND_TABLE_ROW_MAX)) {
whismanoid 33:70a28cfe9e01 4029 // %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 4030 //
whismanoid 33:70a28cfe9e01 4031 command_table_row_count++;
whismanoid 33:70a28cfe9e01 4032 cmdLine.serial().printf("\r\n add next row %d containing \"%s\"",
whismanoid 33:70a28cfe9e01 4033 editRowIndex, cmdLine.str()+argIndex);
whismanoid 33:70a28cfe9e01 4034 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 33:70a28cfe9e01 4035 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 33:70a28cfe9e01 4036 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 33:70a28cfe9e01 4037 //
whismanoid 23:c6c652bef4b9 4038 }
whismanoid 33:70a28cfe9e01 4039 //
whismanoid 23:c6c652bef4b9 4040 break;
whismanoid 23:c6c652bef4b9 4041 case '+':
whismanoid 24:032f3683cb2a 4042 // %B1@+ command add new row (if there is room to add)
whismanoid 23:c6c652bef4b9 4043 // add a new row at end of table
whismanoid 23:c6c652bef4b9 4044 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 4045 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 23:c6c652bef4b9 4046 editRowIndex = command_table_row_count;
whismanoid 28:a9a3a9db592b 4047 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 4048 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 4049 cmdLine.serial().printf("\r\n cannot add new row %d containing nothing",
whismanoid 28:a9a3a9db592b 4050 editRowIndex);
whismanoid 28:a9a3a9db592b 4051 }
whismanoid 28:a9a3a9db592b 4052 else
whismanoid 28:a9a3a9db592b 4053 {
whismanoid 28:a9a3a9db592b 4054 command_table_row_count++;
whismanoid 28:a9a3a9db592b 4055 cmdLine.serial().printf("\r\n add new row %d containing \"%s\"",
whismanoid 28:a9a3a9db592b 4056 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 4057 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4058 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 4059 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 28:a9a3a9db592b 4060 }
whismanoid 23:c6c652bef4b9 4061 }
whismanoid 23:c6c652bef4b9 4062 break;
whismanoid 23:c6c652bef4b9 4063 case '-':
whismanoid 24:032f3683cb2a 4064 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 4065 // delete row from table
whismanoid 23:c6c652bef4b9 4066 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4067 // if command_table_row_count == 0 then the table is empty
whismanoid 23:c6c652bef4b9 4068 if ((cmdLine[5] == '~') && (cmdLine[6] == '~') && (cmdLine[7] == '~')) {
whismanoid 23:c6c652bef4b9 4069 // %B1@-~~~ clear entire command table
whismanoid 24:032f3683cb2a 4070 cmdLine.serial().printf("\r\n clear entire command table");
whismanoid 23:c6c652bef4b9 4071 command_table_row_count = 0;
whismanoid 28:a9a3a9db592b 4072 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 23:c6c652bef4b9 4073 break;
whismanoid 23:c6c652bef4b9 4074 }
whismanoid 24:032f3683cb2a 4075 else
whismanoid 23:c6c652bef4b9 4076 {
whismanoid 24:032f3683cb2a 4077 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 24:032f3683cb2a 4078 editRowIndex = atoi(cmdLine.str()+5);
whismanoid 24:032f3683cb2a 4079 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 24:032f3683cb2a 4080 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 24:032f3683cb2a 4081 // delete row editRowIndex from Datalogger_action_table
whismanoid 24:032f3683cb2a 4082 for (int i = editRowIndex; i < (command_table_row_count-1); i++)
whismanoid 24:032f3683cb2a 4083 {
whismanoid 24:032f3683cb2a 4084 // copy row i+1 into row i
whismanoid 24:032f3683cb2a 4085 cmdLine.serial().printf("\r\n copy row %d into row %d: \"%s\"",
whismanoid 24:032f3683cb2a 4086 i+1, i, command_table[i+1]);
whismanoid 24:032f3683cb2a 4087 strncpy(command_table[i], command_table[i+1], COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4088 command_table[i][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 24:032f3683cb2a 4089 }
whismanoid 24:032f3683cb2a 4090 command_table_row_count--;
whismanoid 28:a9a3a9db592b 4091 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 24:032f3683cb2a 4092 }
whismanoid 23:c6c652bef4b9 4093 }
whismanoid 23:c6c652bef4b9 4094 }
whismanoid 23:c6c652bef4b9 4095 break;
whismanoid 30:07197a430869 4096 case '.': // something other than ! because %B1! means trigger event
whismanoid 30:07197a430869 4097 // pause the button event
whismanoid 30:07197a430869 4098 // TODO: %B1@. disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 4099 //~ Datalogger_action_table_enabled = false;
whismanoid 23:c6c652bef4b9 4100 break;
whismanoid 23:c6c652bef4b9 4101 case '@':
whismanoid 30:07197a430869 4102 // enable the button event
whismanoid 23:c6c652bef4b9 4103 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 4104 //~ Datalogger_action_table_enabled = true;
whismanoid 23:c6c652bef4b9 4105 break;
whismanoid 23:c6c652bef4b9 4106 }
whismanoid 23:c6c652bef4b9 4107 //
whismanoid 23:c6c652bef4b9 4108 // Print the contents of command_table
whismanoid 23:c6c652bef4b9 4109 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 4110 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 4111 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 4112 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 4113 cmdLine.serial().printf("\r\n %%B%1d@%d %s",
whismanoid 24:032f3683cb2a 4114 command_table_button_index,
whismanoid 24:032f3683cb2a 4115 lineIndex,
whismanoid 24:032f3683cb2a 4116 command_table[lineIndex]);
whismanoid 23:c6c652bef4b9 4117 }
whismanoid 30:07197a430869 4118 //~ cmdLine.serial().printf("\r\n command_table_row_count = %d/%d",
whismanoid 30:07197a430869 4119 //~ command_table_row_count, COMMAND_TABLE_ROW_MAX);
whismanoid 30:07197a430869 4120 cmdLine.serial().printf("\r\n\r\nEdit Button%d event (used %d/%d, %d free):",
whismanoid 30:07197a430869 4121 command_table_button_index,
whismanoid 30:07197a430869 4122 command_table_row_count,
whismanoid 30:07197a430869 4123 COMMAND_TABLE_ROW_MAX,
whismanoid 30:07197a430869 4124 (COMMAND_TABLE_ROW_MAX - command_table_row_count)
whismanoid 30:07197a430869 4125 );
whismanoid 23:c6c652bef4b9 4126 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 4127 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 24:032f3683cb2a 4128 cmdLine.serial().printf("\r\n %%B%1d@+ command -- add new row %d at end of table",
whismanoid 24:032f3683cb2a 4129 command_table_button_index,
whismanoid 24:032f3683cb2a 4130 command_table_row_count);
whismanoid 23:c6c652bef4b9 4131 }
whismanoid 23:c6c652bef4b9 4132 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4133 // if command_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 4134 cmdLine.serial().printf("\r\n %%B%1d@%d command -- replace row %d",
whismanoid 24:032f3683cb2a 4135 command_table_button_index,
whismanoid 23:c6c652bef4b9 4136 command_table_row_count-1,
whismanoid 23:c6c652bef4b9 4137 command_table_row_count-1);
whismanoid 24:032f3683cb2a 4138 cmdLine.serial().printf("\r\n %%B%1d@-%d -- delete row %d",
whismanoid 24:032f3683cb2a 4139 command_table_button_index,
whismanoid 24:032f3683cb2a 4140 command_table_row_count-1,
whismanoid 24:032f3683cb2a 4141 command_table_row_count-1);
whismanoid 24:032f3683cb2a 4142 cmdLine.serial().printf("\r\n %%B%1d@-~~~ -- delete all rows",
whismanoid 24:032f3683cb2a 4143 command_table_button_index);
whismanoid 30:07197a430869 4144 //~ cmdLine.serial().printf("\r\n %%B%1d@. -- pause entire command table",
whismanoid 30:07197a430869 4145 //~ command_table_button_index);
whismanoid 30:07197a430869 4146 //~ cmdLine.serial().printf("\r\n %%B%1d@@ -- enable command table",
whismanoid 30:07197a430869 4147 //~ command_table_button_index);
whismanoid 30:07197a430869 4148 cmdLine.serial().printf("\r\n %%B%1d! -- trigger Button%d event",
whismanoid 30:07197a430869 4149 command_table_button_index,
whismanoid 24:032f3683cb2a 4150 command_table_button_index);
whismanoid 23:c6c652bef4b9 4151 }
whismanoid 23:c6c652bef4b9 4152 //
whismanoid 23:c6c652bef4b9 4153 } // case '@' -- %B1@ view/edit command table
whismanoid 23:c6c652bef4b9 4154 break;
whismanoid 23:c6c652bef4b9 4155 case '!':
whismanoid 23:c6c652bef4b9 4156 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 23:c6c652bef4b9 4157 Run_command_table(command_table);
whismanoid 23:c6c652bef4b9 4158 break;
whismanoid 23:c6c652bef4b9 4159 }
whismanoid 23:c6c652bef4b9 4160 }
whismanoid 23:c6c652bef4b9 4161 break;
whismanoid 23:c6c652bef4b9 4162 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4163 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 4164 #if HAS_digitalInOuts
whismanoid 15:37c83ec50ea0 4165 case 'H': case 'h':
whismanoid 15:37c83ec50ea0 4166 {
whismanoid 15:37c83ec50ea0 4167 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 4168 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4169 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4170 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4171 #else
whismanoid 15:37c83ec50ea0 4172 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4173 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 4174 digitalInOutPin.write(1);
whismanoid 15:37c83ec50ea0 4175 #endif
whismanoid 15:37c83ec50ea0 4176 cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex);
whismanoid 15:37c83ec50ea0 4177 }
whismanoid 15:37c83ec50ea0 4178 break;
whismanoid 15:37c83ec50ea0 4179 case 'L': case 'l':
whismanoid 15:37c83ec50ea0 4180 {
whismanoid 15:37c83ec50ea0 4181 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 4182 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4183 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4184 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4185 #else
whismanoid 15:37c83ec50ea0 4186 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4187 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 4188 digitalInOutPin.write(0);
whismanoid 15:37c83ec50ea0 4189 #endif
whismanoid 15:37c83ec50ea0 4190 cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex);
whismanoid 15:37c83ec50ea0 4191 }
whismanoid 15:37c83ec50ea0 4192 break;
whismanoid 15:37c83ec50ea0 4193 case '?':
whismanoid 15:37c83ec50ea0 4194 {
whismanoid 15:37c83ec50ea0 4195 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 4196 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4197 pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4198 #else
whismanoid 15:37c83ec50ea0 4199 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4200 digitalInOutPin.input();
whismanoid 15:37c83ec50ea0 4201 #endif
whismanoid 15:37c83ec50ea0 4202 serial.printf(" digitalInOutPin %d Input ", pinIndex);
whismanoid 15:37c83ec50ea0 4203 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4204 int value = digitalRead(pinIndex);
whismanoid 15:37c83ec50ea0 4205 #else
whismanoid 15:37c83ec50ea0 4206 int value = digitalInOutPin.read();
whismanoid 15:37c83ec50ea0 4207 #endif
whismanoid 15:37c83ec50ea0 4208 cmdLine.serial().printf("%d ", value);
whismanoid 15:37c83ec50ea0 4209 }
whismanoid 15:37c83ec50ea0 4210 break;
whismanoid 15:37c83ec50ea0 4211 #endif
whismanoid 15:37c83ec50ea0 4212 //
whismanoid 15:37c83ec50ea0 4213 #if HAS_analogIns
whismanoid 15:37c83ec50ea0 4214 case 'A': case 'a':
whismanoid 15:37c83ec50ea0 4215 {
whismanoid 15:37c83ec50ea0 4216 // %A %Apin -- analog input
whismanoid 37:3f369235e5bc 4217 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4218 // %A avg= -- set Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 4219 if (cmdLine.parse_int_dec("avg", Platform_AIN_Average_N))
whismanoid 37:3f369235e5bc 4220 {
whismanoid 37:3f369235e5bc 4221 // Platform_AIN_Average_N was updated
whismanoid 37:3f369235e5bc 4222 }
whismanoid 37:3f369235e5bc 4223 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4224 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4225 // %A cal? view/export raw calibration values for all channels
whismanoid 34:a1993a1ee904 4226 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4227 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4228 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4229 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4230 {
whismanoid 34:a1993a1ee904 4231 char valueBuf[16];
whismanoid 34:a1993a1ee904 4232 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 4233 if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 4234 {
whismanoid 34:a1993a1ee904 4235 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4236 {
whismanoid 34:a1993a1ee904 4237 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 4238 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4239 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 4240 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4241 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 4242 );
whismanoid 34:a1993a1ee904 4243 }
whismanoid 34:a1993a1ee904 4244 //
whismanoid 34:a1993a1ee904 4245 // print extended help for %A
whismanoid 34:a1993a1ee904 4246 // %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 4247 //~ cmdLine.serial().printf("\r\n %%A cal0n=0.02 cal0v=0.123 cal0n=0.938 cal0v=1.132 -- update calibration");
whismanoid 34:a1993a1ee904 4248 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 4249 cmdLine.serial().printf(" %%A cal0test=0.5 -- calculate voltage at 50%% of full scale");
whismanoid 34:a1993a1ee904 4250 cmdLine.serial().printf("\r\n %%A v0cal=1.000V -- calibrate channel against a known input voltage");
whismanoid 34:a1993a1ee904 4251 // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 4252 // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 4253 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 4254 cmdLine.serial().printf("\r\n %%A calreset -- reset all calibration data");
whismanoid 37:3f369235e5bc 4255 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4256 // %A avg=%d -- help string display Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 4257 cmdLine.serial().printf("\r\n %%A avg=%d -- average", Platform_AIN_Average_N);
whismanoid 37:3f369235e5bc 4258 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4259 cmdLine.serial().printf("\r\n\r\n");
whismanoid 34:a1993a1ee904 4260 //
whismanoid 34:a1993a1ee904 4261 } // end if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 4262 }
whismanoid 34:a1993a1ee904 4263 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4264 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4265 {
whismanoid 34:a1993a1ee904 4266 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 4267 char valueBuf[16];
whismanoid 34:a1993a1ee904 4268 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 4269 if (cmdLine.parse_and_remove_key("calreset", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 4270 {
whismanoid 34:a1993a1ee904 4271 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 4272 calibration_05_normValue_0_1[0] = 0.25; calibration_05_V[0] = 0.3;
whismanoid 34:a1993a1ee904 4273 calibration_05_normValue_0_1[1] = 0.25; calibration_05_V[1] = 0.3;
whismanoid 34:a1993a1ee904 4274 calibration_05_normValue_0_1[2] = 0.25; calibration_05_V[2] = 0.3;
whismanoid 34:a1993a1ee904 4275 calibration_05_normValue_0_1[3] = 0.25; calibration_05_V[3] = 0.3;
whismanoid 34:a1993a1ee904 4276 calibration_05_normValue_0_1[4] = 0.25; calibration_05_V[4] = 1.5;
whismanoid 34:a1993a1ee904 4277 calibration_05_normValue_0_1[5] = 0.25; calibration_05_V[5] = 1.5;
whismanoid 34:a1993a1ee904 4278 //
whismanoid 34:a1993a1ee904 4279 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 4280 calibration_95_normValue_0_1[0] = 0.75; calibration_95_V[0] = 0.9;
whismanoid 34:a1993a1ee904 4281 calibration_95_normValue_0_1[1] = 0.75; calibration_95_V[1] = 0.9;
whismanoid 34:a1993a1ee904 4282 calibration_95_normValue_0_1[2] = 0.75; calibration_95_V[2] = 0.9;
whismanoid 34:a1993a1ee904 4283 calibration_95_normValue_0_1[3] = 0.75; calibration_95_V[3] = 0.9;
whismanoid 34:a1993a1ee904 4284 calibration_95_normValue_0_1[4] = 0.75; calibration_95_V[4] = 4.5;
whismanoid 34:a1993a1ee904 4285 calibration_95_normValue_0_1[5] = 0.75; calibration_95_V[5] = 4.5;
whismanoid 34:a1993a1ee904 4286 //
whismanoid 34:a1993a1ee904 4287 }
whismanoid 34:a1993a1ee904 4288 }
whismanoid 34:a1993a1ee904 4289 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4290 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4291 // %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 4292 // %A cal4n=0.135874882 cal4v=0.800000012V cal4n=0.286168128 cal4v=1.700000048V
whismanoid 34:a1993a1ee904 4293 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4294 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4295 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4296 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4297 {
whismanoid 34:a1993a1ee904 4298 double normValue_0_1, V;
whismanoid 34:a1993a1ee904 4299 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4300 {
whismanoid 34:a1993a1ee904 4301 static char key_can0n[8] = "cal0n__";
whismanoid 34:a1993a1ee904 4302 sprintf(key_can0n, "cal%1dn", ch);
whismanoid 34:a1993a1ee904 4303 static char key_cal0v[8] = "cal0v__";
whismanoid 34:a1993a1ee904 4304 sprintf(key_cal0v, "cal%1dv", ch);
whismanoid 35:c9549b5c01de 4305 // first point could be the 5% point or the 95% point
whismanoid 35:c9549b5c01de 4306 double norm_threshold = (calibration_05_normValue_0_1[ch] + calibration_95_normValue_0_1[ch]) / 2.0;
whismanoid 35:c9549b5c01de 4307 bool updated_05 = false;
whismanoid 35:c9549b5c01de 4308 //~ bool updated_95 = false;
whismanoid 35:c9549b5c01de 4309 if (cmdLine.parse_double(key_can0n, normValue_0_1)) {
whismanoid 34:a1993a1ee904 4310 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 34:a1993a1ee904 4311 {
whismanoid 35:c9549b5c01de 4312 if (normValue_0_1 < norm_threshold) {
whismanoid 35:c9549b5c01de 4313 // store first calibration point in the 5% slot
whismanoid 35:c9549b5c01de 4314 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 4315 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 4316 updated_05 = true;
whismanoid 34:a1993a1ee904 4317 }
whismanoid 34:a1993a1ee904 4318 else {
whismanoid 35:c9549b5c01de 4319 // store first calibration point in the 95% slot
whismanoid 35:c9549b5c01de 4320 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 4321 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 4322 //~ updated_95 = true;
whismanoid 34:a1993a1ee904 4323 }
whismanoid 34:a1993a1ee904 4324 }
whismanoid 35:c9549b5c01de 4325 }
whismanoid 35:c9549b5c01de 4326 // handle the optional second calibration point
whismanoid 35:c9549b5c01de 4327 if (cmdLine.parse_double(key_can0n, normValue_0_1))
whismanoid 35:c9549b5c01de 4328 {
whismanoid 35:c9549b5c01de 4329 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 35:c9549b5c01de 4330 {
whismanoid 35:c9549b5c01de 4331 if (updated_05) {
whismanoid 35:c9549b5c01de 4332 // we already stored the first point here
whismanoid 35:c9549b5c01de 4333 // calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4334 // calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 4335 // store the second point in the other slot
whismanoid 35:c9549b5c01de 4336 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4337 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 4338 }
whismanoid 35:c9549b5c01de 4339 else {
whismanoid 35:c9549b5c01de 4340 // we already stored the first point here
whismanoid 35:c9549b5c01de 4341 // calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4342 // calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 4343 // store the second point in the other slot
whismanoid 35:c9549b5c01de 4344 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4345 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 4346 }
whismanoid 35:c9549b5c01de 4347 }
whismanoid 35:c9549b5c01de 4348 }
whismanoid 34:a1993a1ee904 4349 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4350 }
whismanoid 34:a1993a1ee904 4351 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4352 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4353 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 4354 // double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 4355 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4356 {
whismanoid 34:a1993a1ee904 4357 static char key_cal0test[12] = "cal0test__";
whismanoid 34:a1993a1ee904 4358 sprintf(key_cal0test, "cal%1dtest", ch);
whismanoid 34:a1993a1ee904 4359 double normValue_0_1, Vtest;
whismanoid 34:a1993a1ee904 4360 if (cmdLine.parse_double(key_cal0test, Vtest))
whismanoid 34:a1993a1ee904 4361 {
whismanoid 34:a1993a1ee904 4362 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 4363 normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 4364 //
whismanoid 34:a1993a1ee904 4365 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 4366 ch,
whismanoid 34:a1993a1ee904 4367 normValue_0_1,
whismanoid 34:a1993a1ee904 4368 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 4369 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4370 );
whismanoid 34:a1993a1ee904 4371 //
whismanoid 34:a1993a1ee904 4372 // sweep CalibratedNormValue argument
whismanoid 34:a1993a1ee904 4373 double normValue_0_1_start = -0.05;
whismanoid 34:a1993a1ee904 4374 double normValue_0_1_step = 0.05;
whismanoid 34:a1993a1ee904 4375 double normValue_0_1_end = 1.07;
whismanoid 34:a1993a1ee904 4376 for (normValue_0_1 = normValue_0_1_start;
whismanoid 34:a1993a1ee904 4377 normValue_0_1 <= normValue_0_1_end;
whismanoid 34:a1993a1ee904 4378 normValue_0_1 = normValue_0_1 + normValue_0_1_step)
whismanoid 34:a1993a1ee904 4379 {
whismanoid 34:a1993a1ee904 4380 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 4381 ch,
whismanoid 34:a1993a1ee904 4382 normValue_0_1,
whismanoid 34:a1993a1ee904 4383 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 4384 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4385 );
whismanoid 34:a1993a1ee904 4386 }
whismanoid 34:a1993a1ee904 4387 }
whismanoid 34:a1993a1ee904 4388 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4389 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4390 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4391 // %A v0cal=1.000V -- calibrate channel against a known input voltage
whismanoid 34:a1993a1ee904 4392 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4393 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4394 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4395 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4396 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4397 {
whismanoid 34:a1993a1ee904 4398 static char key_v0cal[10] = "v0cal__";
whismanoid 34:a1993a1ee904 4399 sprintf(key_v0cal, "v%1dcal", ch);
whismanoid 34:a1993a1ee904 4400 double Vtest;
whismanoid 34:a1993a1ee904 4401 if (cmdLine.parse_double(key_v0cal, Vtest))
whismanoid 34:a1993a1ee904 4402 {
whismanoid 34:a1993a1ee904 4403 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 4404 double Vtest_normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 4405 //
whismanoid 34:a1993a1ee904 4406 // %A v0cal=1.000 calibrate one channel by measuring against a known input voltage
whismanoid 34:a1993a1ee904 4407 //
whismanoid 34:a1993a1ee904 4408 cmdLine.serial().printf("\r\n Measuring against input voltage of %1.6fV...", Vtest);
whismanoid 37:3f369235e5bc 4409 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4410 const int numberOfMeasurements = 16 * Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 4411 #else // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4412 const int numberOfMeasurements = 16;
whismanoid 37:3f369235e5bc 4413 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4414 double Sx_measure_normValue_0_1 = 0; // sum of values
whismanoid 34:a1993a1ee904 4415 double Sxx_measure_normValue_0_1 = 0; // sum of the squares of the values
whismanoid 34:a1993a1ee904 4416 for (int count = 0; count < numberOfMeasurements; count++)
whismanoid 34:a1993a1ee904 4417 {
whismanoid 34:a1993a1ee904 4418 double measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4419 switch(ch)
whismanoid 34:a1993a1ee904 4420 {
whismanoid 34:a1993a1ee904 4421 case 0: measure_normValue_0_1 = analogIn0.read(); break;
whismanoid 34:a1993a1ee904 4422 case 1: measure_normValue_0_1 = analogIn1.read(); break;
whismanoid 34:a1993a1ee904 4423 case 2: measure_normValue_0_1 = analogIn2.read(); break;
whismanoid 34:a1993a1ee904 4424 case 3: measure_normValue_0_1 = analogIn3.read(); break;
whismanoid 34:a1993a1ee904 4425 case 4: measure_normValue_0_1 = analogIn4.read(); break;
whismanoid 34:a1993a1ee904 4426 case 5: measure_normValue_0_1 = analogIn5.read(); break;
whismanoid 34:a1993a1ee904 4427 }
whismanoid 34:a1993a1ee904 4428 Sx_measure_normValue_0_1 = Sx_measure_normValue_0_1 + measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4429 Sxx_measure_normValue_0_1 = Sxx_measure_normValue_0_1 + (measure_normValue_0_1 * measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4430 cmdLine.serial().printf("\r\n raw: %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4431 measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4432 (measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4433 );
whismanoid 34:a1993a1ee904 4434 }
whismanoid 34:a1993a1ee904 4435 cmdLine.serial().printf("\r\n numberOfMeasurements = %d", numberOfMeasurements);
whismanoid 34:a1993a1ee904 4436 cmdLine.serial().printf("\r\n Sx_measure_normValue_0_1 = %1.6f", Sx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4437 cmdLine.serial().printf("\r\n Sxx_measure_normValue_0_1 = %1.6f", Sxx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4438 //
whismanoid 34:a1993a1ee904 4439 // calculate mean_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 4440 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 4441 double mean_measure_normValue_0_1 = Sx_measure_normValue_0_1 / numberOfMeasurements;
whismanoid 34:a1993a1ee904 4442 cmdLine.serial().printf("\r\n mean = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4443 mean_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4444 (mean_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4445 );
whismanoid 34:a1993a1ee904 4446 //
whismanoid 34:a1993a1ee904 4447 // TODO: calculate sample variance_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 4448 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 4449 // variance_measure_normValue_0_1 = (Sxx - ( Sx * Sx / nWords) ) / (nWords - 1);
whismanoid 34:a1993a1ee904 4450 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 4451 cmdLine.serial().printf("\r\n variance = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4452 variance_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4453 (variance_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4454 );
whismanoid 34:a1993a1ee904 4455 //
whismanoid 34:a1993a1ee904 4456 // calculate sample stddev_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 4457 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 4458 double stddev_measure_normValue_0_1 = sqrt(variance_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4459 cmdLine.serial().printf("\r\n stddev = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4460 stddev_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4461 (stddev_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4462 );
whismanoid 34:a1993a1ee904 4463 //
whismanoid 34:a1993a1ee904 4464 // Validate the measurements:
whismanoid 34:a1993a1ee904 4465 // is the mean near the expected value?
whismanoid 34:a1993a1ee904 4466 // is the standard deviation not too high?
whismanoid 34:a1993a1ee904 4467 bool isCalibrationValid = true;
whismanoid 34:a1993a1ee904 4468 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) > 0.1) {
whismanoid 34:a1993a1ee904 4469 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 4470 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 4471 }
whismanoid 34:a1993a1ee904 4472 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) < -0.1) {
whismanoid 34:a1993a1ee904 4473 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 4474 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 4475 }
whismanoid 34:a1993a1ee904 4476 if ((stddev_measure_normValue_0_1) > 10) {
whismanoid 34:a1993a1ee904 4477 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 4478 cmdLine.serial().printf(" stddev too high.\r\n");
whismanoid 34:a1993a1ee904 4479 }
whismanoid 34:a1993a1ee904 4480 if (isCalibrationValid)
whismanoid 34:a1993a1ee904 4481 {
whismanoid 34:a1993a1ee904 4482 // update calibration point (mean_measure_normValue_0_1, Vtest)
whismanoid 34:a1993a1ee904 4483 if (Vtest_normValue_0_1 < 0.5) {
whismanoid 34:a1993a1ee904 4484 calibration_05_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4485 calibration_05_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 4486 } else {
whismanoid 34:a1993a1ee904 4487 calibration_95_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4488 calibration_95_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 4489 }
whismanoid 34:a1993a1ee904 4490 //
whismanoid 34:a1993a1ee904 4491 // print updated calibration values
whismanoid 34:a1993a1ee904 4492 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 4493 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 4494 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4495 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 4496 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4497 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 4498 );
whismanoid 34:a1993a1ee904 4499 // print corrected value of mean of measurements (should be close to Vtest)
whismanoid 34:a1993a1ee904 4500 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV vs %1.6fV\r\n",
whismanoid 34:a1993a1ee904 4501 ch,
whismanoid 34:a1993a1ee904 4502 mean_measure_normValue_0_1,
whismanoid 34:a1993a1ee904 4503 CalibratedNormValue(ch, mean_measure_normValue_0_1),
whismanoid 34:a1993a1ee904 4504 (CalibratedNormValue(ch, mean_measure_normValue_0_1) * adc_full_scale_voltage[ch]),
whismanoid 34:a1993a1ee904 4505 Vtest
whismanoid 34:a1993a1ee904 4506 );
whismanoid 34:a1993a1ee904 4507 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 4508 else {
whismanoid 34:a1993a1ee904 4509 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 4510 cmdLine.serial().printf(" Measurement Error: Calibration will not be updated.\r\n");
whismanoid 34:a1993a1ee904 4511 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 4512 } // end if key_v0cal
whismanoid 34:a1993a1ee904 4513 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4514 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4515 #if HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 4516 // // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 37:3f369235e5bc 4517 // {
whismanoid 37:3f369235e5bc 4518 // char valueBuf[16];
whismanoid 37:3f369235e5bc 4519 // // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 37:3f369235e5bc 4520 // if (cmdLine.parse_and_remove_key("__TBD_saveCal__", valueBuf, sizeof(valueBuf)))
whismanoid 37:3f369235e5bc 4521 // {
whismanoid 37:3f369235e5bc 4522 // // handle %A __TBD_saveCal__ -- command
whismanoid 37:3f369235e5bc 4523 // }
whismanoid 37:3f369235e5bc 4524 // }
whismanoid 34:a1993a1ee904 4525 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4526 #if HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 4527 // // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 37:3f369235e5bc 4528 // {
whismanoid 37:3f369235e5bc 4529 // char valueBuf[16];
whismanoid 37:3f369235e5bc 4530 // // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 37:3f369235e5bc 4531 // if (cmdLine.parse_and_remove_key("__TBD_loadCal__", valueBuf, sizeof(valueBuf)))
whismanoid 37:3f369235e5bc 4532 // {
whismanoid 37:3f369235e5bc 4533 // // handle %A __TBD_loadCal__ -- command
whismanoid 37:3f369235e5bc 4534 // }
whismanoid 37:3f369235e5bc 4535 // }
whismanoid 34:a1993a1ee904 4536 #endif // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 4537 // %A -- report analog input voltages
whismanoid 37:3f369235e5bc 4538 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4539 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 4540 #endif // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 4541 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 4542 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 15:37c83ec50ea0 4543 for (int pinIndex = 0; pinIndex < 2; pinIndex++)
whismanoid 15:37c83ec50ea0 4544 {
whismanoid 15:37c83ec50ea0 4545 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 4546 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 4547 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 4548 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4549 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 4550 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 4551 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 4552 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 4553 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 4554 }
whismanoid 37:3f369235e5bc 4555 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 4556 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 4557 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 4558 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4559 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4560 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4561 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 4562 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4563 //
whismanoid 15:37c83ec50ea0 4564 int pinIndexH = pinIndex + 4;
whismanoid 15:37c83ec50ea0 4565 int cPinIndexH = '0' + pinIndexH;
whismanoid 15:37c83ec50ea0 4566 AnalogIn& analogInPinH = find_analogInPin(cPinIndexH);
whismanoid 15:37c83ec50ea0 4567 float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH];
whismanoid 37:3f369235e5bc 4568 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4569 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 4570 // float normValueH_0_1 = analogInPinH.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 4571 float normValueH_0_1 = 0;
whismanoid 37:3f369235e5bc 4572 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 4573 normValueH_0_1 = normValueH_0_1 + analogInPinH.read();
whismanoid 37:3f369235e5bc 4574 }
whismanoid 37:3f369235e5bc 4575 normValueH_0_1 = normValueH_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 4576 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 4577 float normValueH_0_1 = analogInPinH.read();
whismanoid 37:3f369235e5bc 4578 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4579 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4580 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4581 normValueH_0_1 = CalibratedNormValue(pinIndex, normValueH_0_1);
whismanoid 34:a1993a1ee904 4582 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4583 //
whismanoid 37:3f369235e5bc 4584 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV high range A%c = %7.3f%% = %1.3fV \r\n",
whismanoid 15:37c83ec50ea0 4585 cPinIndex,
whismanoid 15:37c83ec50ea0 4586 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4587 normValue_0_1 * adc_full_scale_voltage,
whismanoid 15:37c83ec50ea0 4588 cPinIndexH,
whismanoid 15:37c83ec50ea0 4589 normValueH_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4590 normValueH_0_1 * adc_full_scale_voltageH
whismanoid 15:37c83ec50ea0 4591 );
whismanoid 15:37c83ec50ea0 4592 }
whismanoid 15:37c83ec50ea0 4593 for (int pinIndex = 2; pinIndex < 4; pinIndex++)
whismanoid 15:37c83ec50ea0 4594 {
whismanoid 15:37c83ec50ea0 4595 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 4596 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 4597 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 4598 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4599 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 4600 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 4601 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 4602 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 4603 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 4604 }
whismanoid 37:3f369235e5bc 4605 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 4606 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 4607 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 4608 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4609 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4610 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4611 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 4612 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4613 //
whismanoid 37:3f369235e5bc 4614 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 4615 cPinIndex,
whismanoid 15:37c83ec50ea0 4616 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4617 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 4618 );
whismanoid 15:37c83ec50ea0 4619 }
whismanoid 15:37c83ec50ea0 4620 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 4621 // Platform board uses simple analog inputs
whismanoid 15:37c83ec50ea0 4622 // assume standard Arduino analog inputs A0-A5
whismanoid 15:37c83ec50ea0 4623 for (int pinIndex = 0; pinIndex < 6; pinIndex++)
whismanoid 15:37c83ec50ea0 4624 {
whismanoid 15:37c83ec50ea0 4625 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 4626 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 4627 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 4628 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4629 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 4630 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 4631 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 4632 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 4633 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 4634 }
whismanoid 37:3f369235e5bc 4635 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 4636 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 4637 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 4638 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4639 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4640 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4641 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 4642 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4643 //
whismanoid 37:3f369235e5bc 4644 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 4645 cPinIndex,
whismanoid 15:37c83ec50ea0 4646 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4647 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 4648 );
whismanoid 15:37c83ec50ea0 4649 }
whismanoid 15:37c83ec50ea0 4650 #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 4651 }
whismanoid 15:37c83ec50ea0 4652 break;
whismanoid 15:37c83ec50ea0 4653 #endif
whismanoid 15:37c83ec50ea0 4654 //
whismanoid 15:37c83ec50ea0 4655 #if HAS_SPI2_MAX541
whismanoid 15:37c83ec50ea0 4656 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 4657 {
whismanoid 15:37c83ec50ea0 4658 // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV)
whismanoid 15:37c83ec50ea0 4659 // MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 15:37c83ec50ea0 4660 float voltageV = max541.Get_Voltage();
whismanoid 15:37c83ec50ea0 4661 // if (cmdLine[2] == '+') {
whismanoid 15:37c83ec50ea0 4662 // // %D+
whismanoid 15:37c83ec50ea0 4663 // voltageV = voltageV * 1.25f;
whismanoid 15:37c83ec50ea0 4664 // if (voltageV >= max541.VRef) voltageV = max541.VRef;
whismanoid 15:37c83ec50ea0 4665 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4666 // }
whismanoid 15:37c83ec50ea0 4667 // else if (cmdLine[2] == '-') {
whismanoid 15:37c83ec50ea0 4668 // // %D-
whismanoid 15:37c83ec50ea0 4669 // voltageV = voltageV * 0.75f;
whismanoid 15:37c83ec50ea0 4670 // if (voltageV < 0.1f) voltageV = 0.1f;
whismanoid 15:37c83ec50ea0 4671 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4672 // }
whismanoid 15:37c83ec50ea0 4673 if (cmdLine.parse_float("V", voltageV))
whismanoid 15:37c83ec50ea0 4674 {
whismanoid 15:37c83ec50ea0 4675 // %D V=1.234 -- set voltage
whismanoid 15:37c83ec50ea0 4676 max541.Set_Voltage(voltageV);
whismanoid 15:37c83ec50ea0 4677 }
whismanoid 15:37c83ec50ea0 4678 else if (cmdLine.parse_float("TEST", voltageV))
whismanoid 15:37c83ec50ea0 4679 {
whismanoid 15:37c83ec50ea0 4680 // %D TEST=1.234 -- set voltage and compare with AIN0
whismanoid 15:37c83ec50ea0 4681 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4682 }
whismanoid 15:37c83ec50ea0 4683 else if (cmdLine.parse_float("CAL", voltageV))
whismanoid 15:37c83ec50ea0 4684 {
whismanoid 15:37c83ec50ea0 4685 // %D CAL=1.234 -- calibrate VRef and compare with AIN0
whismanoid 15:37c83ec50ea0 4686
whismanoid 15:37c83ec50ea0 4687 max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
whismanoid 15:37c83ec50ea0 4688 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 4689 const int average_count = 100;
whismanoid 15:37c83ec50ea0 4690 const double average_K = 0.25;
whismanoid 15:37c83ec50ea0 4691 for (int count = 0; count < average_count; count++) {
whismanoid 15:37c83ec50ea0 4692 double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 4693 max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
whismanoid 15:37c83ec50ea0 4694 }
whismanoid 15:37c83ec50ea0 4695 max541.VRef = 2.0 * max541_midscale_V;
whismanoid 15:37c83ec50ea0 4696 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4697 "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
whismanoid 15:37c83ec50ea0 4698 max541_midscale_V, max541.VRef);
whismanoid 15:37c83ec50ea0 4699 // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
whismanoid 15:37c83ec50ea0 4700 voltageV = 1.0f;
whismanoid 15:37c83ec50ea0 4701 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4702 }
whismanoid 15:37c83ec50ea0 4703 else {
whismanoid 15:37c83ec50ea0 4704 // %D -- print MAX541 DAC status
whismanoid 15:37c83ec50ea0 4705 cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n",
whismanoid 15:37c83ec50ea0 4706 max541.Get_Code(), max541.Get_Voltage(), max541.VRef);
whismanoid 15:37c83ec50ea0 4707 }
whismanoid 15:37c83ec50ea0 4708 }
whismanoid 15:37c83ec50ea0 4709 break;
whismanoid 15:37c83ec50ea0 4710 #endif
whismanoid 15:37c83ec50ea0 4711
whismanoid 15:37c83ec50ea0 4712 //
whismanoid 15:37c83ec50ea0 4713 #if HAS_I2C // SUPPORT_I2C
whismanoid 15:37c83ec50ea0 4714 case 'I': case 'i':
whismanoid 15:37c83ec50ea0 4715 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 4716 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 4717 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 4718 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 4719 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 4720 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 4721 // get next character
whismanoid 15:37c83ec50ea0 4722 // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7
whismanoid 15:37c83ec50ea0 4723 cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7);
whismanoid 15:37c83ec50ea0 4724 // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count
whismanoid 15:37c83ec50ea0 4725 g_I2C_read_count = 0; // read count must be reset every command
whismanoid 15:37c83ec50ea0 4726 cmdLine.parse_byte_dec("RD", g_I2C_read_count);
whismanoid 15:37c83ec50ea0 4727 // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress
whismanoid 15:37c83ec50ea0 4728 cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress);
whismanoid 15:37c83ec50ea0 4729 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 4730 {
whismanoid 15:37c83ec50ea0 4731 case 'P': case 'p':
whismanoid 15:37c83ec50ea0 4732 {
whismanoid 15:37c83ec50ea0 4733 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 4734 HuntAttachedI2CDevices(cmdLine, 0x03, 0x77);
whismanoid 15:37c83ec50ea0 4735 }
whismanoid 15:37c83ec50ea0 4736 break;
whismanoid 15:37c83ec50ea0 4737 case 'C': case 'c':
whismanoid 15:37c83ec50ea0 4738 {
whismanoid 15:37c83ec50ea0 4739 bool isUpdatedI2CConfig = false;
whismanoid 15:37c83ec50ea0 4740 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 4741 // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz
whismanoid 15:37c83ec50ea0 4742 if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz))
whismanoid 15:37c83ec50ea0 4743 {
whismanoid 15:37c83ec50ea0 4744 isUpdatedI2CConfig = true;
whismanoid 15:37c83ec50ea0 4745 // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 4746 if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 4747 {
whismanoid 15:37c83ec50ea0 4748 g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 4749 }
whismanoid 15:37c83ec50ea0 4750 if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 4751 {
whismanoid 15:37c83ec50ea0 4752 g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 4753 }
whismanoid 15:37c83ec50ea0 4754 }
whismanoid 15:37c83ec50ea0 4755 if (isUpdatedI2CConfig)
whismanoid 15:37c83ec50ea0 4756 {
whismanoid 15:37c83ec50ea0 4757 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4758 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4759 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4760 i2cMaster.start();
whismanoid 15:37c83ec50ea0 4761 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 4762 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4763 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4764 "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 15:37c83ec50ea0 4765 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 15:37c83ec50ea0 4766 (g_I2C_SCL_Hz / 1000.));
whismanoid 15:37c83ec50ea0 4767 i2cMaster.start();
whismanoid 15:37c83ec50ea0 4768 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 4769 }
whismanoid 15:37c83ec50ea0 4770 }
whismanoid 15:37c83ec50ea0 4771 break;
whismanoid 15:37c83ec50ea0 4772 case 'W': case 'w':
whismanoid 15:37c83ec50ea0 4773 {
whismanoid 15:37c83ec50ea0 4774 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4775 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4776 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4777 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 4778 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4779 #define MAX_I2C_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 4780 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 4781 static char mosiData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4782 static char misoData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4783 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 4784 MAX_I2C_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 4785 {
whismanoid 15:37c83ec50ea0 4786 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 4787 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4788 "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->",
whismanoid 15:37c83ec50ea0 4789 g_I2C_deviceAddress7,
whismanoid 15:37c83ec50ea0 4790 (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count);
whismanoid 15:37c83ec50ea0 4791 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 4792 {
whismanoid 15:37c83ec50ea0 4793 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 4794 }
whismanoid 15:37c83ec50ea0 4795 //
whismanoid 15:37c83ec50ea0 4796 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 4797 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 4798 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4799 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 4800 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 4801 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 4802 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 4803 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4804 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4805 // /* 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 4806 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 4807 const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4808 unsigned int misoLength = 0;
whismanoid 15:37c83ec50ea0 4809 bool repeated = (g_I2C_read_count > 0);
whismanoid 15:37c83ec50ea0 4810 //
whismanoid 15:37c83ec50ea0 4811 int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated);
whismanoid 15:37c83ec50ea0 4812 switch (writeStatus)
whismanoid 15:37c83ec50ea0 4813 {
whismanoid 15:37c83ec50ea0 4814 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 4815 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 4816 default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 4817 writeStatus);
whismanoid 15:37c83ec50ea0 4818 }
whismanoid 15:37c83ec50ea0 4819 if (repeated)
whismanoid 15:37c83ec50ea0 4820 {
whismanoid 15:37c83ec50ea0 4821 int readStatus =
whismanoid 15:37c83ec50ea0 4822 i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false);
whismanoid 15:37c83ec50ea0 4823 switch (readStatus)
whismanoid 15:37c83ec50ea0 4824 {
whismanoid 15:37c83ec50ea0 4825 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 4826 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 4827 default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 4828 readStatus);
whismanoid 15:37c83ec50ea0 4829 }
whismanoid 15:37c83ec50ea0 4830 }
whismanoid 15:37c83ec50ea0 4831 //
whismanoid 15:37c83ec50ea0 4832 if (misoLength > 0)
whismanoid 15:37c83ec50ea0 4833 {
whismanoid 15:37c83ec50ea0 4834 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 4835 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 4836 for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count;
whismanoid 15:37c83ec50ea0 4837 byteIndex++)
whismanoid 15:37c83ec50ea0 4838 {
whismanoid 15:37c83ec50ea0 4839 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 4840 }
whismanoid 15:37c83ec50ea0 4841 }
whismanoid 15:37c83ec50ea0 4842 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 4843 }
whismanoid 15:37c83ec50ea0 4844 }
whismanoid 15:37c83ec50ea0 4845 break;
whismanoid 15:37c83ec50ea0 4846 case 'R': case 'r':
whismanoid 15:37c83ec50ea0 4847 {
whismanoid 15:37c83ec50ea0 4848 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4849 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4850 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4851 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 4852 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 4853 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 4854 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4855 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 4856 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 4857 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 4858 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 4859 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4860 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4861 // /* 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 4862 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 4863 }
whismanoid 15:37c83ec50ea0 4864 break;
whismanoid 15:37c83ec50ea0 4865 case '^':
whismanoid 15:37c83ec50ea0 4866 {
whismanoid 15:37c83ec50ea0 4867 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4868 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4869 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4870 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 4871 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 4872 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 4873 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4874 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 4875 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 4876 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 4877 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 4878 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4879 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4880 // /* 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 4881 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 4882 }
whismanoid 15:37c83ec50ea0 4883 break;
whismanoid 15:37c83ec50ea0 4884 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 4885 break;
whismanoid 15:37c83ec50ea0 4886 #endif
whismanoid 15:37c83ec50ea0 4887 //
whismanoid 15:37c83ec50ea0 4888 #if HAS_SPI // SUPPORT_SPI
whismanoid 15:37c83ec50ea0 4889 case 'S': case 's':
whismanoid 15:37c83ec50ea0 4890 {
whismanoid 15:37c83ec50ea0 4891 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 4892 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 4893 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 4894 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 4895 //
whismanoid 15:37c83ec50ea0 4896 // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d
whismanoid 15:37c83ec50ea0 4897 bool isUpdatedSPIConfig = false;
whismanoid 15:37c83ec50ea0 4898 // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2
whismanoid 15:37c83ec50ea0 4899 // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1
whismanoid 15:37c83ec50ea0 4900 if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2))
whismanoid 15:37c83ec50ea0 4901 {
whismanoid 15:37c83ec50ea0 4902 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 4903 }
whismanoid 15:37c83ec50ea0 4904 if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1))
whismanoid 15:37c83ec50ea0 4905 {
whismanoid 15:37c83ec50ea0 4906 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 4907 }
whismanoid 15:37c83ec50ea0 4908 if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1))
whismanoid 15:37c83ec50ea0 4909 {
whismanoid 15:37c83ec50ea0 4910 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 4911 }
whismanoid 15:37c83ec50ea0 4912 // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz
whismanoid 15:37c83ec50ea0 4913 if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz))
whismanoid 15:37c83ec50ea0 4914 {
whismanoid 15:37c83ec50ea0 4915 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 4916 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 4917 if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 4918 {
whismanoid 15:37c83ec50ea0 4919 g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 4920 }
whismanoid 15:37c83ec50ea0 4921 if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 4922 {
whismanoid 15:37c83ec50ea0 4923 g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 4924 }
whismanoid 15:37c83ec50ea0 4925 }
whismanoid 15:37c83ec50ea0 4926 // Update SPI configuration
whismanoid 15:37c83ec50ea0 4927 if (isUpdatedSPIConfig)
whismanoid 15:37c83ec50ea0 4928 {
whismanoid 15:37c83ec50ea0 4929 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 4930 spi_cs = g_SPI_cs_state;
whismanoid 15:37c83ec50ea0 4931 spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0
whismanoid 15:37c83ec50ea0 4932 #if APPLICATION_MAX5715
whismanoid 15:37c83ec50ea0 4933 g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 4934 #elif APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 4935 g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 4936 #elif APPLICATION_MAX5171
whismanoid 15:37c83ec50ea0 4937 g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 4938 #elif APPLICATION_MAX11410
whismanoid 15:37c83ec50ea0 4939 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 4940 #elif APPLICATION_MAX12345
whismanoid 15:37c83ec50ea0 4941 g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 4942 #else
whismanoid 15:37c83ec50ea0 4943 spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 15:37c83ec50ea0 4944 #endif
whismanoid 15:37c83ec50ea0 4945 //
whismanoid 15:37c83ec50ea0 4946 double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 4947 int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate
whismanoid 15:37c83ec50ea0 4948 double actual_SCLK_Hz = SystemCoreClock / actual_divisor;
whismanoid 15:37c83ec50ea0 4949 //
whismanoid 15:37c83ec50ea0 4950 // 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 4951 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4952 "\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 4953 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 15:37c83ec50ea0 4954 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0),
whismanoid 15:37c83ec50ea0 4955 g_SPI_cs_state,
whismanoid 15:37c83ec50ea0 4956 g_SPI_SCLK_Hz,
whismanoid 15:37c83ec50ea0 4957 (g_SPI_SCLK_Hz / 1000000.),
whismanoid 15:37c83ec50ea0 4958 ((double)(SystemCoreClock / 1000000.)),
whismanoid 15:37c83ec50ea0 4959 ideal_divisor,
whismanoid 15:37c83ec50ea0 4960 (actual_SCLK_Hz / 1000000.)
whismanoid 15:37c83ec50ea0 4961 );
whismanoid 15:37c83ec50ea0 4962 }
whismanoid 15:37c83ec50ea0 4963 // get next character
whismanoid 15:37c83ec50ea0 4964 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 4965 {
whismanoid 15:37c83ec50ea0 4966 case 'C': case 's':
whismanoid 15:37c83ec50ea0 4967 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 4968 break;
whismanoid 15:37c83ec50ea0 4969 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 4970 // %SD -- SPI diagnostic messages enable
whismanoid 15:37c83ec50ea0 4971 if (g_MAX5719_device.onSPIprint) {
whismanoid 15:37c83ec50ea0 4972 g_MAX5719_device.onSPIprint = NULL;
whismanoid 15:37c83ec50ea0 4973 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') != None is false
whismanoid 15:37c83ec50ea0 4974 }
whismanoid 15:37c83ec50ea0 4975 else {
whismanoid 15:37c83ec50ea0 4976 void onSPIprint_handler(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]);
whismanoid 15:37c83ec50ea0 4977 g_MAX5719_device.onSPIprint = onSPIprint_handler;
whismanoid 15:37c83ec50ea0 4978 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') is false
whismanoid 15:37c83ec50ea0 4979 }
whismanoid 15:37c83ec50ea0 4980 break;
whismanoid 15:37c83ec50ea0 4981 case 'W': case 'R': case 'w': case 'r':
whismanoid 15:37c83ec50ea0 4982 {
whismanoid 15:37c83ec50ea0 4983 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 4984 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 4985 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4986 #define MAX_SPI_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 4987 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 4988 static char mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4989 static char misoData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4990 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 4991 MAX_SPI_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 4992 {
whismanoid 15:37c83ec50ea0 4993 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 4994 cmdLine.serial().printf("\r\nSPI");
whismanoid 15:37c83ec50ea0 4995 if (byteCount > 7) {
whismanoid 15:37c83ec50ea0 4996 cmdLine.serial().printf(" byteCount:%d", byteCount);
whismanoid 15:37c83ec50ea0 4997 }
whismanoid 15:37c83ec50ea0 4998 cmdLine.serial().printf(" MOSI->");
whismanoid 15:37c83ec50ea0 4999 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 5000 {
whismanoid 15:37c83ec50ea0 5001 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 5002 }
whismanoid 15:37c83ec50ea0 5003 spi_cs = 0;
whismanoid 15:37c83ec50ea0 5004 unsigned int numBytesTransferred =
whismanoid 15:37c83ec50ea0 5005 spi.write(mosiData, byteCount, misoData, byteCount);
whismanoid 15:37c83ec50ea0 5006 spi_cs = 1;
whismanoid 15:37c83ec50ea0 5007 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5008 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 5009 for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred;
whismanoid 15:37c83ec50ea0 5010 byteIndex++)
whismanoid 15:37c83ec50ea0 5011 {
whismanoid 15:37c83ec50ea0 5012 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 5013 }
whismanoid 15:37c83ec50ea0 5014 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 5015 }
whismanoid 15:37c83ec50ea0 5016 }
whismanoid 15:37c83ec50ea0 5017 break;
whismanoid 15:37c83ec50ea0 5018 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 5019 } // case 'S': // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 5020 break;
whismanoid 15:37c83ec50ea0 5021 #endif
whismanoid 15:37c83ec50ea0 5022 //
whismanoid 15:37c83ec50ea0 5023 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 5024 } // switch(cmdLine[1])
whismanoid 15:37c83ec50ea0 5025 } // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 15:37c83ec50ea0 5026 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 15:37c83ec50ea0 5027
whismanoid 15:37c83ec50ea0 5028 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 5029 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 5030 void main_menu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 5031 {
whismanoid 9:45f98573eb6d 5032 // process command line
whismanoid 31:47eee7e0cc2d 5033 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 5034 if (g_Run_command_table_running == false) {
whismanoid 31:47eee7e0cc2d 5035 cmdLine.serial().printf("\r\nCmdLine buf:\"%s\"\r\n", cmdLine.str());
whismanoid 31:47eee7e0cc2d 5036 } // if (g_Run_command_table_running)
whismanoid 31:47eee7e0cc2d 5037 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 5038 if (g_Run_command_table_running == false) {
whismanoid 31:47eee7e0cc2d 5039 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 5040
whismanoid 4:d9b05924ad4c 5041 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 31:47eee7e0cc2d 5042 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 5043 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 5044 // If datalog is free running, halt on any possible received command
whismanoid 17:9397ea3ea7e9 5045 if (Datalogger_Trigger != trigger_Halt) {
whismanoid 4:d9b05924ad4c 5046 Datalogger_Trigger = trigger_Halt;
whismanoid 9:45f98573eb6d 5047 cmdLine.serial().printf("Datalog stopped by USB command input\r\n");
whismanoid 9:45f98573eb6d 5048 cmdLine.serial().printf("Restart datalog by sending LR\r\n");
whismanoid 4:d9b05924ad4c 5049 }
whismanoid 31:47eee7e0cc2d 5050 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 5051 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 5052
whismanoid 4:d9b05924ad4c 5053 // DIAGNOSTIC: print line buffer
whismanoid 4:d9b05924ad4c 5054 //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str());
whismanoid 4:d9b05924ad4c 5055 //
whismanoid 4:d9b05924ad4c 5056 switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 5057 {
whismanoid 4:d9b05924ad4c 5058 case '?':
whismanoid 4:d9b05924ad4c 5059 main_menu_status(cmdLine);
whismanoid 4:d9b05924ad4c 5060 main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 5061 // print command prompt
whismanoid 4:d9b05924ad4c 5062 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 5063 break;
whismanoid 4:d9b05924ad4c 5064 case '\r': case '\n': // ignore blank line
whismanoid 4:d9b05924ad4c 5065 case '\0': // ignore empty line
whismanoid 30:07197a430869 5066 main_menu_status(cmdLine);
whismanoid 30:07197a430869 5067 //~ main_menu_help(cmdLine);
whismanoid 30:07197a430869 5068 // print command prompt
whismanoid 30:07197a430869 5069 //cmdLine.serial().printf("\r\n>");
whismanoid 30:07197a430869 5070 break;
whismanoid 4:d9b05924ad4c 5071 case '#': // ignore comment line
whismanoid 4:d9b05924ad4c 5072 // # -- lines beginning with # are comments
whismanoid 30:07197a430869 5073 //
whismanoid 30:07197a430869 5074 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 5075 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in main_menu_onEOLcommandParser
whismanoid 30:07197a430869 5076 // # command handler update gstrRemarkText buffer instead of just ignoring the remark
whismanoid 30:07197a430869 5077 //
whismanoid 30:07197a430869 5078 // ignore extra spaces before the remark
whismanoid 30:07197a430869 5079 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 30:07197a430869 5080 int argIndex;
whismanoid 30:07197a430869 5081 for (argIndex = 1; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 5082 {
whismanoid 30:07197a430869 5083 if (cmdLine[argIndex] == ' ') break;
whismanoid 30:07197a430869 5084 }
whismanoid 30:07197a430869 5085 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 5086 {
whismanoid 30:07197a430869 5087 if (cmdLine[argIndex] != ' ') break;
whismanoid 30:07197a430869 5088 }
whismanoid 30:07197a430869 5089 //
whismanoid 30:07197a430869 5090 strncpy(gstrRemarkText, cmdLine.str()+argIndex, gstrRemarkTextLASTINDEX+1);
whismanoid 30:07197a430869 5091 // do not exceed string buffer limit; keep sentinel null character at end of buffer
whismanoid 30:07197a430869 5092 gstrRemarkText[gstrRemarkTextLASTINDEX] = '\0';
whismanoid 30:07197a430869 5093 for (int index = 0; index < gstrRemarkTextLASTINDEX; index++)
whismanoid 30:07197a430869 5094 {
whismanoid 30:07197a430869 5095 if ((gstrRemarkText[index]) == '\0') break; // null character at end of string
whismanoid 30:07197a430869 5096 if ((gstrRemarkText[index]) < 0x20) {
whismanoid 30:07197a430869 5097 // replace non-printing characters with _
whismanoid 30:07197a430869 5098 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 5099 continue;
whismanoid 30:07197a430869 5100 }
whismanoid 30:07197a430869 5101 if ((gstrRemarkText[index]) >= 0x7F) {
whismanoid 30:07197a430869 5102 // replace non-printing characters with _
whismanoid 30:07197a430869 5103 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 5104 continue;
whismanoid 30:07197a430869 5105 }
whismanoid 30:07197a430869 5106 switch(gstrRemarkText[index])
whismanoid 30:07197a430869 5107 {
whismanoid 30:07197a430869 5108 case ',':
whismanoid 30:07197a430869 5109 // replace , with ;
whismanoid 30:07197a430869 5110 gstrRemarkText[index] = ';';
whismanoid 30:07197a430869 5111 break;
whismanoid 30:07197a430869 5112 case '"':
whismanoid 30:07197a430869 5113 // replace " with '
whismanoid 30:07197a430869 5114 gstrRemarkText[index] = '\'';
whismanoid 30:07197a430869 5115 break;
whismanoid 30:07197a430869 5116 case '\\':
whismanoid 30:07197a430869 5117 // replace \ with /
whismanoid 30:07197a430869 5118 gstrRemarkText[index] = '/';
whismanoid 30:07197a430869 5119 break;
whismanoid 30:07197a430869 5120 }
whismanoid 30:07197a430869 5121 }
whismanoid 30:07197a430869 5122 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 5123 //
whismanoid 31:47eee7e0cc2d 5124 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 5125 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 5126 main_menu_status(cmdLine);
whismanoid 31:47eee7e0cc2d 5127 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 5128 //~ main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 5129 // print command prompt
whismanoid 4:d9b05924ad4c 5130 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 5131 break;
whismanoid 4:d9b05924ad4c 5132 #if ECHO_EOF_ON_EOL
whismanoid 4:d9b05924ad4c 5133 case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file
whismanoid 4:d9b05924ad4c 5134 cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 5135 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 5136 break;
whismanoid 4:d9b05924ad4c 5137 case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file
whismanoid 4:d9b05924ad4c 5138 cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 5139 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 5140 break;
whismanoid 4:d9b05924ad4c 5141 #endif
whismanoid 10:04022a61b527 5142 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 5143 case '!': // device init
whismanoid 10:04022a61b527 5144 {
whismanoid 10:04022a61b527 5145 cmdLine.serial().printf("Init");
whismanoid 10:04022a61b527 5146 // call function Init
whismanoid 10:04022a61b527 5147 uint8_t result = g_MAX11410_device.Init();
whismanoid 10:04022a61b527 5148 // cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 5149 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 5150 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 5151 // in command '!' device init, apply list of custom register writes after init
whismanoid 10:04022a61b527 5152 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 5153 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 10:04022a61b527 5154 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 10:04022a61b527 5155 uint32_t regData = custom_reg_init_data[index];
whismanoid 10:04022a61b527 5156 cmdLine.serial().printf("*%s=0x%06.6x",
whismanoid 10:04022a61b527 5157 g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress),
whismanoid 10:04022a61b527 5158 regData
whismanoid 10:04022a61b527 5159 );
whismanoid 10:04022a61b527 5160 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 10:04022a61b527 5161 }
whismanoid 10:04022a61b527 5162 #endif // USE_CUSTOM_REG_INIT
whismanoid 10:04022a61b527 5163 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 5164 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 5165 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 5166 }
whismanoid 10:04022a61b527 5167 break;
whismanoid 10:04022a61b527 5168 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 5169 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 5170 case '.':
whismanoid 4:d9b05924ad4c 5171 {
whismanoid 4:d9b05924ad4c 5172 // . -- SelfTest
whismanoid 4:d9b05924ad4c 5173 cmdLine.serial().printf("SelfTest()");
whismanoid 4:d9b05924ad4c 5174 SelfTest(cmdLine);
whismanoid 4:d9b05924ad4c 5175 }
whismanoid 4:d9b05924ad4c 5176 break;
whismanoid 4:d9b05924ad4c 5177 #endif // USE_SELFTEST
whismanoid 15:37c83ec50ea0 5178 #if 1 // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 5179 case '%':
whismanoid 4:d9b05924ad4c 5180 {
whismanoid 4:d9b05924ad4c 5181 pinsMonitor_submenu_onEOLcommandParser(cmdLine);
whismanoid 4:d9b05924ad4c 5182 }
whismanoid 4:d9b05924ad4c 5183 break; // case '%'
whismanoid 4:d9b05924ad4c 5184 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 9:45f98573eb6d 5185 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 5186 // reuse the Serial_Tester command *regName=regValue
whismanoid 10:04022a61b527 5187 // CODE GENERATOR: generate * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 5188 case '*':
whismanoid 10:04022a61b527 5189 {
whismanoid 10:04022a61b527 5190 // if buffer starts with a regName:
whismanoid 10:04022a61b527 5191 // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))):
whismanoid 10:04022a61b527 5192 // cmdLine.serial().printf(" scan RegName...\r\n");
whismanoid 10:04022a61b527 5193 }
whismanoid 10:04022a61b527 5194 break;
whismanoid 9:45f98573eb6d 5195 #endif // USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 5196 //
whismanoid 10:04022a61b527 5197 #if 1 // USE_AUX_SERIAL_CMD_FORWARDING && (HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL)
whismanoid 10:04022a61b527 5198 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_onEOLcommandParser
whismanoid 10:04022a61b527 5199 case '>':
whismanoid 10:04022a61b527 5200 {
whismanoid 10:04022a61b527 5201 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 5202 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 5203 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 5204 CmdLine& cmdLine_AuxSerial = cmdLine_AUXserial;
whismanoid 10:04022a61b527 5205 Serial& AuxSerial = AUXserial;
whismanoid 10:04022a61b527 5206 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5207 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 5208 CmdLine& cmdLine_AuxSerial = cmdLine_DAPLINKserial;
whismanoid 10:04022a61b527 5209 Serial& AuxSerial = DAPLINKserial;
whismanoid 10:04022a61b527 5210 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5211 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 5212 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5213 //
whismanoid 10:04022a61b527 5214 // >> suppress key=value parsing
whismanoid 10:04022a61b527 5215 bool suppress_parsing = (cmdLine[1] == '>');
whismanoid 10:04022a61b527 5216 if (suppress_parsing == false) {
whismanoid 10:04022a61b527 5217 // int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 5218 if (cmdLine.parse_int_dec("baud", g_auxSerialCom_baud))
whismanoid 10:04022a61b527 5219 {
whismanoid 10:04022a61b527 5220 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- baud rate
whismanoid 10:04022a61b527 5221 cmdLine_AuxSerial.serial().printf("\r\n*** New Baud Rate %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5222 AuxSerial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5223 cmdLine_AuxSerial.serial().printf("\r\n*** Baud Rate was set to %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5224 }
whismanoid 10:04022a61b527 5225 #if 0
whismanoid 10:04022a61b527 5226 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 5227 if (cmdLine.parse_int_dec("tx_wait_echo", g_auxSerialCom_tx_wait_echo))
whismanoid 10:04022a61b527 5228 {
whismanoid 10:04022a61b527 5229 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_wait_echo
whismanoid 10:04022a61b527 5230 //~ cmdLine_AuxSerial.serial().printf("\r\n*** tx_wait_echo was set to %d ***\r\n", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 5231 cmdLine.serial().printf("\r\n tx_wait_echo=%d", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 5232 }
whismanoid 10:04022a61b527 5233 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 5234 if (cmdLine.parse_int_dec("tx_char_delay_ms", g_auxSerialCom_tx_char_delay_ms))
whismanoid 10:04022a61b527 5235 {
whismanoid 10:04022a61b527 5236 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_char_delay_ms
whismanoid 10:04022a61b527 5237 //~ 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 5238 cmdLine.serial().printf("\r\n tx_char_delay_ms=%dms", g_auxSerialCom_tx_char_delay_ms);
whismanoid 10:04022a61b527 5239 }
whismanoid 10:04022a61b527 5240 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 5241 if (cmdLine.parse_int_dec("tx_line_delay_ms", g_auxSerialCom_tx_line_delay_ms))
whismanoid 10:04022a61b527 5242 {
whismanoid 10:04022a61b527 5243 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_line_delay_ms
whismanoid 10:04022a61b527 5244 //~ 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 5245 cmdLine.serial().printf("\r\n tx_line_delay_ms=%dms", g_auxSerialCom_tx_line_delay_ms);
whismanoid 10:04022a61b527 5246 }
whismanoid 10:04022a61b527 5247 #endif
whismanoid 10:04022a61b527 5248 // int g_auxSerialCom_message_ms = 0; //!< capture RX until response timeout?
whismanoid 10:04022a61b527 5249 if (cmdLine.parse_int_dec("message_ms", g_auxSerialCom_message_ms))
whismanoid 10:04022a61b527 5250 {
whismanoid 10:04022a61b527 5251 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 10:04022a61b527 5252 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 5253 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 5254 }
whismanoid 10:04022a61b527 5255 // int g_auxSerialCom_rx_idle_ms = 0; //!< capture RX until idle timeout?
whismanoid 10:04022a61b527 5256 if (cmdLine.parse_int_dec("rx_idle_ms", g_auxSerialCom_rx_idle_ms))
whismanoid 10:04022a61b527 5257 {
whismanoid 10:04022a61b527 5258 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_idle_ms
whismanoid 10:04022a61b527 5259 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_idle_ms was set to %d ***\r\n", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 5260 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 5261 }
whismanoid 10:04022a61b527 5262 // int g_auxSerialCom_rx_max_count = 0; //!< capture RX until max character count?
whismanoid 10:04022a61b527 5263 if (cmdLine.parse_int_dec("rx_max_count", g_auxSerialCom_rx_max_count))
whismanoid 10:04022a61b527 5264 {
whismanoid 10:04022a61b527 5265 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_max_count
whismanoid 10:04022a61b527 5266 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_max_count was set to %d ***\r\n", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 5267 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 5268 }
whismanoid 10:04022a61b527 5269 // int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text char?
whismanoid 10:04022a61b527 5270 if (cmdLine.parse_int_dec("rx_eot", g_auxSerialCom_rx_eot))
whismanoid 10:04022a61b527 5271 {
whismanoid 10:04022a61b527 5272 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_eot
whismanoid 10:04022a61b527 5273 //~ cmdLine_AUXserial.serial().printf("\r\n*** rx_eot was set to %d ***\r\n", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 5274 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 5275 }
whismanoid 10:04022a61b527 5276 }
whismanoid 10:04022a61b527 5277 // Command forwarding to AUX serial TX/RX cmdLine_AuxSerial #257 -- send outgoing_string
whismanoid 10:04022a61b527 5278 char* outgoing_string = (char*)cmdLine.str();
whismanoid 10:04022a61b527 5279 // > use key=value parsing
whismanoid 10:04022a61b527 5280 // >> suppress key=value parsing
whismanoid 10:04022a61b527 5281 if (suppress_parsing) {
whismanoid 10:04022a61b527 5282 cmdLine.serial().printf("\r\n suppress_parsing outgoing_string=\"%s\"", outgoing_string);
whismanoid 10:04022a61b527 5283 outgoing_string++; // skip the first '>'
whismanoid 10:04022a61b527 5284 outgoing_string++; // skip the second '>'
whismanoid 10:04022a61b527 5285 } else {
whismanoid 10:04022a61b527 5286 // TODO: after parsing, key=value pairs should be deleted, but outgoing_string=">xyzzy abc=def"
whismanoid 10:04022a61b527 5287 cmdLine.serial().printf("\r\n after parsing, outgoing_string=\"%s\"", outgoing_string);
whismanoid 10:04022a61b527 5288 outgoing_string++; // skip the first '>'
whismanoid 10:04022a61b527 5289 }
whismanoid 10:04022a61b527 5290 static char rx_string_buf[RX_STRING_BUF_SIZE];
whismanoid 10:04022a61b527 5291 unsigned int rx_string_length = 0;
whismanoid 10:04022a61b527 5292 cmdLine.serial().printf("\r\n >%s\r\n <", outgoing_string);
whismanoid 10:04022a61b527 5293 rx_string_buf[0] = '\0';
whismanoid 10:04022a61b527 5294 rx_string_length = 0;
whismanoid 10:04022a61b527 5295 //
whismanoid 10:04022a61b527 5296 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 5297 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 5298 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 5299 //
whismanoid 10:04022a61b527 5300 // int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 5301 // int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 5302 // int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 5303 // int g_auxSerialCom_rx_idle_ms = 2000; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 5304 // int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 5305 // int g_auxSerialCom_rx_eot = '\r'; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 5306 //~ cmdLine_AuxSerial.serial().printf("\r\n*** TODO forward %s ***\r\n", outgoing_string);
whismanoid 10:04022a61b527 5307 //
whismanoid 10:04022a61b527 5308 // TODO: send whole string or send character-by-character?
whismanoid 10:04022a61b527 5309 cmdLine_AuxSerial.serial().printf("%s", outgoing_string);
whismanoid 10:04022a61b527 5310 cmdLine_AuxSerial.serial().printf("\r\n");
whismanoid 10:04022a61b527 5311 g_auxSerialCom_Timer.start();
whismanoid 10:04022a61b527 5312 g_auxSerialCom_Timer_begin_message_ms = g_auxSerialCom_Timer.read_ms(); // start of message
whismanoid 10:04022a61b527 5313 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 5314 while (rx_string_length < (RX_STRING_BUF_SIZE-1)) {
whismanoid 10:04022a61b527 5315 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_message_ms) > g_auxSerialCom_message_ms) {
whismanoid 10:04022a61b527 5316 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 5317 break;
whismanoid 10:04022a61b527 5318 }
whismanoid 10:04022a61b527 5319 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_rx_idle_ms) > g_auxSerialCom_rx_idle_ms) {
whismanoid 10:04022a61b527 5320 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 5321 break;
whismanoid 10:04022a61b527 5322 }
whismanoid 10:04022a61b527 5323 if (rx_string_length >= g_auxSerialCom_rx_max_count) {
whismanoid 10:04022a61b527 5324 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 5325 break;
whismanoid 10:04022a61b527 5326 }
whismanoid 10:04022a61b527 5327 if (AuxSerial.readable()) {
whismanoid 10:04022a61b527 5328 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 5329 char ch = AuxSerial.getc();
whismanoid 10:04022a61b527 5330 rx_string_buf[rx_string_length++] = ch;
whismanoid 10:04022a61b527 5331 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 10:04022a61b527 5332 cmdLine.serial().printf("%s", &(rx_string_buf[rx_string_length-1]) ); // immediate character echo
whismanoid 10:04022a61b527 5333 if (g_auxSerialCom_rx_eot != aux_serial_cmd_forwarding_rx_eot_not_used) {
whismanoid 10:04022a61b527 5334 if (ch == g_auxSerialCom_rx_eot) {
whismanoid 10:04022a61b527 5335 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 5336 break;
whismanoid 10:04022a61b527 5337 }
whismanoid 10:04022a61b527 5338 }
whismanoid 10:04022a61b527 5339 }
whismanoid 10:04022a61b527 5340 } // end while (rx_string_length < (RX_STRING_BUF_SIZE-1))
whismanoid 10:04022a61b527 5341 #if 1
whismanoid 10:04022a61b527 5342 // print summary. is this needed? we already print aux rx as it is received.
whismanoid 10:04022a61b527 5343 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 10:04022a61b527 5344 cmdLine.serial().printf("\r\n >%s", outgoing_string);
whismanoid 10:04022a61b527 5345 cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 10:04022a61b527 5346 #endif
whismanoid 10:04022a61b527 5347 //
whismanoid 10:04022a61b527 5348 }
whismanoid 10:04022a61b527 5349 break; // case '>'
whismanoid 10:04022a61b527 5350 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 5351 //
whismanoid 4:d9b05924ad4c 5352 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 5353 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 5354 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 5355 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 5356 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible
whismanoid 9:45f98573eb6d 5357 case 'L': case 'l':
whismanoid 4:d9b05924ad4c 5358 {
whismanoid 4:d9b05924ad4c 5359 // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 5360 Datalogger_Trigger = trigger_Halt;
whismanoid 4:d9b05924ad4c 5361 switch (cmdLine[1])
whismanoid 4:d9b05924ad4c 5362 {
whismanoid 17:9397ea3ea7e9 5363 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 5364 case 'T': case 't':
whismanoid 17:9397ea3ea7e9 5365 {
whismanoid 17:9397ea3ea7e9 5366 // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 5367 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 5368 Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 5369 g_timer_interval_counter = 0;
whismanoid 17:9397ea3ea7e9 5370 // TODO: get g_timer_interval_msec from cmdLine
whismanoid 17:9397ea3ea7e9 5371 // g_timer_interval_msec = 500;
whismanoid 17:9397ea3ea7e9 5372 // g_timer_interval_count = 10;
whismanoid 17:9397ea3ea7e9 5373 if (cmdLine.parse_int_dec("count", g_timer_interval_count))
whismanoid 17:9397ea3ea7e9 5374 {
whismanoid 32:80f3e5eb77d4 5375 if (g_timer_interval_count < 1) { g_timer_interval_count = 1; }
whismanoid 17:9397ea3ea7e9 5376 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 5377 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 5378 cmdLine.serial().printf("\r\n g_timer_interval_count=%d", g_timer_interval_count);
whismanoid 17:9397ea3ea7e9 5379 }
whismanoid 17:9397ea3ea7e9 5380 if (cmdLine.parse_int_dec("base", g_timer_interval_msec))
whismanoid 17:9397ea3ea7e9 5381 {
whismanoid 17:9397ea3ea7e9 5382 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 5383 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 5384 cmdLine.serial().printf("\r\n g_timer_interval_msec=%d", g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 5385 }
whismanoid 17:9397ea3ea7e9 5386 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 17:9397ea3ea7e9 5387 }
whismanoid 17:9397ea3ea7e9 5388 break;
whismanoid 17:9397ea3ea7e9 5389 // LIH3 -- Datalog when input high D3
whismanoid 17:9397ea3ea7e9 5390 // LIL6 -- Datalog when input low D6
whismanoid 17:9397ea3ea7e9 5391 case 'I': case 'i':
whismanoid 17:9397ea3ea7e9 5392 {
whismanoid 17:9397ea3ea7e9 5393 // TODO: switch cmdLine[2] configure High or Low, configure input pin
whismanoid 17:9397ea3ea7e9 5394 }
whismanoid 17:9397ea3ea7e9 5395 break;
whismanoid 17:9397ea3ea7e9 5396 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 5397 // L$ count=10 base=500ms addr=xxx data=xxx mask=xxx -- Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 5398 case '$':
whismanoid 17:9397ea3ea7e9 5399 {
whismanoid 17:9397ea3ea7e9 5400 // TODO: scan cmdLine for regAddr, dataMask, testValue
whismanoid 17:9397ea3ea7e9 5401 }
whismanoid 17:9397ea3ea7e9 5402 break;
whismanoid 17:9397ea3ea7e9 5403 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 5404 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 5405 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5406 case '@':
whismanoid 17:9397ea3ea7e9 5407 {
whismanoid 17:9397ea3ea7e9 5408 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5409 int editRowIndex = 0;
whismanoid 17:9397ea3ea7e9 5410 int edit_action = (int)action_noop;
whismanoid 17:9397ea3ea7e9 5411 int edit_digitalOutPin = 0;
whismanoid 17:9397ea3ea7e9 5412 int edit_condition = (int)condition_always;
whismanoid 17:9397ea3ea7e9 5413 int edit_condition_channel = 0;
whismanoid 17:9397ea3ea7e9 5414 double edit_condition_threshold = 0;
whismanoid 17:9397ea3ea7e9 5415 //
whismanoid 17:9397ea3ea7e9 5416 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 17:9397ea3ea7e9 5417 {
whismanoid 17:9397ea3ea7e9 5418 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 17:9397ea3ea7e9 5419 }
whismanoid 17:9397ea3ea7e9 5420 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 17:9397ea3ea7e9 5421 {
whismanoid 17:9397ea3ea7e9 5422 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 17:9397ea3ea7e9 5423 }
whismanoid 17:9397ea3ea7e9 5424 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 17:9397ea3ea7e9 5425 {
whismanoid 17:9397ea3ea7e9 5426 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 17:9397ea3ea7e9 5427 }
whismanoid 17:9397ea3ea7e9 5428 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 17:9397ea3ea7e9 5429 {
whismanoid 17:9397ea3ea7e9 5430 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 17:9397ea3ea7e9 5431 }
whismanoid 17:9397ea3ea7e9 5432 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 17:9397ea3ea7e9 5433 {
whismanoid 17:9397ea3ea7e9 5434 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 17:9397ea3ea7e9 5435 }
whismanoid 17:9397ea3ea7e9 5436 //
whismanoid 17:9397ea3ea7e9 5437 // Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5438 switch (cmdLine[2]) // L@... -- Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5439 {
whismanoid 17:9397ea3ea7e9 5440 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 5441 case '0': case '1': case '2': case '3': case '4':
whismanoid 17:9397ea3ea7e9 5442 case '5': case '6': case '7': case '8': case '9':
whismanoid 17:9397ea3ea7e9 5443 // edit row data
whismanoid 30:07197a430869 5444 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 5445 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 5446 // get row number to edit from cmdLine[2]
whismanoid 17:9397ea3ea7e9 5447 editRowIndex = atoi(cmdLine.str()+2);
whismanoid 30:07197a430869 5448 if ((editRowIndex >= 0) && (editRowIndex < Datalogger_action_table_row_count)) {
whismanoid 30:07197a430869 5449 // update row
whismanoid 30:07197a430869 5450 cmdLine.serial().printf("\r\n replace row %d", editRowIndex);
whismanoid 30:07197a430869 5451 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 5452 edit_action = Datalogger_action_table[editRowIndex].action;
whismanoid 30:07197a430869 5453 edit_digitalOutPin = Datalogger_action_table[editRowIndex].digitalOutPin;
whismanoid 30:07197a430869 5454 edit_condition = Datalogger_action_table[editRowIndex].condition;
whismanoid 30:07197a430869 5455 edit_condition_channel = Datalogger_action_table[editRowIndex].condition_channel;
whismanoid 30:07197a430869 5456 edit_condition_threshold = Datalogger_action_table[editRowIndex].condition_threshold;
whismanoid 30:07197a430869 5457 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 5458 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 30:07197a430869 5459 {
whismanoid 30:07197a430869 5460 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 30:07197a430869 5461 }
whismanoid 30:07197a430869 5462 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 30:07197a430869 5463 {
whismanoid 30:07197a430869 5464 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 30:07197a430869 5465 }
whismanoid 30:07197a430869 5466 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 30:07197a430869 5467 {
whismanoid 30:07197a430869 5468 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 30:07197a430869 5469 }
whismanoid 30:07197a430869 5470 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 30:07197a430869 5471 {
whismanoid 30:07197a430869 5472 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 30:07197a430869 5473 }
whismanoid 30:07197a430869 5474 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 30:07197a430869 5475 {
whismanoid 30:07197a430869 5476 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 30:07197a430869 5477 }
whismanoid 30:07197a430869 5478 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 5479 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 5480 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 5481 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 5482 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 5483 }
whismanoid 30:07197a430869 5484 else if ((editRowIndex == Datalogger_action_table_row_count) && (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX)) {
whismanoid 30:07197a430869 5485 // %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 5486 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 5487 cmdLine.serial().printf("\r\n add next row %d", editRowIndex);
whismanoid 30:07197a430869 5488 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 5489 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 5490 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 5491 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 5492 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 30:07197a430869 5493 //
whismanoid 17:9397ea3ea7e9 5494 }
whismanoid 17:9397ea3ea7e9 5495 }
whismanoid 17:9397ea3ea7e9 5496 break;
whismanoid 17:9397ea3ea7e9 5497 case '+':
whismanoid 17:9397ea3ea7e9 5498 // add a new row at end of table
whismanoid 17:9397ea3ea7e9 5499 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 5500 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 5501 editRowIndex = Datalogger_action_table_row_count;
whismanoid 17:9397ea3ea7e9 5502 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 5503 cmdLine.serial().printf("\r\n add new row %d", editRowIndex);
whismanoid 17:9397ea3ea7e9 5504 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 17:9397ea3ea7e9 5505 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 17:9397ea3ea7e9 5506 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 17:9397ea3ea7e9 5507 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 17:9397ea3ea7e9 5508 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 5509 }
whismanoid 17:9397ea3ea7e9 5510 break;
whismanoid 17:9397ea3ea7e9 5511 case '-':
whismanoid 17:9397ea3ea7e9 5512 // delete row from table
whismanoid 17:9397ea3ea7e9 5513 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 5514 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 5515 if ((cmdLine[3] == '~') && (cmdLine[4] == '~') && (cmdLine[5] == '~')) {
whismanoid 17:9397ea3ea7e9 5516 // L@-~~~ -- delete all rows from table
whismanoid 30:07197a430869 5517 cmdLine.serial().printf("\r\n delete all rows");
whismanoid 17:9397ea3ea7e9 5518 Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 5519 break;
whismanoid 17:9397ea3ea7e9 5520 }
whismanoid 30:07197a430869 5521 else {
whismanoid 30:07197a430869 5522 editRowIndex = atoi(cmdLine.str()+3);
whismanoid 30:07197a430869 5523 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 30:07197a430869 5524 // delete row editRowIndex from Datalogger_action_table
whismanoid 30:07197a430869 5525 for (int i = editRowIndex; i < (Datalogger_action_table_row_count-1); i++)
whismanoid 30:07197a430869 5526 {
whismanoid 30:07197a430869 5527 // copy row i+1 into row i
whismanoid 30:07197a430869 5528 Datalogger_action_table[i].action = Datalogger_action_table[i+1].action;
whismanoid 30:07197a430869 5529 Datalogger_action_table[i].digitalOutPin = Datalogger_action_table[i+1].digitalOutPin;
whismanoid 30:07197a430869 5530 Datalogger_action_table[i].condition = Datalogger_action_table[i+1].condition;
whismanoid 30:07197a430869 5531 Datalogger_action_table[i].condition_channel = Datalogger_action_table[i+1].condition_channel;
whismanoid 30:07197a430869 5532 Datalogger_action_table[i].condition_threshold = Datalogger_action_table[i+1].condition_threshold;
whismanoid 30:07197a430869 5533 }
whismanoid 30:07197a430869 5534 Datalogger_action_table_row_count--;
whismanoid 17:9397ea3ea7e9 5535 }
whismanoid 17:9397ea3ea7e9 5536 }
whismanoid 17:9397ea3ea7e9 5537 break;
whismanoid 30:07197a430869 5538 case '.':
whismanoid 30:07197a430869 5539 // L@. pause the entire Log action table
whismanoid 30:07197a430869 5540 cmdLine.serial().printf("\r\n pause the entire Log action table");
whismanoid 17:9397ea3ea7e9 5541 Datalogger_action_table_enabled = false;
whismanoid 17:9397ea3ea7e9 5542 break;
whismanoid 17:9397ea3ea7e9 5543 case '@':
whismanoid 30:07197a430869 5544 // L@@ enable the entire Log action table
whismanoid 30:07197a430869 5545 cmdLine.serial().printf("\r\n enable the entire Log action table");
whismanoid 17:9397ea3ea7e9 5546 Datalogger_action_table_enabled = true;
whismanoid 17:9397ea3ea7e9 5547 break;
whismanoid 17:9397ea3ea7e9 5548 }
whismanoid 17:9397ea3ea7e9 5549 //
whismanoid 17:9397ea3ea7e9 5550 // Print the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5551 if (Datalogger_action_table_enabled) {
whismanoid 30:07197a430869 5552 // cmdLine.serial().printf("Log action table enabled; L@. to pause");
whismanoid 17:9397ea3ea7e9 5553 }
whismanoid 17:9397ea3ea7e9 5554 else {
whismanoid 30:07197a430869 5555 cmdLine.serial().printf("Log action table paused; L@@ to enable");
whismanoid 17:9397ea3ea7e9 5556 }
whismanoid 17:9397ea3ea7e9 5557 //~ cmdLine.serial().printf("\r\n Datalogger_action_table_row_count=%d", Datalogger_action_table_row_count);
whismanoid 17:9397ea3ea7e9 5558 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 5559 {
whismanoid 17:9397ea3ea7e9 5560 cmdLine.serial().printf("\r\n L@%d", i);
whismanoid 17:9397ea3ea7e9 5561 cmdLine.serial().printf(" act=%d", Datalogger_action_table[i].action);
whismanoid 17:9397ea3ea7e9 5562 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5563 {
whismanoid 17:9397ea3ea7e9 5564 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 5565 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 5566 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5567 break;
whismanoid 29:6a9edb6e973b 5568 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 5569 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 5570 break;
whismanoid 17:9397ea3ea7e9 5571 default:
whismanoid 17:9397ea3ea7e9 5572 case action_noop:
whismanoid 17:9397ea3ea7e9 5573 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 5574 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 5575 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 5576 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 5577 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 5578 break;
whismanoid 17:9397ea3ea7e9 5579 }
whismanoid 17:9397ea3ea7e9 5580 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5581 {
whismanoid 17:9397ea3ea7e9 5582 case condition_always:
whismanoid 17:9397ea3ea7e9 5583 break;
whismanoid 17:9397ea3ea7e9 5584 default:
whismanoid 17:9397ea3ea7e9 5585 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 5586 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 5587 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 5588 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 5589 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 5590 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 5591 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 5592 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 5593 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 5594 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 5595 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 5596 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 5597 cmdLine.serial().printf(" if=%d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 5598 cmdLine.serial().printf(" ch=%d", Datalogger_action_table[i].condition_channel);
whismanoid 17:9397ea3ea7e9 5599 cmdLine.serial().printf(" x=%f", Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5600 break;
whismanoid 17:9397ea3ea7e9 5601 }
whismanoid 17:9397ea3ea7e9 5602 cmdLine.serial().printf(" -- ");
whismanoid 17:9397ea3ea7e9 5603 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5604 {
whismanoid 17:9397ea3ea7e9 5605 case action_noop:
whismanoid 17:9397ea3ea7e9 5606 cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 5607 break;
whismanoid 17:9397ea3ea7e9 5608 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 5609 cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 5610 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5611 break;
whismanoid 17:9397ea3ea7e9 5612 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 5613 cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 5614 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5615 break;
whismanoid 29:6a9edb6e973b 5616 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 5617 cmdLine.serial().printf("button");
whismanoid 29:6a9edb6e973b 5618 cmdLine.serial().printf(" %d", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 5619 break;
whismanoid 17:9397ea3ea7e9 5620 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 5621 cmdLine.serial().printf("trigger_Halt");
whismanoid 17:9397ea3ea7e9 5622 break;
whismanoid 17:9397ea3ea7e9 5623 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 5624 cmdLine.serial().printf("trigger_FreeRun");
whismanoid 17:9397ea3ea7e9 5625 break;
whismanoid 17:9397ea3ea7e9 5626 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 5627 cmdLine.serial().printf("trigger_Timer");
whismanoid 17:9397ea3ea7e9 5628 // print configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 5629 cmdLine.serial().printf("(%d x %dmsec)", g_timer_interval_count, g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 5630 break;
whismanoid 17:9397ea3ea7e9 5631 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 5632 cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 5633 // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 5634 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 5635 break;
whismanoid 17:9397ea3ea7e9 5636 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 5637 cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 5638 // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 5639 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 5640 break;
whismanoid 17:9397ea3ea7e9 5641 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5642 //~ cmdLine.serial().printf(" condition %d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 5643 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5644 {
whismanoid 17:9397ea3ea7e9 5645 case condition_always:
whismanoid 17:9397ea3ea7e9 5646 cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 5647 break;
whismanoid 17:9397ea3ea7e9 5648 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 5649 cmdLine.serial().printf(" if A%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5650 break;
whismanoid 17:9397ea3ea7e9 5651 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 5652 cmdLine.serial().printf(" if A%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5653 break;
whismanoid 17:9397ea3ea7e9 5654 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 5655 cmdLine.serial().printf(" if A%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5656 break;
whismanoid 17:9397ea3ea7e9 5657 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 5658 cmdLine.serial().printf(" if A%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5659 break;
whismanoid 17:9397ea3ea7e9 5660 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 5661 cmdLine.serial().printf(" if A%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5662 break;
whismanoid 17:9397ea3ea7e9 5663 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 5664 cmdLine.serial().printf(" if A%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5665 break;
whismanoid 17:9397ea3ea7e9 5666 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 5667 cmdLine.serial().printf(" if AIN%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5668 break;
whismanoid 17:9397ea3ea7e9 5669 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 5670 cmdLine.serial().printf(" if AIN%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5671 break;
whismanoid 17:9397ea3ea7e9 5672 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 5673 cmdLine.serial().printf(" if AIN%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5674 break;
whismanoid 17:9397ea3ea7e9 5675 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 5676 cmdLine.serial().printf(" if AIN%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5677 break;
whismanoid 17:9397ea3ea7e9 5678 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 5679 cmdLine.serial().printf(" if AIN%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5680 break;
whismanoid 17:9397ea3ea7e9 5681 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 5682 cmdLine.serial().printf(" if AIN%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5683 break;
whismanoid 17:9397ea3ea7e9 5684 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5685 } // for ...Datalogger_action_table_row_count // Print the contents of Datalogger_action_table
whismanoid 30:07197a430869 5686 cmdLine.serial().printf("\r\n\r\nEdit Log action table (used %d/%d, %d free):",
whismanoid 30:07197a430869 5687 Datalogger_action_table_row_count,
whismanoid 30:07197a430869 5688 ACTION_TABLE_ROW_MAX,
whismanoid 30:07197a430869 5689 (ACTION_TABLE_ROW_MAX - Datalogger_action_table_row_count)
whismanoid 30:07197a430869 5690 );
whismanoid 17:9397ea3ea7e9 5691 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 5692 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 5693 cmdLine.serial().printf("\r\n L@+ act=4 if=1 ch=5 x=12345 -- add new entry at end of table");
whismanoid 17:9397ea3ea7e9 5694 }
whismanoid 17:9397ea3ea7e9 5695 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 5696 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 5697 cmdLine.serial().printf("\r\n L@%d act=4 if=1 ch=5 x=12345 -- edit row %d",
whismanoid 17:9397ea3ea7e9 5698 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 5699 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 5700 cmdLine.serial().printf("\r\n L@-%d -- delete row %d",
whismanoid 17:9397ea3ea7e9 5701 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 5702 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 5703 cmdLine.serial().printf("\r\n L@-~~~ -- delete all rows");
whismanoid 30:07197a430869 5704 if (Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@. -- pause entire Log action table");
whismanoid 30:07197a430869 5705 if (!Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@@ -- enable Log action table");
whismanoid 17:9397ea3ea7e9 5706 }
whismanoid 17:9397ea3ea7e9 5707 //
whismanoid 17:9397ea3ea7e9 5708 } // case L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5709 break;
whismanoid 17:9397ea3ea7e9 5710 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 5711 // LR -- Datalog free run as fast as possible
whismanoid 4:d9b05924ad4c 5712 case 'R': case 'r':
whismanoid 4:d9b05924ad4c 5713 // free run as fast as possible
whismanoid 8:dffee7509bfb 5714 Datalogger_Trigger = trigger_FreeRun;
whismanoid 8:dffee7509bfb 5715 Datalogger_Need_PrintHeader = true;
whismanoid 4:d9b05924ad4c 5716 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 9:45f98573eb6d 5717 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 5718 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 5719 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 5720 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 5721 case 'S': case 's':
whismanoid 9:45f98573eb6d 5722 {
whismanoid 9:45f98573eb6d 5723 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 5724 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 5725 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 5726 )
whismanoid 9:45f98573eb6d 5727 {
whismanoid 9:45f98573eb6d 5728 // it's me
whismanoid 9:45f98573eb6d 5729 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 5730 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 5731 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 5732 {
whismanoid 9:45f98573eb6d 5733 case 'D': case 'd':
whismanoid 9:45f98573eb6d 5734 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Disable;
whismanoid 9:45f98573eb6d 5735 break;
whismanoid 9:45f98573eb6d 5736 case 'L': case 'l':
whismanoid 9:45f98573eb6d 5737 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 5738 break;
whismanoid 9:45f98573eb6d 5739 case 'V': case 'v':
whismanoid 9:45f98573eb6d 5740 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 5741 break;
whismanoid 9:45f98573eb6d 5742 //
whismanoid 9:45f98573eb6d 5743 //
whismanoid 9:45f98573eb6d 5744 // TODO: MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 5745 case 'C': case 'c':
whismanoid 9:45f98573eb6d 5746 {
whismanoid 9:45f98573eb6d 5747 uint8_t hexValue = 0;
whismanoid 9:45f98573eb6d 5748 hexValue = hexValueOfChar(cmdLine[5]) * 0x10 + hexValueOfChar(cmdLine[6]);
whismanoid 9:45f98573eb6d 5749 switch (cmdLine[4])
whismanoid 9:45f98573eb6d 5750 {
whismanoid 9:45f98573eb6d 5751 //
whismanoid 9:45f98573eb6d 5752 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 5753 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34"));
whismanoid 9:45f98573eb6d 5754 case 'F': case 'f':
whismanoid 9:45f98573eb6d 5755 SPI_AIN_Cfg_v_filter_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 5756 break;
whismanoid 9:45f98573eb6d 5757 //
whismanoid 9:45f98573eb6d 5758 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 5759 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 5760 case 'C': case 'c':
whismanoid 9:45f98573eb6d 5761 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 5762 break;
whismanoid 9:45f98573eb6d 5763 //
whismanoid 9:45f98573eb6d 5764 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 5765 // cmdLine.serial().print(F("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00"));
whismanoid 9:45f98573eb6d 5766 case 'P': case 'p':
whismanoid 9:45f98573eb6d 5767 SPI_AIN_Cfg_v_pga_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 5768 break;
whismanoid 9:45f98573eb6d 5769 //
whismanoid 9:45f98573eb6d 5770 // cmdLine.serial().print(F("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar"));
whismanoid 9:45f98573eb6d 5771 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 5772 case 'U': case 'u':
whismanoid 9:45f98573eb6d 5773 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] | 0x40;
whismanoid 9:45f98573eb6d 5774 break;
whismanoid 9:45f98573eb6d 5775 //
whismanoid 9:45f98573eb6d 5776 // cmdLine.serial().print(F("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar"));
whismanoid 9:45f98573eb6d 5777 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 5778 case 'B': case 'b':
whismanoid 9:45f98573eb6d 5779 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] &~ 0x40;
whismanoid 9:45f98573eb6d 5780 break;
whismanoid 9:45f98573eb6d 5781 }
whismanoid 9:45f98573eb6d 5782 break;
whismanoid 9:45f98573eb6d 5783 }
whismanoid 9:45f98573eb6d 5784 //
whismanoid 9:45f98573eb6d 5785 //
whismanoid 9:45f98573eb6d 5786 }
whismanoid 9:45f98573eb6d 5787 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 5788 } // end for channel_index
whismanoid 9:45f98573eb6d 5789 Datalogger_PrintHeader();
whismanoid 9:45f98573eb6d 5790 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 5791 }
whismanoid 9:45f98573eb6d 5792 break;
whismanoid 9:45f98573eb6d 5793 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 5794 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 5795 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 5796 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 5797 // verb: D for disable, V for Voltage, L for LSB
whismanoid 8:dffee7509bfb 5798 case 'A': case 'a':
whismanoid 9:45f98573eb6d 5799 {
whismanoid 9:45f98573eb6d 5800 // all-channel: loop through all valid channel_index, test cmdLine[2] 'is it me'?
whismanoid 9:45f98573eb6d 5801 // for channel_index loop through 0..NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 9:45f98573eb6d 5802 // if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 5803 // || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 5804 // ) {
whismanoid 9:45f98573eb6d 5805 // // it's me
whismanoid 9:45f98573eb6d 5806 // // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 5807 // // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 5808 // } end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 5809 // } end for channel_index
whismanoid 9:45f98573eb6d 5810 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 5811 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 5812 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 5813 )
whismanoid 9:45f98573eb6d 5814 {
whismanoid 9:45f98573eb6d 5815 // it's me
whismanoid 9:45f98573eb6d 5816 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 5817 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 5818 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 5819 {
whismanoid 9:45f98573eb6d 5820 case 'D': case 'd':
whismanoid 9:45f98573eb6d 5821 Platform_Enable_ch[channel_index] = Platform_AIN_Disable;
whismanoid 9:45f98573eb6d 5822 break;
whismanoid 9:45f98573eb6d 5823 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 5824 case 'L': case 'l':
whismanoid 9:45f98573eb6d 5825 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 5826 break;
whismanoid 9:45f98573eb6d 5827 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 5828 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 5829 case 'V': case 'v':
whismanoid 9:45f98573eb6d 5830 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 5831 break;
whismanoid 9:45f98573eb6d 5832 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 5833 }
whismanoid 9:45f98573eb6d 5834 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 5835 } // end for channel_index
whismanoid 10:04022a61b527 5836 // Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 5837 if (Datalogger_enable_serial) {
whismanoid 9:45f98573eb6d 5838 Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 5839 }
whismanoid 9:45f98573eb6d 5840 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 5841 if (Datalogger_enable_AUXserial) {
whismanoid 9:45f98573eb6d 5842 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 9:45f98573eb6d 5843 }
whismanoid 9:45f98573eb6d 5844 # endif // HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 5845 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 5846 if (Datalogger_enable_DAPLINKserial) {
whismanoid 9:45f98573eb6d 5847 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 9:45f98573eb6d 5848 }
whismanoid 9:45f98573eb6d 5849 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 5850 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 5851 }
whismanoid 8:dffee7509bfb 5852 break;
whismanoid 9:45f98573eb6d 5853 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 5854 case '>':
whismanoid 9:45f98573eb6d 5855 // L>A -- Datalogger_enable_AUXserial
whismanoid 9:45f98573eb6d 5856 // L>D -- Datalogger_enable_DAPLINKserial
whismanoid 9:45f98573eb6d 5857 // L>S -- Datalogger_enable_serial
whismanoid 9:45f98573eb6d 5858 switch (cmdLine[2])
whismanoid 9:45f98573eb6d 5859 {
whismanoid 9:45f98573eb6d 5860 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 5861 case 'A': case 'a':
whismanoid 9:45f98573eb6d 5862 Datalogger_enable_AUXserial = !Datalogger_enable_AUXserial;
whismanoid 9:45f98573eb6d 5863 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 5864 break;
whismanoid 8:dffee7509bfb 5865 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 5866 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 5867 case 'D': case 'd':
whismanoid 9:45f98573eb6d 5868 Datalogger_enable_DAPLINKserial = !Datalogger_enable_DAPLINKserial;
whismanoid 9:45f98573eb6d 5869 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 5870 break;
whismanoid 8:dffee7509bfb 5871 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 5872 case 'S': case 's':
whismanoid 9:45f98573eb6d 5873 Datalogger_enable_serial = !Datalogger_enable_serial;
whismanoid 9:45f98573eb6d 5874 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 5875 break;
whismanoid 9:45f98573eb6d 5876 }
whismanoid 9:45f98573eb6d 5877 break; // case '>' L>S serial enable toggle
whismanoid 28:a9a3a9db592b 5878 default:
whismanoid 28:a9a3a9db592b 5879 // TODO: L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 5880 //
whismanoid 28:a9a3a9db592b 5881 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 5882 #if 1 // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 5883 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 5884 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 5885 //
whismanoid 28:a9a3a9db592b 5886 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 28:a9a3a9db592b 5887 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 28:a9a3a9db592b 5888 cmdLine.serial().printf("\r\n LT count=%d base=%dms -- Datalog timer", g_timer_interval_count, g_timer_interval_msec); // trigger_Timer
whismanoid 28:a9a3a9db592b 5889 //
whismanoid 28:a9a3a9db592b 5890 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 28:a9a3a9db592b 5891 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 5892 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 5893 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 5894 //
whismanoid 28:a9a3a9db592b 5895 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 5896 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 28:a9a3a9db592b 5897 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 5898 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 5899 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 5900 //
whismanoid 28:a9a3a9db592b 5901 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 5902 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 5903 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 5904 //
whismanoid 28:a9a3a9db592b 5905 //
whismanoid 28:a9a3a9db592b 5906 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 5907 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 28:a9a3a9db592b 5908 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 5909 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 5910 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 28:a9a3a9db592b 5911 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 28:a9a3a9db592b 5912 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 28:a9a3a9db592b 5913 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 28:a9a3a9db592b 5914 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 28:a9a3a9db592b 5915 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 28:a9a3a9db592b 5916 //
whismanoid 28:a9a3a9db592b 5917 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 28:a9a3a9db592b 5918 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 28:a9a3a9db592b 5919 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 28:a9a3a9db592b 5920 //
whismanoid 28:a9a3a9db592b 5921 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 5922 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 28:a9a3a9db592b 5923 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 28:a9a3a9db592b 5924 //
whismanoid 28:a9a3a9db592b 5925 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 5926 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 28:a9a3a9db592b 5927 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 5928 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 28:a9a3a9db592b 5929 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 5930 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 28:a9a3a9db592b 5931 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 5932 //
whismanoid 28:a9a3a9db592b 5933 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 28:a9a3a9db592b 5934 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 28:a9a3a9db592b 5935 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 28:a9a3a9db592b 5936 //
whismanoid 28:a9a3a9db592b 5937 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 5938 //
whismanoid 28:a9a3a9db592b 5939 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 28:a9a3a9db592b 5940 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 28:a9a3a9db592b 5941 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 5942 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 5943 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 28:a9a3a9db592b 5944 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 5945 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 28:a9a3a9db592b 5946 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 5947 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 5948 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 28:a9a3a9db592b 5949 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 5950 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 28:a9a3a9db592b 5951 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 5952 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 28:a9a3a9db592b 5953 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 5954 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 5955 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 28:a9a3a9db592b 5956 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 5957 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 5958 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 5959 # if HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 5960 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 5961 # endif // HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 5962 # if HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 5963 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 5964 # endif // HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 5965 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 5966 //
whismanoid 28:a9a3a9db592b 5967 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 5968 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 5969 break;
whismanoid 17:9397ea3ea7e9 5970 } // switch (cmdLine[1]) inside case 'L'
whismanoid 4:d9b05924ad4c 5971 }
whismanoid 4:d9b05924ad4c 5972 break; // case 'L'
whismanoid 4:d9b05924ad4c 5973 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 5974 //
whismanoid 4:d9b05924ad4c 5975 // Application-specific commands here
whismanoid 4:d9b05924ad4c 5976 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 5977 //
whismanoid 4:d9b05924ad4c 5978 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 5979 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 5980
whismanoid 4:d9b05924ad4c 5981 //
whismanoid 4:d9b05924ad4c 5982 // TODO1: add new commands here
whismanoid 4:d9b05924ad4c 5983 //
whismanoid 4:d9b05924ad4c 5984 default:
whismanoid 4:d9b05924ad4c 5985 #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 5986 extern bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5715.cpp
whismanoid 4:d9b05924ad4c 5987 if (!MAX5715_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 5988 #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 5989 extern bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11131.cpp
whismanoid 4:d9b05924ad4c 5990 if (!MAX11131_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 5991 #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 5992 extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp
whismanoid 4:d9b05924ad4c 5993 if (!MAX5171_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 5994 #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 5995 extern bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp
whismanoid 4:d9b05924ad4c 5996 if (!MAX11410_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 5997 #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 5998 extern bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX12345.cpp
whismanoid 4:d9b05924ad4c 5999 if (!MAX12345_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6000 #else
whismanoid 4:d9b05924ad4c 6001 if (0) // not_handled_by_device_submenu
whismanoid 4:d9b05924ad4c 6002 #endif
whismanoid 4:d9b05924ad4c 6003 {
whismanoid 4:d9b05924ad4c 6004 cmdLine.serial().printf("\r\n unknown command ");
whismanoid 4:d9b05924ad4c 6005 //~ cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 6006 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 6007 cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n",
whismanoid 4:d9b05924ad4c 6008 cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 6009 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6010 }
whismanoid 4:d9b05924ad4c 6011 } // switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 6012 //
whismanoid 31:47eee7e0cc2d 6013 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 6014 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 6015 // print command prompt
whismanoid 8:dffee7509bfb 6016 // print_command_prompt();
whismanoid 8:dffee7509bfb 6017 cmdLine.serial().printf("\r\n> ");
whismanoid 31:47eee7e0cc2d 6018 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 6019 }
whismanoid 4:d9b05924ad4c 6020 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 6021
whismanoid 4:d9b05924ad4c 6022 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 6023 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 6024 void Datalogger_PrintHeader(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 6025 {
whismanoid 37:3f369235e5bc 6026 #if MAX40108_DEMO // main_menu_status banner
whismanoid 37:3f369235e5bc 6027 cmdLine.serial().printf("\r\n\r\n\"MAX40108_U%d", MAX40108_DEMO);
whismanoid 37:3f369235e5bc 6028 #ifdef BOARD_SERIAL_NUMBER
whismanoid 37:3f369235e5bc 6029 // data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 6030 cmdLine.serial().printf(" [s/n %d]", BOARD_SERIAL_NUMBER);
whismanoid 37:3f369235e5bc 6031 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 6032 #ifdef FW_REV
whismanoid 37:3f369235e5bc 6033 cmdLine.serial().printf(" [FW_REV %d]", FW_REV);
whismanoid 37:3f369235e5bc 6034 #endif // FW_REV
whismanoid 37:3f369235e5bc 6035 cmdLine.serial().printf("\"\r\n");
whismanoid 37:3f369235e5bc 6036 #endif // MAX40108_DEMO
whismanoid 37:3f369235e5bc 6037
whismanoid 4:d9b05924ad4c 6038 // column header banner for csv data columns
whismanoid 4:d9b05924ad4c 6039 int field_index = 0;
whismanoid 4:d9b05924ad4c 6040 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6041 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 6042 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 4:d9b05924ad4c 6043 continue;
whismanoid 4:d9b05924ad4c 6044 }
whismanoid 4:d9b05924ad4c 6045 // comma between fields
whismanoid 4:d9b05924ad4c 6046 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 6047 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 6048 }
whismanoid 10:04022a61b527 6049 field_index++;
whismanoid 4:d9b05924ad4c 6050 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 6051 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 6052 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 4:d9b05924ad4c 6053 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 4:d9b05924ad4c 6054 cmdLine.serial().printf("\"AIN%d-%d_BIP", channel_index, channel_index+1);
whismanoid 4:d9b05924ad4c 6055 }
whismanoid 4:d9b05924ad4c 6056 else {
whismanoid 4:d9b05924ad4c 6057 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 6058 }
whismanoid 4:d9b05924ad4c 6059 #else // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 6060 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 6061 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 6062 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_LSB) {
whismanoid 4:d9b05924ad4c 6063 // _LSB column header suffix
whismanoid 13:184a08909405 6064 cmdLine.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 6065 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6066 cmdLine_DAPLINKserial.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 6067 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6068 }
whismanoid 10:04022a61b527 6069 else if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_Volt) {
whismanoid 4:d9b05924ad4c 6070 // _V column header suffix
whismanoid 13:184a08909405 6071 cmdLine.serial().printf("_V");
whismanoid 4:d9b05924ad4c 6072 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6073 cmdLine_DAPLINKserial.serial().printf("_V");
whismanoid 4:d9b05924ad4c 6074 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6075 }
whismanoid 13:184a08909405 6076 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6077 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6078 if (SPI_AIN_customChannelHeader_ch[channel_index] && SPI_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 6079 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 6080 cmdLine.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6081 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6082 cmdLine_DAPLINKserial.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6083 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6084 } else {
whismanoid 13:184a08909405 6085 // no custom channel name for this channel
whismanoid 13:184a08909405 6086 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 6087 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6088 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 6089 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6090 }
whismanoid 13:184a08909405 6091 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 6092 // close quote
whismanoid 13:184a08909405 6093 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 6094 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6095 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 6096 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6097 }
whismanoid 4:d9b05924ad4c 6098
whismanoid 4:d9b05924ad4c 6099 #if VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 6100 // PART_ID field: Device ID Validation
whismanoid 4:d9b05924ad4c 6101 cmdLine.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 6102 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6103 cmdLine_DAPLINKserial.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 6104 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6105 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 6106 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 6107 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 6108 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6109 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 6110 continue;
whismanoid 9:45f98573eb6d 6111 }
whismanoid 4:d9b05924ad4c 6112 // comma between fields
whismanoid 4:d9b05924ad4c 6113 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 6114 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 6115 }
whismanoid 9:45f98573eb6d 6116 field_index++;
whismanoid 4:d9b05924ad4c 6117 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 6118 cmdLine.serial().printf("\"A%d", channel_index);
whismanoid 9:45f98573eb6d 6119 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 9:45f98573eb6d 6120 // _LSB column header suffix
whismanoid 13:184a08909405 6121 cmdLine.serial().printf("_LSB");
whismanoid 9:45f98573eb6d 6122 }
whismanoid 9:45f98573eb6d 6123 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 6124 // _V column header suffix
whismanoid 13:184a08909405 6125 cmdLine.serial().printf("_V");
whismanoid 9:45f98573eb6d 6126 }
whismanoid 13:184a08909405 6127 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6128 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6129 if (Platform_AIN_customChannelHeader_ch[channel_index] && Platform_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 6130 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 6131 cmdLine.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6132 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6133 cmdLine_DAPLINKserial.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6134 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6135 } else {
whismanoid 13:184a08909405 6136 // no custom channel name for this channel
whismanoid 13:184a08909405 6137 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 6138 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6139 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 6140 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6141 }
whismanoid 13:184a08909405 6142 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 6143 // close quote
whismanoid 13:184a08909405 6144 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 6145 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6146 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 6147 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6148 }
whismanoid 4:d9b05924ad4c 6149 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 30:07197a430869 6150 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 6151 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in Datalogger_PrintHeader
whismanoid 30:07197a430869 6152 cmdLine.serial().printf(",\"%s\"", gstrRemarkHeader);
whismanoid 30:07197a430869 6153 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 4:d9b05924ad4c 6154 // end of column header line
whismanoid 4:d9b05924ad4c 6155 cmdLine.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 6156 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6157 cmdLine_DAPLINKserial.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 6158 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6159 } // void Datalogger_PrintHeader()
whismanoid 4:d9b05924ad4c 6160
whismanoid 5:aaf8b5f5fda1 6161 //--------------------------------------------------
whismanoid 5:aaf8b5f5fda1 6162 void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 6163 {
whismanoid 5:aaf8b5f5fda1 6164 // CODE GENERATOR: example code: has no member function ScanStandardExternalClock
whismanoid 5:aaf8b5f5fda1 6165 // CODE GENERATOR: example code: has no member function ReadAINcode
whismanoid 5:aaf8b5f5fda1 6166 // CODE GENERATOR: example code: member function Read_All_Voltages
whismanoid 5:aaf8b5f5fda1 6167 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6168 // Measure ADC channels in sequence from AIN0 to channelNumber_0_9.
whismanoid 5:aaf8b5f5fda1 6169 // @param[in] g_MAX11410_device.channelNumber_0_15: AIN Channel Number
whismanoid 5:aaf8b5f5fda1 6170 // @param[in] g_MAX11410_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
whismanoid 5:aaf8b5f5fda1 6171 // @param[in] g_MAX11410_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
whismanoid 10:04022a61b527 6172 //~ int channelId_0_9 = NUM_DUT_ANALOG_IN_CHANNELS-1+1;
whismanoid 5:aaf8b5f5fda1 6173 //g_MAX11410_device.channelNumber_0_15 = channelId_0_9;
whismanoid 5:aaf8b5f5fda1 6174 //g_MAX11410_device.PowerManagement_0_2 = 0;
whismanoid 5:aaf8b5f5fda1 6175 //g_MAX11410_device.chan_id_0_1 = 1;
whismanoid 5:aaf8b5f5fda1 6176 //----------------------------------------
whismanoid 5:aaf8b5f5fda1 6177 // scan AIN0..AIN9
whismanoid 5:aaf8b5f5fda1 6178 //
whismanoid 10:04022a61b527 6179 #if 1
whismanoid 10:04022a61b527 6180 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 6181 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 6182 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 6183 //
whismanoid 10:04022a61b527 6184 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6185 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc3); // GP1 = 0
whismanoid 10:04022a61b527 6186 //
whismanoid 10:04022a61b527 6187 int field_index = 0;
whismanoid 10:04022a61b527 6188 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 6189 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 10:04022a61b527 6190 continue;
whismanoid 10:04022a61b527 6191 }
whismanoid 10:04022a61b527 6192 field_index++;
whismanoid 10:04022a61b527 6193 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[channel_index];
whismanoid 10:04022a61b527 6194 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[channel_index];
whismanoid 10:04022a61b527 6195 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[channel_index];
whismanoid 10:04022a61b527 6196 //
whismanoid 10:04022a61b527 6197 // WIP SampleRate_of_FILTER_CONV_START() MAX11410EMC-FW slow ODR 10Sps #262
whismanoid 10:04022a61b527 6198 // adjust the MAX11410.loop_limit value if the sample rate is set to a value slower than 20sps
whismanoid 10:04022a61b527 6199 // SampleRate_of_FILTER_CONV_START(uint8_t FILTER_RegValue, uint8_t CONV_START_RegValue)
whismanoid 10:04022a61b527 6200 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 6201 if (SampleRate < 20.0) {
whismanoid 10:04022a61b527 6202 g_MAX11410_device.loop_limit = 32767; // TODO: is this timeout long enough for the slow output data rates?
whismanoid 10:04022a61b527 6203 }
whismanoid 10:04022a61b527 6204 //
whismanoid 10:04022a61b527 6205 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6206 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc3); // GP0 = 0
whismanoid 10:04022a61b527 6207 //
whismanoid 10:04022a61b527 6208 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 6209 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 10:04022a61b527 6210 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 10:04022a61b527 6211 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 6212 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = (MAX11410::MAX11410_AINN_SEL_enum_t)(channel_index^1);
whismanoid 10:04022a61b527 6213 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 6214 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 6215 }
whismanoid 10:04022a61b527 6216 else {
whismanoid 10:04022a61b527 6217 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 6218 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = MAX11410::AINN_SEL_1010_GND;
whismanoid 10:04022a61b527 6219 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 6220 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 6221 }
whismanoid 10:04022a61b527 6222 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 6223 //
whismanoid 10:04022a61b527 6224 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6225 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc4); // GP0 = 1
whismanoid 10:04022a61b527 6226 //
whismanoid 10:04022a61b527 6227 }
whismanoid 10:04022a61b527 6228 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6229 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc4); // GP1 = 1
whismanoid 10:04022a61b527 6230 #else
whismanoid 5:aaf8b5f5fda1 6231 g_MAX11410_device.Read_All_Voltages();
whismanoid 10:04022a61b527 6232 #endif
whismanoid 10:04022a61b527 6233 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6234 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 6235 // mbed
whismanoid 5:aaf8b5f5fda1 6236 // Platform board uses simple analog inputs
whismanoid 5:aaf8b5f5fda1 6237 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 5:aaf8b5f5fda1 6238 Platform_LSB[0] = analogIn0.read();
whismanoid 5:aaf8b5f5fda1 6239 Platform_LSB[1] = analogIn1.read();
whismanoid 5:aaf8b5f5fda1 6240 Platform_LSB[2] = analogIn2.read();
whismanoid 5:aaf8b5f5fda1 6241 Platform_LSB[3] = analogIn3.read();
whismanoid 5:aaf8b5f5fda1 6242 Platform_LSB[4] = analogIn4.read();
whismanoid 5:aaf8b5f5fda1 6243 Platform_LSB[5] = analogIn5.read();
whismanoid 10:04022a61b527 6244 #endif
whismanoid 10:04022a61b527 6245 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 37:3f369235e5bc 6246 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 6247 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogIn012345.read()
whismanoid 37:3f369235e5bc 6248 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 6249 float analogIn0_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6250 float analogIn1_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6251 float analogIn2_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6252 float analogIn3_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6253 float analogIn4_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6254 float analogIn5_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6255 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 6256 analogIn0_normValue_0_1 = analogIn0_normValue_0_1 + analogIn0.read();
whismanoid 37:3f369235e5bc 6257 analogIn1_normValue_0_1 = analogIn1_normValue_0_1 + analogIn1.read();
whismanoid 37:3f369235e5bc 6258 analogIn2_normValue_0_1 = analogIn2_normValue_0_1 + analogIn2.read();
whismanoid 37:3f369235e5bc 6259 analogIn3_normValue_0_1 = analogIn3_normValue_0_1 + analogIn3.read();
whismanoid 37:3f369235e5bc 6260 analogIn4_normValue_0_1 = analogIn4_normValue_0_1 + analogIn4.read();
whismanoid 37:3f369235e5bc 6261 analogIn5_normValue_0_1 = analogIn5_normValue_0_1 + analogIn5.read();
whismanoid 37:3f369235e5bc 6262 }
whismanoid 37:3f369235e5bc 6263 analogIn0_normValue_0_1 = analogIn0_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6264 analogIn1_normValue_0_1 = analogIn1_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6265 analogIn2_normValue_0_1 = analogIn2_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6266 analogIn3_normValue_0_1 = analogIn3_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6267 analogIn4_normValue_0_1 = analogIn4_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6268 analogIn5_normValue_0_1 = analogIn5_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6269 #else // USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 6270 float analogIn0_normValue_0_1 = analogIn0.read();
whismanoid 37:3f369235e5bc 6271 float analogIn1_normValue_0_1 = analogIn1.read();
whismanoid 37:3f369235e5bc 6272 float analogIn2_normValue_0_1 = analogIn2.read();
whismanoid 37:3f369235e5bc 6273 float analogIn3_normValue_0_1 = analogIn3.read();
whismanoid 37:3f369235e5bc 6274 float analogIn4_normValue_0_1 = analogIn4.read();
whismanoid 37:3f369235e5bc 6275 float analogIn5_normValue_0_1 = analogIn5.read();
whismanoid 37:3f369235e5bc 6276 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 6277 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 6278 // apply calibration to normValue_0_1 value
whismanoid 37:3f369235e5bc 6279 Platform_Voltage[0] = CalibratedNormValue(0, analogIn0_normValue_0_1) * adc_full_scale_voltage[0];
whismanoid 37:3f369235e5bc 6280 Platform_Voltage[1] = CalibratedNormValue(1, analogIn1_normValue_0_1) * adc_full_scale_voltage[1];
whismanoid 37:3f369235e5bc 6281 Platform_Voltage[2] = CalibratedNormValue(2, analogIn2_normValue_0_1) * adc_full_scale_voltage[2];
whismanoid 37:3f369235e5bc 6282 Platform_Voltage[3] = CalibratedNormValue(3, analogIn3_normValue_0_1) * adc_full_scale_voltage[3];
whismanoid 37:3f369235e5bc 6283 Platform_Voltage[4] = CalibratedNormValue(4, analogIn4_normValue_0_1) * adc_full_scale_voltage[4];
whismanoid 37:3f369235e5bc 6284 Platform_Voltage[5] = CalibratedNormValue(5, analogIn5_normValue_0_1) * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 6285 #else // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 6286 Platform_Voltage[0] = analogIn0_normValue_0_1 * adc_full_scale_voltage[0];
whismanoid 37:3f369235e5bc 6287 Platform_Voltage[1] = analogIn1_normValue_0_1 * adc_full_scale_voltage[1];
whismanoid 37:3f369235e5bc 6288 Platform_Voltage[2] = analogIn2_normValue_0_1 * adc_full_scale_voltage[2];
whismanoid 37:3f369235e5bc 6289 Platform_Voltage[3] = analogIn3_normValue_0_1 * adc_full_scale_voltage[3];
whismanoid 37:3f369235e5bc 6290 Platform_Voltage[4] = analogIn4_normValue_0_1 * adc_full_scale_voltage[4];
whismanoid 37:3f369235e5bc 6291 Platform_Voltage[5] = analogIn5_normValue_0_1 * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 6292 #endif // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 6293 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 5:aaf8b5f5fda1 6294 #endif // defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 6295
whismanoid 5:aaf8b5f5fda1 6296 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6297 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 6298 const uint32_t part_id_expect = 0x000F02;
whismanoid 5:aaf8b5f5fda1 6299 uint32_t part_id_readback;
whismanoid 5:aaf8b5f5fda1 6300 g_MAX11410_device.RegRead(MAX11410::CMD_r001_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xddd_PART_ID, &part_id_readback);
whismanoid 5:aaf8b5f5fda1 6301 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6302 } // void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 6303
whismanoid 17:9397ea3ea7e9 6304 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6305 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 6306 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 6307 void Datalogger_RunActionTable()
whismanoid 17:9397ea3ea7e9 6308 {
whismanoid 17:9397ea3ea7e9 6309 if (Datalogger_action_table_enabled == false) {
whismanoid 17:9397ea3ea7e9 6310 return;
whismanoid 17:9397ea3ea7e9 6311 }
whismanoid 17:9397ea3ea7e9 6312 // TODO: verbose Datalogger_RunActionTable() emit a csv column ,"Action"
whismanoid 17:9397ea3ea7e9 6313 // TODO: assert Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX
whismanoid 17:9397ea3ea7e9 6314 // for Datalogger_action_table[0..Datalogger_action_table_row_count]
whismanoid 17:9397ea3ea7e9 6315 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 6316 {
whismanoid 17:9397ea3ea7e9 6317 // skip if Datalogger_action_table[i].action == action_noop
whismanoid 17:9397ea3ea7e9 6318 if (Datalogger_action_table[i].action == action_noop) {
whismanoid 17:9397ea3ea7e9 6319 continue;
whismanoid 17:9397ea3ea7e9 6320 }
whismanoid 17:9397ea3ea7e9 6321 // TODO: test Datalogger_action_table[i].condition "if="
whismanoid 17:9397ea3ea7e9 6322 // TODO: Could the .condition field also distinguish Platform ADC from SPI ADC?
whismanoid 17:9397ea3ea7e9 6323 // That way we keep both sets of ADC channels in separate lists
whismanoid 17:9397ea3ea7e9 6324 // if=0 -- always
whismanoid 17:9397ea3ea7e9 6325 // if=1,2,3,4,5,6 -- Platform_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 6326 // if=7,8,9,10,11,12 -- SPI_AIN_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 6327 // also, are we comparing code or voltage?
whismanoid 17:9397ea3ea7e9 6328 // TODO: selected Datalogger_action_table[i].condition_channel
whismanoid 17:9397ea3ea7e9 6329 // Datalogger could have both platform ADC and external SPI ADC channels
whismanoid 17:9397ea3ea7e9 6330 // if SPI_ADC_DeviceName
whismanoid 17:9397ea3ea7e9 6331 // NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 6332 // SPI_AIN_Enable_ch[]
whismanoid 17:9397ea3ea7e9 6333 // SPI_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 6334 // SPI_AIN_Voltage[]
whismanoid 17:9397ea3ea7e9 6335 // if LOG_PLATFORM_AIN
whismanoid 17:9397ea3ea7e9 6336 // NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 6337 // analogInPin_fullScaleVoltage[]
whismanoid 17:9397ea3ea7e9 6338 // Platform_Enable_ch[]
whismanoid 17:9397ea3ea7e9 6339 // Platform_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 6340 // Platform_Voltage[]
whismanoid 17:9397ea3ea7e9 6341 // TODO: selected Datalogger_action_table[i].condition_threshold
whismanoid 17:9397ea3ea7e9 6342 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6343 {
whismanoid 17:9397ea3ea7e9 6344 case condition_always:
whismanoid 17:9397ea3ea7e9 6345 //~ cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 6346 break;
whismanoid 17:9397ea3ea7e9 6347 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 6348 //~ cmdLine.serial().printf(" if A%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6349 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6350 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6351 continue;
whismanoid 17:9397ea3ea7e9 6352 }
whismanoid 17:9397ea3ea7e9 6353 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6354 break;
whismanoid 17:9397ea3ea7e9 6355 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 6356 //~ cmdLine.serial().printf(" if A%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6357 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6358 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6359 continue;
whismanoid 17:9397ea3ea7e9 6360 }
whismanoid 17:9397ea3ea7e9 6361 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6362 break;
whismanoid 17:9397ea3ea7e9 6363 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 6364 //~ cmdLine.serial().printf(" if A%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6365 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6366 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6367 continue;
whismanoid 17:9397ea3ea7e9 6368 }
whismanoid 17:9397ea3ea7e9 6369 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6370 break;
whismanoid 17:9397ea3ea7e9 6371 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 6372 //~ cmdLine.serial().printf(" if A%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6373 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6374 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6375 continue;
whismanoid 17:9397ea3ea7e9 6376 }
whismanoid 17:9397ea3ea7e9 6377 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6378 break;
whismanoid 17:9397ea3ea7e9 6379 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 6380 //~ cmdLine.serial().printf(" if A%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6381 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6382 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6383 continue;
whismanoid 17:9397ea3ea7e9 6384 }
whismanoid 17:9397ea3ea7e9 6385 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6386 break;
whismanoid 17:9397ea3ea7e9 6387 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 6388 //~ cmdLine.serial().printf(" if A%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6389 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6390 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6391 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6392 continue;
whismanoid 17:9397ea3ea7e9 6393 }
whismanoid 17:9397ea3ea7e9 6394 break;
whismanoid 17:9397ea3ea7e9 6395 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 6396 //~ cmdLine.serial().printf(" if AIN%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6397 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6398 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6399 continue;
whismanoid 17:9397ea3ea7e9 6400 }
whismanoid 17:9397ea3ea7e9 6401 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6402 break;
whismanoid 17:9397ea3ea7e9 6403 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 6404 //~ cmdLine.serial().printf(" if AIN%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6405 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6406 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6407 continue;
whismanoid 17:9397ea3ea7e9 6408 }
whismanoid 17:9397ea3ea7e9 6409 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6410 break;
whismanoid 17:9397ea3ea7e9 6411 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 6412 //~ cmdLine.serial().printf(" if AIN%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6413 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6414 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6415 continue;
whismanoid 17:9397ea3ea7e9 6416 }
whismanoid 17:9397ea3ea7e9 6417 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6418 break;
whismanoid 17:9397ea3ea7e9 6419 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 6420 //~ cmdLine.serial().printf(" if AIN%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6421 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6422 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6423 continue;
whismanoid 17:9397ea3ea7e9 6424 }
whismanoid 17:9397ea3ea7e9 6425 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6426 break;
whismanoid 17:9397ea3ea7e9 6427 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 6428 //~ cmdLine.serial().printf(" if AIN%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6429 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6430 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6431 continue;
whismanoid 17:9397ea3ea7e9 6432 }
whismanoid 17:9397ea3ea7e9 6433 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6434 break;
whismanoid 17:9397ea3ea7e9 6435 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 6436 //~ cmdLine.serial().printf(" if AIN%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6437 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6438 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6439 continue;
whismanoid 17:9397ea3ea7e9 6440 }
whismanoid 17:9397ea3ea7e9 6441 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6442 break;
whismanoid 17:9397ea3ea7e9 6443 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6444 // selected Datalogger_action_table[i].digitalOutPin
whismanoid 17:9397ea3ea7e9 6445 // perform selected Datalogger_action_table[i].action
whismanoid 17:9397ea3ea7e9 6446 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6447 {
whismanoid 17:9397ea3ea7e9 6448 case action_noop:
whismanoid 17:9397ea3ea7e9 6449 //~ cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 6450 break;
whismanoid 17:9397ea3ea7e9 6451 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 6452 {
whismanoid 17:9397ea3ea7e9 6453 //~ cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 6454 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6455 // perform action digitalOutLow
whismanoid 17:9397ea3ea7e9 6456 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 6457 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 6458 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6459 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6460 #else
whismanoid 17:9397ea3ea7e9 6461 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 6462 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 6463 digitalInOutPin.write(0);
whismanoid 17:9397ea3ea7e9 6464 #endif
whismanoid 17:9397ea3ea7e9 6465 }
whismanoid 17:9397ea3ea7e9 6466 break;
whismanoid 17:9397ea3ea7e9 6467 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 6468 {
whismanoid 17:9397ea3ea7e9 6469 //~ cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 6470 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6471 // perform action digitalOutHigh
whismanoid 17:9397ea3ea7e9 6472 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 6473 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 6474 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6475 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6476 #else
whismanoid 17:9397ea3ea7e9 6477 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 6478 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 6479 digitalInOutPin.write(1);
whismanoid 17:9397ea3ea7e9 6480 #endif
whismanoid 17:9397ea3ea7e9 6481 }
whismanoid 17:9397ea3ea7e9 6482 break;
whismanoid 29:6a9edb6e973b 6483 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6484 {
whismanoid 30:07197a430869 6485 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 6486 Datalogger_Trigger_enum_t saved_Datalogger_Trigger = Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 6487 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6488 switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6489 {
whismanoid 29:6a9edb6e973b 6490 case 1:
whismanoid 29:6a9edb6e973b 6491 onButton1FallingEdge();
whismanoid 29:6a9edb6e973b 6492 break;
whismanoid 29:6a9edb6e973b 6493 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6494 case 2:
whismanoid 29:6a9edb6e973b 6495 onButton2FallingEdge();
whismanoid 29:6a9edb6e973b 6496 break;
whismanoid 29:6a9edb6e973b 6497 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6498 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6499 case 3:
whismanoid 29:6a9edb6e973b 6500 onButton3FallingEdge();
whismanoid 29:6a9edb6e973b 6501 break;
whismanoid 29:6a9edb6e973b 6502 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6503 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6504 case 4:
whismanoid 29:6a9edb6e973b 6505 onButton4FallingEdge();
whismanoid 29:6a9edb6e973b 6506 break;
whismanoid 29:6a9edb6e973b 6507 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6508 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6509 case 5:
whismanoid 29:6a9edb6e973b 6510 onButton5FallingEdge();
whismanoid 29:6a9edb6e973b 6511 break;
whismanoid 29:6a9edb6e973b 6512 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6513 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6514 case 6:
whismanoid 29:6a9edb6e973b 6515 onButton6FallingEdge();
whismanoid 29:6a9edb6e973b 6516 break;
whismanoid 29:6a9edb6e973b 6517 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6518 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6519 case 7:
whismanoid 29:6a9edb6e973b 6520 onButton7FallingEdge();
whismanoid 29:6a9edb6e973b 6521 break;
whismanoid 29:6a9edb6e973b 6522 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6523 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6524 case 8:
whismanoid 29:6a9edb6e973b 6525 onButton8FallingEdge();
whismanoid 29:6a9edb6e973b 6526 break;
whismanoid 29:6a9edb6e973b 6527 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6528 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6529 case 9:
whismanoid 29:6a9edb6e973b 6530 onButton9FallingEdge();
whismanoid 29:6a9edb6e973b 6531 break;
whismanoid 29:6a9edb6e973b 6532 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6533 } // switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6534 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 30:07197a430869 6535 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 6536 Datalogger_Trigger = saved_Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 6537 } // case action_button
whismanoid 29:6a9edb6e973b 6538 break;
whismanoid 17:9397ea3ea7e9 6539 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 6540 //~ cmdLine.serial().printf("trigger_Halt");
whismanoid 17:9397ea3ea7e9 6541 // perform action trigger_Halt
whismanoid 17:9397ea3ea7e9 6542 Datalogger_Trigger = trigger_Halt;
whismanoid 17:9397ea3ea7e9 6543 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6544 break;
whismanoid 17:9397ea3ea7e9 6545 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 6546 //~ cmdLine.serial().printf("trigger_FreeRun");
whismanoid 17:9397ea3ea7e9 6547 // perform action trigger_FreeRun
whismanoid 17:9397ea3ea7e9 6548 Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 6549 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6550 break;
whismanoid 17:9397ea3ea7e9 6551 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 6552 //~ cmdLine.serial().printf("trigger_Timer");
whismanoid 17:9397ea3ea7e9 6553 //~ // print configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 6554 //~ cmdLine.serial().printf("(%d x %dmsec)", g_timer_interval_count, g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 6555 // perform action trigger_Timer
whismanoid 17:9397ea3ea7e9 6556 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 6557 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6558 break;
whismanoid 17:9397ea3ea7e9 6559 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 6560 //~ cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 6561 //~ // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 6562 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 6563 // TODO: perform action action_trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 6564 Datalogger_Trigger = trigger_PlatformDigitalInput;
whismanoid 17:9397ea3ea7e9 6565 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6566 break;
whismanoid 17:9397ea3ea7e9 6567 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 6568 //~ cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 6569 //~ // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6570 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 6571 // TODO: perform action action_trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6572 Datalogger_Trigger = trigger_SPIDeviceRegRead;
whismanoid 17:9397ea3ea7e9 6573 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6574 break;
whismanoid 17:9397ea3ea7e9 6575 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6576 // consider next row of action table
whismanoid 17:9397ea3ea7e9 6577 } // for ...Datalogger_action_table_row_count
whismanoid 17:9397ea3ea7e9 6578 }
whismanoid 17:9397ea3ea7e9 6579 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6580
whismanoid 5:aaf8b5f5fda1 6581 //--------------------------------------------------
whismanoid 8:dffee7509bfb 6582 void Datalogger_PrintRow(CmdLine& cmdLine)
whismanoid 5:aaf8b5f5fda1 6583 {
whismanoid 5:aaf8b5f5fda1 6584 int field_index = 0;
whismanoid 5:aaf8b5f5fda1 6585 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6586 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 6587 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 5:aaf8b5f5fda1 6588 continue;
whismanoid 5:aaf8b5f5fda1 6589 }
whismanoid 5:aaf8b5f5fda1 6590 // comma between fields
whismanoid 5:aaf8b5f5fda1 6591 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 6592 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 6593 }
whismanoid 10:04022a61b527 6594 field_index++;
whismanoid 10:04022a61b527 6595 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 10:04022a61b527 6596 cmdLine.serial().printf("%d", g_MAX11410_device.AINcode[channel_index]);
whismanoid 10:04022a61b527 6597 }
whismanoid 10:04022a61b527 6598 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 10:04022a61b527 6599 // TODO: report Voltage instead of LSB
whismanoid 10:04022a61b527 6600 // Serial.print(SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 6601 static char strOutLineBuffer[16];
whismanoid 10:04022a61b527 6602 cmdLine.serial().printf("%6.6f", SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 6603 }
whismanoid 5:aaf8b5f5fda1 6604 }
whismanoid 5:aaf8b5f5fda1 6605 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6606 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 6607 if (part_id_readback != part_id_expect) {
whismanoid 5:aaf8b5f5fda1 6608 cmdLine.serial().printf(",\"FAIL\"");
whismanoid 9:45f98573eb6d 6609 need_reinit = true;
whismanoid 5:aaf8b5f5fda1 6610 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6611 g_MAX11410_device.Init();
whismanoid 5:aaf8b5f5fda1 6612 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 5:aaf8b5f5fda1 6613 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 5:aaf8b5f5fda1 6614 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 5:aaf8b5f5fda1 6615 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6616 }
whismanoid 5:aaf8b5f5fda1 6617 else {
whismanoid 5:aaf8b5f5fda1 6618 cmdLine.serial().printf(",\"OK\"");
whismanoid 5:aaf8b5f5fda1 6619 }
whismanoid 5:aaf8b5f5fda1 6620 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6621 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6622 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 6623 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6624 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 6625 continue;
whismanoid 9:45f98573eb6d 6626 }
whismanoid 5:aaf8b5f5fda1 6627 // comma between fields
whismanoid 5:aaf8b5f5fda1 6628 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 6629 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 6630 }
whismanoid 9:45f98573eb6d 6631 field_index++;
whismanoid 9:45f98573eb6d 6632 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 5:aaf8b5f5fda1 6633 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 6634 cmdLine.serial().printf("%u", Platform_LSB[channel_index]);
whismanoid 9:45f98573eb6d 6635 #endif
whismanoid 9:45f98573eb6d 6636 }
whismanoid 9:45f98573eb6d 6637 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 6638 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 11:2b8adc78618a 6639 // Datalog Volts omit V suffix from numbers #275
whismanoid 11:2b8adc78618a 6640 // because Excel graphs can't handle numbers that have a suffix.
whismanoid 11:2b8adc78618a 6641 cmdLine.serial().printf("%6.6f", Platform_Voltage[channel_index]);
whismanoid 9:45f98573eb6d 6642 #endif
whismanoid 9:45f98573eb6d 6643 }
whismanoid 5:aaf8b5f5fda1 6644 }
whismanoid 5:aaf8b5f5fda1 6645 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 6646 if (need_reinit) {
whismanoid 9:45f98573eb6d 6647 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6648 if (g_MAX11410_device.Init() == 0) {
whismanoid 9:45f98573eb6d 6649 //~ cmdLine.serial().printf(",\"Init() failed\"");
whismanoid 9:45f98573eb6d 6650 } else {
whismanoid 9:45f98573eb6d 6651 //~ cmdLine.serial().printf(",\"Init() success\"");
whismanoid 9:45f98573eb6d 6652 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 6653 // in Datalogger_PrintRow(), when part_id test fails,
whismanoid 9:45f98573eb6d 6654 // apply list of custom register writes after re-init
whismanoid 9:45f98573eb6d 6655 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 6656 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 9:45f98573eb6d 6657 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 9:45f98573eb6d 6658 uint32_t regData = custom_reg_init_data[index];
whismanoid 9:45f98573eb6d 6659 cmdLine.serial().printf("*%s=0x%06.6x", g_MAX11410_device.RegName(regAddress), regData);
whismanoid 9:45f98573eb6d 6660 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 9:45f98573eb6d 6661 }
whismanoid 9:45f98573eb6d 6662 #endif // USE_CUSTOM_REG_INIT
whismanoid 9:45f98573eb6d 6663 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 9:45f98573eb6d 6664 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 9:45f98573eb6d 6665 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 9:45f98573eb6d 6666 need_reinit = false;
whismanoid 9:45f98573eb6d 6667 }
whismanoid 9:45f98573eb6d 6668 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6669 need_reinit = false;
whismanoid 9:45f98573eb6d 6670 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6671 }
whismanoid 30:07197a430869 6672 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 6673 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in void Datalogger_PrintRow()
whismanoid 30:07197a430869 6674 cmdLine.serial().printf(",\"%s\"", gstrRemarkText);
whismanoid 30:07197a430869 6675 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 5:aaf8b5f5fda1 6676 cmdLine.serial().printf("\r\n");
whismanoid 9:45f98573eb6d 6677 if (need_reinit) {
whismanoid 9:45f98573eb6d 6678 //~ delay(500); // platform_delay_ms 500ms timing delay function
whismanoid 9:45f98573eb6d 6679 }
whismanoid 5:aaf8b5f5fda1 6680 } // void Datalogger_PrintRow()
whismanoid 5:aaf8b5f5fda1 6681
whismanoid 0:cb44e2e9ec4c 6682 // example code main function
whismanoid 0:cb44e2e9ec4c 6683 int main()
whismanoid 0:cb44e2e9ec4c 6684 {
whismanoid 0:cb44e2e9ec4c 6685 // setup: put your setup code here, to run once
whismanoid 4:d9b05924ad4c 6686 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 6687 // Configure serial ports
whismanoid 4:d9b05924ad4c 6688 cmdLine.clear();
whismanoid 4:d9b05924ad4c 6689 //~ cmdLine.serial().printf("\r\n cmdLine.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 6690 cmdLine.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 6691 //~ cmdLine.diagnostic_led_EOF = diagnostic_led_EOF;
whismanoid 4:d9b05924ad4c 6692 /// CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21);
whismanoid 4:d9b05924ad4c 6693 //~ cmdLine.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 6694 //~ cmdLine.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 6695 //~ cmdLine.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 6696 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6697 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6698 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 6699 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 6700 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 6701 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 6702 # else
whismanoid 10:04022a61b527 6703 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 6704 DAPLINKserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6705 # endif
whismanoid 10:04022a61b527 6706 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 6707 cmdLine_DAPLINKserial.clear();
whismanoid 4:d9b05924ad4c 6708 //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 6709 cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 6710 //~ cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 6711 //~ cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 6712 //~ cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 6713 # endif
whismanoid 6:f6d16658342b 6714 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6715 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 10:04022a61b527 6716 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6717 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 6718 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 6719 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 6720 AUXserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6721 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 6:f6d16658342b 6722 cmdLine_AUXserial.clear();
whismanoid 6:f6d16658342b 6723 //~ cmdLine_AUXserial.serial().printf("\r\n cmdLine_AUXserial.serial().printf test\r\n");
whismanoid 6:f6d16658342b 6724 cmdLine_AUXserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 6:f6d16658342b 6725 //~ cmdLine_AUXserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 6:f6d16658342b 6726 //~ cmdLine_AUXserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 6:f6d16658342b 6727 //~ cmdLine_AUXserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 6:f6d16658342b 6728 # endif // HAS_AUX_SERIAL
whismanoid 4:d9b05924ad4c 6729 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 0:cb44e2e9ec4c 6730
whismanoid 0:cb44e2e9ec4c 6731 // example code: serial port banner message
whismanoid 0:cb44e2e9ec4c 6732 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 6733 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6734 cmdLine.serial().printf("\r\nDataLogger_MAX11410\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 6735 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 6736 cmdLine.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 6737 # if HAS_DAPLINK_SERIAL
whismanoid 3:9055e17e181a 6738 cmdLine_DAPLINKserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 6739 # endif // HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 6740 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6741 cmdLine_AUXserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 6:f6d16658342b 6742 # endif // HAS_AUX_SERIAL
whismanoid 3:9055e17e181a 6743 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6744
whismanoid 1:747f1602abfc 6745 // CODE GENERATOR: get spi properties from device
whismanoid 3:9055e17e181a 6746 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6747 if (g_SPI_SCLK_Hz > g_MAX11410_device.get_spi_frequency())
whismanoid 3:9055e17e181a 6748 { // Device limits SPI SCLK frequency
whismanoid 3:9055e17e181a 6749 g_SPI_SCLK_Hz = g_MAX11410_device.get_spi_frequency();
whismanoid 3:9055e17e181a 6750 cmdLine.serial().printf("\r\nMAX11410 limits SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 6751
whismanoid 3:9055e17e181a 6752 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 6753 }
whismanoid 3:9055e17e181a 6754 if (g_MAX11410_device.get_spi_frequency() > g_SPI_SCLK_Hz)
whismanoid 3:9055e17e181a 6755 { // Platform limits SPI SCLK frequency
whismanoid 3:9055e17e181a 6756 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 6757 cmdLine.serial().printf("\r\nPlatform limits MAX11410 SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 6758
whismanoid 3:9055e17e181a 6759 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 6760 }
whismanoid 0:cb44e2e9ec4c 6761 // g_SPI_dataMode = g_MAX11410_device.get_spi_dataMode();
whismanoid 3:9055e17e181a 6762 while (g_MAX11410_device.Init() == 0)
whismanoid 3:9055e17e181a 6763 {
whismanoid 3:9055e17e181a 6764 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 6765 cmdLine.serial().printf("\r\nMAX11410 Init failed; retry...\r\n");
whismanoid 3:9055e17e181a 6766
whismanoid 3:9055e17e181a 6767 }
whismanoid 0:cb44e2e9ec4c 6768
whismanoid 0:cb44e2e9ec4c 6769 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 3:9055e17e181a 6770 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6771 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 3:9055e17e181a 6772 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 3:9055e17e181a 6773 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 3:9055e17e181a 6774 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 6775 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 3:9055e17e181a 6776 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 6777 // CODE GENERATOR: example code: has no member function REF
whismanoid 0:cb44e2e9ec4c 6778 // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line
whismanoid 0:cb44e2e9ec4c 6779 // CODE GENERATOR: ResolutionBits = 24
whismanoid 0:cb44e2e9ec4c 6780 // CODE GENERATOR: FScode = 0xffffff
whismanoid 0:cb44e2e9ec4c 6781 // CODE GENERATOR: NumChannels = 10
whismanoid 0:cb44e2e9ec4c 6782 // CODE GENERATOR: banner before DataLogHelloCppCodeList while(1)
whismanoid 3:9055e17e181a 6783 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6784 cmdLine.serial().printf("v_filter = 0x%2.2x\r\n", g_MAX11410_device.v_filter);
whismanoid 0:cb44e2e9ec4c 6785
whismanoid 3:9055e17e181a 6786 cmdLine.serial().printf("v_pga = 0x%2.2x\r\n", g_MAX11410_device.v_pga);
whismanoid 0:cb44e2e9ec4c 6787
whismanoid 3:9055e17e181a 6788 cmdLine.serial().printf("v_ctrl = 0x%2.2x\r\n", g_MAX11410_device.v_ctrl);
whismanoid 3:9055e17e181a 6789
whismanoid 3:9055e17e181a 6790 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 6791
whismanoid 3:9055e17e181a 6792 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 6793 Datalogger_Need_PrintHeader = true;
whismanoid 10:04022a61b527 6794
whismanoid 12:2dfc1f2009e0 6795 #if USE_LEDS
whismanoid 12:2dfc1f2009e0 6796 #if defined(TARGET_MAX32630)
whismanoid 12:2dfc1f2009e0 6797 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 6798 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6799 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 6800 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6801 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 6802 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6803 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 6804 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6805 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 6806 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6807 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 6808 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6809 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 6810 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6811 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 6812 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 19:5ff09c8e9daf 6813 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 12:2dfc1f2009e0 6814 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 6815 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6816 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 6817 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6818 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 6819 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6820 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 6821 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6822 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 6823 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6824 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 6825 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6826 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 6827 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6828 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 6829 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6830 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 12:2dfc1f2009e0 6831 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 6832 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6833 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6834 led4 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6835 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 6836 //led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 6837 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 6838 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 6839 led1 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6840 //led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 6841 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 6842 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 6843 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6844 //led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 6845 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 6846 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 6847 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6848 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 6849 //
whismanoid 12:2dfc1f2009e0 6850 #endif // target definition
whismanoid 12:2dfc1f2009e0 6851 #endif
whismanoid 12:2dfc1f2009e0 6852
whismanoid 12:2dfc1f2009e0 6853 if (led1.is_connected()) {
whismanoid 12:2dfc1f2009e0 6854 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 6855 }
whismanoid 12:2dfc1f2009e0 6856 if (led2.is_connected()) {
whismanoid 12:2dfc1f2009e0 6857 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 6858 }
whismanoid 12:2dfc1f2009e0 6859 if (led3.is_connected()) {
whismanoid 12:2dfc1f2009e0 6860 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 6861 }
whismanoid 12:2dfc1f2009e0 6862
whismanoid 4:d9b05924ad4c 6863 while(1) { // this code repeats forever
whismanoid 4:d9b05924ad4c 6864 // this code repeats forever
whismanoid 4:d9b05924ad4c 6865
whismanoid 21:ac062a97a71d 6866 #if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 6867 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 6868 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 6869 # if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 6870 static int button1_value_prev = 1;
whismanoid 21:ac062a97a71d 6871 static int button1_value_now = 1;
whismanoid 21:ac062a97a71d 6872 button1_value_prev = button1_value_now;
whismanoid 21:ac062a97a71d 6873 button1_value_now = button1.read();
whismanoid 21:ac062a97a71d 6874 if ((button1_value_prev - button1_value_now) == 1)
whismanoid 21:ac062a97a71d 6875 {
whismanoid 21:ac062a97a71d 6876 // on button1 falling edge (button1 press)
whismanoid 21:ac062a97a71d 6877 onButton1FallingEdge();
whismanoid 21:ac062a97a71d 6878 }
whismanoid 21:ac062a97a71d 6879 # endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 6880 # if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 6881 static int button2_value_prev = 1;
whismanoid 24:032f3683cb2a 6882 static int button2_value_now = 1;
whismanoid 24:032f3683cb2a 6883 button2_value_prev = button2_value_now;
whismanoid 24:032f3683cb2a 6884 button2_value_now = button2.read();
whismanoid 24:032f3683cb2a 6885 if ((button2_value_prev - button2_value_now) == 1)
whismanoid 24:032f3683cb2a 6886 {
whismanoid 24:032f3683cb2a 6887 // on button2 falling edge (button2 press)
whismanoid 24:032f3683cb2a 6888 onButton2FallingEdge();
whismanoid 24:032f3683cb2a 6889 }
whismanoid 24:032f3683cb2a 6890 # endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 6891 # if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 6892 static int button3_value_prev = 1;
whismanoid 24:032f3683cb2a 6893 static int button3_value_now = 1;
whismanoid 24:032f3683cb2a 6894 button3_value_prev = button3_value_now;
whismanoid 24:032f3683cb2a 6895 button3_value_now = button3.read();
whismanoid 24:032f3683cb2a 6896 if ((button3_value_prev - button3_value_now) == 1)
whismanoid 24:032f3683cb2a 6897 {
whismanoid 24:032f3683cb2a 6898 // on button3 falling edge (button3 press)
whismanoid 26:13cba69d88eb 6899 onButton3FallingEdge();
whismanoid 24:032f3683cb2a 6900 }
whismanoid 24:032f3683cb2a 6901 # endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 6902 #endif // HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 4:d9b05924ad4c 6903 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 6904 // TODO support CmdLine command menus (like on Serial_Tester); help and usual boilerplate
whismanoid 10:04022a61b527 6905 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6906 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 6907 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 6908 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6909 // Accept commands from Auxiliary serial port
whismanoid 6:f6d16658342b 6910 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6911 if (AUXserial.readable()) {
whismanoid 6:f6d16658342b 6912 cmdLine_AUXserial.append(AUXserial.getc());
whismanoid 6:f6d16658342b 6913 }
whismanoid 6:f6d16658342b 6914 # endif // HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6915 # if HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 6916 if (DAPLINKserial.readable()) {
whismanoid 6:f6d16658342b 6917 cmdLine_DAPLINKserial.append(DAPLINKserial.getc());
whismanoid 6:f6d16658342b 6918 }
whismanoid 6:f6d16658342b 6919 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6920 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 6921 if (serial.readable()) {
whismanoid 4:d9b05924ad4c 6922 int c = serial.getc(); // instead of getc() or fgetc()
whismanoid 4:d9b05924ad4c 6923 cmdLine.append(c);
whismanoid 4:d9b05924ad4c 6924 // cmdLine.onEOLcommandParser handler implements menus
whismanoid 4:d9b05924ad4c 6925 } // if (Serial.available())
whismanoid 4:d9b05924ad4c 6926 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 6927
whismanoid 4:d9b05924ad4c 6928 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 32:80f3e5eb77d4 6929 // Datalog trigger
whismanoid 4:d9b05924ad4c 6930 if (Datalogger_Trigger == trigger_Halt) {
whismanoid 4:d9b05924ad4c 6931 // halt the datalogger; continue accepting commands
whismanoid 3:9055e17e181a 6932 continue;
whismanoid 3:9055e17e181a 6933 }
whismanoid 4:d9b05924ad4c 6934 if (Datalogger_Trigger == trigger_FreeRun) {
whismanoid 4:d9b05924ad4c 6935 // free run as fast as possible
whismanoid 3:9055e17e181a 6936 }
whismanoid 4:d9b05924ad4c 6937 if (Datalogger_Trigger == trigger_Timer) {
whismanoid 4:d9b05924ad4c 6938 // timer (configure interval)
whismanoid 32:80f3e5eb77d4 6939 // if Datalogger_Trigger == trigger_Timer sleep(g_timer_interval_msec)
whismanoid 17:9397ea3ea7e9 6940 // sleep(g_timer_interval_msec); // error: too many arguments to function 'void sleep()'
whismanoid 17:9397ea3ea7e9 6941 wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 17:9397ea3ea7e9 6942 if (g_timer_interval_counter > 0) {
whismanoid 17:9397ea3ea7e9 6943 g_timer_interval_counter--;
whismanoid 17:9397ea3ea7e9 6944 continue;
whismanoid 17:9397ea3ea7e9 6945 }
whismanoid 17:9397ea3ea7e9 6946 // if time interval not yet reached, continue (continue accepting commands)
whismanoid 32:80f3e5eb77d4 6947 g_timer_interval_counter = g_timer_interval_count-1;
whismanoid 3:9055e17e181a 6948 }
whismanoid 4:d9b05924ad4c 6949 if (Datalogger_Trigger == trigger_PlatformDigitalInput) {
whismanoid 4:d9b05924ad4c 6950 // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 6951 // TODO: read selected input pin, test value
whismanoid 17:9397ea3ea7e9 6952 // TODO: if no match, continue (continue accepting commands)
whismanoid 3:9055e17e181a 6953 }
whismanoid 4:d9b05924ad4c 6954 if (Datalogger_Trigger == trigger_SPIDeviceRegRead) {
whismanoid 4:d9b05924ad4c 6955 // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 6956 // TODO: SPI transfer regAddr
whismanoid 17:9397ea3ea7e9 6957 // TODO: apply dataMask, compare with testValue
whismanoid 17:9397ea3ea7e9 6958 // TODO: if no match, continue (continue accepting commands)
whismanoid 4:d9b05924ad4c 6959 }
whismanoid 4:d9b05924ad4c 6960 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 0:cb44e2e9ec4c 6961
whismanoid 8:dffee7509bfb 6962 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 6963 if (Datalogger_Need_PrintHeader) {
whismanoid 8:dffee7509bfb 6964 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 6965 Datalogger_PrintHeader(cmdLine);
whismanoid 8:dffee7509bfb 6966 }
whismanoid 8:dffee7509bfb 6967 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6968 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 6969 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 6970 }
whismanoid 8:dffee7509bfb 6971 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6972 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 6973 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 6974 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 6975 }
whismanoid 8:dffee7509bfb 6976 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 6977 Datalogger_Need_PrintHeader = false;
whismanoid 8:dffee7509bfb 6978 }
whismanoid 5:aaf8b5f5fda1 6979 Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 6980 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6981 // Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 6982 Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 6983 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 0:cb44e2e9ec4c 6984 // wait(3.0);
whismanoid 0:cb44e2e9ec4c 6985 // CODE GENERATOR: print conversion result
whismanoid 0:cb44e2e9ec4c 6986 // Use Arduino Serial Plotter to view output: Tools | Serial Plotter
whismanoid 8:dffee7509bfb 6987 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 6988 Datalogger_PrintRow(cmdLine);
whismanoid 8:dffee7509bfb 6989 }
whismanoid 8:dffee7509bfb 6990 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6991 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 6992 Datalogger_PrintRow(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 6993 }
whismanoid 8:dffee7509bfb 6994 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6995 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 6996 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 6997 Datalogger_PrintRow(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 6998 }
whismanoid 8:dffee7509bfb 6999 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:cb44e2e9ec4c 7000
whismanoid 0:cb44e2e9ec4c 7001 } // this code repeats forever
whismanoid 0:cb44e2e9ec4c 7002 }
whismanoid 0:cb44e2e9ec4c 7003 //---------- CODE GENERATOR: end DataLogHelloCppCodeList