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:
Tue Apr 27 00:00:38 2021 -0700
Revision:
30:07197a430869
Parent:
29:6a9edb6e973b
Child:
31:47eee7e0cc2d
button1-9, action_button, Datalog comment field from #remarks in button handler

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