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 01:18:48 2021 -0700
Revision:
36:e7aac874b8be
Parent:
35:c9549b5c01de
Child:
37:3f369235e5bc
BOARD_SERIAL_NUMBER data unique to certain boards based on serial number

Who changed what in which revision?

UserRevisionLine numberNew contents of line
whismanoid 0:cb44e2e9ec4c 1 // /*******************************************************************************
whismanoid 28:a9a3a9db592b 2 // * Copyright (C) 2021 Maxim Integrated Products, Inc., All Rights Reserved.
whismanoid 0:cb44e2e9ec4c 3 // *
whismanoid 0:cb44e2e9ec4c 4 // * Permission is hereby granted, free of charge, to any person obtaining a
whismanoid 0:cb44e2e9ec4c 5 // * copy of this software and associated documentation files (the "Software"),
whismanoid 0:cb44e2e9ec4c 6 // * to deal in the Software without restriction, including without limitation
whismanoid 0:cb44e2e9ec4c 7 // * the rights to use, copy, modify, merge, publish, distribute, sublicense,
whismanoid 0:cb44e2e9ec4c 8 // * and/or sell copies of the Software, and to permit persons to whom the
whismanoid 0:cb44e2e9ec4c 9 // * Software is furnished to do so, subject to the following conditions:
whismanoid 0:cb44e2e9ec4c 10 // *
whismanoid 0:cb44e2e9ec4c 11 // * The above copyright notice and this permission notice shall be included
whismanoid 0:cb44e2e9ec4c 12 // * in all copies or substantial portions of the Software.
whismanoid 0:cb44e2e9ec4c 13 // *
whismanoid 0:cb44e2e9ec4c 14 // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
whismanoid 0:cb44e2e9ec4c 15 // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
whismanoid 0:cb44e2e9ec4c 16 // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
whismanoid 0:cb44e2e9ec4c 17 // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
whismanoid 0:cb44e2e9ec4c 18 // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
whismanoid 0:cb44e2e9ec4c 19 // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
whismanoid 0:cb44e2e9ec4c 20 // * OTHER DEALINGS IN THE SOFTWARE.
whismanoid 0:cb44e2e9ec4c 21 // *
whismanoid 0:cb44e2e9ec4c 22 // * Except as contained in this notice, the name of Maxim Integrated
whismanoid 0:cb44e2e9ec4c 23 // * Products, Inc. shall not be used except as stated in the Maxim Integrated
whismanoid 0:cb44e2e9ec4c 24 // * Products, Inc. Branding Policy.
whismanoid 0:cb44e2e9ec4c 25 // *
whismanoid 0:cb44e2e9ec4c 26 // * The mere transfer of this software does not imply any licenses
whismanoid 0:cb44e2e9ec4c 27 // * of trade secrets, proprietary technology, copyrights, patents,
whismanoid 0:cb44e2e9ec4c 28 // * trademarks, maskwork rights, or any other form of intellectual
whismanoid 0:cb44e2e9ec4c 29 // * property whatsoever. Maxim Integrated Products, Inc. retains all
whismanoid 0:cb44e2e9ec4c 30 // * ownership rights.
whismanoid 0:cb44e2e9ec4c 31 // *******************************************************************************
whismanoid 0:cb44e2e9ec4c 32 // */
whismanoid 0:cb44e2e9ec4c 33 // *******************************************************************************
whismanoid 0:cb44e2e9ec4c 34 // COM port settings are 9600 baud 8N1
whismanoid 0:cb44e2e9ec4c 35 // *******************************************************************************
whismanoid 19:5ff09c8e9daf 36 // Support custom target MAX40108DEMOP2U9 based on MAX32625PICO but MAX32625_NO_BOOT
whismanoid 19:5ff09c8e9daf 37 // file custom_targets.json:
whismanoid 19:5ff09c8e9daf 38 // {
whismanoid 19:5ff09c8e9daf 39 // "MAX40108DEMOP2U9": {
whismanoid 19:5ff09c8e9daf 40 // "inherits": ["MAX32625_BASE"],
whismanoid 19:5ff09c8e9daf 41 // "macros_remove": [],
whismanoid 19:5ff09c8e9daf 42 // "macros_add": ["MAX32625_NO_BOOT"]
whismanoid 19:5ff09c8e9daf 43 // }
whismanoid 19:5ff09c8e9daf 44 // }
whismanoid 19:5ff09c8e9daf 45 // files copied from mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\TARGET_MAX32625PICO
whismanoid 19:5ff09c8e9daf 46 // file TARGET_MAX40108DEMOP2U9\PeripheralNames.h -- copied from TARGET_MAX32625PICO
whismanoid 19:5ff09c8e9daf 47 // file TARGET_MAX40108DEMOP2U9\PinNames.h -- copied from TARGET_MAX32625PICO
whismanoid 19:5ff09c8e9daf 48 // files copied from mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\device\___\TARGET_MAX32625_NO_BOOT
whismanoid 19:5ff09c8e9daf 49 // file TARGET_MAX40108DEMOP2U9\device\TOOLCHAIN_ARM_STD\MAX32625.sct
whismanoid 19:5ff09c8e9daf 50 // file TARGET_MAX40108DEMOP2U9\device\TOOLCHAIN_GCC_ARM\max32625.ld
whismanoid 19:5ff09c8e9daf 51 // file TARGET_MAX40108DEMOP2U9\device\TOOLCHAIN_IAR\MAX32625.icf
whismanoid 19:5ff09c8e9daf 52 // file mbed_app.json:
whismanoid 19:5ff09c8e9daf 53 // {
whismanoid 19:5ff09c8e9daf 54 // "config": {
whismanoid 19:5ff09c8e9daf 55 // },
whismanoid 19:5ff09c8e9daf 56 // "macros": [
whismanoid 19:5ff09c8e9daf 57 // "MAX40108_DEMO=9"
whismanoid 19:5ff09c8e9daf 58 // ],
whismanoid 19:5ff09c8e9daf 59 // "target_overrides": {
whismanoid 19:5ff09c8e9daf 60 // }
whismanoid 19:5ff09c8e9daf 61 // }
whismanoid 19:5ff09c8e9daf 62 // *******************************************************************************
whismanoid 19:5ff09c8e9daf 63 // Validating project global defines from mbed_app.json "macros": []
whismanoid 19:5ff09c8e9daf 64 #ifndef MAX40108_DEMO
whismanoid 19:5ff09c8e9daf 65 #warning "MAX40108_DEMO not defined, missing mbed_app.json"
whismanoid 19:5ff09c8e9daf 66 #else // #ifndef MAX40108_DEMO
whismanoid 19:5ff09c8e9daf 67 #warning "Note: MAX40108_DEMO is defined, which is expected"
whismanoid 19:5ff09c8e9daf 68 #if (MAX40108_DEMO)==(9)
whismanoid 19:5ff09c8e9daf 69 #warning "Note: MAX40108_DEMO is defined with the expected value of 9"
whismanoid 19:5ff09c8e9daf 70 #elif (MAX40108_DEMO)==(5)
whismanoid 19:5ff09c8e9daf 71 #warning "Note: MAX40108_DEMO is defined with the wrong value 5"
whismanoid 19:5ff09c8e9daf 72 #else
whismanoid 19:5ff09c8e9daf 73 #warning "Note: MAX40108_DEMO is defined, but with an unsupported value"
whismanoid 19:5ff09c8e9daf 74 #endif
whismanoid 19:5ff09c8e9daf 75 #endif // #ifndef MAX40108_DEMO
whismanoid 19:5ff09c8e9daf 76 // *******************************************************************************
whismanoid 14:d4092094dbfe 77 #ifndef MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 78 // #define MAX40108_DEMO 5 for U5, or #define MAX40108_DEMO 9 for U9 in banner
whismanoid 17:9397ea3ea7e9 79 #define MAX40108_DEMO 9
whismanoid 15:37c83ec50ea0 80 #define HAS_DAPLINK_SERIAL 1
whismanoid 14:d4092094dbfe 81 #endif // MAX40108_DEMO
whismanoid 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 0:cb44e2e9ec4c 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 34:a1993a1ee904 2415 // Option to apply calibration to Arduino platform analog inputs
whismanoid 34:a1993a1ee904 2416 #ifndef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2417 #define HAS_Platform_AIN_Calibration 1
whismanoid 34:a1993a1ee904 2418 //~ #undef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2419 #endif
whismanoid 34:a1993a1ee904 2420 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2421 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 2422 // Calibration is between two points for each channel, defined by
whismanoid 34:a1993a1ee904 2423 // a normalized value between 0% and 100%, and the corresponding voltage.
whismanoid 34:a1993a1ee904 2424 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 2425 // calibration_05_normValue_0_1, calibration_05_V should be around 5% or 25%
whismanoid 34:a1993a1ee904 2426 double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2427 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2428 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2429 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2430 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 36:e7aac874b8be 2431 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2432 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2433 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2434 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2435 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2436 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2437 //
whismanoid 36:e7aac874b8be 2438 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2439 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 36:e7aac874b8be 2440 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2441 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2442 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2443 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2444 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2445 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2446 //
whismanoid 36:e7aac874b8be 2447 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2448 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 36:e7aac874b8be 2449 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2450 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2451 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2452 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2453 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2454 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2455 //
whismanoid 36:e7aac874b8be 2456 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2457 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 36:e7aac874b8be 2458 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2459 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2460 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2461 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2462 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2463 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2464 //
whismanoid 36:e7aac874b8be 2465 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2466 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 36:e7aac874b8be 2467 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2468 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2469 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2470 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2471 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2472 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2473 //
whismanoid 36:e7aac874b8be 2474 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2475 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 36:e7aac874b8be 2476 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2477 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2478 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2479 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2480 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2481 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2482 //
whismanoid 36:e7aac874b8be 2483 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2484 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 36:e7aac874b8be 2485 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2486 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2487 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2488 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2489 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2490 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2491 //
whismanoid 36:e7aac874b8be 2492 # else
whismanoid 36:e7aac874b8be 2493 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2494 # endif
whismanoid 36:e7aac874b8be 2495 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2496 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2497 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2498 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2499 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2500 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2501 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2502 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2503 //
whismanoid 36:e7aac874b8be 2504 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2505 };
whismanoid 34:a1993a1ee904 2506 double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2507 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2508 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2509 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2510 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 36:e7aac874b8be 2511 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2512 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2513 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2514 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2515 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2516 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2517 //
whismanoid 36:e7aac874b8be 2518 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2519 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 36:e7aac874b8be 2520 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2521 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2522 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2523 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2524 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2525 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2526 //
whismanoid 36:e7aac874b8be 2527 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2528 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 36:e7aac874b8be 2529 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2530 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2531 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2532 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2533 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2534 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2535 //
whismanoid 36:e7aac874b8be 2536 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2537 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 36:e7aac874b8be 2538 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2539 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2540 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2541 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2542 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2543 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2544 //
whismanoid 36:e7aac874b8be 2545 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2546 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 36:e7aac874b8be 2547 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2548 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2549 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2550 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2551 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2552 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2553 //
whismanoid 36:e7aac874b8be 2554 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2555 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 36:e7aac874b8be 2556 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2557 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2558 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2559 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2560 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2561 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2562 //
whismanoid 36:e7aac874b8be 2563 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2564 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 36:e7aac874b8be 2565 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2566 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2567 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2568 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2569 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2570 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2571 //
whismanoid 36:e7aac874b8be 2572 # else
whismanoid 36:e7aac874b8be 2573 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2574 # endif
whismanoid 36:e7aac874b8be 2575 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2576 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2577 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2578 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2579 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2580 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2581 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2582 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2583 //
whismanoid 36:e7aac874b8be 2584 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2585 };
whismanoid 34:a1993a1ee904 2586 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 2587 // calibration_95_normValue_0_1, calibration_95_V should be around 95% or 75%
whismanoid 34:a1993a1ee904 2588 double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2589 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2590 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2591 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2592 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 36:e7aac874b8be 2593 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2594 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2595 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2596 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2597 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2598 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2599 //
whismanoid 36:e7aac874b8be 2600 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2601 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 36:e7aac874b8be 2602 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2603 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2604 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2605 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2606 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2607 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2608 //
whismanoid 36:e7aac874b8be 2609 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2610 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 36:e7aac874b8be 2611 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2612 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2613 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2614 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2615 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2616 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2617 //
whismanoid 36:e7aac874b8be 2618 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2619 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 36:e7aac874b8be 2620 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2621 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2622 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2623 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2624 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2625 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2626 //
whismanoid 36:e7aac874b8be 2627 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2628 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 36:e7aac874b8be 2629 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2630 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2631 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2632 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2633 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2634 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2635 //
whismanoid 36:e7aac874b8be 2636 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2637 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 36:e7aac874b8be 2638 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2639 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2640 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2641 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2642 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2643 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2644 //
whismanoid 36:e7aac874b8be 2645 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2646 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 36:e7aac874b8be 2647 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2648 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2649 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2650 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2651 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2652 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2653 //
whismanoid 36:e7aac874b8be 2654 # else
whismanoid 36:e7aac874b8be 2655 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2656 # endif
whismanoid 36:e7aac874b8be 2657 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2658 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2659 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2660 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2661 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2662 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2663 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2664 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2665 //
whismanoid 36:e7aac874b8be 2666 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2667 };
whismanoid 34:a1993a1ee904 2668 double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2669 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2670 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2671 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2672 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 36:e7aac874b8be 2673 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2674 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2675 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2676 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2677 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2678 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2679 //
whismanoid 36:e7aac874b8be 2680 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2681 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 36:e7aac874b8be 2682 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2683 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2684 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2685 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2686 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2687 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2688 //
whismanoid 36:e7aac874b8be 2689 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2690 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 36:e7aac874b8be 2691 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2692 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2693 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2694 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2695 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2696 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2697 //
whismanoid 36:e7aac874b8be 2698 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2699 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 36:e7aac874b8be 2700 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2701 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2702 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2703 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2704 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2705 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2706 //
whismanoid 36:e7aac874b8be 2707 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2708 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 36:e7aac874b8be 2709 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2710 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2711 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2712 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2713 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2714 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2715 //
whismanoid 36:e7aac874b8be 2716 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2717 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 36:e7aac874b8be 2718 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2719 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2720 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2721 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2722 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2723 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2724 //
whismanoid 36:e7aac874b8be 2725 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2726 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 36:e7aac874b8be 2727 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2728 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2729 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2730 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2731 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2732 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2733 //
whismanoid 36:e7aac874b8be 2734 # else
whismanoid 36:e7aac874b8be 2735 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2736 # endif
whismanoid 36:e7aac874b8be 2737 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2738 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2739 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2740 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2741 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2742 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2743 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2744 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2745 //
whismanoid 36:e7aac874b8be 2746 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2747 };
whismanoid 34:a1993a1ee904 2748 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2749 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2750 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1)
whismanoid 34:a1993a1ee904 2751 {
whismanoid 34:a1993a1ee904 2752 // TODO: return corrected normValue_0_1 using two-point linear calibration
whismanoid 34:a1993a1ee904 2753 // point 1: calibration_05_normValue_0_1[ch], calibration_05_V[ch]
whismanoid 34:a1993a1ee904 2754 // point 2: calibration_95_normValue_0_1[ch], calibration_95_V[ch]
whismanoid 34:a1993a1ee904 2755 // validate that there is enough span to get sensible results
whismanoid 34:a1993a1ee904 2756 //
whismanoid 34:a1993a1ee904 2757 int ch = channel_0_5;
whismanoid 34:a1993a1ee904 2758 // 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 2759 // ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 2760 // ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 2761 // ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 2762 // ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 2763 // );
whismanoid 34:a1993a1ee904 2764 // cmdLine.serial().printf("\r\n adc_full_scale_voltage[%d] = %1.6fV",
whismanoid 34:a1993a1ee904 2765 // ch,
whismanoid 34:a1993a1ee904 2766 // adc_full_scale_voltage[ch]
whismanoid 34:a1993a1ee904 2767 // );
whismanoid 34:a1993a1ee904 2768 // raw normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 2769 double raw_05_normValue = calibration_05_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 2770 double raw_95_normValue = calibration_95_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 2771 // calibrated normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 2772 // divide V/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 2773 double cal_05_normValue = calibration_05_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 2774 double cal_95_normValue = calibration_95_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 2775 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_05_normValue = %1.6f",
whismanoid 34:a1993a1ee904 2776 // ch,
whismanoid 34:a1993a1ee904 2777 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2778 // cal_05_normValue
whismanoid 34:a1993a1ee904 2779 // );
whismanoid 34:a1993a1ee904 2780 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_95_normValue = %1.6f",
whismanoid 34:a1993a1ee904 2781 // ch,
whismanoid 34:a1993a1ee904 2782 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2783 // cal_95_normValue
whismanoid 34:a1993a1ee904 2784 // );
whismanoid 34:a1993a1ee904 2785 //
whismanoid 34:a1993a1ee904 2786 double span_raw = raw_95_normValue - raw_05_normValue;
whismanoid 34:a1993a1ee904 2787 double span_cal = cal_95_normValue - cal_05_normValue;
whismanoid 34:a1993a1ee904 2788 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_raw = %1.6f",
whismanoid 34:a1993a1ee904 2789 // ch,
whismanoid 34:a1993a1ee904 2790 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2791 // span_raw
whismanoid 34:a1993a1ee904 2792 // );
whismanoid 34:a1993a1ee904 2793 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_cal = %1.6f",
whismanoid 34:a1993a1ee904 2794 // ch,
whismanoid 34:a1993a1ee904 2795 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2796 // span_cal
whismanoid 34:a1993a1ee904 2797 // );
whismanoid 34:a1993a1ee904 2798 // if calibration is not valid, return unmodified normValue_0_1 and print a warning
whismanoid 34:a1993a1ee904 2799 if (span_raw < 0.001) {
whismanoid 34:a1993a1ee904 2800 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_raw = %1.6f",
whismanoid 34:a1993a1ee904 2801 ch,
whismanoid 34:a1993a1ee904 2802 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2803 span_raw
whismanoid 34:a1993a1ee904 2804 );
whismanoid 34:a1993a1ee904 2805 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 2806 }
whismanoid 34:a1993a1ee904 2807 if (span_cal < 0.001) {
whismanoid 34:a1993a1ee904 2808 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_cal = %1.6f",
whismanoid 34:a1993a1ee904 2809 ch,
whismanoid 34:a1993a1ee904 2810 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2811 span_cal
whismanoid 34:a1993a1ee904 2812 );
whismanoid 34:a1993a1ee904 2813 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 2814 }
whismanoid 34:a1993a1ee904 2815 double slope_correction = span_cal / span_raw;
whismanoid 34:a1993a1ee904 2816 double corrected_normValue_0_1 = cal_05_normValue + ((raw_normValue_0_1 - raw_05_normValue) * slope_correction);
whismanoid 34:a1993a1ee904 2817 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) slope_correction = %1.6f",
whismanoid 34:a1993a1ee904 2818 // ch,
whismanoid 34:a1993a1ee904 2819 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2820 // slope_correction
whismanoid 34:a1993a1ee904 2821 // );
whismanoid 34:a1993a1ee904 2822 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) corrected_normValue_0_1 = %1.6f\r\n",
whismanoid 34:a1993a1ee904 2823 // ch,
whismanoid 34:a1993a1ee904 2824 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2825 // corrected_normValue_0_1
whismanoid 34:a1993a1ee904 2826 // );
whismanoid 34:a1993a1ee904 2827 return corrected_normValue_0_1;
whismanoid 34:a1993a1ee904 2828 }
whismanoid 34:a1993a1ee904 2829 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2830 // Option to customize channel names in datalog header line
whismanoid 13:184a08909405 2831 #ifndef HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 2832 #define HAS_Platform_AIN_customChannelHeader 1
whismanoid 13:184a08909405 2833 #endif
whismanoid 13:184a08909405 2834 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2835 const char* const Platform_AIN_customChannelHeader_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 2836 "=AIN4", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 2837 "=AIN5", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 2838 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 2839 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 2840 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 2841 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 2842 };
whismanoid 13:184a08909405 2843 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 1:747f1602abfc 2844 //--------------------------------------------------
whismanoid 1:747f1602abfc 2845 // Option to log platform analog inputs as raw LSB code
whismanoid 1:747f1602abfc 2846 #ifndef LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 2847 #define LOG_PLATFORM_ANALOG_IN_LSB 0
whismanoid 1:747f1602abfc 2848 #endif
whismanoid 1:747f1602abfc 2849 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 2850 int Platform_LSB[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 2851 #endif
whismanoid 1:747f1602abfc 2852
whismanoid 1:747f1602abfc 2853 //--------------------------------------------------
whismanoid 1:747f1602abfc 2854 // Option to use platform analog inputs as Voltage
whismanoid 1:747f1602abfc 2855 #ifndef LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 2856 #define LOG_PLATFORM_ANALOG_IN_VOLTS 1
whismanoid 1:747f1602abfc 2857 #endif
whismanoid 1:747f1602abfc 2858 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 2859 double Platform_Voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 2860 #endif
whismanoid 3:9055e17e181a 2861 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 0:cb44e2e9ec4c 2862
whismanoid 10:04022a61b527 2863 //--------------------------------------------------
whismanoid 10:04022a61b527 2864 // Option to use Command forwarding to Auxiliary serial port
whismanoid 10:04022a61b527 2865 // Command forwarding to Auxiliary serial port TX/RX
whismanoid 10:04022a61b527 2866 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial
whismanoid 10:04022a61b527 2867 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial
whismanoid 10:04022a61b527 2868 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 2869 #ifndef USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2870 #define USE_AUX_SERIAL_CMD_FORWARDING 1
whismanoid 10:04022a61b527 2871 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2872 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2873 // Command forwarding to Auxiliary serial port TX/RX #257 -- global parameters
whismanoid 10:04022a61b527 2874 const size_t RX_STRING_BUF_SIZE = 1000;
whismanoid 10:04022a61b527 2875 int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 2876 // transmit command string by AUX TX
whismanoid 10:04022a61b527 2877 #if 0
whismanoid 10:04022a61b527 2878 int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 2879 int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 2880 int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 2881 #endif
whismanoid 10:04022a61b527 2882 // capture received string from AUX RX
whismanoid 10:04022a61b527 2883 Timer g_auxSerialCom_Timer;
whismanoid 10:04022a61b527 2884 int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 2885 int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 2886 int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 2887 int g_auxSerialCom_rx_idle_ms = 500; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 2888 int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 2889 const int aux_serial_cmd_forwarding_rx_eot_not_used = 'x';
whismanoid 10:04022a61b527 2890 int g_auxSerialCom_rx_eot = aux_serial_cmd_forwarding_rx_eot_not_used; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 2891 //~ int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text string?
whismanoid 10:04022a61b527 2892 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2893 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2894 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257
whismanoid 10:04022a61b527 2895 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 2896 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2897 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2898 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2899 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 2900 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2901 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 2902 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2903 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2904 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2905 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2906 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2907 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 2908 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2909 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2910
whismanoid 8:dffee7509bfb 2911 // CODE GENERATOR: example code for ADC: serial port declaration
whismanoid 8:dffee7509bfb 2912 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2913 // Declare the Serial driver
whismanoid 8:dffee7509bfb 2914 // default baud rate settings are 9600 8N1
whismanoid 8:dffee7509bfb 2915 // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
whismanoid 8:dffee7509bfb 2916 // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
whismanoid 8:dffee7509bfb 2917 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2918 #if defined(TARGET_MAX32630)
whismanoid 8:dffee7509bfb 2919 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 2920 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2921 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2922 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 2923 //
whismanoid 8:dffee7509bfb 2924 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2925 Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2926 //Serial J3AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 2927 //Serial BTAUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 2928 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 2929 //
whismanoid 8:dffee7509bfb 2930 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2931 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2932 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2933 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2934 //
whismanoid 8:dffee7509bfb 2935 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2936 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2937 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2938 USBSerial serial;
whismanoid 8:dffee7509bfb 2939 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2940 #elif defined(TARGET_MAX32625MBED)
whismanoid 8:dffee7509bfb 2941 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625MBED: P0_1,P0_0 (Arduino D1,D0)
whismanoid 8:dffee7509bfb 2942 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2943 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625MBED: P3_1,P3_0 (J15-LEDgreen,LEDred)
whismanoid 8:dffee7509bfb 2944 //
whismanoid 8:dffee7509bfb 2945 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2946 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2947 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2948 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2949 //
whismanoid 8:dffee7509bfb 2950 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2951 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2952 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2953 USBSerial serial;
whismanoid 8:dffee7509bfb 2954 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 2955 #elif defined(TARGET_MAX32625PICO)
whismanoid 8:dffee7509bfb 2956 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 2957 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625PICO: P2_1,P2_0 (underside?)
whismanoid 8:dffee7509bfb 2958 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2959 //
whismanoid 8:dffee7509bfb 2960 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2961 Serial AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 2962 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 2963 //
whismanoid 8:dffee7509bfb 2964 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2965 Serial DAPLINKserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2966 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2967 //
whismanoid 8:dffee7509bfb 2968 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2969 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2970 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2971 USBSerial serial;
whismanoid 22:d6dc8a85f435 2972 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 2973 #elif defined(TARGET_MAX40108DEMOP2U9)
whismanoid 22:d6dc8a85f435 2974 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 2975 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK)
whismanoid 22:d6dc8a85f435 2976 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 2977 //
whismanoid 22:d6dc8a85f435 2978 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial is used as main serial port in MAX40108 Demo board
whismanoid 22:d6dc8a85f435 2979 Serial serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 2980 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 2981 //
whismanoid 22:d6dc8a85f435 2982 // Hardware serial port over DAPLink
whismanoid 22:d6dc8a85f435 2983 // connection to external MAX32625PICO(DAPLINK) needed TX/RX swap in firmware.
whismanoid 22:d6dc8a85f435 2984 // MAX32625PICO(DAPLINK) drives DAPLINK.8, listens on DAPLINK.6.
whismanoid 22:d6dc8a85f435 2985 // See AN6350 MAX32625 Users Guide 7.5.2.3.1 TX and RX Pin Mapping for UART 1 -- Mapping Option B
whismanoid 22:d6dc8a85f435 2986 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 22:d6dc8a85f435 2987 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 22:d6dc8a85f435 2988 #define HAS_DAPLINK_SERIAL 1
whismanoid 22:d6dc8a85f435 2989 //
whismanoid 22:d6dc8a85f435 2990 // Serial AUXserial(UART1_TX,UART1_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 2991 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 2992 //
whismanoid 22:d6dc8a85f435 2993 // Virtual serial port over USB
whismanoid 22:d6dc8a85f435 2994 // #include "USBSerial.h"
whismanoid 22:d6dc8a85f435 2995 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 22:d6dc8a85f435 2996 //USBSerial serial;
whismanoid 8:dffee7509bfb 2997 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2998 #elif defined(TARGET_MAX32620FTHR)
whismanoid 8:dffee7509bfb 2999 #warning "TARGET_MAX32620FTHR not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3000 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3001 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32620FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3002 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3003 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3004 //
whismanoid 8:dffee7509bfb 3005 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3006 Serial serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3007 //Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3008 Serial AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3009 //Serial PMOD0AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3010 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3011 //
whismanoid 8:dffee7509bfb 3012 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3013 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3014 Serial DAPLINKserial(USBTX, USBRX); // tx,rx MAX32620FTHR: P2_1,P2_0
whismanoid 8:dffee7509bfb 3015 //Serial DAPLINKserial(STDIO_UART_TX, STDIO_UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3016 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3017 //
whismanoid 8:dffee7509bfb 3018 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3019 // #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3020 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3021 //USBSerial serial; // MAX32620FTHR: USBSerial crash??
whismanoid 8:dffee7509bfb 3022 #warning "TARGET_MAX32620FTHR not previously tested; USBSerial crash?"
whismanoid 8:dffee7509bfb 3023 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3024 #elif defined(TARGET_MAX32600)
whismanoid 8:dffee7509bfb 3025 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3026 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART2 MAX32625MBED: P1_3,P1_2 (Arduino D3,D2)
whismanoid 8:dffee7509bfb 3027 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART1 MAX32625MBED: P7_3,P7_2 ( ?? )
whismanoid 8:dffee7509bfb 3028 //
whismanoid 8:dffee7509bfb 3029 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3030 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3031 Serial DAPLINKserial(P1_1,P1_0); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3032 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3033 //
whismanoid 8:dffee7509bfb 3034 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3035 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3036 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3037 USBSerial serial;
whismanoid 8:dffee7509bfb 3038 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3039 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 8:dffee7509bfb 3040 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3041 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3042 #else
whismanoid 8:dffee7509bfb 3043 #if defined(SERIAL_TX)
whismanoid 8:dffee7509bfb 3044 #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..."
whismanoid 8:dffee7509bfb 3045 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3046 #elif defined(USBTX)
whismanoid 8:dffee7509bfb 3047 #warning "target not previously tested; guess serial pins are USBTX, USBRX..."
whismanoid 8:dffee7509bfb 3048 Serial serial(USBTX, USBRX); // tx, rx
whismanoid 8:dffee7509bfb 3049 #elif defined(UART_TX)
whismanoid 8:dffee7509bfb 3050 #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..."
whismanoid 8:dffee7509bfb 3051 Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3052 #else
whismanoid 8:dffee7509bfb 3053 #warning "target not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3054 #endif
whismanoid 8:dffee7509bfb 3055 #endif
whismanoid 8:dffee7509bfb 3056 //
whismanoid 8:dffee7509bfb 3057 #include "CmdLine.h"
whismanoid 8:dffee7509bfb 3058
whismanoid 8:dffee7509bfb 3059 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3060 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3061 CmdLine cmdLine_AUXserial(AUXserial, "AUXserial");
whismanoid 10:04022a61b527 3062 uint8_t Datalogger_enable_AUXserial = {
whismanoid 10:04022a61b527 3063 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3064 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 3065 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 3066 false
whismanoid 10:04022a61b527 3067 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3068 true
whismanoid 10:04022a61b527 3069 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3070 };
whismanoid 8:dffee7509bfb 3071 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3072 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3073 CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK");
whismanoid 8:dffee7509bfb 3074 uint8_t Datalogger_enable_DAPLINKserial = true;
whismanoid 8:dffee7509bfb 3075 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3076 CmdLine cmdLine(serial, "serial");
whismanoid 8:dffee7509bfb 3077 uint8_t Datalogger_enable_serial = true;
whismanoid 8:dffee7509bfb 3078 // CODE GENERATOR: example code for ADC: serial port declaration (end)
whismanoid 8:dffee7509bfb 3079
whismanoid 21:ac062a97a71d 3080
whismanoid 21:ac062a97a71d 3081 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3082 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 3083 #ifndef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3084 #define USE_DATALOGGER_CommandTable 1
whismanoid 23:c6c652bef4b9 3085 //~ #undef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3086 #endif
whismanoid 23:c6c652bef4b9 3087 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3088 const int COMMAND_TABLE_ROW_MAX = 10;
whismanoid 23:c6c652bef4b9 3089 const int COMMAND_TABLE_COL_MAX = 40;
whismanoid 23:c6c652bef4b9 3090 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3091 //
whismanoid 23:c6c652bef4b9 3092 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3093 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3094 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3095 char onButton1_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button1 event";
whismanoid 23:c6c652bef4b9 3096 char onButton1_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 23:c6c652bef4b9 3097 char onButton1_command_table_02[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 23:c6c652bef4b9 3098 char onButton1_command_table_03[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 23:c6c652bef4b9 3099 char onButton1_command_table_04[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 23:c6c652bef4b9 3100 char onButton1_command_table_05[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 23:c6c652bef4b9 3101 char onButton1_command_table_06[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 23:c6c652bef4b9 3102 char onButton1_command_table_07[COMMAND_TABLE_COL_MAX] = "LR";
whismanoid 23:c6c652bef4b9 3103 char onButton1_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3104 char onButton1_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3105 static char* onButton1_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3106 onButton1_command_table_00,
whismanoid 23:c6c652bef4b9 3107 onButton1_command_table_01,
whismanoid 23:c6c652bef4b9 3108 onButton1_command_table_02,
whismanoid 23:c6c652bef4b9 3109 onButton1_command_table_03,
whismanoid 23:c6c652bef4b9 3110 onButton1_command_table_04,
whismanoid 23:c6c652bef4b9 3111 onButton1_command_table_05,
whismanoid 23:c6c652bef4b9 3112 onButton1_command_table_06,
whismanoid 23:c6c652bef4b9 3113 onButton1_command_table_07,
whismanoid 23:c6c652bef4b9 3114 onButton1_command_table_08,
whismanoid 23:c6c652bef4b9 3115 onButton1_command_table_09,
whismanoid 23:c6c652bef4b9 3116 };
whismanoid 23:c6c652bef4b9 3117 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3118 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3119 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3120 char onButton2_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button2 event";
whismanoid 23:c6c652bef4b9 3121 char onButton2_command_table_01[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 23:c6c652bef4b9 3122 char onButton2_command_table_02[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 23:c6c652bef4b9 3123 char onButton2_command_table_03[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 23:c6c652bef4b9 3124 char onButton2_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3125 char onButton2_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3126 char onButton2_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3127 char onButton2_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3128 char onButton2_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3129 char onButton2_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3130 static char* onButton2_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3131 onButton2_command_table_00,
whismanoid 23:c6c652bef4b9 3132 onButton2_command_table_01,
whismanoid 23:c6c652bef4b9 3133 onButton2_command_table_02,
whismanoid 23:c6c652bef4b9 3134 onButton2_command_table_03,
whismanoid 23:c6c652bef4b9 3135 onButton2_command_table_04,
whismanoid 23:c6c652bef4b9 3136 onButton2_command_table_05,
whismanoid 23:c6c652bef4b9 3137 onButton2_command_table_06,
whismanoid 23:c6c652bef4b9 3138 onButton2_command_table_07,
whismanoid 23:c6c652bef4b9 3139 onButton2_command_table_08,
whismanoid 23:c6c652bef4b9 3140 onButton2_command_table_09,
whismanoid 23:c6c652bef4b9 3141 };
whismanoid 23:c6c652bef4b9 3142 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3143 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3144 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3145 char onButton3_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button3 event";
whismanoid 24:032f3683cb2a 3146 char onButton3_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 24:032f3683cb2a 3147 char onButton3_command_table_02[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 24:032f3683cb2a 3148 char onButton3_command_table_03[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 24:032f3683cb2a 3149 char onButton3_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3150 char onButton3_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3151 char onButton3_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3152 char onButton3_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3153 char onButton3_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3154 char onButton3_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3155 static char* onButton3_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 24:032f3683cb2a 3156 onButton3_command_table_00,
whismanoid 24:032f3683cb2a 3157 onButton3_command_table_01,
whismanoid 24:032f3683cb2a 3158 onButton3_command_table_02,
whismanoid 24:032f3683cb2a 3159 onButton3_command_table_03,
whismanoid 24:032f3683cb2a 3160 onButton3_command_table_04,
whismanoid 24:032f3683cb2a 3161 onButton3_command_table_05,
whismanoid 24:032f3683cb2a 3162 onButton3_command_table_06,
whismanoid 24:032f3683cb2a 3163 onButton3_command_table_07,
whismanoid 24:032f3683cb2a 3164 onButton3_command_table_08,
whismanoid 24:032f3683cb2a 3165 onButton3_command_table_09,
whismanoid 24:032f3683cb2a 3166 };
whismanoid 24:032f3683cb2a 3167 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3168 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3169 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3170 char onButton4_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button4 event";
whismanoid 30:07197a430869 3171 char onButton4_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE>0.7:active";
whismanoid 29:6a9edb6e973b 3172 char onButton4_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3173 char onButton4_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3174 char onButton4_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3175 char onButton4_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3176 char onButton4_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3177 char onButton4_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3178 char onButton4_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3179 char onButton4_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3180 static char* onButton4_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3181 onButton4_command_table_00,
whismanoid 29:6a9edb6e973b 3182 onButton4_command_table_01,
whismanoid 29:6a9edb6e973b 3183 onButton4_command_table_02,
whismanoid 29:6a9edb6e973b 3184 onButton4_command_table_03,
whismanoid 29:6a9edb6e973b 3185 onButton4_command_table_04,
whismanoid 29:6a9edb6e973b 3186 onButton4_command_table_05,
whismanoid 29:6a9edb6e973b 3187 onButton4_command_table_06,
whismanoid 29:6a9edb6e973b 3188 onButton4_command_table_07,
whismanoid 29:6a9edb6e973b 3189 onButton4_command_table_08,
whismanoid 29:6a9edb6e973b 3190 onButton4_command_table_09,
whismanoid 29:6a9edb6e973b 3191 };
whismanoid 29:6a9edb6e973b 3192 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3193 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3194 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3195 char onButton5_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button5 event";
whismanoid 30:07197a430869 3196 char onButton5_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE<0.6:sleep";
whismanoid 29:6a9edb6e973b 3197 char onButton5_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3198 char onButton5_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3199 char onButton5_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3200 char onButton5_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3201 char onButton5_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3202 char onButton5_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3203 char onButton5_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3204 char onButton5_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3205 static char* onButton5_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3206 onButton5_command_table_00,
whismanoid 29:6a9edb6e973b 3207 onButton5_command_table_01,
whismanoid 29:6a9edb6e973b 3208 onButton5_command_table_02,
whismanoid 29:6a9edb6e973b 3209 onButton5_command_table_03,
whismanoid 29:6a9edb6e973b 3210 onButton5_command_table_04,
whismanoid 29:6a9edb6e973b 3211 onButton5_command_table_05,
whismanoid 29:6a9edb6e973b 3212 onButton5_command_table_06,
whismanoid 29:6a9edb6e973b 3213 onButton5_command_table_07,
whismanoid 29:6a9edb6e973b 3214 onButton5_command_table_08,
whismanoid 29:6a9edb6e973b 3215 onButton5_command_table_09,
whismanoid 29:6a9edb6e973b 3216 };
whismanoid 29:6a9edb6e973b 3217 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3218 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3219 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3220 char onButton6_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button6 event";
whismanoid 29:6a9edb6e973b 3221 char onButton6_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3222 char onButton6_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3223 char onButton6_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3224 char onButton6_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3225 char onButton6_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3226 char onButton6_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3227 char onButton6_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3228 char onButton6_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3229 char onButton6_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3230 static char* onButton6_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3231 onButton6_command_table_00,
whismanoid 29:6a9edb6e973b 3232 onButton6_command_table_01,
whismanoid 29:6a9edb6e973b 3233 onButton6_command_table_02,
whismanoid 29:6a9edb6e973b 3234 onButton6_command_table_03,
whismanoid 29:6a9edb6e973b 3235 onButton6_command_table_04,
whismanoid 29:6a9edb6e973b 3236 onButton6_command_table_05,
whismanoid 29:6a9edb6e973b 3237 onButton6_command_table_06,
whismanoid 29:6a9edb6e973b 3238 onButton6_command_table_07,
whismanoid 29:6a9edb6e973b 3239 onButton6_command_table_08,
whismanoid 29:6a9edb6e973b 3240 onButton6_command_table_09,
whismanoid 29:6a9edb6e973b 3241 };
whismanoid 29:6a9edb6e973b 3242 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3243 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3244 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3245 char onButton7_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button7 event";
whismanoid 29:6a9edb6e973b 3246 char onButton7_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3247 char onButton7_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3248 char onButton7_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3249 char onButton7_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3250 char onButton7_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3251 char onButton7_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3252 char onButton7_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3253 char onButton7_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3254 char onButton7_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3255 static char* onButton7_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3256 onButton7_command_table_00,
whismanoid 29:6a9edb6e973b 3257 onButton7_command_table_01,
whismanoid 29:6a9edb6e973b 3258 onButton7_command_table_02,
whismanoid 29:6a9edb6e973b 3259 onButton7_command_table_03,
whismanoid 29:6a9edb6e973b 3260 onButton7_command_table_04,
whismanoid 29:6a9edb6e973b 3261 onButton7_command_table_05,
whismanoid 29:6a9edb6e973b 3262 onButton7_command_table_06,
whismanoid 29:6a9edb6e973b 3263 onButton7_command_table_07,
whismanoid 29:6a9edb6e973b 3264 onButton7_command_table_08,
whismanoid 29:6a9edb6e973b 3265 onButton7_command_table_09,
whismanoid 29:6a9edb6e973b 3266 };
whismanoid 29:6a9edb6e973b 3267 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3268 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3269 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3270 char onButton8_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button8 event";
whismanoid 29:6a9edb6e973b 3271 char onButton8_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3272 char onButton8_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3273 char onButton8_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3274 char onButton8_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3275 char onButton8_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3276 char onButton8_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3277 char onButton8_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3278 char onButton8_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3279 char onButton8_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3280 static char* onButton8_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3281 onButton8_command_table_00,
whismanoid 29:6a9edb6e973b 3282 onButton8_command_table_01,
whismanoid 29:6a9edb6e973b 3283 onButton8_command_table_02,
whismanoid 29:6a9edb6e973b 3284 onButton8_command_table_03,
whismanoid 29:6a9edb6e973b 3285 onButton8_command_table_04,
whismanoid 29:6a9edb6e973b 3286 onButton8_command_table_05,
whismanoid 29:6a9edb6e973b 3287 onButton8_command_table_06,
whismanoid 29:6a9edb6e973b 3288 onButton8_command_table_07,
whismanoid 29:6a9edb6e973b 3289 onButton8_command_table_08,
whismanoid 29:6a9edb6e973b 3290 onButton8_command_table_09,
whismanoid 29:6a9edb6e973b 3291 };
whismanoid 29:6a9edb6e973b 3292 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3293 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3294 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3295 char onButton9_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button9 event";
whismanoid 29:6a9edb6e973b 3296 char onButton9_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3297 char onButton9_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3298 char onButton9_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3299 char onButton9_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3300 char onButton9_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3301 char onButton9_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3302 char onButton9_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3303 char onButton9_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3304 char onButton9_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3305 static char* onButton9_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3306 onButton9_command_table_00,
whismanoid 29:6a9edb6e973b 3307 onButton9_command_table_01,
whismanoid 29:6a9edb6e973b 3308 onButton9_command_table_02,
whismanoid 29:6a9edb6e973b 3309 onButton9_command_table_03,
whismanoid 29:6a9edb6e973b 3310 onButton9_command_table_04,
whismanoid 29:6a9edb6e973b 3311 onButton9_command_table_05,
whismanoid 29:6a9edb6e973b 3312 onButton9_command_table_06,
whismanoid 29:6a9edb6e973b 3313 onButton9_command_table_07,
whismanoid 29:6a9edb6e973b 3314 onButton9_command_table_08,
whismanoid 29:6a9edb6e973b 3315 onButton9_command_table_09,
whismanoid 29:6a9edb6e973b 3316 };
whismanoid 29:6a9edb6e973b 3317 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3318 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3319 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3320 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 3321 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3322 bool g_Run_command_table_running = false;
whismanoid 23:c6c652bef4b9 3323 void Run_command_table(char* command_table[])
whismanoid 23:c6c652bef4b9 3324 {
whismanoid 23:c6c652bef4b9 3325 // command_table: perform list of commands
whismanoid 31:47eee7e0cc2d 3326 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3327 if (g_Run_command_table_running) {
whismanoid 31:47eee7e0cc2d 3328 // TODO: button event chaining is not supported at this time
whismanoid 31:47eee7e0cc2d 3329 } // if (g_Run_command_table_running)
whismanoid 31:47eee7e0cc2d 3330 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3331 g_Run_command_table_running = true;
whismanoid 23:c6c652bef4b9 3332 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 3333 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 3334 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 23:c6c652bef4b9 3335 cmdLine.clear();
whismanoid 31:47eee7e0cc2d 3336 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3337 //~ char* strIndex = command_table[lineIndex];
whismanoid 23:c6c652bef4b9 3338 for (char* strIndex = command_table[lineIndex]; *strIndex != '\0'; strIndex++)
whismanoid 23:c6c652bef4b9 3339 {
whismanoid 23:c6c652bef4b9 3340 cmdLine.append(*strIndex);
whismanoid 23:c6c652bef4b9 3341 }
whismanoid 23:c6c652bef4b9 3342 cmdLine.append('\r'); // append \r invokes onEOLcommandParser to handle command
whismanoid 23:c6c652bef4b9 3343 }
whismanoid 31:47eee7e0cc2d 3344 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3345 g_Run_command_table_running = false;
whismanoid 31:47eee7e0cc2d 3346 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3347 }
whismanoid 23:c6c652bef4b9 3348 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3349 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3350 // When user presses button BUTTON1, perform actions
whismanoid 21:ac062a97a71d 3351 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3352 void onButton1FallingEdge(void)
whismanoid 21:ac062a97a71d 3353 {
whismanoid 21:ac062a97a71d 3354 //~ void SelfTest(CmdLine & cmdLine);
whismanoid 21:ac062a97a71d 3355 //~ SelfTest(cmdLine_serial);
whismanoid 22:d6dc8a85f435 3356 //
whismanoid 23:c6c652bef4b9 3357 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3358 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3359 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3360 Run_command_table(onButton1_command_table);
whismanoid 23:c6c652bef4b9 3361 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3362 }
whismanoid 21:ac062a97a71d 3363 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3364
whismanoid 21:ac062a97a71d 3365 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3366 // When user presses button BUTTON2, perform actions
whismanoid 21:ac062a97a71d 3367 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3368 void onButton2FallingEdge(void)
whismanoid 21:ac062a97a71d 3369 {
whismanoid 21:ac062a97a71d 3370 // TBD demo configuration
whismanoid 21:ac062a97a71d 3371 // TODO diagnostic LED
whismanoid 21:ac062a97a71d 3372 // led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 22:d6dc8a85f435 3373 //
whismanoid 23:c6c652bef4b9 3374 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3375 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3376 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3377 Run_command_table(onButton2_command_table);
whismanoid 23:c6c652bef4b9 3378 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3379 }
whismanoid 21:ac062a97a71d 3380 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3381
whismanoid 24:032f3683cb2a 3382 //--------------------------------------------------
whismanoid 29:6a9edb6e973b 3383 // When user presses button BUTTON3, perform actions
whismanoid 24:032f3683cb2a 3384 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3385 void onButton3FallingEdge(void)
whismanoid 24:032f3683cb2a 3386 {
whismanoid 24:032f3683cb2a 3387 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 24:032f3683cb2a 3388 // command_table: list of commands to perform on button press
whismanoid 24:032f3683cb2a 3389 // command_table: perform list of commands
whismanoid 24:032f3683cb2a 3390 Run_command_table(onButton3_command_table);
whismanoid 24:032f3683cb2a 3391 #endif // USE_DATALOGGER_CommandTable
whismanoid 24:032f3683cb2a 3392 }
whismanoid 24:032f3683cb2a 3393 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3394 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3395 void onButton4FallingEdge(void)
whismanoid 29:6a9edb6e973b 3396 {
whismanoid 29:6a9edb6e973b 3397 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3398 Run_command_table(onButton4_command_table);
whismanoid 29:6a9edb6e973b 3399 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3400 }
whismanoid 29:6a9edb6e973b 3401 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3402 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3403 void onButton5FallingEdge(void)
whismanoid 29:6a9edb6e973b 3404 {
whismanoid 29:6a9edb6e973b 3405 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3406 Run_command_table(onButton5_command_table);
whismanoid 29:6a9edb6e973b 3407 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3408 }
whismanoid 29:6a9edb6e973b 3409 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3410 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3411 void onButton6FallingEdge(void)
whismanoid 29:6a9edb6e973b 3412 {
whismanoid 29:6a9edb6e973b 3413 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3414 Run_command_table(onButton6_command_table);
whismanoid 29:6a9edb6e973b 3415 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3416 }
whismanoid 29:6a9edb6e973b 3417 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3418 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3419 void onButton7FallingEdge(void)
whismanoid 29:6a9edb6e973b 3420 {
whismanoid 29:6a9edb6e973b 3421 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3422 Run_command_table(onButton7_command_table);
whismanoid 29:6a9edb6e973b 3423 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3424 }
whismanoid 29:6a9edb6e973b 3425 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3426 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3427 void onButton8FallingEdge(void)
whismanoid 29:6a9edb6e973b 3428 {
whismanoid 29:6a9edb6e973b 3429 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3430 Run_command_table(onButton8_command_table);
whismanoid 29:6a9edb6e973b 3431 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3432 }
whismanoid 29:6a9edb6e973b 3433 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3434 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3435 void onButton9FallingEdge(void)
whismanoid 29:6a9edb6e973b 3436 {
whismanoid 29:6a9edb6e973b 3437 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3438 Run_command_table(onButton9_command_table);
whismanoid 29:6a9edb6e973b 3439 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3440 }
whismanoid 29:6a9edb6e973b 3441 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3442
whismanoid 4:d9b05924ad4c 3443 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3444 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3445 inline void print_command_prompt()
whismanoid 4:d9b05924ad4c 3446 {
whismanoid 4:d9b05924ad4c 3447 //~ Serial.println(F(">"));
whismanoid 4:d9b05924ad4c 3448 cmdLine.serial().printf("\r\n> ");
whismanoid 4:d9b05924ad4c 3449 }
whismanoid 4:d9b05924ad4c 3450 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3451
whismanoid 4:d9b05924ad4c 3452 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3453 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3454 void main_menu_status(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 3455 {
whismanoid 4:d9b05924ad4c 3456 cmdLine.serial().printf("\r\nMain menu");
whismanoid 4:d9b05924ad4c 3457 #if APPLICATION_MAX5715 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3458 cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC");
whismanoid 4:d9b05924ad4c 3459 #elif APPLICATION_MAX11131 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3460 cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC");
whismanoid 4:d9b05924ad4c 3461 #elif APPLICATION_MAX5171 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3462 cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC");
whismanoid 4:d9b05924ad4c 3463 #elif APPLICATION_MAX11410 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3464 cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC");
whismanoid 4:d9b05924ad4c 3465 #elif APPLICATION_MAX12345 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3466 cmdLine.serial().printf(" MAX12345");
whismanoid 16:819c5aaf5271 3467 #elif MAX40108_DEMO // main_menu_status banner
whismanoid 17:9397ea3ea7e9 3468 cmdLine.serial().printf(" MAX40108_U%d", MAX40108_DEMO);
whismanoid 36:e7aac874b8be 3469 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 3470 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 3471 cmdLine.serial().printf(" s/n %d", BOARD_SERIAL_NUMBER);
whismanoid 36:e7aac874b8be 3472 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 3473 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 3474 //
whismanoid 36:e7aac874b8be 3475 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 4:d9b05924ad4c 3476 #else
whismanoid 4:d9b05924ad4c 3477 //cmdLine.serial().printf(" ");
whismanoid 4:d9b05924ad4c 3478 #endif
whismanoid 4:d9b05924ad4c 3479 //cmdLine.serial().printf(" %s", TARGET_NAME);
whismanoid 4:d9b05924ad4c 3480 if (cmdLine.nameStr())
whismanoid 4:d9b05924ad4c 3481 {
whismanoid 4:d9b05924ad4c 3482 cmdLine.serial().printf(" [%s]", cmdLine.nameStr());
whismanoid 4:d9b05924ad4c 3483 }
whismanoid 4:d9b05924ad4c 3484 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3485 cmdLine.serial().printf(" [Button1");
whismanoid 4:d9b05924ad4c 3486 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3487 cmdLine.serial().printf("2");
whismanoid 24:032f3683cb2a 3488 #endif
whismanoid 24:032f3683cb2a 3489 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3490 cmdLine.serial().printf("3");
whismanoid 29:6a9edb6e973b 3491 #endif
whismanoid 29:6a9edb6e973b 3492 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3493 cmdLine.serial().printf("4");
whismanoid 29:6a9edb6e973b 3494 #endif
whismanoid 29:6a9edb6e973b 3495 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3496 cmdLine.serial().printf("5");
whismanoid 29:6a9edb6e973b 3497 #endif
whismanoid 29:6a9edb6e973b 3498 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3499 cmdLine.serial().printf("6");
whismanoid 29:6a9edb6e973b 3500 #endif
whismanoid 29:6a9edb6e973b 3501 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3502 cmdLine.serial().printf("7");
whismanoid 29:6a9edb6e973b 3503 #endif
whismanoid 29:6a9edb6e973b 3504 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3505 cmdLine.serial().printf("8");
whismanoid 29:6a9edb6e973b 3506 #endif
whismanoid 29:6a9edb6e973b 3507 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3508 cmdLine.serial().printf("9");
whismanoid 29:6a9edb6e973b 3509 #endif
whismanoid 29:6a9edb6e973b 3510 cmdLine.serial().printf("]");
whismanoid 29:6a9edb6e973b 3511 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 4:d9b05924ad4c 3512 #if HAS_BUTTON1_DEMO
whismanoid 4:d9b05924ad4c 3513 // print BUTTON1 status
whismanoid 4:d9b05924ad4c 3514 cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read());
whismanoid 4:d9b05924ad4c 3515 #endif
whismanoid 4:d9b05924ad4c 3516 #if HAS_BUTTON2_DEMO
whismanoid 24:032f3683cb2a 3517 // print BUTTON2 status
whismanoid 4:d9b05924ad4c 3518 cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read());
whismanoid 4:d9b05924ad4c 3519 #endif
whismanoid 24:032f3683cb2a 3520 #if HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 3521 // print BUTTON3 status
whismanoid 24:032f3683cb2a 3522 cmdLine.serial().printf("\r\n BUTTON3 = %d", button3.read());
whismanoid 24:032f3683cb2a 3523 #endif
whismanoid 4:d9b05924ad4c 3524 cmdLine.serial().printf("\r\n ? -- help");
whismanoid 4:d9b05924ad4c 3525 }
whismanoid 4:d9b05924ad4c 3526 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3527
whismanoid 28:a9a3a9db592b 3528 //--------------------------------------------------
whismanoid 28:a9a3a9db592b 3529 #ifndef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3530 #define USE_DATALOGGER_TRIGGER_HELP_BRIEF 1
whismanoid 28:a9a3a9db592b 3531 //~ #undef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3532 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3533
whismanoid 4:d9b05924ad4c 3534 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3535 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3536 void main_menu_help(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 3537 {
whismanoid 4:d9b05924ad4c 3538 // ? -- help
whismanoid 4:d9b05924ad4c 3539 //~ cmdLine.serial().printf("\r\nMenu:");
whismanoid 10:04022a61b527 3540 //
whismanoid 4:d9b05924ad4c 3541 cmdLine.serial().printf("\r\n # -- lines beginning with # are comments");
whismanoid 10:04022a61b527 3542 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 3543 cmdLine.serial().printf("\r\n ! -- Init");
whismanoid 10:04022a61b527 3544 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 3545 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 3546 cmdLine.serial().printf("\r\n . -- SelfTest");
whismanoid 4:d9b05924ad4c 3547 #endif // USE_SELFTEST
whismanoid 9:45f98573eb6d 3548 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 9:45f98573eb6d 3549 // CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register
whismanoid 9:45f98573eb6d 3550 cmdLine.serial().printf("\r\n * -- read core registers\r\n *regname? -- read register\r\n *regname=regvalue -- write register");
whismanoid 9:45f98573eb6d 3551 // cmdLine.serial().printf("\r\n 01 23 45 67 89 ab cd ef -- write and read raw hex codes");
whismanoid 10:04022a61b527 3552 #endif // USE_STAR_REG_READWRITE
whismanoid 10:04022a61b527 3553 //
whismanoid 10:04022a61b527 3554 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3555 // Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_help
whismanoid 10:04022a61b527 3556 //~ cmdLine.serial().printf("\r\n > -- auxiliary UART port");
whismanoid 10:04022a61b527 3557 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3558 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3559 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3560 if (cmdLine_AUXserial.nameStr())
whismanoid 10:04022a61b527 3561 {
whismanoid 10:04022a61b527 3562 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_AUXserial.nameStr());
whismanoid 10:04022a61b527 3563 }
whismanoid 10:04022a61b527 3564 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3565 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3566 if (cmdLine_DAPLINKserial.nameStr())
whismanoid 10:04022a61b527 3567 {
whismanoid 10:04022a61b527 3568 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_DAPLINKserial.nameStr());
whismanoid 10:04022a61b527 3569 }
whismanoid 10:04022a61b527 3570 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3571 # if HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3572 // WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3573 cmdLine.serial().printf("\r\n >xyzzy -- Forward command/data 'xyzzy' to aux TX/RX");
whismanoid 10:04022a61b527 3574 cmdLine.serial().printf("\r\n >>xyzzy -- Forward 'xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 3575 cmdLine.serial().printf("\r\n >>>xyzzy -- Forward '>xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 3576 #if 0
whismanoid 10:04022a61b527 3577 cmdLine.serial().printf("\r\n >tx_wait_echo=%d -- configure TX wait for each character echo", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 3578 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 3579 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 3580 #endif
whismanoid 20:78ef670955d4 3581 #if 1 // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 3582 cmdLine.serial().printf("\r\n >baud=%d message_ms=%d rx_idle_ms=%d rx_max_count=%d rx_eot=%d",
whismanoid 20:78ef670955d4 3583 g_auxSerialCom_baud,
whismanoid 20:78ef670955d4 3584 g_auxSerialCom_message_ms,
whismanoid 20:78ef670955d4 3585 g_auxSerialCom_rx_idle_ms,
whismanoid 20:78ef670955d4 3586 g_auxSerialCom_rx_max_count,
whismanoid 20:78ef670955d4 3587 g_auxSerialCom_rx_eot);
whismanoid 20:78ef670955d4 3588 #else // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 3589 cmdLine.serial().printf("\r\n >baud=%d -- configure aux TX/RX port", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 3590 cmdLine.serial().printf("\r\n >message_ms=%d -- maximum RX message total response time", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 3591 cmdLine.serial().printf("\r\n >rx_idle_ms=%d -- maximum RX message idle time between characters", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 3592 cmdLine.serial().printf("\r\n >rx_max_count=%d -- maximum RX message total length", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 3593 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 3594 #endif // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 10:04022a61b527 3595 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3596 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3597 //
whismanoid 4:d9b05924ad4c 3598 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 3599 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3600 // Datalog trigger menu
whismanoid 28:a9a3a9db592b 3601 // brief toplevel heading for datalog help L
whismanoid 28:a9a3a9db592b 3602 // L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 3603 cmdLine.serial().printf("\r\n L -- halt the datalogger; show more commands");
whismanoid 28:a9a3a9db592b 3604 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 28:a9a3a9db592b 3605 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 28:a9a3a9db592b 3606 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 28:a9a3a9db592b 3607 //
whismanoid 28:a9a3a9db592b 3608 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 3609 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 3610 //
whismanoid 28:a9a3a9db592b 3611 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 3612 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3613 //~ cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 3614 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3615 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 3616 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 3617 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 3618 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 9:45f98573eb6d 3619 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 9:45f98573eb6d 3620 //
whismanoid 17:9397ea3ea7e9 3621 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 4:d9b05924ad4c 3622 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 9:45f98573eb6d 3623 //
whismanoid 17:9397ea3ea7e9 3624 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 3625 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 17:9397ea3ea7e9 3626 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 3627 //
whismanoid 9:45f98573eb6d 3628 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 3629 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 3630 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 3631 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 9:45f98573eb6d 3632 //
whismanoid 17:9397ea3ea7e9 3633 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 9:45f98573eb6d 3634 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 3635 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 3636 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 3637 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 3638 //
whismanoid 17:9397ea3ea7e9 3639 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3640 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 17:9397ea3ea7e9 3641 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 9:45f98573eb6d 3642 //
whismanoid 9:45f98573eb6d 3643 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 3644 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 3645 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 3646 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 3647 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 9:45f98573eb6d 3648 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 9:45f98573eb6d 3649 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 9:45f98573eb6d 3650 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 9:45f98573eb6d 3651 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 9:45f98573eb6d 3652 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 9:45f98573eb6d 3653 //
whismanoid 9:45f98573eb6d 3654 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 3655 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 9:45f98573eb6d 3656 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 9:45f98573eb6d 3657 //
whismanoid 9:45f98573eb6d 3658 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 3659 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 3660 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 9:45f98573eb6d 3661 //
whismanoid 9:45f98573eb6d 3662 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 3663 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 9:45f98573eb6d 3664 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 3665 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 9:45f98573eb6d 3666 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 3667 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 9:45f98573eb6d 3668 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 3669 //
whismanoid 9:45f98573eb6d 3670 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 3671 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 9:45f98573eb6d 3672 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 9:45f98573eb6d 3673 //
whismanoid 9:45f98573eb6d 3674 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 3675 //
whismanoid 9:45f98573eb6d 3676 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 3677 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 3678 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 3679 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 3680 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 9:45f98573eb6d 3681 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3682 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 9:45f98573eb6d 3683 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3684 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3685 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 9:45f98573eb6d 3686 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3687 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 9:45f98573eb6d 3688 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3689 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 9:45f98573eb6d 3690 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3691 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3692 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 9:45f98573eb6d 3693 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3694 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 3695 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 3696 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 3697 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3698 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 3699 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 3700 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 3701 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3702 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 3703 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 3704 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 3705 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 3706 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 3707 //
whismanoid 4:d9b05924ad4c 3708 //cmdLine.serial().print(F("\r\n ! -- Initial Configuration"));
whismanoid 4:d9b05924ad4c 3709 //
whismanoid 4:d9b05924ad4c 3710 // % standardize diagnostic commands
whismanoid 4:d9b05924ad4c 3711 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 3712 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 3713 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 3714 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 3715 // %Ppin df=xx -- pwm output
whismanoid 4:d9b05924ad4c 3716 // %Wpin -- measure high pulsewidth input in usec
whismanoid 4:d9b05924ad4c 3717 // %wpin -- measure low pulsewidth input in usec
whismanoid 4:d9b05924ad4c 3718 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 3719 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 3720 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 3721 // %IW ADDR=? cmd=? data,data,data -- write
whismanoid 4:d9b05924ad4c 3722 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 3723 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3724 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 3725 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 3726 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 3727 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 3728 // A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 3729 //
whismanoid 23:c6c652bef4b9 3730 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3731 #if USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3732 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 3733 // TODO: %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 3734 // TODO: future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 3735 // TODO: future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 3736 // TODO: %B1@ view command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 3737 // TODO: %B1@+ command add new row (if there is room to add) (ignore one space before command)
whismanoid 23:c6c652bef4b9 3738 // TODO: %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 3739 // TODO: %B1@-~~~ clear entire command table
whismanoid 23:c6c652bef4b9 3740 // TODO: %B1@nnn command replace row number nnn (ignore one space before command)
whismanoid 23:c6c652bef4b9 3741 // TODO: %B1@! disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 3742 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 3743 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 30:07197a430869 3744 cmdLine.serial().printf("\r\n %%B1! trigger Button1 event; %%B1@ -- view/edit command table");
whismanoid 23:c6c652bef4b9 3745 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3746 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3747 #if HAS_digitalInOuts
whismanoid 4:d9b05924ad4c 3748 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 3749 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 3750 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 3751 cmdLine.serial().printf("\r\n %%Hn {pin:");
whismanoid 4:d9b05924ad4c 3752 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3753 cmdLine.serial().printf("} -- High Output");
whismanoid 4:d9b05924ad4c 3754 cmdLine.serial().printf("\r\n %%Ln {pin:");
whismanoid 4:d9b05924ad4c 3755 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3756 cmdLine.serial().printf("} -- Low Output");
whismanoid 4:d9b05924ad4c 3757 cmdLine.serial().printf("\r\n %%?n {pin:");
whismanoid 4:d9b05924ad4c 3758 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3759 cmdLine.serial().printf("} -- Input");
whismanoid 4:d9b05924ad4c 3760 #endif
whismanoid 4:d9b05924ad4c 3761
whismanoid 4:d9b05924ad4c 3762 #if HAS_analogIns
whismanoid 4:d9b05924ad4c 3763 // Menu A) analogRead A0..7
whismanoid 4:d9b05924ad4c 3764 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 3765 // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0)
whismanoid 34:a1993a1ee904 3766 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3767 // %A cal? view/export raw calibration values for all channels
whismanoid 34:a1993a1ee904 3768 cmdLine.serial().printf("\r\n %%A -- analogRead; %%A cal? -- calibration");
whismanoid 34:a1993a1ee904 3769 #else // HAS_Platform_AIN_Calibration
whismanoid 4:d9b05924ad4c 3770 cmdLine.serial().printf("\r\n %%A -- analogRead");
whismanoid 34:a1993a1ee904 3771 #endif // HAS_Platform_AIN_Calibration
whismanoid 4:d9b05924ad4c 3772 #endif
whismanoid 4:d9b05924ad4c 3773
whismanoid 4:d9b05924ad4c 3774 #if HAS_SPI2_MAX541
whismanoid 4:d9b05924ad4c 3775 // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 4:d9b05924ad4c 3776 cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)");
whismanoid 4:d9b05924ad4c 3777 #endif
whismanoid 4:d9b05924ad4c 3778
whismanoid 4:d9b05924ad4c 3779 #if HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3780 // TODO: support I2C HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3781 // VERIFY: I2C utility commands SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3782 // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz);
whismanoid 4:d9b05924ad4c 3783 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 3784 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 3785 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 3786 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 4:d9b05924ad4c 3787 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 3788 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3789 //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope
whismanoid 4:d9b05924ad4c 3790 cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 4:d9b05924ad4c 3791 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 4:d9b05924ad4c 3792 (g_I2C_SCL_Hz / 1000.));
whismanoid 4:d9b05924ad4c 3793 cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read",
whismanoid 4:d9b05924ad4c 3794 g_I2C_deviceAddress7);
whismanoid 4:d9b05924ad4c 3795 //
whismanoid 4:d9b05924ad4c 3796 #if SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3797 // Menu ^ cmd=?) i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3798 cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data");
whismanoid 4:d9b05924ad4c 3799 // test low-level I2C i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3800 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3801 //cmdLine.serial().printf(" H) Hunt for attached I2C devices");
whismanoid 4:d9b05924ad4c 3802 cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices");
whismanoid 4:d9b05924ad4c 3803 // cmdLine.serial().printf(" s) search i2c address");
whismanoid 4:d9b05924ad4c 3804 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3805
whismanoid 4:d9b05924ad4c 3806 #if HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3807 // TODO: support SPI HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3808 // SPI test command S (mosiData)+
whismanoid 4:d9b05924ad4c 3809 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 3810 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 3811 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 3812 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 3813 // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 4:d9b05924ad4c 3814 // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 4:d9b05924ad4c 3815 // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 4:d9b05924ad4c 3816 // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 4:d9b05924ad4c 3817 // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 4:d9b05924ad4c 3818 // mode | POL PHA
whismanoid 4:d9b05924ad4c 3819 // -----+--------
whismanoid 4:d9b05924ad4c 3820 // 0 | 0 0
whismanoid 4:d9b05924ad4c 3821 // 1 | 0 1
whismanoid 4:d9b05924ad4c 3822 // 2 | 1 0
whismanoid 4:d9b05924ad4c 3823 // 3 | 1 1
whismanoid 4:d9b05924ad4c 3824 //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0");
whismanoid 4:d9b05924ad4c 3825 // 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 3826 cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config",
whismanoid 4:d9b05924ad4c 3827 g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.),
whismanoid 4:d9b05924ad4c 3828 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 4:d9b05924ad4c 3829 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0));
whismanoid 4:d9b05924ad4c 3830 cmdLine.serial().printf("\r\n %%SD -- SPI diagnostic messages ");
whismanoid 4:d9b05924ad4c 3831 if (g_MAX11410_device.onSPIprint) {
whismanoid 4:d9b05924ad4c 3832 cmdLine.serial().printf("hide");
whismanoid 4:d9b05924ad4c 3833 }
whismanoid 4:d9b05924ad4c 3834 else {
whismanoid 4:d9b05924ad4c 3835 cmdLine.serial().printf("show");
whismanoid 4:d9b05924ad4c 3836 }
whismanoid 4:d9b05924ad4c 3837 cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes");
whismanoid 4:d9b05924ad4c 3838 // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0
whismanoid 4:d9b05924ad4c 3839 #endif // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3840 //
whismanoid 4:d9b05924ad4c 3841 // Application-specific commands (help text) here
whismanoid 4:d9b05924ad4c 3842 //
whismanoid 4:d9b05924ad4c 3843 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3844 cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3845 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3846 //
whismanoid 4:d9b05924ad4c 3847
whismanoid 4:d9b05924ad4c 3848 //~ extern void MAX11410_menu_help(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp\n
whismanoid 4:d9b05924ad4c 3849 //~ MAX11410_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 3850 }
whismanoid 4:d9b05924ad4c 3851 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3852
whismanoid 4:d9b05924ad4c 3853 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 15:37c83ec50ea0 3854
whismanoid 15:37c83ec50ea0 3855 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 3856 void pinsMonitor_submenu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 15:37c83ec50ea0 3857 {
whismanoid 15:37c83ec50ea0 3858 // % diagnostic commands submenu
whismanoid 15:37c83ec50ea0 3859 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 3860 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 3861 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 3862 // %A %Apin -- analog input
whismanoid 15:37c83ec50ea0 3863 // %Ppin df=xx -- pwm output
whismanoid 15:37c83ec50ea0 3864 // %Wpin -- measure high pulsewidth input in usec
whismanoid 15:37c83ec50ea0 3865 // %wpin -- measure low pulsewidth input in usec
whismanoid 15:37c83ec50ea0 3866 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 3867 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 3868 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 3869 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 3870 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 3871 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 3872 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 3873 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 3874 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 3875 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 3876 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 3877 //
whismanoid 15:37c83ec50ea0 3878 char strPinIndex[3];
whismanoid 15:37c83ec50ea0 3879 strPinIndex[0] = cmdLine[2];
whismanoid 15:37c83ec50ea0 3880 strPinIndex[1] = cmdLine[3];
whismanoid 15:37c83ec50ea0 3881 strPinIndex[2] = '\0';
whismanoid 15:37c83ec50ea0 3882 int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 15:37c83ec50ea0 3883 //cmdLine.serial().printf(" pinIndex=%d ", pinIndex);
whismanoid 15:37c83ec50ea0 3884 //
whismanoid 15:37c83ec50ea0 3885 // get next character
whismanoid 15:37c83ec50ea0 3886 switch (cmdLine[1])
whismanoid 15:37c83ec50ea0 3887 {
whismanoid 23:c6c652bef4b9 3888 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3889 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3890 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 3891 case 'B': case 'b':
whismanoid 23:c6c652bef4b9 3892 {
whismanoid 24:032f3683cb2a 3893 int command_table_button_index = 1;
whismanoid 23:c6c652bef4b9 3894 // %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 3895 // future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 3896 // future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 3897 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3898 // cmdLine[2] == '1' selects onButton1_command_table
whismanoid 23:c6c652bef4b9 3899 char** command_table = onButton1_command_table;
whismanoid 23:c6c652bef4b9 3900 #endif
whismanoid 24:032f3683cb2a 3901 switch(cmdLine[2])
whismanoid 24:032f3683cb2a 3902 {
whismanoid 24:032f3683cb2a 3903 default:
whismanoid 24:032f3683cb2a 3904 case '1': case 'A': case 'a': case '!':
whismanoid 24:032f3683cb2a 3905 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3906 command_table_button_index = 1;
whismanoid 24:032f3683cb2a 3907 command_table = onButton1_command_table;
whismanoid 24:032f3683cb2a 3908 #endif
whismanoid 24:032f3683cb2a 3909 break;
whismanoid 24:032f3683cb2a 3910 case '2': case 'B': case 'b': case '@':
whismanoid 23:c6c652bef4b9 3911 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3912 command_table_button_index = 2;
whismanoid 24:032f3683cb2a 3913 command_table = onButton2_command_table;
whismanoid 24:032f3683cb2a 3914 #endif
whismanoid 24:032f3683cb2a 3915 break;
whismanoid 24:032f3683cb2a 3916 case '3': case 'C': case 'c': case '#':
whismanoid 23:c6c652bef4b9 3917 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3918 command_table_button_index = 3;
whismanoid 24:032f3683cb2a 3919 command_table = onButton3_command_table;
whismanoid 24:032f3683cb2a 3920 #endif
whismanoid 24:032f3683cb2a 3921 break;
whismanoid 29:6a9edb6e973b 3922 case '4':
whismanoid 29:6a9edb6e973b 3923 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3924 command_table_button_index = 4;
whismanoid 29:6a9edb6e973b 3925 command_table = onButton4_command_table;
whismanoid 29:6a9edb6e973b 3926 #endif
whismanoid 29:6a9edb6e973b 3927 break;
whismanoid 29:6a9edb6e973b 3928 case '5':
whismanoid 29:6a9edb6e973b 3929 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3930 command_table_button_index = 5;
whismanoid 29:6a9edb6e973b 3931 command_table = onButton5_command_table;
whismanoid 29:6a9edb6e973b 3932 #endif
whismanoid 29:6a9edb6e973b 3933 break;
whismanoid 29:6a9edb6e973b 3934 case '6':
whismanoid 29:6a9edb6e973b 3935 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3936 command_table_button_index = 6;
whismanoid 29:6a9edb6e973b 3937 command_table = onButton6_command_table;
whismanoid 29:6a9edb6e973b 3938 #endif
whismanoid 29:6a9edb6e973b 3939 break;
whismanoid 29:6a9edb6e973b 3940 case '7':
whismanoid 29:6a9edb6e973b 3941 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3942 command_table_button_index = 7;
whismanoid 29:6a9edb6e973b 3943 command_table = onButton7_command_table;
whismanoid 29:6a9edb6e973b 3944 #endif
whismanoid 29:6a9edb6e973b 3945 break;
whismanoid 29:6a9edb6e973b 3946 case '8':
whismanoid 29:6a9edb6e973b 3947 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3948 command_table_button_index = 8;
whismanoid 29:6a9edb6e973b 3949 command_table = onButton8_command_table;
whismanoid 29:6a9edb6e973b 3950 #endif
whismanoid 29:6a9edb6e973b 3951 break;
whismanoid 29:6a9edb6e973b 3952 case '9':
whismanoid 29:6a9edb6e973b 3953 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3954 command_table_button_index = 9;
whismanoid 29:6a9edb6e973b 3955 command_table = onButton9_command_table;
whismanoid 29:6a9edb6e973b 3956 #endif
whismanoid 29:6a9edb6e973b 3957 break;
whismanoid 24:032f3683cb2a 3958 }
whismanoid 24:032f3683cb2a 3959 //
whismanoid 23:c6c652bef4b9 3960 switch(cmdLine[3])
whismanoid 23:c6c652bef4b9 3961 {
whismanoid 23:c6c652bef4b9 3962 case '@':
whismanoid 23:c6c652bef4b9 3963 {
whismanoid 23:c6c652bef4b9 3964 // %B1@ view/edit command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 3965 int editRowIndex = 0;
whismanoid 23:c6c652bef4b9 3966 int command_table_row_count = 0;
whismanoid 23:c6c652bef4b9 3967 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 3968 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 3969 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 3970 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 3971 }
whismanoid 24:032f3683cb2a 3972 //
whismanoid 24:032f3683cb2a 3973 // ignore extra spaces before the command
whismanoid 24:032f3683cb2a 3974 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 24:032f3683cb2a 3975 int argIndex;
whismanoid 24:032f3683cb2a 3976 for (argIndex = 5; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 3977 {
whismanoid 24:032f3683cb2a 3978 if (cmdLine[argIndex] == ' ') break;
whismanoid 24:032f3683cb2a 3979 }
whismanoid 24:032f3683cb2a 3980 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 3981 {
whismanoid 24:032f3683cb2a 3982 if (cmdLine[argIndex] != ' ') break;
whismanoid 23:c6c652bef4b9 3983 }
whismanoid 23:c6c652bef4b9 3984 //
whismanoid 23:c6c652bef4b9 3985 // Edit the contents of command_table
whismanoid 23:c6c652bef4b9 3986 switch (cmdLine[4]) // %B1@... -- Edit the contents of command_table
whismanoid 23:c6c652bef4b9 3987 {
whismanoid 23:c6c652bef4b9 3988 case '0': case '1': case '2': case '3': case '4':
whismanoid 23:c6c652bef4b9 3989 case '5': case '6': case '7': case '8': case '9':
whismanoid 24:032f3683cb2a 3990 // %B1@nnn command replace row number nnn
whismanoid 23:c6c652bef4b9 3991 // edit row data
whismanoid 33:70a28cfe9e01 3992 // get row number to edit from cmdLine[4]
whismanoid 33:70a28cfe9e01 3993 editRowIndex = atoi(cmdLine.str()+4);
whismanoid 23:c6c652bef4b9 3994 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 3995 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 3996 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 28:a9a3a9db592b 3997 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 3998 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 3999 cmdLine.serial().printf("\r\n cannot replace row %d with nothing",
whismanoid 28:a9a3a9db592b 4000 editRowIndex);
whismanoid 28:a9a3a9db592b 4001 }
whismanoid 28:a9a3a9db592b 4002 else
whismanoid 28:a9a3a9db592b 4003 {
whismanoid 28:a9a3a9db592b 4004 // update row
whismanoid 28:a9a3a9db592b 4005 cmdLine.serial().printf("\r\n replace row %d with \"%s\"",
whismanoid 28:a9a3a9db592b 4006 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 4007 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4008 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 4009 }
whismanoid 24:032f3683cb2a 4010 }
whismanoid 33:70a28cfe9e01 4011 } // end if (command_table_row_count > 0)
whismanoid 33:70a28cfe9e01 4012 if ((editRowIndex == command_table_row_count) && (command_table_row_count < COMMAND_TABLE_ROW_MAX)) {
whismanoid 33:70a28cfe9e01 4013 // %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 4014 //
whismanoid 33:70a28cfe9e01 4015 command_table_row_count++;
whismanoid 33:70a28cfe9e01 4016 cmdLine.serial().printf("\r\n add next row %d containing \"%s\"",
whismanoid 33:70a28cfe9e01 4017 editRowIndex, cmdLine.str()+argIndex);
whismanoid 33:70a28cfe9e01 4018 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 33:70a28cfe9e01 4019 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 33:70a28cfe9e01 4020 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 33:70a28cfe9e01 4021 //
whismanoid 23:c6c652bef4b9 4022 }
whismanoid 33:70a28cfe9e01 4023 //
whismanoid 23:c6c652bef4b9 4024 break;
whismanoid 23:c6c652bef4b9 4025 case '+':
whismanoid 24:032f3683cb2a 4026 // %B1@+ command add new row (if there is room to add)
whismanoid 23:c6c652bef4b9 4027 // add a new row at end of table
whismanoid 23:c6c652bef4b9 4028 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 4029 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 23:c6c652bef4b9 4030 editRowIndex = command_table_row_count;
whismanoid 28:a9a3a9db592b 4031 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 4032 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 4033 cmdLine.serial().printf("\r\n cannot add new row %d containing nothing",
whismanoid 28:a9a3a9db592b 4034 editRowIndex);
whismanoid 28:a9a3a9db592b 4035 }
whismanoid 28:a9a3a9db592b 4036 else
whismanoid 28:a9a3a9db592b 4037 {
whismanoid 28:a9a3a9db592b 4038 command_table_row_count++;
whismanoid 28:a9a3a9db592b 4039 cmdLine.serial().printf("\r\n add new row %d containing \"%s\"",
whismanoid 28:a9a3a9db592b 4040 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 4041 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4042 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 4043 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 28:a9a3a9db592b 4044 }
whismanoid 23:c6c652bef4b9 4045 }
whismanoid 23:c6c652bef4b9 4046 break;
whismanoid 23:c6c652bef4b9 4047 case '-':
whismanoid 24:032f3683cb2a 4048 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 4049 // delete row from table
whismanoid 23:c6c652bef4b9 4050 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4051 // if command_table_row_count == 0 then the table is empty
whismanoid 23:c6c652bef4b9 4052 if ((cmdLine[5] == '~') && (cmdLine[6] == '~') && (cmdLine[7] == '~')) {
whismanoid 23:c6c652bef4b9 4053 // %B1@-~~~ clear entire command table
whismanoid 24:032f3683cb2a 4054 cmdLine.serial().printf("\r\n clear entire command table");
whismanoid 23:c6c652bef4b9 4055 command_table_row_count = 0;
whismanoid 28:a9a3a9db592b 4056 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 23:c6c652bef4b9 4057 break;
whismanoid 23:c6c652bef4b9 4058 }
whismanoid 24:032f3683cb2a 4059 else
whismanoid 23:c6c652bef4b9 4060 {
whismanoid 24:032f3683cb2a 4061 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 24:032f3683cb2a 4062 editRowIndex = atoi(cmdLine.str()+5);
whismanoid 24:032f3683cb2a 4063 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 24:032f3683cb2a 4064 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 24:032f3683cb2a 4065 // delete row editRowIndex from Datalogger_action_table
whismanoid 24:032f3683cb2a 4066 for (int i = editRowIndex; i < (command_table_row_count-1); i++)
whismanoid 24:032f3683cb2a 4067 {
whismanoid 24:032f3683cb2a 4068 // copy row i+1 into row i
whismanoid 24:032f3683cb2a 4069 cmdLine.serial().printf("\r\n copy row %d into row %d: \"%s\"",
whismanoid 24:032f3683cb2a 4070 i+1, i, command_table[i+1]);
whismanoid 24:032f3683cb2a 4071 strncpy(command_table[i], command_table[i+1], COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4072 command_table[i][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 24:032f3683cb2a 4073 }
whismanoid 24:032f3683cb2a 4074 command_table_row_count--;
whismanoid 28:a9a3a9db592b 4075 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 24:032f3683cb2a 4076 }
whismanoid 23:c6c652bef4b9 4077 }
whismanoid 23:c6c652bef4b9 4078 }
whismanoid 23:c6c652bef4b9 4079 break;
whismanoid 30:07197a430869 4080 case '.': // something other than ! because %B1! means trigger event
whismanoid 30:07197a430869 4081 // pause the button event
whismanoid 30:07197a430869 4082 // TODO: %B1@. disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 4083 //~ Datalogger_action_table_enabled = false;
whismanoid 23:c6c652bef4b9 4084 break;
whismanoid 23:c6c652bef4b9 4085 case '@':
whismanoid 30:07197a430869 4086 // enable the button event
whismanoid 23:c6c652bef4b9 4087 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 4088 //~ Datalogger_action_table_enabled = true;
whismanoid 23:c6c652bef4b9 4089 break;
whismanoid 23:c6c652bef4b9 4090 }
whismanoid 23:c6c652bef4b9 4091 //
whismanoid 23:c6c652bef4b9 4092 // Print the contents of command_table
whismanoid 23:c6c652bef4b9 4093 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 4094 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 4095 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 4096 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 4097 cmdLine.serial().printf("\r\n %%B%1d@%d %s",
whismanoid 24:032f3683cb2a 4098 command_table_button_index,
whismanoid 24:032f3683cb2a 4099 lineIndex,
whismanoid 24:032f3683cb2a 4100 command_table[lineIndex]);
whismanoid 23:c6c652bef4b9 4101 }
whismanoid 30:07197a430869 4102 //~ cmdLine.serial().printf("\r\n command_table_row_count = %d/%d",
whismanoid 30:07197a430869 4103 //~ command_table_row_count, COMMAND_TABLE_ROW_MAX);
whismanoid 30:07197a430869 4104 cmdLine.serial().printf("\r\n\r\nEdit Button%d event (used %d/%d, %d free):",
whismanoid 30:07197a430869 4105 command_table_button_index,
whismanoid 30:07197a430869 4106 command_table_row_count,
whismanoid 30:07197a430869 4107 COMMAND_TABLE_ROW_MAX,
whismanoid 30:07197a430869 4108 (COMMAND_TABLE_ROW_MAX - command_table_row_count)
whismanoid 30:07197a430869 4109 );
whismanoid 23:c6c652bef4b9 4110 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 4111 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 24:032f3683cb2a 4112 cmdLine.serial().printf("\r\n %%B%1d@+ command -- add new row %d at end of table",
whismanoid 24:032f3683cb2a 4113 command_table_button_index,
whismanoid 24:032f3683cb2a 4114 command_table_row_count);
whismanoid 23:c6c652bef4b9 4115 }
whismanoid 23:c6c652bef4b9 4116 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4117 // if command_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 4118 cmdLine.serial().printf("\r\n %%B%1d@%d command -- replace row %d",
whismanoid 24:032f3683cb2a 4119 command_table_button_index,
whismanoid 23:c6c652bef4b9 4120 command_table_row_count-1,
whismanoid 23:c6c652bef4b9 4121 command_table_row_count-1);
whismanoid 24:032f3683cb2a 4122 cmdLine.serial().printf("\r\n %%B%1d@-%d -- delete row %d",
whismanoid 24:032f3683cb2a 4123 command_table_button_index,
whismanoid 24:032f3683cb2a 4124 command_table_row_count-1,
whismanoid 24:032f3683cb2a 4125 command_table_row_count-1);
whismanoid 24:032f3683cb2a 4126 cmdLine.serial().printf("\r\n %%B%1d@-~~~ -- delete all rows",
whismanoid 24:032f3683cb2a 4127 command_table_button_index);
whismanoid 30:07197a430869 4128 //~ cmdLine.serial().printf("\r\n %%B%1d@. -- pause entire command table",
whismanoid 30:07197a430869 4129 //~ command_table_button_index);
whismanoid 30:07197a430869 4130 //~ cmdLine.serial().printf("\r\n %%B%1d@@ -- enable command table",
whismanoid 30:07197a430869 4131 //~ command_table_button_index);
whismanoid 30:07197a430869 4132 cmdLine.serial().printf("\r\n %%B%1d! -- trigger Button%d event",
whismanoid 30:07197a430869 4133 command_table_button_index,
whismanoid 24:032f3683cb2a 4134 command_table_button_index);
whismanoid 23:c6c652bef4b9 4135 }
whismanoid 23:c6c652bef4b9 4136 //
whismanoid 23:c6c652bef4b9 4137 } // case '@' -- %B1@ view/edit command table
whismanoid 23:c6c652bef4b9 4138 break;
whismanoid 23:c6c652bef4b9 4139 case '!':
whismanoid 23:c6c652bef4b9 4140 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 23:c6c652bef4b9 4141 Run_command_table(command_table);
whismanoid 23:c6c652bef4b9 4142 break;
whismanoid 23:c6c652bef4b9 4143 }
whismanoid 23:c6c652bef4b9 4144 }
whismanoid 23:c6c652bef4b9 4145 break;
whismanoid 23:c6c652bef4b9 4146 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4147 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 4148 #if HAS_digitalInOuts
whismanoid 15:37c83ec50ea0 4149 case 'H': case 'h':
whismanoid 15:37c83ec50ea0 4150 {
whismanoid 15:37c83ec50ea0 4151 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 4152 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4153 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4154 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4155 #else
whismanoid 15:37c83ec50ea0 4156 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4157 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 4158 digitalInOutPin.write(1);
whismanoid 15:37c83ec50ea0 4159 #endif
whismanoid 15:37c83ec50ea0 4160 cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex);
whismanoid 15:37c83ec50ea0 4161 }
whismanoid 15:37c83ec50ea0 4162 break;
whismanoid 15:37c83ec50ea0 4163 case 'L': case 'l':
whismanoid 15:37c83ec50ea0 4164 {
whismanoid 15:37c83ec50ea0 4165 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 4166 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4167 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4168 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4169 #else
whismanoid 15:37c83ec50ea0 4170 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4171 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 4172 digitalInOutPin.write(0);
whismanoid 15:37c83ec50ea0 4173 #endif
whismanoid 15:37c83ec50ea0 4174 cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex);
whismanoid 15:37c83ec50ea0 4175 }
whismanoid 15:37c83ec50ea0 4176 break;
whismanoid 15:37c83ec50ea0 4177 case '?':
whismanoid 15:37c83ec50ea0 4178 {
whismanoid 15:37c83ec50ea0 4179 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 4180 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4181 pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4182 #else
whismanoid 15:37c83ec50ea0 4183 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4184 digitalInOutPin.input();
whismanoid 15:37c83ec50ea0 4185 #endif
whismanoid 15:37c83ec50ea0 4186 serial.printf(" digitalInOutPin %d Input ", pinIndex);
whismanoid 15:37c83ec50ea0 4187 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4188 int value = digitalRead(pinIndex);
whismanoid 15:37c83ec50ea0 4189 #else
whismanoid 15:37c83ec50ea0 4190 int value = digitalInOutPin.read();
whismanoid 15:37c83ec50ea0 4191 #endif
whismanoid 15:37c83ec50ea0 4192 cmdLine.serial().printf("%d ", value);
whismanoid 15:37c83ec50ea0 4193 }
whismanoid 15:37c83ec50ea0 4194 break;
whismanoid 15:37c83ec50ea0 4195 #endif
whismanoid 15:37c83ec50ea0 4196 //
whismanoid 15:37c83ec50ea0 4197 #if HAS_analogIns
whismanoid 15:37c83ec50ea0 4198 case 'A': case 'a':
whismanoid 15:37c83ec50ea0 4199 {
whismanoid 15:37c83ec50ea0 4200 // %A %Apin -- analog input
whismanoid 34:a1993a1ee904 4201 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4202 // %A cal? view/export raw calibration values for all channels
whismanoid 34:a1993a1ee904 4203 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4204 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4205 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4206 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4207 {
whismanoid 34:a1993a1ee904 4208 char valueBuf[16];
whismanoid 34:a1993a1ee904 4209 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 4210 if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 4211 {
whismanoid 34:a1993a1ee904 4212 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4213 {
whismanoid 34:a1993a1ee904 4214 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 4215 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4216 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 4217 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4218 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 4219 );
whismanoid 34:a1993a1ee904 4220 }
whismanoid 34:a1993a1ee904 4221 //
whismanoid 34:a1993a1ee904 4222 // print extended help for %A
whismanoid 34:a1993a1ee904 4223 // %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 4224 //~ cmdLine.serial().printf("\r\n %%A cal0n=0.02 cal0v=0.123 cal0n=0.938 cal0v=1.132 -- update calibration");
whismanoid 34:a1993a1ee904 4225 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 4226 cmdLine.serial().printf(" %%A cal0test=0.5 -- calculate voltage at 50%% of full scale");
whismanoid 34:a1993a1ee904 4227 cmdLine.serial().printf("\r\n %%A v0cal=1.000V -- calibrate channel against a known input voltage");
whismanoid 34:a1993a1ee904 4228 // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 4229 // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 4230 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 4231 cmdLine.serial().printf("\r\n %%A calreset -- reset all calibration data");
whismanoid 34:a1993a1ee904 4232 cmdLine.serial().printf("\r\n\r\n");
whismanoid 34:a1993a1ee904 4233 //
whismanoid 34:a1993a1ee904 4234 } // end if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 4235 }
whismanoid 34:a1993a1ee904 4236 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4237 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4238 {
whismanoid 34:a1993a1ee904 4239 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 4240 char valueBuf[16];
whismanoid 34:a1993a1ee904 4241 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 4242 if (cmdLine.parse_and_remove_key("calreset", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 4243 {
whismanoid 34:a1993a1ee904 4244 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 4245 calibration_05_normValue_0_1[0] = 0.25; calibration_05_V[0] = 0.3;
whismanoid 34:a1993a1ee904 4246 calibration_05_normValue_0_1[1] = 0.25; calibration_05_V[1] = 0.3;
whismanoid 34:a1993a1ee904 4247 calibration_05_normValue_0_1[2] = 0.25; calibration_05_V[2] = 0.3;
whismanoid 34:a1993a1ee904 4248 calibration_05_normValue_0_1[3] = 0.25; calibration_05_V[3] = 0.3;
whismanoid 34:a1993a1ee904 4249 calibration_05_normValue_0_1[4] = 0.25; calibration_05_V[4] = 1.5;
whismanoid 34:a1993a1ee904 4250 calibration_05_normValue_0_1[5] = 0.25; calibration_05_V[5] = 1.5;
whismanoid 34:a1993a1ee904 4251 //
whismanoid 34:a1993a1ee904 4252 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 4253 calibration_95_normValue_0_1[0] = 0.75; calibration_95_V[0] = 0.9;
whismanoid 34:a1993a1ee904 4254 calibration_95_normValue_0_1[1] = 0.75; calibration_95_V[1] = 0.9;
whismanoid 34:a1993a1ee904 4255 calibration_95_normValue_0_1[2] = 0.75; calibration_95_V[2] = 0.9;
whismanoid 34:a1993a1ee904 4256 calibration_95_normValue_0_1[3] = 0.75; calibration_95_V[3] = 0.9;
whismanoid 34:a1993a1ee904 4257 calibration_95_normValue_0_1[4] = 0.75; calibration_95_V[4] = 4.5;
whismanoid 34:a1993a1ee904 4258 calibration_95_normValue_0_1[5] = 0.75; calibration_95_V[5] = 4.5;
whismanoid 34:a1993a1ee904 4259 //
whismanoid 34:a1993a1ee904 4260 }
whismanoid 34:a1993a1ee904 4261 }
whismanoid 34:a1993a1ee904 4262 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4263 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4264 // %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 4265 // %A cal4n=0.135874882 cal4v=0.800000012V cal4n=0.286168128 cal4v=1.700000048V
whismanoid 34:a1993a1ee904 4266 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4267 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4268 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4269 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4270 {
whismanoid 34:a1993a1ee904 4271 double normValue_0_1, V;
whismanoid 34:a1993a1ee904 4272 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4273 {
whismanoid 34:a1993a1ee904 4274 static char key_can0n[8] = "cal0n__";
whismanoid 34:a1993a1ee904 4275 sprintf(key_can0n, "cal%1dn", ch);
whismanoid 34:a1993a1ee904 4276 static char key_cal0v[8] = "cal0v__";
whismanoid 34:a1993a1ee904 4277 sprintf(key_cal0v, "cal%1dv", ch);
whismanoid 35:c9549b5c01de 4278 // first point could be the 5% point or the 95% point
whismanoid 35:c9549b5c01de 4279 double norm_threshold = (calibration_05_normValue_0_1[ch] + calibration_95_normValue_0_1[ch]) / 2.0;
whismanoid 35:c9549b5c01de 4280 bool updated_05 = false;
whismanoid 35:c9549b5c01de 4281 //~ bool updated_95 = false;
whismanoid 35:c9549b5c01de 4282 if (cmdLine.parse_double(key_can0n, normValue_0_1)) {
whismanoid 34:a1993a1ee904 4283 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 34:a1993a1ee904 4284 {
whismanoid 35:c9549b5c01de 4285 if (normValue_0_1 < norm_threshold) {
whismanoid 35:c9549b5c01de 4286 // store first calibration point in the 5% slot
whismanoid 35:c9549b5c01de 4287 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 4288 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 4289 updated_05 = true;
whismanoid 34:a1993a1ee904 4290 }
whismanoid 34:a1993a1ee904 4291 else {
whismanoid 35:c9549b5c01de 4292 // store first calibration point in the 95% slot
whismanoid 35:c9549b5c01de 4293 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 4294 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 4295 //~ updated_95 = true;
whismanoid 34:a1993a1ee904 4296 }
whismanoid 34:a1993a1ee904 4297 }
whismanoid 35:c9549b5c01de 4298 }
whismanoid 35:c9549b5c01de 4299 // handle the optional second calibration point
whismanoid 35:c9549b5c01de 4300 if (cmdLine.parse_double(key_can0n, normValue_0_1))
whismanoid 35:c9549b5c01de 4301 {
whismanoid 35:c9549b5c01de 4302 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 35:c9549b5c01de 4303 {
whismanoid 35:c9549b5c01de 4304 if (updated_05) {
whismanoid 35:c9549b5c01de 4305 // we already stored the first point here
whismanoid 35:c9549b5c01de 4306 // calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4307 // calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 4308 // store the second point in the other slot
whismanoid 35:c9549b5c01de 4309 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4310 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 4311 }
whismanoid 35:c9549b5c01de 4312 else {
whismanoid 35:c9549b5c01de 4313 // we already stored the first point here
whismanoid 35:c9549b5c01de 4314 // calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4315 // calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 4316 // store the second point in the other slot
whismanoid 35:c9549b5c01de 4317 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4318 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 4319 }
whismanoid 35:c9549b5c01de 4320 }
whismanoid 35:c9549b5c01de 4321 }
whismanoid 34:a1993a1ee904 4322 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4323 }
whismanoid 34:a1993a1ee904 4324 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4325 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4326 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 4327 // double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 4328 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4329 {
whismanoid 34:a1993a1ee904 4330 static char key_cal0test[12] = "cal0test__";
whismanoid 34:a1993a1ee904 4331 sprintf(key_cal0test, "cal%1dtest", ch);
whismanoid 34:a1993a1ee904 4332 double normValue_0_1, Vtest;
whismanoid 34:a1993a1ee904 4333 if (cmdLine.parse_double(key_cal0test, Vtest))
whismanoid 34:a1993a1ee904 4334 {
whismanoid 34:a1993a1ee904 4335 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 4336 normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 4337 //
whismanoid 34:a1993a1ee904 4338 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 4339 ch,
whismanoid 34:a1993a1ee904 4340 normValue_0_1,
whismanoid 34:a1993a1ee904 4341 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 4342 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4343 );
whismanoid 34:a1993a1ee904 4344 //
whismanoid 34:a1993a1ee904 4345 // sweep CalibratedNormValue argument
whismanoid 34:a1993a1ee904 4346 double normValue_0_1_start = -0.05;
whismanoid 34:a1993a1ee904 4347 double normValue_0_1_step = 0.05;
whismanoid 34:a1993a1ee904 4348 double normValue_0_1_end = 1.07;
whismanoid 34:a1993a1ee904 4349 for (normValue_0_1 = normValue_0_1_start;
whismanoid 34:a1993a1ee904 4350 normValue_0_1 <= normValue_0_1_end;
whismanoid 34:a1993a1ee904 4351 normValue_0_1 = normValue_0_1 + normValue_0_1_step)
whismanoid 34:a1993a1ee904 4352 {
whismanoid 34:a1993a1ee904 4353 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 4354 ch,
whismanoid 34:a1993a1ee904 4355 normValue_0_1,
whismanoid 34:a1993a1ee904 4356 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 4357 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4358 );
whismanoid 34:a1993a1ee904 4359 }
whismanoid 34:a1993a1ee904 4360 }
whismanoid 34:a1993a1ee904 4361 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4362 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4363 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4364 // %A v0cal=1.000V -- calibrate channel against a known input voltage
whismanoid 34:a1993a1ee904 4365 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4366 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4367 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4368 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4369 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4370 {
whismanoid 34:a1993a1ee904 4371 static char key_v0cal[10] = "v0cal__";
whismanoid 34:a1993a1ee904 4372 sprintf(key_v0cal, "v%1dcal", ch);
whismanoid 34:a1993a1ee904 4373 double Vtest;
whismanoid 34:a1993a1ee904 4374 if (cmdLine.parse_double(key_v0cal, Vtest))
whismanoid 34:a1993a1ee904 4375 {
whismanoid 34:a1993a1ee904 4376 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 4377 double Vtest_normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 4378 //
whismanoid 34:a1993a1ee904 4379 // %A v0cal=1.000 calibrate one channel by measuring against a known input voltage
whismanoid 34:a1993a1ee904 4380 //
whismanoid 34:a1993a1ee904 4381 cmdLine.serial().printf("\r\n Measuring against input voltage of %1.6fV...", Vtest);
whismanoid 34:a1993a1ee904 4382 const int numberOfMeasurements = 16;
whismanoid 34:a1993a1ee904 4383 double Sx_measure_normValue_0_1 = 0; // sum of values
whismanoid 34:a1993a1ee904 4384 double Sxx_measure_normValue_0_1 = 0; // sum of the squares of the values
whismanoid 34:a1993a1ee904 4385 for (int count = 0; count < numberOfMeasurements; count++)
whismanoid 34:a1993a1ee904 4386 {
whismanoid 34:a1993a1ee904 4387 double measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4388 switch(ch)
whismanoid 34:a1993a1ee904 4389 {
whismanoid 34:a1993a1ee904 4390 case 0: measure_normValue_0_1 = analogIn0.read(); break;
whismanoid 34:a1993a1ee904 4391 case 1: measure_normValue_0_1 = analogIn1.read(); break;
whismanoid 34:a1993a1ee904 4392 case 2: measure_normValue_0_1 = analogIn2.read(); break;
whismanoid 34:a1993a1ee904 4393 case 3: measure_normValue_0_1 = analogIn3.read(); break;
whismanoid 34:a1993a1ee904 4394 case 4: measure_normValue_0_1 = analogIn4.read(); break;
whismanoid 34:a1993a1ee904 4395 case 5: measure_normValue_0_1 = analogIn5.read(); break;
whismanoid 34:a1993a1ee904 4396 }
whismanoid 34:a1993a1ee904 4397 Sx_measure_normValue_0_1 = Sx_measure_normValue_0_1 + measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4398 Sxx_measure_normValue_0_1 = Sxx_measure_normValue_0_1 + (measure_normValue_0_1 * measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4399 cmdLine.serial().printf("\r\n raw: %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4400 measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4401 (measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4402 );
whismanoid 34:a1993a1ee904 4403 }
whismanoid 34:a1993a1ee904 4404 cmdLine.serial().printf("\r\n numberOfMeasurements = %d", numberOfMeasurements);
whismanoid 34:a1993a1ee904 4405 cmdLine.serial().printf("\r\n Sx_measure_normValue_0_1 = %1.6f", Sx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4406 cmdLine.serial().printf("\r\n Sxx_measure_normValue_0_1 = %1.6f", Sxx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4407 //
whismanoid 34:a1993a1ee904 4408 // calculate mean_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 4409 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 4410 double mean_measure_normValue_0_1 = Sx_measure_normValue_0_1 / numberOfMeasurements;
whismanoid 34:a1993a1ee904 4411 cmdLine.serial().printf("\r\n mean = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4412 mean_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4413 (mean_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4414 );
whismanoid 34:a1993a1ee904 4415 //
whismanoid 34:a1993a1ee904 4416 // TODO: calculate sample variance_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 4417 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 4418 // variance_measure_normValue_0_1 = (Sxx - ( Sx * Sx / nWords) ) / (nWords - 1);
whismanoid 34:a1993a1ee904 4419 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 4420 cmdLine.serial().printf("\r\n variance = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4421 variance_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4422 (variance_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4423 );
whismanoid 34:a1993a1ee904 4424 //
whismanoid 34:a1993a1ee904 4425 // calculate sample stddev_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 4426 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 4427 double stddev_measure_normValue_0_1 = sqrt(variance_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4428 cmdLine.serial().printf("\r\n stddev = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4429 stddev_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4430 (stddev_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4431 );
whismanoid 34:a1993a1ee904 4432 //
whismanoid 34:a1993a1ee904 4433 // Validate the measurements:
whismanoid 34:a1993a1ee904 4434 // is the mean near the expected value?
whismanoid 34:a1993a1ee904 4435 // is the standard deviation not too high?
whismanoid 34:a1993a1ee904 4436 bool isCalibrationValid = true;
whismanoid 34:a1993a1ee904 4437 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) > 0.1) {
whismanoid 34:a1993a1ee904 4438 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 4439 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 4440 }
whismanoid 34:a1993a1ee904 4441 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) < -0.1) {
whismanoid 34:a1993a1ee904 4442 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 4443 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 4444 }
whismanoid 34:a1993a1ee904 4445 if ((stddev_measure_normValue_0_1) > 10) {
whismanoid 34:a1993a1ee904 4446 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 4447 cmdLine.serial().printf(" stddev too high.\r\n");
whismanoid 34:a1993a1ee904 4448 }
whismanoid 34:a1993a1ee904 4449 if (isCalibrationValid)
whismanoid 34:a1993a1ee904 4450 {
whismanoid 34:a1993a1ee904 4451 // update calibration point (mean_measure_normValue_0_1, Vtest)
whismanoid 34:a1993a1ee904 4452 if (Vtest_normValue_0_1 < 0.5) {
whismanoid 34:a1993a1ee904 4453 calibration_05_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4454 calibration_05_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 4455 } else {
whismanoid 34:a1993a1ee904 4456 calibration_95_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4457 calibration_95_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 4458 }
whismanoid 34:a1993a1ee904 4459 //
whismanoid 34:a1993a1ee904 4460 // print updated calibration values
whismanoid 34:a1993a1ee904 4461 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 4462 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 4463 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4464 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 4465 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4466 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 4467 );
whismanoid 34:a1993a1ee904 4468 // print corrected value of mean of measurements (should be close to Vtest)
whismanoid 34:a1993a1ee904 4469 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV vs %1.6fV\r\n",
whismanoid 34:a1993a1ee904 4470 ch,
whismanoid 34:a1993a1ee904 4471 mean_measure_normValue_0_1,
whismanoid 34:a1993a1ee904 4472 CalibratedNormValue(ch, mean_measure_normValue_0_1),
whismanoid 34:a1993a1ee904 4473 (CalibratedNormValue(ch, mean_measure_normValue_0_1) * adc_full_scale_voltage[ch]),
whismanoid 34:a1993a1ee904 4474 Vtest
whismanoid 34:a1993a1ee904 4475 );
whismanoid 34:a1993a1ee904 4476 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 4477 else {
whismanoid 34:a1993a1ee904 4478 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 4479 cmdLine.serial().printf(" Measurement Error: Calibration will not be updated.\r\n");
whismanoid 34:a1993a1ee904 4480 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 4481 } // end if key_v0cal
whismanoid 34:a1993a1ee904 4482 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4483 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4484 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4485 // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 4486 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4487 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4488 // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 4489 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4490 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 4491 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 15:37c83ec50ea0 4492 for (int pinIndex = 0; pinIndex < 2; pinIndex++)
whismanoid 15:37c83ec50ea0 4493 {
whismanoid 15:37c83ec50ea0 4494 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 4495 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 4496 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 15:37c83ec50ea0 4497 float normValue_0_1 = analogInPin.read();
whismanoid 34:a1993a1ee904 4498 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4499 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4500 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 4501 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4502 //
whismanoid 15:37c83ec50ea0 4503 int pinIndexH = pinIndex + 4;
whismanoid 15:37c83ec50ea0 4504 int cPinIndexH = '0' + pinIndexH;
whismanoid 15:37c83ec50ea0 4505 AnalogIn& analogInPinH = find_analogInPin(cPinIndexH);
whismanoid 15:37c83ec50ea0 4506 float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH];
whismanoid 15:37c83ec50ea0 4507 float normValueH_0_1 = analogInPinH.read();
whismanoid 34:a1993a1ee904 4508 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4509 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4510 normValueH_0_1 = CalibratedNormValue(pinIndex, normValueH_0_1);
whismanoid 34:a1993a1ee904 4511 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4512 //
whismanoid 15:37c83ec50ea0 4513 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV AIN%c = %7.3f%% = %1.3fV \r\n",
whismanoid 15:37c83ec50ea0 4514 cPinIndex,
whismanoid 15:37c83ec50ea0 4515 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4516 normValue_0_1 * adc_full_scale_voltage,
whismanoid 15:37c83ec50ea0 4517 cPinIndexH,
whismanoid 15:37c83ec50ea0 4518 normValueH_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4519 normValueH_0_1 * adc_full_scale_voltageH
whismanoid 15:37c83ec50ea0 4520 );
whismanoid 15:37c83ec50ea0 4521 }
whismanoid 15:37c83ec50ea0 4522 for (int pinIndex = 2; pinIndex < 4; pinIndex++)
whismanoid 15:37c83ec50ea0 4523 {
whismanoid 15:37c83ec50ea0 4524 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 4525 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 4526 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 15:37c83ec50ea0 4527 float normValue_0_1 = analogInPin.read();
whismanoid 34:a1993a1ee904 4528 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4529 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4530 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 4531 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4532 //
whismanoid 15:37c83ec50ea0 4533 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 4534 cPinIndex,
whismanoid 15:37c83ec50ea0 4535 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4536 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 4537 );
whismanoid 15:37c83ec50ea0 4538 }
whismanoid 15:37c83ec50ea0 4539 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 4540 // Platform board uses simple analog inputs
whismanoid 15:37c83ec50ea0 4541 // assume standard Arduino analog inputs A0-A5
whismanoid 15:37c83ec50ea0 4542 for (int pinIndex = 0; pinIndex < 6; pinIndex++)
whismanoid 15:37c83ec50ea0 4543 {
whismanoid 15:37c83ec50ea0 4544 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 4545 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 4546 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 15:37c83ec50ea0 4547 float normValue_0_1 = analogInPin.read();
whismanoid 34:a1993a1ee904 4548 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4549 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4550 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 4551 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4552 //
whismanoid 15:37c83ec50ea0 4553 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 4554 cPinIndex,
whismanoid 15:37c83ec50ea0 4555 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4556 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 4557 );
whismanoid 15:37c83ec50ea0 4558 }
whismanoid 15:37c83ec50ea0 4559 #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 4560 }
whismanoid 15:37c83ec50ea0 4561 break;
whismanoid 15:37c83ec50ea0 4562 #endif
whismanoid 15:37c83ec50ea0 4563 //
whismanoid 15:37c83ec50ea0 4564 #if HAS_SPI2_MAX541
whismanoid 15:37c83ec50ea0 4565 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 4566 {
whismanoid 15:37c83ec50ea0 4567 // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV)
whismanoid 15:37c83ec50ea0 4568 // MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 15:37c83ec50ea0 4569 float voltageV = max541.Get_Voltage();
whismanoid 15:37c83ec50ea0 4570 // if (cmdLine[2] == '+') {
whismanoid 15:37c83ec50ea0 4571 // // %D+
whismanoid 15:37c83ec50ea0 4572 // voltageV = voltageV * 1.25f;
whismanoid 15:37c83ec50ea0 4573 // if (voltageV >= max541.VRef) voltageV = max541.VRef;
whismanoid 15:37c83ec50ea0 4574 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4575 // }
whismanoid 15:37c83ec50ea0 4576 // else if (cmdLine[2] == '-') {
whismanoid 15:37c83ec50ea0 4577 // // %D-
whismanoid 15:37c83ec50ea0 4578 // voltageV = voltageV * 0.75f;
whismanoid 15:37c83ec50ea0 4579 // if (voltageV < 0.1f) voltageV = 0.1f;
whismanoid 15:37c83ec50ea0 4580 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4581 // }
whismanoid 15:37c83ec50ea0 4582 if (cmdLine.parse_float("V", voltageV))
whismanoid 15:37c83ec50ea0 4583 {
whismanoid 15:37c83ec50ea0 4584 // %D V=1.234 -- set voltage
whismanoid 15:37c83ec50ea0 4585 max541.Set_Voltage(voltageV);
whismanoid 15:37c83ec50ea0 4586 }
whismanoid 15:37c83ec50ea0 4587 else if (cmdLine.parse_float("TEST", voltageV))
whismanoid 15:37c83ec50ea0 4588 {
whismanoid 15:37c83ec50ea0 4589 // %D TEST=1.234 -- set voltage and compare with AIN0
whismanoid 15:37c83ec50ea0 4590 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4591 }
whismanoid 15:37c83ec50ea0 4592 else if (cmdLine.parse_float("CAL", voltageV))
whismanoid 15:37c83ec50ea0 4593 {
whismanoid 15:37c83ec50ea0 4594 // %D CAL=1.234 -- calibrate VRef and compare with AIN0
whismanoid 15:37c83ec50ea0 4595
whismanoid 15:37c83ec50ea0 4596 max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
whismanoid 15:37c83ec50ea0 4597 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 4598 const int average_count = 100;
whismanoid 15:37c83ec50ea0 4599 const double average_K = 0.25;
whismanoid 15:37c83ec50ea0 4600 for (int count = 0; count < average_count; count++) {
whismanoid 15:37c83ec50ea0 4601 double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 4602 max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
whismanoid 15:37c83ec50ea0 4603 }
whismanoid 15:37c83ec50ea0 4604 max541.VRef = 2.0 * max541_midscale_V;
whismanoid 15:37c83ec50ea0 4605 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4606 "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
whismanoid 15:37c83ec50ea0 4607 max541_midscale_V, max541.VRef);
whismanoid 15:37c83ec50ea0 4608 // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
whismanoid 15:37c83ec50ea0 4609 voltageV = 1.0f;
whismanoid 15:37c83ec50ea0 4610 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4611 }
whismanoid 15:37c83ec50ea0 4612 else {
whismanoid 15:37c83ec50ea0 4613 // %D -- print MAX541 DAC status
whismanoid 15:37c83ec50ea0 4614 cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n",
whismanoid 15:37c83ec50ea0 4615 max541.Get_Code(), max541.Get_Voltage(), max541.VRef);
whismanoid 15:37c83ec50ea0 4616 }
whismanoid 15:37c83ec50ea0 4617 }
whismanoid 15:37c83ec50ea0 4618 break;
whismanoid 15:37c83ec50ea0 4619 #endif
whismanoid 15:37c83ec50ea0 4620
whismanoid 15:37c83ec50ea0 4621 //
whismanoid 15:37c83ec50ea0 4622 #if HAS_I2C // SUPPORT_I2C
whismanoid 15:37c83ec50ea0 4623 case 'I': case 'i':
whismanoid 15:37c83ec50ea0 4624 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 4625 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 4626 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 4627 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 4628 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 4629 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 4630 // get next character
whismanoid 15:37c83ec50ea0 4631 // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7
whismanoid 15:37c83ec50ea0 4632 cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7);
whismanoid 15:37c83ec50ea0 4633 // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count
whismanoid 15:37c83ec50ea0 4634 g_I2C_read_count = 0; // read count must be reset every command
whismanoid 15:37c83ec50ea0 4635 cmdLine.parse_byte_dec("RD", g_I2C_read_count);
whismanoid 15:37c83ec50ea0 4636 // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress
whismanoid 15:37c83ec50ea0 4637 cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress);
whismanoid 15:37c83ec50ea0 4638 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 4639 {
whismanoid 15:37c83ec50ea0 4640 case 'P': case 'p':
whismanoid 15:37c83ec50ea0 4641 {
whismanoid 15:37c83ec50ea0 4642 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 4643 HuntAttachedI2CDevices(cmdLine, 0x03, 0x77);
whismanoid 15:37c83ec50ea0 4644 }
whismanoid 15:37c83ec50ea0 4645 break;
whismanoid 15:37c83ec50ea0 4646 case 'C': case 'c':
whismanoid 15:37c83ec50ea0 4647 {
whismanoid 15:37c83ec50ea0 4648 bool isUpdatedI2CConfig = false;
whismanoid 15:37c83ec50ea0 4649 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 4650 // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz
whismanoid 15:37c83ec50ea0 4651 if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz))
whismanoid 15:37c83ec50ea0 4652 {
whismanoid 15:37c83ec50ea0 4653 isUpdatedI2CConfig = true;
whismanoid 15:37c83ec50ea0 4654 // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 4655 if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 4656 {
whismanoid 15:37c83ec50ea0 4657 g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 4658 }
whismanoid 15:37c83ec50ea0 4659 if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 4660 {
whismanoid 15:37c83ec50ea0 4661 g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 4662 }
whismanoid 15:37c83ec50ea0 4663 }
whismanoid 15:37c83ec50ea0 4664 if (isUpdatedI2CConfig)
whismanoid 15:37c83ec50ea0 4665 {
whismanoid 15:37c83ec50ea0 4666 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4667 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4668 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4669 i2cMaster.start();
whismanoid 15:37c83ec50ea0 4670 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 4671 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4672 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4673 "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 15:37c83ec50ea0 4674 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 15:37c83ec50ea0 4675 (g_I2C_SCL_Hz / 1000.));
whismanoid 15:37c83ec50ea0 4676 i2cMaster.start();
whismanoid 15:37c83ec50ea0 4677 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 4678 }
whismanoid 15:37c83ec50ea0 4679 }
whismanoid 15:37c83ec50ea0 4680 break;
whismanoid 15:37c83ec50ea0 4681 case 'W': case 'w':
whismanoid 15:37c83ec50ea0 4682 {
whismanoid 15:37c83ec50ea0 4683 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4684 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4685 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4686 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 4687 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4688 #define MAX_I2C_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 4689 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 4690 static char mosiData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4691 static char misoData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4692 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 4693 MAX_I2C_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 4694 {
whismanoid 15:37c83ec50ea0 4695 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 4696 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4697 "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->",
whismanoid 15:37c83ec50ea0 4698 g_I2C_deviceAddress7,
whismanoid 15:37c83ec50ea0 4699 (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count);
whismanoid 15:37c83ec50ea0 4700 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 4701 {
whismanoid 15:37c83ec50ea0 4702 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 4703 }
whismanoid 15:37c83ec50ea0 4704 //
whismanoid 15:37c83ec50ea0 4705 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 4706 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 4707 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4708 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 4709 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 4710 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 4711 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 4712 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4713 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4714 // /* 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 4715 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 4716 const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4717 unsigned int misoLength = 0;
whismanoid 15:37c83ec50ea0 4718 bool repeated = (g_I2C_read_count > 0);
whismanoid 15:37c83ec50ea0 4719 //
whismanoid 15:37c83ec50ea0 4720 int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated);
whismanoid 15:37c83ec50ea0 4721 switch (writeStatus)
whismanoid 15:37c83ec50ea0 4722 {
whismanoid 15:37c83ec50ea0 4723 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 4724 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 4725 default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 4726 writeStatus);
whismanoid 15:37c83ec50ea0 4727 }
whismanoid 15:37c83ec50ea0 4728 if (repeated)
whismanoid 15:37c83ec50ea0 4729 {
whismanoid 15:37c83ec50ea0 4730 int readStatus =
whismanoid 15:37c83ec50ea0 4731 i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false);
whismanoid 15:37c83ec50ea0 4732 switch (readStatus)
whismanoid 15:37c83ec50ea0 4733 {
whismanoid 15:37c83ec50ea0 4734 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 4735 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 4736 default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 4737 readStatus);
whismanoid 15:37c83ec50ea0 4738 }
whismanoid 15:37c83ec50ea0 4739 }
whismanoid 15:37c83ec50ea0 4740 //
whismanoid 15:37c83ec50ea0 4741 if (misoLength > 0)
whismanoid 15:37c83ec50ea0 4742 {
whismanoid 15:37c83ec50ea0 4743 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 4744 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 4745 for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count;
whismanoid 15:37c83ec50ea0 4746 byteIndex++)
whismanoid 15:37c83ec50ea0 4747 {
whismanoid 15:37c83ec50ea0 4748 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 4749 }
whismanoid 15:37c83ec50ea0 4750 }
whismanoid 15:37c83ec50ea0 4751 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 4752 }
whismanoid 15:37c83ec50ea0 4753 }
whismanoid 15:37c83ec50ea0 4754 break;
whismanoid 15:37c83ec50ea0 4755 case 'R': case 'r':
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 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 4761 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 4762 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 4763 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4764 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 4765 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 4766 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 4767 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 4768 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4769 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4770 // /* 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 4771 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 4772 }
whismanoid 15:37c83ec50ea0 4773 break;
whismanoid 15:37c83ec50ea0 4774 case '^':
whismanoid 15:37c83ec50ea0 4775 {
whismanoid 15:37c83ec50ea0 4776 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4777 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4778 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4779 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 4780 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 4781 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 4782 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4783 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 4784 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 4785 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 4786 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 4787 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4788 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4789 // /* 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 4790 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 4791 }
whismanoid 15:37c83ec50ea0 4792 break;
whismanoid 15:37c83ec50ea0 4793 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 4794 break;
whismanoid 15:37c83ec50ea0 4795 #endif
whismanoid 15:37c83ec50ea0 4796 //
whismanoid 15:37c83ec50ea0 4797 #if HAS_SPI // SUPPORT_SPI
whismanoid 15:37c83ec50ea0 4798 case 'S': case 's':
whismanoid 15:37c83ec50ea0 4799 {
whismanoid 15:37c83ec50ea0 4800 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 4801 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 4802 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 4803 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 4804 //
whismanoid 15:37c83ec50ea0 4805 // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d
whismanoid 15:37c83ec50ea0 4806 bool isUpdatedSPIConfig = false;
whismanoid 15:37c83ec50ea0 4807 // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2
whismanoid 15:37c83ec50ea0 4808 // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1
whismanoid 15:37c83ec50ea0 4809 if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2))
whismanoid 15:37c83ec50ea0 4810 {
whismanoid 15:37c83ec50ea0 4811 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 4812 }
whismanoid 15:37c83ec50ea0 4813 if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1))
whismanoid 15:37c83ec50ea0 4814 {
whismanoid 15:37c83ec50ea0 4815 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 4816 }
whismanoid 15:37c83ec50ea0 4817 if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1))
whismanoid 15:37c83ec50ea0 4818 {
whismanoid 15:37c83ec50ea0 4819 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 4820 }
whismanoid 15:37c83ec50ea0 4821 // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz
whismanoid 15:37c83ec50ea0 4822 if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz))
whismanoid 15:37c83ec50ea0 4823 {
whismanoid 15:37c83ec50ea0 4824 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 4825 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 4826 if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 4827 {
whismanoid 15:37c83ec50ea0 4828 g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 4829 }
whismanoid 15:37c83ec50ea0 4830 if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 4831 {
whismanoid 15:37c83ec50ea0 4832 g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 4833 }
whismanoid 15:37c83ec50ea0 4834 }
whismanoid 15:37c83ec50ea0 4835 // Update SPI configuration
whismanoid 15:37c83ec50ea0 4836 if (isUpdatedSPIConfig)
whismanoid 15:37c83ec50ea0 4837 {
whismanoid 15:37c83ec50ea0 4838 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 4839 spi_cs = g_SPI_cs_state;
whismanoid 15:37c83ec50ea0 4840 spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0
whismanoid 15:37c83ec50ea0 4841 #if APPLICATION_MAX5715
whismanoid 15:37c83ec50ea0 4842 g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 4843 #elif APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 4844 g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 4845 #elif APPLICATION_MAX5171
whismanoid 15:37c83ec50ea0 4846 g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 4847 #elif APPLICATION_MAX11410
whismanoid 15:37c83ec50ea0 4848 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 4849 #elif APPLICATION_MAX12345
whismanoid 15:37c83ec50ea0 4850 g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 4851 #else
whismanoid 15:37c83ec50ea0 4852 spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 15:37c83ec50ea0 4853 #endif
whismanoid 15:37c83ec50ea0 4854 //
whismanoid 15:37c83ec50ea0 4855 double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 4856 int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate
whismanoid 15:37c83ec50ea0 4857 double actual_SCLK_Hz = SystemCoreClock / actual_divisor;
whismanoid 15:37c83ec50ea0 4858 //
whismanoid 15:37c83ec50ea0 4859 // 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 4860 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4861 "\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 4862 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 15:37c83ec50ea0 4863 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0),
whismanoid 15:37c83ec50ea0 4864 g_SPI_cs_state,
whismanoid 15:37c83ec50ea0 4865 g_SPI_SCLK_Hz,
whismanoid 15:37c83ec50ea0 4866 (g_SPI_SCLK_Hz / 1000000.),
whismanoid 15:37c83ec50ea0 4867 ((double)(SystemCoreClock / 1000000.)),
whismanoid 15:37c83ec50ea0 4868 ideal_divisor,
whismanoid 15:37c83ec50ea0 4869 (actual_SCLK_Hz / 1000000.)
whismanoid 15:37c83ec50ea0 4870 );
whismanoid 15:37c83ec50ea0 4871 }
whismanoid 15:37c83ec50ea0 4872 // get next character
whismanoid 15:37c83ec50ea0 4873 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 4874 {
whismanoid 15:37c83ec50ea0 4875 case 'C': case 's':
whismanoid 15:37c83ec50ea0 4876 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 4877 break;
whismanoid 15:37c83ec50ea0 4878 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 4879 // %SD -- SPI diagnostic messages enable
whismanoid 15:37c83ec50ea0 4880 if (g_MAX5719_device.onSPIprint) {
whismanoid 15:37c83ec50ea0 4881 g_MAX5719_device.onSPIprint = NULL;
whismanoid 15:37c83ec50ea0 4882 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') != None is false
whismanoid 15:37c83ec50ea0 4883 }
whismanoid 15:37c83ec50ea0 4884 else {
whismanoid 15:37c83ec50ea0 4885 void onSPIprint_handler(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]);
whismanoid 15:37c83ec50ea0 4886 g_MAX5719_device.onSPIprint = onSPIprint_handler;
whismanoid 15:37c83ec50ea0 4887 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') is false
whismanoid 15:37c83ec50ea0 4888 }
whismanoid 15:37c83ec50ea0 4889 break;
whismanoid 15:37c83ec50ea0 4890 case 'W': case 'R': case 'w': case 'r':
whismanoid 15:37c83ec50ea0 4891 {
whismanoid 15:37c83ec50ea0 4892 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 4893 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 4894 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4895 #define MAX_SPI_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 4896 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 4897 static char mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4898 static char misoData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4899 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 4900 MAX_SPI_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 4901 {
whismanoid 15:37c83ec50ea0 4902 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 4903 cmdLine.serial().printf("\r\nSPI");
whismanoid 15:37c83ec50ea0 4904 if (byteCount > 7) {
whismanoid 15:37c83ec50ea0 4905 cmdLine.serial().printf(" byteCount:%d", byteCount);
whismanoid 15:37c83ec50ea0 4906 }
whismanoid 15:37c83ec50ea0 4907 cmdLine.serial().printf(" MOSI->");
whismanoid 15:37c83ec50ea0 4908 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 4909 {
whismanoid 15:37c83ec50ea0 4910 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 4911 }
whismanoid 15:37c83ec50ea0 4912 spi_cs = 0;
whismanoid 15:37c83ec50ea0 4913 unsigned int numBytesTransferred =
whismanoid 15:37c83ec50ea0 4914 spi.write(mosiData, byteCount, misoData, byteCount);
whismanoid 15:37c83ec50ea0 4915 spi_cs = 1;
whismanoid 15:37c83ec50ea0 4916 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 4917 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 4918 for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred;
whismanoid 15:37c83ec50ea0 4919 byteIndex++)
whismanoid 15:37c83ec50ea0 4920 {
whismanoid 15:37c83ec50ea0 4921 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 4922 }
whismanoid 15:37c83ec50ea0 4923 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 4924 }
whismanoid 15:37c83ec50ea0 4925 }
whismanoid 15:37c83ec50ea0 4926 break;
whismanoid 15:37c83ec50ea0 4927 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 4928 } // case 'S': // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 4929 break;
whismanoid 15:37c83ec50ea0 4930 #endif
whismanoid 15:37c83ec50ea0 4931 //
whismanoid 15:37c83ec50ea0 4932 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 4933 } // switch(cmdLine[1])
whismanoid 15:37c83ec50ea0 4934 } // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 15:37c83ec50ea0 4935 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 15:37c83ec50ea0 4936
whismanoid 15:37c83ec50ea0 4937 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 4938 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 4939 void main_menu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 4940 {
whismanoid 9:45f98573eb6d 4941 // process command line
whismanoid 31:47eee7e0cc2d 4942 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 4943 if (g_Run_command_table_running == false) {
whismanoid 31:47eee7e0cc2d 4944 cmdLine.serial().printf("\r\nCmdLine buf:\"%s\"\r\n", cmdLine.str());
whismanoid 31:47eee7e0cc2d 4945 } // if (g_Run_command_table_running)
whismanoid 31:47eee7e0cc2d 4946 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 4947 if (g_Run_command_table_running == false) {
whismanoid 31:47eee7e0cc2d 4948 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 4949
whismanoid 4:d9b05924ad4c 4950 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 31:47eee7e0cc2d 4951 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 4952 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 4953 // If datalog is free running, halt on any possible received command
whismanoid 17:9397ea3ea7e9 4954 if (Datalogger_Trigger != trigger_Halt) {
whismanoid 4:d9b05924ad4c 4955 Datalogger_Trigger = trigger_Halt;
whismanoid 9:45f98573eb6d 4956 cmdLine.serial().printf("Datalog stopped by USB command input\r\n");
whismanoid 9:45f98573eb6d 4957 cmdLine.serial().printf("Restart datalog by sending LR\r\n");
whismanoid 4:d9b05924ad4c 4958 }
whismanoid 31:47eee7e0cc2d 4959 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 4960 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 4961
whismanoid 4:d9b05924ad4c 4962 // DIAGNOSTIC: print line buffer
whismanoid 4:d9b05924ad4c 4963 //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str());
whismanoid 4:d9b05924ad4c 4964 //
whismanoid 4:d9b05924ad4c 4965 switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 4966 {
whismanoid 4:d9b05924ad4c 4967 case '?':
whismanoid 4:d9b05924ad4c 4968 main_menu_status(cmdLine);
whismanoid 4:d9b05924ad4c 4969 main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 4970 // print command prompt
whismanoid 4:d9b05924ad4c 4971 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 4972 break;
whismanoid 4:d9b05924ad4c 4973 case '\r': case '\n': // ignore blank line
whismanoid 4:d9b05924ad4c 4974 case '\0': // ignore empty line
whismanoid 30:07197a430869 4975 main_menu_status(cmdLine);
whismanoid 30:07197a430869 4976 //~ main_menu_help(cmdLine);
whismanoid 30:07197a430869 4977 // print command prompt
whismanoid 30:07197a430869 4978 //cmdLine.serial().printf("\r\n>");
whismanoid 30:07197a430869 4979 break;
whismanoid 4:d9b05924ad4c 4980 case '#': // ignore comment line
whismanoid 4:d9b05924ad4c 4981 // # -- lines beginning with # are comments
whismanoid 30:07197a430869 4982 //
whismanoid 30:07197a430869 4983 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 4984 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in main_menu_onEOLcommandParser
whismanoid 30:07197a430869 4985 // # command handler update gstrRemarkText buffer instead of just ignoring the remark
whismanoid 30:07197a430869 4986 //
whismanoid 30:07197a430869 4987 // ignore extra spaces before the remark
whismanoid 30:07197a430869 4988 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 30:07197a430869 4989 int argIndex;
whismanoid 30:07197a430869 4990 for (argIndex = 1; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 4991 {
whismanoid 30:07197a430869 4992 if (cmdLine[argIndex] == ' ') break;
whismanoid 30:07197a430869 4993 }
whismanoid 30:07197a430869 4994 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 4995 {
whismanoid 30:07197a430869 4996 if (cmdLine[argIndex] != ' ') break;
whismanoid 30:07197a430869 4997 }
whismanoid 30:07197a430869 4998 //
whismanoid 30:07197a430869 4999 strncpy(gstrRemarkText, cmdLine.str()+argIndex, gstrRemarkTextLASTINDEX+1);
whismanoid 30:07197a430869 5000 // do not exceed string buffer limit; keep sentinel null character at end of buffer
whismanoid 30:07197a430869 5001 gstrRemarkText[gstrRemarkTextLASTINDEX] = '\0';
whismanoid 30:07197a430869 5002 for (int index = 0; index < gstrRemarkTextLASTINDEX; index++)
whismanoid 30:07197a430869 5003 {
whismanoid 30:07197a430869 5004 if ((gstrRemarkText[index]) == '\0') break; // null character at end of string
whismanoid 30:07197a430869 5005 if ((gstrRemarkText[index]) < 0x20) {
whismanoid 30:07197a430869 5006 // replace non-printing characters with _
whismanoid 30:07197a430869 5007 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 5008 continue;
whismanoid 30:07197a430869 5009 }
whismanoid 30:07197a430869 5010 if ((gstrRemarkText[index]) >= 0x7F) {
whismanoid 30:07197a430869 5011 // replace non-printing characters with _
whismanoid 30:07197a430869 5012 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 5013 continue;
whismanoid 30:07197a430869 5014 }
whismanoid 30:07197a430869 5015 switch(gstrRemarkText[index])
whismanoid 30:07197a430869 5016 {
whismanoid 30:07197a430869 5017 case ',':
whismanoid 30:07197a430869 5018 // replace , with ;
whismanoid 30:07197a430869 5019 gstrRemarkText[index] = ';';
whismanoid 30:07197a430869 5020 break;
whismanoid 30:07197a430869 5021 case '"':
whismanoid 30:07197a430869 5022 // replace " with '
whismanoid 30:07197a430869 5023 gstrRemarkText[index] = '\'';
whismanoid 30:07197a430869 5024 break;
whismanoid 30:07197a430869 5025 case '\\':
whismanoid 30:07197a430869 5026 // replace \ with /
whismanoid 30:07197a430869 5027 gstrRemarkText[index] = '/';
whismanoid 30:07197a430869 5028 break;
whismanoid 30:07197a430869 5029 }
whismanoid 30:07197a430869 5030 }
whismanoid 30:07197a430869 5031 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 5032 //
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 4:d9b05924ad4c 5035 main_menu_status(cmdLine);
whismanoid 31:47eee7e0cc2d 5036 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 5037 //~ main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 5038 // print command prompt
whismanoid 4:d9b05924ad4c 5039 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 5040 break;
whismanoid 4:d9b05924ad4c 5041 #if ECHO_EOF_ON_EOL
whismanoid 4:d9b05924ad4c 5042 case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file
whismanoid 4:d9b05924ad4c 5043 cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 5044 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 5045 break;
whismanoid 4:d9b05924ad4c 5046 case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file
whismanoid 4:d9b05924ad4c 5047 cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 5048 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 5049 break;
whismanoid 4:d9b05924ad4c 5050 #endif
whismanoid 10:04022a61b527 5051 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 5052 case '!': // device init
whismanoid 10:04022a61b527 5053 {
whismanoid 10:04022a61b527 5054 cmdLine.serial().printf("Init");
whismanoid 10:04022a61b527 5055 // call function Init
whismanoid 10:04022a61b527 5056 uint8_t result = g_MAX11410_device.Init();
whismanoid 10:04022a61b527 5057 // cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 5058 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 5059 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 5060 // in command '!' device init, apply list of custom register writes after init
whismanoid 10:04022a61b527 5061 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 5062 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 10:04022a61b527 5063 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 10:04022a61b527 5064 uint32_t regData = custom_reg_init_data[index];
whismanoid 10:04022a61b527 5065 cmdLine.serial().printf("*%s=0x%06.6x",
whismanoid 10:04022a61b527 5066 g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress),
whismanoid 10:04022a61b527 5067 regData
whismanoid 10:04022a61b527 5068 );
whismanoid 10:04022a61b527 5069 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 10:04022a61b527 5070 }
whismanoid 10:04022a61b527 5071 #endif // USE_CUSTOM_REG_INIT
whismanoid 10:04022a61b527 5072 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 5073 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 5074 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 5075 }
whismanoid 10:04022a61b527 5076 break;
whismanoid 10:04022a61b527 5077 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 5078 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 5079 case '.':
whismanoid 4:d9b05924ad4c 5080 {
whismanoid 4:d9b05924ad4c 5081 // . -- SelfTest
whismanoid 4:d9b05924ad4c 5082 cmdLine.serial().printf("SelfTest()");
whismanoid 4:d9b05924ad4c 5083 SelfTest(cmdLine);
whismanoid 4:d9b05924ad4c 5084 }
whismanoid 4:d9b05924ad4c 5085 break;
whismanoid 4:d9b05924ad4c 5086 #endif // USE_SELFTEST
whismanoid 15:37c83ec50ea0 5087 #if 1 // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 5088 case '%':
whismanoid 4:d9b05924ad4c 5089 {
whismanoid 4:d9b05924ad4c 5090 pinsMonitor_submenu_onEOLcommandParser(cmdLine);
whismanoid 4:d9b05924ad4c 5091 }
whismanoid 4:d9b05924ad4c 5092 break; // case '%'
whismanoid 4:d9b05924ad4c 5093 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 9:45f98573eb6d 5094 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 5095 // reuse the Serial_Tester command *regName=regValue
whismanoid 10:04022a61b527 5096 // CODE GENERATOR: generate * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 5097 case '*':
whismanoid 10:04022a61b527 5098 {
whismanoid 10:04022a61b527 5099 // if buffer starts with a regName:
whismanoid 10:04022a61b527 5100 // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))):
whismanoid 10:04022a61b527 5101 // cmdLine.serial().printf(" scan RegName...\r\n");
whismanoid 10:04022a61b527 5102 }
whismanoid 10:04022a61b527 5103 break;
whismanoid 9:45f98573eb6d 5104 #endif // USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 5105 //
whismanoid 10:04022a61b527 5106 #if 1 // USE_AUX_SERIAL_CMD_FORWARDING && (HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL)
whismanoid 10:04022a61b527 5107 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_onEOLcommandParser
whismanoid 10:04022a61b527 5108 case '>':
whismanoid 10:04022a61b527 5109 {
whismanoid 10:04022a61b527 5110 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 5111 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 5112 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 5113 CmdLine& cmdLine_AuxSerial = cmdLine_AUXserial;
whismanoid 10:04022a61b527 5114 Serial& AuxSerial = AUXserial;
whismanoid 10:04022a61b527 5115 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5116 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 5117 CmdLine& cmdLine_AuxSerial = cmdLine_DAPLINKserial;
whismanoid 10:04022a61b527 5118 Serial& AuxSerial = DAPLINKserial;
whismanoid 10:04022a61b527 5119 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5120 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 5121 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5122 //
whismanoid 10:04022a61b527 5123 // >> suppress key=value parsing
whismanoid 10:04022a61b527 5124 bool suppress_parsing = (cmdLine[1] == '>');
whismanoid 10:04022a61b527 5125 if (suppress_parsing == false) {
whismanoid 10:04022a61b527 5126 // int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 5127 if (cmdLine.parse_int_dec("baud", g_auxSerialCom_baud))
whismanoid 10:04022a61b527 5128 {
whismanoid 10:04022a61b527 5129 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- baud rate
whismanoid 10:04022a61b527 5130 cmdLine_AuxSerial.serial().printf("\r\n*** New Baud Rate %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5131 AuxSerial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5132 cmdLine_AuxSerial.serial().printf("\r\n*** Baud Rate was set to %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5133 }
whismanoid 10:04022a61b527 5134 #if 0
whismanoid 10:04022a61b527 5135 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 5136 if (cmdLine.parse_int_dec("tx_wait_echo", g_auxSerialCom_tx_wait_echo))
whismanoid 10:04022a61b527 5137 {
whismanoid 10:04022a61b527 5138 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_wait_echo
whismanoid 10:04022a61b527 5139 //~ cmdLine_AuxSerial.serial().printf("\r\n*** tx_wait_echo was set to %d ***\r\n", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 5140 cmdLine.serial().printf("\r\n tx_wait_echo=%d", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 5141 }
whismanoid 10:04022a61b527 5142 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 5143 if (cmdLine.parse_int_dec("tx_char_delay_ms", g_auxSerialCom_tx_char_delay_ms))
whismanoid 10:04022a61b527 5144 {
whismanoid 10:04022a61b527 5145 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_char_delay_ms
whismanoid 10:04022a61b527 5146 //~ 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 5147 cmdLine.serial().printf("\r\n tx_char_delay_ms=%dms", g_auxSerialCom_tx_char_delay_ms);
whismanoid 10:04022a61b527 5148 }
whismanoid 10:04022a61b527 5149 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 5150 if (cmdLine.parse_int_dec("tx_line_delay_ms", g_auxSerialCom_tx_line_delay_ms))
whismanoid 10:04022a61b527 5151 {
whismanoid 10:04022a61b527 5152 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_line_delay_ms
whismanoid 10:04022a61b527 5153 //~ 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 5154 cmdLine.serial().printf("\r\n tx_line_delay_ms=%dms", g_auxSerialCom_tx_line_delay_ms);
whismanoid 10:04022a61b527 5155 }
whismanoid 10:04022a61b527 5156 #endif
whismanoid 10:04022a61b527 5157 // int g_auxSerialCom_message_ms = 0; //!< capture RX until response timeout?
whismanoid 10:04022a61b527 5158 if (cmdLine.parse_int_dec("message_ms", g_auxSerialCom_message_ms))
whismanoid 10:04022a61b527 5159 {
whismanoid 10:04022a61b527 5160 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 10:04022a61b527 5161 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 5162 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 5163 }
whismanoid 10:04022a61b527 5164 // int g_auxSerialCom_rx_idle_ms = 0; //!< capture RX until idle timeout?
whismanoid 10:04022a61b527 5165 if (cmdLine.parse_int_dec("rx_idle_ms", g_auxSerialCom_rx_idle_ms))
whismanoid 10:04022a61b527 5166 {
whismanoid 10:04022a61b527 5167 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_idle_ms
whismanoid 10:04022a61b527 5168 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_idle_ms was set to %d ***\r\n", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 5169 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 5170 }
whismanoid 10:04022a61b527 5171 // int g_auxSerialCom_rx_max_count = 0; //!< capture RX until max character count?
whismanoid 10:04022a61b527 5172 if (cmdLine.parse_int_dec("rx_max_count", g_auxSerialCom_rx_max_count))
whismanoid 10:04022a61b527 5173 {
whismanoid 10:04022a61b527 5174 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_max_count
whismanoid 10:04022a61b527 5175 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_max_count was set to %d ***\r\n", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 5176 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 5177 }
whismanoid 10:04022a61b527 5178 // int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text char?
whismanoid 10:04022a61b527 5179 if (cmdLine.parse_int_dec("rx_eot", g_auxSerialCom_rx_eot))
whismanoid 10:04022a61b527 5180 {
whismanoid 10:04022a61b527 5181 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_eot
whismanoid 10:04022a61b527 5182 //~ cmdLine_AUXserial.serial().printf("\r\n*** rx_eot was set to %d ***\r\n", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 5183 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 5184 }
whismanoid 10:04022a61b527 5185 }
whismanoid 10:04022a61b527 5186 // Command forwarding to AUX serial TX/RX cmdLine_AuxSerial #257 -- send outgoing_string
whismanoid 10:04022a61b527 5187 char* outgoing_string = (char*)cmdLine.str();
whismanoid 10:04022a61b527 5188 // > use key=value parsing
whismanoid 10:04022a61b527 5189 // >> suppress key=value parsing
whismanoid 10:04022a61b527 5190 if (suppress_parsing) {
whismanoid 10:04022a61b527 5191 cmdLine.serial().printf("\r\n suppress_parsing outgoing_string=\"%s\"", outgoing_string);
whismanoid 10:04022a61b527 5192 outgoing_string++; // skip the first '>'
whismanoid 10:04022a61b527 5193 outgoing_string++; // skip the second '>'
whismanoid 10:04022a61b527 5194 } else {
whismanoid 10:04022a61b527 5195 // TODO: after parsing, key=value pairs should be deleted, but outgoing_string=">xyzzy abc=def"
whismanoid 10:04022a61b527 5196 cmdLine.serial().printf("\r\n after parsing, outgoing_string=\"%s\"", outgoing_string);
whismanoid 10:04022a61b527 5197 outgoing_string++; // skip the first '>'
whismanoid 10:04022a61b527 5198 }
whismanoid 10:04022a61b527 5199 static char rx_string_buf[RX_STRING_BUF_SIZE];
whismanoid 10:04022a61b527 5200 unsigned int rx_string_length = 0;
whismanoid 10:04022a61b527 5201 cmdLine.serial().printf("\r\n >%s\r\n <", outgoing_string);
whismanoid 10:04022a61b527 5202 rx_string_buf[0] = '\0';
whismanoid 10:04022a61b527 5203 rx_string_length = 0;
whismanoid 10:04022a61b527 5204 //
whismanoid 10:04022a61b527 5205 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 5206 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 5207 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 5208 //
whismanoid 10:04022a61b527 5209 // int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 5210 // int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 5211 // int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 5212 // int g_auxSerialCom_rx_idle_ms = 2000; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 5213 // int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 5214 // int g_auxSerialCom_rx_eot = '\r'; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 5215 //~ cmdLine_AuxSerial.serial().printf("\r\n*** TODO forward %s ***\r\n", outgoing_string);
whismanoid 10:04022a61b527 5216 //
whismanoid 10:04022a61b527 5217 // TODO: send whole string or send character-by-character?
whismanoid 10:04022a61b527 5218 cmdLine_AuxSerial.serial().printf("%s", outgoing_string);
whismanoid 10:04022a61b527 5219 cmdLine_AuxSerial.serial().printf("\r\n");
whismanoid 10:04022a61b527 5220 g_auxSerialCom_Timer.start();
whismanoid 10:04022a61b527 5221 g_auxSerialCom_Timer_begin_message_ms = g_auxSerialCom_Timer.read_ms(); // start of message
whismanoid 10:04022a61b527 5222 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 5223 while (rx_string_length < (RX_STRING_BUF_SIZE-1)) {
whismanoid 10:04022a61b527 5224 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_message_ms) > g_auxSerialCom_message_ms) {
whismanoid 10:04022a61b527 5225 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 5226 break;
whismanoid 10:04022a61b527 5227 }
whismanoid 10:04022a61b527 5228 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_rx_idle_ms) > g_auxSerialCom_rx_idle_ms) {
whismanoid 10:04022a61b527 5229 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 5230 break;
whismanoid 10:04022a61b527 5231 }
whismanoid 10:04022a61b527 5232 if (rx_string_length >= g_auxSerialCom_rx_max_count) {
whismanoid 10:04022a61b527 5233 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 5234 break;
whismanoid 10:04022a61b527 5235 }
whismanoid 10:04022a61b527 5236 if (AuxSerial.readable()) {
whismanoid 10:04022a61b527 5237 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 5238 char ch = AuxSerial.getc();
whismanoid 10:04022a61b527 5239 rx_string_buf[rx_string_length++] = ch;
whismanoid 10:04022a61b527 5240 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 10:04022a61b527 5241 cmdLine.serial().printf("%s", &(rx_string_buf[rx_string_length-1]) ); // immediate character echo
whismanoid 10:04022a61b527 5242 if (g_auxSerialCom_rx_eot != aux_serial_cmd_forwarding_rx_eot_not_used) {
whismanoid 10:04022a61b527 5243 if (ch == g_auxSerialCom_rx_eot) {
whismanoid 10:04022a61b527 5244 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 5245 break;
whismanoid 10:04022a61b527 5246 }
whismanoid 10:04022a61b527 5247 }
whismanoid 10:04022a61b527 5248 }
whismanoid 10:04022a61b527 5249 } // end while (rx_string_length < (RX_STRING_BUF_SIZE-1))
whismanoid 10:04022a61b527 5250 #if 1
whismanoid 10:04022a61b527 5251 // print summary. is this needed? we already print aux rx as it is received.
whismanoid 10:04022a61b527 5252 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 10:04022a61b527 5253 cmdLine.serial().printf("\r\n >%s", outgoing_string);
whismanoid 10:04022a61b527 5254 cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 10:04022a61b527 5255 #endif
whismanoid 10:04022a61b527 5256 //
whismanoid 10:04022a61b527 5257 }
whismanoid 10:04022a61b527 5258 break; // case '>'
whismanoid 10:04022a61b527 5259 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 5260 //
whismanoid 4:d9b05924ad4c 5261 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 5262 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 5263 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 5264 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 5265 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible
whismanoid 9:45f98573eb6d 5266 case 'L': case 'l':
whismanoid 4:d9b05924ad4c 5267 {
whismanoid 4:d9b05924ad4c 5268 // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 5269 Datalogger_Trigger = trigger_Halt;
whismanoid 4:d9b05924ad4c 5270 switch (cmdLine[1])
whismanoid 4:d9b05924ad4c 5271 {
whismanoid 17:9397ea3ea7e9 5272 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 5273 case 'T': case 't':
whismanoid 17:9397ea3ea7e9 5274 {
whismanoid 17:9397ea3ea7e9 5275 // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 5276 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 5277 Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 5278 g_timer_interval_counter = 0;
whismanoid 17:9397ea3ea7e9 5279 // TODO: get g_timer_interval_msec from cmdLine
whismanoid 17:9397ea3ea7e9 5280 // g_timer_interval_msec = 500;
whismanoid 17:9397ea3ea7e9 5281 // g_timer_interval_count = 10;
whismanoid 17:9397ea3ea7e9 5282 if (cmdLine.parse_int_dec("count", g_timer_interval_count))
whismanoid 17:9397ea3ea7e9 5283 {
whismanoid 32:80f3e5eb77d4 5284 if (g_timer_interval_count < 1) { g_timer_interval_count = 1; }
whismanoid 17:9397ea3ea7e9 5285 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 5286 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 5287 cmdLine.serial().printf("\r\n g_timer_interval_count=%d", g_timer_interval_count);
whismanoid 17:9397ea3ea7e9 5288 }
whismanoid 17:9397ea3ea7e9 5289 if (cmdLine.parse_int_dec("base", g_timer_interval_msec))
whismanoid 17:9397ea3ea7e9 5290 {
whismanoid 17:9397ea3ea7e9 5291 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 5292 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 5293 cmdLine.serial().printf("\r\n g_timer_interval_msec=%d", g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 5294 }
whismanoid 17:9397ea3ea7e9 5295 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 17:9397ea3ea7e9 5296 }
whismanoid 17:9397ea3ea7e9 5297 break;
whismanoid 17:9397ea3ea7e9 5298 // LIH3 -- Datalog when input high D3
whismanoid 17:9397ea3ea7e9 5299 // LIL6 -- Datalog when input low D6
whismanoid 17:9397ea3ea7e9 5300 case 'I': case 'i':
whismanoid 17:9397ea3ea7e9 5301 {
whismanoid 17:9397ea3ea7e9 5302 // TODO: switch cmdLine[2] configure High or Low, configure input pin
whismanoid 17:9397ea3ea7e9 5303 }
whismanoid 17:9397ea3ea7e9 5304 break;
whismanoid 17:9397ea3ea7e9 5305 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 5306 // L$ count=10 base=500ms addr=xxx data=xxx mask=xxx -- Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 5307 case '$':
whismanoid 17:9397ea3ea7e9 5308 {
whismanoid 17:9397ea3ea7e9 5309 // TODO: scan cmdLine for regAddr, dataMask, testValue
whismanoid 17:9397ea3ea7e9 5310 }
whismanoid 17:9397ea3ea7e9 5311 break;
whismanoid 17:9397ea3ea7e9 5312 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 5313 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 5314 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5315 case '@':
whismanoid 17:9397ea3ea7e9 5316 {
whismanoid 17:9397ea3ea7e9 5317 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5318 int editRowIndex = 0;
whismanoid 17:9397ea3ea7e9 5319 int edit_action = (int)action_noop;
whismanoid 17:9397ea3ea7e9 5320 int edit_digitalOutPin = 0;
whismanoid 17:9397ea3ea7e9 5321 int edit_condition = (int)condition_always;
whismanoid 17:9397ea3ea7e9 5322 int edit_condition_channel = 0;
whismanoid 17:9397ea3ea7e9 5323 double edit_condition_threshold = 0;
whismanoid 17:9397ea3ea7e9 5324 //
whismanoid 17:9397ea3ea7e9 5325 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 17:9397ea3ea7e9 5326 {
whismanoid 17:9397ea3ea7e9 5327 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 17:9397ea3ea7e9 5328 }
whismanoid 17:9397ea3ea7e9 5329 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 17:9397ea3ea7e9 5330 {
whismanoid 17:9397ea3ea7e9 5331 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 17:9397ea3ea7e9 5332 }
whismanoid 17:9397ea3ea7e9 5333 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 17:9397ea3ea7e9 5334 {
whismanoid 17:9397ea3ea7e9 5335 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 17:9397ea3ea7e9 5336 }
whismanoid 17:9397ea3ea7e9 5337 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 17:9397ea3ea7e9 5338 {
whismanoid 17:9397ea3ea7e9 5339 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 17:9397ea3ea7e9 5340 }
whismanoid 17:9397ea3ea7e9 5341 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 17:9397ea3ea7e9 5342 {
whismanoid 17:9397ea3ea7e9 5343 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 17:9397ea3ea7e9 5344 }
whismanoid 17:9397ea3ea7e9 5345 //
whismanoid 17:9397ea3ea7e9 5346 // Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5347 switch (cmdLine[2]) // L@... -- Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5348 {
whismanoid 17:9397ea3ea7e9 5349 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 5350 case '0': case '1': case '2': case '3': case '4':
whismanoid 17:9397ea3ea7e9 5351 case '5': case '6': case '7': case '8': case '9':
whismanoid 17:9397ea3ea7e9 5352 // edit row data
whismanoid 30:07197a430869 5353 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 5354 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 5355 // get row number to edit from cmdLine[2]
whismanoid 17:9397ea3ea7e9 5356 editRowIndex = atoi(cmdLine.str()+2);
whismanoid 30:07197a430869 5357 if ((editRowIndex >= 0) && (editRowIndex < Datalogger_action_table_row_count)) {
whismanoid 30:07197a430869 5358 // update row
whismanoid 30:07197a430869 5359 cmdLine.serial().printf("\r\n replace row %d", editRowIndex);
whismanoid 30:07197a430869 5360 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 5361 edit_action = Datalogger_action_table[editRowIndex].action;
whismanoid 30:07197a430869 5362 edit_digitalOutPin = Datalogger_action_table[editRowIndex].digitalOutPin;
whismanoid 30:07197a430869 5363 edit_condition = Datalogger_action_table[editRowIndex].condition;
whismanoid 30:07197a430869 5364 edit_condition_channel = Datalogger_action_table[editRowIndex].condition_channel;
whismanoid 30:07197a430869 5365 edit_condition_threshold = Datalogger_action_table[editRowIndex].condition_threshold;
whismanoid 30:07197a430869 5366 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 5367 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 30:07197a430869 5368 {
whismanoid 30:07197a430869 5369 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 30:07197a430869 5370 }
whismanoid 30:07197a430869 5371 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 30:07197a430869 5372 {
whismanoid 30:07197a430869 5373 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 30:07197a430869 5374 }
whismanoid 30:07197a430869 5375 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 30:07197a430869 5376 {
whismanoid 30:07197a430869 5377 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 30:07197a430869 5378 }
whismanoid 30:07197a430869 5379 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 30:07197a430869 5380 {
whismanoid 30:07197a430869 5381 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 30:07197a430869 5382 }
whismanoid 30:07197a430869 5383 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 30:07197a430869 5384 {
whismanoid 30:07197a430869 5385 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 30:07197a430869 5386 }
whismanoid 30:07197a430869 5387 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 5388 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 5389 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 5390 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 5391 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 5392 }
whismanoid 30:07197a430869 5393 else if ((editRowIndex == Datalogger_action_table_row_count) && (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX)) {
whismanoid 30:07197a430869 5394 // %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 5395 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 5396 cmdLine.serial().printf("\r\n add next row %d", editRowIndex);
whismanoid 30:07197a430869 5397 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 5398 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 5399 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 5400 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 5401 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 30:07197a430869 5402 //
whismanoid 17:9397ea3ea7e9 5403 }
whismanoid 17:9397ea3ea7e9 5404 }
whismanoid 17:9397ea3ea7e9 5405 break;
whismanoid 17:9397ea3ea7e9 5406 case '+':
whismanoid 17:9397ea3ea7e9 5407 // add a new row at end of table
whismanoid 17:9397ea3ea7e9 5408 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 5409 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 5410 editRowIndex = Datalogger_action_table_row_count;
whismanoid 17:9397ea3ea7e9 5411 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 5412 cmdLine.serial().printf("\r\n add new row %d", editRowIndex);
whismanoid 17:9397ea3ea7e9 5413 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 17:9397ea3ea7e9 5414 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 17:9397ea3ea7e9 5415 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 17:9397ea3ea7e9 5416 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 17:9397ea3ea7e9 5417 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 5418 }
whismanoid 17:9397ea3ea7e9 5419 break;
whismanoid 17:9397ea3ea7e9 5420 case '-':
whismanoid 17:9397ea3ea7e9 5421 // delete row from table
whismanoid 17:9397ea3ea7e9 5422 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 5423 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 5424 if ((cmdLine[3] == '~') && (cmdLine[4] == '~') && (cmdLine[5] == '~')) {
whismanoid 17:9397ea3ea7e9 5425 // L@-~~~ -- delete all rows from table
whismanoid 30:07197a430869 5426 cmdLine.serial().printf("\r\n delete all rows");
whismanoid 17:9397ea3ea7e9 5427 Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 5428 break;
whismanoid 17:9397ea3ea7e9 5429 }
whismanoid 30:07197a430869 5430 else {
whismanoid 30:07197a430869 5431 editRowIndex = atoi(cmdLine.str()+3);
whismanoid 30:07197a430869 5432 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 30:07197a430869 5433 // delete row editRowIndex from Datalogger_action_table
whismanoid 30:07197a430869 5434 for (int i = editRowIndex; i < (Datalogger_action_table_row_count-1); i++)
whismanoid 30:07197a430869 5435 {
whismanoid 30:07197a430869 5436 // copy row i+1 into row i
whismanoid 30:07197a430869 5437 Datalogger_action_table[i].action = Datalogger_action_table[i+1].action;
whismanoid 30:07197a430869 5438 Datalogger_action_table[i].digitalOutPin = Datalogger_action_table[i+1].digitalOutPin;
whismanoid 30:07197a430869 5439 Datalogger_action_table[i].condition = Datalogger_action_table[i+1].condition;
whismanoid 30:07197a430869 5440 Datalogger_action_table[i].condition_channel = Datalogger_action_table[i+1].condition_channel;
whismanoid 30:07197a430869 5441 Datalogger_action_table[i].condition_threshold = Datalogger_action_table[i+1].condition_threshold;
whismanoid 30:07197a430869 5442 }
whismanoid 30:07197a430869 5443 Datalogger_action_table_row_count--;
whismanoid 17:9397ea3ea7e9 5444 }
whismanoid 17:9397ea3ea7e9 5445 }
whismanoid 17:9397ea3ea7e9 5446 break;
whismanoid 30:07197a430869 5447 case '.':
whismanoid 30:07197a430869 5448 // L@. pause the entire Log action table
whismanoid 30:07197a430869 5449 cmdLine.serial().printf("\r\n pause the entire Log action table");
whismanoid 17:9397ea3ea7e9 5450 Datalogger_action_table_enabled = false;
whismanoid 17:9397ea3ea7e9 5451 break;
whismanoid 17:9397ea3ea7e9 5452 case '@':
whismanoid 30:07197a430869 5453 // L@@ enable the entire Log action table
whismanoid 30:07197a430869 5454 cmdLine.serial().printf("\r\n enable the entire Log action table");
whismanoid 17:9397ea3ea7e9 5455 Datalogger_action_table_enabled = true;
whismanoid 17:9397ea3ea7e9 5456 break;
whismanoid 17:9397ea3ea7e9 5457 }
whismanoid 17:9397ea3ea7e9 5458 //
whismanoid 17:9397ea3ea7e9 5459 // Print the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5460 if (Datalogger_action_table_enabled) {
whismanoid 30:07197a430869 5461 // cmdLine.serial().printf("Log action table enabled; L@. to pause");
whismanoid 17:9397ea3ea7e9 5462 }
whismanoid 17:9397ea3ea7e9 5463 else {
whismanoid 30:07197a430869 5464 cmdLine.serial().printf("Log action table paused; L@@ to enable");
whismanoid 17:9397ea3ea7e9 5465 }
whismanoid 17:9397ea3ea7e9 5466 //~ cmdLine.serial().printf("\r\n Datalogger_action_table_row_count=%d", Datalogger_action_table_row_count);
whismanoid 17:9397ea3ea7e9 5467 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 5468 {
whismanoid 17:9397ea3ea7e9 5469 cmdLine.serial().printf("\r\n L@%d", i);
whismanoid 17:9397ea3ea7e9 5470 cmdLine.serial().printf(" act=%d", Datalogger_action_table[i].action);
whismanoid 17:9397ea3ea7e9 5471 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5472 {
whismanoid 17:9397ea3ea7e9 5473 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 5474 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 5475 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5476 break;
whismanoid 29:6a9edb6e973b 5477 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 5478 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 5479 break;
whismanoid 17:9397ea3ea7e9 5480 default:
whismanoid 17:9397ea3ea7e9 5481 case action_noop:
whismanoid 17:9397ea3ea7e9 5482 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 5483 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 5484 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 5485 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 5486 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 5487 break;
whismanoid 17:9397ea3ea7e9 5488 }
whismanoid 17:9397ea3ea7e9 5489 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5490 {
whismanoid 17:9397ea3ea7e9 5491 case condition_always:
whismanoid 17:9397ea3ea7e9 5492 break;
whismanoid 17:9397ea3ea7e9 5493 default:
whismanoid 17:9397ea3ea7e9 5494 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 5495 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 5496 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 5497 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 5498 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 5499 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 5500 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 5501 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 5502 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 5503 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 5504 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 5505 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 5506 cmdLine.serial().printf(" if=%d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 5507 cmdLine.serial().printf(" ch=%d", Datalogger_action_table[i].condition_channel);
whismanoid 17:9397ea3ea7e9 5508 cmdLine.serial().printf(" x=%f", Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5509 break;
whismanoid 17:9397ea3ea7e9 5510 }
whismanoid 17:9397ea3ea7e9 5511 cmdLine.serial().printf(" -- ");
whismanoid 17:9397ea3ea7e9 5512 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5513 {
whismanoid 17:9397ea3ea7e9 5514 case action_noop:
whismanoid 17:9397ea3ea7e9 5515 cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 5516 break;
whismanoid 17:9397ea3ea7e9 5517 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 5518 cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 5519 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5520 break;
whismanoid 17:9397ea3ea7e9 5521 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 5522 cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 5523 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5524 break;
whismanoid 29:6a9edb6e973b 5525 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 5526 cmdLine.serial().printf("button");
whismanoid 29:6a9edb6e973b 5527 cmdLine.serial().printf(" %d", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 5528 break;
whismanoid 17:9397ea3ea7e9 5529 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 5530 cmdLine.serial().printf("trigger_Halt");
whismanoid 17:9397ea3ea7e9 5531 break;
whismanoid 17:9397ea3ea7e9 5532 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 5533 cmdLine.serial().printf("trigger_FreeRun");
whismanoid 17:9397ea3ea7e9 5534 break;
whismanoid 17:9397ea3ea7e9 5535 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 5536 cmdLine.serial().printf("trigger_Timer");
whismanoid 17:9397ea3ea7e9 5537 // print configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 5538 cmdLine.serial().printf("(%d x %dmsec)", g_timer_interval_count, g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 5539 break;
whismanoid 17:9397ea3ea7e9 5540 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 5541 cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 5542 // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 5543 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 5544 break;
whismanoid 17:9397ea3ea7e9 5545 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 5546 cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 5547 // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 5548 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 5549 break;
whismanoid 17:9397ea3ea7e9 5550 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5551 //~ cmdLine.serial().printf(" condition %d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 5552 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5553 {
whismanoid 17:9397ea3ea7e9 5554 case condition_always:
whismanoid 17:9397ea3ea7e9 5555 cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 5556 break;
whismanoid 17:9397ea3ea7e9 5557 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 5558 cmdLine.serial().printf(" if A%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5559 break;
whismanoid 17:9397ea3ea7e9 5560 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 5561 cmdLine.serial().printf(" if A%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5562 break;
whismanoid 17:9397ea3ea7e9 5563 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 5564 cmdLine.serial().printf(" if A%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5565 break;
whismanoid 17:9397ea3ea7e9 5566 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 5567 cmdLine.serial().printf(" if A%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5568 break;
whismanoid 17:9397ea3ea7e9 5569 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 5570 cmdLine.serial().printf(" if A%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5571 break;
whismanoid 17:9397ea3ea7e9 5572 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 5573 cmdLine.serial().printf(" if A%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5574 break;
whismanoid 17:9397ea3ea7e9 5575 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 5576 cmdLine.serial().printf(" if AIN%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5577 break;
whismanoid 17:9397ea3ea7e9 5578 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 5579 cmdLine.serial().printf(" if AIN%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5580 break;
whismanoid 17:9397ea3ea7e9 5581 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 5582 cmdLine.serial().printf(" if AIN%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5583 break;
whismanoid 17:9397ea3ea7e9 5584 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 5585 cmdLine.serial().printf(" if AIN%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5586 break;
whismanoid 17:9397ea3ea7e9 5587 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 5588 cmdLine.serial().printf(" if AIN%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5589 break;
whismanoid 17:9397ea3ea7e9 5590 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 5591 cmdLine.serial().printf(" if AIN%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5592 break;
whismanoid 17:9397ea3ea7e9 5593 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5594 } // for ...Datalogger_action_table_row_count // Print the contents of Datalogger_action_table
whismanoid 30:07197a430869 5595 cmdLine.serial().printf("\r\n\r\nEdit Log action table (used %d/%d, %d free):",
whismanoid 30:07197a430869 5596 Datalogger_action_table_row_count,
whismanoid 30:07197a430869 5597 ACTION_TABLE_ROW_MAX,
whismanoid 30:07197a430869 5598 (ACTION_TABLE_ROW_MAX - Datalogger_action_table_row_count)
whismanoid 30:07197a430869 5599 );
whismanoid 17:9397ea3ea7e9 5600 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 5601 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 5602 cmdLine.serial().printf("\r\n L@+ act=4 if=1 ch=5 x=12345 -- add new entry at end of table");
whismanoid 17:9397ea3ea7e9 5603 }
whismanoid 17:9397ea3ea7e9 5604 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 5605 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 5606 cmdLine.serial().printf("\r\n L@%d act=4 if=1 ch=5 x=12345 -- edit row %d",
whismanoid 17:9397ea3ea7e9 5607 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 5608 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 5609 cmdLine.serial().printf("\r\n L@-%d -- delete row %d",
whismanoid 17:9397ea3ea7e9 5610 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 5611 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 5612 cmdLine.serial().printf("\r\n L@-~~~ -- delete all rows");
whismanoid 30:07197a430869 5613 if (Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@. -- pause entire Log action table");
whismanoid 30:07197a430869 5614 if (!Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@@ -- enable Log action table");
whismanoid 17:9397ea3ea7e9 5615 }
whismanoid 17:9397ea3ea7e9 5616 //
whismanoid 17:9397ea3ea7e9 5617 } // case L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5618 break;
whismanoid 17:9397ea3ea7e9 5619 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 5620 // LR -- Datalog free run as fast as possible
whismanoid 4:d9b05924ad4c 5621 case 'R': case 'r':
whismanoid 4:d9b05924ad4c 5622 // free run as fast as possible
whismanoid 8:dffee7509bfb 5623 Datalogger_Trigger = trigger_FreeRun;
whismanoid 8:dffee7509bfb 5624 Datalogger_Need_PrintHeader = true;
whismanoid 4:d9b05924ad4c 5625 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 9:45f98573eb6d 5626 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 5627 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 5628 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 5629 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 5630 case 'S': case 's':
whismanoid 9:45f98573eb6d 5631 {
whismanoid 9:45f98573eb6d 5632 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 5633 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 5634 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 5635 )
whismanoid 9:45f98573eb6d 5636 {
whismanoid 9:45f98573eb6d 5637 // it's me
whismanoid 9:45f98573eb6d 5638 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 5639 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 5640 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 5641 {
whismanoid 9:45f98573eb6d 5642 case 'D': case 'd':
whismanoid 9:45f98573eb6d 5643 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Disable;
whismanoid 9:45f98573eb6d 5644 break;
whismanoid 9:45f98573eb6d 5645 case 'L': case 'l':
whismanoid 9:45f98573eb6d 5646 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 5647 break;
whismanoid 9:45f98573eb6d 5648 case 'V': case 'v':
whismanoid 9:45f98573eb6d 5649 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 5650 break;
whismanoid 9:45f98573eb6d 5651 //
whismanoid 9:45f98573eb6d 5652 //
whismanoid 9:45f98573eb6d 5653 // TODO: MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 5654 case 'C': case 'c':
whismanoid 9:45f98573eb6d 5655 {
whismanoid 9:45f98573eb6d 5656 uint8_t hexValue = 0;
whismanoid 9:45f98573eb6d 5657 hexValue = hexValueOfChar(cmdLine[5]) * 0x10 + hexValueOfChar(cmdLine[6]);
whismanoid 9:45f98573eb6d 5658 switch (cmdLine[4])
whismanoid 9:45f98573eb6d 5659 {
whismanoid 9:45f98573eb6d 5660 //
whismanoid 9:45f98573eb6d 5661 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 5662 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34"));
whismanoid 9:45f98573eb6d 5663 case 'F': case 'f':
whismanoid 9:45f98573eb6d 5664 SPI_AIN_Cfg_v_filter_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 5665 break;
whismanoid 9:45f98573eb6d 5666 //
whismanoid 9:45f98573eb6d 5667 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 5668 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 5669 case 'C': case 'c':
whismanoid 9:45f98573eb6d 5670 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 5671 break;
whismanoid 9:45f98573eb6d 5672 //
whismanoid 9:45f98573eb6d 5673 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 5674 // cmdLine.serial().print(F("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00"));
whismanoid 9:45f98573eb6d 5675 case 'P': case 'p':
whismanoid 9:45f98573eb6d 5676 SPI_AIN_Cfg_v_pga_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 5677 break;
whismanoid 9:45f98573eb6d 5678 //
whismanoid 9:45f98573eb6d 5679 // cmdLine.serial().print(F("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar"));
whismanoid 9:45f98573eb6d 5680 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 5681 case 'U': case 'u':
whismanoid 9:45f98573eb6d 5682 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] | 0x40;
whismanoid 9:45f98573eb6d 5683 break;
whismanoid 9:45f98573eb6d 5684 //
whismanoid 9:45f98573eb6d 5685 // cmdLine.serial().print(F("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar"));
whismanoid 9:45f98573eb6d 5686 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 5687 case 'B': case 'b':
whismanoid 9:45f98573eb6d 5688 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] &~ 0x40;
whismanoid 9:45f98573eb6d 5689 break;
whismanoid 9:45f98573eb6d 5690 }
whismanoid 9:45f98573eb6d 5691 break;
whismanoid 9:45f98573eb6d 5692 }
whismanoid 9:45f98573eb6d 5693 //
whismanoid 9:45f98573eb6d 5694 //
whismanoid 9:45f98573eb6d 5695 }
whismanoid 9:45f98573eb6d 5696 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 5697 } // end for channel_index
whismanoid 9:45f98573eb6d 5698 Datalogger_PrintHeader();
whismanoid 9:45f98573eb6d 5699 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 5700 }
whismanoid 9:45f98573eb6d 5701 break;
whismanoid 9:45f98573eb6d 5702 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 5703 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 5704 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 5705 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 5706 // verb: D for disable, V for Voltage, L for LSB
whismanoid 8:dffee7509bfb 5707 case 'A': case 'a':
whismanoid 9:45f98573eb6d 5708 {
whismanoid 9:45f98573eb6d 5709 // all-channel: loop through all valid channel_index, test cmdLine[2] 'is it me'?
whismanoid 9:45f98573eb6d 5710 // for channel_index loop through 0..NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 9:45f98573eb6d 5711 // if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 5712 // || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 5713 // ) {
whismanoid 9:45f98573eb6d 5714 // // it's me
whismanoid 9:45f98573eb6d 5715 // // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 5716 // // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 5717 // } end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 5718 // } end for channel_index
whismanoid 9:45f98573eb6d 5719 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 5720 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 5721 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 5722 )
whismanoid 9:45f98573eb6d 5723 {
whismanoid 9:45f98573eb6d 5724 // it's me
whismanoid 9:45f98573eb6d 5725 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 5726 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 5727 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 5728 {
whismanoid 9:45f98573eb6d 5729 case 'D': case 'd':
whismanoid 9:45f98573eb6d 5730 Platform_Enable_ch[channel_index] = Platform_AIN_Disable;
whismanoid 9:45f98573eb6d 5731 break;
whismanoid 9:45f98573eb6d 5732 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 5733 case 'L': case 'l':
whismanoid 9:45f98573eb6d 5734 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 5735 break;
whismanoid 9:45f98573eb6d 5736 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 5737 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 5738 case 'V': case 'v':
whismanoid 9:45f98573eb6d 5739 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 5740 break;
whismanoid 9:45f98573eb6d 5741 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 5742 }
whismanoid 9:45f98573eb6d 5743 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 5744 } // end for channel_index
whismanoid 10:04022a61b527 5745 // Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 5746 if (Datalogger_enable_serial) {
whismanoid 9:45f98573eb6d 5747 Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 5748 }
whismanoid 9:45f98573eb6d 5749 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 5750 if (Datalogger_enable_AUXserial) {
whismanoid 9:45f98573eb6d 5751 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 9:45f98573eb6d 5752 }
whismanoid 9:45f98573eb6d 5753 # endif // HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 5754 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 5755 if (Datalogger_enable_DAPLINKserial) {
whismanoid 9:45f98573eb6d 5756 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 9:45f98573eb6d 5757 }
whismanoid 9:45f98573eb6d 5758 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 5759 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 5760 }
whismanoid 8:dffee7509bfb 5761 break;
whismanoid 9:45f98573eb6d 5762 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 5763 case '>':
whismanoid 9:45f98573eb6d 5764 // L>A -- Datalogger_enable_AUXserial
whismanoid 9:45f98573eb6d 5765 // L>D -- Datalogger_enable_DAPLINKserial
whismanoid 9:45f98573eb6d 5766 // L>S -- Datalogger_enable_serial
whismanoid 9:45f98573eb6d 5767 switch (cmdLine[2])
whismanoid 9:45f98573eb6d 5768 {
whismanoid 9:45f98573eb6d 5769 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 5770 case 'A': case 'a':
whismanoid 9:45f98573eb6d 5771 Datalogger_enable_AUXserial = !Datalogger_enable_AUXserial;
whismanoid 9:45f98573eb6d 5772 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 5773 break;
whismanoid 8:dffee7509bfb 5774 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 5775 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 5776 case 'D': case 'd':
whismanoid 9:45f98573eb6d 5777 Datalogger_enable_DAPLINKserial = !Datalogger_enable_DAPLINKserial;
whismanoid 9:45f98573eb6d 5778 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 5779 break;
whismanoid 8:dffee7509bfb 5780 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 5781 case 'S': case 's':
whismanoid 9:45f98573eb6d 5782 Datalogger_enable_serial = !Datalogger_enable_serial;
whismanoid 9:45f98573eb6d 5783 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 5784 break;
whismanoid 9:45f98573eb6d 5785 }
whismanoid 9:45f98573eb6d 5786 break; // case '>' L>S serial enable toggle
whismanoid 28:a9a3a9db592b 5787 default:
whismanoid 28:a9a3a9db592b 5788 // TODO: L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 5789 //
whismanoid 28:a9a3a9db592b 5790 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 5791 #if 1 // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 5792 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 5793 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 5794 //
whismanoid 28:a9a3a9db592b 5795 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 28:a9a3a9db592b 5796 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 28:a9a3a9db592b 5797 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 5798 //
whismanoid 28:a9a3a9db592b 5799 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 28:a9a3a9db592b 5800 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 5801 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 5802 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 5803 //
whismanoid 28:a9a3a9db592b 5804 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 5805 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 28:a9a3a9db592b 5806 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 5807 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 5808 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 5809 //
whismanoid 28:a9a3a9db592b 5810 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 5811 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 5812 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 5813 //
whismanoid 28:a9a3a9db592b 5814 //
whismanoid 28:a9a3a9db592b 5815 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 5816 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 28:a9a3a9db592b 5817 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 5818 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 5819 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 28:a9a3a9db592b 5820 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 28:a9a3a9db592b 5821 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 28:a9a3a9db592b 5822 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 28:a9a3a9db592b 5823 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 28:a9a3a9db592b 5824 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 28:a9a3a9db592b 5825 //
whismanoid 28:a9a3a9db592b 5826 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 28:a9a3a9db592b 5827 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 28:a9a3a9db592b 5828 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 28:a9a3a9db592b 5829 //
whismanoid 28:a9a3a9db592b 5830 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 5831 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 28:a9a3a9db592b 5832 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 28:a9a3a9db592b 5833 //
whismanoid 28:a9a3a9db592b 5834 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 5835 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 28:a9a3a9db592b 5836 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 5837 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 28:a9a3a9db592b 5838 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 5839 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 28:a9a3a9db592b 5840 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 5841 //
whismanoid 28:a9a3a9db592b 5842 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 28:a9a3a9db592b 5843 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 28:a9a3a9db592b 5844 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 28:a9a3a9db592b 5845 //
whismanoid 28:a9a3a9db592b 5846 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 5847 //
whismanoid 28:a9a3a9db592b 5848 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 28:a9a3a9db592b 5849 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 28:a9a3a9db592b 5850 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 5851 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 5852 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 28:a9a3a9db592b 5853 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 5854 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 28:a9a3a9db592b 5855 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 5856 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 5857 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 28:a9a3a9db592b 5858 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 5859 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 28:a9a3a9db592b 5860 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 5861 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 28:a9a3a9db592b 5862 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 5863 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 5864 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 28:a9a3a9db592b 5865 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 5866 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 5867 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 5868 # if HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 5869 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 5870 # endif // HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 5871 # if HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 5872 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 5873 # endif // HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 5874 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 5875 //
whismanoid 28:a9a3a9db592b 5876 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 5877 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 5878 break;
whismanoid 17:9397ea3ea7e9 5879 } // switch (cmdLine[1]) inside case 'L'
whismanoid 4:d9b05924ad4c 5880 }
whismanoid 4:d9b05924ad4c 5881 break; // case 'L'
whismanoid 4:d9b05924ad4c 5882 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 5883 //
whismanoid 4:d9b05924ad4c 5884 // Application-specific commands here
whismanoid 4:d9b05924ad4c 5885 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 5886 //
whismanoid 4:d9b05924ad4c 5887 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 5888 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 5889
whismanoid 4:d9b05924ad4c 5890 //
whismanoid 4:d9b05924ad4c 5891 // TODO1: add new commands here
whismanoid 4:d9b05924ad4c 5892 //
whismanoid 4:d9b05924ad4c 5893 default:
whismanoid 4:d9b05924ad4c 5894 #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 5895 extern bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5715.cpp
whismanoid 4:d9b05924ad4c 5896 if (!MAX5715_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 5897 #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 5898 extern bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11131.cpp
whismanoid 4:d9b05924ad4c 5899 if (!MAX11131_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 5900 #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 5901 extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp
whismanoid 4:d9b05924ad4c 5902 if (!MAX5171_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 5903 #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 5904 extern bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp
whismanoid 4:d9b05924ad4c 5905 if (!MAX11410_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 5906 #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 5907 extern bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX12345.cpp
whismanoid 4:d9b05924ad4c 5908 if (!MAX12345_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 5909 #else
whismanoid 4:d9b05924ad4c 5910 if (0) // not_handled_by_device_submenu
whismanoid 4:d9b05924ad4c 5911 #endif
whismanoid 4:d9b05924ad4c 5912 {
whismanoid 4:d9b05924ad4c 5913 cmdLine.serial().printf("\r\n unknown command ");
whismanoid 4:d9b05924ad4c 5914 //~ cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 5915 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 5916 cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n",
whismanoid 4:d9b05924ad4c 5917 cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 5918 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 5919 }
whismanoid 4:d9b05924ad4c 5920 } // switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 5921 //
whismanoid 31:47eee7e0cc2d 5922 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 5923 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 5924 // print command prompt
whismanoid 8:dffee7509bfb 5925 // print_command_prompt();
whismanoid 8:dffee7509bfb 5926 cmdLine.serial().printf("\r\n> ");
whismanoid 31:47eee7e0cc2d 5927 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 5928 }
whismanoid 4:d9b05924ad4c 5929 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 5930
whismanoid 4:d9b05924ad4c 5931 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 5932 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 5933 void Datalogger_PrintHeader(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 5934 {
whismanoid 4:d9b05924ad4c 5935 // column header banner for csv data columns
whismanoid 4:d9b05924ad4c 5936 int field_index = 0;
whismanoid 4:d9b05924ad4c 5937 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 5938 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 5939 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 4:d9b05924ad4c 5940 continue;
whismanoid 4:d9b05924ad4c 5941 }
whismanoid 4:d9b05924ad4c 5942 // comma between fields
whismanoid 4:d9b05924ad4c 5943 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 5944 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 5945 }
whismanoid 10:04022a61b527 5946 field_index++;
whismanoid 4:d9b05924ad4c 5947 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 5948 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 5949 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 4:d9b05924ad4c 5950 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 4:d9b05924ad4c 5951 cmdLine.serial().printf("\"AIN%d-%d_BIP", channel_index, channel_index+1);
whismanoid 4:d9b05924ad4c 5952 }
whismanoid 4:d9b05924ad4c 5953 else {
whismanoid 4:d9b05924ad4c 5954 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 5955 }
whismanoid 4:d9b05924ad4c 5956 #else // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 5957 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 5958 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 5959 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_LSB) {
whismanoid 4:d9b05924ad4c 5960 // _LSB column header suffix
whismanoid 13:184a08909405 5961 cmdLine.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 5962 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5963 cmdLine_DAPLINKserial.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 5964 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 5965 }
whismanoid 10:04022a61b527 5966 else if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_Volt) {
whismanoid 4:d9b05924ad4c 5967 // _V column header suffix
whismanoid 13:184a08909405 5968 cmdLine.serial().printf("_V");
whismanoid 4:d9b05924ad4c 5969 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5970 cmdLine_DAPLINKserial.serial().printf("_V");
whismanoid 4:d9b05924ad4c 5971 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 5972 }
whismanoid 13:184a08909405 5973 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 5974 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 5975 if (SPI_AIN_customChannelHeader_ch[channel_index] && SPI_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 5976 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 5977 cmdLine.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 5978 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5979 cmdLine_DAPLINKserial.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 5980 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5981 } else {
whismanoid 13:184a08909405 5982 // no custom channel name for this channel
whismanoid 13:184a08909405 5983 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 5984 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5985 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 5986 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5987 }
whismanoid 13:184a08909405 5988 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 5989 // close quote
whismanoid 13:184a08909405 5990 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 5991 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5992 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 5993 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 5994 }
whismanoid 4:d9b05924ad4c 5995
whismanoid 4:d9b05924ad4c 5996 #if VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 5997 // PART_ID field: Device ID Validation
whismanoid 4:d9b05924ad4c 5998 cmdLine.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 5999 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6000 cmdLine_DAPLINKserial.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 6001 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6002 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 6003 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 6004 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 6005 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6006 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 6007 continue;
whismanoid 9:45f98573eb6d 6008 }
whismanoid 4:d9b05924ad4c 6009 // comma between fields
whismanoid 4:d9b05924ad4c 6010 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 6011 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 6012 }
whismanoid 9:45f98573eb6d 6013 field_index++;
whismanoid 4:d9b05924ad4c 6014 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 6015 cmdLine.serial().printf("\"A%d", channel_index);
whismanoid 9:45f98573eb6d 6016 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 9:45f98573eb6d 6017 // _LSB column header suffix
whismanoid 13:184a08909405 6018 cmdLine.serial().printf("_LSB");
whismanoid 9:45f98573eb6d 6019 }
whismanoid 9:45f98573eb6d 6020 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 6021 // _V column header suffix
whismanoid 13:184a08909405 6022 cmdLine.serial().printf("_V");
whismanoid 9:45f98573eb6d 6023 }
whismanoid 13:184a08909405 6024 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6025 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6026 if (Platform_AIN_customChannelHeader_ch[channel_index] && Platform_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 6027 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 6028 cmdLine.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6029 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6030 cmdLine_DAPLINKserial.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6031 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6032 } else {
whismanoid 13:184a08909405 6033 // no custom channel name for this channel
whismanoid 13:184a08909405 6034 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 6035 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6036 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 6037 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6038 }
whismanoid 13:184a08909405 6039 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 6040 // close quote
whismanoid 13:184a08909405 6041 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 6042 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6043 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 6044 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6045 }
whismanoid 4:d9b05924ad4c 6046 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 30:07197a430869 6047 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 6048 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in Datalogger_PrintHeader
whismanoid 30:07197a430869 6049 cmdLine.serial().printf(",\"%s\"", gstrRemarkHeader);
whismanoid 30:07197a430869 6050 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 4:d9b05924ad4c 6051 // end of column header line
whismanoid 4:d9b05924ad4c 6052 cmdLine.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 6053 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6054 cmdLine_DAPLINKserial.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 6055 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6056 } // void Datalogger_PrintHeader()
whismanoid 4:d9b05924ad4c 6057
whismanoid 5:aaf8b5f5fda1 6058 //--------------------------------------------------
whismanoid 5:aaf8b5f5fda1 6059 void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 6060 {
whismanoid 5:aaf8b5f5fda1 6061 // CODE GENERATOR: example code: has no member function ScanStandardExternalClock
whismanoid 5:aaf8b5f5fda1 6062 // CODE GENERATOR: example code: has no member function ReadAINcode
whismanoid 5:aaf8b5f5fda1 6063 // CODE GENERATOR: example code: member function Read_All_Voltages
whismanoid 5:aaf8b5f5fda1 6064 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6065 // Measure ADC channels in sequence from AIN0 to channelNumber_0_9.
whismanoid 5:aaf8b5f5fda1 6066 // @param[in] g_MAX11410_device.channelNumber_0_15: AIN Channel Number
whismanoid 5:aaf8b5f5fda1 6067 // @param[in] g_MAX11410_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
whismanoid 5:aaf8b5f5fda1 6068 // @param[in] g_MAX11410_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
whismanoid 10:04022a61b527 6069 //~ int channelId_0_9 = NUM_DUT_ANALOG_IN_CHANNELS-1+1;
whismanoid 5:aaf8b5f5fda1 6070 //g_MAX11410_device.channelNumber_0_15 = channelId_0_9;
whismanoid 5:aaf8b5f5fda1 6071 //g_MAX11410_device.PowerManagement_0_2 = 0;
whismanoid 5:aaf8b5f5fda1 6072 //g_MAX11410_device.chan_id_0_1 = 1;
whismanoid 5:aaf8b5f5fda1 6073 //----------------------------------------
whismanoid 5:aaf8b5f5fda1 6074 // scan AIN0..AIN9
whismanoid 5:aaf8b5f5fda1 6075 //
whismanoid 10:04022a61b527 6076 #if 1
whismanoid 10:04022a61b527 6077 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 6078 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 6079 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 6080 //
whismanoid 10:04022a61b527 6081 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6082 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc3); // GP1 = 0
whismanoid 10:04022a61b527 6083 //
whismanoid 10:04022a61b527 6084 int field_index = 0;
whismanoid 10:04022a61b527 6085 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 6086 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 10:04022a61b527 6087 continue;
whismanoid 10:04022a61b527 6088 }
whismanoid 10:04022a61b527 6089 field_index++;
whismanoid 10:04022a61b527 6090 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[channel_index];
whismanoid 10:04022a61b527 6091 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[channel_index];
whismanoid 10:04022a61b527 6092 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[channel_index];
whismanoid 10:04022a61b527 6093 //
whismanoid 10:04022a61b527 6094 // WIP SampleRate_of_FILTER_CONV_START() MAX11410EMC-FW slow ODR 10Sps #262
whismanoid 10:04022a61b527 6095 // adjust the MAX11410.loop_limit value if the sample rate is set to a value slower than 20sps
whismanoid 10:04022a61b527 6096 // SampleRate_of_FILTER_CONV_START(uint8_t FILTER_RegValue, uint8_t CONV_START_RegValue)
whismanoid 10:04022a61b527 6097 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 6098 if (SampleRate < 20.0) {
whismanoid 10:04022a61b527 6099 g_MAX11410_device.loop_limit = 32767; // TODO: is this timeout long enough for the slow output data rates?
whismanoid 10:04022a61b527 6100 }
whismanoid 10:04022a61b527 6101 //
whismanoid 10:04022a61b527 6102 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6103 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc3); // GP0 = 0
whismanoid 10:04022a61b527 6104 //
whismanoid 10:04022a61b527 6105 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 6106 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 10:04022a61b527 6107 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 10:04022a61b527 6108 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 6109 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = (MAX11410::MAX11410_AINN_SEL_enum_t)(channel_index^1);
whismanoid 10:04022a61b527 6110 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 6111 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 6112 }
whismanoid 10:04022a61b527 6113 else {
whismanoid 10:04022a61b527 6114 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 6115 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = MAX11410::AINN_SEL_1010_GND;
whismanoid 10:04022a61b527 6116 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 6117 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 6118 }
whismanoid 10:04022a61b527 6119 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 6120 //
whismanoid 10:04022a61b527 6121 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6122 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc4); // GP0 = 1
whismanoid 10:04022a61b527 6123 //
whismanoid 10:04022a61b527 6124 }
whismanoid 10:04022a61b527 6125 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6126 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc4); // GP1 = 1
whismanoid 10:04022a61b527 6127 #else
whismanoid 5:aaf8b5f5fda1 6128 g_MAX11410_device.Read_All_Voltages();
whismanoid 10:04022a61b527 6129 #endif
whismanoid 10:04022a61b527 6130 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6131 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 6132 // mbed
whismanoid 5:aaf8b5f5fda1 6133 // Platform board uses simple analog inputs
whismanoid 5:aaf8b5f5fda1 6134 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 5:aaf8b5f5fda1 6135 Platform_LSB[0] = analogIn0.read();
whismanoid 5:aaf8b5f5fda1 6136 Platform_LSB[1] = analogIn1.read();
whismanoid 5:aaf8b5f5fda1 6137 Platform_LSB[2] = analogIn2.read();
whismanoid 5:aaf8b5f5fda1 6138 Platform_LSB[3] = analogIn3.read();
whismanoid 5:aaf8b5f5fda1 6139 Platform_LSB[4] = analogIn4.read();
whismanoid 5:aaf8b5f5fda1 6140 Platform_LSB[5] = analogIn5.read();
whismanoid 10:04022a61b527 6141 #endif
whismanoid 10:04022a61b527 6142 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 34:a1993a1ee904 6143 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 6144 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 6145 Platform_Voltage[0] = CalibratedNormValue(0, analogIn0.read()) * adc_full_scale_voltage[0];
whismanoid 34:a1993a1ee904 6146 Platform_Voltage[1] = CalibratedNormValue(1, analogIn1.read()) * adc_full_scale_voltage[1];
whismanoid 34:a1993a1ee904 6147 Platform_Voltage[2] = CalibratedNormValue(2, analogIn2.read()) * adc_full_scale_voltage[2];
whismanoid 34:a1993a1ee904 6148 Platform_Voltage[3] = CalibratedNormValue(3, analogIn3.read()) * adc_full_scale_voltage[3];
whismanoid 34:a1993a1ee904 6149 Platform_Voltage[4] = CalibratedNormValue(4, analogIn4.read()) * adc_full_scale_voltage[4];
whismanoid 34:a1993a1ee904 6150 Platform_Voltage[5] = CalibratedNormValue(5, analogIn5.read()) * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 6151 #else // HAS_Platform_AIN_Calibration
whismanoid 5:aaf8b5f5fda1 6152 Platform_Voltage[0] = analogIn0.read() * adc_full_scale_voltage[0];
whismanoid 5:aaf8b5f5fda1 6153 Platform_Voltage[1] = analogIn1.read() * adc_full_scale_voltage[1];
whismanoid 5:aaf8b5f5fda1 6154 Platform_Voltage[2] = analogIn2.read() * adc_full_scale_voltage[2];
whismanoid 5:aaf8b5f5fda1 6155 Platform_Voltage[3] = analogIn3.read() * adc_full_scale_voltage[3];
whismanoid 5:aaf8b5f5fda1 6156 Platform_Voltage[4] = analogIn4.read() * adc_full_scale_voltage[4];
whismanoid 5:aaf8b5f5fda1 6157 Platform_Voltage[5] = analogIn5.read() * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 6158 #endif // HAS_Platform_AIN_Calibration
whismanoid 5:aaf8b5f5fda1 6159 #endif
whismanoid 5:aaf8b5f5fda1 6160 #endif // defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 6161
whismanoid 5:aaf8b5f5fda1 6162 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6163 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 6164 const uint32_t part_id_expect = 0x000F02;
whismanoid 5:aaf8b5f5fda1 6165 uint32_t part_id_readback;
whismanoid 5:aaf8b5f5fda1 6166 g_MAX11410_device.RegRead(MAX11410::CMD_r001_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xddd_PART_ID, &part_id_readback);
whismanoid 5:aaf8b5f5fda1 6167 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6168 } // void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 6169
whismanoid 17:9397ea3ea7e9 6170 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6171 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 6172 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 6173 void Datalogger_RunActionTable()
whismanoid 17:9397ea3ea7e9 6174 {
whismanoid 17:9397ea3ea7e9 6175 if (Datalogger_action_table_enabled == false) {
whismanoid 17:9397ea3ea7e9 6176 return;
whismanoid 17:9397ea3ea7e9 6177 }
whismanoid 17:9397ea3ea7e9 6178 // TODO: verbose Datalogger_RunActionTable() emit a csv column ,"Action"
whismanoid 17:9397ea3ea7e9 6179 // TODO: assert Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX
whismanoid 17:9397ea3ea7e9 6180 // for Datalogger_action_table[0..Datalogger_action_table_row_count]
whismanoid 17:9397ea3ea7e9 6181 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 6182 {
whismanoid 17:9397ea3ea7e9 6183 // skip if Datalogger_action_table[i].action == action_noop
whismanoid 17:9397ea3ea7e9 6184 if (Datalogger_action_table[i].action == action_noop) {
whismanoid 17:9397ea3ea7e9 6185 continue;
whismanoid 17:9397ea3ea7e9 6186 }
whismanoid 17:9397ea3ea7e9 6187 // TODO: test Datalogger_action_table[i].condition "if="
whismanoid 17:9397ea3ea7e9 6188 // TODO: Could the .condition field also distinguish Platform ADC from SPI ADC?
whismanoid 17:9397ea3ea7e9 6189 // That way we keep both sets of ADC channels in separate lists
whismanoid 17:9397ea3ea7e9 6190 // if=0 -- always
whismanoid 17:9397ea3ea7e9 6191 // if=1,2,3,4,5,6 -- Platform_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 6192 // if=7,8,9,10,11,12 -- SPI_AIN_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 6193 // also, are we comparing code or voltage?
whismanoid 17:9397ea3ea7e9 6194 // TODO: selected Datalogger_action_table[i].condition_channel
whismanoid 17:9397ea3ea7e9 6195 // Datalogger could have both platform ADC and external SPI ADC channels
whismanoid 17:9397ea3ea7e9 6196 // if SPI_ADC_DeviceName
whismanoid 17:9397ea3ea7e9 6197 // NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 6198 // SPI_AIN_Enable_ch[]
whismanoid 17:9397ea3ea7e9 6199 // SPI_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 6200 // SPI_AIN_Voltage[]
whismanoid 17:9397ea3ea7e9 6201 // if LOG_PLATFORM_AIN
whismanoid 17:9397ea3ea7e9 6202 // NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 6203 // analogInPin_fullScaleVoltage[]
whismanoid 17:9397ea3ea7e9 6204 // Platform_Enable_ch[]
whismanoid 17:9397ea3ea7e9 6205 // Platform_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 6206 // Platform_Voltage[]
whismanoid 17:9397ea3ea7e9 6207 // TODO: selected Datalogger_action_table[i].condition_threshold
whismanoid 17:9397ea3ea7e9 6208 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6209 {
whismanoid 17:9397ea3ea7e9 6210 case condition_always:
whismanoid 17:9397ea3ea7e9 6211 //~ cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 6212 break;
whismanoid 17:9397ea3ea7e9 6213 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 6214 //~ cmdLine.serial().printf(" if A%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6215 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6216 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6217 continue;
whismanoid 17:9397ea3ea7e9 6218 }
whismanoid 17:9397ea3ea7e9 6219 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6220 break;
whismanoid 17:9397ea3ea7e9 6221 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 6222 //~ cmdLine.serial().printf(" if A%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6223 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6224 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6225 continue;
whismanoid 17:9397ea3ea7e9 6226 }
whismanoid 17:9397ea3ea7e9 6227 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6228 break;
whismanoid 17:9397ea3ea7e9 6229 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 6230 //~ cmdLine.serial().printf(" if A%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6231 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6232 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6233 continue;
whismanoid 17:9397ea3ea7e9 6234 }
whismanoid 17:9397ea3ea7e9 6235 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6236 break;
whismanoid 17:9397ea3ea7e9 6237 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 6238 //~ cmdLine.serial().printf(" if A%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6239 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6240 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6241 continue;
whismanoid 17:9397ea3ea7e9 6242 }
whismanoid 17:9397ea3ea7e9 6243 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6244 break;
whismanoid 17:9397ea3ea7e9 6245 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 6246 //~ cmdLine.serial().printf(" if A%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6247 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6248 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6249 continue;
whismanoid 17:9397ea3ea7e9 6250 }
whismanoid 17:9397ea3ea7e9 6251 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6252 break;
whismanoid 17:9397ea3ea7e9 6253 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 6254 //~ cmdLine.serial().printf(" if A%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6255 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6256 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6257 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6258 continue;
whismanoid 17:9397ea3ea7e9 6259 }
whismanoid 17:9397ea3ea7e9 6260 break;
whismanoid 17:9397ea3ea7e9 6261 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 6262 //~ cmdLine.serial().printf(" if AIN%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6263 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6264 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6265 continue;
whismanoid 17:9397ea3ea7e9 6266 }
whismanoid 17:9397ea3ea7e9 6267 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6268 break;
whismanoid 17:9397ea3ea7e9 6269 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 6270 //~ cmdLine.serial().printf(" if AIN%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6271 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6272 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6273 continue;
whismanoid 17:9397ea3ea7e9 6274 }
whismanoid 17:9397ea3ea7e9 6275 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6276 break;
whismanoid 17:9397ea3ea7e9 6277 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 6278 //~ cmdLine.serial().printf(" if AIN%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6279 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6280 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6281 continue;
whismanoid 17:9397ea3ea7e9 6282 }
whismanoid 17:9397ea3ea7e9 6283 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6284 break;
whismanoid 17:9397ea3ea7e9 6285 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 6286 //~ cmdLine.serial().printf(" if AIN%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6287 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6288 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6289 continue;
whismanoid 17:9397ea3ea7e9 6290 }
whismanoid 17:9397ea3ea7e9 6291 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6292 break;
whismanoid 17:9397ea3ea7e9 6293 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 6294 //~ cmdLine.serial().printf(" if AIN%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6295 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6296 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6297 continue;
whismanoid 17:9397ea3ea7e9 6298 }
whismanoid 17:9397ea3ea7e9 6299 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6300 break;
whismanoid 17:9397ea3ea7e9 6301 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 6302 //~ cmdLine.serial().printf(" if AIN%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6303 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6304 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6305 continue;
whismanoid 17:9397ea3ea7e9 6306 }
whismanoid 17:9397ea3ea7e9 6307 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6308 break;
whismanoid 17:9397ea3ea7e9 6309 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6310 // selected Datalogger_action_table[i].digitalOutPin
whismanoid 17:9397ea3ea7e9 6311 // perform selected Datalogger_action_table[i].action
whismanoid 17:9397ea3ea7e9 6312 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6313 {
whismanoid 17:9397ea3ea7e9 6314 case action_noop:
whismanoid 17:9397ea3ea7e9 6315 //~ cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 6316 break;
whismanoid 17:9397ea3ea7e9 6317 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 6318 {
whismanoid 17:9397ea3ea7e9 6319 //~ cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 6320 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6321 // perform action digitalOutLow
whismanoid 17:9397ea3ea7e9 6322 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 6323 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 6324 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6325 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6326 #else
whismanoid 17:9397ea3ea7e9 6327 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 6328 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 6329 digitalInOutPin.write(0);
whismanoid 17:9397ea3ea7e9 6330 #endif
whismanoid 17:9397ea3ea7e9 6331 }
whismanoid 17:9397ea3ea7e9 6332 break;
whismanoid 17:9397ea3ea7e9 6333 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 6334 {
whismanoid 17:9397ea3ea7e9 6335 //~ cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 6336 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6337 // perform action digitalOutHigh
whismanoid 17:9397ea3ea7e9 6338 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 6339 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 6340 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6341 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6342 #else
whismanoid 17:9397ea3ea7e9 6343 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 6344 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 6345 digitalInOutPin.write(1);
whismanoid 17:9397ea3ea7e9 6346 #endif
whismanoid 17:9397ea3ea7e9 6347 }
whismanoid 17:9397ea3ea7e9 6348 break;
whismanoid 29:6a9edb6e973b 6349 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6350 {
whismanoid 30:07197a430869 6351 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 6352 Datalogger_Trigger_enum_t saved_Datalogger_Trigger = Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 6353 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6354 switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6355 {
whismanoid 29:6a9edb6e973b 6356 case 1:
whismanoid 29:6a9edb6e973b 6357 onButton1FallingEdge();
whismanoid 29:6a9edb6e973b 6358 break;
whismanoid 29:6a9edb6e973b 6359 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6360 case 2:
whismanoid 29:6a9edb6e973b 6361 onButton2FallingEdge();
whismanoid 29:6a9edb6e973b 6362 break;
whismanoid 29:6a9edb6e973b 6363 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6364 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6365 case 3:
whismanoid 29:6a9edb6e973b 6366 onButton3FallingEdge();
whismanoid 29:6a9edb6e973b 6367 break;
whismanoid 29:6a9edb6e973b 6368 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6369 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6370 case 4:
whismanoid 29:6a9edb6e973b 6371 onButton4FallingEdge();
whismanoid 29:6a9edb6e973b 6372 break;
whismanoid 29:6a9edb6e973b 6373 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6374 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6375 case 5:
whismanoid 29:6a9edb6e973b 6376 onButton5FallingEdge();
whismanoid 29:6a9edb6e973b 6377 break;
whismanoid 29:6a9edb6e973b 6378 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6379 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6380 case 6:
whismanoid 29:6a9edb6e973b 6381 onButton6FallingEdge();
whismanoid 29:6a9edb6e973b 6382 break;
whismanoid 29:6a9edb6e973b 6383 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6384 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6385 case 7:
whismanoid 29:6a9edb6e973b 6386 onButton7FallingEdge();
whismanoid 29:6a9edb6e973b 6387 break;
whismanoid 29:6a9edb6e973b 6388 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6389 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6390 case 8:
whismanoid 29:6a9edb6e973b 6391 onButton8FallingEdge();
whismanoid 29:6a9edb6e973b 6392 break;
whismanoid 29:6a9edb6e973b 6393 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6394 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6395 case 9:
whismanoid 29:6a9edb6e973b 6396 onButton9FallingEdge();
whismanoid 29:6a9edb6e973b 6397 break;
whismanoid 29:6a9edb6e973b 6398 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6399 } // switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6400 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 30:07197a430869 6401 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 6402 Datalogger_Trigger = saved_Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 6403 } // case action_button
whismanoid 29:6a9edb6e973b 6404 break;
whismanoid 17:9397ea3ea7e9 6405 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 6406 //~ cmdLine.serial().printf("trigger_Halt");
whismanoid 17:9397ea3ea7e9 6407 // perform action trigger_Halt
whismanoid 17:9397ea3ea7e9 6408 Datalogger_Trigger = trigger_Halt;
whismanoid 17:9397ea3ea7e9 6409 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6410 break;
whismanoid 17:9397ea3ea7e9 6411 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 6412 //~ cmdLine.serial().printf("trigger_FreeRun");
whismanoid 17:9397ea3ea7e9 6413 // perform action trigger_FreeRun
whismanoid 17:9397ea3ea7e9 6414 Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 6415 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6416 break;
whismanoid 17:9397ea3ea7e9 6417 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 6418 //~ cmdLine.serial().printf("trigger_Timer");
whismanoid 17:9397ea3ea7e9 6419 //~ // print configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 6420 //~ cmdLine.serial().printf("(%d x %dmsec)", g_timer_interval_count, g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 6421 // perform action trigger_Timer
whismanoid 17:9397ea3ea7e9 6422 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 6423 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6424 break;
whismanoid 17:9397ea3ea7e9 6425 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 6426 //~ cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 6427 //~ // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 6428 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 6429 // TODO: perform action action_trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 6430 Datalogger_Trigger = trigger_PlatformDigitalInput;
whismanoid 17:9397ea3ea7e9 6431 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6432 break;
whismanoid 17:9397ea3ea7e9 6433 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 6434 //~ cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 6435 //~ // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6436 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 6437 // TODO: perform action action_trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6438 Datalogger_Trigger = trigger_SPIDeviceRegRead;
whismanoid 17:9397ea3ea7e9 6439 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6440 break;
whismanoid 17:9397ea3ea7e9 6441 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6442 // consider next row of action table
whismanoid 17:9397ea3ea7e9 6443 } // for ...Datalogger_action_table_row_count
whismanoid 17:9397ea3ea7e9 6444 }
whismanoid 17:9397ea3ea7e9 6445 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6446
whismanoid 5:aaf8b5f5fda1 6447 //--------------------------------------------------
whismanoid 8:dffee7509bfb 6448 void Datalogger_PrintRow(CmdLine& cmdLine)
whismanoid 5:aaf8b5f5fda1 6449 {
whismanoid 5:aaf8b5f5fda1 6450 int field_index = 0;
whismanoid 5:aaf8b5f5fda1 6451 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6452 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 6453 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 5:aaf8b5f5fda1 6454 continue;
whismanoid 5:aaf8b5f5fda1 6455 }
whismanoid 5:aaf8b5f5fda1 6456 // comma between fields
whismanoid 5:aaf8b5f5fda1 6457 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 6458 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 6459 }
whismanoid 10:04022a61b527 6460 field_index++;
whismanoid 10:04022a61b527 6461 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 10:04022a61b527 6462 cmdLine.serial().printf("%d", g_MAX11410_device.AINcode[channel_index]);
whismanoid 10:04022a61b527 6463 }
whismanoid 10:04022a61b527 6464 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 10:04022a61b527 6465 // TODO: report Voltage instead of LSB
whismanoid 10:04022a61b527 6466 // Serial.print(SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 6467 static char strOutLineBuffer[16];
whismanoid 10:04022a61b527 6468 cmdLine.serial().printf("%6.6f", SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 6469 }
whismanoid 5:aaf8b5f5fda1 6470 }
whismanoid 5:aaf8b5f5fda1 6471 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6472 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 6473 if (part_id_readback != part_id_expect) {
whismanoid 5:aaf8b5f5fda1 6474 cmdLine.serial().printf(",\"FAIL\"");
whismanoid 9:45f98573eb6d 6475 need_reinit = true;
whismanoid 5:aaf8b5f5fda1 6476 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6477 g_MAX11410_device.Init();
whismanoid 5:aaf8b5f5fda1 6478 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 5:aaf8b5f5fda1 6479 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 5:aaf8b5f5fda1 6480 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 5:aaf8b5f5fda1 6481 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6482 }
whismanoid 5:aaf8b5f5fda1 6483 else {
whismanoid 5:aaf8b5f5fda1 6484 cmdLine.serial().printf(",\"OK\"");
whismanoid 5:aaf8b5f5fda1 6485 }
whismanoid 5:aaf8b5f5fda1 6486 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6487 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6488 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 6489 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6490 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 6491 continue;
whismanoid 9:45f98573eb6d 6492 }
whismanoid 5:aaf8b5f5fda1 6493 // comma between fields
whismanoid 5:aaf8b5f5fda1 6494 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 6495 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 6496 }
whismanoid 9:45f98573eb6d 6497 field_index++;
whismanoid 9:45f98573eb6d 6498 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 5:aaf8b5f5fda1 6499 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 6500 cmdLine.serial().printf("%u", Platform_LSB[channel_index]);
whismanoid 9:45f98573eb6d 6501 #endif
whismanoid 9:45f98573eb6d 6502 }
whismanoid 9:45f98573eb6d 6503 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 6504 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 11:2b8adc78618a 6505 // Datalog Volts omit V suffix from numbers #275
whismanoid 11:2b8adc78618a 6506 // because Excel graphs can't handle numbers that have a suffix.
whismanoid 11:2b8adc78618a 6507 cmdLine.serial().printf("%6.6f", Platform_Voltage[channel_index]);
whismanoid 9:45f98573eb6d 6508 #endif
whismanoid 9:45f98573eb6d 6509 }
whismanoid 5:aaf8b5f5fda1 6510 }
whismanoid 5:aaf8b5f5fda1 6511 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 6512 if (need_reinit) {
whismanoid 9:45f98573eb6d 6513 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6514 if (g_MAX11410_device.Init() == 0) {
whismanoid 9:45f98573eb6d 6515 //~ cmdLine.serial().printf(",\"Init() failed\"");
whismanoid 9:45f98573eb6d 6516 } else {
whismanoid 9:45f98573eb6d 6517 //~ cmdLine.serial().printf(",\"Init() success\"");
whismanoid 9:45f98573eb6d 6518 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 6519 // in Datalogger_PrintRow(), when part_id test fails,
whismanoid 9:45f98573eb6d 6520 // apply list of custom register writes after re-init
whismanoid 9:45f98573eb6d 6521 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 6522 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 9:45f98573eb6d 6523 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 9:45f98573eb6d 6524 uint32_t regData = custom_reg_init_data[index];
whismanoid 9:45f98573eb6d 6525 cmdLine.serial().printf("*%s=0x%06.6x", g_MAX11410_device.RegName(regAddress), regData);
whismanoid 9:45f98573eb6d 6526 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 9:45f98573eb6d 6527 }
whismanoid 9:45f98573eb6d 6528 #endif // USE_CUSTOM_REG_INIT
whismanoid 9:45f98573eb6d 6529 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 9:45f98573eb6d 6530 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 9:45f98573eb6d 6531 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 9:45f98573eb6d 6532 need_reinit = false;
whismanoid 9:45f98573eb6d 6533 }
whismanoid 9:45f98573eb6d 6534 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6535 need_reinit = false;
whismanoid 9:45f98573eb6d 6536 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6537 }
whismanoid 30:07197a430869 6538 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 6539 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in void Datalogger_PrintRow()
whismanoid 30:07197a430869 6540 cmdLine.serial().printf(",\"%s\"", gstrRemarkText);
whismanoid 30:07197a430869 6541 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 5:aaf8b5f5fda1 6542 cmdLine.serial().printf("\r\n");
whismanoid 9:45f98573eb6d 6543 if (need_reinit) {
whismanoid 9:45f98573eb6d 6544 //~ delay(500); // platform_delay_ms 500ms timing delay function
whismanoid 9:45f98573eb6d 6545 }
whismanoid 5:aaf8b5f5fda1 6546 } // void Datalogger_PrintRow()
whismanoid 5:aaf8b5f5fda1 6547
whismanoid 0:cb44e2e9ec4c 6548 // example code main function
whismanoid 0:cb44e2e9ec4c 6549 int main()
whismanoid 0:cb44e2e9ec4c 6550 {
whismanoid 0:cb44e2e9ec4c 6551 // setup: put your setup code here, to run once
whismanoid 4:d9b05924ad4c 6552 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 6553 // Configure serial ports
whismanoid 4:d9b05924ad4c 6554 cmdLine.clear();
whismanoid 4:d9b05924ad4c 6555 //~ cmdLine.serial().printf("\r\n cmdLine.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 6556 cmdLine.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 6557 //~ cmdLine.diagnostic_led_EOF = diagnostic_led_EOF;
whismanoid 4:d9b05924ad4c 6558 /// CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21);
whismanoid 4:d9b05924ad4c 6559 //~ cmdLine.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 6560 //~ cmdLine.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 6561 //~ cmdLine.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 6562 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6563 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6564 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 6565 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 6566 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 6567 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 6568 # else
whismanoid 10:04022a61b527 6569 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 6570 DAPLINKserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6571 # endif
whismanoid 10:04022a61b527 6572 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 6573 cmdLine_DAPLINKserial.clear();
whismanoid 4:d9b05924ad4c 6574 //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 6575 cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 6576 //~ cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 6577 //~ cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 6578 //~ cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 6579 # endif
whismanoid 6:f6d16658342b 6580 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6581 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 10:04022a61b527 6582 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6583 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 6584 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 6585 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 6586 AUXserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6587 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 6:f6d16658342b 6588 cmdLine_AUXserial.clear();
whismanoid 6:f6d16658342b 6589 //~ cmdLine_AUXserial.serial().printf("\r\n cmdLine_AUXserial.serial().printf test\r\n");
whismanoid 6:f6d16658342b 6590 cmdLine_AUXserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 6:f6d16658342b 6591 //~ cmdLine_AUXserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 6:f6d16658342b 6592 //~ cmdLine_AUXserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 6:f6d16658342b 6593 //~ cmdLine_AUXserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 6:f6d16658342b 6594 # endif // HAS_AUX_SERIAL
whismanoid 4:d9b05924ad4c 6595 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 0:cb44e2e9ec4c 6596
whismanoid 0:cb44e2e9ec4c 6597 // example code: serial port banner message
whismanoid 0:cb44e2e9ec4c 6598 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 6599 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6600 cmdLine.serial().printf("\r\nDataLogger_MAX11410\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 6601 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 6602 cmdLine.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 6603 # if HAS_DAPLINK_SERIAL
whismanoid 3:9055e17e181a 6604 cmdLine_DAPLINKserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 6605 # endif // HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 6606 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6607 cmdLine_AUXserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 6:f6d16658342b 6608 # endif // HAS_AUX_SERIAL
whismanoid 3:9055e17e181a 6609 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6610
whismanoid 1:747f1602abfc 6611 // CODE GENERATOR: get spi properties from device
whismanoid 3:9055e17e181a 6612 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6613 if (g_SPI_SCLK_Hz > g_MAX11410_device.get_spi_frequency())
whismanoid 3:9055e17e181a 6614 { // Device limits SPI SCLK frequency
whismanoid 3:9055e17e181a 6615 g_SPI_SCLK_Hz = g_MAX11410_device.get_spi_frequency();
whismanoid 3:9055e17e181a 6616 cmdLine.serial().printf("\r\nMAX11410 limits SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 6617
whismanoid 3:9055e17e181a 6618 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 6619 }
whismanoid 3:9055e17e181a 6620 if (g_MAX11410_device.get_spi_frequency() > g_SPI_SCLK_Hz)
whismanoid 3:9055e17e181a 6621 { // Platform limits SPI SCLK frequency
whismanoid 3:9055e17e181a 6622 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 6623 cmdLine.serial().printf("\r\nPlatform limits MAX11410 SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 6624
whismanoid 3:9055e17e181a 6625 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 6626 }
whismanoid 0:cb44e2e9ec4c 6627 // g_SPI_dataMode = g_MAX11410_device.get_spi_dataMode();
whismanoid 3:9055e17e181a 6628 while (g_MAX11410_device.Init() == 0)
whismanoid 3:9055e17e181a 6629 {
whismanoid 3:9055e17e181a 6630 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 6631 cmdLine.serial().printf("\r\nMAX11410 Init failed; retry...\r\n");
whismanoid 3:9055e17e181a 6632
whismanoid 3:9055e17e181a 6633 }
whismanoid 0:cb44e2e9ec4c 6634
whismanoid 0:cb44e2e9ec4c 6635 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 3:9055e17e181a 6636 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6637 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 3:9055e17e181a 6638 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 3:9055e17e181a 6639 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 3:9055e17e181a 6640 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 6641 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 3:9055e17e181a 6642 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 6643 // CODE GENERATOR: example code: has no member function REF
whismanoid 0:cb44e2e9ec4c 6644 // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line
whismanoid 0:cb44e2e9ec4c 6645 // CODE GENERATOR: ResolutionBits = 24
whismanoid 0:cb44e2e9ec4c 6646 // CODE GENERATOR: FScode = 0xffffff
whismanoid 0:cb44e2e9ec4c 6647 // CODE GENERATOR: NumChannels = 10
whismanoid 0:cb44e2e9ec4c 6648 // CODE GENERATOR: banner before DataLogHelloCppCodeList while(1)
whismanoid 3:9055e17e181a 6649 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6650 cmdLine.serial().printf("v_filter = 0x%2.2x\r\n", g_MAX11410_device.v_filter);
whismanoid 0:cb44e2e9ec4c 6651
whismanoid 3:9055e17e181a 6652 cmdLine.serial().printf("v_pga = 0x%2.2x\r\n", g_MAX11410_device.v_pga);
whismanoid 0:cb44e2e9ec4c 6653
whismanoid 3:9055e17e181a 6654 cmdLine.serial().printf("v_ctrl = 0x%2.2x\r\n", g_MAX11410_device.v_ctrl);
whismanoid 3:9055e17e181a 6655
whismanoid 3:9055e17e181a 6656 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 6657
whismanoid 3:9055e17e181a 6658 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 6659 Datalogger_Need_PrintHeader = true;
whismanoid 10:04022a61b527 6660
whismanoid 12:2dfc1f2009e0 6661 #if USE_LEDS
whismanoid 12:2dfc1f2009e0 6662 #if defined(TARGET_MAX32630)
whismanoid 12:2dfc1f2009e0 6663 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 6664 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6665 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 6666 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6667 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 6668 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6669 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 6670 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6671 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 6672 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6673 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 6674 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6675 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 6676 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6677 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 6678 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 19:5ff09c8e9daf 6679 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 12:2dfc1f2009e0 6680 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 6681 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6682 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 6683 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6684 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 6685 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6686 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 6687 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6688 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 6689 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6690 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 6691 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6692 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 6693 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6694 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 6695 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6696 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 12:2dfc1f2009e0 6697 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 6698 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6699 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6700 led4 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6701 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 6702 //led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 6703 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 6704 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 6705 led1 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6706 //led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 6707 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 6708 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 6709 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6710 //led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 6711 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 6712 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 6713 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6714 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 6715 //
whismanoid 12:2dfc1f2009e0 6716 #endif // target definition
whismanoid 12:2dfc1f2009e0 6717 #endif
whismanoid 12:2dfc1f2009e0 6718
whismanoid 12:2dfc1f2009e0 6719 if (led1.is_connected()) {
whismanoid 12:2dfc1f2009e0 6720 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 6721 }
whismanoid 12:2dfc1f2009e0 6722 if (led2.is_connected()) {
whismanoid 12:2dfc1f2009e0 6723 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 6724 }
whismanoid 12:2dfc1f2009e0 6725 if (led3.is_connected()) {
whismanoid 12:2dfc1f2009e0 6726 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 6727 }
whismanoid 12:2dfc1f2009e0 6728
whismanoid 4:d9b05924ad4c 6729 while(1) { // this code repeats forever
whismanoid 4:d9b05924ad4c 6730 // this code repeats forever
whismanoid 4:d9b05924ad4c 6731
whismanoid 21:ac062a97a71d 6732 #if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 6733 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 6734 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 6735 # if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 6736 static int button1_value_prev = 1;
whismanoid 21:ac062a97a71d 6737 static int button1_value_now = 1;
whismanoid 21:ac062a97a71d 6738 button1_value_prev = button1_value_now;
whismanoid 21:ac062a97a71d 6739 button1_value_now = button1.read();
whismanoid 21:ac062a97a71d 6740 if ((button1_value_prev - button1_value_now) == 1)
whismanoid 21:ac062a97a71d 6741 {
whismanoid 21:ac062a97a71d 6742 // on button1 falling edge (button1 press)
whismanoid 21:ac062a97a71d 6743 onButton1FallingEdge();
whismanoid 21:ac062a97a71d 6744 }
whismanoid 21:ac062a97a71d 6745 # endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 6746 # if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 6747 static int button2_value_prev = 1;
whismanoid 24:032f3683cb2a 6748 static int button2_value_now = 1;
whismanoid 24:032f3683cb2a 6749 button2_value_prev = button2_value_now;
whismanoid 24:032f3683cb2a 6750 button2_value_now = button2.read();
whismanoid 24:032f3683cb2a 6751 if ((button2_value_prev - button2_value_now) == 1)
whismanoid 24:032f3683cb2a 6752 {
whismanoid 24:032f3683cb2a 6753 // on button2 falling edge (button2 press)
whismanoid 24:032f3683cb2a 6754 onButton2FallingEdge();
whismanoid 24:032f3683cb2a 6755 }
whismanoid 24:032f3683cb2a 6756 # endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 6757 # if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 6758 static int button3_value_prev = 1;
whismanoid 24:032f3683cb2a 6759 static int button3_value_now = 1;
whismanoid 24:032f3683cb2a 6760 button3_value_prev = button3_value_now;
whismanoid 24:032f3683cb2a 6761 button3_value_now = button3.read();
whismanoid 24:032f3683cb2a 6762 if ((button3_value_prev - button3_value_now) == 1)
whismanoid 24:032f3683cb2a 6763 {
whismanoid 24:032f3683cb2a 6764 // on button3 falling edge (button3 press)
whismanoid 26:13cba69d88eb 6765 onButton3FallingEdge();
whismanoid 24:032f3683cb2a 6766 }
whismanoid 24:032f3683cb2a 6767 # endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 6768 #endif // HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 4:d9b05924ad4c 6769 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 6770 // TODO support CmdLine command menus (like on Serial_Tester); help and usual boilerplate
whismanoid 10:04022a61b527 6771 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6772 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 6773 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 6774 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6775 // Accept commands from Auxiliary serial port
whismanoid 6:f6d16658342b 6776 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6777 if (AUXserial.readable()) {
whismanoid 6:f6d16658342b 6778 cmdLine_AUXserial.append(AUXserial.getc());
whismanoid 6:f6d16658342b 6779 }
whismanoid 6:f6d16658342b 6780 # endif // HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6781 # if HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 6782 if (DAPLINKserial.readable()) {
whismanoid 6:f6d16658342b 6783 cmdLine_DAPLINKserial.append(DAPLINKserial.getc());
whismanoid 6:f6d16658342b 6784 }
whismanoid 6:f6d16658342b 6785 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6786 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 6787 if (serial.readable()) {
whismanoid 4:d9b05924ad4c 6788 int c = serial.getc(); // instead of getc() or fgetc()
whismanoid 4:d9b05924ad4c 6789 cmdLine.append(c);
whismanoid 4:d9b05924ad4c 6790 // cmdLine.onEOLcommandParser handler implements menus
whismanoid 4:d9b05924ad4c 6791 } // if (Serial.available())
whismanoid 4:d9b05924ad4c 6792 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 6793
whismanoid 4:d9b05924ad4c 6794 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 32:80f3e5eb77d4 6795 // Datalog trigger
whismanoid 4:d9b05924ad4c 6796 if (Datalogger_Trigger == trigger_Halt) {
whismanoid 4:d9b05924ad4c 6797 // halt the datalogger; continue accepting commands
whismanoid 3:9055e17e181a 6798 continue;
whismanoid 3:9055e17e181a 6799 }
whismanoid 4:d9b05924ad4c 6800 if (Datalogger_Trigger == trigger_FreeRun) {
whismanoid 4:d9b05924ad4c 6801 // free run as fast as possible
whismanoid 3:9055e17e181a 6802 }
whismanoid 4:d9b05924ad4c 6803 if (Datalogger_Trigger == trigger_Timer) {
whismanoid 4:d9b05924ad4c 6804 // timer (configure interval)
whismanoid 32:80f3e5eb77d4 6805 // if Datalogger_Trigger == trigger_Timer sleep(g_timer_interval_msec)
whismanoid 17:9397ea3ea7e9 6806 // sleep(g_timer_interval_msec); // error: too many arguments to function 'void sleep()'
whismanoid 17:9397ea3ea7e9 6807 wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 17:9397ea3ea7e9 6808 if (g_timer_interval_counter > 0) {
whismanoid 17:9397ea3ea7e9 6809 g_timer_interval_counter--;
whismanoid 17:9397ea3ea7e9 6810 continue;
whismanoid 17:9397ea3ea7e9 6811 }
whismanoid 17:9397ea3ea7e9 6812 // if time interval not yet reached, continue (continue accepting commands)
whismanoid 32:80f3e5eb77d4 6813 g_timer_interval_counter = g_timer_interval_count-1;
whismanoid 3:9055e17e181a 6814 }
whismanoid 4:d9b05924ad4c 6815 if (Datalogger_Trigger == trigger_PlatformDigitalInput) {
whismanoid 4:d9b05924ad4c 6816 // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 6817 // TODO: read selected input pin, test value
whismanoid 17:9397ea3ea7e9 6818 // TODO: if no match, continue (continue accepting commands)
whismanoid 3:9055e17e181a 6819 }
whismanoid 4:d9b05924ad4c 6820 if (Datalogger_Trigger == trigger_SPIDeviceRegRead) {
whismanoid 4:d9b05924ad4c 6821 // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 6822 // TODO: SPI transfer regAddr
whismanoid 17:9397ea3ea7e9 6823 // TODO: apply dataMask, compare with testValue
whismanoid 17:9397ea3ea7e9 6824 // TODO: if no match, continue (continue accepting commands)
whismanoid 4:d9b05924ad4c 6825 }
whismanoid 4:d9b05924ad4c 6826 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 0:cb44e2e9ec4c 6827
whismanoid 8:dffee7509bfb 6828 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 6829 if (Datalogger_Need_PrintHeader) {
whismanoid 8:dffee7509bfb 6830 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 6831 Datalogger_PrintHeader(cmdLine);
whismanoid 8:dffee7509bfb 6832 }
whismanoid 8:dffee7509bfb 6833 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6834 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 6835 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 6836 }
whismanoid 8:dffee7509bfb 6837 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6838 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 6839 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 6840 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 6841 }
whismanoid 8:dffee7509bfb 6842 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 6843 Datalogger_Need_PrintHeader = false;
whismanoid 8:dffee7509bfb 6844 }
whismanoid 5:aaf8b5f5fda1 6845 Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 6846 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6847 // Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 6848 Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 6849 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 0:cb44e2e9ec4c 6850 // wait(3.0);
whismanoid 0:cb44e2e9ec4c 6851 // CODE GENERATOR: print conversion result
whismanoid 0:cb44e2e9ec4c 6852 // Use Arduino Serial Plotter to view output: Tools | Serial Plotter
whismanoid 8:dffee7509bfb 6853 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 6854 Datalogger_PrintRow(cmdLine);
whismanoid 8:dffee7509bfb 6855 }
whismanoid 8:dffee7509bfb 6856 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6857 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 6858 Datalogger_PrintRow(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 6859 }
whismanoid 8:dffee7509bfb 6860 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6861 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 6862 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 6863 Datalogger_PrintRow(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 6864 }
whismanoid 8:dffee7509bfb 6865 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:cb44e2e9ec4c 6866
whismanoid 0:cb44e2e9ec4c 6867 } // this code repeats forever
whismanoid 0:cb44e2e9ec4c 6868 }
whismanoid 0:cb44e2e9ec4c 6869 //---------- CODE GENERATOR: end DataLogHelloCppCodeList