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

Dependencies:   max32625pico CmdLine

Committer:
whismanoid
Date:
Fri Apr 30 15:03:52 2021 -0700
Revision:
34:a1993a1ee904
Parent:
33:70a28cfe9e01
Child:
35:c9549b5c01de
%A v0cal=1.000V -- calibrate channel against a known input voltage

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 0:cb44e2e9ec4c 82 //---------- CODE GENERATOR: DataLogHelloCppCodeList
whismanoid 0:cb44e2e9ec4c 83 // CODE GENERATOR: example code includes
whismanoid 0:cb44e2e9ec4c 84
whismanoid 0:cb44e2e9ec4c 85 // example code includes
whismanoid 0:cb44e2e9ec4c 86 // standard include for target platform -- Platform_Include_Boilerplate
whismanoid 0:cb44e2e9ec4c 87 #include "mbed.h"
whismanoid 0:cb44e2e9ec4c 88 // Platforms:
whismanoid 0:cb44e2e9ec4c 89 // - MAX32625MBED
whismanoid 0:cb44e2e9ec4c 90 // - supports mbed-os-5.11, requires USBDevice library
whismanoid 0:cb44e2e9ec4c 91 // - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
whismanoid 0:cb44e2e9ec4c 92 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 93 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 94 // - MAX32600MBED
whismanoid 7:949ec8581f5e 95 // - Please note the last supported version is Mbed OS 6.3.
whismanoid 0:cb44e2e9ec4c 96 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 97 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 98 // - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board.
whismanoid 0:cb44e2e9ec4c 99 // - NUCLEO_F446RE
whismanoid 0:cb44e2e9ec4c 100 // - remove USBDevice library
whismanoid 0:cb44e2e9ec4c 101 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 102 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 103 // - NUCLEO_F401RE
whismanoid 0:cb44e2e9ec4c 104 // - remove USBDevice library
whismanoid 0:cb44e2e9ec4c 105 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 106 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 107 // - MAX32630FTHR
whismanoid 0:cb44e2e9ec4c 108 // - #include "max32630fthr.h"
whismanoid 7:949ec8581f5e 109 // - add http://developer.mbed.org/teams/MaximIntegrated/code/max32630fthr/
whismanoid 0:cb44e2e9ec4c 110 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 111 // - MAX32620FTHR
whismanoid 0:cb44e2e9ec4c 112 // - #include "MAX32620FTHR.h"
whismanoid 0:cb44e2e9ec4c 113 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 114 // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
whismanoid 0:cb44e2e9ec4c 115 // - not tested yet
whismanoid 0:cb44e2e9ec4c 116 // - MAX32625PICO
whismanoid 0:cb44e2e9ec4c 117 // - #include "max32625pico.h"
whismanoid 0:cb44e2e9ec4c 118 // - add https://os.mbed.com/users/switches/code/max32625pico/
whismanoid 0:cb44e2e9ec4c 119 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 120 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 121 // - not tested yet
whismanoid 0:cb44e2e9ec4c 122 // - see https://os.mbed.com/users/switches/code/max32625pico/
whismanoid 0:cb44e2e9ec4c 123 // - see https://os.mbed.com/users/switches/code/PICO_board_demo/
whismanoid 0:cb44e2e9ec4c 124 // - see https://os.mbed.com/users/switches/code/PICO_USB_I2C_SPI/
whismanoid 0:cb44e2e9ec4c 125 // - see https://os.mbed.com/users/switches/code/SerialInterface/
whismanoid 0:cb44e2e9ec4c 126 // - Note: To load the MAX32625PICO firmware, hold the button while
whismanoid 0:cb44e2e9ec4c 127 // connecting the USB cable, then copy firmware bin file
whismanoid 0:cb44e2e9ec4c 128 // to the MAINTENANCE drive.
whismanoid 0:cb44e2e9ec4c 129 // - see https://os.mbed.com/platforms/MAX32625PICO/
whismanoid 0:cb44e2e9ec4c 130 // - see https://os.mbed.com/teams/MaximIntegrated/wiki/MAX32625PICO-Firmware-Updates
whismanoid 0:cb44e2e9ec4c 131 //
whismanoid 0:cb44e2e9ec4c 132 // end Platform_Include_Boilerplate
whismanoid 0:cb44e2e9ec4c 133
whismanoid 0:cb44e2e9ec4c 134 //--------------------------------------------------
whismanoid 3:9055e17e181a 135 // Option to use SPI connected ADC
whismanoid 3:9055e17e181a 136 #ifndef SPI_ADC_DeviceName
whismanoid 9:45f98573eb6d 137 #define SPI_ADC_DeviceName MAX11410
whismanoid 3:9055e17e181a 138 #undef SPI_ADC_DeviceName
whismanoid 3:9055e17e181a 139 #endif
whismanoid 3:9055e17e181a 140 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 141 #include "MAX11410.h"
whismanoid 3:9055e17e181a 142 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 143
whismanoid 0:cb44e2e9ec4c 144 #if defined(TARGET)
whismanoid 0:cb44e2e9ec4c 145 // TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h
whismanoid 0:cb44e2e9ec4c 146 // Create a string definition for the TARGET
whismanoid 0:cb44e2e9ec4c 147 #define STRING_ARG(arg) #arg
whismanoid 0:cb44e2e9ec4c 148 #define STRING_NAME(name) STRING_ARG(name)
whismanoid 0:cb44e2e9ec4c 149 #define TARGET_NAME STRING_NAME(TARGET)
whismanoid 0:cb44e2e9ec4c 150 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 151 #define TARGET_NAME "MAX32600"
whismanoid 0:cb44e2e9ec4c 152 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 153 #define TARGET_NAME "LPC1768"
whismanoid 0:cb44e2e9ec4c 154 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 155 #define TARGET_NAME "NUCLEO_F446RE"
whismanoid 0:cb44e2e9ec4c 156 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 157 #define TARGET_NAME "NUCLEO_F401RE"
whismanoid 0:cb44e2e9ec4c 158 #else
whismanoid 0:cb44e2e9ec4c 159 #error TARGET NOT DEFINED
whismanoid 0:cb44e2e9ec4c 160 #endif
whismanoid 0:cb44e2e9ec4c 161 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 162 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 163 // TARGET=MAX32630FTHR ARM Cortex-M4F 96MHz 2048kB Flash 512kB SRAM
whismanoid 0:cb44e2e9ec4c 164 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 165 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 166 // ______ | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 167 // ______ | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 168 // ______ | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 169 // ______ | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 170 // analogIn0/4 | [a] AIN_0 1.2Vfs (bat) SYS [ ] | switched BAT+
whismanoid 0:cb44e2e9ec4c 171 // analogIn1/5 | [a] AIN_1 1.2Vfs PWR [ ] | external pwr btn
whismanoid 0:cb44e2e9ec4c 172 // analogIn2 | [a] AIN_2 1.2Vfs +5V VBUS [ ] | USB +5V power
whismanoid 0:cb44e2e9ec4c 173 // analogIn3 | [a] AIN_3 1.2Vfs 1-WIRE P4_0 [d] | D0 dig9
whismanoid 0:cb44e2e9ec4c 174 // (I2C2.SDA) | [d] P5_7 SDA2 SRN P5_6 [d] | D1 dig8
whismanoid 0:cb44e2e9ec4c 175 // (I2C2.SCL) | [d] P6_0 SCL2 SDIO3 P5_5 [d] | D2 dig7
whismanoid 0:cb44e2e9ec4c 176 // D13/SCLK | [s] P5_0 SCLK SDIO2 P5_4 [d] | D3 dig6
whismanoid 0:cb44e2e9ec4c 177 // D11/MOSI | [s] P5_1 MOSI SSEL P5_3 [d] | D4 dig5
whismanoid 0:cb44e2e9ec4c 178 // D12/MISO | [s] P5_2 MISO RTS P3_3 [d] | D5 dig4
whismanoid 0:cb44e2e9ec4c 179 // D10/CS | [s] P3_0 RX CTS P3_2 [d] | D6 dig3
whismanoid 0:cb44e2e9ec4c 180 // D9 dig0 | [d] P3_1 TX SCL P3_5 [d] | D7 dig2
whismanoid 0:cb44e2e9ec4c 181 // ______ | [ ] GND SDA P3_4 [d] | D8 dig1
whismanoid 0:cb44e2e9ec4c 182 // | |
whismanoid 0:cb44e2e9ec4c 183 // | XIP Flash MAX14690N |
whismanoid 0:cb44e2e9ec4c 184 // | XIP_SCLK P1_0 SDA2 P5_7 |
whismanoid 0:cb44e2e9ec4c 185 // | XIP_MOSI P1_1 SCL2 P6_0 |
whismanoid 0:cb44e2e9ec4c 186 // | XIP_MISO P1_2 PMIC_INIT P3_7 |
whismanoid 0:cb44e2e9ec4c 187 // | XIP_SSEL P1_3 MPC P2_7 |
whismanoid 0:cb44e2e9ec4c 188 // | XIP_DIO2 P1_4 MON AIN_0 |
whismanoid 0:cb44e2e9ec4c 189 // | XIP_DIO3 P1_5 |
whismanoid 0:cb44e2e9ec4c 190 // | |
whismanoid 0:cb44e2e9ec4c 191 // | PAN1326B MicroSD LED |
whismanoid 0:cb44e2e9ec4c 192 // | BT_RX P0_0 SD_SCLK P0_4 r P2_4 |
whismanoid 0:cb44e2e9ec4c 193 // | BT_TX P0_1 SD_MOSI P0_5 g P2_5 |
whismanoid 0:cb44e2e9ec4c 194 // | BT_CTS P0_2 SD_MISO P0_6 b P2_6 |
whismanoid 0:cb44e2e9ec4c 195 // | BT_RTS P0_3 SD_SSEL P0_7 |
whismanoid 0:cb44e2e9ec4c 196 // | BT_RST P1_6 DETECT P2_2 |
whismanoid 0:cb44e2e9ec4c 197 // | BT_CLK P1_7 SW2 P2_3 |
whismanoid 0:cb44e2e9ec4c 198 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 199 // 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 200 // 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 201 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 202 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 203 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 204 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 205 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 206 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 207 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 208 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 209 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 210 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 211 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 212 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 213 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 214 //
whismanoid 0:cb44e2e9ec4c 215 #include "max32630fthr.h"
whismanoid 0:cb44e2e9ec4c 216 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 217 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 218 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 219 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 220 // Arduino connector
whismanoid 0:cb44e2e9ec4c 221 #ifndef A0
whismanoid 0:cb44e2e9ec4c 222 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 223 #endif
whismanoid 0:cb44e2e9ec4c 224 #ifndef A1
whismanoid 0:cb44e2e9ec4c 225 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 226 #endif
whismanoid 0:cb44e2e9ec4c 227 #ifndef A2
whismanoid 0:cb44e2e9ec4c 228 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 229 #endif
whismanoid 0:cb44e2e9ec4c 230 #ifndef A3
whismanoid 0:cb44e2e9ec4c 231 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 232 #endif
whismanoid 0:cb44e2e9ec4c 233 #ifndef D0
whismanoid 0:cb44e2e9ec4c 234 #define D0 P4_0
whismanoid 0:cb44e2e9ec4c 235 #endif
whismanoid 0:cb44e2e9ec4c 236 #ifndef D1
whismanoid 0:cb44e2e9ec4c 237 #define D1 P5_6
whismanoid 0:cb44e2e9ec4c 238 #endif
whismanoid 0:cb44e2e9ec4c 239 #ifndef D2
whismanoid 0:cb44e2e9ec4c 240 #define D2 P5_5
whismanoid 0:cb44e2e9ec4c 241 #endif
whismanoid 0:cb44e2e9ec4c 242 #ifndef D3
whismanoid 0:cb44e2e9ec4c 243 #define D3 P5_4
whismanoid 0:cb44e2e9ec4c 244 #endif
whismanoid 0:cb44e2e9ec4c 245 #ifndef D4
whismanoid 0:cb44e2e9ec4c 246 #define D4 P5_3
whismanoid 0:cb44e2e9ec4c 247 #endif
whismanoid 0:cb44e2e9ec4c 248 #ifndef D5
whismanoid 0:cb44e2e9ec4c 249 #define D5 P3_3
whismanoid 0:cb44e2e9ec4c 250 #endif
whismanoid 0:cb44e2e9ec4c 251 #ifndef D6
whismanoid 0:cb44e2e9ec4c 252 #define D6 P3_2
whismanoid 0:cb44e2e9ec4c 253 #endif
whismanoid 0:cb44e2e9ec4c 254 #ifndef D7
whismanoid 0:cb44e2e9ec4c 255 #define D7 P3_5
whismanoid 0:cb44e2e9ec4c 256 #endif
whismanoid 0:cb44e2e9ec4c 257 #ifndef D8
whismanoid 0:cb44e2e9ec4c 258 #define D8 P3_4
whismanoid 0:cb44e2e9ec4c 259 #endif
whismanoid 0:cb44e2e9ec4c 260 #ifndef D9
whismanoid 0:cb44e2e9ec4c 261 #define D9 P3_1
whismanoid 0:cb44e2e9ec4c 262 #endif
whismanoid 0:cb44e2e9ec4c 263 #ifndef D10
whismanoid 0:cb44e2e9ec4c 264 #define D10 P3_0
whismanoid 0:cb44e2e9ec4c 265 #endif
whismanoid 0:cb44e2e9ec4c 266 #ifndef D11
whismanoid 0:cb44e2e9ec4c 267 #define D11 P5_1
whismanoid 0:cb44e2e9ec4c 268 #endif
whismanoid 0:cb44e2e9ec4c 269 #ifndef D12
whismanoid 0:cb44e2e9ec4c 270 #define D12 P5_2
whismanoid 0:cb44e2e9ec4c 271 #endif
whismanoid 0:cb44e2e9ec4c 272 #ifndef D13
whismanoid 0:cb44e2e9ec4c 273 #define D13 P5_0
whismanoid 0:cb44e2e9ec4c 274 #endif
whismanoid 0:cb44e2e9ec4c 275 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 276 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 277 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 278 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 279 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 280 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 281 // | |
whismanoid 0:cb44e2e9ec4c 282 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 283 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 284 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 285 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 286 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 287 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 288 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 289 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 290 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 291 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 292 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 293 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 294 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 295 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 296 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 297 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 298 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 299 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 300 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 301 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 302 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 303 // \_______________________/
whismanoid 0:cb44e2e9ec4c 304 //
whismanoid 0:cb44e2e9ec4c 305 // +------------------------+
whismanoid 0:cb44e2e9ec4c 306 // | |
whismanoid 0:cb44e2e9ec4c 307 // | MicroSD LED |
whismanoid 0:cb44e2e9ec4c 308 // | SD_SCLK P2_4 r P3_0 |
whismanoid 0:cb44e2e9ec4c 309 // | SD_MOSI P2_5 g P3_1 |
whismanoid 0:cb44e2e9ec4c 310 // | SD_MISO P2_6 b P3_2 |
whismanoid 0:cb44e2e9ec4c 311 // | SD_SSEL P2_7 y P3_3 |
whismanoid 0:cb44e2e9ec4c 312 // | |
whismanoid 0:cb44e2e9ec4c 313 // | DAPLINK BUTTONS |
whismanoid 0:cb44e2e9ec4c 314 // | TX P2_1 SW3 P2_3 |
whismanoid 0:cb44e2e9ec4c 315 // | RX P2_0 SW2 P2_2 |
whismanoid 0:cb44e2e9ec4c 316 // +------------------------+
whismanoid 0:cb44e2e9ec4c 317 //
whismanoid 0:cb44e2e9ec4c 318 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 319 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 320 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 321 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 322 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 323 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 324 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 325 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 326 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 327 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 328 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 329 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 330 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 331 //
whismanoid 0:cb44e2e9ec4c 332 //#include "max32625mbed.h" // ?
whismanoid 0:cb44e2e9ec4c 333 //MAX32625MBED mbed(MAX32625MBED::VIO_3V3); // ?
whismanoid 0:cb44e2e9ec4c 334 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 335 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 336 const float ADC_FULL_SCALE_VOLTAGE = 1.200; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 337 // Arduino connector
whismanoid 0:cb44e2e9ec4c 338 #ifndef A0
whismanoid 0:cb44e2e9ec4c 339 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 340 #endif
whismanoid 0:cb44e2e9ec4c 341 #ifndef A1
whismanoid 0:cb44e2e9ec4c 342 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 343 #endif
whismanoid 0:cb44e2e9ec4c 344 #ifndef A2
whismanoid 0:cb44e2e9ec4c 345 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 346 #endif
whismanoid 0:cb44e2e9ec4c 347 #ifndef A3
whismanoid 0:cb44e2e9ec4c 348 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 349 #endif
whismanoid 0:cb44e2e9ec4c 350 #ifndef D0
whismanoid 0:cb44e2e9ec4c 351 #define D0 P0_0
whismanoid 0:cb44e2e9ec4c 352 #endif
whismanoid 0:cb44e2e9ec4c 353 #ifndef D1
whismanoid 0:cb44e2e9ec4c 354 #define D1 P0_1
whismanoid 0:cb44e2e9ec4c 355 #endif
whismanoid 0:cb44e2e9ec4c 356 #ifndef D2
whismanoid 0:cb44e2e9ec4c 357 #define D2 P0_2
whismanoid 0:cb44e2e9ec4c 358 #endif
whismanoid 0:cb44e2e9ec4c 359 #ifndef D3
whismanoid 0:cb44e2e9ec4c 360 #define D3 P0_3
whismanoid 0:cb44e2e9ec4c 361 #endif
whismanoid 0:cb44e2e9ec4c 362 #ifndef D4
whismanoid 0:cb44e2e9ec4c 363 #define D4 P0_4
whismanoid 0:cb44e2e9ec4c 364 #endif
whismanoid 0:cb44e2e9ec4c 365 #ifndef D5
whismanoid 0:cb44e2e9ec4c 366 #define D5 P0_5
whismanoid 0:cb44e2e9ec4c 367 #endif
whismanoid 0:cb44e2e9ec4c 368 #ifndef D6
whismanoid 0:cb44e2e9ec4c 369 #define D6 P0_6
whismanoid 0:cb44e2e9ec4c 370 #endif
whismanoid 0:cb44e2e9ec4c 371 #ifndef D7
whismanoid 0:cb44e2e9ec4c 372 #define D7 P0_7
whismanoid 0:cb44e2e9ec4c 373 #endif
whismanoid 0:cb44e2e9ec4c 374 #ifndef D8
whismanoid 0:cb44e2e9ec4c 375 #define D8 P1_4
whismanoid 0:cb44e2e9ec4c 376 #endif
whismanoid 0:cb44e2e9ec4c 377 #ifndef D9
whismanoid 0:cb44e2e9ec4c 378 #define D9 P1_5
whismanoid 0:cb44e2e9ec4c 379 #endif
whismanoid 0:cb44e2e9ec4c 380 #ifndef D10
whismanoid 0:cb44e2e9ec4c 381 #define D10 P1_3
whismanoid 0:cb44e2e9ec4c 382 #endif
whismanoid 0:cb44e2e9ec4c 383 #ifndef D11
whismanoid 0:cb44e2e9ec4c 384 #define D11 P1_1
whismanoid 0:cb44e2e9ec4c 385 #endif
whismanoid 0:cb44e2e9ec4c 386 #ifndef D12
whismanoid 0:cb44e2e9ec4c 387 #define D12 P1_2
whismanoid 0:cb44e2e9ec4c 388 #endif
whismanoid 0:cb44e2e9ec4c 389 #ifndef D13
whismanoid 0:cb44e2e9ec4c 390 #define D13 P1_0
whismanoid 0:cb44e2e9ec4c 391 #endif
whismanoid 0:cb44e2e9ec4c 392 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 393 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 394 // target MAX32600
whismanoid 0:cb44e2e9ec4c 395 //
whismanoid 0:cb44e2e9ec4c 396 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 397 const float ADC_FULL_SCALE_VOLTAGE = 1.500;
whismanoid 0:cb44e2e9ec4c 398 //
whismanoid 0:cb44e2e9ec4c 399 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 400 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 401 #warning "TARGET_MAX32620FTHR not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 402 #include "MAX32620FTHR.h"
whismanoid 0:cb44e2e9ec4c 403 // Initialize I/O voltages on MAX32620FTHR board
whismanoid 0:cb44e2e9ec4c 404 MAX32620FTHR fthr(MAX32620FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 405 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 406 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 407 #warning "TARGET_MAX32620FTHR not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 408 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 409 //
whismanoid 0:cb44e2e9ec4c 410 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 411 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 15:37c83ec50ea0 412 // #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 413 #include "max32625pico.h"
whismanoid 0:cb44e2e9ec4c 414 // configure MAX32625PICO VDDIOH mode, and I/O voltages for DIP pins and SWD pins
whismanoid 0:cb44e2e9ec4c 415 MAX32625PICO pico(
whismanoid 13:184a08909405 416 // Select source of higher-voltage logic high supply VDDIOH
whismanoid 0:cb44e2e9ec4c 417 // vddioh_mode_t iohMode
whismanoid 0:cb44e2e9ec4c 418 //~ MAX32625PICO::IOH_OFF, // No connections to VDDIOH
whismanoid 0:cb44e2e9ec4c 419 //~ MAX32625PICO::IOH_DIP_IN, // VDDIOH input from DIP pin 1 (AIN0)
whismanoid 0:cb44e2e9ec4c 420 //~ MAX32625PICO::IOH_SWD_IN, // VDDIOH input from SWD pin 1
whismanoid 0:cb44e2e9ec4c 421 MAX32625PICO::IOH_3V3, // VDDIOH = 3.3V from local supply
whismanoid 0:cb44e2e9ec4c 422 //~ MAX32625PICO::IOH_DIP_OUT, // VDDIOH = 3.3V output to DIP pin 1
whismanoid 0:cb44e2e9ec4c 423 //~ MAX32625PICO::IOH_SWD_OUT, // VDDIOH = 3.3V output to SWD pin 1
whismanoid 0:cb44e2e9ec4c 424 //
whismanoid 13:184a08909405 425 // Digital I/O pin logic high voltage 1.8V or 3.3V
whismanoid 0:cb44e2e9ec4c 426 // vio_t dipVio = MAX32625PICO::VIO_1V8 or MAX32625PICO::VIO_IOH
whismanoid 13:184a08909405 427 MAX32625PICO::VIO_1V8, // 1.8V IO (local)
whismanoid 13:184a08909405 428 //~ MAX32625PICO::VIO_IOH, // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 429 //
whismanoid 13:184a08909405 430 // Software Debug logic high voltage (normally use VIO_IOH)
whismanoid 0:cb44e2e9ec4c 431 // vio_t swdVio
whismanoid 0:cb44e2e9ec4c 432 //~ MAX32625PICO::VIO_1V8 // 1.8V IO (local)
whismanoid 0:cb44e2e9ec4c 433 MAX32625PICO::VIO_IOH // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 434 );
whismanoid 0:cb44e2e9ec4c 435 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 436 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 15:37c83ec50ea0 437 // #warning "TARGET_MAX32625PICO not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 438 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 439 //
whismanoid 0:cb44e2e9ec4c 440 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 441 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 442 // TODO1: target NUCLEO_F446RE
whismanoid 0:cb44e2e9ec4c 443 //
whismanoid 0:cb44e2e9ec4c 444 // USER_BUTTON PC13
whismanoid 0:cb44e2e9ec4c 445 // LED1 is shared with SPI_SCK on NUCLEO_F446RE PA_5, so don't use LED1.
whismanoid 0:cb44e2e9ec4c 446 #define USE_LEDS 0
whismanoid 0:cb44e2e9ec4c 447 // SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
whismanoid 0:cb44e2e9ec4c 448 // Serial serial(SERIAL_TX, SERIAL_RX);
whismanoid 0:cb44e2e9ec4c 449 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 450 const float ADC_FULL_SCALE_VOLTAGE = 3.300; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 451 //
whismanoid 0:cb44e2e9ec4c 452 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 453 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 454 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 455 // TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM
whismanoid 0:cb44e2e9ec4c 456 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 457 // ______ | [ ] GND +3.3V VOUT [ ] | ______
whismanoid 0:cb44e2e9ec4c 458 // ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | ______
whismanoid 0:cb44e2e9ec4c 459 // ______ | [ ] VB USB.IF- [ ] | ______
whismanoid 0:cb44e2e9ec4c 460 // ______ | [ ] nR USB.IF+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 461 // digitalInOut0 | [ ] p5 MOSI ETHERNET.RD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 462 // digitalInOut1 | [ ] p6 MISO ETHERNET.RD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 463 // digitalInOut2 | [ ] p7 SCLK ETHERNET.TD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 464 // digitalInOut3 | [ ] p8 ETHERNET.TD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 465 // digitalInOut4 | [ ] p9 TX SDA USB.D- [ ] | ______
whismanoid 0:cb44e2e9ec4c 466 // digitalInOut5 | [ ] p10 RX SCL USB.D+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 467 // digitalInOut6 | [ ] p11 MOSI CAN-RD p30 [ ] | digitalInOut13
whismanoid 0:cb44e2e9ec4c 468 // digitalInOut7 | [ ] p12 MISO CAN-TD p29 [ ] | digitalInOut12
whismanoid 0:cb44e2e9ec4c 469 // digitalInOut8 | [ ] p13 TX SCLK SDA TX p28 [ ] | digitalInOut11
whismanoid 0:cb44e2e9ec4c 470 // digitalInOut9 | [ ] p14 RX SCL RX p27 [ ] | digitalInOut10
whismanoid 0:cb44e2e9ec4c 471 // analogIn0 | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1
whismanoid 0:cb44e2e9ec4c 472 // analogIn1 | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2
whismanoid 0:cb44e2e9ec4c 473 // analogIn2 | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3
whismanoid 0:cb44e2e9ec4c 474 // analogIn3 | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4
whismanoid 0:cb44e2e9ec4c 475 // analogIn4 | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5
whismanoid 0:cb44e2e9ec4c 476 // analogIn5 | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6
whismanoid 0:cb44e2e9ec4c 477 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 478 // AIN6 = P0.3 = TGT_SBL_RXD?
whismanoid 0:cb44e2e9ec4c 479 // AIN7 = P0.2 = TGT_SBL_TXD?
whismanoid 0:cb44e2e9ec4c 480 //
whismanoid 0:cb44e2e9ec4c 481 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 482 // LPC1768 board uses VREF = 3.300V +A3,3V thru L1 to bypass capacitor C14
whismanoid 0:cb44e2e9ec4c 483 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 484 const float ADC_FULL_SCALE_VOLTAGE = 3.300;
whismanoid 0:cb44e2e9ec4c 485 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 0:cb44e2e9ec4c 486 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 487 // unknown target
whismanoid 0:cb44e2e9ec4c 488 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 489 #endif // target definition
whismanoid 0:cb44e2e9ec4c 490
whismanoid 0:cb44e2e9ec4c 491
whismanoid 0:cb44e2e9ec4c 492
whismanoid 0:cb44e2e9ec4c 493
whismanoid 18:1235c17b451e 494 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 495 // move definiton of USE_LEDS earlier than find_digitalInOutPin()
whismanoid 18:1235c17b451e 496 //--------------------------------------------------
whismanoid 18:1235c17b451e 497 // Option to use LEDs to show status
whismanoid 18:1235c17b451e 498 #ifndef USE_LEDS
whismanoid 18:1235c17b451e 499 #define USE_LEDS 1
whismanoid 18:1235c17b451e 500 #endif
whismanoid 18:1235c17b451e 501 #if USE_LEDS
whismanoid 18:1235c17b451e 502 #if defined(TARGET_MAX32630)
whismanoid 18:1235c17b451e 503 # define LED_ON 0
whismanoid 18:1235c17b451e 504 # define LED_OFF 1
whismanoid 18:1235c17b451e 505 //--------------------------------------------------
whismanoid 18:1235c17b451e 506 #elif defined(TARGET_MAX32625MBED)
whismanoid 18:1235c17b451e 507 # define LED_ON 0
whismanoid 18:1235c17b451e 508 # define LED_OFF 1
whismanoid 19:5ff09c8e9daf 509 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 18:1235c17b451e 510 # define LED_ON 0
whismanoid 18:1235c17b451e 511 # define LED_OFF 1
whismanoid 18:1235c17b451e 512 //--------------------------------------------------
whismanoid 18:1235c17b451e 513 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 18:1235c17b451e 514 #elif defined(TARGET_LPC1768)
whismanoid 18:1235c17b451e 515 # define LED_ON 1
whismanoid 18:1235c17b451e 516 # define LED_OFF 0
whismanoid 18:1235c17b451e 517 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 18:1235c17b451e 518 // USE_LEDS with some platform other than MAX32630, MAX32625MBED, LPC1768
whismanoid 18:1235c17b451e 519 // bugfix for MAX32600MBED LED blink pattern: check if LED_ON/LED_OFF already defined
whismanoid 18:1235c17b451e 520 # ifndef LED_ON
whismanoid 18:1235c17b451e 521 # define LED_ON 0
whismanoid 18:1235c17b451e 522 # endif
whismanoid 18:1235c17b451e 523 # ifndef LED_OFF
whismanoid 18:1235c17b451e 524 # define LED_OFF 1
whismanoid 18:1235c17b451e 525 # endif
whismanoid 18:1235c17b451e 526 //# define LED_ON 1
whismanoid 18:1235c17b451e 527 //# define LED_OFF 0
whismanoid 18:1235c17b451e 528 #endif // target definition
whismanoid 18:1235c17b451e 529 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 530 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 531 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 532 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 533 // change led1/2/3/4 from DigitalOut to DigitalInOut
whismanoid 18:1235c17b451e 534 DigitalInOut led1(LED1, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED1 = LED_RED
whismanoid 18:1235c17b451e 535 DigitalInOut led2(LED2, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN
whismanoid 18:1235c17b451e 536 DigitalInOut led3(LED3, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE
whismanoid 18:1235c17b451e 537 DigitalInOut led4(LED4, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 538 #else // USE_LEDS=0
whismanoid 18:1235c17b451e 539 // issue #41 support Nucleo_F446RE
whismanoid 18:1235c17b451e 540 // there are no LED indicators on the board, LED1 interferes with SPI;
whismanoid 18:1235c17b451e 541 // but we still need placeholders led1 led2 led3 led4.
whismanoid 18:1235c17b451e 542 // Declare DigitalInOut led1 led2 led3 led4 targeting safe pins.
whismanoid 18:1235c17b451e 543 // PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false
whismanoid 18:1235c17b451e 544 # define LED_ON 0
whismanoid 18:1235c17b451e 545 # define LED_OFF 1
whismanoid 18:1235c17b451e 546 // change led1/2/3/4 from DigitalOut to DigitalInOut
whismanoid 18:1235c17b451e 547 DigitalInOut led1(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 548 DigitalInOut led2(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 549 DigitalInOut led3(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 550 DigitalInOut led4(NC, PIN_INPUT, PullUp, LED_OFF);
whismanoid 18:1235c17b451e 551 #endif // USE_LEDS
whismanoid 18:1235c17b451e 552 #define led1_RFailLED led1
whismanoid 18:1235c17b451e 553 #define led2_GPassLED led2
whismanoid 18:1235c17b451e 554 #define led3_BBusyLED led3
whismanoid 18:1235c17b451e 555
whismanoid 21:ac062a97a71d 556 //--------------------------------------------------
whismanoid 21:ac062a97a71d 557 // use BUTTON1 trigger some action
whismanoid 21:ac062a97a71d 558 #if defined(TARGET_MAX32630)
whismanoid 21:ac062a97a71d 559 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 560 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 561 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 562 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 25:8a61cb34191d 563 // #warning "TARGET_MAX32625PICO not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 564 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 24:032f3683cb2a 565 #if MAX40108_DEMO
whismanoid 25:8a61cb34191d 566 #if HAS_I2C
whismanoid 25:8a61cb34191d 567 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 568 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 24:032f3683cb2a 569 #define BUTTON2 P3_7
whismanoid 25:8a61cb34191d 570 #else // HAS_I2C
whismanoid 25:8a61cb34191d 571 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 572 // 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 573 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 574 #define BUTTON2 P1_7
whismanoid 25:8a61cb34191d 575 #endif // HAS_I2C
whismanoid 24:032f3683cb2a 576 #define HAS_BUTTON2_DEMO 0
whismanoid 24:032f3683cb2a 577 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 25:8a61cb34191d 578 #if HAS_I2C
whismanoid 25:8a61cb34191d 579 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 580 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 24:032f3683cb2a 581 #define BUTTON3 P3_6
whismanoid 25:8a61cb34191d 582 #else // HAS_I2C
whismanoid 25:8a61cb34191d 583 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 584 // 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 585 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 586 #define BUTTON3 P1_6
whismanoid 25:8a61cb34191d 587 #endif // HAS_I2C
whismanoid 24:032f3683cb2a 588 #define HAS_BUTTON3_DEMO 0
whismanoid 24:032f3683cb2a 589 #define HAS_BUTTON3_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 590 // additional buttons are assigned to unused/unaccessible pins to avoid conflicts
whismanoid 29:6a9edb6e973b 591 // activate using %B4! or action_button pin=4
whismanoid 29:6a9edb6e973b 592 #define BUTTON4 P1_5
whismanoid 29:6a9edb6e973b 593 #define HAS_BUTTON4_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 594 #define BUTTON5 P1_4
whismanoid 29:6a9edb6e973b 595 #define HAS_BUTTON5_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 596 #define BUTTON6 P1_3
whismanoid 29:6a9edb6e973b 597 #define HAS_BUTTON6_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 598 #define BUTTON7 P1_2
whismanoid 29:6a9edb6e973b 599 #define HAS_BUTTON7_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 600 #define BUTTON8 P1_1
whismanoid 29:6a9edb6e973b 601 #define HAS_BUTTON8_DEMO_INTERRUPT 1
whismanoid 29:6a9edb6e973b 602 #define BUTTON9 P1_0
whismanoid 29:6a9edb6e973b 603 #define HAS_BUTTON9_DEMO_INTERRUPT 1
whismanoid 24:032f3683cb2a 604 #else // MAX40108_DEMO
whismanoid 21:ac062a97a71d 605 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 606 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 29:6a9edb6e973b 607 #endif // MAX40108_DEMO ---------------------------------
whismanoid 21:ac062a97a71d 608 #elif defined(TARGET_MAX32625)
whismanoid 21:ac062a97a71d 609 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 610 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 611 #elif defined(TARGET_MAX32620FTHR)
whismanoid 21:ac062a97a71d 612 #warning "TARGET_MAX32620FTHR not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 613 #define BUTTON1 SW1
whismanoid 21:ac062a97a71d 614 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 615 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 616 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 617 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 21:ac062a97a71d 618 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 619 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 620 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 21:ac062a97a71d 621 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 622 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 623 #else
whismanoid 21:ac062a97a71d 624 #warning "target not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 625 #endif
whismanoid 21:ac062a97a71d 626 //
whismanoid 21:ac062a97a71d 627 #ifndef HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 628 #define HAS_BUTTON1_DEMO 0
whismanoid 21:ac062a97a71d 629 #endif
whismanoid 21:ac062a97a71d 630 #ifndef HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 631 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 632 #endif
whismanoid 24:032f3683cb2a 633 #ifndef HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 634 #define HAS_BUTTON3_DEMO 0
whismanoid 24:032f3683cb2a 635 #endif
whismanoid 21:ac062a97a71d 636 //
whismanoid 21:ac062a97a71d 637 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 638 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 639 #ifndef HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 640 #define HAS_BUTTON1_DEMO_INTERRUPT_POLLING 1
whismanoid 21:ac062a97a71d 641 #endif
whismanoid 21:ac062a97a71d 642 //
whismanoid 21:ac062a97a71d 643 #ifndef HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 644 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 645 #endif
whismanoid 21:ac062a97a71d 646 #ifndef HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 647 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 648 #endif
whismanoid 21:ac062a97a71d 649 //
whismanoid 21:ac062a97a71d 650 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 651 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 652 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 653 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 654 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 655 # else
whismanoid 21:ac062a97a71d 656 InterruptIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 657 # endif
whismanoid 21:ac062a97a71d 658 #elif HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 659 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 660 #endif
whismanoid 21:ac062a97a71d 661 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 662 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 663 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 664 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 665 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 666 # else
whismanoid 21:ac062a97a71d 667 InterruptIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 668 # endif
whismanoid 21:ac062a97a71d 669 #elif HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 670 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 671 #endif
whismanoid 24:032f3683cb2a 672 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 673 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 24:032f3683cb2a 674 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 24:032f3683cb2a 675 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 24:032f3683cb2a 676 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 677 # else
whismanoid 24:032f3683cb2a 678 InterruptIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 679 # endif
whismanoid 24:032f3683cb2a 680 #elif HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 681 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 682 #endif
whismanoid 21:ac062a97a71d 683
whismanoid 0:cb44e2e9ec4c 684 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 685 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 686 // Declare the DigitalInOut GPIO pins
whismanoid 0:cb44e2e9ec4c 687 // Optional digitalInOut support. If there is only one it should be digitalInOut1.
whismanoid 0:cb44e2e9ec4c 688 // D) Digital High/Low/Input Pin
whismanoid 0:cb44e2e9ec4c 689 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 690 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 691 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 692 // | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 693 // | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 694 // | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 695 // | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 696 // | [ ] AIN_0 1.2Vfs (bat) SYS [ ] |
whismanoid 0:cb44e2e9ec4c 697 // | [ ] AIN_1 1.2Vfs PWR [ ] |
whismanoid 0:cb44e2e9ec4c 698 // | [ ] AIN_2 1.2Vfs +5V VBUS [ ] |
whismanoid 0:cb44e2e9ec4c 699 // | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9
whismanoid 0:cb44e2e9ec4c 700 // dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8
whismanoid 0:cb44e2e9ec4c 701 // dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7
whismanoid 0:cb44e2e9ec4c 702 // dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6
whismanoid 0:cb44e2e9ec4c 703 // dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5
whismanoid 0:cb44e2e9ec4c 704 // dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4
whismanoid 0:cb44e2e9ec4c 705 // dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3
whismanoid 0:cb44e2e9ec4c 706 // dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2
whismanoid 0:cb44e2e9ec4c 707 // | [ ] GND SDA P3_4 [x] | dig1
whismanoid 0:cb44e2e9ec4c 708 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 709 #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 710 #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 711 #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 712 #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 713 #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 714 #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 715 #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 716 #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 717 #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 718 #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 719 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 720 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 721 #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 722 #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 723 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 724 #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 725 #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 726 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 727 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 728 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 729 #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 730 #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 731 #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 732 #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 733 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 734 #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 735 #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 736 #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 737 #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 738 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 739 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 740 DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 741 #endif
whismanoid 0:cb44e2e9ec4c 742 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 743 DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 744 #endif
whismanoid 0:cb44e2e9ec4c 745 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 746 DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 747 #endif
whismanoid 0:cb44e2e9ec4c 748 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 749 DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 750 #endif
whismanoid 0:cb44e2e9ec4c 751 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 752 DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 753 #endif
whismanoid 0:cb44e2e9ec4c 754 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 755 DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 756 #endif
whismanoid 0:cb44e2e9ec4c 757 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 758 DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 759 #endif
whismanoid 0:cb44e2e9ec4c 760 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 761 DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 762 #endif
whismanoid 0:cb44e2e9ec4c 763 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 764 DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 765 #endif
whismanoid 0:cb44e2e9ec4c 766 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 767 DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 768 #endif
whismanoid 0:cb44e2e9ec4c 769 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 770 DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 771 #endif
whismanoid 0:cb44e2e9ec4c 772 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 773 DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 774 #endif
whismanoid 0:cb44e2e9ec4c 775 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 776 DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 777 #endif
whismanoid 0:cb44e2e9ec4c 778 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 779 DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 780 #endif
whismanoid 0:cb44e2e9ec4c 781 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 782 DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 783 #endif
whismanoid 0:cb44e2e9ec4c 784 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 785 DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 786 #endif
whismanoid 0:cb44e2e9ec4c 787 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 788 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 789 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 790 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 791 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 792 // | |
whismanoid 0:cb44e2e9ec4c 793 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 794 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 795 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 796 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 797 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 798 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 799 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 800 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 801 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 802 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 803 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 804 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 805 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 806 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 807 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 808 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 809 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 810 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 811 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 812 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 813 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 814 // \_______________________/
whismanoid 0:cb44e2e9ec4c 815 //
whismanoid 0:cb44e2e9ec4c 816 #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 817 #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 818 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 819 #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 820 #else
whismanoid 0:cb44e2e9ec4c 821 #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 822 #endif
whismanoid 0:cb44e2e9ec4c 823 #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 824 #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 825 #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 826 #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 827 #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 828 #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 829 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 830 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 831 #else
whismanoid 0:cb44e2e9ec4c 832 #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 833 #endif
whismanoid 0:cb44e2e9ec4c 834 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 835 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 836 #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 837 #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 838 #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 839 #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 840 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 841 #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 842 #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 843 #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 844 #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 845 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 846 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 847 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 848 #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 849 #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 850 #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 851 #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 852 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 853 #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 854 #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 855 #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 856 #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 857 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 858 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 859 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 860 #endif
whismanoid 0:cb44e2e9ec4c 861 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 862 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 863 #endif
whismanoid 0:cb44e2e9ec4c 864 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 865 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 866 #endif
whismanoid 0:cb44e2e9ec4c 867 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 868 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 869 #endif
whismanoid 0:cb44e2e9ec4c 870 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 871 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 872 #endif
whismanoid 0:cb44e2e9ec4c 873 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 874 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 875 #endif
whismanoid 0:cb44e2e9ec4c 876 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 877 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 878 #endif
whismanoid 0:cb44e2e9ec4c 879 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 880 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 881 #endif
whismanoid 0:cb44e2e9ec4c 882 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 883 DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 884 #endif
whismanoid 0:cb44e2e9ec4c 885 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 886 DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 887 #endif
whismanoid 0:cb44e2e9ec4c 888 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 889 DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 890 #endif
whismanoid 0:cb44e2e9ec4c 891 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 892 DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 893 #endif
whismanoid 0:cb44e2e9ec4c 894 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 895 DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 896 #endif
whismanoid 0:cb44e2e9ec4c 897 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 898 DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 899 #endif
whismanoid 0:cb44e2e9ec4c 900 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 901 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 902 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 903 DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 904 #endif
whismanoid 0:cb44e2e9ec4c 905 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 906 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 907 DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 908 #endif
whismanoid 0:cb44e2e9ec4c 909 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 910 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 911 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 912 // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V
whismanoid 0:cb44e2e9ec4c 913 DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 914 #endif
whismanoid 0:cb44e2e9ec4c 915 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 916 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 917 DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 918 #endif
whismanoid 0:cb44e2e9ec4c 919 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 920 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 15:37c83ec50ea0 921 // TARGET=MAX32625PICO ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 15:37c83ec50ea0 922 // +-------------[microUSB]-------------+
whismanoid 15:37c83ec50ea0 923 // | [27]D+ D-[26] |
whismanoid 15:37c83ec50ea0 924 // | |
whismanoid 15:37c83ec50ea0 925 // | [BUTTON P2_7] |
whismanoid 15:37c83ec50ea0 926 // | P2_4 LED_R P2_5 LED_G P2_6 LED_B |
whismanoid 15:37c83ec50ea0 927 // | |
whismanoid 15:37c83ec50ea0 928 // 1V8 | [11] 1.8V MAX32625PICO GND [10] | GND
whismanoid 15:37c83ec50ea0 929 // 3V3 | [12] 3.3V +5V [09] | 5V0
whismanoid 15:37c83ec50ea0 930 // SPI CS D7 | [13] P0_7 CS s-ssel P4_7 [08] | D15
whismanoid 15:37c83ec50ea0 931 // SPI MISO D6 | [14] P0_6 MISO s-miso P4_6 [07] | D14
whismanoid 15:37c83ec50ea0 932 // SPI MOSI D5 | [15] P0_5 MOSI s-mosi P4_5 [06] | D13
whismanoid 15:37c83ec50ea0 933 // SPI SCLK D4 | [16] P0_4 SCLK s-sclk P4_4 [05] | D12
whismanoid 15:37c83ec50ea0 934 // D3 | [17] P0_3 RTS SCL P1_7 [04] | SCL/D17
whismanoid 15:37c83ec50ea0 935 // D2 | [18] P0_2 CTS SDA P1_6 [03] | SDA/D16
whismanoid 15:37c83ec50ea0 936 // TX/D1 | [19] P0_1 TX0 AIN_2 [02] | A2
whismanoid 15:37c83ec50ea0 937 // RX/D0 | [20] P0_0 RX0 AIN_0 [01] | A0/A4
whismanoid 15:37c83ec50ea0 938 // | |
whismanoid 15:37c83ec50ea0 939 // | DAPLINK |
whismanoid 15:37c83ec50ea0 940 // | J3 p3_3 p3_2 p3_0 p3_1 p3_7 |
whismanoid 15:37c83ec50ea0 941 // | DAP [ ] [ ] [RX2][TX2][ ] |
whismanoid 15:37c83ec50ea0 942 // | TOP [ ] [ ] [ ] [ ] [ ] |
whismanoid 15:37c83ec50ea0 943 // | AIN1/A5 gnd gnd nc AIN3 |
whismanoid 15:37c83ec50ea0 944 // | IOH 1-wire |
whismanoid 15:37c83ec50ea0 945 // | |
whismanoid 15:37c83ec50ea0 946 // |NO USE RST P2_0 P2_1 |
whismanoid 15:37c83ec50ea0 947 // |BOTTOM [ ] [ ] [RX1][ ] [TX1] |
whismanoid 15:37c83ec50ea0 948 // | RST SWC GND SWD 1V8 |
whismanoid 15:37c83ec50ea0 949 // |BOTTOM [21] [22] [23] [24] [25] |
whismanoid 15:37c83ec50ea0 950 // +------------------------------------+
whismanoid 15:37c83ec50ea0 951 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 952 // MAX40108 demo p2: D0..D7 = P0_0..P0_7; D8..15 = P4_0..P4_7; D16/D17=I2C
whismanoid 15:37c83ec50ea0 953 #endif
whismanoid 15:37c83ec50ea0 954 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 955 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 956 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 957 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 958 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 959 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 960 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 961 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 962 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 963 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 15:37c83ec50ea0 964 // AIN_10 = x undefined?
whismanoid 15:37c83ec50ea0 965 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 966 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 967 //
whismanoid 15:37c83ec50ea0 968 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 969 // avoid resource conflict D0,D1 alternate function as RX/TX
whismanoid 15:37c83ec50ea0 970 #define HAS_digitalInOut0 0
whismanoid 15:37c83ec50ea0 971 #define HAS_digitalInOut1 0
whismanoid 15:37c83ec50ea0 972 #else
whismanoid 15:37c83ec50ea0 973 #define HAS_digitalInOut0 1
whismanoid 19:5ff09c8e9daf 974 #define HAS_digitalInOut1 1
whismanoid 19:5ff09c8e9daf 975 // P0_1 TARGET_MAX32625PICO D1
whismanoid 15:37c83ec50ea0 976 #endif
whismanoid 15:37c83ec50ea0 977 #if APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 978 // avoid resource conflict D2 alternate function as interrupt input
whismanoid 15:37c83ec50ea0 979 #define HAS_digitalInOut2 0
whismanoid 15:37c83ec50ea0 980 #else
whismanoid 15:37c83ec50ea0 981 #define HAS_digitalInOut2 1
whismanoid 15:37c83ec50ea0 982 #endif
whismanoid 15:37c83ec50ea0 983 #define HAS_digitalInOut3 1
whismanoid 15:37c83ec50ea0 984 #define HAS_digitalInOut4 1
whismanoid 15:37c83ec50ea0 985 #define HAS_digitalInOut5 1
whismanoid 15:37c83ec50ea0 986 #define HAS_digitalInOut6 1
whismanoid 15:37c83ec50ea0 987 #define HAS_digitalInOut7 1
whismanoid 15:37c83ec50ea0 988 //
whismanoid 15:37c83ec50ea0 989 #define HAS_digitalInOut8 1
whismanoid 15:37c83ec50ea0 990 #define HAS_digitalInOut9 1
whismanoid 15:37c83ec50ea0 991 #define HAS_digitalInOut10 1
whismanoid 15:37c83ec50ea0 992 #define HAS_digitalInOut11 1
whismanoid 15:37c83ec50ea0 993 #define HAS_digitalInOut12 1
whismanoid 15:37c83ec50ea0 994 #define HAS_digitalInOut13 1
whismanoid 15:37c83ec50ea0 995 #define HAS_digitalInOut14 1
whismanoid 15:37c83ec50ea0 996 #define HAS_digitalInOut15 1
whismanoid 15:37c83ec50ea0 997 #if HAS_I2C
whismanoid 25:8a61cb34191d 998 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 999 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 25:8a61cb34191d 1000 // #define BUTTON2 P3_7
whismanoid 25:8a61cb34191d 1001 // avoid resource conflict between I2C and DigitalInOut
whismanoid 25:8a61cb34191d 1002 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1003 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 1004 #else // HAS_I2C
whismanoid 25:8a61cb34191d 1005 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 1006 // 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 1007 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1008 // #define BUTTON2 P1_7
whismanoid 25:8a61cb34191d 1009 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1010 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1011 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1012 #else // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1013 #define HAS_digitalInOut16 1 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1014 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1015 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1016 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1017 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1018 #else // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1019 #define HAS_digitalInOut17 1 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1020 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 15:37c83ec50ea0 1021 #endif // HAS_I2C
whismanoid 15:37c83ec50ea0 1022 #if HAS_digitalInOut0
whismanoid 25:8a61cb34191d 1023 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D0
whismanoid 15:37c83ec50ea0 1024 #endif
whismanoid 15:37c83ec50ea0 1025 #if HAS_digitalInOut1
whismanoid 25:8a61cb34191d 1026 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D1
whismanoid 15:37c83ec50ea0 1027 #endif
whismanoid 15:37c83ec50ea0 1028 #if HAS_digitalInOut2
whismanoid 25:8a61cb34191d 1029 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D2
whismanoid 15:37c83ec50ea0 1030 #endif
whismanoid 15:37c83ec50ea0 1031 #if HAS_digitalInOut3
whismanoid 25:8a61cb34191d 1032 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D3
whismanoid 15:37c83ec50ea0 1033 #endif
whismanoid 15:37c83ec50ea0 1034 #if HAS_digitalInOut4
whismanoid 25:8a61cb34191d 1035 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D4
whismanoid 15:37c83ec50ea0 1036 #endif
whismanoid 15:37c83ec50ea0 1037 #if HAS_digitalInOut5
whismanoid 25:8a61cb34191d 1038 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D5
whismanoid 15:37c83ec50ea0 1039 #endif
whismanoid 15:37c83ec50ea0 1040 #if HAS_digitalInOut6
whismanoid 25:8a61cb34191d 1041 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D6
whismanoid 15:37c83ec50ea0 1042 #endif
whismanoid 15:37c83ec50ea0 1043 #if HAS_digitalInOut7
whismanoid 25:8a61cb34191d 1044 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D7
whismanoid 15:37c83ec50ea0 1045 #endif
whismanoid 15:37c83ec50ea0 1046 #if HAS_digitalInOut8
whismanoid 25:8a61cb34191d 1047 DigitalInOut digitalInOut8(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX40108DEMOP2U9 D8
whismanoid 15:37c83ec50ea0 1048 #endif
whismanoid 15:37c83ec50ea0 1049 #if HAS_digitalInOut9
whismanoid 25:8a61cb34191d 1050 DigitalInOut digitalInOut9(P4_1, PIN_INPUT, PullUp, 1); // P4_1 TARGET_MAX40108DEMOP2U9 D9
whismanoid 15:37c83ec50ea0 1051 #endif
whismanoid 15:37c83ec50ea0 1052 #if HAS_digitalInOut10
whismanoid 25:8a61cb34191d 1053 DigitalInOut digitalInOut10(P4_2, PIN_INPUT, PullUp, 1); // P4_2 TARGET_MAX40108DEMOP2U9 D10
whismanoid 15:37c83ec50ea0 1054 #endif
whismanoid 15:37c83ec50ea0 1055 #if HAS_digitalInOut11
whismanoid 25:8a61cb34191d 1056 DigitalInOut digitalInOut11(P4_3, PIN_INPUT, PullUp, 1); // P4_3 TARGET_MAX40108DEMOP2U9 D11
whismanoid 15:37c83ec50ea0 1057 #endif
whismanoid 15:37c83ec50ea0 1058 #if HAS_digitalInOut12
whismanoid 25:8a61cb34191d 1059 DigitalInOut digitalInOut12(P4_4, PIN_INPUT, PullUp, 1); // P4_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D12
whismanoid 15:37c83ec50ea0 1060 #endif
whismanoid 15:37c83ec50ea0 1061 #if HAS_digitalInOut13
whismanoid 25:8a61cb34191d 1062 DigitalInOut digitalInOut13(P4_5, PIN_INPUT, PullUp, 1); // P4_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D13
whismanoid 15:37c83ec50ea0 1063 #endif
whismanoid 15:37c83ec50ea0 1064 #if HAS_digitalInOut14
whismanoid 25:8a61cb34191d 1065 DigitalInOut digitalInOut14(P4_6, PIN_INPUT, PullUp, 1); // P4_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D14
whismanoid 15:37c83ec50ea0 1066 #endif
whismanoid 15:37c83ec50ea0 1067 #if HAS_digitalInOut15
whismanoid 25:8a61cb34191d 1068 DigitalInOut digitalInOut15(P4_7, PIN_INPUT, PullUp, 1); // P4_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D15
whismanoid 15:37c83ec50ea0 1069 #endif
whismanoid 15:37c83ec50ea0 1070 #if HAS_digitalInOut16
whismanoid 15:37c83ec50ea0 1071 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 15:37c83ec50ea0 1072 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 25:8a61cb34191d 1073 DigitalInOut digitalInOut16(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 15:37c83ec50ea0 1074 #endif
whismanoid 15:37c83ec50ea0 1075 #if HAS_digitalInOut17
whismanoid 15:37c83ec50ea0 1076 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 25:8a61cb34191d 1077 DigitalInOut digitalInOut17(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 1078 #endif
whismanoid 15:37c83ec50ea0 1079 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1080 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1081 #define HAS_digitalInOut0 0
whismanoid 0:cb44e2e9ec4c 1082 #define HAS_digitalInOut1 0
whismanoid 0:cb44e2e9ec4c 1083 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1084 // D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 1085 #define HAS_digitalInOut2 0
whismanoid 0:cb44e2e9ec4c 1086 #else
whismanoid 0:cb44e2e9ec4c 1087 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1088 #endif
whismanoid 0:cb44e2e9ec4c 1089 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1090 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1091 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1092 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1093 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1094 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1095 // D8 -- MAX5715 CLRb DigitalOut
whismanoid 0:cb44e2e9ec4c 1096 #define HAS_digitalInOut8 0
whismanoid 0:cb44e2e9ec4c 1097 #else
whismanoid 0:cb44e2e9ec4c 1098 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1099 #endif
whismanoid 0:cb44e2e9ec4c 1100 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1101 // D9 -- MAX5715 LDACb DigitalOut
whismanoid 0:cb44e2e9ec4c 1102 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1103 #elif APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1104 // D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 1105 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1106 #else
whismanoid 0:cb44e2e9ec4c 1107 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1108 #endif
whismanoid 0:cb44e2e9ec4c 1109 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 1110 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1111 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1112 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1113 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1114 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1115 #define HAS_digitalInOut10 0
whismanoid 0:cb44e2e9ec4c 1116 #define HAS_digitalInOut11 0
whismanoid 0:cb44e2e9ec4c 1117 #define HAS_digitalInOut12 0
whismanoid 0:cb44e2e9ec4c 1118 #define HAS_digitalInOut13 0
whismanoid 0:cb44e2e9ec4c 1119 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1120 #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1121 #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1122 #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1123 #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1124 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1125 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 1126 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1127 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1128 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1129 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1130 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1131 #define HAS_digitalInOut14 0
whismanoid 0:cb44e2e9ec4c 1132 #define HAS_digitalInOut15 0
whismanoid 0:cb44e2e9ec4c 1133 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1134 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1135 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1136 #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1137 #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1138 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1139 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1140 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1141 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1142 DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1143 #endif
whismanoid 0:cb44e2e9ec4c 1144 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1145 DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1146 #endif
whismanoid 0:cb44e2e9ec4c 1147 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1148 DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1149 #endif
whismanoid 0:cb44e2e9ec4c 1150 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1151 DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1152 #endif
whismanoid 0:cb44e2e9ec4c 1153 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1154 DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1155 #endif
whismanoid 0:cb44e2e9ec4c 1156 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1157 DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1158 #endif
whismanoid 0:cb44e2e9ec4c 1159 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1160 DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1161 #endif
whismanoid 0:cb44e2e9ec4c 1162 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1163 DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1164 #endif
whismanoid 0:cb44e2e9ec4c 1165 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1166 DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1167 #endif
whismanoid 0:cb44e2e9ec4c 1168 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1169 DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1170 #endif
whismanoid 0:cb44e2e9ec4c 1171 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1172 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1173 DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1174 #endif
whismanoid 0:cb44e2e9ec4c 1175 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1176 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1177 DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1178 #endif
whismanoid 0:cb44e2e9ec4c 1179 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1180 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1181 DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1182 #endif
whismanoid 0:cb44e2e9ec4c 1183 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1184 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1185 DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1186 #endif
whismanoid 0:cb44e2e9ec4c 1187 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1188 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1189 DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1190 #endif
whismanoid 0:cb44e2e9ec4c 1191 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1192 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1193 DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1194 #endif
whismanoid 0:cb44e2e9ec4c 1195 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1196 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1197 DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1198 #endif
whismanoid 0:cb44e2e9ec4c 1199 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1200 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1201 DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1202 #endif
whismanoid 0:cb44e2e9ec4c 1203 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1204 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1205 #define HAS_digitalInOut0 1
whismanoid 0:cb44e2e9ec4c 1206 #define HAS_digitalInOut1 1
whismanoid 0:cb44e2e9ec4c 1207 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1208 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1209 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1210 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1211 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1212 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1213 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1214 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1215 // #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1216 // #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1217 // #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1218 // #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1219 // #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1220 // #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1221 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1222 DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3
whismanoid 0:cb44e2e9ec4c 1223 #endif
whismanoid 0:cb44e2e9ec4c 1224 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1225 DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2
whismanoid 0:cb44e2e9ec4c 1226 #endif
whismanoid 0:cb44e2e9ec4c 1227 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1228 DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1
whismanoid 0:cb44e2e9ec4c 1229 #endif
whismanoid 0:cb44e2e9ec4c 1230 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1231 DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0
whismanoid 0:cb44e2e9ec4c 1232 #endif
whismanoid 0:cb44e2e9ec4c 1233 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1234 DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1
whismanoid 0:cb44e2e9ec4c 1235 #endif
whismanoid 0:cb44e2e9ec4c 1236 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1237 DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1
whismanoid 0:cb44e2e9ec4c 1238 #endif
whismanoid 0:cb44e2e9ec4c 1239 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1240 DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1
whismanoid 0:cb44e2e9ec4c 1241 #endif
whismanoid 0:cb44e2e9ec4c 1242 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1243 DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO
whismanoid 0:cb44e2e9ec4c 1244 #endif
whismanoid 0:cb44e2e9ec4c 1245 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1246 DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK
whismanoid 0:cb44e2e9ec4c 1247 #endif
whismanoid 0:cb44e2e9ec4c 1248 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1249 DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL
whismanoid 0:cb44e2e9ec4c 1250 #endif
whismanoid 0:cb44e2e9ec4c 1251 //
whismanoid 0:cb44e2e9ec4c 1252 // these pins support analog input analogIn0 .. analogIn5
whismanoid 0:cb44e2e9ec4c 1253 //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1254 //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1255 //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1256 //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1257 //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1258 //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1259 //
whismanoid 0:cb44e2e9ec4c 1260 // these pins support PWM pwmDriver1 .. pwmDriver6
whismanoid 0:cb44e2e9ec4c 1261 //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0
whismanoid 0:cb44e2e9ec4c 1262 //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1
whismanoid 0:cb44e2e9ec4c 1263 //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2
whismanoid 0:cb44e2e9ec4c 1264 //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3
whismanoid 0:cb44e2e9ec4c 1265 //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1
whismanoid 0:cb44e2e9ec4c 1266 //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK
whismanoid 0:cb44e2e9ec4c 1267 //
whismanoid 0:cb44e2e9ec4c 1268 // these could be additional digitalInOut pins
whismanoid 0:cb44e2e9ec4c 1269 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1270 DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1
whismanoid 0:cb44e2e9ec4c 1271 #endif
whismanoid 0:cb44e2e9ec4c 1272 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1273 DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0
whismanoid 0:cb44e2e9ec4c 1274 #endif
whismanoid 0:cb44e2e9ec4c 1275 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1276 DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1
whismanoid 0:cb44e2e9ec4c 1277 #endif
whismanoid 0:cb44e2e9ec4c 1278 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1279 DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0
whismanoid 0:cb44e2e9ec4c 1280 #endif
whismanoid 0:cb44e2e9ec4c 1281 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1282 DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1283 #endif
whismanoid 0:cb44e2e9ec4c 1284 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1285 DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1286 #endif
whismanoid 0:cb44e2e9ec4c 1287 #else
whismanoid 0:cb44e2e9ec4c 1288 // unknown target
whismanoid 0:cb44e2e9ec4c 1289 #endif
whismanoid 0:cb44e2e9ec4c 1290 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1291 #if HAS_digitalInOut0 || HAS_digitalInOut1 \
whismanoid 0:cb44e2e9ec4c 1292 || HAS_digitalInOut2 || HAS_digitalInOut3 \
whismanoid 0:cb44e2e9ec4c 1293 || HAS_digitalInOut4 || HAS_digitalInOut5 \
whismanoid 0:cb44e2e9ec4c 1294 || HAS_digitalInOut6 || HAS_digitalInOut7 \
whismanoid 0:cb44e2e9ec4c 1295 || HAS_digitalInOut8 || HAS_digitalInOut9 \
whismanoid 0:cb44e2e9ec4c 1296 || HAS_digitalInOut10 || HAS_digitalInOut11 \
whismanoid 0:cb44e2e9ec4c 1297 || HAS_digitalInOut12 || HAS_digitalInOut13 \
whismanoid 0:cb44e2e9ec4c 1298 || HAS_digitalInOut14 || HAS_digitalInOut15 \
whismanoid 0:cb44e2e9ec4c 1299 || HAS_digitalInOut16 || HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1300 #define HAS_digitalInOuts 1
whismanoid 0:cb44e2e9ec4c 1301 #else
whismanoid 0:cb44e2e9ec4c 1302 #warning "Note: There are no digitalInOut resources defined"
whismanoid 0:cb44e2e9ec4c 1303 #endif
whismanoid 0:cb44e2e9ec4c 1304
whismanoid 0:cb44e2e9ec4c 1305 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 1306 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1307 // Declare the AnalogIn driver
whismanoid 0:cb44e2e9ec4c 1308 // Optional analogIn support. If there is only one it should be analogIn1.
whismanoid 0:cb44e2e9ec4c 1309 // A) analog input
whismanoid 0:cb44e2e9ec4c 1310 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1311 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1312 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1313 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1314 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1315 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1316 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1317 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1318 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1319 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1320 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1321 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1322 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1323 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1324 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1325 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1326 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1327 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1328 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1329 #endif
whismanoid 0:cb44e2e9ec4c 1330 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1331 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1332 #endif
whismanoid 0:cb44e2e9ec4c 1333 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1334 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1335 #endif
whismanoid 0:cb44e2e9ec4c 1336 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1337 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1338 #endif
whismanoid 0:cb44e2e9ec4c 1339 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1340 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1341 #endif
whismanoid 0:cb44e2e9ec4c 1342 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1343 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1344 #endif
whismanoid 0:cb44e2e9ec4c 1345 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1346 AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1347 #endif
whismanoid 0:cb44e2e9ec4c 1348 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1349 AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1350 #endif
whismanoid 0:cb44e2e9ec4c 1351 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1352 AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1353 #endif
whismanoid 0:cb44e2e9ec4c 1354 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1355 AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1356 #endif
whismanoid 0:cb44e2e9ec4c 1357 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1358 AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1359 #endif
whismanoid 0:cb44e2e9ec4c 1360 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1361 AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1362 #endif
whismanoid 0:cb44e2e9ec4c 1363 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1364 AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1365 #endif
whismanoid 0:cb44e2e9ec4c 1366 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1367 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1368 #endif
whismanoid 0:cb44e2e9ec4c 1369 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1370 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1371 #endif
whismanoid 0:cb44e2e9ec4c 1372 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1373 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1374 #endif
whismanoid 0:cb44e2e9ec4c 1375 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1376 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 1377 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1378 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1379 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1380 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1381 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1382 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1383 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1384 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1385 #endif
whismanoid 0:cb44e2e9ec4c 1386 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1387 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1388 #endif
whismanoid 0:cb44e2e9ec4c 1389 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1390 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1391 #endif
whismanoid 0:cb44e2e9ec4c 1392 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1393 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1394 #endif
whismanoid 0:cb44e2e9ec4c 1395 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1396 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1397 #endif
whismanoid 0:cb44e2e9ec4c 1398 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1399 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1400 #endif
whismanoid 0:cb44e2e9ec4c 1401 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1402 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 1403 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1404 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1405 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1406 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1407 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1408 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1409 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1410 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1411 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1412 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1413 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1414 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1415 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1416 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1417 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1418 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1419 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1420 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1421 AnalogIn analogIn0(AIN_0); // TARGET_MAX32620FTHR J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1422 #endif
whismanoid 0:cb44e2e9ec4c 1423 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1424 AnalogIn analogIn1(AIN_1); // TARGET_MAX32620FTHR J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1425 #endif
whismanoid 0:cb44e2e9ec4c 1426 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1427 AnalogIn analogIn2(AIN_2); // TARGET_MAX32620FTHR J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1428 #endif
whismanoid 0:cb44e2e9ec4c 1429 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1430 AnalogIn analogIn3(AIN_3); // TARGET_MAX32620FTHR J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1431 #endif
whismanoid 0:cb44e2e9ec4c 1432 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1433 AnalogIn analogIn4(AIN_4); // TARGET_MAX32620FTHR J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1434 #endif
whismanoid 0:cb44e2e9ec4c 1435 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1436 AnalogIn analogIn5(AIN_5); // TARGET_MAX32620FTHR J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1437 #endif
whismanoid 0:cb44e2e9ec4c 1438 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1439 AnalogIn analogIn6(AIN_6); // TARGET_MAX32620FTHR AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1440 #endif
whismanoid 0:cb44e2e9ec4c 1441 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1442 AnalogIn analogIn7(AIN_7); // TARGET_MAX32620FTHR AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1443 #endif
whismanoid 0:cb44e2e9ec4c 1444 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1445 AnalogIn analogIn8(AIN_8); // TARGET_MAX32620FTHR AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1446 #endif
whismanoid 0:cb44e2e9ec4c 1447 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1448 AnalogIn analogIn9(AIN_9); // TARGET_MAX32620FTHR AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1449 #endif
whismanoid 0:cb44e2e9ec4c 1450 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1451 AnalogIn analogIn10(____); // TARGET_MAX32620FTHR AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1452 #endif
whismanoid 0:cb44e2e9ec4c 1453 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1454 AnalogIn analogIn11(____); // TARGET_MAX32620FTHR AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1455 #endif
whismanoid 0:cb44e2e9ec4c 1456 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1457 AnalogIn analogIn12(____); // TARGET_MAX32620FTHR AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1458 #endif
whismanoid 0:cb44e2e9ec4c 1459 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1460 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1461 #endif
whismanoid 0:cb44e2e9ec4c 1462 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1463 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1464 #endif
whismanoid 0:cb44e2e9ec4c 1465 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1466 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1467 #endif
whismanoid 0:cb44e2e9ec4c 1468 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 1469 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 1470 #warning "TARGET_MAX32625PICO not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1471 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1472 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1473 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1474 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1475 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1476 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1477 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1478 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1479 #endif
whismanoid 0:cb44e2e9ec4c 1480 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1481 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1482 #endif
whismanoid 0:cb44e2e9ec4c 1483 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1484 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1485 #endif
whismanoid 0:cb44e2e9ec4c 1486 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1487 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1488 #endif
whismanoid 0:cb44e2e9ec4c 1489 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1490 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1491 #endif
whismanoid 0:cb44e2e9ec4c 1492 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1493 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1494 #endif
whismanoid 0:cb44e2e9ec4c 1495 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1496 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 1497 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1498 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1499 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1500 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1501 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1502 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1503 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1504 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1505 #endif
whismanoid 0:cb44e2e9ec4c 1506 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1507 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1508 #endif
whismanoid 0:cb44e2e9ec4c 1509 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1510 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1511 #endif
whismanoid 0:cb44e2e9ec4c 1512 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1513 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1514 #endif
whismanoid 0:cb44e2e9ec4c 1515 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1516 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1517 #endif
whismanoid 0:cb44e2e9ec4c 1518 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1519 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1520 #endif
whismanoid 0:cb44e2e9ec4c 1521 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1522 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 1523 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1524 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1525 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1526 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1527 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1528 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1529 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1530 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1531 #endif
whismanoid 0:cb44e2e9ec4c 1532 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1533 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1534 #endif
whismanoid 0:cb44e2e9ec4c 1535 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1536 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1537 #endif
whismanoid 0:cb44e2e9ec4c 1538 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1539 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1540 #endif
whismanoid 0:cb44e2e9ec4c 1541 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1542 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1543 #endif
whismanoid 0:cb44e2e9ec4c 1544 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1545 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1546 #endif
whismanoid 0:cb44e2e9ec4c 1547 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1548 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1549 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1550 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1551 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1552 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1553 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1554 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1555 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1556 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1557 #endif
whismanoid 0:cb44e2e9ec4c 1558 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1559 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1560 #endif
whismanoid 0:cb44e2e9ec4c 1561 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1562 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1563 #endif
whismanoid 0:cb44e2e9ec4c 1564 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1565 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1566 #endif
whismanoid 0:cb44e2e9ec4c 1567 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1568 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1569 #endif
whismanoid 0:cb44e2e9ec4c 1570 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1571 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1572 #endif
whismanoid 0:cb44e2e9ec4c 1573 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1574 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 1575 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1576 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1577 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1578 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1579 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1580 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1581 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1582 // #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1583 // #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1584 // #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1585 // #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1586 // #define HAS_analogIn10 1
whismanoid 0:cb44e2e9ec4c 1587 // #define HAS_analogIn11 1
whismanoid 0:cb44e2e9ec4c 1588 // #define HAS_analogIn12 1
whismanoid 0:cb44e2e9ec4c 1589 // #define HAS_analogIn13 1
whismanoid 0:cb44e2e9ec4c 1590 // #define HAS_analogIn14 1
whismanoid 0:cb44e2e9ec4c 1591 // #define HAS_analogIn15 1
whismanoid 0:cb44e2e9ec4c 1592 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1593 AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1594 #endif
whismanoid 0:cb44e2e9ec4c 1595 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1596 AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1597 #endif
whismanoid 0:cb44e2e9ec4c 1598 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1599 AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1600 #endif
whismanoid 0:cb44e2e9ec4c 1601 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1602 AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1603 #endif
whismanoid 0:cb44e2e9ec4c 1604 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1605 AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1606 #endif
whismanoid 0:cb44e2e9ec4c 1607 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1608 AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1609 #endif
whismanoid 0:cb44e2e9ec4c 1610 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1611 AnalogIn analogIn6(____);
whismanoid 0:cb44e2e9ec4c 1612 #endif
whismanoid 0:cb44e2e9ec4c 1613 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1614 AnalogIn analogIn7(____);
whismanoid 0:cb44e2e9ec4c 1615 #endif
whismanoid 0:cb44e2e9ec4c 1616 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1617 AnalogIn analogIn8(____);
whismanoid 0:cb44e2e9ec4c 1618 #endif
whismanoid 0:cb44e2e9ec4c 1619 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1620 AnalogIn analogIn9(____);
whismanoid 0:cb44e2e9ec4c 1621 #endif
whismanoid 0:cb44e2e9ec4c 1622 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1623 AnalogIn analogIn10(____);
whismanoid 0:cb44e2e9ec4c 1624 #endif
whismanoid 0:cb44e2e9ec4c 1625 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1626 AnalogIn analogIn11(____);
whismanoid 0:cb44e2e9ec4c 1627 #endif
whismanoid 0:cb44e2e9ec4c 1628 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1629 AnalogIn analogIn12(____);
whismanoid 0:cb44e2e9ec4c 1630 #endif
whismanoid 0:cb44e2e9ec4c 1631 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1632 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1633 #endif
whismanoid 0:cb44e2e9ec4c 1634 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1635 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1636 #endif
whismanoid 0:cb44e2e9ec4c 1637 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1638 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1639 #endif
whismanoid 0:cb44e2e9ec4c 1640 #else
whismanoid 0:cb44e2e9ec4c 1641 // unknown target
whismanoid 0:cb44e2e9ec4c 1642 #endif
whismanoid 0:cb44e2e9ec4c 1643 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1644 #if HAS_analogIn0 || HAS_analogIn1 \
whismanoid 0:cb44e2e9ec4c 1645 || HAS_analogIn2 || HAS_analogIn3 \
whismanoid 0:cb44e2e9ec4c 1646 || HAS_analogIn4 || HAS_analogIn5 \
whismanoid 0:cb44e2e9ec4c 1647 || HAS_analogIn6 || HAS_analogIn7 \
whismanoid 0:cb44e2e9ec4c 1648 || HAS_analogIn8 || HAS_analogIn9 \
whismanoid 0:cb44e2e9ec4c 1649 || HAS_analogIn10 || HAS_analogIn11 \
whismanoid 0:cb44e2e9ec4c 1650 || HAS_analogIn12 || HAS_analogIn13 \
whismanoid 0:cb44e2e9ec4c 1651 || HAS_analogIn14 || HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1652 #define HAS_analogIns 1
whismanoid 0:cb44e2e9ec4c 1653 #else
whismanoid 0:cb44e2e9ec4c 1654 #warning "Note: There are no analogIn resources defined"
whismanoid 0:cb44e2e9ec4c 1655 #endif
whismanoid 0:cb44e2e9ec4c 1656
whismanoid 0:cb44e2e9ec4c 1657 // DigitalInOut pin resource: print the pin index names to serial
whismanoid 0:cb44e2e9ec4c 1658 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 1659 void list_digitalInOutPins(Stream& serialStream)
whismanoid 0:cb44e2e9ec4c 1660 {
whismanoid 0:cb44e2e9ec4c 1661 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1662 serialStream.printf(" 0");
whismanoid 0:cb44e2e9ec4c 1663 #endif
whismanoid 0:cb44e2e9ec4c 1664 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1665 serialStream.printf(" 1");
whismanoid 0:cb44e2e9ec4c 1666 #endif
whismanoid 0:cb44e2e9ec4c 1667 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1668 serialStream.printf(" 2");
whismanoid 0:cb44e2e9ec4c 1669 #endif
whismanoid 0:cb44e2e9ec4c 1670 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1671 serialStream.printf(" 3");
whismanoid 0:cb44e2e9ec4c 1672 #endif
whismanoid 0:cb44e2e9ec4c 1673 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1674 serialStream.printf(" 4");
whismanoid 0:cb44e2e9ec4c 1675 #endif
whismanoid 0:cb44e2e9ec4c 1676 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1677 serialStream.printf(" 5");
whismanoid 0:cb44e2e9ec4c 1678 #endif
whismanoid 0:cb44e2e9ec4c 1679 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1680 serialStream.printf(" 6");
whismanoid 0:cb44e2e9ec4c 1681 #endif
whismanoid 0:cb44e2e9ec4c 1682 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1683 serialStream.printf(" 7");
whismanoid 0:cb44e2e9ec4c 1684 #endif
whismanoid 0:cb44e2e9ec4c 1685 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1686 serialStream.printf(" 8");
whismanoid 0:cb44e2e9ec4c 1687 #endif
whismanoid 0:cb44e2e9ec4c 1688 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1689 serialStream.printf(" 9");
whismanoid 0:cb44e2e9ec4c 1690 #endif
whismanoid 0:cb44e2e9ec4c 1691 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1692 serialStream.printf(" 10");
whismanoid 0:cb44e2e9ec4c 1693 #endif
whismanoid 0:cb44e2e9ec4c 1694 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1695 serialStream.printf(" 11");
whismanoid 0:cb44e2e9ec4c 1696 #endif
whismanoid 0:cb44e2e9ec4c 1697 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1698 serialStream.printf(" 12");
whismanoid 0:cb44e2e9ec4c 1699 #endif
whismanoid 0:cb44e2e9ec4c 1700 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1701 serialStream.printf(" 13");
whismanoid 0:cb44e2e9ec4c 1702 #endif
whismanoid 0:cb44e2e9ec4c 1703 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1704 serialStream.printf(" 14");
whismanoid 0:cb44e2e9ec4c 1705 #endif
whismanoid 0:cb44e2e9ec4c 1706 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1707 serialStream.printf(" 15");
whismanoid 0:cb44e2e9ec4c 1708 #endif
whismanoid 0:cb44e2e9ec4c 1709 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1710 serialStream.printf(" 16");
whismanoid 0:cb44e2e9ec4c 1711 #endif
whismanoid 0:cb44e2e9ec4c 1712 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1713 serialStream.printf(" 17");
whismanoid 0:cb44e2e9ec4c 1714 #endif
whismanoid 18:1235c17b451e 1715 #if USE_LEDS
whismanoid 18:1235c17b451e 1716 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 1717 // support list_digitalInOutPins() listing buttons and leds as pin numbers 90/91/92/93
whismanoid 18:1235c17b451e 1718 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 1719 //~ serialStream.printf(" 90");
whismanoid 18:1235c17b451e 1720 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 1721 serialStream.printf(" 91");
whismanoid 18:1235c17b451e 1722 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 1723 serialStream.printf(" 92");
whismanoid 18:1235c17b451e 1724 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 1725 serialStream.printf(" 93");
whismanoid 18:1235c17b451e 1726 #else // USE_LEDS
whismanoid 18:1235c17b451e 1727 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 1728 }
whismanoid 0:cb44e2e9ec4c 1729 #endif
whismanoid 0:cb44e2e9ec4c 1730
whismanoid 0:cb44e2e9ec4c 1731
whismanoid 0:cb44e2e9ec4c 1732 // DigitalInOut pin resource: search index
whismanoid 0:cb44e2e9ec4c 1733 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 1734 DigitalInOut& find_digitalInOutPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 1735 {
whismanoid 0:cb44e2e9ec4c 1736 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 1737 {
whismanoid 0:cb44e2e9ec4c 1738 default: // default to the first defined digitalInOut pin
whismanoid 0:cb44e2e9ec4c 1739 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1740 case '0': case 0x00: return digitalInOut0;
whismanoid 0:cb44e2e9ec4c 1741 #endif
whismanoid 0:cb44e2e9ec4c 1742 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1743 case '1': case 0x01: return digitalInOut1;
whismanoid 0:cb44e2e9ec4c 1744 #endif
whismanoid 0:cb44e2e9ec4c 1745 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1746 case '2': case 0x02: return digitalInOut2;
whismanoid 0:cb44e2e9ec4c 1747 #endif
whismanoid 0:cb44e2e9ec4c 1748 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1749 case '3': case 0x03: return digitalInOut3;
whismanoid 0:cb44e2e9ec4c 1750 #endif
whismanoid 0:cb44e2e9ec4c 1751 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1752 case '4': case 0x04: return digitalInOut4;
whismanoid 0:cb44e2e9ec4c 1753 #endif
whismanoid 0:cb44e2e9ec4c 1754 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1755 case '5': case 0x05: return digitalInOut5;
whismanoid 0:cb44e2e9ec4c 1756 #endif
whismanoid 0:cb44e2e9ec4c 1757 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1758 case '6': case 0x06: return digitalInOut6;
whismanoid 0:cb44e2e9ec4c 1759 #endif
whismanoid 0:cb44e2e9ec4c 1760 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1761 case '7': case 0x07: return digitalInOut7;
whismanoid 0:cb44e2e9ec4c 1762 #endif
whismanoid 0:cb44e2e9ec4c 1763 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1764 case '8': case 0x08: return digitalInOut8;
whismanoid 0:cb44e2e9ec4c 1765 #endif
whismanoid 0:cb44e2e9ec4c 1766 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1767 case '9': case 0x09: return digitalInOut9;
whismanoid 0:cb44e2e9ec4c 1768 #endif
whismanoid 0:cb44e2e9ec4c 1769 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1770 case 'a': case 0x0a: return digitalInOut10;
whismanoid 0:cb44e2e9ec4c 1771 #endif
whismanoid 0:cb44e2e9ec4c 1772 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1773 case 'b': case 0x0b: return digitalInOut11;
whismanoid 0:cb44e2e9ec4c 1774 #endif
whismanoid 0:cb44e2e9ec4c 1775 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1776 case 'c': case 0x0c: return digitalInOut12;
whismanoid 0:cb44e2e9ec4c 1777 #endif
whismanoid 0:cb44e2e9ec4c 1778 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1779 case 'd': case 0x0d: return digitalInOut13;
whismanoid 0:cb44e2e9ec4c 1780 #endif
whismanoid 0:cb44e2e9ec4c 1781 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1782 case 'e': case 0x0e: return digitalInOut14;
whismanoid 0:cb44e2e9ec4c 1783 #endif
whismanoid 0:cb44e2e9ec4c 1784 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1785 case 'f': case 0x0f: return digitalInOut15;
whismanoid 0:cb44e2e9ec4c 1786 #endif
whismanoid 0:cb44e2e9ec4c 1787 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1788 case 'g': case 0x10: return digitalInOut16;
whismanoid 0:cb44e2e9ec4c 1789 #endif
whismanoid 0:cb44e2e9ec4c 1790 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1791 case 'h': case 0x11: return digitalInOut17;
whismanoid 0:cb44e2e9ec4c 1792 #endif
whismanoid 18:1235c17b451e 1793 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 1794 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 1795 //~ case 90: return button1;
whismanoid 18:1235c17b451e 1796 #if USE_LEDS
whismanoid 18:1235c17b451e 1797 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 1798 case 91: return led1_RFailLED;
whismanoid 18:1235c17b451e 1799 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 1800 case 92: return led2_GPassLED;
whismanoid 18:1235c17b451e 1801 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 1802 case 93: return led3_BBusyLED;
whismanoid 18:1235c17b451e 1803 #else // USE_LEDS
whismanoid 18:1235c17b451e 1804 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 1805 }
whismanoid 0:cb44e2e9ec4c 1806 }
whismanoid 0:cb44e2e9ec4c 1807 #endif
whismanoid 0:cb44e2e9ec4c 1808
whismanoid 0:cb44e2e9ec4c 1809
whismanoid 0:cb44e2e9ec4c 1810 // AnalogIn pin resource: search index
whismanoid 0:cb44e2e9ec4c 1811 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 1812 AnalogIn& find_analogInPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 1813 {
whismanoid 0:cb44e2e9ec4c 1814 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 1815 {
whismanoid 0:cb44e2e9ec4c 1816 default: // default to the first defined analogIn pin
whismanoid 0:cb44e2e9ec4c 1817 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1818 case '0': case 0x00: return analogIn0;
whismanoid 0:cb44e2e9ec4c 1819 #endif
whismanoid 0:cb44e2e9ec4c 1820 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1821 case '1': case 0x01: return analogIn1;
whismanoid 0:cb44e2e9ec4c 1822 #endif
whismanoid 0:cb44e2e9ec4c 1823 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1824 case '2': case 0x02: return analogIn2;
whismanoid 0:cb44e2e9ec4c 1825 #endif
whismanoid 0:cb44e2e9ec4c 1826 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1827 case '3': case 0x03: return analogIn3;
whismanoid 0:cb44e2e9ec4c 1828 #endif
whismanoid 0:cb44e2e9ec4c 1829 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1830 case '4': case 0x04: return analogIn4;
whismanoid 0:cb44e2e9ec4c 1831 #endif
whismanoid 0:cb44e2e9ec4c 1832 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1833 case '5': case 0x05: return analogIn5;
whismanoid 0:cb44e2e9ec4c 1834 #endif
whismanoid 0:cb44e2e9ec4c 1835 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1836 case '6': case 0x06: return analogIn6;
whismanoid 0:cb44e2e9ec4c 1837 #endif
whismanoid 0:cb44e2e9ec4c 1838 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1839 case '7': case 0x07: return analogIn7;
whismanoid 0:cb44e2e9ec4c 1840 #endif
whismanoid 0:cb44e2e9ec4c 1841 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1842 case '8': case 0x08: return analogIn8;
whismanoid 0:cb44e2e9ec4c 1843 #endif
whismanoid 0:cb44e2e9ec4c 1844 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1845 case '9': case 0x09: return analogIn9;
whismanoid 0:cb44e2e9ec4c 1846 #endif
whismanoid 0:cb44e2e9ec4c 1847 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1848 case 'a': case 0x0a: return analogIn10;
whismanoid 0:cb44e2e9ec4c 1849 #endif
whismanoid 0:cb44e2e9ec4c 1850 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1851 case 'b': case 0x0b: return analogIn11;
whismanoid 0:cb44e2e9ec4c 1852 #endif
whismanoid 0:cb44e2e9ec4c 1853 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1854 case 'c': case 0x0c: return analogIn12;
whismanoid 0:cb44e2e9ec4c 1855 #endif
whismanoid 0:cb44e2e9ec4c 1856 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1857 case 'd': case 0x0d: return analogIn13;
whismanoid 0:cb44e2e9ec4c 1858 #endif
whismanoid 0:cb44e2e9ec4c 1859 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1860 case 'e': case 0x0e: return analogIn14;
whismanoid 0:cb44e2e9ec4c 1861 #endif
whismanoid 0:cb44e2e9ec4c 1862 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1863 case 'f': case 0x0f: return analogIn15;
whismanoid 0:cb44e2e9ec4c 1864 #endif
whismanoid 0:cb44e2e9ec4c 1865 }
whismanoid 0:cb44e2e9ec4c 1866 }
whismanoid 0:cb44e2e9ec4c 1867 #endif
whismanoid 0:cb44e2e9ec4c 1868
whismanoid 0:cb44e2e9ec4c 1869 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 1870 const float analogInPin_fullScaleVoltage[] = {
whismanoid 0:cb44e2e9ec4c 1871 # if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1872 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1873 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1874 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1875 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1876 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1877 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1878 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1879 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1880 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1881 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1882 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1883 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1884 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1885 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1886 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1887 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1888 # elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 1889 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1890 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1891 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1892 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1893 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1894 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1895 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1896 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1897 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1898 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1899 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1900 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1901 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1902 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1903 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1904 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1905 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 19:5ff09c8e9daf 1906 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 1907 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1908 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1909 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1910 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1911 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1912 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1913 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1914 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1915 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1916 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1917 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1918 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1919 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1920 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1921 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1922 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1923 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 1924 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1925 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1926 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1927 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1928 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1929 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1930 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1931 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1932 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1933 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 1934 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 1935 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 1936 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 1937 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1938 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1939 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1940 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1941 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1942 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1943 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1944 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1945 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1946 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1947 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1948 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1949 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1950 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 1951 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 1952 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 1953 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 1954 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1955 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1956 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1957 //#elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1958 #else
whismanoid 0:cb44e2e9ec4c 1959 // unknown target
whismanoid 0:cb44e2e9ec4c 1960 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1961 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1962 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1963 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1964 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1965 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1966 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1967 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1968 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1969 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 1970 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 1971 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 1972 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 1973 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1974 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1975 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1976 # endif
whismanoid 0:cb44e2e9ec4c 1977 };
whismanoid 0:cb44e2e9ec4c 1978 #endif
whismanoid 0:cb44e2e9ec4c 1979
whismanoid 0:cb44e2e9ec4c 1980
whismanoid 0:cb44e2e9ec4c 1981
whismanoid 0:cb44e2e9ec4c 1982
whismanoid 0:cb44e2e9ec4c 1983 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 1984 // TODO support CmdLine command menus (like on Serial_Tester)
whismanoid 4:d9b05924ad4c 1985 #ifndef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 1986 #define USE_CMDLINE_MENUS 1
whismanoid 4:d9b05924ad4c 1987 //~ #undef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 1988 #endif
whismanoid 4:d9b05924ad4c 1989 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 1990 #include "CmdLine.h"
whismanoid 4:d9b05924ad4c 1991 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 1992 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 1993 extern CmdLine cmdLine; // declared later
whismanoid 4:d9b05924ad4c 1994 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 1995
whismanoid 4:d9b05924ad4c 1996 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 1997 // Datalog trigger types
whismanoid 4:d9b05924ad4c 1998 #ifndef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 1999 #define USE_DATALOGGER_TRIGGER 1
whismanoid 4:d9b05924ad4c 2000 //~ #undef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 2001 #endif
whismanoid 4:d9b05924ad4c 2002 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 2003 typedef enum Datalogger_Trigger_enum_t {
whismanoid 4:d9b05924ad4c 2004 trigger_Halt = 0, //!< halt
whismanoid 4:d9b05924ad4c 2005 trigger_FreeRun = 1, //!< free run as fast as possible
whismanoid 4:d9b05924ad4c 2006 trigger_Timer = 2, //!< timer (configure interval)
whismanoid 4:d9b05924ad4c 2007 trigger_PlatformDigitalInput, //!< platform digital input (configure digital input pin reference)
whismanoid 4:d9b05924ad4c 2008 trigger_SPIDeviceRegRead, //!< SPI device register read (configure regaddr, mask value, match value)
whismanoid 4:d9b05924ad4c 2009 } Datalogger_Trigger_enum_t;
whismanoid 4:d9b05924ad4c 2010 Datalogger_Trigger_enum_t Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 2011 //
whismanoid 17:9397ea3ea7e9 2012 // configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 2013 int g_timer_interval_msec = 500; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2014 int g_timer_interval_count = 10; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2015 int g_timer_interval_counter = 0; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2016 //
whismanoid 17:9397ea3ea7e9 2017 // TODO: configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 2018 //
whismanoid 17:9397ea3ea7e9 2019 // TODO: configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2020 //
whismanoid 4:d9b05924ad4c 2021 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 2022
whismanoid 4:d9b05924ad4c 2023 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2024 // support trigger_SPIDeviceRegRead: Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 2025 #ifndef USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2026 #define USE_DATALOGGER_SPIDeviceRegRead 0
whismanoid 17:9397ea3ea7e9 2027 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2028 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2029 // TODO: uint16_t regAddr;
whismanoid 17:9397ea3ea7e9 2030 // TODO: uint16_t regDataMask;
whismanoid 17:9397ea3ea7e9 2031 // TODO: uint16_t regDataTest;
whismanoid 17:9397ea3ea7e9 2032 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2033
whismanoid 17:9397ea3ea7e9 2034 //--------------------------------------------------
whismanoid 30:07197a430869 2035 // support Datalogger_PrintRow() print gstrRemarkText field from recent #remark
whismanoid 30:07197a430869 2036 #ifndef USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2037 #define USE_DATALOGGER_REMARK_FIELD 1
whismanoid 30:07197a430869 2038 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2039 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2040 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark
whismanoid 30:07197a430869 2041 const size_t gstrRemarkTextLASTINDEX = 40; // gstrRemarkText buffer size - 1
whismanoid 30:07197a430869 2042 char gstrRemarkText[gstrRemarkTextLASTINDEX+1] = "";
whismanoid 30:07197a430869 2043 char gstrRemarkHeader[] = "comment"; // comment or remark?
whismanoid 30:07197a430869 2044 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 2045
whismanoid 30:07197a430869 2046 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2047 // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2048 #ifndef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2049 #define USE_DATALOGGER_ActionTable 1
whismanoid 17:9397ea3ea7e9 2050 //~ #undef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2051 #endif
whismanoid 17:9397ea3ea7e9 2052 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2053 //
whismanoid 17:9397ea3ea7e9 2054 // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2055 typedef enum action_type_enum_t {
whismanoid 17:9397ea3ea7e9 2056 action_noop = 0, // no operation
whismanoid 30:07197a430869 2057 action_digitalOutLow = 1, // pin = low if condition
whismanoid 30:07197a430869 2058 action_digitalOutHigh = 2, // pin = high if condition
whismanoid 30:07197a430869 2059 action_button = 3, // pin = button event index 1, 2, 3
whismanoid 30:07197a430869 2060 action_trigger_Halt = 4,
whismanoid 30:07197a430869 2061 action_trigger_FreeRun = 5,
whismanoid 30:07197a430869 2062 action_trigger_Timer = 6,
whismanoid 30:07197a430869 2063 action_trigger_PlatformDigitalInput = 7,
whismanoid 30:07197a430869 2064 action_trigger_SPIDeviceRegRead = 8,
whismanoid 17:9397ea3ea7e9 2065 } action_type_enum_t;
whismanoid 17:9397ea3ea7e9 2066 //
whismanoid 17:9397ea3ea7e9 2067 // Datalogger_RunActionTable() supported conditions
whismanoid 17:9397ea3ea7e9 2068 typedef enum action_condition_enum_t {
whismanoid 17:9397ea3ea7e9 2069 condition_always = 0, // ( true )
whismanoid 17:9397ea3ea7e9 2070 condition_if_An_gt_threshold, // (Platform_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2071 condition_if_An_lt_threshold, // (Platform_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2072 condition_if_An_eq_threshold, // (Platform_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2073 condition_if_An_ge_threshold, // (Platform_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2074 condition_if_An_le_threshold, // (Platform_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2075 condition_if_An_ne_threshold, // (Platform_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2076 condition_if_AINn_gt_threshold, // (SPI_AIN_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2077 condition_if_AINn_lt_threshold, // (SPI_AIN_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2078 condition_if_AINn_eq_threshold, // (SPI_AIN_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2079 condition_if_AINn_ge_threshold, // (SPI_AIN_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2080 condition_if_AINn_le_threshold, // (SPI_AIN_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2081 condition_if_AINn_ne_threshold, // (SPI_AIN_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2082 } condition_enum_t;
whismanoid 17:9397ea3ea7e9 2083 //
whismanoid 17:9397ea3ea7e9 2084 // Datalogger_RunActionTable() structure
whismanoid 17:9397ea3ea7e9 2085 typedef struct action_table_row_t {
whismanoid 17:9397ea3ea7e9 2086 action_type_enum_t action;
whismanoid 17:9397ea3ea7e9 2087 int digitalOutPin;
whismanoid 17:9397ea3ea7e9 2088 action_condition_enum_t condition;
whismanoid 17:9397ea3ea7e9 2089 int condition_channel;
whismanoid 17:9397ea3ea7e9 2090 double condition_threshold;
whismanoid 17:9397ea3ea7e9 2091 } action_table_row_t;
whismanoid 17:9397ea3ea7e9 2092 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2093 const int channel_WE = 2;
whismanoid 17:9397ea3ea7e9 2094 const double threshold_WE_0V5 = 0.5;
whismanoid 17:9397ea3ea7e9 2095 const double threshold_WE_0V6 = 0.6;
whismanoid 17:9397ea3ea7e9 2096 const double threshold_WE_0V7 = 0.7;
whismanoid 18:1235c17b451e 2097 const int pin_LED_1 = 91; // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 2098 const int pin_LED_2 = 92; // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 2099 const int pin_LED_3 = 93; // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 17:9397ea3ea7e9 2100 #endif
whismanoid 17:9397ea3ea7e9 2101 const int ACTION_TABLE_ROW_MAX = 20;
whismanoid 17:9397ea3ea7e9 2102 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2103 bool Datalogger_action_table_enabled = true;
whismanoid 30:07197a430869 2104 int Datalogger_action_table_row_count = 8; // assert (Datalogger_action_table_row_count <= ACTION_TABLE_ROW_MAX)
whismanoid 17:9397ea3ea7e9 2105 #else // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2106 int Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 2107 #endif // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2108 action_table_row_t Datalogger_action_table[ACTION_TABLE_ROW_MAX] = {
whismanoid 17:9397ea3ea7e9 2109 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2110 // LED indicator show (WE > 0.5V)
whismanoid 18:1235c17b451e 2111 // L@0 act=1 pin=92 if=1 ch=2 x=0.500000 -- digitalOutLow D92 if A2 > 0.500000
whismanoid 18:1235c17b451e 2112 {action_digitalOutLow, pin_LED_2, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V5},
whismanoid 17:9397ea3ea7e9 2113 //
whismanoid 17:9397ea3ea7e9 2114 // LED indicator show (WE > 0.6V)
whismanoid 18:1235c17b451e 2115 // L@1 act=1 pin=93 if=1 ch=2 x=0.600000 -- digitalOutLow D93 if A2 > 0.600000
whismanoid 18:1235c17b451e 2116 {action_digitalOutLow, pin_LED_3, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 17:9397ea3ea7e9 2117 //
whismanoid 17:9397ea3ea7e9 2118 // switch to always-on mode `trigger_FreeRun` if (WE > 0.7V)
whismanoid 29:6a9edb6e973b 2119 // L@2 act=5 if=1 ch=2 x=0.700000 -- trigger_FreeRun if A2 > 0.700000
whismanoid 17:9397ea3ea7e9 2120 {action_trigger_FreeRun, 0, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 17:9397ea3ea7e9 2121 //
whismanoid 17:9397ea3ea7e9 2122 // switch to intermittent-sleep-mode `trigger_Timer` if (WE < 0.6V)
whismanoid 29:6a9edb6e973b 2123 // L@3 act=6 if=2 ch=2 x=0.600000 -- trigger_Timer(10 x 500msec) if A2 < 0.600000
whismanoid 17:9397ea3ea7e9 2124 {action_trigger_Timer, 0, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 18:1235c17b451e 2125 //
whismanoid 18:1235c17b451e 2126 // LED indicator show (`Datalogger_Trigger` == `trigger_FreeRun`)
whismanoid 18:1235c17b451e 2127 // {action_noop, 0, condition_always, 0, 0},
whismanoid 18:1235c17b451e 2128 // L@4 act=1 pin=91 if=1 ch=2 x=0.700000 -- digitalOutLow D91 if A2 > 0.700000
whismanoid 18:1235c17b451e 2129 {action_digitalOutLow, pin_LED_1, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 18:1235c17b451e 2130 //
whismanoid 18:1235c17b451e 2131 // L@5 act=2 pin=91 if=2 ch=2 x=0.600000 -- digitalOutHigh D91 if A2 < 0.600000
whismanoid 18:1235c17b451e 2132 {action_digitalOutHigh, pin_LED_1, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 18:1235c17b451e 2133 //
whismanoid 30:07197a430869 2134 // L@6 act=3 pin=4 if=1 ch=2 x=0.700000 -- button 4 event if A2 > 0.700000
whismanoid 30:07197a430869 2135 {action_button, 4, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 29:6a9edb6e973b 2136 //
whismanoid 30:07197a430869 2137 // L@7 act=3 pin=5 if=2 ch=2 x=0.600000 -- button 5 event if A2 < 0.600000
whismanoid 30:07197a430869 2138 {action_button, 5, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 29:6a9edb6e973b 2139 //
whismanoid 17:9397ea3ea7e9 2140 #endif // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2141 //
whismanoid 17:9397ea3ea7e9 2142 {action_noop, 0, condition_always, 0, 0},
whismanoid 17:9397ea3ea7e9 2143 };
whismanoid 17:9397ea3ea7e9 2144 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2145
whismanoid 17:9397ea3ea7e9 2146 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2147 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 2148 uint8_t Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 2149 uint8_t need_reinit = true;
whismanoid 8:dffee7509bfb 2150 void Datalogger_PrintHeader(CmdLine& cmdLine);
whismanoid 5:aaf8b5f5fda1 2151 void Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 2152 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2153 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 2154 void Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 2155 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 8:dffee7509bfb 2156 void Datalogger_PrintRow(CmdLine& cmdLine);
whismanoid 4:d9b05924ad4c 2157
whismanoid 4:d9b05924ad4c 2158 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 2159 // Option to validate SPI link by reading PART_ID register
whismanoid 0:cb44e2e9ec4c 2160 #ifndef VERIFY_PART_ID_IN_LOOP
whismanoid 3:9055e17e181a 2161 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 2162 #define VERIFY_PART_ID_IN_LOOP 1
whismanoid 3:9055e17e181a 2163 #else
whismanoid 0:cb44e2e9ec4c 2164 #define VERIFY_PART_ID_IN_LOOP 0
whismanoid 3:9055e17e181a 2165 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2166 #endif
whismanoid 0:cb44e2e9ec4c 2167
whismanoid 3:9055e17e181a 2168 //--------------------------------------------------
whismanoid 3:9055e17e181a 2169 #define NUM_DUT_ANALOG_IN_CHANNELS 10
whismanoid 3:9055e17e181a 2170
whismanoid 3:9055e17e181a 2171 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 2172 // MAX11410 individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 3:9055e17e181a 2173 typedef enum SPI_AIN_Enable_t {
whismanoid 10:04022a61b527 2174 SPI_AIN_Disable = 0,
whismanoid 10:04022a61b527 2175 SPI_AIN_Enable_LSB = 1,
whismanoid 10:04022a61b527 2176 SPI_AIN_Enable_Volt = 2,
whismanoid 3:9055e17e181a 2177 } SPI_AIN_Enable_t;
whismanoid 3:9055e17e181a 2178 uint8_t SPI_AIN_Enable_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 2179 SPI_AIN_Enable_LSB, // AIN0 1=LSB
whismanoid 10:04022a61b527 2180 SPI_AIN_Enable_LSB, // AIN1 1=LSB
whismanoid 10:04022a61b527 2181 SPI_AIN_Enable_LSB, // AIN2 1=LSB
whismanoid 10:04022a61b527 2182 SPI_AIN_Enable_LSB, // AIN3 1=LSB
whismanoid 10:04022a61b527 2183 SPI_AIN_Enable_LSB, // AIN4 1=LSB
whismanoid 10:04022a61b527 2184 SPI_AIN_Enable_LSB, // AIN5 1=LSB
whismanoid 10:04022a61b527 2185 SPI_AIN_Enable_LSB, // AIN6 1=LSB
whismanoid 10:04022a61b527 2186 SPI_AIN_Enable_LSB, // AIN7 1=LSB
whismanoid 10:04022a61b527 2187 SPI_AIN_Enable_LSB, // AIN8 1=LSB
whismanoid 10:04022a61b527 2188 SPI_AIN_Enable_LSB, // AIN9 1=LSB
whismanoid 3:9055e17e181a 2189 };
whismanoid 3:9055e17e181a 2190 //
whismanoid 10:04022a61b527 2191 double SPI_AIN_Voltage[NUM_DUT_ANALOG_IN_CHANNELS];
whismanoid 13:184a08909405 2192 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2193 #ifndef HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 2194 #define HAS_SPI_AIN_customChannelHeader 0
whismanoid 13:184a08909405 2195 #endif
whismanoid 13:184a08909405 2196 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2197 const char* const SPI_AIN_customChannelHeader_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 2198 "", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 2199 "", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 2200 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 2201 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 2202 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 2203 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 2204 };
whismanoid 13:184a08909405 2205 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 3:9055e17e181a 2206 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2207 // ---------- Measure_Voltage_custom_props in Measure_Voltage @pre and in class properties ----------
whismanoid 3:9055e17e181a 2208 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 2209 // MAX11410 specific per-channel config register v_filter
whismanoid 3:9055e17e181a 2210 uint8_t SPI_AIN_Cfg_v_filter_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2211 0x34, // AIN0 @ v_filter=0x34
whismanoid 3:9055e17e181a 2212 0x34, // AIN1 @ v_filter=0x34
whismanoid 3:9055e17e181a 2213 0x34, // AIN2 @ v_filter=0x34
whismanoid 3:9055e17e181a 2214 0x34, // AIN3 @ v_filter=0x34
whismanoid 3:9055e17e181a 2215 0x34, // AIN4 @ v_filter=0x34
whismanoid 3:9055e17e181a 2216 0x34, // AIN5 @ v_filter=0x34
whismanoid 3:9055e17e181a 2217 0x34, // AIN6 @ v_filter=0x34
whismanoid 3:9055e17e181a 2218 0x34, // AIN7 @ v_filter=0x34
whismanoid 3:9055e17e181a 2219 0x34, // AIN8 @ v_filter=0x34
whismanoid 3:9055e17e181a 2220 0x34, // AIN9 @ v_filter=0x34
whismanoid 3:9055e17e181a 2221 };
whismanoid 3:9055e17e181a 2222 //
whismanoid 4:d9b05924ad4c 2223 // MAX11410 specific per-channel config register v_ctrl
whismanoid 3:9055e17e181a 2224 uint8_t SPI_AIN_Cfg_v_ctrl_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2225 0x42, // AIN0 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2226 0x42, // AIN1 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2227 0x42, // AIN2 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2228 0x42, // AIN3 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2229 0x42, // AIN4 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2230 0x42, // AIN5 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2231 0x42, // AIN6 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2232 0x42, // AIN7 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2233 0x42, // AIN8 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2234 0x42, // AIN9 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2235 };
whismanoid 3:9055e17e181a 2236 //
whismanoid 4:d9b05924ad4c 2237 // MAX11410 specific per-channel config register v_pga
whismanoid 3:9055e17e181a 2238 uint8_t SPI_AIN_Cfg_v_pga_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2239 0x00, // AIN0 @ v_pga=0x00
whismanoid 3:9055e17e181a 2240 0x00, // AIN1 @ v_pga=0x00
whismanoid 3:9055e17e181a 2241 0x00, // AIN2 @ v_pga=0x00
whismanoid 3:9055e17e181a 2242 0x00, // AIN3 @ v_pga=0x00
whismanoid 3:9055e17e181a 2243 0x00, // AIN4 @ v_pga=0x00
whismanoid 3:9055e17e181a 2244 0x00, // AIN5 @ v_pga=0x00
whismanoid 3:9055e17e181a 2245 0x00, // AIN6 @ v_pga=0x00
whismanoid 3:9055e17e181a 2246 0x00, // AIN7 @ v_pga=0x00
whismanoid 3:9055e17e181a 2247 0x00, // AIN8 @ v_pga=0x00
whismanoid 3:9055e17e181a 2248 0x00, // AIN9 @ v_pga=0x00
whismanoid 3:9055e17e181a 2249 };
whismanoid 3:9055e17e181a 2250 //
whismanoid 3:9055e17e181a 2251 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2252 // ---------- Measure_Voltage_custom_props ----------
whismanoid 0:cb44e2e9ec4c 2253 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2254 // filter register configuration in Measure_Voltage and Read_All_Voltages CONV_TYPE_01_Continuous
whismanoid 0:cb44e2e9ec4c 2255 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 2256 //~ const uint8_t custom_v_filter = 0x00; // @ v_filter=0x00 -- LINEF_00_50Hz_60Hz_FIR RATE_0000 | 1.1SPS
whismanoid 0:cb44e2e9ec4c 2257 //~ const uint8_t custom_v_filter = 0x01; // @ v_filter=0x01 -- LINEF_00_50Hz_60Hz_FIR RATE_0001 | 2.1SPS
whismanoid 0:cb44e2e9ec4c 2258 //~ const uint8_t custom_v_filter = 0x02; // @ v_filter=0x02 -- LINEF_00_50Hz_60Hz_FIR RATE_0010 | 4.2SPS
whismanoid 0:cb44e2e9ec4c 2259 //~ const uint8_t custom_v_filter = 0x03; // @ v_filter=0x03 -- LINEF_00_50Hz_60Hz_FIR RATE_0011 | 8.4SPS
whismanoid 0:cb44e2e9ec4c 2260 //~ const uint8_t custom_v_filter = 0x04; // @ v_filter=0x04 -- LINEF_00_50Hz_60Hz_FIR RATE_0100 | 16.8SPS
whismanoid 0:cb44e2e9ec4c 2261 //~ const uint8_t custom_v_filter = 0x10; // @ v_filter=0x10 -- LINEF_01_50Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 2262 //~ const uint8_t custom_v_filter = 0x11; // @ v_filter=0x11 -- LINEF_01_50Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 2263 //~ const uint8_t custom_v_filter = 0x12; // @ v_filter=0x12 -- LINEF_01_50Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 2264 //~ const uint8_t custom_v_filter = 0x13; // @ v_filter=0x13 -- LINEF_01_50Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 2265 //~ const uint8_t custom_v_filter = 0x14; // @ v_filter=0x14 -- LINEF_01_50Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 2266 //~ const uint8_t custom_v_filter = 0x15; // @ v_filter=0x15 -- LINEF_01_50Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 2267 //~ const uint8_t custom_v_filter = 0x20; // @ v_filter=0x20 -- LINEF_10_60Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 2268 //~ const uint8_t custom_v_filter = 0x21; // @ v_filter=0x21 -- LINEF_10_60Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 2269 //~ const uint8_t custom_v_filter = 0x22; // @ v_filter=0x22 -- LINEF_10_60Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 2270 //~ const uint8_t custom_v_filter = 0x23; // @ v_filter=0x23 -- LINEF_10_60Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 2271 //~ const uint8_t custom_v_filter = 0x24; // @ v_filter=0x24 -- LINEF_10_60Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 2272 //~ const uint8_t custom_v_filter = 0x25; // @ v_filter=0x25 -- LINEF_10_60Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 2273 //~ const uint8_t custom_v_filter = 0x30; // @ v_filter=0x30 -- LINEF_11_SINC4 RATE_0000 | 4SPS
whismanoid 0:cb44e2e9ec4c 2274 //~ const uint8_t custom_v_filter = 0x31; // @ v_filter=0x31 -- LINEF_11_SINC4 RATE_0001 | 10SPS
whismanoid 0:cb44e2e9ec4c 2275 //~ const uint8_t custom_v_filter = 0x32; // @ v_filter=0x32 -- LINEF_11_SINC4 RATE_0010 | 20SPS
whismanoid 0:cb44e2e9ec4c 2276 //~ const uint8_t custom_v_filter = 0x33; // @ v_filter=0x33 -- LINEF_11_SINC4 RATE_0011 | 40SPS
whismanoid 0:cb44e2e9ec4c 2277 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 2278 //~ const uint8_t custom_v_filter = 0x35; // @ v_filter=0x35 -- LINEF_11_SINC4 RATE_0101 | 120SPS
whismanoid 0:cb44e2e9ec4c 2279 //~ const uint8_t custom_v_filter = 0x36; // @ v_filter=0x36 -- LINEF_11_SINC4 RATE_0110 | 240SPS
whismanoid 0:cb44e2e9ec4c 2280 //~ const uint8_t custom_v_filter = 0x37; // @ v_filter=0x37 -- LINEF_11_SINC4 RATE_0111 | 480SPS
whismanoid 0:cb44e2e9ec4c 2281 //~ const uint8_t custom_v_filter = 0x38; // @ v_filter=0x38 -- LINEF_11_SINC4 RATE_1000 | 960SPS
whismanoid 0:cb44e2e9ec4c 2282 //~ const uint8_t custom_v_filter = 0x39; // @ v_filter=0x39 -- LINEF_11_SINC4 RATE_1001 | 1920SPS
whismanoid 0:cb44e2e9ec4c 2283 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2284 //
whismanoid 0:cb44e2e9ec4c 2285 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2286 // pga register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 0:cb44e2e9ec4c 2287 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 2288 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 2289 //~ const uint8_t custom_v_pga = 0x10; // @ v_pga=0x10 -- 0x10 SIG_PATH_01_BYPASS
whismanoid 0:cb44e2e9ec4c 2290 //~ const uint8_t custom_v_pga = 0x20; // @ v_pga=0x20 -- 0x20 SIG_PATH_10_PGA GAIN_000_1
whismanoid 0:cb44e2e9ec4c 2291 //~ const uint8_t custom_v_pga = 0x21; // @ v_pga=0x21 --*0x21 SIG_PATH_10_PGA GAIN_001_2
whismanoid 0:cb44e2e9ec4c 2292 //~ const uint8_t custom_v_pga = 0x22; // @ v_pga=0x22 -- 0x22 SIG_PATH_10_PGA GAIN_010_4
whismanoid 0:cb44e2e9ec4c 2293 //~ const uint8_t custom_v_pga = 0x23; // @ v_pga=0x23 -- 0x23 SIG_PATH_10_PGA GAIN_011_8
whismanoid 0:cb44e2e9ec4c 2294 //~ const uint8_t custom_v_pga = 0x24; // @ v_pga=0x24 -- 0x24 SIG_PATH_10_PGA GAIN_100_16
whismanoid 0:cb44e2e9ec4c 2295 //~ const uint8_t custom_v_pga = 0x25; // @ v_pga=0x25 -- 0x25 SIG_PATH_10_PGA GAIN_101_32
whismanoid 0:cb44e2e9ec4c 2296 //~ const uint8_t custom_v_pga = 0x26; // @ v_pga=0x26 -- 0x26 SIG_PATH_10_PGA GAIN_110_64
whismanoid 0:cb44e2e9ec4c 2297 //~ const uint8_t custom_v_pga = 0x27; // @ v_pga=0x27 -- 0x27 SIG_PATH_10_PGA GAIN_111_128
whismanoid 0:cb44e2e9ec4c 2298 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2299 //
whismanoid 0:cb44e2e9ec4c 2300 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2301 // ctrl register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 3:9055e17e181a 2302 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2303 //~ const uint8_t custom_v_ctrl = 0x40; // @ v_ctrl=0x40 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1
whismanoid 0:cb44e2e9ec4c 2304 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 2305 //~ const uint8_t custom_v_ctrl = 0x58; // @ v_ctrl=0x58 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 2306 //
whismanoid 0:cb44e2e9ec4c 2307 //~ const uint8_t custom_v_ctrl = 0x41; // @ v_ctrl=0x41 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N
whismanoid 0:cb44e2e9ec4c 2308 //~ const uint8_t custom_v_ctrl = 0x45; // @ v_ctrl=0x45 -- 0x40 unipolar, 0x05 REF_SEL_101_REF1P_AGND
whismanoid 0:cb44e2e9ec4c 2309 //~ const uint8_t custom_v_ctrl = 0x59; // @ v_ctrl=0x59 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 2310 //
whismanoid 0:cb44e2e9ec4c 2311 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2312 //~ const uint8_t custom_v_ctrl = 0x46; // @ v_ctrl=0x46 -- 0x40 unipolar, 0x06 REF_SEL_110_REF2P_AGND
whismanoid 0:cb44e2e9ec4c 2313 //~ const uint8_t custom_v_ctrl = 0x22; // @ v_ctrl=0x22 -- 0x20 bipolar offset binary, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2314 //~ const uint8_t custom_v_ctrl = 0x02; // @ v_ctrl=0x02 -- 0x00 bipolar 2's complement, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2315 //
whismanoid 0:cb44e2e9ec4c 2316 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 2317 //~ const uint8_t custom_v_ctrl = 0x47; // @ v_ctrl=0x47 -- 0x40 unipolar, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2318 //~ const uint8_t custom_v_ctrl = 0x27; // @ v_ctrl=0x27 -- 0x20 bipolar offset binary, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2319 //~ const uint8_t custom_v_ctrl = 0x07; // @ v_ctrl=0x07 -- 0x00 bipolar 2's complement, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2320 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2321
whismanoid 3:9055e17e181a 2322 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2323 // example code declare SPI interface (GPIO controlled CS)
whismanoid 0:cb44e2e9ec4c 2324 #if defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 2325 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 2326 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
whismanoid 19:5ff09c8e9daf 2327 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 2328 #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 2329 SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625PICO: pin P0_5 P0_6 P0_4
whismanoid 0:cb44e2e9ec4c 2330 DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32625PICO: pin P0_7
whismanoid 0:cb44e2e9ec4c 2331 #elif defined(TARGET_MAX32600MBED)
whismanoid 0:cb44e2e9ec4c 2332 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 0:cb44e2e9ec4c 2333 DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2334 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 2335 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 2336 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:cb44e2e9ec4c 2337 //
whismanoid 0:cb44e2e9ec4c 2338 // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses.
whismanoid 0:cb44e2e9ec4c 2339 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 2340 DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2341 //
whismanoid 0:cb44e2e9ec4c 2342 #else
whismanoid 3:9055e17e181a 2343 SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 3:9055e17e181a 2344 DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2345 #endif
whismanoid 0:cb44e2e9ec4c 2346
whismanoid 0:cb44e2e9ec4c 2347 // example code declare GPIO interface pins
whismanoid 0:cb44e2e9ec4c 2348 // example code declare device instance
whismanoid 3:9055e17e181a 2349 MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC);
whismanoid 3:9055e17e181a 2350 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2351
whismanoid 1:747f1602abfc 2352 //--------------------------------------------------
whismanoid 3:9055e17e181a 2353 // Option to Datalog Arduino platform analog inputs
whismanoid 3:9055e17e181a 2354 #ifndef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 2355 #define LOG_PLATFORM_AIN 6
whismanoid 3:9055e17e181a 2356 //~ #undef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 2357 #endif
whismanoid 3:9055e17e181a 2358 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 1:747f1602abfc 2359 //#ifndef NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 1:747f1602abfc 2360 //#define NUM_PLATFORM_ANALOG_IN_CHANNELS 6
whismanoid 1:747f1602abfc 2361 //#endif
whismanoid 1:747f1602abfc 2362 const int NUM_PLATFORM_ANALOG_IN_CHANNELS = 6;
whismanoid 1:747f1602abfc 2363 const double adc_full_scale_voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 2364 analogInPin_fullScaleVoltage[0], // 1.2,
whismanoid 10:04022a61b527 2365 analogInPin_fullScaleVoltage[1], // 1.2,
whismanoid 10:04022a61b527 2366 analogInPin_fullScaleVoltage[2], // 1.2,
whismanoid 10:04022a61b527 2367 analogInPin_fullScaleVoltage[3], // 1.2,
whismanoid 10:04022a61b527 2368 analogInPin_fullScaleVoltage[4], // 6.0
whismanoid 10:04022a61b527 2369 analogInPin_fullScaleVoltage[5], // 6.0
whismanoid 0:cb44e2e9ec4c 2370 };
whismanoid 9:45f98573eb6d 2371 // Platform ADC individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 9:45f98573eb6d 2372 typedef enum Platform_AIN_Enable_t {
whismanoid 9:45f98573eb6d 2373 Platform_AIN_Disable = 0,
whismanoid 9:45f98573eb6d 2374 Platform_AIN_Enable_LSB = 1,
whismanoid 9:45f98573eb6d 2375 Platform_AIN_Enable_Volt = 2,
whismanoid 9:45f98573eb6d 2376 } Platform_AIN_Enable_t;
whismanoid 13:184a08909405 2377 uint8_t Platform_Enable_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 9:45f98573eb6d 2378 Platform_AIN_Enable_Volt, // AIN0 2=Volt
whismanoid 9:45f98573eb6d 2379 Platform_AIN_Enable_Volt, // AIN1 2=Volt
whismanoid 9:45f98573eb6d 2380 Platform_AIN_Enable_Volt, // AIN2 2=Volt
whismanoid 9:45f98573eb6d 2381 Platform_AIN_Enable_Volt, // AIN3 2=Volt
whismanoid 9:45f98573eb6d 2382 Platform_AIN_Enable_Volt, // AIN4 2=Volt
whismanoid 9:45f98573eb6d 2383 Platform_AIN_Enable_Volt, // AIN5 2=Volt
whismanoid 9:45f98573eb6d 2384 };
whismanoid 34:a1993a1ee904 2385 // Option to apply calibration to Arduino platform analog inputs
whismanoid 34:a1993a1ee904 2386 #ifndef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2387 #define HAS_Platform_AIN_Calibration 1
whismanoid 34:a1993a1ee904 2388 //~ #undef HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2389 #endif
whismanoid 34:a1993a1ee904 2390 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2391 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 2392 // Calibration is between two points for each channel, defined by
whismanoid 34:a1993a1ee904 2393 // a normalized value between 0% and 100%, and the corresponding voltage.
whismanoid 34:a1993a1ee904 2394 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 2395 // calibration_05_normValue_0_1, calibration_05_V should be around 5% or 25%
whismanoid 34:a1993a1ee904 2396 double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 34:a1993a1ee904 2397 0.25,
whismanoid 34:a1993a1ee904 2398 0.25,
whismanoid 34:a1993a1ee904 2399 0.25,
whismanoid 34:a1993a1ee904 2400 0.25,
whismanoid 34:a1993a1ee904 2401 0.25,
whismanoid 34:a1993a1ee904 2402 0.25,
whismanoid 34:a1993a1ee904 2403 };
whismanoid 34:a1993a1ee904 2404 double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 34:a1993a1ee904 2405 0.3,
whismanoid 34:a1993a1ee904 2406 0.3,
whismanoid 34:a1993a1ee904 2407 0.3,
whismanoid 34:a1993a1ee904 2408 0.3,
whismanoid 34:a1993a1ee904 2409 1.5,
whismanoid 34:a1993a1ee904 2410 1.5,
whismanoid 34:a1993a1ee904 2411 };
whismanoid 34:a1993a1ee904 2412 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 2413 // calibration_95_normValue_0_1, calibration_95_V should be around 95% or 75%
whismanoid 34:a1993a1ee904 2414 double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 34:a1993a1ee904 2415 0.75,
whismanoid 34:a1993a1ee904 2416 0.75,
whismanoid 34:a1993a1ee904 2417 0.75,
whismanoid 34:a1993a1ee904 2418 0.75,
whismanoid 34:a1993a1ee904 2419 0.75,
whismanoid 34:a1993a1ee904 2420 0.75,
whismanoid 34:a1993a1ee904 2421 };
whismanoid 34:a1993a1ee904 2422 double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 34:a1993a1ee904 2423 0.9,
whismanoid 34:a1993a1ee904 2424 0.9,
whismanoid 34:a1993a1ee904 2425 0.9,
whismanoid 34:a1993a1ee904 2426 0.9,
whismanoid 34:a1993a1ee904 2427 4.5,
whismanoid 34:a1993a1ee904 2428 4.5,
whismanoid 34:a1993a1ee904 2429 };
whismanoid 34:a1993a1ee904 2430 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2431 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2432 double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1)
whismanoid 34:a1993a1ee904 2433 {
whismanoid 34:a1993a1ee904 2434 // TODO: return corrected normValue_0_1 using two-point linear calibration
whismanoid 34:a1993a1ee904 2435 // point 1: calibration_05_normValue_0_1[ch], calibration_05_V[ch]
whismanoid 34:a1993a1ee904 2436 // point 2: calibration_95_normValue_0_1[ch], calibration_95_V[ch]
whismanoid 34:a1993a1ee904 2437 // validate that there is enough span to get sensible results
whismanoid 34:a1993a1ee904 2438 //
whismanoid 34:a1993a1ee904 2439 int ch = channel_0_5;
whismanoid 34:a1993a1ee904 2440 // 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 2441 // ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 2442 // ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 2443 // ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 2444 // ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 2445 // );
whismanoid 34:a1993a1ee904 2446 // cmdLine.serial().printf("\r\n adc_full_scale_voltage[%d] = %1.6fV",
whismanoid 34:a1993a1ee904 2447 // ch,
whismanoid 34:a1993a1ee904 2448 // adc_full_scale_voltage[ch]
whismanoid 34:a1993a1ee904 2449 // );
whismanoid 34:a1993a1ee904 2450 // raw normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 2451 double raw_05_normValue = calibration_05_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 2452 double raw_95_normValue = calibration_95_normValue_0_1[ch];
whismanoid 34:a1993a1ee904 2453 // calibrated normValue nominal 5% and 95% points
whismanoid 34:a1993a1ee904 2454 // divide V/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 2455 double cal_05_normValue = calibration_05_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 2456 double cal_95_normValue = calibration_95_V[ch] / adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 2457 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_05_normValue = %1.6f",
whismanoid 34:a1993a1ee904 2458 // ch,
whismanoid 34:a1993a1ee904 2459 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2460 // cal_05_normValue
whismanoid 34:a1993a1ee904 2461 // );
whismanoid 34:a1993a1ee904 2462 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) cal_95_normValue = %1.6f",
whismanoid 34:a1993a1ee904 2463 // ch,
whismanoid 34:a1993a1ee904 2464 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2465 // cal_95_normValue
whismanoid 34:a1993a1ee904 2466 // );
whismanoid 34:a1993a1ee904 2467 //
whismanoid 34:a1993a1ee904 2468 double span_raw = raw_95_normValue - raw_05_normValue;
whismanoid 34:a1993a1ee904 2469 double span_cal = cal_95_normValue - cal_05_normValue;
whismanoid 34:a1993a1ee904 2470 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_raw = %1.6f",
whismanoid 34:a1993a1ee904 2471 // ch,
whismanoid 34:a1993a1ee904 2472 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2473 // span_raw
whismanoid 34:a1993a1ee904 2474 // );
whismanoid 34:a1993a1ee904 2475 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) span_cal = %1.6f",
whismanoid 34:a1993a1ee904 2476 // ch,
whismanoid 34:a1993a1ee904 2477 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2478 // span_cal
whismanoid 34:a1993a1ee904 2479 // );
whismanoid 34:a1993a1ee904 2480 // if calibration is not valid, return unmodified normValue_0_1 and print a warning
whismanoid 34:a1993a1ee904 2481 if (span_raw < 0.001) {
whismanoid 34:a1993a1ee904 2482 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_raw = %1.6f",
whismanoid 34:a1993a1ee904 2483 ch,
whismanoid 34:a1993a1ee904 2484 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2485 span_raw
whismanoid 34:a1993a1ee904 2486 );
whismanoid 34:a1993a1ee904 2487 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 2488 }
whismanoid 34:a1993a1ee904 2489 if (span_cal < 0.001) {
whismanoid 34:a1993a1ee904 2490 cmdLine.serial().printf("\r\n! CalibratedNormValue(%d, %1.6f) ERRRRRR span_cal = %1.6f",
whismanoid 34:a1993a1ee904 2491 ch,
whismanoid 34:a1993a1ee904 2492 raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2493 span_cal
whismanoid 34:a1993a1ee904 2494 );
whismanoid 34:a1993a1ee904 2495 return raw_normValue_0_1;
whismanoid 34:a1993a1ee904 2496 }
whismanoid 34:a1993a1ee904 2497 double slope_correction = span_cal / span_raw;
whismanoid 34:a1993a1ee904 2498 double corrected_normValue_0_1 = cal_05_normValue + ((raw_normValue_0_1 - raw_05_normValue) * slope_correction);
whismanoid 34:a1993a1ee904 2499 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) slope_correction = %1.6f",
whismanoid 34:a1993a1ee904 2500 // ch,
whismanoid 34:a1993a1ee904 2501 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2502 // slope_correction
whismanoid 34:a1993a1ee904 2503 // );
whismanoid 34:a1993a1ee904 2504 // cmdLine.serial().printf("\r\n CalibratedNormValue(%d, %1.6f) corrected_normValue_0_1 = %1.6f\r\n",
whismanoid 34:a1993a1ee904 2505 // ch,
whismanoid 34:a1993a1ee904 2506 // raw_normValue_0_1,
whismanoid 34:a1993a1ee904 2507 // corrected_normValue_0_1
whismanoid 34:a1993a1ee904 2508 // );
whismanoid 34:a1993a1ee904 2509 return corrected_normValue_0_1;
whismanoid 34:a1993a1ee904 2510 }
whismanoid 34:a1993a1ee904 2511 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 2512 // Option to customize channel names in datalog header line
whismanoid 13:184a08909405 2513 #ifndef HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 2514 #define HAS_Platform_AIN_customChannelHeader 1
whismanoid 13:184a08909405 2515 #endif
whismanoid 13:184a08909405 2516 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2517 const char* const Platform_AIN_customChannelHeader_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 2518 "=AIN4", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 2519 "=AIN5", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 2520 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 2521 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 2522 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 2523 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 2524 };
whismanoid 13:184a08909405 2525 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 1:747f1602abfc 2526 //--------------------------------------------------
whismanoid 1:747f1602abfc 2527 // Option to log platform analog inputs as raw LSB code
whismanoid 1:747f1602abfc 2528 #ifndef LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 2529 #define LOG_PLATFORM_ANALOG_IN_LSB 0
whismanoid 1:747f1602abfc 2530 #endif
whismanoid 1:747f1602abfc 2531 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 2532 int Platform_LSB[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 2533 #endif
whismanoid 1:747f1602abfc 2534
whismanoid 1:747f1602abfc 2535 //--------------------------------------------------
whismanoid 1:747f1602abfc 2536 // Option to use platform analog inputs as Voltage
whismanoid 1:747f1602abfc 2537 #ifndef LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 2538 #define LOG_PLATFORM_ANALOG_IN_VOLTS 1
whismanoid 1:747f1602abfc 2539 #endif
whismanoid 1:747f1602abfc 2540 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 2541 double Platform_Voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 2542 #endif
whismanoid 3:9055e17e181a 2543 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 0:cb44e2e9ec4c 2544
whismanoid 10:04022a61b527 2545 //--------------------------------------------------
whismanoid 10:04022a61b527 2546 // Option to use Command forwarding to Auxiliary serial port
whismanoid 10:04022a61b527 2547 // Command forwarding to Auxiliary serial port TX/RX
whismanoid 10:04022a61b527 2548 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial
whismanoid 10:04022a61b527 2549 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial
whismanoid 10:04022a61b527 2550 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 2551 #ifndef USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2552 #define USE_AUX_SERIAL_CMD_FORWARDING 1
whismanoid 10:04022a61b527 2553 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2554 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2555 // Command forwarding to Auxiliary serial port TX/RX #257 -- global parameters
whismanoid 10:04022a61b527 2556 const size_t RX_STRING_BUF_SIZE = 1000;
whismanoid 10:04022a61b527 2557 int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 2558 // transmit command string by AUX TX
whismanoid 10:04022a61b527 2559 #if 0
whismanoid 10:04022a61b527 2560 int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 2561 int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 2562 int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 2563 #endif
whismanoid 10:04022a61b527 2564 // capture received string from AUX RX
whismanoid 10:04022a61b527 2565 Timer g_auxSerialCom_Timer;
whismanoid 10:04022a61b527 2566 int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 2567 int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 2568 int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 2569 int g_auxSerialCom_rx_idle_ms = 500; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 2570 int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 2571 const int aux_serial_cmd_forwarding_rx_eot_not_used = 'x';
whismanoid 10:04022a61b527 2572 int g_auxSerialCom_rx_eot = aux_serial_cmd_forwarding_rx_eot_not_used; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 2573 //~ int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text string?
whismanoid 10:04022a61b527 2574 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2575 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2576 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257
whismanoid 10:04022a61b527 2577 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 2578 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2579 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2580 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2581 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 2582 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2583 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 2584 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2585 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2586 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2587 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2588 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2589 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 2590 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2591 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2592
whismanoid 8:dffee7509bfb 2593 // CODE GENERATOR: example code for ADC: serial port declaration
whismanoid 8:dffee7509bfb 2594 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2595 // Declare the Serial driver
whismanoid 8:dffee7509bfb 2596 // default baud rate settings are 9600 8N1
whismanoid 8:dffee7509bfb 2597 // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
whismanoid 8:dffee7509bfb 2598 // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
whismanoid 8:dffee7509bfb 2599 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2600 #if defined(TARGET_MAX32630)
whismanoid 8:dffee7509bfb 2601 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 2602 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2603 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2604 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 2605 //
whismanoid 8:dffee7509bfb 2606 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2607 Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2608 //Serial J3AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 2609 //Serial BTAUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 2610 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 2611 //
whismanoid 8:dffee7509bfb 2612 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2613 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2614 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2615 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2616 //
whismanoid 8:dffee7509bfb 2617 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2618 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2619 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2620 USBSerial serial;
whismanoid 8:dffee7509bfb 2621 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2622 #elif defined(TARGET_MAX32625MBED)
whismanoid 8:dffee7509bfb 2623 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625MBED: P0_1,P0_0 (Arduino D1,D0)
whismanoid 8:dffee7509bfb 2624 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2625 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625MBED: P3_1,P3_0 (J15-LEDgreen,LEDred)
whismanoid 8:dffee7509bfb 2626 //
whismanoid 8:dffee7509bfb 2627 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2628 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2629 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2630 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2631 //
whismanoid 8:dffee7509bfb 2632 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2633 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2634 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2635 USBSerial serial;
whismanoid 8:dffee7509bfb 2636 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 2637 #elif defined(TARGET_MAX32625PICO)
whismanoid 8:dffee7509bfb 2638 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 2639 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625PICO: P2_1,P2_0 (underside?)
whismanoid 8:dffee7509bfb 2640 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2641 //
whismanoid 8:dffee7509bfb 2642 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2643 Serial AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 2644 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 2645 //
whismanoid 8:dffee7509bfb 2646 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2647 Serial DAPLINKserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2648 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2649 //
whismanoid 8:dffee7509bfb 2650 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2651 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2652 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2653 USBSerial serial;
whismanoid 22:d6dc8a85f435 2654 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 2655 #elif defined(TARGET_MAX40108DEMOP2U9)
whismanoid 22:d6dc8a85f435 2656 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 2657 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK)
whismanoid 22:d6dc8a85f435 2658 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 2659 //
whismanoid 22:d6dc8a85f435 2660 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial is used as main serial port in MAX40108 Demo board
whismanoid 22:d6dc8a85f435 2661 Serial serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 2662 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 2663 //
whismanoid 22:d6dc8a85f435 2664 // Hardware serial port over DAPLink
whismanoid 22:d6dc8a85f435 2665 // connection to external MAX32625PICO(DAPLINK) needed TX/RX swap in firmware.
whismanoid 22:d6dc8a85f435 2666 // MAX32625PICO(DAPLINK) drives DAPLINK.8, listens on DAPLINK.6.
whismanoid 22:d6dc8a85f435 2667 // See AN6350 MAX32625 Users Guide 7.5.2.3.1 TX and RX Pin Mapping for UART 1 -- Mapping Option B
whismanoid 22:d6dc8a85f435 2668 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 22:d6dc8a85f435 2669 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 22:d6dc8a85f435 2670 #define HAS_DAPLINK_SERIAL 1
whismanoid 22:d6dc8a85f435 2671 //
whismanoid 22:d6dc8a85f435 2672 // Serial AUXserial(UART1_TX,UART1_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 2673 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 2674 //
whismanoid 22:d6dc8a85f435 2675 // Virtual serial port over USB
whismanoid 22:d6dc8a85f435 2676 // #include "USBSerial.h"
whismanoid 22:d6dc8a85f435 2677 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 22:d6dc8a85f435 2678 //USBSerial serial;
whismanoid 8:dffee7509bfb 2679 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2680 #elif defined(TARGET_MAX32620FTHR)
whismanoid 8:dffee7509bfb 2681 #warning "TARGET_MAX32620FTHR not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 2682 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 2683 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32620FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2684 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2685 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 2686 //
whismanoid 8:dffee7509bfb 2687 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2688 Serial serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2689 //Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2690 Serial AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 2691 //Serial PMOD0AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 2692 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 2693 //
whismanoid 8:dffee7509bfb 2694 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2695 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2696 Serial DAPLINKserial(USBTX, USBRX); // tx,rx MAX32620FTHR: P2_1,P2_0
whismanoid 8:dffee7509bfb 2697 //Serial DAPLINKserial(STDIO_UART_TX, STDIO_UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 2698 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2699 //
whismanoid 8:dffee7509bfb 2700 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2701 // #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2702 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2703 //USBSerial serial; // MAX32620FTHR: USBSerial crash??
whismanoid 8:dffee7509bfb 2704 #warning "TARGET_MAX32620FTHR not previously tested; USBSerial crash?"
whismanoid 8:dffee7509bfb 2705 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2706 #elif defined(TARGET_MAX32600)
whismanoid 8:dffee7509bfb 2707 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 2708 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART2 MAX32625MBED: P1_3,P1_2 (Arduino D3,D2)
whismanoid 8:dffee7509bfb 2709 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART1 MAX32625MBED: P7_3,P7_2 ( ?? )
whismanoid 8:dffee7509bfb 2710 //
whismanoid 8:dffee7509bfb 2711 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2712 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2713 Serial DAPLINKserial(P1_1,P1_0); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 2714 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2715 //
whismanoid 8:dffee7509bfb 2716 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2717 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2718 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2719 USBSerial serial;
whismanoid 8:dffee7509bfb 2720 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2721 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 8:dffee7509bfb 2722 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 2723 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2724 #else
whismanoid 8:dffee7509bfb 2725 #if defined(SERIAL_TX)
whismanoid 8:dffee7509bfb 2726 #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..."
whismanoid 8:dffee7509bfb 2727 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 2728 #elif defined(USBTX)
whismanoid 8:dffee7509bfb 2729 #warning "target not previously tested; guess serial pins are USBTX, USBRX..."
whismanoid 8:dffee7509bfb 2730 Serial serial(USBTX, USBRX); // tx, rx
whismanoid 8:dffee7509bfb 2731 #elif defined(UART_TX)
whismanoid 8:dffee7509bfb 2732 #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..."
whismanoid 8:dffee7509bfb 2733 Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 2734 #else
whismanoid 8:dffee7509bfb 2735 #warning "target not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 2736 #endif
whismanoid 8:dffee7509bfb 2737 #endif
whismanoid 8:dffee7509bfb 2738 //
whismanoid 8:dffee7509bfb 2739 #include "CmdLine.h"
whismanoid 8:dffee7509bfb 2740
whismanoid 8:dffee7509bfb 2741 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 2742 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2743 CmdLine cmdLine_AUXserial(AUXserial, "AUXserial");
whismanoid 10:04022a61b527 2744 uint8_t Datalogger_enable_AUXserial = {
whismanoid 10:04022a61b527 2745 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2746 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 2747 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 2748 false
whismanoid 10:04022a61b527 2749 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2750 true
whismanoid 10:04022a61b527 2751 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2752 };
whismanoid 8:dffee7509bfb 2753 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 2754 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 2755 CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK");
whismanoid 8:dffee7509bfb 2756 uint8_t Datalogger_enable_DAPLINKserial = true;
whismanoid 8:dffee7509bfb 2757 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 2758 CmdLine cmdLine(serial, "serial");
whismanoid 8:dffee7509bfb 2759 uint8_t Datalogger_enable_serial = true;
whismanoid 8:dffee7509bfb 2760 // CODE GENERATOR: example code for ADC: serial port declaration (end)
whismanoid 8:dffee7509bfb 2761
whismanoid 21:ac062a97a71d 2762
whismanoid 21:ac062a97a71d 2763 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 2764 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 2765 #ifndef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 2766 #define USE_DATALOGGER_CommandTable 1
whismanoid 23:c6c652bef4b9 2767 //~ #undef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 2768 #endif
whismanoid 23:c6c652bef4b9 2769 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 2770 const int COMMAND_TABLE_ROW_MAX = 10;
whismanoid 23:c6c652bef4b9 2771 const int COMMAND_TABLE_COL_MAX = 40;
whismanoid 23:c6c652bef4b9 2772 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 2773 //
whismanoid 23:c6c652bef4b9 2774 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 2775 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 2776 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 2777 char onButton1_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button1 event";
whismanoid 23:c6c652bef4b9 2778 char onButton1_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 23:c6c652bef4b9 2779 char onButton1_command_table_02[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 23:c6c652bef4b9 2780 char onButton1_command_table_03[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 23:c6c652bef4b9 2781 char onButton1_command_table_04[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 23:c6c652bef4b9 2782 char onButton1_command_table_05[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 23:c6c652bef4b9 2783 char onButton1_command_table_06[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 23:c6c652bef4b9 2784 char onButton1_command_table_07[COMMAND_TABLE_COL_MAX] = "LR";
whismanoid 23:c6c652bef4b9 2785 char onButton1_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2786 char onButton1_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2787 static char* onButton1_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 2788 onButton1_command_table_00,
whismanoid 23:c6c652bef4b9 2789 onButton1_command_table_01,
whismanoid 23:c6c652bef4b9 2790 onButton1_command_table_02,
whismanoid 23:c6c652bef4b9 2791 onButton1_command_table_03,
whismanoid 23:c6c652bef4b9 2792 onButton1_command_table_04,
whismanoid 23:c6c652bef4b9 2793 onButton1_command_table_05,
whismanoid 23:c6c652bef4b9 2794 onButton1_command_table_06,
whismanoid 23:c6c652bef4b9 2795 onButton1_command_table_07,
whismanoid 23:c6c652bef4b9 2796 onButton1_command_table_08,
whismanoid 23:c6c652bef4b9 2797 onButton1_command_table_09,
whismanoid 23:c6c652bef4b9 2798 };
whismanoid 23:c6c652bef4b9 2799 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 2800 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 2801 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 2802 char onButton2_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button2 event";
whismanoid 23:c6c652bef4b9 2803 char onButton2_command_table_01[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 23:c6c652bef4b9 2804 char onButton2_command_table_02[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 23:c6c652bef4b9 2805 char onButton2_command_table_03[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 23:c6c652bef4b9 2806 char onButton2_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2807 char onButton2_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2808 char onButton2_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2809 char onButton2_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2810 char onButton2_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2811 char onButton2_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2812 static char* onButton2_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 2813 onButton2_command_table_00,
whismanoid 23:c6c652bef4b9 2814 onButton2_command_table_01,
whismanoid 23:c6c652bef4b9 2815 onButton2_command_table_02,
whismanoid 23:c6c652bef4b9 2816 onButton2_command_table_03,
whismanoid 23:c6c652bef4b9 2817 onButton2_command_table_04,
whismanoid 23:c6c652bef4b9 2818 onButton2_command_table_05,
whismanoid 23:c6c652bef4b9 2819 onButton2_command_table_06,
whismanoid 23:c6c652bef4b9 2820 onButton2_command_table_07,
whismanoid 23:c6c652bef4b9 2821 onButton2_command_table_08,
whismanoid 23:c6c652bef4b9 2822 onButton2_command_table_09,
whismanoid 23:c6c652bef4b9 2823 };
whismanoid 23:c6c652bef4b9 2824 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 2825 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 2826 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 2827 char onButton3_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button3 event";
whismanoid 24:032f3683cb2a 2828 char onButton3_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 24:032f3683cb2a 2829 char onButton3_command_table_02[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 24:032f3683cb2a 2830 char onButton3_command_table_03[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 24:032f3683cb2a 2831 char onButton3_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 2832 char onButton3_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 2833 char onButton3_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 2834 char onButton3_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 2835 char onButton3_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 2836 char onButton3_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 2837 static char* onButton3_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 24:032f3683cb2a 2838 onButton3_command_table_00,
whismanoid 24:032f3683cb2a 2839 onButton3_command_table_01,
whismanoid 24:032f3683cb2a 2840 onButton3_command_table_02,
whismanoid 24:032f3683cb2a 2841 onButton3_command_table_03,
whismanoid 24:032f3683cb2a 2842 onButton3_command_table_04,
whismanoid 24:032f3683cb2a 2843 onButton3_command_table_05,
whismanoid 24:032f3683cb2a 2844 onButton3_command_table_06,
whismanoid 24:032f3683cb2a 2845 onButton3_command_table_07,
whismanoid 24:032f3683cb2a 2846 onButton3_command_table_08,
whismanoid 24:032f3683cb2a 2847 onButton3_command_table_09,
whismanoid 24:032f3683cb2a 2848 };
whismanoid 24:032f3683cb2a 2849 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 2850 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 2851 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 2852 char onButton4_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button4 event";
whismanoid 30:07197a430869 2853 char onButton4_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE>0.7:active";
whismanoid 29:6a9edb6e973b 2854 char onButton4_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2855 char onButton4_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2856 char onButton4_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2857 char onButton4_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2858 char onButton4_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2859 char onButton4_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2860 char onButton4_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2861 char onButton4_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2862 static char* onButton4_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 2863 onButton4_command_table_00,
whismanoid 29:6a9edb6e973b 2864 onButton4_command_table_01,
whismanoid 29:6a9edb6e973b 2865 onButton4_command_table_02,
whismanoid 29:6a9edb6e973b 2866 onButton4_command_table_03,
whismanoid 29:6a9edb6e973b 2867 onButton4_command_table_04,
whismanoid 29:6a9edb6e973b 2868 onButton4_command_table_05,
whismanoid 29:6a9edb6e973b 2869 onButton4_command_table_06,
whismanoid 29:6a9edb6e973b 2870 onButton4_command_table_07,
whismanoid 29:6a9edb6e973b 2871 onButton4_command_table_08,
whismanoid 29:6a9edb6e973b 2872 onButton4_command_table_09,
whismanoid 29:6a9edb6e973b 2873 };
whismanoid 29:6a9edb6e973b 2874 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 2875 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 2876 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 2877 char onButton5_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button5 event";
whismanoid 30:07197a430869 2878 char onButton5_command_table_01[COMMAND_TABLE_COL_MAX] = "# WE<0.6:sleep";
whismanoid 29:6a9edb6e973b 2879 char onButton5_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2880 char onButton5_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2881 char onButton5_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2882 char onButton5_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2883 char onButton5_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2884 char onButton5_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2885 char onButton5_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2886 char onButton5_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2887 static char* onButton5_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 2888 onButton5_command_table_00,
whismanoid 29:6a9edb6e973b 2889 onButton5_command_table_01,
whismanoid 29:6a9edb6e973b 2890 onButton5_command_table_02,
whismanoid 29:6a9edb6e973b 2891 onButton5_command_table_03,
whismanoid 29:6a9edb6e973b 2892 onButton5_command_table_04,
whismanoid 29:6a9edb6e973b 2893 onButton5_command_table_05,
whismanoid 29:6a9edb6e973b 2894 onButton5_command_table_06,
whismanoid 29:6a9edb6e973b 2895 onButton5_command_table_07,
whismanoid 29:6a9edb6e973b 2896 onButton5_command_table_08,
whismanoid 29:6a9edb6e973b 2897 onButton5_command_table_09,
whismanoid 29:6a9edb6e973b 2898 };
whismanoid 29:6a9edb6e973b 2899 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 2900 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 2901 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 2902 char onButton6_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button6 event";
whismanoid 29:6a9edb6e973b 2903 char onButton6_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2904 char onButton6_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2905 char onButton6_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2906 char onButton6_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2907 char onButton6_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2908 char onButton6_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2909 char onButton6_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2910 char onButton6_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2911 char onButton6_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2912 static char* onButton6_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 2913 onButton6_command_table_00,
whismanoid 29:6a9edb6e973b 2914 onButton6_command_table_01,
whismanoid 29:6a9edb6e973b 2915 onButton6_command_table_02,
whismanoid 29:6a9edb6e973b 2916 onButton6_command_table_03,
whismanoid 29:6a9edb6e973b 2917 onButton6_command_table_04,
whismanoid 29:6a9edb6e973b 2918 onButton6_command_table_05,
whismanoid 29:6a9edb6e973b 2919 onButton6_command_table_06,
whismanoid 29:6a9edb6e973b 2920 onButton6_command_table_07,
whismanoid 29:6a9edb6e973b 2921 onButton6_command_table_08,
whismanoid 29:6a9edb6e973b 2922 onButton6_command_table_09,
whismanoid 29:6a9edb6e973b 2923 };
whismanoid 29:6a9edb6e973b 2924 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 2925 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 2926 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 2927 char onButton7_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button7 event";
whismanoid 29:6a9edb6e973b 2928 char onButton7_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2929 char onButton7_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2930 char onButton7_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2931 char onButton7_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2932 char onButton7_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2933 char onButton7_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2934 char onButton7_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2935 char onButton7_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2936 char onButton7_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2937 static char* onButton7_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 2938 onButton7_command_table_00,
whismanoid 29:6a9edb6e973b 2939 onButton7_command_table_01,
whismanoid 29:6a9edb6e973b 2940 onButton7_command_table_02,
whismanoid 29:6a9edb6e973b 2941 onButton7_command_table_03,
whismanoid 29:6a9edb6e973b 2942 onButton7_command_table_04,
whismanoid 29:6a9edb6e973b 2943 onButton7_command_table_05,
whismanoid 29:6a9edb6e973b 2944 onButton7_command_table_06,
whismanoid 29:6a9edb6e973b 2945 onButton7_command_table_07,
whismanoid 29:6a9edb6e973b 2946 onButton7_command_table_08,
whismanoid 29:6a9edb6e973b 2947 onButton7_command_table_09,
whismanoid 29:6a9edb6e973b 2948 };
whismanoid 29:6a9edb6e973b 2949 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 2950 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 2951 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 2952 char onButton8_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button8 event";
whismanoid 29:6a9edb6e973b 2953 char onButton8_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2954 char onButton8_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2955 char onButton8_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2956 char onButton8_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2957 char onButton8_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2958 char onButton8_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2959 char onButton8_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2960 char onButton8_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2961 char onButton8_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2962 static char* onButton8_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 2963 onButton8_command_table_00,
whismanoid 29:6a9edb6e973b 2964 onButton8_command_table_01,
whismanoid 29:6a9edb6e973b 2965 onButton8_command_table_02,
whismanoid 29:6a9edb6e973b 2966 onButton8_command_table_03,
whismanoid 29:6a9edb6e973b 2967 onButton8_command_table_04,
whismanoid 29:6a9edb6e973b 2968 onButton8_command_table_05,
whismanoid 29:6a9edb6e973b 2969 onButton8_command_table_06,
whismanoid 29:6a9edb6e973b 2970 onButton8_command_table_07,
whismanoid 29:6a9edb6e973b 2971 onButton8_command_table_08,
whismanoid 29:6a9edb6e973b 2972 onButton8_command_table_09,
whismanoid 29:6a9edb6e973b 2973 };
whismanoid 29:6a9edb6e973b 2974 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 2975 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 2976 // command_table: list of commands to perform on button press
whismanoid 29:6a9edb6e973b 2977 char onButton9_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button9 event";
whismanoid 29:6a9edb6e973b 2978 char onButton9_command_table_01[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2979 char onButton9_command_table_02[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2980 char onButton9_command_table_03[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2981 char onButton9_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2982 char onButton9_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2983 char onButton9_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2984 char onButton9_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2985 char onButton9_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2986 char onButton9_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 29:6a9edb6e973b 2987 static char* onButton9_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 29:6a9edb6e973b 2988 onButton9_command_table_00,
whismanoid 29:6a9edb6e973b 2989 onButton9_command_table_01,
whismanoid 29:6a9edb6e973b 2990 onButton9_command_table_02,
whismanoid 29:6a9edb6e973b 2991 onButton9_command_table_03,
whismanoid 29:6a9edb6e973b 2992 onButton9_command_table_04,
whismanoid 29:6a9edb6e973b 2993 onButton9_command_table_05,
whismanoid 29:6a9edb6e973b 2994 onButton9_command_table_06,
whismanoid 29:6a9edb6e973b 2995 onButton9_command_table_07,
whismanoid 29:6a9edb6e973b 2996 onButton9_command_table_08,
whismanoid 29:6a9edb6e973b 2997 onButton9_command_table_09,
whismanoid 29:6a9edb6e973b 2998 };
whismanoid 29:6a9edb6e973b 2999 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3000 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3001 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3002 #if USE_DATALOGGER_CommandTable
whismanoid 31:47eee7e0cc2d 3003 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3004 bool g_Run_command_table_running = false;
whismanoid 23:c6c652bef4b9 3005 void Run_command_table(char* command_table[])
whismanoid 23:c6c652bef4b9 3006 {
whismanoid 23:c6c652bef4b9 3007 // command_table: perform list of commands
whismanoid 31:47eee7e0cc2d 3008 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3009 if (g_Run_command_table_running) {
whismanoid 31:47eee7e0cc2d 3010 // TODO: button event chaining is not supported at this time
whismanoid 31:47eee7e0cc2d 3011 } // if (g_Run_command_table_running)
whismanoid 31:47eee7e0cc2d 3012 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3013 g_Run_command_table_running = true;
whismanoid 23:c6c652bef4b9 3014 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 3015 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 3016 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 23:c6c652bef4b9 3017 cmdLine.clear();
whismanoid 31:47eee7e0cc2d 3018 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3019 //~ char* strIndex = command_table[lineIndex];
whismanoid 23:c6c652bef4b9 3020 for (char* strIndex = command_table[lineIndex]; *strIndex != '\0'; strIndex++)
whismanoid 23:c6c652bef4b9 3021 {
whismanoid 23:c6c652bef4b9 3022 cmdLine.append(*strIndex);
whismanoid 23:c6c652bef4b9 3023 }
whismanoid 23:c6c652bef4b9 3024 cmdLine.append('\r'); // append \r invokes onEOLcommandParser to handle command
whismanoid 23:c6c652bef4b9 3025 }
whismanoid 31:47eee7e0cc2d 3026 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 3027 g_Run_command_table_running = false;
whismanoid 31:47eee7e0cc2d 3028 cmdLine.quiet = g_Run_command_table_running;
whismanoid 23:c6c652bef4b9 3029 }
whismanoid 23:c6c652bef4b9 3030 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3031 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3032 // When user presses button BUTTON1, perform actions
whismanoid 21:ac062a97a71d 3033 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3034 void onButton1FallingEdge(void)
whismanoid 21:ac062a97a71d 3035 {
whismanoid 21:ac062a97a71d 3036 //~ void SelfTest(CmdLine & cmdLine);
whismanoid 21:ac062a97a71d 3037 //~ SelfTest(cmdLine_serial);
whismanoid 22:d6dc8a85f435 3038 //
whismanoid 23:c6c652bef4b9 3039 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3040 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3041 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3042 Run_command_table(onButton1_command_table);
whismanoid 23:c6c652bef4b9 3043 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3044 }
whismanoid 21:ac062a97a71d 3045 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3046
whismanoid 21:ac062a97a71d 3047 //--------------------------------------------------
whismanoid 21:ac062a97a71d 3048 // When user presses button BUTTON2, perform actions
whismanoid 21:ac062a97a71d 3049 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3050 void onButton2FallingEdge(void)
whismanoid 21:ac062a97a71d 3051 {
whismanoid 21:ac062a97a71d 3052 // TBD demo configuration
whismanoid 21:ac062a97a71d 3053 // TODO diagnostic LED
whismanoid 21:ac062a97a71d 3054 // led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 22:d6dc8a85f435 3055 //
whismanoid 23:c6c652bef4b9 3056 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 3057 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 3058 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 3059 Run_command_table(onButton2_command_table);
whismanoid 23:c6c652bef4b9 3060 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 3061 }
whismanoid 21:ac062a97a71d 3062 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 3063
whismanoid 24:032f3683cb2a 3064 //--------------------------------------------------
whismanoid 29:6a9edb6e973b 3065 // When user presses button BUTTON3, perform actions
whismanoid 24:032f3683cb2a 3066 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3067 void onButton3FallingEdge(void)
whismanoid 24:032f3683cb2a 3068 {
whismanoid 24:032f3683cb2a 3069 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 24:032f3683cb2a 3070 // command_table: list of commands to perform on button press
whismanoid 24:032f3683cb2a 3071 // command_table: perform list of commands
whismanoid 24:032f3683cb2a 3072 Run_command_table(onButton3_command_table);
whismanoid 24:032f3683cb2a 3073 #endif // USE_DATALOGGER_CommandTable
whismanoid 24:032f3683cb2a 3074 }
whismanoid 24:032f3683cb2a 3075 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3076 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3077 void onButton4FallingEdge(void)
whismanoid 29:6a9edb6e973b 3078 {
whismanoid 29:6a9edb6e973b 3079 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3080 Run_command_table(onButton4_command_table);
whismanoid 29:6a9edb6e973b 3081 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3082 }
whismanoid 29:6a9edb6e973b 3083 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3084 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3085 void onButton5FallingEdge(void)
whismanoid 29:6a9edb6e973b 3086 {
whismanoid 29:6a9edb6e973b 3087 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3088 Run_command_table(onButton5_command_table);
whismanoid 29:6a9edb6e973b 3089 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3090 }
whismanoid 29:6a9edb6e973b 3091 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3092 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3093 void onButton6FallingEdge(void)
whismanoid 29:6a9edb6e973b 3094 {
whismanoid 29:6a9edb6e973b 3095 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3096 Run_command_table(onButton6_command_table);
whismanoid 29:6a9edb6e973b 3097 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3098 }
whismanoid 29:6a9edb6e973b 3099 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3100 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3101 void onButton7FallingEdge(void)
whismanoid 29:6a9edb6e973b 3102 {
whismanoid 29:6a9edb6e973b 3103 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3104 Run_command_table(onButton7_command_table);
whismanoid 29:6a9edb6e973b 3105 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3106 }
whismanoid 29:6a9edb6e973b 3107 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3108 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3109 void onButton8FallingEdge(void)
whismanoid 29:6a9edb6e973b 3110 {
whismanoid 29:6a9edb6e973b 3111 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3112 Run_command_table(onButton8_command_table);
whismanoid 29:6a9edb6e973b 3113 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3114 }
whismanoid 29:6a9edb6e973b 3115 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3116 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3117 void onButton9FallingEdge(void)
whismanoid 29:6a9edb6e973b 3118 {
whismanoid 29:6a9edb6e973b 3119 #if USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3120 Run_command_table(onButton9_command_table);
whismanoid 29:6a9edb6e973b 3121 #endif // USE_DATALOGGER_CommandTable
whismanoid 29:6a9edb6e973b 3122 }
whismanoid 29:6a9edb6e973b 3123 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3124
whismanoid 4:d9b05924ad4c 3125 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3126 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3127 inline void print_command_prompt()
whismanoid 4:d9b05924ad4c 3128 {
whismanoid 4:d9b05924ad4c 3129 //~ Serial.println(F(">"));
whismanoid 4:d9b05924ad4c 3130 cmdLine.serial().printf("\r\n> ");
whismanoid 4:d9b05924ad4c 3131 }
whismanoid 4:d9b05924ad4c 3132 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3133
whismanoid 4:d9b05924ad4c 3134 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3135 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3136 void main_menu_status(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 3137 {
whismanoid 4:d9b05924ad4c 3138 cmdLine.serial().printf("\r\nMain menu");
whismanoid 4:d9b05924ad4c 3139 #if APPLICATION_MAX5715 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3140 cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC");
whismanoid 4:d9b05924ad4c 3141 #elif APPLICATION_MAX11131 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3142 cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC");
whismanoid 4:d9b05924ad4c 3143 #elif APPLICATION_MAX5171 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3144 cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC");
whismanoid 4:d9b05924ad4c 3145 #elif APPLICATION_MAX11410 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3146 cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC");
whismanoid 4:d9b05924ad4c 3147 #elif APPLICATION_MAX12345 // main_menu_status banner
whismanoid 4:d9b05924ad4c 3148 cmdLine.serial().printf(" MAX12345");
whismanoid 16:819c5aaf5271 3149 #elif MAX40108_DEMO // main_menu_status banner
whismanoid 17:9397ea3ea7e9 3150 cmdLine.serial().printf(" MAX40108_U%d", MAX40108_DEMO);
whismanoid 4:d9b05924ad4c 3151 #else
whismanoid 4:d9b05924ad4c 3152 //cmdLine.serial().printf(" ");
whismanoid 4:d9b05924ad4c 3153 #endif
whismanoid 4:d9b05924ad4c 3154 //cmdLine.serial().printf(" %s", TARGET_NAME);
whismanoid 4:d9b05924ad4c 3155 if (cmdLine.nameStr())
whismanoid 4:d9b05924ad4c 3156 {
whismanoid 4:d9b05924ad4c 3157 cmdLine.serial().printf(" [%s]", cmdLine.nameStr());
whismanoid 4:d9b05924ad4c 3158 }
whismanoid 4:d9b05924ad4c 3159 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3160 cmdLine.serial().printf(" [Button1");
whismanoid 4:d9b05924ad4c 3161 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3162 cmdLine.serial().printf("2");
whismanoid 24:032f3683cb2a 3163 #endif
whismanoid 24:032f3683cb2a 3164 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3165 cmdLine.serial().printf("3");
whismanoid 29:6a9edb6e973b 3166 #endif
whismanoid 29:6a9edb6e973b 3167 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3168 cmdLine.serial().printf("4");
whismanoid 29:6a9edb6e973b 3169 #endif
whismanoid 29:6a9edb6e973b 3170 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3171 cmdLine.serial().printf("5");
whismanoid 29:6a9edb6e973b 3172 #endif
whismanoid 29:6a9edb6e973b 3173 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3174 cmdLine.serial().printf("6");
whismanoid 29:6a9edb6e973b 3175 #endif
whismanoid 29:6a9edb6e973b 3176 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3177 cmdLine.serial().printf("7");
whismanoid 29:6a9edb6e973b 3178 #endif
whismanoid 29:6a9edb6e973b 3179 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3180 cmdLine.serial().printf("8");
whismanoid 29:6a9edb6e973b 3181 #endif
whismanoid 29:6a9edb6e973b 3182 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3183 cmdLine.serial().printf("9");
whismanoid 29:6a9edb6e973b 3184 #endif
whismanoid 29:6a9edb6e973b 3185 cmdLine.serial().printf("]");
whismanoid 29:6a9edb6e973b 3186 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 4:d9b05924ad4c 3187 #if HAS_BUTTON1_DEMO
whismanoid 4:d9b05924ad4c 3188 // print BUTTON1 status
whismanoid 4:d9b05924ad4c 3189 cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read());
whismanoid 4:d9b05924ad4c 3190 #endif
whismanoid 4:d9b05924ad4c 3191 #if HAS_BUTTON2_DEMO
whismanoid 24:032f3683cb2a 3192 // print BUTTON2 status
whismanoid 4:d9b05924ad4c 3193 cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read());
whismanoid 4:d9b05924ad4c 3194 #endif
whismanoid 24:032f3683cb2a 3195 #if HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 3196 // print BUTTON3 status
whismanoid 24:032f3683cb2a 3197 cmdLine.serial().printf("\r\n BUTTON3 = %d", button3.read());
whismanoid 24:032f3683cb2a 3198 #endif
whismanoid 4:d9b05924ad4c 3199 cmdLine.serial().printf("\r\n ? -- help");
whismanoid 4:d9b05924ad4c 3200 }
whismanoid 4:d9b05924ad4c 3201 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3202
whismanoid 28:a9a3a9db592b 3203 //--------------------------------------------------
whismanoid 28:a9a3a9db592b 3204 #ifndef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3205 #define USE_DATALOGGER_TRIGGER_HELP_BRIEF 1
whismanoid 28:a9a3a9db592b 3206 //~ #undef USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3207 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3208
whismanoid 4:d9b05924ad4c 3209 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3210 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3211 void main_menu_help(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 3212 {
whismanoid 4:d9b05924ad4c 3213 // ? -- help
whismanoid 4:d9b05924ad4c 3214 //~ cmdLine.serial().printf("\r\nMenu:");
whismanoid 10:04022a61b527 3215 //
whismanoid 4:d9b05924ad4c 3216 cmdLine.serial().printf("\r\n # -- lines beginning with # are comments");
whismanoid 10:04022a61b527 3217 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 3218 cmdLine.serial().printf("\r\n ! -- Init");
whismanoid 10:04022a61b527 3219 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 3220 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 3221 cmdLine.serial().printf("\r\n . -- SelfTest");
whismanoid 4:d9b05924ad4c 3222 #endif // USE_SELFTEST
whismanoid 9:45f98573eb6d 3223 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 9:45f98573eb6d 3224 // CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register
whismanoid 9:45f98573eb6d 3225 cmdLine.serial().printf("\r\n * -- read core registers\r\n *regname? -- read register\r\n *regname=regvalue -- write register");
whismanoid 9:45f98573eb6d 3226 // cmdLine.serial().printf("\r\n 01 23 45 67 89 ab cd ef -- write and read raw hex codes");
whismanoid 10:04022a61b527 3227 #endif // USE_STAR_REG_READWRITE
whismanoid 10:04022a61b527 3228 //
whismanoid 10:04022a61b527 3229 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3230 // Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_help
whismanoid 10:04022a61b527 3231 //~ cmdLine.serial().printf("\r\n > -- auxiliary UART port");
whismanoid 10:04022a61b527 3232 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3233 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3234 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3235 if (cmdLine_AUXserial.nameStr())
whismanoid 10:04022a61b527 3236 {
whismanoid 10:04022a61b527 3237 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_AUXserial.nameStr());
whismanoid 10:04022a61b527 3238 }
whismanoid 10:04022a61b527 3239 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3240 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3241 if (cmdLine_DAPLINKserial.nameStr())
whismanoid 10:04022a61b527 3242 {
whismanoid 10:04022a61b527 3243 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_DAPLINKserial.nameStr());
whismanoid 10:04022a61b527 3244 }
whismanoid 10:04022a61b527 3245 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3246 # if HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3247 // WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3248 cmdLine.serial().printf("\r\n >xyzzy -- Forward command/data 'xyzzy' to aux TX/RX");
whismanoid 10:04022a61b527 3249 cmdLine.serial().printf("\r\n >>xyzzy -- Forward 'xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 3250 cmdLine.serial().printf("\r\n >>>xyzzy -- Forward '>xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 3251 #if 0
whismanoid 10:04022a61b527 3252 cmdLine.serial().printf("\r\n >tx_wait_echo=%d -- configure TX wait for each character echo", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 3253 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 3254 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 3255 #endif
whismanoid 20:78ef670955d4 3256 #if 1 // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 3257 cmdLine.serial().printf("\r\n >baud=%d message_ms=%d rx_idle_ms=%d rx_max_count=%d rx_eot=%d",
whismanoid 20:78ef670955d4 3258 g_auxSerialCom_baud,
whismanoid 20:78ef670955d4 3259 g_auxSerialCom_message_ms,
whismanoid 20:78ef670955d4 3260 g_auxSerialCom_rx_idle_ms,
whismanoid 20:78ef670955d4 3261 g_auxSerialCom_rx_max_count,
whismanoid 20:78ef670955d4 3262 g_auxSerialCom_rx_eot);
whismanoid 20:78ef670955d4 3263 #else // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 3264 cmdLine.serial().printf("\r\n >baud=%d -- configure aux TX/RX port", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 3265 cmdLine.serial().printf("\r\n >message_ms=%d -- maximum RX message total response time", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 3266 cmdLine.serial().printf("\r\n >rx_idle_ms=%d -- maximum RX message idle time between characters", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 3267 cmdLine.serial().printf("\r\n >rx_max_count=%d -- maximum RX message total length", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 3268 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 3269 #endif // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 10:04022a61b527 3270 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3271 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3272 //
whismanoid 4:d9b05924ad4c 3273 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 3274 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3275 // Datalog trigger menu
whismanoid 28:a9a3a9db592b 3276 // brief toplevel heading for datalog help L
whismanoid 28:a9a3a9db592b 3277 // L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 3278 cmdLine.serial().printf("\r\n L -- halt the datalogger; show more commands");
whismanoid 28:a9a3a9db592b 3279 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 28:a9a3a9db592b 3280 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 28:a9a3a9db592b 3281 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 28:a9a3a9db592b 3282 //
whismanoid 28:a9a3a9db592b 3283 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 3284 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 3285 //
whismanoid 28:a9a3a9db592b 3286 cmdLine.serial().printf("\r\n LT count=%d base=%dms -- Datalog timer", g_timer_interval_count, g_timer_interval_msec); // trigger_Timer
whismanoid 28:a9a3a9db592b 3287 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3288 //~ cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 3289 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3290 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 3291 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 3292 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 3293 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 9:45f98573eb6d 3294 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 9:45f98573eb6d 3295 //
whismanoid 17:9397ea3ea7e9 3296 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 4:d9b05924ad4c 3297 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 9:45f98573eb6d 3298 //
whismanoid 17:9397ea3ea7e9 3299 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 3300 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 17:9397ea3ea7e9 3301 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 3302 //
whismanoid 9:45f98573eb6d 3303 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 3304 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 3305 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 3306 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 9:45f98573eb6d 3307 //
whismanoid 17:9397ea3ea7e9 3308 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 9:45f98573eb6d 3309 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 3310 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 3311 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 3312 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 3313 //
whismanoid 17:9397ea3ea7e9 3314 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 3315 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 17:9397ea3ea7e9 3316 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 9:45f98573eb6d 3317 //
whismanoid 9:45f98573eb6d 3318 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 3319 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 3320 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 3321 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 3322 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 9:45f98573eb6d 3323 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 9:45f98573eb6d 3324 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 9:45f98573eb6d 3325 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 9:45f98573eb6d 3326 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 9:45f98573eb6d 3327 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 9:45f98573eb6d 3328 //
whismanoid 9:45f98573eb6d 3329 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 3330 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 9:45f98573eb6d 3331 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 9:45f98573eb6d 3332 //
whismanoid 9:45f98573eb6d 3333 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 3334 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 3335 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 9:45f98573eb6d 3336 //
whismanoid 9:45f98573eb6d 3337 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 3338 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 9:45f98573eb6d 3339 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 3340 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 9:45f98573eb6d 3341 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 3342 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 9:45f98573eb6d 3343 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 3344 //
whismanoid 9:45f98573eb6d 3345 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 3346 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 9:45f98573eb6d 3347 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 9:45f98573eb6d 3348 //
whismanoid 9:45f98573eb6d 3349 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 3350 //
whismanoid 9:45f98573eb6d 3351 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 3352 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 3353 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 3354 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 3355 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 9:45f98573eb6d 3356 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3357 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 9:45f98573eb6d 3358 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3359 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3360 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 9:45f98573eb6d 3361 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3362 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 9:45f98573eb6d 3363 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3364 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 9:45f98573eb6d 3365 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 3366 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3367 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 9:45f98573eb6d 3368 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3369 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 3370 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 4:d9b05924ad4c 3371 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 3372 #if USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 3373 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 3374 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 3375 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 3376 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3377 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 3378 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 3379 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 3380 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 3381 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF -----------------------------------------------
whismanoid 8:dffee7509bfb 3382 //
whismanoid 4:d9b05924ad4c 3383 //cmdLine.serial().print(F("\r\n ! -- Initial Configuration"));
whismanoid 4:d9b05924ad4c 3384 //
whismanoid 4:d9b05924ad4c 3385 // % standardize diagnostic commands
whismanoid 4:d9b05924ad4c 3386 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 3387 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 3388 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 3389 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 3390 // %Ppin df=xx -- pwm output
whismanoid 4:d9b05924ad4c 3391 // %Wpin -- measure high pulsewidth input in usec
whismanoid 4:d9b05924ad4c 3392 // %wpin -- measure low pulsewidth input in usec
whismanoid 4:d9b05924ad4c 3393 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 3394 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 3395 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 3396 // %IW ADDR=? cmd=? data,data,data -- write
whismanoid 4:d9b05924ad4c 3397 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 3398 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3399 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 3400 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 3401 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 3402 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 3403 // A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 3404 //
whismanoid 23:c6c652bef4b9 3405 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3406 #if USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3407 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 3408 // TODO: %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 3409 // TODO: future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 3410 // TODO: future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 3411 // TODO: %B1@ view command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 3412 // TODO: %B1@+ command add new row (if there is room to add) (ignore one space before command)
whismanoid 23:c6c652bef4b9 3413 // TODO: %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 3414 // TODO: %B1@-~~~ clear entire command table
whismanoid 23:c6c652bef4b9 3415 // TODO: %B1@nnn command replace row number nnn (ignore one space before command)
whismanoid 23:c6c652bef4b9 3416 // TODO: %B1@! disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 3417 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 3418 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 30:07197a430869 3419 cmdLine.serial().printf("\r\n %%B1! trigger Button1 event; %%B1@ -- view/edit command table");
whismanoid 23:c6c652bef4b9 3420 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3421 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3422 #if HAS_digitalInOuts
whismanoid 4:d9b05924ad4c 3423 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 3424 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 3425 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 3426 cmdLine.serial().printf("\r\n %%Hn {pin:");
whismanoid 4:d9b05924ad4c 3427 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3428 cmdLine.serial().printf("} -- High Output");
whismanoid 4:d9b05924ad4c 3429 cmdLine.serial().printf("\r\n %%Ln {pin:");
whismanoid 4:d9b05924ad4c 3430 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3431 cmdLine.serial().printf("} -- Low Output");
whismanoid 4:d9b05924ad4c 3432 cmdLine.serial().printf("\r\n %%?n {pin:");
whismanoid 4:d9b05924ad4c 3433 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3434 cmdLine.serial().printf("} -- Input");
whismanoid 4:d9b05924ad4c 3435 #endif
whismanoid 4:d9b05924ad4c 3436
whismanoid 4:d9b05924ad4c 3437 #if HAS_analogIns
whismanoid 4:d9b05924ad4c 3438 // Menu A) analogRead A0..7
whismanoid 4:d9b05924ad4c 3439 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 3440 // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0)
whismanoid 34:a1993a1ee904 3441 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3442 // %A cal? view/export raw calibration values for all channels
whismanoid 34:a1993a1ee904 3443 cmdLine.serial().printf("\r\n %%A -- analogRead; %%A cal? -- calibration");
whismanoid 34:a1993a1ee904 3444 #else // HAS_Platform_AIN_Calibration
whismanoid 4:d9b05924ad4c 3445 cmdLine.serial().printf("\r\n %%A -- analogRead");
whismanoid 34:a1993a1ee904 3446 #endif // HAS_Platform_AIN_Calibration
whismanoid 4:d9b05924ad4c 3447 #endif
whismanoid 4:d9b05924ad4c 3448
whismanoid 4:d9b05924ad4c 3449 #if HAS_SPI2_MAX541
whismanoid 4:d9b05924ad4c 3450 // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 4:d9b05924ad4c 3451 cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)");
whismanoid 4:d9b05924ad4c 3452 #endif
whismanoid 4:d9b05924ad4c 3453
whismanoid 4:d9b05924ad4c 3454 #if HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3455 // TODO: support I2C HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3456 // VERIFY: I2C utility commands SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3457 // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz);
whismanoid 4:d9b05924ad4c 3458 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 3459 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 3460 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 3461 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 4:d9b05924ad4c 3462 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 3463 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3464 //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope
whismanoid 4:d9b05924ad4c 3465 cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 4:d9b05924ad4c 3466 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 4:d9b05924ad4c 3467 (g_I2C_SCL_Hz / 1000.));
whismanoid 4:d9b05924ad4c 3468 cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read",
whismanoid 4:d9b05924ad4c 3469 g_I2C_deviceAddress7);
whismanoid 4:d9b05924ad4c 3470 //
whismanoid 4:d9b05924ad4c 3471 #if SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3472 // Menu ^ cmd=?) i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3473 cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data");
whismanoid 4:d9b05924ad4c 3474 // test low-level I2C i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3475 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3476 //cmdLine.serial().printf(" H) Hunt for attached I2C devices");
whismanoid 4:d9b05924ad4c 3477 cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices");
whismanoid 4:d9b05924ad4c 3478 // cmdLine.serial().printf(" s) search i2c address");
whismanoid 4:d9b05924ad4c 3479 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3480
whismanoid 4:d9b05924ad4c 3481 #if HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3482 // TODO: support SPI HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3483 // SPI test command S (mosiData)+
whismanoid 4:d9b05924ad4c 3484 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 3485 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 3486 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 3487 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 3488 // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 4:d9b05924ad4c 3489 // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 4:d9b05924ad4c 3490 // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 4:d9b05924ad4c 3491 // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 4:d9b05924ad4c 3492 // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 4:d9b05924ad4c 3493 // mode | POL PHA
whismanoid 4:d9b05924ad4c 3494 // -----+--------
whismanoid 4:d9b05924ad4c 3495 // 0 | 0 0
whismanoid 4:d9b05924ad4c 3496 // 1 | 0 1
whismanoid 4:d9b05924ad4c 3497 // 2 | 1 0
whismanoid 4:d9b05924ad4c 3498 // 3 | 1 1
whismanoid 4:d9b05924ad4c 3499 //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0");
whismanoid 4:d9b05924ad4c 3500 // 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 3501 cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config",
whismanoid 4:d9b05924ad4c 3502 g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.),
whismanoid 4:d9b05924ad4c 3503 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 4:d9b05924ad4c 3504 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0));
whismanoid 4:d9b05924ad4c 3505 cmdLine.serial().printf("\r\n %%SD -- SPI diagnostic messages ");
whismanoid 4:d9b05924ad4c 3506 if (g_MAX11410_device.onSPIprint) {
whismanoid 4:d9b05924ad4c 3507 cmdLine.serial().printf("hide");
whismanoid 4:d9b05924ad4c 3508 }
whismanoid 4:d9b05924ad4c 3509 else {
whismanoid 4:d9b05924ad4c 3510 cmdLine.serial().printf("show");
whismanoid 4:d9b05924ad4c 3511 }
whismanoid 4:d9b05924ad4c 3512 cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes");
whismanoid 4:d9b05924ad4c 3513 // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0
whismanoid 4:d9b05924ad4c 3514 #endif // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3515 //
whismanoid 4:d9b05924ad4c 3516 // Application-specific commands (help text) here
whismanoid 4:d9b05924ad4c 3517 //
whismanoid 4:d9b05924ad4c 3518 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3519 cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3520 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3521 //
whismanoid 4:d9b05924ad4c 3522
whismanoid 4:d9b05924ad4c 3523 //~ extern void MAX11410_menu_help(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp\n
whismanoid 4:d9b05924ad4c 3524 //~ MAX11410_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 3525 }
whismanoid 4:d9b05924ad4c 3526 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3527
whismanoid 4:d9b05924ad4c 3528 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 15:37c83ec50ea0 3529
whismanoid 15:37c83ec50ea0 3530 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 3531 void pinsMonitor_submenu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 15:37c83ec50ea0 3532 {
whismanoid 15:37c83ec50ea0 3533 // % diagnostic commands submenu
whismanoid 15:37c83ec50ea0 3534 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 3535 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 3536 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 3537 // %A %Apin -- analog input
whismanoid 15:37c83ec50ea0 3538 // %Ppin df=xx -- pwm output
whismanoid 15:37c83ec50ea0 3539 // %Wpin -- measure high pulsewidth input in usec
whismanoid 15:37c83ec50ea0 3540 // %wpin -- measure low pulsewidth input in usec
whismanoid 15:37c83ec50ea0 3541 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 3542 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 3543 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 3544 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 3545 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 3546 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 3547 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 3548 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 3549 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 3550 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 3551 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 3552 //
whismanoid 15:37c83ec50ea0 3553 char strPinIndex[3];
whismanoid 15:37c83ec50ea0 3554 strPinIndex[0] = cmdLine[2];
whismanoid 15:37c83ec50ea0 3555 strPinIndex[1] = cmdLine[3];
whismanoid 15:37c83ec50ea0 3556 strPinIndex[2] = '\0';
whismanoid 15:37c83ec50ea0 3557 int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 15:37c83ec50ea0 3558 //cmdLine.serial().printf(" pinIndex=%d ", pinIndex);
whismanoid 15:37c83ec50ea0 3559 //
whismanoid 15:37c83ec50ea0 3560 // get next character
whismanoid 15:37c83ec50ea0 3561 switch (cmdLine[1])
whismanoid 15:37c83ec50ea0 3562 {
whismanoid 23:c6c652bef4b9 3563 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3564 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3565 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 3566 case 'B': case 'b':
whismanoid 23:c6c652bef4b9 3567 {
whismanoid 24:032f3683cb2a 3568 int command_table_button_index = 1;
whismanoid 23:c6c652bef4b9 3569 // %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 3570 // future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 3571 // future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 3572 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3573 // cmdLine[2] == '1' selects onButton1_command_table
whismanoid 23:c6c652bef4b9 3574 char** command_table = onButton1_command_table;
whismanoid 23:c6c652bef4b9 3575 #endif
whismanoid 24:032f3683cb2a 3576 switch(cmdLine[2])
whismanoid 24:032f3683cb2a 3577 {
whismanoid 24:032f3683cb2a 3578 default:
whismanoid 24:032f3683cb2a 3579 case '1': case 'A': case 'a': case '!':
whismanoid 24:032f3683cb2a 3580 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3581 command_table_button_index = 1;
whismanoid 24:032f3683cb2a 3582 command_table = onButton1_command_table;
whismanoid 24:032f3683cb2a 3583 #endif
whismanoid 24:032f3683cb2a 3584 break;
whismanoid 24:032f3683cb2a 3585 case '2': case 'B': case 'b': case '@':
whismanoid 23:c6c652bef4b9 3586 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3587 command_table_button_index = 2;
whismanoid 24:032f3683cb2a 3588 command_table = onButton2_command_table;
whismanoid 24:032f3683cb2a 3589 #endif
whismanoid 24:032f3683cb2a 3590 break;
whismanoid 24:032f3683cb2a 3591 case '3': case 'C': case 'c': case '#':
whismanoid 23:c6c652bef4b9 3592 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3593 command_table_button_index = 3;
whismanoid 24:032f3683cb2a 3594 command_table = onButton3_command_table;
whismanoid 24:032f3683cb2a 3595 #endif
whismanoid 24:032f3683cb2a 3596 break;
whismanoid 29:6a9edb6e973b 3597 case '4':
whismanoid 29:6a9edb6e973b 3598 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3599 command_table_button_index = 4;
whismanoid 29:6a9edb6e973b 3600 command_table = onButton4_command_table;
whismanoid 29:6a9edb6e973b 3601 #endif
whismanoid 29:6a9edb6e973b 3602 break;
whismanoid 29:6a9edb6e973b 3603 case '5':
whismanoid 29:6a9edb6e973b 3604 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3605 command_table_button_index = 5;
whismanoid 29:6a9edb6e973b 3606 command_table = onButton5_command_table;
whismanoid 29:6a9edb6e973b 3607 #endif
whismanoid 29:6a9edb6e973b 3608 break;
whismanoid 29:6a9edb6e973b 3609 case '6':
whismanoid 29:6a9edb6e973b 3610 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3611 command_table_button_index = 6;
whismanoid 29:6a9edb6e973b 3612 command_table = onButton6_command_table;
whismanoid 29:6a9edb6e973b 3613 #endif
whismanoid 29:6a9edb6e973b 3614 break;
whismanoid 29:6a9edb6e973b 3615 case '7':
whismanoid 29:6a9edb6e973b 3616 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3617 command_table_button_index = 7;
whismanoid 29:6a9edb6e973b 3618 command_table = onButton7_command_table;
whismanoid 29:6a9edb6e973b 3619 #endif
whismanoid 29:6a9edb6e973b 3620 break;
whismanoid 29:6a9edb6e973b 3621 case '8':
whismanoid 29:6a9edb6e973b 3622 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3623 command_table_button_index = 8;
whismanoid 29:6a9edb6e973b 3624 command_table = onButton8_command_table;
whismanoid 29:6a9edb6e973b 3625 #endif
whismanoid 29:6a9edb6e973b 3626 break;
whismanoid 29:6a9edb6e973b 3627 case '9':
whismanoid 29:6a9edb6e973b 3628 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 3629 command_table_button_index = 9;
whismanoid 29:6a9edb6e973b 3630 command_table = onButton9_command_table;
whismanoid 29:6a9edb6e973b 3631 #endif
whismanoid 29:6a9edb6e973b 3632 break;
whismanoid 24:032f3683cb2a 3633 }
whismanoid 24:032f3683cb2a 3634 //
whismanoid 23:c6c652bef4b9 3635 switch(cmdLine[3])
whismanoid 23:c6c652bef4b9 3636 {
whismanoid 23:c6c652bef4b9 3637 case '@':
whismanoid 23:c6c652bef4b9 3638 {
whismanoid 23:c6c652bef4b9 3639 // %B1@ view/edit command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 3640 int editRowIndex = 0;
whismanoid 23:c6c652bef4b9 3641 int command_table_row_count = 0;
whismanoid 23:c6c652bef4b9 3642 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 3643 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 3644 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 3645 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 3646 }
whismanoid 24:032f3683cb2a 3647 //
whismanoid 24:032f3683cb2a 3648 // ignore extra spaces before the command
whismanoid 24:032f3683cb2a 3649 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 24:032f3683cb2a 3650 int argIndex;
whismanoid 24:032f3683cb2a 3651 for (argIndex = 5; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 3652 {
whismanoid 24:032f3683cb2a 3653 if (cmdLine[argIndex] == ' ') break;
whismanoid 24:032f3683cb2a 3654 }
whismanoid 24:032f3683cb2a 3655 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 3656 {
whismanoid 24:032f3683cb2a 3657 if (cmdLine[argIndex] != ' ') break;
whismanoid 23:c6c652bef4b9 3658 }
whismanoid 23:c6c652bef4b9 3659 //
whismanoid 23:c6c652bef4b9 3660 // Edit the contents of command_table
whismanoid 23:c6c652bef4b9 3661 switch (cmdLine[4]) // %B1@... -- Edit the contents of command_table
whismanoid 23:c6c652bef4b9 3662 {
whismanoid 23:c6c652bef4b9 3663 case '0': case '1': case '2': case '3': case '4':
whismanoid 23:c6c652bef4b9 3664 case '5': case '6': case '7': case '8': case '9':
whismanoid 24:032f3683cb2a 3665 // %B1@nnn command replace row number nnn
whismanoid 23:c6c652bef4b9 3666 // edit row data
whismanoid 33:70a28cfe9e01 3667 // get row number to edit from cmdLine[4]
whismanoid 33:70a28cfe9e01 3668 editRowIndex = atoi(cmdLine.str()+4);
whismanoid 23:c6c652bef4b9 3669 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 3670 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 3671 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 28:a9a3a9db592b 3672 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 3673 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 3674 cmdLine.serial().printf("\r\n cannot replace row %d with nothing",
whismanoid 28:a9a3a9db592b 3675 editRowIndex);
whismanoid 28:a9a3a9db592b 3676 }
whismanoid 28:a9a3a9db592b 3677 else
whismanoid 28:a9a3a9db592b 3678 {
whismanoid 28:a9a3a9db592b 3679 // update row
whismanoid 28:a9a3a9db592b 3680 cmdLine.serial().printf("\r\n replace row %d with \"%s\"",
whismanoid 28:a9a3a9db592b 3681 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 3682 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 3683 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 3684 }
whismanoid 24:032f3683cb2a 3685 }
whismanoid 33:70a28cfe9e01 3686 } // end if (command_table_row_count > 0)
whismanoid 33:70a28cfe9e01 3687 if ((editRowIndex == command_table_row_count) && (command_table_row_count < COMMAND_TABLE_ROW_MAX)) {
whismanoid 33:70a28cfe9e01 3688 // %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 3689 //
whismanoid 33:70a28cfe9e01 3690 command_table_row_count++;
whismanoid 33:70a28cfe9e01 3691 cmdLine.serial().printf("\r\n add next row %d containing \"%s\"",
whismanoid 33:70a28cfe9e01 3692 editRowIndex, cmdLine.str()+argIndex);
whismanoid 33:70a28cfe9e01 3693 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 33:70a28cfe9e01 3694 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 33:70a28cfe9e01 3695 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 33:70a28cfe9e01 3696 //
whismanoid 23:c6c652bef4b9 3697 }
whismanoid 33:70a28cfe9e01 3698 //
whismanoid 23:c6c652bef4b9 3699 break;
whismanoid 23:c6c652bef4b9 3700 case '+':
whismanoid 24:032f3683cb2a 3701 // %B1@+ command add new row (if there is room to add)
whismanoid 23:c6c652bef4b9 3702 // add a new row at end of table
whismanoid 23:c6c652bef4b9 3703 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 3704 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 23:c6c652bef4b9 3705 editRowIndex = command_table_row_count;
whismanoid 28:a9a3a9db592b 3706 // avoid replacing with null because that would truncate the table
whismanoid 28:a9a3a9db592b 3707 if (*(cmdLine.str()+argIndex)=='\0') {
whismanoid 28:a9a3a9db592b 3708 cmdLine.serial().printf("\r\n cannot add new row %d containing nothing",
whismanoid 28:a9a3a9db592b 3709 editRowIndex);
whismanoid 28:a9a3a9db592b 3710 }
whismanoid 28:a9a3a9db592b 3711 else
whismanoid 28:a9a3a9db592b 3712 {
whismanoid 28:a9a3a9db592b 3713 command_table_row_count++;
whismanoid 28:a9a3a9db592b 3714 cmdLine.serial().printf("\r\n add new row %d containing \"%s\"",
whismanoid 28:a9a3a9db592b 3715 editRowIndex, cmdLine.str()+argIndex);
whismanoid 28:a9a3a9db592b 3716 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 3717 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 28:a9a3a9db592b 3718 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 28:a9a3a9db592b 3719 }
whismanoid 23:c6c652bef4b9 3720 }
whismanoid 23:c6c652bef4b9 3721 break;
whismanoid 23:c6c652bef4b9 3722 case '-':
whismanoid 24:032f3683cb2a 3723 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 3724 // delete row from table
whismanoid 23:c6c652bef4b9 3725 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 3726 // if command_table_row_count == 0 then the table is empty
whismanoid 23:c6c652bef4b9 3727 if ((cmdLine[5] == '~') && (cmdLine[6] == '~') && (cmdLine[7] == '~')) {
whismanoid 23:c6c652bef4b9 3728 // %B1@-~~~ clear entire command table
whismanoid 24:032f3683cb2a 3729 cmdLine.serial().printf("\r\n clear entire command table");
whismanoid 23:c6c652bef4b9 3730 command_table_row_count = 0;
whismanoid 28:a9a3a9db592b 3731 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 23:c6c652bef4b9 3732 break;
whismanoid 23:c6c652bef4b9 3733 }
whismanoid 24:032f3683cb2a 3734 else
whismanoid 23:c6c652bef4b9 3735 {
whismanoid 24:032f3683cb2a 3736 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 24:032f3683cb2a 3737 editRowIndex = atoi(cmdLine.str()+5);
whismanoid 24:032f3683cb2a 3738 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 24:032f3683cb2a 3739 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 24:032f3683cb2a 3740 // delete row editRowIndex from Datalogger_action_table
whismanoid 24:032f3683cb2a 3741 for (int i = editRowIndex; i < (command_table_row_count-1); i++)
whismanoid 24:032f3683cb2a 3742 {
whismanoid 24:032f3683cb2a 3743 // copy row i+1 into row i
whismanoid 24:032f3683cb2a 3744 cmdLine.serial().printf("\r\n copy row %d into row %d: \"%s\"",
whismanoid 24:032f3683cb2a 3745 i+1, i, command_table[i+1]);
whismanoid 24:032f3683cb2a 3746 strncpy(command_table[i], command_table[i+1], COMMAND_TABLE_COL_MAX-1);
whismanoid 28:a9a3a9db592b 3747 command_table[i][COMMAND_TABLE_COL_MAX-1]='\0'; // null character at end of line
whismanoid 24:032f3683cb2a 3748 }
whismanoid 24:032f3683cb2a 3749 command_table_row_count--;
whismanoid 28:a9a3a9db592b 3750 command_table[command_table_row_count][0]='\0'; // empty string marks end of command_table
whismanoid 24:032f3683cb2a 3751 }
whismanoid 23:c6c652bef4b9 3752 }
whismanoid 23:c6c652bef4b9 3753 }
whismanoid 23:c6c652bef4b9 3754 break;
whismanoid 30:07197a430869 3755 case '.': // something other than ! because %B1! means trigger event
whismanoid 30:07197a430869 3756 // pause the button event
whismanoid 30:07197a430869 3757 // TODO: %B1@. disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 3758 //~ Datalogger_action_table_enabled = false;
whismanoid 23:c6c652bef4b9 3759 break;
whismanoid 23:c6c652bef4b9 3760 case '@':
whismanoid 30:07197a430869 3761 // enable the button event
whismanoid 23:c6c652bef4b9 3762 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 3763 //~ Datalogger_action_table_enabled = true;
whismanoid 23:c6c652bef4b9 3764 break;
whismanoid 23:c6c652bef4b9 3765 }
whismanoid 23:c6c652bef4b9 3766 //
whismanoid 23:c6c652bef4b9 3767 // Print the contents of command_table
whismanoid 23:c6c652bef4b9 3768 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 3769 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 3770 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 3771 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 3772 cmdLine.serial().printf("\r\n %%B%1d@%d %s",
whismanoid 24:032f3683cb2a 3773 command_table_button_index,
whismanoid 24:032f3683cb2a 3774 lineIndex,
whismanoid 24:032f3683cb2a 3775 command_table[lineIndex]);
whismanoid 23:c6c652bef4b9 3776 }
whismanoid 30:07197a430869 3777 //~ cmdLine.serial().printf("\r\n command_table_row_count = %d/%d",
whismanoid 30:07197a430869 3778 //~ command_table_row_count, COMMAND_TABLE_ROW_MAX);
whismanoid 30:07197a430869 3779 cmdLine.serial().printf("\r\n\r\nEdit Button%d event (used %d/%d, %d free):",
whismanoid 30:07197a430869 3780 command_table_button_index,
whismanoid 30:07197a430869 3781 command_table_row_count,
whismanoid 30:07197a430869 3782 COMMAND_TABLE_ROW_MAX,
whismanoid 30:07197a430869 3783 (COMMAND_TABLE_ROW_MAX - command_table_row_count)
whismanoid 30:07197a430869 3784 );
whismanoid 23:c6c652bef4b9 3785 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 3786 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 24:032f3683cb2a 3787 cmdLine.serial().printf("\r\n %%B%1d@+ command -- add new row %d at end of table",
whismanoid 24:032f3683cb2a 3788 command_table_button_index,
whismanoid 24:032f3683cb2a 3789 command_table_row_count);
whismanoid 23:c6c652bef4b9 3790 }
whismanoid 23:c6c652bef4b9 3791 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 3792 // if command_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 3793 cmdLine.serial().printf("\r\n %%B%1d@%d command -- replace row %d",
whismanoid 24:032f3683cb2a 3794 command_table_button_index,
whismanoid 23:c6c652bef4b9 3795 command_table_row_count-1,
whismanoid 23:c6c652bef4b9 3796 command_table_row_count-1);
whismanoid 24:032f3683cb2a 3797 cmdLine.serial().printf("\r\n %%B%1d@-%d -- delete row %d",
whismanoid 24:032f3683cb2a 3798 command_table_button_index,
whismanoid 24:032f3683cb2a 3799 command_table_row_count-1,
whismanoid 24:032f3683cb2a 3800 command_table_row_count-1);
whismanoid 24:032f3683cb2a 3801 cmdLine.serial().printf("\r\n %%B%1d@-~~~ -- delete all rows",
whismanoid 24:032f3683cb2a 3802 command_table_button_index);
whismanoid 30:07197a430869 3803 //~ cmdLine.serial().printf("\r\n %%B%1d@. -- pause entire command table",
whismanoid 30:07197a430869 3804 //~ command_table_button_index);
whismanoid 30:07197a430869 3805 //~ cmdLine.serial().printf("\r\n %%B%1d@@ -- enable command table",
whismanoid 30:07197a430869 3806 //~ command_table_button_index);
whismanoid 30:07197a430869 3807 cmdLine.serial().printf("\r\n %%B%1d! -- trigger Button%d event",
whismanoid 30:07197a430869 3808 command_table_button_index,
whismanoid 24:032f3683cb2a 3809 command_table_button_index);
whismanoid 23:c6c652bef4b9 3810 }
whismanoid 23:c6c652bef4b9 3811 //
whismanoid 23:c6c652bef4b9 3812 } // case '@' -- %B1@ view/edit command table
whismanoid 23:c6c652bef4b9 3813 break;
whismanoid 23:c6c652bef4b9 3814 case '!':
whismanoid 23:c6c652bef4b9 3815 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 23:c6c652bef4b9 3816 Run_command_table(command_table);
whismanoid 23:c6c652bef4b9 3817 break;
whismanoid 23:c6c652bef4b9 3818 }
whismanoid 23:c6c652bef4b9 3819 }
whismanoid 23:c6c652bef4b9 3820 break;
whismanoid 23:c6c652bef4b9 3821 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3822 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 3823 #if HAS_digitalInOuts
whismanoid 15:37c83ec50ea0 3824 case 'H': case 'h':
whismanoid 15:37c83ec50ea0 3825 {
whismanoid 15:37c83ec50ea0 3826 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 3827 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 3828 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 3829 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 3830 #else
whismanoid 15:37c83ec50ea0 3831 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 3832 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 3833 digitalInOutPin.write(1);
whismanoid 15:37c83ec50ea0 3834 #endif
whismanoid 15:37c83ec50ea0 3835 cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex);
whismanoid 15:37c83ec50ea0 3836 }
whismanoid 15:37c83ec50ea0 3837 break;
whismanoid 15:37c83ec50ea0 3838 case 'L': case 'l':
whismanoid 15:37c83ec50ea0 3839 {
whismanoid 15:37c83ec50ea0 3840 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 3841 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 3842 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 3843 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 3844 #else
whismanoid 15:37c83ec50ea0 3845 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 3846 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 3847 digitalInOutPin.write(0);
whismanoid 15:37c83ec50ea0 3848 #endif
whismanoid 15:37c83ec50ea0 3849 cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex);
whismanoid 15:37c83ec50ea0 3850 }
whismanoid 15:37c83ec50ea0 3851 break;
whismanoid 15:37c83ec50ea0 3852 case '?':
whismanoid 15:37c83ec50ea0 3853 {
whismanoid 15:37c83ec50ea0 3854 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 3855 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 3856 pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 3857 #else
whismanoid 15:37c83ec50ea0 3858 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 3859 digitalInOutPin.input();
whismanoid 15:37c83ec50ea0 3860 #endif
whismanoid 15:37c83ec50ea0 3861 serial.printf(" digitalInOutPin %d Input ", pinIndex);
whismanoid 15:37c83ec50ea0 3862 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 3863 int value = digitalRead(pinIndex);
whismanoid 15:37c83ec50ea0 3864 #else
whismanoid 15:37c83ec50ea0 3865 int value = digitalInOutPin.read();
whismanoid 15:37c83ec50ea0 3866 #endif
whismanoid 15:37c83ec50ea0 3867 cmdLine.serial().printf("%d ", value);
whismanoid 15:37c83ec50ea0 3868 }
whismanoid 15:37c83ec50ea0 3869 break;
whismanoid 15:37c83ec50ea0 3870 #endif
whismanoid 15:37c83ec50ea0 3871 //
whismanoid 15:37c83ec50ea0 3872 #if HAS_analogIns
whismanoid 15:37c83ec50ea0 3873 case 'A': case 'a':
whismanoid 15:37c83ec50ea0 3874 {
whismanoid 15:37c83ec50ea0 3875 // %A %Apin -- analog input
whismanoid 34:a1993a1ee904 3876 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3877 // %A cal? view/export raw calibration values for all channels
whismanoid 34:a1993a1ee904 3878 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 3879 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 3880 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 3881 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 3882 {
whismanoid 34:a1993a1ee904 3883 char valueBuf[16];
whismanoid 34:a1993a1ee904 3884 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 3885 if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 3886 {
whismanoid 34:a1993a1ee904 3887 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 3888 {
whismanoid 34:a1993a1ee904 3889 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 3890 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 3891 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 3892 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 3893 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 3894 );
whismanoid 34:a1993a1ee904 3895 }
whismanoid 34:a1993a1ee904 3896 //
whismanoid 34:a1993a1ee904 3897 // print extended help for %A
whismanoid 34:a1993a1ee904 3898 // %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 3899 //~ cmdLine.serial().printf("\r\n %%A cal0n=0.02 cal0v=0.123 cal0n=0.938 cal0v=1.132 -- update calibration");
whismanoid 34:a1993a1ee904 3900 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 3901 cmdLine.serial().printf(" %%A cal0test=0.5 -- calculate voltage at 50%% of full scale");
whismanoid 34:a1993a1ee904 3902 cmdLine.serial().printf("\r\n %%A v0cal=1.000V -- calibrate channel against a known input voltage");
whismanoid 34:a1993a1ee904 3903 // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 3904 // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 3905 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 3906 cmdLine.serial().printf("\r\n %%A calreset -- reset all calibration data");
whismanoid 34:a1993a1ee904 3907 cmdLine.serial().printf("\r\n\r\n");
whismanoid 34:a1993a1ee904 3908 //
whismanoid 34:a1993a1ee904 3909 } // end if (cmdLine.parse_and_remove_key("cal?", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 3910 }
whismanoid 34:a1993a1ee904 3911 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3912 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3913 {
whismanoid 34:a1993a1ee904 3914 // %A calreset -- reset all calibration data
whismanoid 34:a1993a1ee904 3915 char valueBuf[16];
whismanoid 34:a1993a1ee904 3916 // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
whismanoid 34:a1993a1ee904 3917 if (cmdLine.parse_and_remove_key("calreset", valueBuf, sizeof(valueBuf)))
whismanoid 34:a1993a1ee904 3918 {
whismanoid 34:a1993a1ee904 3919 // nominal 5% fullscale point; normValue_0_1 < 0.5
whismanoid 34:a1993a1ee904 3920 calibration_05_normValue_0_1[0] = 0.25; calibration_05_V[0] = 0.3;
whismanoid 34:a1993a1ee904 3921 calibration_05_normValue_0_1[1] = 0.25; calibration_05_V[1] = 0.3;
whismanoid 34:a1993a1ee904 3922 calibration_05_normValue_0_1[2] = 0.25; calibration_05_V[2] = 0.3;
whismanoid 34:a1993a1ee904 3923 calibration_05_normValue_0_1[3] = 0.25; calibration_05_V[3] = 0.3;
whismanoid 34:a1993a1ee904 3924 calibration_05_normValue_0_1[4] = 0.25; calibration_05_V[4] = 1.5;
whismanoid 34:a1993a1ee904 3925 calibration_05_normValue_0_1[5] = 0.25; calibration_05_V[5] = 1.5;
whismanoid 34:a1993a1ee904 3926 //
whismanoid 34:a1993a1ee904 3927 // nominal 95% fullscale point; normValue_0_1 > 0.5
whismanoid 34:a1993a1ee904 3928 calibration_95_normValue_0_1[0] = 0.75; calibration_95_V[0] = 0.9;
whismanoid 34:a1993a1ee904 3929 calibration_95_normValue_0_1[1] = 0.75; calibration_95_V[1] = 0.9;
whismanoid 34:a1993a1ee904 3930 calibration_95_normValue_0_1[2] = 0.75; calibration_95_V[2] = 0.9;
whismanoid 34:a1993a1ee904 3931 calibration_95_normValue_0_1[3] = 0.75; calibration_95_V[3] = 0.9;
whismanoid 34:a1993a1ee904 3932 calibration_95_normValue_0_1[4] = 0.75; calibration_95_V[4] = 4.5;
whismanoid 34:a1993a1ee904 3933 calibration_95_normValue_0_1[5] = 0.75; calibration_95_V[5] = 4.5;
whismanoid 34:a1993a1ee904 3934 //
whismanoid 34:a1993a1ee904 3935 }
whismanoid 34:a1993a1ee904 3936 }
whismanoid 34:a1993a1ee904 3937 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3938 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3939 // %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 3940 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 3941 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 3942 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 3943 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 3944 {
whismanoid 34:a1993a1ee904 3945 double normValue_0_1, V;
whismanoid 34:a1993a1ee904 3946 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 3947 {
whismanoid 34:a1993a1ee904 3948 static char key_can0n[8] = "cal0n__";
whismanoid 34:a1993a1ee904 3949 sprintf(key_can0n, "cal%1dn", ch);
whismanoid 34:a1993a1ee904 3950 static char key_cal0v[8] = "cal0v__";
whismanoid 34:a1993a1ee904 3951 sprintf(key_cal0v, "cal%1dv", ch);
whismanoid 34:a1993a1ee904 3952 int pointLimit = 3;
whismanoid 34:a1993a1ee904 3953 while (cmdLine.parse_double(key_can0n, normValue_0_1))
whismanoid 34:a1993a1ee904 3954 {
whismanoid 34:a1993a1ee904 3955 if (normValue_0_1 < 0.5) {
whismanoid 34:a1993a1ee904 3956 calibration_05_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 3957 }
whismanoid 34:a1993a1ee904 3958 else {
whismanoid 34:a1993a1ee904 3959 calibration_95_normValue_0_1[ch] = normValue_0_1;
whismanoid 34:a1993a1ee904 3960 }
whismanoid 34:a1993a1ee904 3961 if (cmdLine.parse_double(key_cal0v, V))
whismanoid 34:a1993a1ee904 3962 {
whismanoid 34:a1993a1ee904 3963 if (normValue_0_1 < 0.5) {
whismanoid 34:a1993a1ee904 3964 calibration_05_V[ch] = V;
whismanoid 34:a1993a1ee904 3965 }
whismanoid 34:a1993a1ee904 3966 else {
whismanoid 34:a1993a1ee904 3967 calibration_95_V[ch] = V;
whismanoid 34:a1993a1ee904 3968 }
whismanoid 34:a1993a1ee904 3969 }
whismanoid 34:a1993a1ee904 3970 if (pointLimit-- == 0) break;
whismanoid 34:a1993a1ee904 3971 } // end while (cmdLine.parse_double(key_can0n, normValue_0_1))
whismanoid 34:a1993a1ee904 3972 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 3973 }
whismanoid 34:a1993a1ee904 3974 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3975 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 3976 // %A cal0test=0.5 test calibration functions by calculating the calibrated voltage of specified normValue_0_1
whismanoid 34:a1993a1ee904 3977 // double CalibratedNormValue(int channel_0_5, double raw_normValue_0_1);
whismanoid 34:a1993a1ee904 3978 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 3979 {
whismanoid 34:a1993a1ee904 3980 static char key_cal0test[12] = "cal0test__";
whismanoid 34:a1993a1ee904 3981 sprintf(key_cal0test, "cal%1dtest", ch);
whismanoid 34:a1993a1ee904 3982 double normValue_0_1, Vtest;
whismanoid 34:a1993a1ee904 3983 if (cmdLine.parse_double(key_cal0test, Vtest))
whismanoid 34:a1993a1ee904 3984 {
whismanoid 34:a1993a1ee904 3985 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 3986 normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 3987 //
whismanoid 34:a1993a1ee904 3988 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 3989 ch,
whismanoid 34:a1993a1ee904 3990 normValue_0_1,
whismanoid 34:a1993a1ee904 3991 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 3992 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 3993 );
whismanoid 34:a1993a1ee904 3994 //
whismanoid 34:a1993a1ee904 3995 // sweep CalibratedNormValue argument
whismanoid 34:a1993a1ee904 3996 double normValue_0_1_start = -0.05;
whismanoid 34:a1993a1ee904 3997 double normValue_0_1_step = 0.05;
whismanoid 34:a1993a1ee904 3998 double normValue_0_1_end = 1.07;
whismanoid 34:a1993a1ee904 3999 for (normValue_0_1 = normValue_0_1_start;
whismanoid 34:a1993a1ee904 4000 normValue_0_1 <= normValue_0_1_end;
whismanoid 34:a1993a1ee904 4001 normValue_0_1 = normValue_0_1 + normValue_0_1_step)
whismanoid 34:a1993a1ee904 4002 {
whismanoid 34:a1993a1ee904 4003 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV\r\n",
whismanoid 34:a1993a1ee904 4004 ch,
whismanoid 34:a1993a1ee904 4005 normValue_0_1,
whismanoid 34:a1993a1ee904 4006 CalibratedNormValue(ch, normValue_0_1),
whismanoid 34:a1993a1ee904 4007 (CalibratedNormValue(ch, normValue_0_1) * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4008 );
whismanoid 34:a1993a1ee904 4009 }
whismanoid 34:a1993a1ee904 4010 }
whismanoid 34:a1993a1ee904 4011 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4012 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4013 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4014 // %A v0cal=1.000V -- calibrate channel against a known input voltage
whismanoid 34:a1993a1ee904 4015 // double calibration_05_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4016 // double calibration_05_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4017 // double calibration_95_normValue_0_1 [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4018 // double calibration_95_V [NUM_PLATFORM_ANALOG_IN_CHANNELS] = {0.0, ... }
whismanoid 34:a1993a1ee904 4019 for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4020 {
whismanoid 34:a1993a1ee904 4021 static char key_v0cal[10] = "v0cal__";
whismanoid 34:a1993a1ee904 4022 sprintf(key_v0cal, "v%1dcal", ch);
whismanoid 34:a1993a1ee904 4023 double Vtest;
whismanoid 34:a1993a1ee904 4024 if (cmdLine.parse_double(key_v0cal, Vtest))
whismanoid 34:a1993a1ee904 4025 {
whismanoid 34:a1993a1ee904 4026 // divide Vtest/adc_full_scale_voltage[0] to get normValue_0_1
whismanoid 34:a1993a1ee904 4027 double Vtest_normValue_0_1 = Vtest/adc_full_scale_voltage[ch];
whismanoid 34:a1993a1ee904 4028 //
whismanoid 34:a1993a1ee904 4029 // %A v0cal=1.000 calibrate one channel by measuring against a known input voltage
whismanoid 34:a1993a1ee904 4030 //
whismanoid 34:a1993a1ee904 4031 cmdLine.serial().printf("\r\n Measuring against input voltage of %1.6fV...", Vtest);
whismanoid 34:a1993a1ee904 4032 const int numberOfMeasurements = 16;
whismanoid 34:a1993a1ee904 4033 double Sx_measure_normValue_0_1 = 0; // sum of values
whismanoid 34:a1993a1ee904 4034 double Sxx_measure_normValue_0_1 = 0; // sum of the squares of the values
whismanoid 34:a1993a1ee904 4035 for (int count = 0; count < numberOfMeasurements; count++)
whismanoid 34:a1993a1ee904 4036 {
whismanoid 34:a1993a1ee904 4037 double measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4038 switch(ch)
whismanoid 34:a1993a1ee904 4039 {
whismanoid 34:a1993a1ee904 4040 case 0: measure_normValue_0_1 = analogIn0.read(); break;
whismanoid 34:a1993a1ee904 4041 case 1: measure_normValue_0_1 = analogIn1.read(); break;
whismanoid 34:a1993a1ee904 4042 case 2: measure_normValue_0_1 = analogIn2.read(); break;
whismanoid 34:a1993a1ee904 4043 case 3: measure_normValue_0_1 = analogIn3.read(); break;
whismanoid 34:a1993a1ee904 4044 case 4: measure_normValue_0_1 = analogIn4.read(); break;
whismanoid 34:a1993a1ee904 4045 case 5: measure_normValue_0_1 = analogIn5.read(); break;
whismanoid 34:a1993a1ee904 4046 }
whismanoid 34:a1993a1ee904 4047 Sx_measure_normValue_0_1 = Sx_measure_normValue_0_1 + measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4048 Sxx_measure_normValue_0_1 = Sxx_measure_normValue_0_1 + (measure_normValue_0_1 * measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4049 cmdLine.serial().printf("\r\n raw: %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4050 measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4051 (measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4052 );
whismanoid 34:a1993a1ee904 4053 }
whismanoid 34:a1993a1ee904 4054 cmdLine.serial().printf("\r\n numberOfMeasurements = %d", numberOfMeasurements);
whismanoid 34:a1993a1ee904 4055 cmdLine.serial().printf("\r\n Sx_measure_normValue_0_1 = %1.6f", Sx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4056 cmdLine.serial().printf("\r\n Sxx_measure_normValue_0_1 = %1.6f", Sxx_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4057 //
whismanoid 34:a1993a1ee904 4058 // calculate mean_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 4059 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 4060 double mean_measure_normValue_0_1 = Sx_measure_normValue_0_1 / numberOfMeasurements;
whismanoid 34:a1993a1ee904 4061 cmdLine.serial().printf("\r\n mean = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4062 mean_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4063 (mean_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4064 );
whismanoid 34:a1993a1ee904 4065 //
whismanoid 34:a1993a1ee904 4066 // TODO: calculate sample variance_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 4067 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 4068 // variance_measure_normValue_0_1 = (Sxx - ( Sx * Sx / nWords) ) / (nWords - 1);
whismanoid 34:a1993a1ee904 4069 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 4070 cmdLine.serial().printf("\r\n variance = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4071 variance_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4072 (variance_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4073 );
whismanoid 34:a1993a1ee904 4074 //
whismanoid 34:a1993a1ee904 4075 // calculate sample stddev_measure_normValue_0_1 from
whismanoid 34:a1993a1ee904 4076 // Sxx_measure_normValue_0_1, Sx_measure_normValue_0_1, numberOfMeasurements
whismanoid 34:a1993a1ee904 4077 double stddev_measure_normValue_0_1 = sqrt(variance_measure_normValue_0_1);
whismanoid 34:a1993a1ee904 4078 cmdLine.serial().printf("\r\n stddev = %7.6f%% = %1.6fV",
whismanoid 34:a1993a1ee904 4079 stddev_measure_normValue_0_1 * 100.0,
whismanoid 34:a1993a1ee904 4080 (stddev_measure_normValue_0_1 * adc_full_scale_voltage[ch])
whismanoid 34:a1993a1ee904 4081 );
whismanoid 34:a1993a1ee904 4082 //
whismanoid 34:a1993a1ee904 4083 // Validate the measurements:
whismanoid 34:a1993a1ee904 4084 // is the mean near the expected value?
whismanoid 34:a1993a1ee904 4085 // is the standard deviation not too high?
whismanoid 34:a1993a1ee904 4086 bool isCalibrationValid = true;
whismanoid 34:a1993a1ee904 4087 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) > 0.1) {
whismanoid 34:a1993a1ee904 4088 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 4089 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 4090 }
whismanoid 34:a1993a1ee904 4091 if ((Vtest_normValue_0_1 - mean_measure_normValue_0_1) < -0.1) {
whismanoid 34:a1993a1ee904 4092 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 4093 cmdLine.serial().printf(" mean value too far from expected.\r\n");
whismanoid 34:a1993a1ee904 4094 }
whismanoid 34:a1993a1ee904 4095 if ((stddev_measure_normValue_0_1) > 10) {
whismanoid 34:a1993a1ee904 4096 isCalibrationValid = false;
whismanoid 34:a1993a1ee904 4097 cmdLine.serial().printf(" stddev too high.\r\n");
whismanoid 34:a1993a1ee904 4098 }
whismanoid 34:a1993a1ee904 4099 if (isCalibrationValid)
whismanoid 34:a1993a1ee904 4100 {
whismanoid 34:a1993a1ee904 4101 // update calibration point (mean_measure_normValue_0_1, Vtest)
whismanoid 34:a1993a1ee904 4102 if (Vtest_normValue_0_1 < 0.5) {
whismanoid 34:a1993a1ee904 4103 calibration_05_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4104 calibration_05_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 4105 } else {
whismanoid 34:a1993a1ee904 4106 calibration_95_normValue_0_1[ch] = mean_measure_normValue_0_1;
whismanoid 34:a1993a1ee904 4107 calibration_95_V[ch] = Vtest;
whismanoid 34:a1993a1ee904 4108 }
whismanoid 34:a1993a1ee904 4109 //
whismanoid 34:a1993a1ee904 4110 // print updated calibration values
whismanoid 34:a1993a1ee904 4111 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 4112 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 4113 ch, calibration_05_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4114 ch, calibration_05_V[ch],
whismanoid 34:a1993a1ee904 4115 ch, calibration_95_normValue_0_1[ch],
whismanoid 34:a1993a1ee904 4116 ch, calibration_95_V[ch]
whismanoid 34:a1993a1ee904 4117 );
whismanoid 34:a1993a1ee904 4118 // print corrected value of mean of measurements (should be close to Vtest)
whismanoid 34:a1993a1ee904 4119 cmdLine.serial().printf(" CalibratedNormValue(%d, %1.6f) = %1.6f = %1.6fV vs %1.6fV\r\n",
whismanoid 34:a1993a1ee904 4120 ch,
whismanoid 34:a1993a1ee904 4121 mean_measure_normValue_0_1,
whismanoid 34:a1993a1ee904 4122 CalibratedNormValue(ch, mean_measure_normValue_0_1),
whismanoid 34:a1993a1ee904 4123 (CalibratedNormValue(ch, mean_measure_normValue_0_1) * adc_full_scale_voltage[ch]),
whismanoid 34:a1993a1ee904 4124 Vtest
whismanoid 34:a1993a1ee904 4125 );
whismanoid 34:a1993a1ee904 4126 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 4127 else {
whismanoid 34:a1993a1ee904 4128 cmdLine.serial().printf("\r\n");
whismanoid 34:a1993a1ee904 4129 cmdLine.serial().printf(" Measurement Error: Calibration will not be updated.\r\n");
whismanoid 34:a1993a1ee904 4130 } // end if (isCalibrationValid)
whismanoid 34:a1993a1ee904 4131 } // end if key_v0cal
whismanoid 34:a1993a1ee904 4132 } // end for (int ch = 0; ch < NUM_PLATFORM_ANALOG_IN_CHANNELS; ch++)
whismanoid 34:a1993a1ee904 4133 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4134 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4135 // TODO: %A___TBD___ save calibration values in non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 4136 #endif // HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4137 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4138 // TODO: %A___TBD___ load calibration values from non-volatile memory on-chip (if supported)
whismanoid 34:a1993a1ee904 4139 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4140 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 4141 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 15:37c83ec50ea0 4142 for (int pinIndex = 0; pinIndex < 2; pinIndex++)
whismanoid 15:37c83ec50ea0 4143 {
whismanoid 15:37c83ec50ea0 4144 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 4145 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 4146 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 15:37c83ec50ea0 4147 float normValue_0_1 = analogInPin.read();
whismanoid 34:a1993a1ee904 4148 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4149 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4150 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 4151 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4152 //
whismanoid 15:37c83ec50ea0 4153 int pinIndexH = pinIndex + 4;
whismanoid 15:37c83ec50ea0 4154 int cPinIndexH = '0' + pinIndexH;
whismanoid 15:37c83ec50ea0 4155 AnalogIn& analogInPinH = find_analogInPin(cPinIndexH);
whismanoid 15:37c83ec50ea0 4156 float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH];
whismanoid 15:37c83ec50ea0 4157 float normValueH_0_1 = analogInPinH.read();
whismanoid 34:a1993a1ee904 4158 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4159 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4160 normValueH_0_1 = CalibratedNormValue(pinIndex, normValueH_0_1);
whismanoid 34:a1993a1ee904 4161 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4162 //
whismanoid 15:37c83ec50ea0 4163 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV AIN%c = %7.3f%% = %1.3fV \r\n",
whismanoid 15:37c83ec50ea0 4164 cPinIndex,
whismanoid 15:37c83ec50ea0 4165 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4166 normValue_0_1 * adc_full_scale_voltage,
whismanoid 15:37c83ec50ea0 4167 cPinIndexH,
whismanoid 15:37c83ec50ea0 4168 normValueH_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4169 normValueH_0_1 * adc_full_scale_voltageH
whismanoid 15:37c83ec50ea0 4170 );
whismanoid 15:37c83ec50ea0 4171 }
whismanoid 15:37c83ec50ea0 4172 for (int pinIndex = 2; pinIndex < 4; pinIndex++)
whismanoid 15:37c83ec50ea0 4173 {
whismanoid 15:37c83ec50ea0 4174 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 4175 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 4176 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 15:37c83ec50ea0 4177 float normValue_0_1 = analogInPin.read();
whismanoid 34:a1993a1ee904 4178 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4179 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4180 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 4181 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4182 //
whismanoid 15:37c83ec50ea0 4183 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 4184 cPinIndex,
whismanoid 15:37c83ec50ea0 4185 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4186 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 4187 );
whismanoid 15:37c83ec50ea0 4188 }
whismanoid 15:37c83ec50ea0 4189 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 4190 // Platform board uses simple analog inputs
whismanoid 15:37c83ec50ea0 4191 // assume standard Arduino analog inputs A0-A5
whismanoid 15:37c83ec50ea0 4192 for (int pinIndex = 0; pinIndex < 6; pinIndex++)
whismanoid 15:37c83ec50ea0 4193 {
whismanoid 15:37c83ec50ea0 4194 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 4195 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 4196 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 15:37c83ec50ea0 4197 float normValue_0_1 = analogInPin.read();
whismanoid 34:a1993a1ee904 4198 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 4199 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 4200 normValue_0_1 = CalibratedNormValue(pinIndex, normValue_0_1);
whismanoid 34:a1993a1ee904 4201 #endif // HAS_Platform_AIN_Calibration
whismanoid 15:37c83ec50ea0 4202 //
whismanoid 15:37c83ec50ea0 4203 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 4204 cPinIndex,
whismanoid 15:37c83ec50ea0 4205 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 4206 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 4207 );
whismanoid 15:37c83ec50ea0 4208 }
whismanoid 15:37c83ec50ea0 4209 #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 4210 }
whismanoid 15:37c83ec50ea0 4211 break;
whismanoid 15:37c83ec50ea0 4212 #endif
whismanoid 15:37c83ec50ea0 4213 //
whismanoid 15:37c83ec50ea0 4214 #if HAS_SPI2_MAX541
whismanoid 15:37c83ec50ea0 4215 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 4216 {
whismanoid 15:37c83ec50ea0 4217 // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV)
whismanoid 15:37c83ec50ea0 4218 // MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 15:37c83ec50ea0 4219 float voltageV = max541.Get_Voltage();
whismanoid 15:37c83ec50ea0 4220 // if (cmdLine[2] == '+') {
whismanoid 15:37c83ec50ea0 4221 // // %D+
whismanoid 15:37c83ec50ea0 4222 // voltageV = voltageV * 1.25f;
whismanoid 15:37c83ec50ea0 4223 // if (voltageV >= max541.VRef) voltageV = max541.VRef;
whismanoid 15:37c83ec50ea0 4224 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4225 // }
whismanoid 15:37c83ec50ea0 4226 // else if (cmdLine[2] == '-') {
whismanoid 15:37c83ec50ea0 4227 // // %D-
whismanoid 15:37c83ec50ea0 4228 // voltageV = voltageV * 0.75f;
whismanoid 15:37c83ec50ea0 4229 // if (voltageV < 0.1f) voltageV = 0.1f;
whismanoid 15:37c83ec50ea0 4230 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4231 // }
whismanoid 15:37c83ec50ea0 4232 if (cmdLine.parse_float("V", voltageV))
whismanoid 15:37c83ec50ea0 4233 {
whismanoid 15:37c83ec50ea0 4234 // %D V=1.234 -- set voltage
whismanoid 15:37c83ec50ea0 4235 max541.Set_Voltage(voltageV);
whismanoid 15:37c83ec50ea0 4236 }
whismanoid 15:37c83ec50ea0 4237 else if (cmdLine.parse_float("TEST", voltageV))
whismanoid 15:37c83ec50ea0 4238 {
whismanoid 15:37c83ec50ea0 4239 // %D TEST=1.234 -- set voltage and compare with AIN0
whismanoid 15:37c83ec50ea0 4240 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4241 }
whismanoid 15:37c83ec50ea0 4242 else if (cmdLine.parse_float("CAL", voltageV))
whismanoid 15:37c83ec50ea0 4243 {
whismanoid 15:37c83ec50ea0 4244 // %D CAL=1.234 -- calibrate VRef and compare with AIN0
whismanoid 15:37c83ec50ea0 4245
whismanoid 15:37c83ec50ea0 4246 max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
whismanoid 15:37c83ec50ea0 4247 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 4248 const int average_count = 100;
whismanoid 15:37c83ec50ea0 4249 const double average_K = 0.25;
whismanoid 15:37c83ec50ea0 4250 for (int count = 0; count < average_count; count++) {
whismanoid 15:37c83ec50ea0 4251 double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 4252 max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
whismanoid 15:37c83ec50ea0 4253 }
whismanoid 15:37c83ec50ea0 4254 max541.VRef = 2.0 * max541_midscale_V;
whismanoid 15:37c83ec50ea0 4255 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4256 "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
whismanoid 15:37c83ec50ea0 4257 max541_midscale_V, max541.VRef);
whismanoid 15:37c83ec50ea0 4258 // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
whismanoid 15:37c83ec50ea0 4259 voltageV = 1.0f;
whismanoid 15:37c83ec50ea0 4260 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 4261 }
whismanoid 15:37c83ec50ea0 4262 else {
whismanoid 15:37c83ec50ea0 4263 // %D -- print MAX541 DAC status
whismanoid 15:37c83ec50ea0 4264 cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n",
whismanoid 15:37c83ec50ea0 4265 max541.Get_Code(), max541.Get_Voltage(), max541.VRef);
whismanoid 15:37c83ec50ea0 4266 }
whismanoid 15:37c83ec50ea0 4267 }
whismanoid 15:37c83ec50ea0 4268 break;
whismanoid 15:37c83ec50ea0 4269 #endif
whismanoid 15:37c83ec50ea0 4270
whismanoid 15:37c83ec50ea0 4271 //
whismanoid 15:37c83ec50ea0 4272 #if HAS_I2C // SUPPORT_I2C
whismanoid 15:37c83ec50ea0 4273 case 'I': case 'i':
whismanoid 15:37c83ec50ea0 4274 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 4275 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 4276 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 4277 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 4278 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 4279 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 4280 // get next character
whismanoid 15:37c83ec50ea0 4281 // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7
whismanoid 15:37c83ec50ea0 4282 cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7);
whismanoid 15:37c83ec50ea0 4283 // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count
whismanoid 15:37c83ec50ea0 4284 g_I2C_read_count = 0; // read count must be reset every command
whismanoid 15:37c83ec50ea0 4285 cmdLine.parse_byte_dec("RD", g_I2C_read_count);
whismanoid 15:37c83ec50ea0 4286 // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress
whismanoid 15:37c83ec50ea0 4287 cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress);
whismanoid 15:37c83ec50ea0 4288 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 4289 {
whismanoid 15:37c83ec50ea0 4290 case 'P': case 'p':
whismanoid 15:37c83ec50ea0 4291 {
whismanoid 15:37c83ec50ea0 4292 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 4293 HuntAttachedI2CDevices(cmdLine, 0x03, 0x77);
whismanoid 15:37c83ec50ea0 4294 }
whismanoid 15:37c83ec50ea0 4295 break;
whismanoid 15:37c83ec50ea0 4296 case 'C': case 'c':
whismanoid 15:37c83ec50ea0 4297 {
whismanoid 15:37c83ec50ea0 4298 bool isUpdatedI2CConfig = false;
whismanoid 15:37c83ec50ea0 4299 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 4300 // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz
whismanoid 15:37c83ec50ea0 4301 if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz))
whismanoid 15:37c83ec50ea0 4302 {
whismanoid 15:37c83ec50ea0 4303 isUpdatedI2CConfig = true;
whismanoid 15:37c83ec50ea0 4304 // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 4305 if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 4306 {
whismanoid 15:37c83ec50ea0 4307 g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 4308 }
whismanoid 15:37c83ec50ea0 4309 if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 4310 {
whismanoid 15:37c83ec50ea0 4311 g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 4312 }
whismanoid 15:37c83ec50ea0 4313 }
whismanoid 15:37c83ec50ea0 4314 if (isUpdatedI2CConfig)
whismanoid 15:37c83ec50ea0 4315 {
whismanoid 15:37c83ec50ea0 4316 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4317 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4318 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4319 i2cMaster.start();
whismanoid 15:37c83ec50ea0 4320 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 4321 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4322 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4323 "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 15:37c83ec50ea0 4324 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 15:37c83ec50ea0 4325 (g_I2C_SCL_Hz / 1000.));
whismanoid 15:37c83ec50ea0 4326 i2cMaster.start();
whismanoid 15:37c83ec50ea0 4327 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 4328 }
whismanoid 15:37c83ec50ea0 4329 }
whismanoid 15:37c83ec50ea0 4330 break;
whismanoid 15:37c83ec50ea0 4331 case 'W': case 'w':
whismanoid 15:37c83ec50ea0 4332 {
whismanoid 15:37c83ec50ea0 4333 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4334 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4335 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4336 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 4337 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4338 #define MAX_I2C_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 4339 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 4340 static char mosiData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4341 static char misoData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4342 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 4343 MAX_I2C_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 4344 {
whismanoid 15:37c83ec50ea0 4345 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 4346 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4347 "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->",
whismanoid 15:37c83ec50ea0 4348 g_I2C_deviceAddress7,
whismanoid 15:37c83ec50ea0 4349 (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count);
whismanoid 15:37c83ec50ea0 4350 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 4351 {
whismanoid 15:37c83ec50ea0 4352 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 4353 }
whismanoid 15:37c83ec50ea0 4354 //
whismanoid 15:37c83ec50ea0 4355 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 4356 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 4357 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4358 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 4359 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 4360 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 4361 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 4362 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4363 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4364 // /* 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 4365 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 4366 const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4367 unsigned int misoLength = 0;
whismanoid 15:37c83ec50ea0 4368 bool repeated = (g_I2C_read_count > 0);
whismanoid 15:37c83ec50ea0 4369 //
whismanoid 15:37c83ec50ea0 4370 int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated);
whismanoid 15:37c83ec50ea0 4371 switch (writeStatus)
whismanoid 15:37c83ec50ea0 4372 {
whismanoid 15:37c83ec50ea0 4373 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 4374 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 4375 default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 4376 writeStatus);
whismanoid 15:37c83ec50ea0 4377 }
whismanoid 15:37c83ec50ea0 4378 if (repeated)
whismanoid 15:37c83ec50ea0 4379 {
whismanoid 15:37c83ec50ea0 4380 int readStatus =
whismanoid 15:37c83ec50ea0 4381 i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false);
whismanoid 15:37c83ec50ea0 4382 switch (readStatus)
whismanoid 15:37c83ec50ea0 4383 {
whismanoid 15:37c83ec50ea0 4384 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 4385 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 4386 default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 4387 readStatus);
whismanoid 15:37c83ec50ea0 4388 }
whismanoid 15:37c83ec50ea0 4389 }
whismanoid 15:37c83ec50ea0 4390 //
whismanoid 15:37c83ec50ea0 4391 if (misoLength > 0)
whismanoid 15:37c83ec50ea0 4392 {
whismanoid 15:37c83ec50ea0 4393 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 4394 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 4395 for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count;
whismanoid 15:37c83ec50ea0 4396 byteIndex++)
whismanoid 15:37c83ec50ea0 4397 {
whismanoid 15:37c83ec50ea0 4398 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 4399 }
whismanoid 15:37c83ec50ea0 4400 }
whismanoid 15:37c83ec50ea0 4401 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 4402 }
whismanoid 15:37c83ec50ea0 4403 }
whismanoid 15:37c83ec50ea0 4404 break;
whismanoid 15:37c83ec50ea0 4405 case 'R': case 'r':
whismanoid 15:37c83ec50ea0 4406 {
whismanoid 15:37c83ec50ea0 4407 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4408 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4409 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4410 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 4411 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 4412 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 4413 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4414 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 4415 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 4416 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 4417 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 4418 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4419 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4420 // /* 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 4421 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 4422 }
whismanoid 15:37c83ec50ea0 4423 break;
whismanoid 15:37c83ec50ea0 4424 case '^':
whismanoid 15:37c83ec50ea0 4425 {
whismanoid 15:37c83ec50ea0 4426 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 4427 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 4428 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 4429 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 4430 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 4431 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 4432 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 4433 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 4434 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 4435 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 4436 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 4437 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4438 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 4439 // /* 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 4440 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 4441 }
whismanoid 15:37c83ec50ea0 4442 break;
whismanoid 15:37c83ec50ea0 4443 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 4444 break;
whismanoid 15:37c83ec50ea0 4445 #endif
whismanoid 15:37c83ec50ea0 4446 //
whismanoid 15:37c83ec50ea0 4447 #if HAS_SPI // SUPPORT_SPI
whismanoid 15:37c83ec50ea0 4448 case 'S': case 's':
whismanoid 15:37c83ec50ea0 4449 {
whismanoid 15:37c83ec50ea0 4450 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 4451 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 4452 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 4453 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 4454 //
whismanoid 15:37c83ec50ea0 4455 // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d
whismanoid 15:37c83ec50ea0 4456 bool isUpdatedSPIConfig = false;
whismanoid 15:37c83ec50ea0 4457 // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2
whismanoid 15:37c83ec50ea0 4458 // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1
whismanoid 15:37c83ec50ea0 4459 if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2))
whismanoid 15:37c83ec50ea0 4460 {
whismanoid 15:37c83ec50ea0 4461 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 4462 }
whismanoid 15:37c83ec50ea0 4463 if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1))
whismanoid 15:37c83ec50ea0 4464 {
whismanoid 15:37c83ec50ea0 4465 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 4466 }
whismanoid 15:37c83ec50ea0 4467 if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1))
whismanoid 15:37c83ec50ea0 4468 {
whismanoid 15:37c83ec50ea0 4469 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 4470 }
whismanoid 15:37c83ec50ea0 4471 // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz
whismanoid 15:37c83ec50ea0 4472 if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz))
whismanoid 15:37c83ec50ea0 4473 {
whismanoid 15:37c83ec50ea0 4474 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 4475 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 4476 if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 4477 {
whismanoid 15:37c83ec50ea0 4478 g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 4479 }
whismanoid 15:37c83ec50ea0 4480 if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 4481 {
whismanoid 15:37c83ec50ea0 4482 g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 4483 }
whismanoid 15:37c83ec50ea0 4484 }
whismanoid 15:37c83ec50ea0 4485 // Update SPI configuration
whismanoid 15:37c83ec50ea0 4486 if (isUpdatedSPIConfig)
whismanoid 15:37c83ec50ea0 4487 {
whismanoid 15:37c83ec50ea0 4488 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 4489 spi_cs = g_SPI_cs_state;
whismanoid 15:37c83ec50ea0 4490 spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0
whismanoid 15:37c83ec50ea0 4491 #if APPLICATION_MAX5715
whismanoid 15:37c83ec50ea0 4492 g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 4493 #elif APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 4494 g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 4495 #elif APPLICATION_MAX5171
whismanoid 15:37c83ec50ea0 4496 g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 4497 #elif APPLICATION_MAX11410
whismanoid 15:37c83ec50ea0 4498 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 4499 #elif APPLICATION_MAX12345
whismanoid 15:37c83ec50ea0 4500 g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 4501 #else
whismanoid 15:37c83ec50ea0 4502 spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 15:37c83ec50ea0 4503 #endif
whismanoid 15:37c83ec50ea0 4504 //
whismanoid 15:37c83ec50ea0 4505 double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 4506 int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate
whismanoid 15:37c83ec50ea0 4507 double actual_SCLK_Hz = SystemCoreClock / actual_divisor;
whismanoid 15:37c83ec50ea0 4508 //
whismanoid 15:37c83ec50ea0 4509 // 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 4510 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 4511 "\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 4512 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 15:37c83ec50ea0 4513 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0),
whismanoid 15:37c83ec50ea0 4514 g_SPI_cs_state,
whismanoid 15:37c83ec50ea0 4515 g_SPI_SCLK_Hz,
whismanoid 15:37c83ec50ea0 4516 (g_SPI_SCLK_Hz / 1000000.),
whismanoid 15:37c83ec50ea0 4517 ((double)(SystemCoreClock / 1000000.)),
whismanoid 15:37c83ec50ea0 4518 ideal_divisor,
whismanoid 15:37c83ec50ea0 4519 (actual_SCLK_Hz / 1000000.)
whismanoid 15:37c83ec50ea0 4520 );
whismanoid 15:37c83ec50ea0 4521 }
whismanoid 15:37c83ec50ea0 4522 // get next character
whismanoid 15:37c83ec50ea0 4523 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 4524 {
whismanoid 15:37c83ec50ea0 4525 case 'C': case 's':
whismanoid 15:37c83ec50ea0 4526 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 4527 break;
whismanoid 15:37c83ec50ea0 4528 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 4529 // %SD -- SPI diagnostic messages enable
whismanoid 15:37c83ec50ea0 4530 if (g_MAX5719_device.onSPIprint) {
whismanoid 15:37c83ec50ea0 4531 g_MAX5719_device.onSPIprint = NULL;
whismanoid 15:37c83ec50ea0 4532 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') != None is false
whismanoid 15:37c83ec50ea0 4533 }
whismanoid 15:37c83ec50ea0 4534 else {
whismanoid 15:37c83ec50ea0 4535 void onSPIprint_handler(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]);
whismanoid 15:37c83ec50ea0 4536 g_MAX5719_device.onSPIprint = onSPIprint_handler;
whismanoid 15:37c83ec50ea0 4537 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') is false
whismanoid 15:37c83ec50ea0 4538 }
whismanoid 15:37c83ec50ea0 4539 break;
whismanoid 15:37c83ec50ea0 4540 case 'W': case 'R': case 'w': case 'r':
whismanoid 15:37c83ec50ea0 4541 {
whismanoid 15:37c83ec50ea0 4542 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 4543 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 4544 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4545 #define MAX_SPI_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 4546 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 4547 static char mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4548 static char misoData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 4549 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 4550 MAX_SPI_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 4551 {
whismanoid 15:37c83ec50ea0 4552 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 4553 cmdLine.serial().printf("\r\nSPI");
whismanoid 15:37c83ec50ea0 4554 if (byteCount > 7) {
whismanoid 15:37c83ec50ea0 4555 cmdLine.serial().printf(" byteCount:%d", byteCount);
whismanoid 15:37c83ec50ea0 4556 }
whismanoid 15:37c83ec50ea0 4557 cmdLine.serial().printf(" MOSI->");
whismanoid 15:37c83ec50ea0 4558 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 4559 {
whismanoid 15:37c83ec50ea0 4560 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 4561 }
whismanoid 15:37c83ec50ea0 4562 spi_cs = 0;
whismanoid 15:37c83ec50ea0 4563 unsigned int numBytesTransferred =
whismanoid 15:37c83ec50ea0 4564 spi.write(mosiData, byteCount, misoData, byteCount);
whismanoid 15:37c83ec50ea0 4565 spi_cs = 1;
whismanoid 15:37c83ec50ea0 4566 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 4567 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 4568 for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred;
whismanoid 15:37c83ec50ea0 4569 byteIndex++)
whismanoid 15:37c83ec50ea0 4570 {
whismanoid 15:37c83ec50ea0 4571 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 4572 }
whismanoid 15:37c83ec50ea0 4573 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 4574 }
whismanoid 15:37c83ec50ea0 4575 }
whismanoid 15:37c83ec50ea0 4576 break;
whismanoid 15:37c83ec50ea0 4577 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 4578 } // case 'S': // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 4579 break;
whismanoid 15:37c83ec50ea0 4580 #endif
whismanoid 15:37c83ec50ea0 4581 //
whismanoid 15:37c83ec50ea0 4582 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 4583 } // switch(cmdLine[1])
whismanoid 15:37c83ec50ea0 4584 } // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 15:37c83ec50ea0 4585 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 15:37c83ec50ea0 4586
whismanoid 15:37c83ec50ea0 4587 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 4588 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 4589 void main_menu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 4590 {
whismanoid 9:45f98573eb6d 4591 // process command line
whismanoid 31:47eee7e0cc2d 4592 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 4593 if (g_Run_command_table_running == false) {
whismanoid 31:47eee7e0cc2d 4594 cmdLine.serial().printf("\r\nCmdLine buf:\"%s\"\r\n", cmdLine.str());
whismanoid 31:47eee7e0cc2d 4595 } // if (g_Run_command_table_running)
whismanoid 31:47eee7e0cc2d 4596 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 4597 if (g_Run_command_table_running == false) {
whismanoid 31:47eee7e0cc2d 4598 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 4599
whismanoid 4:d9b05924ad4c 4600 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 31:47eee7e0cc2d 4601 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 4602 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 4603 // If datalog is free running, halt on any possible received command
whismanoid 17:9397ea3ea7e9 4604 if (Datalogger_Trigger != trigger_Halt) {
whismanoid 4:d9b05924ad4c 4605 Datalogger_Trigger = trigger_Halt;
whismanoid 9:45f98573eb6d 4606 cmdLine.serial().printf("Datalog stopped by USB command input\r\n");
whismanoid 9:45f98573eb6d 4607 cmdLine.serial().printf("Restart datalog by sending LR\r\n");
whismanoid 4:d9b05924ad4c 4608 }
whismanoid 31:47eee7e0cc2d 4609 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 4610 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 4611
whismanoid 4:d9b05924ad4c 4612 // DIAGNOSTIC: print line buffer
whismanoid 4:d9b05924ad4c 4613 //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str());
whismanoid 4:d9b05924ad4c 4614 //
whismanoid 4:d9b05924ad4c 4615 switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 4616 {
whismanoid 4:d9b05924ad4c 4617 case '?':
whismanoid 4:d9b05924ad4c 4618 main_menu_status(cmdLine);
whismanoid 4:d9b05924ad4c 4619 main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 4620 // print command prompt
whismanoid 4:d9b05924ad4c 4621 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 4622 break;
whismanoid 4:d9b05924ad4c 4623 case '\r': case '\n': // ignore blank line
whismanoid 4:d9b05924ad4c 4624 case '\0': // ignore empty line
whismanoid 30:07197a430869 4625 main_menu_status(cmdLine);
whismanoid 30:07197a430869 4626 //~ main_menu_help(cmdLine);
whismanoid 30:07197a430869 4627 // print command prompt
whismanoid 30:07197a430869 4628 //cmdLine.serial().printf("\r\n>");
whismanoid 30:07197a430869 4629 break;
whismanoid 4:d9b05924ad4c 4630 case '#': // ignore comment line
whismanoid 4:d9b05924ad4c 4631 // # -- lines beginning with # are comments
whismanoid 30:07197a430869 4632 //
whismanoid 30:07197a430869 4633 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 4634 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in main_menu_onEOLcommandParser
whismanoid 30:07197a430869 4635 // # command handler update gstrRemarkText buffer instead of just ignoring the remark
whismanoid 30:07197a430869 4636 //
whismanoid 30:07197a430869 4637 // ignore extra spaces before the remark
whismanoid 30:07197a430869 4638 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 30:07197a430869 4639 int argIndex;
whismanoid 30:07197a430869 4640 for (argIndex = 1; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 4641 {
whismanoid 30:07197a430869 4642 if (cmdLine[argIndex] == ' ') break;
whismanoid 30:07197a430869 4643 }
whismanoid 30:07197a430869 4644 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 30:07197a430869 4645 {
whismanoid 30:07197a430869 4646 if (cmdLine[argIndex] != ' ') break;
whismanoid 30:07197a430869 4647 }
whismanoid 30:07197a430869 4648 //
whismanoid 30:07197a430869 4649 strncpy(gstrRemarkText, cmdLine.str()+argIndex, gstrRemarkTextLASTINDEX+1);
whismanoid 30:07197a430869 4650 // do not exceed string buffer limit; keep sentinel null character at end of buffer
whismanoid 30:07197a430869 4651 gstrRemarkText[gstrRemarkTextLASTINDEX] = '\0';
whismanoid 30:07197a430869 4652 for (int index = 0; index < gstrRemarkTextLASTINDEX; index++)
whismanoid 30:07197a430869 4653 {
whismanoid 30:07197a430869 4654 if ((gstrRemarkText[index]) == '\0') break; // null character at end of string
whismanoid 30:07197a430869 4655 if ((gstrRemarkText[index]) < 0x20) {
whismanoid 30:07197a430869 4656 // replace non-printing characters with _
whismanoid 30:07197a430869 4657 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 4658 continue;
whismanoid 30:07197a430869 4659 }
whismanoid 30:07197a430869 4660 if ((gstrRemarkText[index]) >= 0x7F) {
whismanoid 30:07197a430869 4661 // replace non-printing characters with _
whismanoid 30:07197a430869 4662 gstrRemarkText[index] = '_';
whismanoid 30:07197a430869 4663 continue;
whismanoid 30:07197a430869 4664 }
whismanoid 30:07197a430869 4665 switch(gstrRemarkText[index])
whismanoid 30:07197a430869 4666 {
whismanoid 30:07197a430869 4667 case ',':
whismanoid 30:07197a430869 4668 // replace , with ;
whismanoid 30:07197a430869 4669 gstrRemarkText[index] = ';';
whismanoid 30:07197a430869 4670 break;
whismanoid 30:07197a430869 4671 case '"':
whismanoid 30:07197a430869 4672 // replace " with '
whismanoid 30:07197a430869 4673 gstrRemarkText[index] = '\'';
whismanoid 30:07197a430869 4674 break;
whismanoid 30:07197a430869 4675 case '\\':
whismanoid 30:07197a430869 4676 // replace \ with /
whismanoid 30:07197a430869 4677 gstrRemarkText[index] = '/';
whismanoid 30:07197a430869 4678 break;
whismanoid 30:07197a430869 4679 }
whismanoid 30:07197a430869 4680 }
whismanoid 30:07197a430869 4681 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 4682 //
whismanoid 31:47eee7e0cc2d 4683 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 4684 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 4685 main_menu_status(cmdLine);
whismanoid 31:47eee7e0cc2d 4686 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 4687 //~ main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 4688 // print command prompt
whismanoid 4:d9b05924ad4c 4689 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 4690 break;
whismanoid 4:d9b05924ad4c 4691 #if ECHO_EOF_ON_EOL
whismanoid 4:d9b05924ad4c 4692 case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file
whismanoid 4:d9b05924ad4c 4693 cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 4694 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 4695 break;
whismanoid 4:d9b05924ad4c 4696 case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file
whismanoid 4:d9b05924ad4c 4697 cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 4698 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 4699 break;
whismanoid 4:d9b05924ad4c 4700 #endif
whismanoid 10:04022a61b527 4701 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 4702 case '!': // device init
whismanoid 10:04022a61b527 4703 {
whismanoid 10:04022a61b527 4704 cmdLine.serial().printf("Init");
whismanoid 10:04022a61b527 4705 // call function Init
whismanoid 10:04022a61b527 4706 uint8_t result = g_MAX11410_device.Init();
whismanoid 10:04022a61b527 4707 // cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 4708 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 4709 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 4710 // in command '!' device init, apply list of custom register writes after init
whismanoid 10:04022a61b527 4711 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 4712 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 10:04022a61b527 4713 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 10:04022a61b527 4714 uint32_t regData = custom_reg_init_data[index];
whismanoid 10:04022a61b527 4715 cmdLine.serial().printf("*%s=0x%06.6x",
whismanoid 10:04022a61b527 4716 g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress),
whismanoid 10:04022a61b527 4717 regData
whismanoid 10:04022a61b527 4718 );
whismanoid 10:04022a61b527 4719 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 10:04022a61b527 4720 }
whismanoid 10:04022a61b527 4721 #endif // USE_CUSTOM_REG_INIT
whismanoid 10:04022a61b527 4722 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 4723 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 4724 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 4725 }
whismanoid 10:04022a61b527 4726 break;
whismanoid 10:04022a61b527 4727 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 4728 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 4729 case '.':
whismanoid 4:d9b05924ad4c 4730 {
whismanoid 4:d9b05924ad4c 4731 // . -- SelfTest
whismanoid 4:d9b05924ad4c 4732 cmdLine.serial().printf("SelfTest()");
whismanoid 4:d9b05924ad4c 4733 SelfTest(cmdLine);
whismanoid 4:d9b05924ad4c 4734 }
whismanoid 4:d9b05924ad4c 4735 break;
whismanoid 4:d9b05924ad4c 4736 #endif // USE_SELFTEST
whismanoid 15:37c83ec50ea0 4737 #if 1 // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 4738 case '%':
whismanoid 4:d9b05924ad4c 4739 {
whismanoid 4:d9b05924ad4c 4740 pinsMonitor_submenu_onEOLcommandParser(cmdLine);
whismanoid 4:d9b05924ad4c 4741 }
whismanoid 4:d9b05924ad4c 4742 break; // case '%'
whismanoid 4:d9b05924ad4c 4743 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 9:45f98573eb6d 4744 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 4745 // reuse the Serial_Tester command *regName=regValue
whismanoid 10:04022a61b527 4746 // CODE GENERATOR: generate * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 4747 case '*':
whismanoid 10:04022a61b527 4748 {
whismanoid 10:04022a61b527 4749 // if buffer starts with a regName:
whismanoid 10:04022a61b527 4750 // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))):
whismanoid 10:04022a61b527 4751 // cmdLine.serial().printf(" scan RegName...\r\n");
whismanoid 10:04022a61b527 4752 }
whismanoid 10:04022a61b527 4753 break;
whismanoid 9:45f98573eb6d 4754 #endif // USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 4755 //
whismanoid 10:04022a61b527 4756 #if 1 // USE_AUX_SERIAL_CMD_FORWARDING && (HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL)
whismanoid 10:04022a61b527 4757 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_onEOLcommandParser
whismanoid 10:04022a61b527 4758 case '>':
whismanoid 10:04022a61b527 4759 {
whismanoid 10:04022a61b527 4760 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 4761 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 4762 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 4763 CmdLine& cmdLine_AuxSerial = cmdLine_AUXserial;
whismanoid 10:04022a61b527 4764 Serial& AuxSerial = AUXserial;
whismanoid 10:04022a61b527 4765 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 4766 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 4767 CmdLine& cmdLine_AuxSerial = cmdLine_DAPLINKserial;
whismanoid 10:04022a61b527 4768 Serial& AuxSerial = DAPLINKserial;
whismanoid 10:04022a61b527 4769 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 4770 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 4771 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 4772 //
whismanoid 10:04022a61b527 4773 // >> suppress key=value parsing
whismanoid 10:04022a61b527 4774 bool suppress_parsing = (cmdLine[1] == '>');
whismanoid 10:04022a61b527 4775 if (suppress_parsing == false) {
whismanoid 10:04022a61b527 4776 // int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 4777 if (cmdLine.parse_int_dec("baud", g_auxSerialCom_baud))
whismanoid 10:04022a61b527 4778 {
whismanoid 10:04022a61b527 4779 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- baud rate
whismanoid 10:04022a61b527 4780 cmdLine_AuxSerial.serial().printf("\r\n*** New Baud Rate %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 4781 AuxSerial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 4782 cmdLine_AuxSerial.serial().printf("\r\n*** Baud Rate was set to %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 4783 }
whismanoid 10:04022a61b527 4784 #if 0
whismanoid 10:04022a61b527 4785 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 4786 if (cmdLine.parse_int_dec("tx_wait_echo", g_auxSerialCom_tx_wait_echo))
whismanoid 10:04022a61b527 4787 {
whismanoid 10:04022a61b527 4788 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_wait_echo
whismanoid 10:04022a61b527 4789 //~ cmdLine_AuxSerial.serial().printf("\r\n*** tx_wait_echo was set to %d ***\r\n", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 4790 cmdLine.serial().printf("\r\n tx_wait_echo=%d", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 4791 }
whismanoid 10:04022a61b527 4792 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 4793 if (cmdLine.parse_int_dec("tx_char_delay_ms", g_auxSerialCom_tx_char_delay_ms))
whismanoid 10:04022a61b527 4794 {
whismanoid 10:04022a61b527 4795 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_char_delay_ms
whismanoid 10:04022a61b527 4796 //~ 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 4797 cmdLine.serial().printf("\r\n tx_char_delay_ms=%dms", g_auxSerialCom_tx_char_delay_ms);
whismanoid 10:04022a61b527 4798 }
whismanoid 10:04022a61b527 4799 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 4800 if (cmdLine.parse_int_dec("tx_line_delay_ms", g_auxSerialCom_tx_line_delay_ms))
whismanoid 10:04022a61b527 4801 {
whismanoid 10:04022a61b527 4802 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_line_delay_ms
whismanoid 10:04022a61b527 4803 //~ 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 4804 cmdLine.serial().printf("\r\n tx_line_delay_ms=%dms", g_auxSerialCom_tx_line_delay_ms);
whismanoid 10:04022a61b527 4805 }
whismanoid 10:04022a61b527 4806 #endif
whismanoid 10:04022a61b527 4807 // int g_auxSerialCom_message_ms = 0; //!< capture RX until response timeout?
whismanoid 10:04022a61b527 4808 if (cmdLine.parse_int_dec("message_ms", g_auxSerialCom_message_ms))
whismanoid 10:04022a61b527 4809 {
whismanoid 10:04022a61b527 4810 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 10:04022a61b527 4811 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 4812 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 4813 }
whismanoid 10:04022a61b527 4814 // int g_auxSerialCom_rx_idle_ms = 0; //!< capture RX until idle timeout?
whismanoid 10:04022a61b527 4815 if (cmdLine.parse_int_dec("rx_idle_ms", g_auxSerialCom_rx_idle_ms))
whismanoid 10:04022a61b527 4816 {
whismanoid 10:04022a61b527 4817 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_idle_ms
whismanoid 10:04022a61b527 4818 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_idle_ms was set to %d ***\r\n", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 4819 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 4820 }
whismanoid 10:04022a61b527 4821 // int g_auxSerialCom_rx_max_count = 0; //!< capture RX until max character count?
whismanoid 10:04022a61b527 4822 if (cmdLine.parse_int_dec("rx_max_count", g_auxSerialCom_rx_max_count))
whismanoid 10:04022a61b527 4823 {
whismanoid 10:04022a61b527 4824 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_max_count
whismanoid 10:04022a61b527 4825 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_max_count was set to %d ***\r\n", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 4826 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 4827 }
whismanoid 10:04022a61b527 4828 // int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text char?
whismanoid 10:04022a61b527 4829 if (cmdLine.parse_int_dec("rx_eot", g_auxSerialCom_rx_eot))
whismanoid 10:04022a61b527 4830 {
whismanoid 10:04022a61b527 4831 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_eot
whismanoid 10:04022a61b527 4832 //~ cmdLine_AUXserial.serial().printf("\r\n*** rx_eot was set to %d ***\r\n", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 4833 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 4834 }
whismanoid 10:04022a61b527 4835 }
whismanoid 10:04022a61b527 4836 // Command forwarding to AUX serial TX/RX cmdLine_AuxSerial #257 -- send outgoing_string
whismanoid 10:04022a61b527 4837 char* outgoing_string = (char*)cmdLine.str();
whismanoid 10:04022a61b527 4838 // > use key=value parsing
whismanoid 10:04022a61b527 4839 // >> suppress key=value parsing
whismanoid 10:04022a61b527 4840 if (suppress_parsing) {
whismanoid 10:04022a61b527 4841 cmdLine.serial().printf("\r\n suppress_parsing outgoing_string=\"%s\"", outgoing_string);
whismanoid 10:04022a61b527 4842 outgoing_string++; // skip the first '>'
whismanoid 10:04022a61b527 4843 outgoing_string++; // skip the second '>'
whismanoid 10:04022a61b527 4844 } else {
whismanoid 10:04022a61b527 4845 // TODO: after parsing, key=value pairs should be deleted, but outgoing_string=">xyzzy abc=def"
whismanoid 10:04022a61b527 4846 cmdLine.serial().printf("\r\n after parsing, outgoing_string=\"%s\"", outgoing_string);
whismanoid 10:04022a61b527 4847 outgoing_string++; // skip the first '>'
whismanoid 10:04022a61b527 4848 }
whismanoid 10:04022a61b527 4849 static char rx_string_buf[RX_STRING_BUF_SIZE];
whismanoid 10:04022a61b527 4850 unsigned int rx_string_length = 0;
whismanoid 10:04022a61b527 4851 cmdLine.serial().printf("\r\n >%s\r\n <", outgoing_string);
whismanoid 10:04022a61b527 4852 rx_string_buf[0] = '\0';
whismanoid 10:04022a61b527 4853 rx_string_length = 0;
whismanoid 10:04022a61b527 4854 //
whismanoid 10:04022a61b527 4855 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 4856 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 4857 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 4858 //
whismanoid 10:04022a61b527 4859 // int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 4860 // int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 4861 // int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 4862 // int g_auxSerialCom_rx_idle_ms = 2000; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 4863 // int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 4864 // int g_auxSerialCom_rx_eot = '\r'; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 4865 //~ cmdLine_AuxSerial.serial().printf("\r\n*** TODO forward %s ***\r\n", outgoing_string);
whismanoid 10:04022a61b527 4866 //
whismanoid 10:04022a61b527 4867 // TODO: send whole string or send character-by-character?
whismanoid 10:04022a61b527 4868 cmdLine_AuxSerial.serial().printf("%s", outgoing_string);
whismanoid 10:04022a61b527 4869 cmdLine_AuxSerial.serial().printf("\r\n");
whismanoid 10:04022a61b527 4870 g_auxSerialCom_Timer.start();
whismanoid 10:04022a61b527 4871 g_auxSerialCom_Timer_begin_message_ms = g_auxSerialCom_Timer.read_ms(); // start of message
whismanoid 10:04022a61b527 4872 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 4873 while (rx_string_length < (RX_STRING_BUF_SIZE-1)) {
whismanoid 10:04022a61b527 4874 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_message_ms) > g_auxSerialCom_message_ms) {
whismanoid 10:04022a61b527 4875 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 4876 break;
whismanoid 10:04022a61b527 4877 }
whismanoid 10:04022a61b527 4878 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_rx_idle_ms) > g_auxSerialCom_rx_idle_ms) {
whismanoid 10:04022a61b527 4879 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 4880 break;
whismanoid 10:04022a61b527 4881 }
whismanoid 10:04022a61b527 4882 if (rx_string_length >= g_auxSerialCom_rx_max_count) {
whismanoid 10:04022a61b527 4883 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 4884 break;
whismanoid 10:04022a61b527 4885 }
whismanoid 10:04022a61b527 4886 if (AuxSerial.readable()) {
whismanoid 10:04022a61b527 4887 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 4888 char ch = AuxSerial.getc();
whismanoid 10:04022a61b527 4889 rx_string_buf[rx_string_length++] = ch;
whismanoid 10:04022a61b527 4890 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 10:04022a61b527 4891 cmdLine.serial().printf("%s", &(rx_string_buf[rx_string_length-1]) ); // immediate character echo
whismanoid 10:04022a61b527 4892 if (g_auxSerialCom_rx_eot != aux_serial_cmd_forwarding_rx_eot_not_used) {
whismanoid 10:04022a61b527 4893 if (ch == g_auxSerialCom_rx_eot) {
whismanoid 10:04022a61b527 4894 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 4895 break;
whismanoid 10:04022a61b527 4896 }
whismanoid 10:04022a61b527 4897 }
whismanoid 10:04022a61b527 4898 }
whismanoid 10:04022a61b527 4899 } // end while (rx_string_length < (RX_STRING_BUF_SIZE-1))
whismanoid 10:04022a61b527 4900 #if 1
whismanoid 10:04022a61b527 4901 // print summary. is this needed? we already print aux rx as it is received.
whismanoid 10:04022a61b527 4902 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 10:04022a61b527 4903 cmdLine.serial().printf("\r\n >%s", outgoing_string);
whismanoid 10:04022a61b527 4904 cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 10:04022a61b527 4905 #endif
whismanoid 10:04022a61b527 4906 //
whismanoid 10:04022a61b527 4907 }
whismanoid 10:04022a61b527 4908 break; // case '>'
whismanoid 10:04022a61b527 4909 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 4910 //
whismanoid 4:d9b05924ad4c 4911 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 4912 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 4913 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 4914 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 4915 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible
whismanoid 9:45f98573eb6d 4916 case 'L': case 'l':
whismanoid 4:d9b05924ad4c 4917 {
whismanoid 4:d9b05924ad4c 4918 // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 4919 Datalogger_Trigger = trigger_Halt;
whismanoid 4:d9b05924ad4c 4920 switch (cmdLine[1])
whismanoid 4:d9b05924ad4c 4921 {
whismanoid 17:9397ea3ea7e9 4922 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 4923 case 'T': case 't':
whismanoid 17:9397ea3ea7e9 4924 {
whismanoid 17:9397ea3ea7e9 4925 // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 4926 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 4927 Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 4928 g_timer_interval_counter = 0;
whismanoid 17:9397ea3ea7e9 4929 // TODO: get g_timer_interval_msec from cmdLine
whismanoid 17:9397ea3ea7e9 4930 // g_timer_interval_msec = 500;
whismanoid 17:9397ea3ea7e9 4931 // g_timer_interval_count = 10;
whismanoid 17:9397ea3ea7e9 4932 if (cmdLine.parse_int_dec("count", g_timer_interval_count))
whismanoid 17:9397ea3ea7e9 4933 {
whismanoid 32:80f3e5eb77d4 4934 if (g_timer_interval_count < 1) { g_timer_interval_count = 1; }
whismanoid 17:9397ea3ea7e9 4935 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 4936 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 4937 cmdLine.serial().printf("\r\n g_timer_interval_count=%d", g_timer_interval_count);
whismanoid 17:9397ea3ea7e9 4938 }
whismanoid 17:9397ea3ea7e9 4939 if (cmdLine.parse_int_dec("base", g_timer_interval_msec))
whismanoid 17:9397ea3ea7e9 4940 {
whismanoid 17:9397ea3ea7e9 4941 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 4942 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 4943 cmdLine.serial().printf("\r\n g_timer_interval_msec=%d", g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 4944 }
whismanoid 17:9397ea3ea7e9 4945 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 17:9397ea3ea7e9 4946 }
whismanoid 17:9397ea3ea7e9 4947 break;
whismanoid 17:9397ea3ea7e9 4948 // LIH3 -- Datalog when input high D3
whismanoid 17:9397ea3ea7e9 4949 // LIL6 -- Datalog when input low D6
whismanoid 17:9397ea3ea7e9 4950 case 'I': case 'i':
whismanoid 17:9397ea3ea7e9 4951 {
whismanoid 17:9397ea3ea7e9 4952 // TODO: switch cmdLine[2] configure High or Low, configure input pin
whismanoid 17:9397ea3ea7e9 4953 }
whismanoid 17:9397ea3ea7e9 4954 break;
whismanoid 17:9397ea3ea7e9 4955 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 27:b4ac095b83b3 4956 // L$ count=10 base=500ms addr=xxx data=xxx mask=xxx -- Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 4957 case '$':
whismanoid 17:9397ea3ea7e9 4958 {
whismanoid 17:9397ea3ea7e9 4959 // TODO: scan cmdLine for regAddr, dataMask, testValue
whismanoid 17:9397ea3ea7e9 4960 }
whismanoid 17:9397ea3ea7e9 4961 break;
whismanoid 17:9397ea3ea7e9 4962 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 4963 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 4964 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 4965 case '@':
whismanoid 17:9397ea3ea7e9 4966 {
whismanoid 17:9397ea3ea7e9 4967 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 4968 int editRowIndex = 0;
whismanoid 17:9397ea3ea7e9 4969 int edit_action = (int)action_noop;
whismanoid 17:9397ea3ea7e9 4970 int edit_digitalOutPin = 0;
whismanoid 17:9397ea3ea7e9 4971 int edit_condition = (int)condition_always;
whismanoid 17:9397ea3ea7e9 4972 int edit_condition_channel = 0;
whismanoid 17:9397ea3ea7e9 4973 double edit_condition_threshold = 0;
whismanoid 17:9397ea3ea7e9 4974 //
whismanoid 17:9397ea3ea7e9 4975 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 17:9397ea3ea7e9 4976 {
whismanoid 17:9397ea3ea7e9 4977 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 17:9397ea3ea7e9 4978 }
whismanoid 17:9397ea3ea7e9 4979 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 17:9397ea3ea7e9 4980 {
whismanoid 17:9397ea3ea7e9 4981 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 17:9397ea3ea7e9 4982 }
whismanoid 17:9397ea3ea7e9 4983 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 17:9397ea3ea7e9 4984 {
whismanoid 17:9397ea3ea7e9 4985 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 17:9397ea3ea7e9 4986 }
whismanoid 17:9397ea3ea7e9 4987 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 17:9397ea3ea7e9 4988 {
whismanoid 17:9397ea3ea7e9 4989 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 17:9397ea3ea7e9 4990 }
whismanoid 17:9397ea3ea7e9 4991 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 17:9397ea3ea7e9 4992 {
whismanoid 17:9397ea3ea7e9 4993 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 17:9397ea3ea7e9 4994 }
whismanoid 17:9397ea3ea7e9 4995 //
whismanoid 17:9397ea3ea7e9 4996 // Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 4997 switch (cmdLine[2]) // L@... -- Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 4998 {
whismanoid 17:9397ea3ea7e9 4999 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 5000 case '0': case '1': case '2': case '3': case '4':
whismanoid 17:9397ea3ea7e9 5001 case '5': case '6': case '7': case '8': case '9':
whismanoid 17:9397ea3ea7e9 5002 // edit row data
whismanoid 30:07197a430869 5003 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 5004 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 5005 // get row number to edit from cmdLine[2]
whismanoid 17:9397ea3ea7e9 5006 editRowIndex = atoi(cmdLine.str()+2);
whismanoid 30:07197a430869 5007 if ((editRowIndex >= 0) && (editRowIndex < Datalogger_action_table_row_count)) {
whismanoid 30:07197a430869 5008 // update row
whismanoid 30:07197a430869 5009 cmdLine.serial().printf("\r\n replace row %d", editRowIndex);
whismanoid 30:07197a430869 5010 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 5011 edit_action = Datalogger_action_table[editRowIndex].action;
whismanoid 30:07197a430869 5012 edit_digitalOutPin = Datalogger_action_table[editRowIndex].digitalOutPin;
whismanoid 30:07197a430869 5013 edit_condition = Datalogger_action_table[editRowIndex].condition;
whismanoid 30:07197a430869 5014 edit_condition_channel = Datalogger_action_table[editRowIndex].condition_channel;
whismanoid 30:07197a430869 5015 edit_condition_threshold = Datalogger_action_table[editRowIndex].condition_threshold;
whismanoid 30:07197a430869 5016 // rescan cmdLine[2] for key=value of what fields to change (now that we have got defaults from the existing line
whismanoid 30:07197a430869 5017 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 30:07197a430869 5018 {
whismanoid 30:07197a430869 5019 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 30:07197a430869 5020 }
whismanoid 30:07197a430869 5021 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 30:07197a430869 5022 {
whismanoid 30:07197a430869 5023 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 30:07197a430869 5024 }
whismanoid 30:07197a430869 5025 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 30:07197a430869 5026 {
whismanoid 30:07197a430869 5027 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 30:07197a430869 5028 }
whismanoid 30:07197a430869 5029 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 30:07197a430869 5030 {
whismanoid 30:07197a430869 5031 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 30:07197a430869 5032 }
whismanoid 30:07197a430869 5033 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 30:07197a430869 5034 {
whismanoid 30:07197a430869 5035 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 30:07197a430869 5036 }
whismanoid 30:07197a430869 5037 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 5038 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 5039 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 5040 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 5041 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 5042 }
whismanoid 30:07197a430869 5043 else if ((editRowIndex == Datalogger_action_table_row_count) && (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX)) {
whismanoid 30:07197a430869 5044 // %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 5045 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 5046 cmdLine.serial().printf("\r\n add next row %d", editRowIndex);
whismanoid 30:07197a430869 5047 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 30:07197a430869 5048 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 30:07197a430869 5049 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 30:07197a430869 5050 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 30:07197a430869 5051 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 30:07197a430869 5052 //
whismanoid 17:9397ea3ea7e9 5053 }
whismanoid 17:9397ea3ea7e9 5054 }
whismanoid 17:9397ea3ea7e9 5055 break;
whismanoid 17:9397ea3ea7e9 5056 case '+':
whismanoid 17:9397ea3ea7e9 5057 // add a new row at end of table
whismanoid 17:9397ea3ea7e9 5058 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 5059 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 5060 editRowIndex = Datalogger_action_table_row_count;
whismanoid 17:9397ea3ea7e9 5061 Datalogger_action_table_row_count++;
whismanoid 30:07197a430869 5062 cmdLine.serial().printf("\r\n add new row %d", editRowIndex);
whismanoid 17:9397ea3ea7e9 5063 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 17:9397ea3ea7e9 5064 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 17:9397ea3ea7e9 5065 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 17:9397ea3ea7e9 5066 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 17:9397ea3ea7e9 5067 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 5068 }
whismanoid 17:9397ea3ea7e9 5069 break;
whismanoid 17:9397ea3ea7e9 5070 case '-':
whismanoid 17:9397ea3ea7e9 5071 // delete row from table
whismanoid 17:9397ea3ea7e9 5072 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 5073 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 5074 if ((cmdLine[3] == '~') && (cmdLine[4] == '~') && (cmdLine[5] == '~')) {
whismanoid 17:9397ea3ea7e9 5075 // L@-~~~ -- delete all rows from table
whismanoid 30:07197a430869 5076 cmdLine.serial().printf("\r\n delete all rows");
whismanoid 17:9397ea3ea7e9 5077 Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 5078 break;
whismanoid 17:9397ea3ea7e9 5079 }
whismanoid 30:07197a430869 5080 else {
whismanoid 30:07197a430869 5081 editRowIndex = atoi(cmdLine.str()+3);
whismanoid 30:07197a430869 5082 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 30:07197a430869 5083 // delete row editRowIndex from Datalogger_action_table
whismanoid 30:07197a430869 5084 for (int i = editRowIndex; i < (Datalogger_action_table_row_count-1); i++)
whismanoid 30:07197a430869 5085 {
whismanoid 30:07197a430869 5086 // copy row i+1 into row i
whismanoid 30:07197a430869 5087 Datalogger_action_table[i].action = Datalogger_action_table[i+1].action;
whismanoid 30:07197a430869 5088 Datalogger_action_table[i].digitalOutPin = Datalogger_action_table[i+1].digitalOutPin;
whismanoid 30:07197a430869 5089 Datalogger_action_table[i].condition = Datalogger_action_table[i+1].condition;
whismanoid 30:07197a430869 5090 Datalogger_action_table[i].condition_channel = Datalogger_action_table[i+1].condition_channel;
whismanoid 30:07197a430869 5091 Datalogger_action_table[i].condition_threshold = Datalogger_action_table[i+1].condition_threshold;
whismanoid 30:07197a430869 5092 }
whismanoid 30:07197a430869 5093 Datalogger_action_table_row_count--;
whismanoid 17:9397ea3ea7e9 5094 }
whismanoid 17:9397ea3ea7e9 5095 }
whismanoid 17:9397ea3ea7e9 5096 break;
whismanoid 30:07197a430869 5097 case '.':
whismanoid 30:07197a430869 5098 // L@. pause the entire Log action table
whismanoid 30:07197a430869 5099 cmdLine.serial().printf("\r\n pause the entire Log action table");
whismanoid 17:9397ea3ea7e9 5100 Datalogger_action_table_enabled = false;
whismanoid 17:9397ea3ea7e9 5101 break;
whismanoid 17:9397ea3ea7e9 5102 case '@':
whismanoid 30:07197a430869 5103 // L@@ enable the entire Log action table
whismanoid 30:07197a430869 5104 cmdLine.serial().printf("\r\n enable the entire Log action table");
whismanoid 17:9397ea3ea7e9 5105 Datalogger_action_table_enabled = true;
whismanoid 17:9397ea3ea7e9 5106 break;
whismanoid 17:9397ea3ea7e9 5107 }
whismanoid 17:9397ea3ea7e9 5108 //
whismanoid 17:9397ea3ea7e9 5109 // Print the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5110 if (Datalogger_action_table_enabled) {
whismanoid 30:07197a430869 5111 // cmdLine.serial().printf("Log action table enabled; L@. to pause");
whismanoid 17:9397ea3ea7e9 5112 }
whismanoid 17:9397ea3ea7e9 5113 else {
whismanoid 30:07197a430869 5114 cmdLine.serial().printf("Log action table paused; L@@ to enable");
whismanoid 17:9397ea3ea7e9 5115 }
whismanoid 17:9397ea3ea7e9 5116 //~ cmdLine.serial().printf("\r\n Datalogger_action_table_row_count=%d", Datalogger_action_table_row_count);
whismanoid 17:9397ea3ea7e9 5117 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 5118 {
whismanoid 17:9397ea3ea7e9 5119 cmdLine.serial().printf("\r\n L@%d", i);
whismanoid 17:9397ea3ea7e9 5120 cmdLine.serial().printf(" act=%d", Datalogger_action_table[i].action);
whismanoid 17:9397ea3ea7e9 5121 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5122 {
whismanoid 17:9397ea3ea7e9 5123 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 5124 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 5125 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5126 break;
whismanoid 29:6a9edb6e973b 5127 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 5128 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 5129 break;
whismanoid 17:9397ea3ea7e9 5130 default:
whismanoid 17:9397ea3ea7e9 5131 case action_noop:
whismanoid 17:9397ea3ea7e9 5132 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 5133 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 5134 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 5135 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 5136 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 5137 break;
whismanoid 17:9397ea3ea7e9 5138 }
whismanoid 17:9397ea3ea7e9 5139 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5140 {
whismanoid 17:9397ea3ea7e9 5141 case condition_always:
whismanoid 17:9397ea3ea7e9 5142 break;
whismanoid 17:9397ea3ea7e9 5143 default:
whismanoid 17:9397ea3ea7e9 5144 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 5145 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 5146 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 5147 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 5148 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 5149 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 5150 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 5151 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 5152 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 5153 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 5154 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 5155 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 5156 cmdLine.serial().printf(" if=%d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 5157 cmdLine.serial().printf(" ch=%d", Datalogger_action_table[i].condition_channel);
whismanoid 17:9397ea3ea7e9 5158 cmdLine.serial().printf(" x=%f", Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5159 break;
whismanoid 17:9397ea3ea7e9 5160 }
whismanoid 17:9397ea3ea7e9 5161 cmdLine.serial().printf(" -- ");
whismanoid 17:9397ea3ea7e9 5162 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5163 {
whismanoid 17:9397ea3ea7e9 5164 case action_noop:
whismanoid 17:9397ea3ea7e9 5165 cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 5166 break;
whismanoid 17:9397ea3ea7e9 5167 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 5168 cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 5169 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5170 break;
whismanoid 17:9397ea3ea7e9 5171 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 5172 cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 5173 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5174 break;
whismanoid 29:6a9edb6e973b 5175 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 5176 cmdLine.serial().printf("button");
whismanoid 29:6a9edb6e973b 5177 cmdLine.serial().printf(" %d", Datalogger_action_table[i].digitalOutPin);
whismanoid 29:6a9edb6e973b 5178 break;
whismanoid 17:9397ea3ea7e9 5179 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 5180 cmdLine.serial().printf("trigger_Halt");
whismanoid 17:9397ea3ea7e9 5181 break;
whismanoid 17:9397ea3ea7e9 5182 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 5183 cmdLine.serial().printf("trigger_FreeRun");
whismanoid 17:9397ea3ea7e9 5184 break;
whismanoid 17:9397ea3ea7e9 5185 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 5186 cmdLine.serial().printf("trigger_Timer");
whismanoid 17:9397ea3ea7e9 5187 // print configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 5188 cmdLine.serial().printf("(%d x %dmsec)", g_timer_interval_count, g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 5189 break;
whismanoid 17:9397ea3ea7e9 5190 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 5191 cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 5192 // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 5193 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 5194 break;
whismanoid 17:9397ea3ea7e9 5195 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 5196 cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 5197 // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 5198 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 5199 break;
whismanoid 17:9397ea3ea7e9 5200 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5201 //~ cmdLine.serial().printf(" condition %d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 5202 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5203 {
whismanoid 17:9397ea3ea7e9 5204 case condition_always:
whismanoid 17:9397ea3ea7e9 5205 cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 5206 break;
whismanoid 17:9397ea3ea7e9 5207 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 5208 cmdLine.serial().printf(" if A%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5209 break;
whismanoid 17:9397ea3ea7e9 5210 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 5211 cmdLine.serial().printf(" if A%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5212 break;
whismanoid 17:9397ea3ea7e9 5213 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 5214 cmdLine.serial().printf(" if A%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5215 break;
whismanoid 17:9397ea3ea7e9 5216 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 5217 cmdLine.serial().printf(" if A%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5218 break;
whismanoid 17:9397ea3ea7e9 5219 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 5220 cmdLine.serial().printf(" if A%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5221 break;
whismanoid 17:9397ea3ea7e9 5222 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 5223 cmdLine.serial().printf(" if A%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5224 break;
whismanoid 17:9397ea3ea7e9 5225 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 5226 cmdLine.serial().printf(" if AIN%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5227 break;
whismanoid 17:9397ea3ea7e9 5228 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 5229 cmdLine.serial().printf(" if AIN%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5230 break;
whismanoid 17:9397ea3ea7e9 5231 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 5232 cmdLine.serial().printf(" if AIN%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5233 break;
whismanoid 17:9397ea3ea7e9 5234 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 5235 cmdLine.serial().printf(" if AIN%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5236 break;
whismanoid 17:9397ea3ea7e9 5237 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 5238 cmdLine.serial().printf(" if AIN%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5239 break;
whismanoid 17:9397ea3ea7e9 5240 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 5241 cmdLine.serial().printf(" if AIN%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5242 break;
whismanoid 17:9397ea3ea7e9 5243 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5244 } // for ...Datalogger_action_table_row_count // Print the contents of Datalogger_action_table
whismanoid 30:07197a430869 5245 cmdLine.serial().printf("\r\n\r\nEdit Log action table (used %d/%d, %d free):",
whismanoid 30:07197a430869 5246 Datalogger_action_table_row_count,
whismanoid 30:07197a430869 5247 ACTION_TABLE_ROW_MAX,
whismanoid 30:07197a430869 5248 (ACTION_TABLE_ROW_MAX - Datalogger_action_table_row_count)
whismanoid 30:07197a430869 5249 );
whismanoid 17:9397ea3ea7e9 5250 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 5251 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 5252 cmdLine.serial().printf("\r\n L@+ act=4 if=1 ch=5 x=12345 -- add new entry at end of table");
whismanoid 17:9397ea3ea7e9 5253 }
whismanoid 17:9397ea3ea7e9 5254 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 5255 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 5256 cmdLine.serial().printf("\r\n L@%d act=4 if=1 ch=5 x=12345 -- edit row %d",
whismanoid 17:9397ea3ea7e9 5257 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 5258 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 5259 cmdLine.serial().printf("\r\n L@-%d -- delete row %d",
whismanoid 17:9397ea3ea7e9 5260 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 5261 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 5262 cmdLine.serial().printf("\r\n L@-~~~ -- delete all rows");
whismanoid 30:07197a430869 5263 if (Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@. -- pause entire Log action table");
whismanoid 30:07197a430869 5264 if (!Datalogger_action_table_enabled) cmdLine.serial().printf("\r\n L@@ -- enable Log action table");
whismanoid 17:9397ea3ea7e9 5265 }
whismanoid 17:9397ea3ea7e9 5266 //
whismanoid 17:9397ea3ea7e9 5267 } // case L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 5268 break;
whismanoid 17:9397ea3ea7e9 5269 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 5270 // LR -- Datalog free run as fast as possible
whismanoid 4:d9b05924ad4c 5271 case 'R': case 'r':
whismanoid 4:d9b05924ad4c 5272 // free run as fast as possible
whismanoid 8:dffee7509bfb 5273 Datalogger_Trigger = trigger_FreeRun;
whismanoid 8:dffee7509bfb 5274 Datalogger_Need_PrintHeader = true;
whismanoid 4:d9b05924ad4c 5275 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 9:45f98573eb6d 5276 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 5277 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 5278 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 5279 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 5280 case 'S': case 's':
whismanoid 9:45f98573eb6d 5281 {
whismanoid 9:45f98573eb6d 5282 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 5283 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 5284 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 5285 )
whismanoid 9:45f98573eb6d 5286 {
whismanoid 9:45f98573eb6d 5287 // it's me
whismanoid 9:45f98573eb6d 5288 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 5289 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 5290 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 5291 {
whismanoid 9:45f98573eb6d 5292 case 'D': case 'd':
whismanoid 9:45f98573eb6d 5293 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Disable;
whismanoid 9:45f98573eb6d 5294 break;
whismanoid 9:45f98573eb6d 5295 case 'L': case 'l':
whismanoid 9:45f98573eb6d 5296 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 5297 break;
whismanoid 9:45f98573eb6d 5298 case 'V': case 'v':
whismanoid 9:45f98573eb6d 5299 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 5300 break;
whismanoid 9:45f98573eb6d 5301 //
whismanoid 9:45f98573eb6d 5302 //
whismanoid 9:45f98573eb6d 5303 // TODO: MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 5304 case 'C': case 'c':
whismanoid 9:45f98573eb6d 5305 {
whismanoid 9:45f98573eb6d 5306 uint8_t hexValue = 0;
whismanoid 9:45f98573eb6d 5307 hexValue = hexValueOfChar(cmdLine[5]) * 0x10 + hexValueOfChar(cmdLine[6]);
whismanoid 9:45f98573eb6d 5308 switch (cmdLine[4])
whismanoid 9:45f98573eb6d 5309 {
whismanoid 9:45f98573eb6d 5310 //
whismanoid 9:45f98573eb6d 5311 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 5312 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34"));
whismanoid 9:45f98573eb6d 5313 case 'F': case 'f':
whismanoid 9:45f98573eb6d 5314 SPI_AIN_Cfg_v_filter_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 5315 break;
whismanoid 9:45f98573eb6d 5316 //
whismanoid 9:45f98573eb6d 5317 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 5318 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 5319 case 'C': case 'c':
whismanoid 9:45f98573eb6d 5320 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 5321 break;
whismanoid 9:45f98573eb6d 5322 //
whismanoid 9:45f98573eb6d 5323 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 5324 // cmdLine.serial().print(F("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00"));
whismanoid 9:45f98573eb6d 5325 case 'P': case 'p':
whismanoid 9:45f98573eb6d 5326 SPI_AIN_Cfg_v_pga_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 5327 break;
whismanoid 9:45f98573eb6d 5328 //
whismanoid 9:45f98573eb6d 5329 // cmdLine.serial().print(F("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar"));
whismanoid 9:45f98573eb6d 5330 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 5331 case 'U': case 'u':
whismanoid 9:45f98573eb6d 5332 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] | 0x40;
whismanoid 9:45f98573eb6d 5333 break;
whismanoid 9:45f98573eb6d 5334 //
whismanoid 9:45f98573eb6d 5335 // cmdLine.serial().print(F("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar"));
whismanoid 9:45f98573eb6d 5336 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 5337 case 'B': case 'b':
whismanoid 9:45f98573eb6d 5338 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] &~ 0x40;
whismanoid 9:45f98573eb6d 5339 break;
whismanoid 9:45f98573eb6d 5340 }
whismanoid 9:45f98573eb6d 5341 break;
whismanoid 9:45f98573eb6d 5342 }
whismanoid 9:45f98573eb6d 5343 //
whismanoid 9:45f98573eb6d 5344 //
whismanoid 9:45f98573eb6d 5345 }
whismanoid 9:45f98573eb6d 5346 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 5347 } // end for channel_index
whismanoid 9:45f98573eb6d 5348 Datalogger_PrintHeader();
whismanoid 9:45f98573eb6d 5349 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 5350 }
whismanoid 9:45f98573eb6d 5351 break;
whismanoid 9:45f98573eb6d 5352 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 5353 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 5354 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 5355 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 5356 // verb: D for disable, V for Voltage, L for LSB
whismanoid 8:dffee7509bfb 5357 case 'A': case 'a':
whismanoid 9:45f98573eb6d 5358 {
whismanoid 9:45f98573eb6d 5359 // all-channel: loop through all valid channel_index, test cmdLine[2] 'is it me'?
whismanoid 9:45f98573eb6d 5360 // for channel_index loop through 0..NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 9:45f98573eb6d 5361 // if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 5362 // || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 5363 // ) {
whismanoid 9:45f98573eb6d 5364 // // it's me
whismanoid 9:45f98573eb6d 5365 // // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 5366 // // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 5367 // } end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 5368 // } end for channel_index
whismanoid 9:45f98573eb6d 5369 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 5370 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 5371 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 5372 )
whismanoid 9:45f98573eb6d 5373 {
whismanoid 9:45f98573eb6d 5374 // it's me
whismanoid 9:45f98573eb6d 5375 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 5376 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 5377 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 5378 {
whismanoid 9:45f98573eb6d 5379 case 'D': case 'd':
whismanoid 9:45f98573eb6d 5380 Platform_Enable_ch[channel_index] = Platform_AIN_Disable;
whismanoid 9:45f98573eb6d 5381 break;
whismanoid 9:45f98573eb6d 5382 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 5383 case 'L': case 'l':
whismanoid 9:45f98573eb6d 5384 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 5385 break;
whismanoid 9:45f98573eb6d 5386 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 5387 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 5388 case 'V': case 'v':
whismanoid 9:45f98573eb6d 5389 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 5390 break;
whismanoid 9:45f98573eb6d 5391 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 5392 }
whismanoid 9:45f98573eb6d 5393 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 5394 } // end for channel_index
whismanoid 10:04022a61b527 5395 // Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 5396 if (Datalogger_enable_serial) {
whismanoid 9:45f98573eb6d 5397 Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 5398 }
whismanoid 9:45f98573eb6d 5399 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 5400 if (Datalogger_enable_AUXserial) {
whismanoid 9:45f98573eb6d 5401 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 9:45f98573eb6d 5402 }
whismanoid 9:45f98573eb6d 5403 # endif // HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 5404 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 5405 if (Datalogger_enable_DAPLINKserial) {
whismanoid 9:45f98573eb6d 5406 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 9:45f98573eb6d 5407 }
whismanoid 9:45f98573eb6d 5408 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 5409 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 5410 }
whismanoid 8:dffee7509bfb 5411 break;
whismanoid 9:45f98573eb6d 5412 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 5413 case '>':
whismanoid 9:45f98573eb6d 5414 // L>A -- Datalogger_enable_AUXserial
whismanoid 9:45f98573eb6d 5415 // L>D -- Datalogger_enable_DAPLINKserial
whismanoid 9:45f98573eb6d 5416 // L>S -- Datalogger_enable_serial
whismanoid 9:45f98573eb6d 5417 switch (cmdLine[2])
whismanoid 9:45f98573eb6d 5418 {
whismanoid 9:45f98573eb6d 5419 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 5420 case 'A': case 'a':
whismanoid 9:45f98573eb6d 5421 Datalogger_enable_AUXserial = !Datalogger_enable_AUXserial;
whismanoid 9:45f98573eb6d 5422 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 5423 break;
whismanoid 8:dffee7509bfb 5424 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 5425 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 5426 case 'D': case 'd':
whismanoid 9:45f98573eb6d 5427 Datalogger_enable_DAPLINKserial = !Datalogger_enable_DAPLINKserial;
whismanoid 9:45f98573eb6d 5428 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 5429 break;
whismanoid 8:dffee7509bfb 5430 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 5431 case 'S': case 's':
whismanoid 9:45f98573eb6d 5432 Datalogger_enable_serial = !Datalogger_enable_serial;
whismanoid 9:45f98573eb6d 5433 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 5434 break;
whismanoid 9:45f98573eb6d 5435 }
whismanoid 9:45f98573eb6d 5436 break; // case '>' L>S serial enable toggle
whismanoid 28:a9a3a9db592b 5437 default:
whismanoid 28:a9a3a9db592b 5438 // TODO: L -- detailed help for datalog commands
whismanoid 28:a9a3a9db592b 5439 //
whismanoid 28:a9a3a9db592b 5440 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 28:a9a3a9db592b 5441 #if 1 // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 5442 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 28:a9a3a9db592b 5443 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 28:a9a3a9db592b 5444 //
whismanoid 28:a9a3a9db592b 5445 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 28:a9a3a9db592b 5446 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 28:a9a3a9db592b 5447 cmdLine.serial().printf("\r\n LT count=%d base=%dms -- Datalog timer", g_timer_interval_count, g_timer_interval_msec); // trigger_Timer
whismanoid 28:a9a3a9db592b 5448 //
whismanoid 28:a9a3a9db592b 5449 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 28:a9a3a9db592b 5450 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 5451 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 5452 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 28:a9a3a9db592b 5453 //
whismanoid 28:a9a3a9db592b 5454 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 5455 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 28:a9a3a9db592b 5456 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 5457 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 5458 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 28:a9a3a9db592b 5459 //
whismanoid 28:a9a3a9db592b 5460 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 5461 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table; show more commands");
whismanoid 28:a9a3a9db592b 5462 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 28:a9a3a9db592b 5463 //
whismanoid 28:a9a3a9db592b 5464 //
whismanoid 28:a9a3a9db592b 5465 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 5466 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 28:a9a3a9db592b 5467 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 5468 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 5469 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 28:a9a3a9db592b 5470 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 28:a9a3a9db592b 5471 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 28:a9a3a9db592b 5472 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 28:a9a3a9db592b 5473 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 28:a9a3a9db592b 5474 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 28:a9a3a9db592b 5475 //
whismanoid 28:a9a3a9db592b 5476 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 28:a9a3a9db592b 5477 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 28:a9a3a9db592b 5478 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 28:a9a3a9db592b 5479 //
whismanoid 28:a9a3a9db592b 5480 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 5481 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 28:a9a3a9db592b 5482 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 28:a9a3a9db592b 5483 //
whismanoid 28:a9a3a9db592b 5484 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 5485 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 28:a9a3a9db592b 5486 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 28:a9a3a9db592b 5487 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 28:a9a3a9db592b 5488 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 5489 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 28:a9a3a9db592b 5490 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 28:a9a3a9db592b 5491 //
whismanoid 28:a9a3a9db592b 5492 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 28:a9a3a9db592b 5493 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 28:a9a3a9db592b 5494 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 28:a9a3a9db592b 5495 //
whismanoid 28:a9a3a9db592b 5496 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 28:a9a3a9db592b 5497 //
whismanoid 28:a9a3a9db592b 5498 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 28:a9a3a9db592b 5499 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 28:a9a3a9db592b 5500 // channel ID: 0,1,2,... or - for all channels
whismanoid 28:a9a3a9db592b 5501 // verb: D for disable, V for Voltage, L for LSB
whismanoid 28:a9a3a9db592b 5502 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 28:a9a3a9db592b 5503 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 5504 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 28:a9a3a9db592b 5505 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 5506 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 5507 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 28:a9a3a9db592b 5508 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 5509 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 28:a9a3a9db592b 5510 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 5511 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 28:a9a3a9db592b 5512 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 28:a9a3a9db592b 5513 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 5514 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 28:a9a3a9db592b 5515 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 28:a9a3a9db592b 5516 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 28:a9a3a9db592b 5517 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 28:a9a3a9db592b 5518 # if HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 5519 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 5520 # endif // HAS_AUX_SERIAL
whismanoid 28:a9a3a9db592b 5521 # if HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 5522 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 5523 # endif // HAS_DAPLINK_SERIAL
whismanoid 28:a9a3a9db592b 5524 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 28:a9a3a9db592b 5525 //
whismanoid 28:a9a3a9db592b 5526 #else // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 5527 #endif // USE_DATALOGGER_TRIGGER_HELP_BRIEF
whismanoid 28:a9a3a9db592b 5528 break;
whismanoid 17:9397ea3ea7e9 5529 } // switch (cmdLine[1]) inside case 'L'
whismanoid 4:d9b05924ad4c 5530 }
whismanoid 4:d9b05924ad4c 5531 break; // case 'L'
whismanoid 4:d9b05924ad4c 5532 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 5533 //
whismanoid 4:d9b05924ad4c 5534 // Application-specific commands here
whismanoid 4:d9b05924ad4c 5535 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 5536 //
whismanoid 4:d9b05924ad4c 5537 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 5538 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 5539
whismanoid 4:d9b05924ad4c 5540 //
whismanoid 4:d9b05924ad4c 5541 // TODO1: add new commands here
whismanoid 4:d9b05924ad4c 5542 //
whismanoid 4:d9b05924ad4c 5543 default:
whismanoid 4:d9b05924ad4c 5544 #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 5545 extern bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5715.cpp
whismanoid 4:d9b05924ad4c 5546 if (!MAX5715_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 5547 #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 5548 extern bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11131.cpp
whismanoid 4:d9b05924ad4c 5549 if (!MAX11131_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 5550 #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 5551 extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp
whismanoid 4:d9b05924ad4c 5552 if (!MAX5171_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 5553 #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 5554 extern bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp
whismanoid 4:d9b05924ad4c 5555 if (!MAX11410_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 5556 #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 5557 extern bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX12345.cpp
whismanoid 4:d9b05924ad4c 5558 if (!MAX12345_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 5559 #else
whismanoid 4:d9b05924ad4c 5560 if (0) // not_handled_by_device_submenu
whismanoid 4:d9b05924ad4c 5561 #endif
whismanoid 4:d9b05924ad4c 5562 {
whismanoid 4:d9b05924ad4c 5563 cmdLine.serial().printf("\r\n unknown command ");
whismanoid 4:d9b05924ad4c 5564 //~ cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 5565 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 5566 cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n",
whismanoid 4:d9b05924ad4c 5567 cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 5568 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 5569 }
whismanoid 4:d9b05924ad4c 5570 } // switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 5571 //
whismanoid 31:47eee7e0cc2d 5572 // TODO: avoid excess console noise when a Button event happens during datalogging -- quiet inside Run_command_table()
whismanoid 31:47eee7e0cc2d 5573 if (g_Run_command_table_running == false) {
whismanoid 4:d9b05924ad4c 5574 // print command prompt
whismanoid 8:dffee7509bfb 5575 // print_command_prompt();
whismanoid 8:dffee7509bfb 5576 cmdLine.serial().printf("\r\n> ");
whismanoid 31:47eee7e0cc2d 5577 } // if (g_Run_command_table_running)
whismanoid 4:d9b05924ad4c 5578 }
whismanoid 4:d9b05924ad4c 5579 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 5580
whismanoid 4:d9b05924ad4c 5581 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 5582 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 5583 void Datalogger_PrintHeader(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 5584 {
whismanoid 4:d9b05924ad4c 5585 // column header banner for csv data columns
whismanoid 4:d9b05924ad4c 5586 int field_index = 0;
whismanoid 4:d9b05924ad4c 5587 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 5588 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 5589 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 4:d9b05924ad4c 5590 continue;
whismanoid 4:d9b05924ad4c 5591 }
whismanoid 4:d9b05924ad4c 5592 // comma between fields
whismanoid 4:d9b05924ad4c 5593 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 5594 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 5595 }
whismanoid 10:04022a61b527 5596 field_index++;
whismanoid 4:d9b05924ad4c 5597 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 5598 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 5599 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 4:d9b05924ad4c 5600 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 4:d9b05924ad4c 5601 cmdLine.serial().printf("\"AIN%d-%d_BIP", channel_index, channel_index+1);
whismanoid 4:d9b05924ad4c 5602 }
whismanoid 4:d9b05924ad4c 5603 else {
whismanoid 4:d9b05924ad4c 5604 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 5605 }
whismanoid 4:d9b05924ad4c 5606 #else // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 5607 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 5608 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 5609 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_LSB) {
whismanoid 4:d9b05924ad4c 5610 // _LSB column header suffix
whismanoid 13:184a08909405 5611 cmdLine.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 5612 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5613 cmdLine_DAPLINKserial.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 5614 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 5615 }
whismanoid 10:04022a61b527 5616 else if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_Volt) {
whismanoid 4:d9b05924ad4c 5617 // _V column header suffix
whismanoid 13:184a08909405 5618 cmdLine.serial().printf("_V");
whismanoid 4:d9b05924ad4c 5619 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5620 cmdLine_DAPLINKserial.serial().printf("_V");
whismanoid 4:d9b05924ad4c 5621 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 5622 }
whismanoid 13:184a08909405 5623 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 5624 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 5625 if (SPI_AIN_customChannelHeader_ch[channel_index] && SPI_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 5626 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 5627 cmdLine.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 5628 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5629 cmdLine_DAPLINKserial.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 5630 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5631 } else {
whismanoid 13:184a08909405 5632 // no custom channel name for this channel
whismanoid 13:184a08909405 5633 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 5634 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5635 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 5636 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5637 }
whismanoid 13:184a08909405 5638 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 5639 // close quote
whismanoid 13:184a08909405 5640 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 5641 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5642 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 5643 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 5644 }
whismanoid 4:d9b05924ad4c 5645
whismanoid 4:d9b05924ad4c 5646 #if VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 5647 // PART_ID field: Device ID Validation
whismanoid 4:d9b05924ad4c 5648 cmdLine.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 5649 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 5650 cmdLine_DAPLINKserial.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 5651 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 5652 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 5653 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 5654 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 5655 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 5656 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 5657 continue;
whismanoid 9:45f98573eb6d 5658 }
whismanoid 4:d9b05924ad4c 5659 // comma between fields
whismanoid 4:d9b05924ad4c 5660 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 5661 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 5662 }
whismanoid 9:45f98573eb6d 5663 field_index++;
whismanoid 4:d9b05924ad4c 5664 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 5665 cmdLine.serial().printf("\"A%d", channel_index);
whismanoid 9:45f98573eb6d 5666 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 9:45f98573eb6d 5667 // _LSB column header suffix
whismanoid 13:184a08909405 5668 cmdLine.serial().printf("_LSB");
whismanoid 9:45f98573eb6d 5669 }
whismanoid 9:45f98573eb6d 5670 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 5671 // _V column header suffix
whismanoid 13:184a08909405 5672 cmdLine.serial().printf("_V");
whismanoid 9:45f98573eb6d 5673 }
whismanoid 13:184a08909405 5674 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 5675 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 5676 if (Platform_AIN_customChannelHeader_ch[channel_index] && Platform_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 5677 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 5678 cmdLine.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 5679 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5680 cmdLine_DAPLINKserial.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 5681 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5682 } else {
whismanoid 13:184a08909405 5683 // no custom channel name for this channel
whismanoid 13:184a08909405 5684 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 5685 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5686 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 5687 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5688 }
whismanoid 13:184a08909405 5689 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 5690 // close quote
whismanoid 13:184a08909405 5691 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 5692 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 5693 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 5694 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 5695 }
whismanoid 4:d9b05924ad4c 5696 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 30:07197a430869 5697 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 5698 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in Datalogger_PrintHeader
whismanoid 30:07197a430869 5699 cmdLine.serial().printf(",\"%s\"", gstrRemarkHeader);
whismanoid 30:07197a430869 5700 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 4:d9b05924ad4c 5701 // end of column header line
whismanoid 4:d9b05924ad4c 5702 cmdLine.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 5703 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 5704 cmdLine_DAPLINKserial.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 5705 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 5706 } // void Datalogger_PrintHeader()
whismanoid 4:d9b05924ad4c 5707
whismanoid 5:aaf8b5f5fda1 5708 //--------------------------------------------------
whismanoid 5:aaf8b5f5fda1 5709 void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 5710 {
whismanoid 5:aaf8b5f5fda1 5711 // CODE GENERATOR: example code: has no member function ScanStandardExternalClock
whismanoid 5:aaf8b5f5fda1 5712 // CODE GENERATOR: example code: has no member function ReadAINcode
whismanoid 5:aaf8b5f5fda1 5713 // CODE GENERATOR: example code: member function Read_All_Voltages
whismanoid 5:aaf8b5f5fda1 5714 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 5715 // Measure ADC channels in sequence from AIN0 to channelNumber_0_9.
whismanoid 5:aaf8b5f5fda1 5716 // @param[in] g_MAX11410_device.channelNumber_0_15: AIN Channel Number
whismanoid 5:aaf8b5f5fda1 5717 // @param[in] g_MAX11410_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
whismanoid 5:aaf8b5f5fda1 5718 // @param[in] g_MAX11410_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
whismanoid 10:04022a61b527 5719 //~ int channelId_0_9 = NUM_DUT_ANALOG_IN_CHANNELS-1+1;
whismanoid 5:aaf8b5f5fda1 5720 //g_MAX11410_device.channelNumber_0_15 = channelId_0_9;
whismanoid 5:aaf8b5f5fda1 5721 //g_MAX11410_device.PowerManagement_0_2 = 0;
whismanoid 5:aaf8b5f5fda1 5722 //g_MAX11410_device.chan_id_0_1 = 1;
whismanoid 5:aaf8b5f5fda1 5723 //----------------------------------------
whismanoid 5:aaf8b5f5fda1 5724 // scan AIN0..AIN9
whismanoid 5:aaf8b5f5fda1 5725 //
whismanoid 10:04022a61b527 5726 #if 1
whismanoid 10:04022a61b527 5727 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 5728 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 5729 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 5730 //
whismanoid 10:04022a61b527 5731 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 5732 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc3); // GP1 = 0
whismanoid 10:04022a61b527 5733 //
whismanoid 10:04022a61b527 5734 int field_index = 0;
whismanoid 10:04022a61b527 5735 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 5736 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 10:04022a61b527 5737 continue;
whismanoid 10:04022a61b527 5738 }
whismanoid 10:04022a61b527 5739 field_index++;
whismanoid 10:04022a61b527 5740 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[channel_index];
whismanoid 10:04022a61b527 5741 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[channel_index];
whismanoid 10:04022a61b527 5742 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[channel_index];
whismanoid 10:04022a61b527 5743 //
whismanoid 10:04022a61b527 5744 // WIP SampleRate_of_FILTER_CONV_START() MAX11410EMC-FW slow ODR 10Sps #262
whismanoid 10:04022a61b527 5745 // adjust the MAX11410.loop_limit value if the sample rate is set to a value slower than 20sps
whismanoid 10:04022a61b527 5746 // SampleRate_of_FILTER_CONV_START(uint8_t FILTER_RegValue, uint8_t CONV_START_RegValue)
whismanoid 10:04022a61b527 5747 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 5748 if (SampleRate < 20.0) {
whismanoid 10:04022a61b527 5749 g_MAX11410_device.loop_limit = 32767; // TODO: is this timeout long enough for the slow output data rates?
whismanoid 10:04022a61b527 5750 }
whismanoid 10:04022a61b527 5751 //
whismanoid 10:04022a61b527 5752 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 5753 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc3); // GP0 = 0
whismanoid 10:04022a61b527 5754 //
whismanoid 10:04022a61b527 5755 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 5756 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 10:04022a61b527 5757 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 10:04022a61b527 5758 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 5759 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = (MAX11410::MAX11410_AINN_SEL_enum_t)(channel_index^1);
whismanoid 10:04022a61b527 5760 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 5761 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 5762 }
whismanoid 10:04022a61b527 5763 else {
whismanoid 10:04022a61b527 5764 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 5765 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = MAX11410::AINN_SEL_1010_GND;
whismanoid 10:04022a61b527 5766 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 5767 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 5768 }
whismanoid 10:04022a61b527 5769 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 5770 //
whismanoid 10:04022a61b527 5771 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 5772 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc4); // GP0 = 1
whismanoid 10:04022a61b527 5773 //
whismanoid 10:04022a61b527 5774 }
whismanoid 10:04022a61b527 5775 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 5776 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc4); // GP1 = 1
whismanoid 10:04022a61b527 5777 #else
whismanoid 5:aaf8b5f5fda1 5778 g_MAX11410_device.Read_All_Voltages();
whismanoid 10:04022a61b527 5779 #endif
whismanoid 10:04022a61b527 5780 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 5781 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 5782 // mbed
whismanoid 5:aaf8b5f5fda1 5783 // Platform board uses simple analog inputs
whismanoid 5:aaf8b5f5fda1 5784 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 5:aaf8b5f5fda1 5785 Platform_LSB[0] = analogIn0.read();
whismanoid 5:aaf8b5f5fda1 5786 Platform_LSB[1] = analogIn1.read();
whismanoid 5:aaf8b5f5fda1 5787 Platform_LSB[2] = analogIn2.read();
whismanoid 5:aaf8b5f5fda1 5788 Platform_LSB[3] = analogIn3.read();
whismanoid 5:aaf8b5f5fda1 5789 Platform_LSB[4] = analogIn4.read();
whismanoid 5:aaf8b5f5fda1 5790 Platform_LSB[5] = analogIn5.read();
whismanoid 10:04022a61b527 5791 #endif
whismanoid 10:04022a61b527 5792 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 34:a1993a1ee904 5793 #if HAS_Platform_AIN_Calibration
whismanoid 34:a1993a1ee904 5794 // apply calibration to normValue_0_1 value
whismanoid 34:a1993a1ee904 5795 Platform_Voltage[0] = CalibratedNormValue(0, analogIn0.read()) * adc_full_scale_voltage[0];
whismanoid 34:a1993a1ee904 5796 Platform_Voltage[1] = CalibratedNormValue(1, analogIn1.read()) * adc_full_scale_voltage[1];
whismanoid 34:a1993a1ee904 5797 Platform_Voltage[2] = CalibratedNormValue(2, analogIn2.read()) * adc_full_scale_voltage[2];
whismanoid 34:a1993a1ee904 5798 Platform_Voltage[3] = CalibratedNormValue(3, analogIn3.read()) * adc_full_scale_voltage[3];
whismanoid 34:a1993a1ee904 5799 Platform_Voltage[4] = CalibratedNormValue(4, analogIn4.read()) * adc_full_scale_voltage[4];
whismanoid 34:a1993a1ee904 5800 Platform_Voltage[5] = CalibratedNormValue(5, analogIn5.read()) * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 5801 #else // HAS_Platform_AIN_Calibration
whismanoid 5:aaf8b5f5fda1 5802 Platform_Voltage[0] = analogIn0.read() * adc_full_scale_voltage[0];
whismanoid 5:aaf8b5f5fda1 5803 Platform_Voltage[1] = analogIn1.read() * adc_full_scale_voltage[1];
whismanoid 5:aaf8b5f5fda1 5804 Platform_Voltage[2] = analogIn2.read() * adc_full_scale_voltage[2];
whismanoid 5:aaf8b5f5fda1 5805 Platform_Voltage[3] = analogIn3.read() * adc_full_scale_voltage[3];
whismanoid 5:aaf8b5f5fda1 5806 Platform_Voltage[4] = analogIn4.read() * adc_full_scale_voltage[4];
whismanoid 5:aaf8b5f5fda1 5807 Platform_Voltage[5] = analogIn5.read() * adc_full_scale_voltage[5];
whismanoid 34:a1993a1ee904 5808 #endif // HAS_Platform_AIN_Calibration
whismanoid 5:aaf8b5f5fda1 5809 #endif
whismanoid 5:aaf8b5f5fda1 5810 #endif // defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 5811
whismanoid 5:aaf8b5f5fda1 5812 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 5813 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 5814 const uint32_t part_id_expect = 0x000F02;
whismanoid 5:aaf8b5f5fda1 5815 uint32_t part_id_readback;
whismanoid 5:aaf8b5f5fda1 5816 g_MAX11410_device.RegRead(MAX11410::CMD_r001_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xddd_PART_ID, &part_id_readback);
whismanoid 5:aaf8b5f5fda1 5817 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 5818 } // void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 5819
whismanoid 17:9397ea3ea7e9 5820 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 5821 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 5822 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 5823 void Datalogger_RunActionTable()
whismanoid 17:9397ea3ea7e9 5824 {
whismanoid 17:9397ea3ea7e9 5825 if (Datalogger_action_table_enabled == false) {
whismanoid 17:9397ea3ea7e9 5826 return;
whismanoid 17:9397ea3ea7e9 5827 }
whismanoid 17:9397ea3ea7e9 5828 // TODO: verbose Datalogger_RunActionTable() emit a csv column ,"Action"
whismanoid 17:9397ea3ea7e9 5829 // TODO: assert Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX
whismanoid 17:9397ea3ea7e9 5830 // for Datalogger_action_table[0..Datalogger_action_table_row_count]
whismanoid 17:9397ea3ea7e9 5831 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 5832 {
whismanoid 17:9397ea3ea7e9 5833 // skip if Datalogger_action_table[i].action == action_noop
whismanoid 17:9397ea3ea7e9 5834 if (Datalogger_action_table[i].action == action_noop) {
whismanoid 17:9397ea3ea7e9 5835 continue;
whismanoid 17:9397ea3ea7e9 5836 }
whismanoid 17:9397ea3ea7e9 5837 // TODO: test Datalogger_action_table[i].condition "if="
whismanoid 17:9397ea3ea7e9 5838 // TODO: Could the .condition field also distinguish Platform ADC from SPI ADC?
whismanoid 17:9397ea3ea7e9 5839 // That way we keep both sets of ADC channels in separate lists
whismanoid 17:9397ea3ea7e9 5840 // if=0 -- always
whismanoid 17:9397ea3ea7e9 5841 // if=1,2,3,4,5,6 -- Platform_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 5842 // if=7,8,9,10,11,12 -- SPI_AIN_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 5843 // also, are we comparing code or voltage?
whismanoid 17:9397ea3ea7e9 5844 // TODO: selected Datalogger_action_table[i].condition_channel
whismanoid 17:9397ea3ea7e9 5845 // Datalogger could have both platform ADC and external SPI ADC channels
whismanoid 17:9397ea3ea7e9 5846 // if SPI_ADC_DeviceName
whismanoid 17:9397ea3ea7e9 5847 // NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 5848 // SPI_AIN_Enable_ch[]
whismanoid 17:9397ea3ea7e9 5849 // SPI_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 5850 // SPI_AIN_Voltage[]
whismanoid 17:9397ea3ea7e9 5851 // if LOG_PLATFORM_AIN
whismanoid 17:9397ea3ea7e9 5852 // NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 5853 // analogInPin_fullScaleVoltage[]
whismanoid 17:9397ea3ea7e9 5854 // Platform_Enable_ch[]
whismanoid 17:9397ea3ea7e9 5855 // Platform_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 5856 // Platform_Voltage[]
whismanoid 17:9397ea3ea7e9 5857 // TODO: selected Datalogger_action_table[i].condition_threshold
whismanoid 17:9397ea3ea7e9 5858 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5859 {
whismanoid 17:9397ea3ea7e9 5860 case condition_always:
whismanoid 17:9397ea3ea7e9 5861 //~ cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 5862 break;
whismanoid 17:9397ea3ea7e9 5863 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 5864 //~ cmdLine.serial().printf(" if A%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5865 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 5866 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 5867 continue;
whismanoid 17:9397ea3ea7e9 5868 }
whismanoid 17:9397ea3ea7e9 5869 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 5870 break;
whismanoid 17:9397ea3ea7e9 5871 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 5872 //~ cmdLine.serial().printf(" if A%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5873 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 5874 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 5875 continue;
whismanoid 17:9397ea3ea7e9 5876 }
whismanoid 17:9397ea3ea7e9 5877 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 5878 break;
whismanoid 17:9397ea3ea7e9 5879 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 5880 //~ cmdLine.serial().printf(" if A%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5881 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 5882 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 5883 continue;
whismanoid 17:9397ea3ea7e9 5884 }
whismanoid 17:9397ea3ea7e9 5885 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 5886 break;
whismanoid 17:9397ea3ea7e9 5887 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 5888 //~ cmdLine.serial().printf(" if A%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5889 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 5890 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 5891 continue;
whismanoid 17:9397ea3ea7e9 5892 }
whismanoid 17:9397ea3ea7e9 5893 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 5894 break;
whismanoid 17:9397ea3ea7e9 5895 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 5896 //~ cmdLine.serial().printf(" if A%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5897 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 5898 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 5899 continue;
whismanoid 17:9397ea3ea7e9 5900 }
whismanoid 17:9397ea3ea7e9 5901 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 5902 break;
whismanoid 17:9397ea3ea7e9 5903 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 5904 //~ cmdLine.serial().printf(" if A%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5905 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 5906 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 5907 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 5908 continue;
whismanoid 17:9397ea3ea7e9 5909 }
whismanoid 17:9397ea3ea7e9 5910 break;
whismanoid 17:9397ea3ea7e9 5911 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 5912 //~ cmdLine.serial().printf(" if AIN%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5913 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 5914 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 5915 continue;
whismanoid 17:9397ea3ea7e9 5916 }
whismanoid 17:9397ea3ea7e9 5917 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 5918 break;
whismanoid 17:9397ea3ea7e9 5919 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 5920 //~ cmdLine.serial().printf(" if AIN%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5921 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 5922 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 5923 continue;
whismanoid 17:9397ea3ea7e9 5924 }
whismanoid 17:9397ea3ea7e9 5925 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 5926 break;
whismanoid 17:9397ea3ea7e9 5927 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 5928 //~ cmdLine.serial().printf(" if AIN%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5929 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 5930 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 5931 continue;
whismanoid 17:9397ea3ea7e9 5932 }
whismanoid 17:9397ea3ea7e9 5933 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 5934 break;
whismanoid 17:9397ea3ea7e9 5935 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 5936 //~ cmdLine.serial().printf(" if AIN%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5937 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 5938 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 5939 continue;
whismanoid 17:9397ea3ea7e9 5940 }
whismanoid 17:9397ea3ea7e9 5941 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 5942 break;
whismanoid 17:9397ea3ea7e9 5943 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 5944 //~ cmdLine.serial().printf(" if AIN%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5945 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 5946 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 5947 continue;
whismanoid 17:9397ea3ea7e9 5948 }
whismanoid 17:9397ea3ea7e9 5949 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 5950 break;
whismanoid 17:9397ea3ea7e9 5951 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 5952 //~ cmdLine.serial().printf(" if AIN%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 5953 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 5954 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 5955 continue;
whismanoid 17:9397ea3ea7e9 5956 }
whismanoid 17:9397ea3ea7e9 5957 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 5958 break;
whismanoid 17:9397ea3ea7e9 5959 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 5960 // selected Datalogger_action_table[i].digitalOutPin
whismanoid 17:9397ea3ea7e9 5961 // perform selected Datalogger_action_table[i].action
whismanoid 17:9397ea3ea7e9 5962 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5963 {
whismanoid 17:9397ea3ea7e9 5964 case action_noop:
whismanoid 17:9397ea3ea7e9 5965 //~ cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 5966 break;
whismanoid 17:9397ea3ea7e9 5967 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 5968 {
whismanoid 17:9397ea3ea7e9 5969 //~ cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 5970 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5971 // perform action digitalOutLow
whismanoid 17:9397ea3ea7e9 5972 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 5973 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 5974 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 5975 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 5976 #else
whismanoid 17:9397ea3ea7e9 5977 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 5978 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 5979 digitalInOutPin.write(0);
whismanoid 17:9397ea3ea7e9 5980 #endif
whismanoid 17:9397ea3ea7e9 5981 }
whismanoid 17:9397ea3ea7e9 5982 break;
whismanoid 17:9397ea3ea7e9 5983 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 5984 {
whismanoid 17:9397ea3ea7e9 5985 //~ cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 5986 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5987 // perform action digitalOutHigh
whismanoid 17:9397ea3ea7e9 5988 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 5989 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 5990 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 5991 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 5992 #else
whismanoid 17:9397ea3ea7e9 5993 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 5994 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 5995 digitalInOutPin.write(1);
whismanoid 17:9397ea3ea7e9 5996 #endif
whismanoid 17:9397ea3ea7e9 5997 }
whismanoid 17:9397ea3ea7e9 5998 break;
whismanoid 29:6a9edb6e973b 5999 case action_button: // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6000 {
whismanoid 30:07197a430869 6001 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 6002 Datalogger_Trigger_enum_t saved_Datalogger_Trigger = Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 6003 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6004 switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6005 {
whismanoid 29:6a9edb6e973b 6006 case 1:
whismanoid 29:6a9edb6e973b 6007 onButton1FallingEdge();
whismanoid 29:6a9edb6e973b 6008 break;
whismanoid 29:6a9edb6e973b 6009 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6010 case 2:
whismanoid 29:6a9edb6e973b 6011 onButton2FallingEdge();
whismanoid 29:6a9edb6e973b 6012 break;
whismanoid 29:6a9edb6e973b 6013 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6014 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6015 case 3:
whismanoid 29:6a9edb6e973b 6016 onButton3FallingEdge();
whismanoid 29:6a9edb6e973b 6017 break;
whismanoid 29:6a9edb6e973b 6018 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6019 #if HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6020 case 4:
whismanoid 29:6a9edb6e973b 6021 onButton4FallingEdge();
whismanoid 29:6a9edb6e973b 6022 break;
whismanoid 29:6a9edb6e973b 6023 #endif // HAS_BUTTON4_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6024 #if HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6025 case 5:
whismanoid 29:6a9edb6e973b 6026 onButton5FallingEdge();
whismanoid 29:6a9edb6e973b 6027 break;
whismanoid 29:6a9edb6e973b 6028 #endif // HAS_BUTTON5_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6029 #if HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6030 case 6:
whismanoid 29:6a9edb6e973b 6031 onButton6FallingEdge();
whismanoid 29:6a9edb6e973b 6032 break;
whismanoid 29:6a9edb6e973b 6033 #endif // HAS_BUTTON6_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6034 #if HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6035 case 7:
whismanoid 29:6a9edb6e973b 6036 onButton7FallingEdge();
whismanoid 29:6a9edb6e973b 6037 break;
whismanoid 29:6a9edb6e973b 6038 #endif // HAS_BUTTON7_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6039 #if HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6040 case 8:
whismanoid 29:6a9edb6e973b 6041 onButton8FallingEdge();
whismanoid 29:6a9edb6e973b 6042 break;
whismanoid 29:6a9edb6e973b 6043 #endif // HAS_BUTTON8_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6044 #if HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6045 case 9:
whismanoid 29:6a9edb6e973b 6046 onButton9FallingEdge();
whismanoid 29:6a9edb6e973b 6047 break;
whismanoid 29:6a9edb6e973b 6048 #endif // HAS_BUTTON9_DEMO_INTERRUPT
whismanoid 29:6a9edb6e973b 6049 } // switch (Datalogger_action_table[i].digitalOutPin) // pin = button index 1, 2, 3
whismanoid 29:6a9edb6e973b 6050 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 30:07197a430869 6051 // don't allow onButton1FallingEdge() command processing to halt the datalog
whismanoid 30:07197a430869 6052 Datalogger_Trigger = saved_Datalogger_Trigger;
whismanoid 29:6a9edb6e973b 6053 } // case action_button
whismanoid 29:6a9edb6e973b 6054 break;
whismanoid 17:9397ea3ea7e9 6055 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 6056 //~ cmdLine.serial().printf("trigger_Halt");
whismanoid 17:9397ea3ea7e9 6057 // perform action trigger_Halt
whismanoid 17:9397ea3ea7e9 6058 Datalogger_Trigger = trigger_Halt;
whismanoid 17:9397ea3ea7e9 6059 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6060 break;
whismanoid 17:9397ea3ea7e9 6061 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 6062 //~ cmdLine.serial().printf("trigger_FreeRun");
whismanoid 17:9397ea3ea7e9 6063 // perform action trigger_FreeRun
whismanoid 17:9397ea3ea7e9 6064 Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 6065 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6066 break;
whismanoid 17:9397ea3ea7e9 6067 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 6068 //~ cmdLine.serial().printf("trigger_Timer");
whismanoid 17:9397ea3ea7e9 6069 //~ // print configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 6070 //~ cmdLine.serial().printf("(%d x %dmsec)", g_timer_interval_count, g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 6071 // perform action trigger_Timer
whismanoid 17:9397ea3ea7e9 6072 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 6073 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6074 break;
whismanoid 17:9397ea3ea7e9 6075 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 6076 //~ cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 6077 //~ // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 6078 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 6079 // TODO: perform action action_trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 6080 Datalogger_Trigger = trigger_PlatformDigitalInput;
whismanoid 17:9397ea3ea7e9 6081 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6082 break;
whismanoid 17:9397ea3ea7e9 6083 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 6084 //~ cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 6085 //~ // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6086 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 6087 // TODO: perform action action_trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 6088 Datalogger_Trigger = trigger_SPIDeviceRegRead;
whismanoid 17:9397ea3ea7e9 6089 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 6090 break;
whismanoid 17:9397ea3ea7e9 6091 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 6092 // consider next row of action table
whismanoid 17:9397ea3ea7e9 6093 } // for ...Datalogger_action_table_row_count
whismanoid 17:9397ea3ea7e9 6094 }
whismanoid 17:9397ea3ea7e9 6095 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6096
whismanoid 5:aaf8b5f5fda1 6097 //--------------------------------------------------
whismanoid 8:dffee7509bfb 6098 void Datalogger_PrintRow(CmdLine& cmdLine)
whismanoid 5:aaf8b5f5fda1 6099 {
whismanoid 5:aaf8b5f5fda1 6100 int field_index = 0;
whismanoid 5:aaf8b5f5fda1 6101 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6102 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 6103 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 5:aaf8b5f5fda1 6104 continue;
whismanoid 5:aaf8b5f5fda1 6105 }
whismanoid 5:aaf8b5f5fda1 6106 // comma between fields
whismanoid 5:aaf8b5f5fda1 6107 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 6108 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 6109 }
whismanoid 10:04022a61b527 6110 field_index++;
whismanoid 10:04022a61b527 6111 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 10:04022a61b527 6112 cmdLine.serial().printf("%d", g_MAX11410_device.AINcode[channel_index]);
whismanoid 10:04022a61b527 6113 }
whismanoid 10:04022a61b527 6114 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 10:04022a61b527 6115 // TODO: report Voltage instead of LSB
whismanoid 10:04022a61b527 6116 // Serial.print(SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 6117 static char strOutLineBuffer[16];
whismanoid 10:04022a61b527 6118 cmdLine.serial().printf("%6.6f", SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 6119 }
whismanoid 5:aaf8b5f5fda1 6120 }
whismanoid 5:aaf8b5f5fda1 6121 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6122 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 6123 if (part_id_readback != part_id_expect) {
whismanoid 5:aaf8b5f5fda1 6124 cmdLine.serial().printf(",\"FAIL\"");
whismanoid 9:45f98573eb6d 6125 need_reinit = true;
whismanoid 5:aaf8b5f5fda1 6126 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6127 g_MAX11410_device.Init();
whismanoid 5:aaf8b5f5fda1 6128 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 5:aaf8b5f5fda1 6129 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 5:aaf8b5f5fda1 6130 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 5:aaf8b5f5fda1 6131 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6132 }
whismanoid 5:aaf8b5f5fda1 6133 else {
whismanoid 5:aaf8b5f5fda1 6134 cmdLine.serial().printf(",\"OK\"");
whismanoid 5:aaf8b5f5fda1 6135 }
whismanoid 5:aaf8b5f5fda1 6136 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 6137 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 6138 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 6139 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 6140 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 6141 continue;
whismanoid 9:45f98573eb6d 6142 }
whismanoid 5:aaf8b5f5fda1 6143 // comma between fields
whismanoid 5:aaf8b5f5fda1 6144 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 6145 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 6146 }
whismanoid 9:45f98573eb6d 6147 field_index++;
whismanoid 9:45f98573eb6d 6148 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 5:aaf8b5f5fda1 6149 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 6150 cmdLine.serial().printf("%u", Platform_LSB[channel_index]);
whismanoid 9:45f98573eb6d 6151 #endif
whismanoid 9:45f98573eb6d 6152 }
whismanoid 9:45f98573eb6d 6153 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 6154 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 11:2b8adc78618a 6155 // Datalog Volts omit V suffix from numbers #275
whismanoid 11:2b8adc78618a 6156 // because Excel graphs can't handle numbers that have a suffix.
whismanoid 11:2b8adc78618a 6157 cmdLine.serial().printf("%6.6f", Platform_Voltage[channel_index]);
whismanoid 9:45f98573eb6d 6158 #endif
whismanoid 9:45f98573eb6d 6159 }
whismanoid 5:aaf8b5f5fda1 6160 }
whismanoid 5:aaf8b5f5fda1 6161 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 6162 if (need_reinit) {
whismanoid 9:45f98573eb6d 6163 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6164 if (g_MAX11410_device.Init() == 0) {
whismanoid 9:45f98573eb6d 6165 //~ cmdLine.serial().printf(",\"Init() failed\"");
whismanoid 9:45f98573eb6d 6166 } else {
whismanoid 9:45f98573eb6d 6167 //~ cmdLine.serial().printf(",\"Init() success\"");
whismanoid 9:45f98573eb6d 6168 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 6169 // in Datalogger_PrintRow(), when part_id test fails,
whismanoid 9:45f98573eb6d 6170 // apply list of custom register writes after re-init
whismanoid 9:45f98573eb6d 6171 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 6172 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 9:45f98573eb6d 6173 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 9:45f98573eb6d 6174 uint32_t regData = custom_reg_init_data[index];
whismanoid 9:45f98573eb6d 6175 cmdLine.serial().printf("*%s=0x%06.6x", g_MAX11410_device.RegName(regAddress), regData);
whismanoid 9:45f98573eb6d 6176 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 9:45f98573eb6d 6177 }
whismanoid 9:45f98573eb6d 6178 #endif // USE_CUSTOM_REG_INIT
whismanoid 9:45f98573eb6d 6179 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 9:45f98573eb6d 6180 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 9:45f98573eb6d 6181 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 9:45f98573eb6d 6182 need_reinit = false;
whismanoid 9:45f98573eb6d 6183 }
whismanoid 9:45f98573eb6d 6184 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6185 need_reinit = false;
whismanoid 9:45f98573eb6d 6186 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 6187 }
whismanoid 30:07197a430869 6188 #if USE_DATALOGGER_REMARK_FIELD
whismanoid 30:07197a430869 6189 // Datalogger_PrintRow() print gstrRemarkText field from recent #remark -- in void Datalogger_PrintRow()
whismanoid 30:07197a430869 6190 cmdLine.serial().printf(",\"%s\"", gstrRemarkText);
whismanoid 30:07197a430869 6191 #endif // USE_DATALOGGER_REMARK_FIELD
whismanoid 5:aaf8b5f5fda1 6192 cmdLine.serial().printf("\r\n");
whismanoid 9:45f98573eb6d 6193 if (need_reinit) {
whismanoid 9:45f98573eb6d 6194 //~ delay(500); // platform_delay_ms 500ms timing delay function
whismanoid 9:45f98573eb6d 6195 }
whismanoid 5:aaf8b5f5fda1 6196 } // void Datalogger_PrintRow()
whismanoid 5:aaf8b5f5fda1 6197
whismanoid 0:cb44e2e9ec4c 6198 // example code main function
whismanoid 0:cb44e2e9ec4c 6199 int main()
whismanoid 0:cb44e2e9ec4c 6200 {
whismanoid 0:cb44e2e9ec4c 6201 // setup: put your setup code here, to run once
whismanoid 4:d9b05924ad4c 6202 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 6203 // Configure serial ports
whismanoid 4:d9b05924ad4c 6204 cmdLine.clear();
whismanoid 4:d9b05924ad4c 6205 //~ cmdLine.serial().printf("\r\n cmdLine.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 6206 cmdLine.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 6207 //~ cmdLine.diagnostic_led_EOF = diagnostic_led_EOF;
whismanoid 4:d9b05924ad4c 6208 /// CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21);
whismanoid 4:d9b05924ad4c 6209 //~ cmdLine.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 6210 //~ cmdLine.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 6211 //~ cmdLine.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 6212 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6213 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6214 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 6215 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 6216 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 6217 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 6218 # else
whismanoid 10:04022a61b527 6219 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 6220 DAPLINKserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6221 # endif
whismanoid 10:04022a61b527 6222 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 6223 cmdLine_DAPLINKserial.clear();
whismanoid 4:d9b05924ad4c 6224 //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 6225 cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 6226 //~ cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 6227 //~ cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 6228 //~ cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 6229 # endif
whismanoid 6:f6d16658342b 6230 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6231 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 10:04022a61b527 6232 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6233 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 6234 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 6235 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 6236 AUXserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 6237 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 6:f6d16658342b 6238 cmdLine_AUXserial.clear();
whismanoid 6:f6d16658342b 6239 //~ cmdLine_AUXserial.serial().printf("\r\n cmdLine_AUXserial.serial().printf test\r\n");
whismanoid 6:f6d16658342b 6240 cmdLine_AUXserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 6:f6d16658342b 6241 //~ cmdLine_AUXserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 6:f6d16658342b 6242 //~ cmdLine_AUXserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 6:f6d16658342b 6243 //~ cmdLine_AUXserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 6:f6d16658342b 6244 # endif // HAS_AUX_SERIAL
whismanoid 4:d9b05924ad4c 6245 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 0:cb44e2e9ec4c 6246
whismanoid 0:cb44e2e9ec4c 6247 // example code: serial port banner message
whismanoid 0:cb44e2e9ec4c 6248 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 6249 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6250 cmdLine.serial().printf("\r\nDataLogger_MAX11410\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 6251 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 6252 cmdLine.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 6253 # if HAS_DAPLINK_SERIAL
whismanoid 3:9055e17e181a 6254 cmdLine_DAPLINKserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 6255 # endif // HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 6256 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6257 cmdLine_AUXserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 6:f6d16658342b 6258 # endif // HAS_AUX_SERIAL
whismanoid 3:9055e17e181a 6259 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 6260
whismanoid 1:747f1602abfc 6261 // CODE GENERATOR: get spi properties from device
whismanoid 3:9055e17e181a 6262 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6263 if (g_SPI_SCLK_Hz > g_MAX11410_device.get_spi_frequency())
whismanoid 3:9055e17e181a 6264 { // Device limits SPI SCLK frequency
whismanoid 3:9055e17e181a 6265 g_SPI_SCLK_Hz = g_MAX11410_device.get_spi_frequency();
whismanoid 3:9055e17e181a 6266 cmdLine.serial().printf("\r\nMAX11410 limits SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 6267
whismanoid 3:9055e17e181a 6268 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 6269 }
whismanoid 3:9055e17e181a 6270 if (g_MAX11410_device.get_spi_frequency() > g_SPI_SCLK_Hz)
whismanoid 3:9055e17e181a 6271 { // Platform limits SPI SCLK frequency
whismanoid 3:9055e17e181a 6272 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 6273 cmdLine.serial().printf("\r\nPlatform limits MAX11410 SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 6274
whismanoid 3:9055e17e181a 6275 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 6276 }
whismanoid 0:cb44e2e9ec4c 6277 // g_SPI_dataMode = g_MAX11410_device.get_spi_dataMode();
whismanoid 3:9055e17e181a 6278 while (g_MAX11410_device.Init() == 0)
whismanoid 3:9055e17e181a 6279 {
whismanoid 3:9055e17e181a 6280 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 6281 cmdLine.serial().printf("\r\nMAX11410 Init failed; retry...\r\n");
whismanoid 3:9055e17e181a 6282
whismanoid 3:9055e17e181a 6283 }
whismanoid 0:cb44e2e9ec4c 6284
whismanoid 0:cb44e2e9ec4c 6285 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 3:9055e17e181a 6286 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6287 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 3:9055e17e181a 6288 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 3:9055e17e181a 6289 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 3:9055e17e181a 6290 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 6291 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 3:9055e17e181a 6292 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 6293 // CODE GENERATOR: example code: has no member function REF
whismanoid 0:cb44e2e9ec4c 6294 // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line
whismanoid 0:cb44e2e9ec4c 6295 // CODE GENERATOR: ResolutionBits = 24
whismanoid 0:cb44e2e9ec4c 6296 // CODE GENERATOR: FScode = 0xffffff
whismanoid 0:cb44e2e9ec4c 6297 // CODE GENERATOR: NumChannels = 10
whismanoid 0:cb44e2e9ec4c 6298 // CODE GENERATOR: banner before DataLogHelloCppCodeList while(1)
whismanoid 3:9055e17e181a 6299 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 6300 cmdLine.serial().printf("v_filter = 0x%2.2x\r\n", g_MAX11410_device.v_filter);
whismanoid 0:cb44e2e9ec4c 6301
whismanoid 3:9055e17e181a 6302 cmdLine.serial().printf("v_pga = 0x%2.2x\r\n", g_MAX11410_device.v_pga);
whismanoid 0:cb44e2e9ec4c 6303
whismanoid 3:9055e17e181a 6304 cmdLine.serial().printf("v_ctrl = 0x%2.2x\r\n", g_MAX11410_device.v_ctrl);
whismanoid 3:9055e17e181a 6305
whismanoid 3:9055e17e181a 6306 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 6307
whismanoid 3:9055e17e181a 6308 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 6309 Datalogger_Need_PrintHeader = true;
whismanoid 10:04022a61b527 6310
whismanoid 12:2dfc1f2009e0 6311 #if USE_LEDS
whismanoid 12:2dfc1f2009e0 6312 #if defined(TARGET_MAX32630)
whismanoid 12:2dfc1f2009e0 6313 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 6314 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6315 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 6316 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6317 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 6318 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6319 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 6320 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6321 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 6322 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6323 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 6324 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6325 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 6326 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6327 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 6328 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 19:5ff09c8e9daf 6329 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 12:2dfc1f2009e0 6330 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 6331 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6332 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 6333 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6334 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 6335 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6336 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 6337 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6338 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 6339 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6340 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 6341 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6342 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 6343 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6344 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 6345 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 6346 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 12:2dfc1f2009e0 6347 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 6348 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6349 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6350 led4 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6351 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 6352 //led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 6353 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 6354 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 6355 led1 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6356 //led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 6357 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 6358 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 6359 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6360 //led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 6361 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 6362 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 6363 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 6364 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 6365 //
whismanoid 12:2dfc1f2009e0 6366 #endif // target definition
whismanoid 12:2dfc1f2009e0 6367 #endif
whismanoid 12:2dfc1f2009e0 6368
whismanoid 12:2dfc1f2009e0 6369 if (led1.is_connected()) {
whismanoid 12:2dfc1f2009e0 6370 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 6371 }
whismanoid 12:2dfc1f2009e0 6372 if (led2.is_connected()) {
whismanoid 12:2dfc1f2009e0 6373 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 6374 }
whismanoid 12:2dfc1f2009e0 6375 if (led3.is_connected()) {
whismanoid 12:2dfc1f2009e0 6376 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 6377 }
whismanoid 12:2dfc1f2009e0 6378
whismanoid 4:d9b05924ad4c 6379 while(1) { // this code repeats forever
whismanoid 4:d9b05924ad4c 6380 // this code repeats forever
whismanoid 4:d9b05924ad4c 6381
whismanoid 21:ac062a97a71d 6382 #if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 6383 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 6384 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 6385 # if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 6386 static int button1_value_prev = 1;
whismanoid 21:ac062a97a71d 6387 static int button1_value_now = 1;
whismanoid 21:ac062a97a71d 6388 button1_value_prev = button1_value_now;
whismanoid 21:ac062a97a71d 6389 button1_value_now = button1.read();
whismanoid 21:ac062a97a71d 6390 if ((button1_value_prev - button1_value_now) == 1)
whismanoid 21:ac062a97a71d 6391 {
whismanoid 21:ac062a97a71d 6392 // on button1 falling edge (button1 press)
whismanoid 21:ac062a97a71d 6393 onButton1FallingEdge();
whismanoid 21:ac062a97a71d 6394 }
whismanoid 21:ac062a97a71d 6395 # endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 6396 # if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 6397 static int button2_value_prev = 1;
whismanoid 24:032f3683cb2a 6398 static int button2_value_now = 1;
whismanoid 24:032f3683cb2a 6399 button2_value_prev = button2_value_now;
whismanoid 24:032f3683cb2a 6400 button2_value_now = button2.read();
whismanoid 24:032f3683cb2a 6401 if ((button2_value_prev - button2_value_now) == 1)
whismanoid 24:032f3683cb2a 6402 {
whismanoid 24:032f3683cb2a 6403 // on button2 falling edge (button2 press)
whismanoid 24:032f3683cb2a 6404 onButton2FallingEdge();
whismanoid 24:032f3683cb2a 6405 }
whismanoid 24:032f3683cb2a 6406 # endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 6407 # if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 6408 static int button3_value_prev = 1;
whismanoid 24:032f3683cb2a 6409 static int button3_value_now = 1;
whismanoid 24:032f3683cb2a 6410 button3_value_prev = button3_value_now;
whismanoid 24:032f3683cb2a 6411 button3_value_now = button3.read();
whismanoid 24:032f3683cb2a 6412 if ((button3_value_prev - button3_value_now) == 1)
whismanoid 24:032f3683cb2a 6413 {
whismanoid 24:032f3683cb2a 6414 // on button3 falling edge (button3 press)
whismanoid 26:13cba69d88eb 6415 onButton3FallingEdge();
whismanoid 24:032f3683cb2a 6416 }
whismanoid 24:032f3683cb2a 6417 # endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 6418 #endif // HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 4:d9b05924ad4c 6419 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 6420 // TODO support CmdLine command menus (like on Serial_Tester); help and usual boilerplate
whismanoid 10:04022a61b527 6421 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6422 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 6423 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 6424 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 6425 // Accept commands from Auxiliary serial port
whismanoid 6:f6d16658342b 6426 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6427 if (AUXserial.readable()) {
whismanoid 6:f6d16658342b 6428 cmdLine_AUXserial.append(AUXserial.getc());
whismanoid 6:f6d16658342b 6429 }
whismanoid 6:f6d16658342b 6430 # endif // HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 6431 # if HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 6432 if (DAPLINKserial.readable()) {
whismanoid 6:f6d16658342b 6433 cmdLine_DAPLINKserial.append(DAPLINKserial.getc());
whismanoid 6:f6d16658342b 6434 }
whismanoid 6:f6d16658342b 6435 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 6436 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 6437 if (serial.readable()) {
whismanoid 4:d9b05924ad4c 6438 int c = serial.getc(); // instead of getc() or fgetc()
whismanoid 4:d9b05924ad4c 6439 cmdLine.append(c);
whismanoid 4:d9b05924ad4c 6440 // cmdLine.onEOLcommandParser handler implements menus
whismanoid 4:d9b05924ad4c 6441 } // if (Serial.available())
whismanoid 4:d9b05924ad4c 6442 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 6443
whismanoid 4:d9b05924ad4c 6444 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 32:80f3e5eb77d4 6445 // Datalog trigger
whismanoid 4:d9b05924ad4c 6446 if (Datalogger_Trigger == trigger_Halt) {
whismanoid 4:d9b05924ad4c 6447 // halt the datalogger; continue accepting commands
whismanoid 3:9055e17e181a 6448 continue;
whismanoid 3:9055e17e181a 6449 }
whismanoid 4:d9b05924ad4c 6450 if (Datalogger_Trigger == trigger_FreeRun) {
whismanoid 4:d9b05924ad4c 6451 // free run as fast as possible
whismanoid 3:9055e17e181a 6452 }
whismanoid 4:d9b05924ad4c 6453 if (Datalogger_Trigger == trigger_Timer) {
whismanoid 4:d9b05924ad4c 6454 // timer (configure interval)
whismanoid 32:80f3e5eb77d4 6455 // if Datalogger_Trigger == trigger_Timer sleep(g_timer_interval_msec)
whismanoid 17:9397ea3ea7e9 6456 // sleep(g_timer_interval_msec); // error: too many arguments to function 'void sleep()'
whismanoid 17:9397ea3ea7e9 6457 wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 17:9397ea3ea7e9 6458 if (g_timer_interval_counter > 0) {
whismanoid 17:9397ea3ea7e9 6459 g_timer_interval_counter--;
whismanoid 17:9397ea3ea7e9 6460 continue;
whismanoid 17:9397ea3ea7e9 6461 }
whismanoid 17:9397ea3ea7e9 6462 // if time interval not yet reached, continue (continue accepting commands)
whismanoid 32:80f3e5eb77d4 6463 g_timer_interval_counter = g_timer_interval_count-1;
whismanoid 3:9055e17e181a 6464 }
whismanoid 4:d9b05924ad4c 6465 if (Datalogger_Trigger == trigger_PlatformDigitalInput) {
whismanoid 4:d9b05924ad4c 6466 // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 6467 // TODO: read selected input pin, test value
whismanoid 17:9397ea3ea7e9 6468 // TODO: if no match, continue (continue accepting commands)
whismanoid 3:9055e17e181a 6469 }
whismanoid 4:d9b05924ad4c 6470 if (Datalogger_Trigger == trigger_SPIDeviceRegRead) {
whismanoid 4:d9b05924ad4c 6471 // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 6472 // TODO: SPI transfer regAddr
whismanoid 17:9397ea3ea7e9 6473 // TODO: apply dataMask, compare with testValue
whismanoid 17:9397ea3ea7e9 6474 // TODO: if no match, continue (continue accepting commands)
whismanoid 4:d9b05924ad4c 6475 }
whismanoid 4:d9b05924ad4c 6476 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 0:cb44e2e9ec4c 6477
whismanoid 8:dffee7509bfb 6478 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 6479 if (Datalogger_Need_PrintHeader) {
whismanoid 8:dffee7509bfb 6480 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 6481 Datalogger_PrintHeader(cmdLine);
whismanoid 8:dffee7509bfb 6482 }
whismanoid 8:dffee7509bfb 6483 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6484 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 6485 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 6486 }
whismanoid 8:dffee7509bfb 6487 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6488 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 6489 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 6490 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 6491 }
whismanoid 8:dffee7509bfb 6492 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 6493 Datalogger_Need_PrintHeader = false;
whismanoid 8:dffee7509bfb 6494 }
whismanoid 5:aaf8b5f5fda1 6495 Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 6496 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 6497 // Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 6498 Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 6499 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 0:cb44e2e9ec4c 6500 // wait(3.0);
whismanoid 0:cb44e2e9ec4c 6501 // CODE GENERATOR: print conversion result
whismanoid 0:cb44e2e9ec4c 6502 // Use Arduino Serial Plotter to view output: Tools | Serial Plotter
whismanoid 8:dffee7509bfb 6503 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 6504 Datalogger_PrintRow(cmdLine);
whismanoid 8:dffee7509bfb 6505 }
whismanoid 8:dffee7509bfb 6506 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6507 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 6508 Datalogger_PrintRow(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 6509 }
whismanoid 8:dffee7509bfb 6510 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 6511 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 6512 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 6513 Datalogger_PrintRow(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 6514 }
whismanoid 8:dffee7509bfb 6515 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:cb44e2e9ec4c 6516
whismanoid 0:cb44e2e9ec4c 6517 } // this code repeats forever
whismanoid 0:cb44e2e9ec4c 6518 }
whismanoid 0:cb44e2e9ec4c 6519 //---------- CODE GENERATOR: end DataLogHelloCppCodeList