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

Dependencies:   max32625pico CmdLine

Committer:
whismanoid
Date:
Fri May 07 01:54:54 2021 -0700
Revision:
40:330b28116178
Parent:
39:4d285e961435
Child:
41:13a6a097502c
WIP LT sleep=2 Sleep vs Deep Sleep; > no LF; < rx only

Who changed what in which revision?

UserRevisionLine numberNew contents of line
whismanoid 0:cb44e2e9ec4c 1 // /*******************************************************************************
whismanoid 28:a9a3a9db592b 2 // * Copyright (C) 2021 Maxim Integrated Products, Inc., All Rights Reserved.
whismanoid 0:cb44e2e9ec4c 3 // *
whismanoid 0:cb44e2e9ec4c 4 // * Permission is hereby granted, free of charge, to any person obtaining a
whismanoid 0:cb44e2e9ec4c 5 // * copy of this software and associated documentation files (the "Software"),
whismanoid 0:cb44e2e9ec4c 6 // * to deal in the Software without restriction, including without limitation
whismanoid 0:cb44e2e9ec4c 7 // * the rights to use, copy, modify, merge, publish, distribute, sublicense,
whismanoid 0:cb44e2e9ec4c 8 // * and/or sell copies of the Software, and to permit persons to whom the
whismanoid 0:cb44e2e9ec4c 9 // * Software is furnished to do so, subject to the following conditions:
whismanoid 0:cb44e2e9ec4c 10 // *
whismanoid 0:cb44e2e9ec4c 11 // * The above copyright notice and this permission notice shall be included
whismanoid 0:cb44e2e9ec4c 12 // * in all copies or substantial portions of the Software.
whismanoid 0:cb44e2e9ec4c 13 // *
whismanoid 0:cb44e2e9ec4c 14 // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
whismanoid 0:cb44e2e9ec4c 15 // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
whismanoid 0:cb44e2e9ec4c 16 // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
whismanoid 0:cb44e2e9ec4c 17 // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
whismanoid 0:cb44e2e9ec4c 18 // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
whismanoid 0:cb44e2e9ec4c 19 // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
whismanoid 0:cb44e2e9ec4c 20 // * OTHER DEALINGS IN THE SOFTWARE.
whismanoid 0:cb44e2e9ec4c 21 // *
whismanoid 0:cb44e2e9ec4c 22 // * Except as contained in this notice, the name of Maxim Integrated
whismanoid 0:cb44e2e9ec4c 23 // * Products, Inc. shall not be used except as stated in the Maxim Integrated
whismanoid 0:cb44e2e9ec4c 24 // * Products, Inc. Branding Policy.
whismanoid 0:cb44e2e9ec4c 25 // *
whismanoid 0:cb44e2e9ec4c 26 // * The mere transfer of this software does not imply any licenses
whismanoid 0:cb44e2e9ec4c 27 // * of trade secrets, proprietary technology, copyrights, patents,
whismanoid 0:cb44e2e9ec4c 28 // * trademarks, maskwork rights, or any other form of intellectual
whismanoid 0:cb44e2e9ec4c 29 // * property whatsoever. Maxim Integrated Products, Inc. retains all
whismanoid 0:cb44e2e9ec4c 30 // * ownership rights.
whismanoid 0:cb44e2e9ec4c 31 // *******************************************************************************
whismanoid 0:cb44e2e9ec4c 32 // */
whismanoid 0:cb44e2e9ec4c 33 // *******************************************************************************
whismanoid 0:cb44e2e9ec4c 34 // COM port settings are 9600 baud 8N1
whismanoid 0:cb44e2e9ec4c 35 // *******************************************************************************
whismanoid 19:5ff09c8e9daf 36 // Support custom target MAX40108DEMOP2U9 based on MAX32625PICO but MAX32625_NO_BOOT
whismanoid 19:5ff09c8e9daf 37 // file custom_targets.json:
whismanoid 19:5ff09c8e9daf 38 // {
whismanoid 19:5ff09c8e9daf 39 // "MAX40108DEMOP2U9": {
whismanoid 19:5ff09c8e9daf 40 // "inherits": ["MAX32625_BASE"],
whismanoid 19:5ff09c8e9daf 41 // "macros_remove": [],
whismanoid 19:5ff09c8e9daf 42 // "macros_add": ["MAX32625_NO_BOOT"]
whismanoid 19:5ff09c8e9daf 43 // }
whismanoid 19:5ff09c8e9daf 44 // }
whismanoid 19:5ff09c8e9daf 45 // files copied from mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\TARGET_MAX32625PICO
whismanoid 19:5ff09c8e9daf 46 // file TARGET_MAX40108DEMOP2U9\PeripheralNames.h -- copied from TARGET_MAX32625PICO
whismanoid 19:5ff09c8e9daf 47 // file TARGET_MAX40108DEMOP2U9\PinNames.h -- copied from TARGET_MAX32625PICO
whismanoid 19:5ff09c8e9daf 48 // files copied from mbed-os\targets\TARGET_Maxim\TARGET_MAX32625\device\___\TARGET_MAX32625_NO_BOOT
whismanoid 19:5ff09c8e9daf 49 // file TARGET_MAX40108DEMOP2U9\device\TOOLCHAIN_ARM_STD\MAX32625.sct
whismanoid 19:5ff09c8e9daf 50 // file TARGET_MAX40108DEMOP2U9\device\TOOLCHAIN_GCC_ARM\max32625.ld
whismanoid 19:5ff09c8e9daf 51 // file TARGET_MAX40108DEMOP2U9\device\TOOLCHAIN_IAR\MAX32625.icf
whismanoid 19:5ff09c8e9daf 52 // file mbed_app.json:
whismanoid 19:5ff09c8e9daf 53 // {
whismanoid 19:5ff09c8e9daf 54 // "config": {
whismanoid 19:5ff09c8e9daf 55 // },
whismanoid 19:5ff09c8e9daf 56 // "macros": [
whismanoid 19:5ff09c8e9daf 57 // "MAX40108_DEMO=9"
whismanoid 19:5ff09c8e9daf 58 // ],
whismanoid 19:5ff09c8e9daf 59 // "target_overrides": {
whismanoid 19:5ff09c8e9daf 60 // }
whismanoid 19:5ff09c8e9daf 61 // }
whismanoid 19:5ff09c8e9daf 62 // *******************************************************************************
whismanoid 19:5ff09c8e9daf 63 // Validating project global defines from mbed_app.json "macros": []
whismanoid 19:5ff09c8e9daf 64 #ifndef MAX40108_DEMO
whismanoid 19:5ff09c8e9daf 65 #warning "MAX40108_DEMO not defined, missing mbed_app.json"
whismanoid 19:5ff09c8e9daf 66 #else // #ifndef MAX40108_DEMO
whismanoid 19:5ff09c8e9daf 67 #warning "Note: MAX40108_DEMO is defined, which is expected"
whismanoid 19:5ff09c8e9daf 68 #if (MAX40108_DEMO)==(9)
whismanoid 19:5ff09c8e9daf 69 #warning "Note: MAX40108_DEMO is defined with the expected value of 9"
whismanoid 19:5ff09c8e9daf 70 #elif (MAX40108_DEMO)==(5)
whismanoid 19:5ff09c8e9daf 71 #warning "Note: MAX40108_DEMO is defined with the wrong value 5"
whismanoid 19:5ff09c8e9daf 72 #else
whismanoid 19:5ff09c8e9daf 73 #warning "Note: MAX40108_DEMO is defined, but with an unsupported value"
whismanoid 19:5ff09c8e9daf 74 #endif
whismanoid 19:5ff09c8e9daf 75 #endif // #ifndef MAX40108_DEMO
whismanoid 19:5ff09c8e9daf 76 // *******************************************************************************
whismanoid 14:d4092094dbfe 77 #ifndef MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 78 // #define MAX40108_DEMO 5 for U5, or #define MAX40108_DEMO 9 for U9 in banner
whismanoid 17:9397ea3ea7e9 79 #define MAX40108_DEMO 9
whismanoid 15:37c83ec50ea0 80 #define HAS_DAPLINK_SERIAL 1
whismanoid 14:d4092094dbfe 81 #endif // MAX40108_DEMO
whismanoid 36:e7aac874b8be 82 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 83 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 84 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 85 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 36:e7aac874b8be 86 //
whismanoid 36:e7aac874b8be 87 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 88 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 36:e7aac874b8be 89 //
whismanoid 36:e7aac874b8be 90 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 91 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 36:e7aac874b8be 92 //
whismanoid 36:e7aac874b8be 93 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 94 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 36:e7aac874b8be 95 //
whismanoid 36:e7aac874b8be 96 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 97 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 36:e7aac874b8be 98 //
whismanoid 36:e7aac874b8be 99 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 100 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 36:e7aac874b8be 101 //
whismanoid 36:e7aac874b8be 102 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 103 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 36:e7aac874b8be 104 //
whismanoid 36:e7aac874b8be 105 # else
whismanoid 36:e7aac874b8be 106 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 107 # endif
whismanoid 36:e7aac874b8be 108 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 109 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 110 //
whismanoid 36:e7aac874b8be 111 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 0:cb44e2e9ec4c 112 //---------- CODE GENERATOR: DataLogHelloCppCodeList
whismanoid 0:cb44e2e9ec4c 113 // CODE GENERATOR: example code includes
whismanoid 0:cb44e2e9ec4c 114
whismanoid 0:cb44e2e9ec4c 115 // example code includes
whismanoid 0:cb44e2e9ec4c 116 // standard include for target platform -- Platform_Include_Boilerplate
whismanoid 0:cb44e2e9ec4c 117 #include "mbed.h"
whismanoid 0:cb44e2e9ec4c 118 // Platforms:
whismanoid 0:cb44e2e9ec4c 119 // - MAX32625MBED
whismanoid 0:cb44e2e9ec4c 120 // - supports mbed-os-5.11, requires USBDevice library
whismanoid 0:cb44e2e9ec4c 121 // - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
whismanoid 0:cb44e2e9ec4c 122 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 123 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 124 // - MAX32600MBED
whismanoid 7:949ec8581f5e 125 // - Please note the last supported version is Mbed OS 6.3.
whismanoid 0:cb44e2e9ec4c 126 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 127 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 128 // - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board.
whismanoid 0:cb44e2e9ec4c 129 // - NUCLEO_F446RE
whismanoid 0:cb44e2e9ec4c 130 // - remove USBDevice library
whismanoid 0:cb44e2e9ec4c 131 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 132 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 133 // - NUCLEO_F401RE
whismanoid 0:cb44e2e9ec4c 134 // - remove USBDevice library
whismanoid 0:cb44e2e9ec4c 135 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 136 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 137 // - MAX32630FTHR
whismanoid 0:cb44e2e9ec4c 138 // - #include "max32630fthr.h"
whismanoid 7:949ec8581f5e 139 // - add http://developer.mbed.org/teams/MaximIntegrated/code/max32630fthr/
whismanoid 0:cb44e2e9ec4c 140 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 141 // - MAX32620FTHR
whismanoid 0:cb44e2e9ec4c 142 // - #include "MAX32620FTHR.h"
whismanoid 0:cb44e2e9ec4c 143 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 144 // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
whismanoid 0:cb44e2e9ec4c 145 // - not tested yet
whismanoid 0:cb44e2e9ec4c 146 // - MAX32625PICO
whismanoid 0:cb44e2e9ec4c 147 // - #include "max32625pico.h"
whismanoid 0:cb44e2e9ec4c 148 // - add https://os.mbed.com/users/switches/code/max32625pico/
whismanoid 0:cb44e2e9ec4c 149 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 150 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 151 // - not tested yet
whismanoid 0:cb44e2e9ec4c 152 // - see https://os.mbed.com/users/switches/code/max32625pico/
whismanoid 0:cb44e2e9ec4c 153 // - see https://os.mbed.com/users/switches/code/PICO_board_demo/
whismanoid 0:cb44e2e9ec4c 154 // - see https://os.mbed.com/users/switches/code/PICO_USB_I2C_SPI/
whismanoid 0:cb44e2e9ec4c 155 // - see https://os.mbed.com/users/switches/code/SerialInterface/
whismanoid 0:cb44e2e9ec4c 156 // - Note: To load the MAX32625PICO firmware, hold the button while
whismanoid 0:cb44e2e9ec4c 157 // connecting the USB cable, then copy firmware bin file
whismanoid 0:cb44e2e9ec4c 158 // to the MAINTENANCE drive.
whismanoid 0:cb44e2e9ec4c 159 // - see https://os.mbed.com/platforms/MAX32625PICO/
whismanoid 0:cb44e2e9ec4c 160 // - see https://os.mbed.com/teams/MaximIntegrated/wiki/MAX32625PICO-Firmware-Updates
whismanoid 0:cb44e2e9ec4c 161 //
whismanoid 0:cb44e2e9ec4c 162 // end Platform_Include_Boilerplate
whismanoid 0:cb44e2e9ec4c 163
whismanoid 0:cb44e2e9ec4c 164 //--------------------------------------------------
whismanoid 3:9055e17e181a 165 // Option to use SPI connected ADC
whismanoid 3:9055e17e181a 166 #ifndef SPI_ADC_DeviceName
whismanoid 9:45f98573eb6d 167 #define SPI_ADC_DeviceName MAX11410
whismanoid 3:9055e17e181a 168 #undef SPI_ADC_DeviceName
whismanoid 3:9055e17e181a 169 #endif
whismanoid 3:9055e17e181a 170 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 171 #include "MAX11410.h"
whismanoid 3:9055e17e181a 172 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 173
whismanoid 0:cb44e2e9ec4c 174 #if defined(TARGET)
whismanoid 0:cb44e2e9ec4c 175 // TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h
whismanoid 0:cb44e2e9ec4c 176 // Create a string definition for the TARGET
whismanoid 0:cb44e2e9ec4c 177 #define STRING_ARG(arg) #arg
whismanoid 0:cb44e2e9ec4c 178 #define STRING_NAME(name) STRING_ARG(name)
whismanoid 0:cb44e2e9ec4c 179 #define TARGET_NAME STRING_NAME(TARGET)
whismanoid 0:cb44e2e9ec4c 180 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 181 #define TARGET_NAME "MAX32600"
whismanoid 0:cb44e2e9ec4c 182 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 183 #define TARGET_NAME "LPC1768"
whismanoid 0:cb44e2e9ec4c 184 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 185 #define TARGET_NAME "NUCLEO_F446RE"
whismanoid 0:cb44e2e9ec4c 186 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 187 #define TARGET_NAME "NUCLEO_F401RE"
whismanoid 0:cb44e2e9ec4c 188 #else
whismanoid 0:cb44e2e9ec4c 189 #error TARGET NOT DEFINED
whismanoid 0:cb44e2e9ec4c 190 #endif
whismanoid 0:cb44e2e9ec4c 191 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 192 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 193 // TARGET=MAX32630FTHR ARM Cortex-M4F 96MHz 2048kB Flash 512kB SRAM
whismanoid 0:cb44e2e9ec4c 194 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 195 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 196 // ______ | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 197 // ______ | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 198 // ______ | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 199 // ______ | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 200 // analogIn0/4 | [a] AIN_0 1.2Vfs (bat) SYS [ ] | switched BAT+
whismanoid 0:cb44e2e9ec4c 201 // analogIn1/5 | [a] AIN_1 1.2Vfs PWR [ ] | external pwr btn
whismanoid 0:cb44e2e9ec4c 202 // analogIn2 | [a] AIN_2 1.2Vfs +5V VBUS [ ] | USB +5V power
whismanoid 0:cb44e2e9ec4c 203 // analogIn3 | [a] AIN_3 1.2Vfs 1-WIRE P4_0 [d] | D0 dig9
whismanoid 0:cb44e2e9ec4c 204 // (I2C2.SDA) | [d] P5_7 SDA2 SRN P5_6 [d] | D1 dig8
whismanoid 0:cb44e2e9ec4c 205 // (I2C2.SCL) | [d] P6_0 SCL2 SDIO3 P5_5 [d] | D2 dig7
whismanoid 0:cb44e2e9ec4c 206 // D13/SCLK | [s] P5_0 SCLK SDIO2 P5_4 [d] | D3 dig6
whismanoid 0:cb44e2e9ec4c 207 // D11/MOSI | [s] P5_1 MOSI SSEL P5_3 [d] | D4 dig5
whismanoid 0:cb44e2e9ec4c 208 // D12/MISO | [s] P5_2 MISO RTS P3_3 [d] | D5 dig4
whismanoid 0:cb44e2e9ec4c 209 // D10/CS | [s] P3_0 RX CTS P3_2 [d] | D6 dig3
whismanoid 0:cb44e2e9ec4c 210 // D9 dig0 | [d] P3_1 TX SCL P3_5 [d] | D7 dig2
whismanoid 0:cb44e2e9ec4c 211 // ______ | [ ] GND SDA P3_4 [d] | D8 dig1
whismanoid 0:cb44e2e9ec4c 212 // | |
whismanoid 0:cb44e2e9ec4c 213 // | XIP Flash MAX14690N |
whismanoid 0:cb44e2e9ec4c 214 // | XIP_SCLK P1_0 SDA2 P5_7 |
whismanoid 0:cb44e2e9ec4c 215 // | XIP_MOSI P1_1 SCL2 P6_0 |
whismanoid 0:cb44e2e9ec4c 216 // | XIP_MISO P1_2 PMIC_INIT P3_7 |
whismanoid 0:cb44e2e9ec4c 217 // | XIP_SSEL P1_3 MPC P2_7 |
whismanoid 0:cb44e2e9ec4c 218 // | XIP_DIO2 P1_4 MON AIN_0 |
whismanoid 0:cb44e2e9ec4c 219 // | XIP_DIO3 P1_5 |
whismanoid 0:cb44e2e9ec4c 220 // | |
whismanoid 0:cb44e2e9ec4c 221 // | PAN1326B MicroSD LED |
whismanoid 0:cb44e2e9ec4c 222 // | BT_RX P0_0 SD_SCLK P0_4 r P2_4 |
whismanoid 0:cb44e2e9ec4c 223 // | BT_TX P0_1 SD_MOSI P0_5 g P2_5 |
whismanoid 0:cb44e2e9ec4c 224 // | BT_CTS P0_2 SD_MISO P0_6 b P2_6 |
whismanoid 0:cb44e2e9ec4c 225 // | BT_RTS P0_3 SD_SSEL P0_7 |
whismanoid 0:cb44e2e9ec4c 226 // | BT_RST P1_6 DETECT P2_2 |
whismanoid 0:cb44e2e9ec4c 227 // | BT_CLK P1_7 SW2 P2_3 |
whismanoid 0:cb44e2e9ec4c 228 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 229 // MAX32630FTHR board has MAX14690 PMIC on I2C bus (P5_7 SDA, P6_0 SCL) at slave address 0101_000r 0x50 (or 0x28 for 7 MSbit address).
whismanoid 0:cb44e2e9ec4c 230 // MAX32630FTHR board has BMI160 accelerometer on I2C bus (P5_7 SDA, P6_0 SCL) at slave address 1101_000r 0xD0 (or 0x68 for 7 MSbit address).
whismanoid 0:cb44e2e9ec4c 231 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 232 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 233 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 234 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 235 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 236 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 237 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 238 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 239 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 240 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 241 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 242 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 243 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 244 //
whismanoid 0:cb44e2e9ec4c 245 #include "max32630fthr.h"
whismanoid 0:cb44e2e9ec4c 246 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 247 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 248 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 249 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 250 // Arduino connector
whismanoid 0:cb44e2e9ec4c 251 #ifndef A0
whismanoid 0:cb44e2e9ec4c 252 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 253 #endif
whismanoid 0:cb44e2e9ec4c 254 #ifndef A1
whismanoid 0:cb44e2e9ec4c 255 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 256 #endif
whismanoid 0:cb44e2e9ec4c 257 #ifndef A2
whismanoid 0:cb44e2e9ec4c 258 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 259 #endif
whismanoid 0:cb44e2e9ec4c 260 #ifndef A3
whismanoid 0:cb44e2e9ec4c 261 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 262 #endif
whismanoid 0:cb44e2e9ec4c 263 #ifndef D0
whismanoid 0:cb44e2e9ec4c 264 #define D0 P4_0
whismanoid 0:cb44e2e9ec4c 265 #endif
whismanoid 0:cb44e2e9ec4c 266 #ifndef D1
whismanoid 0:cb44e2e9ec4c 267 #define D1 P5_6
whismanoid 0:cb44e2e9ec4c 268 #endif
whismanoid 0:cb44e2e9ec4c 269 #ifndef D2
whismanoid 0:cb44e2e9ec4c 270 #define D2 P5_5
whismanoid 0:cb44e2e9ec4c 271 #endif
whismanoid 0:cb44e2e9ec4c 272 #ifndef D3
whismanoid 0:cb44e2e9ec4c 273 #define D3 P5_4
whismanoid 0:cb44e2e9ec4c 274 #endif
whismanoid 0:cb44e2e9ec4c 275 #ifndef D4
whismanoid 0:cb44e2e9ec4c 276 #define D4 P5_3
whismanoid 0:cb44e2e9ec4c 277 #endif
whismanoid 0:cb44e2e9ec4c 278 #ifndef D5
whismanoid 0:cb44e2e9ec4c 279 #define D5 P3_3
whismanoid 0:cb44e2e9ec4c 280 #endif
whismanoid 0:cb44e2e9ec4c 281 #ifndef D6
whismanoid 0:cb44e2e9ec4c 282 #define D6 P3_2
whismanoid 0:cb44e2e9ec4c 283 #endif
whismanoid 0:cb44e2e9ec4c 284 #ifndef D7
whismanoid 0:cb44e2e9ec4c 285 #define D7 P3_5
whismanoid 0:cb44e2e9ec4c 286 #endif
whismanoid 0:cb44e2e9ec4c 287 #ifndef D8
whismanoid 0:cb44e2e9ec4c 288 #define D8 P3_4
whismanoid 0:cb44e2e9ec4c 289 #endif
whismanoid 0:cb44e2e9ec4c 290 #ifndef D9
whismanoid 0:cb44e2e9ec4c 291 #define D9 P3_1
whismanoid 0:cb44e2e9ec4c 292 #endif
whismanoid 0:cb44e2e9ec4c 293 #ifndef D10
whismanoid 0:cb44e2e9ec4c 294 #define D10 P3_0
whismanoid 0:cb44e2e9ec4c 295 #endif
whismanoid 0:cb44e2e9ec4c 296 #ifndef D11
whismanoid 0:cb44e2e9ec4c 297 #define D11 P5_1
whismanoid 0:cb44e2e9ec4c 298 #endif
whismanoid 0:cb44e2e9ec4c 299 #ifndef D12
whismanoid 0:cb44e2e9ec4c 300 #define D12 P5_2
whismanoid 0:cb44e2e9ec4c 301 #endif
whismanoid 0:cb44e2e9ec4c 302 #ifndef D13
whismanoid 0:cb44e2e9ec4c 303 #define D13 P5_0
whismanoid 0:cb44e2e9ec4c 304 #endif
whismanoid 0:cb44e2e9ec4c 305 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 306 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 307 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 308 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 309 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 310 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 311 // | |
whismanoid 0:cb44e2e9ec4c 312 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 313 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 314 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 315 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 316 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 317 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 318 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 319 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 320 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 321 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 322 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 323 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 324 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 325 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 326 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 327 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 328 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 329 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 330 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 331 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 332 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 333 // \_______________________/
whismanoid 0:cb44e2e9ec4c 334 //
whismanoid 0:cb44e2e9ec4c 335 // +------------------------+
whismanoid 0:cb44e2e9ec4c 336 // | |
whismanoid 0:cb44e2e9ec4c 337 // | MicroSD LED |
whismanoid 0:cb44e2e9ec4c 338 // | SD_SCLK P2_4 r P3_0 |
whismanoid 0:cb44e2e9ec4c 339 // | SD_MOSI P2_5 g P3_1 |
whismanoid 0:cb44e2e9ec4c 340 // | SD_MISO P2_6 b P3_2 |
whismanoid 0:cb44e2e9ec4c 341 // | SD_SSEL P2_7 y P3_3 |
whismanoid 0:cb44e2e9ec4c 342 // | |
whismanoid 0:cb44e2e9ec4c 343 // | DAPLINK BUTTONS |
whismanoid 0:cb44e2e9ec4c 344 // | TX P2_1 SW3 P2_3 |
whismanoid 0:cb44e2e9ec4c 345 // | RX P2_0 SW2 P2_2 |
whismanoid 0:cb44e2e9ec4c 346 // +------------------------+
whismanoid 0:cb44e2e9ec4c 347 //
whismanoid 0:cb44e2e9ec4c 348 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 349 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 350 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 351 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 352 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 353 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 354 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 355 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 356 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 357 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 358 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 359 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 360 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 361 //
whismanoid 0:cb44e2e9ec4c 362 //#include "max32625mbed.h" // ?
whismanoid 0:cb44e2e9ec4c 363 //MAX32625MBED mbed(MAX32625MBED::VIO_3V3); // ?
whismanoid 0:cb44e2e9ec4c 364 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 365 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 366 const float ADC_FULL_SCALE_VOLTAGE = 1.200; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 367 // Arduino connector
whismanoid 0:cb44e2e9ec4c 368 #ifndef A0
whismanoid 0:cb44e2e9ec4c 369 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 370 #endif
whismanoid 0:cb44e2e9ec4c 371 #ifndef A1
whismanoid 0:cb44e2e9ec4c 372 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 373 #endif
whismanoid 0:cb44e2e9ec4c 374 #ifndef A2
whismanoid 0:cb44e2e9ec4c 375 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 376 #endif
whismanoid 0:cb44e2e9ec4c 377 #ifndef A3
whismanoid 0:cb44e2e9ec4c 378 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 379 #endif
whismanoid 0:cb44e2e9ec4c 380 #ifndef D0
whismanoid 0:cb44e2e9ec4c 381 #define D0 P0_0
whismanoid 0:cb44e2e9ec4c 382 #endif
whismanoid 0:cb44e2e9ec4c 383 #ifndef D1
whismanoid 0:cb44e2e9ec4c 384 #define D1 P0_1
whismanoid 0:cb44e2e9ec4c 385 #endif
whismanoid 0:cb44e2e9ec4c 386 #ifndef D2
whismanoid 0:cb44e2e9ec4c 387 #define D2 P0_2
whismanoid 0:cb44e2e9ec4c 388 #endif
whismanoid 0:cb44e2e9ec4c 389 #ifndef D3
whismanoid 0:cb44e2e9ec4c 390 #define D3 P0_3
whismanoid 0:cb44e2e9ec4c 391 #endif
whismanoid 0:cb44e2e9ec4c 392 #ifndef D4
whismanoid 0:cb44e2e9ec4c 393 #define D4 P0_4
whismanoid 0:cb44e2e9ec4c 394 #endif
whismanoid 0:cb44e2e9ec4c 395 #ifndef D5
whismanoid 0:cb44e2e9ec4c 396 #define D5 P0_5
whismanoid 0:cb44e2e9ec4c 397 #endif
whismanoid 0:cb44e2e9ec4c 398 #ifndef D6
whismanoid 0:cb44e2e9ec4c 399 #define D6 P0_6
whismanoid 0:cb44e2e9ec4c 400 #endif
whismanoid 0:cb44e2e9ec4c 401 #ifndef D7
whismanoid 0:cb44e2e9ec4c 402 #define D7 P0_7
whismanoid 0:cb44e2e9ec4c 403 #endif
whismanoid 0:cb44e2e9ec4c 404 #ifndef D8
whismanoid 0:cb44e2e9ec4c 405 #define D8 P1_4
whismanoid 0:cb44e2e9ec4c 406 #endif
whismanoid 0:cb44e2e9ec4c 407 #ifndef D9
whismanoid 0:cb44e2e9ec4c 408 #define D9 P1_5
whismanoid 0:cb44e2e9ec4c 409 #endif
whismanoid 0:cb44e2e9ec4c 410 #ifndef D10
whismanoid 0:cb44e2e9ec4c 411 #define D10 P1_3
whismanoid 0:cb44e2e9ec4c 412 #endif
whismanoid 0:cb44e2e9ec4c 413 #ifndef D11
whismanoid 0:cb44e2e9ec4c 414 #define D11 P1_1
whismanoid 0:cb44e2e9ec4c 415 #endif
whismanoid 0:cb44e2e9ec4c 416 #ifndef D12
whismanoid 0:cb44e2e9ec4c 417 #define D12 P1_2
whismanoid 0:cb44e2e9ec4c 418 #endif
whismanoid 0:cb44e2e9ec4c 419 #ifndef D13
whismanoid 0:cb44e2e9ec4c 420 #define D13 P1_0
whismanoid 0:cb44e2e9ec4c 421 #endif
whismanoid 0:cb44e2e9ec4c 422 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 423 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 424 // target MAX32600
whismanoid 0:cb44e2e9ec4c 425 //
whismanoid 0:cb44e2e9ec4c 426 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 427 const float ADC_FULL_SCALE_VOLTAGE = 1.500;
whismanoid 0:cb44e2e9ec4c 428 //
whismanoid 0:cb44e2e9ec4c 429 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 430 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 431 #warning "TARGET_MAX32620FTHR not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 432 #include "MAX32620FTHR.h"
whismanoid 0:cb44e2e9ec4c 433 // Initialize I/O voltages on MAX32620FTHR board
whismanoid 0:cb44e2e9ec4c 434 MAX32620FTHR fthr(MAX32620FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 435 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 436 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 437 #warning "TARGET_MAX32620FTHR not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 438 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 439 //
whismanoid 0:cb44e2e9ec4c 440 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 441 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 15:37c83ec50ea0 442 // #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 443 #include "max32625pico.h"
whismanoid 0:cb44e2e9ec4c 444 // configure MAX32625PICO VDDIOH mode, and I/O voltages for DIP pins and SWD pins
whismanoid 0:cb44e2e9ec4c 445 MAX32625PICO pico(
whismanoid 13:184a08909405 446 // Select source of higher-voltage logic high supply VDDIOH
whismanoid 0:cb44e2e9ec4c 447 // vddioh_mode_t iohMode
whismanoid 0:cb44e2e9ec4c 448 //~ MAX32625PICO::IOH_OFF, // No connections to VDDIOH
whismanoid 0:cb44e2e9ec4c 449 //~ MAX32625PICO::IOH_DIP_IN, // VDDIOH input from DIP pin 1 (AIN0)
whismanoid 0:cb44e2e9ec4c 450 //~ MAX32625PICO::IOH_SWD_IN, // VDDIOH input from SWD pin 1
whismanoid 0:cb44e2e9ec4c 451 MAX32625PICO::IOH_3V3, // VDDIOH = 3.3V from local supply
whismanoid 0:cb44e2e9ec4c 452 //~ MAX32625PICO::IOH_DIP_OUT, // VDDIOH = 3.3V output to DIP pin 1
whismanoid 0:cb44e2e9ec4c 453 //~ MAX32625PICO::IOH_SWD_OUT, // VDDIOH = 3.3V output to SWD pin 1
whismanoid 0:cb44e2e9ec4c 454 //
whismanoid 13:184a08909405 455 // Digital I/O pin logic high voltage 1.8V or 3.3V
whismanoid 0:cb44e2e9ec4c 456 // vio_t dipVio = MAX32625PICO::VIO_1V8 or MAX32625PICO::VIO_IOH
whismanoid 13:184a08909405 457 MAX32625PICO::VIO_1V8, // 1.8V IO (local)
whismanoid 13:184a08909405 458 //~ MAX32625PICO::VIO_IOH, // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 459 //
whismanoid 13:184a08909405 460 // Software Debug logic high voltage (normally use VIO_IOH)
whismanoid 0:cb44e2e9ec4c 461 // vio_t swdVio
whismanoid 0:cb44e2e9ec4c 462 //~ MAX32625PICO::VIO_1V8 // 1.8V IO (local)
whismanoid 0:cb44e2e9ec4c 463 MAX32625PICO::VIO_IOH // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 464 );
whismanoid 0:cb44e2e9ec4c 465 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 466 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 15:37c83ec50ea0 467 // #warning "TARGET_MAX32625PICO not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 468 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 469 //
whismanoid 0:cb44e2e9ec4c 470 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 471 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 472 // TODO1: target NUCLEO_F446RE
whismanoid 0:cb44e2e9ec4c 473 //
whismanoid 0:cb44e2e9ec4c 474 // USER_BUTTON PC13
whismanoid 0:cb44e2e9ec4c 475 // LED1 is shared with SPI_SCK on NUCLEO_F446RE PA_5, so don't use LED1.
whismanoid 0:cb44e2e9ec4c 476 #define USE_LEDS 0
whismanoid 0:cb44e2e9ec4c 477 // SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
whismanoid 0:cb44e2e9ec4c 478 // Serial serial(SERIAL_TX, SERIAL_RX);
whismanoid 0:cb44e2e9ec4c 479 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 480 const float ADC_FULL_SCALE_VOLTAGE = 3.300; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 481 //
whismanoid 0:cb44e2e9ec4c 482 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 483 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 484 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 485 // TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM
whismanoid 0:cb44e2e9ec4c 486 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 487 // ______ | [ ] GND +3.3V VOUT [ ] | ______
whismanoid 0:cb44e2e9ec4c 488 // ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | ______
whismanoid 0:cb44e2e9ec4c 489 // ______ | [ ] VB USB.IF- [ ] | ______
whismanoid 0:cb44e2e9ec4c 490 // ______ | [ ] nR USB.IF+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 491 // digitalInOut0 | [ ] p5 MOSI ETHERNET.RD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 492 // digitalInOut1 | [ ] p6 MISO ETHERNET.RD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 493 // digitalInOut2 | [ ] p7 SCLK ETHERNET.TD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 494 // digitalInOut3 | [ ] p8 ETHERNET.TD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 495 // digitalInOut4 | [ ] p9 TX SDA USB.D- [ ] | ______
whismanoid 0:cb44e2e9ec4c 496 // digitalInOut5 | [ ] p10 RX SCL USB.D+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 497 // digitalInOut6 | [ ] p11 MOSI CAN-RD p30 [ ] | digitalInOut13
whismanoid 0:cb44e2e9ec4c 498 // digitalInOut7 | [ ] p12 MISO CAN-TD p29 [ ] | digitalInOut12
whismanoid 0:cb44e2e9ec4c 499 // digitalInOut8 | [ ] p13 TX SCLK SDA TX p28 [ ] | digitalInOut11
whismanoid 0:cb44e2e9ec4c 500 // digitalInOut9 | [ ] p14 RX SCL RX p27 [ ] | digitalInOut10
whismanoid 0:cb44e2e9ec4c 501 // analogIn0 | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1
whismanoid 0:cb44e2e9ec4c 502 // analogIn1 | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2
whismanoid 0:cb44e2e9ec4c 503 // analogIn2 | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3
whismanoid 0:cb44e2e9ec4c 504 // analogIn3 | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4
whismanoid 0:cb44e2e9ec4c 505 // analogIn4 | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5
whismanoid 0:cb44e2e9ec4c 506 // analogIn5 | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6
whismanoid 0:cb44e2e9ec4c 507 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 508 // AIN6 = P0.3 = TGT_SBL_RXD?
whismanoid 0:cb44e2e9ec4c 509 // AIN7 = P0.2 = TGT_SBL_TXD?
whismanoid 0:cb44e2e9ec4c 510 //
whismanoid 0:cb44e2e9ec4c 511 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 512 // LPC1768 board uses VREF = 3.300V +A3,3V thru L1 to bypass capacitor C14
whismanoid 0:cb44e2e9ec4c 513 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 514 const float ADC_FULL_SCALE_VOLTAGE = 3.300;
whismanoid 0:cb44e2e9ec4c 515 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 0:cb44e2e9ec4c 516 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 517 // unknown target
whismanoid 0:cb44e2e9ec4c 518 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 519 #endif // target definition
whismanoid 0:cb44e2e9ec4c 520
whismanoid 0:cb44e2e9ec4c 521
whismanoid 0:cb44e2e9ec4c 522
whismanoid 0:cb44e2e9ec4c 523
whismanoid 18:1235c17b451e 524 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 525 // move definiton of USE_LEDS earlier than find_digitalInOutPin()
whismanoid 18:1235c17b451e 526 //--------------------------------------------------
whismanoid 18:1235c17b451e 527 // Option to use LEDs to show status
whismanoid 18:1235c17b451e 528 #ifndef USE_LEDS
whismanoid 18:1235c17b451e 529 #define USE_LEDS 1
whismanoid 18:1235c17b451e 530 #endif
whismanoid 18:1235c17b451e 531 #if USE_LEDS
whismanoid 18:1235c17b451e 532 #if defined(TARGET_MAX32630)
whismanoid 18:1235c17b451e 533 # define LED_ON 0
whismanoid 18:1235c17b451e 534 # define LED_OFF 1
whismanoid 18:1235c17b451e 535 //--------------------------------------------------
whismanoid 18:1235c17b451e 536 #elif defined(TARGET_MAX32625MBED)
whismanoid 18:1235c17b451e 537 # define LED_ON 0
whismanoid 18:1235c17b451e 538 # define LED_OFF 1
whismanoid 19:5ff09c8e9daf 539 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 18:1235c17b451e 540 # define LED_ON 0
whismanoid 18:1235c17b451e 541 # define LED_OFF 1
whismanoid 18:1235c17b451e 542 //--------------------------------------------------
whismanoid 18:1235c17b451e 543 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 18:1235c17b451e 544 #elif defined(TARGET_LPC1768)
whismanoid 18:1235c17b451e 545 # define LED_ON 1
whismanoid 18:1235c17b451e 546 # define LED_OFF 0
whismanoid 18:1235c17b451e 547 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 18:1235c17b451e 548 // USE_LEDS with some platform other than MAX32630, MAX32625MBED, LPC1768
whismanoid 18:1235c17b451e 549 // bugfix for MAX32600MBED LED blink pattern: check if LED_ON/LED_OFF already defined
whismanoid 18:1235c17b451e 550 # ifndef LED_ON
whismanoid 18:1235c17b451e 551 # define LED_ON 0
whismanoid 18:1235c17b451e 552 # endif
whismanoid 18:1235c17b451e 553 # ifndef LED_OFF
whismanoid 18:1235c17b451e 554 # define LED_OFF 1
whismanoid 18:1235c17b451e 555 # endif
whismanoid 18:1235c17b451e 556 //# define LED_ON 1
whismanoid 18:1235c17b451e 557 //# define LED_OFF 0
whismanoid 18:1235c17b451e 558 #endif // target definition
whismanoid 18:1235c17b451e 559 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 560 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 561 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 562 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 563 // change led1/2/3/4 from DigitalOut to DigitalInOut
whismanoid 18:1235c17b451e 564 DigitalInOut led1(LED1, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED1 = LED_RED
whismanoid 18:1235c17b451e 565 DigitalInOut led2(LED2, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN
whismanoid 18:1235c17b451e 566 DigitalInOut led3(LED3, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE
whismanoid 18:1235c17b451e 567 DigitalInOut led4(LED4, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 568 #else // USE_LEDS=0
whismanoid 18:1235c17b451e 569 // issue #41 support Nucleo_F446RE
whismanoid 18:1235c17b451e 570 // there are no LED indicators on the board, LED1 interferes with SPI;
whismanoid 18:1235c17b451e 571 // but we still need placeholders led1 led2 led3 led4.
whismanoid 18:1235c17b451e 572 // Declare DigitalInOut led1 led2 led3 led4 targeting safe pins.
whismanoid 18:1235c17b451e 573 // PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false
whismanoid 18:1235c17b451e 574 # define LED_ON 0
whismanoid 18:1235c17b451e 575 # define LED_OFF 1
whismanoid 18:1235c17b451e 576 // change led1/2/3/4 from DigitalOut to DigitalInOut
whismanoid 18:1235c17b451e 577 DigitalInOut led1(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 578 DigitalInOut led2(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 579 DigitalInOut led3(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 580 DigitalInOut led4(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 581 #endif // USE_LEDS
whismanoid 18:1235c17b451e 582 #define led1_RFailLED led1
whismanoid 18:1235c17b451e 583 #define led2_GPassLED led2
whismanoid 18:1235c17b451e 584 #define led3_BBusyLED led3
whismanoid 18:1235c17b451e 585
whismanoid 21:ac062a97a71d 586 //--------------------------------------------------
whismanoid 21:ac062a97a71d 587 // use BUTTON1 trigger some action
whismanoid 21:ac062a97a71d 588 #if defined(TARGET_MAX32630)
whismanoid 21:ac062a97a71d 589 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 590 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 591 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 592 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 25:8a61cb34191d 593 // #warning "TARGET_MAX32625PICO not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 594 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 24:032f3683cb2a 595 #if MAX40108_DEMO
whismanoid 25:8a61cb34191d 596 #if HAS_I2C
whismanoid 25:8a61cb34191d 597 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 598 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 24:032f3683cb2a 599 #define BUTTON2 P3_7
whismanoid 25:8a61cb34191d 600 #else // HAS_I2C
whismanoid 25:8a61cb34191d 601 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 602 // MAX40108DEMOP2U9 no HAS_I2C: header J91.1=1V8 J91.2=P1_6(button3/'%B3!') J91.3=P1_7(button2/'%B2!') J91.4=GND
whismanoid 25:8a61cb34191d 603 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 604 #define BUTTON2 P1_7
whismanoid 25:8a61cb34191d 605 #endif // HAS_I2C
whismanoid 24:032f3683cb2a 606 #define HAS_BUTTON2_DEMO 0
whismanoid 24:032f3683cb2a 607 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 25:8a61cb34191d 608 #if HAS_I2C
whismanoid 25:8a61cb34191d 609 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 610 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 24:032f3683cb2a 611 #define BUTTON3 P3_6
whismanoid 25:8a61cb34191d 612 #else // HAS_I2C
whismanoid 25:8a61cb34191d 613 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 614 // MAX40108DEMOP2U9 no HAS_I2C: header J91.1=1V8 J91.2=P1_6(button3/'%B3!') J91.3=P1_7(button2/'%B2!') J91.4=GND
whismanoid 25:8a61cb34191d 615 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 616 #define BUTTON3 P1_6
whismanoid 25:8a61cb34191d 617 #endif // HAS_I2C
whismanoid 24:032f3683cb2a 618 #define HAS_BUTTON3_DEMO 0
whismanoid 24:032f3683cb2a 619 #define HAS_BUTTON3_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 620 // additional buttons are assigned to unused/unaccessible pins to avoid conflicts
whismanoid 29:6a9edb6e973b 621 // activate using %B4! or action_button pin=4
whismanoid 29:6a9edb6e973b 622 #define BUTTON4 P1_5
whismanoid 29:6a9edb6e973b 623 #define HAS_BUTTON4_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 624 #define BUTTON5 P1_4
whismanoid 29:6a9edb6e973b 625 #define HAS_BUTTON5_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 626 #define BUTTON6 P1_3
whismanoid 29:6a9edb6e973b 627 #define HAS_BUTTON6_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 628 #define BUTTON7 P1_2
whismanoid 29:6a9edb6e973b 629 #define HAS_BUTTON7_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 630 #define BUTTON8 P1_1
whismanoid 29:6a9edb6e973b 631 #define HAS_BUTTON8_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 632 #define BUTTON9 P1_0
whismanoid 29:6a9edb6e973b 633 #define HAS_BUTTON9_DEMO_INTERRUPT 1
whismanoid 24:032f3683cb2a 634 #else // MAX40108_DEMO
whismanoid 21:ac062a97a71d 635 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 636 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 29:6a9edb6e973b 637 #endif // MAX40108_DEMO ---------------------------------
whismanoid 21:ac062a97a71d 638 #elif defined(TARGET_MAX32625)
whismanoid 21:ac062a97a71d 639 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 640 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 641 #elif defined(TARGET_MAX32620FTHR)
whismanoid 21:ac062a97a71d 642 #warning "TARGET_MAX32620FTHR not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 643 #define BUTTON1 SW1
whismanoid 21:ac062a97a71d 644 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 645 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 646 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 647 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 21:ac062a97a71d 648 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 649 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 650 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 21:ac062a97a71d 651 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 652 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 653 #else
whismanoid 21:ac062a97a71d 654 #warning "target not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 655 #endif
whismanoid 21:ac062a97a71d 656 //
whismanoid 21:ac062a97a71d 657 #ifndef HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 658 #define HAS_BUTTON1_DEMO 0
whismanoid 21:ac062a97a71d 659 #endif
whismanoid 21:ac062a97a71d 660 #ifndef HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 661 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 662 #endif
whismanoid 24:032f3683cb2a 663 #ifndef HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 664 #define HAS_BUTTON3_DEMO 0
whismanoid 24:032f3683cb2a 665 #endif
whismanoid 21:ac062a97a71d 666 //
whismanoid 21:ac062a97a71d 667 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 668 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 669 #ifndef HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 670 #define HAS_BUTTON1_DEMO_INTERRUPT_POLLING 1
whismanoid 21:ac062a97a71d 671 #endif
whismanoid 21:ac062a97a71d 672 //
whismanoid 21:ac062a97a71d 673 #ifndef HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 674 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 675 #endif
whismanoid 21:ac062a97a71d 676 #ifndef HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 677 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 678 #endif
whismanoid 21:ac062a97a71d 679 //
whismanoid 21:ac062a97a71d 680 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 681 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 682 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 683 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 684 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 685 # else
whismanoid 21:ac062a97a71d 686 InterruptIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 687 # endif
whismanoid 21:ac062a97a71d 688 #elif HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 689 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 690 #endif
whismanoid 21:ac062a97a71d 691 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 692 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 693 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 694 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 695 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 696 # else
whismanoid 21:ac062a97a71d 697 InterruptIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 698 # endif
whismanoid 21:ac062a97a71d 699 #elif HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 700 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 701 #endif
whismanoid 24:032f3683cb2a 702 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 703 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 24:032f3683cb2a 704 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 24:032f3683cb2a 705 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 24:032f3683cb2a 706 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 707 # else
whismanoid 24:032f3683cb2a 708 InterruptIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 709 # endif
whismanoid 24:032f3683cb2a 710 #elif HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 711 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 712 #endif
whismanoid 21:ac062a97a71d 713
whismanoid 0:cb44e2e9ec4c 714 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 715 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 716 // Declare the DigitalInOut GPIO pins
whismanoid 0:cb44e2e9ec4c 717 // Optional digitalInOut support. If there is only one it should be digitalInOut1.
whismanoid 0:cb44e2e9ec4c 718 // D) Digital High/Low/Input Pin
whismanoid 0:cb44e2e9ec4c 719 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 720 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 721 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 722 // | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 723 // | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 724 // | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 725 // | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 726 // | [ ] AIN_0 1.2Vfs (bat) SYS [ ] |
whismanoid 0:cb44e2e9ec4c 727 // | [ ] AIN_1 1.2Vfs PWR [ ] |
whismanoid 0:cb44e2e9ec4c 728 // | [ ] AIN_2 1.2Vfs +5V VBUS [ ] |
whismanoid 0:cb44e2e9ec4c 729 // | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9
whismanoid 0:cb44e2e9ec4c 730 // dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8
whismanoid 0:cb44e2e9ec4c 731 // dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7
whismanoid 0:cb44e2e9ec4c 732 // dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6
whismanoid 0:cb44e2e9ec4c 733 // dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5
whismanoid 0:cb44e2e9ec4c 734 // dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4
whismanoid 0:cb44e2e9ec4c 735 // dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3
whismanoid 0:cb44e2e9ec4c 736 // dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2
whismanoid 0:cb44e2e9ec4c 737 // | [ ] GND SDA P3_4 [x] | dig1
whismanoid 0:cb44e2e9ec4c 738 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 739 #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 740 #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 741 #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 742 #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 743 #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 744 #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 745 #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 746 #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 747 #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 748 #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 749 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 750 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 751 #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 752 #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 753 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 754 #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 755 #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 756 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 757 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 758 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 759 #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 760 #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 761 #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 762 #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 763 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 764 #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 765 #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 766 #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 767 #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 768 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 769 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 770 DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 771 #endif
whismanoid 0:cb44e2e9ec4c 772 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 773 DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 774 #endif
whismanoid 0:cb44e2e9ec4c 775 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 776 DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 777 #endif
whismanoid 0:cb44e2e9ec4c 778 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 779 DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 780 #endif
whismanoid 0:cb44e2e9ec4c 781 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 782 DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 783 #endif
whismanoid 0:cb44e2e9ec4c 784 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 785 DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 786 #endif
whismanoid 0:cb44e2e9ec4c 787 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 788 DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 789 #endif
whismanoid 0:cb44e2e9ec4c 790 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 791 DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 792 #endif
whismanoid 0:cb44e2e9ec4c 793 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 794 DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 795 #endif
whismanoid 0:cb44e2e9ec4c 796 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 797 DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 798 #endif
whismanoid 0:cb44e2e9ec4c 799 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 800 DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 801 #endif
whismanoid 0:cb44e2e9ec4c 802 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 803 DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 804 #endif
whismanoid 0:cb44e2e9ec4c 805 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 806 DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 807 #endif
whismanoid 0:cb44e2e9ec4c 808 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 809 DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 810 #endif
whismanoid 0:cb44e2e9ec4c 811 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 812 DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 813 #endif
whismanoid 0:cb44e2e9ec4c 814 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 815 DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 816 #endif
whismanoid 0:cb44e2e9ec4c 817 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 818 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 819 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 820 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 821 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 822 // | |
whismanoid 0:cb44e2e9ec4c 823 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 824 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 825 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 826 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 827 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 828 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 829 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 830 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 831 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 832 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 833 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 834 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 835 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 836 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 837 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 838 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 839 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 840 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 841 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 842 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 843 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 844 // \_______________________/
whismanoid 0:cb44e2e9ec4c 845 //
whismanoid 0:cb44e2e9ec4c 846 #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 847 #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 848 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 849 #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 850 #else
whismanoid 0:cb44e2e9ec4c 851 #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 852 #endif
whismanoid 0:cb44e2e9ec4c 853 #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 854 #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 855 #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 856 #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 857 #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 858 #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 859 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 860 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 861 #else
whismanoid 0:cb44e2e9ec4c 862 #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 863 #endif
whismanoid 0:cb44e2e9ec4c 864 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 865 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 866 #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 867 #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 868 #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 869 #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 870 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 871 #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 872 #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 873 #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 874 #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 875 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 876 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 877 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 878 #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 879 #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 880 #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 881 #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 882 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 883 #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 884 #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 885 #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 886 #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 887 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 888 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 889 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 890 #endif
whismanoid 0:cb44e2e9ec4c 891 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 892 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 893 #endif
whismanoid 0:cb44e2e9ec4c 894 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 895 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 896 #endif
whismanoid 0:cb44e2e9ec4c 897 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 898 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 899 #endif
whismanoid 0:cb44e2e9ec4c 900 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 901 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 902 #endif
whismanoid 0:cb44e2e9ec4c 903 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 904 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 905 #endif
whismanoid 0:cb44e2e9ec4c 906 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 907 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 908 #endif
whismanoid 0:cb44e2e9ec4c 909 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 910 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 911 #endif
whismanoid 0:cb44e2e9ec4c 912 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 913 DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 914 #endif
whismanoid 0:cb44e2e9ec4c 915 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 916 DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 917 #endif
whismanoid 0:cb44e2e9ec4c 918 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 919 DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 920 #endif
whismanoid 0:cb44e2e9ec4c 921 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 922 DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 923 #endif
whismanoid 0:cb44e2e9ec4c 924 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 925 DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 926 #endif
whismanoid 0:cb44e2e9ec4c 927 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 928 DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 929 #endif
whismanoid 0:cb44e2e9ec4c 930 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 931 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 932 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 933 DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 934 #endif
whismanoid 0:cb44e2e9ec4c 935 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 936 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 937 DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 938 #endif
whismanoid 0:cb44e2e9ec4c 939 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 940 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 941 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 942 // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V
whismanoid 0:cb44e2e9ec4c 943 DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 944 #endif
whismanoid 0:cb44e2e9ec4c 945 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 946 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 947 DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 948 #endif
whismanoid 0:cb44e2e9ec4c 949 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 950 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 15:37c83ec50ea0 951 // TARGET=MAX32625PICO ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 15:37c83ec50ea0 952 // +-------------[microUSB]-------------+
whismanoid 15:37c83ec50ea0 953 // | [27]D+ D-[26] |
whismanoid 15:37c83ec50ea0 954 // | |
whismanoid 15:37c83ec50ea0 955 // | [BUTTON P2_7] |
whismanoid 15:37c83ec50ea0 956 // | P2_4 LED_R P2_5 LED_G P2_6 LED_B |
whismanoid 15:37c83ec50ea0 957 // | |
whismanoid 15:37c83ec50ea0 958 // 1V8 | [11] 1.8V MAX32625PICO GND [10] | GND
whismanoid 15:37c83ec50ea0 959 // 3V3 | [12] 3.3V +5V [09] | 5V0
whismanoid 15:37c83ec50ea0 960 // SPI CS D7 | [13] P0_7 CS s-ssel P4_7 [08] | D15
whismanoid 15:37c83ec50ea0 961 // SPI MISO D6 | [14] P0_6 MISO s-miso P4_6 [07] | D14
whismanoid 15:37c83ec50ea0 962 // SPI MOSI D5 | [15] P0_5 MOSI s-mosi P4_5 [06] | D13
whismanoid 15:37c83ec50ea0 963 // SPI SCLK D4 | [16] P0_4 SCLK s-sclk P4_4 [05] | D12
whismanoid 15:37c83ec50ea0 964 // D3 | [17] P0_3 RTS SCL P1_7 [04] | SCL/D17
whismanoid 15:37c83ec50ea0 965 // D2 | [18] P0_2 CTS SDA P1_6 [03] | SDA/D16
whismanoid 15:37c83ec50ea0 966 // TX/D1 | [19] P0_1 TX0 AIN_2 [02] | A2
whismanoid 15:37c83ec50ea0 967 // RX/D0 | [20] P0_0 RX0 AIN_0 [01] | A0/A4
whismanoid 15:37c83ec50ea0 968 // | |
whismanoid 15:37c83ec50ea0 969 // | DAPLINK |
whismanoid 15:37c83ec50ea0 970 // | J3 p3_3 p3_2 p3_0 p3_1 p3_7 |
whismanoid 15:37c83ec50ea0 971 // | DAP [ ] [ ] [RX2][TX2][ ] |
whismanoid 15:37c83ec50ea0 972 // | TOP [ ] [ ] [ ] [ ] [ ] |
whismanoid 15:37c83ec50ea0 973 // | AIN1/A5 gnd gnd nc AIN3 |
whismanoid 15:37c83ec50ea0 974 // | IOH 1-wire |
whismanoid 15:37c83ec50ea0 975 // | |
whismanoid 15:37c83ec50ea0 976 // |NO USE RST P2_0 P2_1 |
whismanoid 15:37c83ec50ea0 977 // |BOTTOM [ ] [ ] [RX1][ ] [TX1] |
whismanoid 15:37c83ec50ea0 978 // | RST SWC GND SWD 1V8 |
whismanoid 15:37c83ec50ea0 979 // |BOTTOM [21] [22] [23] [24] [25] |
whismanoid 15:37c83ec50ea0 980 // +------------------------------------+
whismanoid 15:37c83ec50ea0 981 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 982 // MAX40108 demo p2: D0..D7 = P0_0..P0_7; D8..15 = P4_0..P4_7; D16/D17=I2C
whismanoid 15:37c83ec50ea0 983 #endif
whismanoid 15:37c83ec50ea0 984 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 985 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 986 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 987 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 988 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 989 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 990 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 991 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 992 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 993 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 15:37c83ec50ea0 994 // AIN_10 = x undefined?
whismanoid 15:37c83ec50ea0 995 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 996 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 997 //
whismanoid 15:37c83ec50ea0 998 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 999 // avoid resource conflict D0,D1 alternate function as RX/TX
whismanoid 15:37c83ec50ea0 1000 #define HAS_digitalInOut0 0
whismanoid 15:37c83ec50ea0 1001 #define HAS_digitalInOut1 0
whismanoid 15:37c83ec50ea0 1002 #else
whismanoid 15:37c83ec50ea0 1003 #define HAS_digitalInOut0 1
whismanoid 19:5ff09c8e9daf 1004 #define HAS_digitalInOut1 1
whismanoid 19:5ff09c8e9daf 1005 // P0_1 TARGET_MAX32625PICO D1
whismanoid 15:37c83ec50ea0 1006 #endif
whismanoid 15:37c83ec50ea0 1007 #if APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 1008 // avoid resource conflict D2 alternate function as interrupt input
whismanoid 15:37c83ec50ea0 1009 #define HAS_digitalInOut2 0
whismanoid 15:37c83ec50ea0 1010 #else
whismanoid 15:37c83ec50ea0 1011 #define HAS_digitalInOut2 1
whismanoid 15:37c83ec50ea0 1012 #endif
whismanoid 15:37c83ec50ea0 1013 #define HAS_digitalInOut3 1
whismanoid 15:37c83ec50ea0 1014 #define HAS_digitalInOut4 1
whismanoid 15:37c83ec50ea0 1015 #define HAS_digitalInOut5 1
whismanoid 15:37c83ec50ea0 1016 #define HAS_digitalInOut6 1
whismanoid 15:37c83ec50ea0 1017 #define HAS_digitalInOut7 1
whismanoid 15:37c83ec50ea0 1018 //
whismanoid 15:37c83ec50ea0 1019 #define HAS_digitalInOut8 1
whismanoid 15:37c83ec50ea0 1020 #define HAS_digitalInOut9 1
whismanoid 15:37c83ec50ea0 1021 #define HAS_digitalInOut10 1
whismanoid 15:37c83ec50ea0 1022 #define HAS_digitalInOut11 1
whismanoid 15:37c83ec50ea0 1023 #define HAS_digitalInOut12 1
whismanoid 15:37c83ec50ea0 1024 #define HAS_digitalInOut13 1
whismanoid 15:37c83ec50ea0 1025 #define HAS_digitalInOut14 1
whismanoid 15:37c83ec50ea0 1026 #define HAS_digitalInOut15 1
whismanoid 15:37c83ec50ea0 1027 #if HAS_I2C
whismanoid 25:8a61cb34191d 1028 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 1029 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 25:8a61cb34191d 1030 // #define BUTTON2 P3_7
whismanoid 25:8a61cb34191d 1031 // avoid resource conflict between I2C and DigitalInOut
whismanoid 25:8a61cb34191d 1032 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1033 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 1034 #else // HAS_I2C
whismanoid 25:8a61cb34191d 1035 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 1036 // MAX40108DEMOP2U9 no HAS_I2C: header J91.1=1V8 J91.2=P1_6(button3/'%B3!') J91.3=P1_7(button2/'%B2!') J91.4=GND
whismanoid 25:8a61cb34191d 1037 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1038 // #define BUTTON2 P1_7
whismanoid 25:8a61cb34191d 1039 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1040 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1041 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1042 #else // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1043 #define HAS_digitalInOut16 1 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1044 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1045 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1046 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1047 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1048 #else // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1049 #define HAS_digitalInOut17 1 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1050 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 15:37c83ec50ea0 1051 #endif // HAS_I2C
whismanoid 15:37c83ec50ea0 1052 #if HAS_digitalInOut0
whismanoid 25:8a61cb34191d 1053 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D0
whismanoid 15:37c83ec50ea0 1054 #endif
whismanoid 15:37c83ec50ea0 1055 #if HAS_digitalInOut1
whismanoid 25:8a61cb34191d 1056 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D1
whismanoid 15:37c83ec50ea0 1057 #endif
whismanoid 15:37c83ec50ea0 1058 #if HAS_digitalInOut2
whismanoid 25:8a61cb34191d 1059 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D2
whismanoid 15:37c83ec50ea0 1060 #endif
whismanoid 15:37c83ec50ea0 1061 #if HAS_digitalInOut3
whismanoid 25:8a61cb34191d 1062 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D3
whismanoid 15:37c83ec50ea0 1063 #endif
whismanoid 15:37c83ec50ea0 1064 #if HAS_digitalInOut4
whismanoid 25:8a61cb34191d 1065 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D4
whismanoid 15:37c83ec50ea0 1066 #endif
whismanoid 15:37c83ec50ea0 1067 #if HAS_digitalInOut5
whismanoid 25:8a61cb34191d 1068 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D5
whismanoid 15:37c83ec50ea0 1069 #endif
whismanoid 15:37c83ec50ea0 1070 #if HAS_digitalInOut6
whismanoid 25:8a61cb34191d 1071 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D6
whismanoid 15:37c83ec50ea0 1072 #endif
whismanoid 15:37c83ec50ea0 1073 #if HAS_digitalInOut7
whismanoid 25:8a61cb34191d 1074 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D7
whismanoid 15:37c83ec50ea0 1075 #endif
whismanoid 15:37c83ec50ea0 1076 #if HAS_digitalInOut8
whismanoid 25:8a61cb34191d 1077 DigitalInOut digitalInOut8(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX40108DEMOP2U9 D8
whismanoid 15:37c83ec50ea0 1078 #endif
whismanoid 15:37c83ec50ea0 1079 #if HAS_digitalInOut9
whismanoid 25:8a61cb34191d 1080 DigitalInOut digitalInOut9(P4_1, PIN_INPUT, PullUp, 1); // P4_1 TARGET_MAX40108DEMOP2U9 D9
whismanoid 15:37c83ec50ea0 1081 #endif
whismanoid 15:37c83ec50ea0 1082 #if HAS_digitalInOut10
whismanoid 25:8a61cb34191d 1083 DigitalInOut digitalInOut10(P4_2, PIN_INPUT, PullUp, 1); // P4_2 TARGET_MAX40108DEMOP2U9 D10
whismanoid 15:37c83ec50ea0 1084 #endif
whismanoid 15:37c83ec50ea0 1085 #if HAS_digitalInOut11
whismanoid 25:8a61cb34191d 1086 DigitalInOut digitalInOut11(P4_3, PIN_INPUT, PullUp, 1); // P4_3 TARGET_MAX40108DEMOP2U9 D11
whismanoid 15:37c83ec50ea0 1087 #endif
whismanoid 15:37c83ec50ea0 1088 #if HAS_digitalInOut12
whismanoid 25:8a61cb34191d 1089 DigitalInOut digitalInOut12(P4_4, PIN_INPUT, PullUp, 1); // P4_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D12
whismanoid 15:37c83ec50ea0 1090 #endif
whismanoid 15:37c83ec50ea0 1091 #if HAS_digitalInOut13
whismanoid 25:8a61cb34191d 1092 DigitalInOut digitalInOut13(P4_5, PIN_INPUT, PullUp, 1); // P4_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D13
whismanoid 15:37c83ec50ea0 1093 #endif
whismanoid 15:37c83ec50ea0 1094 #if HAS_digitalInOut14
whismanoid 25:8a61cb34191d 1095 DigitalInOut digitalInOut14(P4_6, PIN_INPUT, PullUp, 1); // P4_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D14
whismanoid 15:37c83ec50ea0 1096 #endif
whismanoid 15:37c83ec50ea0 1097 #if HAS_digitalInOut15
whismanoid 25:8a61cb34191d 1098 DigitalInOut digitalInOut15(P4_7, PIN_INPUT, PullUp, 1); // P4_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D15
whismanoid 15:37c83ec50ea0 1099 #endif
whismanoid 15:37c83ec50ea0 1100 #if HAS_digitalInOut16
whismanoid 15:37c83ec50ea0 1101 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 15:37c83ec50ea0 1102 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 25:8a61cb34191d 1103 DigitalInOut digitalInOut16(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 15:37c83ec50ea0 1104 #endif
whismanoid 15:37c83ec50ea0 1105 #if HAS_digitalInOut17
whismanoid 15:37c83ec50ea0 1106 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 25:8a61cb34191d 1107 DigitalInOut digitalInOut17(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 1108 #endif
whismanoid 15:37c83ec50ea0 1109 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1110 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1111 #define HAS_digitalInOut0 0
whismanoid 0:cb44e2e9ec4c 1112 #define HAS_digitalInOut1 0
whismanoid 0:cb44e2e9ec4c 1113 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1114 // D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 1115 #define HAS_digitalInOut2 0
whismanoid 0:cb44e2e9ec4c 1116 #else
whismanoid 0:cb44e2e9ec4c 1117 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1118 #endif
whismanoid 0:cb44e2e9ec4c 1119 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1120 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1121 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1122 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1123 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1124 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1125 // D8 -- MAX5715 CLRb DigitalOut
whismanoid 0:cb44e2e9ec4c 1126 #define HAS_digitalInOut8 0
whismanoid 0:cb44e2e9ec4c 1127 #else
whismanoid 0:cb44e2e9ec4c 1128 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1129 #endif
whismanoid 0:cb44e2e9ec4c 1130 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1131 // D9 -- MAX5715 LDACb DigitalOut
whismanoid 0:cb44e2e9ec4c 1132 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1133 #elif APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1134 // D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 1135 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1136 #else
whismanoid 0:cb44e2e9ec4c 1137 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1138 #endif
whismanoid 0:cb44e2e9ec4c 1139 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 1140 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1141 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1142 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1143 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1144 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1145 #define HAS_digitalInOut10 0
whismanoid 0:cb44e2e9ec4c 1146 #define HAS_digitalInOut11 0
whismanoid 0:cb44e2e9ec4c 1147 #define HAS_digitalInOut12 0
whismanoid 0:cb44e2e9ec4c 1148 #define HAS_digitalInOut13 0
whismanoid 0:cb44e2e9ec4c 1149 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1150 #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1151 #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1152 #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1153 #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1154 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1155 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 1156 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1157 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1158 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1159 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1160 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1161 #define HAS_digitalInOut14 0
whismanoid 0:cb44e2e9ec4c 1162 #define HAS_digitalInOut15 0
whismanoid 0:cb44e2e9ec4c 1163 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1164 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1165 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1166 #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1167 #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1168 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1169 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1170 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1171 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1172 DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1173 #endif
whismanoid 0:cb44e2e9ec4c 1174 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1175 DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1176 #endif
whismanoid 0:cb44e2e9ec4c 1177 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1178 DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1179 #endif
whismanoid 0:cb44e2e9ec4c 1180 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1181 DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1182 #endif
whismanoid 0:cb44e2e9ec4c 1183 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1184 DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1185 #endif
whismanoid 0:cb44e2e9ec4c 1186 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1187 DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1188 #endif
whismanoid 0:cb44e2e9ec4c 1189 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1190 DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1191 #endif
whismanoid 0:cb44e2e9ec4c 1192 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1193 DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1194 #endif
whismanoid 0:cb44e2e9ec4c 1195 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1196 DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1197 #endif
whismanoid 0:cb44e2e9ec4c 1198 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1199 DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1200 #endif
whismanoid 0:cb44e2e9ec4c 1201 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1202 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1203 DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1204 #endif
whismanoid 0:cb44e2e9ec4c 1205 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1206 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1207 DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1208 #endif
whismanoid 0:cb44e2e9ec4c 1209 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1210 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1211 DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1212 #endif
whismanoid 0:cb44e2e9ec4c 1213 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1214 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1215 DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1216 #endif
whismanoid 0:cb44e2e9ec4c 1217 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1218 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1219 DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1220 #endif
whismanoid 0:cb44e2e9ec4c 1221 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1222 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1223 DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1224 #endif
whismanoid 0:cb44e2e9ec4c 1225 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1226 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1227 DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1228 #endif
whismanoid 0:cb44e2e9ec4c 1229 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1230 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1231 DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1232 #endif
whismanoid 0:cb44e2e9ec4c 1233 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1234 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1235 #define HAS_digitalInOut0 1
whismanoid 0:cb44e2e9ec4c 1236 #define HAS_digitalInOut1 1
whismanoid 0:cb44e2e9ec4c 1237 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1238 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1239 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1240 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1241 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1242 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1243 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1244 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1245 // #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1246 // #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1247 // #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1248 // #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1249 // #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1250 // #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1251 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1252 DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3
whismanoid 0:cb44e2e9ec4c 1253 #endif
whismanoid 0:cb44e2e9ec4c 1254 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1255 DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2
whismanoid 0:cb44e2e9ec4c 1256 #endif
whismanoid 0:cb44e2e9ec4c 1257 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1258 DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1
whismanoid 0:cb44e2e9ec4c 1259 #endif
whismanoid 0:cb44e2e9ec4c 1260 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1261 DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0
whismanoid 0:cb44e2e9ec4c 1262 #endif
whismanoid 0:cb44e2e9ec4c 1263 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1264 DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1
whismanoid 0:cb44e2e9ec4c 1265 #endif
whismanoid 0:cb44e2e9ec4c 1266 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1267 DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1
whismanoid 0:cb44e2e9ec4c 1268 #endif
whismanoid 0:cb44e2e9ec4c 1269 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1270 DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1
whismanoid 0:cb44e2e9ec4c 1271 #endif
whismanoid 0:cb44e2e9ec4c 1272 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1273 DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO
whismanoid 0:cb44e2e9ec4c 1274 #endif
whismanoid 0:cb44e2e9ec4c 1275 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1276 DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK
whismanoid 0:cb44e2e9ec4c 1277 #endif
whismanoid 0:cb44e2e9ec4c 1278 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1279 DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL
whismanoid 0:cb44e2e9ec4c 1280 #endif
whismanoid 0:cb44e2e9ec4c 1281 //
whismanoid 0:cb44e2e9ec4c 1282 // these pins support analog input analogIn0 .. analogIn5
whismanoid 0:cb44e2e9ec4c 1283 //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1284 //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1285 //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1286 //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1287 //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1288 //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1289 //
whismanoid 0:cb44e2e9ec4c 1290 // these pins support PWM pwmDriver1 .. pwmDriver6
whismanoid 0:cb44e2e9ec4c 1291 //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0
whismanoid 0:cb44e2e9ec4c 1292 //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1
whismanoid 0:cb44e2e9ec4c 1293 //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2
whismanoid 0:cb44e2e9ec4c 1294 //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3
whismanoid 0:cb44e2e9ec4c 1295 //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1
whismanoid 0:cb44e2e9ec4c 1296 //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK
whismanoid 0:cb44e2e9ec4c 1297 //
whismanoid 0:cb44e2e9ec4c 1298 // these could be additional digitalInOut pins
whismanoid 0:cb44e2e9ec4c 1299 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1300 DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1
whismanoid 0:cb44e2e9ec4c 1301 #endif
whismanoid 0:cb44e2e9ec4c 1302 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1303 DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0
whismanoid 0:cb44e2e9ec4c 1304 #endif
whismanoid 0:cb44e2e9ec4c 1305 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1306 DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1
whismanoid 0:cb44e2e9ec4c 1307 #endif
whismanoid 0:cb44e2e9ec4c 1308 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1309 DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0
whismanoid 0:cb44e2e9ec4c 1310 #endif
whismanoid 0:cb44e2e9ec4c 1311 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1312 DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1313 #endif
whismanoid 0:cb44e2e9ec4c 1314 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1315 DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1316 #endif
whismanoid 0:cb44e2e9ec4c 1317 #else
whismanoid 0:cb44e2e9ec4c 1318 // unknown target
whismanoid 0:cb44e2e9ec4c 1319 #endif
whismanoid 0:cb44e2e9ec4c 1320 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1321 #if HAS_digitalInOut0 || HAS_digitalInOut1 \
whismanoid 0:cb44e2e9ec4c 1322 || HAS_digitalInOut2 || HAS_digitalInOut3 \
whismanoid 0:cb44e2e9ec4c 1323 || HAS_digitalInOut4 || HAS_digitalInOut5 \
whismanoid 0:cb44e2e9ec4c 1324 || HAS_digitalInOut6 || HAS_digitalInOut7 \
whismanoid 0:cb44e2e9ec4c 1325 || HAS_digitalInOut8 || HAS_digitalInOut9 \
whismanoid 0:cb44e2e9ec4c 1326 || HAS_digitalInOut10 || HAS_digitalInOut11 \
whismanoid 0:cb44e2e9ec4c 1327 || HAS_digitalInOut12 || HAS_digitalInOut13 \
whismanoid 0:cb44e2e9ec4c 1328 || HAS_digitalInOut14 || HAS_digitalInOut15 \
whismanoid 0:cb44e2e9ec4c 1329 || HAS_digitalInOut16 || HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1330 #define HAS_digitalInOuts 1
whismanoid 0:cb44e2e9ec4c 1331 #else
whismanoid 0:cb44e2e9ec4c 1332 #warning "Note: There are no digitalInOut resources defined"
whismanoid 0:cb44e2e9ec4c 1333 #endif
whismanoid 0:cb44e2e9ec4c 1334
whismanoid 0:cb44e2e9ec4c 1335 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 1336 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1337 // Declare the AnalogIn driver
whismanoid 0:cb44e2e9ec4c 1338 // Optional analogIn support. If there is only one it should be analogIn1.
whismanoid 0:cb44e2e9ec4c 1339 // A) analog input
whismanoid 0:cb44e2e9ec4c 1340 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1341 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1342 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1343 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1344 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1345 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1346 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1347 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1348 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1349 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1350 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1351 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1352 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1353 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1354 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1355 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1356 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1357 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1358 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1359 #endif
whismanoid 0:cb44e2e9ec4c 1360 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1361 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1362 #endif
whismanoid 0:cb44e2e9ec4c 1363 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1364 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1365 #endif
whismanoid 0:cb44e2e9ec4c 1366 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1367 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1368 #endif
whismanoid 0:cb44e2e9ec4c 1369 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1370 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1371 #endif
whismanoid 0:cb44e2e9ec4c 1372 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1373 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1374 #endif
whismanoid 0:cb44e2e9ec4c 1375 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1376 AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1377 #endif
whismanoid 0:cb44e2e9ec4c 1378 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1379 AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1380 #endif
whismanoid 0:cb44e2e9ec4c 1381 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1382 AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1383 #endif
whismanoid 0:cb44e2e9ec4c 1384 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1385 AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1386 #endif
whismanoid 0:cb44e2e9ec4c 1387 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1388 AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1389 #endif
whismanoid 0:cb44e2e9ec4c 1390 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1391 AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1392 #endif
whismanoid 0:cb44e2e9ec4c 1393 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1394 AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1395 #endif
whismanoid 0:cb44e2e9ec4c 1396 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1397 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1398 #endif
whismanoid 0:cb44e2e9ec4c 1399 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1400 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1401 #endif
whismanoid 0:cb44e2e9ec4c 1402 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1403 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1404 #endif
whismanoid 0:cb44e2e9ec4c 1405 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1406 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 1407 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1408 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1409 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1410 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1411 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1412 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1413 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1414 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1415 #endif
whismanoid 0:cb44e2e9ec4c 1416 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1417 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1418 #endif
whismanoid 0:cb44e2e9ec4c 1419 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1420 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1421 #endif
whismanoid 0:cb44e2e9ec4c 1422 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1423 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1424 #endif
whismanoid 0:cb44e2e9ec4c 1425 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1426 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1427 #endif
whismanoid 0:cb44e2e9ec4c 1428 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1429 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1430 #endif
whismanoid 0:cb44e2e9ec4c 1431 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1432 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 1433 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1434 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1435 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1436 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1437 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1438 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1439 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1440 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1441 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1442 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1443 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1444 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1445 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1446 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1447 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1448 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1449 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1450 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1451 AnalogIn analogIn0(AIN_0); // TARGET_MAX32620FTHR J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1452 #endif
whismanoid 0:cb44e2e9ec4c 1453 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1454 AnalogIn analogIn1(AIN_1); // TARGET_MAX32620FTHR J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1455 #endif
whismanoid 0:cb44e2e9ec4c 1456 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1457 AnalogIn analogIn2(AIN_2); // TARGET_MAX32620FTHR J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1458 #endif
whismanoid 0:cb44e2e9ec4c 1459 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1460 AnalogIn analogIn3(AIN_3); // TARGET_MAX32620FTHR J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1461 #endif
whismanoid 0:cb44e2e9ec4c 1462 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1463 AnalogIn analogIn4(AIN_4); // TARGET_MAX32620FTHR J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1464 #endif
whismanoid 0:cb44e2e9ec4c 1465 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1466 AnalogIn analogIn5(AIN_5); // TARGET_MAX32620FTHR J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1467 #endif
whismanoid 0:cb44e2e9ec4c 1468 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1469 AnalogIn analogIn6(AIN_6); // TARGET_MAX32620FTHR AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1470 #endif
whismanoid 0:cb44e2e9ec4c 1471 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1472 AnalogIn analogIn7(AIN_7); // TARGET_MAX32620FTHR AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1473 #endif
whismanoid 0:cb44e2e9ec4c 1474 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1475 AnalogIn analogIn8(AIN_8); // TARGET_MAX32620FTHR AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1476 #endif
whismanoid 0:cb44e2e9ec4c 1477 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1478 AnalogIn analogIn9(AIN_9); // TARGET_MAX32620FTHR AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1479 #endif
whismanoid 0:cb44e2e9ec4c 1480 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1481 AnalogIn analogIn10(____); // TARGET_MAX32620FTHR AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1482 #endif
whismanoid 0:cb44e2e9ec4c 1483 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1484 AnalogIn analogIn11(____); // TARGET_MAX32620FTHR AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1485 #endif
whismanoid 0:cb44e2e9ec4c 1486 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1487 AnalogIn analogIn12(____); // TARGET_MAX32620FTHR AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1488 #endif
whismanoid 0:cb44e2e9ec4c 1489 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1490 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1491 #endif
whismanoid 0:cb44e2e9ec4c 1492 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1493 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1494 #endif
whismanoid 0:cb44e2e9ec4c 1495 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1496 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1497 #endif
whismanoid 0:cb44e2e9ec4c 1498 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 1499 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 37:3f369235e5bc 1500 // #warning "TARGET_MAX32625PICO not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1501 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1502 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1503 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1504 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1505 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1506 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1507 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1508 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1509 #endif
whismanoid 0:cb44e2e9ec4c 1510 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1511 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1512 #endif
whismanoid 0:cb44e2e9ec4c 1513 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1514 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1515 #endif
whismanoid 0:cb44e2e9ec4c 1516 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1517 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1518 #endif
whismanoid 0:cb44e2e9ec4c 1519 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1520 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1521 #endif
whismanoid 0:cb44e2e9ec4c 1522 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1523 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1524 #endif
whismanoid 0:cb44e2e9ec4c 1525 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1526 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 1527 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1528 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1529 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1530 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1531 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1532 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1533 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1534 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1535 #endif
whismanoid 0:cb44e2e9ec4c 1536 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1537 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1538 #endif
whismanoid 0:cb44e2e9ec4c 1539 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1540 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1541 #endif
whismanoid 0:cb44e2e9ec4c 1542 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1543 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1544 #endif
whismanoid 0:cb44e2e9ec4c 1545 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1546 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1547 #endif
whismanoid 0:cb44e2e9ec4c 1548 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1549 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1550 #endif
whismanoid 0:cb44e2e9ec4c 1551 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1552 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 1553 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1554 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1555 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1556 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1557 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1558 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1559 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1560 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1561 #endif
whismanoid 0:cb44e2e9ec4c 1562 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1563 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1564 #endif
whismanoid 0:cb44e2e9ec4c 1565 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1566 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1567 #endif
whismanoid 0:cb44e2e9ec4c 1568 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1569 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1570 #endif
whismanoid 0:cb44e2e9ec4c 1571 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1572 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1573 #endif
whismanoid 0:cb44e2e9ec4c 1574 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1575 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1576 #endif
whismanoid 0:cb44e2e9ec4c 1577 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1578 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1579 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1580 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1581 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1582 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1583 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1584 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1585 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1586 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1587 #endif
whismanoid 0:cb44e2e9ec4c 1588 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1589 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1590 #endif
whismanoid 0:cb44e2e9ec4c 1591 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1592 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1593 #endif
whismanoid 0:cb44e2e9ec4c 1594 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1595 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1596 #endif
whismanoid 0:cb44e2e9ec4c 1597 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1598 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1599 #endif
whismanoid 0:cb44e2e9ec4c 1600 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1601 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1602 #endif
whismanoid 0:cb44e2e9ec4c 1603 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1604 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 1605 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1606 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1607 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1608 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1609 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1610 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1611 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1612 // #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1613 // #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1614 // #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1615 // #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1616 // #define HAS_analogIn10 1
whismanoid 0:cb44e2e9ec4c 1617 // #define HAS_analogIn11 1
whismanoid 0:cb44e2e9ec4c 1618 // #define HAS_analogIn12 1
whismanoid 0:cb44e2e9ec4c 1619 // #define HAS_analogIn13 1
whismanoid 0:cb44e2e9ec4c 1620 // #define HAS_analogIn14 1
whismanoid 0:cb44e2e9ec4c 1621 // #define HAS_analogIn15 1
whismanoid 0:cb44e2e9ec4c 1622 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1623 AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1624 #endif
whismanoid 0:cb44e2e9ec4c 1625 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1626 AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1627 #endif
whismanoid 0:cb44e2e9ec4c 1628 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1629 AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1630 #endif
whismanoid 0:cb44e2e9ec4c 1631 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1632 AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1633 #endif
whismanoid 0:cb44e2e9ec4c 1634 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1635 AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1636 #endif
whismanoid 0:cb44e2e9ec4c 1637 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1638 AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1639 #endif
whismanoid 0:cb44e2e9ec4c 1640 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1641 AnalogIn analogIn6(____);
whismanoid 0:cb44e2e9ec4c 1642 #endif
whismanoid 0:cb44e2e9ec4c 1643 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1644 AnalogIn analogIn7(____);
whismanoid 0:cb44e2e9ec4c 1645 #endif
whismanoid 0:cb44e2e9ec4c 1646 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1647 AnalogIn analogIn8(____);
whismanoid 0:cb44e2e9ec4c 1648 #endif
whismanoid 0:cb44e2e9ec4c 1649 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1650 AnalogIn analogIn9(____);
whismanoid 0:cb44e2e9ec4c 1651 #endif
whismanoid 0:cb44e2e9ec4c 1652 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1653 AnalogIn analogIn10(____);
whismanoid 0:cb44e2e9ec4c 1654 #endif
whismanoid 0:cb44e2e9ec4c 1655 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1656 AnalogIn analogIn11(____);
whismanoid 0:cb44e2e9ec4c 1657 #endif
whismanoid 0:cb44e2e9ec4c 1658 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1659 AnalogIn analogIn12(____);
whismanoid 0:cb44e2e9ec4c 1660 #endif
whismanoid 0:cb44e2e9ec4c 1661 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1662 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1663 #endif
whismanoid 0:cb44e2e9ec4c 1664 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1665 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1666 #endif
whismanoid 0:cb44e2e9ec4c 1667 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1668 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1669 #endif
whismanoid 0:cb44e2e9ec4c 1670 #else
whismanoid 0:cb44e2e9ec4c 1671 // unknown target
whismanoid 0:cb44e2e9ec4c 1672 #endif
whismanoid 0:cb44e2e9ec4c 1673 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1674 #if HAS_analogIn0 || HAS_analogIn1 \
whismanoid 0:cb44e2e9ec4c 1675 || HAS_analogIn2 || HAS_analogIn3 \
whismanoid 0:cb44e2e9ec4c 1676 || HAS_analogIn4 || HAS_analogIn5 \
whismanoid 0:cb44e2e9ec4c 1677 || HAS_analogIn6 || HAS_analogIn7 \
whismanoid 0:cb44e2e9ec4c 1678 || HAS_analogIn8 || HAS_analogIn9 \
whismanoid 0:cb44e2e9ec4c 1679 || HAS_analogIn10 || HAS_analogIn11 \
whismanoid 0:cb44e2e9ec4c 1680 || HAS_analogIn12 || HAS_analogIn13 \
whismanoid 0:cb44e2e9ec4c 1681 || HAS_analogIn14 || HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1682 #define HAS_analogIns 1
whismanoid 0:cb44e2e9ec4c 1683 #else
whismanoid 0:cb44e2e9ec4c 1684 #warning "Note: There are no analogIn resources defined"
whismanoid 0:cb44e2e9ec4c 1685 #endif
whismanoid 0:cb44e2e9ec4c 1686
whismanoid 0:cb44e2e9ec4c 1687 // DigitalInOut pin resource: print the pin index names to serial
whismanoid 0:cb44e2e9ec4c 1688 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 1689 void list_digitalInOutPins(Stream& serialStream)
whismanoid 0:cb44e2e9ec4c 1690 {
whismanoid 0:cb44e2e9ec4c 1691 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1692 serialStream.printf(" 0");
whismanoid 0:cb44e2e9ec4c 1693 #endif
whismanoid 0:cb44e2e9ec4c 1694 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1695 serialStream.printf(" 1");
whismanoid 0:cb44e2e9ec4c 1696 #endif
whismanoid 0:cb44e2e9ec4c 1697 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1698 serialStream.printf(" 2");
whismanoid 0:cb44e2e9ec4c 1699 #endif
whismanoid 0:cb44e2e9ec4c 1700 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1701 serialStream.printf(" 3");
whismanoid 0:cb44e2e9ec4c 1702 #endif
whismanoid 0:cb44e2e9ec4c 1703 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1704 serialStream.printf(" 4");
whismanoid 0:cb44e2e9ec4c 1705 #endif
whismanoid 0:cb44e2e9ec4c 1706 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1707 serialStream.printf(" 5");
whismanoid 0:cb44e2e9ec4c 1708 #endif
whismanoid 0:cb44e2e9ec4c 1709 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1710 serialStream.printf(" 6");
whismanoid 0:cb44e2e9ec4c 1711 #endif
whismanoid 0:cb44e2e9ec4c 1712 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1713 serialStream.printf(" 7");
whismanoid 0:cb44e2e9ec4c 1714 #endif
whismanoid 0:cb44e2e9ec4c 1715 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1716 serialStream.printf(" 8");
whismanoid 0:cb44e2e9ec4c 1717 #endif
whismanoid 0:cb44e2e9ec4c 1718 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1719 serialStream.printf(" 9");
whismanoid 0:cb44e2e9ec4c 1720 #endif
whismanoid 0:cb44e2e9ec4c 1721 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1722 serialStream.printf(" 10");
whismanoid 0:cb44e2e9ec4c 1723 #endif
whismanoid 0:cb44e2e9ec4c 1724 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1725 serialStream.printf(" 11");
whismanoid 0:cb44e2e9ec4c 1726 #endif
whismanoid 0:cb44e2e9ec4c 1727 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1728 serialStream.printf(" 12");
whismanoid 0:cb44e2e9ec4c 1729 #endif
whismanoid 0:cb44e2e9ec4c 1730 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1731 serialStream.printf(" 13");
whismanoid 0:cb44e2e9ec4c 1732 #endif
whismanoid 0:cb44e2e9ec4c 1733 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1734 serialStream.printf(" 14");
whismanoid 0:cb44e2e9ec4c 1735 #endif
whismanoid 0:cb44e2e9ec4c 1736 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1737 serialStream.printf(" 15");
whismanoid 0:cb44e2e9ec4c 1738 #endif
whismanoid 0:cb44e2e9ec4c 1739 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1740 serialStream.printf(" 16");
whismanoid 0:cb44e2e9ec4c 1741 #endif
whismanoid 0:cb44e2e9ec4c 1742 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1743 serialStream.printf(" 17");
whismanoid 0:cb44e2e9ec4c 1744 #endif
whismanoid 18:1235c17b451e 1745 #if USE_LEDS
whismanoid 18:1235c17b451e 1746 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 1747 // support list_digitalInOutPins() listing buttons and leds as pin numbers 90/91/92/93
whismanoid 18:1235c17b451e 1748 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 1749 //~ serialStream.printf(" 90");
whismanoid 18:1235c17b451e 1750 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 1751 serialStream.printf(" 91");
whismanoid 18:1235c17b451e 1752 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 1753 serialStream.printf(" 92");
whismanoid 18:1235c17b451e 1754 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 1755 serialStream.printf(" 93");
whismanoid 18:1235c17b451e 1756 #else // USE_LEDS
whismanoid 18:1235c17b451e 1757 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 1758 }
whismanoid 0:cb44e2e9ec4c 1759 #endif
whismanoid 0:cb44e2e9ec4c 1760
whismanoid 0:cb44e2e9ec4c 1761
whismanoid 0:cb44e2e9ec4c 1762 // DigitalInOut pin resource: search index
whismanoid 0:cb44e2e9ec4c 1763 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 1764 DigitalInOut& find_digitalInOutPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 1765 {
whismanoid 0:cb44e2e9ec4c 1766 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 1767 {
whismanoid 0:cb44e2e9ec4c 1768 default: // default to the first defined digitalInOut pin
whismanoid 0:cb44e2e9ec4c 1769 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1770 case '0': case 0x00: return digitalInOut0;
whismanoid 0:cb44e2e9ec4c 1771 #endif
whismanoid 0:cb44e2e9ec4c 1772 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1773 case '1': case 0x01: return digitalInOut1;
whismanoid 0:cb44e2e9ec4c 1774 #endif
whismanoid 0:cb44e2e9ec4c 1775 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1776 case '2': case 0x02: return digitalInOut2;
whismanoid 0:cb44e2e9ec4c 1777 #endif
whismanoid 0:cb44e2e9ec4c 1778 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1779 case '3': case 0x03: return digitalInOut3;
whismanoid 0:cb44e2e9ec4c 1780 #endif
whismanoid 0:cb44e2e9ec4c 1781 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1782 case '4': case 0x04: return digitalInOut4;
whismanoid 0:cb44e2e9ec4c 1783 #endif
whismanoid 0:cb44e2e9ec4c 1784 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1785 case '5': case 0x05: return digitalInOut5;
whismanoid 0:cb44e2e9ec4c 1786 #endif
whismanoid 0:cb44e2e9ec4c 1787 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1788 case '6': case 0x06: return digitalInOut6;
whismanoid 0:cb44e2e9ec4c 1789 #endif
whismanoid 0:cb44e2e9ec4c 1790 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1791 case '7': case 0x07: return digitalInOut7;
whismanoid 0:cb44e2e9ec4c 1792 #endif
whismanoid 0:cb44e2e9ec4c 1793 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1794 case '8': case 0x08: return digitalInOut8;
whismanoid 0:cb44e2e9ec4c 1795 #endif
whismanoid 0:cb44e2e9ec4c 1796 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1797 case '9': case 0x09: return digitalInOut9;
whismanoid 0:cb44e2e9ec4c 1798 #endif
whismanoid 0:cb44e2e9ec4c 1799 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1800 case 'a': case 0x0a: return digitalInOut10;
whismanoid 0:cb44e2e9ec4c 1801 #endif
whismanoid 0:cb44e2e9ec4c 1802 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1803 case 'b': case 0x0b: return digitalInOut11;
whismanoid 0:cb44e2e9ec4c 1804 #endif
whismanoid 0:cb44e2e9ec4c 1805 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1806 case 'c': case 0x0c: return digitalInOut12;
whismanoid 0:cb44e2e9ec4c 1807 #endif
whismanoid 0:cb44e2e9ec4c 1808 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1809 case 'd': case 0x0d: return digitalInOut13;
whismanoid 0:cb44e2e9ec4c 1810 #endif
whismanoid 0:cb44e2e9ec4c 1811 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1812 case 'e': case 0x0e: return digitalInOut14;
whismanoid 0:cb44e2e9ec4c 1813 #endif
whismanoid 0:cb44e2e9ec4c 1814 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1815 case 'f': case 0x0f: return digitalInOut15;
whismanoid 0:cb44e2e9ec4c 1816 #endif
whismanoid 0:cb44e2e9ec4c 1817 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1818 case 'g': case 0x10: return digitalInOut16;
whismanoid 0:cb44e2e9ec4c 1819 #endif
whismanoid 0:cb44e2e9ec4c 1820 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1821 case 'h': case 0x11: return digitalInOut17;
whismanoid 0:cb44e2e9ec4c 1822 #endif
whismanoid 18:1235c17b451e 1823 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 1824 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 1825 //~ case 90: return button1;
whismanoid 18:1235c17b451e 1826 #if USE_LEDS
whismanoid 18:1235c17b451e 1827 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 1828 case 91: return led1_RFailLED;
whismanoid 18:1235c17b451e 1829 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 1830 case 92: return led2_GPassLED;
whismanoid 18:1235c17b451e 1831 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 1832 case 93: return led3_BBusyLED;
whismanoid 18:1235c17b451e 1833 #else // USE_LEDS
whismanoid 18:1235c17b451e 1834 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 1835 }
whismanoid 0:cb44e2e9ec4c 1836 }
whismanoid 0:cb44e2e9ec4c 1837 #endif
whismanoid 0:cb44e2e9ec4c 1838
whismanoid 0:cb44e2e9ec4c 1839
whismanoid 0:cb44e2e9ec4c 1840 // AnalogIn pin resource: search index
whismanoid 0:cb44e2e9ec4c 1841 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 1842 AnalogIn& find_analogInPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 1843 {
whismanoid 0:cb44e2e9ec4c 1844 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 1845 {
whismanoid 0:cb44e2e9ec4c 1846 default: // default to the first defined analogIn pin
whismanoid 0:cb44e2e9ec4c 1847 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1848 case '0': case 0x00: return analogIn0;
whismanoid 0:cb44e2e9ec4c 1849 #endif
whismanoid 0:cb44e2e9ec4c 1850 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1851 case '1': case 0x01: return analogIn1;
whismanoid 0:cb44e2e9ec4c 1852 #endif
whismanoid 0:cb44e2e9ec4c 1853 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1854 case '2': case 0x02: return analogIn2;
whismanoid 0:cb44e2e9ec4c 1855 #endif
whismanoid 0:cb44e2e9ec4c 1856 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1857 case '3': case 0x03: return analogIn3;
whismanoid 0:cb44e2e9ec4c 1858 #endif
whismanoid 0:cb44e2e9ec4c 1859 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1860 case '4': case 0x04: return analogIn4;
whismanoid 0:cb44e2e9ec4c 1861 #endif
whismanoid 0:cb44e2e9ec4c 1862 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1863 case '5': case 0x05: return analogIn5;
whismanoid 0:cb44e2e9ec4c 1864 #endif
whismanoid 0:cb44e2e9ec4c 1865 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1866 case '6': case 0x06: return analogIn6;
whismanoid 0:cb44e2e9ec4c 1867 #endif
whismanoid 0:cb44e2e9ec4c 1868 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1869 case '7': case 0x07: return analogIn7;
whismanoid 0:cb44e2e9ec4c 1870 #endif
whismanoid 0:cb44e2e9ec4c 1871 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1872 case '8': case 0x08: return analogIn8;
whismanoid 0:cb44e2e9ec4c 1873 #endif
whismanoid 0:cb44e2e9ec4c 1874 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1875 case '9': case 0x09: return analogIn9;
whismanoid 0:cb44e2e9ec4c 1876 #endif
whismanoid 0:cb44e2e9ec4c 1877 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1878 case 'a': case 0x0a: return analogIn10;
whismanoid 0:cb44e2e9ec4c 1879 #endif
whismanoid 0:cb44e2e9ec4c 1880 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1881 case 'b': case 0x0b: return analogIn11;
whismanoid 0:cb44e2e9ec4c 1882 #endif
whismanoid 0:cb44e2e9ec4c 1883 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1884 case 'c': case 0x0c: return analogIn12;
whismanoid 0:cb44e2e9ec4c 1885 #endif
whismanoid 0:cb44e2e9ec4c 1886 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1887 case 'd': case 0x0d: return analogIn13;
whismanoid 0:cb44e2e9ec4c 1888 #endif
whismanoid 0:cb44e2e9ec4c 1889 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1890 case 'e': case 0x0e: return analogIn14;
whismanoid 0:cb44e2e9ec4c 1891 #endif
whismanoid 0:cb44e2e9ec4c 1892 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1893 case 'f': case 0x0f: return analogIn15;
whismanoid 0:cb44e2e9ec4c 1894 #endif
whismanoid 0:cb44e2e9ec4c 1895 }
whismanoid 0:cb44e2e9ec4c 1896 }
whismanoid 0:cb44e2e9ec4c 1897 #endif
whismanoid 0:cb44e2e9ec4c 1898
whismanoid 0:cb44e2e9ec4c 1899 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 1900 const float analogInPin_fullScaleVoltage[] = {
whismanoid 0:cb44e2e9ec4c 1901 # if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1902 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1903 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1904 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1905 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1906 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1907 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1908 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1909 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1910 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1911 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1912 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1913 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1914 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1915 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1916 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1917 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1918 # elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 1919 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1920 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1921 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1922 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1923 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1924 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1925 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1926 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1927 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1928 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1929 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1930 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1931 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1932 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1933 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1934 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1935 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 19:5ff09c8e9daf 1936 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 1937 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1938 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1939 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1940 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1941 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1942 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1943 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1944 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1945 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1946 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1947 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1948 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1949 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1950 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1951 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1952 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1953 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 1954 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1955 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1956 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1957 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1958 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1959 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1960 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1961 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1962 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1963 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 1964 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 1965 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 1966 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 1967 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1968 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1969 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1970 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1971 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1972 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1973 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1974 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1975 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1976 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1977 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1978 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1979 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1980 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 1981 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 1982 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 1983 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 1984 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1985 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1986 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1987 //#elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1988 #else
whismanoid 0:cb44e2e9ec4c 1989 // unknown target
whismanoid 0:cb44e2e9ec4c 1990 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1991 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1992 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1993 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1994 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1995 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1996 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1997 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1998 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1999 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 2000 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 2001 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 2002 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 2003 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2004 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2005 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2006 # endif
whismanoid 0:cb44e2e9ec4c 2007 };
whismanoid 0:cb44e2e9ec4c 2008 #endif
whismanoid 0:cb44e2e9ec4c 2009
whismanoid 0:cb44e2e9ec4c 2010
whismanoid 0:cb44e2e9ec4c 2011
whismanoid 0:cb44e2e9ec4c 2012
whismanoid 0:cb44e2e9ec4c 2013 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2014 // TODO support CmdLine command menus (like on Serial_Tester)
whismanoid 4:d9b05924ad4c 2015 #ifndef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 2016 #define USE_CMDLINE_MENUS 1
whismanoid 4:d9b05924ad4c 2017 //~ #undef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 2018 #endif
whismanoid 4:d9b05924ad4c 2019 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2020 #include "CmdLine.h"
whismanoid 4:d9b05924ad4c 2021 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2022 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2023 extern CmdLine cmdLine; // declared later
whismanoid 4:d9b05924ad4c 2024 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2025
whismanoid 4:d9b05924ad4c 2026 //--------------------------------------------------
whismanoid 39:4d285e961435 2027 // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2028 #ifndef USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 2029 #define USE_DATALOGGER_SLEEP 1
whismanoid 39:4d285e961435 2030 //~ #undef USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 2031 #endif
whismanoid 39:4d285e961435 2032 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2033 // TODO: USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2034 #endif
whismanoid 39:4d285e961435 2035 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2036 typedef enum Datalogger_Sleep_enum_t {
whismanoid 39:4d285e961435 2037 datalogger_Sleep_LP0_Stop = 0,
whismanoid 39:4d285e961435 2038 datalogger_Sleep_LP1_DeepSleep = 1,
whismanoid 39:4d285e961435 2039 datalogger_Sleep_LP2_Sleep = 2,
whismanoid 39:4d285e961435 2040 datalogger_Sleep_LP3_Run = 3,
whismanoid 39:4d285e961435 2041 } Datalogger_Sleep_enum_t;
whismanoid 39:4d285e961435 2042 // TODO: USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2043 Datalogger_Sleep_enum_t g_timer_sleepmode = datalogger_Sleep_LP3_Run;
whismanoid 39:4d285e961435 2044 #endif
whismanoid 39:4d285e961435 2045
whismanoid 39:4d285e961435 2046 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2047 // Datalog trigger types
whismanoid 4:d9b05924ad4c 2048 #ifndef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 2049 #define USE_DATALOGGER_TRIGGER 1
whismanoid 4:d9b05924ad4c 2050 //~ #undef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 2051 #endif
whismanoid 4:d9b05924ad4c 2052 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 2053 typedef enum Datalogger_Trigger_enum_t {
whismanoid 4:d9b05924ad4c 2054 trigger_Halt = 0, //!< halt
whismanoid 4:d9b05924ad4c 2055 trigger_FreeRun = 1, //!< free run as fast as possible
whismanoid 4:d9b05924ad4c 2056 trigger_Timer = 2, //!< timer (configure interval)
whismanoid 4:d9b05924ad4c 2057 trigger_PlatformDigitalInput, //!< platform digital input (configure digital input pin reference)
whismanoid 4:d9b05924ad4c 2058 trigger_SPIDeviceRegRead, //!< SPI device register read (configure regaddr, mask value, match value)
whismanoid 4:d9b05924ad4c 2059 } Datalogger_Trigger_enum_t;
whismanoid 4:d9b05924ad4c 2060 Datalogger_Trigger_enum_t Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 2061 //
whismanoid 17:9397ea3ea7e9 2062 // configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 2063 int g_timer_interval_msec = 500; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2064 int g_timer_interval_count = 10; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2065 int g_timer_interval_counter = 0; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2066 //
whismanoid 17:9397ea3ea7e9 2067 // TODO: configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 2068 //
whismanoid 17:9397ea3ea7e9 2069 // TODO: configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2070 //
whismanoid 4:d9b05924ad4c 2071 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 2072
whismanoid 4:d9b05924ad4c 2073 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2074 // support trigger_SPIDeviceRegRead: Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 2075 #ifndef USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2076 #define USE_DATALOGGER_SPIDeviceRegRead 0
whismanoid 17:9397ea3ea7e9 2077 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2078 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2079 // TODO: uint16_t regAddr;
whismanoid 17:9397ea3ea7e9 2080 // TODO: uint16_t regDataMask;
whismanoid 17:9397ea3ea7e9 2081 // TODO: uint16_t regDataTest;
whismanoid 17:9397ea3ea7e9 2082 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2083
whismanoid 17:9397ea3ea7e9 2084 //--------------------------------------------------
whismanoid 30:07197a430869 2085 // support Datalogger_PrintRow() print gstrRemarkText field from recent #remark
whismanoid 30:07197a430869 2086 #ifndef USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2087 #define USE_DATALOGGER_REMARK_FIELD 1
whismanoid 30:07197a430869 2088 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2089 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2090 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark
whismanoid 30:07197a430869 2091 const size_t gstrRemarkTextLASTINDEX = 40; // gstrRemarkText buffer size - 1
whismanoid 30:07197a430869 2092 char gstrRemarkText[gstrRemarkTextLASTINDEX+1] = "";
whismanoid 30:07197a430869 2093 char gstrRemarkHeader[] = "comment"; // comment or remark?
whismanoid 30:07197a430869 2094 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2095
whismanoid 30:07197a430869 2096 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2097 // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2098 #ifndef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2099 #define USE_DATALOGGER_ActionTable 1
whismanoid 17:9397ea3ea7e9 2100 //~ #undef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2101 #endif
whismanoid 17:9397ea3ea7e9 2102 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2103 //
whismanoid 17:9397ea3ea7e9 2104 // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2105 typedef enum action_type_enum_t {
whismanoid 17:9397ea3ea7e9 2106 action_noop = 0, // no operation
whismanoid 30:07197a430869 2107 action_digitalOutLow = 1, // pin = low if condition
whismanoid 30:07197a430869 2108 action_digitalOutHigh = 2, // pin = high if condition
whismanoid 30:07197a430869 2109 action_button = 3, // pin = button event index 1, 2, 3
whismanoid 30:07197a430869 2110 action_trigger_Halt = 4,
whismanoid 30:07197a430869 2111 action_trigger_FreeRun = 5,
whismanoid 30:07197a430869 2112 action_trigger_Timer = 6,
whismanoid 30:07197a430869 2113 action_trigger_PlatformDigitalInput = 7,
whismanoid 30:07197a430869 2114 action_trigger_SPIDeviceRegRead = 8,
whismanoid 17:9397ea3ea7e9 2115 } action_type_enum_t;
whismanoid 17:9397ea3ea7e9 2116 //
whismanoid 17:9397ea3ea7e9 2117 // Datalogger_RunActionTable() supported conditions
whismanoid 17:9397ea3ea7e9 2118 typedef enum action_condition_enum_t {
whismanoid 17:9397ea3ea7e9 2119 condition_always = 0, // ( true )
whismanoid 17:9397ea3ea7e9 2120 condition_if_An_gt_threshold, // (Platform_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2121 condition_if_An_lt_threshold, // (Platform_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2122 condition_if_An_eq_threshold, // (Platform_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2123 condition_if_An_ge_threshold, // (Platform_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2124 condition_if_An_le_threshold, // (Platform_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2125 condition_if_An_ne_threshold, // (Platform_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2126 condition_if_AINn_gt_threshold, // (SPI_AIN_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2127 condition_if_AINn_lt_threshold, // (SPI_AIN_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2128 condition_if_AINn_eq_threshold, // (SPI_AIN_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2129 condition_if_AINn_ge_threshold, // (SPI_AIN_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2130 condition_if_AINn_le_threshold, // (SPI_AIN_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2131 condition_if_AINn_ne_threshold, // (SPI_AIN_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2132 } condition_enum_t;
whismanoid 17:9397ea3ea7e9 2133 //
whismanoid 17:9397ea3ea7e9 2134 // Datalogger_RunActionTable() structure
whismanoid 17:9397ea3ea7e9 2135 typedef struct action_table_row_t {
whismanoid 17:9397ea3ea7e9 2136 action_type_enum_t action;
whismanoid 17:9397ea3ea7e9 2137 int digitalOutPin;
whismanoid 17:9397ea3ea7e9 2138 action_condition_enum_t condition;
whismanoid 17:9397ea3ea7e9 2139 int condition_channel;
whismanoid 17:9397ea3ea7e9 2140 double condition_threshold;
whismanoid 17:9397ea3ea7e9 2141 } action_table_row_t;
whismanoid 17:9397ea3ea7e9 2142 #if MAX40108_DEMO
whismanoid 39:4d285e961435 2143 # ifdef BOARD_SERIAL_NUMBER
whismanoid 39:4d285e961435 2144 // data unique to certain boards based on serial number
whismanoid 39:4d285e961435 2145 // channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 39:4d285e961435 2146 # if (BOARD_SERIAL_NUMBER) == 1
whismanoid 39:4d285e961435 2147 #warning "(BOARD_SERIAL_NUMBER) == 1 -- logic uses A3(CE) instead of A2(WE)"
whismanoid 39:4d285e961435 2148 const int channel_WE = 3; // use channel_CE instead on proto board s/n 1 for diagnostics; easier to sweep values
whismanoid 39:4d285e961435 2149 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 39:4d285e961435 2150 #warning "(BOARD_SERIAL_NUMBER) == 5 -- logic uses A3(CE) instead of A2(WE)"
whismanoid 39:4d285e961435 2151 const int channel_WE = 3; // use channel_CE instead on proto board s/n 1 for diagnostics; easier to sweep values
whismanoid 39:4d285e961435 2152 # else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 17:9397ea3ea7e9 2153 const int channel_WE = 2;
whismanoid 39:4d285e961435 2154 # endif
whismanoid 39:4d285e961435 2155 # endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 17:9397ea3ea7e9 2156 const double threshold_WE_0V5 = 0.5;
whismanoid 17:9397ea3ea7e9 2157 const double threshold_WE_0V6 = 0.6;
whismanoid 17:9397ea3ea7e9 2158 const double threshold_WE_0V7 = 0.7;
whismanoid 18:1235c17b451e 2159 const int pin_LED_1 = 91; // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 2160 const int pin_LED_2 = 92; // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 2161 const int pin_LED_3 = 93; // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 17:9397ea3ea7e9 2162 #endif
whismanoid 17:9397ea3ea7e9 2163 const int ACTION_TABLE_ROW_MAX = 20;
whismanoid 17:9397ea3ea7e9 2164 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2165 bool Datalogger_action_table_enabled = true;
whismanoid 30:07197a430869 2166 int Datalogger_action_table_row_count = 8; // assert (Datalogger_action_table_row_count <= ACTION_TABLE_ROW_MAX)
whismanoid 17:9397ea3ea7e9 2167 #else // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2168 int Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 2169 #endif // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2170 action_table_row_t Datalogger_action_table[ACTION_TABLE_ROW_MAX] = {
whismanoid 17:9397ea3ea7e9 2171 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2172 // LED indicator show (WE > 0.5V)
whismanoid 18:1235c17b451e 2173 // L@0 act=1 pin=92 if=1 ch=2 x=0.500000 -- digitalOutLow D92 if A2 > 0.500000
whismanoid 18:1235c17b451e 2174 {action_digitalOutLow, pin_LED_2, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V5},
whismanoid 17:9397ea3ea7e9 2175 //
whismanoid 17:9397ea3ea7e9 2176 // LED indicator show (WE > 0.6V)
whismanoid 18:1235c17b451e 2177 // L@1 act=1 pin=93 if=1 ch=2 x=0.600000 -- digitalOutLow D93 if A2 > 0.600000
whismanoid 18:1235c17b451e 2178 {action_digitalOutLow, pin_LED_3, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 17:9397ea3ea7e9 2179 //
whismanoid 17:9397ea3ea7e9 2180 // switch to always-on mode `trigger_FreeRun` if (WE > 0.7V)
whismanoid 29:6a9edb6e973b 2181 // L@2 act=5 if=1 ch=2 x=0.700000 -- trigger_FreeRun if A2 > 0.700000
whismanoid 17:9397ea3ea7e9 2182 {action_trigger_FreeRun, 0, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 17:9397ea3ea7e9 2183 //
whismanoid 17:9397ea3ea7e9 2184 // switch to intermittent-sleep-mode `trigger_Timer` if (WE < 0.6V)
whismanoid 29:6a9edb6e973b 2185 // L@3 act=6 if=2 ch=2 x=0.600000 -- trigger_Timer(10 x 500msec) if A2 < 0.600000
whismanoid 17:9397ea3ea7e9 2186 {action_trigger_Timer, 0, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 18:1235c17b451e 2187 //
whismanoid 18:1235c17b451e 2188 // LED indicator show (`Datalogger_Trigger` == `trigger_FreeRun`)
whismanoid 18:1235c17b451e 2189 // {action_noop, 0, condition_always, 0, 0},
whismanoid 18:1235c17b451e 2190 // L@4 act=1 pin=91 if=1 ch=2 x=0.700000 -- digitalOutLow D91 if A2 > 0.700000
whismanoid 18:1235c17b451e 2191 {action_digitalOutLow, pin_LED_1, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 18:1235c17b451e 2192 //
whismanoid 18:1235c17b451e 2193 // L@5 act=2 pin=91 if=2 ch=2 x=0.600000 -- digitalOutHigh D91 if A2 < 0.600000
whismanoid 18:1235c17b451e 2194 {action_digitalOutHigh, pin_LED_1, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 18:1235c17b451e 2195 //
whismanoid 30:07197a430869 2196 // L@6 act=3 pin=4 if=1 ch=2 x=0.700000 -- button 4 event if A2 > 0.700000
whismanoid 30:07197a430869 2197 {action_button, 4, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 29:6a9edb6e973b 2198 //
whismanoid 30:07197a430869 2199 // L@7 act=3 pin=5 if=2 ch=2 x=0.600000 -- button 5 event if A2 < 0.600000
whismanoid 30:07197a430869 2200 {action_button, 5, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 29:6a9edb6e973b 2201 //
whismanoid 17:9397ea3ea7e9 2202 #endif // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2203 //
whismanoid 17:9397ea3ea7e9 2204 {action_noop, 0, condition_always, 0, 0},
whismanoid 17:9397ea3ea7e9 2205 };
whismanoid 17:9397ea3ea7e9 2206 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2207
whismanoid 17:9397ea3ea7e9 2208 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2209 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 2210 uint8_t Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 2211 uint8_t need_reinit = true;
whismanoid 8:dffee7509bfb 2212 void Datalogger_PrintHeader(CmdLine& cmdLine);
whismanoid 5:aaf8b5f5fda1 2213 void Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 2214 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2215 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 2216 void Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 2217 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 8:dffee7509bfb 2218 void Datalogger_PrintRow(CmdLine& cmdLine);
whismanoid 4:d9b05924ad4c 2219
whismanoid 4:d9b05924ad4c 2220 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 2221 // Option to validate SPI link by reading PART_ID register
whismanoid 0:cb44e2e9ec4c 2222 #ifndef VERIFY_PART_ID_IN_LOOP
whismanoid 3:9055e17e181a 2223 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 2224 #define VERIFY_PART_ID_IN_LOOP 1
whismanoid 3:9055e17e181a 2225 #else
whismanoid 0:cb44e2e9ec4c 2226 #define VERIFY_PART_ID_IN_LOOP 0
whismanoid 3:9055e17e181a 2227 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2228 #endif
whismanoid 0:cb44e2e9ec4c 2229
whismanoid 3:9055e17e181a 2230 //--------------------------------------------------
whismanoid 3:9055e17e181a 2231 #define NUM_DUT_ANALOG_IN_CHANNELS 10
whismanoid 3:9055e17e181a 2232
whismanoid 3:9055e17e181a 2233 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 2234 // MAX11410 individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 3:9055e17e181a 2235 typedef enum SPI_AIN_Enable_t {
whismanoid 10:04022a61b527 2236 SPI_AIN_Disable = 0,
whismanoid 10:04022a61b527 2237 SPI_AIN_Enable_LSB = 1,
whismanoid 10:04022a61b527 2238 SPI_AIN_Enable_Volt = 2,
whismanoid 3:9055e17e181a 2239 } SPI_AIN_Enable_t;
whismanoid 3:9055e17e181a 2240 uint8_t SPI_AIN_Enable_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 2241 SPI_AIN_Enable_LSB, // AIN0 1=LSB
whismanoid 10:04022a61b527 2242 SPI_AIN_Enable_LSB, // AIN1 1=LSB
whismanoid 10:04022a61b527 2243 SPI_AIN_Enable_LSB, // AIN2 1=LSB
whismanoid 10:04022a61b527 2244 SPI_AIN_Enable_LSB, // AIN3 1=LSB
whismanoid 10:04022a61b527 2245 SPI_AIN_Enable_LSB, // AIN4 1=LSB
whismanoid 10:04022a61b527 2246 SPI_AIN_Enable_LSB, // AIN5 1=LSB
whismanoid 10:04022a61b527 2247 SPI_AIN_Enable_LSB, // AIN6 1=LSB
whismanoid 10:04022a61b527 2248 SPI_AIN_Enable_LSB, // AIN7 1=LSB
whismanoid 10:04022a61b527 2249 SPI_AIN_Enable_LSB, // AIN8 1=LSB
whismanoid 10:04022a61b527 2250 SPI_AIN_Enable_LSB, // AIN9 1=LSB
whismanoid 3:9055e17e181a 2251 };
whismanoid 3:9055e17e181a 2252 //
whismanoid 10:04022a61b527 2253 double SPI_AIN_Voltage[NUM_DUT_ANALOG_IN_CHANNELS];
whismanoid 13:184a08909405 2254 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2255 #ifndef HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 2256 #define HAS_SPI_AIN_customChannelHeader 0
whismanoid 13:184a08909405 2257 #endif
whismanoid 13:184a08909405 2258 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2259 const char* const SPI_AIN_customChannelHeader_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 2260 "", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 2261 "", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 2262 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 2263 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 2264 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 2265 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 2266 };
whismanoid 13:184a08909405 2267 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 3:9055e17e181a 2268 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2269 // ---------- Measure_Voltage_custom_props in Measure_Voltage @pre and in class properties ----------
whismanoid 3:9055e17e181a 2270 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 2271 // MAX11410 specific per-channel config register v_filter
whismanoid 3:9055e17e181a 2272 uint8_t SPI_AIN_Cfg_v_filter_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2273 0x34, // AIN0 @ v_filter=0x34
whismanoid 3:9055e17e181a 2274 0x34, // AIN1 @ v_filter=0x34
whismanoid 3:9055e17e181a 2275 0x34, // AIN2 @ v_filter=0x34
whismanoid 3:9055e17e181a 2276 0x34, // AIN3 @ v_filter=0x34
whismanoid 3:9055e17e181a 2277 0x34, // AIN4 @ v_filter=0x34
whismanoid 3:9055e17e181a 2278 0x34, // AIN5 @ v_filter=0x34
whismanoid 3:9055e17e181a 2279 0x34, // AIN6 @ v_filter=0x34
whismanoid 3:9055e17e181a 2280 0x34, // AIN7 @ v_filter=0x34
whismanoid 3:9055e17e181a 2281 0x34, // AIN8 @ v_filter=0x34
whismanoid 3:9055e17e181a 2282 0x34, // AIN9 @ v_filter=0x34
whismanoid 3:9055e17e181a 2283 };
whismanoid 3:9055e17e181a 2284 //
whismanoid 4:d9b05924ad4c 2285 // MAX11410 specific per-channel config register v_ctrl
whismanoid 3:9055e17e181a 2286 uint8_t SPI_AIN_Cfg_v_ctrl_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2287 0x42, // AIN0 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2288 0x42, // AIN1 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2289 0x42, // AIN2 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2290 0x42, // AIN3 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2291 0x42, // AIN4 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2292 0x42, // AIN5 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2293 0x42, // AIN6 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2294 0x42, // AIN7 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2295 0x42, // AIN8 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2296 0x42, // AIN9 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2297 };
whismanoid 3:9055e17e181a 2298 //
whismanoid 4:d9b05924ad4c 2299 // MAX11410 specific per-channel config register v_pga
whismanoid 3:9055e17e181a 2300 uint8_t SPI_AIN_Cfg_v_pga_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2301 0x00, // AIN0 @ v_pga=0x00
whismanoid 3:9055e17e181a 2302 0x00, // AIN1 @ v_pga=0x00
whismanoid 3:9055e17e181a 2303 0x00, // AIN2 @ v_pga=0x00
whismanoid 3:9055e17e181a 2304 0x00, // AIN3 @ v_pga=0x00
whismanoid 3:9055e17e181a 2305 0x00, // AIN4 @ v_pga=0x00
whismanoid 3:9055e17e181a 2306 0x00, // AIN5 @ v_pga=0x00
whismanoid 3:9055e17e181a 2307 0x00, // AIN6 @ v_pga=0x00
whismanoid 3:9055e17e181a 2308 0x00, // AIN7 @ v_pga=0x00
whismanoid 3:9055e17e181a 2309 0x00, // AIN8 @ v_pga=0x00
whismanoid 3:9055e17e181a 2310 0x00, // AIN9 @ v_pga=0x00
whismanoid 3:9055e17e181a 2311 };
whismanoid 3:9055e17e181a 2312 //
whismanoid 3:9055e17e181a 2313 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2314 // ---------- Measure_Voltage_custom_props ----------
whismanoid 0:cb44e2e9ec4c 2315 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2316 // filter register configuration in Measure_Voltage and Read_All_Voltages CONV_TYPE_01_Continuous
whismanoid 0:cb44e2e9ec4c 2317 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 2318 //~ const uint8_t custom_v_filter = 0x00; // @ v_filter=0x00 -- LINEF_00_50Hz_60Hz_FIR RATE_0000 | 1.1SPS
whismanoid 0:cb44e2e9ec4c 2319 //~ const uint8_t custom_v_filter = 0x01; // @ v_filter=0x01 -- LINEF_00_50Hz_60Hz_FIR RATE_0001 | 2.1SPS
whismanoid 0:cb44e2e9ec4c 2320 //~ const uint8_t custom_v_filter = 0x02; // @ v_filter=0x02 -- LINEF_00_50Hz_60Hz_FIR RATE_0010 | 4.2SPS
whismanoid 0:cb44e2e9ec4c 2321 //~ const uint8_t custom_v_filter = 0x03; // @ v_filter=0x03 -- LINEF_00_50Hz_60Hz_FIR RATE_0011 | 8.4SPS
whismanoid 0:cb44e2e9ec4c 2322 //~ const uint8_t custom_v_filter = 0x04; // @ v_filter=0x04 -- LINEF_00_50Hz_60Hz_FIR RATE_0100 | 16.8SPS
whismanoid 0:cb44e2e9ec4c 2323 //~ const uint8_t custom_v_filter = 0x10; // @ v_filter=0x10 -- LINEF_01_50Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 2324 //~ const uint8_t custom_v_filter = 0x11; // @ v_filter=0x11 -- LINEF_01_50Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 2325 //~ const uint8_t custom_v_filter = 0x12; // @ v_filter=0x12 -- LINEF_01_50Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 2326 //~ const uint8_t custom_v_filter = 0x13; // @ v_filter=0x13 -- LINEF_01_50Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 2327 //~ const uint8_t custom_v_filter = 0x14; // @ v_filter=0x14 -- LINEF_01_50Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 2328 //~ const uint8_t custom_v_filter = 0x15; // @ v_filter=0x15 -- LINEF_01_50Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 2329 //~ const uint8_t custom_v_filter = 0x20; // @ v_filter=0x20 -- LINEF_10_60Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 2330 //~ const uint8_t custom_v_filter = 0x21; // @ v_filter=0x21 -- LINEF_10_60Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 2331 //~ const uint8_t custom_v_filter = 0x22; // @ v_filter=0x22 -- LINEF_10_60Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 2332 //~ const uint8_t custom_v_filter = 0x23; // @ v_filter=0x23 -- LINEF_10_60Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 2333 //~ const uint8_t custom_v_filter = 0x24; // @ v_filter=0x24 -- LINEF_10_60Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 2334 //~ const uint8_t custom_v_filter = 0x25; // @ v_filter=0x25 -- LINEF_10_60Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 2335 //~ const uint8_t custom_v_filter = 0x30; // @ v_filter=0x30 -- LINEF_11_SINC4 RATE_0000 | 4SPS
whismanoid 0:cb44e2e9ec4c 2336 //~ const uint8_t custom_v_filter = 0x31; // @ v_filter=0x31 -- LINEF_11_SINC4 RATE_0001 | 10SPS
whismanoid 0:cb44e2e9ec4c 2337 //~ const uint8_t custom_v_filter = 0x32; // @ v_filter=0x32 -- LINEF_11_SINC4 RATE_0010 | 20SPS
whismanoid 0:cb44e2e9ec4c 2338 //~ const uint8_t custom_v_filter = 0x33; // @ v_filter=0x33 -- LINEF_11_SINC4 RATE_0011 | 40SPS
whismanoid 0:cb44e2e9ec4c 2339 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 2340 //~ const uint8_t custom_v_filter = 0x35; // @ v_filter=0x35 -- LINEF_11_SINC4 RATE_0101 | 120SPS
whismanoid 0:cb44e2e9ec4c 2341 //~ const uint8_t custom_v_filter = 0x36; // @ v_filter=0x36 -- LINEF_11_SINC4 RATE_0110 | 240SPS
whismanoid 0:cb44e2e9ec4c 2342 //~ const uint8_t custom_v_filter = 0x37; // @ v_filter=0x37 -- LINEF_11_SINC4 RATE_0111 | 480SPS
whismanoid 0:cb44e2e9ec4c 2343 //~ const uint8_t custom_v_filter = 0x38; // @ v_filter=0x38 -- LINEF_11_SINC4 RATE_1000 | 960SPS
whismanoid 0:cb44e2e9ec4c 2344 //~ const uint8_t custom_v_filter = 0x39; // @ v_filter=0x39 -- LINEF_11_SINC4 RATE_1001 | 1920SPS
whismanoid 0:cb44e2e9ec4c 2345 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2346 //
whismanoid 0:cb44e2e9ec4c 2347 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2348 // pga register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 0:cb44e2e9ec4c 2349 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 2350 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 2351 //~ const uint8_t custom_v_pga = 0x10; // @ v_pga=0x10 -- 0x10 SIG_PATH_01_BYPASS
whismanoid 0:cb44e2e9ec4c 2352 //~ const uint8_t custom_v_pga = 0x20; // @ v_pga=0x20 -- 0x20 SIG_PATH_10_PGA GAIN_000_1
whismanoid 0:cb44e2e9ec4c 2353 //~ const uint8_t custom_v_pga = 0x21; // @ v_pga=0x21 --*0x21 SIG_PATH_10_PGA GAIN_001_2
whismanoid 0:cb44e2e9ec4c 2354 //~ const uint8_t custom_v_pga = 0x22; // @ v_pga=0x22 -- 0x22 SIG_PATH_10_PGA GAIN_010_4
whismanoid 0:cb44e2e9ec4c 2355 //~ const uint8_t custom_v_pga = 0x23; // @ v_pga=0x23 -- 0x23 SIG_PATH_10_PGA GAIN_011_8
whismanoid 0:cb44e2e9ec4c 2356 //~ const uint8_t custom_v_pga = 0x24; // @ v_pga=0x24 -- 0x24 SIG_PATH_10_PGA GAIN_100_16
whismanoid 0:cb44e2e9ec4c 2357 //~ const uint8_t custom_v_pga = 0x25; // @ v_pga=0x25 -- 0x25 SIG_PATH_10_PGA GAIN_101_32
whismanoid 0:cb44e2e9ec4c 2358 //~ const uint8_t custom_v_pga = 0x26; // @ v_pga=0x26 -- 0x26 SIG_PATH_10_PGA GAIN_110_64
whismanoid 0:cb44e2e9ec4c 2359 //~ const uint8_t custom_v_pga = 0x27; // @ v_pga=0x27 -- 0x27 SIG_PATH_10_PGA GAIN_111_128
whismanoid 0:cb44e2e9ec4c 2360 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2361 //
whismanoid 0:cb44e2e9ec4c 2362 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2363 // ctrl register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 3:9055e17e181a 2364 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2365 //~ const uint8_t custom_v_ctrl = 0x40; // @ v_ctrl=0x40 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1
whismanoid 0:cb44e2e9ec4c 2366 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 2367 //~ const uint8_t custom_v_ctrl = 0x58; // @ v_ctrl=0x58 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 2368 //
whismanoid 0:cb44e2e9ec4c 2369 //~ const uint8_t custom_v_ctrl = 0x41; // @ v_ctrl=0x41 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N
whismanoid 0:cb44e2e9ec4c 2370 //~ const uint8_t custom_v_ctrl = 0x45; // @ v_ctrl=0x45 -- 0x40 unipolar, 0x05 REF_SEL_101_REF1P_AGND
whismanoid 0:cb44e2e9ec4c 2371 //~ const uint8_t custom_v_ctrl = 0x59; // @ v_ctrl=0x59 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 2372 //
whismanoid 0:cb44e2e9ec4c 2373 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2374 //~ const uint8_t custom_v_ctrl = 0x46; // @ v_ctrl=0x46 -- 0x40 unipolar, 0x06 REF_SEL_110_REF2P_AGND
whismanoid 0:cb44e2e9ec4c 2375 //~ const uint8_t custom_v_ctrl = 0x22; // @ v_ctrl=0x22 -- 0x20 bipolar offset binary, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2376 //~ const uint8_t custom_v_ctrl = 0x02; // @ v_ctrl=0x02 -- 0x00 bipolar 2's complement, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2377 //
whismanoid 0:cb44e2e9ec4c 2378 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 2379 //~ const uint8_t custom_v_ctrl = 0x47; // @ v_ctrl=0x47 -- 0x40 unipolar, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2380 //~ const uint8_t custom_v_ctrl = 0x27; // @ v_ctrl=0x27 -- 0x20 bipolar offset binary, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2381 //~ const uint8_t custom_v_ctrl = 0x07; // @ v_ctrl=0x07 -- 0x00 bipolar 2's complement, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2382 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2383
whismanoid 3:9055e17e181a 2384 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2385 // example code declare SPI interface (GPIO controlled CS)
whismanoid 0:cb44e2e9ec4c 2386 #if defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 2387 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 2388 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
whismanoid 19:5ff09c8e9daf 2389 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 2390 #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 2391 SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625PICO: pin P0_5 P0_6 P0_4
whismanoid 0:cb44e2e9ec4c 2392 DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32625PICO: pin P0_7
whismanoid 0:cb44e2e9ec4c 2393 #elif defined(TARGET_MAX32600MBED)
whismanoid 0:cb44e2e9ec4c 2394 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 0:cb44e2e9ec4c 2395 DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2396 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 2397 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 2398 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:cb44e2e9ec4c 2399 //
whismanoid 0:cb44e2e9ec4c 2400 // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses.
whismanoid 0:cb44e2e9ec4c 2401 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 2402 DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2403 //
whismanoid 0:cb44e2e9ec4c 2404 #else
whismanoid 3:9055e17e181a 2405 SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 3:9055e17e181a 2406 DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2407 #endif
whismanoid 0:cb44e2e9ec4c 2408
whismanoid 0:cb44e2e9ec4c 2409 // example code declare GPIO interface pins
whismanoid 0:cb44e2e9ec4c 2410 // example code declare device instance
whismanoid 3:9055e17e181a 2411 MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC);
whismanoid 3:9055e17e181a 2412 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2413
whismanoid 1:747f1602abfc 2414 //--------------------------------------------------
whismanoid 3:9055e17e181a 2415 // Option to Datalog Arduino platform analog inputs
whismanoid 3:9055e17e181a 2416 #ifndef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 2417 #define LOG_PLATFORM_AIN 6
whismanoid 3:9055e17e181a 2418 //~ #undef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 2419 #endif
whismanoid 3:9055e17e181a 2420 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 1:747f1602abfc 2421 //#ifndef NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 1:747f1602abfc 2422 //#define NUM_PLATFORM_ANALOG_IN_CHANNELS 6
whismanoid 1:747f1602abfc 2423 //#endif
whismanoid 1:747f1602abfc 2424 const int NUM_PLATFORM_ANALOG_IN_CHANNELS = 6;
whismanoid 1:747f1602abfc 2425 const double adc_full_scale_voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 2426 analogInPin_fullScaleVoltage[0], // 1.2,
whismanoid 10:04022a61b527 2427 analogInPin_fullScaleVoltage[1], // 1.2,
whismanoid 10:04022a61b527 2428 analogInPin_fullScaleVoltage[2], // 1.2,
whismanoid 10:04022a61b527 2429 analogInPin_fullScaleVoltage[3], // 1.2,
whismanoid 10:04022a61b527 2430 analogInPin_fullScaleVoltage[4], // 6.0
whismanoid 10:04022a61b527 2431 analogInPin_fullScaleVoltage[5], // 6.0
whismanoid 0:cb44e2e9ec4c 2432 };
whismanoid 9:45f98573eb6d 2433 // Platform ADC individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 9:45f98573eb6d 2434 typedef enum Platform_AIN_Enable_t {
whismanoid 9:45f98573eb6d 2435 Platform_AIN_Disable = 0,
whismanoid 9:45f98573eb6d 2436 Platform_AIN_Enable_LSB = 1,
whismanoid 9:45f98573eb6d 2437 Platform_AIN_Enable_Volt = 2,
whismanoid 9:45f98573eb6d 2438 } Platform_AIN_Enable_t;
whismanoid 13:184a08909405 2439 uint8_t Platform_Enable_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 9:45f98573eb6d 2440 Platform_AIN_Enable_Volt, // AIN0 2=Volt
whismanoid 9:45f98573eb6d 2441 Platform_AIN_Enable_Volt, // AIN1 2=Volt
whismanoid 9:45f98573eb6d 2442 Platform_AIN_Enable_Volt, // AIN2 2=Volt
whismanoid 9:45f98573eb6d 2443 Platform_AIN_Enable_Volt, // AIN3 2=Volt
whismanoid 9:45f98573eb6d 2444 Platform_AIN_Enable_Volt, // AIN4 2=Volt
whismanoid 9:45f98573eb6d 2445 Platform_AIN_Enable_Volt, // AIN5 2=Volt
whismanoid 9:45f98573eb6d 2446 };
whismanoid 37:3f369235e5bc 2447 // Option to report average value of Arduino platform analog inputs
whismanoid 37:3f369235e5bc 2448 #ifndef USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 2449 #define USE_Platform_AIN_Average 1
whismanoid 37:3f369235e5bc 2450 //~ #undef USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 2451 #endif
whismanoid 37:3f369235e5bc 2452 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 2453 #endif // USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 2454 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 2455 int Platform_AIN_Average_N = 16;
whismanoid 37:3f369235e5bc 2456 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 2457 // Option to apply calibration to Arduino platform analog inputs
whismanoid 34:a1993a1ee904 2458 #ifndef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2459 #define HAS_Platform_AIN_Calibration 1
whismanoid 34:a1993a1ee904 2460 //~ #undef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2461 #endif
whismanoid 34:a1993a1ee904 2462 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2463 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 2464 // Calibration is between two points for each channel, defined by
whismanoid 34:a1993a1ee904 2465 // a normalized value between 0% and 100%, and the corresponding voltage.
whismanoid 34:a1993a1ee904 2466 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 2467 // calibration_05_normValue_0_1, calibration_05_V should be around 5% or 25%
whismanoid 34:a1993a1ee904 2468 double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2469 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2470 // data unique to certain boards based on serial number
whismanoid 38:fda80a0020d1 2471 // channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2472 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2473 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 38:fda80a0020d1 2474 // TODO: calibrate BOARD_SERIAL_NUMBER 0 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2475 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2476 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2477 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2478 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2479 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2480 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2481 //
whismanoid 36:e7aac874b8be 2482 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2483 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 38:fda80a0020d1 2484 // TODO: calibrate BOARD_SERIAL_NUMBER 1 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 37:3f369235e5bc 2485 0.250000000, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 37:3f369235e5bc 2486 0.624736547, // %A cal1n=0.624736547 cal1v=0.748000026V cal1n=0.979754724 cal1v=1.167500019V
whismanoid 37:3f369235e5bc 2487 0.250000000, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 37:3f369235e5bc 2488 0.250000000, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 37:3f369235e5bc 2489 0.250000000, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 37:3f369235e5bc 2490 0.127252869, // %A cal5n=0.127252869 cal5v=0.748000026V cal5n=0.267205842 cal5v=1.578999996V
whismanoid 36:e7aac874b8be 2491 //
whismanoid 36:e7aac874b8be 2492 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2493 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 38:fda80a0020d1 2494 // TODO: calibrate BOARD_SERIAL_NUMBER 2 channels A1/A5(1V0)?
whismanoid 38:fda80a0020d1 2495 0.001955034, // %A cal0n=0.001955034 cal0v=0.000120000V cal0n=0.964797903 cal0v=1.149270058V
whismanoid 38:fda80a0020d1 2496 0.646371711, // %A cal1n=0.646371711 cal1v=0.761619985V cal1n=0.964797903 cal1v=1.149270058V
whismanoid 38:fda80a0020d1 2497 0.121437412, // %A cal2n=0.121437412 cal2v=0.146500006V cal2n=0.833466958 cal2v=1.004999995V
whismanoid 38:fda80a0020d1 2498 0.121437412, // %A cal3n=0.121437412 cal3v=0.146500006V cal3n=0.833466958 cal3v=1.004999995V
whismanoid 38:fda80a0020d1 2499 0.001955034, // %A cal4n=0.001955034 cal4v=0.000120000V cal4n=0.291349728 cal4v=1.735399961V
whismanoid 38:fda80a0020d1 2500 0.130005952, // %A cal5n=0.130005952 cal5v=0.761650026V cal5n=0.291349728 cal5v=1.735399961V
whismanoid 36:e7aac874b8be 2501 //
whismanoid 36:e7aac874b8be 2502 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2503 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 38:fda80a0020d1 2504 // TODO: calibrate BOARD_SERIAL_NUMBER 3 channels A2(WE), A3(CE) not quite right yet
whismanoid 38:fda80a0020d1 2505 0.002932551, // %A cal0n=0.002932551 cal0v=0.000130000V cal0n=0.966447462 cal0v=1.149999976V
whismanoid 38:fda80a0020d1 2506 0.643798094, // %A cal1n=0.643798094 cal1v=0.756900012V cal1n=0.966447462 cal1v=1.149999976V
whismanoid 38:fda80a0020d1 2507 0.151286051, // %A cal2n=0.151286051 cal2v=0.181050003V cal2n=0.786534725 cal2v=0.936999977V
whismanoid 38:fda80a0020d1 2508 0.151286051, // %A cal3n=0.151286051 cal3v=0.181050003V cal3n=0.786023080 cal3v=0.936999977V
whismanoid 38:fda80a0020d1 2509 0.002932551, // %A cal4n=0.002932551 cal4v=0.000130000V cal4n=0.286962360 cal4v=1.707499981V
whismanoid 38:fda80a0020d1 2510 0.130120505, // %A cal5n=0.130120505 cal5v=0.757099986V cal5n=0.286962360 cal5v=1.707499981V
whismanoid 36:e7aac874b8be 2511 //
whismanoid 36:e7aac874b8be 2512 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2513 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 38:fda80a0020d1 2514 0.003910068, // %A cal0n=0.003910068 cal0v=0.000120000V cal0n=0.925441444 cal0v=1.107100010V
whismanoid 38:fda80a0020d1 2515 0.635619044, // %A cal1n=0.635619044 cal1v=0.759999990V cal1n=0.925441444 cal1v=1.107100010V
whismanoid 38:fda80a0020d1 2516 0.083768636, // %A cal2n=0.083768636 cal2v=0.100000001V cal2n=0.820740156 cal2v=0.980000019V
whismanoid 38:fda80a0020d1 2517 0.083768636, // %A cal3n=0.083768636 cal3v=0.100000001V cal3n=0.820740156 cal3v=0.980000019V
whismanoid 38:fda80a0020d1 2518 0.003910068, // %A cal4n=0.003910068 cal4v=0.000120000V cal4n=0.279630989 cal4v=1.651999950V
whismanoid 38:fda80a0020d1 2519 0.129257541, // %A cal5n=0.129257541 cal5v=0.759999990V cal5n=0.279630989 cal5v=1.651999950V
whismanoid 36:e7aac874b8be 2520 //
whismanoid 36:e7aac874b8be 2521 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2522 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 38:fda80a0020d1 2523 // TODO: calibrate BOARD_SERIAL_NUMBER 5 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE) broken unit?
whismanoid 36:e7aac874b8be 2524 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2525 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2526 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2527 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2528 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2529 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2530 //
whismanoid 36:e7aac874b8be 2531 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2532 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 38:fda80a0020d1 2533 // TODO: calibrate BOARD_SERIAL_NUMBER 6 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2534 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2535 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2536 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2537 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2538 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2539 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2540 //
whismanoid 36:e7aac874b8be 2541 # else
whismanoid 36:e7aac874b8be 2542 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2543 # endif
whismanoid 36:e7aac874b8be 2544 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2545 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2546 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2547 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2548 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2549 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2550 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2551 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2552 //
whismanoid 36:e7aac874b8be 2553 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2554 };
whismanoid 34:a1993a1ee904 2555 double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2556 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2557 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2558 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2559 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 38:fda80a0020d1 2560 // TODO: calibrate BOARD_SERIAL_NUMBER 0 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2561 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2562 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2563 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2564 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2565 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2566 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2567 //
whismanoid 36:e7aac874b8be 2568 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2569 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 38:fda80a0020d1 2570 // TODO: calibrate BOARD_SERIAL_NUMBER 1 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 37:3f369235e5bc 2571 0.300000000, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 37:3f369235e5bc 2572 0.748000026, // %A cal1n=0.624736547 cal1v=0.748000026V cal1n=0.979754724 cal1v=1.167500019V
whismanoid 37:3f369235e5bc 2573 0.300000000, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 37:3f369235e5bc 2574 0.300000000, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 37:3f369235e5bc 2575 1.500000000, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 37:3f369235e5bc 2576 0.748000026, // %A cal5n=0.127252869 cal5v=0.748000026V cal5n=0.267205842 cal5v=1.578999996V
whismanoid 36:e7aac874b8be 2577 //
whismanoid 36:e7aac874b8be 2578 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2579 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 38:fda80a0020d1 2580 // TODO: calibrate BOARD_SERIAL_NUMBER 2 channels A1/A5(1V0)?
whismanoid 38:fda80a0020d1 2581 0.000120000, // %A cal0n=0.001955034 cal0v=0.000120000V cal0n=0.964797903 cal0v=1.149270058V
whismanoid 38:fda80a0020d1 2582 0.761619985, // %A cal1n=0.646371711 cal1v=0.761619985V cal1n=0.964797903 cal1v=1.149270058V
whismanoid 38:fda80a0020d1 2583 0.146500006, // %A cal2n=0.121437412 cal2v=0.146500006V cal2n=0.833466958 cal2v=1.004999995V
whismanoid 38:fda80a0020d1 2584 0.146500006, // %A cal3n=0.121437412 cal3v=0.146500006V cal3n=0.833466958 cal3v=1.004999995V
whismanoid 38:fda80a0020d1 2585 0.000120000, // %A cal4n=0.001955034 cal4v=0.000120000V cal4n=0.291349728 cal4v=1.735399961V
whismanoid 38:fda80a0020d1 2586 0.761650026, // %A cal5n=0.130005952 cal5v=0.761650026V cal5n=0.291349728 cal5v=1.735399961V
whismanoid 36:e7aac874b8be 2587 //
whismanoid 36:e7aac874b8be 2588 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2589 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 38:fda80a0020d1 2590 // TODO: calibrate BOARD_SERIAL_NUMBER 3 channels A2(WE), A3(CE) not quite right yet
whismanoid 38:fda80a0020d1 2591 0.000130000, // %A cal0n=0.002932551 cal0v=0.000130000V cal0n=0.966447462 cal0v=1.149999976V
whismanoid 38:fda80a0020d1 2592 0.756900012, // %A cal1n=0.643798094 cal1v=0.756900012V cal1n=0.966447462 cal1v=1.149999976V
whismanoid 38:fda80a0020d1 2593 0.181050003, // %A cal2n=0.151286051 cal2v=0.181050003V cal2n=0.786534725 cal2v=0.936999977V
whismanoid 38:fda80a0020d1 2594 0.181050003, // %A cal3n=0.151286051 cal3v=0.181050003V cal3n=0.786023080 cal3v=0.936999977V
whismanoid 38:fda80a0020d1 2595 0.000130000, // %A cal4n=0.002932551 cal4v=0.000130000V cal4n=0.286962360 cal4v=1.707499981V
whismanoid 38:fda80a0020d1 2596 0.757099986, // %A cal5n=0.130120505 cal5v=0.757099986V cal5n=0.286962360 cal5v=1.707499981V
whismanoid 36:e7aac874b8be 2597 //
whismanoid 36:e7aac874b8be 2598 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2599 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 38:fda80a0020d1 2600 0.000120000, // %A cal0n=0.003910068 cal0v=0.000120000V cal0n=0.925441444 cal0v=1.107100010V
whismanoid 38:fda80a0020d1 2601 0.759999990, // %A cal1n=0.635619044 cal1v=0.759999990V cal1n=0.925441444 cal1v=1.107100010V
whismanoid 38:fda80a0020d1 2602 0.100000001, // %A cal2n=0.083768636 cal2v=0.100000001V cal2n=0.820740156 cal2v=0.980000019V
whismanoid 38:fda80a0020d1 2603 0.100000001, // %A cal3n=0.083768636 cal3v=0.100000001V cal3n=0.820740156 cal3v=0.980000019V
whismanoid 38:fda80a0020d1 2604 0.000120000, // %A cal4n=0.003910068 cal4v=0.000120000V cal4n=0.279630989 cal4v=1.651999950V
whismanoid 38:fda80a0020d1 2605 0.759999990, // %A cal5n=0.129257541 cal5v=0.759999990V cal5n=0.279630989 cal5v=1.651999950V
whismanoid 36:e7aac874b8be 2606 //
whismanoid 36:e7aac874b8be 2607 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2608 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 38:fda80a0020d1 2609 // TODO: calibrate BOARD_SERIAL_NUMBER 5 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2610 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2611 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2612 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2613 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2614 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2615 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2616 //
whismanoid 36:e7aac874b8be 2617 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2618 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 38:fda80a0020d1 2619 // TODO: calibrate BOARD_SERIAL_NUMBER 6 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2620 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2621 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2622 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2623 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2624 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2625 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2626 //
whismanoid 36:e7aac874b8be 2627 # else
whismanoid 36:e7aac874b8be 2628 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2629 # endif
whismanoid 36:e7aac874b8be 2630 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2631 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2632 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2633 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2634 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2635 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2636 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2637 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2638 //
whismanoid 36:e7aac874b8be 2639 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2640 };
whismanoid 34:a1993a1ee904 2641 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 2642 // calibration_95_normValue_0_1, calibration_95_V should be around 95% or 75%
whismanoid 34:a1993a1ee904 2643 double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2644 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2645 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2646 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2647 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 38:fda80a0020d1 2648 // TODO: calibrate BOARD_SERIAL_NUMBER 0 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2649 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2650 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2651 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2652 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2653 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2654 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2655 //
whismanoid 36:e7aac874b8be 2656 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2657 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 38:fda80a0020d1 2658 // TODO: calibrate BOARD_SERIAL_NUMBER 1 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 37:3f369235e5bc 2659 0.750000000, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 37:3f369235e5bc 2660 0.979754724, // %A cal1n=0.624736547 cal1v=0.748000026V cal1n=0.979754724 cal1v=1.167500019V
whismanoid 37:3f369235e5bc 2661 0.750000000, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 37:3f369235e5bc 2662 0.750000000, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 37:3f369235e5bc 2663 0.750000000, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 37:3f369235e5bc 2664 0.267205842, // %A cal5n=0.127252869 cal5v=0.748000026V cal5n=0.267205842 cal5v=1.578999996V
whismanoid 36:e7aac874b8be 2665 //
whismanoid 36:e7aac874b8be 2666 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2667 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 38:fda80a0020d1 2668 // TODO: calibrate BOARD_SERIAL_NUMBER 2 channels A1/A5(1V0)?
whismanoid 38:fda80a0020d1 2669 0.964797903, // %A cal0n=0.001955034 cal0v=0.000120000V cal0n=0.964797903 cal0v=1.149270058V
whismanoid 38:fda80a0020d1 2670 0.964797903, // %A cal1n=0.646371711 cal1v=0.761619985V cal1n=0.964797903 cal1v=1.149270058V
whismanoid 38:fda80a0020d1 2671 0.833466958, // %A cal2n=0.121437412 cal2v=0.146500006V cal2n=0.833466958 cal2v=1.004999995V
whismanoid 38:fda80a0020d1 2672 0.833466958, // %A cal3n=0.121437412 cal3v=0.146500006V cal3n=0.833466958 cal3v=1.004999995V
whismanoid 38:fda80a0020d1 2673 0.291349728, // %A cal4n=0.001955034 cal4v=0.000120000V cal4n=0.291349728 cal4v=1.735399961V
whismanoid 38:fda80a0020d1 2674 0.291349728, // %A cal5n=0.130005952 cal5v=0.761650026V cal5n=0.291349728 cal5v=1.735399961V
whismanoid 36:e7aac874b8be 2675 //
whismanoid 36:e7aac874b8be 2676 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2677 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 38:fda80a0020d1 2678 // TODO: calibrate BOARD_SERIAL_NUMBER 3 channels A2(WE), A3(CE) not quite right yet
whismanoid 38:fda80a0020d1 2679 0.966447462, // %A cal0n=0.002932551 cal0v=0.000130000V cal0n=0.966447462 cal0v=1.149999976V
whismanoid 38:fda80a0020d1 2680 0.966447462, // %A cal1n=0.643798094 cal1v=0.756900012V cal1n=0.966447462 cal1v=1.149999976V
whismanoid 38:fda80a0020d1 2681 0.786534725, // %A cal2n=0.151286051 cal2v=0.181050003V cal2n=0.786534725 cal2v=0.936999977V
whismanoid 38:fda80a0020d1 2682 0.786023080, // %A cal3n=0.151286051 cal3v=0.181050003V cal3n=0.786023080 cal3v=0.936999977V
whismanoid 38:fda80a0020d1 2683 0.286962360, // %A cal4n=0.002932551 cal4v=0.000130000V cal4n=0.286962360 cal4v=1.707499981V
whismanoid 38:fda80a0020d1 2684 0.286962360, // %A cal5n=0.130120505 cal5v=0.757099986V cal5n=0.286962360 cal5v=1.707499981V
whismanoid 36:e7aac874b8be 2685 //
whismanoid 36:e7aac874b8be 2686 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2687 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 38:fda80a0020d1 2688 0.925441444, // %A cal0n=0.003910068 cal0v=0.000120000V cal0n=0.925441444 cal0v=1.107100010V
whismanoid 38:fda80a0020d1 2689 0.925441444, // %A cal1n=0.635619044 cal1v=0.759999990V cal1n=0.925441444 cal1v=1.107100010V
whismanoid 38:fda80a0020d1 2690 0.820740156, // %A cal2n=0.083768636 cal2v=0.100000001V cal2n=0.820740156 cal2v=0.980000019V
whismanoid 38:fda80a0020d1 2691 0.820740156, // %A cal3n=0.083768636 cal3v=0.100000001V cal3n=0.820740156 cal3v=0.980000019V
whismanoid 38:fda80a0020d1 2692 0.279630989, // %A cal4n=0.003910068 cal4v=0.000120000V cal4n=0.279630989 cal4v=1.651999950V
whismanoid 38:fda80a0020d1 2693 0.279630989, // %A cal5n=0.129257541 cal5v=0.759999990V cal5n=0.279630989 cal5v=1.651999950V
whismanoid 36:e7aac874b8be 2694 //
whismanoid 36:e7aac874b8be 2695 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2696 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 38:fda80a0020d1 2697 // TODO: calibrate BOARD_SERIAL_NUMBER 5 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2698 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2699 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2700 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2701 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2702 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2703 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2704 //
whismanoid 36:e7aac874b8be 2705 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2706 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 38:fda80a0020d1 2707 // TODO: calibrate BOARD_SERIAL_NUMBER 6 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2708 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2709 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2710 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2711 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2712 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2713 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2714 //
whismanoid 36:e7aac874b8be 2715 # else
whismanoid 36:e7aac874b8be 2716 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2717 # endif
whismanoid 36:e7aac874b8be 2718 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2719 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2720 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2721 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2722 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2723 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2724 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2725 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2726 //
whismanoid 36:e7aac874b8be 2727 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2728 };
whismanoid 34:a1993a1ee904 2729 double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2730 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2731 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2732 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2733 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 38:fda80a0020d1 2734 // TODO: calibrate BOARD_SERIAL_NUMBER 0 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2735 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2736 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2737 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2738 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2739 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2740 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2741 //
whismanoid 36:e7aac874b8be 2742 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2743 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 38:fda80a0020d1 2744 // TODO: calibrate BOARD_SERIAL_NUMBER 1 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 37:3f369235e5bc 2745 0.900000000, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 37:3f369235e5bc 2746 1.167500019, // %A cal1n=0.624736547 cal1v=0.748000026V cal1n=0.979754724 cal1v=1.167500019V
whismanoid 37:3f369235e5bc 2747 0.900000000, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 37:3f369235e5bc 2748 0.900000000, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 37:3f369235e5bc 2749 4.500000000, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 37:3f369235e5bc 2750 1.578999996, // %A cal5n=0.127252869 cal5v=0.748000026V cal5n=0.267205842 cal5v=1.578999996V
whismanoid 36:e7aac874b8be 2751 //
whismanoid 36:e7aac874b8be 2752 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2753 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 38:fda80a0020d1 2754 // TODO: calibrate BOARD_SERIAL_NUMBER 2 channels A1/A5(1V0)?
whismanoid 38:fda80a0020d1 2755 1.149270058, // %A cal0n=0.001955034 cal0v=0.000120000V cal0n=0.964797903 cal0v=1.149270058V
whismanoid 38:fda80a0020d1 2756 1.149270058, // %A cal1n=0.646371711 cal1v=0.761619985V cal1n=0.964797903 cal1v=1.149270058V
whismanoid 38:fda80a0020d1 2757 1.004999995, // %A cal2n=0.121437412 cal2v=0.146500006V cal2n=0.833466958 cal2v=1.004999995V
whismanoid 38:fda80a0020d1 2758 1.004999995, // %A cal3n=0.121437412 cal3v=0.146500006V cal3n=0.833466958 cal3v=1.004999995V
whismanoid 38:fda80a0020d1 2759 1.735399961, // %A cal4n=0.001955034 cal4v=0.000120000V cal4n=0.291349728 cal4v=1.735399961V
whismanoid 38:fda80a0020d1 2760 1.735399961, // %A cal5n=0.130005952 cal5v=0.761650026V cal5n=0.291349728 cal5v=1.735399961V
whismanoid 36:e7aac874b8be 2761 //
whismanoid 36:e7aac874b8be 2762 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2763 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 38:fda80a0020d1 2764 // TODO: calibrate BOARD_SERIAL_NUMBER 3 channels A2(WE), A3(CE) not quite right yet
whismanoid 38:fda80a0020d1 2765 1.149999976, // %A cal0n=0.002932551 cal0v=0.000130000V cal0n=0.966447462 cal0v=1.149999976V
whismanoid 38:fda80a0020d1 2766 1.149999976, // %A cal1n=0.643798094 cal1v=0.756900012V cal1n=0.966447462 cal1v=1.149999976V
whismanoid 38:fda80a0020d1 2767 0.936999977, // %A cal2n=0.151286051 cal2v=0.181050003V cal2n=0.786534725 cal2v=0.936999977V
whismanoid 38:fda80a0020d1 2768 0.936999977, // %A cal3n=0.151286051 cal3v=0.181050003V cal3n=0.786023080 cal3v=0.936999977V
whismanoid 38:fda80a0020d1 2769 1.707499981, // %A cal4n=0.002932551 cal4v=0.000130000V cal4n=0.286962360 cal4v=1.707499981V
whismanoid 38:fda80a0020d1 2770 1.707499981, // %A cal5n=0.130120505 cal5v=0.757099986V cal5n=0.286962360 cal5v=1.707499981V
whismanoid 36:e7aac874b8be 2771 //
whismanoid 36:e7aac874b8be 2772 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2773 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 38:fda80a0020d1 2774 1.107100010, // %A cal0n=0.003910068 cal0v=0.000120000V cal0n=0.925441444 cal0v=1.107100010V
whismanoid 38:fda80a0020d1 2775 1.107100010, // %A cal1n=0.635619044 cal1v=0.759999990V cal1n=0.925441444 cal1v=1.107100010V
whismanoid 38:fda80a0020d1 2776 0.980000019, // %A cal2n=0.083768636 cal2v=0.100000001V cal2n=0.820740156 cal2v=0.980000019V
whismanoid 38:fda80a0020d1 2777 0.980000019, // %A cal3n=0.083768636 cal3v=0.100000001V cal3n=0.820740156 cal3v=0.980000019V
whismanoid 38:fda80a0020d1 2778 1.651999950, // %A cal4n=0.003910068 cal4v=0.000120000V cal4n=0.279630989 cal4v=1.651999950V
whismanoid 38:fda80a0020d1 2779 1.651999950, // %A cal5n=0.129257541 cal5v=0.759999990V cal5n=0.279630989 cal5v=1.651999950V
whismanoid 36:e7aac874b8be 2780 //
whismanoid 36:e7aac874b8be 2781 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2782 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 38:fda80a0020d1 2783 // TODO: calibrate BOARD_SERIAL_NUMBER 5 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2784 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2785 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2786 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2787 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2788 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2789 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2790 //
whismanoid 36:e7aac874b8be 2791 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2792 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 38:fda80a0020d1 2793 // TODO: calibrate BOARD_SERIAL_NUMBER 6 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2794 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2795 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2796 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2797 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2798 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2799 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2800 //
whismanoid 36:e7aac874b8be 2801 # else
whismanoid 36:e7aac874b8be 2802 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2803 # endif
whismanoid 36:e7aac874b8be 2804 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2805 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2806 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2807 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2808 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2809 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2810 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2811 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2812 //
whismanoid 36:e7aac874b8be 2813 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2814 };
whismanoid 34:a1993a1ee904 2815 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2816 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2817 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1)
whismanoid 34:a1993a1ee904 2818 {
whismanoid 34:a1993a1ee904 2819 // TODO: return corrected normValue_0_1 using two-point linear calibration
whismanoid 34:a1993a1ee904 2820 // point 1: calibration_05_normValue_0_1[ch], calibration_05_V[ch]
whismanoid 34:a1993a1ee904 2821 // point 2: calibration_95_normValue_0_1[ch], calibration_95_V[ch]
whismanoid 34:a1993a1ee904 2822 // validate that there is enough span to get sensible results
whismanoid 34:a1993a1ee904 2823 //
whismanoid 34:a1993a1ee904 2824 int ch = channel_0_5;
whismanoid 34:a1993a1ee904 2825 // 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 2826 // ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 2827 // ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 2828 // ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 2829 // ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 2830 // );
whismanoid 34:a1993a1ee904 2831 // cmdLine.serial().printf("\r\n adc_full_scale_voltage[%d] = %1.6fV",
whismanoid 34:a1993a1ee904 2832 // ch,
whismanoid 34:a1993a1ee904 2833 // adc_full_scale_voltage[ch]
whismanoid 34:a1993a1ee904 2834 // );
whismanoid 34:a1993a1ee904 2835 // raw normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 2836 double raw_05_normValue = calibration_05_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 2837 double raw_95_normValue = calibration_95_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 2838 // calibrated normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 2839 // divide V/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 2840 double cal_05_normValue = calibration_05_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 2841 double cal_95_normValue = calibration_95_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 2842 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_05_normValue = %1.6f",
whismanoid 34:a1993a1ee904 2843 // ch,
whismanoid 34:a1993a1ee904 2844 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2845 // cal_05_normValue
whismanoid 34:a1993a1ee904 2846 // );
whismanoid 34:a1993a1ee904 2847 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_95_normValue = %1.6f",
whismanoid 34:a1993a1ee904 2848 // ch,
whismanoid 34:a1993a1ee904 2849 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2850 // cal_95_normValue
whismanoid 34:a1993a1ee904 2851 // );
whismanoid 34:a1993a1ee904 2852 //
whismanoid 34:a1993a1ee904 2853 double span_raw = raw_95_normValue - raw_05_normValue;
whismanoid 34:a1993a1ee904 2854 double span_cal = cal_95_normValue - cal_05_normValue;
whismanoid 34:a1993a1ee904 2855 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_raw = %1.6f",
whismanoid 34:a1993a1ee904 2856 // ch,
whismanoid 34:a1993a1ee904 2857 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2858 // span_raw
whismanoid 34:a1993a1ee904 2859 // );
whismanoid 34:a1993a1ee904 2860 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_cal = %1.6f",
whismanoid 34:a1993a1ee904 2861 // ch,
whismanoid 34:a1993a1ee904 2862 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2863 // span_cal
whismanoid 34:a1993a1ee904 2864 // );
whismanoid 34:a1993a1ee904 2865 // if calibration is not valid, return unmodified normValue_0_1 and print a warning
whismanoid 34:a1993a1ee904 2866 if (span_raw < 0.001) {
whismanoid 34:a1993a1ee904 2867 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_raw = %1.6f",
whismanoid 34:a1993a1ee904 2868 ch,
whismanoid 34:a1993a1ee904 2869 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2870 span_raw
whismanoid 34:a1993a1ee904 2871 );
whismanoid 34:a1993a1ee904 2872 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 2873 }
whismanoid 34:a1993a1ee904 2874 if (span_cal < 0.001) {
whismanoid 34:a1993a1ee904 2875 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_cal = %1.6f",
whismanoid 34:a1993a1ee904 2876 ch,
whismanoid 34:a1993a1ee904 2877 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2878 span_cal
whismanoid 34:a1993a1ee904 2879 );
whismanoid 34:a1993a1ee904 2880 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 2881 }
whismanoid 34:a1993a1ee904 2882 double slope_correction = span_cal / span_raw;
whismanoid 34:a1993a1ee904 2883 double corrected_normValue_0_1 = cal_05_normValue + ((raw_normValue_0_1 - raw_05_normValue) * slope_correction);
whismanoid 34:a1993a1ee904 2884 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) slope_correction = %1.6f",
whismanoid 34:a1993a1ee904 2885 // ch,
whismanoid 34:a1993a1ee904 2886 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2887 // slope_correction
whismanoid 34:a1993a1ee904 2888 // );
whismanoid 34:a1993a1ee904 2889 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) corrected_normValue_0_1 = %1.6f\r\n",
whismanoid 34:a1993a1ee904 2890 // ch,
whismanoid 34:a1993a1ee904 2891 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2892 // corrected_normValue_0_1
whismanoid 34:a1993a1ee904 2893 // );
whismanoid 34:a1993a1ee904 2894 return corrected_normValue_0_1;
whismanoid 34:a1993a1ee904 2895 }
whismanoid 34:a1993a1ee904 2896 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2897 // Option to customize channel names in datalog header line
whismanoid 13:184a08909405 2898 #ifndef HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 2899 #define HAS_Platform_AIN_customChannelHeader 1
whismanoid 13:184a08909405 2900 #endif
whismanoid 13:184a08909405 2901 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2902 const char* const Platform_AIN_customChannelHeader_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 2903 "=AIN4", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 2904 "=AIN5", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 2905 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 2906 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 2907 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 2908 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 2909 };
whismanoid 13:184a08909405 2910 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 1:747f1602abfc 2911 //--------------------------------------------------
whismanoid 1:747f1602abfc 2912 // Option to log platform analog inputs as raw LSB code
whismanoid 1:747f1602abfc 2913 #ifndef LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 2914 #define LOG_PLATFORM_ANALOG_IN_LSB 0
whismanoid 1:747f1602abfc 2915 #endif
whismanoid 1:747f1602abfc 2916 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 2917 int Platform_LSB[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 2918 #endif
whismanoid 1:747f1602abfc 2919
whismanoid 1:747f1602abfc 2920 //--------------------------------------------------
whismanoid 1:747f1602abfc 2921 // Option to use platform analog inputs as Voltage
whismanoid 1:747f1602abfc 2922 #ifndef LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 2923 #define LOG_PLATFORM_ANALOG_IN_VOLTS 1
whismanoid 1:747f1602abfc 2924 #endif
whismanoid 1:747f1602abfc 2925 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 2926 double Platform_Voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 2927 #endif
whismanoid 3:9055e17e181a 2928 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 0:cb44e2e9ec4c 2929
whismanoid 10:04022a61b527 2930 //--------------------------------------------------
whismanoid 10:04022a61b527 2931 // Option to use Command forwarding to Auxiliary serial port
whismanoid 10:04022a61b527 2932 // Command forwarding to Auxiliary serial port TX/RX
whismanoid 10:04022a61b527 2933 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial
whismanoid 10:04022a61b527 2934 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial
whismanoid 10:04022a61b527 2935 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 2936 #ifndef USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2937 #define USE_AUX_SERIAL_CMD_FORWARDING 1
whismanoid 10:04022a61b527 2938 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2939 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2940 // Command forwarding to Auxiliary serial port TX/RX #257 -- global parameters
whismanoid 10:04022a61b527 2941 const size_t RX_STRING_BUF_SIZE = 1000;
whismanoid 10:04022a61b527 2942 int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 2943 // transmit command string by AUX TX
whismanoid 10:04022a61b527 2944 #if 0
whismanoid 10:04022a61b527 2945 int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 2946 int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 2947 int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 2948 #endif
whismanoid 10:04022a61b527 2949 // capture received string from AUX RX
whismanoid 10:04022a61b527 2950 Timer g_auxSerialCom_Timer;
whismanoid 10:04022a61b527 2951 int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 2952 int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 2953 int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 2954 int g_auxSerialCom_rx_idle_ms = 500; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 2955 int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 2956 const int aux_serial_cmd_forwarding_rx_eot_not_used = 'x';
whismanoid 10:04022a61b527 2957 int g_auxSerialCom_rx_eot = aux_serial_cmd_forwarding_rx_eot_not_used; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 2958 //~ int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text string?
whismanoid 10:04022a61b527 2959 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2960 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2961 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257
whismanoid 10:04022a61b527 2962 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 2963 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2964 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2965 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2966 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 2967 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2968 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 2969 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2970 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2971 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2972 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2973 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2974 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 2975 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2976 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2977
whismanoid 8:dffee7509bfb 2978 // CODE GENERATOR: example code for ADC: serial port declaration
whismanoid 8:dffee7509bfb 2979 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2980 // Declare the Serial driver
whismanoid 8:dffee7509bfb 2981 // default baud rate settings are 9600 8N1
whismanoid 8:dffee7509bfb 2982 // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
whismanoid 8:dffee7509bfb 2983 // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
whismanoid 8:dffee7509bfb 2984 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2985 #if defined(TARGET_MAX32630)
whismanoid 8:dffee7509bfb 2986 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 2987 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2988 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2989 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 2990 //
whismanoid 8:dffee7509bfb 2991 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2992 Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2993 //Serial J3AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 2994 //Serial BTAUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 2995 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 2996 //
whismanoid 8:dffee7509bfb 2997 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2998 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2999 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3000 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3001 //
whismanoid 8:dffee7509bfb 3002 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3003 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3004 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3005 USBSerial serial;
whismanoid 8:dffee7509bfb 3006 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3007 #elif defined(TARGET_MAX32625MBED)
whismanoid 8:dffee7509bfb 3008 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625MBED: P0_1,P0_0 (Arduino D1,D0)
whismanoid 8:dffee7509bfb 3009 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3010 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625MBED: P3_1,P3_0 (J15-LEDgreen,LEDred)
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(P2_1,P2_0); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3015 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3016 //
whismanoid 8:dffee7509bfb 3017 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3018 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3019 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3020 USBSerial serial;
whismanoid 8:dffee7509bfb 3021 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 3022 #elif defined(TARGET_MAX32625PICO)
whismanoid 8:dffee7509bfb 3023 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 3024 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625PICO: P2_1,P2_0 (underside?)
whismanoid 8:dffee7509bfb 3025 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3026 //
whismanoid 8:dffee7509bfb 3027 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3028 Serial AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 3029 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3030 //
whismanoid 8:dffee7509bfb 3031 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3032 Serial DAPLINKserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3033 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3034 //
whismanoid 8:dffee7509bfb 3035 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3036 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3037 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3038 USBSerial serial;
whismanoid 22:d6dc8a85f435 3039 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 3040 #elif defined(TARGET_MAX40108DEMOP2U9)
whismanoid 22:d6dc8a85f435 3041 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 3042 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK)
whismanoid 22:d6dc8a85f435 3043 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 3044 //
whismanoid 22:d6dc8a85f435 3045 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial is used as main serial port in MAX40108 Demo board
whismanoid 22:d6dc8a85f435 3046 Serial serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 3047 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 3048 //
whismanoid 22:d6dc8a85f435 3049 // Hardware serial port over DAPLink
whismanoid 22:d6dc8a85f435 3050 // connection to external MAX32625PICO(DAPLINK) needed TX/RX swap in firmware.
whismanoid 22:d6dc8a85f435 3051 // MAX32625PICO(DAPLINK) drives DAPLINK.8, listens on DAPLINK.6.
whismanoid 22:d6dc8a85f435 3052 // See AN6350 MAX32625 Users Guide 7.5.2.3.1 TX and RX Pin Mapping for UART 1 -- Mapping Option B
whismanoid 39:4d285e961435 3053 #ifdef BOARD_SERIAL_NUMBER
whismanoid 39:4d285e961435 3054 // data unique to certain boards based on serial number
whismanoid 39:4d285e961435 3055 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 39:4d285e961435 3056 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 39:4d285e961435 3057 // s/n 0 is not really a MAX40108 board, it's actually a MAX32625PICO used for early development. So no swap.
whismanoid 39:4d285e961435 3058 Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 39:4d285e961435 3059 //Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 39:4d285e961435 3060 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3061 //
whismanoid 39:4d285e961435 3062 // # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 39:4d285e961435 3063 // #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 39:4d285e961435 3064 // //
whismanoid 39:4d285e961435 3065 // # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 39:4d285e961435 3066 // #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 39:4d285e961435 3067 // //
whismanoid 39:4d285e961435 3068 // # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 39:4d285e961435 3069 // #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 39:4d285e961435 3070 // //
whismanoid 39:4d285e961435 3071 // # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 39:4d285e961435 3072 // #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 39:4d285e961435 3073 // //
whismanoid 39:4d285e961435 3074 // # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 39:4d285e961435 3075 // #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 39:4d285e961435 3076 // //
whismanoid 39:4d285e961435 3077 // # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 39:4d285e961435 3078 // #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 39:4d285e961435 3079 // //
whismanoid 39:4d285e961435 3080 # else
whismanoid 39:4d285e961435 3081 // #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 22:d6dc8a85f435 3082 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 22:d6dc8a85f435 3083 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 22:d6dc8a85f435 3084 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3085 # endif
whismanoid 39:4d285e961435 3086 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 39:4d285e961435 3087 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 39:4d285e961435 3088 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 39:4d285e961435 3089 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 39:4d285e961435 3090 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3091 //
whismanoid 39:4d285e961435 3092 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 22:d6dc8a85f435 3093 //
whismanoid 22:d6dc8a85f435 3094 // Serial AUXserial(UART1_TX,UART1_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 3095 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 3096 //
whismanoid 22:d6dc8a85f435 3097 // Virtual serial port over USB
whismanoid 22:d6dc8a85f435 3098 // #include "USBSerial.h"
whismanoid 22:d6dc8a85f435 3099 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 22:d6dc8a85f435 3100 //USBSerial serial;
whismanoid 8:dffee7509bfb 3101 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3102 #elif defined(TARGET_MAX32620FTHR)
whismanoid 8:dffee7509bfb 3103 #warning "TARGET_MAX32620FTHR not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3104 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3105 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32620FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3106 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3107 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3108 //
whismanoid 8:dffee7509bfb 3109 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3110 Serial serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3111 //Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3112 Serial AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3113 //Serial PMOD0AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3114 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3115 //
whismanoid 8:dffee7509bfb 3116 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3117 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3118 Serial DAPLINKserial(USBTX, USBRX); // tx,rx MAX32620FTHR: P2_1,P2_0
whismanoid 8:dffee7509bfb 3119 //Serial DAPLINKserial(STDIO_UART_TX, STDIO_UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3120 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3121 //
whismanoid 8:dffee7509bfb 3122 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3123 // #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3124 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3125 //USBSerial serial; // MAX32620FTHR: USBSerial crash??
whismanoid 8:dffee7509bfb 3126 #warning "TARGET_MAX32620FTHR not previously tested; USBSerial crash?"
whismanoid 8:dffee7509bfb 3127 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3128 #elif defined(TARGET_MAX32600)
whismanoid 8:dffee7509bfb 3129 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3130 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART2 MAX32625MBED: P1_3,P1_2 (Arduino D3,D2)
whismanoid 8:dffee7509bfb 3131 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART1 MAX32625MBED: P7_3,P7_2 ( ?? )
whismanoid 8:dffee7509bfb 3132 //
whismanoid 8:dffee7509bfb 3133 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3134 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3135 Serial DAPLINKserial(P1_1,P1_0); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3136 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3137 //
whismanoid 8:dffee7509bfb 3138 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3139 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3140 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3141 USBSerial serial;
whismanoid 8:dffee7509bfb 3142 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3143 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 8:dffee7509bfb 3144 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3145 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3146 #else
whismanoid 8:dffee7509bfb 3147 #if defined(SERIAL_TX)
whismanoid 8:dffee7509bfb 3148 #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..."
whismanoid 8:dffee7509bfb 3149 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3150 #elif defined(USBTX)
whismanoid 8:dffee7509bfb 3151 #warning "target not previously tested; guess serial pins are USBTX, USBRX..."
whismanoid 8:dffee7509bfb 3152 Serial serial(USBTX, USBRX); // tx, rx
whismanoid 8:dffee7509bfb 3153 #elif defined(UART_TX)
whismanoid 8:dffee7509bfb 3154 #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..."
whismanoid 8:dffee7509bfb 3155 Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3156 #else
whismanoid 8:dffee7509bfb 3157 #warning "target not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3158 #endif
whismanoid 8:dffee7509bfb 3159 #endif
whismanoid 8:dffee7509bfb 3160 //
whismanoid 8:dffee7509bfb 3161 #include "CmdLine.h"
whismanoid 8:dffee7509bfb 3162
whismanoid 8:dffee7509bfb 3163 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3164 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3165 CmdLine cmdLine_AUXserial(AUXserial, "AUXserial");
whismanoid 10:04022a61b527 3166 uint8_t Datalogger_enable_AUXserial = {
whismanoid 10:04022a61b527 3167 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3168 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 3169 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 3170 false
whismanoid 10:04022a61b527 3171 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3172 true
whismanoid 10:04022a61b527 3173 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3174 };
whismanoid 8:dffee7509bfb 3175 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3176 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3177 CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK");
whismanoid 8:dffee7509bfb 3178 uint8_t Datalogger_enable_DAPLINKserial = true;
whismanoid 8:dffee7509bfb 3179 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3180 CmdLine cmdLine(serial, "serial");
whismanoid 8:dffee7509bfb 3181 uint8_t Datalogger_enable_serial = true;
whismanoid 8:dffee7509bfb 3182 // CODE GENERATOR: example code for ADC: serial port declaration (end)
whismanoid 8:dffee7509bfb 3183
whismanoid 21:ac062a97a71d 3184
whismanoid 21:ac062a97a71d 3185 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3186 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 3187 #ifndef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3188 #define USE_DATALOGGER_CommandTable 1
whismanoid 23:c6c652bef4b9 3189 //~ #undef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3190 #endif
whismanoid 23:c6c652bef4b9 3191 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3192 const int COMMAND_TABLE_ROW_MAX = 10;
whismanoid 23:c6c652bef4b9 3193 const int COMMAND_TABLE_COL_MAX = 40;
whismanoid 23:c6c652bef4b9 3194 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3195 //
whismanoid 23:c6c652bef4b9 3196 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3197 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3198 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3199 char onButton1_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button1 event";
whismanoid 23:c6c652bef4b9 3200 char onButton1_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 23:c6c652bef4b9 3201 char onButton1_command_table_02[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 23:c6c652bef4b9 3202 char onButton1_command_table_03[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 23:c6c652bef4b9 3203 char onButton1_command_table_04[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 23:c6c652bef4b9 3204 char onButton1_command_table_05[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 23:c6c652bef4b9 3205 char onButton1_command_table_06[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 23:c6c652bef4b9 3206 char onButton1_command_table_07[COMMAND_TABLE_COL_MAX] = "LR";
whismanoid 23:c6c652bef4b9 3207 char onButton1_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3208 char onButton1_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3209 static char* onButton1_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3210 onButton1_command_table_00,
whismanoid 23:c6c652bef4b9 3211 onButton1_command_table_01,
whismanoid 23:c6c652bef4b9 3212 onButton1_command_table_02,
whismanoid 23:c6c652bef4b9 3213 onButton1_command_table_03,
whismanoid 23:c6c652bef4b9 3214 onButton1_command_table_04,
whismanoid 23:c6c652bef4b9 3215 onButton1_command_table_05,
whismanoid 23:c6c652bef4b9 3216 onButton1_command_table_06,
whismanoid 23:c6c652bef4b9 3217 onButton1_command_table_07,
whismanoid 23:c6c652bef4b9 3218 onButton1_command_table_08,
whismanoid 23:c6c652bef4b9 3219 onButton1_command_table_09,
whismanoid 23:c6c652bef4b9 3220 };
whismanoid 23:c6c652bef4b9 3221 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3222 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3223 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3224 char onButton2_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button2 event";
whismanoid 23:c6c652bef4b9 3225 char onButton2_command_table_01[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 23:c6c652bef4b9 3226 char onButton2_command_table_02[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 23:c6c652bef4b9 3227 char onButton2_command_table_03[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 23:c6c652bef4b9 3228 char onButton2_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3229 char onButton2_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3230 char onButton2_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3231 char onButton2_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3232 char onButton2_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3233 char onButton2_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3234 static char* onButton2_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3235 onButton2_command_table_00,
whismanoid 23:c6c652bef4b9 3236 onButton2_command_table_01,
whismanoid 23:c6c652bef4b9 3237 onButton2_command_table_02,
whismanoid 23:c6c652bef4b9 3238 onButton2_command_table_03,
whismanoid 23:c6c652bef4b9 3239 onButton2_command_table_04,
whismanoid 23:c6c652bef4b9 3240 onButton2_command_table_05,
whismanoid 23:c6c652bef4b9 3241 onButton2_command_table_06,
whismanoid 23:c6c652bef4b9 3242 onButton2_command_table_07,
whismanoid 23:c6c652bef4b9 3243 onButton2_command_table_08,
whismanoid 23:c6c652bef4b9 3244 onButton2_command_table_09,
whismanoid 23:c6c652bef4b9 3245 };
whismanoid 23:c6c652bef4b9 3246 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3247 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3248 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3249 char onButton3_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button3 event";
whismanoid 24:032f3683cb2a 3250 char onButton3_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 24:032f3683cb2a 3251 char onButton3_command_table_02[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 24:032f3683cb2a 3252 char onButton3_command_table_03[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 24:032f3683cb2a 3253 char onButton3_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3254 char onButton3_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3255 char onButton3_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3256 char onButton3_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3257 char onButton3_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3258 char onButton3_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3259 static char* onButton3_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 24:032f3683cb2a 3260 onButton3_command_table_00,
whismanoid 24:032f3683cb2a 3261 onButton3_command_table_01,
whismanoid 24:032f3683cb2a 3262 onButton3_command_table_02,
whismanoid 24:032f3683cb2a 3263 onButton3_command_table_03,
whismanoid 24:032f3683cb2a 3264 onButton3_command_table_04,
whismanoid 24:032f3683cb2a 3265 onButton3_command_table_05,
whismanoid 24:032f3683cb2a 3266 onButton3_command_table_06,
whismanoid 24:032f3683cb2a 3267 onButton3_command_table_07,
whismanoid 24:032f3683cb2a 3268 onButton3_command_table_08,
whismanoid 24:032f3683cb2a 3269 onButton3_command_table_09,
whismanoid 24:032f3683cb2a 3270 };
whismanoid 24:032f3683cb2a 3271 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3272 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3273 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3274 char onButton4_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button4 event";
whismanoid 30:07197a430869 3275 char onButton4_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE>0.7:active";
whismanoid 29:6a9edb6e973b 3276 char onButton4_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3277 char onButton4_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3278 char onButton4_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3279 char onButton4_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3280 char onButton4_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3281 char onButton4_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3282 char onButton4_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3283 char onButton4_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3284 static char* onButton4_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3285 onButton4_command_table_00,
whismanoid 29:6a9edb6e973b 3286 onButton4_command_table_01,
whismanoid 29:6a9edb6e973b 3287 onButton4_command_table_02,
whismanoid 29:6a9edb6e973b 3288 onButton4_command_table_03,
whismanoid 29:6a9edb6e973b 3289 onButton4_command_table_04,
whismanoid 29:6a9edb6e973b 3290 onButton4_command_table_05,
whismanoid 29:6a9edb6e973b 3291 onButton4_command_table_06,
whismanoid 29:6a9edb6e973b 3292 onButton4_command_table_07,
whismanoid 29:6a9edb6e973b 3293 onButton4_command_table_08,
whismanoid 29:6a9edb6e973b 3294 onButton4_command_table_09,
whismanoid 29:6a9edb6e973b 3295 };
whismanoid 29:6a9edb6e973b 3296 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3297 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3298 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3299 char onButton5_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button5 event";
whismanoid 30:07197a430869 3300 char onButton5_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE<0.6:sleep";
whismanoid 29:6a9edb6e973b 3301 char onButton5_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3302 char onButton5_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3303 char onButton5_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3304 char onButton5_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3305 char onButton5_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3306 char onButton5_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3307 char onButton5_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3308 char onButton5_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3309 static char* onButton5_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3310 onButton5_command_table_00,
whismanoid 29:6a9edb6e973b 3311 onButton5_command_table_01,
whismanoid 29:6a9edb6e973b 3312 onButton5_command_table_02,
whismanoid 29:6a9edb6e973b 3313 onButton5_command_table_03,
whismanoid 29:6a9edb6e973b 3314 onButton5_command_table_04,
whismanoid 29:6a9edb6e973b 3315 onButton5_command_table_05,
whismanoid 29:6a9edb6e973b 3316 onButton5_command_table_06,
whismanoid 29:6a9edb6e973b 3317 onButton5_command_table_07,
whismanoid 29:6a9edb6e973b 3318 onButton5_command_table_08,
whismanoid 29:6a9edb6e973b 3319 onButton5_command_table_09,
whismanoid 29:6a9edb6e973b 3320 };
whismanoid 29:6a9edb6e973b 3321 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3322 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3323 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3324 char onButton6_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button6 event";
whismanoid 29:6a9edb6e973b 3325 char onButton6_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3326 char onButton6_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3327 char onButton6_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3328 char onButton6_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3329 char onButton6_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3330 char onButton6_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3331 char onButton6_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3332 char onButton6_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3333 char onButton6_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3334 static char* onButton6_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3335 onButton6_command_table_00,
whismanoid 29:6a9edb6e973b 3336 onButton6_command_table_01,
whismanoid 29:6a9edb6e973b 3337 onButton6_command_table_02,
whismanoid 29:6a9edb6e973b 3338 onButton6_command_table_03,
whismanoid 29:6a9edb6e973b 3339 onButton6_command_table_04,
whismanoid 29:6a9edb6e973b 3340 onButton6_command_table_05,
whismanoid 29:6a9edb6e973b 3341 onButton6_command_table_06,
whismanoid 29:6a9edb6e973b 3342 onButton6_command_table_07,
whismanoid 29:6a9edb6e973b 3343 onButton6_command_table_08,
whismanoid 29:6a9edb6e973b 3344 onButton6_command_table_09,
whismanoid 29:6a9edb6e973b 3345 };
whismanoid 29:6a9edb6e973b 3346 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3347 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3348 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3349 char onButton7_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button7 event";
whismanoid 29:6a9edb6e973b 3350 char onButton7_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3351 char onButton7_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3352 char onButton7_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3353 char onButton7_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3354 char onButton7_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3355 char onButton7_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3356 char onButton7_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3357 char onButton7_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3358 char onButton7_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3359 static char* onButton7_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3360 onButton7_command_table_00,
whismanoid 29:6a9edb6e973b 3361 onButton7_command_table_01,
whismanoid 29:6a9edb6e973b 3362 onButton7_command_table_02,
whismanoid 29:6a9edb6e973b 3363 onButton7_command_table_03,
whismanoid 29:6a9edb6e973b 3364 onButton7_command_table_04,
whismanoid 29:6a9edb6e973b 3365 onButton7_command_table_05,
whismanoid 29:6a9edb6e973b 3366 onButton7_command_table_06,
whismanoid 29:6a9edb6e973b 3367 onButton7_command_table_07,
whismanoid 29:6a9edb6e973b 3368 onButton7_command_table_08,
whismanoid 29:6a9edb6e973b 3369 onButton7_command_table_09,
whismanoid 29:6a9edb6e973b 3370 };
whismanoid 29:6a9edb6e973b 3371 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3372 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3373 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3374 char onButton8_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button8 event";
whismanoid 29:6a9edb6e973b 3375 char onButton8_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3376 char onButton8_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3377 char onButton8_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3378 char onButton8_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3379 char onButton8_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3380 char onButton8_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3381 char onButton8_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3382 char onButton8_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3383 char onButton8_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3384 static char* onButton8_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3385 onButton8_command_table_00,
whismanoid 29:6a9edb6e973b 3386 onButton8_command_table_01,
whismanoid 29:6a9edb6e973b 3387 onButton8_command_table_02,
whismanoid 29:6a9edb6e973b 3388 onButton8_command_table_03,
whismanoid 29:6a9edb6e973b 3389 onButton8_command_table_04,
whismanoid 29:6a9edb6e973b 3390 onButton8_command_table_05,
whismanoid 29:6a9edb6e973b 3391 onButton8_command_table_06,
whismanoid 29:6a9edb6e973b 3392 onButton8_command_table_07,
whismanoid 29:6a9edb6e973b 3393 onButton8_command_table_08,
whismanoid 29:6a9edb6e973b 3394 onButton8_command_table_09,
whismanoid 29:6a9edb6e973b 3395 };
whismanoid 29:6a9edb6e973b 3396 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3397 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3398 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3399 char onButton9_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button9 event";
whismanoid 29:6a9edb6e973b 3400 char onButton9_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3401 char onButton9_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3402 char onButton9_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3403 char onButton9_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3404 char onButton9_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3405 char onButton9_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3406 char onButton9_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3407 char onButton9_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3408 char onButton9_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3409 static char* onButton9_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3410 onButton9_command_table_00,
whismanoid 29:6a9edb6e973b 3411 onButton9_command_table_01,
whismanoid 29:6a9edb6e973b 3412 onButton9_command_table_02,
whismanoid 29:6a9edb6e973b 3413 onButton9_command_table_03,
whismanoid 29:6a9edb6e973b 3414 onButton9_command_table_04,
whismanoid 29:6a9edb6e973b 3415 onButton9_command_table_05,
whismanoid 29:6a9edb6e973b 3416 onButton9_command_table_06,
whismanoid 29:6a9edb6e973b 3417 onButton9_command_table_07,
whismanoid 29:6a9edb6e973b 3418 onButton9_command_table_08,
whismanoid 29:6a9edb6e973b 3419 onButton9_command_table_09,
whismanoid 29:6a9edb6e973b 3420 };
whismanoid 29:6a9edb6e973b 3421 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3422 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3423 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3424 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 3425 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3426 bool g_Run_command_table_running = false;
whismanoid 23:c6c652bef4b9 3427 void Run_command_table(char* command_table[])
whismanoid 23:c6c652bef4b9 3428 {
whismanoid 23:c6c652bef4b9 3429 // command_table: perform list of commands
whismanoid 31:47eee7e0cc2d 3430 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3431 if (g_Run_command_table_running) {
whismanoid 31:47eee7e0cc2d 3432 // TODO: button event chaining is not supported at this time
whismanoid 31:47eee7e0cc2d 3433 } // if (g_Run_command_table_running)
whismanoid 31:47eee7e0cc2d 3434 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3435 g_Run_command_table_running = true;
whismanoid 23:c6c652bef4b9 3436 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 3437 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 3438 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 23:c6c652bef4b9 3439 cmdLine.clear();
whismanoid 31:47eee7e0cc2d 3440 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3441 //~ char* strIndex = command_table[lineIndex];
whismanoid 23:c6c652bef4b9 3442 for (char* strIndex = command_table[lineIndex]; *strIndex != '\0'; strIndex++)
whismanoid 23:c6c652bef4b9 3443 {
whismanoid 23:c6c652bef4b9 3444 cmdLine.append(*strIndex);
whismanoid 23:c6c652bef4b9 3445 }
whismanoid 23:c6c652bef4b9 3446 cmdLine.append('\r'); // append \r invokes onEOLcommandParser to handle command
whismanoid 23:c6c652bef4b9 3447 }
whismanoid 31:47eee7e0cc2d 3448 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3449 g_Run_command_table_running = false;
whismanoid 31:47eee7e0cc2d 3450 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3451 }
whismanoid 23:c6c652bef4b9 3452 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3453 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3454 // When user presses button BUTTON1, perform actions
whismanoid 21:ac062a97a71d 3455 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3456 void onButton1FallingEdge(void)
whismanoid 21:ac062a97a71d 3457 {
whismanoid 21:ac062a97a71d 3458 //~ void SelfTest(CmdLine & cmdLine);
whismanoid 21:ac062a97a71d 3459 //~ SelfTest(cmdLine_serial);
whismanoid 22:d6dc8a85f435 3460 //
whismanoid 23:c6c652bef4b9 3461 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3462 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3463 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3464 Run_command_table(onButton1_command_table);
whismanoid 23:c6c652bef4b9 3465 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3466 }
whismanoid 21:ac062a97a71d 3467 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3468
whismanoid 21:ac062a97a71d 3469 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3470 // When user presses button BUTTON2, perform actions
whismanoid 21:ac062a97a71d 3471 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3472 void onButton2FallingEdge(void)
whismanoid 21:ac062a97a71d 3473 {
whismanoid 21:ac062a97a71d 3474 // TBD demo configuration
whismanoid 21:ac062a97a71d 3475 // TODO diagnostic LED
whismanoid 21:ac062a97a71d 3476 // led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 22:d6dc8a85f435 3477 //
whismanoid 23:c6c652bef4b9 3478 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3479 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3480 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3481 Run_command_table(onButton2_command_table);
whismanoid 23:c6c652bef4b9 3482 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3483 }
whismanoid 21:ac062a97a71d 3484 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3485
whismanoid 24:032f3683cb2a 3486 //--------------------------------------------------
whismanoid 29:6a9edb6e973b 3487 // When user presses button BUTTON3, perform actions
whismanoid 24:032f3683cb2a 3488 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3489 void onButton3FallingEdge(void)
whismanoid 24:032f3683cb2a 3490 {
whismanoid 24:032f3683cb2a 3491 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 24:032f3683cb2a 3492 // command_table: list of commands to perform on button press
whismanoid 24:032f3683cb2a 3493 // command_table: perform list of commands
whismanoid 24:032f3683cb2a 3494 Run_command_table(onButton3_command_table);
whismanoid 24:032f3683cb2a 3495 #endif // USE_DATALOGGER_CommandTable
whismanoid 24:032f3683cb2a 3496 }
whismanoid 24:032f3683cb2a 3497 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3498 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3499 void onButton4FallingEdge(void)
whismanoid 29:6a9edb6e973b 3500 {
whismanoid 29:6a9edb6e973b 3501 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3502 Run_command_table(onButton4_command_table);
whismanoid 29:6a9edb6e973b 3503 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3504 }
whismanoid 29:6a9edb6e973b 3505 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3506 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3507 void onButton5FallingEdge(void)
whismanoid 29:6a9edb6e973b 3508 {
whismanoid 29:6a9edb6e973b 3509 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3510 Run_command_table(onButton5_command_table);
whismanoid 29:6a9edb6e973b 3511 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3512 }
whismanoid 29:6a9edb6e973b 3513 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3514 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3515 void onButton6FallingEdge(void)
whismanoid 29:6a9edb6e973b 3516 {
whismanoid 29:6a9edb6e973b 3517 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3518 Run_command_table(onButton6_command_table);
whismanoid 29:6a9edb6e973b 3519 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3520 }
whismanoid 29:6a9edb6e973b 3521 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3522 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3523 void onButton7FallingEdge(void)
whismanoid 29:6a9edb6e973b 3524 {
whismanoid 29:6a9edb6e973b 3525 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3526 Run_command_table(onButton7_command_table);
whismanoid 29:6a9edb6e973b 3527 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3528 }
whismanoid 29:6a9edb6e973b 3529 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3530 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3531 void onButton8FallingEdge(void)
whismanoid 29:6a9edb6e973b 3532 {
whismanoid 29:6a9edb6e973b 3533 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3534 Run_command_table(onButton8_command_table);
whismanoid 29:6a9edb6e973b 3535 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3536 }
whismanoid 29:6a9edb6e973b 3537 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3538 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3539 void onButton9FallingEdge(void)
whismanoid 29:6a9edb6e973b 3540 {
whismanoid 29:6a9edb6e973b 3541 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3542 Run_command_table(onButton9_command_table);
whismanoid 29:6a9edb6e973b 3543 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3544 }
whismanoid 29:6a9edb6e973b 3545 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3546
whismanoid 4:d9b05924ad4c 3547 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3548 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3549 inline void print_command_prompt()
whismanoid 4:d9b05924ad4c 3550 {
whismanoid 4:d9b05924ad4c 3551 //~ Serial.println(F(">"));
whismanoid 4:d9b05924ad4c 3552 cmdLine.serial().printf("\r\n> ");
whismanoid 4:d9b05924ad4c 3553 }
whismanoid 4:d9b05924ad4c 3554 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3555
whismanoid 4:d9b05924ad4c 3556 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3557 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3558 void main_menu_status(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 3559 {
whismanoid 4:d9b05924ad4c 3560 cmdLine.serial().printf("\r\nMain menu");
whismanoid 4:d9b05924ad4c 3561 #if APPLICATION_MAX5715 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3562 cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC");
whismanoid 4:d9b05924ad4c 3563 #elif APPLICATION_MAX11131 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3564 cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC");
whismanoid 4:d9b05924ad4c 3565 #elif APPLICATION_MAX5171 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3566 cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC");
whismanoid 4:d9b05924ad4c 3567 #elif APPLICATION_MAX11410 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3568 cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC");
whismanoid 4:d9b05924ad4c 3569 #elif APPLICATION_MAX12345 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3570 cmdLine.serial().printf(" MAX12345");
whismanoid 16:819c5aaf5271 3571 #elif MAX40108_DEMO // main_menu_status banner
whismanoid 17:9397ea3ea7e9 3572 cmdLine.serial().printf(" MAX40108_U%d", MAX40108_DEMO);
whismanoid 36:e7aac874b8be 3573 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 3574 // data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 3575 cmdLine.serial().printf(" [s/n %d]", BOARD_SERIAL_NUMBER);
whismanoid 36:e7aac874b8be 3576 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 3577 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 3578 //
whismanoid 36:e7aac874b8be 3579 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 3580 #ifdef FW_REV
whismanoid 37:3f369235e5bc 3581 cmdLine.serial().printf(" [FW_REV %d]", FW_REV);
whismanoid 37:3f369235e5bc 3582 #endif // FW_REV
whismanoid 4:d9b05924ad4c 3583 #else
whismanoid 4:d9b05924ad4c 3584 //cmdLine.serial().printf(" ");
whismanoid 4:d9b05924ad4c 3585 #endif
whismanoid 4:d9b05924ad4c 3586 //cmdLine.serial().printf(" %s", TARGET_NAME);
whismanoid 4:d9b05924ad4c 3587 if (cmdLine.nameStr())
whismanoid 4:d9b05924ad4c 3588 {
whismanoid 4:d9b05924ad4c 3589 cmdLine.serial().printf(" [%s]", cmdLine.nameStr());
whismanoid 4:d9b05924ad4c 3590 }
whismanoid 4:d9b05924ad4c 3591 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3592 cmdLine.serial().printf(" [Button1");
whismanoid 4:d9b05924ad4c 3593 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3594 cmdLine.serial().printf("2");
whismanoid 24:032f3683cb2a 3595 #endif
whismanoid 24:032f3683cb2a 3596 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3597 cmdLine.serial().printf("3");
whismanoid 29:6a9edb6e973b 3598 #endif
whismanoid 29:6a9edb6e973b 3599 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3600 cmdLine.serial().printf("4");
whismanoid 29:6a9edb6e973b 3601 #endif
whismanoid 29:6a9edb6e973b 3602 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3603 cmdLine.serial().printf("5");
whismanoid 29:6a9edb6e973b 3604 #endif
whismanoid 29:6a9edb6e973b 3605 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3606 cmdLine.serial().printf("6");
whismanoid 29:6a9edb6e973b 3607 #endif
whismanoid 29:6a9edb6e973b 3608 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3609 cmdLine.serial().printf("7");
whismanoid 29:6a9edb6e973b 3610 #endif
whismanoid 29:6a9edb6e973b 3611 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3612 cmdLine.serial().printf("8");
whismanoid 29:6a9edb6e973b 3613 #endif
whismanoid 29:6a9edb6e973b 3614 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3615 cmdLine.serial().printf("9");
whismanoid 29:6a9edb6e973b 3616 #endif
whismanoid 29:6a9edb6e973b 3617 cmdLine.serial().printf("]");
whismanoid 29:6a9edb6e973b 3618 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 4:d9b05924ad4c 3619 #if HAS_BUTTON1_DEMO
whismanoid 4:d9b05924ad4c 3620 // print BUTTON1 status
whismanoid 4:d9b05924ad4c 3621 cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read());
whismanoid 4:d9b05924ad4c 3622 #endif
whismanoid 4:d9b05924ad4c 3623 #if HAS_BUTTON2_DEMO
whismanoid 24:032f3683cb2a 3624 // print BUTTON2 status
whismanoid 4:d9b05924ad4c 3625 cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read());
whismanoid 4:d9b05924ad4c 3626 #endif
whismanoid 24:032f3683cb2a 3627 #if HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 3628 // print BUTTON3 status
whismanoid 24:032f3683cb2a 3629 cmdLine.serial().printf("\r\n BUTTON3 = %d", button3.read());
whismanoid 24:032f3683cb2a 3630 #endif
whismanoid 4:d9b05924ad4c 3631 cmdLine.serial().printf("\r\n ? -- help");
whismanoid 4:d9b05924ad4c 3632 }
whismanoid 4:d9b05924ad4c 3633 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3634
whismanoid 28:a9a3a9db592b 3635 //--------------------------------------------------
whismanoid 28:a9a3a9db592b 3636 #ifndef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3637 #define USE_DATALOGGER_TRIGGER_HELP_BRIEF 1
whismanoid 28:a9a3a9db592b 3638 //~ #undef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3639 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3640
whismanoid 4:d9b05924ad4c 3641 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3642 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3643 void main_menu_help(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 3644 {
whismanoid 4:d9b05924ad4c 3645 // ? -- help
whismanoid 4:d9b05924ad4c 3646 //~ cmdLine.serial().printf("\r\nMenu:");
whismanoid 10:04022a61b527 3647 //
whismanoid 4:d9b05924ad4c 3648 cmdLine.serial().printf("\r\n # -- lines beginning with # are comments");
whismanoid 10:04022a61b527 3649 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 3650 cmdLine.serial().printf("\r\n ! -- Init");
whismanoid 10:04022a61b527 3651 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 3652 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 3653 cmdLine.serial().printf("\r\n . -- SelfTest");
whismanoid 4:d9b05924ad4c 3654 #endif // USE_SELFTEST
whismanoid 9:45f98573eb6d 3655 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 9:45f98573eb6d 3656 // CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register
whismanoid 9:45f98573eb6d 3657 cmdLine.serial().printf("\r\n * -- read core registers\r\n *regname? -- read register\r\n *regname=regvalue -- write register");
whismanoid 9:45f98573eb6d 3658 // cmdLine.serial().printf("\r\n 01 23 45 67 89 ab cd ef -- write and read raw hex codes");
whismanoid 10:04022a61b527 3659 #endif // USE_STAR_REG_READWRITE
whismanoid 10:04022a61b527 3660 //
whismanoid 10:04022a61b527 3661 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3662 // Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_help
whismanoid 10:04022a61b527 3663 //~ cmdLine.serial().printf("\r\n > -- auxiliary UART port");
whismanoid 10:04022a61b527 3664 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3665 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3666 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3667 if (cmdLine_AUXserial.nameStr())
whismanoid 10:04022a61b527 3668 {
whismanoid 10:04022a61b527 3669 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_AUXserial.nameStr());
whismanoid 10:04022a61b527 3670 }
whismanoid 10:04022a61b527 3671 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3672 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3673 if (cmdLine_DAPLINKserial.nameStr())
whismanoid 10:04022a61b527 3674 {
whismanoid 10:04022a61b527 3675 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_DAPLINKserial.nameStr());
whismanoid 10:04022a61b527 3676 }
whismanoid 10:04022a61b527 3677 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3678 # if HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3679 // WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3680 cmdLine.serial().printf("\r\n >xyzzy -- Forward command/data 'xyzzy' to aux TX/RX");
whismanoid 10:04022a61b527 3681 cmdLine.serial().printf("\r\n >>xyzzy -- Forward 'xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 3682 cmdLine.serial().printf("\r\n >>>xyzzy -- Forward '>xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 3683 #if 0
whismanoid 10:04022a61b527 3684 cmdLine.serial().printf("\r\n >tx_wait_echo=%d -- configure TX wait for each character echo", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 3685 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 3686 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 3687 #endif
whismanoid 20:78ef670955d4 3688 #if 1 // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 3689 cmdLine.serial().printf("\r\n >baud=%d message_ms=%d rx_idle_ms=%d rx_max_count=%d rx_eot=%d",
whismanoid 20:78ef670955d4 3690 g_auxSerialCom_baud,
whismanoid 20:78ef670955d4 3691 g_auxSerialCom_message_ms,
whismanoid 20:78ef670955d4 3692 g_auxSerialCom_rx_idle_ms,
whismanoid 20:78ef670955d4 3693 g_auxSerialCom_rx_max_count,
whismanoid 20:78ef670955d4 3694 g_auxSerialCom_rx_eot);
whismanoid 20:78ef670955d4 3695 #else // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 3696 cmdLine.serial().printf("\r\n >baud=%d -- configure aux TX/RX port", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 3697 cmdLine.serial().printf("\r\n >message_ms=%d -- maximum RX message total response time", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 3698 cmdLine.serial().printf("\r\n >rx_idle_ms=%d -- maximum RX message idle time between characters", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 3699 cmdLine.serial().printf("\r\n >rx_max_count=%d -- maximum RX message total length", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 3700 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 3701 #endif // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 10:04022a61b527 3702 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3703 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3704 //
whismanoid 4:d9b05924ad4c 3705 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 3706 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3707 // Datalog trigger menu
whismanoid 28:a9a3a9db592b 3708 // brief toplevel heading for datalog help L
whismanoid 28:a9a3a9db592b 3709 // L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 3710 cmdLine.serial().printf("\r\n L -- halt the datalogger; show more commands");
whismanoid 28:a9a3a9db592b 3711 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 28:a9a3a9db592b 3712 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 28:a9a3a9db592b 3713 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 28:a9a3a9db592b 3714 //
whismanoid 28:a9a3a9db592b 3715 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 3716 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 3717 //
whismanoid 39:4d285e961435 3718 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 3719 // TODO: USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 3720 cmdLine.serial().printf("\r\n LT count=%d base=%dms sleep=%d -- Datalog timer",
whismanoid 39:4d285e961435 3721 g_timer_interval_count,
whismanoid 39:4d285e961435 3722 g_timer_interval_msec,
whismanoid 39:4d285e961435 3723 (int)g_timer_sleepmode
whismanoid 39:4d285e961435 3724 ); // trigger_Timer
whismanoid 39:4d285e961435 3725 #else // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 3726 cmdLine.serial().printf("\r\n LT count=%d base=%dms -- Datalog timer", g_timer_interval_count, g_timer_interval_msec); // trigger_Timer
whismanoid 39:4d285e961435 3727 #endif // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 3728 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3729 //~ cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 3730 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3731 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 3732 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 3733 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 3734 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 9:45f98573eb6d 3735 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 9:45f98573eb6d 3736 //
whismanoid 17:9397ea3ea7e9 3737 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 4:d9b05924ad4c 3738 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 9:45f98573eb6d 3739 //
whismanoid 17:9397ea3ea7e9 3740 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 3741 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 17:9397ea3ea7e9 3742 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 3743 //
whismanoid 9:45f98573eb6d 3744 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 3745 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 3746 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 3747 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 9:45f98573eb6d 3748 //
whismanoid 17:9397ea3ea7e9 3749 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 9:45f98573eb6d 3750 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 3751 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 3752 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 3753 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 3754 //
whismanoid 17:9397ea3ea7e9 3755 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3756 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 17:9397ea3ea7e9 3757 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 9:45f98573eb6d 3758 //
whismanoid 9:45f98573eb6d 3759 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 3760 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 3761 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 3762 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 3763 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 9:45f98573eb6d 3764 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 9:45f98573eb6d 3765 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 9:45f98573eb6d 3766 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 9:45f98573eb6d 3767 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 9:45f98573eb6d 3768 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 9:45f98573eb6d 3769 //
whismanoid 9:45f98573eb6d 3770 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 3771 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 9:45f98573eb6d 3772 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 9:45f98573eb6d 3773 //
whismanoid 9:45f98573eb6d 3774 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 3775 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 3776 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 9:45f98573eb6d 3777 //
whismanoid 9:45f98573eb6d 3778 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 3779 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 9:45f98573eb6d 3780 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 3781 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 9:45f98573eb6d 3782 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 3783 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 9:45f98573eb6d 3784 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 3785 //
whismanoid 9:45f98573eb6d 3786 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 3787 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 9:45f98573eb6d 3788 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 9:45f98573eb6d 3789 //
whismanoid 9:45f98573eb6d 3790 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 3791 //
whismanoid 9:45f98573eb6d 3792 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 3793 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 3794 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 3795 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 3796 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 9:45f98573eb6d 3797 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3798 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 9:45f98573eb6d 3799 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3800 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3801 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 9:45f98573eb6d 3802 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3803 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 9:45f98573eb6d 3804 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3805 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 9:45f98573eb6d 3806 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3807 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3808 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 9:45f98573eb6d 3809 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3810 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 3811 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 3812 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 3813 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3814 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 3815 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 3816 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 3817 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3818 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 3819 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 3820 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 3821 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 3822 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 3823 //
whismanoid 4:d9b05924ad4c 3824 //cmdLine.serial().print(F("\r\n ! -- Initial Configuration"));
whismanoid 4:d9b05924ad4c 3825 //
whismanoid 4:d9b05924ad4c 3826 // % standardize diagnostic commands
whismanoid 4:d9b05924ad4c 3827 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 3828 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 3829 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 3830 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 3831 // %Ppin df=xx -- pwm output
whismanoid 4:d9b05924ad4c 3832 // %Wpin -- measure high pulsewidth input in usec
whismanoid 4:d9b05924ad4c 3833 // %wpin -- measure low pulsewidth input in usec
whismanoid 4:d9b05924ad4c 3834 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 3835 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 3836 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 3837 // %IW ADDR=? cmd=? data,data,data -- write
whismanoid 4:d9b05924ad4c 3838 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 3839 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3840 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 3841 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 3842 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 3843 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 3844 // A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 3845 //
whismanoid 23:c6c652bef4b9 3846 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3847 #if USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3848 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 3849 // TODO: %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 3850 // TODO: future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 3851 // TODO: future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 3852 // TODO: %B1@ view command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 3853 // TODO: %B1@+ command add new row (if there is room to add) (ignore one space before command)
whismanoid 23:c6c652bef4b9 3854 // TODO: %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 3855 // TODO: %B1@-~~~ clear entire command table
whismanoid 23:c6c652bef4b9 3856 // TODO: %B1@nnn command replace row number nnn (ignore one space before command)
whismanoid 23:c6c652bef4b9 3857 // TODO: %B1@! disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 3858 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 3859 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 30:07197a430869 3860 cmdLine.serial().printf("\r\n %%B1! trigger Button1 event; %%B1@ -- view/edit command table");
whismanoid 23:c6c652bef4b9 3861 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3862 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3863 #if HAS_digitalInOuts
whismanoid 4:d9b05924ad4c 3864 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 3865 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 3866 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 3867 cmdLine.serial().printf("\r\n %%Hn {pin:");
whismanoid 4:d9b05924ad4c 3868 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3869 cmdLine.serial().printf("} -- High Output");
whismanoid 4:d9b05924ad4c 3870 cmdLine.serial().printf("\r\n %%Ln {pin:");
whismanoid 4:d9b05924ad4c 3871 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3872 cmdLine.serial().printf("} -- Low Output");
whismanoid 4:d9b05924ad4c 3873 cmdLine.serial().printf("\r\n %%?n {pin:");
whismanoid 4:d9b05924ad4c 3874 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3875 cmdLine.serial().printf("} -- Input");
whismanoid 4:d9b05924ad4c 3876 #endif
whismanoid 4:d9b05924ad4c 3877
whismanoid 4:d9b05924ad4c 3878 #if HAS_analogIns
whismanoid 4:d9b05924ad4c 3879 // Menu A) analogRead A0..7
whismanoid 4:d9b05924ad4c 3880 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 3881 // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0)
whismanoid 37:3f369235e5bc 3882 cmdLine.serial().printf("\r\n %%A -- analogRead");
whismanoid 37:3f369235e5bc 3883 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3884 // %A avg=%d -- help string display Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 3885 cmdLine.serial().printf("; %%A avg=%d -- average", Platform_AIN_Average_N);
whismanoid 37:3f369235e5bc 3886 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 3887 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3888 // %A cal? view/export raw calibration values for all channels
whismanoid 37:3f369235e5bc 3889 cmdLine.serial().printf("; %%A cal? -- calibration");
whismanoid 34:a1993a1ee904 3890 #endif // HAS_Platform_AIN_Calibration
whismanoid 4:d9b05924ad4c 3891 #endif
whismanoid 4:d9b05924ad4c 3892
whismanoid 4:d9b05924ad4c 3893 #if HAS_SPI2_MAX541
whismanoid 4:d9b05924ad4c 3894 // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 4:d9b05924ad4c 3895 cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)");
whismanoid 4:d9b05924ad4c 3896 #endif
whismanoid 4:d9b05924ad4c 3897
whismanoid 4:d9b05924ad4c 3898 #if HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3899 // TODO: support I2C HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3900 // VERIFY: I2C utility commands SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3901 // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz);
whismanoid 4:d9b05924ad4c 3902 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 3903 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 3904 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 3905 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 4:d9b05924ad4c 3906 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 3907 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3908 //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope
whismanoid 4:d9b05924ad4c 3909 cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 4:d9b05924ad4c 3910 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 4:d9b05924ad4c 3911 (g_I2C_SCL_Hz / 1000.));
whismanoid 4:d9b05924ad4c 3912 cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read",
whismanoid 4:d9b05924ad4c 3913 g_I2C_deviceAddress7);
whismanoid 4:d9b05924ad4c 3914 //
whismanoid 4:d9b05924ad4c 3915 #if SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3916 // Menu ^ cmd=?) i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3917 cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data");
whismanoid 4:d9b05924ad4c 3918 // test low-level I2C i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3919 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3920 //cmdLine.serial().printf(" H) Hunt for attached I2C devices");
whismanoid 4:d9b05924ad4c 3921 cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices");
whismanoid 4:d9b05924ad4c 3922 // cmdLine.serial().printf(" s) search i2c address");
whismanoid 4:d9b05924ad4c 3923 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3924
whismanoid 4:d9b05924ad4c 3925 #if HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3926 // TODO: support SPI HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3927 // SPI test command S (mosiData)+
whismanoid 4:d9b05924ad4c 3928 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 3929 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 3930 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 3931 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 3932 // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 4:d9b05924ad4c 3933 // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 4:d9b05924ad4c 3934 // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 4:d9b05924ad4c 3935 // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 4:d9b05924ad4c 3936 // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 4:d9b05924ad4c 3937 // mode | POL PHA
whismanoid 4:d9b05924ad4c 3938 // -----+--------
whismanoid 4:d9b05924ad4c 3939 // 0 | 0 0
whismanoid 4:d9b05924ad4c 3940 // 1 | 0 1
whismanoid 4:d9b05924ad4c 3941 // 2 | 1 0
whismanoid 4:d9b05924ad4c 3942 // 3 | 1 1
whismanoid 4:d9b05924ad4c 3943 //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0");
whismanoid 4:d9b05924ad4c 3944 // 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 3945 cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config",
whismanoid 4:d9b05924ad4c 3946 g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.),
whismanoid 4:d9b05924ad4c 3947 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 4:d9b05924ad4c 3948 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0));
whismanoid 4:d9b05924ad4c 3949 cmdLine.serial().printf("\r\n %%SD -- SPI diagnostic messages ");
whismanoid 4:d9b05924ad4c 3950 if (g_MAX11410_device.onSPIprint) {
whismanoid 4:d9b05924ad4c 3951 cmdLine.serial().printf("hide");
whismanoid 4:d9b05924ad4c 3952 }
whismanoid 4:d9b05924ad4c 3953 else {
whismanoid 4:d9b05924ad4c 3954 cmdLine.serial().printf("show");
whismanoid 4:d9b05924ad4c 3955 }
whismanoid 4:d9b05924ad4c 3956 cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes");
whismanoid 4:d9b05924ad4c 3957 // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0
whismanoid 4:d9b05924ad4c 3958 #endif // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3959 //
whismanoid 4:d9b05924ad4c 3960 // Application-specific commands (help text) here
whismanoid 4:d9b05924ad4c 3961 //
whismanoid 4:d9b05924ad4c 3962 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3963 cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3964 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3965 //
whismanoid 4:d9b05924ad4c 3966
whismanoid 4:d9b05924ad4c 3967 //~ extern void MAX11410_menu_help(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp\n
whismanoid 4:d9b05924ad4c 3968 //~ MAX11410_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 3969 }
whismanoid 4:d9b05924ad4c 3970 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3971
whismanoid 4:d9b05924ad4c 3972 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 15:37c83ec50ea0 3973
whismanoid 15:37c83ec50ea0 3974 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 3975 void pinsMonitor_submenu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 15:37c83ec50ea0 3976 {
whismanoid 15:37c83ec50ea0 3977 // % diagnostic commands submenu
whismanoid 15:37c83ec50ea0 3978 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 3979 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 3980 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 3981 // %A %Apin -- analog input
whismanoid 15:37c83ec50ea0 3982 // %Ppin df=xx -- pwm output
whismanoid 15:37c83ec50ea0 3983 // %Wpin -- measure high pulsewidth input in usec
whismanoid 15:37c83ec50ea0 3984 // %wpin -- measure low pulsewidth input in usec
whismanoid 15:37c83ec50ea0 3985 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 3986 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 3987 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 3988 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 3989 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 3990 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 3991 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 3992 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 3993 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 3994 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 3995 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 3996 //
whismanoid 15:37c83ec50ea0 3997 char strPinIndex[3];
whismanoid 15:37c83ec50ea0 3998 strPinIndex[0] = cmdLine[2];
whismanoid 15:37c83ec50ea0 3999 strPinIndex[1] = cmdLine[3];
whismanoid 15:37c83ec50ea0 4000 strPinIndex[2] = '\0';
whismanoid 15:37c83ec50ea0 4001 int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 15:37c83ec50ea0 4002 //cmdLine.serial().printf(" pinIndex=%d ", pinIndex);
whismanoid 15:37c83ec50ea0 4003 //
whismanoid 15:37c83ec50ea0 4004 // get next character
whismanoid 15:37c83ec50ea0 4005 switch (cmdLine[1])
whismanoid 15:37c83ec50ea0 4006 {
whismanoid 23:c6c652bef4b9 4007 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 4008 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 4009 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 4010 case 'B': case 'b':
whismanoid 23:c6c652bef4b9 4011 {
whismanoid 24:032f3683cb2a 4012 int command_table_button_index = 1;
whismanoid 23:c6c652bef4b9 4013 // %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 4014 // future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 4015 // future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 4016 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 4017 // cmdLine[2] == '1' selects onButton1_command_table
whismanoid 23:c6c652bef4b9 4018 char** command_table = onButton1_command_table;
whismanoid 23:c6c652bef4b9 4019 #endif
whismanoid 24:032f3683cb2a 4020 switch(cmdLine[2])
whismanoid 24:032f3683cb2a 4021 {
whismanoid 24:032f3683cb2a 4022 default:
whismanoid 24:032f3683cb2a 4023 case '1': case 'A': case 'a': case '!':
whismanoid 24:032f3683cb2a 4024 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4025 command_table_button_index = 1;
whismanoid 24:032f3683cb2a 4026 command_table = onButton1_command_table;
whismanoid 24:032f3683cb2a 4027 #endif
whismanoid 24:032f3683cb2a 4028 break;
whismanoid 24:032f3683cb2a 4029 case '2': case 'B': case 'b': case '@':
whismanoid 23:c6c652bef4b9 4030 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4031 command_table_button_index = 2;
whismanoid 24:032f3683cb2a 4032 command_table = onButton2_command_table;
whismanoid 24:032f3683cb2a 4033 #endif
whismanoid 24:032f3683cb2a 4034 break;
whismanoid 24:032f3683cb2a 4035 case '3': case 'C': case 'c': case '#':
whismanoid 23:c6c652bef4b9 4036 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4037 command_table_button_index = 3;
whismanoid 24:032f3683cb2a 4038 command_table = onButton3_command_table;
whismanoid 24:032f3683cb2a 4039 #endif
whismanoid 24:032f3683cb2a 4040 break;
whismanoid 29:6a9edb6e973b 4041 case '4':
whismanoid 29:6a9edb6e973b 4042 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4043 command_table_button_index = 4;
whismanoid 29:6a9edb6e973b 4044 command_table = onButton4_command_table;
whismanoid 29:6a9edb6e973b 4045 #endif
whismanoid 29:6a9edb6e973b 4046 break;
whismanoid 29:6a9edb6e973b 4047 case '5':
whismanoid 29:6a9edb6e973b 4048 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4049 command_table_button_index = 5;
whismanoid 29:6a9edb6e973b 4050 command_table = onButton5_command_table;
whismanoid 29:6a9edb6e973b 4051 #endif
whismanoid 29:6a9edb6e973b 4052 break;
whismanoid 29:6a9edb6e973b 4053 case '6':
whismanoid 29:6a9edb6e973b 4054 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4055 command_table_button_index = 6;
whismanoid 29:6a9edb6e973b 4056 command_table = onButton6_command_table;
whismanoid 29:6a9edb6e973b 4057 #endif
whismanoid 29:6a9edb6e973b 4058 break;
whismanoid 29:6a9edb6e973b 4059 case '7':
whismanoid 29:6a9edb6e973b 4060 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4061 command_table_button_index = 7;
whismanoid 29:6a9edb6e973b 4062 command_table = onButton7_command_table;
whismanoid 29:6a9edb6e973b 4063 #endif
whismanoid 29:6a9edb6e973b 4064 break;
whismanoid 29:6a9edb6e973b 4065 case '8':
whismanoid 29:6a9edb6e973b 4066 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4067 command_table_button_index = 8;
whismanoid 29:6a9edb6e973b 4068 command_table = onButton8_command_table;
whismanoid 29:6a9edb6e973b 4069 #endif
whismanoid 29:6a9edb6e973b 4070 break;
whismanoid 29:6a9edb6e973b 4071 case '9':
whismanoid 29:6a9edb6e973b 4072 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4073 command_table_button_index = 9;
whismanoid 29:6a9edb6e973b 4074 command_table = onButton9_command_table;
whismanoid 29:6a9edb6e973b 4075 #endif
whismanoid 29:6a9edb6e973b 4076 break;
whismanoid 24:032f3683cb2a 4077 }
whismanoid 24:032f3683cb2a 4078 //
whismanoid 23:c6c652bef4b9 4079 switch(cmdLine[3])
whismanoid 23:c6c652bef4b9 4080 {
whismanoid 23:c6c652bef4b9 4081 case '@':
whismanoid 23:c6c652bef4b9 4082 {
whismanoid 23:c6c652bef4b9 4083 // %B1@ view/edit command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 4084 int editRowIndex = 0;
whismanoid 23:c6c652bef4b9 4085 int command_table_row_count = 0;
whismanoid 23:c6c652bef4b9 4086 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 4087 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 4088 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 4089 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 4090 }
whismanoid 24:032f3683cb2a 4091 //
whismanoid 24:032f3683cb2a 4092 // ignore extra spaces before the command
whismanoid 24:032f3683cb2a 4093 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 24:032f3683cb2a 4094 int argIndex;
whismanoid 24:032f3683cb2a 4095 for (argIndex = 5; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 4096 {
whismanoid 24:032f3683cb2a 4097 if (cmdLine[argIndex] == ' ') break;
whismanoid 24:032f3683cb2a 4098 }
whismanoid 24:032f3683cb2a 4099 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 4100 {
whismanoid 24:032f3683cb2a 4101 if (cmdLine[argIndex] != ' ') break;
whismanoid 23:c6c652bef4b9 4102 }
whismanoid 23:c6c652bef4b9 4103 //
whismanoid 23:c6c652bef4b9 4104 // Edit the contents of command_table
whismanoid 23:c6c652bef4b9 4105 switch (cmdLine[4]) // %B1@... -- Edit the contents of command_table
whismanoid 23:c6c652bef4b9 4106 {
whismanoid 23:c6c652bef4b9 4107 case '0': case '1': case '2': case '3': case '4':
whismanoid 23:c6c652bef4b9 4108 case '5': case '6': case '7': case '8': case '9':
whismanoid 24:032f3683cb2a 4109 // %B1@nnn command replace row number nnn
whismanoid 23:c6c652bef4b9 4110 // edit row data
whismanoid 33:70a28cfe9e01 4111 // get row number to edit from cmdLine[4]
whismanoid 33:70a28cfe9e01 4112 editRowIndex = atoi(cmdLine.str()+4);
whismanoid 23:c6c652bef4b9 4113 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4114 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 4115 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 28:a9a3a9db592b 4116 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 4117 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 4118 cmdLine.serial().printf("\r\n cannot replace row %d with nothing",
whismanoid 28:a9a3a9db592b 4119 editRowIndex);
whismanoid 28:a9a3a9db592b 4120 }
whismanoid 28:a9a3a9db592b 4121 else
whismanoid 28:a9a3a9db592b 4122 {
whismanoid 28:a9a3a9db592b 4123 // update row
whismanoid 28:a9a3a9db592b 4124 cmdLine.serial().printf("\r\n replace row %d with \"%s\"",
whismanoid 28:a9a3a9db592b 4125 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 4126 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4127 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 4128 }
whismanoid 24:032f3683cb2a 4129 }
whismanoid 33:70a28cfe9e01 4130 } // end if (command_table_row_count > 0)
whismanoid 33:70a28cfe9e01 4131 if ((editRowIndex == command_table_row_count) && (command_table_row_count < COMMAND_TABLE_ROW_MAX)) {
whismanoid 33:70a28cfe9e01 4132 // %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 4133 //
whismanoid 33:70a28cfe9e01 4134 command_table_row_count++;
whismanoid 33:70a28cfe9e01 4135 cmdLine.serial().printf("\r\n add next row %d containing \"%s\"",
whismanoid 33:70a28cfe9e01 4136 editRowIndex, cmdLine.str()+argIndex);
whismanoid 33:70a28cfe9e01 4137 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 33:70a28cfe9e01 4138 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 33:70a28cfe9e01 4139 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 33:70a28cfe9e01 4140 //
whismanoid 23:c6c652bef4b9 4141 }
whismanoid 33:70a28cfe9e01 4142 //
whismanoid 23:c6c652bef4b9 4143 break;
whismanoid 23:c6c652bef4b9 4144 case '+':
whismanoid 24:032f3683cb2a 4145 // %B1@+ command add new row (if there is room to add)
whismanoid 23:c6c652bef4b9 4146 // add a new row at end of table
whismanoid 23:c6c652bef4b9 4147 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 4148 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 23:c6c652bef4b9 4149 editRowIndex = command_table_row_count;
whismanoid 28:a9a3a9db592b 4150 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 4151 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 4152 cmdLine.serial().printf("\r\n cannot add new row %d containing nothing",
whismanoid 28:a9a3a9db592b 4153 editRowIndex);
whismanoid 28:a9a3a9db592b 4154 }
whismanoid 28:a9a3a9db592b 4155 else
whismanoid 28:a9a3a9db592b 4156 {
whismanoid 28:a9a3a9db592b 4157 command_table_row_count++;
whismanoid 28:a9a3a9db592b 4158 cmdLine.serial().printf("\r\n add new row %d containing \"%s\"",
whismanoid 28:a9a3a9db592b 4159 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 4160 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4161 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 4162 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 28:a9a3a9db592b 4163 }
whismanoid 23:c6c652bef4b9 4164 }
whismanoid 23:c6c652bef4b9 4165 break;
whismanoid 23:c6c652bef4b9 4166 case '-':
whismanoid 24:032f3683cb2a 4167 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 4168 // delete row from table
whismanoid 23:c6c652bef4b9 4169 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4170 // if command_table_row_count == 0 then the table is empty
whismanoid 23:c6c652bef4b9 4171 if ((cmdLine[5] == '~') && (cmdLine[6] == '~') && (cmdLine[7] == '~')) {
whismanoid 23:c6c652bef4b9 4172 // %B1@-~~~ clear entire command table
whismanoid 24:032f3683cb2a 4173 cmdLine.serial().printf("\r\n clear entire command table");
whismanoid 23:c6c652bef4b9 4174 command_table_row_count = 0;
whismanoid 28:a9a3a9db592b 4175 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 23:c6c652bef4b9 4176 break;
whismanoid 23:c6c652bef4b9 4177 }
whismanoid 24:032f3683cb2a 4178 else
whismanoid 23:c6c652bef4b9 4179 {
whismanoid 24:032f3683cb2a 4180 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 24:032f3683cb2a 4181 editRowIndex = atoi(cmdLine.str()+5);
whismanoid 24:032f3683cb2a 4182 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 24:032f3683cb2a 4183 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 24:032f3683cb2a 4184 // delete row editRowIndex from Datalogger_action_table
whismanoid 24:032f3683cb2a 4185 for (int i = editRowIndex; i < (command_table_row_count-1); i++)
whismanoid 24:032f3683cb2a 4186 {
whismanoid 24:032f3683cb2a 4187 // copy row i+1 into row i
whismanoid 24:032f3683cb2a 4188 cmdLine.serial().printf("\r\n copy row %d into row %d: \"%s\"",
whismanoid 24:032f3683cb2a 4189 i+1, i, command_table[i+1]);
whismanoid 24:032f3683cb2a 4190 strncpy(command_table[i], command_table[i+1], COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4191 command_table[i][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 24:032f3683cb2a 4192 }
whismanoid 24:032f3683cb2a 4193 command_table_row_count--;
whismanoid 28:a9a3a9db592b 4194 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 24:032f3683cb2a 4195 }
whismanoid 23:c6c652bef4b9 4196 }
whismanoid 23:c6c652bef4b9 4197 }
whismanoid 23:c6c652bef4b9 4198 break;
whismanoid 30:07197a430869 4199 case '.': // something other than ! because %B1! means trigger event
whismanoid 30:07197a430869 4200 // pause the button event
whismanoid 30:07197a430869 4201 // TODO: %B1@. disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 4202 //~ Datalogger_action_table_enabled = false;
whismanoid 23:c6c652bef4b9 4203 break;
whismanoid 23:c6c652bef4b9 4204 case '@':
whismanoid 30:07197a430869 4205 // enable the button event
whismanoid 23:c6c652bef4b9 4206 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 4207 //~ Datalogger_action_table_enabled = true;
whismanoid 23:c6c652bef4b9 4208 break;
whismanoid 23:c6c652bef4b9 4209 }
whismanoid 23:c6c652bef4b9 4210 //
whismanoid 23:c6c652bef4b9 4211 // Print the contents of command_table
whismanoid 23:c6c652bef4b9 4212 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 4213 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 4214 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 4215 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 4216 cmdLine.serial().printf("\r\n %%B%1d@%d %s",
whismanoid 24:032f3683cb2a 4217 command_table_button_index,
whismanoid 24:032f3683cb2a 4218 lineIndex,
whismanoid 24:032f3683cb2a 4219 command_table[lineIndex]);
whismanoid 23:c6c652bef4b9 4220 }
whismanoid 30:07197a430869 4221 //~ cmdLine.serial().printf("\r\n command_table_row_count = %d/%d",
whismanoid 30:07197a430869 4222 //~ command_table_row_count, COMMAND_TABLE_ROW_MAX);
whismanoid 30:07197a430869 4223 cmdLine.serial().printf("\r\n\r\nEdit Button%d event (used %d/%d, %d free):",
whismanoid 30:07197a430869 4224 command_table_button_index,
whismanoid 30:07197a430869 4225 command_table_row_count,
whismanoid 30:07197a430869 4226 COMMAND_TABLE_ROW_MAX,
whismanoid 30:07197a430869 4227 (COMMAND_TABLE_ROW_MAX - command_table_row_count)
whismanoid 30:07197a430869 4228 );
whismanoid 23:c6c652bef4b9 4229 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 4230 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 24:032f3683cb2a 4231 cmdLine.serial().printf("\r\n %%B%1d@+ command -- add new row %d at end of table",
whismanoid 24:032f3683cb2a 4232 command_table_button_index,
whismanoid 24:032f3683cb2a 4233 command_table_row_count);
whismanoid 23:c6c652bef4b9 4234 }
whismanoid 23:c6c652bef4b9 4235 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4236 // if command_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 4237 cmdLine.serial().printf("\r\n %%B%1d@%d command -- replace row %d",
whismanoid 24:032f3683cb2a 4238 command_table_button_index,
whismanoid 23:c6c652bef4b9 4239 command_table_row_count-1,
whismanoid 23:c6c652bef4b9 4240 command_table_row_count-1);
whismanoid 24:032f3683cb2a 4241 cmdLine.serial().printf("\r\n %%B%1d@-%d -- delete row %d",
whismanoid 24:032f3683cb2a 4242 command_table_button_index,
whismanoid 24:032f3683cb2a 4243 command_table_row_count-1,
whismanoid 24:032f3683cb2a 4244 command_table_row_count-1);
whismanoid 24:032f3683cb2a 4245 cmdLine.serial().printf("\r\n %%B%1d@-~~~ -- delete all rows",
whismanoid 24:032f3683cb2a 4246 command_table_button_index);
whismanoid 30:07197a430869 4247 //~ cmdLine.serial().printf("\r\n %%B%1d@. -- pause entire command table",
whismanoid 30:07197a430869 4248 //~ command_table_button_index);
whismanoid 30:07197a430869 4249 //~ cmdLine.serial().printf("\r\n %%B%1d@@ -- enable command table",
whismanoid 30:07197a430869 4250 //~ command_table_button_index);
whismanoid 30:07197a430869 4251 cmdLine.serial().printf("\r\n %%B%1d! -- trigger Button%d event",
whismanoid 30:07197a430869 4252 command_table_button_index,
whismanoid 24:032f3683cb2a 4253 command_table_button_index);
whismanoid 23:c6c652bef4b9 4254 }
whismanoid 23:c6c652bef4b9 4255 //
whismanoid 23:c6c652bef4b9 4256 } // case '@' -- %B1@ view/edit command table
whismanoid 23:c6c652bef4b9 4257 break;
whismanoid 23:c6c652bef4b9 4258 case '!':
whismanoid 23:c6c652bef4b9 4259 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 23:c6c652bef4b9 4260 Run_command_table(command_table);
whismanoid 23:c6c652bef4b9 4261 break;
whismanoid 23:c6c652bef4b9 4262 }
whismanoid 23:c6c652bef4b9 4263 }
whismanoid 23:c6c652bef4b9 4264 break;
whismanoid 23:c6c652bef4b9 4265 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4266 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 4267 #if HAS_digitalInOuts
whismanoid 15:37c83ec50ea0 4268 case 'H': case 'h':
whismanoid 15:37c83ec50ea0 4269 {
whismanoid 15:37c83ec50ea0 4270 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 4271 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4272 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4273 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4274 #else
whismanoid 15:37c83ec50ea0 4275 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4276 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 4277 digitalInOutPin.write(1);
whismanoid 15:37c83ec50ea0 4278 #endif
whismanoid 15:37c83ec50ea0 4279 cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex);
whismanoid 15:37c83ec50ea0 4280 }
whismanoid 15:37c83ec50ea0 4281 break;
whismanoid 15:37c83ec50ea0 4282 case 'L': case 'l':
whismanoid 15:37c83ec50ea0 4283 {
whismanoid 15:37c83ec50ea0 4284 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 4285 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4286 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4287 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4288 #else
whismanoid 15:37c83ec50ea0 4289 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4290 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 4291 digitalInOutPin.write(0);
whismanoid 15:37c83ec50ea0 4292 #endif
whismanoid 15:37c83ec50ea0 4293 cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex);
whismanoid 15:37c83ec50ea0 4294 }
whismanoid 15:37c83ec50ea0 4295 break;
whismanoid 15:37c83ec50ea0 4296 case '?':
whismanoid 15:37c83ec50ea0 4297 {
whismanoid 15:37c83ec50ea0 4298 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 4299 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4300 pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4301 #else
whismanoid 15:37c83ec50ea0 4302 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4303 digitalInOutPin.input();
whismanoid 15:37c83ec50ea0 4304 #endif
whismanoid 15:37c83ec50ea0 4305 serial.printf(" digitalInOutPin %d Input ", pinIndex);
whismanoid 15:37c83ec50ea0 4306 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4307 int value = digitalRead(pinIndex);
whismanoid 15:37c83ec50ea0 4308 #else
whismanoid 15:37c83ec50ea0 4309 int value = digitalInOutPin.read();
whismanoid 15:37c83ec50ea0 4310 #endif
whismanoid 15:37c83ec50ea0 4311 cmdLine.serial().printf("%d ", value);
whismanoid 15:37c83ec50ea0 4312 }
whismanoid 15:37c83ec50ea0 4313 break;
whismanoid 15:37c83ec50ea0 4314 #endif
whismanoid 15:37c83ec50ea0 4315 //
whismanoid 15:37c83ec50ea0 4316 #if HAS_analogIns
whismanoid 15:37c83ec50ea0 4317 case 'A': case 'a':
whismanoid 15:37c83ec50ea0 4318 {
whismanoid 15:37c83ec50ea0 4319 // %A %Apin -- analog input
whismanoid 37:3f369235e5bc 4320 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4321 // %A avg= -- set Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 4322 if (cmdLine.parse_int_dec("avg", Platform_AIN_Average_N))
whismanoid 37:3f369235e5bc 4323 {
whismanoid 37:3f369235e5bc 4324 // Platform_AIN_Average_N was updated
whismanoid 37:3f369235e5bc 4325 }
whismanoid 37:3f369235e5bc 4326 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4327 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4328 // %A cal? view/export raw calibration values for all channels
whismanoid 34:a1993a1ee904 4329 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4330 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4331 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4332 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4333 {
whismanoid 34:a1993a1ee904 4334 char valueBuf[16];
whismanoid 34:a1993a1ee904 4335 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 4336 if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 4337 {
whismanoid 34:a1993a1ee904 4338 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4339 {
whismanoid 34:a1993a1ee904 4340 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 4341 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4342 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 4343 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4344 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 4345 );
whismanoid 34:a1993a1ee904 4346 }
whismanoid 34:a1993a1ee904 4347 //
whismanoid 34:a1993a1ee904 4348 // print extended help for %A
whismanoid 34:a1993a1ee904 4349 // %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 4350 //~ cmdLine.serial().printf("\r\n %%A cal0n=0.02 cal0v=0.123 cal0n=0.938 cal0v=1.132 -- update calibration");
whismanoid 34:a1993a1ee904 4351 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 4352 cmdLine.serial().printf(" %%A cal0test=0.5 -- calculate voltage at 50%% of full scale");
whismanoid 34:a1993a1ee904 4353 cmdLine.serial().printf("\r\n %%A v0cal=1.000V -- calibrate channel against a known input voltage");
whismanoid 34:a1993a1ee904 4354 // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 4355 // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 4356 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 4357 cmdLine.serial().printf("\r\n %%A calreset -- reset all calibration data");
whismanoid 37:3f369235e5bc 4358 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4359 // %A avg=%d -- help string display Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 4360 cmdLine.serial().printf("\r\n %%A avg=%d -- average", Platform_AIN_Average_N);
whismanoid 37:3f369235e5bc 4361 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4362 cmdLine.serial().printf("\r\n\r\n");
whismanoid 34:a1993a1ee904 4363 //
whismanoid 34:a1993a1ee904 4364 } // end if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 4365 }
whismanoid 34:a1993a1ee904 4366 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4367 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4368 {
whismanoid 34:a1993a1ee904 4369 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 4370 char valueBuf[16];
whismanoid 34:a1993a1ee904 4371 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 4372 if (cmdLine.parse_and_remove_key("calreset", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 4373 {
whismanoid 34:a1993a1ee904 4374 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 4375 calibration_05_normValue_0_1[0] = 0.25; calibration_05_V[0] = 0.3;
whismanoid 34:a1993a1ee904 4376 calibration_05_normValue_0_1[1] = 0.25; calibration_05_V[1] = 0.3;
whismanoid 34:a1993a1ee904 4377 calibration_05_normValue_0_1[2] = 0.25; calibration_05_V[2] = 0.3;
whismanoid 34:a1993a1ee904 4378 calibration_05_normValue_0_1[3] = 0.25; calibration_05_V[3] = 0.3;
whismanoid 34:a1993a1ee904 4379 calibration_05_normValue_0_1[4] = 0.25; calibration_05_V[4] = 1.5;
whismanoid 34:a1993a1ee904 4380 calibration_05_normValue_0_1[5] = 0.25; calibration_05_V[5] = 1.5;
whismanoid 34:a1993a1ee904 4381 //
whismanoid 34:a1993a1ee904 4382 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 4383 calibration_95_normValue_0_1[0] = 0.75; calibration_95_V[0] = 0.9;
whismanoid 34:a1993a1ee904 4384 calibration_95_normValue_0_1[1] = 0.75; calibration_95_V[1] = 0.9;
whismanoid 34:a1993a1ee904 4385 calibration_95_normValue_0_1[2] = 0.75; calibration_95_V[2] = 0.9;
whismanoid 34:a1993a1ee904 4386 calibration_95_normValue_0_1[3] = 0.75; calibration_95_V[3] = 0.9;
whismanoid 34:a1993a1ee904 4387 calibration_95_normValue_0_1[4] = 0.75; calibration_95_V[4] = 4.5;
whismanoid 34:a1993a1ee904 4388 calibration_95_normValue_0_1[5] = 0.75; calibration_95_V[5] = 4.5;
whismanoid 34:a1993a1ee904 4389 //
whismanoid 34:a1993a1ee904 4390 }
whismanoid 34:a1993a1ee904 4391 }
whismanoid 34:a1993a1ee904 4392 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4393 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4394 // %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 4395 // %A cal4n=0.135874882 cal4v=0.800000012V cal4n=0.286168128 cal4v=1.700000048V
whismanoid 34:a1993a1ee904 4396 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4397 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4398 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4399 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4400 {
whismanoid 34:a1993a1ee904 4401 double normValue_0_1, V;
whismanoid 34:a1993a1ee904 4402 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4403 {
whismanoid 34:a1993a1ee904 4404 static char key_can0n[8] = "cal0n__";
whismanoid 34:a1993a1ee904 4405 sprintf(key_can0n, "cal%1dn", ch);
whismanoid 34:a1993a1ee904 4406 static char key_cal0v[8] = "cal0v__";
whismanoid 34:a1993a1ee904 4407 sprintf(key_cal0v, "cal%1dv", ch);
whismanoid 35:c9549b5c01de 4408 // first point could be the 5% point or the 95% point
whismanoid 35:c9549b5c01de 4409 double norm_threshold = (calibration_05_normValue_0_1[ch] + calibration_95_normValue_0_1[ch]) / 2.0;
whismanoid 35:c9549b5c01de 4410 bool updated_05 = false;
whismanoid 35:c9549b5c01de 4411 //~ bool updated_95 = false;
whismanoid 35:c9549b5c01de 4412 if (cmdLine.parse_double(key_can0n, normValue_0_1)) {
whismanoid 34:a1993a1ee904 4413 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 34:a1993a1ee904 4414 {
whismanoid 35:c9549b5c01de 4415 if (normValue_0_1 < norm_threshold) {
whismanoid 35:c9549b5c01de 4416 // store first calibration point in the 5% slot
whismanoid 35:c9549b5c01de 4417 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 4418 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 4419 updated_05 = true;
whismanoid 34:a1993a1ee904 4420 }
whismanoid 34:a1993a1ee904 4421 else {
whismanoid 35:c9549b5c01de 4422 // store first calibration point in the 95% slot
whismanoid 35:c9549b5c01de 4423 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 4424 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 4425 //~ updated_95 = true;
whismanoid 34:a1993a1ee904 4426 }
whismanoid 34:a1993a1ee904 4427 }
whismanoid 35:c9549b5c01de 4428 }
whismanoid 35:c9549b5c01de 4429 // handle the optional second calibration point
whismanoid 35:c9549b5c01de 4430 if (cmdLine.parse_double(key_can0n, normValue_0_1))
whismanoid 35:c9549b5c01de 4431 {
whismanoid 35:c9549b5c01de 4432 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 35:c9549b5c01de 4433 {
whismanoid 35:c9549b5c01de 4434 if (updated_05) {
whismanoid 35:c9549b5c01de 4435 // we already stored the first point here
whismanoid 35:c9549b5c01de 4436 // calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4437 // calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 4438 // store the second point in the other slot
whismanoid 35:c9549b5c01de 4439 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4440 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 4441 }
whismanoid 35:c9549b5c01de 4442 else {
whismanoid 35:c9549b5c01de 4443 // we already stored the first point here
whismanoid 35:c9549b5c01de 4444 // calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4445 // calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 4446 // store the second point in the other slot
whismanoid 35:c9549b5c01de 4447 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4448 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 4449 }
whismanoid 35:c9549b5c01de 4450 }
whismanoid 35:c9549b5c01de 4451 }
whismanoid 38:fda80a0020d1 4452 // make sure calibration_05_normValue_0_1[ch] < calibration_95_normValue_0_1[ch]
whismanoid 38:fda80a0020d1 4453 if (calibration_05_normValue_0_1[ch] > calibration_95_normValue_0_1[ch])
whismanoid 38:fda80a0020d1 4454 {
whismanoid 38:fda80a0020d1 4455 // swap to make sure calibration_05_normValue_0_1[ch] < calibration_95_normValue_0_1[ch]
whismanoid 38:fda80a0020d1 4456 double n05 = calibration_95_normValue_0_1[ch];
whismanoid 38:fda80a0020d1 4457 double V05 = calibration_95_V[ch];
whismanoid 38:fda80a0020d1 4458 double n95 = calibration_05_normValue_0_1[ch];
whismanoid 38:fda80a0020d1 4459 double V95 = calibration_05_V[ch];
whismanoid 38:fda80a0020d1 4460 calibration_05_normValue_0_1[ch] = n05;
whismanoid 38:fda80a0020d1 4461 calibration_05_V[ch] = V05;
whismanoid 38:fda80a0020d1 4462 calibration_95_normValue_0_1[ch] = n95;
whismanoid 38:fda80a0020d1 4463 calibration_95_V[ch] = V95;
whismanoid 38:fda80a0020d1 4464 }
whismanoid 34:a1993a1ee904 4465 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4466 }
whismanoid 34:a1993a1ee904 4467 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4468 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4469 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 4470 // double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 4471 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4472 {
whismanoid 34:a1993a1ee904 4473 static char key_cal0test[12] = "cal0test__";
whismanoid 34:a1993a1ee904 4474 sprintf(key_cal0test, "cal%1dtest", ch);
whismanoid 34:a1993a1ee904 4475 double normValue_0_1, Vtest;
whismanoid 34:a1993a1ee904 4476 if (cmdLine.parse_double(key_cal0test, Vtest))
whismanoid 34:a1993a1ee904 4477 {
whismanoid 34:a1993a1ee904 4478 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 4479 normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 4480 //
whismanoid 34:a1993a1ee904 4481 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 4482 ch,
whismanoid 34:a1993a1ee904 4483 normValue_0_1,
whismanoid 34:a1993a1ee904 4484 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 4485 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4486 );
whismanoid 34:a1993a1ee904 4487 //
whismanoid 34:a1993a1ee904 4488 // sweep CalibratedNormValue argument
whismanoid 34:a1993a1ee904 4489 double normValue_0_1_start = -0.05;
whismanoid 34:a1993a1ee904 4490 double normValue_0_1_step = 0.05;
whismanoid 34:a1993a1ee904 4491 double normValue_0_1_end = 1.07;
whismanoid 34:a1993a1ee904 4492 for (normValue_0_1 = normValue_0_1_start;
whismanoid 34:a1993a1ee904 4493 normValue_0_1 <= normValue_0_1_end;
whismanoid 34:a1993a1ee904 4494 normValue_0_1 = normValue_0_1 + normValue_0_1_step)
whismanoid 34:a1993a1ee904 4495 {
whismanoid 34:a1993a1ee904 4496 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 4497 ch,
whismanoid 34:a1993a1ee904 4498 normValue_0_1,
whismanoid 34:a1993a1ee904 4499 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 4500 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4501 );
whismanoid 34:a1993a1ee904 4502 }
whismanoid 34:a1993a1ee904 4503 }
whismanoid 34:a1993a1ee904 4504 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4505 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4506 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4507 // %A v0cal=1.000V -- calibrate channel against a known input voltage
whismanoid 34:a1993a1ee904 4508 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4509 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4510 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4511 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4512 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4513 {
whismanoid 34:a1993a1ee904 4514 static char key_v0cal[10] = "v0cal__";
whismanoid 34:a1993a1ee904 4515 sprintf(key_v0cal, "v%1dcal", ch);
whismanoid 34:a1993a1ee904 4516 double Vtest;
whismanoid 34:a1993a1ee904 4517 if (cmdLine.parse_double(key_v0cal, Vtest))
whismanoid 34:a1993a1ee904 4518 {
whismanoid 34:a1993a1ee904 4519 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 4520 double Vtest_normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 4521 //
whismanoid 34:a1993a1ee904 4522 // %A v0cal=1.000 calibrate one channel by measuring against a known input voltage
whismanoid 34:a1993a1ee904 4523 //
whismanoid 34:a1993a1ee904 4524 cmdLine.serial().printf("\r\n Measuring against input voltage of %1.6fV...", Vtest);
whismanoid 37:3f369235e5bc 4525 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4526 const int numberOfMeasurements = 16 * Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 4527 #else // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4528 const int numberOfMeasurements = 16;
whismanoid 37:3f369235e5bc 4529 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4530 double Sx_measure_normValue_0_1 = 0; // sum of values
whismanoid 34:a1993a1ee904 4531 double Sxx_measure_normValue_0_1 = 0; // sum of the squares of the values
whismanoid 34:a1993a1ee904 4532 for (int count = 0; count < numberOfMeasurements; count++)
whismanoid 34:a1993a1ee904 4533 {
whismanoid 34:a1993a1ee904 4534 double measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4535 switch(ch)
whismanoid 34:a1993a1ee904 4536 {
whismanoid 34:a1993a1ee904 4537 case 0: measure_normValue_0_1 = analogIn0.read(); break;
whismanoid 34:a1993a1ee904 4538 case 1: measure_normValue_0_1 = analogIn1.read(); break;
whismanoid 34:a1993a1ee904 4539 case 2: measure_normValue_0_1 = analogIn2.read(); break;
whismanoid 34:a1993a1ee904 4540 case 3: measure_normValue_0_1 = analogIn3.read(); break;
whismanoid 34:a1993a1ee904 4541 case 4: measure_normValue_0_1 = analogIn4.read(); break;
whismanoid 34:a1993a1ee904 4542 case 5: measure_normValue_0_1 = analogIn5.read(); break;
whismanoid 34:a1993a1ee904 4543 }
whismanoid 34:a1993a1ee904 4544 Sx_measure_normValue_0_1 = Sx_measure_normValue_0_1 + measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4545 Sxx_measure_normValue_0_1 = Sxx_measure_normValue_0_1 + (measure_normValue_0_1 * measure_normValue_0_1);
whismanoid 38:fda80a0020d1 4546 if ((count < 3) || (count >= numberOfMeasurements - 3)) {
whismanoid 38:fda80a0020d1 4547 cmdLine.serial().printf("\r\n raw: %7.6f%% = %1.6fV",
whismanoid 38:fda80a0020d1 4548 measure_normValue_0_1 * 100.0,
whismanoid 38:fda80a0020d1 4549 (measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 38:fda80a0020d1 4550 );
whismanoid 38:fda80a0020d1 4551 }
whismanoid 34:a1993a1ee904 4552 }
whismanoid 34:a1993a1ee904 4553 cmdLine.serial().printf("\r\n numberOfMeasurements = %d", numberOfMeasurements);
whismanoid 34:a1993a1ee904 4554 cmdLine.serial().printf("\r\n Sx_measure_normValue_0_1 = %1.6f", Sx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4555 cmdLine.serial().printf("\r\n Sxx_measure_normValue_0_1 = %1.6f", Sxx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4556 //
whismanoid 34:a1993a1ee904 4557 // calculate mean_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 4558 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 4559 double mean_measure_normValue_0_1 = Sx_measure_normValue_0_1 / numberOfMeasurements;
whismanoid 34:a1993a1ee904 4560 cmdLine.serial().printf("\r\n mean = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4561 mean_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4562 (mean_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4563 );
whismanoid 34:a1993a1ee904 4564 //
whismanoid 34:a1993a1ee904 4565 // TODO: calculate sample variance_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 4566 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 4567 // variance_measure_normValue_0_1 = (Sxx - ( Sx * Sx / nWords) ) / (nWords - 1);
whismanoid 34:a1993a1ee904 4568 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 4569 cmdLine.serial().printf("\r\n variance = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4570 variance_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4571 (variance_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4572 );
whismanoid 34:a1993a1ee904 4573 //
whismanoid 34:a1993a1ee904 4574 // calculate sample stddev_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 4575 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 4576 double stddev_measure_normValue_0_1 = sqrt(variance_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4577 cmdLine.serial().printf("\r\n stddev = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4578 stddev_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4579 (stddev_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4580 );
whismanoid 34:a1993a1ee904 4581 //
whismanoid 34:a1993a1ee904 4582 // Validate the measurements:
whismanoid 34:a1993a1ee904 4583 // is the mean near the expected value?
whismanoid 34:a1993a1ee904 4584 // is the standard deviation not too high?
whismanoid 34:a1993a1ee904 4585 bool isCalibrationValid = true;
whismanoid 34:a1993a1ee904 4586 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) > 0.1) {
whismanoid 34:a1993a1ee904 4587 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 4588 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 4589 }
whismanoid 34:a1993a1ee904 4590 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) < -0.1) {
whismanoid 34:a1993a1ee904 4591 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 4592 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 4593 }
whismanoid 34:a1993a1ee904 4594 if ((stddev_measure_normValue_0_1) > 10) {
whismanoid 34:a1993a1ee904 4595 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 4596 cmdLine.serial().printf(" stddev too high.\r\n");
whismanoid 34:a1993a1ee904 4597 }
whismanoid 34:a1993a1ee904 4598 if (isCalibrationValid)
whismanoid 34:a1993a1ee904 4599 {
whismanoid 34:a1993a1ee904 4600 // update calibration point (mean_measure_normValue_0_1, Vtest)
whismanoid 34:a1993a1ee904 4601 if (Vtest_normValue_0_1 < 0.5) {
whismanoid 34:a1993a1ee904 4602 calibration_05_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4603 calibration_05_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 4604 } else {
whismanoid 34:a1993a1ee904 4605 calibration_95_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4606 calibration_95_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 4607 }
whismanoid 34:a1993a1ee904 4608 //
whismanoid 34:a1993a1ee904 4609 // print updated calibration values
whismanoid 34:a1993a1ee904 4610 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 4611 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 4612 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4613 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 4614 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4615 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 4616 );
whismanoid 34:a1993a1ee904 4617 // print corrected value of mean of measurements (should be close to Vtest)
whismanoid 34:a1993a1ee904 4618 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV vs %1.6fV\r\n",
whismanoid 34:a1993a1ee904 4619 ch,
whismanoid 34:a1993a1ee904 4620 mean_measure_normValue_0_1,
whismanoid 34:a1993a1ee904 4621 CalibratedNormValue(ch, mean_measure_normValue_0_1),
whismanoid 34:a1993a1ee904 4622 (CalibratedNormValue(ch, mean_measure_normValue_0_1) * adc_full_scale_voltage[ch]),
whismanoid 34:a1993a1ee904 4623 Vtest
whismanoid 34:a1993a1ee904 4624 );
whismanoid 34:a1993a1ee904 4625 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 4626 else {
whismanoid 34:a1993a1ee904 4627 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 4628 cmdLine.serial().printf(" Measurement Error: Calibration will not be updated.\r\n");
whismanoid 34:a1993a1ee904 4629 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 4630 } // end if key_v0cal
whismanoid 34:a1993a1ee904 4631 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4632 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4633 #if HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 4634 // // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 37:3f369235e5bc 4635 // {
whismanoid 37:3f369235e5bc 4636 // char valueBuf[16];
whismanoid 37:3f369235e5bc 4637 // // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 37:3f369235e5bc 4638 // if (cmdLine.parse_and_remove_key("__TBD_saveCal__", valueBuf, sizeof(valueBuf)))
whismanoid 37:3f369235e5bc 4639 // {
whismanoid 37:3f369235e5bc 4640 // // handle %A __TBD_saveCal__ -- command
whismanoid 37:3f369235e5bc 4641 // }
whismanoid 37:3f369235e5bc 4642 // }
whismanoid 34:a1993a1ee904 4643 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4644 #if HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 4645 // // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 37:3f369235e5bc 4646 // {
whismanoid 37:3f369235e5bc 4647 // char valueBuf[16];
whismanoid 37:3f369235e5bc 4648 // // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 37:3f369235e5bc 4649 // if (cmdLine.parse_and_remove_key("__TBD_loadCal__", valueBuf, sizeof(valueBuf)))
whismanoid 37:3f369235e5bc 4650 // {
whismanoid 37:3f369235e5bc 4651 // // handle %A __TBD_loadCal__ -- command
whismanoid 37:3f369235e5bc 4652 // }
whismanoid 37:3f369235e5bc 4653 // }
whismanoid 34:a1993a1ee904 4654 #endif // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 4655 // %A -- report analog input voltages
whismanoid 37:3f369235e5bc 4656 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4657 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 4658 #endif // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 4659 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 4660 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 15:37c83ec50ea0 4661 for (int pinIndex = 0; pinIndex < 2; pinIndex++)
whismanoid 15:37c83ec50ea0 4662 {
whismanoid 15:37c83ec50ea0 4663 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 4664 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 4665 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 4666 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4667 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 4668 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 4669 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 4670 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 4671 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 4672 }
whismanoid 37:3f369235e5bc 4673 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 4674 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 4675 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 4676 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4677 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4678 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4679 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 4680 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4681 //
whismanoid 15:37c83ec50ea0 4682 int pinIndexH = pinIndex + 4;
whismanoid 15:37c83ec50ea0 4683 int cPinIndexH = '0' + pinIndexH;
whismanoid 15:37c83ec50ea0 4684 AnalogIn& analogInPinH = find_analogInPin(cPinIndexH);
whismanoid 15:37c83ec50ea0 4685 float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH];
whismanoid 37:3f369235e5bc 4686 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4687 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 4688 // float normValueH_0_1 = analogInPinH.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 4689 float normValueH_0_1 = 0;
whismanoid 37:3f369235e5bc 4690 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 4691 normValueH_0_1 = normValueH_0_1 + analogInPinH.read();
whismanoid 37:3f369235e5bc 4692 }
whismanoid 37:3f369235e5bc 4693 normValueH_0_1 = normValueH_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 4694 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 4695 float normValueH_0_1 = analogInPinH.read();
whismanoid 37:3f369235e5bc 4696 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4697 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4698 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4699 normValueH_0_1 = CalibratedNormValue(pinIndex, normValueH_0_1);
whismanoid 34:a1993a1ee904 4700 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4701 //
whismanoid 37:3f369235e5bc 4702 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV high range A%c = %7.3f%% = %1.3fV \r\n",
whismanoid 15:37c83ec50ea0 4703 cPinIndex,
whismanoid 15:37c83ec50ea0 4704 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4705 normValue_0_1 * adc_full_scale_voltage,
whismanoid 15:37c83ec50ea0 4706 cPinIndexH,
whismanoid 15:37c83ec50ea0 4707 normValueH_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4708 normValueH_0_1 * adc_full_scale_voltageH
whismanoid 15:37c83ec50ea0 4709 );
whismanoid 15:37c83ec50ea0 4710 }
whismanoid 15:37c83ec50ea0 4711 for (int pinIndex = 2; pinIndex < 4; pinIndex++)
whismanoid 15:37c83ec50ea0 4712 {
whismanoid 15:37c83ec50ea0 4713 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 4714 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 4715 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 4716 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4717 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 4718 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 4719 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 4720 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 4721 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 4722 }
whismanoid 37:3f369235e5bc 4723 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 4724 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 4725 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 4726 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4727 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4728 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4729 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 4730 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4731 //
whismanoid 37:3f369235e5bc 4732 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 4733 cPinIndex,
whismanoid 15:37c83ec50ea0 4734 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4735 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 4736 );
whismanoid 15:37c83ec50ea0 4737 }
whismanoid 15:37c83ec50ea0 4738 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 4739 // Platform board uses simple analog inputs
whismanoid 15:37c83ec50ea0 4740 // assume standard Arduino analog inputs A0-A5
whismanoid 15:37c83ec50ea0 4741 for (int pinIndex = 0; pinIndex < 6; pinIndex++)
whismanoid 15:37c83ec50ea0 4742 {
whismanoid 15:37c83ec50ea0 4743 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 4744 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 4745 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 4746 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4747 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 4748 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 4749 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 4750 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 4751 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 4752 }
whismanoid 37:3f369235e5bc 4753 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 4754 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 4755 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 4756 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4757 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4758 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4759 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 4760 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4761 //
whismanoid 37:3f369235e5bc 4762 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 4763 cPinIndex,
whismanoid 15:37c83ec50ea0 4764 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4765 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 4766 );
whismanoid 15:37c83ec50ea0 4767 }
whismanoid 15:37c83ec50ea0 4768 #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 4769 }
whismanoid 15:37c83ec50ea0 4770 break;
whismanoid 15:37c83ec50ea0 4771 #endif
whismanoid 15:37c83ec50ea0 4772 //
whismanoid 15:37c83ec50ea0 4773 #if HAS_SPI2_MAX541
whismanoid 15:37c83ec50ea0 4774 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 4775 {
whismanoid 15:37c83ec50ea0 4776 // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV)
whismanoid 15:37c83ec50ea0 4777 // MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 15:37c83ec50ea0 4778 float voltageV = max541.Get_Voltage();
whismanoid 15:37c83ec50ea0 4779 // if (cmdLine[2] == '+') {
whismanoid 15:37c83ec50ea0 4780 // // %D+
whismanoid 15:37c83ec50ea0 4781 // voltageV = voltageV * 1.25f;
whismanoid 15:37c83ec50ea0 4782 // if (voltageV >= max541.VRef) voltageV = max541.VRef;
whismanoid 15:37c83ec50ea0 4783 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4784 // }
whismanoid 15:37c83ec50ea0 4785 // else if (cmdLine[2] == '-') {
whismanoid 15:37c83ec50ea0 4786 // // %D-
whismanoid 15:37c83ec50ea0 4787 // voltageV = voltageV * 0.75f;
whismanoid 15:37c83ec50ea0 4788 // if (voltageV < 0.1f) voltageV = 0.1f;
whismanoid 15:37c83ec50ea0 4789 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4790 // }
whismanoid 15:37c83ec50ea0 4791 if (cmdLine.parse_float("V", voltageV))
whismanoid 15:37c83ec50ea0 4792 {
whismanoid 15:37c83ec50ea0 4793 // %D V=1.234 -- set voltage
whismanoid 15:37c83ec50ea0 4794 max541.Set_Voltage(voltageV);
whismanoid 15:37c83ec50ea0 4795 }
whismanoid 15:37c83ec50ea0 4796 else if (cmdLine.parse_float("TEST", voltageV))
whismanoid 15:37c83ec50ea0 4797 {
whismanoid 15:37c83ec50ea0 4798 // %D TEST=1.234 -- set voltage and compare with AIN0
whismanoid 15:37c83ec50ea0 4799 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4800 }
whismanoid 15:37c83ec50ea0 4801 else if (cmdLine.parse_float("CAL", voltageV))
whismanoid 15:37c83ec50ea0 4802 {
whismanoid 15:37c83ec50ea0 4803 // %D CAL=1.234 -- calibrate VRef and compare with AIN0
whismanoid 15:37c83ec50ea0 4804
whismanoid 15:37c83ec50ea0 4805 max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
whismanoid 15:37c83ec50ea0 4806 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 4807 const int average_count = 100;
whismanoid 15:37c83ec50ea0 4808 const double average_K = 0.25;
whismanoid 15:37c83ec50ea0 4809 for (int count = 0; count < average_count; count++) {
whismanoid 15:37c83ec50ea0 4810 double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 4811 max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
whismanoid 15:37c83ec50ea0 4812 }
whismanoid 15:37c83ec50ea0 4813 max541.VRef = 2.0 * max541_midscale_V;
whismanoid 15:37c83ec50ea0 4814 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4815 "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
whismanoid 15:37c83ec50ea0 4816 max541_midscale_V, max541.VRef);
whismanoid 15:37c83ec50ea0 4817 // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
whismanoid 15:37c83ec50ea0 4818 voltageV = 1.0f;
whismanoid 15:37c83ec50ea0 4819 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4820 }
whismanoid 15:37c83ec50ea0 4821 else {
whismanoid 15:37c83ec50ea0 4822 // %D -- print MAX541 DAC status
whismanoid 15:37c83ec50ea0 4823 cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n",
whismanoid 15:37c83ec50ea0 4824 max541.Get_Code(), max541.Get_Voltage(), max541.VRef);
whismanoid 15:37c83ec50ea0 4825 }
whismanoid 15:37c83ec50ea0 4826 }
whismanoid 15:37c83ec50ea0 4827 break;
whismanoid 15:37c83ec50ea0 4828 #endif
whismanoid 15:37c83ec50ea0 4829
whismanoid 15:37c83ec50ea0 4830 //
whismanoid 15:37c83ec50ea0 4831 #if HAS_I2C // SUPPORT_I2C
whismanoid 15:37c83ec50ea0 4832 case 'I': case 'i':
whismanoid 15:37c83ec50ea0 4833 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 4834 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 4835 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 4836 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 4837 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 4838 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 4839 // get next character
whismanoid 15:37c83ec50ea0 4840 // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7
whismanoid 15:37c83ec50ea0 4841 cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7);
whismanoid 15:37c83ec50ea0 4842 // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count
whismanoid 15:37c83ec50ea0 4843 g_I2C_read_count = 0; // read count must be reset every command
whismanoid 15:37c83ec50ea0 4844 cmdLine.parse_byte_dec("RD", g_I2C_read_count);
whismanoid 15:37c83ec50ea0 4845 // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress
whismanoid 15:37c83ec50ea0 4846 cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress);
whismanoid 15:37c83ec50ea0 4847 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 4848 {
whismanoid 15:37c83ec50ea0 4849 case 'P': case 'p':
whismanoid 15:37c83ec50ea0 4850 {
whismanoid 15:37c83ec50ea0 4851 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 4852 HuntAttachedI2CDevices(cmdLine, 0x03, 0x77);
whismanoid 15:37c83ec50ea0 4853 }
whismanoid 15:37c83ec50ea0 4854 break;
whismanoid 15:37c83ec50ea0 4855 case 'C': case 'c':
whismanoid 15:37c83ec50ea0 4856 {
whismanoid 15:37c83ec50ea0 4857 bool isUpdatedI2CConfig = false;
whismanoid 15:37c83ec50ea0 4858 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 4859 // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz
whismanoid 15:37c83ec50ea0 4860 if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz))
whismanoid 15:37c83ec50ea0 4861 {
whismanoid 15:37c83ec50ea0 4862 isUpdatedI2CConfig = true;
whismanoid 15:37c83ec50ea0 4863 // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 4864 if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 4865 {
whismanoid 15:37c83ec50ea0 4866 g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 4867 }
whismanoid 15:37c83ec50ea0 4868 if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 4869 {
whismanoid 15:37c83ec50ea0 4870 g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 4871 }
whismanoid 15:37c83ec50ea0 4872 }
whismanoid 15:37c83ec50ea0 4873 if (isUpdatedI2CConfig)
whismanoid 15:37c83ec50ea0 4874 {
whismanoid 15:37c83ec50ea0 4875 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4876 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4877 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4878 i2cMaster.start();
whismanoid 15:37c83ec50ea0 4879 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 4880 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4881 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4882 "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 15:37c83ec50ea0 4883 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 15:37c83ec50ea0 4884 (g_I2C_SCL_Hz / 1000.));
whismanoid 15:37c83ec50ea0 4885 i2cMaster.start();
whismanoid 15:37c83ec50ea0 4886 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 4887 }
whismanoid 15:37c83ec50ea0 4888 }
whismanoid 15:37c83ec50ea0 4889 break;
whismanoid 15:37c83ec50ea0 4890 case 'W': case 'w':
whismanoid 15:37c83ec50ea0 4891 {
whismanoid 15:37c83ec50ea0 4892 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4893 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4894 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4895 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 4896 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4897 #define MAX_I2C_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 4898 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 4899 static char mosiData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4900 static char misoData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4901 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 4902 MAX_I2C_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 4903 {
whismanoid 15:37c83ec50ea0 4904 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 4905 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4906 "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->",
whismanoid 15:37c83ec50ea0 4907 g_I2C_deviceAddress7,
whismanoid 15:37c83ec50ea0 4908 (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count);
whismanoid 15:37c83ec50ea0 4909 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 4910 {
whismanoid 15:37c83ec50ea0 4911 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 4912 }
whismanoid 15:37c83ec50ea0 4913 //
whismanoid 15:37c83ec50ea0 4914 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 4915 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 4916 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4917 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 4918 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 4919 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 4920 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 4921 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4922 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4923 // /* 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 4924 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 4925 const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4926 unsigned int misoLength = 0;
whismanoid 15:37c83ec50ea0 4927 bool repeated = (g_I2C_read_count > 0);
whismanoid 15:37c83ec50ea0 4928 //
whismanoid 15:37c83ec50ea0 4929 int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated);
whismanoid 15:37c83ec50ea0 4930 switch (writeStatus)
whismanoid 15:37c83ec50ea0 4931 {
whismanoid 15:37c83ec50ea0 4932 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 4933 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 4934 default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 4935 writeStatus);
whismanoid 15:37c83ec50ea0 4936 }
whismanoid 15:37c83ec50ea0 4937 if (repeated)
whismanoid 15:37c83ec50ea0 4938 {
whismanoid 15:37c83ec50ea0 4939 int readStatus =
whismanoid 15:37c83ec50ea0 4940 i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false);
whismanoid 15:37c83ec50ea0 4941 switch (readStatus)
whismanoid 15:37c83ec50ea0 4942 {
whismanoid 15:37c83ec50ea0 4943 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 4944 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 4945 default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 4946 readStatus);
whismanoid 15:37c83ec50ea0 4947 }
whismanoid 15:37c83ec50ea0 4948 }
whismanoid 15:37c83ec50ea0 4949 //
whismanoid 15:37c83ec50ea0 4950 if (misoLength > 0)
whismanoid 15:37c83ec50ea0 4951 {
whismanoid 15:37c83ec50ea0 4952 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 4953 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 4954 for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count;
whismanoid 15:37c83ec50ea0 4955 byteIndex++)
whismanoid 15:37c83ec50ea0 4956 {
whismanoid 15:37c83ec50ea0 4957 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 4958 }
whismanoid 15:37c83ec50ea0 4959 }
whismanoid 15:37c83ec50ea0 4960 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 4961 }
whismanoid 15:37c83ec50ea0 4962 }
whismanoid 15:37c83ec50ea0 4963 break;
whismanoid 15:37c83ec50ea0 4964 case 'R': case 'r':
whismanoid 15:37c83ec50ea0 4965 {
whismanoid 15:37c83ec50ea0 4966 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4967 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4968 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4969 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 4970 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 4971 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 4972 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4973 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 4974 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 4975 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 4976 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 4977 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4978 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4979 // /* 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 4980 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 4981 }
whismanoid 15:37c83ec50ea0 4982 break;
whismanoid 15:37c83ec50ea0 4983 case '^':
whismanoid 15:37c83ec50ea0 4984 {
whismanoid 15:37c83ec50ea0 4985 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4986 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4987 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4988 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 4989 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 4990 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 4991 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4992 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 4993 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 4994 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 4995 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 4996 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4997 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4998 // /* 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 4999 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 5000 }
whismanoid 15:37c83ec50ea0 5001 break;
whismanoid 15:37c83ec50ea0 5002 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 5003 break;
whismanoid 15:37c83ec50ea0 5004 #endif
whismanoid 15:37c83ec50ea0 5005 //
whismanoid 15:37c83ec50ea0 5006 #if HAS_SPI // SUPPORT_SPI
whismanoid 15:37c83ec50ea0 5007 case 'S': case 's':
whismanoid 15:37c83ec50ea0 5008 {
whismanoid 15:37c83ec50ea0 5009 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 5010 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 5011 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 5012 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 5013 //
whismanoid 15:37c83ec50ea0 5014 // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d
whismanoid 15:37c83ec50ea0 5015 bool isUpdatedSPIConfig = false;
whismanoid 15:37c83ec50ea0 5016 // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2
whismanoid 15:37c83ec50ea0 5017 // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1
whismanoid 15:37c83ec50ea0 5018 if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2))
whismanoid 15:37c83ec50ea0 5019 {
whismanoid 15:37c83ec50ea0 5020 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5021 }
whismanoid 15:37c83ec50ea0 5022 if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1))
whismanoid 15:37c83ec50ea0 5023 {
whismanoid 15:37c83ec50ea0 5024 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5025 }
whismanoid 15:37c83ec50ea0 5026 if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1))
whismanoid 15:37c83ec50ea0 5027 {
whismanoid 15:37c83ec50ea0 5028 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5029 }
whismanoid 15:37c83ec50ea0 5030 // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz
whismanoid 15:37c83ec50ea0 5031 if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz))
whismanoid 15:37c83ec50ea0 5032 {
whismanoid 15:37c83ec50ea0 5033 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5034 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 5035 if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 5036 {
whismanoid 15:37c83ec50ea0 5037 g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 5038 }
whismanoid 15:37c83ec50ea0 5039 if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 5040 {
whismanoid 15:37c83ec50ea0 5041 g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 5042 }
whismanoid 15:37c83ec50ea0 5043 }
whismanoid 15:37c83ec50ea0 5044 // Update SPI configuration
whismanoid 15:37c83ec50ea0 5045 if (isUpdatedSPIConfig)
whismanoid 15:37c83ec50ea0 5046 {
whismanoid 15:37c83ec50ea0 5047 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 5048 spi_cs = g_SPI_cs_state;
whismanoid 15:37c83ec50ea0 5049 spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0
whismanoid 15:37c83ec50ea0 5050 #if APPLICATION_MAX5715
whismanoid 15:37c83ec50ea0 5051 g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5052 #elif APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 5053 g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5054 #elif APPLICATION_MAX5171
whismanoid 15:37c83ec50ea0 5055 g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5056 #elif APPLICATION_MAX11410
whismanoid 15:37c83ec50ea0 5057 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5058 #elif APPLICATION_MAX12345
whismanoid 15:37c83ec50ea0 5059 g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5060 #else
whismanoid 15:37c83ec50ea0 5061 spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 15:37c83ec50ea0 5062 #endif
whismanoid 15:37c83ec50ea0 5063 //
whismanoid 15:37c83ec50ea0 5064 double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 5065 int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate
whismanoid 15:37c83ec50ea0 5066 double actual_SCLK_Hz = SystemCoreClock / actual_divisor;
whismanoid 15:37c83ec50ea0 5067 //
whismanoid 15:37c83ec50ea0 5068 // 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 5069 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5070 "\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 5071 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 15:37c83ec50ea0 5072 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0),
whismanoid 15:37c83ec50ea0 5073 g_SPI_cs_state,
whismanoid 15:37c83ec50ea0 5074 g_SPI_SCLK_Hz,
whismanoid 15:37c83ec50ea0 5075 (g_SPI_SCLK_Hz / 1000000.),
whismanoid 15:37c83ec50ea0 5076 ((double)(SystemCoreClock / 1000000.)),
whismanoid 15:37c83ec50ea0 5077 ideal_divisor,
whismanoid 15:37c83ec50ea0 5078 (actual_SCLK_Hz / 1000000.)
whismanoid 15:37c83ec50ea0 5079 );
whismanoid 15:37c83ec50ea0 5080 }
whismanoid 15:37c83ec50ea0 5081 // get next character
whismanoid 15:37c83ec50ea0 5082 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 5083 {
whismanoid 15:37c83ec50ea0 5084 case 'C': case 's':
whismanoid 15:37c83ec50ea0 5085 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 5086 break;
whismanoid 15:37c83ec50ea0 5087 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 5088 // %SD -- SPI diagnostic messages enable
whismanoid 15:37c83ec50ea0 5089 if (g_MAX5719_device.onSPIprint) {
whismanoid 15:37c83ec50ea0 5090 g_MAX5719_device.onSPIprint = NULL;
whismanoid 15:37c83ec50ea0 5091 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') != None is false
whismanoid 15:37c83ec50ea0 5092 }
whismanoid 15:37c83ec50ea0 5093 else {
whismanoid 15:37c83ec50ea0 5094 void onSPIprint_handler(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]);
whismanoid 15:37c83ec50ea0 5095 g_MAX5719_device.onSPIprint = onSPIprint_handler;
whismanoid 15:37c83ec50ea0 5096 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') is false
whismanoid 15:37c83ec50ea0 5097 }
whismanoid 15:37c83ec50ea0 5098 break;
whismanoid 15:37c83ec50ea0 5099 case 'W': case 'R': case 'w': case 'r':
whismanoid 15:37c83ec50ea0 5100 {
whismanoid 15:37c83ec50ea0 5101 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 5102 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 5103 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5104 #define MAX_SPI_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 5105 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 5106 static char mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5107 static char misoData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5108 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 5109 MAX_SPI_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 5110 {
whismanoid 15:37c83ec50ea0 5111 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5112 cmdLine.serial().printf("\r\nSPI");
whismanoid 15:37c83ec50ea0 5113 if (byteCount > 7) {
whismanoid 15:37c83ec50ea0 5114 cmdLine.serial().printf(" byteCount:%d", byteCount);
whismanoid 15:37c83ec50ea0 5115 }
whismanoid 15:37c83ec50ea0 5116 cmdLine.serial().printf(" MOSI->");
whismanoid 15:37c83ec50ea0 5117 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 5118 {
whismanoid 15:37c83ec50ea0 5119 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 5120 }
whismanoid 15:37c83ec50ea0 5121 spi_cs = 0;
whismanoid 15:37c83ec50ea0 5122 unsigned int numBytesTransferred =
whismanoid 15:37c83ec50ea0 5123 spi.write(mosiData, byteCount, misoData, byteCount);
whismanoid 15:37c83ec50ea0 5124 spi_cs = 1;
whismanoid 15:37c83ec50ea0 5125 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5126 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 5127 for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred;
whismanoid 15:37c83ec50ea0 5128 byteIndex++)
whismanoid 15:37c83ec50ea0 5129 {
whismanoid 15:37c83ec50ea0 5130 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 5131 }
whismanoid 15:37c83ec50ea0 5132 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 5133 }
whismanoid 15:37c83ec50ea0 5134 }
whismanoid 15:37c83ec50ea0 5135 break;
whismanoid 15:37c83ec50ea0 5136 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 5137 } // case 'S': // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 5138 break;
whismanoid 15:37c83ec50ea0 5139 #endif
whismanoid 15:37c83ec50ea0 5140 //
whismanoid 15:37c83ec50ea0 5141 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 5142 } // switch(cmdLine[1])
whismanoid 15:37c83ec50ea0 5143 } // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 15:37c83ec50ea0 5144 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 15:37c83ec50ea0 5145
whismanoid 15:37c83ec50ea0 5146 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 5147 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 5148 void main_menu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 5149 {
whismanoid 9:45f98573eb6d 5150 // process command line
whismanoid 31:47eee7e0cc2d 5151 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 5152 if (g_Run_command_table_running == false) {
whismanoid 31:47eee7e0cc2d 5153 cmdLine.serial().printf("\r\nCmdLine buf:\"%s\"\r\n", cmdLine.str());
whismanoid 31:47eee7e0cc2d 5154 } // if (g_Run_command_table_running)
whismanoid 31:47eee7e0cc2d 5155 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 5156 if (g_Run_command_table_running == false) {
whismanoid 31:47eee7e0cc2d 5157 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 5158
whismanoid 4:d9b05924ad4c 5159 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 31:47eee7e0cc2d 5160 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 5161 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 5162 // If datalog is free running, halt on any possible received command
whismanoid 17:9397ea3ea7e9 5163 if (Datalogger_Trigger != trigger_Halt) {
whismanoid 4:d9b05924ad4c 5164 Datalogger_Trigger = trigger_Halt;
whismanoid 9:45f98573eb6d 5165 cmdLine.serial().printf("Datalog stopped by USB command input\r\n");
whismanoid 9:45f98573eb6d 5166 cmdLine.serial().printf("Restart datalog by sending LR\r\n");
whismanoid 4:d9b05924ad4c 5167 }
whismanoid 31:47eee7e0cc2d 5168 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 5169 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 5170
whismanoid 4:d9b05924ad4c 5171 // DIAGNOSTIC: print line buffer
whismanoid 4:d9b05924ad4c 5172 //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str());
whismanoid 4:d9b05924ad4c 5173 //
whismanoid 4:d9b05924ad4c 5174 switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 5175 {
whismanoid 4:d9b05924ad4c 5176 case '?':
whismanoid 4:d9b05924ad4c 5177 main_menu_status(cmdLine);
whismanoid 4:d9b05924ad4c 5178 main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 5179 // print command prompt
whismanoid 4:d9b05924ad4c 5180 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 5181 break;
whismanoid 4:d9b05924ad4c 5182 case '\r': case '\n': // ignore blank line
whismanoid 4:d9b05924ad4c 5183 case '\0': // ignore empty line
whismanoid 30:07197a430869 5184 main_menu_status(cmdLine);
whismanoid 30:07197a430869 5185 //~ main_menu_help(cmdLine);
whismanoid 30:07197a430869 5186 // print command prompt
whismanoid 30:07197a430869 5187 //cmdLine.serial().printf("\r\n>");
whismanoid 30:07197a430869 5188 break;
whismanoid 4:d9b05924ad4c 5189 case '#': // ignore comment line
whismanoid 4:d9b05924ad4c 5190 // # -- lines beginning with # are comments
whismanoid 30:07197a430869 5191 //
whismanoid 30:07197a430869 5192 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 5193 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in main_menu_onEOLcommandParser
whismanoid 30:07197a430869 5194 // # command handler update gstrRemarkText buffer instead of just ignoring the remark
whismanoid 30:07197a430869 5195 //
whismanoid 30:07197a430869 5196 // ignore extra spaces before the remark
whismanoid 30:07197a430869 5197 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 30:07197a430869 5198 int argIndex;
whismanoid 30:07197a430869 5199 for (argIndex = 1; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 5200 {
whismanoid 30:07197a430869 5201 if (cmdLine[argIndex] == ' ') break;
whismanoid 30:07197a430869 5202 }
whismanoid 30:07197a430869 5203 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 5204 {
whismanoid 30:07197a430869 5205 if (cmdLine[argIndex] != ' ') break;
whismanoid 30:07197a430869 5206 }
whismanoid 30:07197a430869 5207 //
whismanoid 30:07197a430869 5208 strncpy(gstrRemarkText, cmdLine.str()+argIndex, gstrRemarkTextLASTINDEX+1);
whismanoid 30:07197a430869 5209 // do not exceed string buffer limit; keep sentinel null character at end of buffer
whismanoid 30:07197a430869 5210 gstrRemarkText[gstrRemarkTextLASTINDEX] = '\0';
whismanoid 30:07197a430869 5211 for (int index = 0; index < gstrRemarkTextLASTINDEX; index++)
whismanoid 30:07197a430869 5212 {
whismanoid 30:07197a430869 5213 if ((gstrRemarkText[index]) == '\0') break; // null character at end of string
whismanoid 30:07197a430869 5214 if ((gstrRemarkText[index]) < 0x20) {
whismanoid 30:07197a430869 5215 // replace non-printing characters with _
whismanoid 30:07197a430869 5216 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 5217 continue;
whismanoid 30:07197a430869 5218 }
whismanoid 30:07197a430869 5219 if ((gstrRemarkText[index]) >= 0x7F) {
whismanoid 30:07197a430869 5220 // replace non-printing characters with _
whismanoid 30:07197a430869 5221 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 5222 continue;
whismanoid 30:07197a430869 5223 }
whismanoid 30:07197a430869 5224 switch(gstrRemarkText[index])
whismanoid 30:07197a430869 5225 {
whismanoid 30:07197a430869 5226 case ',':
whismanoid 30:07197a430869 5227 // replace , with ;
whismanoid 30:07197a430869 5228 gstrRemarkText[index] = ';';
whismanoid 30:07197a430869 5229 break;
whismanoid 30:07197a430869 5230 case '"':
whismanoid 30:07197a430869 5231 // replace " with '
whismanoid 30:07197a430869 5232 gstrRemarkText[index] = '\'';
whismanoid 30:07197a430869 5233 break;
whismanoid 30:07197a430869 5234 case '\\':
whismanoid 30:07197a430869 5235 // replace \ with /
whismanoid 30:07197a430869 5236 gstrRemarkText[index] = '/';
whismanoid 30:07197a430869 5237 break;
whismanoid 30:07197a430869 5238 }
whismanoid 30:07197a430869 5239 }
whismanoid 30:07197a430869 5240 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 5241 //
whismanoid 31:47eee7e0cc2d 5242 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 5243 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 5244 main_menu_status(cmdLine);
whismanoid 31:47eee7e0cc2d 5245 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 5246 //~ main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 5247 // print command prompt
whismanoid 4:d9b05924ad4c 5248 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 5249 break;
whismanoid 4:d9b05924ad4c 5250 #if ECHO_EOF_ON_EOL
whismanoid 4:d9b05924ad4c 5251 case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file
whismanoid 4:d9b05924ad4c 5252 cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 5253 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 5254 break;
whismanoid 4:d9b05924ad4c 5255 case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file
whismanoid 4:d9b05924ad4c 5256 cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 5257 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 5258 break;
whismanoid 4:d9b05924ad4c 5259 #endif
whismanoid 10:04022a61b527 5260 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 5261 case '!': // device init
whismanoid 10:04022a61b527 5262 {
whismanoid 10:04022a61b527 5263 cmdLine.serial().printf("Init");
whismanoid 10:04022a61b527 5264 // call function Init
whismanoid 10:04022a61b527 5265 uint8_t result = g_MAX11410_device.Init();
whismanoid 10:04022a61b527 5266 // cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 5267 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 5268 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 5269 // in command '!' device init, apply list of custom register writes after init
whismanoid 10:04022a61b527 5270 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 5271 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 10:04022a61b527 5272 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 10:04022a61b527 5273 uint32_t regData = custom_reg_init_data[index];
whismanoid 10:04022a61b527 5274 cmdLine.serial().printf("*%s=0x%06.6x",
whismanoid 10:04022a61b527 5275 g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress),
whismanoid 10:04022a61b527 5276 regData
whismanoid 10:04022a61b527 5277 );
whismanoid 10:04022a61b527 5278 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 10:04022a61b527 5279 }
whismanoid 10:04022a61b527 5280 #endif // USE_CUSTOM_REG_INIT
whismanoid 10:04022a61b527 5281 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 5282 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 5283 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 5284 }
whismanoid 10:04022a61b527 5285 break;
whismanoid 10:04022a61b527 5286 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 5287 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 5288 case '.':
whismanoid 4:d9b05924ad4c 5289 {
whismanoid 4:d9b05924ad4c 5290 // . -- SelfTest
whismanoid 4:d9b05924ad4c 5291 cmdLine.serial().printf("SelfTest()");
whismanoid 4:d9b05924ad4c 5292 SelfTest(cmdLine);
whismanoid 4:d9b05924ad4c 5293 }
whismanoid 4:d9b05924ad4c 5294 break;
whismanoid 4:d9b05924ad4c 5295 #endif // USE_SELFTEST
whismanoid 15:37c83ec50ea0 5296 #if 1 // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 5297 case '%':
whismanoid 4:d9b05924ad4c 5298 {
whismanoid 4:d9b05924ad4c 5299 pinsMonitor_submenu_onEOLcommandParser(cmdLine);
whismanoid 4:d9b05924ad4c 5300 }
whismanoid 4:d9b05924ad4c 5301 break; // case '%'
whismanoid 4:d9b05924ad4c 5302 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 9:45f98573eb6d 5303 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 5304 // reuse the Serial_Tester command *regName=regValue
whismanoid 10:04022a61b527 5305 // CODE GENERATOR: generate * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 5306 case '*':
whismanoid 10:04022a61b527 5307 {
whismanoid 10:04022a61b527 5308 // if buffer starts with a regName:
whismanoid 10:04022a61b527 5309 // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))):
whismanoid 10:04022a61b527 5310 // cmdLine.serial().printf(" scan RegName...\r\n");
whismanoid 10:04022a61b527 5311 }
whismanoid 10:04022a61b527 5312 break;
whismanoid 9:45f98573eb6d 5313 #endif // USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 5314 //
whismanoid 10:04022a61b527 5315 #if 1 // USE_AUX_SERIAL_CMD_FORWARDING && (HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL)
whismanoid 10:04022a61b527 5316 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_onEOLcommandParser
whismanoid 40:330b28116178 5317 case '>': case '<': // > send and receive; < receive without sending anything
whismanoid 10:04022a61b527 5318 {
whismanoid 10:04022a61b527 5319 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 5320 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 5321 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 5322 CmdLine& cmdLine_AuxSerial = cmdLine_AUXserial;
whismanoid 10:04022a61b527 5323 Serial& AuxSerial = AUXserial;
whismanoid 10:04022a61b527 5324 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5325 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 5326 CmdLine& cmdLine_AuxSerial = cmdLine_DAPLINKserial;
whismanoid 10:04022a61b527 5327 Serial& AuxSerial = DAPLINKserial;
whismanoid 10:04022a61b527 5328 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5329 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 5330 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5331 //
whismanoid 40:330b28116178 5332 int g_auxSerialCom_outgoing_string_cr = 1; // option to send CR after outgoing_string
whismanoid 40:330b28116178 5333 int g_auxSerialCom_outgoing_string_lf = 0; // option to send LF after outgoing_string (breaks remote datalogger LR!)
whismanoid 40:330b28116178 5334 int g_auxSerialCom_rx_string_verbose_crlf = 0; // option to display \r\n as "\\r\\n" in rx_string_buf
whismanoid 40:330b28116178 5335 int g_auxSerialCom_rx_string_verbose_ctrl = 1; // option to display control codes as \xXX
whismanoid 40:330b28116178 5336 const char* g_auxSerialCom_display_tx_prefix = "\r\n->|"; // "\r\n >";
whismanoid 40:330b28116178 5337 const char* g_auxSerialCom_display_rx_prefix = "\r\n<-|"; // "\r\n< ";
whismanoid 40:330b28116178 5338 //
whismanoid 40:330b28116178 5339 bool need_g_auxSerialCom_display_rx_prefix = 1; // temp
whismanoid 40:330b28116178 5340 //
whismanoid 10:04022a61b527 5341 // >> suppress key=value parsing
whismanoid 10:04022a61b527 5342 bool suppress_parsing = (cmdLine[1] == '>');
whismanoid 10:04022a61b527 5343 if (suppress_parsing == false) {
whismanoid 10:04022a61b527 5344 // int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 5345 if (cmdLine.parse_int_dec("baud", g_auxSerialCom_baud))
whismanoid 10:04022a61b527 5346 {
whismanoid 10:04022a61b527 5347 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- baud rate
whismanoid 10:04022a61b527 5348 cmdLine_AuxSerial.serial().printf("\r\n*** New Baud Rate %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5349 AuxSerial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5350 cmdLine_AuxSerial.serial().printf("\r\n*** Baud Rate was set to %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5351 }
whismanoid 10:04022a61b527 5352 #if 0
whismanoid 10:04022a61b527 5353 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 5354 if (cmdLine.parse_int_dec("tx_wait_echo", g_auxSerialCom_tx_wait_echo))
whismanoid 10:04022a61b527 5355 {
whismanoid 10:04022a61b527 5356 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_wait_echo
whismanoid 10:04022a61b527 5357 //~ cmdLine_AuxSerial.serial().printf("\r\n*** tx_wait_echo was set to %d ***\r\n", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 5358 cmdLine.serial().printf("\r\n tx_wait_echo=%d", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 5359 }
whismanoid 10:04022a61b527 5360 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 5361 if (cmdLine.parse_int_dec("tx_char_delay_ms", g_auxSerialCom_tx_char_delay_ms))
whismanoid 10:04022a61b527 5362 {
whismanoid 10:04022a61b527 5363 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_char_delay_ms
whismanoid 10:04022a61b527 5364 //~ 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 5365 cmdLine.serial().printf("\r\n tx_char_delay_ms=%dms", g_auxSerialCom_tx_char_delay_ms);
whismanoid 10:04022a61b527 5366 }
whismanoid 10:04022a61b527 5367 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 5368 if (cmdLine.parse_int_dec("tx_line_delay_ms", g_auxSerialCom_tx_line_delay_ms))
whismanoid 10:04022a61b527 5369 {
whismanoid 10:04022a61b527 5370 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_line_delay_ms
whismanoid 10:04022a61b527 5371 //~ 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 5372 cmdLine.serial().printf("\r\n tx_line_delay_ms=%dms", g_auxSerialCom_tx_line_delay_ms);
whismanoid 10:04022a61b527 5373 }
whismanoid 10:04022a61b527 5374 #endif
whismanoid 10:04022a61b527 5375 // int g_auxSerialCom_message_ms = 0; //!< capture RX until response timeout?
whismanoid 10:04022a61b527 5376 if (cmdLine.parse_int_dec("message_ms", g_auxSerialCom_message_ms))
whismanoid 10:04022a61b527 5377 {
whismanoid 10:04022a61b527 5378 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 10:04022a61b527 5379 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 5380 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 5381 }
whismanoid 10:04022a61b527 5382 // int g_auxSerialCom_rx_idle_ms = 0; //!< capture RX until idle timeout?
whismanoid 10:04022a61b527 5383 if (cmdLine.parse_int_dec("rx_idle_ms", g_auxSerialCom_rx_idle_ms))
whismanoid 10:04022a61b527 5384 {
whismanoid 10:04022a61b527 5385 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_idle_ms
whismanoid 10:04022a61b527 5386 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_idle_ms was set to %d ***\r\n", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 5387 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 5388 }
whismanoid 10:04022a61b527 5389 // int g_auxSerialCom_rx_max_count = 0; //!< capture RX until max character count?
whismanoid 10:04022a61b527 5390 if (cmdLine.parse_int_dec("rx_max_count", g_auxSerialCom_rx_max_count))
whismanoid 10:04022a61b527 5391 {
whismanoid 10:04022a61b527 5392 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_max_count
whismanoid 10:04022a61b527 5393 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_max_count was set to %d ***\r\n", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 5394 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 5395 }
whismanoid 10:04022a61b527 5396 // int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text char?
whismanoid 10:04022a61b527 5397 if (cmdLine.parse_int_dec("rx_eot", g_auxSerialCom_rx_eot))
whismanoid 10:04022a61b527 5398 {
whismanoid 10:04022a61b527 5399 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_eot
whismanoid 10:04022a61b527 5400 //~ cmdLine_AUXserial.serial().printf("\r\n*** rx_eot was set to %d ***\r\n", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 5401 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 5402 }
whismanoid 10:04022a61b527 5403 }
whismanoid 10:04022a61b527 5404 // Command forwarding to AUX serial TX/RX cmdLine_AuxSerial #257 -- send outgoing_string
whismanoid 40:330b28116178 5405 char* outgoing_string = "";
whismanoid 40:330b28116178 5406 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 5407 outgoing_string = (char*)cmdLine.str();
whismanoid 40:330b28116178 5408 // > use key=value parsing
whismanoid 40:330b28116178 5409 // >> suppress key=value parsing
whismanoid 40:330b28116178 5410 if (suppress_parsing) {
whismanoid 40:330b28116178 5411 cmdLine.serial().printf("\r\n suppress_parsing outgoing_string=\"%s\"", outgoing_string);
whismanoid 40:330b28116178 5412 outgoing_string++; // skip the first '>'
whismanoid 40:330b28116178 5413 outgoing_string++; // skip the second '>'
whismanoid 40:330b28116178 5414 } else {
whismanoid 40:330b28116178 5415 // TODO: after parsing, key=value pairs should be deleted, but outgoing_string=">xyzzy abc=def"
whismanoid 40:330b28116178 5416 cmdLine.serial().printf("\r\n after parsing, outgoing_string=\"%s\"", outgoing_string);
whismanoid 40:330b28116178 5417 outgoing_string++; // skip the first '>'
whismanoid 40:330b28116178 5418 }
whismanoid 40:330b28116178 5419 } // if (cmdLine[0] == '>')
whismanoid 10:04022a61b527 5420 static char rx_string_buf[RX_STRING_BUF_SIZE];
whismanoid 10:04022a61b527 5421 unsigned int rx_string_length = 0;
whismanoid 40:330b28116178 5422 //cmdLine.serial().printf("\r\n >%s\r\n <", outgoing_string);
whismanoid 40:330b28116178 5423 //char* g_auxSerialCom_display_tx_prefix = "\r\n >";
whismanoid 40:330b28116178 5424 //char* g_auxSerialCom_display_rx_prefix = "\r\n< ";
whismanoid 40:330b28116178 5425 cmdLine.serial().printf("%s%s%s",
whismanoid 40:330b28116178 5426 g_auxSerialCom_display_tx_prefix, // "\r\n >"
whismanoid 40:330b28116178 5427 outgoing_string,
whismanoid 40:330b28116178 5428 g_auxSerialCom_display_rx_prefix // "\r\n <"
whismanoid 40:330b28116178 5429 );
whismanoid 10:04022a61b527 5430 rx_string_buf[0] = '\0';
whismanoid 10:04022a61b527 5431 rx_string_length = 0;
whismanoid 10:04022a61b527 5432 //
whismanoid 10:04022a61b527 5433 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 5434 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 5435 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 5436 //
whismanoid 10:04022a61b527 5437 // int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 5438 // int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 5439 // int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 5440 // int g_auxSerialCom_rx_idle_ms = 2000; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 5441 // int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 5442 // int g_auxSerialCom_rx_eot = '\r'; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 5443 //~ cmdLine_AuxSerial.serial().printf("\r\n*** TODO forward %s ***\r\n", outgoing_string);
whismanoid 10:04022a61b527 5444 //
whismanoid 10:04022a61b527 5445 // TODO: send whole string or send character-by-character?
whismanoid 40:330b28116178 5446 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 5447 cmdLine_AuxSerial.serial().printf("%s", outgoing_string);
whismanoid 40:330b28116178 5448 //
whismanoid 40:330b28116178 5449 // TODO: send CRLF or just send CR line end?
whismanoid 40:330b28116178 5450 if (g_auxSerialCom_outgoing_string_cr) { cmdLine_AuxSerial.serial().printf("\r"); }
whismanoid 40:330b28116178 5451 if (g_auxSerialCom_outgoing_string_lf) { cmdLine_AuxSerial.serial().printf("\n"); }
whismanoid 40:330b28116178 5452 // cmdLine_AuxSerial.serial().printf("\r\n");
whismanoid 40:330b28116178 5453 } // if (cmdLine[0] == '>')
whismanoid 40:330b28116178 5454 //
whismanoid 10:04022a61b527 5455 g_auxSerialCom_Timer.start();
whismanoid 10:04022a61b527 5456 g_auxSerialCom_Timer_begin_message_ms = g_auxSerialCom_Timer.read_ms(); // start of message
whismanoid 10:04022a61b527 5457 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 5458 while (rx_string_length < (RX_STRING_BUF_SIZE-1)) {
whismanoid 10:04022a61b527 5459 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_message_ms) > g_auxSerialCom_message_ms) {
whismanoid 10:04022a61b527 5460 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 5461 break;
whismanoid 10:04022a61b527 5462 }
whismanoid 10:04022a61b527 5463 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_rx_idle_ms) > g_auxSerialCom_rx_idle_ms) {
whismanoid 10:04022a61b527 5464 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 5465 break;
whismanoid 10:04022a61b527 5466 }
whismanoid 10:04022a61b527 5467 if (rx_string_length >= g_auxSerialCom_rx_max_count) {
whismanoid 10:04022a61b527 5468 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 5469 break;
whismanoid 10:04022a61b527 5470 }
whismanoid 10:04022a61b527 5471 if (AuxSerial.readable()) {
whismanoid 10:04022a61b527 5472 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 5473 char ch = AuxSerial.getc();
whismanoid 10:04022a61b527 5474 rx_string_buf[rx_string_length++] = ch;
whismanoid 10:04022a61b527 5475 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 40:330b28116178 5476 //
whismanoid 40:330b28116178 5477 #if 1
whismanoid 40:330b28116178 5478 // immediate character echo
whismanoid 40:330b28116178 5479 for (char* cp = &(rx_string_buf[rx_string_length-1]); *cp != '\0'; cp++)
whismanoid 40:330b28116178 5480 {
whismanoid 40:330b28116178 5481 //cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 5482 if (need_g_auxSerialCom_display_rx_prefix) {
whismanoid 40:330b28116178 5483 cmdLine.serial().printf(g_auxSerialCom_display_rx_prefix); // "\r\n< " g_auxSerialCom_rx_string display prefix
whismanoid 40:330b28116178 5484 need_g_auxSerialCom_display_rx_prefix = 0;
whismanoid 40:330b28116178 5485 }
whismanoid 40:330b28116178 5486 if ((*cp) == '\r') {
whismanoid 40:330b28116178 5487 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\r"); }
whismanoid 40:330b28116178 5488 // if (*(cp+1) != '\n') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 5489 } else if ((*cp) == '\n') {
whismanoid 40:330b28116178 5490 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\n"); }
whismanoid 40:330b28116178 5491 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 5492 if (*(cp-1) != '\r') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 5493 } else if ((*cp) < 0x20) {
whismanoid 40:330b28116178 5494 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 5495 } else if ((*cp) >= 0x7f) {
whismanoid 40:330b28116178 5496 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 5497 } else {
whismanoid 40:330b28116178 5498 cmdLine.serial().printf("%c", *cp);
whismanoid 40:330b28116178 5499 }
whismanoid 40:330b28116178 5500 }
whismanoid 40:330b28116178 5501 #else
whismanoid 40:330b28116178 5502 // immediate character echo
whismanoid 40:330b28116178 5503 cmdLine.serial().printf("%s", &(rx_string_buf[rx_string_length-1]) );
whismanoid 40:330b28116178 5504 #endif
whismanoid 40:330b28116178 5505 //
whismanoid 10:04022a61b527 5506 if (g_auxSerialCom_rx_eot != aux_serial_cmd_forwarding_rx_eot_not_used) {
whismanoid 10:04022a61b527 5507 if (ch == g_auxSerialCom_rx_eot) {
whismanoid 10:04022a61b527 5508 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 5509 break;
whismanoid 10:04022a61b527 5510 }
whismanoid 10:04022a61b527 5511 }
whismanoid 10:04022a61b527 5512 }
whismanoid 10:04022a61b527 5513 } // end while (rx_string_length < (RX_STRING_BUF_SIZE-1))
whismanoid 40:330b28116178 5514 #if 0
whismanoid 10:04022a61b527 5515 // print summary. is this needed? we already print aux rx as it is received.
whismanoid 10:04022a61b527 5516 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 40:330b28116178 5517 # if 1 // support multi-line rx_string_buf response
whismanoid 40:330b28116178 5518 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 5519 cmdLine.serial().printf("%s%s", g_auxSerialCom_display_tx_prefix, outgoing_string);
whismanoid 40:330b28116178 5520 } // if (cmdLine[0] == '>')
whismanoid 40:330b28116178 5521 // cmdLine.serial().printf("\r\n <"); // prefix
whismanoid 40:330b28116178 5522 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 5523 for (char* cp = rx_string_buf; *cp != '\0'; cp++)
whismanoid 40:330b28116178 5524 {
whismanoid 40:330b28116178 5525 //cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 5526 if (need_g_auxSerialCom_display_rx_prefix) {
whismanoid 40:330b28116178 5527 cmdLine.serial().printf(g_auxSerialCom_display_rx_prefix); // "\r\n< " g_auxSerialCom_rx_string display prefix
whismanoid 40:330b28116178 5528 need_g_auxSerialCom_display_rx_prefix = 0;
whismanoid 40:330b28116178 5529 }
whismanoid 40:330b28116178 5530 if ((*cp) == '\r') {
whismanoid 40:330b28116178 5531 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\r"); }
whismanoid 40:330b28116178 5532 if (*(cp+1) != '\n') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 5533 } else if ((*cp) == '\n') {
whismanoid 40:330b28116178 5534 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\n"); }
whismanoid 40:330b28116178 5535 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 5536 } else if ((*cp) < 0x20) {
whismanoid 40:330b28116178 5537 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 5538 } else if ((*cp) >= 0x7f) {
whismanoid 40:330b28116178 5539 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 5540 } else {
whismanoid 40:330b28116178 5541 cmdLine.serial().printf("%c", *cp);
whismanoid 40:330b28116178 5542 }
whismanoid 40:330b28116178 5543 }
whismanoid 40:330b28116178 5544 cmdLine.serial().printf("\r\n");
whismanoid 40:330b28116178 5545 # else
whismanoid 10:04022a61b527 5546 cmdLine.serial().printf("\r\n >%s", outgoing_string);
whismanoid 10:04022a61b527 5547 cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 5548 # endif
whismanoid 10:04022a61b527 5549 #endif
whismanoid 10:04022a61b527 5550 //
whismanoid 10:04022a61b527 5551 }
whismanoid 10:04022a61b527 5552 break; // case '>'
whismanoid 10:04022a61b527 5553 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 5554 //
whismanoid 4:d9b05924ad4c 5555 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 5556 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 5557 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 5558 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 5559 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible
whismanoid 9:45f98573eb6d 5560 case 'L': case 'l':
whismanoid 4:d9b05924ad4c 5561 {
whismanoid 4:d9b05924ad4c 5562 // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 5563 Datalogger_Trigger = trigger_Halt;
whismanoid 4:d9b05924ad4c 5564 switch (cmdLine[1])
whismanoid 4:d9b05924ad4c 5565 {
whismanoid 17:9397ea3ea7e9 5566 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 5567 case 'T': case 't':
whismanoid 17:9397ea3ea7e9 5568 {
whismanoid 17:9397ea3ea7e9 5569 // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 5570 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 5571 Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 5572 g_timer_interval_counter = 0;
whismanoid 39:4d285e961435 5573 // get g_timer_interval_msec from cmdLine
whismanoid 17:9397ea3ea7e9 5574 // g_timer_interval_msec = 500;
whismanoid 17:9397ea3ea7e9 5575 // g_timer_interval_count = 10;
whismanoid 17:9397ea3ea7e9 5576 if (cmdLine.parse_int_dec("count", g_timer_interval_count))
whismanoid 17:9397ea3ea7e9 5577 {
whismanoid 32:80f3e5eb77d4 5578 if (g_timer_interval_count < 1) { g_timer_interval_count = 1; }
whismanoid 17:9397ea3ea7e9 5579 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 5580 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 5581 cmdLine.serial().printf("\r\n g_timer_interval_count=%d", g_timer_interval_count);
whismanoid 17:9397ea3ea7e9 5582 }
whismanoid 17:9397ea3ea7e9 5583 if (cmdLine.parse_int_dec("base", g_timer_interval_msec))
whismanoid 17:9397ea3ea7e9 5584 {
whismanoid 17:9397ea3ea7e9 5585 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 5586 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 5587 cmdLine.serial().printf("\r\n g_timer_interval_msec=%d", g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 5588 }
whismanoid 39:4d285e961435 5589 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 5590 // TODO: USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 5591 int int_timer_sleepmode = g_timer_sleepmode;
whismanoid 39:4d285e961435 5592 if (cmdLine.parse_int_dec("sleep", int_timer_sleepmode))
whismanoid 39:4d285e961435 5593 {
whismanoid 39:4d285e961435 5594 g_timer_sleepmode = (Datalogger_Sleep_enum_t)int_timer_sleepmode;
whismanoid 39:4d285e961435 5595 //~ if (g_timer_interval_count < 1) { g_timer_interval_count = 1; }
whismanoid 39:4d285e961435 5596 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 39:4d285e961435 5597 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 39:4d285e961435 5598 cmdLine.serial().printf("\r\n g_timer_sleepmode=%d", (int)g_timer_sleepmode);
whismanoid 39:4d285e961435 5599 }
whismanoid 39:4d285e961435 5600 #else // USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 5601 #endif // USE_DATALOGGER_SLEEP
whismanoid 17:9397ea3ea7e9 5602 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 17:9397ea3ea7e9 5603 }
whismanoid 17:9397ea3ea7e9 5604 break;
whismanoid 17:9397ea3ea7e9 5605 // LIH3 -- Datalog when input high D3
whismanoid 17:9397ea3ea7e9 5606 // LIL6 -- Datalog when input low D6
whismanoid 17:9397ea3ea7e9 5607 case 'I': case 'i':
whismanoid 17:9397ea3ea7e9 5608 {
whismanoid 17:9397ea3ea7e9 5609 // TODO: switch cmdLine[2] configure High or Low, configure input pin
whismanoid 17:9397ea3ea7e9 5610 }
whismanoid 17:9397ea3ea7e9 5611 break;
whismanoid 17:9397ea3ea7e9 5612 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 5613 // L$ count=10 base=500ms addr=xxx data=xxx mask=xxx -- Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 5614 case '$':
whismanoid 17:9397ea3ea7e9 5615 {
whismanoid 17:9397ea3ea7e9 5616 // TODO: scan cmdLine for regAddr, dataMask, testValue
whismanoid 17:9397ea3ea7e9 5617 }
whismanoid 17:9397ea3ea7e9 5618 break;
whismanoid 17:9397ea3ea7e9 5619 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 5620 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 5621 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5622 case '@':
whismanoid 17:9397ea3ea7e9 5623 {
whismanoid 17:9397ea3ea7e9 5624 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5625 int editRowIndex = 0;
whismanoid 17:9397ea3ea7e9 5626 int edit_action = (int)action_noop;
whismanoid 17:9397ea3ea7e9 5627 int edit_digitalOutPin = 0;
whismanoid 17:9397ea3ea7e9 5628 int edit_condition = (int)condition_always;
whismanoid 17:9397ea3ea7e9 5629 int edit_condition_channel = 0;
whismanoid 17:9397ea3ea7e9 5630 double edit_condition_threshold = 0;
whismanoid 17:9397ea3ea7e9 5631 //
whismanoid 17:9397ea3ea7e9 5632 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 17:9397ea3ea7e9 5633 {
whismanoid 17:9397ea3ea7e9 5634 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 17:9397ea3ea7e9 5635 }
whismanoid 17:9397ea3ea7e9 5636 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 17:9397ea3ea7e9 5637 {
whismanoid 17:9397ea3ea7e9 5638 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 17:9397ea3ea7e9 5639 }
whismanoid 17:9397ea3ea7e9 5640 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 17:9397ea3ea7e9 5641 {
whismanoid 17:9397ea3ea7e9 5642 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 17:9397ea3ea7e9 5643 }
whismanoid 17:9397ea3ea7e9 5644 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 17:9397ea3ea7e9 5645 {
whismanoid 17:9397ea3ea7e9 5646 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 17:9397ea3ea7e9 5647 }
whismanoid 17:9397ea3ea7e9 5648 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 17:9397ea3ea7e9 5649 {
whismanoid 17:9397ea3ea7e9 5650 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 17:9397ea3ea7e9 5651 }
whismanoid 17:9397ea3ea7e9 5652 //
whismanoid 17:9397ea3ea7e9 5653 // Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5654 switch (cmdLine[2]) // L@... -- Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5655 {
whismanoid 17:9397ea3ea7e9 5656 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 5657 case '0': case '1': case '2': case '3': case '4':
whismanoid 17:9397ea3ea7e9 5658 case '5': case '6': case '7': case '8': case '9':
whismanoid 17:9397ea3ea7e9 5659 // edit row data
whismanoid 30:07197a430869 5660 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 5661 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 5662 // get row number to edit from cmdLine[2]
whismanoid 17:9397ea3ea7e9 5663 editRowIndex = atoi(cmdLine.str()+2);
whismanoid 30:07197a430869 5664 if ((editRowIndex >= 0) && (editRowIndex < Datalogger_action_table_row_count)) {
whismanoid 30:07197a430869 5665 // update row
whismanoid 30:07197a430869 5666 cmdLine.serial().printf("\r\n replace row %d", editRowIndex);
whismanoid 30:07197a430869 5667 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 5668 edit_action = Datalogger_action_table[editRowIndex].action;
whismanoid 30:07197a430869 5669 edit_digitalOutPin = Datalogger_action_table[editRowIndex].digitalOutPin;
whismanoid 30:07197a430869 5670 edit_condition = Datalogger_action_table[editRowIndex].condition;
whismanoid 30:07197a430869 5671 edit_condition_channel = Datalogger_action_table[editRowIndex].condition_channel;
whismanoid 30:07197a430869 5672 edit_condition_threshold = Datalogger_action_table[editRowIndex].condition_threshold;
whismanoid 30:07197a430869 5673 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 5674 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 30:07197a430869 5675 {
whismanoid 30:07197a430869 5676 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 30:07197a430869 5677 }
whismanoid 30:07197a430869 5678 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 30:07197a430869 5679 {
whismanoid 30:07197a430869 5680 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 30:07197a430869 5681 }
whismanoid 30:07197a430869 5682 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 30:07197a430869 5683 {
whismanoid 30:07197a430869 5684 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 30:07197a430869 5685 }
whismanoid 30:07197a430869 5686 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 30:07197a430869 5687 {
whismanoid 30:07197a430869 5688 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 30:07197a430869 5689 }
whismanoid 30:07197a430869 5690 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 30:07197a430869 5691 {
whismanoid 30:07197a430869 5692 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 30:07197a430869 5693 }
whismanoid 30:07197a430869 5694 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 5695 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 5696 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 5697 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 5698 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 5699 }
whismanoid 30:07197a430869 5700 else if ((editRowIndex == Datalogger_action_table_row_count) && (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX)) {
whismanoid 30:07197a430869 5701 // %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 5702 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 5703 cmdLine.serial().printf("\r\n add next row %d", editRowIndex);
whismanoid 30:07197a430869 5704 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 5705 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 5706 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 5707 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 5708 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 30:07197a430869 5709 //
whismanoid 17:9397ea3ea7e9 5710 }
whismanoid 17:9397ea3ea7e9 5711 }
whismanoid 17:9397ea3ea7e9 5712 break;
whismanoid 17:9397ea3ea7e9 5713 case '+':
whismanoid 17:9397ea3ea7e9 5714 // add a new row at end of table
whismanoid 17:9397ea3ea7e9 5715 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 5716 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 5717 editRowIndex = Datalogger_action_table_row_count;
whismanoid 17:9397ea3ea7e9 5718 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 5719 cmdLine.serial().printf("\r\n add new row %d", editRowIndex);
whismanoid 17:9397ea3ea7e9 5720 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 17:9397ea3ea7e9 5721 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 17:9397ea3ea7e9 5722 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 17:9397ea3ea7e9 5723 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 17:9397ea3ea7e9 5724 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 5725 }
whismanoid 17:9397ea3ea7e9 5726 break;
whismanoid 17:9397ea3ea7e9 5727 case '-':
whismanoid 17:9397ea3ea7e9 5728 // delete row from table
whismanoid 17:9397ea3ea7e9 5729 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 5730 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 5731 if ((cmdLine[3] == '~') && (cmdLine[4] == '~') && (cmdLine[5] == '~')) {
whismanoid 17:9397ea3ea7e9 5732 // L@-~~~ -- delete all rows from table
whismanoid 30:07197a430869 5733 cmdLine.serial().printf("\r\n delete all rows");
whismanoid 17:9397ea3ea7e9 5734 Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 5735 break;
whismanoid 17:9397ea3ea7e9 5736 }
whismanoid 30:07197a430869 5737 else {
whismanoid 30:07197a430869 5738 editRowIndex = atoi(cmdLine.str()+3);
whismanoid 30:07197a430869 5739 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 30:07197a430869 5740 // delete row editRowIndex from Datalogger_action_table
whismanoid 30:07197a430869 5741 for (int i = editRowIndex; i < (Datalogger_action_table_row_count-1); i++)
whismanoid 30:07197a430869 5742 {
whismanoid 30:07197a430869 5743 // copy row i+1 into row i
whismanoid 30:07197a430869 5744 Datalogger_action_table[i].action = Datalogger_action_table[i+1].action;
whismanoid 30:07197a430869 5745 Datalogger_action_table[i].digitalOutPin = Datalogger_action_table[i+1].digitalOutPin;
whismanoid 30:07197a430869 5746 Datalogger_action_table[i].condition = Datalogger_action_table[i+1].condition;
whismanoid 30:07197a430869 5747 Datalogger_action_table[i].condition_channel = Datalogger_action_table[i+1].condition_channel;
whismanoid 30:07197a430869 5748 Datalogger_action_table[i].condition_threshold = Datalogger_action_table[i+1].condition_threshold;
whismanoid 30:07197a430869 5749 }
whismanoid 30:07197a430869 5750 Datalogger_action_table_row_count--;
whismanoid 17:9397ea3ea7e9 5751 }
whismanoid 17:9397ea3ea7e9 5752 }
whismanoid 17:9397ea3ea7e9 5753 break;
whismanoid 30:07197a430869 5754 case '.':
whismanoid 30:07197a430869 5755 // L@. pause the entire Log action table
whismanoid 30:07197a430869 5756 cmdLine.serial().printf("\r\n pause the entire Log action table");
whismanoid 17:9397ea3ea7e9 5757 Datalogger_action_table_enabled = false;
whismanoid 17:9397ea3ea7e9 5758 break;
whismanoid 17:9397ea3ea7e9 5759 case '@':
whismanoid 30:07197a430869 5760 // L@@ enable the entire Log action table
whismanoid 30:07197a430869 5761 cmdLine.serial().printf("\r\n enable the entire Log action table");
whismanoid 17:9397ea3ea7e9 5762 Datalogger_action_table_enabled = true;
whismanoid 17:9397ea3ea7e9 5763 break;
whismanoid 17:9397ea3ea7e9 5764 }
whismanoid 17:9397ea3ea7e9 5765 //
whismanoid 17:9397ea3ea7e9 5766 // Print the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5767 if (Datalogger_action_table_enabled) {
whismanoid 30:07197a430869 5768 // cmdLine.serial().printf("Log action table enabled; L@. to pause");
whismanoid 17:9397ea3ea7e9 5769 }
whismanoid 17:9397ea3ea7e9 5770 else {
whismanoid 30:07197a430869 5771 cmdLine.serial().printf("Log action table paused; L@@ to enable");
whismanoid 17:9397ea3ea7e9 5772 }
whismanoid 17:9397ea3ea7e9 5773 //~ cmdLine.serial().printf("\r\n Datalogger_action_table_row_count=%d", Datalogger_action_table_row_count);
whismanoid 17:9397ea3ea7e9 5774 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 5775 {
whismanoid 17:9397ea3ea7e9 5776 cmdLine.serial().printf("\r\n L@%d", i);
whismanoid 17:9397ea3ea7e9 5777 cmdLine.serial().printf(" act=%d", Datalogger_action_table[i].action);
whismanoid 17:9397ea3ea7e9 5778 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5779 {
whismanoid 17:9397ea3ea7e9 5780 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 5781 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 5782 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5783 break;
whismanoid 29:6a9edb6e973b 5784 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 5785 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 5786 break;
whismanoid 17:9397ea3ea7e9 5787 default:
whismanoid 17:9397ea3ea7e9 5788 case action_noop:
whismanoid 17:9397ea3ea7e9 5789 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 5790 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 5791 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 5792 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 5793 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 5794 break;
whismanoid 17:9397ea3ea7e9 5795 }
whismanoid 17:9397ea3ea7e9 5796 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5797 {
whismanoid 17:9397ea3ea7e9 5798 case condition_always:
whismanoid 17:9397ea3ea7e9 5799 break;
whismanoid 17:9397ea3ea7e9 5800 default:
whismanoid 17:9397ea3ea7e9 5801 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 5802 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 5803 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 5804 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 5805 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 5806 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 5807 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 5808 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 5809 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 5810 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 5811 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 5812 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 5813 cmdLine.serial().printf(" if=%d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 5814 cmdLine.serial().printf(" ch=%d", Datalogger_action_table[i].condition_channel);
whismanoid 40:330b28116178 5815 // our voltage measurement is around 1mV at best
whismanoid 40:330b28116178 5816 cmdLine.serial().printf(" x=%1.4f", Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5817 break;
whismanoid 17:9397ea3ea7e9 5818 }
whismanoid 17:9397ea3ea7e9 5819 cmdLine.serial().printf(" -- ");
whismanoid 17:9397ea3ea7e9 5820 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5821 {
whismanoid 17:9397ea3ea7e9 5822 case action_noop:
whismanoid 17:9397ea3ea7e9 5823 cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 5824 break;
whismanoid 17:9397ea3ea7e9 5825 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 5826 cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 5827 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5828 break;
whismanoid 17:9397ea3ea7e9 5829 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 5830 cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 5831 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5832 break;
whismanoid 29:6a9edb6e973b 5833 case action_button: // pin = button index 1, 2, 3
whismanoid 40:330b28116178 5834 cmdLine.serial().printf("button %%B%d!", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 5835 break;
whismanoid 17:9397ea3ea7e9 5836 case action_trigger_Halt:
whismanoid 40:330b28116178 5837 cmdLine.serial().printf("Halt");
whismanoid 17:9397ea3ea7e9 5838 break;
whismanoid 17:9397ea3ea7e9 5839 case action_trigger_FreeRun:
whismanoid 40:330b28116178 5840 cmdLine.serial().printf("LR");
whismanoid 17:9397ea3ea7e9 5841 break;
whismanoid 17:9397ea3ea7e9 5842 case action_trigger_Timer:
whismanoid 40:330b28116178 5843 cmdLine.serial().printf("LT count=%d base=%dms sleep=%d", g_timer_interval_count, g_timer_interval_msec, g_timer_sleepmode);
whismanoid 17:9397ea3ea7e9 5844 break;
whismanoid 17:9397ea3ea7e9 5845 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 5846 cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 5847 // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 5848 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 5849 break;
whismanoid 17:9397ea3ea7e9 5850 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 5851 cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 5852 // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 5853 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 5854 break;
whismanoid 17:9397ea3ea7e9 5855 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5856 //~ cmdLine.serial().printf(" condition %d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 5857 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5858 {
whismanoid 17:9397ea3ea7e9 5859 case condition_always:
whismanoid 17:9397ea3ea7e9 5860 cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 5861 break;
whismanoid 17:9397ea3ea7e9 5862 case condition_if_An_gt_threshold:
whismanoid 40:330b28116178 5863 cmdLine.serial().printf(" if A%d > %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5864 break;
whismanoid 17:9397ea3ea7e9 5865 case condition_if_An_lt_threshold:
whismanoid 40:330b28116178 5866 cmdLine.serial().printf(" if A%d < %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5867 break;
whismanoid 17:9397ea3ea7e9 5868 case condition_if_An_eq_threshold:
whismanoid 40:330b28116178 5869 cmdLine.serial().printf(" if A%d == %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5870 break;
whismanoid 17:9397ea3ea7e9 5871 case condition_if_An_ge_threshold:
whismanoid 40:330b28116178 5872 cmdLine.serial().printf(" if A%d >= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5873 break;
whismanoid 17:9397ea3ea7e9 5874 case condition_if_An_le_threshold:
whismanoid 40:330b28116178 5875 cmdLine.serial().printf(" if A%d <= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5876 break;
whismanoid 17:9397ea3ea7e9 5877 case condition_if_An_ne_threshold:
whismanoid 40:330b28116178 5878 cmdLine.serial().printf(" if A%d != %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5879 break;
whismanoid 17:9397ea3ea7e9 5880 case condition_if_AINn_gt_threshold:
whismanoid 40:330b28116178 5881 cmdLine.serial().printf(" if AIN%d > %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5882 break;
whismanoid 17:9397ea3ea7e9 5883 case condition_if_AINn_lt_threshold:
whismanoid 40:330b28116178 5884 cmdLine.serial().printf(" if AIN%d < %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5885 break;
whismanoid 17:9397ea3ea7e9 5886 case condition_if_AINn_eq_threshold:
whismanoid 40:330b28116178 5887 cmdLine.serial().printf(" if AIN%d == %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5888 break;
whismanoid 17:9397ea3ea7e9 5889 case condition_if_AINn_ge_threshold:
whismanoid 40:330b28116178 5890 cmdLine.serial().printf(" if AIN%d >= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5891 break;
whismanoid 17:9397ea3ea7e9 5892 case condition_if_AINn_le_threshold:
whismanoid 40:330b28116178 5893 cmdLine.serial().printf(" if AIN%d <= %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5894 break;
whismanoid 17:9397ea3ea7e9 5895 case condition_if_AINn_ne_threshold:
whismanoid 40:330b28116178 5896 cmdLine.serial().printf(" if AIN%d != %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5897 break;
whismanoid 17:9397ea3ea7e9 5898 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5899 } // for ...Datalogger_action_table_row_count // Print the contents of Datalogger_action_table
whismanoid 30:07197a430869 5900 cmdLine.serial().printf("\r\n\r\nEdit Log action table (used %d/%d, %d free):",
whismanoid 30:07197a430869 5901 Datalogger_action_table_row_count,
whismanoid 30:07197a430869 5902 ACTION_TABLE_ROW_MAX,
whismanoid 30:07197a430869 5903 (ACTION_TABLE_ROW_MAX - Datalogger_action_table_row_count)
whismanoid 30:07197a430869 5904 );
whismanoid 17:9397ea3ea7e9 5905 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 5906 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 5907 cmdLine.serial().printf("\r\n L@+ act=4 if=1 ch=5 x=12345 -- add new entry at end of table");
whismanoid 17:9397ea3ea7e9 5908 }
whismanoid 17:9397ea3ea7e9 5909 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 5910 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 5911 cmdLine.serial().printf("\r\n L@%d act=4 if=1 ch=5 x=12345 -- edit row %d",
whismanoid 17:9397ea3ea7e9 5912 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 5913 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 5914 cmdLine.serial().printf("\r\n L@-%d -- delete row %d",
whismanoid 17:9397ea3ea7e9 5915 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 5916 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 5917 cmdLine.serial().printf("\r\n L@-~~~ -- delete all rows");
whismanoid 30:07197a430869 5918 if (Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@. -- pause entire Log action table");
whismanoid 30:07197a430869 5919 if (!Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@@ -- enable Log action table");
whismanoid 17:9397ea3ea7e9 5920 }
whismanoid 17:9397ea3ea7e9 5921 //
whismanoid 17:9397ea3ea7e9 5922 } // case L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5923 break;
whismanoid 17:9397ea3ea7e9 5924 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 5925 // LR -- Datalog free run as fast as possible
whismanoid 4:d9b05924ad4c 5926 case 'R': case 'r':
whismanoid 4:d9b05924ad4c 5927 // free run as fast as possible
whismanoid 8:dffee7509bfb 5928 Datalogger_Trigger = trigger_FreeRun;
whismanoid 8:dffee7509bfb 5929 Datalogger_Need_PrintHeader = true;
whismanoid 4:d9b05924ad4c 5930 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 9:45f98573eb6d 5931 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 5932 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 5933 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 5934 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 5935 case 'S': case 's':
whismanoid 9:45f98573eb6d 5936 {
whismanoid 9:45f98573eb6d 5937 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 5938 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 5939 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 5940 )
whismanoid 9:45f98573eb6d 5941 {
whismanoid 9:45f98573eb6d 5942 // it's me
whismanoid 9:45f98573eb6d 5943 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 5944 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 5945 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 5946 {
whismanoid 9:45f98573eb6d 5947 case 'D': case 'd':
whismanoid 9:45f98573eb6d 5948 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Disable;
whismanoid 9:45f98573eb6d 5949 break;
whismanoid 9:45f98573eb6d 5950 case 'L': case 'l':
whismanoid 9:45f98573eb6d 5951 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 5952 break;
whismanoid 9:45f98573eb6d 5953 case 'V': case 'v':
whismanoid 9:45f98573eb6d 5954 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 5955 break;
whismanoid 9:45f98573eb6d 5956 //
whismanoid 9:45f98573eb6d 5957 //
whismanoid 9:45f98573eb6d 5958 // TODO: MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 5959 case 'C': case 'c':
whismanoid 9:45f98573eb6d 5960 {
whismanoid 9:45f98573eb6d 5961 uint8_t hexValue = 0;
whismanoid 9:45f98573eb6d 5962 hexValue = hexValueOfChar(cmdLine[5]) * 0x10 + hexValueOfChar(cmdLine[6]);
whismanoid 9:45f98573eb6d 5963 switch (cmdLine[4])
whismanoid 9:45f98573eb6d 5964 {
whismanoid 9:45f98573eb6d 5965 //
whismanoid 9:45f98573eb6d 5966 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 5967 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34"));
whismanoid 9:45f98573eb6d 5968 case 'F': case 'f':
whismanoid 9:45f98573eb6d 5969 SPI_AIN_Cfg_v_filter_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 5970 break;
whismanoid 9:45f98573eb6d 5971 //
whismanoid 9:45f98573eb6d 5972 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 5973 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 5974 case 'C': case 'c':
whismanoid 9:45f98573eb6d 5975 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 5976 break;
whismanoid 9:45f98573eb6d 5977 //
whismanoid 9:45f98573eb6d 5978 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 5979 // cmdLine.serial().print(F("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00"));
whismanoid 9:45f98573eb6d 5980 case 'P': case 'p':
whismanoid 9:45f98573eb6d 5981 SPI_AIN_Cfg_v_pga_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 5982 break;
whismanoid 9:45f98573eb6d 5983 //
whismanoid 9:45f98573eb6d 5984 // cmdLine.serial().print(F("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar"));
whismanoid 9:45f98573eb6d 5985 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 5986 case 'U': case 'u':
whismanoid 9:45f98573eb6d 5987 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] | 0x40;
whismanoid 9:45f98573eb6d 5988 break;
whismanoid 9:45f98573eb6d 5989 //
whismanoid 9:45f98573eb6d 5990 // cmdLine.serial().print(F("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar"));
whismanoid 9:45f98573eb6d 5991 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 5992 case 'B': case 'b':
whismanoid 9:45f98573eb6d 5993 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] &~ 0x40;
whismanoid 9:45f98573eb6d 5994 break;
whismanoid 9:45f98573eb6d 5995 }
whismanoid 9:45f98573eb6d 5996 break;
whismanoid 9:45f98573eb6d 5997 }
whismanoid 9:45f98573eb6d 5998 //
whismanoid 9:45f98573eb6d 5999 //
whismanoid 9:45f98573eb6d 6000 }
whismanoid 9:45f98573eb6d 6001 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 6002 } // end for channel_index
whismanoid 9:45f98573eb6d 6003 Datalogger_PrintHeader();
whismanoid 9:45f98573eb6d 6004 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6005 }
whismanoid 9:45f98573eb6d 6006 break;
whismanoid 9:45f98573eb6d 6007 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6008 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 6009 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 6010 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 6011 // verb: D for disable, V for Voltage, L for LSB
whismanoid 8:dffee7509bfb 6012 case 'A': case 'a':
whismanoid 9:45f98573eb6d 6013 {
whismanoid 9:45f98573eb6d 6014 // all-channel: loop through all valid channel_index, test cmdLine[2] 'is it me'?
whismanoid 9:45f98573eb6d 6015 // for channel_index loop through 0..NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 9:45f98573eb6d 6016 // if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 6017 // || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 6018 // ) {
whismanoid 9:45f98573eb6d 6019 // // it's me
whismanoid 9:45f98573eb6d 6020 // // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 6021 // // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 6022 // } end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 6023 // } end for channel_index
whismanoid 9:45f98573eb6d 6024 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6025 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 6026 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 6027 )
whismanoid 9:45f98573eb6d 6028 {
whismanoid 9:45f98573eb6d 6029 // it's me
whismanoid 9:45f98573eb6d 6030 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 6031 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 6032 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 6033 {
whismanoid 9:45f98573eb6d 6034 case 'D': case 'd':
whismanoid 9:45f98573eb6d 6035 Platform_Enable_ch[channel_index] = Platform_AIN_Disable;
whismanoid 9:45f98573eb6d 6036 break;
whismanoid 9:45f98573eb6d 6037 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 6038 case 'L': case 'l':
whismanoid 9:45f98573eb6d 6039 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 6040 break;
whismanoid 9:45f98573eb6d 6041 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 6042 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 6043 case 'V': case 'v':
whismanoid 9:45f98573eb6d 6044 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 6045 break;
whismanoid 9:45f98573eb6d 6046 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 6047 }
whismanoid 9:45f98573eb6d 6048 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 6049 } // end for channel_index
whismanoid 10:04022a61b527 6050 // Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 6051 if (Datalogger_enable_serial) {
whismanoid 9:45f98573eb6d 6052 Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 6053 }
whismanoid 9:45f98573eb6d 6054 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 6055 if (Datalogger_enable_AUXserial) {
whismanoid 9:45f98573eb6d 6056 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 9:45f98573eb6d 6057 }
whismanoid 9:45f98573eb6d 6058 # endif // HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 6059 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6060 if (Datalogger_enable_DAPLINKserial) {
whismanoid 9:45f98573eb6d 6061 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 9:45f98573eb6d 6062 }
whismanoid 9:45f98573eb6d 6063 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6064 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6065 }
whismanoid 8:dffee7509bfb 6066 break;
whismanoid 9:45f98573eb6d 6067 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 6068 case '>':
whismanoid 9:45f98573eb6d 6069 // L>A -- Datalogger_enable_AUXserial
whismanoid 9:45f98573eb6d 6070 // L>D -- Datalogger_enable_DAPLINKserial
whismanoid 9:45f98573eb6d 6071 // L>S -- Datalogger_enable_serial
whismanoid 9:45f98573eb6d 6072 switch (cmdLine[2])
whismanoid 9:45f98573eb6d 6073 {
whismanoid 9:45f98573eb6d 6074 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 6075 case 'A': case 'a':
whismanoid 9:45f98573eb6d 6076 Datalogger_enable_AUXserial = !Datalogger_enable_AUXserial;
whismanoid 9:45f98573eb6d 6077 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6078 break;
whismanoid 8:dffee7509bfb 6079 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6080 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6081 case 'D': case 'd':
whismanoid 9:45f98573eb6d 6082 Datalogger_enable_DAPLINKserial = !Datalogger_enable_DAPLINKserial;
whismanoid 9:45f98573eb6d 6083 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6084 break;
whismanoid 8:dffee7509bfb 6085 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6086 case 'S': case 's':
whismanoid 9:45f98573eb6d 6087 Datalogger_enable_serial = !Datalogger_enable_serial;
whismanoid 9:45f98573eb6d 6088 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6089 break;
whismanoid 9:45f98573eb6d 6090 }
whismanoid 9:45f98573eb6d 6091 break; // case '>' L>S serial enable toggle
whismanoid 28:a9a3a9db592b 6092 default:
whismanoid 28:a9a3a9db592b 6093 // TODO: L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 6094 //
whismanoid 28:a9a3a9db592b 6095 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 6096 #if 1 // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 6097 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 6098 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 6099 //
whismanoid 28:a9a3a9db592b 6100 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 28:a9a3a9db592b 6101 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 39:4d285e961435 6102 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 6103 // TODO: USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 6104 cmdLine.serial().printf("\r\n LT count=%d base=%dms sleep=%d -- Datalog timer",
whismanoid 39:4d285e961435 6105 g_timer_interval_count,
whismanoid 39:4d285e961435 6106 g_timer_interval_msec,
whismanoid 39:4d285e961435 6107 (int)g_timer_sleepmode
whismanoid 39:4d285e961435 6108 ); // trigger_Timer
whismanoid 39:4d285e961435 6109 #else // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 6110 cmdLine.serial().printf("\r\n LT count=%d base=%dms -- Datalog timer", g_timer_interval_count, g_timer_interval_msec); // trigger_Timer
whismanoid 39:4d285e961435 6111 #endif // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 6112 //
whismanoid 28:a9a3a9db592b 6113 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 28:a9a3a9db592b 6114 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 6115 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 6116 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 6117 //
whismanoid 28:a9a3a9db592b 6118 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 6119 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 28:a9a3a9db592b 6120 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 6121 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 6122 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 6123 //
whismanoid 28:a9a3a9db592b 6124 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 6125 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 6126 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 6127 //
whismanoid 28:a9a3a9db592b 6128 //
whismanoid 28:a9a3a9db592b 6129 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 6130 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 28:a9a3a9db592b 6131 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 6132 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 6133 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 28:a9a3a9db592b 6134 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 28:a9a3a9db592b 6135 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 28:a9a3a9db592b 6136 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 28:a9a3a9db592b 6137 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 28:a9a3a9db592b 6138 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 28:a9a3a9db592b 6139 //
whismanoid 28:a9a3a9db592b 6140 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 28:a9a3a9db592b 6141 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 28:a9a3a9db592b 6142 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 28:a9a3a9db592b 6143 //
whismanoid 28:a9a3a9db592b 6144 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 6145 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 28:a9a3a9db592b 6146 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 28:a9a3a9db592b 6147 //
whismanoid 28:a9a3a9db592b 6148 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 6149 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 28:a9a3a9db592b 6150 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 6151 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 28:a9a3a9db592b 6152 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 6153 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 28:a9a3a9db592b 6154 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 6155 //
whismanoid 28:a9a3a9db592b 6156 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 28:a9a3a9db592b 6157 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 28:a9a3a9db592b 6158 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 28:a9a3a9db592b 6159 //
whismanoid 28:a9a3a9db592b 6160 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 6161 //
whismanoid 28:a9a3a9db592b 6162 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 28:a9a3a9db592b 6163 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 28:a9a3a9db592b 6164 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 6165 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 6166 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 28:a9a3a9db592b 6167 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6168 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 28:a9a3a9db592b 6169 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6170 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6171 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 28:a9a3a9db592b 6172 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6173 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 28:a9a3a9db592b 6174 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6175 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 28:a9a3a9db592b 6176 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6177 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6178 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 28:a9a3a9db592b 6179 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6180 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 6181 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 6182 # if HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 6183 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 6184 # endif // HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 6185 # if HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 6186 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 6187 # endif // HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 6188 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 6189 //
whismanoid 28:a9a3a9db592b 6190 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 6191 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 6192 break;
whismanoid 17:9397ea3ea7e9 6193 } // switch (cmdLine[1]) inside case 'L'
whismanoid 4:d9b05924ad4c 6194 }
whismanoid 4:d9b05924ad4c 6195 break; // case 'L'
whismanoid 4:d9b05924ad4c 6196 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 6197 //
whismanoid 4:d9b05924ad4c 6198 // Application-specific commands here
whismanoid 4:d9b05924ad4c 6199 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 6200 //
whismanoid 4:d9b05924ad4c 6201 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 6202 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 6203
whismanoid 4:d9b05924ad4c 6204 //
whismanoid 4:d9b05924ad4c 6205 // TODO1: add new commands here
whismanoid 4:d9b05924ad4c 6206 //
whismanoid 4:d9b05924ad4c 6207 default:
whismanoid 4:d9b05924ad4c 6208 #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6209 extern bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5715.cpp
whismanoid 4:d9b05924ad4c 6210 if (!MAX5715_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6211 #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6212 extern bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11131.cpp
whismanoid 4:d9b05924ad4c 6213 if (!MAX11131_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6214 #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6215 extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp
whismanoid 4:d9b05924ad4c 6216 if (!MAX5171_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6217 #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6218 extern bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp
whismanoid 4:d9b05924ad4c 6219 if (!MAX11410_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6220 #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6221 extern bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX12345.cpp
whismanoid 4:d9b05924ad4c 6222 if (!MAX12345_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6223 #else
whismanoid 4:d9b05924ad4c 6224 if (0) // not_handled_by_device_submenu
whismanoid 4:d9b05924ad4c 6225 #endif
whismanoid 4:d9b05924ad4c 6226 {
whismanoid 4:d9b05924ad4c 6227 cmdLine.serial().printf("\r\n unknown command ");
whismanoid 4:d9b05924ad4c 6228 //~ cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 6229 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 6230 cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n",
whismanoid 4:d9b05924ad4c 6231 cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 6232 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6233 }
whismanoid 4:d9b05924ad4c 6234 } // switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 6235 //
whismanoid 31:47eee7e0cc2d 6236 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 6237 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 6238 // print command prompt
whismanoid 8:dffee7509bfb 6239 // print_command_prompt();
whismanoid 8:dffee7509bfb 6240 cmdLine.serial().printf("\r\n> ");
whismanoid 31:47eee7e0cc2d 6241 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 6242 }
whismanoid 4:d9b05924ad4c 6243 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 6244
whismanoid 4:d9b05924ad4c 6245 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 6246 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 6247 void Datalogger_PrintHeader(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 6248 {
whismanoid 37:3f369235e5bc 6249 #if MAX40108_DEMO // main_menu_status banner
whismanoid 37:3f369235e5bc 6250 cmdLine.serial().printf("\r\n\r\n\"MAX40108_U%d", MAX40108_DEMO);
whismanoid 37:3f369235e5bc 6251 #ifdef BOARD_SERIAL_NUMBER
whismanoid 37:3f369235e5bc 6252 // data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 6253 cmdLine.serial().printf(" [s/n %d]", BOARD_SERIAL_NUMBER);
whismanoid 37:3f369235e5bc 6254 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 6255 #ifdef FW_REV
whismanoid 37:3f369235e5bc 6256 cmdLine.serial().printf(" [FW_REV %d]", FW_REV);
whismanoid 37:3f369235e5bc 6257 #endif // FW_REV
whismanoid 37:3f369235e5bc 6258 cmdLine.serial().printf("\"\r\n");
whismanoid 37:3f369235e5bc 6259 #endif // MAX40108_DEMO
whismanoid 37:3f369235e5bc 6260
whismanoid 4:d9b05924ad4c 6261 // column header banner for csv data columns
whismanoid 4:d9b05924ad4c 6262 int field_index = 0;
whismanoid 4:d9b05924ad4c 6263 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6264 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 6265 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 4:d9b05924ad4c 6266 continue;
whismanoid 4:d9b05924ad4c 6267 }
whismanoid 4:d9b05924ad4c 6268 // comma between fields
whismanoid 4:d9b05924ad4c 6269 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 6270 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 6271 }
whismanoid 10:04022a61b527 6272 field_index++;
whismanoid 4:d9b05924ad4c 6273 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 6274 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 6275 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 4:d9b05924ad4c 6276 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 4:d9b05924ad4c 6277 cmdLine.serial().printf("\"AIN%d-%d_BIP", channel_index, channel_index+1);
whismanoid 4:d9b05924ad4c 6278 }
whismanoid 4:d9b05924ad4c 6279 else {
whismanoid 4:d9b05924ad4c 6280 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 6281 }
whismanoid 4:d9b05924ad4c 6282 #else // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 6283 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 6284 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 6285 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_LSB) {
whismanoid 4:d9b05924ad4c 6286 // _LSB column header suffix
whismanoid 13:184a08909405 6287 cmdLine.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 6288 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6289 cmdLine_DAPLINKserial.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 6290 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6291 }
whismanoid 10:04022a61b527 6292 else if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_Volt) {
whismanoid 4:d9b05924ad4c 6293 // _V column header suffix
whismanoid 13:184a08909405 6294 cmdLine.serial().printf("_V");
whismanoid 4:d9b05924ad4c 6295 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6296 cmdLine_DAPLINKserial.serial().printf("_V");
whismanoid 4:d9b05924ad4c 6297 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6298 }
whismanoid 13:184a08909405 6299 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6300 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6301 if (SPI_AIN_customChannelHeader_ch[channel_index] && SPI_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 6302 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 6303 cmdLine.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6304 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6305 cmdLine_DAPLINKserial.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6306 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6307 } else {
whismanoid 13:184a08909405 6308 // no custom channel name for this channel
whismanoid 13:184a08909405 6309 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 6310 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6311 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 6312 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6313 }
whismanoid 13:184a08909405 6314 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 6315 // close quote
whismanoid 13:184a08909405 6316 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 6317 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6318 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 6319 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6320 }
whismanoid 4:d9b05924ad4c 6321
whismanoid 4:d9b05924ad4c 6322 #if VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 6323 // PART_ID field: Device ID Validation
whismanoid 4:d9b05924ad4c 6324 cmdLine.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 6325 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6326 cmdLine_DAPLINKserial.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 6327 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6328 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 6329 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 6330 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 6331 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6332 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 6333 continue;
whismanoid 9:45f98573eb6d 6334 }
whismanoid 4:d9b05924ad4c 6335 // comma between fields
whismanoid 4:d9b05924ad4c 6336 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 6337 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 6338 }
whismanoid 9:45f98573eb6d 6339 field_index++;
whismanoid 4:d9b05924ad4c 6340 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 6341 cmdLine.serial().printf("\"A%d", channel_index);
whismanoid 9:45f98573eb6d 6342 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 9:45f98573eb6d 6343 // _LSB column header suffix
whismanoid 13:184a08909405 6344 cmdLine.serial().printf("_LSB");
whismanoid 9:45f98573eb6d 6345 }
whismanoid 9:45f98573eb6d 6346 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 6347 // _V column header suffix
whismanoid 13:184a08909405 6348 cmdLine.serial().printf("_V");
whismanoid 9:45f98573eb6d 6349 }
whismanoid 13:184a08909405 6350 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6351 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6352 if (Platform_AIN_customChannelHeader_ch[channel_index] && Platform_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 6353 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 6354 cmdLine.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6355 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6356 cmdLine_DAPLINKserial.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6357 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6358 } else {
whismanoid 13:184a08909405 6359 // no custom channel name for this channel
whismanoid 13:184a08909405 6360 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 6361 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6362 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 6363 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6364 }
whismanoid 13:184a08909405 6365 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 6366 // close quote
whismanoid 13:184a08909405 6367 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 6368 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6369 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 6370 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6371 }
whismanoid 4:d9b05924ad4c 6372 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 30:07197a430869 6373 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 6374 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in Datalogger_PrintHeader
whismanoid 30:07197a430869 6375 cmdLine.serial().printf(",\"%s\"", gstrRemarkHeader);
whismanoid 30:07197a430869 6376 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 4:d9b05924ad4c 6377 // end of column header line
whismanoid 4:d9b05924ad4c 6378 cmdLine.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 6379 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6380 cmdLine_DAPLINKserial.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 6381 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6382 } // void Datalogger_PrintHeader()
whismanoid 4:d9b05924ad4c 6383
whismanoid 5:aaf8b5f5fda1 6384 //--------------------------------------------------
whismanoid 5:aaf8b5f5fda1 6385 void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 6386 {
whismanoid 5:aaf8b5f5fda1 6387 // CODE GENERATOR: example code: has no member function ScanStandardExternalClock
whismanoid 5:aaf8b5f5fda1 6388 // CODE GENERATOR: example code: has no member function ReadAINcode
whismanoid 5:aaf8b5f5fda1 6389 // CODE GENERATOR: example code: member function Read_All_Voltages
whismanoid 5:aaf8b5f5fda1 6390 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6391 // Measure ADC channels in sequence from AIN0 to channelNumber_0_9.
whismanoid 5:aaf8b5f5fda1 6392 // @param[in] g_MAX11410_device.channelNumber_0_15: AIN Channel Number
whismanoid 5:aaf8b5f5fda1 6393 // @param[in] g_MAX11410_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
whismanoid 5:aaf8b5f5fda1 6394 // @param[in] g_MAX11410_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
whismanoid 10:04022a61b527 6395 //~ int channelId_0_9 = NUM_DUT_ANALOG_IN_CHANNELS-1+1;
whismanoid 5:aaf8b5f5fda1 6396 //g_MAX11410_device.channelNumber_0_15 = channelId_0_9;
whismanoid 5:aaf8b5f5fda1 6397 //g_MAX11410_device.PowerManagement_0_2 = 0;
whismanoid 5:aaf8b5f5fda1 6398 //g_MAX11410_device.chan_id_0_1 = 1;
whismanoid 5:aaf8b5f5fda1 6399 //----------------------------------------
whismanoid 5:aaf8b5f5fda1 6400 // scan AIN0..AIN9
whismanoid 5:aaf8b5f5fda1 6401 //
whismanoid 10:04022a61b527 6402 #if 1
whismanoid 10:04022a61b527 6403 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 6404 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 6405 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 6406 //
whismanoid 10:04022a61b527 6407 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6408 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc3); // GP1 = 0
whismanoid 10:04022a61b527 6409 //
whismanoid 10:04022a61b527 6410 int field_index = 0;
whismanoid 10:04022a61b527 6411 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 6412 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 10:04022a61b527 6413 continue;
whismanoid 10:04022a61b527 6414 }
whismanoid 10:04022a61b527 6415 field_index++;
whismanoid 10:04022a61b527 6416 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[channel_index];
whismanoid 10:04022a61b527 6417 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[channel_index];
whismanoid 10:04022a61b527 6418 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[channel_index];
whismanoid 10:04022a61b527 6419 //
whismanoid 10:04022a61b527 6420 // WIP SampleRate_of_FILTER_CONV_START() MAX11410EMC-FW slow ODR 10Sps #262
whismanoid 10:04022a61b527 6421 // adjust the MAX11410.loop_limit value if the sample rate is set to a value slower than 20sps
whismanoid 10:04022a61b527 6422 // SampleRate_of_FILTER_CONV_START(uint8_t FILTER_RegValue, uint8_t CONV_START_RegValue)
whismanoid 10:04022a61b527 6423 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 6424 if (SampleRate < 20.0) {
whismanoid 10:04022a61b527 6425 g_MAX11410_device.loop_limit = 32767; // TODO: is this timeout long enough for the slow output data rates?
whismanoid 10:04022a61b527 6426 }
whismanoid 10:04022a61b527 6427 //
whismanoid 10:04022a61b527 6428 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6429 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc3); // GP0 = 0
whismanoid 10:04022a61b527 6430 //
whismanoid 10:04022a61b527 6431 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 6432 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 10:04022a61b527 6433 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 10:04022a61b527 6434 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 6435 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = (MAX11410::MAX11410_AINN_SEL_enum_t)(channel_index^1);
whismanoid 10:04022a61b527 6436 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 6437 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 6438 }
whismanoid 10:04022a61b527 6439 else {
whismanoid 10:04022a61b527 6440 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 6441 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = MAX11410::AINN_SEL_1010_GND;
whismanoid 10:04022a61b527 6442 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 6443 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 6444 }
whismanoid 10:04022a61b527 6445 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 6446 //
whismanoid 10:04022a61b527 6447 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6448 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc4); // GP0 = 1
whismanoid 10:04022a61b527 6449 //
whismanoid 10:04022a61b527 6450 }
whismanoid 10:04022a61b527 6451 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6452 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc4); // GP1 = 1
whismanoid 10:04022a61b527 6453 #else
whismanoid 5:aaf8b5f5fda1 6454 g_MAX11410_device.Read_All_Voltages();
whismanoid 10:04022a61b527 6455 #endif
whismanoid 10:04022a61b527 6456 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6457 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 6458 // mbed
whismanoid 5:aaf8b5f5fda1 6459 // Platform board uses simple analog inputs
whismanoid 5:aaf8b5f5fda1 6460 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 5:aaf8b5f5fda1 6461 Platform_LSB[0] = analogIn0.read();
whismanoid 5:aaf8b5f5fda1 6462 Platform_LSB[1] = analogIn1.read();
whismanoid 5:aaf8b5f5fda1 6463 Platform_LSB[2] = analogIn2.read();
whismanoid 5:aaf8b5f5fda1 6464 Platform_LSB[3] = analogIn3.read();
whismanoid 5:aaf8b5f5fda1 6465 Platform_LSB[4] = analogIn4.read();
whismanoid 5:aaf8b5f5fda1 6466 Platform_LSB[5] = analogIn5.read();
whismanoid 10:04022a61b527 6467 #endif
whismanoid 10:04022a61b527 6468 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 37:3f369235e5bc 6469 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 6470 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogIn012345.read()
whismanoid 37:3f369235e5bc 6471 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 6472 float analogIn0_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6473 float analogIn1_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6474 float analogIn2_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6475 float analogIn3_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6476 float analogIn4_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6477 float analogIn5_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6478 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 6479 analogIn0_normValue_0_1 = analogIn0_normValue_0_1 + analogIn0.read();
whismanoid 37:3f369235e5bc 6480 analogIn1_normValue_0_1 = analogIn1_normValue_0_1 + analogIn1.read();
whismanoid 37:3f369235e5bc 6481 analogIn2_normValue_0_1 = analogIn2_normValue_0_1 + analogIn2.read();
whismanoid 37:3f369235e5bc 6482 analogIn3_normValue_0_1 = analogIn3_normValue_0_1 + analogIn3.read();
whismanoid 37:3f369235e5bc 6483 analogIn4_normValue_0_1 = analogIn4_normValue_0_1 + analogIn4.read();
whismanoid 37:3f369235e5bc 6484 analogIn5_normValue_0_1 = analogIn5_normValue_0_1 + analogIn5.read();
whismanoid 37:3f369235e5bc 6485 }
whismanoid 37:3f369235e5bc 6486 analogIn0_normValue_0_1 = analogIn0_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6487 analogIn1_normValue_0_1 = analogIn1_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6488 analogIn2_normValue_0_1 = analogIn2_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6489 analogIn3_normValue_0_1 = analogIn3_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6490 analogIn4_normValue_0_1 = analogIn4_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6491 analogIn5_normValue_0_1 = analogIn5_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6492 #else // USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 6493 float analogIn0_normValue_0_1 = analogIn0.read();
whismanoid 37:3f369235e5bc 6494 float analogIn1_normValue_0_1 = analogIn1.read();
whismanoid 37:3f369235e5bc 6495 float analogIn2_normValue_0_1 = analogIn2.read();
whismanoid 37:3f369235e5bc 6496 float analogIn3_normValue_0_1 = analogIn3.read();
whismanoid 37:3f369235e5bc 6497 float analogIn4_normValue_0_1 = analogIn4.read();
whismanoid 37:3f369235e5bc 6498 float analogIn5_normValue_0_1 = analogIn5.read();
whismanoid 37:3f369235e5bc 6499 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 6500 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 6501 // apply calibration to normValue_0_1 value
whismanoid 37:3f369235e5bc 6502 Platform_Voltage[0] = CalibratedNormValue(0, analogIn0_normValue_0_1) * adc_full_scale_voltage[0];
whismanoid 37:3f369235e5bc 6503 Platform_Voltage[1] = CalibratedNormValue(1, analogIn1_normValue_0_1) * adc_full_scale_voltage[1];
whismanoid 37:3f369235e5bc 6504 Platform_Voltage[2] = CalibratedNormValue(2, analogIn2_normValue_0_1) * adc_full_scale_voltage[2];
whismanoid 37:3f369235e5bc 6505 Platform_Voltage[3] = CalibratedNormValue(3, analogIn3_normValue_0_1) * adc_full_scale_voltage[3];
whismanoid 37:3f369235e5bc 6506 Platform_Voltage[4] = CalibratedNormValue(4, analogIn4_normValue_0_1) * adc_full_scale_voltage[4];
whismanoid 37:3f369235e5bc 6507 Platform_Voltage[5] = CalibratedNormValue(5, analogIn5_normValue_0_1) * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 6508 #else // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 6509 Platform_Voltage[0] = analogIn0_normValue_0_1 * adc_full_scale_voltage[0];
whismanoid 37:3f369235e5bc 6510 Platform_Voltage[1] = analogIn1_normValue_0_1 * adc_full_scale_voltage[1];
whismanoid 37:3f369235e5bc 6511 Platform_Voltage[2] = analogIn2_normValue_0_1 * adc_full_scale_voltage[2];
whismanoid 37:3f369235e5bc 6512 Platform_Voltage[3] = analogIn3_normValue_0_1 * adc_full_scale_voltage[3];
whismanoid 37:3f369235e5bc 6513 Platform_Voltage[4] = analogIn4_normValue_0_1 * adc_full_scale_voltage[4];
whismanoid 37:3f369235e5bc 6514 Platform_Voltage[5] = analogIn5_normValue_0_1 * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 6515 #endif // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 6516 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 5:aaf8b5f5fda1 6517 #endif // defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 6518
whismanoid 5:aaf8b5f5fda1 6519 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6520 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 6521 const uint32_t part_id_expect = 0x000F02;
whismanoid 5:aaf8b5f5fda1 6522 uint32_t part_id_readback;
whismanoid 5:aaf8b5f5fda1 6523 g_MAX11410_device.RegRead(MAX11410::CMD_r001_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xddd_PART_ID, &part_id_readback);
whismanoid 5:aaf8b5f5fda1 6524 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6525 } // void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 6526
whismanoid 17:9397ea3ea7e9 6527 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6528 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 6529 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 6530 void Datalogger_RunActionTable()
whismanoid 17:9397ea3ea7e9 6531 {
whismanoid 17:9397ea3ea7e9 6532 if (Datalogger_action_table_enabled == false) {
whismanoid 17:9397ea3ea7e9 6533 return;
whismanoid 17:9397ea3ea7e9 6534 }
whismanoid 17:9397ea3ea7e9 6535 // TODO: verbose Datalogger_RunActionTable() emit a csv column ,"Action"
whismanoid 17:9397ea3ea7e9 6536 // TODO: assert Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX
whismanoid 17:9397ea3ea7e9 6537 // for Datalogger_action_table[0..Datalogger_action_table_row_count]
whismanoid 17:9397ea3ea7e9 6538 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 6539 {
whismanoid 17:9397ea3ea7e9 6540 // skip if Datalogger_action_table[i].action == action_noop
whismanoid 17:9397ea3ea7e9 6541 if (Datalogger_action_table[i].action == action_noop) {
whismanoid 17:9397ea3ea7e9 6542 continue;
whismanoid 17:9397ea3ea7e9 6543 }
whismanoid 17:9397ea3ea7e9 6544 // TODO: test Datalogger_action_table[i].condition "if="
whismanoid 17:9397ea3ea7e9 6545 // TODO: Could the .condition field also distinguish Platform ADC from SPI ADC?
whismanoid 17:9397ea3ea7e9 6546 // That way we keep both sets of ADC channels in separate lists
whismanoid 17:9397ea3ea7e9 6547 // if=0 -- always
whismanoid 17:9397ea3ea7e9 6548 // if=1,2,3,4,5,6 -- Platform_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 6549 // if=7,8,9,10,11,12 -- SPI_AIN_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 6550 // also, are we comparing code or voltage?
whismanoid 17:9397ea3ea7e9 6551 // TODO: selected Datalogger_action_table[i].condition_channel
whismanoid 17:9397ea3ea7e9 6552 // Datalogger could have both platform ADC and external SPI ADC channels
whismanoid 17:9397ea3ea7e9 6553 // if SPI_ADC_DeviceName
whismanoid 17:9397ea3ea7e9 6554 // NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 6555 // SPI_AIN_Enable_ch[]
whismanoid 17:9397ea3ea7e9 6556 // SPI_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 6557 // SPI_AIN_Voltage[]
whismanoid 17:9397ea3ea7e9 6558 // if LOG_PLATFORM_AIN
whismanoid 17:9397ea3ea7e9 6559 // NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 6560 // analogInPin_fullScaleVoltage[]
whismanoid 17:9397ea3ea7e9 6561 // Platform_Enable_ch[]
whismanoid 17:9397ea3ea7e9 6562 // Platform_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 6563 // Platform_Voltage[]
whismanoid 17:9397ea3ea7e9 6564 // TODO: selected Datalogger_action_table[i].condition_threshold
whismanoid 17:9397ea3ea7e9 6565 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6566 {
whismanoid 17:9397ea3ea7e9 6567 case condition_always:
whismanoid 17:9397ea3ea7e9 6568 //~ cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 6569 break;
whismanoid 17:9397ea3ea7e9 6570 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 6571 //~ cmdLine.serial().printf(" if A%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6572 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6573 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6574 continue;
whismanoid 17:9397ea3ea7e9 6575 }
whismanoid 17:9397ea3ea7e9 6576 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6577 break;
whismanoid 17:9397ea3ea7e9 6578 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 6579 //~ cmdLine.serial().printf(" if A%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6580 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6581 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6582 continue;
whismanoid 17:9397ea3ea7e9 6583 }
whismanoid 17:9397ea3ea7e9 6584 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6585 break;
whismanoid 17:9397ea3ea7e9 6586 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 6587 //~ cmdLine.serial().printf(" if A%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6588 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6589 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6590 continue;
whismanoid 17:9397ea3ea7e9 6591 }
whismanoid 17:9397ea3ea7e9 6592 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6593 break;
whismanoid 17:9397ea3ea7e9 6594 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 6595 //~ cmdLine.serial().printf(" if A%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6596 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6597 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6598 continue;
whismanoid 17:9397ea3ea7e9 6599 }
whismanoid 17:9397ea3ea7e9 6600 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6601 break;
whismanoid 17:9397ea3ea7e9 6602 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 6603 //~ cmdLine.serial().printf(" if A%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6604 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6605 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6606 continue;
whismanoid 17:9397ea3ea7e9 6607 }
whismanoid 17:9397ea3ea7e9 6608 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6609 break;
whismanoid 17:9397ea3ea7e9 6610 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 6611 //~ cmdLine.serial().printf(" if A%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6612 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6613 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6614 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6615 continue;
whismanoid 17:9397ea3ea7e9 6616 }
whismanoid 17:9397ea3ea7e9 6617 break;
whismanoid 17:9397ea3ea7e9 6618 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 6619 //~ cmdLine.serial().printf(" if AIN%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6620 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6621 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6622 continue;
whismanoid 17:9397ea3ea7e9 6623 }
whismanoid 17:9397ea3ea7e9 6624 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6625 break;
whismanoid 17:9397ea3ea7e9 6626 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 6627 //~ cmdLine.serial().printf(" if AIN%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6628 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6629 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6630 continue;
whismanoid 17:9397ea3ea7e9 6631 }
whismanoid 17:9397ea3ea7e9 6632 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6633 break;
whismanoid 17:9397ea3ea7e9 6634 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 6635 //~ cmdLine.serial().printf(" if AIN%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6636 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6637 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6638 continue;
whismanoid 17:9397ea3ea7e9 6639 }
whismanoid 17:9397ea3ea7e9 6640 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6641 break;
whismanoid 17:9397ea3ea7e9 6642 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 6643 //~ cmdLine.serial().printf(" if AIN%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6644 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6645 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6646 continue;
whismanoid 17:9397ea3ea7e9 6647 }
whismanoid 17:9397ea3ea7e9 6648 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6649 break;
whismanoid 17:9397ea3ea7e9 6650 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 6651 //~ cmdLine.serial().printf(" if AIN%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6652 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6653 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6654 continue;
whismanoid 17:9397ea3ea7e9 6655 }
whismanoid 17:9397ea3ea7e9 6656 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6657 break;
whismanoid 17:9397ea3ea7e9 6658 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 6659 //~ cmdLine.serial().printf(" if AIN%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6660 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6661 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6662 continue;
whismanoid 17:9397ea3ea7e9 6663 }
whismanoid 17:9397ea3ea7e9 6664 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6665 break;
whismanoid 17:9397ea3ea7e9 6666 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6667 // selected Datalogger_action_table[i].digitalOutPin
whismanoid 17:9397ea3ea7e9 6668 // perform selected Datalogger_action_table[i].action
whismanoid 17:9397ea3ea7e9 6669 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6670 {
whismanoid 17:9397ea3ea7e9 6671 case action_noop:
whismanoid 17:9397ea3ea7e9 6672 //~ cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 6673 break;
whismanoid 17:9397ea3ea7e9 6674 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 6675 {
whismanoid 17:9397ea3ea7e9 6676 //~ cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 6677 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6678 // perform action digitalOutLow
whismanoid 17:9397ea3ea7e9 6679 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 6680 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 6681 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6682 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6683 #else
whismanoid 17:9397ea3ea7e9 6684 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 6685 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 6686 digitalInOutPin.write(0);
whismanoid 17:9397ea3ea7e9 6687 #endif
whismanoid 17:9397ea3ea7e9 6688 }
whismanoid 17:9397ea3ea7e9 6689 break;
whismanoid 17:9397ea3ea7e9 6690 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 6691 {
whismanoid 17:9397ea3ea7e9 6692 //~ cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 6693 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6694 // perform action digitalOutHigh
whismanoid 17:9397ea3ea7e9 6695 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 6696 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 6697 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6698 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6699 #else
whismanoid 17:9397ea3ea7e9 6700 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 6701 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 6702 digitalInOutPin.write(1);
whismanoid 17:9397ea3ea7e9 6703 #endif
whismanoid 17:9397ea3ea7e9 6704 }
whismanoid 17:9397ea3ea7e9 6705 break;
whismanoid 29:6a9edb6e973b 6706 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6707 {
whismanoid 30:07197a430869 6708 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 6709 Datalogger_Trigger_enum_t saved_Datalogger_Trigger = Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 6710 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6711 switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6712 {
whismanoid 29:6a9edb6e973b 6713 case 1:
whismanoid 29:6a9edb6e973b 6714 onButton1FallingEdge();
whismanoid 29:6a9edb6e973b 6715 break;
whismanoid 29:6a9edb6e973b 6716 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6717 case 2:
whismanoid 29:6a9edb6e973b 6718 onButton2FallingEdge();
whismanoid 29:6a9edb6e973b 6719 break;
whismanoid 29:6a9edb6e973b 6720 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6721 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6722 case 3:
whismanoid 29:6a9edb6e973b 6723 onButton3FallingEdge();
whismanoid 29:6a9edb6e973b 6724 break;
whismanoid 29:6a9edb6e973b 6725 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6726 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6727 case 4:
whismanoid 29:6a9edb6e973b 6728 onButton4FallingEdge();
whismanoid 29:6a9edb6e973b 6729 break;
whismanoid 29:6a9edb6e973b 6730 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6731 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6732 case 5:
whismanoid 29:6a9edb6e973b 6733 onButton5FallingEdge();
whismanoid 29:6a9edb6e973b 6734 break;
whismanoid 29:6a9edb6e973b 6735 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6736 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6737 case 6:
whismanoid 29:6a9edb6e973b 6738 onButton6FallingEdge();
whismanoid 29:6a9edb6e973b 6739 break;
whismanoid 29:6a9edb6e973b 6740 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6741 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6742 case 7:
whismanoid 29:6a9edb6e973b 6743 onButton7FallingEdge();
whismanoid 29:6a9edb6e973b 6744 break;
whismanoid 29:6a9edb6e973b 6745 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6746 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6747 case 8:
whismanoid 29:6a9edb6e973b 6748 onButton8FallingEdge();
whismanoid 29:6a9edb6e973b 6749 break;
whismanoid 29:6a9edb6e973b 6750 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6751 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6752 case 9:
whismanoid 29:6a9edb6e973b 6753 onButton9FallingEdge();
whismanoid 29:6a9edb6e973b 6754 break;
whismanoid 29:6a9edb6e973b 6755 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6756 } // switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6757 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 30:07197a430869 6758 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 6759 Datalogger_Trigger = saved_Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 6760 } // case action_button
whismanoid 29:6a9edb6e973b 6761 break;
whismanoid 17:9397ea3ea7e9 6762 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 6763 //~ cmdLine.serial().printf("trigger_Halt");
whismanoid 17:9397ea3ea7e9 6764 // perform action trigger_Halt
whismanoid 17:9397ea3ea7e9 6765 Datalogger_Trigger = trigger_Halt;
whismanoid 17:9397ea3ea7e9 6766 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6767 break;
whismanoid 17:9397ea3ea7e9 6768 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 6769 //~ cmdLine.serial().printf("trigger_FreeRun");
whismanoid 17:9397ea3ea7e9 6770 // perform action trigger_FreeRun
whismanoid 17:9397ea3ea7e9 6771 Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 6772 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6773 break;
whismanoid 17:9397ea3ea7e9 6774 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 6775 //~ cmdLine.serial().printf("trigger_Timer");
whismanoid 17:9397ea3ea7e9 6776 //~ // print configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 6777 //~ cmdLine.serial().printf("(%d x %dmsec)", g_timer_interval_count, g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 6778 // perform action trigger_Timer
whismanoid 17:9397ea3ea7e9 6779 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 6780 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6781 break;
whismanoid 17:9397ea3ea7e9 6782 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 6783 //~ cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 6784 //~ // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 6785 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 6786 // TODO: perform action action_trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 6787 Datalogger_Trigger = trigger_PlatformDigitalInput;
whismanoid 17:9397ea3ea7e9 6788 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6789 break;
whismanoid 17:9397ea3ea7e9 6790 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 6791 //~ cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 6792 //~ // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6793 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 6794 // TODO: perform action action_trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6795 Datalogger_Trigger = trigger_SPIDeviceRegRead;
whismanoid 17:9397ea3ea7e9 6796 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6797 break;
whismanoid 17:9397ea3ea7e9 6798 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6799 // consider next row of action table
whismanoid 17:9397ea3ea7e9 6800 } // for ...Datalogger_action_table_row_count
whismanoid 17:9397ea3ea7e9 6801 }
whismanoid 17:9397ea3ea7e9 6802 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6803
whismanoid 5:aaf8b5f5fda1 6804 //--------------------------------------------------
whismanoid 8:dffee7509bfb 6805 void Datalogger_PrintRow(CmdLine& cmdLine)
whismanoid 5:aaf8b5f5fda1 6806 {
whismanoid 5:aaf8b5f5fda1 6807 int field_index = 0;
whismanoid 5:aaf8b5f5fda1 6808 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6809 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 6810 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 5:aaf8b5f5fda1 6811 continue;
whismanoid 5:aaf8b5f5fda1 6812 }
whismanoid 5:aaf8b5f5fda1 6813 // comma between fields
whismanoid 5:aaf8b5f5fda1 6814 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 6815 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 6816 }
whismanoid 10:04022a61b527 6817 field_index++;
whismanoid 10:04022a61b527 6818 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 10:04022a61b527 6819 cmdLine.serial().printf("%d", g_MAX11410_device.AINcode[channel_index]);
whismanoid 10:04022a61b527 6820 }
whismanoid 10:04022a61b527 6821 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 10:04022a61b527 6822 // TODO: report Voltage instead of LSB
whismanoid 10:04022a61b527 6823 // Serial.print(SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 6824 static char strOutLineBuffer[16];
whismanoid 10:04022a61b527 6825 cmdLine.serial().printf("%6.6f", SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 6826 }
whismanoid 5:aaf8b5f5fda1 6827 }
whismanoid 5:aaf8b5f5fda1 6828 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6829 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 6830 if (part_id_readback != part_id_expect) {
whismanoid 5:aaf8b5f5fda1 6831 cmdLine.serial().printf(",\"FAIL\"");
whismanoid 9:45f98573eb6d 6832 need_reinit = true;
whismanoid 5:aaf8b5f5fda1 6833 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6834 g_MAX11410_device.Init();
whismanoid 5:aaf8b5f5fda1 6835 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 5:aaf8b5f5fda1 6836 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 5:aaf8b5f5fda1 6837 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 5:aaf8b5f5fda1 6838 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6839 }
whismanoid 5:aaf8b5f5fda1 6840 else {
whismanoid 5:aaf8b5f5fda1 6841 cmdLine.serial().printf(",\"OK\"");
whismanoid 5:aaf8b5f5fda1 6842 }
whismanoid 5:aaf8b5f5fda1 6843 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6844 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6845 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 6846 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6847 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 6848 continue;
whismanoid 9:45f98573eb6d 6849 }
whismanoid 5:aaf8b5f5fda1 6850 // comma between fields
whismanoid 5:aaf8b5f5fda1 6851 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 6852 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 6853 }
whismanoid 9:45f98573eb6d 6854 field_index++;
whismanoid 9:45f98573eb6d 6855 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 5:aaf8b5f5fda1 6856 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 6857 cmdLine.serial().printf("%u", Platform_LSB[channel_index]);
whismanoid 9:45f98573eb6d 6858 #endif
whismanoid 9:45f98573eb6d 6859 }
whismanoid 9:45f98573eb6d 6860 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 6861 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 11:2b8adc78618a 6862 // Datalog Volts omit V suffix from numbers #275
whismanoid 11:2b8adc78618a 6863 // because Excel graphs can't handle numbers that have a suffix.
whismanoid 11:2b8adc78618a 6864 cmdLine.serial().printf("%6.6f", Platform_Voltage[channel_index]);
whismanoid 9:45f98573eb6d 6865 #endif
whismanoid 9:45f98573eb6d 6866 }
whismanoid 5:aaf8b5f5fda1 6867 }
whismanoid 5:aaf8b5f5fda1 6868 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 6869 if (need_reinit) {
whismanoid 9:45f98573eb6d 6870 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6871 if (g_MAX11410_device.Init() == 0) {
whismanoid 9:45f98573eb6d 6872 //~ cmdLine.serial().printf(",\"Init() failed\"");
whismanoid 9:45f98573eb6d 6873 } else {
whismanoid 9:45f98573eb6d 6874 //~ cmdLine.serial().printf(",\"Init() success\"");
whismanoid 9:45f98573eb6d 6875 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 6876 // in Datalogger_PrintRow(), when part_id test fails,
whismanoid 9:45f98573eb6d 6877 // apply list of custom register writes after re-init
whismanoid 9:45f98573eb6d 6878 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 6879 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 9:45f98573eb6d 6880 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 9:45f98573eb6d 6881 uint32_t regData = custom_reg_init_data[index];
whismanoid 9:45f98573eb6d 6882 cmdLine.serial().printf("*%s=0x%06.6x", g_MAX11410_device.RegName(regAddress), regData);
whismanoid 9:45f98573eb6d 6883 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 9:45f98573eb6d 6884 }
whismanoid 9:45f98573eb6d 6885 #endif // USE_CUSTOM_REG_INIT
whismanoid 9:45f98573eb6d 6886 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 9:45f98573eb6d 6887 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 9:45f98573eb6d 6888 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 9:45f98573eb6d 6889 need_reinit = false;
whismanoid 9:45f98573eb6d 6890 }
whismanoid 9:45f98573eb6d 6891 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6892 need_reinit = false;
whismanoid 9:45f98573eb6d 6893 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6894 }
whismanoid 30:07197a430869 6895 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 6896 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in void Datalogger_PrintRow()
whismanoid 30:07197a430869 6897 cmdLine.serial().printf(",\"%s\"", gstrRemarkText);
whismanoid 30:07197a430869 6898 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 5:aaf8b5f5fda1 6899 cmdLine.serial().printf("\r\n");
whismanoid 9:45f98573eb6d 6900 if (need_reinit) {
whismanoid 9:45f98573eb6d 6901 //~ delay(500); // platform_delay_ms 500ms timing delay function
whismanoid 9:45f98573eb6d 6902 }
whismanoid 5:aaf8b5f5fda1 6903 } // void Datalogger_PrintRow()
whismanoid 5:aaf8b5f5fda1 6904
whismanoid 0:cb44e2e9ec4c 6905 // example code main function
whismanoid 0:cb44e2e9ec4c 6906 int main()
whismanoid 0:cb44e2e9ec4c 6907 {
whismanoid 0:cb44e2e9ec4c 6908 // setup: put your setup code here, to run once
whismanoid 4:d9b05924ad4c 6909 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 6910 // Configure serial ports
whismanoid 4:d9b05924ad4c 6911 cmdLine.clear();
whismanoid 4:d9b05924ad4c 6912 //~ cmdLine.serial().printf("\r\n cmdLine.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 6913 cmdLine.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 6914 //~ cmdLine.diagnostic_led_EOF = diagnostic_led_EOF;
whismanoid 4:d9b05924ad4c 6915 /// CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21);
whismanoid 4:d9b05924ad4c 6916 //~ cmdLine.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 6917 //~ cmdLine.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 6918 //~ cmdLine.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 6919 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6920 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6921 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 6922 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 6923 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 6924 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 6925 # else
whismanoid 10:04022a61b527 6926 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 6927 DAPLINKserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6928 # endif
whismanoid 10:04022a61b527 6929 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 6930 cmdLine_DAPLINKserial.clear();
whismanoid 4:d9b05924ad4c 6931 //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 6932 cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 6933 //~ cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 6934 //~ cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 6935 //~ cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 6936 # endif
whismanoid 6:f6d16658342b 6937 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6938 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 10:04022a61b527 6939 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6940 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 6941 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 6942 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 6943 AUXserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6944 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 6:f6d16658342b 6945 cmdLine_AUXserial.clear();
whismanoid 6:f6d16658342b 6946 //~ cmdLine_AUXserial.serial().printf("\r\n cmdLine_AUXserial.serial().printf test\r\n");
whismanoid 6:f6d16658342b 6947 cmdLine_AUXserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 6:f6d16658342b 6948 //~ cmdLine_AUXserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 6:f6d16658342b 6949 //~ cmdLine_AUXserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 6:f6d16658342b 6950 //~ cmdLine_AUXserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 6:f6d16658342b 6951 # endif // HAS_AUX_SERIAL
whismanoid 4:d9b05924ad4c 6952 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 0:cb44e2e9ec4c 6953
whismanoid 0:cb44e2e9ec4c 6954 // example code: serial port banner message
whismanoid 0:cb44e2e9ec4c 6955 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 6956 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6957 cmdLine.serial().printf("\r\nDataLogger_MAX11410\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 6958 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 6959 cmdLine.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 6960 # if HAS_DAPLINK_SERIAL
whismanoid 3:9055e17e181a 6961 cmdLine_DAPLINKserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 6962 # endif // HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 6963 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6964 cmdLine_AUXserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 6:f6d16658342b 6965 # endif // HAS_AUX_SERIAL
whismanoid 3:9055e17e181a 6966 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6967
whismanoid 1:747f1602abfc 6968 // CODE GENERATOR: get spi properties from device
whismanoid 3:9055e17e181a 6969 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6970 if (g_SPI_SCLK_Hz > g_MAX11410_device.get_spi_frequency())
whismanoid 3:9055e17e181a 6971 { // Device limits SPI SCLK frequency
whismanoid 3:9055e17e181a 6972 g_SPI_SCLK_Hz = g_MAX11410_device.get_spi_frequency();
whismanoid 3:9055e17e181a 6973 cmdLine.serial().printf("\r\nMAX11410 limits SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 6974
whismanoid 3:9055e17e181a 6975 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 6976 }
whismanoid 3:9055e17e181a 6977 if (g_MAX11410_device.get_spi_frequency() > g_SPI_SCLK_Hz)
whismanoid 3:9055e17e181a 6978 { // Platform limits SPI SCLK frequency
whismanoid 3:9055e17e181a 6979 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 6980 cmdLine.serial().printf("\r\nPlatform limits MAX11410 SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 6981
whismanoid 3:9055e17e181a 6982 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 6983 }
whismanoid 0:cb44e2e9ec4c 6984 // g_SPI_dataMode = g_MAX11410_device.get_spi_dataMode();
whismanoid 3:9055e17e181a 6985 while (g_MAX11410_device.Init() == 0)
whismanoid 3:9055e17e181a 6986 {
whismanoid 3:9055e17e181a 6987 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 6988 cmdLine.serial().printf("\r\nMAX11410 Init failed; retry...\r\n");
whismanoid 3:9055e17e181a 6989
whismanoid 3:9055e17e181a 6990 }
whismanoid 0:cb44e2e9ec4c 6991
whismanoid 0:cb44e2e9ec4c 6992 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 3:9055e17e181a 6993 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6994 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 3:9055e17e181a 6995 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 3:9055e17e181a 6996 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 3:9055e17e181a 6997 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 6998 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 3:9055e17e181a 6999 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7000 // CODE GENERATOR: example code: has no member function REF
whismanoid 0:cb44e2e9ec4c 7001 // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line
whismanoid 0:cb44e2e9ec4c 7002 // CODE GENERATOR: ResolutionBits = 24
whismanoid 0:cb44e2e9ec4c 7003 // CODE GENERATOR: FScode = 0xffffff
whismanoid 0:cb44e2e9ec4c 7004 // CODE GENERATOR: NumChannels = 10
whismanoid 0:cb44e2e9ec4c 7005 // CODE GENERATOR: banner before DataLogHelloCppCodeList while(1)
whismanoid 3:9055e17e181a 7006 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 7007 cmdLine.serial().printf("v_filter = 0x%2.2x\r\n", g_MAX11410_device.v_filter);
whismanoid 0:cb44e2e9ec4c 7008
whismanoid 3:9055e17e181a 7009 cmdLine.serial().printf("v_pga = 0x%2.2x\r\n", g_MAX11410_device.v_pga);
whismanoid 0:cb44e2e9ec4c 7010
whismanoid 3:9055e17e181a 7011 cmdLine.serial().printf("v_ctrl = 0x%2.2x\r\n", g_MAX11410_device.v_ctrl);
whismanoid 3:9055e17e181a 7012
whismanoid 3:9055e17e181a 7013 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7014
whismanoid 3:9055e17e181a 7015 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 7016 Datalogger_Need_PrintHeader = true;
whismanoid 10:04022a61b527 7017
whismanoid 12:2dfc1f2009e0 7018 #if USE_LEDS
whismanoid 12:2dfc1f2009e0 7019 #if defined(TARGET_MAX32630)
whismanoid 12:2dfc1f2009e0 7020 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 7021 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7022 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 7023 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7024 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 7025 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7026 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 7027 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7028 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 7029 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7030 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 7031 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7032 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 7033 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7034 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 7035 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 19:5ff09c8e9daf 7036 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 12:2dfc1f2009e0 7037 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 7038 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7039 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 7040 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7041 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 7042 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7043 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 7044 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7045 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 7046 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7047 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 7048 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7049 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 7050 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7051 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 7052 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7053 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 12:2dfc1f2009e0 7054 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 7055 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7056 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7057 led4 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7058 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7059 //led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 7060 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 7061 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7062 led1 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7063 //led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 7064 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 7065 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7066 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7067 //led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 7068 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 7069 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7070 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7071 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 7072 //
whismanoid 12:2dfc1f2009e0 7073 #endif // target definition
whismanoid 12:2dfc1f2009e0 7074 #endif
whismanoid 12:2dfc1f2009e0 7075
whismanoid 12:2dfc1f2009e0 7076 if (led1.is_connected()) {
whismanoid 12:2dfc1f2009e0 7077 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 7078 }
whismanoid 12:2dfc1f2009e0 7079 if (led2.is_connected()) {
whismanoid 12:2dfc1f2009e0 7080 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 7081 }
whismanoid 12:2dfc1f2009e0 7082 if (led3.is_connected()) {
whismanoid 12:2dfc1f2009e0 7083 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 7084 }
whismanoid 12:2dfc1f2009e0 7085
whismanoid 4:d9b05924ad4c 7086 while(1) { // this code repeats forever
whismanoid 4:d9b05924ad4c 7087 // this code repeats forever
whismanoid 4:d9b05924ad4c 7088
whismanoid 21:ac062a97a71d 7089 #if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 7090 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 7091 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 7092 # if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 7093 static int button1_value_prev = 1;
whismanoid 21:ac062a97a71d 7094 static int button1_value_now = 1;
whismanoid 21:ac062a97a71d 7095 button1_value_prev = button1_value_now;
whismanoid 21:ac062a97a71d 7096 button1_value_now = button1.read();
whismanoid 21:ac062a97a71d 7097 if ((button1_value_prev - button1_value_now) == 1)
whismanoid 21:ac062a97a71d 7098 {
whismanoid 21:ac062a97a71d 7099 // on button1 falling edge (button1 press)
whismanoid 21:ac062a97a71d 7100 onButton1FallingEdge();
whismanoid 21:ac062a97a71d 7101 }
whismanoid 21:ac062a97a71d 7102 # endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7103 # if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7104 static int button2_value_prev = 1;
whismanoid 24:032f3683cb2a 7105 static int button2_value_now = 1;
whismanoid 24:032f3683cb2a 7106 button2_value_prev = button2_value_now;
whismanoid 24:032f3683cb2a 7107 button2_value_now = button2.read();
whismanoid 24:032f3683cb2a 7108 if ((button2_value_prev - button2_value_now) == 1)
whismanoid 24:032f3683cb2a 7109 {
whismanoid 24:032f3683cb2a 7110 // on button2 falling edge (button2 press)
whismanoid 24:032f3683cb2a 7111 onButton2FallingEdge();
whismanoid 24:032f3683cb2a 7112 }
whismanoid 24:032f3683cb2a 7113 # endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7114 # if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7115 static int button3_value_prev = 1;
whismanoid 24:032f3683cb2a 7116 static int button3_value_now = 1;
whismanoid 24:032f3683cb2a 7117 button3_value_prev = button3_value_now;
whismanoid 24:032f3683cb2a 7118 button3_value_now = button3.read();
whismanoid 24:032f3683cb2a 7119 if ((button3_value_prev - button3_value_now) == 1)
whismanoid 24:032f3683cb2a 7120 {
whismanoid 24:032f3683cb2a 7121 // on button3 falling edge (button3 press)
whismanoid 26:13cba69d88eb 7122 onButton3FallingEdge();
whismanoid 24:032f3683cb2a 7123 }
whismanoid 24:032f3683cb2a 7124 # endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 7125 #endif // HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 4:d9b05924ad4c 7126 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 7127 // TODO support CmdLine command menus (like on Serial_Tester); help and usual boilerplate
whismanoid 10:04022a61b527 7128 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 7129 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 7130 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 7131 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 7132 // Accept commands from Auxiliary serial port
whismanoid 6:f6d16658342b 7133 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 7134 if (AUXserial.readable()) {
whismanoid 6:f6d16658342b 7135 cmdLine_AUXserial.append(AUXserial.getc());
whismanoid 6:f6d16658342b 7136 }
whismanoid 6:f6d16658342b 7137 # endif // HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 7138 # if HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 7139 if (DAPLINKserial.readable()) {
whismanoid 6:f6d16658342b 7140 cmdLine_DAPLINKserial.append(DAPLINKserial.getc());
whismanoid 6:f6d16658342b 7141 }
whismanoid 6:f6d16658342b 7142 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 7143 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 7144 if (serial.readable()) {
whismanoid 4:d9b05924ad4c 7145 int c = serial.getc(); // instead of getc() or fgetc()
whismanoid 4:d9b05924ad4c 7146 cmdLine.append(c);
whismanoid 4:d9b05924ad4c 7147 // cmdLine.onEOLcommandParser handler implements menus
whismanoid 4:d9b05924ad4c 7148 } // if (Serial.available())
whismanoid 4:d9b05924ad4c 7149 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 7150
whismanoid 4:d9b05924ad4c 7151 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 32:80f3e5eb77d4 7152 // Datalog trigger
whismanoid 4:d9b05924ad4c 7153 if (Datalogger_Trigger == trigger_Halt) {
whismanoid 4:d9b05924ad4c 7154 // halt the datalogger; continue accepting commands
whismanoid 3:9055e17e181a 7155 continue;
whismanoid 3:9055e17e181a 7156 }
whismanoid 4:d9b05924ad4c 7157 if (Datalogger_Trigger == trigger_FreeRun) {
whismanoid 4:d9b05924ad4c 7158 // free run as fast as possible
whismanoid 3:9055e17e181a 7159 }
whismanoid 4:d9b05924ad4c 7160 if (Datalogger_Trigger == trigger_Timer) {
whismanoid 4:d9b05924ad4c 7161 // timer (configure interval)
whismanoid 32:80f3e5eb77d4 7162 // if Datalogger_Trigger == trigger_Timer sleep(g_timer_interval_msec)
whismanoid 39:4d285e961435 7163 //
whismanoid 39:4d285e961435 7164 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 7165 // TODO: USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 7166 // TODO: Sleep Mode vs Deep Sleep Mode
whismanoid 39:4d285e961435 7167 // See documentation https://os.mbed.com/docs/mbed-os/v5.15/apis/power-management-sleep.html
whismanoid 39:4d285e961435 7168 // sleep()
whismanoid 39:4d285e961435 7169 // sleep_manager_can_deep_sleep()
whismanoid 39:4d285e961435 7170 // sleep_manager_lock_deep_sleep()
whismanoid 39:4d285e961435 7171 switch(g_timer_sleepmode)
whismanoid 39:4d285e961435 7172 {
whismanoid 39:4d285e961435 7173 case datalogger_Sleep_LP0_Stop: // LT sleep = 0,
whismanoid 39:4d285e961435 7174 break;
whismanoid 39:4d285e961435 7175 case datalogger_Sleep_LP1_DeepSleep: // LT sleep = 1,
whismanoid 39:4d285e961435 7176 // sleep_manager_can_deep_sleep();
whismanoid 39:4d285e961435 7177 sleep();
whismanoid 39:4d285e961435 7178 wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 39:4d285e961435 7179 break;
whismanoid 39:4d285e961435 7180 case datalogger_Sleep_LP2_Sleep: // LT sleep = 2,
whismanoid 39:4d285e961435 7181 sleep_manager_lock_deep_sleep();
whismanoid 39:4d285e961435 7182 sleep();
whismanoid 39:4d285e961435 7183 wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 39:4d285e961435 7184 sleep_manager_can_deep_sleep();
whismanoid 39:4d285e961435 7185 break;
whismanoid 39:4d285e961435 7186 case datalogger_Sleep_LP3_Run: // LT sleep = 3,
whismanoid 39:4d285e961435 7187 wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 39:4d285e961435 7188 break;
whismanoid 39:4d285e961435 7189 }
whismanoid 39:4d285e961435 7190 #else // USE_DATALOGGER_SLEEP
whismanoid 17:9397ea3ea7e9 7191 wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 39:4d285e961435 7192 #endif // USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 7193 //
whismanoid 17:9397ea3ea7e9 7194 if (g_timer_interval_counter > 0) {
whismanoid 17:9397ea3ea7e9 7195 g_timer_interval_counter--;
whismanoid 17:9397ea3ea7e9 7196 continue;
whismanoid 17:9397ea3ea7e9 7197 }
whismanoid 17:9397ea3ea7e9 7198 // if time interval not yet reached, continue (continue accepting commands)
whismanoid 32:80f3e5eb77d4 7199 g_timer_interval_counter = g_timer_interval_count-1;
whismanoid 3:9055e17e181a 7200 }
whismanoid 4:d9b05924ad4c 7201 if (Datalogger_Trigger == trigger_PlatformDigitalInput) {
whismanoid 4:d9b05924ad4c 7202 // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 7203 // TODO: read selected input pin, test value
whismanoid 17:9397ea3ea7e9 7204 // TODO: if no match, continue (continue accepting commands)
whismanoid 3:9055e17e181a 7205 }
whismanoid 4:d9b05924ad4c 7206 if (Datalogger_Trigger == trigger_SPIDeviceRegRead) {
whismanoid 4:d9b05924ad4c 7207 // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 7208 // TODO: SPI transfer regAddr
whismanoid 17:9397ea3ea7e9 7209 // TODO: apply dataMask, compare with testValue
whismanoid 17:9397ea3ea7e9 7210 // TODO: if no match, continue (continue accepting commands)
whismanoid 4:d9b05924ad4c 7211 }
whismanoid 4:d9b05924ad4c 7212 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 0:cb44e2e9ec4c 7213
whismanoid 8:dffee7509bfb 7214 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 7215 if (Datalogger_Need_PrintHeader) {
whismanoid 8:dffee7509bfb 7216 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 7217 Datalogger_PrintHeader(cmdLine);
whismanoid 8:dffee7509bfb 7218 }
whismanoid 8:dffee7509bfb 7219 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 7220 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 7221 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 7222 }
whismanoid 8:dffee7509bfb 7223 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 7224 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 7225 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 7226 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 7227 }
whismanoid 8:dffee7509bfb 7228 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 7229 Datalogger_Need_PrintHeader = false;
whismanoid 8:dffee7509bfb 7230 }
whismanoid 5:aaf8b5f5fda1 7231 Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 7232 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 7233 // Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 7234 Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 7235 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 0:cb44e2e9ec4c 7236 // wait(3.0);
whismanoid 0:cb44e2e9ec4c 7237 // CODE GENERATOR: print conversion result
whismanoid 0:cb44e2e9ec4c 7238 // Use Arduino Serial Plotter to view output: Tools | Serial Plotter
whismanoid 8:dffee7509bfb 7239 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 7240 Datalogger_PrintRow(cmdLine);
whismanoid 8:dffee7509bfb 7241 }
whismanoid 8:dffee7509bfb 7242 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 7243 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 7244 Datalogger_PrintRow(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 7245 }
whismanoid 8:dffee7509bfb 7246 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 7247 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 7248 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 7249 Datalogger_PrintRow(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 7250 }
whismanoid 8:dffee7509bfb 7251 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:cb44e2e9ec4c 7252
whismanoid 0:cb44e2e9ec4c 7253 } // this code repeats forever
whismanoid 0:cb44e2e9ec4c 7254 }
whismanoid 0:cb44e2e9ec4c 7255 //---------- CODE GENERATOR: end DataLogHelloCppCodeList