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

Dependencies:   max32625pico CmdLine

Committer:
whismanoid
Date:
Wed May 12 02:31:52 2021 -0700
Revision:
41:13a6a097502c
Parent:
40:330b28116178
Child:
42:89607d5d4e6d
WIP LT sleep=1 Sleep vs Deep Sleep (mbed-os-5.15)

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 41:13a6a097502c 161 // - update from mbed-os-5.11.5 to mbed-os-5.15 to support deep sleep
whismanoid 41:13a6a097502c 162 // - cd mbed-os ; mbed update mbed-os-5.15.7 ; cd .. ; mbed remove USBDevice ; mbed sync
whismanoid 41:13a6a097502c 163 // - (Internal_DataLogger_NoUSB_MAX32625PICO does not use USBDevice library anyway)
whismanoid 0:cb44e2e9ec4c 164 //
whismanoid 0:cb44e2e9ec4c 165 // end Platform_Include_Boilerplate
whismanoid 0:cb44e2e9ec4c 166
whismanoid 0:cb44e2e9ec4c 167 //--------------------------------------------------
whismanoid 3:9055e17e181a 168 // Option to use SPI connected ADC
whismanoid 3:9055e17e181a 169 #ifndef SPI_ADC_DeviceName
whismanoid 9:45f98573eb6d 170 #define SPI_ADC_DeviceName MAX11410
whismanoid 3:9055e17e181a 171 #undef SPI_ADC_DeviceName
whismanoid 3:9055e17e181a 172 #endif
whismanoid 3:9055e17e181a 173 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 174 #include "MAX11410.h"
whismanoid 3:9055e17e181a 175 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 176
whismanoid 0:cb44e2e9ec4c 177 #if defined(TARGET)
whismanoid 0:cb44e2e9ec4c 178 // TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h
whismanoid 0:cb44e2e9ec4c 179 // Create a string definition for the TARGET
whismanoid 0:cb44e2e9ec4c 180 #define STRING_ARG(arg) #arg
whismanoid 0:cb44e2e9ec4c 181 #define STRING_NAME(name) STRING_ARG(name)
whismanoid 0:cb44e2e9ec4c 182 #define TARGET_NAME STRING_NAME(TARGET)
whismanoid 0:cb44e2e9ec4c 183 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 184 #define TARGET_NAME "MAX32600"
whismanoid 0:cb44e2e9ec4c 185 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 186 #define TARGET_NAME "LPC1768"
whismanoid 0:cb44e2e9ec4c 187 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 188 #define TARGET_NAME "NUCLEO_F446RE"
whismanoid 0:cb44e2e9ec4c 189 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 190 #define TARGET_NAME "NUCLEO_F401RE"
whismanoid 0:cb44e2e9ec4c 191 #else
whismanoid 0:cb44e2e9ec4c 192 #error TARGET NOT DEFINED
whismanoid 0:cb44e2e9ec4c 193 #endif
whismanoid 0:cb44e2e9ec4c 194 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 195 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 196 // TARGET=MAX32630FTHR ARM Cortex-M4F 96MHz 2048kB Flash 512kB SRAM
whismanoid 0:cb44e2e9ec4c 197 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 198 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 199 // ______ | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 200 // ______ | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 201 // ______ | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 202 // ______ | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 203 // analogIn0/4 | [a] AIN_0 1.2Vfs (bat) SYS [ ] | switched BAT+
whismanoid 0:cb44e2e9ec4c 204 // analogIn1/5 | [a] AIN_1 1.2Vfs PWR [ ] | external pwr btn
whismanoid 0:cb44e2e9ec4c 205 // analogIn2 | [a] AIN_2 1.2Vfs +5V VBUS [ ] | USB +5V power
whismanoid 0:cb44e2e9ec4c 206 // analogIn3 | [a] AIN_3 1.2Vfs 1-WIRE P4_0 [d] | D0 dig9
whismanoid 0:cb44e2e9ec4c 207 // (I2C2.SDA) | [d] P5_7 SDA2 SRN P5_6 [d] | D1 dig8
whismanoid 0:cb44e2e9ec4c 208 // (I2C2.SCL) | [d] P6_0 SCL2 SDIO3 P5_5 [d] | D2 dig7
whismanoid 0:cb44e2e9ec4c 209 // D13/SCLK | [s] P5_0 SCLK SDIO2 P5_4 [d] | D3 dig6
whismanoid 0:cb44e2e9ec4c 210 // D11/MOSI | [s] P5_1 MOSI SSEL P5_3 [d] | D4 dig5
whismanoid 0:cb44e2e9ec4c 211 // D12/MISO | [s] P5_2 MISO RTS P3_3 [d] | D5 dig4
whismanoid 0:cb44e2e9ec4c 212 // D10/CS | [s] P3_0 RX CTS P3_2 [d] | D6 dig3
whismanoid 0:cb44e2e9ec4c 213 // D9 dig0 | [d] P3_1 TX SCL P3_5 [d] | D7 dig2
whismanoid 0:cb44e2e9ec4c 214 // ______ | [ ] GND SDA P3_4 [d] | D8 dig1
whismanoid 0:cb44e2e9ec4c 215 // | |
whismanoid 0:cb44e2e9ec4c 216 // | XIP Flash MAX14690N |
whismanoid 0:cb44e2e9ec4c 217 // | XIP_SCLK P1_0 SDA2 P5_7 |
whismanoid 0:cb44e2e9ec4c 218 // | XIP_MOSI P1_1 SCL2 P6_0 |
whismanoid 0:cb44e2e9ec4c 219 // | XIP_MISO P1_2 PMIC_INIT P3_7 |
whismanoid 0:cb44e2e9ec4c 220 // | XIP_SSEL P1_3 MPC P2_7 |
whismanoid 0:cb44e2e9ec4c 221 // | XIP_DIO2 P1_4 MON AIN_0 |
whismanoid 0:cb44e2e9ec4c 222 // | XIP_DIO3 P1_5 |
whismanoid 0:cb44e2e9ec4c 223 // | |
whismanoid 0:cb44e2e9ec4c 224 // | PAN1326B MicroSD LED |
whismanoid 0:cb44e2e9ec4c 225 // | BT_RX P0_0 SD_SCLK P0_4 r P2_4 |
whismanoid 0:cb44e2e9ec4c 226 // | BT_TX P0_1 SD_MOSI P0_5 g P2_5 |
whismanoid 0:cb44e2e9ec4c 227 // | BT_CTS P0_2 SD_MISO P0_6 b P2_6 |
whismanoid 0:cb44e2e9ec4c 228 // | BT_RTS P0_3 SD_SSEL P0_7 |
whismanoid 0:cb44e2e9ec4c 229 // | BT_RST P1_6 DETECT P2_2 |
whismanoid 0:cb44e2e9ec4c 230 // | BT_CLK P1_7 SW2 P2_3 |
whismanoid 0:cb44e2e9ec4c 231 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 232 // 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 233 // 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 234 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 235 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 236 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 237 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 238 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 239 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 240 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 241 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 242 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 243 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 244 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 245 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 246 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 247 //
whismanoid 0:cb44e2e9ec4c 248 #include "max32630fthr.h"
whismanoid 0:cb44e2e9ec4c 249 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 250 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 251 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 252 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 253 // Arduino connector
whismanoid 0:cb44e2e9ec4c 254 #ifndef A0
whismanoid 0:cb44e2e9ec4c 255 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 256 #endif
whismanoid 0:cb44e2e9ec4c 257 #ifndef A1
whismanoid 0:cb44e2e9ec4c 258 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 259 #endif
whismanoid 0:cb44e2e9ec4c 260 #ifndef A2
whismanoid 0:cb44e2e9ec4c 261 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 262 #endif
whismanoid 0:cb44e2e9ec4c 263 #ifndef A3
whismanoid 0:cb44e2e9ec4c 264 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 265 #endif
whismanoid 0:cb44e2e9ec4c 266 #ifndef D0
whismanoid 0:cb44e2e9ec4c 267 #define D0 P4_0
whismanoid 0:cb44e2e9ec4c 268 #endif
whismanoid 0:cb44e2e9ec4c 269 #ifndef D1
whismanoid 0:cb44e2e9ec4c 270 #define D1 P5_6
whismanoid 0:cb44e2e9ec4c 271 #endif
whismanoid 0:cb44e2e9ec4c 272 #ifndef D2
whismanoid 0:cb44e2e9ec4c 273 #define D2 P5_5
whismanoid 0:cb44e2e9ec4c 274 #endif
whismanoid 0:cb44e2e9ec4c 275 #ifndef D3
whismanoid 0:cb44e2e9ec4c 276 #define D3 P5_4
whismanoid 0:cb44e2e9ec4c 277 #endif
whismanoid 0:cb44e2e9ec4c 278 #ifndef D4
whismanoid 0:cb44e2e9ec4c 279 #define D4 P5_3
whismanoid 0:cb44e2e9ec4c 280 #endif
whismanoid 0:cb44e2e9ec4c 281 #ifndef D5
whismanoid 0:cb44e2e9ec4c 282 #define D5 P3_3
whismanoid 0:cb44e2e9ec4c 283 #endif
whismanoid 0:cb44e2e9ec4c 284 #ifndef D6
whismanoid 0:cb44e2e9ec4c 285 #define D6 P3_2
whismanoid 0:cb44e2e9ec4c 286 #endif
whismanoid 0:cb44e2e9ec4c 287 #ifndef D7
whismanoid 0:cb44e2e9ec4c 288 #define D7 P3_5
whismanoid 0:cb44e2e9ec4c 289 #endif
whismanoid 0:cb44e2e9ec4c 290 #ifndef D8
whismanoid 0:cb44e2e9ec4c 291 #define D8 P3_4
whismanoid 0:cb44e2e9ec4c 292 #endif
whismanoid 0:cb44e2e9ec4c 293 #ifndef D9
whismanoid 0:cb44e2e9ec4c 294 #define D9 P3_1
whismanoid 0:cb44e2e9ec4c 295 #endif
whismanoid 0:cb44e2e9ec4c 296 #ifndef D10
whismanoid 0:cb44e2e9ec4c 297 #define D10 P3_0
whismanoid 0:cb44e2e9ec4c 298 #endif
whismanoid 0:cb44e2e9ec4c 299 #ifndef D11
whismanoid 0:cb44e2e9ec4c 300 #define D11 P5_1
whismanoid 0:cb44e2e9ec4c 301 #endif
whismanoid 0:cb44e2e9ec4c 302 #ifndef D12
whismanoid 0:cb44e2e9ec4c 303 #define D12 P5_2
whismanoid 0:cb44e2e9ec4c 304 #endif
whismanoid 0:cb44e2e9ec4c 305 #ifndef D13
whismanoid 0:cb44e2e9ec4c 306 #define D13 P5_0
whismanoid 0:cb44e2e9ec4c 307 #endif
whismanoid 0:cb44e2e9ec4c 308 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 309 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 310 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 311 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 312 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 313 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 314 // | |
whismanoid 0:cb44e2e9ec4c 315 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 316 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 317 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 318 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 319 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 320 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 321 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 322 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 323 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 324 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 325 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 326 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 327 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 328 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 329 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 330 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 331 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 332 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 333 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 334 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 335 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 336 // \_______________________/
whismanoid 0:cb44e2e9ec4c 337 //
whismanoid 0:cb44e2e9ec4c 338 // +------------------------+
whismanoid 0:cb44e2e9ec4c 339 // | |
whismanoid 0:cb44e2e9ec4c 340 // | MicroSD LED |
whismanoid 0:cb44e2e9ec4c 341 // | SD_SCLK P2_4 r P3_0 |
whismanoid 0:cb44e2e9ec4c 342 // | SD_MOSI P2_5 g P3_1 |
whismanoid 0:cb44e2e9ec4c 343 // | SD_MISO P2_6 b P3_2 |
whismanoid 0:cb44e2e9ec4c 344 // | SD_SSEL P2_7 y P3_3 |
whismanoid 0:cb44e2e9ec4c 345 // | |
whismanoid 0:cb44e2e9ec4c 346 // | DAPLINK BUTTONS |
whismanoid 0:cb44e2e9ec4c 347 // | TX P2_1 SW3 P2_3 |
whismanoid 0:cb44e2e9ec4c 348 // | RX P2_0 SW2 P2_2 |
whismanoid 0:cb44e2e9ec4c 349 // +------------------------+
whismanoid 0:cb44e2e9ec4c 350 //
whismanoid 0:cb44e2e9ec4c 351 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 352 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 353 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 354 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 355 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 356 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 357 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 358 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 359 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 360 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 361 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 362 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 363 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 364 //
whismanoid 0:cb44e2e9ec4c 365 //#include "max32625mbed.h" // ?
whismanoid 0:cb44e2e9ec4c 366 //MAX32625MBED mbed(MAX32625MBED::VIO_3V3); // ?
whismanoid 0:cb44e2e9ec4c 367 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 368 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 369 const float ADC_FULL_SCALE_VOLTAGE = 1.200; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 370 // Arduino connector
whismanoid 0:cb44e2e9ec4c 371 #ifndef A0
whismanoid 0:cb44e2e9ec4c 372 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 373 #endif
whismanoid 0:cb44e2e9ec4c 374 #ifndef A1
whismanoid 0:cb44e2e9ec4c 375 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 376 #endif
whismanoid 0:cb44e2e9ec4c 377 #ifndef A2
whismanoid 0:cb44e2e9ec4c 378 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 379 #endif
whismanoid 0:cb44e2e9ec4c 380 #ifndef A3
whismanoid 0:cb44e2e9ec4c 381 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 382 #endif
whismanoid 0:cb44e2e9ec4c 383 #ifndef D0
whismanoid 0:cb44e2e9ec4c 384 #define D0 P0_0
whismanoid 0:cb44e2e9ec4c 385 #endif
whismanoid 0:cb44e2e9ec4c 386 #ifndef D1
whismanoid 0:cb44e2e9ec4c 387 #define D1 P0_1
whismanoid 0:cb44e2e9ec4c 388 #endif
whismanoid 0:cb44e2e9ec4c 389 #ifndef D2
whismanoid 0:cb44e2e9ec4c 390 #define D2 P0_2
whismanoid 0:cb44e2e9ec4c 391 #endif
whismanoid 0:cb44e2e9ec4c 392 #ifndef D3
whismanoid 0:cb44e2e9ec4c 393 #define D3 P0_3
whismanoid 0:cb44e2e9ec4c 394 #endif
whismanoid 0:cb44e2e9ec4c 395 #ifndef D4
whismanoid 0:cb44e2e9ec4c 396 #define D4 P0_4
whismanoid 0:cb44e2e9ec4c 397 #endif
whismanoid 0:cb44e2e9ec4c 398 #ifndef D5
whismanoid 0:cb44e2e9ec4c 399 #define D5 P0_5
whismanoid 0:cb44e2e9ec4c 400 #endif
whismanoid 0:cb44e2e9ec4c 401 #ifndef D6
whismanoid 0:cb44e2e9ec4c 402 #define D6 P0_6
whismanoid 0:cb44e2e9ec4c 403 #endif
whismanoid 0:cb44e2e9ec4c 404 #ifndef D7
whismanoid 0:cb44e2e9ec4c 405 #define D7 P0_7
whismanoid 0:cb44e2e9ec4c 406 #endif
whismanoid 0:cb44e2e9ec4c 407 #ifndef D8
whismanoid 0:cb44e2e9ec4c 408 #define D8 P1_4
whismanoid 0:cb44e2e9ec4c 409 #endif
whismanoid 0:cb44e2e9ec4c 410 #ifndef D9
whismanoid 0:cb44e2e9ec4c 411 #define D9 P1_5
whismanoid 0:cb44e2e9ec4c 412 #endif
whismanoid 0:cb44e2e9ec4c 413 #ifndef D10
whismanoid 0:cb44e2e9ec4c 414 #define D10 P1_3
whismanoid 0:cb44e2e9ec4c 415 #endif
whismanoid 0:cb44e2e9ec4c 416 #ifndef D11
whismanoid 0:cb44e2e9ec4c 417 #define D11 P1_1
whismanoid 0:cb44e2e9ec4c 418 #endif
whismanoid 0:cb44e2e9ec4c 419 #ifndef D12
whismanoid 0:cb44e2e9ec4c 420 #define D12 P1_2
whismanoid 0:cb44e2e9ec4c 421 #endif
whismanoid 0:cb44e2e9ec4c 422 #ifndef D13
whismanoid 0:cb44e2e9ec4c 423 #define D13 P1_0
whismanoid 0:cb44e2e9ec4c 424 #endif
whismanoid 0:cb44e2e9ec4c 425 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 426 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 427 // target MAX32600
whismanoid 0:cb44e2e9ec4c 428 //
whismanoid 0:cb44e2e9ec4c 429 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 430 const float ADC_FULL_SCALE_VOLTAGE = 1.500;
whismanoid 0:cb44e2e9ec4c 431 //
whismanoid 0:cb44e2e9ec4c 432 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 433 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 434 #warning "TARGET_MAX32620FTHR not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 435 #include "MAX32620FTHR.h"
whismanoid 0:cb44e2e9ec4c 436 // Initialize I/O voltages on MAX32620FTHR board
whismanoid 0:cb44e2e9ec4c 437 MAX32620FTHR fthr(MAX32620FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 438 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 439 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 440 #warning "TARGET_MAX32620FTHR not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 441 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 442 //
whismanoid 0:cb44e2e9ec4c 443 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 444 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 15:37c83ec50ea0 445 // #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 446 #include "max32625pico.h"
whismanoid 0:cb44e2e9ec4c 447 // configure MAX32625PICO VDDIOH mode, and I/O voltages for DIP pins and SWD pins
whismanoid 0:cb44e2e9ec4c 448 MAX32625PICO pico(
whismanoid 13:184a08909405 449 // Select source of higher-voltage logic high supply VDDIOH
whismanoid 0:cb44e2e9ec4c 450 // vddioh_mode_t iohMode
whismanoid 0:cb44e2e9ec4c 451 //~ MAX32625PICO::IOH_OFF, // No connections to VDDIOH
whismanoid 0:cb44e2e9ec4c 452 //~ MAX32625PICO::IOH_DIP_IN, // VDDIOH input from DIP pin 1 (AIN0)
whismanoid 0:cb44e2e9ec4c 453 //~ MAX32625PICO::IOH_SWD_IN, // VDDIOH input from SWD pin 1
whismanoid 0:cb44e2e9ec4c 454 MAX32625PICO::IOH_3V3, // VDDIOH = 3.3V from local supply
whismanoid 0:cb44e2e9ec4c 455 //~ MAX32625PICO::IOH_DIP_OUT, // VDDIOH = 3.3V output to DIP pin 1
whismanoid 0:cb44e2e9ec4c 456 //~ MAX32625PICO::IOH_SWD_OUT, // VDDIOH = 3.3V output to SWD pin 1
whismanoid 0:cb44e2e9ec4c 457 //
whismanoid 13:184a08909405 458 // Digital I/O pin logic high voltage 1.8V or 3.3V
whismanoid 0:cb44e2e9ec4c 459 // vio_t dipVio = MAX32625PICO::VIO_1V8 or MAX32625PICO::VIO_IOH
whismanoid 13:184a08909405 460 MAX32625PICO::VIO_1V8, // 1.8V IO (local)
whismanoid 13:184a08909405 461 //~ MAX32625PICO::VIO_IOH, // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 462 //
whismanoid 13:184a08909405 463 // Software Debug logic high voltage (normally use VIO_IOH)
whismanoid 0:cb44e2e9ec4c 464 // vio_t swdVio
whismanoid 0:cb44e2e9ec4c 465 //~ MAX32625PICO::VIO_1V8 // 1.8V IO (local)
whismanoid 0:cb44e2e9ec4c 466 MAX32625PICO::VIO_IOH // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 467 );
whismanoid 0:cb44e2e9ec4c 468 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 469 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 15:37c83ec50ea0 470 // #warning "TARGET_MAX32625PICO not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 471 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 472 //
whismanoid 0:cb44e2e9ec4c 473 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 474 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 475 // TODO1: target NUCLEO_F446RE
whismanoid 0:cb44e2e9ec4c 476 //
whismanoid 0:cb44e2e9ec4c 477 // USER_BUTTON PC13
whismanoid 0:cb44e2e9ec4c 478 // LED1 is shared with SPI_SCK on NUCLEO_F446RE PA_5, so don't use LED1.
whismanoid 0:cb44e2e9ec4c 479 #define USE_LEDS 0
whismanoid 0:cb44e2e9ec4c 480 // SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
whismanoid 0:cb44e2e9ec4c 481 // Serial serial(SERIAL_TX, SERIAL_RX);
whismanoid 0:cb44e2e9ec4c 482 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 483 const float ADC_FULL_SCALE_VOLTAGE = 3.300; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 484 //
whismanoid 0:cb44e2e9ec4c 485 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 486 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 487 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 488 // TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM
whismanoid 0:cb44e2e9ec4c 489 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 490 // ______ | [ ] GND +3.3V VOUT [ ] | ______
whismanoid 0:cb44e2e9ec4c 491 // ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | ______
whismanoid 0:cb44e2e9ec4c 492 // ______ | [ ] VB USB.IF- [ ] | ______
whismanoid 0:cb44e2e9ec4c 493 // ______ | [ ] nR USB.IF+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 494 // digitalInOut0 | [ ] p5 MOSI ETHERNET.RD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 495 // digitalInOut1 | [ ] p6 MISO ETHERNET.RD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 496 // digitalInOut2 | [ ] p7 SCLK ETHERNET.TD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 497 // digitalInOut3 | [ ] p8 ETHERNET.TD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 498 // digitalInOut4 | [ ] p9 TX SDA USB.D- [ ] | ______
whismanoid 0:cb44e2e9ec4c 499 // digitalInOut5 | [ ] p10 RX SCL USB.D+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 500 // digitalInOut6 | [ ] p11 MOSI CAN-RD p30 [ ] | digitalInOut13
whismanoid 0:cb44e2e9ec4c 501 // digitalInOut7 | [ ] p12 MISO CAN-TD p29 [ ] | digitalInOut12
whismanoid 0:cb44e2e9ec4c 502 // digitalInOut8 | [ ] p13 TX SCLK SDA TX p28 [ ] | digitalInOut11
whismanoid 0:cb44e2e9ec4c 503 // digitalInOut9 | [ ] p14 RX SCL RX p27 [ ] | digitalInOut10
whismanoid 0:cb44e2e9ec4c 504 // analogIn0 | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1
whismanoid 0:cb44e2e9ec4c 505 // analogIn1 | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2
whismanoid 0:cb44e2e9ec4c 506 // analogIn2 | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3
whismanoid 0:cb44e2e9ec4c 507 // analogIn3 | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4
whismanoid 0:cb44e2e9ec4c 508 // analogIn4 | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5
whismanoid 0:cb44e2e9ec4c 509 // analogIn5 | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6
whismanoid 0:cb44e2e9ec4c 510 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 511 // AIN6 = P0.3 = TGT_SBL_RXD?
whismanoid 0:cb44e2e9ec4c 512 // AIN7 = P0.2 = TGT_SBL_TXD?
whismanoid 0:cb44e2e9ec4c 513 //
whismanoid 0:cb44e2e9ec4c 514 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 515 // LPC1768 board uses VREF = 3.300V +A3,3V thru L1 to bypass capacitor C14
whismanoid 0:cb44e2e9ec4c 516 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 517 const float ADC_FULL_SCALE_VOLTAGE = 3.300;
whismanoid 0:cb44e2e9ec4c 518 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 0:cb44e2e9ec4c 519 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 520 // unknown target
whismanoid 0:cb44e2e9ec4c 521 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 522 #endif // target definition
whismanoid 0:cb44e2e9ec4c 523
whismanoid 0:cb44e2e9ec4c 524
whismanoid 0:cb44e2e9ec4c 525
whismanoid 0:cb44e2e9ec4c 526
whismanoid 18:1235c17b451e 527 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 528 // move definiton of USE_LEDS earlier than find_digitalInOutPin()
whismanoid 18:1235c17b451e 529 //--------------------------------------------------
whismanoid 18:1235c17b451e 530 // Option to use LEDs to show status
whismanoid 18:1235c17b451e 531 #ifndef USE_LEDS
whismanoid 18:1235c17b451e 532 #define USE_LEDS 1
whismanoid 18:1235c17b451e 533 #endif
whismanoid 18:1235c17b451e 534 #if USE_LEDS
whismanoid 18:1235c17b451e 535 #if defined(TARGET_MAX32630)
whismanoid 18:1235c17b451e 536 # define LED_ON 0
whismanoid 18:1235c17b451e 537 # define LED_OFF 1
whismanoid 18:1235c17b451e 538 //--------------------------------------------------
whismanoid 18:1235c17b451e 539 #elif defined(TARGET_MAX32625MBED)
whismanoid 18:1235c17b451e 540 # define LED_ON 0
whismanoid 18:1235c17b451e 541 # define LED_OFF 1
whismanoid 19:5ff09c8e9daf 542 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 18:1235c17b451e 543 # define LED_ON 0
whismanoid 18:1235c17b451e 544 # define LED_OFF 1
whismanoid 18:1235c17b451e 545 //--------------------------------------------------
whismanoid 18:1235c17b451e 546 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 18:1235c17b451e 547 #elif defined(TARGET_LPC1768)
whismanoid 18:1235c17b451e 548 # define LED_ON 1
whismanoid 18:1235c17b451e 549 # define LED_OFF 0
whismanoid 18:1235c17b451e 550 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 18:1235c17b451e 551 // USE_LEDS with some platform other than MAX32630, MAX32625MBED, LPC1768
whismanoid 18:1235c17b451e 552 // bugfix for MAX32600MBED LED blink pattern: check if LED_ON/LED_OFF already defined
whismanoid 18:1235c17b451e 553 # ifndef LED_ON
whismanoid 18:1235c17b451e 554 # define LED_ON 0
whismanoid 18:1235c17b451e 555 # endif
whismanoid 18:1235c17b451e 556 # ifndef LED_OFF
whismanoid 18:1235c17b451e 557 # define LED_OFF 1
whismanoid 18:1235c17b451e 558 # endif
whismanoid 18:1235c17b451e 559 //# define LED_ON 1
whismanoid 18:1235c17b451e 560 //# define LED_OFF 0
whismanoid 18:1235c17b451e 561 #endif // target definition
whismanoid 18:1235c17b451e 562 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 563 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 564 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 565 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 566 // change led1/2/3/4 from DigitalOut to DigitalInOut
whismanoid 18:1235c17b451e 567 DigitalInOut led1(LED1, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED1 = LED_RED
whismanoid 18:1235c17b451e 568 DigitalInOut led2(LED2, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN
whismanoid 18:1235c17b451e 569 DigitalInOut led3(LED3, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE
whismanoid 18:1235c17b451e 570 DigitalInOut led4(LED4, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 571 #else // USE_LEDS=0
whismanoid 18:1235c17b451e 572 // issue #41 support Nucleo_F446RE
whismanoid 18:1235c17b451e 573 // there are no LED indicators on the board, LED1 interferes with SPI;
whismanoid 18:1235c17b451e 574 // but we still need placeholders led1 led2 led3 led4.
whismanoid 18:1235c17b451e 575 // Declare DigitalInOut led1 led2 led3 led4 targeting safe pins.
whismanoid 18:1235c17b451e 576 // PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false
whismanoid 18:1235c17b451e 577 # define LED_ON 0
whismanoid 18:1235c17b451e 578 # define LED_OFF 1
whismanoid 18:1235c17b451e 579 // change led1/2/3/4 from DigitalOut to DigitalInOut
whismanoid 18:1235c17b451e 580 DigitalInOut led1(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 581 DigitalInOut led2(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 582 DigitalInOut led3(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 583 DigitalInOut led4(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 584 #endif // USE_LEDS
whismanoid 18:1235c17b451e 585 #define led1_RFailLED led1
whismanoid 18:1235c17b451e 586 #define led2_GPassLED led2
whismanoid 18:1235c17b451e 587 #define led3_BBusyLED led3
whismanoid 18:1235c17b451e 588
whismanoid 21:ac062a97a71d 589 //--------------------------------------------------
whismanoid 21:ac062a97a71d 590 // use BUTTON1 trigger some action
whismanoid 21:ac062a97a71d 591 #if defined(TARGET_MAX32630)
whismanoid 21:ac062a97a71d 592 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 593 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 594 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 595 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 25:8a61cb34191d 596 // #warning "TARGET_MAX32625PICO not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 597 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 24:032f3683cb2a 598 #if MAX40108_DEMO
whismanoid 25:8a61cb34191d 599 #if HAS_I2C
whismanoid 25:8a61cb34191d 600 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 601 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 24:032f3683cb2a 602 #define BUTTON2 P3_7
whismanoid 25:8a61cb34191d 603 #else // HAS_I2C
whismanoid 25:8a61cb34191d 604 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 605 // 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 606 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 607 #define BUTTON2 P1_7
whismanoid 25:8a61cb34191d 608 #endif // HAS_I2C
whismanoid 24:032f3683cb2a 609 #define HAS_BUTTON2_DEMO 0
whismanoid 24:032f3683cb2a 610 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 25:8a61cb34191d 611 #if HAS_I2C
whismanoid 25:8a61cb34191d 612 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 613 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 24:032f3683cb2a 614 #define BUTTON3 P3_6
whismanoid 25:8a61cb34191d 615 #else // HAS_I2C
whismanoid 25:8a61cb34191d 616 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 617 // 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 618 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 619 #define BUTTON3 P1_6
whismanoid 25:8a61cb34191d 620 #endif // HAS_I2C
whismanoid 24:032f3683cb2a 621 #define HAS_BUTTON3_DEMO 0
whismanoid 24:032f3683cb2a 622 #define HAS_BUTTON3_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 623 // additional buttons are assigned to unused/unaccessible pins to avoid conflicts
whismanoid 29:6a9edb6e973b 624 // activate using %B4! or action_button pin=4
whismanoid 29:6a9edb6e973b 625 #define BUTTON4 P1_5
whismanoid 29:6a9edb6e973b 626 #define HAS_BUTTON4_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 627 #define BUTTON5 P1_4
whismanoid 29:6a9edb6e973b 628 #define HAS_BUTTON5_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 629 #define BUTTON6 P1_3
whismanoid 29:6a9edb6e973b 630 #define HAS_BUTTON6_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 631 #define BUTTON7 P1_2
whismanoid 29:6a9edb6e973b 632 #define HAS_BUTTON7_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 633 #define BUTTON8 P1_1
whismanoid 29:6a9edb6e973b 634 #define HAS_BUTTON8_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 635 #define BUTTON9 P1_0
whismanoid 29:6a9edb6e973b 636 #define HAS_BUTTON9_DEMO_INTERRUPT 1
whismanoid 24:032f3683cb2a 637 #else // MAX40108_DEMO
whismanoid 21:ac062a97a71d 638 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 639 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 29:6a9edb6e973b 640 #endif // MAX40108_DEMO ---------------------------------
whismanoid 21:ac062a97a71d 641 #elif defined(TARGET_MAX32625)
whismanoid 21:ac062a97a71d 642 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 643 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 644 #elif defined(TARGET_MAX32620FTHR)
whismanoid 21:ac062a97a71d 645 #warning "TARGET_MAX32620FTHR not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 646 #define BUTTON1 SW1
whismanoid 21:ac062a97a71d 647 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 648 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 649 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 650 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 21:ac062a97a71d 651 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 652 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 653 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 21:ac062a97a71d 654 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 655 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 656 #else
whismanoid 21:ac062a97a71d 657 #warning "target not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 658 #endif
whismanoid 21:ac062a97a71d 659 //
whismanoid 21:ac062a97a71d 660 #ifndef HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 661 #define HAS_BUTTON1_DEMO 0
whismanoid 21:ac062a97a71d 662 #endif
whismanoid 21:ac062a97a71d 663 #ifndef HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 664 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 665 #endif
whismanoid 24:032f3683cb2a 666 #ifndef HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 667 #define HAS_BUTTON3_DEMO 0
whismanoid 24:032f3683cb2a 668 #endif
whismanoid 21:ac062a97a71d 669 //
whismanoid 21:ac062a97a71d 670 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 671 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 672 #ifndef HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 673 #define HAS_BUTTON1_DEMO_INTERRUPT_POLLING 1
whismanoid 21:ac062a97a71d 674 #endif
whismanoid 21:ac062a97a71d 675 //
whismanoid 21:ac062a97a71d 676 #ifndef HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 677 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 678 #endif
whismanoid 21:ac062a97a71d 679 #ifndef HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 680 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 681 #endif
whismanoid 21:ac062a97a71d 682 //
whismanoid 21:ac062a97a71d 683 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 684 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 685 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 686 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 687 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 688 # else
whismanoid 21:ac062a97a71d 689 InterruptIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 690 # endif
whismanoid 21:ac062a97a71d 691 #elif HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 692 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 693 #endif
whismanoid 21:ac062a97a71d 694 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 695 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 696 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 697 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 698 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 699 # else
whismanoid 21:ac062a97a71d 700 InterruptIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 701 # endif
whismanoid 21:ac062a97a71d 702 #elif HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 703 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 704 #endif
whismanoid 24:032f3683cb2a 705 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 706 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 24:032f3683cb2a 707 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 24:032f3683cb2a 708 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 24:032f3683cb2a 709 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 710 # else
whismanoid 24:032f3683cb2a 711 InterruptIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 712 # endif
whismanoid 24:032f3683cb2a 713 #elif HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 714 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 715 #endif
whismanoid 21:ac062a97a71d 716
whismanoid 0:cb44e2e9ec4c 717 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 718 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 719 // Declare the DigitalInOut GPIO pins
whismanoid 0:cb44e2e9ec4c 720 // Optional digitalInOut support. If there is only one it should be digitalInOut1.
whismanoid 0:cb44e2e9ec4c 721 // D) Digital High/Low/Input Pin
whismanoid 0:cb44e2e9ec4c 722 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 723 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 724 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 725 // | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 726 // | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 727 // | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 728 // | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 729 // | [ ] AIN_0 1.2Vfs (bat) SYS [ ] |
whismanoid 0:cb44e2e9ec4c 730 // | [ ] AIN_1 1.2Vfs PWR [ ] |
whismanoid 0:cb44e2e9ec4c 731 // | [ ] AIN_2 1.2Vfs +5V VBUS [ ] |
whismanoid 0:cb44e2e9ec4c 732 // | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9
whismanoid 0:cb44e2e9ec4c 733 // dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8
whismanoid 0:cb44e2e9ec4c 734 // dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7
whismanoid 0:cb44e2e9ec4c 735 // dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6
whismanoid 0:cb44e2e9ec4c 736 // dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5
whismanoid 0:cb44e2e9ec4c 737 // dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4
whismanoid 0:cb44e2e9ec4c 738 // dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3
whismanoid 0:cb44e2e9ec4c 739 // dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2
whismanoid 0:cb44e2e9ec4c 740 // | [ ] GND SDA P3_4 [x] | dig1
whismanoid 0:cb44e2e9ec4c 741 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 742 #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 743 #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 744 #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 745 #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 746 #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 747 #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 748 #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 749 #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 750 #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 751 #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 752 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 753 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 754 #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 755 #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 756 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 757 #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 758 #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 759 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 760 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 761 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 762 #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 763 #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 764 #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 765 #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 766 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 767 #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 768 #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 769 #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 770 #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 771 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 772 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 773 DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 774 #endif
whismanoid 0:cb44e2e9ec4c 775 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 776 DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 777 #endif
whismanoid 0:cb44e2e9ec4c 778 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 779 DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 780 #endif
whismanoid 0:cb44e2e9ec4c 781 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 782 DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 783 #endif
whismanoid 0:cb44e2e9ec4c 784 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 785 DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 786 #endif
whismanoid 0:cb44e2e9ec4c 787 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 788 DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 789 #endif
whismanoid 0:cb44e2e9ec4c 790 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 791 DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 792 #endif
whismanoid 0:cb44e2e9ec4c 793 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 794 DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 795 #endif
whismanoid 0:cb44e2e9ec4c 796 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 797 DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 798 #endif
whismanoid 0:cb44e2e9ec4c 799 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 800 DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 801 #endif
whismanoid 0:cb44e2e9ec4c 802 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 803 DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 804 #endif
whismanoid 0:cb44e2e9ec4c 805 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 806 DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 807 #endif
whismanoid 0:cb44e2e9ec4c 808 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 809 DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 810 #endif
whismanoid 0:cb44e2e9ec4c 811 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 812 DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 813 #endif
whismanoid 0:cb44e2e9ec4c 814 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 815 DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 816 #endif
whismanoid 0:cb44e2e9ec4c 817 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 818 DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 819 #endif
whismanoid 0:cb44e2e9ec4c 820 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 821 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 822 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 823 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 824 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 825 // | |
whismanoid 0:cb44e2e9ec4c 826 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 827 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 828 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 829 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 830 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 831 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 832 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 833 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 834 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 835 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 836 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 837 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 838 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 839 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 840 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 841 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 842 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 843 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 844 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 845 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 846 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 847 // \_______________________/
whismanoid 0:cb44e2e9ec4c 848 //
whismanoid 0:cb44e2e9ec4c 849 #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 850 #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 851 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 852 #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 853 #else
whismanoid 0:cb44e2e9ec4c 854 #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 855 #endif
whismanoid 0:cb44e2e9ec4c 856 #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 857 #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 858 #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 859 #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 860 #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 861 #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 862 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 863 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 864 #else
whismanoid 0:cb44e2e9ec4c 865 #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 866 #endif
whismanoid 0:cb44e2e9ec4c 867 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 868 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 869 #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 870 #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 871 #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 872 #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 873 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 874 #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 875 #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 876 #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 877 #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 878 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 879 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 880 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 881 #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 882 #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 883 #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 884 #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 885 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 886 #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 887 #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 888 #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 889 #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 890 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 891 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 892 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 893 #endif
whismanoid 0:cb44e2e9ec4c 894 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 895 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 896 #endif
whismanoid 0:cb44e2e9ec4c 897 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 898 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 899 #endif
whismanoid 0:cb44e2e9ec4c 900 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 901 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 902 #endif
whismanoid 0:cb44e2e9ec4c 903 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 904 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 905 #endif
whismanoid 0:cb44e2e9ec4c 906 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 907 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 908 #endif
whismanoid 0:cb44e2e9ec4c 909 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 910 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 911 #endif
whismanoid 0:cb44e2e9ec4c 912 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 913 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 914 #endif
whismanoid 0:cb44e2e9ec4c 915 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 916 DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 917 #endif
whismanoid 0:cb44e2e9ec4c 918 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 919 DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 920 #endif
whismanoid 0:cb44e2e9ec4c 921 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 922 DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 923 #endif
whismanoid 0:cb44e2e9ec4c 924 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 925 DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 926 #endif
whismanoid 0:cb44e2e9ec4c 927 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 928 DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 929 #endif
whismanoid 0:cb44e2e9ec4c 930 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 931 DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 932 #endif
whismanoid 0:cb44e2e9ec4c 933 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 934 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 935 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 936 DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 937 #endif
whismanoid 0:cb44e2e9ec4c 938 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 939 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 940 DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 941 #endif
whismanoid 0:cb44e2e9ec4c 942 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 943 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 944 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 945 // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V
whismanoid 0:cb44e2e9ec4c 946 DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 947 #endif
whismanoid 0:cb44e2e9ec4c 948 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 949 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 950 DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 951 #endif
whismanoid 0:cb44e2e9ec4c 952 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 953 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 15:37c83ec50ea0 954 // TARGET=MAX32625PICO ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 15:37c83ec50ea0 955 // +-------------[microUSB]-------------+
whismanoid 15:37c83ec50ea0 956 // | [27]D+ D-[26] |
whismanoid 15:37c83ec50ea0 957 // | |
whismanoid 15:37c83ec50ea0 958 // | [BUTTON P2_7] |
whismanoid 15:37c83ec50ea0 959 // | P2_4 LED_R P2_5 LED_G P2_6 LED_B |
whismanoid 15:37c83ec50ea0 960 // | |
whismanoid 15:37c83ec50ea0 961 // 1V8 | [11] 1.8V MAX32625PICO GND [10] | GND
whismanoid 15:37c83ec50ea0 962 // 3V3 | [12] 3.3V +5V [09] | 5V0
whismanoid 15:37c83ec50ea0 963 // SPI CS D7 | [13] P0_7 CS s-ssel P4_7 [08] | D15
whismanoid 15:37c83ec50ea0 964 // SPI MISO D6 | [14] P0_6 MISO s-miso P4_6 [07] | D14
whismanoid 15:37c83ec50ea0 965 // SPI MOSI D5 | [15] P0_5 MOSI s-mosi P4_5 [06] | D13
whismanoid 15:37c83ec50ea0 966 // SPI SCLK D4 | [16] P0_4 SCLK s-sclk P4_4 [05] | D12
whismanoid 15:37c83ec50ea0 967 // D3 | [17] P0_3 RTS SCL P1_7 [04] | SCL/D17
whismanoid 15:37c83ec50ea0 968 // D2 | [18] P0_2 CTS SDA P1_6 [03] | SDA/D16
whismanoid 15:37c83ec50ea0 969 // TX/D1 | [19] P0_1 TX0 AIN_2 [02] | A2
whismanoid 15:37c83ec50ea0 970 // RX/D0 | [20] P0_0 RX0 AIN_0 [01] | A0/A4
whismanoid 15:37c83ec50ea0 971 // | |
whismanoid 15:37c83ec50ea0 972 // | DAPLINK |
whismanoid 15:37c83ec50ea0 973 // | J3 p3_3 p3_2 p3_0 p3_1 p3_7 |
whismanoid 15:37c83ec50ea0 974 // | DAP [ ] [ ] [RX2][TX2][ ] |
whismanoid 15:37c83ec50ea0 975 // | TOP [ ] [ ] [ ] [ ] [ ] |
whismanoid 15:37c83ec50ea0 976 // | AIN1/A5 gnd gnd nc AIN3 |
whismanoid 15:37c83ec50ea0 977 // | IOH 1-wire |
whismanoid 15:37c83ec50ea0 978 // | |
whismanoid 15:37c83ec50ea0 979 // |NO USE RST P2_0 P2_1 |
whismanoid 15:37c83ec50ea0 980 // |BOTTOM [ ] [ ] [RX1][ ] [TX1] |
whismanoid 15:37c83ec50ea0 981 // | RST SWC GND SWD 1V8 |
whismanoid 15:37c83ec50ea0 982 // |BOTTOM [21] [22] [23] [24] [25] |
whismanoid 15:37c83ec50ea0 983 // +------------------------------------+
whismanoid 15:37c83ec50ea0 984 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 985 // MAX40108 demo p2: D0..D7 = P0_0..P0_7; D8..15 = P4_0..P4_7; D16/D17=I2C
whismanoid 15:37c83ec50ea0 986 #endif
whismanoid 15:37c83ec50ea0 987 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 988 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 989 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 990 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 991 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 992 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 993 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 994 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 995 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 996 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 15:37c83ec50ea0 997 // AIN_10 = x undefined?
whismanoid 15:37c83ec50ea0 998 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 999 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 1000 //
whismanoid 15:37c83ec50ea0 1001 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 1002 // avoid resource conflict D0,D1 alternate function as RX/TX
whismanoid 15:37c83ec50ea0 1003 #define HAS_digitalInOut0 0
whismanoid 15:37c83ec50ea0 1004 #define HAS_digitalInOut1 0
whismanoid 15:37c83ec50ea0 1005 #else
whismanoid 15:37c83ec50ea0 1006 #define HAS_digitalInOut0 1
whismanoid 19:5ff09c8e9daf 1007 #define HAS_digitalInOut1 1
whismanoid 19:5ff09c8e9daf 1008 // P0_1 TARGET_MAX32625PICO D1
whismanoid 15:37c83ec50ea0 1009 #endif
whismanoid 15:37c83ec50ea0 1010 #if APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 1011 // avoid resource conflict D2 alternate function as interrupt input
whismanoid 15:37c83ec50ea0 1012 #define HAS_digitalInOut2 0
whismanoid 15:37c83ec50ea0 1013 #else
whismanoid 15:37c83ec50ea0 1014 #define HAS_digitalInOut2 1
whismanoid 15:37c83ec50ea0 1015 #endif
whismanoid 15:37c83ec50ea0 1016 #define HAS_digitalInOut3 1
whismanoid 15:37c83ec50ea0 1017 #define HAS_digitalInOut4 1
whismanoid 15:37c83ec50ea0 1018 #define HAS_digitalInOut5 1
whismanoid 15:37c83ec50ea0 1019 #define HAS_digitalInOut6 1
whismanoid 15:37c83ec50ea0 1020 #define HAS_digitalInOut7 1
whismanoid 15:37c83ec50ea0 1021 //
whismanoid 15:37c83ec50ea0 1022 #define HAS_digitalInOut8 1
whismanoid 15:37c83ec50ea0 1023 #define HAS_digitalInOut9 1
whismanoid 15:37c83ec50ea0 1024 #define HAS_digitalInOut10 1
whismanoid 15:37c83ec50ea0 1025 #define HAS_digitalInOut11 1
whismanoid 15:37c83ec50ea0 1026 #define HAS_digitalInOut12 1
whismanoid 15:37c83ec50ea0 1027 #define HAS_digitalInOut13 1
whismanoid 15:37c83ec50ea0 1028 #define HAS_digitalInOut14 1
whismanoid 15:37c83ec50ea0 1029 #define HAS_digitalInOut15 1
whismanoid 15:37c83ec50ea0 1030 #if HAS_I2C
whismanoid 25:8a61cb34191d 1031 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 1032 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 25:8a61cb34191d 1033 // #define BUTTON2 P3_7
whismanoid 25:8a61cb34191d 1034 // avoid resource conflict between I2C and DigitalInOut
whismanoid 25:8a61cb34191d 1035 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1036 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 1037 #else // HAS_I2C
whismanoid 25:8a61cb34191d 1038 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 1039 // 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 1040 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1041 // #define BUTTON2 P1_7
whismanoid 25:8a61cb34191d 1042 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1043 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1044 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1045 #else // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1046 #define HAS_digitalInOut16 1 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1047 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1048 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1049 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1050 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1051 #else // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1052 #define HAS_digitalInOut17 1 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1053 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 15:37c83ec50ea0 1054 #endif // HAS_I2C
whismanoid 15:37c83ec50ea0 1055 #if HAS_digitalInOut0
whismanoid 25:8a61cb34191d 1056 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D0
whismanoid 15:37c83ec50ea0 1057 #endif
whismanoid 15:37c83ec50ea0 1058 #if HAS_digitalInOut1
whismanoid 25:8a61cb34191d 1059 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D1
whismanoid 15:37c83ec50ea0 1060 #endif
whismanoid 15:37c83ec50ea0 1061 #if HAS_digitalInOut2
whismanoid 25:8a61cb34191d 1062 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D2
whismanoid 15:37c83ec50ea0 1063 #endif
whismanoid 15:37c83ec50ea0 1064 #if HAS_digitalInOut3
whismanoid 25:8a61cb34191d 1065 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D3
whismanoid 15:37c83ec50ea0 1066 #endif
whismanoid 15:37c83ec50ea0 1067 #if HAS_digitalInOut4
whismanoid 25:8a61cb34191d 1068 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D4
whismanoid 15:37c83ec50ea0 1069 #endif
whismanoid 15:37c83ec50ea0 1070 #if HAS_digitalInOut5
whismanoid 25:8a61cb34191d 1071 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D5
whismanoid 15:37c83ec50ea0 1072 #endif
whismanoid 15:37c83ec50ea0 1073 #if HAS_digitalInOut6
whismanoid 25:8a61cb34191d 1074 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D6
whismanoid 15:37c83ec50ea0 1075 #endif
whismanoid 15:37c83ec50ea0 1076 #if HAS_digitalInOut7
whismanoid 25:8a61cb34191d 1077 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D7
whismanoid 15:37c83ec50ea0 1078 #endif
whismanoid 15:37c83ec50ea0 1079 #if HAS_digitalInOut8
whismanoid 25:8a61cb34191d 1080 DigitalInOut digitalInOut8(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX40108DEMOP2U9 D8
whismanoid 15:37c83ec50ea0 1081 #endif
whismanoid 15:37c83ec50ea0 1082 #if HAS_digitalInOut9
whismanoid 25:8a61cb34191d 1083 DigitalInOut digitalInOut9(P4_1, PIN_INPUT, PullUp, 1); // P4_1 TARGET_MAX40108DEMOP2U9 D9
whismanoid 15:37c83ec50ea0 1084 #endif
whismanoid 15:37c83ec50ea0 1085 #if HAS_digitalInOut10
whismanoid 25:8a61cb34191d 1086 DigitalInOut digitalInOut10(P4_2, PIN_INPUT, PullUp, 1); // P4_2 TARGET_MAX40108DEMOP2U9 D10
whismanoid 15:37c83ec50ea0 1087 #endif
whismanoid 15:37c83ec50ea0 1088 #if HAS_digitalInOut11
whismanoid 25:8a61cb34191d 1089 DigitalInOut digitalInOut11(P4_3, PIN_INPUT, PullUp, 1); // P4_3 TARGET_MAX40108DEMOP2U9 D11
whismanoid 15:37c83ec50ea0 1090 #endif
whismanoid 15:37c83ec50ea0 1091 #if HAS_digitalInOut12
whismanoid 25:8a61cb34191d 1092 DigitalInOut digitalInOut12(P4_4, PIN_INPUT, PullUp, 1); // P4_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D12
whismanoid 15:37c83ec50ea0 1093 #endif
whismanoid 15:37c83ec50ea0 1094 #if HAS_digitalInOut13
whismanoid 25:8a61cb34191d 1095 DigitalInOut digitalInOut13(P4_5, PIN_INPUT, PullUp, 1); // P4_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D13
whismanoid 15:37c83ec50ea0 1096 #endif
whismanoid 15:37c83ec50ea0 1097 #if HAS_digitalInOut14
whismanoid 25:8a61cb34191d 1098 DigitalInOut digitalInOut14(P4_6, PIN_INPUT, PullUp, 1); // P4_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D14
whismanoid 15:37c83ec50ea0 1099 #endif
whismanoid 15:37c83ec50ea0 1100 #if HAS_digitalInOut15
whismanoid 25:8a61cb34191d 1101 DigitalInOut digitalInOut15(P4_7, PIN_INPUT, PullUp, 1); // P4_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D15
whismanoid 15:37c83ec50ea0 1102 #endif
whismanoid 15:37c83ec50ea0 1103 #if HAS_digitalInOut16
whismanoid 15:37c83ec50ea0 1104 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 15:37c83ec50ea0 1105 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 25:8a61cb34191d 1106 DigitalInOut digitalInOut16(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 15:37c83ec50ea0 1107 #endif
whismanoid 15:37c83ec50ea0 1108 #if HAS_digitalInOut17
whismanoid 15:37c83ec50ea0 1109 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 25:8a61cb34191d 1110 DigitalInOut digitalInOut17(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 1111 #endif
whismanoid 15:37c83ec50ea0 1112 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1113 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1114 #define HAS_digitalInOut0 0
whismanoid 0:cb44e2e9ec4c 1115 #define HAS_digitalInOut1 0
whismanoid 0:cb44e2e9ec4c 1116 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1117 // D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 1118 #define HAS_digitalInOut2 0
whismanoid 0:cb44e2e9ec4c 1119 #else
whismanoid 0:cb44e2e9ec4c 1120 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1121 #endif
whismanoid 0:cb44e2e9ec4c 1122 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1123 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1124 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1125 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1126 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1127 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1128 // D8 -- MAX5715 CLRb DigitalOut
whismanoid 0:cb44e2e9ec4c 1129 #define HAS_digitalInOut8 0
whismanoid 0:cb44e2e9ec4c 1130 #else
whismanoid 0:cb44e2e9ec4c 1131 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1132 #endif
whismanoid 0:cb44e2e9ec4c 1133 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1134 // D9 -- MAX5715 LDACb DigitalOut
whismanoid 0:cb44e2e9ec4c 1135 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1136 #elif APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1137 // D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 1138 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1139 #else
whismanoid 0:cb44e2e9ec4c 1140 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1141 #endif
whismanoid 0:cb44e2e9ec4c 1142 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 1143 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1144 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1145 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1146 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1147 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1148 #define HAS_digitalInOut10 0
whismanoid 0:cb44e2e9ec4c 1149 #define HAS_digitalInOut11 0
whismanoid 0:cb44e2e9ec4c 1150 #define HAS_digitalInOut12 0
whismanoid 0:cb44e2e9ec4c 1151 #define HAS_digitalInOut13 0
whismanoid 0:cb44e2e9ec4c 1152 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1153 #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1154 #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1155 #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1156 #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1157 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1158 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 1159 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1160 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1161 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1162 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1163 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1164 #define HAS_digitalInOut14 0
whismanoid 0:cb44e2e9ec4c 1165 #define HAS_digitalInOut15 0
whismanoid 0:cb44e2e9ec4c 1166 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1167 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1168 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1169 #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1170 #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1171 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1172 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1173 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1174 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1175 DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1176 #endif
whismanoid 0:cb44e2e9ec4c 1177 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1178 DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1179 #endif
whismanoid 0:cb44e2e9ec4c 1180 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1181 DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1182 #endif
whismanoid 0:cb44e2e9ec4c 1183 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1184 DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1185 #endif
whismanoid 0:cb44e2e9ec4c 1186 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1187 DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1188 #endif
whismanoid 0:cb44e2e9ec4c 1189 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1190 DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1191 #endif
whismanoid 0:cb44e2e9ec4c 1192 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1193 DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1194 #endif
whismanoid 0:cb44e2e9ec4c 1195 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1196 DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1197 #endif
whismanoid 0:cb44e2e9ec4c 1198 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1199 DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1200 #endif
whismanoid 0:cb44e2e9ec4c 1201 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1202 DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1203 #endif
whismanoid 0:cb44e2e9ec4c 1204 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1205 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1206 DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1207 #endif
whismanoid 0:cb44e2e9ec4c 1208 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1209 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1210 DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1211 #endif
whismanoid 0:cb44e2e9ec4c 1212 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1213 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1214 DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1215 #endif
whismanoid 0:cb44e2e9ec4c 1216 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1217 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1218 DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1219 #endif
whismanoid 0:cb44e2e9ec4c 1220 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1221 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1222 DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1223 #endif
whismanoid 0:cb44e2e9ec4c 1224 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1225 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1226 DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1227 #endif
whismanoid 0:cb44e2e9ec4c 1228 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1229 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1230 DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1231 #endif
whismanoid 0:cb44e2e9ec4c 1232 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1233 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1234 DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1235 #endif
whismanoid 0:cb44e2e9ec4c 1236 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1237 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1238 #define HAS_digitalInOut0 1
whismanoid 0:cb44e2e9ec4c 1239 #define HAS_digitalInOut1 1
whismanoid 0:cb44e2e9ec4c 1240 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1241 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1242 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1243 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1244 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1245 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1246 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1247 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1248 // #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1249 // #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1250 // #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1251 // #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1252 // #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1253 // #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1254 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1255 DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3
whismanoid 0:cb44e2e9ec4c 1256 #endif
whismanoid 0:cb44e2e9ec4c 1257 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1258 DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2
whismanoid 0:cb44e2e9ec4c 1259 #endif
whismanoid 0:cb44e2e9ec4c 1260 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1261 DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1
whismanoid 0:cb44e2e9ec4c 1262 #endif
whismanoid 0:cb44e2e9ec4c 1263 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1264 DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0
whismanoid 0:cb44e2e9ec4c 1265 #endif
whismanoid 0:cb44e2e9ec4c 1266 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1267 DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1
whismanoid 0:cb44e2e9ec4c 1268 #endif
whismanoid 0:cb44e2e9ec4c 1269 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1270 DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1
whismanoid 0:cb44e2e9ec4c 1271 #endif
whismanoid 0:cb44e2e9ec4c 1272 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1273 DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1
whismanoid 0:cb44e2e9ec4c 1274 #endif
whismanoid 0:cb44e2e9ec4c 1275 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1276 DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO
whismanoid 0:cb44e2e9ec4c 1277 #endif
whismanoid 0:cb44e2e9ec4c 1278 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1279 DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK
whismanoid 0:cb44e2e9ec4c 1280 #endif
whismanoid 0:cb44e2e9ec4c 1281 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1282 DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL
whismanoid 0:cb44e2e9ec4c 1283 #endif
whismanoid 0:cb44e2e9ec4c 1284 //
whismanoid 0:cb44e2e9ec4c 1285 // these pins support analog input analogIn0 .. analogIn5
whismanoid 0:cb44e2e9ec4c 1286 //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1287 //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1288 //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1289 //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1290 //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1291 //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1292 //
whismanoid 0:cb44e2e9ec4c 1293 // these pins support PWM pwmDriver1 .. pwmDriver6
whismanoid 0:cb44e2e9ec4c 1294 //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0
whismanoid 0:cb44e2e9ec4c 1295 //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1
whismanoid 0:cb44e2e9ec4c 1296 //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2
whismanoid 0:cb44e2e9ec4c 1297 //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3
whismanoid 0:cb44e2e9ec4c 1298 //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1
whismanoid 0:cb44e2e9ec4c 1299 //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK
whismanoid 0:cb44e2e9ec4c 1300 //
whismanoid 0:cb44e2e9ec4c 1301 // these could be additional digitalInOut pins
whismanoid 0:cb44e2e9ec4c 1302 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1303 DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1
whismanoid 0:cb44e2e9ec4c 1304 #endif
whismanoid 0:cb44e2e9ec4c 1305 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1306 DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0
whismanoid 0:cb44e2e9ec4c 1307 #endif
whismanoid 0:cb44e2e9ec4c 1308 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1309 DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1
whismanoid 0:cb44e2e9ec4c 1310 #endif
whismanoid 0:cb44e2e9ec4c 1311 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1312 DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0
whismanoid 0:cb44e2e9ec4c 1313 #endif
whismanoid 0:cb44e2e9ec4c 1314 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1315 DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1316 #endif
whismanoid 0:cb44e2e9ec4c 1317 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1318 DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1319 #endif
whismanoid 0:cb44e2e9ec4c 1320 #else
whismanoid 0:cb44e2e9ec4c 1321 // unknown target
whismanoid 0:cb44e2e9ec4c 1322 #endif
whismanoid 0:cb44e2e9ec4c 1323 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1324 #if HAS_digitalInOut0 || HAS_digitalInOut1 \
whismanoid 0:cb44e2e9ec4c 1325 || HAS_digitalInOut2 || HAS_digitalInOut3 \
whismanoid 0:cb44e2e9ec4c 1326 || HAS_digitalInOut4 || HAS_digitalInOut5 \
whismanoid 0:cb44e2e9ec4c 1327 || HAS_digitalInOut6 || HAS_digitalInOut7 \
whismanoid 0:cb44e2e9ec4c 1328 || HAS_digitalInOut8 || HAS_digitalInOut9 \
whismanoid 0:cb44e2e9ec4c 1329 || HAS_digitalInOut10 || HAS_digitalInOut11 \
whismanoid 0:cb44e2e9ec4c 1330 || HAS_digitalInOut12 || HAS_digitalInOut13 \
whismanoid 0:cb44e2e9ec4c 1331 || HAS_digitalInOut14 || HAS_digitalInOut15 \
whismanoid 0:cb44e2e9ec4c 1332 || HAS_digitalInOut16 || HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1333 #define HAS_digitalInOuts 1
whismanoid 0:cb44e2e9ec4c 1334 #else
whismanoid 0:cb44e2e9ec4c 1335 #warning "Note: There are no digitalInOut resources defined"
whismanoid 0:cb44e2e9ec4c 1336 #endif
whismanoid 0:cb44e2e9ec4c 1337
whismanoid 0:cb44e2e9ec4c 1338 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 1339 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1340 // Declare the AnalogIn driver
whismanoid 0:cb44e2e9ec4c 1341 // Optional analogIn support. If there is only one it should be analogIn1.
whismanoid 0:cb44e2e9ec4c 1342 // A) analog input
whismanoid 0:cb44e2e9ec4c 1343 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1344 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1345 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1346 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1347 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1348 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1349 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1350 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1351 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1352 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1353 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1354 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1355 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1356 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1357 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1358 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1359 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1360 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1361 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1362 #endif
whismanoid 0:cb44e2e9ec4c 1363 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1364 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1365 #endif
whismanoid 0:cb44e2e9ec4c 1366 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1367 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1368 #endif
whismanoid 0:cb44e2e9ec4c 1369 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1370 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1371 #endif
whismanoid 0:cb44e2e9ec4c 1372 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1373 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1374 #endif
whismanoid 0:cb44e2e9ec4c 1375 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1376 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1377 #endif
whismanoid 0:cb44e2e9ec4c 1378 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1379 AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1380 #endif
whismanoid 0:cb44e2e9ec4c 1381 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1382 AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1383 #endif
whismanoid 0:cb44e2e9ec4c 1384 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1385 AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1386 #endif
whismanoid 0:cb44e2e9ec4c 1387 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1388 AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1389 #endif
whismanoid 0:cb44e2e9ec4c 1390 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1391 AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1392 #endif
whismanoid 0:cb44e2e9ec4c 1393 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1394 AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1395 #endif
whismanoid 0:cb44e2e9ec4c 1396 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1397 AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1398 #endif
whismanoid 0:cb44e2e9ec4c 1399 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1400 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1401 #endif
whismanoid 0:cb44e2e9ec4c 1402 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1403 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1404 #endif
whismanoid 0:cb44e2e9ec4c 1405 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1406 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1407 #endif
whismanoid 0:cb44e2e9ec4c 1408 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1409 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 1410 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1411 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1412 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1413 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1414 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1415 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1416 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1417 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1418 #endif
whismanoid 0:cb44e2e9ec4c 1419 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1420 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1421 #endif
whismanoid 0:cb44e2e9ec4c 1422 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1423 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1424 #endif
whismanoid 0:cb44e2e9ec4c 1425 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1426 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1427 #endif
whismanoid 0:cb44e2e9ec4c 1428 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1429 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1430 #endif
whismanoid 0:cb44e2e9ec4c 1431 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1432 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1433 #endif
whismanoid 0:cb44e2e9ec4c 1434 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1435 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 1436 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1437 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1438 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1439 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1440 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1441 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1442 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1443 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1444 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1445 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1446 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1447 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1448 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1449 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1450 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1451 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1452 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1453 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1454 AnalogIn analogIn0(AIN_0); // TARGET_MAX32620FTHR J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1455 #endif
whismanoid 0:cb44e2e9ec4c 1456 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1457 AnalogIn analogIn1(AIN_1); // TARGET_MAX32620FTHR J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1458 #endif
whismanoid 0:cb44e2e9ec4c 1459 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1460 AnalogIn analogIn2(AIN_2); // TARGET_MAX32620FTHR J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1461 #endif
whismanoid 0:cb44e2e9ec4c 1462 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1463 AnalogIn analogIn3(AIN_3); // TARGET_MAX32620FTHR J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1464 #endif
whismanoid 0:cb44e2e9ec4c 1465 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1466 AnalogIn analogIn4(AIN_4); // TARGET_MAX32620FTHR J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1467 #endif
whismanoid 0:cb44e2e9ec4c 1468 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1469 AnalogIn analogIn5(AIN_5); // TARGET_MAX32620FTHR J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1470 #endif
whismanoid 0:cb44e2e9ec4c 1471 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1472 AnalogIn analogIn6(AIN_6); // TARGET_MAX32620FTHR AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1473 #endif
whismanoid 0:cb44e2e9ec4c 1474 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1475 AnalogIn analogIn7(AIN_7); // TARGET_MAX32620FTHR AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1476 #endif
whismanoid 0:cb44e2e9ec4c 1477 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1478 AnalogIn analogIn8(AIN_8); // TARGET_MAX32620FTHR AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1479 #endif
whismanoid 0:cb44e2e9ec4c 1480 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1481 AnalogIn analogIn9(AIN_9); // TARGET_MAX32620FTHR AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1482 #endif
whismanoid 0:cb44e2e9ec4c 1483 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1484 AnalogIn analogIn10(____); // TARGET_MAX32620FTHR AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1485 #endif
whismanoid 0:cb44e2e9ec4c 1486 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1487 AnalogIn analogIn11(____); // TARGET_MAX32620FTHR AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1488 #endif
whismanoid 0:cb44e2e9ec4c 1489 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1490 AnalogIn analogIn12(____); // TARGET_MAX32620FTHR AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1491 #endif
whismanoid 0:cb44e2e9ec4c 1492 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1493 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1494 #endif
whismanoid 0:cb44e2e9ec4c 1495 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1496 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1497 #endif
whismanoid 0:cb44e2e9ec4c 1498 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1499 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1500 #endif
whismanoid 0:cb44e2e9ec4c 1501 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 1502 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 37:3f369235e5bc 1503 // #warning "TARGET_MAX32625PICO not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1504 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1505 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1506 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1507 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1508 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1509 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1510 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1511 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1512 #endif
whismanoid 0:cb44e2e9ec4c 1513 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1514 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1515 #endif
whismanoid 0:cb44e2e9ec4c 1516 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1517 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1518 #endif
whismanoid 0:cb44e2e9ec4c 1519 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1520 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1521 #endif
whismanoid 0:cb44e2e9ec4c 1522 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1523 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1524 #endif
whismanoid 0:cb44e2e9ec4c 1525 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1526 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1527 #endif
whismanoid 0:cb44e2e9ec4c 1528 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1529 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 1530 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1531 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1532 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1533 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1534 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1535 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1536 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1537 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1538 #endif
whismanoid 0:cb44e2e9ec4c 1539 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1540 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1541 #endif
whismanoid 0:cb44e2e9ec4c 1542 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1543 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1544 #endif
whismanoid 0:cb44e2e9ec4c 1545 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1546 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1547 #endif
whismanoid 0:cb44e2e9ec4c 1548 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1549 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1550 #endif
whismanoid 0:cb44e2e9ec4c 1551 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1552 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1553 #endif
whismanoid 0:cb44e2e9ec4c 1554 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1555 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 1556 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1557 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1558 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1559 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1560 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1561 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1562 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1563 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1564 #endif
whismanoid 0:cb44e2e9ec4c 1565 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1566 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1567 #endif
whismanoid 0:cb44e2e9ec4c 1568 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1569 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1570 #endif
whismanoid 0:cb44e2e9ec4c 1571 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1572 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1573 #endif
whismanoid 0:cb44e2e9ec4c 1574 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1575 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1576 #endif
whismanoid 0:cb44e2e9ec4c 1577 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1578 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1579 #endif
whismanoid 0:cb44e2e9ec4c 1580 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1581 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1582 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1583 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1584 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1585 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1586 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1587 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1588 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1589 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1590 #endif
whismanoid 0:cb44e2e9ec4c 1591 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1592 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1593 #endif
whismanoid 0:cb44e2e9ec4c 1594 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1595 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1596 #endif
whismanoid 0:cb44e2e9ec4c 1597 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1598 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1599 #endif
whismanoid 0:cb44e2e9ec4c 1600 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1601 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1602 #endif
whismanoid 0:cb44e2e9ec4c 1603 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1604 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1605 #endif
whismanoid 0:cb44e2e9ec4c 1606 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1607 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 1608 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1609 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1610 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1611 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1612 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1613 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1614 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1615 // #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1616 // #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1617 // #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1618 // #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1619 // #define HAS_analogIn10 1
whismanoid 0:cb44e2e9ec4c 1620 // #define HAS_analogIn11 1
whismanoid 0:cb44e2e9ec4c 1621 // #define HAS_analogIn12 1
whismanoid 0:cb44e2e9ec4c 1622 // #define HAS_analogIn13 1
whismanoid 0:cb44e2e9ec4c 1623 // #define HAS_analogIn14 1
whismanoid 0:cb44e2e9ec4c 1624 // #define HAS_analogIn15 1
whismanoid 0:cb44e2e9ec4c 1625 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1626 AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1627 #endif
whismanoid 0:cb44e2e9ec4c 1628 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1629 AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1630 #endif
whismanoid 0:cb44e2e9ec4c 1631 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1632 AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1633 #endif
whismanoid 0:cb44e2e9ec4c 1634 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1635 AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1636 #endif
whismanoid 0:cb44e2e9ec4c 1637 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1638 AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1639 #endif
whismanoid 0:cb44e2e9ec4c 1640 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1641 AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1642 #endif
whismanoid 0:cb44e2e9ec4c 1643 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1644 AnalogIn analogIn6(____);
whismanoid 0:cb44e2e9ec4c 1645 #endif
whismanoid 0:cb44e2e9ec4c 1646 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1647 AnalogIn analogIn7(____);
whismanoid 0:cb44e2e9ec4c 1648 #endif
whismanoid 0:cb44e2e9ec4c 1649 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1650 AnalogIn analogIn8(____);
whismanoid 0:cb44e2e9ec4c 1651 #endif
whismanoid 0:cb44e2e9ec4c 1652 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1653 AnalogIn analogIn9(____);
whismanoid 0:cb44e2e9ec4c 1654 #endif
whismanoid 0:cb44e2e9ec4c 1655 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1656 AnalogIn analogIn10(____);
whismanoid 0:cb44e2e9ec4c 1657 #endif
whismanoid 0:cb44e2e9ec4c 1658 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1659 AnalogIn analogIn11(____);
whismanoid 0:cb44e2e9ec4c 1660 #endif
whismanoid 0:cb44e2e9ec4c 1661 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1662 AnalogIn analogIn12(____);
whismanoid 0:cb44e2e9ec4c 1663 #endif
whismanoid 0:cb44e2e9ec4c 1664 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1665 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1666 #endif
whismanoid 0:cb44e2e9ec4c 1667 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1668 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1669 #endif
whismanoid 0:cb44e2e9ec4c 1670 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1671 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1672 #endif
whismanoid 0:cb44e2e9ec4c 1673 #else
whismanoid 0:cb44e2e9ec4c 1674 // unknown target
whismanoid 0:cb44e2e9ec4c 1675 #endif
whismanoid 0:cb44e2e9ec4c 1676 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1677 #if HAS_analogIn0 || HAS_analogIn1 \
whismanoid 0:cb44e2e9ec4c 1678 || HAS_analogIn2 || HAS_analogIn3 \
whismanoid 0:cb44e2e9ec4c 1679 || HAS_analogIn4 || HAS_analogIn5 \
whismanoid 0:cb44e2e9ec4c 1680 || HAS_analogIn6 || HAS_analogIn7 \
whismanoid 0:cb44e2e9ec4c 1681 || HAS_analogIn8 || HAS_analogIn9 \
whismanoid 0:cb44e2e9ec4c 1682 || HAS_analogIn10 || HAS_analogIn11 \
whismanoid 0:cb44e2e9ec4c 1683 || HAS_analogIn12 || HAS_analogIn13 \
whismanoid 0:cb44e2e9ec4c 1684 || HAS_analogIn14 || HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1685 #define HAS_analogIns 1
whismanoid 0:cb44e2e9ec4c 1686 #else
whismanoid 0:cb44e2e9ec4c 1687 #warning "Note: There are no analogIn resources defined"
whismanoid 0:cb44e2e9ec4c 1688 #endif
whismanoid 0:cb44e2e9ec4c 1689
whismanoid 0:cb44e2e9ec4c 1690 // DigitalInOut pin resource: print the pin index names to serial
whismanoid 0:cb44e2e9ec4c 1691 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 1692 void list_digitalInOutPins(Stream& serialStream)
whismanoid 0:cb44e2e9ec4c 1693 {
whismanoid 0:cb44e2e9ec4c 1694 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1695 serialStream.printf(" 0");
whismanoid 0:cb44e2e9ec4c 1696 #endif
whismanoid 0:cb44e2e9ec4c 1697 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1698 serialStream.printf(" 1");
whismanoid 0:cb44e2e9ec4c 1699 #endif
whismanoid 0:cb44e2e9ec4c 1700 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1701 serialStream.printf(" 2");
whismanoid 0:cb44e2e9ec4c 1702 #endif
whismanoid 0:cb44e2e9ec4c 1703 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1704 serialStream.printf(" 3");
whismanoid 0:cb44e2e9ec4c 1705 #endif
whismanoid 0:cb44e2e9ec4c 1706 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1707 serialStream.printf(" 4");
whismanoid 0:cb44e2e9ec4c 1708 #endif
whismanoid 0:cb44e2e9ec4c 1709 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1710 serialStream.printf(" 5");
whismanoid 0:cb44e2e9ec4c 1711 #endif
whismanoid 0:cb44e2e9ec4c 1712 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1713 serialStream.printf(" 6");
whismanoid 0:cb44e2e9ec4c 1714 #endif
whismanoid 0:cb44e2e9ec4c 1715 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1716 serialStream.printf(" 7");
whismanoid 0:cb44e2e9ec4c 1717 #endif
whismanoid 0:cb44e2e9ec4c 1718 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1719 serialStream.printf(" 8");
whismanoid 0:cb44e2e9ec4c 1720 #endif
whismanoid 0:cb44e2e9ec4c 1721 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1722 serialStream.printf(" 9");
whismanoid 0:cb44e2e9ec4c 1723 #endif
whismanoid 0:cb44e2e9ec4c 1724 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1725 serialStream.printf(" 10");
whismanoid 0:cb44e2e9ec4c 1726 #endif
whismanoid 0:cb44e2e9ec4c 1727 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1728 serialStream.printf(" 11");
whismanoid 0:cb44e2e9ec4c 1729 #endif
whismanoid 0:cb44e2e9ec4c 1730 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1731 serialStream.printf(" 12");
whismanoid 0:cb44e2e9ec4c 1732 #endif
whismanoid 0:cb44e2e9ec4c 1733 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1734 serialStream.printf(" 13");
whismanoid 0:cb44e2e9ec4c 1735 #endif
whismanoid 0:cb44e2e9ec4c 1736 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1737 serialStream.printf(" 14");
whismanoid 0:cb44e2e9ec4c 1738 #endif
whismanoid 0:cb44e2e9ec4c 1739 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1740 serialStream.printf(" 15");
whismanoid 0:cb44e2e9ec4c 1741 #endif
whismanoid 0:cb44e2e9ec4c 1742 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1743 serialStream.printf(" 16");
whismanoid 0:cb44e2e9ec4c 1744 #endif
whismanoid 0:cb44e2e9ec4c 1745 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1746 serialStream.printf(" 17");
whismanoid 0:cb44e2e9ec4c 1747 #endif
whismanoid 18:1235c17b451e 1748 #if USE_LEDS
whismanoid 18:1235c17b451e 1749 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 1750 // support list_digitalInOutPins() listing buttons and leds as pin numbers 90/91/92/93
whismanoid 18:1235c17b451e 1751 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 1752 //~ serialStream.printf(" 90");
whismanoid 18:1235c17b451e 1753 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 1754 serialStream.printf(" 91");
whismanoid 18:1235c17b451e 1755 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 1756 serialStream.printf(" 92");
whismanoid 18:1235c17b451e 1757 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 1758 serialStream.printf(" 93");
whismanoid 18:1235c17b451e 1759 #else // USE_LEDS
whismanoid 18:1235c17b451e 1760 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 1761 }
whismanoid 0:cb44e2e9ec4c 1762 #endif
whismanoid 0:cb44e2e9ec4c 1763
whismanoid 0:cb44e2e9ec4c 1764
whismanoid 0:cb44e2e9ec4c 1765 // DigitalInOut pin resource: search index
whismanoid 0:cb44e2e9ec4c 1766 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 1767 DigitalInOut& find_digitalInOutPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 1768 {
whismanoid 0:cb44e2e9ec4c 1769 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 1770 {
whismanoid 0:cb44e2e9ec4c 1771 default: // default to the first defined digitalInOut pin
whismanoid 0:cb44e2e9ec4c 1772 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1773 case '0': case 0x00: return digitalInOut0;
whismanoid 0:cb44e2e9ec4c 1774 #endif
whismanoid 0:cb44e2e9ec4c 1775 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1776 case '1': case 0x01: return digitalInOut1;
whismanoid 0:cb44e2e9ec4c 1777 #endif
whismanoid 0:cb44e2e9ec4c 1778 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1779 case '2': case 0x02: return digitalInOut2;
whismanoid 0:cb44e2e9ec4c 1780 #endif
whismanoid 0:cb44e2e9ec4c 1781 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1782 case '3': case 0x03: return digitalInOut3;
whismanoid 0:cb44e2e9ec4c 1783 #endif
whismanoid 0:cb44e2e9ec4c 1784 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1785 case '4': case 0x04: return digitalInOut4;
whismanoid 0:cb44e2e9ec4c 1786 #endif
whismanoid 0:cb44e2e9ec4c 1787 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1788 case '5': case 0x05: return digitalInOut5;
whismanoid 0:cb44e2e9ec4c 1789 #endif
whismanoid 0:cb44e2e9ec4c 1790 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1791 case '6': case 0x06: return digitalInOut6;
whismanoid 0:cb44e2e9ec4c 1792 #endif
whismanoid 0:cb44e2e9ec4c 1793 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1794 case '7': case 0x07: return digitalInOut7;
whismanoid 0:cb44e2e9ec4c 1795 #endif
whismanoid 0:cb44e2e9ec4c 1796 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1797 case '8': case 0x08: return digitalInOut8;
whismanoid 0:cb44e2e9ec4c 1798 #endif
whismanoid 0:cb44e2e9ec4c 1799 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1800 case '9': case 0x09: return digitalInOut9;
whismanoid 0:cb44e2e9ec4c 1801 #endif
whismanoid 0:cb44e2e9ec4c 1802 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1803 case 'a': case 0x0a: return digitalInOut10;
whismanoid 0:cb44e2e9ec4c 1804 #endif
whismanoid 0:cb44e2e9ec4c 1805 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1806 case 'b': case 0x0b: return digitalInOut11;
whismanoid 0:cb44e2e9ec4c 1807 #endif
whismanoid 0:cb44e2e9ec4c 1808 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1809 case 'c': case 0x0c: return digitalInOut12;
whismanoid 0:cb44e2e9ec4c 1810 #endif
whismanoid 0:cb44e2e9ec4c 1811 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1812 case 'd': case 0x0d: return digitalInOut13;
whismanoid 0:cb44e2e9ec4c 1813 #endif
whismanoid 0:cb44e2e9ec4c 1814 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1815 case 'e': case 0x0e: return digitalInOut14;
whismanoid 0:cb44e2e9ec4c 1816 #endif
whismanoid 0:cb44e2e9ec4c 1817 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1818 case 'f': case 0x0f: return digitalInOut15;
whismanoid 0:cb44e2e9ec4c 1819 #endif
whismanoid 0:cb44e2e9ec4c 1820 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1821 case 'g': case 0x10: return digitalInOut16;
whismanoid 0:cb44e2e9ec4c 1822 #endif
whismanoid 0:cb44e2e9ec4c 1823 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1824 case 'h': case 0x11: return digitalInOut17;
whismanoid 0:cb44e2e9ec4c 1825 #endif
whismanoid 18:1235c17b451e 1826 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 1827 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 1828 //~ case 90: return button1;
whismanoid 18:1235c17b451e 1829 #if USE_LEDS
whismanoid 18:1235c17b451e 1830 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 1831 case 91: return led1_RFailLED;
whismanoid 18:1235c17b451e 1832 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 1833 case 92: return led2_GPassLED;
whismanoid 18:1235c17b451e 1834 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 1835 case 93: return led3_BBusyLED;
whismanoid 18:1235c17b451e 1836 #else // USE_LEDS
whismanoid 18:1235c17b451e 1837 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 1838 }
whismanoid 0:cb44e2e9ec4c 1839 }
whismanoid 0:cb44e2e9ec4c 1840 #endif
whismanoid 0:cb44e2e9ec4c 1841
whismanoid 0:cb44e2e9ec4c 1842
whismanoid 0:cb44e2e9ec4c 1843 // AnalogIn pin resource: search index
whismanoid 0:cb44e2e9ec4c 1844 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 1845 AnalogIn& find_analogInPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 1846 {
whismanoid 0:cb44e2e9ec4c 1847 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 1848 {
whismanoid 0:cb44e2e9ec4c 1849 default: // default to the first defined analogIn pin
whismanoid 0:cb44e2e9ec4c 1850 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1851 case '0': case 0x00: return analogIn0;
whismanoid 0:cb44e2e9ec4c 1852 #endif
whismanoid 0:cb44e2e9ec4c 1853 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1854 case '1': case 0x01: return analogIn1;
whismanoid 0:cb44e2e9ec4c 1855 #endif
whismanoid 0:cb44e2e9ec4c 1856 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1857 case '2': case 0x02: return analogIn2;
whismanoid 0:cb44e2e9ec4c 1858 #endif
whismanoid 0:cb44e2e9ec4c 1859 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1860 case '3': case 0x03: return analogIn3;
whismanoid 0:cb44e2e9ec4c 1861 #endif
whismanoid 0:cb44e2e9ec4c 1862 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1863 case '4': case 0x04: return analogIn4;
whismanoid 0:cb44e2e9ec4c 1864 #endif
whismanoid 0:cb44e2e9ec4c 1865 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1866 case '5': case 0x05: return analogIn5;
whismanoid 0:cb44e2e9ec4c 1867 #endif
whismanoid 0:cb44e2e9ec4c 1868 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1869 case '6': case 0x06: return analogIn6;
whismanoid 0:cb44e2e9ec4c 1870 #endif
whismanoid 0:cb44e2e9ec4c 1871 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1872 case '7': case 0x07: return analogIn7;
whismanoid 0:cb44e2e9ec4c 1873 #endif
whismanoid 0:cb44e2e9ec4c 1874 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1875 case '8': case 0x08: return analogIn8;
whismanoid 0:cb44e2e9ec4c 1876 #endif
whismanoid 0:cb44e2e9ec4c 1877 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1878 case '9': case 0x09: return analogIn9;
whismanoid 0:cb44e2e9ec4c 1879 #endif
whismanoid 0:cb44e2e9ec4c 1880 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1881 case 'a': case 0x0a: return analogIn10;
whismanoid 0:cb44e2e9ec4c 1882 #endif
whismanoid 0:cb44e2e9ec4c 1883 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1884 case 'b': case 0x0b: return analogIn11;
whismanoid 0:cb44e2e9ec4c 1885 #endif
whismanoid 0:cb44e2e9ec4c 1886 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1887 case 'c': case 0x0c: return analogIn12;
whismanoid 0:cb44e2e9ec4c 1888 #endif
whismanoid 0:cb44e2e9ec4c 1889 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1890 case 'd': case 0x0d: return analogIn13;
whismanoid 0:cb44e2e9ec4c 1891 #endif
whismanoid 0:cb44e2e9ec4c 1892 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1893 case 'e': case 0x0e: return analogIn14;
whismanoid 0:cb44e2e9ec4c 1894 #endif
whismanoid 0:cb44e2e9ec4c 1895 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1896 case 'f': case 0x0f: return analogIn15;
whismanoid 0:cb44e2e9ec4c 1897 #endif
whismanoid 0:cb44e2e9ec4c 1898 }
whismanoid 0:cb44e2e9ec4c 1899 }
whismanoid 0:cb44e2e9ec4c 1900 #endif
whismanoid 0:cb44e2e9ec4c 1901
whismanoid 0:cb44e2e9ec4c 1902 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 1903 const float analogInPin_fullScaleVoltage[] = {
whismanoid 0:cb44e2e9ec4c 1904 # if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1905 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1906 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1907 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1908 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1909 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1910 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1911 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1912 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1913 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1914 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1915 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1916 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1917 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1918 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1919 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1920 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1921 # elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 1922 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1923 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1924 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1925 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1926 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1927 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1928 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1929 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1930 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1931 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1932 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1933 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1934 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1935 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1936 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1937 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1938 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 19:5ff09c8e9daf 1939 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 1940 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1941 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1942 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1943 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1944 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1945 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1946 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1947 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1948 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1949 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1950 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1951 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1952 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1953 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1954 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1955 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1956 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 1957 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1958 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1959 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1960 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1961 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1962 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1963 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1964 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1965 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1966 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 1967 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 1968 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 1969 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 1970 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1971 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1972 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1973 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1974 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1975 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1976 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1977 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1978 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1979 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1980 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1981 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1982 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1983 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 1984 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 1985 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 1986 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 1987 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1988 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1989 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1990 //#elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1991 #else
whismanoid 0:cb44e2e9ec4c 1992 // unknown target
whismanoid 0:cb44e2e9ec4c 1993 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1994 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1995 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1996 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1997 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1998 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1999 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 2000 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 2001 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 2002 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 2003 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 2004 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 2005 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 2006 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 2007 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 2008 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 2009 # endif
whismanoid 0:cb44e2e9ec4c 2010 };
whismanoid 0:cb44e2e9ec4c 2011 #endif
whismanoid 0:cb44e2e9ec4c 2012
whismanoid 0:cb44e2e9ec4c 2013
whismanoid 0:cb44e2e9ec4c 2014
whismanoid 0:cb44e2e9ec4c 2015
whismanoid 0:cb44e2e9ec4c 2016 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2017 // TODO support CmdLine command menus (like on Serial_Tester)
whismanoid 4:d9b05924ad4c 2018 #ifndef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 2019 #define USE_CMDLINE_MENUS 1
whismanoid 4:d9b05924ad4c 2020 //~ #undef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 2021 #endif
whismanoid 4:d9b05924ad4c 2022 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2023 #include "CmdLine.h"
whismanoid 4:d9b05924ad4c 2024 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2025 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2026 extern CmdLine cmdLine; // declared later
whismanoid 4:d9b05924ad4c 2027 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2028
whismanoid 4:d9b05924ad4c 2029 //--------------------------------------------------
whismanoid 39:4d285e961435 2030 // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2031 #ifndef USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 2032 #define USE_DATALOGGER_SLEEP 1
whismanoid 39:4d285e961435 2033 //~ #undef USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 2034 #endif
whismanoid 39:4d285e961435 2035 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2036 // TODO: USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2037 #endif
whismanoid 39:4d285e961435 2038 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2039 typedef enum Datalogger_Sleep_enum_t {
whismanoid 39:4d285e961435 2040 datalogger_Sleep_LP0_Stop = 0,
whismanoid 39:4d285e961435 2041 datalogger_Sleep_LP1_DeepSleep = 1,
whismanoid 39:4d285e961435 2042 datalogger_Sleep_LP2_Sleep = 2,
whismanoid 39:4d285e961435 2043 datalogger_Sleep_LP3_Run = 3,
whismanoid 39:4d285e961435 2044 } Datalogger_Sleep_enum_t;
whismanoid 39:4d285e961435 2045 // TODO: USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 2046 Datalogger_Sleep_enum_t g_timer_sleepmode = datalogger_Sleep_LP3_Run;
whismanoid 39:4d285e961435 2047 #endif
whismanoid 39:4d285e961435 2048
whismanoid 39:4d285e961435 2049 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2050 // Datalog trigger types
whismanoid 4:d9b05924ad4c 2051 #ifndef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 2052 #define USE_DATALOGGER_TRIGGER 1
whismanoid 4:d9b05924ad4c 2053 //~ #undef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 2054 #endif
whismanoid 4:d9b05924ad4c 2055 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 2056 typedef enum Datalogger_Trigger_enum_t {
whismanoid 4:d9b05924ad4c 2057 trigger_Halt = 0, //!< halt
whismanoid 4:d9b05924ad4c 2058 trigger_FreeRun = 1, //!< free run as fast as possible
whismanoid 4:d9b05924ad4c 2059 trigger_Timer = 2, //!< timer (configure interval)
whismanoid 4:d9b05924ad4c 2060 trigger_PlatformDigitalInput, //!< platform digital input (configure digital input pin reference)
whismanoid 4:d9b05924ad4c 2061 trigger_SPIDeviceRegRead, //!< SPI device register read (configure regaddr, mask value, match value)
whismanoid 4:d9b05924ad4c 2062 } Datalogger_Trigger_enum_t;
whismanoid 4:d9b05924ad4c 2063 Datalogger_Trigger_enum_t Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 2064 //
whismanoid 17:9397ea3ea7e9 2065 // configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 2066 int g_timer_interval_msec = 500; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2067 int g_timer_interval_count = 10; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2068 int g_timer_interval_counter = 0; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2069 //
whismanoid 17:9397ea3ea7e9 2070 // TODO: configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 2071 //
whismanoid 17:9397ea3ea7e9 2072 // TODO: configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2073 //
whismanoid 4:d9b05924ad4c 2074 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 2075
whismanoid 4:d9b05924ad4c 2076 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2077 // support trigger_SPIDeviceRegRead: Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 2078 #ifndef USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2079 #define USE_DATALOGGER_SPIDeviceRegRead 0
whismanoid 17:9397ea3ea7e9 2080 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2081 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2082 // TODO: uint16_t regAddr;
whismanoid 17:9397ea3ea7e9 2083 // TODO: uint16_t regDataMask;
whismanoid 17:9397ea3ea7e9 2084 // TODO: uint16_t regDataTest;
whismanoid 17:9397ea3ea7e9 2085 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2086
whismanoid 17:9397ea3ea7e9 2087 //--------------------------------------------------
whismanoid 30:07197a430869 2088 // support Datalogger_PrintRow() print gstrRemarkText field from recent #remark
whismanoid 30:07197a430869 2089 #ifndef USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2090 #define USE_DATALOGGER_REMARK_FIELD 1
whismanoid 30:07197a430869 2091 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2092 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2093 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark
whismanoid 30:07197a430869 2094 const size_t gstrRemarkTextLASTINDEX = 40; // gstrRemarkText buffer size - 1
whismanoid 30:07197a430869 2095 char gstrRemarkText[gstrRemarkTextLASTINDEX+1] = "";
whismanoid 30:07197a430869 2096 char gstrRemarkHeader[] = "comment"; // comment or remark?
whismanoid 30:07197a430869 2097 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2098
whismanoid 30:07197a430869 2099 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2100 // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2101 #ifndef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2102 #define USE_DATALOGGER_ActionTable 1
whismanoid 17:9397ea3ea7e9 2103 //~ #undef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2104 #endif
whismanoid 17:9397ea3ea7e9 2105 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2106 //
whismanoid 17:9397ea3ea7e9 2107 // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2108 typedef enum action_type_enum_t {
whismanoid 17:9397ea3ea7e9 2109 action_noop = 0, // no operation
whismanoid 30:07197a430869 2110 action_digitalOutLow = 1, // pin = low if condition
whismanoid 30:07197a430869 2111 action_digitalOutHigh = 2, // pin = high if condition
whismanoid 30:07197a430869 2112 action_button = 3, // pin = button event index 1, 2, 3
whismanoid 30:07197a430869 2113 action_trigger_Halt = 4,
whismanoid 30:07197a430869 2114 action_trigger_FreeRun = 5,
whismanoid 30:07197a430869 2115 action_trigger_Timer = 6,
whismanoid 30:07197a430869 2116 action_trigger_PlatformDigitalInput = 7,
whismanoid 30:07197a430869 2117 action_trigger_SPIDeviceRegRead = 8,
whismanoid 17:9397ea3ea7e9 2118 } action_type_enum_t;
whismanoid 17:9397ea3ea7e9 2119 //
whismanoid 17:9397ea3ea7e9 2120 // Datalogger_RunActionTable() supported conditions
whismanoid 17:9397ea3ea7e9 2121 typedef enum action_condition_enum_t {
whismanoid 17:9397ea3ea7e9 2122 condition_always = 0, // ( true )
whismanoid 17:9397ea3ea7e9 2123 condition_if_An_gt_threshold, // (Platform_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2124 condition_if_An_lt_threshold, // (Platform_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2125 condition_if_An_eq_threshold, // (Platform_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2126 condition_if_An_ge_threshold, // (Platform_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2127 condition_if_An_le_threshold, // (Platform_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2128 condition_if_An_ne_threshold, // (Platform_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2129 condition_if_AINn_gt_threshold, // (SPI_AIN_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2130 condition_if_AINn_lt_threshold, // (SPI_AIN_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2131 condition_if_AINn_eq_threshold, // (SPI_AIN_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2132 condition_if_AINn_ge_threshold, // (SPI_AIN_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2133 condition_if_AINn_le_threshold, // (SPI_AIN_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2134 condition_if_AINn_ne_threshold, // (SPI_AIN_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2135 } condition_enum_t;
whismanoid 17:9397ea3ea7e9 2136 //
whismanoid 17:9397ea3ea7e9 2137 // Datalogger_RunActionTable() structure
whismanoid 17:9397ea3ea7e9 2138 typedef struct action_table_row_t {
whismanoid 17:9397ea3ea7e9 2139 action_type_enum_t action;
whismanoid 17:9397ea3ea7e9 2140 int digitalOutPin;
whismanoid 17:9397ea3ea7e9 2141 action_condition_enum_t condition;
whismanoid 17:9397ea3ea7e9 2142 int condition_channel;
whismanoid 17:9397ea3ea7e9 2143 double condition_threshold;
whismanoid 17:9397ea3ea7e9 2144 } action_table_row_t;
whismanoid 17:9397ea3ea7e9 2145 #if MAX40108_DEMO
whismanoid 39:4d285e961435 2146 # ifdef BOARD_SERIAL_NUMBER
whismanoid 39:4d285e961435 2147 // data unique to certain boards based on serial number
whismanoid 39:4d285e961435 2148 // channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 39:4d285e961435 2149 # if (BOARD_SERIAL_NUMBER) == 1
whismanoid 39:4d285e961435 2150 #warning "(BOARD_SERIAL_NUMBER) == 1 -- 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 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 39:4d285e961435 2153 #warning "(BOARD_SERIAL_NUMBER) == 5 -- logic uses A3(CE) instead of A2(WE)"
whismanoid 39:4d285e961435 2154 const int channel_WE = 3; // use channel_CE instead on proto board s/n 1 for diagnostics; easier to sweep values
whismanoid 39:4d285e961435 2155 # else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 17:9397ea3ea7e9 2156 const int channel_WE = 2;
whismanoid 39:4d285e961435 2157 # endif
whismanoid 39:4d285e961435 2158 # endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 17:9397ea3ea7e9 2159 const double threshold_WE_0V5 = 0.5;
whismanoid 17:9397ea3ea7e9 2160 const double threshold_WE_0V6 = 0.6;
whismanoid 17:9397ea3ea7e9 2161 const double threshold_WE_0V7 = 0.7;
whismanoid 18:1235c17b451e 2162 const int pin_LED_1 = 91; // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 2163 const int pin_LED_2 = 92; // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 2164 const int pin_LED_3 = 93; // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 17:9397ea3ea7e9 2165 #endif
whismanoid 17:9397ea3ea7e9 2166 const int ACTION_TABLE_ROW_MAX = 20;
whismanoid 17:9397ea3ea7e9 2167 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2168 bool Datalogger_action_table_enabled = true;
whismanoid 30:07197a430869 2169 int Datalogger_action_table_row_count = 8; // assert (Datalogger_action_table_row_count <= ACTION_TABLE_ROW_MAX)
whismanoid 17:9397ea3ea7e9 2170 #else // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2171 int Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 2172 #endif // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2173 action_table_row_t Datalogger_action_table[ACTION_TABLE_ROW_MAX] = {
whismanoid 17:9397ea3ea7e9 2174 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2175 // LED indicator show (WE > 0.5V)
whismanoid 18:1235c17b451e 2176 // L@0 act=1 pin=92 if=1 ch=2 x=0.500000 -- digitalOutLow D92 if A2 > 0.500000
whismanoid 18:1235c17b451e 2177 {action_digitalOutLow, pin_LED_2, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V5},
whismanoid 17:9397ea3ea7e9 2178 //
whismanoid 17:9397ea3ea7e9 2179 // LED indicator show (WE > 0.6V)
whismanoid 18:1235c17b451e 2180 // L@1 act=1 pin=93 if=1 ch=2 x=0.600000 -- digitalOutLow D93 if A2 > 0.600000
whismanoid 18:1235c17b451e 2181 {action_digitalOutLow, pin_LED_3, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 17:9397ea3ea7e9 2182 //
whismanoid 17:9397ea3ea7e9 2183 // switch to always-on mode `trigger_FreeRun` if (WE > 0.7V)
whismanoid 29:6a9edb6e973b 2184 // L@2 act=5 if=1 ch=2 x=0.700000 -- trigger_FreeRun if A2 > 0.700000
whismanoid 17:9397ea3ea7e9 2185 {action_trigger_FreeRun, 0, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 17:9397ea3ea7e9 2186 //
whismanoid 17:9397ea3ea7e9 2187 // switch to intermittent-sleep-mode `trigger_Timer` if (WE < 0.6V)
whismanoid 29:6a9edb6e973b 2188 // L@3 act=6 if=2 ch=2 x=0.600000 -- trigger_Timer(10 x 500msec) if A2 < 0.600000
whismanoid 17:9397ea3ea7e9 2189 {action_trigger_Timer, 0, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 18:1235c17b451e 2190 //
whismanoid 18:1235c17b451e 2191 // LED indicator show (`Datalogger_Trigger` == `trigger_FreeRun`)
whismanoid 18:1235c17b451e 2192 // {action_noop, 0, condition_always, 0, 0},
whismanoid 18:1235c17b451e 2193 // L@4 act=1 pin=91 if=1 ch=2 x=0.700000 -- digitalOutLow D91 if A2 > 0.700000
whismanoid 18:1235c17b451e 2194 {action_digitalOutLow, pin_LED_1, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 18:1235c17b451e 2195 //
whismanoid 18:1235c17b451e 2196 // L@5 act=2 pin=91 if=2 ch=2 x=0.600000 -- digitalOutHigh D91 if A2 < 0.600000
whismanoid 18:1235c17b451e 2197 {action_digitalOutHigh, pin_LED_1, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 18:1235c17b451e 2198 //
whismanoid 30:07197a430869 2199 // L@6 act=3 pin=4 if=1 ch=2 x=0.700000 -- button 4 event if A2 > 0.700000
whismanoid 30:07197a430869 2200 {action_button, 4, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 29:6a9edb6e973b 2201 //
whismanoid 30:07197a430869 2202 // L@7 act=3 pin=5 if=2 ch=2 x=0.600000 -- button 5 event if A2 < 0.600000
whismanoid 30:07197a430869 2203 {action_button, 5, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 29:6a9edb6e973b 2204 //
whismanoid 17:9397ea3ea7e9 2205 #endif // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2206 //
whismanoid 17:9397ea3ea7e9 2207 {action_noop, 0, condition_always, 0, 0},
whismanoid 17:9397ea3ea7e9 2208 };
whismanoid 17:9397ea3ea7e9 2209 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2210
whismanoid 17:9397ea3ea7e9 2211 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2212 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 2213 uint8_t Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 2214 uint8_t need_reinit = true;
whismanoid 8:dffee7509bfb 2215 void Datalogger_PrintHeader(CmdLine& cmdLine);
whismanoid 5:aaf8b5f5fda1 2216 void Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 2217 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2218 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 2219 void Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 2220 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 8:dffee7509bfb 2221 void Datalogger_PrintRow(CmdLine& cmdLine);
whismanoid 4:d9b05924ad4c 2222
whismanoid 4:d9b05924ad4c 2223 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 2224 // Option to validate SPI link by reading PART_ID register
whismanoid 0:cb44e2e9ec4c 2225 #ifndef VERIFY_PART_ID_IN_LOOP
whismanoid 3:9055e17e181a 2226 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 2227 #define VERIFY_PART_ID_IN_LOOP 1
whismanoid 3:9055e17e181a 2228 #else
whismanoid 0:cb44e2e9ec4c 2229 #define VERIFY_PART_ID_IN_LOOP 0
whismanoid 3:9055e17e181a 2230 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2231 #endif
whismanoid 0:cb44e2e9ec4c 2232
whismanoid 3:9055e17e181a 2233 //--------------------------------------------------
whismanoid 3:9055e17e181a 2234 #define NUM_DUT_ANALOG_IN_CHANNELS 10
whismanoid 3:9055e17e181a 2235
whismanoid 3:9055e17e181a 2236 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 2237 // MAX11410 individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 3:9055e17e181a 2238 typedef enum SPI_AIN_Enable_t {
whismanoid 10:04022a61b527 2239 SPI_AIN_Disable = 0,
whismanoid 10:04022a61b527 2240 SPI_AIN_Enable_LSB = 1,
whismanoid 10:04022a61b527 2241 SPI_AIN_Enable_Volt = 2,
whismanoid 3:9055e17e181a 2242 } SPI_AIN_Enable_t;
whismanoid 3:9055e17e181a 2243 uint8_t SPI_AIN_Enable_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 2244 SPI_AIN_Enable_LSB, // AIN0 1=LSB
whismanoid 10:04022a61b527 2245 SPI_AIN_Enable_LSB, // AIN1 1=LSB
whismanoid 10:04022a61b527 2246 SPI_AIN_Enable_LSB, // AIN2 1=LSB
whismanoid 10:04022a61b527 2247 SPI_AIN_Enable_LSB, // AIN3 1=LSB
whismanoid 10:04022a61b527 2248 SPI_AIN_Enable_LSB, // AIN4 1=LSB
whismanoid 10:04022a61b527 2249 SPI_AIN_Enable_LSB, // AIN5 1=LSB
whismanoid 10:04022a61b527 2250 SPI_AIN_Enable_LSB, // AIN6 1=LSB
whismanoid 10:04022a61b527 2251 SPI_AIN_Enable_LSB, // AIN7 1=LSB
whismanoid 10:04022a61b527 2252 SPI_AIN_Enable_LSB, // AIN8 1=LSB
whismanoid 10:04022a61b527 2253 SPI_AIN_Enable_LSB, // AIN9 1=LSB
whismanoid 3:9055e17e181a 2254 };
whismanoid 3:9055e17e181a 2255 //
whismanoid 10:04022a61b527 2256 double SPI_AIN_Voltage[NUM_DUT_ANALOG_IN_CHANNELS];
whismanoid 13:184a08909405 2257 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2258 #ifndef HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 2259 #define HAS_SPI_AIN_customChannelHeader 0
whismanoid 13:184a08909405 2260 #endif
whismanoid 13:184a08909405 2261 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2262 const char* const SPI_AIN_customChannelHeader_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 2263 "", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 2264 "", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 2265 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 2266 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 2267 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 2268 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 2269 };
whismanoid 13:184a08909405 2270 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 3:9055e17e181a 2271 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2272 // ---------- Measure_Voltage_custom_props in Measure_Voltage @pre and in class properties ----------
whismanoid 3:9055e17e181a 2273 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 2274 // MAX11410 specific per-channel config register v_filter
whismanoid 3:9055e17e181a 2275 uint8_t SPI_AIN_Cfg_v_filter_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2276 0x34, // AIN0 @ v_filter=0x34
whismanoid 3:9055e17e181a 2277 0x34, // AIN1 @ v_filter=0x34
whismanoid 3:9055e17e181a 2278 0x34, // AIN2 @ v_filter=0x34
whismanoid 3:9055e17e181a 2279 0x34, // AIN3 @ v_filter=0x34
whismanoid 3:9055e17e181a 2280 0x34, // AIN4 @ v_filter=0x34
whismanoid 3:9055e17e181a 2281 0x34, // AIN5 @ v_filter=0x34
whismanoid 3:9055e17e181a 2282 0x34, // AIN6 @ v_filter=0x34
whismanoid 3:9055e17e181a 2283 0x34, // AIN7 @ v_filter=0x34
whismanoid 3:9055e17e181a 2284 0x34, // AIN8 @ v_filter=0x34
whismanoid 3:9055e17e181a 2285 0x34, // AIN9 @ v_filter=0x34
whismanoid 3:9055e17e181a 2286 };
whismanoid 3:9055e17e181a 2287 //
whismanoid 4:d9b05924ad4c 2288 // MAX11410 specific per-channel config register v_ctrl
whismanoid 3:9055e17e181a 2289 uint8_t SPI_AIN_Cfg_v_ctrl_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2290 0x42, // AIN0 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2291 0x42, // AIN1 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2292 0x42, // AIN2 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2293 0x42, // AIN3 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2294 0x42, // AIN4 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2295 0x42, // AIN5 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2296 0x42, // AIN6 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2297 0x42, // AIN7 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2298 0x42, // AIN8 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2299 0x42, // AIN9 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2300 };
whismanoid 3:9055e17e181a 2301 //
whismanoid 4:d9b05924ad4c 2302 // MAX11410 specific per-channel config register v_pga
whismanoid 3:9055e17e181a 2303 uint8_t SPI_AIN_Cfg_v_pga_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2304 0x00, // AIN0 @ v_pga=0x00
whismanoid 3:9055e17e181a 2305 0x00, // AIN1 @ v_pga=0x00
whismanoid 3:9055e17e181a 2306 0x00, // AIN2 @ v_pga=0x00
whismanoid 3:9055e17e181a 2307 0x00, // AIN3 @ v_pga=0x00
whismanoid 3:9055e17e181a 2308 0x00, // AIN4 @ v_pga=0x00
whismanoid 3:9055e17e181a 2309 0x00, // AIN5 @ v_pga=0x00
whismanoid 3:9055e17e181a 2310 0x00, // AIN6 @ v_pga=0x00
whismanoid 3:9055e17e181a 2311 0x00, // AIN7 @ v_pga=0x00
whismanoid 3:9055e17e181a 2312 0x00, // AIN8 @ v_pga=0x00
whismanoid 3:9055e17e181a 2313 0x00, // AIN9 @ v_pga=0x00
whismanoid 3:9055e17e181a 2314 };
whismanoid 3:9055e17e181a 2315 //
whismanoid 3:9055e17e181a 2316 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2317 // ---------- Measure_Voltage_custom_props ----------
whismanoid 0:cb44e2e9ec4c 2318 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2319 // filter register configuration in Measure_Voltage and Read_All_Voltages CONV_TYPE_01_Continuous
whismanoid 0:cb44e2e9ec4c 2320 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 2321 //~ const uint8_t custom_v_filter = 0x00; // @ v_filter=0x00 -- LINEF_00_50Hz_60Hz_FIR RATE_0000 | 1.1SPS
whismanoid 0:cb44e2e9ec4c 2322 //~ const uint8_t custom_v_filter = 0x01; // @ v_filter=0x01 -- LINEF_00_50Hz_60Hz_FIR RATE_0001 | 2.1SPS
whismanoid 0:cb44e2e9ec4c 2323 //~ const uint8_t custom_v_filter = 0x02; // @ v_filter=0x02 -- LINEF_00_50Hz_60Hz_FIR RATE_0010 | 4.2SPS
whismanoid 0:cb44e2e9ec4c 2324 //~ const uint8_t custom_v_filter = 0x03; // @ v_filter=0x03 -- LINEF_00_50Hz_60Hz_FIR RATE_0011 | 8.4SPS
whismanoid 0:cb44e2e9ec4c 2325 //~ const uint8_t custom_v_filter = 0x04; // @ v_filter=0x04 -- LINEF_00_50Hz_60Hz_FIR RATE_0100 | 16.8SPS
whismanoid 0:cb44e2e9ec4c 2326 //~ const uint8_t custom_v_filter = 0x10; // @ v_filter=0x10 -- LINEF_01_50Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 2327 //~ const uint8_t custom_v_filter = 0x11; // @ v_filter=0x11 -- LINEF_01_50Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 2328 //~ const uint8_t custom_v_filter = 0x12; // @ v_filter=0x12 -- LINEF_01_50Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 2329 //~ const uint8_t custom_v_filter = 0x13; // @ v_filter=0x13 -- LINEF_01_50Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 2330 //~ const uint8_t custom_v_filter = 0x14; // @ v_filter=0x14 -- LINEF_01_50Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 2331 //~ const uint8_t custom_v_filter = 0x15; // @ v_filter=0x15 -- LINEF_01_50Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 2332 //~ const uint8_t custom_v_filter = 0x20; // @ v_filter=0x20 -- LINEF_10_60Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 2333 //~ const uint8_t custom_v_filter = 0x21; // @ v_filter=0x21 -- LINEF_10_60Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 2334 //~ const uint8_t custom_v_filter = 0x22; // @ v_filter=0x22 -- LINEF_10_60Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 2335 //~ const uint8_t custom_v_filter = 0x23; // @ v_filter=0x23 -- LINEF_10_60Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 2336 //~ const uint8_t custom_v_filter = 0x24; // @ v_filter=0x24 -- LINEF_10_60Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 2337 //~ const uint8_t custom_v_filter = 0x25; // @ v_filter=0x25 -- LINEF_10_60Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 2338 //~ const uint8_t custom_v_filter = 0x30; // @ v_filter=0x30 -- LINEF_11_SINC4 RATE_0000 | 4SPS
whismanoid 0:cb44e2e9ec4c 2339 //~ const uint8_t custom_v_filter = 0x31; // @ v_filter=0x31 -- LINEF_11_SINC4 RATE_0001 | 10SPS
whismanoid 0:cb44e2e9ec4c 2340 //~ const uint8_t custom_v_filter = 0x32; // @ v_filter=0x32 -- LINEF_11_SINC4 RATE_0010 | 20SPS
whismanoid 0:cb44e2e9ec4c 2341 //~ const uint8_t custom_v_filter = 0x33; // @ v_filter=0x33 -- LINEF_11_SINC4 RATE_0011 | 40SPS
whismanoid 0:cb44e2e9ec4c 2342 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 2343 //~ const uint8_t custom_v_filter = 0x35; // @ v_filter=0x35 -- LINEF_11_SINC4 RATE_0101 | 120SPS
whismanoid 0:cb44e2e9ec4c 2344 //~ const uint8_t custom_v_filter = 0x36; // @ v_filter=0x36 -- LINEF_11_SINC4 RATE_0110 | 240SPS
whismanoid 0:cb44e2e9ec4c 2345 //~ const uint8_t custom_v_filter = 0x37; // @ v_filter=0x37 -- LINEF_11_SINC4 RATE_0111 | 480SPS
whismanoid 0:cb44e2e9ec4c 2346 //~ const uint8_t custom_v_filter = 0x38; // @ v_filter=0x38 -- LINEF_11_SINC4 RATE_1000 | 960SPS
whismanoid 0:cb44e2e9ec4c 2347 //~ const uint8_t custom_v_filter = 0x39; // @ v_filter=0x39 -- LINEF_11_SINC4 RATE_1001 | 1920SPS
whismanoid 0:cb44e2e9ec4c 2348 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2349 //
whismanoid 0:cb44e2e9ec4c 2350 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2351 // pga register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 0:cb44e2e9ec4c 2352 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 2353 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 2354 //~ const uint8_t custom_v_pga = 0x10; // @ v_pga=0x10 -- 0x10 SIG_PATH_01_BYPASS
whismanoid 0:cb44e2e9ec4c 2355 //~ const uint8_t custom_v_pga = 0x20; // @ v_pga=0x20 -- 0x20 SIG_PATH_10_PGA GAIN_000_1
whismanoid 0:cb44e2e9ec4c 2356 //~ const uint8_t custom_v_pga = 0x21; // @ v_pga=0x21 --*0x21 SIG_PATH_10_PGA GAIN_001_2
whismanoid 0:cb44e2e9ec4c 2357 //~ const uint8_t custom_v_pga = 0x22; // @ v_pga=0x22 -- 0x22 SIG_PATH_10_PGA GAIN_010_4
whismanoid 0:cb44e2e9ec4c 2358 //~ const uint8_t custom_v_pga = 0x23; // @ v_pga=0x23 -- 0x23 SIG_PATH_10_PGA GAIN_011_8
whismanoid 0:cb44e2e9ec4c 2359 //~ const uint8_t custom_v_pga = 0x24; // @ v_pga=0x24 -- 0x24 SIG_PATH_10_PGA GAIN_100_16
whismanoid 0:cb44e2e9ec4c 2360 //~ const uint8_t custom_v_pga = 0x25; // @ v_pga=0x25 -- 0x25 SIG_PATH_10_PGA GAIN_101_32
whismanoid 0:cb44e2e9ec4c 2361 //~ const uint8_t custom_v_pga = 0x26; // @ v_pga=0x26 -- 0x26 SIG_PATH_10_PGA GAIN_110_64
whismanoid 0:cb44e2e9ec4c 2362 //~ const uint8_t custom_v_pga = 0x27; // @ v_pga=0x27 -- 0x27 SIG_PATH_10_PGA GAIN_111_128
whismanoid 0:cb44e2e9ec4c 2363 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2364 //
whismanoid 0:cb44e2e9ec4c 2365 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2366 // ctrl register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 3:9055e17e181a 2367 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2368 //~ const uint8_t custom_v_ctrl = 0x40; // @ v_ctrl=0x40 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1
whismanoid 0:cb44e2e9ec4c 2369 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 2370 //~ const uint8_t custom_v_ctrl = 0x58; // @ v_ctrl=0x58 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 2371 //
whismanoid 0:cb44e2e9ec4c 2372 //~ const uint8_t custom_v_ctrl = 0x41; // @ v_ctrl=0x41 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N
whismanoid 0:cb44e2e9ec4c 2373 //~ const uint8_t custom_v_ctrl = 0x45; // @ v_ctrl=0x45 -- 0x40 unipolar, 0x05 REF_SEL_101_REF1P_AGND
whismanoid 0:cb44e2e9ec4c 2374 //~ const uint8_t custom_v_ctrl = 0x59; // @ v_ctrl=0x59 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 2375 //
whismanoid 0:cb44e2e9ec4c 2376 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2377 //~ const uint8_t custom_v_ctrl = 0x46; // @ v_ctrl=0x46 -- 0x40 unipolar, 0x06 REF_SEL_110_REF2P_AGND
whismanoid 0:cb44e2e9ec4c 2378 //~ const uint8_t custom_v_ctrl = 0x22; // @ v_ctrl=0x22 -- 0x20 bipolar offset binary, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2379 //~ const uint8_t custom_v_ctrl = 0x02; // @ v_ctrl=0x02 -- 0x00 bipolar 2's complement, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2380 //
whismanoid 0:cb44e2e9ec4c 2381 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 2382 //~ const uint8_t custom_v_ctrl = 0x47; // @ v_ctrl=0x47 -- 0x40 unipolar, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2383 //~ const uint8_t custom_v_ctrl = 0x27; // @ v_ctrl=0x27 -- 0x20 bipolar offset binary, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2384 //~ const uint8_t custom_v_ctrl = 0x07; // @ v_ctrl=0x07 -- 0x00 bipolar 2's complement, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2385 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2386
whismanoid 3:9055e17e181a 2387 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2388 // example code declare SPI interface (GPIO controlled CS)
whismanoid 0:cb44e2e9ec4c 2389 #if defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 2390 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 2391 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
whismanoid 19:5ff09c8e9daf 2392 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 2393 #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 2394 SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625PICO: pin P0_5 P0_6 P0_4
whismanoid 0:cb44e2e9ec4c 2395 DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32625PICO: pin P0_7
whismanoid 0:cb44e2e9ec4c 2396 #elif defined(TARGET_MAX32600MBED)
whismanoid 0:cb44e2e9ec4c 2397 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 0:cb44e2e9ec4c 2398 DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2399 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 2400 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 2401 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:cb44e2e9ec4c 2402 //
whismanoid 0:cb44e2e9ec4c 2403 // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses.
whismanoid 0:cb44e2e9ec4c 2404 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 2405 DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2406 //
whismanoid 0:cb44e2e9ec4c 2407 #else
whismanoid 3:9055e17e181a 2408 SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 3:9055e17e181a 2409 DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2410 #endif
whismanoid 0:cb44e2e9ec4c 2411
whismanoid 0:cb44e2e9ec4c 2412 // example code declare GPIO interface pins
whismanoid 0:cb44e2e9ec4c 2413 // example code declare device instance
whismanoid 3:9055e17e181a 2414 MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC);
whismanoid 3:9055e17e181a 2415 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2416
whismanoid 1:747f1602abfc 2417 //--------------------------------------------------
whismanoid 3:9055e17e181a 2418 // Option to Datalog Arduino platform analog inputs
whismanoid 3:9055e17e181a 2419 #ifndef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 2420 #define LOG_PLATFORM_AIN 6
whismanoid 3:9055e17e181a 2421 //~ #undef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 2422 #endif
whismanoid 3:9055e17e181a 2423 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 1:747f1602abfc 2424 //#ifndef NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 1:747f1602abfc 2425 //#define NUM_PLATFORM_ANALOG_IN_CHANNELS 6
whismanoid 1:747f1602abfc 2426 //#endif
whismanoid 1:747f1602abfc 2427 const int NUM_PLATFORM_ANALOG_IN_CHANNELS = 6;
whismanoid 1:747f1602abfc 2428 const double adc_full_scale_voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 2429 analogInPin_fullScaleVoltage[0], // 1.2,
whismanoid 10:04022a61b527 2430 analogInPin_fullScaleVoltage[1], // 1.2,
whismanoid 10:04022a61b527 2431 analogInPin_fullScaleVoltage[2], // 1.2,
whismanoid 10:04022a61b527 2432 analogInPin_fullScaleVoltage[3], // 1.2,
whismanoid 10:04022a61b527 2433 analogInPin_fullScaleVoltage[4], // 6.0
whismanoid 10:04022a61b527 2434 analogInPin_fullScaleVoltage[5], // 6.0
whismanoid 0:cb44e2e9ec4c 2435 };
whismanoid 9:45f98573eb6d 2436 // Platform ADC individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 9:45f98573eb6d 2437 typedef enum Platform_AIN_Enable_t {
whismanoid 9:45f98573eb6d 2438 Platform_AIN_Disable = 0,
whismanoid 9:45f98573eb6d 2439 Platform_AIN_Enable_LSB = 1,
whismanoid 9:45f98573eb6d 2440 Platform_AIN_Enable_Volt = 2,
whismanoid 9:45f98573eb6d 2441 } Platform_AIN_Enable_t;
whismanoid 13:184a08909405 2442 uint8_t Platform_Enable_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 9:45f98573eb6d 2443 Platform_AIN_Enable_Volt, // AIN0 2=Volt
whismanoid 9:45f98573eb6d 2444 Platform_AIN_Enable_Volt, // AIN1 2=Volt
whismanoid 9:45f98573eb6d 2445 Platform_AIN_Enable_Volt, // AIN2 2=Volt
whismanoid 9:45f98573eb6d 2446 Platform_AIN_Enable_Volt, // AIN3 2=Volt
whismanoid 9:45f98573eb6d 2447 Platform_AIN_Enable_Volt, // AIN4 2=Volt
whismanoid 9:45f98573eb6d 2448 Platform_AIN_Enable_Volt, // AIN5 2=Volt
whismanoid 9:45f98573eb6d 2449 };
whismanoid 37:3f369235e5bc 2450 // Option to report average value of Arduino platform analog inputs
whismanoid 37:3f369235e5bc 2451 #ifndef USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 2452 #define USE_Platform_AIN_Average 1
whismanoid 37:3f369235e5bc 2453 //~ #undef USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 2454 #endif
whismanoid 37:3f369235e5bc 2455 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 2456 #endif // USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 2457 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 2458 int Platform_AIN_Average_N = 16;
whismanoid 37:3f369235e5bc 2459 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 2460 // Option to apply calibration to Arduino platform analog inputs
whismanoid 34:a1993a1ee904 2461 #ifndef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2462 #define HAS_Platform_AIN_Calibration 1
whismanoid 34:a1993a1ee904 2463 //~ #undef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2464 #endif
whismanoid 34:a1993a1ee904 2465 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2466 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 2467 // Calibration is between two points for each channel, defined by
whismanoid 34:a1993a1ee904 2468 // a normalized value between 0% and 100%, and the corresponding voltage.
whismanoid 34:a1993a1ee904 2469 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 2470 // calibration_05_normValue_0_1, calibration_05_V should be around 5% or 25%
whismanoid 34:a1993a1ee904 2471 double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2472 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2473 // data unique to certain boards based on serial number
whismanoid 38:fda80a0020d1 2474 // channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2475 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2476 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 38:fda80a0020d1 2477 // TODO: calibrate BOARD_SERIAL_NUMBER 0 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2478 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2479 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2480 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2481 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2482 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2483 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2484 //
whismanoid 36:e7aac874b8be 2485 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2486 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 38:fda80a0020d1 2487 // TODO: calibrate BOARD_SERIAL_NUMBER 1 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 37:3f369235e5bc 2488 0.250000000, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 37:3f369235e5bc 2489 0.624736547, // %A cal1n=0.624736547 cal1v=0.748000026V cal1n=0.979754724 cal1v=1.167500019V
whismanoid 37:3f369235e5bc 2490 0.250000000, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 37:3f369235e5bc 2491 0.250000000, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 37:3f369235e5bc 2492 0.250000000, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 37:3f369235e5bc 2493 0.127252869, // %A cal5n=0.127252869 cal5v=0.748000026V cal5n=0.267205842 cal5v=1.578999996V
whismanoid 36:e7aac874b8be 2494 //
whismanoid 36:e7aac874b8be 2495 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2496 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 38:fda80a0020d1 2497 // TODO: calibrate BOARD_SERIAL_NUMBER 2 channels A1/A5(1V0)?
whismanoid 38:fda80a0020d1 2498 0.001955034, // %A cal0n=0.001955034 cal0v=0.000120000V cal0n=0.964797903 cal0v=1.149270058V
whismanoid 38:fda80a0020d1 2499 0.646371711, // %A cal1n=0.646371711 cal1v=0.761619985V cal1n=0.964797903 cal1v=1.149270058V
whismanoid 38:fda80a0020d1 2500 0.121437412, // %A cal2n=0.121437412 cal2v=0.146500006V cal2n=0.833466958 cal2v=1.004999995V
whismanoid 38:fda80a0020d1 2501 0.121437412, // %A cal3n=0.121437412 cal3v=0.146500006V cal3n=0.833466958 cal3v=1.004999995V
whismanoid 38:fda80a0020d1 2502 0.001955034, // %A cal4n=0.001955034 cal4v=0.000120000V cal4n=0.291349728 cal4v=1.735399961V
whismanoid 38:fda80a0020d1 2503 0.130005952, // %A cal5n=0.130005952 cal5v=0.761650026V cal5n=0.291349728 cal5v=1.735399961V
whismanoid 36:e7aac874b8be 2504 //
whismanoid 36:e7aac874b8be 2505 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2506 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 38:fda80a0020d1 2507 // TODO: calibrate BOARD_SERIAL_NUMBER 3 channels A2(WE), A3(CE) not quite right yet
whismanoid 38:fda80a0020d1 2508 0.002932551, // %A cal0n=0.002932551 cal0v=0.000130000V cal0n=0.966447462 cal0v=1.149999976V
whismanoid 38:fda80a0020d1 2509 0.643798094, // %A cal1n=0.643798094 cal1v=0.756900012V cal1n=0.966447462 cal1v=1.149999976V
whismanoid 38:fda80a0020d1 2510 0.151286051, // %A cal2n=0.151286051 cal2v=0.181050003V cal2n=0.786534725 cal2v=0.936999977V
whismanoid 38:fda80a0020d1 2511 0.151286051, // %A cal3n=0.151286051 cal3v=0.181050003V cal3n=0.786023080 cal3v=0.936999977V
whismanoid 38:fda80a0020d1 2512 0.002932551, // %A cal4n=0.002932551 cal4v=0.000130000V cal4n=0.286962360 cal4v=1.707499981V
whismanoid 38:fda80a0020d1 2513 0.130120505, // %A cal5n=0.130120505 cal5v=0.757099986V cal5n=0.286962360 cal5v=1.707499981V
whismanoid 36:e7aac874b8be 2514 //
whismanoid 36:e7aac874b8be 2515 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2516 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 38:fda80a0020d1 2517 0.003910068, // %A cal0n=0.003910068 cal0v=0.000120000V cal0n=0.925441444 cal0v=1.107100010V
whismanoid 38:fda80a0020d1 2518 0.635619044, // %A cal1n=0.635619044 cal1v=0.759999990V cal1n=0.925441444 cal1v=1.107100010V
whismanoid 38:fda80a0020d1 2519 0.083768636, // %A cal2n=0.083768636 cal2v=0.100000001V cal2n=0.820740156 cal2v=0.980000019V
whismanoid 38:fda80a0020d1 2520 0.083768636, // %A cal3n=0.083768636 cal3v=0.100000001V cal3n=0.820740156 cal3v=0.980000019V
whismanoid 38:fda80a0020d1 2521 0.003910068, // %A cal4n=0.003910068 cal4v=0.000120000V cal4n=0.279630989 cal4v=1.651999950V
whismanoid 38:fda80a0020d1 2522 0.129257541, // %A cal5n=0.129257541 cal5v=0.759999990V cal5n=0.279630989 cal5v=1.651999950V
whismanoid 36:e7aac874b8be 2523 //
whismanoid 36:e7aac874b8be 2524 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2525 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 38:fda80a0020d1 2526 // 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 2527 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2528 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2529 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2530 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2531 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2532 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2533 //
whismanoid 36:e7aac874b8be 2534 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2535 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 38:fda80a0020d1 2536 // TODO: calibrate BOARD_SERIAL_NUMBER 6 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2537 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2538 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2539 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2540 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2541 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2542 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2543 //
whismanoid 36:e7aac874b8be 2544 # else
whismanoid 36:e7aac874b8be 2545 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2546 # endif
whismanoid 36:e7aac874b8be 2547 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2548 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2549 0.25, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2550 0.25, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2551 0.25, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2552 0.25, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2553 0.25, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2554 0.25, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2555 //
whismanoid 36:e7aac874b8be 2556 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2557 };
whismanoid 34:a1993a1ee904 2558 double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2559 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2560 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2561 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2562 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 38:fda80a0020d1 2563 // TODO: calibrate BOARD_SERIAL_NUMBER 0 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2564 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2565 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2566 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2567 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2568 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2569 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2570 //
whismanoid 36:e7aac874b8be 2571 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2572 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 38:fda80a0020d1 2573 // TODO: calibrate BOARD_SERIAL_NUMBER 1 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 37:3f369235e5bc 2574 0.300000000, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 37:3f369235e5bc 2575 0.748000026, // %A cal1n=0.624736547 cal1v=0.748000026V cal1n=0.979754724 cal1v=1.167500019V
whismanoid 37:3f369235e5bc 2576 0.300000000, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 37:3f369235e5bc 2577 0.300000000, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 37:3f369235e5bc 2578 1.500000000, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 37:3f369235e5bc 2579 0.748000026, // %A cal5n=0.127252869 cal5v=0.748000026V cal5n=0.267205842 cal5v=1.578999996V
whismanoid 36:e7aac874b8be 2580 //
whismanoid 36:e7aac874b8be 2581 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2582 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 38:fda80a0020d1 2583 // TODO: calibrate BOARD_SERIAL_NUMBER 2 channels A1/A5(1V0)?
whismanoid 38:fda80a0020d1 2584 0.000120000, // %A cal0n=0.001955034 cal0v=0.000120000V cal0n=0.964797903 cal0v=1.149270058V
whismanoid 38:fda80a0020d1 2585 0.761619985, // %A cal1n=0.646371711 cal1v=0.761619985V cal1n=0.964797903 cal1v=1.149270058V
whismanoid 38:fda80a0020d1 2586 0.146500006, // %A cal2n=0.121437412 cal2v=0.146500006V cal2n=0.833466958 cal2v=1.004999995V
whismanoid 38:fda80a0020d1 2587 0.146500006, // %A cal3n=0.121437412 cal3v=0.146500006V cal3n=0.833466958 cal3v=1.004999995V
whismanoid 38:fda80a0020d1 2588 0.000120000, // %A cal4n=0.001955034 cal4v=0.000120000V cal4n=0.291349728 cal4v=1.735399961V
whismanoid 38:fda80a0020d1 2589 0.761650026, // %A cal5n=0.130005952 cal5v=0.761650026V cal5n=0.291349728 cal5v=1.735399961V
whismanoid 36:e7aac874b8be 2590 //
whismanoid 36:e7aac874b8be 2591 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2592 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 38:fda80a0020d1 2593 // TODO: calibrate BOARD_SERIAL_NUMBER 3 channels A2(WE), A3(CE) not quite right yet
whismanoid 38:fda80a0020d1 2594 0.000130000, // %A cal0n=0.002932551 cal0v=0.000130000V cal0n=0.966447462 cal0v=1.149999976V
whismanoid 38:fda80a0020d1 2595 0.756900012, // %A cal1n=0.643798094 cal1v=0.756900012V cal1n=0.966447462 cal1v=1.149999976V
whismanoid 38:fda80a0020d1 2596 0.181050003, // %A cal2n=0.151286051 cal2v=0.181050003V cal2n=0.786534725 cal2v=0.936999977V
whismanoid 38:fda80a0020d1 2597 0.181050003, // %A cal3n=0.151286051 cal3v=0.181050003V cal3n=0.786023080 cal3v=0.936999977V
whismanoid 38:fda80a0020d1 2598 0.000130000, // %A cal4n=0.002932551 cal4v=0.000130000V cal4n=0.286962360 cal4v=1.707499981V
whismanoid 38:fda80a0020d1 2599 0.757099986, // %A cal5n=0.130120505 cal5v=0.757099986V cal5n=0.286962360 cal5v=1.707499981V
whismanoid 36:e7aac874b8be 2600 //
whismanoid 36:e7aac874b8be 2601 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2602 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 38:fda80a0020d1 2603 0.000120000, // %A cal0n=0.003910068 cal0v=0.000120000V cal0n=0.925441444 cal0v=1.107100010V
whismanoid 38:fda80a0020d1 2604 0.759999990, // %A cal1n=0.635619044 cal1v=0.759999990V cal1n=0.925441444 cal1v=1.107100010V
whismanoid 38:fda80a0020d1 2605 0.100000001, // %A cal2n=0.083768636 cal2v=0.100000001V cal2n=0.820740156 cal2v=0.980000019V
whismanoid 38:fda80a0020d1 2606 0.100000001, // %A cal3n=0.083768636 cal3v=0.100000001V cal3n=0.820740156 cal3v=0.980000019V
whismanoid 38:fda80a0020d1 2607 0.000120000, // %A cal4n=0.003910068 cal4v=0.000120000V cal4n=0.279630989 cal4v=1.651999950V
whismanoid 38:fda80a0020d1 2608 0.759999990, // %A cal5n=0.129257541 cal5v=0.759999990V cal5n=0.279630989 cal5v=1.651999950V
whismanoid 36:e7aac874b8be 2609 //
whismanoid 36:e7aac874b8be 2610 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2611 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 38:fda80a0020d1 2612 // TODO: calibrate BOARD_SERIAL_NUMBER 5 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2613 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2614 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2615 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2616 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2617 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2618 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2619 //
whismanoid 36:e7aac874b8be 2620 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2621 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 38:fda80a0020d1 2622 // TODO: calibrate BOARD_SERIAL_NUMBER 6 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2623 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2624 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2625 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2626 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2627 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2628 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2629 //
whismanoid 36:e7aac874b8be 2630 # else
whismanoid 36:e7aac874b8be 2631 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2632 # endif
whismanoid 36:e7aac874b8be 2633 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2634 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2635 0.3, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2636 0.3, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2637 0.3, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2638 0.3, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2639 1.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2640 1.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2641 //
whismanoid 36:e7aac874b8be 2642 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2643 };
whismanoid 34:a1993a1ee904 2644 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 2645 // calibration_95_normValue_0_1, calibration_95_V should be around 95% or 75%
whismanoid 34:a1993a1ee904 2646 double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2647 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2648 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2649 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2650 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 38:fda80a0020d1 2651 // TODO: calibrate BOARD_SERIAL_NUMBER 0 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2652 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2653 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2654 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2655 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2656 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2657 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2658 //
whismanoid 36:e7aac874b8be 2659 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2660 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 38:fda80a0020d1 2661 // TODO: calibrate BOARD_SERIAL_NUMBER 1 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 37:3f369235e5bc 2662 0.750000000, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 37:3f369235e5bc 2663 0.979754724, // %A cal1n=0.624736547 cal1v=0.748000026V cal1n=0.979754724 cal1v=1.167500019V
whismanoid 37:3f369235e5bc 2664 0.750000000, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 37:3f369235e5bc 2665 0.750000000, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 37:3f369235e5bc 2666 0.750000000, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 37:3f369235e5bc 2667 0.267205842, // %A cal5n=0.127252869 cal5v=0.748000026V cal5n=0.267205842 cal5v=1.578999996V
whismanoid 36:e7aac874b8be 2668 //
whismanoid 36:e7aac874b8be 2669 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2670 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 38:fda80a0020d1 2671 // TODO: calibrate BOARD_SERIAL_NUMBER 2 channels A1/A5(1V0)?
whismanoid 38:fda80a0020d1 2672 0.964797903, // %A cal0n=0.001955034 cal0v=0.000120000V cal0n=0.964797903 cal0v=1.149270058V
whismanoid 38:fda80a0020d1 2673 0.964797903, // %A cal1n=0.646371711 cal1v=0.761619985V cal1n=0.964797903 cal1v=1.149270058V
whismanoid 38:fda80a0020d1 2674 0.833466958, // %A cal2n=0.121437412 cal2v=0.146500006V cal2n=0.833466958 cal2v=1.004999995V
whismanoid 38:fda80a0020d1 2675 0.833466958, // %A cal3n=0.121437412 cal3v=0.146500006V cal3n=0.833466958 cal3v=1.004999995V
whismanoid 38:fda80a0020d1 2676 0.291349728, // %A cal4n=0.001955034 cal4v=0.000120000V cal4n=0.291349728 cal4v=1.735399961V
whismanoid 38:fda80a0020d1 2677 0.291349728, // %A cal5n=0.130005952 cal5v=0.761650026V cal5n=0.291349728 cal5v=1.735399961V
whismanoid 36:e7aac874b8be 2678 //
whismanoid 36:e7aac874b8be 2679 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2680 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 38:fda80a0020d1 2681 // TODO: calibrate BOARD_SERIAL_NUMBER 3 channels A2(WE), A3(CE) not quite right yet
whismanoid 38:fda80a0020d1 2682 0.966447462, // %A cal0n=0.002932551 cal0v=0.000130000V cal0n=0.966447462 cal0v=1.149999976V
whismanoid 38:fda80a0020d1 2683 0.966447462, // %A cal1n=0.643798094 cal1v=0.756900012V cal1n=0.966447462 cal1v=1.149999976V
whismanoid 38:fda80a0020d1 2684 0.786534725, // %A cal2n=0.151286051 cal2v=0.181050003V cal2n=0.786534725 cal2v=0.936999977V
whismanoid 38:fda80a0020d1 2685 0.786023080, // %A cal3n=0.151286051 cal3v=0.181050003V cal3n=0.786023080 cal3v=0.936999977V
whismanoid 38:fda80a0020d1 2686 0.286962360, // %A cal4n=0.002932551 cal4v=0.000130000V cal4n=0.286962360 cal4v=1.707499981V
whismanoid 38:fda80a0020d1 2687 0.286962360, // %A cal5n=0.130120505 cal5v=0.757099986V cal5n=0.286962360 cal5v=1.707499981V
whismanoid 36:e7aac874b8be 2688 //
whismanoid 36:e7aac874b8be 2689 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2690 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 38:fda80a0020d1 2691 0.925441444, // %A cal0n=0.003910068 cal0v=0.000120000V cal0n=0.925441444 cal0v=1.107100010V
whismanoid 38:fda80a0020d1 2692 0.925441444, // %A cal1n=0.635619044 cal1v=0.759999990V cal1n=0.925441444 cal1v=1.107100010V
whismanoid 38:fda80a0020d1 2693 0.820740156, // %A cal2n=0.083768636 cal2v=0.100000001V cal2n=0.820740156 cal2v=0.980000019V
whismanoid 38:fda80a0020d1 2694 0.820740156, // %A cal3n=0.083768636 cal3v=0.100000001V cal3n=0.820740156 cal3v=0.980000019V
whismanoid 38:fda80a0020d1 2695 0.279630989, // %A cal4n=0.003910068 cal4v=0.000120000V cal4n=0.279630989 cal4v=1.651999950V
whismanoid 38:fda80a0020d1 2696 0.279630989, // %A cal5n=0.129257541 cal5v=0.759999990V cal5n=0.279630989 cal5v=1.651999950V
whismanoid 36:e7aac874b8be 2697 //
whismanoid 36:e7aac874b8be 2698 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2699 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 38:fda80a0020d1 2700 // TODO: calibrate BOARD_SERIAL_NUMBER 5 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2701 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2702 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2703 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2704 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2705 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2706 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2707 //
whismanoid 36:e7aac874b8be 2708 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2709 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 38:fda80a0020d1 2710 // TODO: calibrate BOARD_SERIAL_NUMBER 6 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2711 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2712 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2713 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2714 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2715 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2716 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2717 //
whismanoid 36:e7aac874b8be 2718 # else
whismanoid 36:e7aac874b8be 2719 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2720 # endif
whismanoid 36:e7aac874b8be 2721 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2722 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2723 0.75, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2724 0.75, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2725 0.75, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2726 0.75, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2727 0.75, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2728 0.75, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2729 //
whismanoid 36:e7aac874b8be 2730 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2731 };
whismanoid 34:a1993a1ee904 2732 double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 36:e7aac874b8be 2733 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 2734 // data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2735 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 36:e7aac874b8be 2736 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 38:fda80a0020d1 2737 // TODO: calibrate BOARD_SERIAL_NUMBER 0 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2738 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2739 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2740 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2741 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2742 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2743 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2744 //
whismanoid 36:e7aac874b8be 2745 # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 36:e7aac874b8be 2746 #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 38:fda80a0020d1 2747 // TODO: calibrate BOARD_SERIAL_NUMBER 1 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 37:3f369235e5bc 2748 0.900000000, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 37:3f369235e5bc 2749 1.167500019, // %A cal1n=0.624736547 cal1v=0.748000026V cal1n=0.979754724 cal1v=1.167500019V
whismanoid 37:3f369235e5bc 2750 0.900000000, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 37:3f369235e5bc 2751 0.900000000, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 37:3f369235e5bc 2752 4.500000000, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 37:3f369235e5bc 2753 1.578999996, // %A cal5n=0.127252869 cal5v=0.748000026V cal5n=0.267205842 cal5v=1.578999996V
whismanoid 36:e7aac874b8be 2754 //
whismanoid 36:e7aac874b8be 2755 # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 36:e7aac874b8be 2756 #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 38:fda80a0020d1 2757 // TODO: calibrate BOARD_SERIAL_NUMBER 2 channels A1/A5(1V0)?
whismanoid 38:fda80a0020d1 2758 1.149270058, // %A cal0n=0.001955034 cal0v=0.000120000V cal0n=0.964797903 cal0v=1.149270058V
whismanoid 38:fda80a0020d1 2759 1.149270058, // %A cal1n=0.646371711 cal1v=0.761619985V cal1n=0.964797903 cal1v=1.149270058V
whismanoid 38:fda80a0020d1 2760 1.004999995, // %A cal2n=0.121437412 cal2v=0.146500006V cal2n=0.833466958 cal2v=1.004999995V
whismanoid 38:fda80a0020d1 2761 1.004999995, // %A cal3n=0.121437412 cal3v=0.146500006V cal3n=0.833466958 cal3v=1.004999995V
whismanoid 38:fda80a0020d1 2762 1.735399961, // %A cal4n=0.001955034 cal4v=0.000120000V cal4n=0.291349728 cal4v=1.735399961V
whismanoid 38:fda80a0020d1 2763 1.735399961, // %A cal5n=0.130005952 cal5v=0.761650026V cal5n=0.291349728 cal5v=1.735399961V
whismanoid 36:e7aac874b8be 2764 //
whismanoid 36:e7aac874b8be 2765 # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 36:e7aac874b8be 2766 #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 38:fda80a0020d1 2767 // TODO: calibrate BOARD_SERIAL_NUMBER 3 channels A2(WE), A3(CE) not quite right yet
whismanoid 38:fda80a0020d1 2768 1.149999976, // %A cal0n=0.002932551 cal0v=0.000130000V cal0n=0.966447462 cal0v=1.149999976V
whismanoid 38:fda80a0020d1 2769 1.149999976, // %A cal1n=0.643798094 cal1v=0.756900012V cal1n=0.966447462 cal1v=1.149999976V
whismanoid 38:fda80a0020d1 2770 0.936999977, // %A cal2n=0.151286051 cal2v=0.181050003V cal2n=0.786534725 cal2v=0.936999977V
whismanoid 38:fda80a0020d1 2771 0.936999977, // %A cal3n=0.151286051 cal3v=0.181050003V cal3n=0.786023080 cal3v=0.936999977V
whismanoid 38:fda80a0020d1 2772 1.707499981, // %A cal4n=0.002932551 cal4v=0.000130000V cal4n=0.286962360 cal4v=1.707499981V
whismanoid 38:fda80a0020d1 2773 1.707499981, // %A cal5n=0.130120505 cal5v=0.757099986V cal5n=0.286962360 cal5v=1.707499981V
whismanoid 36:e7aac874b8be 2774 //
whismanoid 36:e7aac874b8be 2775 # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 36:e7aac874b8be 2776 #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 38:fda80a0020d1 2777 1.107100010, // %A cal0n=0.003910068 cal0v=0.000120000V cal0n=0.925441444 cal0v=1.107100010V
whismanoid 38:fda80a0020d1 2778 1.107100010, // %A cal1n=0.635619044 cal1v=0.759999990V cal1n=0.925441444 cal1v=1.107100010V
whismanoid 38:fda80a0020d1 2779 0.980000019, // %A cal2n=0.083768636 cal2v=0.100000001V cal2n=0.820740156 cal2v=0.980000019V
whismanoid 38:fda80a0020d1 2780 0.980000019, // %A cal3n=0.083768636 cal3v=0.100000001V cal3n=0.820740156 cal3v=0.980000019V
whismanoid 38:fda80a0020d1 2781 1.651999950, // %A cal4n=0.003910068 cal4v=0.000120000V cal4n=0.279630989 cal4v=1.651999950V
whismanoid 38:fda80a0020d1 2782 1.651999950, // %A cal5n=0.129257541 cal5v=0.759999990V cal5n=0.279630989 cal5v=1.651999950V
whismanoid 36:e7aac874b8be 2783 //
whismanoid 36:e7aac874b8be 2784 # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 36:e7aac874b8be 2785 #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 38:fda80a0020d1 2786 // TODO: calibrate BOARD_SERIAL_NUMBER 5 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2787 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2788 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2789 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2790 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2791 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2792 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2793 //
whismanoid 36:e7aac874b8be 2794 # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 36:e7aac874b8be 2795 #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 38:fda80a0020d1 2796 // TODO: calibrate BOARD_SERIAL_NUMBER 6 channels A0/A4(CSA*100/3.34=mA), A1/A5(1V0), A2(WE), A3(CE)
whismanoid 36:e7aac874b8be 2797 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2798 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2799 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2800 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2801 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2802 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2803 //
whismanoid 36:e7aac874b8be 2804 # else
whismanoid 36:e7aac874b8be 2805 #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 36:e7aac874b8be 2806 # endif
whismanoid 36:e7aac874b8be 2807 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 2808 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 2809 0.9, // %A cal0n=0.250000000 cal0v=0.300000000V cal0n=0.750000000 cal0v=0.900000000V
whismanoid 36:e7aac874b8be 2810 0.9, // %A cal1n=0.250000000 cal1v=0.300000000V cal1n=0.750000000 cal1v=0.900000000V
whismanoid 36:e7aac874b8be 2811 0.9, // %A cal2n=0.250000000 cal2v=0.300000000V cal2n=0.750000000 cal2v=0.900000000V
whismanoid 36:e7aac874b8be 2812 0.9, // %A cal3n=0.250000000 cal3v=0.300000000V cal3n=0.750000000 cal3v=0.900000000V
whismanoid 36:e7aac874b8be 2813 4.5, // %A cal4n=0.250000000 cal4v=1.500000000V cal4n=0.750000000 cal4v=4.500000000V
whismanoid 36:e7aac874b8be 2814 4.5, // %A cal5n=0.250000000 cal5v=1.500000000V cal5n=0.750000000 cal5v=4.500000000V
whismanoid 36:e7aac874b8be 2815 //
whismanoid 36:e7aac874b8be 2816 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 34:a1993a1ee904 2817 };
whismanoid 34:a1993a1ee904 2818 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2819 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2820 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1)
whismanoid 34:a1993a1ee904 2821 {
whismanoid 34:a1993a1ee904 2822 // TODO: return corrected normValue_0_1 using two-point linear calibration
whismanoid 34:a1993a1ee904 2823 // point 1: calibration_05_normValue_0_1[ch], calibration_05_V[ch]
whismanoid 34:a1993a1ee904 2824 // point 2: calibration_95_normValue_0_1[ch], calibration_95_V[ch]
whismanoid 34:a1993a1ee904 2825 // validate that there is enough span to get sensible results
whismanoid 34:a1993a1ee904 2826 //
whismanoid 34:a1993a1ee904 2827 int ch = channel_0_5;
whismanoid 34:a1993a1ee904 2828 // 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 2829 // ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 2830 // ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 2831 // ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 2832 // ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 2833 // );
whismanoid 34:a1993a1ee904 2834 // cmdLine.serial().printf("\r\n adc_full_scale_voltage[%d] = %1.6fV",
whismanoid 34:a1993a1ee904 2835 // ch,
whismanoid 34:a1993a1ee904 2836 // adc_full_scale_voltage[ch]
whismanoid 34:a1993a1ee904 2837 // );
whismanoid 34:a1993a1ee904 2838 // raw normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 2839 double raw_05_normValue = calibration_05_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 2840 double raw_95_normValue = calibration_95_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 2841 // calibrated normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 2842 // divide V/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 2843 double cal_05_normValue = calibration_05_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 2844 double cal_95_normValue = calibration_95_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 2845 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_05_normValue = %1.6f",
whismanoid 34:a1993a1ee904 2846 // ch,
whismanoid 34:a1993a1ee904 2847 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2848 // cal_05_normValue
whismanoid 34:a1993a1ee904 2849 // );
whismanoid 34:a1993a1ee904 2850 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_95_normValue = %1.6f",
whismanoid 34:a1993a1ee904 2851 // ch,
whismanoid 34:a1993a1ee904 2852 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2853 // cal_95_normValue
whismanoid 34:a1993a1ee904 2854 // );
whismanoid 34:a1993a1ee904 2855 //
whismanoid 34:a1993a1ee904 2856 double span_raw = raw_95_normValue - raw_05_normValue;
whismanoid 34:a1993a1ee904 2857 double span_cal = cal_95_normValue - cal_05_normValue;
whismanoid 34:a1993a1ee904 2858 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_raw = %1.6f",
whismanoid 34:a1993a1ee904 2859 // ch,
whismanoid 34:a1993a1ee904 2860 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2861 // span_raw
whismanoid 34:a1993a1ee904 2862 // );
whismanoid 34:a1993a1ee904 2863 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_cal = %1.6f",
whismanoid 34:a1993a1ee904 2864 // ch,
whismanoid 34:a1993a1ee904 2865 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2866 // span_cal
whismanoid 34:a1993a1ee904 2867 // );
whismanoid 34:a1993a1ee904 2868 // if calibration is not valid, return unmodified normValue_0_1 and print a warning
whismanoid 34:a1993a1ee904 2869 if (span_raw < 0.001) {
whismanoid 34:a1993a1ee904 2870 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_raw = %1.6f",
whismanoid 34:a1993a1ee904 2871 ch,
whismanoid 34:a1993a1ee904 2872 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2873 span_raw
whismanoid 34:a1993a1ee904 2874 );
whismanoid 34:a1993a1ee904 2875 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 2876 }
whismanoid 34:a1993a1ee904 2877 if (span_cal < 0.001) {
whismanoid 34:a1993a1ee904 2878 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_cal = %1.6f",
whismanoid 34:a1993a1ee904 2879 ch,
whismanoid 34:a1993a1ee904 2880 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2881 span_cal
whismanoid 34:a1993a1ee904 2882 );
whismanoid 34:a1993a1ee904 2883 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 2884 }
whismanoid 34:a1993a1ee904 2885 double slope_correction = span_cal / span_raw;
whismanoid 34:a1993a1ee904 2886 double corrected_normValue_0_1 = cal_05_normValue + ((raw_normValue_0_1 - raw_05_normValue) * slope_correction);
whismanoid 34:a1993a1ee904 2887 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) slope_correction = %1.6f",
whismanoid 34:a1993a1ee904 2888 // ch,
whismanoid 34:a1993a1ee904 2889 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2890 // slope_correction
whismanoid 34:a1993a1ee904 2891 // );
whismanoid 34:a1993a1ee904 2892 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) corrected_normValue_0_1 = %1.6f\r\n",
whismanoid 34:a1993a1ee904 2893 // ch,
whismanoid 34:a1993a1ee904 2894 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2895 // corrected_normValue_0_1
whismanoid 34:a1993a1ee904 2896 // );
whismanoid 34:a1993a1ee904 2897 return corrected_normValue_0_1;
whismanoid 34:a1993a1ee904 2898 }
whismanoid 34:a1993a1ee904 2899 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2900 // Option to customize channel names in datalog header line
whismanoid 13:184a08909405 2901 #ifndef HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 2902 #define HAS_Platform_AIN_customChannelHeader 1
whismanoid 13:184a08909405 2903 #endif
whismanoid 13:184a08909405 2904 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2905 const char* const Platform_AIN_customChannelHeader_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 2906 "=AIN4", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 2907 "=AIN5", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 2908 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 2909 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 2910 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 2911 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 2912 };
whismanoid 13:184a08909405 2913 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 1:747f1602abfc 2914 //--------------------------------------------------
whismanoid 1:747f1602abfc 2915 // Option to log platform analog inputs as raw LSB code
whismanoid 1:747f1602abfc 2916 #ifndef LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 2917 #define LOG_PLATFORM_ANALOG_IN_LSB 0
whismanoid 1:747f1602abfc 2918 #endif
whismanoid 1:747f1602abfc 2919 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 2920 int Platform_LSB[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 2921 #endif
whismanoid 1:747f1602abfc 2922
whismanoid 1:747f1602abfc 2923 //--------------------------------------------------
whismanoid 1:747f1602abfc 2924 // Option to use platform analog inputs as Voltage
whismanoid 1:747f1602abfc 2925 #ifndef LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 2926 #define LOG_PLATFORM_ANALOG_IN_VOLTS 1
whismanoid 1:747f1602abfc 2927 #endif
whismanoid 1:747f1602abfc 2928 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 2929 double Platform_Voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 2930 #endif
whismanoid 3:9055e17e181a 2931 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 0:cb44e2e9ec4c 2932
whismanoid 10:04022a61b527 2933 //--------------------------------------------------
whismanoid 10:04022a61b527 2934 // Option to use Command forwarding to Auxiliary serial port
whismanoid 10:04022a61b527 2935 // Command forwarding to Auxiliary serial port TX/RX
whismanoid 10:04022a61b527 2936 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial
whismanoid 10:04022a61b527 2937 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial
whismanoid 10:04022a61b527 2938 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 2939 #ifndef USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2940 #define USE_AUX_SERIAL_CMD_FORWARDING 1
whismanoid 10:04022a61b527 2941 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2942 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2943 // Command forwarding to Auxiliary serial port TX/RX #257 -- global parameters
whismanoid 10:04022a61b527 2944 const size_t RX_STRING_BUF_SIZE = 1000;
whismanoid 10:04022a61b527 2945 int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 2946 // transmit command string by AUX TX
whismanoid 10:04022a61b527 2947 #if 0
whismanoid 10:04022a61b527 2948 int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 2949 int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 2950 int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 2951 #endif
whismanoid 10:04022a61b527 2952 // capture received string from AUX RX
whismanoid 10:04022a61b527 2953 Timer g_auxSerialCom_Timer;
whismanoid 10:04022a61b527 2954 int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 2955 int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 2956 int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 2957 int g_auxSerialCom_rx_idle_ms = 500; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 2958 int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 2959 const int aux_serial_cmd_forwarding_rx_eot_not_used = 'x';
whismanoid 10:04022a61b527 2960 int g_auxSerialCom_rx_eot = aux_serial_cmd_forwarding_rx_eot_not_used; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 2961 //~ int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text string?
whismanoid 10:04022a61b527 2962 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2963 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2964 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257
whismanoid 10:04022a61b527 2965 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 2966 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2967 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2968 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2969 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 2970 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2971 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 2972 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2973 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2974 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2975 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2976 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2977 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 2978 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2979 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2980
whismanoid 8:dffee7509bfb 2981 // CODE GENERATOR: example code for ADC: serial port declaration
whismanoid 8:dffee7509bfb 2982 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2983 // Declare the Serial driver
whismanoid 8:dffee7509bfb 2984 // default baud rate settings are 9600 8N1
whismanoid 8:dffee7509bfb 2985 // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
whismanoid 8:dffee7509bfb 2986 // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
whismanoid 8:dffee7509bfb 2987 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2988 #if defined(TARGET_MAX32630)
whismanoid 8:dffee7509bfb 2989 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 2990 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2991 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2992 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 2993 //
whismanoid 8:dffee7509bfb 2994 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2995 Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2996 //Serial J3AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 2997 //Serial BTAUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 2998 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 2999 //
whismanoid 8:dffee7509bfb 3000 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3001 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3002 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3003 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3004 //
whismanoid 8:dffee7509bfb 3005 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3006 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3007 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3008 USBSerial serial;
whismanoid 8:dffee7509bfb 3009 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3010 #elif defined(TARGET_MAX32625MBED)
whismanoid 8:dffee7509bfb 3011 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625MBED: P0_1,P0_0 (Arduino D1,D0)
whismanoid 8:dffee7509bfb 3012 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3013 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625MBED: P3_1,P3_0 (J15-LEDgreen,LEDred)
whismanoid 8:dffee7509bfb 3014 //
whismanoid 8:dffee7509bfb 3015 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3016 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3017 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3018 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3019 //
whismanoid 8:dffee7509bfb 3020 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3021 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3022 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3023 USBSerial serial;
whismanoid 8:dffee7509bfb 3024 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 3025 #elif defined(TARGET_MAX32625PICO)
whismanoid 8:dffee7509bfb 3026 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 3027 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625PICO: P2_1,P2_0 (underside?)
whismanoid 8:dffee7509bfb 3028 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3029 //
whismanoid 8:dffee7509bfb 3030 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3031 Serial AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 3032 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3033 //
whismanoid 8:dffee7509bfb 3034 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3035 Serial DAPLINKserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3036 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3037 //
whismanoid 8:dffee7509bfb 3038 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3039 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3040 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3041 USBSerial serial;
whismanoid 22:d6dc8a85f435 3042 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 3043 #elif defined(TARGET_MAX40108DEMOP2U9)
whismanoid 22:d6dc8a85f435 3044 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 3045 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK)
whismanoid 22:d6dc8a85f435 3046 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 3047 //
whismanoid 22:d6dc8a85f435 3048 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial is used as main serial port in MAX40108 Demo board
whismanoid 22:d6dc8a85f435 3049 Serial serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 3050 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 3051 //
whismanoid 22:d6dc8a85f435 3052 // Hardware serial port over DAPLink
whismanoid 22:d6dc8a85f435 3053 // connection to external MAX32625PICO(DAPLINK) needed TX/RX swap in firmware.
whismanoid 22:d6dc8a85f435 3054 // MAX32625PICO(DAPLINK) drives DAPLINK.8, listens on DAPLINK.6.
whismanoid 22:d6dc8a85f435 3055 // See AN6350 MAX32625 Users Guide 7.5.2.3.1 TX and RX Pin Mapping for UART 1 -- Mapping Option B
whismanoid 39:4d285e961435 3056 #ifdef BOARD_SERIAL_NUMBER
whismanoid 39:4d285e961435 3057 // data unique to certain boards based on serial number
whismanoid 39:4d285e961435 3058 # if (BOARD_SERIAL_NUMBER) == 0
whismanoid 39:4d285e961435 3059 #warning "(BOARD_SERIAL_NUMBER) == 0"
whismanoid 39:4d285e961435 3060 // s/n 0 is not really a MAX40108 board, it's actually a MAX32625PICO used for early development. So no swap.
whismanoid 39:4d285e961435 3061 Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 39:4d285e961435 3062 //Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 39:4d285e961435 3063 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3064 //
whismanoid 39:4d285e961435 3065 // # elif (BOARD_SERIAL_NUMBER) == 1
whismanoid 39:4d285e961435 3066 // #warning "(BOARD_SERIAL_NUMBER) == 1"
whismanoid 39:4d285e961435 3067 // //
whismanoid 39:4d285e961435 3068 // # elif (BOARD_SERIAL_NUMBER) == 2
whismanoid 39:4d285e961435 3069 // #warning "(BOARD_SERIAL_NUMBER) == 2"
whismanoid 39:4d285e961435 3070 // //
whismanoid 39:4d285e961435 3071 // # elif (BOARD_SERIAL_NUMBER) == 3
whismanoid 39:4d285e961435 3072 // #warning "(BOARD_SERIAL_NUMBER) == 3"
whismanoid 39:4d285e961435 3073 // //
whismanoid 39:4d285e961435 3074 // # elif (BOARD_SERIAL_NUMBER) == 4
whismanoid 39:4d285e961435 3075 // #warning "(BOARD_SERIAL_NUMBER) == 4"
whismanoid 39:4d285e961435 3076 // //
whismanoid 39:4d285e961435 3077 // # elif (BOARD_SERIAL_NUMBER) == 5
whismanoid 39:4d285e961435 3078 // #warning "(BOARD_SERIAL_NUMBER) == 5"
whismanoid 39:4d285e961435 3079 // //
whismanoid 39:4d285e961435 3080 // # elif (BOARD_SERIAL_NUMBER) == 6
whismanoid 39:4d285e961435 3081 // #warning "(BOARD_SERIAL_NUMBER) == 6"
whismanoid 39:4d285e961435 3082 // //
whismanoid 39:4d285e961435 3083 # else
whismanoid 39:4d285e961435 3084 // #warning "BOARD_SERIAL_NUMBER defined but not recognized"
whismanoid 22:d6dc8a85f435 3085 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 22:d6dc8a85f435 3086 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 22:d6dc8a85f435 3087 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3088 # endif
whismanoid 39:4d285e961435 3089 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 39:4d285e961435 3090 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 39:4d285e961435 3091 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 39:4d285e961435 3092 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 39:4d285e961435 3093 #define HAS_DAPLINK_SERIAL 1
whismanoid 39:4d285e961435 3094 //
whismanoid 39:4d285e961435 3095 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 22:d6dc8a85f435 3096 //
whismanoid 22:d6dc8a85f435 3097 // Serial AUXserial(UART1_TX,UART1_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 3098 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 3099 //
whismanoid 22:d6dc8a85f435 3100 // Virtual serial port over USB
whismanoid 22:d6dc8a85f435 3101 // #include "USBSerial.h"
whismanoid 22:d6dc8a85f435 3102 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 22:d6dc8a85f435 3103 //USBSerial serial;
whismanoid 8:dffee7509bfb 3104 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3105 #elif defined(TARGET_MAX32620FTHR)
whismanoid 8:dffee7509bfb 3106 #warning "TARGET_MAX32620FTHR not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3107 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3108 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32620FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 3109 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3110 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3111 //
whismanoid 8:dffee7509bfb 3112 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3113 Serial serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3114 //Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 3115 Serial AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 3116 //Serial PMOD0AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 3117 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 3118 //
whismanoid 8:dffee7509bfb 3119 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3120 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3121 Serial DAPLINKserial(USBTX, USBRX); // tx,rx MAX32620FTHR: P2_1,P2_0
whismanoid 8:dffee7509bfb 3122 //Serial DAPLINKserial(STDIO_UART_TX, STDIO_UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3123 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3124 //
whismanoid 8:dffee7509bfb 3125 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3126 // #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3127 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3128 //USBSerial serial; // MAX32620FTHR: USBSerial crash??
whismanoid 8:dffee7509bfb 3129 #warning "TARGET_MAX32620FTHR not previously tested; USBSerial crash?"
whismanoid 8:dffee7509bfb 3130 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3131 #elif defined(TARGET_MAX32600)
whismanoid 8:dffee7509bfb 3132 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3133 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART2 MAX32625MBED: P1_3,P1_2 (Arduino D3,D2)
whismanoid 8:dffee7509bfb 3134 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART1 MAX32625MBED: P7_3,P7_2 ( ?? )
whismanoid 8:dffee7509bfb 3135 //
whismanoid 8:dffee7509bfb 3136 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 3137 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 3138 Serial DAPLINKserial(P1_1,P1_0); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 3139 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 3140 //
whismanoid 8:dffee7509bfb 3141 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 3142 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 3143 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 3144 USBSerial serial;
whismanoid 8:dffee7509bfb 3145 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3146 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 8:dffee7509bfb 3147 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3148 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3149 #else
whismanoid 8:dffee7509bfb 3150 #if defined(SERIAL_TX)
whismanoid 8:dffee7509bfb 3151 #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..."
whismanoid 8:dffee7509bfb 3152 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 3153 #elif defined(USBTX)
whismanoid 8:dffee7509bfb 3154 #warning "target not previously tested; guess serial pins are USBTX, USBRX..."
whismanoid 8:dffee7509bfb 3155 Serial serial(USBTX, USBRX); // tx, rx
whismanoid 8:dffee7509bfb 3156 #elif defined(UART_TX)
whismanoid 8:dffee7509bfb 3157 #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..."
whismanoid 8:dffee7509bfb 3158 Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 3159 #else
whismanoid 8:dffee7509bfb 3160 #warning "target not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 3161 #endif
whismanoid 8:dffee7509bfb 3162 #endif
whismanoid 8:dffee7509bfb 3163 //
whismanoid 8:dffee7509bfb 3164 #include "CmdLine.h"
whismanoid 8:dffee7509bfb 3165
whismanoid 8:dffee7509bfb 3166 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3167 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 3168 CmdLine cmdLine_AUXserial(AUXserial, "AUXserial");
whismanoid 10:04022a61b527 3169 uint8_t Datalogger_enable_AUXserial = {
whismanoid 10:04022a61b527 3170 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3171 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 3172 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 3173 false
whismanoid 10:04022a61b527 3174 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3175 true
whismanoid 10:04022a61b527 3176 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3177 };
whismanoid 8:dffee7509bfb 3178 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3179 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3180 CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK");
whismanoid 8:dffee7509bfb 3181 uint8_t Datalogger_enable_DAPLINKserial = true;
whismanoid 8:dffee7509bfb 3182 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3183 CmdLine cmdLine(serial, "serial");
whismanoid 8:dffee7509bfb 3184 uint8_t Datalogger_enable_serial = true;
whismanoid 8:dffee7509bfb 3185 // CODE GENERATOR: example code for ADC: serial port declaration (end)
whismanoid 8:dffee7509bfb 3186
whismanoid 21:ac062a97a71d 3187
whismanoid 21:ac062a97a71d 3188 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3189 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 3190 #ifndef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3191 #define USE_DATALOGGER_CommandTable 1
whismanoid 23:c6c652bef4b9 3192 //~ #undef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3193 #endif
whismanoid 23:c6c652bef4b9 3194 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3195 const int COMMAND_TABLE_ROW_MAX = 10;
whismanoid 23:c6c652bef4b9 3196 const int COMMAND_TABLE_COL_MAX = 40;
whismanoid 23:c6c652bef4b9 3197 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3198 //
whismanoid 23:c6c652bef4b9 3199 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3200 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3201 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3202 char onButton1_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button1 event";
whismanoid 23:c6c652bef4b9 3203 char onButton1_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 23:c6c652bef4b9 3204 char onButton1_command_table_02[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 23:c6c652bef4b9 3205 char onButton1_command_table_03[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 23:c6c652bef4b9 3206 char onButton1_command_table_04[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 23:c6c652bef4b9 3207 char onButton1_command_table_05[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 23:c6c652bef4b9 3208 char onButton1_command_table_06[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 23:c6c652bef4b9 3209 char onButton1_command_table_07[COMMAND_TABLE_COL_MAX] = "LR";
whismanoid 23:c6c652bef4b9 3210 char onButton1_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3211 char onButton1_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3212 static char* onButton1_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3213 onButton1_command_table_00,
whismanoid 23:c6c652bef4b9 3214 onButton1_command_table_01,
whismanoid 23:c6c652bef4b9 3215 onButton1_command_table_02,
whismanoid 23:c6c652bef4b9 3216 onButton1_command_table_03,
whismanoid 23:c6c652bef4b9 3217 onButton1_command_table_04,
whismanoid 23:c6c652bef4b9 3218 onButton1_command_table_05,
whismanoid 23:c6c652bef4b9 3219 onButton1_command_table_06,
whismanoid 23:c6c652bef4b9 3220 onButton1_command_table_07,
whismanoid 23:c6c652bef4b9 3221 onButton1_command_table_08,
whismanoid 23:c6c652bef4b9 3222 onButton1_command_table_09,
whismanoid 23:c6c652bef4b9 3223 };
whismanoid 23:c6c652bef4b9 3224 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3225 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3226 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3227 char onButton2_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button2 event";
whismanoid 23:c6c652bef4b9 3228 char onButton2_command_table_01[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 23:c6c652bef4b9 3229 char onButton2_command_table_02[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 23:c6c652bef4b9 3230 char onButton2_command_table_03[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 23:c6c652bef4b9 3231 char onButton2_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3232 char onButton2_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3233 char onButton2_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3234 char onButton2_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3235 char onButton2_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3236 char onButton2_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 3237 static char* onButton2_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 3238 onButton2_command_table_00,
whismanoid 23:c6c652bef4b9 3239 onButton2_command_table_01,
whismanoid 23:c6c652bef4b9 3240 onButton2_command_table_02,
whismanoid 23:c6c652bef4b9 3241 onButton2_command_table_03,
whismanoid 23:c6c652bef4b9 3242 onButton2_command_table_04,
whismanoid 23:c6c652bef4b9 3243 onButton2_command_table_05,
whismanoid 23:c6c652bef4b9 3244 onButton2_command_table_06,
whismanoid 23:c6c652bef4b9 3245 onButton2_command_table_07,
whismanoid 23:c6c652bef4b9 3246 onButton2_command_table_08,
whismanoid 23:c6c652bef4b9 3247 onButton2_command_table_09,
whismanoid 23:c6c652bef4b9 3248 };
whismanoid 23:c6c652bef4b9 3249 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3250 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3251 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3252 char onButton3_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button3 event";
whismanoid 24:032f3683cb2a 3253 char onButton3_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 24:032f3683cb2a 3254 char onButton3_command_table_02[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 24:032f3683cb2a 3255 char onButton3_command_table_03[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 24:032f3683cb2a 3256 char onButton3_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3257 char onButton3_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3258 char onButton3_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3259 char onButton3_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3260 char onButton3_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3261 char onButton3_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 3262 static char* onButton3_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 24:032f3683cb2a 3263 onButton3_command_table_00,
whismanoid 24:032f3683cb2a 3264 onButton3_command_table_01,
whismanoid 24:032f3683cb2a 3265 onButton3_command_table_02,
whismanoid 24:032f3683cb2a 3266 onButton3_command_table_03,
whismanoid 24:032f3683cb2a 3267 onButton3_command_table_04,
whismanoid 24:032f3683cb2a 3268 onButton3_command_table_05,
whismanoid 24:032f3683cb2a 3269 onButton3_command_table_06,
whismanoid 24:032f3683cb2a 3270 onButton3_command_table_07,
whismanoid 24:032f3683cb2a 3271 onButton3_command_table_08,
whismanoid 24:032f3683cb2a 3272 onButton3_command_table_09,
whismanoid 24:032f3683cb2a 3273 };
whismanoid 24:032f3683cb2a 3274 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3275 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3276 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3277 char onButton4_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button4 event";
whismanoid 30:07197a430869 3278 char onButton4_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE>0.7:active";
whismanoid 29:6a9edb6e973b 3279 char onButton4_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3280 char onButton4_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3281 char onButton4_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3282 char onButton4_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3283 char onButton4_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3284 char onButton4_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3285 char onButton4_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3286 char onButton4_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3287 static char* onButton4_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3288 onButton4_command_table_00,
whismanoid 29:6a9edb6e973b 3289 onButton4_command_table_01,
whismanoid 29:6a9edb6e973b 3290 onButton4_command_table_02,
whismanoid 29:6a9edb6e973b 3291 onButton4_command_table_03,
whismanoid 29:6a9edb6e973b 3292 onButton4_command_table_04,
whismanoid 29:6a9edb6e973b 3293 onButton4_command_table_05,
whismanoid 29:6a9edb6e973b 3294 onButton4_command_table_06,
whismanoid 29:6a9edb6e973b 3295 onButton4_command_table_07,
whismanoid 29:6a9edb6e973b 3296 onButton4_command_table_08,
whismanoid 29:6a9edb6e973b 3297 onButton4_command_table_09,
whismanoid 29:6a9edb6e973b 3298 };
whismanoid 29:6a9edb6e973b 3299 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3300 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3301 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3302 char onButton5_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button5 event";
whismanoid 30:07197a430869 3303 char onButton5_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE<0.6:sleep";
whismanoid 29:6a9edb6e973b 3304 char onButton5_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3305 char onButton5_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3306 char onButton5_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3307 char onButton5_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3308 char onButton5_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3309 char onButton5_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3310 char onButton5_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3311 char onButton5_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3312 static char* onButton5_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3313 onButton5_command_table_00,
whismanoid 29:6a9edb6e973b 3314 onButton5_command_table_01,
whismanoid 29:6a9edb6e973b 3315 onButton5_command_table_02,
whismanoid 29:6a9edb6e973b 3316 onButton5_command_table_03,
whismanoid 29:6a9edb6e973b 3317 onButton5_command_table_04,
whismanoid 29:6a9edb6e973b 3318 onButton5_command_table_05,
whismanoid 29:6a9edb6e973b 3319 onButton5_command_table_06,
whismanoid 29:6a9edb6e973b 3320 onButton5_command_table_07,
whismanoid 29:6a9edb6e973b 3321 onButton5_command_table_08,
whismanoid 29:6a9edb6e973b 3322 onButton5_command_table_09,
whismanoid 29:6a9edb6e973b 3323 };
whismanoid 29:6a9edb6e973b 3324 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3325 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3326 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3327 char onButton6_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button6 event";
whismanoid 29:6a9edb6e973b 3328 char onButton6_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3329 char onButton6_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3330 char onButton6_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3331 char onButton6_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3332 char onButton6_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3333 char onButton6_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3334 char onButton6_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3335 char onButton6_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3336 char onButton6_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3337 static char* onButton6_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3338 onButton6_command_table_00,
whismanoid 29:6a9edb6e973b 3339 onButton6_command_table_01,
whismanoid 29:6a9edb6e973b 3340 onButton6_command_table_02,
whismanoid 29:6a9edb6e973b 3341 onButton6_command_table_03,
whismanoid 29:6a9edb6e973b 3342 onButton6_command_table_04,
whismanoid 29:6a9edb6e973b 3343 onButton6_command_table_05,
whismanoid 29:6a9edb6e973b 3344 onButton6_command_table_06,
whismanoid 29:6a9edb6e973b 3345 onButton6_command_table_07,
whismanoid 29:6a9edb6e973b 3346 onButton6_command_table_08,
whismanoid 29:6a9edb6e973b 3347 onButton6_command_table_09,
whismanoid 29:6a9edb6e973b 3348 };
whismanoid 29:6a9edb6e973b 3349 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3350 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3351 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3352 char onButton7_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button7 event";
whismanoid 29:6a9edb6e973b 3353 char onButton7_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3354 char onButton7_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3355 char onButton7_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3356 char onButton7_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3357 char onButton7_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3358 char onButton7_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3359 char onButton7_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3360 char onButton7_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3361 char onButton7_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3362 static char* onButton7_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3363 onButton7_command_table_00,
whismanoid 29:6a9edb6e973b 3364 onButton7_command_table_01,
whismanoid 29:6a9edb6e973b 3365 onButton7_command_table_02,
whismanoid 29:6a9edb6e973b 3366 onButton7_command_table_03,
whismanoid 29:6a9edb6e973b 3367 onButton7_command_table_04,
whismanoid 29:6a9edb6e973b 3368 onButton7_command_table_05,
whismanoid 29:6a9edb6e973b 3369 onButton7_command_table_06,
whismanoid 29:6a9edb6e973b 3370 onButton7_command_table_07,
whismanoid 29:6a9edb6e973b 3371 onButton7_command_table_08,
whismanoid 29:6a9edb6e973b 3372 onButton7_command_table_09,
whismanoid 29:6a9edb6e973b 3373 };
whismanoid 29:6a9edb6e973b 3374 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3375 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3376 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3377 char onButton8_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button8 event";
whismanoid 29:6a9edb6e973b 3378 char onButton8_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3379 char onButton8_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3380 char onButton8_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3381 char onButton8_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3382 char onButton8_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3383 char onButton8_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3384 char onButton8_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3385 char onButton8_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3386 char onButton8_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3387 static char* onButton8_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3388 onButton8_command_table_00,
whismanoid 29:6a9edb6e973b 3389 onButton8_command_table_01,
whismanoid 29:6a9edb6e973b 3390 onButton8_command_table_02,
whismanoid 29:6a9edb6e973b 3391 onButton8_command_table_03,
whismanoid 29:6a9edb6e973b 3392 onButton8_command_table_04,
whismanoid 29:6a9edb6e973b 3393 onButton8_command_table_05,
whismanoid 29:6a9edb6e973b 3394 onButton8_command_table_06,
whismanoid 29:6a9edb6e973b 3395 onButton8_command_table_07,
whismanoid 29:6a9edb6e973b 3396 onButton8_command_table_08,
whismanoid 29:6a9edb6e973b 3397 onButton8_command_table_09,
whismanoid 29:6a9edb6e973b 3398 };
whismanoid 29:6a9edb6e973b 3399 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3400 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3401 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 3402 char onButton9_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button9 event";
whismanoid 29:6a9edb6e973b 3403 char onButton9_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3404 char onButton9_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3405 char onButton9_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3406 char onButton9_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3407 char onButton9_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3408 char onButton9_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3409 char onButton9_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3410 char onButton9_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3411 char onButton9_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 3412 static char* onButton9_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 3413 onButton9_command_table_00,
whismanoid 29:6a9edb6e973b 3414 onButton9_command_table_01,
whismanoid 29:6a9edb6e973b 3415 onButton9_command_table_02,
whismanoid 29:6a9edb6e973b 3416 onButton9_command_table_03,
whismanoid 29:6a9edb6e973b 3417 onButton9_command_table_04,
whismanoid 29:6a9edb6e973b 3418 onButton9_command_table_05,
whismanoid 29:6a9edb6e973b 3419 onButton9_command_table_06,
whismanoid 29:6a9edb6e973b 3420 onButton9_command_table_07,
whismanoid 29:6a9edb6e973b 3421 onButton9_command_table_08,
whismanoid 29:6a9edb6e973b 3422 onButton9_command_table_09,
whismanoid 29:6a9edb6e973b 3423 };
whismanoid 29:6a9edb6e973b 3424 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3425 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3426 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3427 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 3428 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3429 bool g_Run_command_table_running = false;
whismanoid 23:c6c652bef4b9 3430 void Run_command_table(char* command_table[])
whismanoid 23:c6c652bef4b9 3431 {
whismanoid 23:c6c652bef4b9 3432 // command_table: perform list of commands
whismanoid 31:47eee7e0cc2d 3433 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3434 if (g_Run_command_table_running) {
whismanoid 31:47eee7e0cc2d 3435 // TODO: button event chaining is not supported at this time
whismanoid 31:47eee7e0cc2d 3436 } // if (g_Run_command_table_running)
whismanoid 31:47eee7e0cc2d 3437 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3438 g_Run_command_table_running = true;
whismanoid 23:c6c652bef4b9 3439 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 3440 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 3441 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 23:c6c652bef4b9 3442 cmdLine.clear();
whismanoid 31:47eee7e0cc2d 3443 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3444 //~ char* strIndex = command_table[lineIndex];
whismanoid 23:c6c652bef4b9 3445 for (char* strIndex = command_table[lineIndex]; *strIndex != '\0'; strIndex++)
whismanoid 23:c6c652bef4b9 3446 {
whismanoid 23:c6c652bef4b9 3447 cmdLine.append(*strIndex);
whismanoid 23:c6c652bef4b9 3448 }
whismanoid 23:c6c652bef4b9 3449 cmdLine.append('\r'); // append \r invokes onEOLcommandParser to handle command
whismanoid 23:c6c652bef4b9 3450 }
whismanoid 31:47eee7e0cc2d 3451 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3452 g_Run_command_table_running = false;
whismanoid 31:47eee7e0cc2d 3453 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3454 }
whismanoid 23:c6c652bef4b9 3455 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3456 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3457 // When user presses button BUTTON1, perform actions
whismanoid 21:ac062a97a71d 3458 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3459 void onButton1FallingEdge(void)
whismanoid 21:ac062a97a71d 3460 {
whismanoid 21:ac062a97a71d 3461 //~ void SelfTest(CmdLine & cmdLine);
whismanoid 21:ac062a97a71d 3462 //~ SelfTest(cmdLine_serial);
whismanoid 22:d6dc8a85f435 3463 //
whismanoid 23:c6c652bef4b9 3464 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3465 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3466 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3467 Run_command_table(onButton1_command_table);
whismanoid 23:c6c652bef4b9 3468 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3469 }
whismanoid 21:ac062a97a71d 3470 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3471
whismanoid 21:ac062a97a71d 3472 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3473 // When user presses button BUTTON2, perform actions
whismanoid 21:ac062a97a71d 3474 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3475 void onButton2FallingEdge(void)
whismanoid 21:ac062a97a71d 3476 {
whismanoid 21:ac062a97a71d 3477 // TBD demo configuration
whismanoid 21:ac062a97a71d 3478 // TODO diagnostic LED
whismanoid 21:ac062a97a71d 3479 // led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 22:d6dc8a85f435 3480 //
whismanoid 23:c6c652bef4b9 3481 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3482 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3483 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3484 Run_command_table(onButton2_command_table);
whismanoid 23:c6c652bef4b9 3485 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3486 }
whismanoid 21:ac062a97a71d 3487 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3488
whismanoid 24:032f3683cb2a 3489 //--------------------------------------------------
whismanoid 29:6a9edb6e973b 3490 // When user presses button BUTTON3, perform actions
whismanoid 24:032f3683cb2a 3491 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3492 void onButton3FallingEdge(void)
whismanoid 24:032f3683cb2a 3493 {
whismanoid 24:032f3683cb2a 3494 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 24:032f3683cb2a 3495 // command_table: list of commands to perform on button press
whismanoid 24:032f3683cb2a 3496 // command_table: perform list of commands
whismanoid 24:032f3683cb2a 3497 Run_command_table(onButton3_command_table);
whismanoid 24:032f3683cb2a 3498 #endif // USE_DATALOGGER_CommandTable
whismanoid 24:032f3683cb2a 3499 }
whismanoid 24:032f3683cb2a 3500 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3501 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3502 void onButton4FallingEdge(void)
whismanoid 29:6a9edb6e973b 3503 {
whismanoid 29:6a9edb6e973b 3504 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3505 Run_command_table(onButton4_command_table);
whismanoid 29:6a9edb6e973b 3506 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3507 }
whismanoid 29:6a9edb6e973b 3508 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3509 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3510 void onButton5FallingEdge(void)
whismanoid 29:6a9edb6e973b 3511 {
whismanoid 29:6a9edb6e973b 3512 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3513 Run_command_table(onButton5_command_table);
whismanoid 29:6a9edb6e973b 3514 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3515 }
whismanoid 29:6a9edb6e973b 3516 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3517 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3518 void onButton6FallingEdge(void)
whismanoid 29:6a9edb6e973b 3519 {
whismanoid 29:6a9edb6e973b 3520 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3521 Run_command_table(onButton6_command_table);
whismanoid 29:6a9edb6e973b 3522 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3523 }
whismanoid 29:6a9edb6e973b 3524 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3525 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3526 void onButton7FallingEdge(void)
whismanoid 29:6a9edb6e973b 3527 {
whismanoid 29:6a9edb6e973b 3528 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3529 Run_command_table(onButton7_command_table);
whismanoid 29:6a9edb6e973b 3530 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3531 }
whismanoid 29:6a9edb6e973b 3532 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3533 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3534 void onButton8FallingEdge(void)
whismanoid 29:6a9edb6e973b 3535 {
whismanoid 29:6a9edb6e973b 3536 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3537 Run_command_table(onButton8_command_table);
whismanoid 29:6a9edb6e973b 3538 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3539 }
whismanoid 29:6a9edb6e973b 3540 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3541 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3542 void onButton9FallingEdge(void)
whismanoid 29:6a9edb6e973b 3543 {
whismanoid 29:6a9edb6e973b 3544 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3545 Run_command_table(onButton9_command_table);
whismanoid 29:6a9edb6e973b 3546 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3547 }
whismanoid 29:6a9edb6e973b 3548 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3549
whismanoid 4:d9b05924ad4c 3550 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3551 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3552 inline void print_command_prompt()
whismanoid 4:d9b05924ad4c 3553 {
whismanoid 4:d9b05924ad4c 3554 //~ Serial.println(F(">"));
whismanoid 4:d9b05924ad4c 3555 cmdLine.serial().printf("\r\n> ");
whismanoid 4:d9b05924ad4c 3556 }
whismanoid 4:d9b05924ad4c 3557 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3558
whismanoid 4:d9b05924ad4c 3559 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3560 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3561 void main_menu_status(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 3562 {
whismanoid 4:d9b05924ad4c 3563 cmdLine.serial().printf("\r\nMain menu");
whismanoid 4:d9b05924ad4c 3564 #if APPLICATION_MAX5715 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3565 cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC");
whismanoid 4:d9b05924ad4c 3566 #elif APPLICATION_MAX11131 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3567 cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC");
whismanoid 4:d9b05924ad4c 3568 #elif APPLICATION_MAX5171 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3569 cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC");
whismanoid 4:d9b05924ad4c 3570 #elif APPLICATION_MAX11410 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3571 cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC");
whismanoid 4:d9b05924ad4c 3572 #elif APPLICATION_MAX12345 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3573 cmdLine.serial().printf(" MAX12345");
whismanoid 16:819c5aaf5271 3574 #elif MAX40108_DEMO // main_menu_status banner
whismanoid 17:9397ea3ea7e9 3575 cmdLine.serial().printf(" MAX40108_U%d", MAX40108_DEMO);
whismanoid 36:e7aac874b8be 3576 #ifdef BOARD_SERIAL_NUMBER
whismanoid 36:e7aac874b8be 3577 // data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 3578 cmdLine.serial().printf(" [s/n %d]", BOARD_SERIAL_NUMBER);
whismanoid 36:e7aac874b8be 3579 #else // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 36:e7aac874b8be 3580 #warning "BOARD_SERIAL_NUMBER not defined; using default values"
whismanoid 36:e7aac874b8be 3581 //
whismanoid 36:e7aac874b8be 3582 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 3583 #ifdef FW_REV
whismanoid 37:3f369235e5bc 3584 cmdLine.serial().printf(" [FW_REV %d]", FW_REV);
whismanoid 37:3f369235e5bc 3585 #endif // FW_REV
whismanoid 4:d9b05924ad4c 3586 #else
whismanoid 4:d9b05924ad4c 3587 //cmdLine.serial().printf(" ");
whismanoid 4:d9b05924ad4c 3588 #endif
whismanoid 4:d9b05924ad4c 3589 //cmdLine.serial().printf(" %s", TARGET_NAME);
whismanoid 4:d9b05924ad4c 3590 if (cmdLine.nameStr())
whismanoid 4:d9b05924ad4c 3591 {
whismanoid 4:d9b05924ad4c 3592 cmdLine.serial().printf(" [%s]", cmdLine.nameStr());
whismanoid 4:d9b05924ad4c 3593 }
whismanoid 4:d9b05924ad4c 3594 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3595 cmdLine.serial().printf(" [Button1");
whismanoid 4:d9b05924ad4c 3596 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3597 cmdLine.serial().printf("2");
whismanoid 24:032f3683cb2a 3598 #endif
whismanoid 24:032f3683cb2a 3599 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3600 cmdLine.serial().printf("3");
whismanoid 29:6a9edb6e973b 3601 #endif
whismanoid 29:6a9edb6e973b 3602 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3603 cmdLine.serial().printf("4");
whismanoid 29:6a9edb6e973b 3604 #endif
whismanoid 29:6a9edb6e973b 3605 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3606 cmdLine.serial().printf("5");
whismanoid 29:6a9edb6e973b 3607 #endif
whismanoid 29:6a9edb6e973b 3608 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3609 cmdLine.serial().printf("6");
whismanoid 29:6a9edb6e973b 3610 #endif
whismanoid 29:6a9edb6e973b 3611 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3612 cmdLine.serial().printf("7");
whismanoid 29:6a9edb6e973b 3613 #endif
whismanoid 29:6a9edb6e973b 3614 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3615 cmdLine.serial().printf("8");
whismanoid 29:6a9edb6e973b 3616 #endif
whismanoid 29:6a9edb6e973b 3617 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3618 cmdLine.serial().printf("9");
whismanoid 29:6a9edb6e973b 3619 #endif
whismanoid 29:6a9edb6e973b 3620 cmdLine.serial().printf("]");
whismanoid 29:6a9edb6e973b 3621 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 4:d9b05924ad4c 3622 #if HAS_BUTTON1_DEMO
whismanoid 4:d9b05924ad4c 3623 // print BUTTON1 status
whismanoid 4:d9b05924ad4c 3624 cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read());
whismanoid 4:d9b05924ad4c 3625 #endif
whismanoid 4:d9b05924ad4c 3626 #if HAS_BUTTON2_DEMO
whismanoid 24:032f3683cb2a 3627 // print BUTTON2 status
whismanoid 4:d9b05924ad4c 3628 cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read());
whismanoid 4:d9b05924ad4c 3629 #endif
whismanoid 24:032f3683cb2a 3630 #if HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 3631 // print BUTTON3 status
whismanoid 24:032f3683cb2a 3632 cmdLine.serial().printf("\r\n BUTTON3 = %d", button3.read());
whismanoid 24:032f3683cb2a 3633 #endif
whismanoid 4:d9b05924ad4c 3634 cmdLine.serial().printf("\r\n ? -- help");
whismanoid 4:d9b05924ad4c 3635 }
whismanoid 4:d9b05924ad4c 3636 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3637
whismanoid 28:a9a3a9db592b 3638 //--------------------------------------------------
whismanoid 28:a9a3a9db592b 3639 #ifndef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3640 #define USE_DATALOGGER_TRIGGER_HELP_BRIEF 1
whismanoid 28:a9a3a9db592b 3641 //~ #undef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3642 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3643
whismanoid 4:d9b05924ad4c 3644 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3645 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3646 void main_menu_help(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 3647 {
whismanoid 4:d9b05924ad4c 3648 // ? -- help
whismanoid 4:d9b05924ad4c 3649 //~ cmdLine.serial().printf("\r\nMenu:");
whismanoid 10:04022a61b527 3650 //
whismanoid 4:d9b05924ad4c 3651 cmdLine.serial().printf("\r\n # -- lines beginning with # are comments");
whismanoid 10:04022a61b527 3652 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 3653 cmdLine.serial().printf("\r\n ! -- Init");
whismanoid 10:04022a61b527 3654 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 3655 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 3656 cmdLine.serial().printf("\r\n . -- SelfTest");
whismanoid 4:d9b05924ad4c 3657 #endif // USE_SELFTEST
whismanoid 9:45f98573eb6d 3658 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 9:45f98573eb6d 3659 // CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register
whismanoid 9:45f98573eb6d 3660 cmdLine.serial().printf("\r\n * -- read core registers\r\n *regname? -- read register\r\n *regname=regvalue -- write register");
whismanoid 9:45f98573eb6d 3661 // cmdLine.serial().printf("\r\n 01 23 45 67 89 ab cd ef -- write and read raw hex codes");
whismanoid 10:04022a61b527 3662 #endif // USE_STAR_REG_READWRITE
whismanoid 10:04022a61b527 3663 //
whismanoid 10:04022a61b527 3664 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3665 // Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_help
whismanoid 10:04022a61b527 3666 //~ cmdLine.serial().printf("\r\n > -- auxiliary UART port");
whismanoid 10:04022a61b527 3667 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3668 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3669 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3670 if (cmdLine_AUXserial.nameStr())
whismanoid 10:04022a61b527 3671 {
whismanoid 10:04022a61b527 3672 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_AUXserial.nameStr());
whismanoid 10:04022a61b527 3673 }
whismanoid 10:04022a61b527 3674 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3675 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3676 if (cmdLine_DAPLINKserial.nameStr())
whismanoid 10:04022a61b527 3677 {
whismanoid 10:04022a61b527 3678 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_DAPLINKserial.nameStr());
whismanoid 10:04022a61b527 3679 }
whismanoid 10:04022a61b527 3680 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3681 # if HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3682 // WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3683 cmdLine.serial().printf("\r\n >xyzzy -- Forward command/data 'xyzzy' to aux TX/RX");
whismanoid 10:04022a61b527 3684 cmdLine.serial().printf("\r\n >>xyzzy -- Forward 'xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 3685 cmdLine.serial().printf("\r\n >>>xyzzy -- Forward '>xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 3686 #if 0
whismanoid 10:04022a61b527 3687 cmdLine.serial().printf("\r\n >tx_wait_echo=%d -- configure TX wait for each character echo", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 3688 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 3689 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 3690 #endif
whismanoid 20:78ef670955d4 3691 #if 1 // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 3692 cmdLine.serial().printf("\r\n >baud=%d message_ms=%d rx_idle_ms=%d rx_max_count=%d rx_eot=%d",
whismanoid 20:78ef670955d4 3693 g_auxSerialCom_baud,
whismanoid 20:78ef670955d4 3694 g_auxSerialCom_message_ms,
whismanoid 20:78ef670955d4 3695 g_auxSerialCom_rx_idle_ms,
whismanoid 20:78ef670955d4 3696 g_auxSerialCom_rx_max_count,
whismanoid 20:78ef670955d4 3697 g_auxSerialCom_rx_eot);
whismanoid 20:78ef670955d4 3698 #else // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 3699 cmdLine.serial().printf("\r\n >baud=%d -- configure aux TX/RX port", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 3700 cmdLine.serial().printf("\r\n >message_ms=%d -- maximum RX message total response time", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 3701 cmdLine.serial().printf("\r\n >rx_idle_ms=%d -- maximum RX message idle time between characters", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 3702 cmdLine.serial().printf("\r\n >rx_max_count=%d -- maximum RX message total length", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 3703 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 3704 #endif // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 10:04022a61b527 3705 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3706 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3707 //
whismanoid 4:d9b05924ad4c 3708 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 3709 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3710 // Datalog trigger menu
whismanoid 28:a9a3a9db592b 3711 // brief toplevel heading for datalog help L
whismanoid 28:a9a3a9db592b 3712 // L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 3713 cmdLine.serial().printf("\r\n L -- halt the datalogger; show more commands");
whismanoid 28:a9a3a9db592b 3714 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 28:a9a3a9db592b 3715 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 28:a9a3a9db592b 3716 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 28:a9a3a9db592b 3717 //
whismanoid 28:a9a3a9db592b 3718 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 3719 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 3720 //
whismanoid 39:4d285e961435 3721 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 3722 // TODO: USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 3723 cmdLine.serial().printf("\r\n LT count=%d base=%dms sleep=%d -- Datalog timer",
whismanoid 39:4d285e961435 3724 g_timer_interval_count,
whismanoid 39:4d285e961435 3725 g_timer_interval_msec,
whismanoid 39:4d285e961435 3726 (int)g_timer_sleepmode
whismanoid 39:4d285e961435 3727 ); // trigger_Timer
whismanoid 39:4d285e961435 3728 #else // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 3729 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 3730 #endif // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 3731 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3732 //~ cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 3733 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3734 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 3735 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 3736 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 3737 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 9:45f98573eb6d 3738 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 9:45f98573eb6d 3739 //
whismanoid 17:9397ea3ea7e9 3740 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 4:d9b05924ad4c 3741 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 9:45f98573eb6d 3742 //
whismanoid 17:9397ea3ea7e9 3743 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 3744 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 17:9397ea3ea7e9 3745 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 3746 //
whismanoid 9:45f98573eb6d 3747 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 3748 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 3749 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 3750 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 9:45f98573eb6d 3751 //
whismanoid 17:9397ea3ea7e9 3752 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 9:45f98573eb6d 3753 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 3754 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 3755 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 3756 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 3757 //
whismanoid 17:9397ea3ea7e9 3758 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3759 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 17:9397ea3ea7e9 3760 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 9:45f98573eb6d 3761 //
whismanoid 9:45f98573eb6d 3762 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 3763 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 3764 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 3765 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 3766 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 9:45f98573eb6d 3767 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 9:45f98573eb6d 3768 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 9:45f98573eb6d 3769 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 9:45f98573eb6d 3770 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 9:45f98573eb6d 3771 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 9:45f98573eb6d 3772 //
whismanoid 9:45f98573eb6d 3773 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 3774 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 9:45f98573eb6d 3775 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 9:45f98573eb6d 3776 //
whismanoid 9:45f98573eb6d 3777 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 3778 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 3779 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 9:45f98573eb6d 3780 //
whismanoid 9:45f98573eb6d 3781 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 3782 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 9:45f98573eb6d 3783 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 3784 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 9:45f98573eb6d 3785 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 3786 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 9:45f98573eb6d 3787 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 3788 //
whismanoid 9:45f98573eb6d 3789 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 3790 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 9:45f98573eb6d 3791 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 9:45f98573eb6d 3792 //
whismanoid 9:45f98573eb6d 3793 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 3794 //
whismanoid 9:45f98573eb6d 3795 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 3796 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 3797 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 3798 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 3799 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 9:45f98573eb6d 3800 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3801 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 9:45f98573eb6d 3802 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3803 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3804 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 9:45f98573eb6d 3805 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3806 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 9:45f98573eb6d 3807 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3808 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 9:45f98573eb6d 3809 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3810 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3811 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 9:45f98573eb6d 3812 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3813 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 3814 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 3815 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 3816 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3817 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 3818 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 3819 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 3820 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3821 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 3822 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 3823 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 3824 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 3825 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 3826 //
whismanoid 4:d9b05924ad4c 3827 //cmdLine.serial().print(F("\r\n ! -- Initial Configuration"));
whismanoid 4:d9b05924ad4c 3828 //
whismanoid 4:d9b05924ad4c 3829 // % standardize diagnostic commands
whismanoid 4:d9b05924ad4c 3830 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 3831 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 3832 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 3833 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 3834 // %Ppin df=xx -- pwm output
whismanoid 4:d9b05924ad4c 3835 // %Wpin -- measure high pulsewidth input in usec
whismanoid 4:d9b05924ad4c 3836 // %wpin -- measure low pulsewidth input in usec
whismanoid 4:d9b05924ad4c 3837 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 3838 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 3839 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 3840 // %IW ADDR=? cmd=? data,data,data -- write
whismanoid 4:d9b05924ad4c 3841 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 3842 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3843 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 3844 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 3845 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 3846 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 3847 // A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 3848 //
whismanoid 23:c6c652bef4b9 3849 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3850 #if USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3851 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 3852 // TODO: %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 3853 // TODO: future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 3854 // TODO: future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 3855 // TODO: %B1@ view command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 3856 // TODO: %B1@+ command add new row (if there is room to add) (ignore one space before command)
whismanoid 23:c6c652bef4b9 3857 // TODO: %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 3858 // TODO: %B1@-~~~ clear entire command table
whismanoid 23:c6c652bef4b9 3859 // TODO: %B1@nnn command replace row number nnn (ignore one space before command)
whismanoid 23:c6c652bef4b9 3860 // TODO: %B1@! disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 3861 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 3862 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 30:07197a430869 3863 cmdLine.serial().printf("\r\n %%B1! trigger Button1 event; %%B1@ -- view/edit command table");
whismanoid 23:c6c652bef4b9 3864 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3865 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3866 #if HAS_digitalInOuts
whismanoid 4:d9b05924ad4c 3867 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 3868 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 3869 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 3870 cmdLine.serial().printf("\r\n %%Hn {pin:");
whismanoid 4:d9b05924ad4c 3871 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3872 cmdLine.serial().printf("} -- High Output");
whismanoid 4:d9b05924ad4c 3873 cmdLine.serial().printf("\r\n %%Ln {pin:");
whismanoid 4:d9b05924ad4c 3874 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3875 cmdLine.serial().printf("} -- Low Output");
whismanoid 4:d9b05924ad4c 3876 cmdLine.serial().printf("\r\n %%?n {pin:");
whismanoid 4:d9b05924ad4c 3877 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3878 cmdLine.serial().printf("} -- Input");
whismanoid 4:d9b05924ad4c 3879 #endif
whismanoid 4:d9b05924ad4c 3880
whismanoid 4:d9b05924ad4c 3881 #if HAS_analogIns
whismanoid 4:d9b05924ad4c 3882 // Menu A) analogRead A0..7
whismanoid 4:d9b05924ad4c 3883 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 3884 // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0)
whismanoid 37:3f369235e5bc 3885 cmdLine.serial().printf("\r\n %%A -- analogRead");
whismanoid 37:3f369235e5bc 3886 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 3887 // %A avg=%d -- help string display Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 3888 cmdLine.serial().printf("; %%A avg=%d -- average", Platform_AIN_Average_N);
whismanoid 37:3f369235e5bc 3889 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 3890 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3891 // %A cal? view/export raw calibration values for all channels
whismanoid 37:3f369235e5bc 3892 cmdLine.serial().printf("; %%A cal? -- calibration");
whismanoid 34:a1993a1ee904 3893 #endif // HAS_Platform_AIN_Calibration
whismanoid 4:d9b05924ad4c 3894 #endif
whismanoid 4:d9b05924ad4c 3895
whismanoid 4:d9b05924ad4c 3896 #if HAS_SPI2_MAX541
whismanoid 4:d9b05924ad4c 3897 // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 4:d9b05924ad4c 3898 cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)");
whismanoid 4:d9b05924ad4c 3899 #endif
whismanoid 4:d9b05924ad4c 3900
whismanoid 4:d9b05924ad4c 3901 #if HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3902 // TODO: support I2C HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3903 // VERIFY: I2C utility commands SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3904 // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz);
whismanoid 4:d9b05924ad4c 3905 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 3906 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 3907 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 3908 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 4:d9b05924ad4c 3909 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 3910 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3911 //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope
whismanoid 4:d9b05924ad4c 3912 cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 4:d9b05924ad4c 3913 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 4:d9b05924ad4c 3914 (g_I2C_SCL_Hz / 1000.));
whismanoid 4:d9b05924ad4c 3915 cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read",
whismanoid 4:d9b05924ad4c 3916 g_I2C_deviceAddress7);
whismanoid 4:d9b05924ad4c 3917 //
whismanoid 4:d9b05924ad4c 3918 #if SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3919 // Menu ^ cmd=?) i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3920 cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data");
whismanoid 4:d9b05924ad4c 3921 // test low-level I2C i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3922 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3923 //cmdLine.serial().printf(" H) Hunt for attached I2C devices");
whismanoid 4:d9b05924ad4c 3924 cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices");
whismanoid 4:d9b05924ad4c 3925 // cmdLine.serial().printf(" s) search i2c address");
whismanoid 4:d9b05924ad4c 3926 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3927
whismanoid 4:d9b05924ad4c 3928 #if HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3929 // TODO: support SPI HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3930 // SPI test command S (mosiData)+
whismanoid 4:d9b05924ad4c 3931 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 3932 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 3933 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 3934 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 3935 // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 4:d9b05924ad4c 3936 // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 4:d9b05924ad4c 3937 // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 4:d9b05924ad4c 3938 // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 4:d9b05924ad4c 3939 // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 4:d9b05924ad4c 3940 // mode | POL PHA
whismanoid 4:d9b05924ad4c 3941 // -----+--------
whismanoid 4:d9b05924ad4c 3942 // 0 | 0 0
whismanoid 4:d9b05924ad4c 3943 // 1 | 0 1
whismanoid 4:d9b05924ad4c 3944 // 2 | 1 0
whismanoid 4:d9b05924ad4c 3945 // 3 | 1 1
whismanoid 4:d9b05924ad4c 3946 //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0");
whismanoid 4:d9b05924ad4c 3947 // 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 3948 cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config",
whismanoid 4:d9b05924ad4c 3949 g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.),
whismanoid 4:d9b05924ad4c 3950 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 4:d9b05924ad4c 3951 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0));
whismanoid 4:d9b05924ad4c 3952 cmdLine.serial().printf("\r\n %%SD -- SPI diagnostic messages ");
whismanoid 4:d9b05924ad4c 3953 if (g_MAX11410_device.onSPIprint) {
whismanoid 4:d9b05924ad4c 3954 cmdLine.serial().printf("hide");
whismanoid 4:d9b05924ad4c 3955 }
whismanoid 4:d9b05924ad4c 3956 else {
whismanoid 4:d9b05924ad4c 3957 cmdLine.serial().printf("show");
whismanoid 4:d9b05924ad4c 3958 }
whismanoid 4:d9b05924ad4c 3959 cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes");
whismanoid 4:d9b05924ad4c 3960 // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0
whismanoid 4:d9b05924ad4c 3961 #endif // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3962 //
whismanoid 4:d9b05924ad4c 3963 // Application-specific commands (help text) here
whismanoid 4:d9b05924ad4c 3964 //
whismanoid 4:d9b05924ad4c 3965 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3966 cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3967 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3968 //
whismanoid 4:d9b05924ad4c 3969
whismanoid 4:d9b05924ad4c 3970 //~ extern void MAX11410_menu_help(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp\n
whismanoid 4:d9b05924ad4c 3971 //~ MAX11410_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 3972 }
whismanoid 4:d9b05924ad4c 3973 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3974
whismanoid 4:d9b05924ad4c 3975 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 15:37c83ec50ea0 3976
whismanoid 15:37c83ec50ea0 3977 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 3978 void pinsMonitor_submenu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 15:37c83ec50ea0 3979 {
whismanoid 15:37c83ec50ea0 3980 // % diagnostic commands submenu
whismanoid 15:37c83ec50ea0 3981 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 3982 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 3983 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 3984 // %A %Apin -- analog input
whismanoid 15:37c83ec50ea0 3985 // %Ppin df=xx -- pwm output
whismanoid 15:37c83ec50ea0 3986 // %Wpin -- measure high pulsewidth input in usec
whismanoid 15:37c83ec50ea0 3987 // %wpin -- measure low pulsewidth input in usec
whismanoid 15:37c83ec50ea0 3988 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 3989 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 3990 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 3991 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 3992 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 3993 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 3994 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 3995 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 3996 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 3997 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 3998 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 3999 //
whismanoid 15:37c83ec50ea0 4000 char strPinIndex[3];
whismanoid 15:37c83ec50ea0 4001 strPinIndex[0] = cmdLine[2];
whismanoid 15:37c83ec50ea0 4002 strPinIndex[1] = cmdLine[3];
whismanoid 15:37c83ec50ea0 4003 strPinIndex[2] = '\0';
whismanoid 15:37c83ec50ea0 4004 int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 15:37c83ec50ea0 4005 //cmdLine.serial().printf(" pinIndex=%d ", pinIndex);
whismanoid 15:37c83ec50ea0 4006 //
whismanoid 15:37c83ec50ea0 4007 // get next character
whismanoid 15:37c83ec50ea0 4008 switch (cmdLine[1])
whismanoid 15:37c83ec50ea0 4009 {
whismanoid 23:c6c652bef4b9 4010 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 4011 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 4012 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 4013 case 'B': case 'b':
whismanoid 23:c6c652bef4b9 4014 {
whismanoid 24:032f3683cb2a 4015 int command_table_button_index = 1;
whismanoid 23:c6c652bef4b9 4016 // %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 4017 // future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 4018 // future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 4019 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 4020 // cmdLine[2] == '1' selects onButton1_command_table
whismanoid 23:c6c652bef4b9 4021 char** command_table = onButton1_command_table;
whismanoid 23:c6c652bef4b9 4022 #endif
whismanoid 24:032f3683cb2a 4023 switch(cmdLine[2])
whismanoid 24:032f3683cb2a 4024 {
whismanoid 24:032f3683cb2a 4025 default:
whismanoid 24:032f3683cb2a 4026 case '1': case 'A': case 'a': case '!':
whismanoid 24:032f3683cb2a 4027 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4028 command_table_button_index = 1;
whismanoid 24:032f3683cb2a 4029 command_table = onButton1_command_table;
whismanoid 24:032f3683cb2a 4030 #endif
whismanoid 24:032f3683cb2a 4031 break;
whismanoid 24:032f3683cb2a 4032 case '2': case 'B': case 'b': case '@':
whismanoid 23:c6c652bef4b9 4033 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4034 command_table_button_index = 2;
whismanoid 24:032f3683cb2a 4035 command_table = onButton2_command_table;
whismanoid 24:032f3683cb2a 4036 #endif
whismanoid 24:032f3683cb2a 4037 break;
whismanoid 24:032f3683cb2a 4038 case '3': case 'C': case 'c': case '#':
whismanoid 23:c6c652bef4b9 4039 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 4040 command_table_button_index = 3;
whismanoid 24:032f3683cb2a 4041 command_table = onButton3_command_table;
whismanoid 24:032f3683cb2a 4042 #endif
whismanoid 24:032f3683cb2a 4043 break;
whismanoid 29:6a9edb6e973b 4044 case '4':
whismanoid 29:6a9edb6e973b 4045 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4046 command_table_button_index = 4;
whismanoid 29:6a9edb6e973b 4047 command_table = onButton4_command_table;
whismanoid 29:6a9edb6e973b 4048 #endif
whismanoid 29:6a9edb6e973b 4049 break;
whismanoid 29:6a9edb6e973b 4050 case '5':
whismanoid 29:6a9edb6e973b 4051 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4052 command_table_button_index = 5;
whismanoid 29:6a9edb6e973b 4053 command_table = onButton5_command_table;
whismanoid 29:6a9edb6e973b 4054 #endif
whismanoid 29:6a9edb6e973b 4055 break;
whismanoid 29:6a9edb6e973b 4056 case '6':
whismanoid 29:6a9edb6e973b 4057 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4058 command_table_button_index = 6;
whismanoid 29:6a9edb6e973b 4059 command_table = onButton6_command_table;
whismanoid 29:6a9edb6e973b 4060 #endif
whismanoid 29:6a9edb6e973b 4061 break;
whismanoid 29:6a9edb6e973b 4062 case '7':
whismanoid 29:6a9edb6e973b 4063 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4064 command_table_button_index = 7;
whismanoid 29:6a9edb6e973b 4065 command_table = onButton7_command_table;
whismanoid 29:6a9edb6e973b 4066 #endif
whismanoid 29:6a9edb6e973b 4067 break;
whismanoid 29:6a9edb6e973b 4068 case '8':
whismanoid 29:6a9edb6e973b 4069 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4070 command_table_button_index = 8;
whismanoid 29:6a9edb6e973b 4071 command_table = onButton8_command_table;
whismanoid 29:6a9edb6e973b 4072 #endif
whismanoid 29:6a9edb6e973b 4073 break;
whismanoid 29:6a9edb6e973b 4074 case '9':
whismanoid 29:6a9edb6e973b 4075 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 4076 command_table_button_index = 9;
whismanoid 29:6a9edb6e973b 4077 command_table = onButton9_command_table;
whismanoid 29:6a9edb6e973b 4078 #endif
whismanoid 29:6a9edb6e973b 4079 break;
whismanoid 24:032f3683cb2a 4080 }
whismanoid 24:032f3683cb2a 4081 //
whismanoid 23:c6c652bef4b9 4082 switch(cmdLine[3])
whismanoid 23:c6c652bef4b9 4083 {
whismanoid 23:c6c652bef4b9 4084 case '@':
whismanoid 23:c6c652bef4b9 4085 {
whismanoid 23:c6c652bef4b9 4086 // %B1@ view/edit command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 4087 int editRowIndex = 0;
whismanoid 23:c6c652bef4b9 4088 int command_table_row_count = 0;
whismanoid 23:c6c652bef4b9 4089 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 4090 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 4091 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 4092 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 4093 }
whismanoid 24:032f3683cb2a 4094 //
whismanoid 24:032f3683cb2a 4095 // ignore extra spaces before the command
whismanoid 24:032f3683cb2a 4096 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 24:032f3683cb2a 4097 int argIndex;
whismanoid 24:032f3683cb2a 4098 for (argIndex = 5; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 4099 {
whismanoid 24:032f3683cb2a 4100 if (cmdLine[argIndex] == ' ') break;
whismanoid 24:032f3683cb2a 4101 }
whismanoid 24:032f3683cb2a 4102 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 4103 {
whismanoid 24:032f3683cb2a 4104 if (cmdLine[argIndex] != ' ') break;
whismanoid 23:c6c652bef4b9 4105 }
whismanoid 23:c6c652bef4b9 4106 //
whismanoid 23:c6c652bef4b9 4107 // Edit the contents of command_table
whismanoid 23:c6c652bef4b9 4108 switch (cmdLine[4]) // %B1@... -- Edit the contents of command_table
whismanoid 23:c6c652bef4b9 4109 {
whismanoid 23:c6c652bef4b9 4110 case '0': case '1': case '2': case '3': case '4':
whismanoid 23:c6c652bef4b9 4111 case '5': case '6': case '7': case '8': case '9':
whismanoid 24:032f3683cb2a 4112 // %B1@nnn command replace row number nnn
whismanoid 23:c6c652bef4b9 4113 // edit row data
whismanoid 33:70a28cfe9e01 4114 // get row number to edit from cmdLine[4]
whismanoid 33:70a28cfe9e01 4115 editRowIndex = atoi(cmdLine.str()+4);
whismanoid 23:c6c652bef4b9 4116 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4117 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 4118 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 28:a9a3a9db592b 4119 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 4120 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 4121 cmdLine.serial().printf("\r\n cannot replace row %d with nothing",
whismanoid 28:a9a3a9db592b 4122 editRowIndex);
whismanoid 28:a9a3a9db592b 4123 }
whismanoid 28:a9a3a9db592b 4124 else
whismanoid 28:a9a3a9db592b 4125 {
whismanoid 28:a9a3a9db592b 4126 // update row
whismanoid 28:a9a3a9db592b 4127 cmdLine.serial().printf("\r\n replace row %d with \"%s\"",
whismanoid 28:a9a3a9db592b 4128 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 4129 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4130 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 4131 }
whismanoid 24:032f3683cb2a 4132 }
whismanoid 33:70a28cfe9e01 4133 } // end if (command_table_row_count > 0)
whismanoid 33:70a28cfe9e01 4134 if ((editRowIndex == command_table_row_count) && (command_table_row_count < COMMAND_TABLE_ROW_MAX)) {
whismanoid 33:70a28cfe9e01 4135 // %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 4136 //
whismanoid 33:70a28cfe9e01 4137 command_table_row_count++;
whismanoid 33:70a28cfe9e01 4138 cmdLine.serial().printf("\r\n add next row %d containing \"%s\"",
whismanoid 33:70a28cfe9e01 4139 editRowIndex, cmdLine.str()+argIndex);
whismanoid 33:70a28cfe9e01 4140 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 33:70a28cfe9e01 4141 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 33:70a28cfe9e01 4142 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 33:70a28cfe9e01 4143 //
whismanoid 23:c6c652bef4b9 4144 }
whismanoid 33:70a28cfe9e01 4145 //
whismanoid 23:c6c652bef4b9 4146 break;
whismanoid 23:c6c652bef4b9 4147 case '+':
whismanoid 24:032f3683cb2a 4148 // %B1@+ command add new row (if there is room to add)
whismanoid 23:c6c652bef4b9 4149 // add a new row at end of table
whismanoid 23:c6c652bef4b9 4150 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 4151 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 23:c6c652bef4b9 4152 editRowIndex = command_table_row_count;
whismanoid 28:a9a3a9db592b 4153 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 4154 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 4155 cmdLine.serial().printf("\r\n cannot add new row %d containing nothing",
whismanoid 28:a9a3a9db592b 4156 editRowIndex);
whismanoid 28:a9a3a9db592b 4157 }
whismanoid 28:a9a3a9db592b 4158 else
whismanoid 28:a9a3a9db592b 4159 {
whismanoid 28:a9a3a9db592b 4160 command_table_row_count++;
whismanoid 28:a9a3a9db592b 4161 cmdLine.serial().printf("\r\n add new row %d containing \"%s\"",
whismanoid 28:a9a3a9db592b 4162 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 4163 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4164 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 4165 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 28:a9a3a9db592b 4166 }
whismanoid 23:c6c652bef4b9 4167 }
whismanoid 23:c6c652bef4b9 4168 break;
whismanoid 23:c6c652bef4b9 4169 case '-':
whismanoid 24:032f3683cb2a 4170 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 4171 // delete row from table
whismanoid 23:c6c652bef4b9 4172 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4173 // if command_table_row_count == 0 then the table is empty
whismanoid 23:c6c652bef4b9 4174 if ((cmdLine[5] == '~') && (cmdLine[6] == '~') && (cmdLine[7] == '~')) {
whismanoid 23:c6c652bef4b9 4175 // %B1@-~~~ clear entire command table
whismanoid 24:032f3683cb2a 4176 cmdLine.serial().printf("\r\n clear entire command table");
whismanoid 23:c6c652bef4b9 4177 command_table_row_count = 0;
whismanoid 28:a9a3a9db592b 4178 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 23:c6c652bef4b9 4179 break;
whismanoid 23:c6c652bef4b9 4180 }
whismanoid 24:032f3683cb2a 4181 else
whismanoid 23:c6c652bef4b9 4182 {
whismanoid 24:032f3683cb2a 4183 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 24:032f3683cb2a 4184 editRowIndex = atoi(cmdLine.str()+5);
whismanoid 24:032f3683cb2a 4185 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 24:032f3683cb2a 4186 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 24:032f3683cb2a 4187 // delete row editRowIndex from Datalogger_action_table
whismanoid 24:032f3683cb2a 4188 for (int i = editRowIndex; i < (command_table_row_count-1); i++)
whismanoid 24:032f3683cb2a 4189 {
whismanoid 24:032f3683cb2a 4190 // copy row i+1 into row i
whismanoid 24:032f3683cb2a 4191 cmdLine.serial().printf("\r\n copy row %d into row %d: \"%s\"",
whismanoid 24:032f3683cb2a 4192 i+1, i, command_table[i+1]);
whismanoid 24:032f3683cb2a 4193 strncpy(command_table[i], command_table[i+1], COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 4194 command_table[i][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 24:032f3683cb2a 4195 }
whismanoid 24:032f3683cb2a 4196 command_table_row_count--;
whismanoid 28:a9a3a9db592b 4197 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 24:032f3683cb2a 4198 }
whismanoid 23:c6c652bef4b9 4199 }
whismanoid 23:c6c652bef4b9 4200 }
whismanoid 23:c6c652bef4b9 4201 break;
whismanoid 30:07197a430869 4202 case '.': // something other than ! because %B1! means trigger event
whismanoid 30:07197a430869 4203 // pause the button event
whismanoid 30:07197a430869 4204 // TODO: %B1@. disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 4205 //~ Datalogger_action_table_enabled = false;
whismanoid 23:c6c652bef4b9 4206 break;
whismanoid 23:c6c652bef4b9 4207 case '@':
whismanoid 30:07197a430869 4208 // enable the button event
whismanoid 23:c6c652bef4b9 4209 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 4210 //~ Datalogger_action_table_enabled = true;
whismanoid 23:c6c652bef4b9 4211 break;
whismanoid 23:c6c652bef4b9 4212 }
whismanoid 23:c6c652bef4b9 4213 //
whismanoid 23:c6c652bef4b9 4214 // Print the contents of command_table
whismanoid 23:c6c652bef4b9 4215 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 4216 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 4217 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 4218 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 4219 cmdLine.serial().printf("\r\n %%B%1d@%d %s",
whismanoid 24:032f3683cb2a 4220 command_table_button_index,
whismanoid 24:032f3683cb2a 4221 lineIndex,
whismanoid 24:032f3683cb2a 4222 command_table[lineIndex]);
whismanoid 23:c6c652bef4b9 4223 }
whismanoid 30:07197a430869 4224 //~ cmdLine.serial().printf("\r\n command_table_row_count = %d/%d",
whismanoid 30:07197a430869 4225 //~ command_table_row_count, COMMAND_TABLE_ROW_MAX);
whismanoid 30:07197a430869 4226 cmdLine.serial().printf("\r\n\r\nEdit Button%d event (used %d/%d, %d free):",
whismanoid 30:07197a430869 4227 command_table_button_index,
whismanoid 30:07197a430869 4228 command_table_row_count,
whismanoid 30:07197a430869 4229 COMMAND_TABLE_ROW_MAX,
whismanoid 30:07197a430869 4230 (COMMAND_TABLE_ROW_MAX - command_table_row_count)
whismanoid 30:07197a430869 4231 );
whismanoid 23:c6c652bef4b9 4232 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 4233 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 24:032f3683cb2a 4234 cmdLine.serial().printf("\r\n %%B%1d@+ command -- add new row %d at end of table",
whismanoid 24:032f3683cb2a 4235 command_table_button_index,
whismanoid 24:032f3683cb2a 4236 command_table_row_count);
whismanoid 23:c6c652bef4b9 4237 }
whismanoid 23:c6c652bef4b9 4238 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 4239 // if command_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 4240 cmdLine.serial().printf("\r\n %%B%1d@%d command -- replace row %d",
whismanoid 24:032f3683cb2a 4241 command_table_button_index,
whismanoid 23:c6c652bef4b9 4242 command_table_row_count-1,
whismanoid 23:c6c652bef4b9 4243 command_table_row_count-1);
whismanoid 24:032f3683cb2a 4244 cmdLine.serial().printf("\r\n %%B%1d@-%d -- delete row %d",
whismanoid 24:032f3683cb2a 4245 command_table_button_index,
whismanoid 24:032f3683cb2a 4246 command_table_row_count-1,
whismanoid 24:032f3683cb2a 4247 command_table_row_count-1);
whismanoid 24:032f3683cb2a 4248 cmdLine.serial().printf("\r\n %%B%1d@-~~~ -- delete all rows",
whismanoid 24:032f3683cb2a 4249 command_table_button_index);
whismanoid 30:07197a430869 4250 //~ cmdLine.serial().printf("\r\n %%B%1d@. -- pause entire command table",
whismanoid 30:07197a430869 4251 //~ command_table_button_index);
whismanoid 30:07197a430869 4252 //~ cmdLine.serial().printf("\r\n %%B%1d@@ -- enable command table",
whismanoid 30:07197a430869 4253 //~ command_table_button_index);
whismanoid 30:07197a430869 4254 cmdLine.serial().printf("\r\n %%B%1d! -- trigger Button%d event",
whismanoid 30:07197a430869 4255 command_table_button_index,
whismanoid 24:032f3683cb2a 4256 command_table_button_index);
whismanoid 23:c6c652bef4b9 4257 }
whismanoid 23:c6c652bef4b9 4258 //
whismanoid 23:c6c652bef4b9 4259 } // case '@' -- %B1@ view/edit command table
whismanoid 23:c6c652bef4b9 4260 break;
whismanoid 23:c6c652bef4b9 4261 case '!':
whismanoid 23:c6c652bef4b9 4262 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 23:c6c652bef4b9 4263 Run_command_table(command_table);
whismanoid 23:c6c652bef4b9 4264 break;
whismanoid 23:c6c652bef4b9 4265 }
whismanoid 23:c6c652bef4b9 4266 }
whismanoid 23:c6c652bef4b9 4267 break;
whismanoid 23:c6c652bef4b9 4268 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 4269 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 4270 #if HAS_digitalInOuts
whismanoid 15:37c83ec50ea0 4271 case 'H': case 'h':
whismanoid 15:37c83ec50ea0 4272 {
whismanoid 15:37c83ec50ea0 4273 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 4274 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4275 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4276 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4277 #else
whismanoid 15:37c83ec50ea0 4278 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4279 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 4280 digitalInOutPin.write(1);
whismanoid 15:37c83ec50ea0 4281 #endif
whismanoid 15:37c83ec50ea0 4282 cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex);
whismanoid 15:37c83ec50ea0 4283 }
whismanoid 15:37c83ec50ea0 4284 break;
whismanoid 15:37c83ec50ea0 4285 case 'L': case 'l':
whismanoid 15:37c83ec50ea0 4286 {
whismanoid 15:37c83ec50ea0 4287 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 4288 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4289 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4290 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4291 #else
whismanoid 15:37c83ec50ea0 4292 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4293 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 4294 digitalInOutPin.write(0);
whismanoid 15:37c83ec50ea0 4295 #endif
whismanoid 15:37c83ec50ea0 4296 cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex);
whismanoid 15:37c83ec50ea0 4297 }
whismanoid 15:37c83ec50ea0 4298 break;
whismanoid 15:37c83ec50ea0 4299 case '?':
whismanoid 15:37c83ec50ea0 4300 {
whismanoid 15:37c83ec50ea0 4301 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 4302 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4303 pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 4304 #else
whismanoid 15:37c83ec50ea0 4305 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 4306 digitalInOutPin.input();
whismanoid 15:37c83ec50ea0 4307 #endif
whismanoid 15:37c83ec50ea0 4308 serial.printf(" digitalInOutPin %d Input ", pinIndex);
whismanoid 15:37c83ec50ea0 4309 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 4310 int value = digitalRead(pinIndex);
whismanoid 15:37c83ec50ea0 4311 #else
whismanoid 15:37c83ec50ea0 4312 int value = digitalInOutPin.read();
whismanoid 15:37c83ec50ea0 4313 #endif
whismanoid 15:37c83ec50ea0 4314 cmdLine.serial().printf("%d ", value);
whismanoid 15:37c83ec50ea0 4315 }
whismanoid 15:37c83ec50ea0 4316 break;
whismanoid 15:37c83ec50ea0 4317 #endif
whismanoid 15:37c83ec50ea0 4318 //
whismanoid 15:37c83ec50ea0 4319 #if HAS_analogIns
whismanoid 15:37c83ec50ea0 4320 case 'A': case 'a':
whismanoid 15:37c83ec50ea0 4321 {
whismanoid 15:37c83ec50ea0 4322 // %A %Apin -- analog input
whismanoid 37:3f369235e5bc 4323 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4324 // %A avg= -- set Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 4325 if (cmdLine.parse_int_dec("avg", Platform_AIN_Average_N))
whismanoid 37:3f369235e5bc 4326 {
whismanoid 37:3f369235e5bc 4327 // Platform_AIN_Average_N was updated
whismanoid 37:3f369235e5bc 4328 }
whismanoid 37:3f369235e5bc 4329 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4330 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4331 // %A cal? view/export raw calibration values for all channels
whismanoid 34:a1993a1ee904 4332 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4333 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4334 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4335 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4336 {
whismanoid 34:a1993a1ee904 4337 char valueBuf[16];
whismanoid 34:a1993a1ee904 4338 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 4339 if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 4340 {
whismanoid 34:a1993a1ee904 4341 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4342 {
whismanoid 34:a1993a1ee904 4343 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 4344 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4345 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 4346 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4347 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 4348 );
whismanoid 34:a1993a1ee904 4349 }
whismanoid 34:a1993a1ee904 4350 //
whismanoid 34:a1993a1ee904 4351 // print extended help for %A
whismanoid 34:a1993a1ee904 4352 // %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 4353 //~ cmdLine.serial().printf("\r\n %%A cal0n=0.02 cal0v=0.123 cal0n=0.938 cal0v=1.132 -- update calibration");
whismanoid 34:a1993a1ee904 4354 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 4355 cmdLine.serial().printf(" %%A cal0test=0.5 -- calculate voltage at 50%% of full scale");
whismanoid 34:a1993a1ee904 4356 cmdLine.serial().printf("\r\n %%A v0cal=1.000V -- calibrate channel against a known input voltage");
whismanoid 34:a1993a1ee904 4357 // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 4358 // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 4359 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 4360 cmdLine.serial().printf("\r\n %%A calreset -- reset all calibration data");
whismanoid 37:3f369235e5bc 4361 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4362 // %A avg=%d -- help string display Platform_AIN_Average_N
whismanoid 37:3f369235e5bc 4363 cmdLine.serial().printf("\r\n %%A avg=%d -- average", Platform_AIN_Average_N);
whismanoid 37:3f369235e5bc 4364 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4365 cmdLine.serial().printf("\r\n\r\n");
whismanoid 34:a1993a1ee904 4366 //
whismanoid 34:a1993a1ee904 4367 } // end if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 4368 }
whismanoid 34:a1993a1ee904 4369 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4370 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4371 {
whismanoid 34:a1993a1ee904 4372 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 4373 char valueBuf[16];
whismanoid 34:a1993a1ee904 4374 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 4375 if (cmdLine.parse_and_remove_key("calreset", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 4376 {
whismanoid 34:a1993a1ee904 4377 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 4378 calibration_05_normValue_0_1[0] = 0.25; calibration_05_V[0] = 0.3;
whismanoid 34:a1993a1ee904 4379 calibration_05_normValue_0_1[1] = 0.25; calibration_05_V[1] = 0.3;
whismanoid 34:a1993a1ee904 4380 calibration_05_normValue_0_1[2] = 0.25; calibration_05_V[2] = 0.3;
whismanoid 34:a1993a1ee904 4381 calibration_05_normValue_0_1[3] = 0.25; calibration_05_V[3] = 0.3;
whismanoid 34:a1993a1ee904 4382 calibration_05_normValue_0_1[4] = 0.25; calibration_05_V[4] = 1.5;
whismanoid 34:a1993a1ee904 4383 calibration_05_normValue_0_1[5] = 0.25; calibration_05_V[5] = 1.5;
whismanoid 34:a1993a1ee904 4384 //
whismanoid 34:a1993a1ee904 4385 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 4386 calibration_95_normValue_0_1[0] = 0.75; calibration_95_V[0] = 0.9;
whismanoid 34:a1993a1ee904 4387 calibration_95_normValue_0_1[1] = 0.75; calibration_95_V[1] = 0.9;
whismanoid 34:a1993a1ee904 4388 calibration_95_normValue_0_1[2] = 0.75; calibration_95_V[2] = 0.9;
whismanoid 34:a1993a1ee904 4389 calibration_95_normValue_0_1[3] = 0.75; calibration_95_V[3] = 0.9;
whismanoid 34:a1993a1ee904 4390 calibration_95_normValue_0_1[4] = 0.75; calibration_95_V[4] = 4.5;
whismanoid 34:a1993a1ee904 4391 calibration_95_normValue_0_1[5] = 0.75; calibration_95_V[5] = 4.5;
whismanoid 34:a1993a1ee904 4392 //
whismanoid 34:a1993a1ee904 4393 }
whismanoid 34:a1993a1ee904 4394 }
whismanoid 34:a1993a1ee904 4395 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4396 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4397 // %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 4398 // %A cal4n=0.135874882 cal4v=0.800000012V cal4n=0.286168128 cal4v=1.700000048V
whismanoid 34:a1993a1ee904 4399 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4400 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4401 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4402 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4403 {
whismanoid 34:a1993a1ee904 4404 double normValue_0_1, V;
whismanoid 34:a1993a1ee904 4405 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4406 {
whismanoid 34:a1993a1ee904 4407 static char key_can0n[8] = "cal0n__";
whismanoid 34:a1993a1ee904 4408 sprintf(key_can0n, "cal%1dn", ch);
whismanoid 34:a1993a1ee904 4409 static char key_cal0v[8] = "cal0v__";
whismanoid 34:a1993a1ee904 4410 sprintf(key_cal0v, "cal%1dv", ch);
whismanoid 35:c9549b5c01de 4411 // first point could be the 5% point or the 95% point
whismanoid 35:c9549b5c01de 4412 double norm_threshold = (calibration_05_normValue_0_1[ch] + calibration_95_normValue_0_1[ch]) / 2.0;
whismanoid 35:c9549b5c01de 4413 bool updated_05 = false;
whismanoid 35:c9549b5c01de 4414 //~ bool updated_95 = false;
whismanoid 35:c9549b5c01de 4415 if (cmdLine.parse_double(key_can0n, normValue_0_1)) {
whismanoid 34:a1993a1ee904 4416 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 34:a1993a1ee904 4417 {
whismanoid 35:c9549b5c01de 4418 if (normValue_0_1 < norm_threshold) {
whismanoid 35:c9549b5c01de 4419 // store first calibration point in the 5% slot
whismanoid 35:c9549b5c01de 4420 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 4421 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 4422 updated_05 = true;
whismanoid 34:a1993a1ee904 4423 }
whismanoid 34:a1993a1ee904 4424 else {
whismanoid 35:c9549b5c01de 4425 // store first calibration point in the 95% slot
whismanoid 35:c9549b5c01de 4426 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 4427 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 4428 //~ updated_95 = true;
whismanoid 34:a1993a1ee904 4429 }
whismanoid 34:a1993a1ee904 4430 }
whismanoid 35:c9549b5c01de 4431 }
whismanoid 35:c9549b5c01de 4432 // handle the optional second calibration point
whismanoid 35:c9549b5c01de 4433 if (cmdLine.parse_double(key_can0n, normValue_0_1))
whismanoid 35:c9549b5c01de 4434 {
whismanoid 35:c9549b5c01de 4435 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 35:c9549b5c01de 4436 {
whismanoid 35:c9549b5c01de 4437 if (updated_05) {
whismanoid 35:c9549b5c01de 4438 // we already stored the first point here
whismanoid 35:c9549b5c01de 4439 // calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4440 // calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 4441 // store the second point in the other slot
whismanoid 35:c9549b5c01de 4442 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4443 calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 4444 }
whismanoid 35:c9549b5c01de 4445 else {
whismanoid 35:c9549b5c01de 4446 // we already stored the first point here
whismanoid 35:c9549b5c01de 4447 // calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4448 // calibration_95_V[ch] = V;
whismanoid 35:c9549b5c01de 4449 // store the second point in the other slot
whismanoid 35:c9549b5c01de 4450 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 35:c9549b5c01de 4451 calibration_05_V[ch] = V;
whismanoid 35:c9549b5c01de 4452 }
whismanoid 35:c9549b5c01de 4453 }
whismanoid 35:c9549b5c01de 4454 }
whismanoid 38:fda80a0020d1 4455 // make sure calibration_05_normValue_0_1[ch] < calibration_95_normValue_0_1[ch]
whismanoid 38:fda80a0020d1 4456 if (calibration_05_normValue_0_1[ch] > calibration_95_normValue_0_1[ch])
whismanoid 38:fda80a0020d1 4457 {
whismanoid 38:fda80a0020d1 4458 // swap to make sure calibration_05_normValue_0_1[ch] < calibration_95_normValue_0_1[ch]
whismanoid 38:fda80a0020d1 4459 double n05 = calibration_95_normValue_0_1[ch];
whismanoid 38:fda80a0020d1 4460 double V05 = calibration_95_V[ch];
whismanoid 38:fda80a0020d1 4461 double n95 = calibration_05_normValue_0_1[ch];
whismanoid 38:fda80a0020d1 4462 double V95 = calibration_05_V[ch];
whismanoid 38:fda80a0020d1 4463 calibration_05_normValue_0_1[ch] = n05;
whismanoid 38:fda80a0020d1 4464 calibration_05_V[ch] = V05;
whismanoid 38:fda80a0020d1 4465 calibration_95_normValue_0_1[ch] = n95;
whismanoid 38:fda80a0020d1 4466 calibration_95_V[ch] = V95;
whismanoid 38:fda80a0020d1 4467 }
whismanoid 34:a1993a1ee904 4468 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4469 }
whismanoid 34:a1993a1ee904 4470 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4471 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4472 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 4473 // double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 4474 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4475 {
whismanoid 34:a1993a1ee904 4476 static char key_cal0test[12] = "cal0test__";
whismanoid 34:a1993a1ee904 4477 sprintf(key_cal0test, "cal%1dtest", ch);
whismanoid 34:a1993a1ee904 4478 double normValue_0_1, Vtest;
whismanoid 34:a1993a1ee904 4479 if (cmdLine.parse_double(key_cal0test, Vtest))
whismanoid 34:a1993a1ee904 4480 {
whismanoid 34:a1993a1ee904 4481 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 4482 normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 4483 //
whismanoid 34:a1993a1ee904 4484 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 4485 ch,
whismanoid 34:a1993a1ee904 4486 normValue_0_1,
whismanoid 34:a1993a1ee904 4487 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 4488 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4489 );
whismanoid 34:a1993a1ee904 4490 //
whismanoid 34:a1993a1ee904 4491 // sweep CalibratedNormValue argument
whismanoid 34:a1993a1ee904 4492 double normValue_0_1_start = -0.05;
whismanoid 34:a1993a1ee904 4493 double normValue_0_1_step = 0.05;
whismanoid 34:a1993a1ee904 4494 double normValue_0_1_end = 1.07;
whismanoid 34:a1993a1ee904 4495 for (normValue_0_1 = normValue_0_1_start;
whismanoid 34:a1993a1ee904 4496 normValue_0_1 <= normValue_0_1_end;
whismanoid 34:a1993a1ee904 4497 normValue_0_1 = normValue_0_1 + normValue_0_1_step)
whismanoid 34:a1993a1ee904 4498 {
whismanoid 34:a1993a1ee904 4499 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 4500 ch,
whismanoid 34:a1993a1ee904 4501 normValue_0_1,
whismanoid 34:a1993a1ee904 4502 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 4503 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4504 );
whismanoid 34:a1993a1ee904 4505 }
whismanoid 34:a1993a1ee904 4506 }
whismanoid 34:a1993a1ee904 4507 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4508 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4509 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4510 // %A v0cal=1.000V -- calibrate channel against a known input voltage
whismanoid 34:a1993a1ee904 4511 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4512 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4513 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4514 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4515 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4516 {
whismanoid 34:a1993a1ee904 4517 static char key_v0cal[10] = "v0cal__";
whismanoid 34:a1993a1ee904 4518 sprintf(key_v0cal, "v%1dcal", ch);
whismanoid 34:a1993a1ee904 4519 double Vtest;
whismanoid 34:a1993a1ee904 4520 if (cmdLine.parse_double(key_v0cal, Vtest))
whismanoid 34:a1993a1ee904 4521 {
whismanoid 34:a1993a1ee904 4522 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 4523 double Vtest_normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 4524 //
whismanoid 34:a1993a1ee904 4525 // %A v0cal=1.000 calibrate one channel by measuring against a known input voltage
whismanoid 34:a1993a1ee904 4526 //
whismanoid 34:a1993a1ee904 4527 cmdLine.serial().printf("\r\n Measuring against input voltage of %1.6fV...", Vtest);
whismanoid 37:3f369235e5bc 4528 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4529 const int numberOfMeasurements = 16 * Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 4530 #else // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4531 const int numberOfMeasurements = 16;
whismanoid 37:3f369235e5bc 4532 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4533 double Sx_measure_normValue_0_1 = 0; // sum of values
whismanoid 34:a1993a1ee904 4534 double Sxx_measure_normValue_0_1 = 0; // sum of the squares of the values
whismanoid 34:a1993a1ee904 4535 for (int count = 0; count < numberOfMeasurements; count++)
whismanoid 34:a1993a1ee904 4536 {
whismanoid 34:a1993a1ee904 4537 double measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4538 switch(ch)
whismanoid 34:a1993a1ee904 4539 {
whismanoid 34:a1993a1ee904 4540 case 0: measure_normValue_0_1 = analogIn0.read(); break;
whismanoid 34:a1993a1ee904 4541 case 1: measure_normValue_0_1 = analogIn1.read(); break;
whismanoid 34:a1993a1ee904 4542 case 2: measure_normValue_0_1 = analogIn2.read(); break;
whismanoid 34:a1993a1ee904 4543 case 3: measure_normValue_0_1 = analogIn3.read(); break;
whismanoid 34:a1993a1ee904 4544 case 4: measure_normValue_0_1 = analogIn4.read(); break;
whismanoid 34:a1993a1ee904 4545 case 5: measure_normValue_0_1 = analogIn5.read(); break;
whismanoid 34:a1993a1ee904 4546 }
whismanoid 34:a1993a1ee904 4547 Sx_measure_normValue_0_1 = Sx_measure_normValue_0_1 + measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4548 Sxx_measure_normValue_0_1 = Sxx_measure_normValue_0_1 + (measure_normValue_0_1 * measure_normValue_0_1);
whismanoid 38:fda80a0020d1 4549 if ((count < 3) || (count >= numberOfMeasurements - 3)) {
whismanoid 38:fda80a0020d1 4550 cmdLine.serial().printf("\r\n raw: %7.6f%% = %1.6fV",
whismanoid 38:fda80a0020d1 4551 measure_normValue_0_1 * 100.0,
whismanoid 38:fda80a0020d1 4552 (measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 38:fda80a0020d1 4553 );
whismanoid 38:fda80a0020d1 4554 }
whismanoid 34:a1993a1ee904 4555 }
whismanoid 34:a1993a1ee904 4556 cmdLine.serial().printf("\r\n numberOfMeasurements = %d", numberOfMeasurements);
whismanoid 34:a1993a1ee904 4557 cmdLine.serial().printf("\r\n Sx_measure_normValue_0_1 = %1.6f", Sx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4558 cmdLine.serial().printf("\r\n Sxx_measure_normValue_0_1 = %1.6f", Sxx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4559 //
whismanoid 34:a1993a1ee904 4560 // calculate mean_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 4561 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 4562 double mean_measure_normValue_0_1 = Sx_measure_normValue_0_1 / numberOfMeasurements;
whismanoid 34:a1993a1ee904 4563 cmdLine.serial().printf("\r\n mean = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4564 mean_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4565 (mean_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4566 );
whismanoid 34:a1993a1ee904 4567 //
whismanoid 34:a1993a1ee904 4568 // TODO: calculate sample variance_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 4569 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 4570 // variance_measure_normValue_0_1 = (Sxx - ( Sx * Sx / nWords) ) / (nWords - 1);
whismanoid 34:a1993a1ee904 4571 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 4572 cmdLine.serial().printf("\r\n variance = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4573 variance_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4574 (variance_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4575 );
whismanoid 34:a1993a1ee904 4576 //
whismanoid 34:a1993a1ee904 4577 // calculate sample stddev_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 4578 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 4579 double stddev_measure_normValue_0_1 = sqrt(variance_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4580 cmdLine.serial().printf("\r\n stddev = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4581 stddev_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4582 (stddev_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4583 );
whismanoid 34:a1993a1ee904 4584 //
whismanoid 34:a1993a1ee904 4585 // Validate the measurements:
whismanoid 34:a1993a1ee904 4586 // is the mean near the expected value?
whismanoid 34:a1993a1ee904 4587 // is the standard deviation not too high?
whismanoid 34:a1993a1ee904 4588 bool isCalibrationValid = true;
whismanoid 34:a1993a1ee904 4589 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) > 0.1) {
whismanoid 34:a1993a1ee904 4590 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 4591 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 4592 }
whismanoid 34:a1993a1ee904 4593 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) < -0.1) {
whismanoid 34:a1993a1ee904 4594 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 4595 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 4596 }
whismanoid 34:a1993a1ee904 4597 if ((stddev_measure_normValue_0_1) > 10) {
whismanoid 34:a1993a1ee904 4598 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 4599 cmdLine.serial().printf(" stddev too high.\r\n");
whismanoid 34:a1993a1ee904 4600 }
whismanoid 34:a1993a1ee904 4601 if (isCalibrationValid)
whismanoid 34:a1993a1ee904 4602 {
whismanoid 34:a1993a1ee904 4603 // update calibration point (mean_measure_normValue_0_1, Vtest)
whismanoid 34:a1993a1ee904 4604 if (Vtest_normValue_0_1 < 0.5) {
whismanoid 34:a1993a1ee904 4605 calibration_05_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4606 calibration_05_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 4607 } else {
whismanoid 34:a1993a1ee904 4608 calibration_95_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4609 calibration_95_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 4610 }
whismanoid 34:a1993a1ee904 4611 //
whismanoid 34:a1993a1ee904 4612 // print updated calibration values
whismanoid 34:a1993a1ee904 4613 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 4614 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 4615 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4616 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 4617 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4618 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 4619 );
whismanoid 34:a1993a1ee904 4620 // print corrected value of mean of measurements (should be close to Vtest)
whismanoid 34:a1993a1ee904 4621 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV vs %1.6fV\r\n",
whismanoid 34:a1993a1ee904 4622 ch,
whismanoid 34:a1993a1ee904 4623 mean_measure_normValue_0_1,
whismanoid 34:a1993a1ee904 4624 CalibratedNormValue(ch, mean_measure_normValue_0_1),
whismanoid 34:a1993a1ee904 4625 (CalibratedNormValue(ch, mean_measure_normValue_0_1) * adc_full_scale_voltage[ch]),
whismanoid 34:a1993a1ee904 4626 Vtest
whismanoid 34:a1993a1ee904 4627 );
whismanoid 34:a1993a1ee904 4628 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 4629 else {
whismanoid 34:a1993a1ee904 4630 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 4631 cmdLine.serial().printf(" Measurement Error: Calibration will not be updated.\r\n");
whismanoid 34:a1993a1ee904 4632 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 4633 } // end if key_v0cal
whismanoid 34:a1993a1ee904 4634 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4635 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4636 #if HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 4637 // // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 37:3f369235e5bc 4638 // {
whismanoid 37:3f369235e5bc 4639 // char valueBuf[16];
whismanoid 37:3f369235e5bc 4640 // // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 37:3f369235e5bc 4641 // if (cmdLine.parse_and_remove_key("__TBD_saveCal__", valueBuf, sizeof(valueBuf)))
whismanoid 37:3f369235e5bc 4642 // {
whismanoid 37:3f369235e5bc 4643 // // handle %A __TBD_saveCal__ -- command
whismanoid 37:3f369235e5bc 4644 // }
whismanoid 37:3f369235e5bc 4645 // }
whismanoid 34:a1993a1ee904 4646 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4647 #if HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 4648 // // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 37:3f369235e5bc 4649 // {
whismanoid 37:3f369235e5bc 4650 // char valueBuf[16];
whismanoid 37:3f369235e5bc 4651 // // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 37:3f369235e5bc 4652 // if (cmdLine.parse_and_remove_key("__TBD_loadCal__", valueBuf, sizeof(valueBuf)))
whismanoid 37:3f369235e5bc 4653 // {
whismanoid 37:3f369235e5bc 4654 // // handle %A __TBD_loadCal__ -- command
whismanoid 37:3f369235e5bc 4655 // }
whismanoid 37:3f369235e5bc 4656 // }
whismanoid 34:a1993a1ee904 4657 #endif // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 4658 // %A -- report analog input voltages
whismanoid 37:3f369235e5bc 4659 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4660 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 4661 #endif // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 4662 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 4663 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 15:37c83ec50ea0 4664 for (int pinIndex = 0; pinIndex < 2; pinIndex++)
whismanoid 15:37c83ec50ea0 4665 {
whismanoid 15:37c83ec50ea0 4666 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 4667 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 4668 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 4669 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4670 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 4671 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 4672 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 4673 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 4674 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 4675 }
whismanoid 37:3f369235e5bc 4676 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 4677 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 4678 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 4679 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4680 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4681 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4682 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 4683 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4684 //
whismanoid 15:37c83ec50ea0 4685 int pinIndexH = pinIndex + 4;
whismanoid 15:37c83ec50ea0 4686 int cPinIndexH = '0' + pinIndexH;
whismanoid 15:37c83ec50ea0 4687 AnalogIn& analogInPinH = find_analogInPin(cPinIndexH);
whismanoid 15:37c83ec50ea0 4688 float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH];
whismanoid 37:3f369235e5bc 4689 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4690 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 4691 // float normValueH_0_1 = analogInPinH.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 4692 float normValueH_0_1 = 0;
whismanoid 37:3f369235e5bc 4693 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 4694 normValueH_0_1 = normValueH_0_1 + analogInPinH.read();
whismanoid 37:3f369235e5bc 4695 }
whismanoid 37:3f369235e5bc 4696 normValueH_0_1 = normValueH_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 4697 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 4698 float normValueH_0_1 = analogInPinH.read();
whismanoid 37:3f369235e5bc 4699 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4700 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4701 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4702 normValueH_0_1 = CalibratedNormValue(pinIndex, normValueH_0_1);
whismanoid 34:a1993a1ee904 4703 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4704 //
whismanoid 37:3f369235e5bc 4705 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV high range A%c = %7.3f%% = %1.3fV \r\n",
whismanoid 15:37c83ec50ea0 4706 cPinIndex,
whismanoid 15:37c83ec50ea0 4707 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4708 normValue_0_1 * adc_full_scale_voltage,
whismanoid 15:37c83ec50ea0 4709 cPinIndexH,
whismanoid 15:37c83ec50ea0 4710 normValueH_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4711 normValueH_0_1 * adc_full_scale_voltageH
whismanoid 15:37c83ec50ea0 4712 );
whismanoid 15:37c83ec50ea0 4713 }
whismanoid 15:37c83ec50ea0 4714 for (int pinIndex = 2; pinIndex < 4; pinIndex++)
whismanoid 15:37c83ec50ea0 4715 {
whismanoid 15:37c83ec50ea0 4716 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 4717 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 4718 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 4719 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4720 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 4721 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 4722 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 4723 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 4724 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 4725 }
whismanoid 37:3f369235e5bc 4726 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 4727 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 4728 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 4729 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4730 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4731 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4732 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 4733 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4734 //
whismanoid 37:3f369235e5bc 4735 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 4736 cPinIndex,
whismanoid 15:37c83ec50ea0 4737 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4738 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 4739 );
whismanoid 15:37c83ec50ea0 4740 }
whismanoid 15:37c83ec50ea0 4741 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 4742 // Platform board uses simple analog inputs
whismanoid 15:37c83ec50ea0 4743 // assume standard Arduino analog inputs A0-A5
whismanoid 15:37c83ec50ea0 4744 for (int pinIndex = 0; pinIndex < 6; pinIndex++)
whismanoid 15:37c83ec50ea0 4745 {
whismanoid 15:37c83ec50ea0 4746 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 4747 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 4748 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 37:3f369235e5bc 4749 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 4750 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogInPin.read()
whismanoid 37:3f369235e5bc 4751 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 4752 float normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 4753 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 4754 normValue_0_1 = normValue_0_1 + analogInPin.read();
whismanoid 37:3f369235e5bc 4755 }
whismanoid 37:3f369235e5bc 4756 normValue_0_1 = normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 4757 #else // USE_Platform_AIN_Average
whismanoid 15:37c83ec50ea0 4758 float normValue_0_1 = analogInPin.read();
whismanoid 37:3f369235e5bc 4759 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 4760 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4761 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4762 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 4763 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4764 //
whismanoid 37:3f369235e5bc 4765 cmdLine.serial().printf("A%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 4766 cPinIndex,
whismanoid 15:37c83ec50ea0 4767 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4768 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 4769 );
whismanoid 15:37c83ec50ea0 4770 }
whismanoid 15:37c83ec50ea0 4771 #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 4772 }
whismanoid 15:37c83ec50ea0 4773 break;
whismanoid 15:37c83ec50ea0 4774 #endif
whismanoid 15:37c83ec50ea0 4775 //
whismanoid 15:37c83ec50ea0 4776 #if HAS_SPI2_MAX541
whismanoid 15:37c83ec50ea0 4777 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 4778 {
whismanoid 15:37c83ec50ea0 4779 // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV)
whismanoid 15:37c83ec50ea0 4780 // MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 15:37c83ec50ea0 4781 float voltageV = max541.Get_Voltage();
whismanoid 15:37c83ec50ea0 4782 // if (cmdLine[2] == '+') {
whismanoid 15:37c83ec50ea0 4783 // // %D+
whismanoid 15:37c83ec50ea0 4784 // voltageV = voltageV * 1.25f;
whismanoid 15:37c83ec50ea0 4785 // if (voltageV >= max541.VRef) voltageV = max541.VRef;
whismanoid 15:37c83ec50ea0 4786 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4787 // }
whismanoid 15:37c83ec50ea0 4788 // else if (cmdLine[2] == '-') {
whismanoid 15:37c83ec50ea0 4789 // // %D-
whismanoid 15:37c83ec50ea0 4790 // voltageV = voltageV * 0.75f;
whismanoid 15:37c83ec50ea0 4791 // if (voltageV < 0.1f) voltageV = 0.1f;
whismanoid 15:37c83ec50ea0 4792 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4793 // }
whismanoid 15:37c83ec50ea0 4794 if (cmdLine.parse_float("V", voltageV))
whismanoid 15:37c83ec50ea0 4795 {
whismanoid 15:37c83ec50ea0 4796 // %D V=1.234 -- set voltage
whismanoid 15:37c83ec50ea0 4797 max541.Set_Voltage(voltageV);
whismanoid 15:37c83ec50ea0 4798 }
whismanoid 15:37c83ec50ea0 4799 else if (cmdLine.parse_float("TEST", voltageV))
whismanoid 15:37c83ec50ea0 4800 {
whismanoid 15:37c83ec50ea0 4801 // %D TEST=1.234 -- set voltage and compare with AIN0
whismanoid 15:37c83ec50ea0 4802 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4803 }
whismanoid 15:37c83ec50ea0 4804 else if (cmdLine.parse_float("CAL", voltageV))
whismanoid 15:37c83ec50ea0 4805 {
whismanoid 15:37c83ec50ea0 4806 // %D CAL=1.234 -- calibrate VRef and compare with AIN0
whismanoid 15:37c83ec50ea0 4807
whismanoid 15:37c83ec50ea0 4808 max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
whismanoid 15:37c83ec50ea0 4809 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 4810 const int average_count = 100;
whismanoid 15:37c83ec50ea0 4811 const double average_K = 0.25;
whismanoid 15:37c83ec50ea0 4812 for (int count = 0; count < average_count; count++) {
whismanoid 15:37c83ec50ea0 4813 double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 4814 max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
whismanoid 15:37c83ec50ea0 4815 }
whismanoid 15:37c83ec50ea0 4816 max541.VRef = 2.0 * max541_midscale_V;
whismanoid 15:37c83ec50ea0 4817 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4818 "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
whismanoid 15:37c83ec50ea0 4819 max541_midscale_V, max541.VRef);
whismanoid 15:37c83ec50ea0 4820 // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
whismanoid 15:37c83ec50ea0 4821 voltageV = 1.0f;
whismanoid 15:37c83ec50ea0 4822 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4823 }
whismanoid 15:37c83ec50ea0 4824 else {
whismanoid 15:37c83ec50ea0 4825 // %D -- print MAX541 DAC status
whismanoid 15:37c83ec50ea0 4826 cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n",
whismanoid 15:37c83ec50ea0 4827 max541.Get_Code(), max541.Get_Voltage(), max541.VRef);
whismanoid 15:37c83ec50ea0 4828 }
whismanoid 15:37c83ec50ea0 4829 }
whismanoid 15:37c83ec50ea0 4830 break;
whismanoid 15:37c83ec50ea0 4831 #endif
whismanoid 15:37c83ec50ea0 4832
whismanoid 15:37c83ec50ea0 4833 //
whismanoid 15:37c83ec50ea0 4834 #if HAS_I2C // SUPPORT_I2C
whismanoid 15:37c83ec50ea0 4835 case 'I': case 'i':
whismanoid 15:37c83ec50ea0 4836 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 4837 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 4838 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 4839 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 4840 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 4841 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 4842 // get next character
whismanoid 15:37c83ec50ea0 4843 // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7
whismanoid 15:37c83ec50ea0 4844 cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7);
whismanoid 15:37c83ec50ea0 4845 // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count
whismanoid 15:37c83ec50ea0 4846 g_I2C_read_count = 0; // read count must be reset every command
whismanoid 15:37c83ec50ea0 4847 cmdLine.parse_byte_dec("RD", g_I2C_read_count);
whismanoid 15:37c83ec50ea0 4848 // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress
whismanoid 15:37c83ec50ea0 4849 cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress);
whismanoid 15:37c83ec50ea0 4850 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 4851 {
whismanoid 15:37c83ec50ea0 4852 case 'P': case 'p':
whismanoid 15:37c83ec50ea0 4853 {
whismanoid 15:37c83ec50ea0 4854 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 4855 HuntAttachedI2CDevices(cmdLine, 0x03, 0x77);
whismanoid 15:37c83ec50ea0 4856 }
whismanoid 15:37c83ec50ea0 4857 break;
whismanoid 15:37c83ec50ea0 4858 case 'C': case 'c':
whismanoid 15:37c83ec50ea0 4859 {
whismanoid 15:37c83ec50ea0 4860 bool isUpdatedI2CConfig = false;
whismanoid 15:37c83ec50ea0 4861 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 4862 // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz
whismanoid 15:37c83ec50ea0 4863 if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz))
whismanoid 15:37c83ec50ea0 4864 {
whismanoid 15:37c83ec50ea0 4865 isUpdatedI2CConfig = true;
whismanoid 15:37c83ec50ea0 4866 // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 4867 if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 4868 {
whismanoid 15:37c83ec50ea0 4869 g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 4870 }
whismanoid 15:37c83ec50ea0 4871 if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 4872 {
whismanoid 15:37c83ec50ea0 4873 g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 4874 }
whismanoid 15:37c83ec50ea0 4875 }
whismanoid 15:37c83ec50ea0 4876 if (isUpdatedI2CConfig)
whismanoid 15:37c83ec50ea0 4877 {
whismanoid 15:37c83ec50ea0 4878 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4879 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4880 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4881 i2cMaster.start();
whismanoid 15:37c83ec50ea0 4882 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 4883 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4884 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4885 "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 15:37c83ec50ea0 4886 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 15:37c83ec50ea0 4887 (g_I2C_SCL_Hz / 1000.));
whismanoid 15:37c83ec50ea0 4888 i2cMaster.start();
whismanoid 15:37c83ec50ea0 4889 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 4890 }
whismanoid 15:37c83ec50ea0 4891 }
whismanoid 15:37c83ec50ea0 4892 break;
whismanoid 15:37c83ec50ea0 4893 case 'W': case 'w':
whismanoid 15:37c83ec50ea0 4894 {
whismanoid 15:37c83ec50ea0 4895 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4896 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4897 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4898 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 4899 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4900 #define MAX_I2C_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 4901 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 4902 static char mosiData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4903 static char misoData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4904 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 4905 MAX_I2C_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 4906 {
whismanoid 15:37c83ec50ea0 4907 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 4908 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4909 "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->",
whismanoid 15:37c83ec50ea0 4910 g_I2C_deviceAddress7,
whismanoid 15:37c83ec50ea0 4911 (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count);
whismanoid 15:37c83ec50ea0 4912 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 4913 {
whismanoid 15:37c83ec50ea0 4914 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 4915 }
whismanoid 15:37c83ec50ea0 4916 //
whismanoid 15:37c83ec50ea0 4917 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 4918 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 4919 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4920 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 4921 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 4922 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 4923 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 4924 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4925 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4926 // /* 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 4927 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 4928 const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4929 unsigned int misoLength = 0;
whismanoid 15:37c83ec50ea0 4930 bool repeated = (g_I2C_read_count > 0);
whismanoid 15:37c83ec50ea0 4931 //
whismanoid 15:37c83ec50ea0 4932 int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated);
whismanoid 15:37c83ec50ea0 4933 switch (writeStatus)
whismanoid 15:37c83ec50ea0 4934 {
whismanoid 15:37c83ec50ea0 4935 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 4936 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 4937 default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 4938 writeStatus);
whismanoid 15:37c83ec50ea0 4939 }
whismanoid 15:37c83ec50ea0 4940 if (repeated)
whismanoid 15:37c83ec50ea0 4941 {
whismanoid 15:37c83ec50ea0 4942 int readStatus =
whismanoid 15:37c83ec50ea0 4943 i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false);
whismanoid 15:37c83ec50ea0 4944 switch (readStatus)
whismanoid 15:37c83ec50ea0 4945 {
whismanoid 15:37c83ec50ea0 4946 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 4947 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 4948 default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 4949 readStatus);
whismanoid 15:37c83ec50ea0 4950 }
whismanoid 15:37c83ec50ea0 4951 }
whismanoid 15:37c83ec50ea0 4952 //
whismanoid 15:37c83ec50ea0 4953 if (misoLength > 0)
whismanoid 15:37c83ec50ea0 4954 {
whismanoid 15:37c83ec50ea0 4955 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 4956 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 4957 for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count;
whismanoid 15:37c83ec50ea0 4958 byteIndex++)
whismanoid 15:37c83ec50ea0 4959 {
whismanoid 15:37c83ec50ea0 4960 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 4961 }
whismanoid 15:37c83ec50ea0 4962 }
whismanoid 15:37c83ec50ea0 4963 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 4964 }
whismanoid 15:37c83ec50ea0 4965 }
whismanoid 15:37c83ec50ea0 4966 break;
whismanoid 15:37c83ec50ea0 4967 case 'R': case 'r':
whismanoid 15:37c83ec50ea0 4968 {
whismanoid 15:37c83ec50ea0 4969 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4970 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4971 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4972 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 4973 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 4974 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 4975 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4976 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 4977 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 4978 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 4979 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 4980 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4981 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4982 // /* 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 4983 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 4984 }
whismanoid 15:37c83ec50ea0 4985 break;
whismanoid 15:37c83ec50ea0 4986 case '^':
whismanoid 15:37c83ec50ea0 4987 {
whismanoid 15:37c83ec50ea0 4988 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4989 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4990 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4991 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 4992 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 4993 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 4994 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4995 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 4996 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 4997 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 4998 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 4999 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5000 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 5001 // /* 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 5002 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 5003 }
whismanoid 15:37c83ec50ea0 5004 break;
whismanoid 15:37c83ec50ea0 5005 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 5006 break;
whismanoid 15:37c83ec50ea0 5007 #endif
whismanoid 15:37c83ec50ea0 5008 //
whismanoid 15:37c83ec50ea0 5009 #if HAS_SPI // SUPPORT_SPI
whismanoid 15:37c83ec50ea0 5010 case 'S': case 's':
whismanoid 15:37c83ec50ea0 5011 {
whismanoid 15:37c83ec50ea0 5012 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 5013 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 5014 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 5015 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 5016 //
whismanoid 15:37c83ec50ea0 5017 // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d
whismanoid 15:37c83ec50ea0 5018 bool isUpdatedSPIConfig = false;
whismanoid 15:37c83ec50ea0 5019 // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2
whismanoid 15:37c83ec50ea0 5020 // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1
whismanoid 15:37c83ec50ea0 5021 if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2))
whismanoid 15:37c83ec50ea0 5022 {
whismanoid 15:37c83ec50ea0 5023 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5024 }
whismanoid 15:37c83ec50ea0 5025 if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1))
whismanoid 15:37c83ec50ea0 5026 {
whismanoid 15:37c83ec50ea0 5027 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5028 }
whismanoid 15:37c83ec50ea0 5029 if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1))
whismanoid 15:37c83ec50ea0 5030 {
whismanoid 15:37c83ec50ea0 5031 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5032 }
whismanoid 15:37c83ec50ea0 5033 // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz
whismanoid 15:37c83ec50ea0 5034 if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz))
whismanoid 15:37c83ec50ea0 5035 {
whismanoid 15:37c83ec50ea0 5036 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 5037 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 5038 if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 5039 {
whismanoid 15:37c83ec50ea0 5040 g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 5041 }
whismanoid 15:37c83ec50ea0 5042 if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 5043 {
whismanoid 15:37c83ec50ea0 5044 g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 5045 }
whismanoid 15:37c83ec50ea0 5046 }
whismanoid 15:37c83ec50ea0 5047 // Update SPI configuration
whismanoid 15:37c83ec50ea0 5048 if (isUpdatedSPIConfig)
whismanoid 15:37c83ec50ea0 5049 {
whismanoid 15:37c83ec50ea0 5050 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 5051 spi_cs = g_SPI_cs_state;
whismanoid 15:37c83ec50ea0 5052 spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0
whismanoid 15:37c83ec50ea0 5053 #if APPLICATION_MAX5715
whismanoid 15:37c83ec50ea0 5054 g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5055 #elif APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 5056 g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5057 #elif APPLICATION_MAX5171
whismanoid 15:37c83ec50ea0 5058 g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5059 #elif APPLICATION_MAX11410
whismanoid 15:37c83ec50ea0 5060 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5061 #elif APPLICATION_MAX12345
whismanoid 15:37c83ec50ea0 5062 g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 5063 #else
whismanoid 15:37c83ec50ea0 5064 spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 15:37c83ec50ea0 5065 #endif
whismanoid 15:37c83ec50ea0 5066 //
whismanoid 15:37c83ec50ea0 5067 double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 5068 int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate
whismanoid 15:37c83ec50ea0 5069 double actual_SCLK_Hz = SystemCoreClock / actual_divisor;
whismanoid 15:37c83ec50ea0 5070 //
whismanoid 15:37c83ec50ea0 5071 // 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 5072 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 5073 "\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 5074 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 15:37c83ec50ea0 5075 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0),
whismanoid 15:37c83ec50ea0 5076 g_SPI_cs_state,
whismanoid 15:37c83ec50ea0 5077 g_SPI_SCLK_Hz,
whismanoid 15:37c83ec50ea0 5078 (g_SPI_SCLK_Hz / 1000000.),
whismanoid 15:37c83ec50ea0 5079 ((double)(SystemCoreClock / 1000000.)),
whismanoid 15:37c83ec50ea0 5080 ideal_divisor,
whismanoid 15:37c83ec50ea0 5081 (actual_SCLK_Hz / 1000000.)
whismanoid 15:37c83ec50ea0 5082 );
whismanoid 15:37c83ec50ea0 5083 }
whismanoid 15:37c83ec50ea0 5084 // get next character
whismanoid 15:37c83ec50ea0 5085 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 5086 {
whismanoid 15:37c83ec50ea0 5087 case 'C': case 's':
whismanoid 15:37c83ec50ea0 5088 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 5089 break;
whismanoid 15:37c83ec50ea0 5090 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 5091 // %SD -- SPI diagnostic messages enable
whismanoid 15:37c83ec50ea0 5092 if (g_MAX5719_device.onSPIprint) {
whismanoid 15:37c83ec50ea0 5093 g_MAX5719_device.onSPIprint = NULL;
whismanoid 15:37c83ec50ea0 5094 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') != None is false
whismanoid 15:37c83ec50ea0 5095 }
whismanoid 15:37c83ec50ea0 5096 else {
whismanoid 15:37c83ec50ea0 5097 void onSPIprint_handler(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]);
whismanoid 15:37c83ec50ea0 5098 g_MAX5719_device.onSPIprint = onSPIprint_handler;
whismanoid 15:37c83ec50ea0 5099 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') is false
whismanoid 15:37c83ec50ea0 5100 }
whismanoid 15:37c83ec50ea0 5101 break;
whismanoid 15:37c83ec50ea0 5102 case 'W': case 'R': case 'w': case 'r':
whismanoid 15:37c83ec50ea0 5103 {
whismanoid 15:37c83ec50ea0 5104 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 5105 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 5106 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5107 #define MAX_SPI_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 5108 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 5109 static char mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5110 static char misoData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 5111 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 5112 MAX_SPI_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 5113 {
whismanoid 15:37c83ec50ea0 5114 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5115 cmdLine.serial().printf("\r\nSPI");
whismanoid 15:37c83ec50ea0 5116 if (byteCount > 7) {
whismanoid 15:37c83ec50ea0 5117 cmdLine.serial().printf(" byteCount:%d", byteCount);
whismanoid 15:37c83ec50ea0 5118 }
whismanoid 15:37c83ec50ea0 5119 cmdLine.serial().printf(" MOSI->");
whismanoid 15:37c83ec50ea0 5120 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 5121 {
whismanoid 15:37c83ec50ea0 5122 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 5123 }
whismanoid 15:37c83ec50ea0 5124 spi_cs = 0;
whismanoid 15:37c83ec50ea0 5125 unsigned int numBytesTransferred =
whismanoid 15:37c83ec50ea0 5126 spi.write(mosiData, byteCount, misoData, byteCount);
whismanoid 15:37c83ec50ea0 5127 spi_cs = 1;
whismanoid 15:37c83ec50ea0 5128 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 5129 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 5130 for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred;
whismanoid 15:37c83ec50ea0 5131 byteIndex++)
whismanoid 15:37c83ec50ea0 5132 {
whismanoid 15:37c83ec50ea0 5133 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 5134 }
whismanoid 15:37c83ec50ea0 5135 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 5136 }
whismanoid 15:37c83ec50ea0 5137 }
whismanoid 15:37c83ec50ea0 5138 break;
whismanoid 15:37c83ec50ea0 5139 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 5140 } // case 'S': // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 5141 break;
whismanoid 15:37c83ec50ea0 5142 #endif
whismanoid 15:37c83ec50ea0 5143 //
whismanoid 15:37c83ec50ea0 5144 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 5145 } // switch(cmdLine[1])
whismanoid 15:37c83ec50ea0 5146 } // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 15:37c83ec50ea0 5147 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 15:37c83ec50ea0 5148
whismanoid 15:37c83ec50ea0 5149 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 5150 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 5151 void main_menu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 5152 {
whismanoid 9:45f98573eb6d 5153 // process command line
whismanoid 31:47eee7e0cc2d 5154 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 5155 if (g_Run_command_table_running == false) {
whismanoid 31:47eee7e0cc2d 5156 cmdLine.serial().printf("\r\nCmdLine buf:\"%s\"\r\n", cmdLine.str());
whismanoid 31:47eee7e0cc2d 5157 } // if (g_Run_command_table_running)
whismanoid 31:47eee7e0cc2d 5158 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 5159 if (g_Run_command_table_running == false) {
whismanoid 31:47eee7e0cc2d 5160 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 5161
whismanoid 4:d9b05924ad4c 5162 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 31:47eee7e0cc2d 5163 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 5164 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 5165 // If datalog is free running, halt on any possible received command
whismanoid 17:9397ea3ea7e9 5166 if (Datalogger_Trigger != trigger_Halt) {
whismanoid 4:d9b05924ad4c 5167 Datalogger_Trigger = trigger_Halt;
whismanoid 9:45f98573eb6d 5168 cmdLine.serial().printf("Datalog stopped by USB command input\r\n");
whismanoid 9:45f98573eb6d 5169 cmdLine.serial().printf("Restart datalog by sending LR\r\n");
whismanoid 4:d9b05924ad4c 5170 }
whismanoid 31:47eee7e0cc2d 5171 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 5172 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 5173
whismanoid 4:d9b05924ad4c 5174 // DIAGNOSTIC: print line buffer
whismanoid 4:d9b05924ad4c 5175 //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str());
whismanoid 4:d9b05924ad4c 5176 //
whismanoid 4:d9b05924ad4c 5177 switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 5178 {
whismanoid 4:d9b05924ad4c 5179 case '?':
whismanoid 4:d9b05924ad4c 5180 main_menu_status(cmdLine);
whismanoid 4:d9b05924ad4c 5181 main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 5182 // print command prompt
whismanoid 4:d9b05924ad4c 5183 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 5184 break;
whismanoid 4:d9b05924ad4c 5185 case '\r': case '\n': // ignore blank line
whismanoid 4:d9b05924ad4c 5186 case '\0': // ignore empty line
whismanoid 30:07197a430869 5187 main_menu_status(cmdLine);
whismanoid 30:07197a430869 5188 //~ main_menu_help(cmdLine);
whismanoid 30:07197a430869 5189 // print command prompt
whismanoid 30:07197a430869 5190 //cmdLine.serial().printf("\r\n>");
whismanoid 30:07197a430869 5191 break;
whismanoid 4:d9b05924ad4c 5192 case '#': // ignore comment line
whismanoid 4:d9b05924ad4c 5193 // # -- lines beginning with # are comments
whismanoid 30:07197a430869 5194 //
whismanoid 30:07197a430869 5195 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 5196 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in main_menu_onEOLcommandParser
whismanoid 30:07197a430869 5197 // # command handler update gstrRemarkText buffer instead of just ignoring the remark
whismanoid 30:07197a430869 5198 //
whismanoid 30:07197a430869 5199 // ignore extra spaces before the remark
whismanoid 30:07197a430869 5200 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 30:07197a430869 5201 int argIndex;
whismanoid 30:07197a430869 5202 for (argIndex = 1; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 5203 {
whismanoid 30:07197a430869 5204 if (cmdLine[argIndex] == ' ') break;
whismanoid 30:07197a430869 5205 }
whismanoid 30:07197a430869 5206 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 5207 {
whismanoid 30:07197a430869 5208 if (cmdLine[argIndex] != ' ') break;
whismanoid 30:07197a430869 5209 }
whismanoid 30:07197a430869 5210 //
whismanoid 30:07197a430869 5211 strncpy(gstrRemarkText, cmdLine.str()+argIndex, gstrRemarkTextLASTINDEX+1);
whismanoid 30:07197a430869 5212 // do not exceed string buffer limit; keep sentinel null character at end of buffer
whismanoid 30:07197a430869 5213 gstrRemarkText[gstrRemarkTextLASTINDEX] = '\0';
whismanoid 41:13a6a097502c 5214 for (unsigned int index = 0; index < gstrRemarkTextLASTINDEX; index++)
whismanoid 30:07197a430869 5215 {
whismanoid 30:07197a430869 5216 if ((gstrRemarkText[index]) == '\0') break; // null character at end of string
whismanoid 30:07197a430869 5217 if ((gstrRemarkText[index]) < 0x20) {
whismanoid 30:07197a430869 5218 // replace non-printing characters with _
whismanoid 30:07197a430869 5219 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 5220 continue;
whismanoid 30:07197a430869 5221 }
whismanoid 30:07197a430869 5222 if ((gstrRemarkText[index]) >= 0x7F) {
whismanoid 30:07197a430869 5223 // replace non-printing characters with _
whismanoid 30:07197a430869 5224 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 5225 continue;
whismanoid 30:07197a430869 5226 }
whismanoid 30:07197a430869 5227 switch(gstrRemarkText[index])
whismanoid 30:07197a430869 5228 {
whismanoid 30:07197a430869 5229 case ',':
whismanoid 30:07197a430869 5230 // replace , with ;
whismanoid 30:07197a430869 5231 gstrRemarkText[index] = ';';
whismanoid 30:07197a430869 5232 break;
whismanoid 30:07197a430869 5233 case '"':
whismanoid 30:07197a430869 5234 // replace " with '
whismanoid 30:07197a430869 5235 gstrRemarkText[index] = '\'';
whismanoid 30:07197a430869 5236 break;
whismanoid 30:07197a430869 5237 case '\\':
whismanoid 30:07197a430869 5238 // replace \ with /
whismanoid 30:07197a430869 5239 gstrRemarkText[index] = '/';
whismanoid 30:07197a430869 5240 break;
whismanoid 30:07197a430869 5241 }
whismanoid 30:07197a430869 5242 }
whismanoid 30:07197a430869 5243 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 5244 //
whismanoid 31:47eee7e0cc2d 5245 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 5246 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 5247 main_menu_status(cmdLine);
whismanoid 31:47eee7e0cc2d 5248 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 5249 //~ main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 5250 // print command prompt
whismanoid 4:d9b05924ad4c 5251 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 5252 break;
whismanoid 4:d9b05924ad4c 5253 #if ECHO_EOF_ON_EOL
whismanoid 4:d9b05924ad4c 5254 case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file
whismanoid 4:d9b05924ad4c 5255 cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 5256 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 5257 break;
whismanoid 4:d9b05924ad4c 5258 case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file
whismanoid 4:d9b05924ad4c 5259 cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 5260 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 5261 break;
whismanoid 4:d9b05924ad4c 5262 #endif
whismanoid 10:04022a61b527 5263 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 5264 case '!': // device init
whismanoid 10:04022a61b527 5265 {
whismanoid 10:04022a61b527 5266 cmdLine.serial().printf("Init");
whismanoid 10:04022a61b527 5267 // call function Init
whismanoid 10:04022a61b527 5268 uint8_t result = g_MAX11410_device.Init();
whismanoid 10:04022a61b527 5269 // cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 5270 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 5271 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 5272 // in command '!' device init, apply list of custom register writes after init
whismanoid 10:04022a61b527 5273 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 5274 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 10:04022a61b527 5275 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 10:04022a61b527 5276 uint32_t regData = custom_reg_init_data[index];
whismanoid 10:04022a61b527 5277 cmdLine.serial().printf("*%s=0x%06.6x",
whismanoid 10:04022a61b527 5278 g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress),
whismanoid 10:04022a61b527 5279 regData
whismanoid 10:04022a61b527 5280 );
whismanoid 10:04022a61b527 5281 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 10:04022a61b527 5282 }
whismanoid 10:04022a61b527 5283 #endif // USE_CUSTOM_REG_INIT
whismanoid 10:04022a61b527 5284 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 5285 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 5286 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 5287 }
whismanoid 10:04022a61b527 5288 break;
whismanoid 10:04022a61b527 5289 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 5290 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 5291 case '.':
whismanoid 4:d9b05924ad4c 5292 {
whismanoid 4:d9b05924ad4c 5293 // . -- SelfTest
whismanoid 4:d9b05924ad4c 5294 cmdLine.serial().printf("SelfTest()");
whismanoid 4:d9b05924ad4c 5295 SelfTest(cmdLine);
whismanoid 4:d9b05924ad4c 5296 }
whismanoid 4:d9b05924ad4c 5297 break;
whismanoid 4:d9b05924ad4c 5298 #endif // USE_SELFTEST
whismanoid 15:37c83ec50ea0 5299 #if 1 // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 5300 case '%':
whismanoid 4:d9b05924ad4c 5301 {
whismanoid 4:d9b05924ad4c 5302 pinsMonitor_submenu_onEOLcommandParser(cmdLine);
whismanoid 4:d9b05924ad4c 5303 }
whismanoid 4:d9b05924ad4c 5304 break; // case '%'
whismanoid 4:d9b05924ad4c 5305 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 9:45f98573eb6d 5306 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 5307 // reuse the Serial_Tester command *regName=regValue
whismanoid 10:04022a61b527 5308 // CODE GENERATOR: generate * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 5309 case '*':
whismanoid 10:04022a61b527 5310 {
whismanoid 10:04022a61b527 5311 // if buffer starts with a regName:
whismanoid 10:04022a61b527 5312 // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))):
whismanoid 10:04022a61b527 5313 // cmdLine.serial().printf(" scan RegName...\r\n");
whismanoid 10:04022a61b527 5314 }
whismanoid 10:04022a61b527 5315 break;
whismanoid 9:45f98573eb6d 5316 #endif // USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 5317 //
whismanoid 10:04022a61b527 5318 #if 1 // USE_AUX_SERIAL_CMD_FORWARDING && (HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL)
whismanoid 10:04022a61b527 5319 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_onEOLcommandParser
whismanoid 40:330b28116178 5320 case '>': case '<': // > send and receive; < receive without sending anything
whismanoid 10:04022a61b527 5321 {
whismanoid 10:04022a61b527 5322 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 5323 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 5324 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 5325 CmdLine& cmdLine_AuxSerial = cmdLine_AUXserial;
whismanoid 10:04022a61b527 5326 Serial& AuxSerial = AUXserial;
whismanoid 10:04022a61b527 5327 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5328 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 5329 CmdLine& cmdLine_AuxSerial = cmdLine_DAPLINKserial;
whismanoid 10:04022a61b527 5330 Serial& AuxSerial = DAPLINKserial;
whismanoid 10:04022a61b527 5331 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5332 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 5333 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5334 //
whismanoid 40:330b28116178 5335 int g_auxSerialCom_outgoing_string_cr = 1; // option to send CR after outgoing_string
whismanoid 40:330b28116178 5336 int g_auxSerialCom_outgoing_string_lf = 0; // option to send LF after outgoing_string (breaks remote datalogger LR!)
whismanoid 40:330b28116178 5337 int g_auxSerialCom_rx_string_verbose_crlf = 0; // option to display \r\n as "\\r\\n" in rx_string_buf
whismanoid 40:330b28116178 5338 int g_auxSerialCom_rx_string_verbose_ctrl = 1; // option to display control codes as \xXX
whismanoid 40:330b28116178 5339 const char* g_auxSerialCom_display_tx_prefix = "\r\n->|"; // "\r\n >";
whismanoid 40:330b28116178 5340 const char* g_auxSerialCom_display_rx_prefix = "\r\n<-|"; // "\r\n< ";
whismanoid 40:330b28116178 5341 //
whismanoid 40:330b28116178 5342 bool need_g_auxSerialCom_display_rx_prefix = 1; // temp
whismanoid 40:330b28116178 5343 //
whismanoid 10:04022a61b527 5344 // >> suppress key=value parsing
whismanoid 10:04022a61b527 5345 bool suppress_parsing = (cmdLine[1] == '>');
whismanoid 10:04022a61b527 5346 if (suppress_parsing == false) {
whismanoid 10:04022a61b527 5347 // int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 5348 if (cmdLine.parse_int_dec("baud", g_auxSerialCom_baud))
whismanoid 10:04022a61b527 5349 {
whismanoid 10:04022a61b527 5350 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- baud rate
whismanoid 10:04022a61b527 5351 cmdLine_AuxSerial.serial().printf("\r\n*** New Baud Rate %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5352 AuxSerial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5353 cmdLine_AuxSerial.serial().printf("\r\n*** Baud Rate was set to %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5354 }
whismanoid 10:04022a61b527 5355 #if 0
whismanoid 10:04022a61b527 5356 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 5357 if (cmdLine.parse_int_dec("tx_wait_echo", g_auxSerialCom_tx_wait_echo))
whismanoid 10:04022a61b527 5358 {
whismanoid 10:04022a61b527 5359 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_wait_echo
whismanoid 10:04022a61b527 5360 //~ cmdLine_AuxSerial.serial().printf("\r\n*** tx_wait_echo was set to %d ***\r\n", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 5361 cmdLine.serial().printf("\r\n tx_wait_echo=%d", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 5362 }
whismanoid 10:04022a61b527 5363 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 5364 if (cmdLine.parse_int_dec("tx_char_delay_ms", g_auxSerialCom_tx_char_delay_ms))
whismanoid 10:04022a61b527 5365 {
whismanoid 10:04022a61b527 5366 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_char_delay_ms
whismanoid 10:04022a61b527 5367 //~ 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 5368 cmdLine.serial().printf("\r\n tx_char_delay_ms=%dms", g_auxSerialCom_tx_char_delay_ms);
whismanoid 10:04022a61b527 5369 }
whismanoid 10:04022a61b527 5370 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 5371 if (cmdLine.parse_int_dec("tx_line_delay_ms", g_auxSerialCom_tx_line_delay_ms))
whismanoid 10:04022a61b527 5372 {
whismanoid 10:04022a61b527 5373 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_line_delay_ms
whismanoid 10:04022a61b527 5374 //~ 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 5375 cmdLine.serial().printf("\r\n tx_line_delay_ms=%dms", g_auxSerialCom_tx_line_delay_ms);
whismanoid 10:04022a61b527 5376 }
whismanoid 10:04022a61b527 5377 #endif
whismanoid 10:04022a61b527 5378 // int g_auxSerialCom_message_ms = 0; //!< capture RX until response timeout?
whismanoid 10:04022a61b527 5379 if (cmdLine.parse_int_dec("message_ms", g_auxSerialCom_message_ms))
whismanoid 10:04022a61b527 5380 {
whismanoid 10:04022a61b527 5381 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 10:04022a61b527 5382 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 5383 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 5384 }
whismanoid 10:04022a61b527 5385 // int g_auxSerialCom_rx_idle_ms = 0; //!< capture RX until idle timeout?
whismanoid 10:04022a61b527 5386 if (cmdLine.parse_int_dec("rx_idle_ms", g_auxSerialCom_rx_idle_ms))
whismanoid 10:04022a61b527 5387 {
whismanoid 10:04022a61b527 5388 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_idle_ms
whismanoid 10:04022a61b527 5389 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_idle_ms was set to %d ***\r\n", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 5390 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 5391 }
whismanoid 10:04022a61b527 5392 // int g_auxSerialCom_rx_max_count = 0; //!< capture RX until max character count?
whismanoid 10:04022a61b527 5393 if (cmdLine.parse_int_dec("rx_max_count", g_auxSerialCom_rx_max_count))
whismanoid 10:04022a61b527 5394 {
whismanoid 10:04022a61b527 5395 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_max_count
whismanoid 10:04022a61b527 5396 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_max_count was set to %d ***\r\n", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 5397 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 5398 }
whismanoid 10:04022a61b527 5399 // int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text char?
whismanoid 10:04022a61b527 5400 if (cmdLine.parse_int_dec("rx_eot", g_auxSerialCom_rx_eot))
whismanoid 10:04022a61b527 5401 {
whismanoid 10:04022a61b527 5402 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_eot
whismanoid 10:04022a61b527 5403 //~ cmdLine_AUXserial.serial().printf("\r\n*** rx_eot was set to %d ***\r\n", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 5404 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 5405 }
whismanoid 10:04022a61b527 5406 }
whismanoid 10:04022a61b527 5407 // Command forwarding to AUX serial TX/RX cmdLine_AuxSerial #257 -- send outgoing_string
whismanoid 41:13a6a097502c 5408 char* outgoing_string = ""; // warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
whismanoid 40:330b28116178 5409 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 5410 outgoing_string = (char*)cmdLine.str();
whismanoid 40:330b28116178 5411 // > use key=value parsing
whismanoid 40:330b28116178 5412 // >> suppress key=value parsing
whismanoid 40:330b28116178 5413 if (suppress_parsing) {
whismanoid 40:330b28116178 5414 cmdLine.serial().printf("\r\n suppress_parsing outgoing_string=\"%s\"", outgoing_string);
whismanoid 40:330b28116178 5415 outgoing_string++; // skip the first '>'
whismanoid 40:330b28116178 5416 outgoing_string++; // skip the second '>'
whismanoid 40:330b28116178 5417 } else {
whismanoid 40:330b28116178 5418 // TODO: after parsing, key=value pairs should be deleted, but outgoing_string=">xyzzy abc=def"
whismanoid 40:330b28116178 5419 cmdLine.serial().printf("\r\n after parsing, outgoing_string=\"%s\"", outgoing_string);
whismanoid 40:330b28116178 5420 outgoing_string++; // skip the first '>'
whismanoid 40:330b28116178 5421 }
whismanoid 40:330b28116178 5422 } // if (cmdLine[0] == '>')
whismanoid 10:04022a61b527 5423 static char rx_string_buf[RX_STRING_BUF_SIZE];
whismanoid 10:04022a61b527 5424 unsigned int rx_string_length = 0;
whismanoid 40:330b28116178 5425 //cmdLine.serial().printf("\r\n >%s\r\n <", outgoing_string);
whismanoid 40:330b28116178 5426 //char* g_auxSerialCom_display_tx_prefix = "\r\n >";
whismanoid 40:330b28116178 5427 //char* g_auxSerialCom_display_rx_prefix = "\r\n< ";
whismanoid 40:330b28116178 5428 cmdLine.serial().printf("%s%s%s",
whismanoid 40:330b28116178 5429 g_auxSerialCom_display_tx_prefix, // "\r\n >"
whismanoid 40:330b28116178 5430 outgoing_string,
whismanoid 40:330b28116178 5431 g_auxSerialCom_display_rx_prefix // "\r\n <"
whismanoid 40:330b28116178 5432 );
whismanoid 10:04022a61b527 5433 rx_string_buf[0] = '\0';
whismanoid 10:04022a61b527 5434 rx_string_length = 0;
whismanoid 10:04022a61b527 5435 //
whismanoid 10:04022a61b527 5436 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 5437 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 5438 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 5439 //
whismanoid 10:04022a61b527 5440 // int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 5441 // int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 5442 // int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 5443 // int g_auxSerialCom_rx_idle_ms = 2000; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 5444 // int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 5445 // int g_auxSerialCom_rx_eot = '\r'; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 5446 //~ cmdLine_AuxSerial.serial().printf("\r\n*** TODO forward %s ***\r\n", outgoing_string);
whismanoid 10:04022a61b527 5447 //
whismanoid 10:04022a61b527 5448 // TODO: send whole string or send character-by-character?
whismanoid 40:330b28116178 5449 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 5450 cmdLine_AuxSerial.serial().printf("%s", outgoing_string);
whismanoid 40:330b28116178 5451 //
whismanoid 40:330b28116178 5452 // TODO: send CRLF or just send CR line end?
whismanoid 40:330b28116178 5453 if (g_auxSerialCom_outgoing_string_cr) { cmdLine_AuxSerial.serial().printf("\r"); }
whismanoid 40:330b28116178 5454 if (g_auxSerialCom_outgoing_string_lf) { cmdLine_AuxSerial.serial().printf("\n"); }
whismanoid 40:330b28116178 5455 // cmdLine_AuxSerial.serial().printf("\r\n");
whismanoid 40:330b28116178 5456 } // if (cmdLine[0] == '>')
whismanoid 40:330b28116178 5457 //
whismanoid 10:04022a61b527 5458 g_auxSerialCom_Timer.start();
whismanoid 10:04022a61b527 5459 g_auxSerialCom_Timer_begin_message_ms = g_auxSerialCom_Timer.read_ms(); // start of message
whismanoid 10:04022a61b527 5460 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 5461 while (rx_string_length < (RX_STRING_BUF_SIZE-1)) {
whismanoid 10:04022a61b527 5462 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_message_ms) > g_auxSerialCom_message_ms) {
whismanoid 10:04022a61b527 5463 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 5464 break;
whismanoid 10:04022a61b527 5465 }
whismanoid 10:04022a61b527 5466 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_rx_idle_ms) > g_auxSerialCom_rx_idle_ms) {
whismanoid 10:04022a61b527 5467 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 5468 break;
whismanoid 10:04022a61b527 5469 }
whismanoid 41:13a6a097502c 5470 if ((int)rx_string_length >= g_auxSerialCom_rx_max_count) {
whismanoid 10:04022a61b527 5471 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 5472 break;
whismanoid 10:04022a61b527 5473 }
whismanoid 10:04022a61b527 5474 if (AuxSerial.readable()) {
whismanoid 10:04022a61b527 5475 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 5476 char ch = AuxSerial.getc();
whismanoid 10:04022a61b527 5477 rx_string_buf[rx_string_length++] = ch;
whismanoid 10:04022a61b527 5478 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 40:330b28116178 5479 //
whismanoid 40:330b28116178 5480 #if 1
whismanoid 40:330b28116178 5481 // immediate character echo
whismanoid 40:330b28116178 5482 for (char* cp = &(rx_string_buf[rx_string_length-1]); *cp != '\0'; cp++)
whismanoid 40:330b28116178 5483 {
whismanoid 40:330b28116178 5484 //cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 5485 if (need_g_auxSerialCom_display_rx_prefix) {
whismanoid 40:330b28116178 5486 cmdLine.serial().printf(g_auxSerialCom_display_rx_prefix); // "\r\n< " g_auxSerialCom_rx_string display prefix
whismanoid 40:330b28116178 5487 need_g_auxSerialCom_display_rx_prefix = 0;
whismanoid 40:330b28116178 5488 }
whismanoid 40:330b28116178 5489 if ((*cp) == '\r') {
whismanoid 40:330b28116178 5490 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\r"); }
whismanoid 40:330b28116178 5491 // if (*(cp+1) != '\n') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 5492 } else if ((*cp) == '\n') {
whismanoid 40:330b28116178 5493 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\n"); }
whismanoid 40:330b28116178 5494 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 5495 if (*(cp-1) != '\r') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 5496 } else if ((*cp) < 0x20) {
whismanoid 40:330b28116178 5497 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 5498 } else if ((*cp) >= 0x7f) {
whismanoid 40:330b28116178 5499 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 5500 } else {
whismanoid 40:330b28116178 5501 cmdLine.serial().printf("%c", *cp);
whismanoid 40:330b28116178 5502 }
whismanoid 40:330b28116178 5503 }
whismanoid 40:330b28116178 5504 #else
whismanoid 40:330b28116178 5505 // immediate character echo
whismanoid 40:330b28116178 5506 cmdLine.serial().printf("%s", &(rx_string_buf[rx_string_length-1]) );
whismanoid 40:330b28116178 5507 #endif
whismanoid 40:330b28116178 5508 //
whismanoid 10:04022a61b527 5509 if (g_auxSerialCom_rx_eot != aux_serial_cmd_forwarding_rx_eot_not_used) {
whismanoid 10:04022a61b527 5510 if (ch == g_auxSerialCom_rx_eot) {
whismanoid 10:04022a61b527 5511 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 5512 break;
whismanoid 10:04022a61b527 5513 }
whismanoid 10:04022a61b527 5514 }
whismanoid 10:04022a61b527 5515 }
whismanoid 10:04022a61b527 5516 } // end while (rx_string_length < (RX_STRING_BUF_SIZE-1))
whismanoid 40:330b28116178 5517 #if 0
whismanoid 10:04022a61b527 5518 // print summary. is this needed? we already print aux rx as it is received.
whismanoid 10:04022a61b527 5519 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 40:330b28116178 5520 # if 1 // support multi-line rx_string_buf response
whismanoid 40:330b28116178 5521 if (cmdLine[0] == '>') {
whismanoid 40:330b28116178 5522 cmdLine.serial().printf("%s%s", g_auxSerialCom_display_tx_prefix, outgoing_string);
whismanoid 40:330b28116178 5523 } // if (cmdLine[0] == '>')
whismanoid 40:330b28116178 5524 // cmdLine.serial().printf("\r\n <"); // prefix
whismanoid 40:330b28116178 5525 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 5526 for (char* cp = rx_string_buf; *cp != '\0'; cp++)
whismanoid 40:330b28116178 5527 {
whismanoid 40:330b28116178 5528 //cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 5529 if (need_g_auxSerialCom_display_rx_prefix) {
whismanoid 40:330b28116178 5530 cmdLine.serial().printf(g_auxSerialCom_display_rx_prefix); // "\r\n< " g_auxSerialCom_rx_string display prefix
whismanoid 40:330b28116178 5531 need_g_auxSerialCom_display_rx_prefix = 0;
whismanoid 40:330b28116178 5532 }
whismanoid 40:330b28116178 5533 if ((*cp) == '\r') {
whismanoid 40:330b28116178 5534 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\r"); }
whismanoid 40:330b28116178 5535 if (*(cp+1) != '\n') { need_g_auxSerialCom_display_rx_prefix = 1; }
whismanoid 40:330b28116178 5536 } else if ((*cp) == '\n') {
whismanoid 40:330b28116178 5537 if (g_auxSerialCom_rx_string_verbose_crlf) { cmdLine.serial().printf("\\n"); }
whismanoid 40:330b28116178 5538 need_g_auxSerialCom_display_rx_prefix = 1;
whismanoid 40:330b28116178 5539 } else if ((*cp) < 0x20) {
whismanoid 40:330b28116178 5540 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 5541 } else if ((*cp) >= 0x7f) {
whismanoid 40:330b28116178 5542 if (g_auxSerialCom_rx_string_verbose_ctrl) { cmdLine.serial().printf("\\x%2.2x", *cp); }
whismanoid 40:330b28116178 5543 } else {
whismanoid 40:330b28116178 5544 cmdLine.serial().printf("%c", *cp);
whismanoid 40:330b28116178 5545 }
whismanoid 40:330b28116178 5546 }
whismanoid 40:330b28116178 5547 cmdLine.serial().printf("\r\n");
whismanoid 40:330b28116178 5548 # else
whismanoid 10:04022a61b527 5549 cmdLine.serial().printf("\r\n >%s", outgoing_string);
whismanoid 10:04022a61b527 5550 cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 40:330b28116178 5551 # endif
whismanoid 10:04022a61b527 5552 #endif
whismanoid 10:04022a61b527 5553 //
whismanoid 10:04022a61b527 5554 }
whismanoid 10:04022a61b527 5555 break; // case '>'
whismanoid 10:04022a61b527 5556 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 5557 //
whismanoid 4:d9b05924ad4c 5558 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 5559 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 5560 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 5561 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 5562 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible
whismanoid 9:45f98573eb6d 5563 case 'L': case 'l':
whismanoid 4:d9b05924ad4c 5564 {
whismanoid 4:d9b05924ad4c 5565 // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 5566 Datalogger_Trigger = trigger_Halt;
whismanoid 4:d9b05924ad4c 5567 switch (cmdLine[1])
whismanoid 4:d9b05924ad4c 5568 {
whismanoid 17:9397ea3ea7e9 5569 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 5570 case 'T': case 't':
whismanoid 17:9397ea3ea7e9 5571 {
whismanoid 17:9397ea3ea7e9 5572 // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 5573 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 5574 Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 5575 g_timer_interval_counter = 0;
whismanoid 39:4d285e961435 5576 // get g_timer_interval_msec from cmdLine
whismanoid 17:9397ea3ea7e9 5577 // g_timer_interval_msec = 500;
whismanoid 17:9397ea3ea7e9 5578 // g_timer_interval_count = 10;
whismanoid 17:9397ea3ea7e9 5579 if (cmdLine.parse_int_dec("count", g_timer_interval_count))
whismanoid 17:9397ea3ea7e9 5580 {
whismanoid 32:80f3e5eb77d4 5581 if (g_timer_interval_count < 1) { g_timer_interval_count = 1; }
whismanoid 17:9397ea3ea7e9 5582 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 5583 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 5584 cmdLine.serial().printf("\r\n g_timer_interval_count=%d", g_timer_interval_count);
whismanoid 17:9397ea3ea7e9 5585 }
whismanoid 17:9397ea3ea7e9 5586 if (cmdLine.parse_int_dec("base", g_timer_interval_msec))
whismanoid 17:9397ea3ea7e9 5587 {
whismanoid 17:9397ea3ea7e9 5588 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 5589 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 5590 cmdLine.serial().printf("\r\n g_timer_interval_msec=%d", g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 5591 }
whismanoid 39:4d285e961435 5592 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 5593 // TODO: USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 5594 int int_timer_sleepmode = g_timer_sleepmode;
whismanoid 39:4d285e961435 5595 if (cmdLine.parse_int_dec("sleep", int_timer_sleepmode))
whismanoid 39:4d285e961435 5596 {
whismanoid 39:4d285e961435 5597 g_timer_sleepmode = (Datalogger_Sleep_enum_t)int_timer_sleepmode;
whismanoid 39:4d285e961435 5598 //~ if (g_timer_interval_count < 1) { g_timer_interval_count = 1; }
whismanoid 39:4d285e961435 5599 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 39:4d285e961435 5600 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 39:4d285e961435 5601 cmdLine.serial().printf("\r\n g_timer_sleepmode=%d", (int)g_timer_sleepmode);
whismanoid 39:4d285e961435 5602 }
whismanoid 39:4d285e961435 5603 #else // USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 5604 #endif // USE_DATALOGGER_SLEEP
whismanoid 17:9397ea3ea7e9 5605 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 17:9397ea3ea7e9 5606 }
whismanoid 17:9397ea3ea7e9 5607 break;
whismanoid 17:9397ea3ea7e9 5608 // LIH3 -- Datalog when input high D3
whismanoid 17:9397ea3ea7e9 5609 // LIL6 -- Datalog when input low D6
whismanoid 17:9397ea3ea7e9 5610 case 'I': case 'i':
whismanoid 17:9397ea3ea7e9 5611 {
whismanoid 17:9397ea3ea7e9 5612 // TODO: switch cmdLine[2] configure High or Low, configure input pin
whismanoid 17:9397ea3ea7e9 5613 }
whismanoid 17:9397ea3ea7e9 5614 break;
whismanoid 17:9397ea3ea7e9 5615 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 5616 // L$ count=10 base=500ms addr=xxx data=xxx mask=xxx -- Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 5617 case '$':
whismanoid 17:9397ea3ea7e9 5618 {
whismanoid 17:9397ea3ea7e9 5619 // TODO: scan cmdLine for regAddr, dataMask, testValue
whismanoid 17:9397ea3ea7e9 5620 }
whismanoid 17:9397ea3ea7e9 5621 break;
whismanoid 17:9397ea3ea7e9 5622 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 5623 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 5624 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5625 case '@':
whismanoid 17:9397ea3ea7e9 5626 {
whismanoid 17:9397ea3ea7e9 5627 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5628 int editRowIndex = 0;
whismanoid 17:9397ea3ea7e9 5629 int edit_action = (int)action_noop;
whismanoid 17:9397ea3ea7e9 5630 int edit_digitalOutPin = 0;
whismanoid 17:9397ea3ea7e9 5631 int edit_condition = (int)condition_always;
whismanoid 17:9397ea3ea7e9 5632 int edit_condition_channel = 0;
whismanoid 17:9397ea3ea7e9 5633 double edit_condition_threshold = 0;
whismanoid 17:9397ea3ea7e9 5634 //
whismanoid 17:9397ea3ea7e9 5635 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 17:9397ea3ea7e9 5636 {
whismanoid 17:9397ea3ea7e9 5637 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 17:9397ea3ea7e9 5638 }
whismanoid 17:9397ea3ea7e9 5639 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 17:9397ea3ea7e9 5640 {
whismanoid 17:9397ea3ea7e9 5641 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 17:9397ea3ea7e9 5642 }
whismanoid 17:9397ea3ea7e9 5643 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 17:9397ea3ea7e9 5644 {
whismanoid 17:9397ea3ea7e9 5645 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 17:9397ea3ea7e9 5646 }
whismanoid 17:9397ea3ea7e9 5647 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 17:9397ea3ea7e9 5648 {
whismanoid 17:9397ea3ea7e9 5649 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 17:9397ea3ea7e9 5650 }
whismanoid 17:9397ea3ea7e9 5651 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 17:9397ea3ea7e9 5652 {
whismanoid 17:9397ea3ea7e9 5653 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 17:9397ea3ea7e9 5654 }
whismanoid 17:9397ea3ea7e9 5655 //
whismanoid 17:9397ea3ea7e9 5656 // Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5657 switch (cmdLine[2]) // L@... -- Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5658 {
whismanoid 17:9397ea3ea7e9 5659 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 5660 case '0': case '1': case '2': case '3': case '4':
whismanoid 17:9397ea3ea7e9 5661 case '5': case '6': case '7': case '8': case '9':
whismanoid 17:9397ea3ea7e9 5662 // edit row data
whismanoid 30:07197a430869 5663 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 5664 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 5665 // get row number to edit from cmdLine[2]
whismanoid 17:9397ea3ea7e9 5666 editRowIndex = atoi(cmdLine.str()+2);
whismanoid 30:07197a430869 5667 if ((editRowIndex >= 0) && (editRowIndex < Datalogger_action_table_row_count)) {
whismanoid 30:07197a430869 5668 // update row
whismanoid 30:07197a430869 5669 cmdLine.serial().printf("\r\n replace row %d", editRowIndex);
whismanoid 30:07197a430869 5670 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 5671 edit_action = Datalogger_action_table[editRowIndex].action;
whismanoid 30:07197a430869 5672 edit_digitalOutPin = Datalogger_action_table[editRowIndex].digitalOutPin;
whismanoid 30:07197a430869 5673 edit_condition = Datalogger_action_table[editRowIndex].condition;
whismanoid 30:07197a430869 5674 edit_condition_channel = Datalogger_action_table[editRowIndex].condition_channel;
whismanoid 30:07197a430869 5675 edit_condition_threshold = Datalogger_action_table[editRowIndex].condition_threshold;
whismanoid 30:07197a430869 5676 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 5677 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 30:07197a430869 5678 {
whismanoid 30:07197a430869 5679 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 30:07197a430869 5680 }
whismanoid 30:07197a430869 5681 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 30:07197a430869 5682 {
whismanoid 30:07197a430869 5683 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 30:07197a430869 5684 }
whismanoid 30:07197a430869 5685 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 30:07197a430869 5686 {
whismanoid 30:07197a430869 5687 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 30:07197a430869 5688 }
whismanoid 30:07197a430869 5689 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 30:07197a430869 5690 {
whismanoid 30:07197a430869 5691 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 30:07197a430869 5692 }
whismanoid 30:07197a430869 5693 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 30:07197a430869 5694 {
whismanoid 30:07197a430869 5695 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 30:07197a430869 5696 }
whismanoid 30:07197a430869 5697 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 5698 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 5699 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 5700 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 5701 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 5702 }
whismanoid 30:07197a430869 5703 else if ((editRowIndex == Datalogger_action_table_row_count) && (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX)) {
whismanoid 30:07197a430869 5704 // %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 5705 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 5706 cmdLine.serial().printf("\r\n add next row %d", editRowIndex);
whismanoid 30:07197a430869 5707 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 5708 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 5709 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 5710 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 5711 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 30:07197a430869 5712 //
whismanoid 17:9397ea3ea7e9 5713 }
whismanoid 17:9397ea3ea7e9 5714 }
whismanoid 17:9397ea3ea7e9 5715 break;
whismanoid 17:9397ea3ea7e9 5716 case '+':
whismanoid 17:9397ea3ea7e9 5717 // add a new row at end of table
whismanoid 17:9397ea3ea7e9 5718 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 5719 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 5720 editRowIndex = Datalogger_action_table_row_count;
whismanoid 17:9397ea3ea7e9 5721 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 5722 cmdLine.serial().printf("\r\n add new row %d", editRowIndex);
whismanoid 17:9397ea3ea7e9 5723 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 17:9397ea3ea7e9 5724 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 17:9397ea3ea7e9 5725 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 17:9397ea3ea7e9 5726 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 17:9397ea3ea7e9 5727 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 5728 }
whismanoid 17:9397ea3ea7e9 5729 break;
whismanoid 17:9397ea3ea7e9 5730 case '-':
whismanoid 17:9397ea3ea7e9 5731 // delete row from table
whismanoid 17:9397ea3ea7e9 5732 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 5733 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 5734 if ((cmdLine[3] == '~') && (cmdLine[4] == '~') && (cmdLine[5] == '~')) {
whismanoid 17:9397ea3ea7e9 5735 // L@-~~~ -- delete all rows from table
whismanoid 30:07197a430869 5736 cmdLine.serial().printf("\r\n delete all rows");
whismanoid 17:9397ea3ea7e9 5737 Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 5738 break;
whismanoid 17:9397ea3ea7e9 5739 }
whismanoid 30:07197a430869 5740 else {
whismanoid 30:07197a430869 5741 editRowIndex = atoi(cmdLine.str()+3);
whismanoid 30:07197a430869 5742 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 30:07197a430869 5743 // delete row editRowIndex from Datalogger_action_table
whismanoid 30:07197a430869 5744 for (int i = editRowIndex; i < (Datalogger_action_table_row_count-1); i++)
whismanoid 30:07197a430869 5745 {
whismanoid 30:07197a430869 5746 // copy row i+1 into row i
whismanoid 30:07197a430869 5747 Datalogger_action_table[i].action = Datalogger_action_table[i+1].action;
whismanoid 30:07197a430869 5748 Datalogger_action_table[i].digitalOutPin = Datalogger_action_table[i+1].digitalOutPin;
whismanoid 30:07197a430869 5749 Datalogger_action_table[i].condition = Datalogger_action_table[i+1].condition;
whismanoid 30:07197a430869 5750 Datalogger_action_table[i].condition_channel = Datalogger_action_table[i+1].condition_channel;
whismanoid 30:07197a430869 5751 Datalogger_action_table[i].condition_threshold = Datalogger_action_table[i+1].condition_threshold;
whismanoid 30:07197a430869 5752 }
whismanoid 30:07197a430869 5753 Datalogger_action_table_row_count--;
whismanoid 17:9397ea3ea7e9 5754 }
whismanoid 17:9397ea3ea7e9 5755 }
whismanoid 17:9397ea3ea7e9 5756 break;
whismanoid 30:07197a430869 5757 case '.':
whismanoid 30:07197a430869 5758 // L@. pause the entire Log action table
whismanoid 30:07197a430869 5759 cmdLine.serial().printf("\r\n pause the entire Log action table");
whismanoid 17:9397ea3ea7e9 5760 Datalogger_action_table_enabled = false;
whismanoid 17:9397ea3ea7e9 5761 break;
whismanoid 17:9397ea3ea7e9 5762 case '@':
whismanoid 30:07197a430869 5763 // L@@ enable the entire Log action table
whismanoid 30:07197a430869 5764 cmdLine.serial().printf("\r\n enable the entire Log action table");
whismanoid 17:9397ea3ea7e9 5765 Datalogger_action_table_enabled = true;
whismanoid 17:9397ea3ea7e9 5766 break;
whismanoid 17:9397ea3ea7e9 5767 }
whismanoid 17:9397ea3ea7e9 5768 //
whismanoid 17:9397ea3ea7e9 5769 // Print the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5770 if (Datalogger_action_table_enabled) {
whismanoid 30:07197a430869 5771 // cmdLine.serial().printf("Log action table enabled; L@. to pause");
whismanoid 17:9397ea3ea7e9 5772 }
whismanoid 17:9397ea3ea7e9 5773 else {
whismanoid 30:07197a430869 5774 cmdLine.serial().printf("Log action table paused; L@@ to enable");
whismanoid 17:9397ea3ea7e9 5775 }
whismanoid 17:9397ea3ea7e9 5776 //~ cmdLine.serial().printf("\r\n Datalogger_action_table_row_count=%d", Datalogger_action_table_row_count);
whismanoid 17:9397ea3ea7e9 5777 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 5778 {
whismanoid 17:9397ea3ea7e9 5779 cmdLine.serial().printf("\r\n L@%d", i);
whismanoid 17:9397ea3ea7e9 5780 cmdLine.serial().printf(" act=%d", Datalogger_action_table[i].action);
whismanoid 17:9397ea3ea7e9 5781 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5782 {
whismanoid 17:9397ea3ea7e9 5783 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 5784 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 5785 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5786 break;
whismanoid 29:6a9edb6e973b 5787 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 5788 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 5789 break;
whismanoid 17:9397ea3ea7e9 5790 default:
whismanoid 17:9397ea3ea7e9 5791 case action_noop:
whismanoid 17:9397ea3ea7e9 5792 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 5793 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 5794 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 5795 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 5796 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 5797 break;
whismanoid 17:9397ea3ea7e9 5798 }
whismanoid 17:9397ea3ea7e9 5799 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5800 {
whismanoid 17:9397ea3ea7e9 5801 case condition_always:
whismanoid 17:9397ea3ea7e9 5802 break;
whismanoid 17:9397ea3ea7e9 5803 default:
whismanoid 17:9397ea3ea7e9 5804 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 5805 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 5806 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 5807 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 5808 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 5809 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 5810 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 5811 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 5812 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 5813 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 5814 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 5815 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 5816 cmdLine.serial().printf(" if=%d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 5817 cmdLine.serial().printf(" ch=%d", Datalogger_action_table[i].condition_channel);
whismanoid 40:330b28116178 5818 // our voltage measurement is around 1mV at best
whismanoid 40:330b28116178 5819 cmdLine.serial().printf(" x=%1.4f", Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5820 break;
whismanoid 17:9397ea3ea7e9 5821 }
whismanoid 17:9397ea3ea7e9 5822 cmdLine.serial().printf(" -- ");
whismanoid 17:9397ea3ea7e9 5823 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5824 {
whismanoid 17:9397ea3ea7e9 5825 case action_noop:
whismanoid 17:9397ea3ea7e9 5826 cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 5827 break;
whismanoid 17:9397ea3ea7e9 5828 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 5829 cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 5830 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5831 break;
whismanoid 17:9397ea3ea7e9 5832 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 5833 cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 5834 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5835 break;
whismanoid 29:6a9edb6e973b 5836 case action_button: // pin = button index 1, 2, 3
whismanoid 40:330b28116178 5837 cmdLine.serial().printf("button %%B%d!", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 5838 break;
whismanoid 17:9397ea3ea7e9 5839 case action_trigger_Halt:
whismanoid 40:330b28116178 5840 cmdLine.serial().printf("Halt");
whismanoid 17:9397ea3ea7e9 5841 break;
whismanoid 17:9397ea3ea7e9 5842 case action_trigger_FreeRun:
whismanoid 40:330b28116178 5843 cmdLine.serial().printf("LR");
whismanoid 17:9397ea3ea7e9 5844 break;
whismanoid 17:9397ea3ea7e9 5845 case action_trigger_Timer:
whismanoid 40:330b28116178 5846 cmdLine.serial().printf("LT count=%d base=%dms sleep=%d", g_timer_interval_count, g_timer_interval_msec, g_timer_sleepmode);
whismanoid 17:9397ea3ea7e9 5847 break;
whismanoid 17:9397ea3ea7e9 5848 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 5849 cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 5850 // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 5851 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 5852 break;
whismanoid 17:9397ea3ea7e9 5853 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 5854 cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 5855 // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 5856 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 5857 break;
whismanoid 17:9397ea3ea7e9 5858 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5859 //~ cmdLine.serial().printf(" condition %d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 5860 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5861 {
whismanoid 17:9397ea3ea7e9 5862 case condition_always:
whismanoid 17:9397ea3ea7e9 5863 cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 5864 break;
whismanoid 17:9397ea3ea7e9 5865 case condition_if_An_gt_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_lt_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_eq_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_ge_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_le_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_An_ne_threshold:
whismanoid 40:330b28116178 5881 cmdLine.serial().printf(" if A%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_gt_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_lt_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_eq_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_ge_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_le_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 case condition_if_AINn_ne_threshold:
whismanoid 40:330b28116178 5899 cmdLine.serial().printf(" if AIN%d != %1.2f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5900 break;
whismanoid 17:9397ea3ea7e9 5901 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5902 } // for ...Datalogger_action_table_row_count // Print the contents of Datalogger_action_table
whismanoid 30:07197a430869 5903 cmdLine.serial().printf("\r\n\r\nEdit Log action table (used %d/%d, %d free):",
whismanoid 30:07197a430869 5904 Datalogger_action_table_row_count,
whismanoid 30:07197a430869 5905 ACTION_TABLE_ROW_MAX,
whismanoid 30:07197a430869 5906 (ACTION_TABLE_ROW_MAX - Datalogger_action_table_row_count)
whismanoid 30:07197a430869 5907 );
whismanoid 17:9397ea3ea7e9 5908 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 5909 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 5910 cmdLine.serial().printf("\r\n L@+ act=4 if=1 ch=5 x=12345 -- add new entry at end of table");
whismanoid 17:9397ea3ea7e9 5911 }
whismanoid 17:9397ea3ea7e9 5912 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 5913 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 5914 cmdLine.serial().printf("\r\n L@%d act=4 if=1 ch=5 x=12345 -- edit 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@-%d -- delete row %d",
whismanoid 17:9397ea3ea7e9 5918 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 5919 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 5920 cmdLine.serial().printf("\r\n L@-~~~ -- delete all rows");
whismanoid 30:07197a430869 5921 if (Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@. -- pause entire Log action table");
whismanoid 30:07197a430869 5922 if (!Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@@ -- enable Log action table");
whismanoid 17:9397ea3ea7e9 5923 }
whismanoid 17:9397ea3ea7e9 5924 //
whismanoid 17:9397ea3ea7e9 5925 } // case L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5926 break;
whismanoid 17:9397ea3ea7e9 5927 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 5928 // LR -- Datalog free run as fast as possible
whismanoid 4:d9b05924ad4c 5929 case 'R': case 'r':
whismanoid 4:d9b05924ad4c 5930 // free run as fast as possible
whismanoid 8:dffee7509bfb 5931 Datalogger_Trigger = trigger_FreeRun;
whismanoid 8:dffee7509bfb 5932 Datalogger_Need_PrintHeader = true;
whismanoid 4:d9b05924ad4c 5933 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 9:45f98573eb6d 5934 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 5935 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 5936 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 5937 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 5938 case 'S': case 's':
whismanoid 9:45f98573eb6d 5939 {
whismanoid 9:45f98573eb6d 5940 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 5941 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 5942 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 5943 )
whismanoid 9:45f98573eb6d 5944 {
whismanoid 9:45f98573eb6d 5945 // it's me
whismanoid 9:45f98573eb6d 5946 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 5947 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 5948 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 5949 {
whismanoid 9:45f98573eb6d 5950 case 'D': case 'd':
whismanoid 9:45f98573eb6d 5951 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Disable;
whismanoid 9:45f98573eb6d 5952 break;
whismanoid 9:45f98573eb6d 5953 case 'L': case 'l':
whismanoid 9:45f98573eb6d 5954 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 5955 break;
whismanoid 9:45f98573eb6d 5956 case 'V': case 'v':
whismanoid 9:45f98573eb6d 5957 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 5958 break;
whismanoid 9:45f98573eb6d 5959 //
whismanoid 9:45f98573eb6d 5960 //
whismanoid 9:45f98573eb6d 5961 // TODO: MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 5962 case 'C': case 'c':
whismanoid 9:45f98573eb6d 5963 {
whismanoid 9:45f98573eb6d 5964 uint8_t hexValue = 0;
whismanoid 9:45f98573eb6d 5965 hexValue = hexValueOfChar(cmdLine[5]) * 0x10 + hexValueOfChar(cmdLine[6]);
whismanoid 9:45f98573eb6d 5966 switch (cmdLine[4])
whismanoid 9:45f98573eb6d 5967 {
whismanoid 9:45f98573eb6d 5968 //
whismanoid 9:45f98573eb6d 5969 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 5970 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34"));
whismanoid 9:45f98573eb6d 5971 case 'F': case 'f':
whismanoid 9:45f98573eb6d 5972 SPI_AIN_Cfg_v_filter_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 5973 break;
whismanoid 9:45f98573eb6d 5974 //
whismanoid 9:45f98573eb6d 5975 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 5976 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 5977 case 'C': case 'c':
whismanoid 9:45f98573eb6d 5978 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 5979 break;
whismanoid 9:45f98573eb6d 5980 //
whismanoid 9:45f98573eb6d 5981 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 5982 // cmdLine.serial().print(F("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00"));
whismanoid 9:45f98573eb6d 5983 case 'P': case 'p':
whismanoid 9:45f98573eb6d 5984 SPI_AIN_Cfg_v_pga_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 5985 break;
whismanoid 9:45f98573eb6d 5986 //
whismanoid 9:45f98573eb6d 5987 // cmdLine.serial().print(F("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar"));
whismanoid 9:45f98573eb6d 5988 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 5989 case 'U': case 'u':
whismanoid 9:45f98573eb6d 5990 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] | 0x40;
whismanoid 9:45f98573eb6d 5991 break;
whismanoid 9:45f98573eb6d 5992 //
whismanoid 9:45f98573eb6d 5993 // cmdLine.serial().print(F("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar"));
whismanoid 9:45f98573eb6d 5994 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 5995 case 'B': case 'b':
whismanoid 9:45f98573eb6d 5996 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] &~ 0x40;
whismanoid 9:45f98573eb6d 5997 break;
whismanoid 9:45f98573eb6d 5998 }
whismanoid 9:45f98573eb6d 5999 break;
whismanoid 9:45f98573eb6d 6000 }
whismanoid 9:45f98573eb6d 6001 //
whismanoid 9:45f98573eb6d 6002 //
whismanoid 9:45f98573eb6d 6003 }
whismanoid 9:45f98573eb6d 6004 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 6005 } // end for channel_index
whismanoid 9:45f98573eb6d 6006 Datalogger_PrintHeader();
whismanoid 9:45f98573eb6d 6007 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6008 }
whismanoid 9:45f98573eb6d 6009 break;
whismanoid 9:45f98573eb6d 6010 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6011 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 6012 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 6013 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 6014 // verb: D for disable, V for Voltage, L for LSB
whismanoid 8:dffee7509bfb 6015 case 'A': case 'a':
whismanoid 9:45f98573eb6d 6016 {
whismanoid 9:45f98573eb6d 6017 // all-channel: loop through all valid channel_index, test cmdLine[2] 'is it me'?
whismanoid 9:45f98573eb6d 6018 // for channel_index loop through 0..NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 9:45f98573eb6d 6019 // if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 6020 // || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 6021 // ) {
whismanoid 9:45f98573eb6d 6022 // // it's me
whismanoid 9:45f98573eb6d 6023 // // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 6024 // // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 6025 // } end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 6026 // } end for channel_index
whismanoid 9:45f98573eb6d 6027 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6028 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 6029 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 6030 )
whismanoid 9:45f98573eb6d 6031 {
whismanoid 9:45f98573eb6d 6032 // it's me
whismanoid 9:45f98573eb6d 6033 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 6034 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 6035 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 6036 {
whismanoid 9:45f98573eb6d 6037 case 'D': case 'd':
whismanoid 9:45f98573eb6d 6038 Platform_Enable_ch[channel_index] = Platform_AIN_Disable;
whismanoid 9:45f98573eb6d 6039 break;
whismanoid 9:45f98573eb6d 6040 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 6041 case 'L': case 'l':
whismanoid 9:45f98573eb6d 6042 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 6043 break;
whismanoid 9:45f98573eb6d 6044 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 6045 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 6046 case 'V': case 'v':
whismanoid 9:45f98573eb6d 6047 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 6048 break;
whismanoid 9:45f98573eb6d 6049 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 6050 }
whismanoid 9:45f98573eb6d 6051 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 6052 } // end for channel_index
whismanoid 10:04022a61b527 6053 // Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 6054 if (Datalogger_enable_serial) {
whismanoid 9:45f98573eb6d 6055 Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 6056 }
whismanoid 9:45f98573eb6d 6057 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 6058 if (Datalogger_enable_AUXserial) {
whismanoid 9:45f98573eb6d 6059 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 9:45f98573eb6d 6060 }
whismanoid 9:45f98573eb6d 6061 # endif // HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 6062 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6063 if (Datalogger_enable_DAPLINKserial) {
whismanoid 9:45f98573eb6d 6064 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 9:45f98573eb6d 6065 }
whismanoid 9:45f98573eb6d 6066 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6067 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6068 }
whismanoid 8:dffee7509bfb 6069 break;
whismanoid 9:45f98573eb6d 6070 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 6071 case '>':
whismanoid 9:45f98573eb6d 6072 // L>A -- Datalogger_enable_AUXserial
whismanoid 9:45f98573eb6d 6073 // L>D -- Datalogger_enable_DAPLINKserial
whismanoid 9:45f98573eb6d 6074 // L>S -- Datalogger_enable_serial
whismanoid 9:45f98573eb6d 6075 switch (cmdLine[2])
whismanoid 9:45f98573eb6d 6076 {
whismanoid 9:45f98573eb6d 6077 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 6078 case 'A': case 'a':
whismanoid 9:45f98573eb6d 6079 Datalogger_enable_AUXserial = !Datalogger_enable_AUXserial;
whismanoid 9:45f98573eb6d 6080 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6081 break;
whismanoid 8:dffee7509bfb 6082 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6083 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6084 case 'D': case 'd':
whismanoid 9:45f98573eb6d 6085 Datalogger_enable_DAPLINKserial = !Datalogger_enable_DAPLINKserial;
whismanoid 9:45f98573eb6d 6086 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6087 break;
whismanoid 8:dffee7509bfb 6088 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 6089 case 'S': case 's':
whismanoid 9:45f98573eb6d 6090 Datalogger_enable_serial = !Datalogger_enable_serial;
whismanoid 9:45f98573eb6d 6091 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 6092 break;
whismanoid 9:45f98573eb6d 6093 }
whismanoid 9:45f98573eb6d 6094 break; // case '>' L>S serial enable toggle
whismanoid 28:a9a3a9db592b 6095 default:
whismanoid 28:a9a3a9db592b 6096 // TODO: L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 6097 //
whismanoid 28:a9a3a9db592b 6098 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 6099 #if 1 // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 6100 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 6101 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 6102 //
whismanoid 28:a9a3a9db592b 6103 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 28:a9a3a9db592b 6104 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 39:4d285e961435 6105 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 6106 // TODO: USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 6107 cmdLine.serial().printf("\r\n LT count=%d base=%dms sleep=%d -- Datalog timer",
whismanoid 39:4d285e961435 6108 g_timer_interval_count,
whismanoid 39:4d285e961435 6109 g_timer_interval_msec,
whismanoid 39:4d285e961435 6110 (int)g_timer_sleepmode
whismanoid 39:4d285e961435 6111 ); // trigger_Timer
whismanoid 39:4d285e961435 6112 #else // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 6113 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 6114 #endif // USE_DATALOGGER_SLEEP
whismanoid 28:a9a3a9db592b 6115 //
whismanoid 28:a9a3a9db592b 6116 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 28:a9a3a9db592b 6117 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 6118 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 6119 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 6120 //
whismanoid 28:a9a3a9db592b 6121 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 6122 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 28:a9a3a9db592b 6123 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 6124 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 6125 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 6126 //
whismanoid 28:a9a3a9db592b 6127 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 6128 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 6129 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 6130 //
whismanoid 28:a9a3a9db592b 6131 //
whismanoid 28:a9a3a9db592b 6132 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 6133 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 28:a9a3a9db592b 6134 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 6135 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 6136 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 28:a9a3a9db592b 6137 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 28:a9a3a9db592b 6138 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 28:a9a3a9db592b 6139 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 28:a9a3a9db592b 6140 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 28:a9a3a9db592b 6141 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 28:a9a3a9db592b 6142 //
whismanoid 28:a9a3a9db592b 6143 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 28:a9a3a9db592b 6144 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 28:a9a3a9db592b 6145 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 28:a9a3a9db592b 6146 //
whismanoid 28:a9a3a9db592b 6147 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 6148 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 28:a9a3a9db592b 6149 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 28:a9a3a9db592b 6150 //
whismanoid 28:a9a3a9db592b 6151 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 6152 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 28:a9a3a9db592b 6153 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 6154 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 28:a9a3a9db592b 6155 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 6156 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 28:a9a3a9db592b 6157 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 6158 //
whismanoid 28:a9a3a9db592b 6159 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 28:a9a3a9db592b 6160 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 28:a9a3a9db592b 6161 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 28:a9a3a9db592b 6162 //
whismanoid 28:a9a3a9db592b 6163 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 6164 //
whismanoid 28:a9a3a9db592b 6165 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 28:a9a3a9db592b 6166 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 28:a9a3a9db592b 6167 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 6168 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 6169 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 28:a9a3a9db592b 6170 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6171 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 28:a9a3a9db592b 6172 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6173 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6174 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 28:a9a3a9db592b 6175 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6176 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 28:a9a3a9db592b 6177 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6178 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 28:a9a3a9db592b 6179 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 6180 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6181 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 28:a9a3a9db592b 6182 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 6183 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 6184 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 6185 # if HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 6186 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 6187 # endif // HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 6188 # if HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 6189 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 6190 # endif // HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 6191 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 6192 //
whismanoid 28:a9a3a9db592b 6193 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 6194 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 6195 break;
whismanoid 17:9397ea3ea7e9 6196 } // switch (cmdLine[1]) inside case 'L'
whismanoid 4:d9b05924ad4c 6197 }
whismanoid 4:d9b05924ad4c 6198 break; // case 'L'
whismanoid 4:d9b05924ad4c 6199 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 6200 //
whismanoid 4:d9b05924ad4c 6201 // Application-specific commands here
whismanoid 4:d9b05924ad4c 6202 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 6203 //
whismanoid 4:d9b05924ad4c 6204 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 6205 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 6206
whismanoid 4:d9b05924ad4c 6207 //
whismanoid 4:d9b05924ad4c 6208 // TODO1: add new commands here
whismanoid 4:d9b05924ad4c 6209 //
whismanoid 4:d9b05924ad4c 6210 default:
whismanoid 4:d9b05924ad4c 6211 #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6212 extern bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5715.cpp
whismanoid 4:d9b05924ad4c 6213 if (!MAX5715_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6214 #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6215 extern bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11131.cpp
whismanoid 4:d9b05924ad4c 6216 if (!MAX11131_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6217 #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6218 extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp
whismanoid 4:d9b05924ad4c 6219 if (!MAX5171_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6220 #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6221 extern bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp
whismanoid 4:d9b05924ad4c 6222 if (!MAX11410_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6223 #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 6224 extern bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX12345.cpp
whismanoid 4:d9b05924ad4c 6225 if (!MAX12345_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 6226 #else
whismanoid 4:d9b05924ad4c 6227 if (0) // not_handled_by_device_submenu
whismanoid 4:d9b05924ad4c 6228 #endif
whismanoid 4:d9b05924ad4c 6229 {
whismanoid 4:d9b05924ad4c 6230 cmdLine.serial().printf("\r\n unknown command ");
whismanoid 4:d9b05924ad4c 6231 //~ cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 6232 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 6233 cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n",
whismanoid 4:d9b05924ad4c 6234 cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 6235 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6236 }
whismanoid 4:d9b05924ad4c 6237 } // switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 6238 //
whismanoid 31:47eee7e0cc2d 6239 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 6240 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 6241 // print command prompt
whismanoid 8:dffee7509bfb 6242 // print_command_prompt();
whismanoid 8:dffee7509bfb 6243 cmdLine.serial().printf("\r\n> ");
whismanoid 31:47eee7e0cc2d 6244 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 6245 }
whismanoid 4:d9b05924ad4c 6246 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 6247
whismanoid 4:d9b05924ad4c 6248 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 6249 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 6250 void Datalogger_PrintHeader(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 6251 {
whismanoid 37:3f369235e5bc 6252 #if MAX40108_DEMO // main_menu_status banner
whismanoid 37:3f369235e5bc 6253 cmdLine.serial().printf("\r\n\r\n\"MAX40108_U%d", MAX40108_DEMO);
whismanoid 37:3f369235e5bc 6254 #ifdef BOARD_SERIAL_NUMBER
whismanoid 37:3f369235e5bc 6255 // data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 6256 cmdLine.serial().printf(" [s/n %d]", BOARD_SERIAL_NUMBER);
whismanoid 37:3f369235e5bc 6257 #endif // BOARD_SERIAL_NUMBER data unique to certain boards based on serial number
whismanoid 37:3f369235e5bc 6258 #ifdef FW_REV
whismanoid 37:3f369235e5bc 6259 cmdLine.serial().printf(" [FW_REV %d]", FW_REV);
whismanoid 37:3f369235e5bc 6260 #endif // FW_REV
whismanoid 37:3f369235e5bc 6261 cmdLine.serial().printf("\"\r\n");
whismanoid 37:3f369235e5bc 6262 #endif // MAX40108_DEMO
whismanoid 37:3f369235e5bc 6263
whismanoid 4:d9b05924ad4c 6264 // column header banner for csv data columns
whismanoid 4:d9b05924ad4c 6265 int field_index = 0;
whismanoid 4:d9b05924ad4c 6266 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6267 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 6268 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 4:d9b05924ad4c 6269 continue;
whismanoid 4:d9b05924ad4c 6270 }
whismanoid 4:d9b05924ad4c 6271 // comma between fields
whismanoid 4:d9b05924ad4c 6272 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 6273 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 6274 }
whismanoid 10:04022a61b527 6275 field_index++;
whismanoid 4:d9b05924ad4c 6276 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 6277 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 6278 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 4:d9b05924ad4c 6279 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 4:d9b05924ad4c 6280 cmdLine.serial().printf("\"AIN%d-%d_BIP", channel_index, channel_index+1);
whismanoid 4:d9b05924ad4c 6281 }
whismanoid 4:d9b05924ad4c 6282 else {
whismanoid 4:d9b05924ad4c 6283 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 6284 }
whismanoid 4:d9b05924ad4c 6285 #else // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 6286 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 6287 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 6288 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_LSB) {
whismanoid 4:d9b05924ad4c 6289 // _LSB column header suffix
whismanoid 13:184a08909405 6290 cmdLine.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 6291 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6292 cmdLine_DAPLINKserial.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 6293 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6294 }
whismanoid 10:04022a61b527 6295 else if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_Volt) {
whismanoid 4:d9b05924ad4c 6296 // _V column header suffix
whismanoid 13:184a08909405 6297 cmdLine.serial().printf("_V");
whismanoid 4:d9b05924ad4c 6298 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6299 cmdLine_DAPLINKserial.serial().printf("_V");
whismanoid 4:d9b05924ad4c 6300 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6301 }
whismanoid 13:184a08909405 6302 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6303 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6304 if (SPI_AIN_customChannelHeader_ch[channel_index] && SPI_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 6305 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 6306 cmdLine.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6307 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6308 cmdLine_DAPLINKserial.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6309 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6310 } else {
whismanoid 13:184a08909405 6311 // no custom channel name for this channel
whismanoid 13:184a08909405 6312 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 6313 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6314 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 6315 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6316 }
whismanoid 13:184a08909405 6317 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 6318 // close quote
whismanoid 13:184a08909405 6319 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 6320 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6321 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 6322 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6323 }
whismanoid 4:d9b05924ad4c 6324
whismanoid 4:d9b05924ad4c 6325 #if VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 6326 // PART_ID field: Device ID Validation
whismanoid 4:d9b05924ad4c 6327 cmdLine.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 6328 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6329 cmdLine_DAPLINKserial.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 6330 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6331 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 6332 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 6333 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 6334 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6335 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 6336 continue;
whismanoid 9:45f98573eb6d 6337 }
whismanoid 4:d9b05924ad4c 6338 // comma between fields
whismanoid 4:d9b05924ad4c 6339 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 6340 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 6341 }
whismanoid 9:45f98573eb6d 6342 field_index++;
whismanoid 4:d9b05924ad4c 6343 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 6344 cmdLine.serial().printf("\"A%d", channel_index);
whismanoid 9:45f98573eb6d 6345 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 9:45f98573eb6d 6346 // _LSB column header suffix
whismanoid 13:184a08909405 6347 cmdLine.serial().printf("_LSB");
whismanoid 9:45f98573eb6d 6348 }
whismanoid 9:45f98573eb6d 6349 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 6350 // _V column header suffix
whismanoid 13:184a08909405 6351 cmdLine.serial().printf("_V");
whismanoid 9:45f98573eb6d 6352 }
whismanoid 13:184a08909405 6353 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6354 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 6355 if (Platform_AIN_customChannelHeader_ch[channel_index] && Platform_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 6356 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 6357 cmdLine.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6358 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6359 cmdLine_DAPLINKserial.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 6360 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6361 } else {
whismanoid 13:184a08909405 6362 // no custom channel name for this channel
whismanoid 13:184a08909405 6363 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 6364 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6365 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 6366 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6367 }
whismanoid 13:184a08909405 6368 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 6369 // close quote
whismanoid 13:184a08909405 6370 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 6371 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 6372 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 6373 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6374 }
whismanoid 4:d9b05924ad4c 6375 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 30:07197a430869 6376 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 6377 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in Datalogger_PrintHeader
whismanoid 30:07197a430869 6378 cmdLine.serial().printf(",\"%s\"", gstrRemarkHeader);
whismanoid 30:07197a430869 6379 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 4:d9b05924ad4c 6380 // end of column header line
whismanoid 4:d9b05924ad4c 6381 cmdLine.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 6382 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6383 cmdLine_DAPLINKserial.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 6384 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 6385 } // void Datalogger_PrintHeader()
whismanoid 4:d9b05924ad4c 6386
whismanoid 5:aaf8b5f5fda1 6387 //--------------------------------------------------
whismanoid 5:aaf8b5f5fda1 6388 void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 6389 {
whismanoid 5:aaf8b5f5fda1 6390 // CODE GENERATOR: example code: has no member function ScanStandardExternalClock
whismanoid 5:aaf8b5f5fda1 6391 // CODE GENERATOR: example code: has no member function ReadAINcode
whismanoid 5:aaf8b5f5fda1 6392 // CODE GENERATOR: example code: member function Read_All_Voltages
whismanoid 5:aaf8b5f5fda1 6393 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6394 // Measure ADC channels in sequence from AIN0 to channelNumber_0_9.
whismanoid 5:aaf8b5f5fda1 6395 // @param[in] g_MAX11410_device.channelNumber_0_15: AIN Channel Number
whismanoid 5:aaf8b5f5fda1 6396 // @param[in] g_MAX11410_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
whismanoid 5:aaf8b5f5fda1 6397 // @param[in] g_MAX11410_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
whismanoid 10:04022a61b527 6398 //~ int channelId_0_9 = NUM_DUT_ANALOG_IN_CHANNELS-1+1;
whismanoid 5:aaf8b5f5fda1 6399 //g_MAX11410_device.channelNumber_0_15 = channelId_0_9;
whismanoid 5:aaf8b5f5fda1 6400 //g_MAX11410_device.PowerManagement_0_2 = 0;
whismanoid 5:aaf8b5f5fda1 6401 //g_MAX11410_device.chan_id_0_1 = 1;
whismanoid 5:aaf8b5f5fda1 6402 //----------------------------------------
whismanoid 5:aaf8b5f5fda1 6403 // scan AIN0..AIN9
whismanoid 5:aaf8b5f5fda1 6404 //
whismanoid 10:04022a61b527 6405 #if 1
whismanoid 10:04022a61b527 6406 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 6407 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 6408 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 6409 //
whismanoid 10:04022a61b527 6410 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6411 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc3); // GP1 = 0
whismanoid 10:04022a61b527 6412 //
whismanoid 10:04022a61b527 6413 int field_index = 0;
whismanoid 10:04022a61b527 6414 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 6415 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 10:04022a61b527 6416 continue;
whismanoid 10:04022a61b527 6417 }
whismanoid 10:04022a61b527 6418 field_index++;
whismanoid 10:04022a61b527 6419 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[channel_index];
whismanoid 10:04022a61b527 6420 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[channel_index];
whismanoid 10:04022a61b527 6421 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[channel_index];
whismanoid 10:04022a61b527 6422 //
whismanoid 10:04022a61b527 6423 // WIP SampleRate_of_FILTER_CONV_START() MAX11410EMC-FW slow ODR 10Sps #262
whismanoid 10:04022a61b527 6424 // adjust the MAX11410.loop_limit value if the sample rate is set to a value slower than 20sps
whismanoid 10:04022a61b527 6425 // SampleRate_of_FILTER_CONV_START(uint8_t FILTER_RegValue, uint8_t CONV_START_RegValue)
whismanoid 10:04022a61b527 6426 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 6427 if (SampleRate < 20.0) {
whismanoid 10:04022a61b527 6428 g_MAX11410_device.loop_limit = 32767; // TODO: is this timeout long enough for the slow output data rates?
whismanoid 10:04022a61b527 6429 }
whismanoid 10:04022a61b527 6430 //
whismanoid 10:04022a61b527 6431 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6432 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc3); // GP0 = 0
whismanoid 10:04022a61b527 6433 //
whismanoid 10:04022a61b527 6434 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 6435 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 10:04022a61b527 6436 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 10:04022a61b527 6437 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 6438 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = (MAX11410::MAX11410_AINN_SEL_enum_t)(channel_index^1);
whismanoid 10:04022a61b527 6439 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 6440 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 6441 }
whismanoid 10:04022a61b527 6442 else {
whismanoid 10:04022a61b527 6443 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 6444 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = MAX11410::AINN_SEL_1010_GND;
whismanoid 10:04022a61b527 6445 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 6446 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 6447 }
whismanoid 10:04022a61b527 6448 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 6449 //
whismanoid 10:04022a61b527 6450 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6451 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc4); // GP0 = 1
whismanoid 10:04022a61b527 6452 //
whismanoid 10:04022a61b527 6453 }
whismanoid 10:04022a61b527 6454 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 6455 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc4); // GP1 = 1
whismanoid 10:04022a61b527 6456 #else
whismanoid 5:aaf8b5f5fda1 6457 g_MAX11410_device.Read_All_Voltages();
whismanoid 10:04022a61b527 6458 #endif
whismanoid 10:04022a61b527 6459 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6460 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 6461 // mbed
whismanoid 5:aaf8b5f5fda1 6462 // Platform board uses simple analog inputs
whismanoid 5:aaf8b5f5fda1 6463 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 5:aaf8b5f5fda1 6464 Platform_LSB[0] = analogIn0.read();
whismanoid 5:aaf8b5f5fda1 6465 Platform_LSB[1] = analogIn1.read();
whismanoid 5:aaf8b5f5fda1 6466 Platform_LSB[2] = analogIn2.read();
whismanoid 5:aaf8b5f5fda1 6467 Platform_LSB[3] = analogIn3.read();
whismanoid 5:aaf8b5f5fda1 6468 Platform_LSB[4] = analogIn4.read();
whismanoid 5:aaf8b5f5fda1 6469 Platform_LSB[5] = analogIn5.read();
whismanoid 10:04022a61b527 6470 #endif
whismanoid 10:04022a61b527 6471 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 37:3f369235e5bc 6472 #if USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 6473 // #if USE_Platform_AIN_Average -- for (i=0; i<Platform_AIN_Average_N; i++) -- analogIn012345.read()
whismanoid 37:3f369235e5bc 6474 // float normValue_0_1 = analogInPin.read(); but mean of Platform_AIN_Average_N samples
whismanoid 37:3f369235e5bc 6475 float analogIn0_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6476 float analogIn1_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6477 float analogIn2_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6478 float analogIn3_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6479 float analogIn4_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6480 float analogIn5_normValue_0_1 = 0;
whismanoid 37:3f369235e5bc 6481 for (int i = 0; i < Platform_AIN_Average_N; i++) {
whismanoid 37:3f369235e5bc 6482 analogIn0_normValue_0_1 = analogIn0_normValue_0_1 + analogIn0.read();
whismanoid 37:3f369235e5bc 6483 analogIn1_normValue_0_1 = analogIn1_normValue_0_1 + analogIn1.read();
whismanoid 37:3f369235e5bc 6484 analogIn2_normValue_0_1 = analogIn2_normValue_0_1 + analogIn2.read();
whismanoid 37:3f369235e5bc 6485 analogIn3_normValue_0_1 = analogIn3_normValue_0_1 + analogIn3.read();
whismanoid 37:3f369235e5bc 6486 analogIn4_normValue_0_1 = analogIn4_normValue_0_1 + analogIn4.read();
whismanoid 37:3f369235e5bc 6487 analogIn5_normValue_0_1 = analogIn5_normValue_0_1 + analogIn5.read();
whismanoid 37:3f369235e5bc 6488 }
whismanoid 37:3f369235e5bc 6489 analogIn0_normValue_0_1 = analogIn0_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6490 analogIn1_normValue_0_1 = analogIn1_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6491 analogIn2_normValue_0_1 = analogIn2_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6492 analogIn3_normValue_0_1 = analogIn3_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6493 analogIn4_normValue_0_1 = analogIn4_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6494 analogIn5_normValue_0_1 = analogIn5_normValue_0_1 / Platform_AIN_Average_N;
whismanoid 37:3f369235e5bc 6495 #else // USE_Platform_AIN_Average
whismanoid 37:3f369235e5bc 6496 float analogIn0_normValue_0_1 = analogIn0.read();
whismanoid 37:3f369235e5bc 6497 float analogIn1_normValue_0_1 = analogIn1.read();
whismanoid 37:3f369235e5bc 6498 float analogIn2_normValue_0_1 = analogIn2.read();
whismanoid 37:3f369235e5bc 6499 float analogIn3_normValue_0_1 = analogIn3.read();
whismanoid 37:3f369235e5bc 6500 float analogIn4_normValue_0_1 = analogIn4.read();
whismanoid 37:3f369235e5bc 6501 float analogIn5_normValue_0_1 = analogIn5.read();
whismanoid 37:3f369235e5bc 6502 #endif // USE_Platform_AIN_Average
whismanoid 34:a1993a1ee904 6503 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 6504 // apply calibration to normValue_0_1 value
whismanoid 37:3f369235e5bc 6505 Platform_Voltage[0] = CalibratedNormValue(0, analogIn0_normValue_0_1) * adc_full_scale_voltage[0];
whismanoid 37:3f369235e5bc 6506 Platform_Voltage[1] = CalibratedNormValue(1, analogIn1_normValue_0_1) * adc_full_scale_voltage[1];
whismanoid 37:3f369235e5bc 6507 Platform_Voltage[2] = CalibratedNormValue(2, analogIn2_normValue_0_1) * adc_full_scale_voltage[2];
whismanoid 37:3f369235e5bc 6508 Platform_Voltage[3] = CalibratedNormValue(3, analogIn3_normValue_0_1) * adc_full_scale_voltage[3];
whismanoid 37:3f369235e5bc 6509 Platform_Voltage[4] = CalibratedNormValue(4, analogIn4_normValue_0_1) * adc_full_scale_voltage[4];
whismanoid 37:3f369235e5bc 6510 Platform_Voltage[5] = CalibratedNormValue(5, analogIn5_normValue_0_1) * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 6511 #else // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 6512 Platform_Voltage[0] = analogIn0_normValue_0_1 * adc_full_scale_voltage[0];
whismanoid 37:3f369235e5bc 6513 Platform_Voltage[1] = analogIn1_normValue_0_1 * adc_full_scale_voltage[1];
whismanoid 37:3f369235e5bc 6514 Platform_Voltage[2] = analogIn2_normValue_0_1 * adc_full_scale_voltage[2];
whismanoid 37:3f369235e5bc 6515 Platform_Voltage[3] = analogIn3_normValue_0_1 * adc_full_scale_voltage[3];
whismanoid 37:3f369235e5bc 6516 Platform_Voltage[4] = analogIn4_normValue_0_1 * adc_full_scale_voltage[4];
whismanoid 37:3f369235e5bc 6517 Platform_Voltage[5] = analogIn5_normValue_0_1 * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 6518 #endif // HAS_Platform_AIN_Calibration
whismanoid 37:3f369235e5bc 6519 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 5:aaf8b5f5fda1 6520 #endif // defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 6521
whismanoid 5:aaf8b5f5fda1 6522 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6523 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 6524 const uint32_t part_id_expect = 0x000F02;
whismanoid 5:aaf8b5f5fda1 6525 uint32_t part_id_readback;
whismanoid 5:aaf8b5f5fda1 6526 g_MAX11410_device.RegRead(MAX11410::CMD_r001_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xddd_PART_ID, &part_id_readback);
whismanoid 5:aaf8b5f5fda1 6527 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6528 } // void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 6529
whismanoid 17:9397ea3ea7e9 6530 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6531 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 6532 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 6533 void Datalogger_RunActionTable()
whismanoid 17:9397ea3ea7e9 6534 {
whismanoid 17:9397ea3ea7e9 6535 if (Datalogger_action_table_enabled == false) {
whismanoid 17:9397ea3ea7e9 6536 return;
whismanoid 17:9397ea3ea7e9 6537 }
whismanoid 17:9397ea3ea7e9 6538 // TODO: verbose Datalogger_RunActionTable() emit a csv column ,"Action"
whismanoid 17:9397ea3ea7e9 6539 // TODO: assert Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX
whismanoid 17:9397ea3ea7e9 6540 // for Datalogger_action_table[0..Datalogger_action_table_row_count]
whismanoid 17:9397ea3ea7e9 6541 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 6542 {
whismanoid 17:9397ea3ea7e9 6543 // skip if Datalogger_action_table[i].action == action_noop
whismanoid 17:9397ea3ea7e9 6544 if (Datalogger_action_table[i].action == action_noop) {
whismanoid 17:9397ea3ea7e9 6545 continue;
whismanoid 17:9397ea3ea7e9 6546 }
whismanoid 17:9397ea3ea7e9 6547 // TODO: test Datalogger_action_table[i].condition "if="
whismanoid 17:9397ea3ea7e9 6548 // TODO: Could the .condition field also distinguish Platform ADC from SPI ADC?
whismanoid 17:9397ea3ea7e9 6549 // That way we keep both sets of ADC channels in separate lists
whismanoid 17:9397ea3ea7e9 6550 // if=0 -- always
whismanoid 17:9397ea3ea7e9 6551 // if=1,2,3,4,5,6 -- Platform_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 6552 // if=7,8,9,10,11,12 -- SPI_AIN_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 6553 // also, are we comparing code or voltage?
whismanoid 17:9397ea3ea7e9 6554 // TODO: selected Datalogger_action_table[i].condition_channel
whismanoid 17:9397ea3ea7e9 6555 // Datalogger could have both platform ADC and external SPI ADC channels
whismanoid 17:9397ea3ea7e9 6556 // if SPI_ADC_DeviceName
whismanoid 17:9397ea3ea7e9 6557 // NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 6558 // SPI_AIN_Enable_ch[]
whismanoid 17:9397ea3ea7e9 6559 // SPI_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 6560 // SPI_AIN_Voltage[]
whismanoid 17:9397ea3ea7e9 6561 // if LOG_PLATFORM_AIN
whismanoid 17:9397ea3ea7e9 6562 // NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 6563 // analogInPin_fullScaleVoltage[]
whismanoid 17:9397ea3ea7e9 6564 // Platform_Enable_ch[]
whismanoid 17:9397ea3ea7e9 6565 // Platform_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 6566 // Platform_Voltage[]
whismanoid 17:9397ea3ea7e9 6567 // TODO: selected Datalogger_action_table[i].condition_threshold
whismanoid 17:9397ea3ea7e9 6568 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6569 {
whismanoid 17:9397ea3ea7e9 6570 case condition_always:
whismanoid 17:9397ea3ea7e9 6571 //~ cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 6572 break;
whismanoid 17:9397ea3ea7e9 6573 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 6574 //~ cmdLine.serial().printf(" if A%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6575 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6576 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6577 continue;
whismanoid 17:9397ea3ea7e9 6578 }
whismanoid 17:9397ea3ea7e9 6579 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6580 break;
whismanoid 17:9397ea3ea7e9 6581 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 6582 //~ cmdLine.serial().printf(" if A%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6583 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6584 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6585 continue;
whismanoid 17:9397ea3ea7e9 6586 }
whismanoid 17:9397ea3ea7e9 6587 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6588 break;
whismanoid 17:9397ea3ea7e9 6589 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 6590 //~ cmdLine.serial().printf(" if A%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6591 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6592 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6593 continue;
whismanoid 17:9397ea3ea7e9 6594 }
whismanoid 17:9397ea3ea7e9 6595 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6596 break;
whismanoid 17:9397ea3ea7e9 6597 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 6598 //~ cmdLine.serial().printf(" if A%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6599 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6600 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6601 continue;
whismanoid 17:9397ea3ea7e9 6602 }
whismanoid 17:9397ea3ea7e9 6603 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6604 break;
whismanoid 17:9397ea3ea7e9 6605 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 6606 //~ cmdLine.serial().printf(" if A%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6607 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6608 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6609 continue;
whismanoid 17:9397ea3ea7e9 6610 }
whismanoid 17:9397ea3ea7e9 6611 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6612 break;
whismanoid 17:9397ea3ea7e9 6613 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 6614 //~ cmdLine.serial().printf(" if A%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6615 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 6616 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 6617 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6618 continue;
whismanoid 17:9397ea3ea7e9 6619 }
whismanoid 17:9397ea3ea7e9 6620 break;
whismanoid 17:9397ea3ea7e9 6621 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 6622 //~ cmdLine.serial().printf(" if AIN%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6623 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6624 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6625 continue;
whismanoid 17:9397ea3ea7e9 6626 }
whismanoid 17:9397ea3ea7e9 6627 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6628 break;
whismanoid 17:9397ea3ea7e9 6629 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 6630 //~ cmdLine.serial().printf(" if AIN%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6631 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6632 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6633 continue;
whismanoid 17:9397ea3ea7e9 6634 }
whismanoid 17:9397ea3ea7e9 6635 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6636 break;
whismanoid 17:9397ea3ea7e9 6637 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 6638 //~ cmdLine.serial().printf(" if AIN%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6639 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6640 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6641 continue;
whismanoid 17:9397ea3ea7e9 6642 }
whismanoid 17:9397ea3ea7e9 6643 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6644 break;
whismanoid 17:9397ea3ea7e9 6645 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 6646 //~ cmdLine.serial().printf(" if AIN%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6647 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6648 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6649 continue;
whismanoid 17:9397ea3ea7e9 6650 }
whismanoid 17:9397ea3ea7e9 6651 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6652 break;
whismanoid 17:9397ea3ea7e9 6653 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 6654 //~ cmdLine.serial().printf(" if AIN%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6655 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6656 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6657 continue;
whismanoid 17:9397ea3ea7e9 6658 }
whismanoid 17:9397ea3ea7e9 6659 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6660 break;
whismanoid 17:9397ea3ea7e9 6661 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 6662 //~ cmdLine.serial().printf(" if AIN%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 6663 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6664 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 6665 continue;
whismanoid 17:9397ea3ea7e9 6666 }
whismanoid 17:9397ea3ea7e9 6667 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 6668 break;
whismanoid 17:9397ea3ea7e9 6669 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 6670 // selected Datalogger_action_table[i].digitalOutPin
whismanoid 17:9397ea3ea7e9 6671 // perform selected Datalogger_action_table[i].action
whismanoid 17:9397ea3ea7e9 6672 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6673 {
whismanoid 17:9397ea3ea7e9 6674 case action_noop:
whismanoid 17:9397ea3ea7e9 6675 //~ cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 6676 break;
whismanoid 17:9397ea3ea7e9 6677 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 6678 {
whismanoid 17:9397ea3ea7e9 6679 //~ cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 6680 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6681 // perform action digitalOutLow
whismanoid 17:9397ea3ea7e9 6682 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 6683 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 6684 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6685 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6686 #else
whismanoid 17:9397ea3ea7e9 6687 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 6688 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 6689 digitalInOutPin.write(0);
whismanoid 17:9397ea3ea7e9 6690 #endif
whismanoid 17:9397ea3ea7e9 6691 }
whismanoid 17:9397ea3ea7e9 6692 break;
whismanoid 17:9397ea3ea7e9 6693 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 6694 {
whismanoid 17:9397ea3ea7e9 6695 //~ cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 6696 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 6697 // perform action digitalOutHigh
whismanoid 17:9397ea3ea7e9 6698 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 6699 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 6700 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6701 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 6702 #else
whismanoid 17:9397ea3ea7e9 6703 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 6704 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 6705 digitalInOutPin.write(1);
whismanoid 17:9397ea3ea7e9 6706 #endif
whismanoid 17:9397ea3ea7e9 6707 }
whismanoid 17:9397ea3ea7e9 6708 break;
whismanoid 29:6a9edb6e973b 6709 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6710 {
whismanoid 30:07197a430869 6711 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 6712 Datalogger_Trigger_enum_t saved_Datalogger_Trigger = Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 6713 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6714 switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6715 {
whismanoid 29:6a9edb6e973b 6716 case 1:
whismanoid 29:6a9edb6e973b 6717 onButton1FallingEdge();
whismanoid 29:6a9edb6e973b 6718 break;
whismanoid 29:6a9edb6e973b 6719 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6720 case 2:
whismanoid 29:6a9edb6e973b 6721 onButton2FallingEdge();
whismanoid 29:6a9edb6e973b 6722 break;
whismanoid 29:6a9edb6e973b 6723 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6724 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6725 case 3:
whismanoid 29:6a9edb6e973b 6726 onButton3FallingEdge();
whismanoid 29:6a9edb6e973b 6727 break;
whismanoid 29:6a9edb6e973b 6728 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6729 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6730 case 4:
whismanoid 29:6a9edb6e973b 6731 onButton4FallingEdge();
whismanoid 29:6a9edb6e973b 6732 break;
whismanoid 29:6a9edb6e973b 6733 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6734 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6735 case 5:
whismanoid 29:6a9edb6e973b 6736 onButton5FallingEdge();
whismanoid 29:6a9edb6e973b 6737 break;
whismanoid 29:6a9edb6e973b 6738 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6739 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6740 case 6:
whismanoid 29:6a9edb6e973b 6741 onButton6FallingEdge();
whismanoid 29:6a9edb6e973b 6742 break;
whismanoid 29:6a9edb6e973b 6743 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6744 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6745 case 7:
whismanoid 29:6a9edb6e973b 6746 onButton7FallingEdge();
whismanoid 29:6a9edb6e973b 6747 break;
whismanoid 29:6a9edb6e973b 6748 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6749 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6750 case 8:
whismanoid 29:6a9edb6e973b 6751 onButton8FallingEdge();
whismanoid 29:6a9edb6e973b 6752 break;
whismanoid 29:6a9edb6e973b 6753 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6754 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6755 case 9:
whismanoid 29:6a9edb6e973b 6756 onButton9FallingEdge();
whismanoid 29:6a9edb6e973b 6757 break;
whismanoid 29:6a9edb6e973b 6758 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6759 } // switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6760 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 30:07197a430869 6761 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 6762 Datalogger_Trigger = saved_Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 6763 } // case action_button
whismanoid 29:6a9edb6e973b 6764 break;
whismanoid 17:9397ea3ea7e9 6765 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 6766 //~ cmdLine.serial().printf("trigger_Halt");
whismanoid 17:9397ea3ea7e9 6767 // perform action trigger_Halt
whismanoid 17:9397ea3ea7e9 6768 Datalogger_Trigger = trigger_Halt;
whismanoid 17:9397ea3ea7e9 6769 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6770 break;
whismanoid 17:9397ea3ea7e9 6771 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 6772 //~ cmdLine.serial().printf("trigger_FreeRun");
whismanoid 17:9397ea3ea7e9 6773 // perform action trigger_FreeRun
whismanoid 17:9397ea3ea7e9 6774 Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 6775 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6776 break;
whismanoid 17:9397ea3ea7e9 6777 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 6778 //~ cmdLine.serial().printf("trigger_Timer");
whismanoid 17:9397ea3ea7e9 6779 //~ // print configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 6780 //~ cmdLine.serial().printf("(%d x %dmsec)", g_timer_interval_count, g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 6781 // perform action trigger_Timer
whismanoid 17:9397ea3ea7e9 6782 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 6783 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6784 break;
whismanoid 17:9397ea3ea7e9 6785 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 6786 //~ cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 6787 //~ // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 6788 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 6789 // TODO: perform action action_trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 6790 Datalogger_Trigger = trigger_PlatformDigitalInput;
whismanoid 17:9397ea3ea7e9 6791 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6792 break;
whismanoid 17:9397ea3ea7e9 6793 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 6794 //~ cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 6795 //~ // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6796 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 6797 // TODO: perform action action_trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6798 Datalogger_Trigger = trigger_SPIDeviceRegRead;
whismanoid 17:9397ea3ea7e9 6799 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6800 break;
whismanoid 17:9397ea3ea7e9 6801 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6802 // consider next row of action table
whismanoid 17:9397ea3ea7e9 6803 } // for ...Datalogger_action_table_row_count
whismanoid 17:9397ea3ea7e9 6804 }
whismanoid 17:9397ea3ea7e9 6805 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6806
whismanoid 5:aaf8b5f5fda1 6807 //--------------------------------------------------
whismanoid 8:dffee7509bfb 6808 void Datalogger_PrintRow(CmdLine& cmdLine)
whismanoid 5:aaf8b5f5fda1 6809 {
whismanoid 5:aaf8b5f5fda1 6810 int field_index = 0;
whismanoid 5:aaf8b5f5fda1 6811 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6812 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 6813 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 5:aaf8b5f5fda1 6814 continue;
whismanoid 5:aaf8b5f5fda1 6815 }
whismanoid 5:aaf8b5f5fda1 6816 // comma between fields
whismanoid 5:aaf8b5f5fda1 6817 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 6818 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 6819 }
whismanoid 10:04022a61b527 6820 field_index++;
whismanoid 10:04022a61b527 6821 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 10:04022a61b527 6822 cmdLine.serial().printf("%d", g_MAX11410_device.AINcode[channel_index]);
whismanoid 10:04022a61b527 6823 }
whismanoid 10:04022a61b527 6824 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 10:04022a61b527 6825 // TODO: report Voltage instead of LSB
whismanoid 10:04022a61b527 6826 // Serial.print(SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 6827 static char strOutLineBuffer[16];
whismanoid 10:04022a61b527 6828 cmdLine.serial().printf("%6.6f", SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 6829 }
whismanoid 5:aaf8b5f5fda1 6830 }
whismanoid 5:aaf8b5f5fda1 6831 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6832 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 6833 if (part_id_readback != part_id_expect) {
whismanoid 5:aaf8b5f5fda1 6834 cmdLine.serial().printf(",\"FAIL\"");
whismanoid 9:45f98573eb6d 6835 need_reinit = true;
whismanoid 5:aaf8b5f5fda1 6836 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6837 g_MAX11410_device.Init();
whismanoid 5:aaf8b5f5fda1 6838 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 5:aaf8b5f5fda1 6839 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 5:aaf8b5f5fda1 6840 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 5:aaf8b5f5fda1 6841 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6842 }
whismanoid 5:aaf8b5f5fda1 6843 else {
whismanoid 5:aaf8b5f5fda1 6844 cmdLine.serial().printf(",\"OK\"");
whismanoid 5:aaf8b5f5fda1 6845 }
whismanoid 5:aaf8b5f5fda1 6846 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6847 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6848 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 6849 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6850 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 6851 continue;
whismanoid 9:45f98573eb6d 6852 }
whismanoid 5:aaf8b5f5fda1 6853 // comma between fields
whismanoid 5:aaf8b5f5fda1 6854 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 6855 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 6856 }
whismanoid 9:45f98573eb6d 6857 field_index++;
whismanoid 9:45f98573eb6d 6858 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 5:aaf8b5f5fda1 6859 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 6860 cmdLine.serial().printf("%u", Platform_LSB[channel_index]);
whismanoid 9:45f98573eb6d 6861 #endif
whismanoid 9:45f98573eb6d 6862 }
whismanoid 9:45f98573eb6d 6863 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 6864 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 11:2b8adc78618a 6865 // Datalog Volts omit V suffix from numbers #275
whismanoid 11:2b8adc78618a 6866 // because Excel graphs can't handle numbers that have a suffix.
whismanoid 11:2b8adc78618a 6867 cmdLine.serial().printf("%6.6f", Platform_Voltage[channel_index]);
whismanoid 9:45f98573eb6d 6868 #endif
whismanoid 9:45f98573eb6d 6869 }
whismanoid 5:aaf8b5f5fda1 6870 }
whismanoid 5:aaf8b5f5fda1 6871 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 6872 if (need_reinit) {
whismanoid 9:45f98573eb6d 6873 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6874 if (g_MAX11410_device.Init() == 0) {
whismanoid 9:45f98573eb6d 6875 //~ cmdLine.serial().printf(",\"Init() failed\"");
whismanoid 9:45f98573eb6d 6876 } else {
whismanoid 9:45f98573eb6d 6877 //~ cmdLine.serial().printf(",\"Init() success\"");
whismanoid 9:45f98573eb6d 6878 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 6879 // in Datalogger_PrintRow(), when part_id test fails,
whismanoid 9:45f98573eb6d 6880 // apply list of custom register writes after re-init
whismanoid 9:45f98573eb6d 6881 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 6882 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 9:45f98573eb6d 6883 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 9:45f98573eb6d 6884 uint32_t regData = custom_reg_init_data[index];
whismanoid 9:45f98573eb6d 6885 cmdLine.serial().printf("*%s=0x%06.6x", g_MAX11410_device.RegName(regAddress), regData);
whismanoid 9:45f98573eb6d 6886 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 9:45f98573eb6d 6887 }
whismanoid 9:45f98573eb6d 6888 #endif // USE_CUSTOM_REG_INIT
whismanoid 9:45f98573eb6d 6889 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 9:45f98573eb6d 6890 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 9:45f98573eb6d 6891 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 9:45f98573eb6d 6892 need_reinit = false;
whismanoid 9:45f98573eb6d 6893 }
whismanoid 9:45f98573eb6d 6894 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6895 need_reinit = false;
whismanoid 9:45f98573eb6d 6896 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6897 }
whismanoid 30:07197a430869 6898 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 6899 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in void Datalogger_PrintRow()
whismanoid 30:07197a430869 6900 cmdLine.serial().printf(",\"%s\"", gstrRemarkText);
whismanoid 30:07197a430869 6901 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 5:aaf8b5f5fda1 6902 cmdLine.serial().printf("\r\n");
whismanoid 9:45f98573eb6d 6903 if (need_reinit) {
whismanoid 9:45f98573eb6d 6904 //~ delay(500); // platform_delay_ms 500ms timing delay function
whismanoid 9:45f98573eb6d 6905 }
whismanoid 5:aaf8b5f5fda1 6906 } // void Datalogger_PrintRow()
whismanoid 5:aaf8b5f5fda1 6907
whismanoid 0:cb44e2e9ec4c 6908 // example code main function
whismanoid 0:cb44e2e9ec4c 6909 int main()
whismanoid 0:cb44e2e9ec4c 6910 {
whismanoid 0:cb44e2e9ec4c 6911 // setup: put your setup code here, to run once
whismanoid 4:d9b05924ad4c 6912 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 6913 // Configure serial ports
whismanoid 4:d9b05924ad4c 6914 cmdLine.clear();
whismanoid 4:d9b05924ad4c 6915 //~ cmdLine.serial().printf("\r\n cmdLine.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 6916 cmdLine.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 6917 //~ cmdLine.diagnostic_led_EOF = diagnostic_led_EOF;
whismanoid 4:d9b05924ad4c 6918 /// CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21);
whismanoid 4:d9b05924ad4c 6919 //~ cmdLine.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 6920 //~ cmdLine.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 6921 //~ cmdLine.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 6922 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6923 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6924 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 6925 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 6926 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 6927 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 6928 # else
whismanoid 10:04022a61b527 6929 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 6930 DAPLINKserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6931 # endif
whismanoid 10:04022a61b527 6932 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 6933 cmdLine_DAPLINKserial.clear();
whismanoid 4:d9b05924ad4c 6934 //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 6935 cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 6936 //~ cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 6937 //~ cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 6938 //~ cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 6939 # endif
whismanoid 6:f6d16658342b 6940 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6941 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 10:04022a61b527 6942 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6943 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 6944 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 6945 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 6946 AUXserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6947 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 6:f6d16658342b 6948 cmdLine_AUXserial.clear();
whismanoid 6:f6d16658342b 6949 //~ cmdLine_AUXserial.serial().printf("\r\n cmdLine_AUXserial.serial().printf test\r\n");
whismanoid 6:f6d16658342b 6950 cmdLine_AUXserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 6:f6d16658342b 6951 //~ cmdLine_AUXserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 6:f6d16658342b 6952 //~ cmdLine_AUXserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 6:f6d16658342b 6953 //~ cmdLine_AUXserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 6:f6d16658342b 6954 # endif // HAS_AUX_SERIAL
whismanoid 4:d9b05924ad4c 6955 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 0:cb44e2e9ec4c 6956
whismanoid 0:cb44e2e9ec4c 6957 // example code: serial port banner message
whismanoid 0:cb44e2e9ec4c 6958 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 6959 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6960 cmdLine.serial().printf("\r\nDataLogger_MAX11410\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 6961 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 6962 cmdLine.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 6963 # if HAS_DAPLINK_SERIAL
whismanoid 3:9055e17e181a 6964 cmdLine_DAPLINKserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 6965 # endif // HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 6966 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6967 cmdLine_AUXserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 6:f6d16658342b 6968 # endif // HAS_AUX_SERIAL
whismanoid 3:9055e17e181a 6969 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6970
whismanoid 1:747f1602abfc 6971 // CODE GENERATOR: get spi properties from device
whismanoid 3:9055e17e181a 6972 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6973 if (g_SPI_SCLK_Hz > g_MAX11410_device.get_spi_frequency())
whismanoid 3:9055e17e181a 6974 { // Device limits SPI SCLK frequency
whismanoid 3:9055e17e181a 6975 g_SPI_SCLK_Hz = g_MAX11410_device.get_spi_frequency();
whismanoid 3:9055e17e181a 6976 cmdLine.serial().printf("\r\nMAX11410 limits SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 6977
whismanoid 3:9055e17e181a 6978 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 6979 }
whismanoid 3:9055e17e181a 6980 if (g_MAX11410_device.get_spi_frequency() > g_SPI_SCLK_Hz)
whismanoid 3:9055e17e181a 6981 { // Platform limits SPI SCLK frequency
whismanoid 3:9055e17e181a 6982 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 6983 cmdLine.serial().printf("\r\nPlatform limits MAX11410 SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 6984
whismanoid 3:9055e17e181a 6985 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 6986 }
whismanoid 0:cb44e2e9ec4c 6987 // g_SPI_dataMode = g_MAX11410_device.get_spi_dataMode();
whismanoid 3:9055e17e181a 6988 while (g_MAX11410_device.Init() == 0)
whismanoid 3:9055e17e181a 6989 {
whismanoid 3:9055e17e181a 6990 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 6991 cmdLine.serial().printf("\r\nMAX11410 Init failed; retry...\r\n");
whismanoid 3:9055e17e181a 6992
whismanoid 3:9055e17e181a 6993 }
whismanoid 0:cb44e2e9ec4c 6994
whismanoid 0:cb44e2e9ec4c 6995 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 3:9055e17e181a 6996 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6997 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 3:9055e17e181a 6998 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 3:9055e17e181a 6999 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 3:9055e17e181a 7000 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7001 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 3:9055e17e181a 7002 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7003 // CODE GENERATOR: example code: has no member function REF
whismanoid 0:cb44e2e9ec4c 7004 // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line
whismanoid 0:cb44e2e9ec4c 7005 // CODE GENERATOR: ResolutionBits = 24
whismanoid 0:cb44e2e9ec4c 7006 // CODE GENERATOR: FScode = 0xffffff
whismanoid 0:cb44e2e9ec4c 7007 // CODE GENERATOR: NumChannels = 10
whismanoid 0:cb44e2e9ec4c 7008 // CODE GENERATOR: banner before DataLogHelloCppCodeList while(1)
whismanoid 3:9055e17e181a 7009 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 7010 cmdLine.serial().printf("v_filter = 0x%2.2x\r\n", g_MAX11410_device.v_filter);
whismanoid 0:cb44e2e9ec4c 7011
whismanoid 3:9055e17e181a 7012 cmdLine.serial().printf("v_pga = 0x%2.2x\r\n", g_MAX11410_device.v_pga);
whismanoid 0:cb44e2e9ec4c 7013
whismanoid 3:9055e17e181a 7014 cmdLine.serial().printf("v_ctrl = 0x%2.2x\r\n", g_MAX11410_device.v_ctrl);
whismanoid 3:9055e17e181a 7015
whismanoid 3:9055e17e181a 7016 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 7017
whismanoid 3:9055e17e181a 7018 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 7019 Datalogger_Need_PrintHeader = true;
whismanoid 10:04022a61b527 7020
whismanoid 12:2dfc1f2009e0 7021 #if USE_LEDS
whismanoid 12:2dfc1f2009e0 7022 #if defined(TARGET_MAX32630)
whismanoid 12:2dfc1f2009e0 7023 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 7024 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7025 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 7026 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7027 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 7028 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7029 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 7030 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7031 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 7032 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7033 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 7034 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7035 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 7036 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7037 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 7038 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 19:5ff09c8e9daf 7039 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 12:2dfc1f2009e0 7040 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 7041 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7042 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 7043 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7044 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 7045 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7046 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 7047 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7048 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 7049 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7050 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 7051 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7052 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 7053 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7054 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 7055 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 7056 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 12:2dfc1f2009e0 7057 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 7058 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7059 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7060 led4 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7061 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7062 //led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 7063 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 7064 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7065 led1 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7066 //led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 7067 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 7068 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7069 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7070 //led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 7071 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 7072 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 7073 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 7074 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 7075 //
whismanoid 12:2dfc1f2009e0 7076 #endif // target definition
whismanoid 12:2dfc1f2009e0 7077 #endif
whismanoid 12:2dfc1f2009e0 7078
whismanoid 12:2dfc1f2009e0 7079 if (led1.is_connected()) {
whismanoid 12:2dfc1f2009e0 7080 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 7081 }
whismanoid 12:2dfc1f2009e0 7082 if (led2.is_connected()) {
whismanoid 12:2dfc1f2009e0 7083 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 7084 }
whismanoid 12:2dfc1f2009e0 7085 if (led3.is_connected()) {
whismanoid 12:2dfc1f2009e0 7086 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 7087 }
whismanoid 12:2dfc1f2009e0 7088
whismanoid 4:d9b05924ad4c 7089 while(1) { // this code repeats forever
whismanoid 4:d9b05924ad4c 7090 // this code repeats forever
whismanoid 4:d9b05924ad4c 7091
whismanoid 21:ac062a97a71d 7092 #if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 7093 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 7094 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 7095 # if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 7096 static int button1_value_prev = 1;
whismanoid 21:ac062a97a71d 7097 static int button1_value_now = 1;
whismanoid 21:ac062a97a71d 7098 button1_value_prev = button1_value_now;
whismanoid 21:ac062a97a71d 7099 button1_value_now = button1.read();
whismanoid 21:ac062a97a71d 7100 if ((button1_value_prev - button1_value_now) == 1)
whismanoid 21:ac062a97a71d 7101 {
whismanoid 21:ac062a97a71d 7102 // on button1 falling edge (button1 press)
whismanoid 21:ac062a97a71d 7103 onButton1FallingEdge();
whismanoid 21:ac062a97a71d 7104 }
whismanoid 21:ac062a97a71d 7105 # endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7106 # if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7107 static int button2_value_prev = 1;
whismanoid 24:032f3683cb2a 7108 static int button2_value_now = 1;
whismanoid 24:032f3683cb2a 7109 button2_value_prev = button2_value_now;
whismanoid 24:032f3683cb2a 7110 button2_value_now = button2.read();
whismanoid 24:032f3683cb2a 7111 if ((button2_value_prev - button2_value_now) == 1)
whismanoid 24:032f3683cb2a 7112 {
whismanoid 24:032f3683cb2a 7113 // on button2 falling edge (button2 press)
whismanoid 24:032f3683cb2a 7114 onButton2FallingEdge();
whismanoid 24:032f3683cb2a 7115 }
whismanoid 24:032f3683cb2a 7116 # endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7117 # if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 7118 static int button3_value_prev = 1;
whismanoid 24:032f3683cb2a 7119 static int button3_value_now = 1;
whismanoid 24:032f3683cb2a 7120 button3_value_prev = button3_value_now;
whismanoid 24:032f3683cb2a 7121 button3_value_now = button3.read();
whismanoid 24:032f3683cb2a 7122 if ((button3_value_prev - button3_value_now) == 1)
whismanoid 24:032f3683cb2a 7123 {
whismanoid 24:032f3683cb2a 7124 // on button3 falling edge (button3 press)
whismanoid 26:13cba69d88eb 7125 onButton3FallingEdge();
whismanoid 24:032f3683cb2a 7126 }
whismanoid 24:032f3683cb2a 7127 # endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 7128 #endif // HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 4:d9b05924ad4c 7129 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 7130 // TODO support CmdLine command menus (like on Serial_Tester); help and usual boilerplate
whismanoid 10:04022a61b527 7131 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 7132 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 7133 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 7134 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 7135 // Accept commands from Auxiliary serial port
whismanoid 6:f6d16658342b 7136 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 7137 if (AUXserial.readable()) {
whismanoid 6:f6d16658342b 7138 cmdLine_AUXserial.append(AUXserial.getc());
whismanoid 6:f6d16658342b 7139 }
whismanoid 6:f6d16658342b 7140 # endif // HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 7141 # if HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 7142 if (DAPLINKserial.readable()) {
whismanoid 6:f6d16658342b 7143 cmdLine_DAPLINKserial.append(DAPLINKserial.getc());
whismanoid 6:f6d16658342b 7144 }
whismanoid 6:f6d16658342b 7145 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 7146 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 7147 if (serial.readable()) {
whismanoid 4:d9b05924ad4c 7148 int c = serial.getc(); // instead of getc() or fgetc()
whismanoid 4:d9b05924ad4c 7149 cmdLine.append(c);
whismanoid 4:d9b05924ad4c 7150 // cmdLine.onEOLcommandParser handler implements menus
whismanoid 4:d9b05924ad4c 7151 } // if (Serial.available())
whismanoid 4:d9b05924ad4c 7152 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 7153
whismanoid 4:d9b05924ad4c 7154 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 32:80f3e5eb77d4 7155 // Datalog trigger
whismanoid 4:d9b05924ad4c 7156 if (Datalogger_Trigger == trigger_Halt) {
whismanoid 4:d9b05924ad4c 7157 // halt the datalogger; continue accepting commands
whismanoid 3:9055e17e181a 7158 continue;
whismanoid 3:9055e17e181a 7159 }
whismanoid 4:d9b05924ad4c 7160 if (Datalogger_Trigger == trigger_FreeRun) {
whismanoid 4:d9b05924ad4c 7161 // free run as fast as possible
whismanoid 3:9055e17e181a 7162 }
whismanoid 4:d9b05924ad4c 7163 if (Datalogger_Trigger == trigger_Timer) {
whismanoid 4:d9b05924ad4c 7164 // timer (configure interval)
whismanoid 32:80f3e5eb77d4 7165 // if Datalogger_Trigger == trigger_Timer sleep(g_timer_interval_msec)
whismanoid 39:4d285e961435 7166 //
whismanoid 39:4d285e961435 7167 #if USE_DATALOGGER_SLEEP // support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 7168 // TODO: USE_DATALOGGER_SLEEP -- support sleep modes in Datalogger_Trigger
whismanoid 39:4d285e961435 7169 // TODO: Sleep Mode vs Deep Sleep Mode
whismanoid 39:4d285e961435 7170 // See documentation https://os.mbed.com/docs/mbed-os/v5.15/apis/power-management-sleep.html
whismanoid 41:13a6a097502c 7171 // ThisThread::sleep_for(uint32_t millisec)
whismanoid 41:13a6a097502c 7172 // sleep_manager_can_deep_sleep() // tests whether deep_sleep is locked or not
whismanoid 41:13a6a097502c 7173 // sleep_manager_lock_deep_sleep() // begin section that prevents deep_sleep
whismanoid 41:13a6a097502c 7174 // sleep_manager_unlock_deep_sleep() // end section that prevents deep_sleep
whismanoid 39:4d285e961435 7175 switch(g_timer_sleepmode)
whismanoid 39:4d285e961435 7176 {
whismanoid 39:4d285e961435 7177 case datalogger_Sleep_LP0_Stop: // LT sleep = 0,
whismanoid 39:4d285e961435 7178 break;
whismanoid 39:4d285e961435 7179 case datalogger_Sleep_LP1_DeepSleep: // LT sleep = 1,
whismanoid 41:13a6a097502c 7180 // sleep_manager_can_deep_sleep(); // tests whether deep_sleep is locked or not
whismanoid 41:13a6a097502c 7181 // TODO: USE_DATALOGGER_SLEEP -- ThisThread::sleep_for(uint32_t millisec) instead of wait_ms(g_timer_interval_msec)
whismanoid 41:13a6a097502c 7182 // mbed_file_handle(STDIN_FILENO)->enable_input(false); // (mbed-os-5.15) platform.stdio-buffered-serial prevents deep sleep
whismanoid 41:13a6a097502c 7183 cmdLine.serial().enable_input(false); // (mbed-os-5.15) platform.stdio-buffered-serial prevents deep sleep
whismanoid 41:13a6a097502c 7184 // serial.enable_input(false); // (mbed-os-5.15) platform.stdio-buffered-serial prevents deep sleep
whismanoid 41:13a6a097502c 7185 ThisThread::sleep_for(g_timer_interval_msec); // wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 41:13a6a097502c 7186 // mbed_file_handle(STDIN_FILENO)->enable_input(true); // (mbed-os-5.15)
whismanoid 41:13a6a097502c 7187 cmdLine.serial().enable_input(true); // (mbed-os-5.15)
whismanoid 41:13a6a097502c 7188 // serial.enable_input(true); // (mbed-os-5.15)
whismanoid 39:4d285e961435 7189 break;
whismanoid 39:4d285e961435 7190 case datalogger_Sleep_LP2_Sleep: // LT sleep = 2,
whismanoid 41:13a6a097502c 7191 sleep_manager_lock_deep_sleep(); // begin section that prevents deep_sleep
whismanoid 41:13a6a097502c 7192 // TODO: USE_DATALOGGER_SLEEP -- ThisThread::sleep_for(uint32_t millisec) instead of wait_ms(g_timer_interval_msec)
whismanoid 41:13a6a097502c 7193 ThisThread::sleep_for(g_timer_interval_msec); // wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 41:13a6a097502c 7194 sleep_manager_unlock_deep_sleep(); // end section that prevents deep_sleep
whismanoid 39:4d285e961435 7195 break;
whismanoid 39:4d285e961435 7196 case datalogger_Sleep_LP3_Run: // LT sleep = 3,
whismanoid 41:13a6a097502c 7197 // TODO: USE_DATALOGGER_SLEEP -- ThisThread::sleep_for(uint32_t millisec) instead of wait_ms(g_timer_interval_msec)
whismanoid 41:13a6a097502c 7198 wait_ms(g_timer_interval_msec);
whismanoid 39:4d285e961435 7199 break;
whismanoid 39:4d285e961435 7200 }
whismanoid 39:4d285e961435 7201 #else // USE_DATALOGGER_SLEEP
whismanoid 17:9397ea3ea7e9 7202 wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 39:4d285e961435 7203 #endif // USE_DATALOGGER_SLEEP
whismanoid 39:4d285e961435 7204 //
whismanoid 17:9397ea3ea7e9 7205 if (g_timer_interval_counter > 0) {
whismanoid 17:9397ea3ea7e9 7206 g_timer_interval_counter--;
whismanoid 17:9397ea3ea7e9 7207 continue;
whismanoid 17:9397ea3ea7e9 7208 }
whismanoid 17:9397ea3ea7e9 7209 // if time interval not yet reached, continue (continue accepting commands)
whismanoid 32:80f3e5eb77d4 7210 g_timer_interval_counter = g_timer_interval_count-1;
whismanoid 3:9055e17e181a 7211 }
whismanoid 4:d9b05924ad4c 7212 if (Datalogger_Trigger == trigger_PlatformDigitalInput) {
whismanoid 4:d9b05924ad4c 7213 // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 7214 // TODO: read selected input pin, test value
whismanoid 17:9397ea3ea7e9 7215 // TODO: if no match, continue (continue accepting commands)
whismanoid 3:9055e17e181a 7216 }
whismanoid 4:d9b05924ad4c 7217 if (Datalogger_Trigger == trigger_SPIDeviceRegRead) {
whismanoid 4:d9b05924ad4c 7218 // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 7219 // TODO: SPI transfer regAddr
whismanoid 17:9397ea3ea7e9 7220 // TODO: apply dataMask, compare with testValue
whismanoid 17:9397ea3ea7e9 7221 // TODO: if no match, continue (continue accepting commands)
whismanoid 4:d9b05924ad4c 7222 }
whismanoid 4:d9b05924ad4c 7223 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 0:cb44e2e9ec4c 7224
whismanoid 8:dffee7509bfb 7225 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 7226 if (Datalogger_Need_PrintHeader) {
whismanoid 8:dffee7509bfb 7227 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 7228 Datalogger_PrintHeader(cmdLine);
whismanoid 8:dffee7509bfb 7229 }
whismanoid 8:dffee7509bfb 7230 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 7231 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 7232 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 7233 }
whismanoid 8:dffee7509bfb 7234 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 7235 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 7236 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 7237 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 7238 }
whismanoid 8:dffee7509bfb 7239 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 7240 Datalogger_Need_PrintHeader = false;
whismanoid 8:dffee7509bfb 7241 }
whismanoid 5:aaf8b5f5fda1 7242 Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 7243 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 7244 // Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 7245 Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 7246 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 0:cb44e2e9ec4c 7247 // wait(3.0);
whismanoid 0:cb44e2e9ec4c 7248 // CODE GENERATOR: print conversion result
whismanoid 0:cb44e2e9ec4c 7249 // Use Arduino Serial Plotter to view output: Tools | Serial Plotter
whismanoid 8:dffee7509bfb 7250 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 7251 Datalogger_PrintRow(cmdLine);
whismanoid 8:dffee7509bfb 7252 }
whismanoid 8:dffee7509bfb 7253 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 7254 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 7255 Datalogger_PrintRow(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 7256 }
whismanoid 8:dffee7509bfb 7257 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 7258 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 7259 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 7260 Datalogger_PrintRow(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 7261 }
whismanoid 8:dffee7509bfb 7262 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:cb44e2e9ec4c 7263
whismanoid 0:cb44e2e9ec4c 7264 } // this code repeats forever
whismanoid 0:cb44e2e9ec4c 7265 }
whismanoid 0:cb44e2e9ec4c 7266 //---------- CODE GENERATOR: end DataLogHelloCppCodeList