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:
Sun Apr 25 02:02:37 2021 -0700
Revision:
25:8a61cb34191d
Parent:
24:032f3683cb2a
Child:
26:13cba69d88eb
MAX40108DEMOP2U9 no HAS_I2C: J91.2=P1_6(button3/'%B3!') J91.3=P1_7(button2/'%B2!')

Who changed what in which revision?

UserRevisionLine numberNew contents of line
whismanoid 0:cb44e2e9ec4c 1 // /*******************************************************************************
whismanoid 0:cb44e2e9ec4c 2 // * Copyright (C) 2020 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 24:032f3683cb2a 590 #else // MAX40108_DEMO
whismanoid 21:ac062a97a71d 591 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 592 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 24:032f3683cb2a 593 #endif // MAX40108_DEMO
whismanoid 21:ac062a97a71d 594 #elif defined(TARGET_MAX32625)
whismanoid 21:ac062a97a71d 595 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 596 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 597 #elif defined(TARGET_MAX32620FTHR)
whismanoid 21:ac062a97a71d 598 #warning "TARGET_MAX32620FTHR not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 599 #define BUTTON1 SW1
whismanoid 21:ac062a97a71d 600 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 601 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 602 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 603 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 21:ac062a97a71d 604 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 605 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 606 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 21:ac062a97a71d 607 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 608 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 21:ac062a97a71d 609 #else
whismanoid 21:ac062a97a71d 610 #warning "target not previously tested; need to define buttons..."
whismanoid 21:ac062a97a71d 611 #endif
whismanoid 21:ac062a97a71d 612 //
whismanoid 21:ac062a97a71d 613 #ifndef HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 614 #define HAS_BUTTON1_DEMO 0
whismanoid 21:ac062a97a71d 615 #endif
whismanoid 21:ac062a97a71d 616 #ifndef HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 617 #define HAS_BUTTON2_DEMO 0
whismanoid 21:ac062a97a71d 618 #endif
whismanoid 24:032f3683cb2a 619 #ifndef HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 620 #define HAS_BUTTON3_DEMO 0
whismanoid 24:032f3683cb2a 621 #endif
whismanoid 21:ac062a97a71d 622 //
whismanoid 21:ac062a97a71d 623 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 624 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 625 #ifndef HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 626 #define HAS_BUTTON1_DEMO_INTERRUPT_POLLING 1
whismanoid 21:ac062a97a71d 627 #endif
whismanoid 21:ac062a97a71d 628 //
whismanoid 21:ac062a97a71d 629 #ifndef HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 630 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 631 #endif
whismanoid 21:ac062a97a71d 632 #ifndef HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 633 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 21:ac062a97a71d 634 #endif
whismanoid 21:ac062a97a71d 635 //
whismanoid 21:ac062a97a71d 636 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 637 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 638 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 639 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 640 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 641 # else
whismanoid 21:ac062a97a71d 642 InterruptIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 643 # endif
whismanoid 21:ac062a97a71d 644 #elif HAS_BUTTON1_DEMO
whismanoid 21:ac062a97a71d 645 DigitalIn button1(BUTTON1);
whismanoid 21:ac062a97a71d 646 #endif
whismanoid 21:ac062a97a71d 647 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 648 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 649 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 650 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 651 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 652 # else
whismanoid 21:ac062a97a71d 653 InterruptIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 654 # endif
whismanoid 21:ac062a97a71d 655 #elif HAS_BUTTON2_DEMO
whismanoid 21:ac062a97a71d 656 DigitalIn button2(BUTTON2);
whismanoid 21:ac062a97a71d 657 #endif
whismanoid 24:032f3683cb2a 658 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 659 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 24:032f3683cb2a 660 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 24:032f3683cb2a 661 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 24:032f3683cb2a 662 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 663 # else
whismanoid 24:032f3683cb2a 664 InterruptIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 665 # endif
whismanoid 24:032f3683cb2a 666 #elif HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 667 DigitalIn button3(BUTTON3);
whismanoid 24:032f3683cb2a 668 #endif
whismanoid 21:ac062a97a71d 669
whismanoid 0:cb44e2e9ec4c 670 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 671 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 672 // Declare the DigitalInOut GPIO pins
whismanoid 0:cb44e2e9ec4c 673 // Optional digitalInOut support. If there is only one it should be digitalInOut1.
whismanoid 0:cb44e2e9ec4c 674 // D) Digital High/Low/Input Pin
whismanoid 0:cb44e2e9ec4c 675 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 676 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 677 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 678 // | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 679 // | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 680 // | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 681 // | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 682 // | [ ] AIN_0 1.2Vfs (bat) SYS [ ] |
whismanoid 0:cb44e2e9ec4c 683 // | [ ] AIN_1 1.2Vfs PWR [ ] |
whismanoid 0:cb44e2e9ec4c 684 // | [ ] AIN_2 1.2Vfs +5V VBUS [ ] |
whismanoid 0:cb44e2e9ec4c 685 // | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9
whismanoid 0:cb44e2e9ec4c 686 // dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8
whismanoid 0:cb44e2e9ec4c 687 // dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7
whismanoid 0:cb44e2e9ec4c 688 // dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6
whismanoid 0:cb44e2e9ec4c 689 // dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5
whismanoid 0:cb44e2e9ec4c 690 // dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4
whismanoid 0:cb44e2e9ec4c 691 // dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3
whismanoid 0:cb44e2e9ec4c 692 // dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2
whismanoid 0:cb44e2e9ec4c 693 // | [ ] GND SDA P3_4 [x] | dig1
whismanoid 0:cb44e2e9ec4c 694 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 695 #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 696 #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 697 #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 698 #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 699 #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 700 #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 701 #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 702 #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 703 #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 704 #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 705 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 706 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 707 #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 708 #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 709 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 710 #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 711 #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 712 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 713 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 714 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 715 #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 716 #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 717 #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 718 #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 719 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 720 #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 721 #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 722 #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 723 #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 724 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 725 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 726 DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 727 #endif
whismanoid 0:cb44e2e9ec4c 728 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 729 DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 730 #endif
whismanoid 0:cb44e2e9ec4c 731 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 732 DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 733 #endif
whismanoid 0:cb44e2e9ec4c 734 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 735 DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 736 #endif
whismanoid 0:cb44e2e9ec4c 737 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 738 DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 739 #endif
whismanoid 0:cb44e2e9ec4c 740 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 741 DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 742 #endif
whismanoid 0:cb44e2e9ec4c 743 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 744 DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 745 #endif
whismanoid 0:cb44e2e9ec4c 746 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 747 DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 748 #endif
whismanoid 0:cb44e2e9ec4c 749 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 750 DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 751 #endif
whismanoid 0:cb44e2e9ec4c 752 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 753 DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 754 #endif
whismanoid 0:cb44e2e9ec4c 755 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 756 DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 757 #endif
whismanoid 0:cb44e2e9ec4c 758 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 759 DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 760 #endif
whismanoid 0:cb44e2e9ec4c 761 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 762 DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 763 #endif
whismanoid 0:cb44e2e9ec4c 764 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 765 DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 766 #endif
whismanoid 0:cb44e2e9ec4c 767 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 768 DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 769 #endif
whismanoid 0:cb44e2e9ec4c 770 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 771 DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 772 #endif
whismanoid 0:cb44e2e9ec4c 773 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 774 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 775 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 776 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 777 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 778 // | |
whismanoid 0:cb44e2e9ec4c 779 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 780 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 781 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 782 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 783 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 784 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 785 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 786 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 787 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 788 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 789 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 790 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 791 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 792 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 793 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 794 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 795 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 796 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 797 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 798 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 799 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 800 // \_______________________/
whismanoid 0:cb44e2e9ec4c 801 //
whismanoid 0:cb44e2e9ec4c 802 #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 803 #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 804 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 805 #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 806 #else
whismanoid 0:cb44e2e9ec4c 807 #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 808 #endif
whismanoid 0:cb44e2e9ec4c 809 #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 810 #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 811 #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 812 #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 813 #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 814 #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 815 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 816 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 817 #else
whismanoid 0:cb44e2e9ec4c 818 #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 819 #endif
whismanoid 0:cb44e2e9ec4c 820 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 821 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 822 #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 823 #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 824 #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 825 #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 826 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 827 #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 828 #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 829 #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 830 #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 831 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 832 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 833 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 834 #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 835 #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 836 #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 837 #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 838 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 839 #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 840 #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 841 #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 842 #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 843 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 844 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 845 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 846 #endif
whismanoid 0:cb44e2e9ec4c 847 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 848 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 849 #endif
whismanoid 0:cb44e2e9ec4c 850 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 851 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 852 #endif
whismanoid 0:cb44e2e9ec4c 853 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 854 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 855 #endif
whismanoid 0:cb44e2e9ec4c 856 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 857 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 858 #endif
whismanoid 0:cb44e2e9ec4c 859 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 860 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 861 #endif
whismanoid 0:cb44e2e9ec4c 862 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 863 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 864 #endif
whismanoid 0:cb44e2e9ec4c 865 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 866 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 867 #endif
whismanoid 0:cb44e2e9ec4c 868 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 869 DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 870 #endif
whismanoid 0:cb44e2e9ec4c 871 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 872 DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 873 #endif
whismanoid 0:cb44e2e9ec4c 874 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 875 DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 876 #endif
whismanoid 0:cb44e2e9ec4c 877 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 878 DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 879 #endif
whismanoid 0:cb44e2e9ec4c 880 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 881 DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 882 #endif
whismanoid 0:cb44e2e9ec4c 883 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 884 DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 885 #endif
whismanoid 0:cb44e2e9ec4c 886 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 887 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 888 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 889 DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 890 #endif
whismanoid 0:cb44e2e9ec4c 891 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 892 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 893 DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 894 #endif
whismanoid 0:cb44e2e9ec4c 895 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 896 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 897 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 898 // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V
whismanoid 0:cb44e2e9ec4c 899 DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 900 #endif
whismanoid 0:cb44e2e9ec4c 901 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 902 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 903 DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 904 #endif
whismanoid 0:cb44e2e9ec4c 905 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 906 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 15:37c83ec50ea0 907 // TARGET=MAX32625PICO ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 15:37c83ec50ea0 908 // +-------------[microUSB]-------------+
whismanoid 15:37c83ec50ea0 909 // | [27]D+ D-[26] |
whismanoid 15:37c83ec50ea0 910 // | |
whismanoid 15:37c83ec50ea0 911 // | [BUTTON P2_7] |
whismanoid 15:37c83ec50ea0 912 // | P2_4 LED_R P2_5 LED_G P2_6 LED_B |
whismanoid 15:37c83ec50ea0 913 // | |
whismanoid 15:37c83ec50ea0 914 // 1V8 | [11] 1.8V MAX32625PICO GND [10] | GND
whismanoid 15:37c83ec50ea0 915 // 3V3 | [12] 3.3V +5V [09] | 5V0
whismanoid 15:37c83ec50ea0 916 // SPI CS D7 | [13] P0_7 CS s-ssel P4_7 [08] | D15
whismanoid 15:37c83ec50ea0 917 // SPI MISO D6 | [14] P0_6 MISO s-miso P4_6 [07] | D14
whismanoid 15:37c83ec50ea0 918 // SPI MOSI D5 | [15] P0_5 MOSI s-mosi P4_5 [06] | D13
whismanoid 15:37c83ec50ea0 919 // SPI SCLK D4 | [16] P0_4 SCLK s-sclk P4_4 [05] | D12
whismanoid 15:37c83ec50ea0 920 // D3 | [17] P0_3 RTS SCL P1_7 [04] | SCL/D17
whismanoid 15:37c83ec50ea0 921 // D2 | [18] P0_2 CTS SDA P1_6 [03] | SDA/D16
whismanoid 15:37c83ec50ea0 922 // TX/D1 | [19] P0_1 TX0 AIN_2 [02] | A2
whismanoid 15:37c83ec50ea0 923 // RX/D0 | [20] P0_0 RX0 AIN_0 [01] | A0/A4
whismanoid 15:37c83ec50ea0 924 // | |
whismanoid 15:37c83ec50ea0 925 // | DAPLINK |
whismanoid 15:37c83ec50ea0 926 // | J3 p3_3 p3_2 p3_0 p3_1 p3_7 |
whismanoid 15:37c83ec50ea0 927 // | DAP [ ] [ ] [RX2][TX2][ ] |
whismanoid 15:37c83ec50ea0 928 // | TOP [ ] [ ] [ ] [ ] [ ] |
whismanoid 15:37c83ec50ea0 929 // | AIN1/A5 gnd gnd nc AIN3 |
whismanoid 15:37c83ec50ea0 930 // | IOH 1-wire |
whismanoid 15:37c83ec50ea0 931 // | |
whismanoid 15:37c83ec50ea0 932 // |NO USE RST P2_0 P2_1 |
whismanoid 15:37c83ec50ea0 933 // |BOTTOM [ ] [ ] [RX1][ ] [TX1] |
whismanoid 15:37c83ec50ea0 934 // | RST SWC GND SWD 1V8 |
whismanoid 15:37c83ec50ea0 935 // |BOTTOM [21] [22] [23] [24] [25] |
whismanoid 15:37c83ec50ea0 936 // +------------------------------------+
whismanoid 15:37c83ec50ea0 937 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 938 // MAX40108 demo p2: D0..D7 = P0_0..P0_7; D8..15 = P4_0..P4_7; D16/D17=I2C
whismanoid 15:37c83ec50ea0 939 #endif
whismanoid 15:37c83ec50ea0 940 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 941 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 942 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 943 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 15:37c83ec50ea0 944 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 945 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 946 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 947 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 948 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 15:37c83ec50ea0 949 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 15:37c83ec50ea0 950 // AIN_10 = x undefined?
whismanoid 15:37c83ec50ea0 951 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 952 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 15:37c83ec50ea0 953 //
whismanoid 15:37c83ec50ea0 954 #if MAX40108_DEMO
whismanoid 15:37c83ec50ea0 955 // avoid resource conflict D0,D1 alternate function as RX/TX
whismanoid 15:37c83ec50ea0 956 #define HAS_digitalInOut0 0
whismanoid 15:37c83ec50ea0 957 #define HAS_digitalInOut1 0
whismanoid 15:37c83ec50ea0 958 #else
whismanoid 15:37c83ec50ea0 959 #define HAS_digitalInOut0 1
whismanoid 19:5ff09c8e9daf 960 #define HAS_digitalInOut1 1
whismanoid 19:5ff09c8e9daf 961 // P0_1 TARGET_MAX32625PICO D1
whismanoid 15:37c83ec50ea0 962 #endif
whismanoid 15:37c83ec50ea0 963 #if APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 964 // avoid resource conflict D2 alternate function as interrupt input
whismanoid 15:37c83ec50ea0 965 #define HAS_digitalInOut2 0
whismanoid 15:37c83ec50ea0 966 #else
whismanoid 15:37c83ec50ea0 967 #define HAS_digitalInOut2 1
whismanoid 15:37c83ec50ea0 968 #endif
whismanoid 15:37c83ec50ea0 969 #define HAS_digitalInOut3 1
whismanoid 15:37c83ec50ea0 970 #define HAS_digitalInOut4 1
whismanoid 15:37c83ec50ea0 971 #define HAS_digitalInOut5 1
whismanoid 15:37c83ec50ea0 972 #define HAS_digitalInOut6 1
whismanoid 15:37c83ec50ea0 973 #define HAS_digitalInOut7 1
whismanoid 15:37c83ec50ea0 974 //
whismanoid 15:37c83ec50ea0 975 #define HAS_digitalInOut8 1
whismanoid 15:37c83ec50ea0 976 #define HAS_digitalInOut9 1
whismanoid 15:37c83ec50ea0 977 #define HAS_digitalInOut10 1
whismanoid 15:37c83ec50ea0 978 #define HAS_digitalInOut11 1
whismanoid 15:37c83ec50ea0 979 #define HAS_digitalInOut12 1
whismanoid 15:37c83ec50ea0 980 #define HAS_digitalInOut13 1
whismanoid 15:37c83ec50ea0 981 #define HAS_digitalInOut14 1
whismanoid 15:37c83ec50ea0 982 #define HAS_digitalInOut15 1
whismanoid 15:37c83ec50ea0 983 #if HAS_I2C
whismanoid 25:8a61cb34191d 984 // MAX40108DEMOP2U9 HAS_I2C: J91.1=1V8 J91.2=P1_6(SDA) J91.3=P1_7(SCL) J91.4=GND
whismanoid 25:8a61cb34191d 985 // MAX40108DEMOP2U9 HAS_I2C: move button2/button3 to inaccessible pins P3_6 and P3_7 if we need J91 for I2C
whismanoid 25:8a61cb34191d 986 // #define BUTTON2 P3_7
whismanoid 25:8a61cb34191d 987 // avoid resource conflict between I2C and DigitalInOut
whismanoid 25:8a61cb34191d 988 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 989 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 990 #else // HAS_I2C
whismanoid 25:8a61cb34191d 991 // MAX40108DEMOP2U9 no HAS_I2C: option using J91 for button2 and button3 instead of I2C
whismanoid 25:8a61cb34191d 992 // 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 993 // MAX40108DEMOP2U9 no HAS_I2C: avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 994 // #define BUTTON2 P1_7
whismanoid 25:8a61cb34191d 995 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 996 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 997 #define HAS_digitalInOut16 0 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 998 #else // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 999 #define HAS_digitalInOut16 1 // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 25:8a61cb34191d 1000 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1001 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1002 // MAX40108DEMOP2U9 avoid conflict between digital pins D16 D17 and button2/button3
whismanoid 25:8a61cb34191d 1003 #define HAS_digitalInOut17 0 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1004 #else // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 25:8a61cb34191d 1005 #define HAS_digitalInOut17 1 // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 25:8a61cb34191d 1006 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 15:37c83ec50ea0 1007 #endif // HAS_I2C
whismanoid 15:37c83ec50ea0 1008 #if HAS_digitalInOut0
whismanoid 25:8a61cb34191d 1009 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D0
whismanoid 15:37c83ec50ea0 1010 #endif
whismanoid 15:37c83ec50ea0 1011 #if HAS_digitalInOut1
whismanoid 25:8a61cb34191d 1012 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D1
whismanoid 15:37c83ec50ea0 1013 #endif
whismanoid 15:37c83ec50ea0 1014 #if HAS_digitalInOut2
whismanoid 25:8a61cb34191d 1015 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D2
whismanoid 15:37c83ec50ea0 1016 #endif
whismanoid 15:37c83ec50ea0 1017 #if HAS_digitalInOut3
whismanoid 25:8a61cb34191d 1018 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D3
whismanoid 15:37c83ec50ea0 1019 #endif
whismanoid 15:37c83ec50ea0 1020 #if HAS_digitalInOut4
whismanoid 25:8a61cb34191d 1021 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D4
whismanoid 15:37c83ec50ea0 1022 #endif
whismanoid 15:37c83ec50ea0 1023 #if HAS_digitalInOut5
whismanoid 25:8a61cb34191d 1024 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D5
whismanoid 15:37c83ec50ea0 1025 #endif
whismanoid 15:37c83ec50ea0 1026 #if HAS_digitalInOut6
whismanoid 25:8a61cb34191d 1027 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D6
whismanoid 15:37c83ec50ea0 1028 #endif
whismanoid 15:37c83ec50ea0 1029 #if HAS_digitalInOut7
whismanoid 25:8a61cb34191d 1030 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D7
whismanoid 15:37c83ec50ea0 1031 #endif
whismanoid 15:37c83ec50ea0 1032 #if HAS_digitalInOut8
whismanoid 25:8a61cb34191d 1033 DigitalInOut digitalInOut8(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX40108DEMOP2U9 D8
whismanoid 15:37c83ec50ea0 1034 #endif
whismanoid 15:37c83ec50ea0 1035 #if HAS_digitalInOut9
whismanoid 25:8a61cb34191d 1036 DigitalInOut digitalInOut9(P4_1, PIN_INPUT, PullUp, 1); // P4_1 TARGET_MAX40108DEMOP2U9 D9
whismanoid 15:37c83ec50ea0 1037 #endif
whismanoid 15:37c83ec50ea0 1038 #if HAS_digitalInOut10
whismanoid 25:8a61cb34191d 1039 DigitalInOut digitalInOut10(P4_2, PIN_INPUT, PullUp, 1); // P4_2 TARGET_MAX40108DEMOP2U9 D10
whismanoid 15:37c83ec50ea0 1040 #endif
whismanoid 15:37c83ec50ea0 1041 #if HAS_digitalInOut11
whismanoid 25:8a61cb34191d 1042 DigitalInOut digitalInOut11(P4_3, PIN_INPUT, PullUp, 1); // P4_3 TARGET_MAX40108DEMOP2U9 D11
whismanoid 15:37c83ec50ea0 1043 #endif
whismanoid 15:37c83ec50ea0 1044 #if HAS_digitalInOut12
whismanoid 25:8a61cb34191d 1045 DigitalInOut digitalInOut12(P4_4, PIN_INPUT, PullUp, 1); // P4_4 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D12
whismanoid 15:37c83ec50ea0 1046 #endif
whismanoid 15:37c83ec50ea0 1047 #if HAS_digitalInOut13
whismanoid 25:8a61cb34191d 1048 DigitalInOut digitalInOut13(P4_5, PIN_INPUT, PullUp, 1); // P4_5 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D13
whismanoid 15:37c83ec50ea0 1049 #endif
whismanoid 15:37c83ec50ea0 1050 #if HAS_digitalInOut14
whismanoid 25:8a61cb34191d 1051 DigitalInOut digitalInOut14(P4_6, PIN_INPUT, PullUp, 1); // P4_6 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D14
whismanoid 15:37c83ec50ea0 1052 #endif
whismanoid 15:37c83ec50ea0 1053 #if HAS_digitalInOut15
whismanoid 25:8a61cb34191d 1054 DigitalInOut digitalInOut15(P4_7, PIN_INPUT, PullUp, 1); // P4_7 TARGET_MAX32625PICO TARGET_MAX40108DEMOP2U9 D15
whismanoid 15:37c83ec50ea0 1055 #endif
whismanoid 15:37c83ec50ea0 1056 #if HAS_digitalInOut16
whismanoid 15:37c83ec50ea0 1057 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 15:37c83ec50ea0 1058 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 25:8a61cb34191d 1059 DigitalInOut digitalInOut16(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX40108DEMOP2U9 J91.2=P1_6(button3/'%B3!'/SDA)
whismanoid 15:37c83ec50ea0 1060 #endif
whismanoid 15:37c83ec50ea0 1061 #if HAS_digitalInOut17
whismanoid 15:37c83ec50ea0 1062 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 25:8a61cb34191d 1063 DigitalInOut digitalInOut17(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX40108DEMOP2U9 J91.3=P1_7(button2/'%B2!'/SCL)
whismanoid 15:37c83ec50ea0 1064 #endif
whismanoid 15:37c83ec50ea0 1065 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1066 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1067 #define HAS_digitalInOut0 0
whismanoid 0:cb44e2e9ec4c 1068 #define HAS_digitalInOut1 0
whismanoid 0:cb44e2e9ec4c 1069 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1070 // D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 1071 #define HAS_digitalInOut2 0
whismanoid 0:cb44e2e9ec4c 1072 #else
whismanoid 0:cb44e2e9ec4c 1073 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1074 #endif
whismanoid 0:cb44e2e9ec4c 1075 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1076 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1077 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1078 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1079 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1080 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1081 // D8 -- MAX5715 CLRb DigitalOut
whismanoid 0:cb44e2e9ec4c 1082 #define HAS_digitalInOut8 0
whismanoid 0:cb44e2e9ec4c 1083 #else
whismanoid 0:cb44e2e9ec4c 1084 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1085 #endif
whismanoid 0:cb44e2e9ec4c 1086 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 1087 // D9 -- MAX5715 LDACb DigitalOut
whismanoid 0:cb44e2e9ec4c 1088 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1089 #elif APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 1090 // D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 1091 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 1092 #else
whismanoid 0:cb44e2e9ec4c 1093 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1094 #endif
whismanoid 0:cb44e2e9ec4c 1095 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 1096 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1097 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1098 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1099 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1100 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1101 #define HAS_digitalInOut10 0
whismanoid 0:cb44e2e9ec4c 1102 #define HAS_digitalInOut11 0
whismanoid 0:cb44e2e9ec4c 1103 #define HAS_digitalInOut12 0
whismanoid 0:cb44e2e9ec4c 1104 #define HAS_digitalInOut13 0
whismanoid 0:cb44e2e9ec4c 1105 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1106 #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1107 #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1108 #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1109 #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1110 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 1111 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 1112 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1113 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1114 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1115 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1116 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1117 #define HAS_digitalInOut14 0
whismanoid 0:cb44e2e9ec4c 1118 #define HAS_digitalInOut15 0
whismanoid 0:cb44e2e9ec4c 1119 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1120 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1121 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1122 #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1123 #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1124 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 1125 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 1126 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 1127 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1128 DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1129 #endif
whismanoid 0:cb44e2e9ec4c 1130 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1131 DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1132 #endif
whismanoid 0:cb44e2e9ec4c 1133 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1134 DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1135 #endif
whismanoid 0:cb44e2e9ec4c 1136 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1137 DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1138 #endif
whismanoid 0:cb44e2e9ec4c 1139 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1140 DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1141 #endif
whismanoid 0:cb44e2e9ec4c 1142 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1143 DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1144 #endif
whismanoid 0:cb44e2e9ec4c 1145 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1146 DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1147 #endif
whismanoid 0:cb44e2e9ec4c 1148 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1149 DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1150 #endif
whismanoid 0:cb44e2e9ec4c 1151 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1152 DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1153 #endif
whismanoid 0:cb44e2e9ec4c 1154 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1155 DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1156 #endif
whismanoid 0:cb44e2e9ec4c 1157 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1158 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 1159 DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1160 #endif
whismanoid 0:cb44e2e9ec4c 1161 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1162 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 1163 DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1164 #endif
whismanoid 0:cb44e2e9ec4c 1165 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1166 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 1167 DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1168 #endif
whismanoid 0:cb44e2e9ec4c 1169 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1170 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 1171 DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1172 #endif
whismanoid 0:cb44e2e9ec4c 1173 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1174 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1175 DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1176 #endif
whismanoid 0:cb44e2e9ec4c 1177 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1178 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 1179 DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1180 #endif
whismanoid 0:cb44e2e9ec4c 1181 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1182 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1183 DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1184 #endif
whismanoid 0:cb44e2e9ec4c 1185 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1186 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 1187 DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1188 #endif
whismanoid 0:cb44e2e9ec4c 1189 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1190 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1191 #define HAS_digitalInOut0 1
whismanoid 0:cb44e2e9ec4c 1192 #define HAS_digitalInOut1 1
whismanoid 0:cb44e2e9ec4c 1193 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 1194 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 1195 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 1196 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 1197 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 1198 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 1199 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 1200 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 1201 // #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 1202 // #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 1203 // #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 1204 // #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 1205 // #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 1206 // #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 1207 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1208 DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3
whismanoid 0:cb44e2e9ec4c 1209 #endif
whismanoid 0:cb44e2e9ec4c 1210 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1211 DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2
whismanoid 0:cb44e2e9ec4c 1212 #endif
whismanoid 0:cb44e2e9ec4c 1213 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1214 DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1
whismanoid 0:cb44e2e9ec4c 1215 #endif
whismanoid 0:cb44e2e9ec4c 1216 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1217 DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0
whismanoid 0:cb44e2e9ec4c 1218 #endif
whismanoid 0:cb44e2e9ec4c 1219 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1220 DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1
whismanoid 0:cb44e2e9ec4c 1221 #endif
whismanoid 0:cb44e2e9ec4c 1222 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1223 DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1
whismanoid 0:cb44e2e9ec4c 1224 #endif
whismanoid 0:cb44e2e9ec4c 1225 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1226 DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1
whismanoid 0:cb44e2e9ec4c 1227 #endif
whismanoid 0:cb44e2e9ec4c 1228 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1229 DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO
whismanoid 0:cb44e2e9ec4c 1230 #endif
whismanoid 0:cb44e2e9ec4c 1231 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1232 DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK
whismanoid 0:cb44e2e9ec4c 1233 #endif
whismanoid 0:cb44e2e9ec4c 1234 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1235 DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL
whismanoid 0:cb44e2e9ec4c 1236 #endif
whismanoid 0:cb44e2e9ec4c 1237 //
whismanoid 0:cb44e2e9ec4c 1238 // these pins support analog input analogIn0 .. analogIn5
whismanoid 0:cb44e2e9ec4c 1239 //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1240 //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1241 //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1242 //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1243 //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1244 //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1245 //
whismanoid 0:cb44e2e9ec4c 1246 // these pins support PWM pwmDriver1 .. pwmDriver6
whismanoid 0:cb44e2e9ec4c 1247 //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0
whismanoid 0:cb44e2e9ec4c 1248 //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1
whismanoid 0:cb44e2e9ec4c 1249 //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2
whismanoid 0:cb44e2e9ec4c 1250 //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3
whismanoid 0:cb44e2e9ec4c 1251 //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1
whismanoid 0:cb44e2e9ec4c 1252 //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK
whismanoid 0:cb44e2e9ec4c 1253 //
whismanoid 0:cb44e2e9ec4c 1254 // these could be additional digitalInOut pins
whismanoid 0:cb44e2e9ec4c 1255 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1256 DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1
whismanoid 0:cb44e2e9ec4c 1257 #endif
whismanoid 0:cb44e2e9ec4c 1258 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1259 DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0
whismanoid 0:cb44e2e9ec4c 1260 #endif
whismanoid 0:cb44e2e9ec4c 1261 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1262 DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1
whismanoid 0:cb44e2e9ec4c 1263 #endif
whismanoid 0:cb44e2e9ec4c 1264 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1265 DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0
whismanoid 0:cb44e2e9ec4c 1266 #endif
whismanoid 0:cb44e2e9ec4c 1267 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1268 DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1269 #endif
whismanoid 0:cb44e2e9ec4c 1270 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1271 DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 1272 #endif
whismanoid 0:cb44e2e9ec4c 1273 #else
whismanoid 0:cb44e2e9ec4c 1274 // unknown target
whismanoid 0:cb44e2e9ec4c 1275 #endif
whismanoid 0:cb44e2e9ec4c 1276 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1277 #if HAS_digitalInOut0 || HAS_digitalInOut1 \
whismanoid 0:cb44e2e9ec4c 1278 || HAS_digitalInOut2 || HAS_digitalInOut3 \
whismanoid 0:cb44e2e9ec4c 1279 || HAS_digitalInOut4 || HAS_digitalInOut5 \
whismanoid 0:cb44e2e9ec4c 1280 || HAS_digitalInOut6 || HAS_digitalInOut7 \
whismanoid 0:cb44e2e9ec4c 1281 || HAS_digitalInOut8 || HAS_digitalInOut9 \
whismanoid 0:cb44e2e9ec4c 1282 || HAS_digitalInOut10 || HAS_digitalInOut11 \
whismanoid 0:cb44e2e9ec4c 1283 || HAS_digitalInOut12 || HAS_digitalInOut13 \
whismanoid 0:cb44e2e9ec4c 1284 || HAS_digitalInOut14 || HAS_digitalInOut15 \
whismanoid 0:cb44e2e9ec4c 1285 || HAS_digitalInOut16 || HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1286 #define HAS_digitalInOuts 1
whismanoid 0:cb44e2e9ec4c 1287 #else
whismanoid 0:cb44e2e9ec4c 1288 #warning "Note: There are no digitalInOut resources defined"
whismanoid 0:cb44e2e9ec4c 1289 #endif
whismanoid 0:cb44e2e9ec4c 1290
whismanoid 0:cb44e2e9ec4c 1291 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 1292 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1293 // Declare the AnalogIn driver
whismanoid 0:cb44e2e9ec4c 1294 // Optional analogIn support. If there is only one it should be analogIn1.
whismanoid 0:cb44e2e9ec4c 1295 // A) analog input
whismanoid 0:cb44e2e9ec4c 1296 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1297 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1298 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1299 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1300 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1301 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1302 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1303 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1304 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1305 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1306 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1307 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1308 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1309 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1310 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1311 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1312 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1313 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1314 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1315 #endif
whismanoid 0:cb44e2e9ec4c 1316 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1317 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1318 #endif
whismanoid 0:cb44e2e9ec4c 1319 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1320 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1321 #endif
whismanoid 0:cb44e2e9ec4c 1322 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1323 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1324 #endif
whismanoid 0:cb44e2e9ec4c 1325 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1326 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1327 #endif
whismanoid 0:cb44e2e9ec4c 1328 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1329 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1330 #endif
whismanoid 0:cb44e2e9ec4c 1331 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1332 AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1333 #endif
whismanoid 0:cb44e2e9ec4c 1334 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1335 AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1336 #endif
whismanoid 0:cb44e2e9ec4c 1337 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1338 AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1339 #endif
whismanoid 0:cb44e2e9ec4c 1340 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1341 AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1342 #endif
whismanoid 0:cb44e2e9ec4c 1343 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1344 AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1345 #endif
whismanoid 0:cb44e2e9ec4c 1346 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1347 AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1348 #endif
whismanoid 0:cb44e2e9ec4c 1349 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1350 AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1351 #endif
whismanoid 0:cb44e2e9ec4c 1352 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1353 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1354 #endif
whismanoid 0:cb44e2e9ec4c 1355 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1356 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1357 #endif
whismanoid 0:cb44e2e9ec4c 1358 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1359 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1360 #endif
whismanoid 0:cb44e2e9ec4c 1361 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1362 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 1363 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1364 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1365 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1366 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1367 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1368 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1369 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1370 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1371 #endif
whismanoid 0:cb44e2e9ec4c 1372 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1373 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1374 #endif
whismanoid 0:cb44e2e9ec4c 1375 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1376 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1377 #endif
whismanoid 0:cb44e2e9ec4c 1378 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1379 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1380 #endif
whismanoid 0:cb44e2e9ec4c 1381 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1382 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1383 #endif
whismanoid 0:cb44e2e9ec4c 1384 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1385 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1386 #endif
whismanoid 0:cb44e2e9ec4c 1387 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1388 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 1389 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1390 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1391 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1392 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1393 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1394 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1395 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1396 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1397 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1398 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1399 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1400 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1401 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1402 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1403 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1404 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1405 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1406 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1407 AnalogIn analogIn0(AIN_0); // TARGET_MAX32620FTHR J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1408 #endif
whismanoid 0:cb44e2e9ec4c 1409 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1410 AnalogIn analogIn1(AIN_1); // TARGET_MAX32620FTHR J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1411 #endif
whismanoid 0:cb44e2e9ec4c 1412 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1413 AnalogIn analogIn2(AIN_2); // TARGET_MAX32620FTHR J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1414 #endif
whismanoid 0:cb44e2e9ec4c 1415 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1416 AnalogIn analogIn3(AIN_3); // TARGET_MAX32620FTHR J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1417 #endif
whismanoid 0:cb44e2e9ec4c 1418 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1419 AnalogIn analogIn4(AIN_4); // TARGET_MAX32620FTHR J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1420 #endif
whismanoid 0:cb44e2e9ec4c 1421 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1422 AnalogIn analogIn5(AIN_5); // TARGET_MAX32620FTHR J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1423 #endif
whismanoid 0:cb44e2e9ec4c 1424 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1425 AnalogIn analogIn6(AIN_6); // TARGET_MAX32620FTHR AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1426 #endif
whismanoid 0:cb44e2e9ec4c 1427 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1428 AnalogIn analogIn7(AIN_7); // TARGET_MAX32620FTHR AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1429 #endif
whismanoid 0:cb44e2e9ec4c 1430 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1431 AnalogIn analogIn8(AIN_8); // TARGET_MAX32620FTHR AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1432 #endif
whismanoid 0:cb44e2e9ec4c 1433 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1434 AnalogIn analogIn9(AIN_9); // TARGET_MAX32620FTHR AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1435 #endif
whismanoid 0:cb44e2e9ec4c 1436 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1437 AnalogIn analogIn10(____); // TARGET_MAX32620FTHR AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1438 #endif
whismanoid 0:cb44e2e9ec4c 1439 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1440 AnalogIn analogIn11(____); // TARGET_MAX32620FTHR AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1441 #endif
whismanoid 0:cb44e2e9ec4c 1442 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1443 AnalogIn analogIn12(____); // TARGET_MAX32620FTHR AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1444 #endif
whismanoid 0:cb44e2e9ec4c 1445 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1446 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1447 #endif
whismanoid 0:cb44e2e9ec4c 1448 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1449 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1450 #endif
whismanoid 0:cb44e2e9ec4c 1451 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1452 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1453 #endif
whismanoid 0:cb44e2e9ec4c 1454 //--------------------------------------------------
whismanoid 19:5ff09c8e9daf 1455 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 1456 #warning "TARGET_MAX32625PICO not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1457 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1458 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1459 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1460 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1461 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1462 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1463 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1464 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1465 #endif
whismanoid 0:cb44e2e9ec4c 1466 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1467 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1468 #endif
whismanoid 0:cb44e2e9ec4c 1469 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1470 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1471 #endif
whismanoid 0:cb44e2e9ec4c 1472 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1473 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1474 #endif
whismanoid 0:cb44e2e9ec4c 1475 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1476 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1477 #endif
whismanoid 0:cb44e2e9ec4c 1478 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1479 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1480 #endif
whismanoid 0:cb44e2e9ec4c 1481 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1482 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 1483 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1484 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1485 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1486 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1487 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1488 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1489 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1490 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1491 #endif
whismanoid 0:cb44e2e9ec4c 1492 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1493 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1494 #endif
whismanoid 0:cb44e2e9ec4c 1495 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1496 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1497 #endif
whismanoid 0:cb44e2e9ec4c 1498 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1499 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1500 #endif
whismanoid 0:cb44e2e9ec4c 1501 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1502 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1503 #endif
whismanoid 0:cb44e2e9ec4c 1504 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1505 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1506 #endif
whismanoid 0:cb44e2e9ec4c 1507 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1508 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 1509 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1510 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1511 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1512 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1513 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1514 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1515 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1516 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1517 #endif
whismanoid 0:cb44e2e9ec4c 1518 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1519 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1520 #endif
whismanoid 0:cb44e2e9ec4c 1521 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1522 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1523 #endif
whismanoid 0:cb44e2e9ec4c 1524 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1525 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1526 #endif
whismanoid 0:cb44e2e9ec4c 1527 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1528 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1529 #endif
whismanoid 0:cb44e2e9ec4c 1530 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1531 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1532 #endif
whismanoid 0:cb44e2e9ec4c 1533 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1534 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1535 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1536 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1537 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1538 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1539 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1540 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1541 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1542 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1543 #endif
whismanoid 0:cb44e2e9ec4c 1544 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1545 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1546 #endif
whismanoid 0:cb44e2e9ec4c 1547 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1548 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1549 #endif
whismanoid 0:cb44e2e9ec4c 1550 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1551 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1552 #endif
whismanoid 0:cb44e2e9ec4c 1553 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1554 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1555 #endif
whismanoid 0:cb44e2e9ec4c 1556 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1557 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1558 #endif
whismanoid 0:cb44e2e9ec4c 1559 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1560 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 1561 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1562 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1563 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1564 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1565 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1566 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1567 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1568 // #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1569 // #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1570 // #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1571 // #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1572 // #define HAS_analogIn10 1
whismanoid 0:cb44e2e9ec4c 1573 // #define HAS_analogIn11 1
whismanoid 0:cb44e2e9ec4c 1574 // #define HAS_analogIn12 1
whismanoid 0:cb44e2e9ec4c 1575 // #define HAS_analogIn13 1
whismanoid 0:cb44e2e9ec4c 1576 // #define HAS_analogIn14 1
whismanoid 0:cb44e2e9ec4c 1577 // #define HAS_analogIn15 1
whismanoid 0:cb44e2e9ec4c 1578 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1579 AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1580 #endif
whismanoid 0:cb44e2e9ec4c 1581 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1582 AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1583 #endif
whismanoid 0:cb44e2e9ec4c 1584 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1585 AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1586 #endif
whismanoid 0:cb44e2e9ec4c 1587 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1588 AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1589 #endif
whismanoid 0:cb44e2e9ec4c 1590 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1591 AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1592 #endif
whismanoid 0:cb44e2e9ec4c 1593 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1594 AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1595 #endif
whismanoid 0:cb44e2e9ec4c 1596 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1597 AnalogIn analogIn6(____);
whismanoid 0:cb44e2e9ec4c 1598 #endif
whismanoid 0:cb44e2e9ec4c 1599 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1600 AnalogIn analogIn7(____);
whismanoid 0:cb44e2e9ec4c 1601 #endif
whismanoid 0:cb44e2e9ec4c 1602 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1603 AnalogIn analogIn8(____);
whismanoid 0:cb44e2e9ec4c 1604 #endif
whismanoid 0:cb44e2e9ec4c 1605 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1606 AnalogIn analogIn9(____);
whismanoid 0:cb44e2e9ec4c 1607 #endif
whismanoid 0:cb44e2e9ec4c 1608 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1609 AnalogIn analogIn10(____);
whismanoid 0:cb44e2e9ec4c 1610 #endif
whismanoid 0:cb44e2e9ec4c 1611 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1612 AnalogIn analogIn11(____);
whismanoid 0:cb44e2e9ec4c 1613 #endif
whismanoid 0:cb44e2e9ec4c 1614 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1615 AnalogIn analogIn12(____);
whismanoid 0:cb44e2e9ec4c 1616 #endif
whismanoid 0:cb44e2e9ec4c 1617 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1618 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1619 #endif
whismanoid 0:cb44e2e9ec4c 1620 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1621 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1622 #endif
whismanoid 0:cb44e2e9ec4c 1623 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1624 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1625 #endif
whismanoid 0:cb44e2e9ec4c 1626 #else
whismanoid 0:cb44e2e9ec4c 1627 // unknown target
whismanoid 0:cb44e2e9ec4c 1628 #endif
whismanoid 0:cb44e2e9ec4c 1629 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1630 #if HAS_analogIn0 || HAS_analogIn1 \
whismanoid 0:cb44e2e9ec4c 1631 || HAS_analogIn2 || HAS_analogIn3 \
whismanoid 0:cb44e2e9ec4c 1632 || HAS_analogIn4 || HAS_analogIn5 \
whismanoid 0:cb44e2e9ec4c 1633 || HAS_analogIn6 || HAS_analogIn7 \
whismanoid 0:cb44e2e9ec4c 1634 || HAS_analogIn8 || HAS_analogIn9 \
whismanoid 0:cb44e2e9ec4c 1635 || HAS_analogIn10 || HAS_analogIn11 \
whismanoid 0:cb44e2e9ec4c 1636 || HAS_analogIn12 || HAS_analogIn13 \
whismanoid 0:cb44e2e9ec4c 1637 || HAS_analogIn14 || HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1638 #define HAS_analogIns 1
whismanoid 0:cb44e2e9ec4c 1639 #else
whismanoid 0:cb44e2e9ec4c 1640 #warning "Note: There are no analogIn resources defined"
whismanoid 0:cb44e2e9ec4c 1641 #endif
whismanoid 0:cb44e2e9ec4c 1642
whismanoid 0:cb44e2e9ec4c 1643 // DigitalInOut pin resource: print the pin index names to serial
whismanoid 0:cb44e2e9ec4c 1644 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 1645 void list_digitalInOutPins(Stream& serialStream)
whismanoid 0:cb44e2e9ec4c 1646 {
whismanoid 0:cb44e2e9ec4c 1647 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1648 serialStream.printf(" 0");
whismanoid 0:cb44e2e9ec4c 1649 #endif
whismanoid 0:cb44e2e9ec4c 1650 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1651 serialStream.printf(" 1");
whismanoid 0:cb44e2e9ec4c 1652 #endif
whismanoid 0:cb44e2e9ec4c 1653 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1654 serialStream.printf(" 2");
whismanoid 0:cb44e2e9ec4c 1655 #endif
whismanoid 0:cb44e2e9ec4c 1656 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1657 serialStream.printf(" 3");
whismanoid 0:cb44e2e9ec4c 1658 #endif
whismanoid 0:cb44e2e9ec4c 1659 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1660 serialStream.printf(" 4");
whismanoid 0:cb44e2e9ec4c 1661 #endif
whismanoid 0:cb44e2e9ec4c 1662 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1663 serialStream.printf(" 5");
whismanoid 0:cb44e2e9ec4c 1664 #endif
whismanoid 0:cb44e2e9ec4c 1665 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1666 serialStream.printf(" 6");
whismanoid 0:cb44e2e9ec4c 1667 #endif
whismanoid 0:cb44e2e9ec4c 1668 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1669 serialStream.printf(" 7");
whismanoid 0:cb44e2e9ec4c 1670 #endif
whismanoid 0:cb44e2e9ec4c 1671 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1672 serialStream.printf(" 8");
whismanoid 0:cb44e2e9ec4c 1673 #endif
whismanoid 0:cb44e2e9ec4c 1674 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1675 serialStream.printf(" 9");
whismanoid 0:cb44e2e9ec4c 1676 #endif
whismanoid 0:cb44e2e9ec4c 1677 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1678 serialStream.printf(" 10");
whismanoid 0:cb44e2e9ec4c 1679 #endif
whismanoid 0:cb44e2e9ec4c 1680 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1681 serialStream.printf(" 11");
whismanoid 0:cb44e2e9ec4c 1682 #endif
whismanoid 0:cb44e2e9ec4c 1683 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1684 serialStream.printf(" 12");
whismanoid 0:cb44e2e9ec4c 1685 #endif
whismanoid 0:cb44e2e9ec4c 1686 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1687 serialStream.printf(" 13");
whismanoid 0:cb44e2e9ec4c 1688 #endif
whismanoid 0:cb44e2e9ec4c 1689 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1690 serialStream.printf(" 14");
whismanoid 0:cb44e2e9ec4c 1691 #endif
whismanoid 0:cb44e2e9ec4c 1692 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1693 serialStream.printf(" 15");
whismanoid 0:cb44e2e9ec4c 1694 #endif
whismanoid 0:cb44e2e9ec4c 1695 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1696 serialStream.printf(" 16");
whismanoid 0:cb44e2e9ec4c 1697 #endif
whismanoid 0:cb44e2e9ec4c 1698 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1699 serialStream.printf(" 17");
whismanoid 0:cb44e2e9ec4c 1700 #endif
whismanoid 18:1235c17b451e 1701 #if USE_LEDS
whismanoid 18:1235c17b451e 1702 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 1703 // support list_digitalInOutPins() listing buttons and leds as pin numbers 90/91/92/93
whismanoid 18:1235c17b451e 1704 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 1705 //~ serialStream.printf(" 90");
whismanoid 18:1235c17b451e 1706 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 1707 serialStream.printf(" 91");
whismanoid 18:1235c17b451e 1708 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 1709 serialStream.printf(" 92");
whismanoid 18:1235c17b451e 1710 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 1711 serialStream.printf(" 93");
whismanoid 18:1235c17b451e 1712 #else // USE_LEDS
whismanoid 18:1235c17b451e 1713 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 1714 }
whismanoid 0:cb44e2e9ec4c 1715 #endif
whismanoid 0:cb44e2e9ec4c 1716
whismanoid 0:cb44e2e9ec4c 1717
whismanoid 0:cb44e2e9ec4c 1718 // DigitalInOut pin resource: search index
whismanoid 0:cb44e2e9ec4c 1719 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 1720 DigitalInOut& find_digitalInOutPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 1721 {
whismanoid 0:cb44e2e9ec4c 1722 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 1723 {
whismanoid 0:cb44e2e9ec4c 1724 default: // default to the first defined digitalInOut pin
whismanoid 0:cb44e2e9ec4c 1725 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1726 case '0': case 0x00: return digitalInOut0;
whismanoid 0:cb44e2e9ec4c 1727 #endif
whismanoid 0:cb44e2e9ec4c 1728 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1729 case '1': case 0x01: return digitalInOut1;
whismanoid 0:cb44e2e9ec4c 1730 #endif
whismanoid 0:cb44e2e9ec4c 1731 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1732 case '2': case 0x02: return digitalInOut2;
whismanoid 0:cb44e2e9ec4c 1733 #endif
whismanoid 0:cb44e2e9ec4c 1734 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1735 case '3': case 0x03: return digitalInOut3;
whismanoid 0:cb44e2e9ec4c 1736 #endif
whismanoid 0:cb44e2e9ec4c 1737 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1738 case '4': case 0x04: return digitalInOut4;
whismanoid 0:cb44e2e9ec4c 1739 #endif
whismanoid 0:cb44e2e9ec4c 1740 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1741 case '5': case 0x05: return digitalInOut5;
whismanoid 0:cb44e2e9ec4c 1742 #endif
whismanoid 0:cb44e2e9ec4c 1743 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1744 case '6': case 0x06: return digitalInOut6;
whismanoid 0:cb44e2e9ec4c 1745 #endif
whismanoid 0:cb44e2e9ec4c 1746 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1747 case '7': case 0x07: return digitalInOut7;
whismanoid 0:cb44e2e9ec4c 1748 #endif
whismanoid 0:cb44e2e9ec4c 1749 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1750 case '8': case 0x08: return digitalInOut8;
whismanoid 0:cb44e2e9ec4c 1751 #endif
whismanoid 0:cb44e2e9ec4c 1752 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1753 case '9': case 0x09: return digitalInOut9;
whismanoid 0:cb44e2e9ec4c 1754 #endif
whismanoid 0:cb44e2e9ec4c 1755 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1756 case 'a': case 0x0a: return digitalInOut10;
whismanoid 0:cb44e2e9ec4c 1757 #endif
whismanoid 0:cb44e2e9ec4c 1758 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1759 case 'b': case 0x0b: return digitalInOut11;
whismanoid 0:cb44e2e9ec4c 1760 #endif
whismanoid 0:cb44e2e9ec4c 1761 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1762 case 'c': case 0x0c: return digitalInOut12;
whismanoid 0:cb44e2e9ec4c 1763 #endif
whismanoid 0:cb44e2e9ec4c 1764 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1765 case 'd': case 0x0d: return digitalInOut13;
whismanoid 0:cb44e2e9ec4c 1766 #endif
whismanoid 0:cb44e2e9ec4c 1767 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1768 case 'e': case 0x0e: return digitalInOut14;
whismanoid 0:cb44e2e9ec4c 1769 #endif
whismanoid 0:cb44e2e9ec4c 1770 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1771 case 'f': case 0x0f: return digitalInOut15;
whismanoid 0:cb44e2e9ec4c 1772 #endif
whismanoid 0:cb44e2e9ec4c 1773 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1774 case 'g': case 0x10: return digitalInOut16;
whismanoid 0:cb44e2e9ec4c 1775 #endif
whismanoid 0:cb44e2e9ec4c 1776 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1777 case 'h': case 0x11: return digitalInOut17;
whismanoid 0:cb44e2e9ec4c 1778 #endif
whismanoid 18:1235c17b451e 1779 // support LEDs as digital pins 91 92 93; WIP button as digital pin 90
whismanoid 18:1235c17b451e 1780 // TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1
whismanoid 18:1235c17b451e 1781 //~ case 90: return button1;
whismanoid 18:1235c17b451e 1782 #if USE_LEDS
whismanoid 18:1235c17b451e 1783 // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 1784 case 91: return led1_RFailLED;
whismanoid 18:1235c17b451e 1785 // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 1786 case 92: return led2_GPassLED;
whismanoid 18:1235c17b451e 1787 // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 18:1235c17b451e 1788 case 93: return led3_BBusyLED;
whismanoid 18:1235c17b451e 1789 #else // USE_LEDS
whismanoid 18:1235c17b451e 1790 #endif // USE_LEDS
whismanoid 0:cb44e2e9ec4c 1791 }
whismanoid 0:cb44e2e9ec4c 1792 }
whismanoid 0:cb44e2e9ec4c 1793 #endif
whismanoid 0:cb44e2e9ec4c 1794
whismanoid 0:cb44e2e9ec4c 1795
whismanoid 0:cb44e2e9ec4c 1796 // AnalogIn pin resource: search index
whismanoid 0:cb44e2e9ec4c 1797 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 1798 AnalogIn& find_analogInPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 1799 {
whismanoid 0:cb44e2e9ec4c 1800 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 1801 {
whismanoid 0:cb44e2e9ec4c 1802 default: // default to the first defined analogIn pin
whismanoid 0:cb44e2e9ec4c 1803 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1804 case '0': case 0x00: return analogIn0;
whismanoid 0:cb44e2e9ec4c 1805 #endif
whismanoid 0:cb44e2e9ec4c 1806 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1807 case '1': case 0x01: return analogIn1;
whismanoid 0:cb44e2e9ec4c 1808 #endif
whismanoid 0:cb44e2e9ec4c 1809 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1810 case '2': case 0x02: return analogIn2;
whismanoid 0:cb44e2e9ec4c 1811 #endif
whismanoid 0:cb44e2e9ec4c 1812 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1813 case '3': case 0x03: return analogIn3;
whismanoid 0:cb44e2e9ec4c 1814 #endif
whismanoid 0:cb44e2e9ec4c 1815 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1816 case '4': case 0x04: return analogIn4;
whismanoid 0:cb44e2e9ec4c 1817 #endif
whismanoid 0:cb44e2e9ec4c 1818 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1819 case '5': case 0x05: return analogIn5;
whismanoid 0:cb44e2e9ec4c 1820 #endif
whismanoid 0:cb44e2e9ec4c 1821 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1822 case '6': case 0x06: return analogIn6;
whismanoid 0:cb44e2e9ec4c 1823 #endif
whismanoid 0:cb44e2e9ec4c 1824 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1825 case '7': case 0x07: return analogIn7;
whismanoid 0:cb44e2e9ec4c 1826 #endif
whismanoid 0:cb44e2e9ec4c 1827 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1828 case '8': case 0x08: return analogIn8;
whismanoid 0:cb44e2e9ec4c 1829 #endif
whismanoid 0:cb44e2e9ec4c 1830 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1831 case '9': case 0x09: return analogIn9;
whismanoid 0:cb44e2e9ec4c 1832 #endif
whismanoid 0:cb44e2e9ec4c 1833 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1834 case 'a': case 0x0a: return analogIn10;
whismanoid 0:cb44e2e9ec4c 1835 #endif
whismanoid 0:cb44e2e9ec4c 1836 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1837 case 'b': case 0x0b: return analogIn11;
whismanoid 0:cb44e2e9ec4c 1838 #endif
whismanoid 0:cb44e2e9ec4c 1839 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1840 case 'c': case 0x0c: return analogIn12;
whismanoid 0:cb44e2e9ec4c 1841 #endif
whismanoid 0:cb44e2e9ec4c 1842 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1843 case 'd': case 0x0d: return analogIn13;
whismanoid 0:cb44e2e9ec4c 1844 #endif
whismanoid 0:cb44e2e9ec4c 1845 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1846 case 'e': case 0x0e: return analogIn14;
whismanoid 0:cb44e2e9ec4c 1847 #endif
whismanoid 0:cb44e2e9ec4c 1848 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1849 case 'f': case 0x0f: return analogIn15;
whismanoid 0:cb44e2e9ec4c 1850 #endif
whismanoid 0:cb44e2e9ec4c 1851 }
whismanoid 0:cb44e2e9ec4c 1852 }
whismanoid 0:cb44e2e9ec4c 1853 #endif
whismanoid 0:cb44e2e9ec4c 1854
whismanoid 0:cb44e2e9ec4c 1855 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 1856 const float analogInPin_fullScaleVoltage[] = {
whismanoid 0:cb44e2e9ec4c 1857 # if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1858 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1859 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1860 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1861 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1862 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1863 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1864 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1865 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1866 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1867 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1868 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1869 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1870 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1871 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1872 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1873 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1874 # elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 1875 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1876 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1877 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1878 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1879 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1880 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1881 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1882 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1883 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1884 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1885 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1886 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1887 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1888 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1889 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1890 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1891 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 19:5ff09c8e9daf 1892 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 1893 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1894 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1895 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1896 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1897 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1898 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1899 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1900 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1901 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1902 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1903 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1904 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1905 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1906 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1907 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1908 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1909 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 1910 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1911 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1912 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1913 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1914 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1915 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1916 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1917 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1918 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1919 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 1920 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 1921 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 1922 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 1923 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1924 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1925 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1926 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1927 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1928 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1929 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1930 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1931 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1932 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1933 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1934 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1935 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1936 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 1937 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 1938 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 1939 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 1940 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1941 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1942 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1943 //#elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1944 #else
whismanoid 0:cb44e2e9ec4c 1945 // unknown target
whismanoid 0:cb44e2e9ec4c 1946 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1947 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1948 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1949 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1950 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1951 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1952 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1953 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1954 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1955 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 1956 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 1957 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 1958 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 1959 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1960 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1961 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1962 # endif
whismanoid 0:cb44e2e9ec4c 1963 };
whismanoid 0:cb44e2e9ec4c 1964 #endif
whismanoid 0:cb44e2e9ec4c 1965
whismanoid 0:cb44e2e9ec4c 1966
whismanoid 0:cb44e2e9ec4c 1967
whismanoid 0:cb44e2e9ec4c 1968
whismanoid 0:cb44e2e9ec4c 1969 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 1970 // TODO support CmdLine command menus (like on Serial_Tester)
whismanoid 4:d9b05924ad4c 1971 #ifndef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 1972 #define USE_CMDLINE_MENUS 1
whismanoid 4:d9b05924ad4c 1973 //~ #undef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 1974 #endif
whismanoid 4:d9b05924ad4c 1975 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 1976 #include "CmdLine.h"
whismanoid 4:d9b05924ad4c 1977 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 1978 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 1979 extern CmdLine cmdLine; // declared later
whismanoid 4:d9b05924ad4c 1980 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 1981
whismanoid 4:d9b05924ad4c 1982 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 1983 // Datalog trigger types
whismanoid 4:d9b05924ad4c 1984 #ifndef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 1985 #define USE_DATALOGGER_TRIGGER 1
whismanoid 4:d9b05924ad4c 1986 //~ #undef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 1987 #endif
whismanoid 4:d9b05924ad4c 1988 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 1989 typedef enum Datalogger_Trigger_enum_t {
whismanoid 4:d9b05924ad4c 1990 trigger_Halt = 0, //!< halt
whismanoid 4:d9b05924ad4c 1991 trigger_FreeRun = 1, //!< free run as fast as possible
whismanoid 4:d9b05924ad4c 1992 trigger_Timer = 2, //!< timer (configure interval)
whismanoid 4:d9b05924ad4c 1993 trigger_PlatformDigitalInput, //!< platform digital input (configure digital input pin reference)
whismanoid 4:d9b05924ad4c 1994 trigger_SPIDeviceRegRead, //!< SPI device register read (configure regaddr, mask value, match value)
whismanoid 4:d9b05924ad4c 1995 } Datalogger_Trigger_enum_t;
whismanoid 4:d9b05924ad4c 1996 Datalogger_Trigger_enum_t Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 1997 //
whismanoid 17:9397ea3ea7e9 1998 // configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 1999 int g_timer_interval_msec = 500; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2000 int g_timer_interval_count = 10; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2001 int g_timer_interval_counter = 0; // trigger_Timer
whismanoid 17:9397ea3ea7e9 2002 //
whismanoid 17:9397ea3ea7e9 2003 // TODO: configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 2004 //
whismanoid 17:9397ea3ea7e9 2005 // TODO: configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2006 //
whismanoid 4:d9b05924ad4c 2007 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 2008
whismanoid 4:d9b05924ad4c 2009 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2010 // support trigger_SPIDeviceRegRead: Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 2011 #ifndef USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2012 #define USE_DATALOGGER_SPIDeviceRegRead 0
whismanoid 17:9397ea3ea7e9 2013 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2014 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2015 // TODO: uint16_t regAddr;
whismanoid 17:9397ea3ea7e9 2016 // TODO: uint16_t regDataMask;
whismanoid 17:9397ea3ea7e9 2017 // TODO: uint16_t regDataTest;
whismanoid 17:9397ea3ea7e9 2018 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2019
whismanoid 17:9397ea3ea7e9 2020 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 2021 // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2022 #ifndef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2023 #define USE_DATALOGGER_ActionTable 1
whismanoid 17:9397ea3ea7e9 2024 //~ #undef USE_DATALOGGER_ActionTable
whismanoid 17:9397ea3ea7e9 2025 #endif
whismanoid 17:9397ea3ea7e9 2026 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2027 //
whismanoid 17:9397ea3ea7e9 2028 // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2029 typedef enum action_type_enum_t {
whismanoid 17:9397ea3ea7e9 2030 action_noop = 0, // no operation
whismanoid 17:9397ea3ea7e9 2031 action_digitalOutLow, // pin = low if condition
whismanoid 17:9397ea3ea7e9 2032 action_digitalOutHigh, // pin = low if condition
whismanoid 17:9397ea3ea7e9 2033 action_trigger_Halt,
whismanoid 17:9397ea3ea7e9 2034 action_trigger_FreeRun,
whismanoid 17:9397ea3ea7e9 2035 action_trigger_Timer,
whismanoid 17:9397ea3ea7e9 2036 action_trigger_PlatformDigitalInput,
whismanoid 17:9397ea3ea7e9 2037 action_trigger_SPIDeviceRegRead,
whismanoid 17:9397ea3ea7e9 2038 } action_type_enum_t;
whismanoid 17:9397ea3ea7e9 2039 //
whismanoid 17:9397ea3ea7e9 2040 // Datalogger_RunActionTable() supported conditions
whismanoid 17:9397ea3ea7e9 2041 typedef enum action_condition_enum_t {
whismanoid 17:9397ea3ea7e9 2042 condition_always = 0, // ( true )
whismanoid 17:9397ea3ea7e9 2043 condition_if_An_gt_threshold, // (Platform_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2044 condition_if_An_lt_threshold, // (Platform_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2045 condition_if_An_eq_threshold, // (Platform_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2046 condition_if_An_ge_threshold, // (Platform_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2047 condition_if_An_le_threshold, // (Platform_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2048 condition_if_An_ne_threshold, // (Platform_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2049 condition_if_AINn_gt_threshold, // (SPI_AIN_Voltage[channel] > threhsold)
whismanoid 17:9397ea3ea7e9 2050 condition_if_AINn_lt_threshold, // (SPI_AIN_Voltage[channel] < threhsold)
whismanoid 17:9397ea3ea7e9 2051 condition_if_AINn_eq_threshold, // (SPI_AIN_Voltage[channel] == threhsold)
whismanoid 17:9397ea3ea7e9 2052 condition_if_AINn_ge_threshold, // (SPI_AIN_Voltage[channel] >= threhsold)
whismanoid 17:9397ea3ea7e9 2053 condition_if_AINn_le_threshold, // (SPI_AIN_Voltage[channel] <= threhsold)
whismanoid 17:9397ea3ea7e9 2054 condition_if_AINn_ne_threshold, // (SPI_AIN_Voltage[channel] != threhsold)
whismanoid 17:9397ea3ea7e9 2055 } condition_enum_t;
whismanoid 17:9397ea3ea7e9 2056 //
whismanoid 17:9397ea3ea7e9 2057 // Datalogger_RunActionTable() structure
whismanoid 17:9397ea3ea7e9 2058 typedef struct action_table_row_t {
whismanoid 17:9397ea3ea7e9 2059 action_type_enum_t action;
whismanoid 17:9397ea3ea7e9 2060 int digitalOutPin;
whismanoid 17:9397ea3ea7e9 2061 action_condition_enum_t condition;
whismanoid 17:9397ea3ea7e9 2062 int condition_channel;
whismanoid 17:9397ea3ea7e9 2063 double condition_threshold;
whismanoid 17:9397ea3ea7e9 2064 } action_table_row_t;
whismanoid 17:9397ea3ea7e9 2065 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2066 const int channel_WE = 2;
whismanoid 17:9397ea3ea7e9 2067 const double threshold_WE_0V5 = 0.5;
whismanoid 17:9397ea3ea7e9 2068 const double threshold_WE_0V6 = 0.6;
whismanoid 17:9397ea3ea7e9 2069 const double threshold_WE_0V7 = 0.7;
whismanoid 18:1235c17b451e 2070 const int pin_LED_1 = 91; // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED
whismanoid 18:1235c17b451e 2071 const int pin_LED_2 = 92; // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED
whismanoid 18:1235c17b451e 2072 const int pin_LED_3 = 93; // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED
whismanoid 17:9397ea3ea7e9 2073 #endif
whismanoid 17:9397ea3ea7e9 2074 const int ACTION_TABLE_ROW_MAX = 20;
whismanoid 17:9397ea3ea7e9 2075 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2076 bool Datalogger_action_table_enabled = true;
whismanoid 18:1235c17b451e 2077 int Datalogger_action_table_row_count = 6; // assert (Datalogger_action_table_row_count <= ACTION_TABLE_ROW_MAX)
whismanoid 17:9397ea3ea7e9 2078 #else // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2079 int Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 2080 #endif // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2081 action_table_row_t Datalogger_action_table[ACTION_TABLE_ROW_MAX] = {
whismanoid 17:9397ea3ea7e9 2082 #if MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2083 // LED indicator show (WE > 0.5V)
whismanoid 18:1235c17b451e 2084 // L@0 act=1 pin=92 if=1 ch=2 x=0.500000 -- digitalOutLow D92 if A2 > 0.500000
whismanoid 18:1235c17b451e 2085 {action_digitalOutLow, pin_LED_2, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V5},
whismanoid 17:9397ea3ea7e9 2086 //
whismanoid 17:9397ea3ea7e9 2087 // LED indicator show (WE > 0.6V)
whismanoid 18:1235c17b451e 2088 // L@1 act=1 pin=93 if=1 ch=2 x=0.600000 -- digitalOutLow D93 if A2 > 0.600000
whismanoid 18:1235c17b451e 2089 {action_digitalOutLow, pin_LED_3, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 17:9397ea3ea7e9 2090 //
whismanoid 17:9397ea3ea7e9 2091 // switch to always-on mode `trigger_FreeRun` if (WE > 0.7V)
whismanoid 18:1235c17b451e 2092 // L@2 act=4 if=1 ch=2 x=0.700000 -- trigger_FreeRun if A2 > 0.700000
whismanoid 17:9397ea3ea7e9 2093 {action_trigger_FreeRun, 0, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 17:9397ea3ea7e9 2094 //
whismanoid 17:9397ea3ea7e9 2095 // switch to intermittent-sleep-mode `trigger_Timer` if (WE < 0.6V)
whismanoid 18:1235c17b451e 2096 // L@3 act=5 if=2 ch=2 x=0.600000 -- trigger_Timer(10 x 500msec) if A2 < 0.600000
whismanoid 17:9397ea3ea7e9 2097 {action_trigger_Timer, 0, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 18:1235c17b451e 2098 //
whismanoid 18:1235c17b451e 2099 // LED indicator show (`Datalogger_Trigger` == `trigger_FreeRun`)
whismanoid 18:1235c17b451e 2100 // {action_noop, 0, condition_always, 0, 0},
whismanoid 18:1235c17b451e 2101 // L@4 act=1 pin=91 if=1 ch=2 x=0.700000 -- digitalOutLow D91 if A2 > 0.700000
whismanoid 18:1235c17b451e 2102 {action_digitalOutLow, pin_LED_1, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7},
whismanoid 18:1235c17b451e 2103 //
whismanoid 18:1235c17b451e 2104 // L@5 act=2 pin=91 if=2 ch=2 x=0.600000 -- digitalOutHigh D91 if A2 < 0.600000
whismanoid 18:1235c17b451e 2105 {action_digitalOutHigh, pin_LED_1, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6},
whismanoid 18:1235c17b451e 2106 //
whismanoid 17:9397ea3ea7e9 2107 #endif // MAX40108_DEMO
whismanoid 17:9397ea3ea7e9 2108 //
whismanoid 17:9397ea3ea7e9 2109 {action_noop, 0, condition_always, 0, 0},
whismanoid 17:9397ea3ea7e9 2110 };
whismanoid 17:9397ea3ea7e9 2111 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2112
whismanoid 17:9397ea3ea7e9 2113 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2114 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 2115 uint8_t Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 2116 uint8_t need_reinit = true;
whismanoid 8:dffee7509bfb 2117 void Datalogger_PrintHeader(CmdLine& cmdLine);
whismanoid 5:aaf8b5f5fda1 2118 void Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 2119 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2120 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 2121 void Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 2122 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 8:dffee7509bfb 2123 void Datalogger_PrintRow(CmdLine& cmdLine);
whismanoid 4:d9b05924ad4c 2124
whismanoid 4:d9b05924ad4c 2125 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 2126 // Option to validate SPI link by reading PART_ID register
whismanoid 0:cb44e2e9ec4c 2127 #ifndef VERIFY_PART_ID_IN_LOOP
whismanoid 3:9055e17e181a 2128 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 2129 #define VERIFY_PART_ID_IN_LOOP 1
whismanoid 3:9055e17e181a 2130 #else
whismanoid 0:cb44e2e9ec4c 2131 #define VERIFY_PART_ID_IN_LOOP 0
whismanoid 3:9055e17e181a 2132 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2133 #endif
whismanoid 0:cb44e2e9ec4c 2134
whismanoid 3:9055e17e181a 2135 //--------------------------------------------------
whismanoid 3:9055e17e181a 2136 #define NUM_DUT_ANALOG_IN_CHANNELS 10
whismanoid 3:9055e17e181a 2137
whismanoid 3:9055e17e181a 2138 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 2139 // MAX11410 individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 3:9055e17e181a 2140 typedef enum SPI_AIN_Enable_t {
whismanoid 10:04022a61b527 2141 SPI_AIN_Disable = 0,
whismanoid 10:04022a61b527 2142 SPI_AIN_Enable_LSB = 1,
whismanoid 10:04022a61b527 2143 SPI_AIN_Enable_Volt = 2,
whismanoid 3:9055e17e181a 2144 } SPI_AIN_Enable_t;
whismanoid 3:9055e17e181a 2145 uint8_t SPI_AIN_Enable_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 2146 SPI_AIN_Enable_LSB, // AIN0 1=LSB
whismanoid 10:04022a61b527 2147 SPI_AIN_Enable_LSB, // AIN1 1=LSB
whismanoid 10:04022a61b527 2148 SPI_AIN_Enable_LSB, // AIN2 1=LSB
whismanoid 10:04022a61b527 2149 SPI_AIN_Enable_LSB, // AIN3 1=LSB
whismanoid 10:04022a61b527 2150 SPI_AIN_Enable_LSB, // AIN4 1=LSB
whismanoid 10:04022a61b527 2151 SPI_AIN_Enable_LSB, // AIN5 1=LSB
whismanoid 10:04022a61b527 2152 SPI_AIN_Enable_LSB, // AIN6 1=LSB
whismanoid 10:04022a61b527 2153 SPI_AIN_Enable_LSB, // AIN7 1=LSB
whismanoid 10:04022a61b527 2154 SPI_AIN_Enable_LSB, // AIN8 1=LSB
whismanoid 10:04022a61b527 2155 SPI_AIN_Enable_LSB, // AIN9 1=LSB
whismanoid 3:9055e17e181a 2156 };
whismanoid 3:9055e17e181a 2157 //
whismanoid 10:04022a61b527 2158 double SPI_AIN_Voltage[NUM_DUT_ANALOG_IN_CHANNELS];
whismanoid 13:184a08909405 2159 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2160 #ifndef HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 2161 #define HAS_SPI_AIN_customChannelHeader 0
whismanoid 13:184a08909405 2162 #endif
whismanoid 13:184a08909405 2163 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2164 const char* const SPI_AIN_customChannelHeader_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 2165 "", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 2166 "", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 2167 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 2168 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 2169 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 2170 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 2171 };
whismanoid 13:184a08909405 2172 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 3:9055e17e181a 2173 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2174 // ---------- Measure_Voltage_custom_props in Measure_Voltage @pre and in class properties ----------
whismanoid 3:9055e17e181a 2175 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 2176 // MAX11410 specific per-channel config register v_filter
whismanoid 3:9055e17e181a 2177 uint8_t SPI_AIN_Cfg_v_filter_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2178 0x34, // AIN0 @ v_filter=0x34
whismanoid 3:9055e17e181a 2179 0x34, // AIN1 @ v_filter=0x34
whismanoid 3:9055e17e181a 2180 0x34, // AIN2 @ v_filter=0x34
whismanoid 3:9055e17e181a 2181 0x34, // AIN3 @ v_filter=0x34
whismanoid 3:9055e17e181a 2182 0x34, // AIN4 @ v_filter=0x34
whismanoid 3:9055e17e181a 2183 0x34, // AIN5 @ v_filter=0x34
whismanoid 3:9055e17e181a 2184 0x34, // AIN6 @ v_filter=0x34
whismanoid 3:9055e17e181a 2185 0x34, // AIN7 @ v_filter=0x34
whismanoid 3:9055e17e181a 2186 0x34, // AIN8 @ v_filter=0x34
whismanoid 3:9055e17e181a 2187 0x34, // AIN9 @ v_filter=0x34
whismanoid 3:9055e17e181a 2188 };
whismanoid 3:9055e17e181a 2189 //
whismanoid 4:d9b05924ad4c 2190 // MAX11410 specific per-channel config register v_ctrl
whismanoid 3:9055e17e181a 2191 uint8_t SPI_AIN_Cfg_v_ctrl_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2192 0x42, // AIN0 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2193 0x42, // AIN1 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2194 0x42, // AIN2 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2195 0x42, // AIN3 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2196 0x42, // AIN4 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2197 0x42, // AIN5 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2198 0x42, // AIN6 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2199 0x42, // AIN7 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2200 0x42, // AIN8 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2201 0x42, // AIN9 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 2202 };
whismanoid 3:9055e17e181a 2203 //
whismanoid 4:d9b05924ad4c 2204 // MAX11410 specific per-channel config register v_pga
whismanoid 3:9055e17e181a 2205 uint8_t SPI_AIN_Cfg_v_pga_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 2206 0x00, // AIN0 @ v_pga=0x00
whismanoid 3:9055e17e181a 2207 0x00, // AIN1 @ v_pga=0x00
whismanoid 3:9055e17e181a 2208 0x00, // AIN2 @ v_pga=0x00
whismanoid 3:9055e17e181a 2209 0x00, // AIN3 @ v_pga=0x00
whismanoid 3:9055e17e181a 2210 0x00, // AIN4 @ v_pga=0x00
whismanoid 3:9055e17e181a 2211 0x00, // AIN5 @ v_pga=0x00
whismanoid 3:9055e17e181a 2212 0x00, // AIN6 @ v_pga=0x00
whismanoid 3:9055e17e181a 2213 0x00, // AIN7 @ v_pga=0x00
whismanoid 3:9055e17e181a 2214 0x00, // AIN8 @ v_pga=0x00
whismanoid 3:9055e17e181a 2215 0x00, // AIN9 @ v_pga=0x00
whismanoid 3:9055e17e181a 2216 };
whismanoid 3:9055e17e181a 2217 //
whismanoid 3:9055e17e181a 2218 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2219 // ---------- Measure_Voltage_custom_props ----------
whismanoid 0:cb44e2e9ec4c 2220 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2221 // filter register configuration in Measure_Voltage and Read_All_Voltages CONV_TYPE_01_Continuous
whismanoid 0:cb44e2e9ec4c 2222 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 2223 //~ const uint8_t custom_v_filter = 0x00; // @ v_filter=0x00 -- LINEF_00_50Hz_60Hz_FIR RATE_0000 | 1.1SPS
whismanoid 0:cb44e2e9ec4c 2224 //~ const uint8_t custom_v_filter = 0x01; // @ v_filter=0x01 -- LINEF_00_50Hz_60Hz_FIR RATE_0001 | 2.1SPS
whismanoid 0:cb44e2e9ec4c 2225 //~ const uint8_t custom_v_filter = 0x02; // @ v_filter=0x02 -- LINEF_00_50Hz_60Hz_FIR RATE_0010 | 4.2SPS
whismanoid 0:cb44e2e9ec4c 2226 //~ const uint8_t custom_v_filter = 0x03; // @ v_filter=0x03 -- LINEF_00_50Hz_60Hz_FIR RATE_0011 | 8.4SPS
whismanoid 0:cb44e2e9ec4c 2227 //~ const uint8_t custom_v_filter = 0x04; // @ v_filter=0x04 -- LINEF_00_50Hz_60Hz_FIR RATE_0100 | 16.8SPS
whismanoid 0:cb44e2e9ec4c 2228 //~ const uint8_t custom_v_filter = 0x10; // @ v_filter=0x10 -- LINEF_01_50Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 2229 //~ const uint8_t custom_v_filter = 0x11; // @ v_filter=0x11 -- LINEF_01_50Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 2230 //~ const uint8_t custom_v_filter = 0x12; // @ v_filter=0x12 -- LINEF_01_50Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 2231 //~ const uint8_t custom_v_filter = 0x13; // @ v_filter=0x13 -- LINEF_01_50Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 2232 //~ const uint8_t custom_v_filter = 0x14; // @ v_filter=0x14 -- LINEF_01_50Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 2233 //~ const uint8_t custom_v_filter = 0x15; // @ v_filter=0x15 -- LINEF_01_50Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 2234 //~ const uint8_t custom_v_filter = 0x20; // @ v_filter=0x20 -- LINEF_10_60Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 2235 //~ const uint8_t custom_v_filter = 0x21; // @ v_filter=0x21 -- LINEF_10_60Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 2236 //~ const uint8_t custom_v_filter = 0x22; // @ v_filter=0x22 -- LINEF_10_60Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 2237 //~ const uint8_t custom_v_filter = 0x23; // @ v_filter=0x23 -- LINEF_10_60Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 2238 //~ const uint8_t custom_v_filter = 0x24; // @ v_filter=0x24 -- LINEF_10_60Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 2239 //~ const uint8_t custom_v_filter = 0x25; // @ v_filter=0x25 -- LINEF_10_60Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 2240 //~ const uint8_t custom_v_filter = 0x30; // @ v_filter=0x30 -- LINEF_11_SINC4 RATE_0000 | 4SPS
whismanoid 0:cb44e2e9ec4c 2241 //~ const uint8_t custom_v_filter = 0x31; // @ v_filter=0x31 -- LINEF_11_SINC4 RATE_0001 | 10SPS
whismanoid 0:cb44e2e9ec4c 2242 //~ const uint8_t custom_v_filter = 0x32; // @ v_filter=0x32 -- LINEF_11_SINC4 RATE_0010 | 20SPS
whismanoid 0:cb44e2e9ec4c 2243 //~ const uint8_t custom_v_filter = 0x33; // @ v_filter=0x33 -- LINEF_11_SINC4 RATE_0011 | 40SPS
whismanoid 0:cb44e2e9ec4c 2244 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 2245 //~ const uint8_t custom_v_filter = 0x35; // @ v_filter=0x35 -- LINEF_11_SINC4 RATE_0101 | 120SPS
whismanoid 0:cb44e2e9ec4c 2246 //~ const uint8_t custom_v_filter = 0x36; // @ v_filter=0x36 -- LINEF_11_SINC4 RATE_0110 | 240SPS
whismanoid 0:cb44e2e9ec4c 2247 //~ const uint8_t custom_v_filter = 0x37; // @ v_filter=0x37 -- LINEF_11_SINC4 RATE_0111 | 480SPS
whismanoid 0:cb44e2e9ec4c 2248 //~ const uint8_t custom_v_filter = 0x38; // @ v_filter=0x38 -- LINEF_11_SINC4 RATE_1000 | 960SPS
whismanoid 0:cb44e2e9ec4c 2249 //~ const uint8_t custom_v_filter = 0x39; // @ v_filter=0x39 -- LINEF_11_SINC4 RATE_1001 | 1920SPS
whismanoid 0:cb44e2e9ec4c 2250 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2251 //
whismanoid 0:cb44e2e9ec4c 2252 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2253 // pga register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 0:cb44e2e9ec4c 2254 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 2255 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 2256 //~ const uint8_t custom_v_pga = 0x10; // @ v_pga=0x10 -- 0x10 SIG_PATH_01_BYPASS
whismanoid 0:cb44e2e9ec4c 2257 //~ const uint8_t custom_v_pga = 0x20; // @ v_pga=0x20 -- 0x20 SIG_PATH_10_PGA GAIN_000_1
whismanoid 0:cb44e2e9ec4c 2258 //~ const uint8_t custom_v_pga = 0x21; // @ v_pga=0x21 --*0x21 SIG_PATH_10_PGA GAIN_001_2
whismanoid 0:cb44e2e9ec4c 2259 //~ const uint8_t custom_v_pga = 0x22; // @ v_pga=0x22 -- 0x22 SIG_PATH_10_PGA GAIN_010_4
whismanoid 0:cb44e2e9ec4c 2260 //~ const uint8_t custom_v_pga = 0x23; // @ v_pga=0x23 -- 0x23 SIG_PATH_10_PGA GAIN_011_8
whismanoid 0:cb44e2e9ec4c 2261 //~ const uint8_t custom_v_pga = 0x24; // @ v_pga=0x24 -- 0x24 SIG_PATH_10_PGA GAIN_100_16
whismanoid 0:cb44e2e9ec4c 2262 //~ const uint8_t custom_v_pga = 0x25; // @ v_pga=0x25 -- 0x25 SIG_PATH_10_PGA GAIN_101_32
whismanoid 0:cb44e2e9ec4c 2263 //~ const uint8_t custom_v_pga = 0x26; // @ v_pga=0x26 -- 0x26 SIG_PATH_10_PGA GAIN_110_64
whismanoid 0:cb44e2e9ec4c 2264 //~ const uint8_t custom_v_pga = 0x27; // @ v_pga=0x27 -- 0x27 SIG_PATH_10_PGA GAIN_111_128
whismanoid 0:cb44e2e9ec4c 2265 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2266 //
whismanoid 0:cb44e2e9ec4c 2267 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 2268 // ctrl register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 3:9055e17e181a 2269 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2270 //~ const uint8_t custom_v_ctrl = 0x40; // @ v_ctrl=0x40 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1
whismanoid 0:cb44e2e9ec4c 2271 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 2272 //~ const uint8_t custom_v_ctrl = 0x58; // @ v_ctrl=0x58 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 2273 //
whismanoid 0:cb44e2e9ec4c 2274 //~ const uint8_t custom_v_ctrl = 0x41; // @ v_ctrl=0x41 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N
whismanoid 0:cb44e2e9ec4c 2275 //~ const uint8_t custom_v_ctrl = 0x45; // @ v_ctrl=0x45 -- 0x40 unipolar, 0x05 REF_SEL_101_REF1P_AGND
whismanoid 0:cb44e2e9ec4c 2276 //~ const uint8_t custom_v_ctrl = 0x59; // @ v_ctrl=0x59 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 2277 //
whismanoid 0:cb44e2e9ec4c 2278 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2279 //~ const uint8_t custom_v_ctrl = 0x46; // @ v_ctrl=0x46 -- 0x40 unipolar, 0x06 REF_SEL_110_REF2P_AGND
whismanoid 0:cb44e2e9ec4c 2280 //~ const uint8_t custom_v_ctrl = 0x22; // @ v_ctrl=0x22 -- 0x20 bipolar offset binary, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2281 //~ const uint8_t custom_v_ctrl = 0x02; // @ v_ctrl=0x02 -- 0x00 bipolar 2's complement, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 2282 //
whismanoid 0:cb44e2e9ec4c 2283 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 2284 //~ const uint8_t custom_v_ctrl = 0x47; // @ v_ctrl=0x47 -- 0x40 unipolar, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2285 //~ const uint8_t custom_v_ctrl = 0x27; // @ v_ctrl=0x27 -- 0x20 bipolar offset binary, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2286 //~ const uint8_t custom_v_ctrl = 0x07; // @ v_ctrl=0x07 -- 0x00 bipolar 2's complement, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 2287 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 2288
whismanoid 3:9055e17e181a 2289 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2290 // example code declare SPI interface (GPIO controlled CS)
whismanoid 0:cb44e2e9ec4c 2291 #if defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 2292 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 2293 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
whismanoid 19:5ff09c8e9daf 2294 #elif defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 0:cb44e2e9ec4c 2295 #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 2296 SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625PICO: pin P0_5 P0_6 P0_4
whismanoid 0:cb44e2e9ec4c 2297 DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32625PICO: pin P0_7
whismanoid 0:cb44e2e9ec4c 2298 #elif defined(TARGET_MAX32600MBED)
whismanoid 0:cb44e2e9ec4c 2299 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 0:cb44e2e9ec4c 2300 DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2301 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 2302 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 2303 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:cb44e2e9ec4c 2304 //
whismanoid 0:cb44e2e9ec4c 2305 // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses.
whismanoid 0:cb44e2e9ec4c 2306 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 2307 DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2308 //
whismanoid 0:cb44e2e9ec4c 2309 #else
whismanoid 3:9055e17e181a 2310 SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 3:9055e17e181a 2311 DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 2312 #endif
whismanoid 0:cb44e2e9ec4c 2313
whismanoid 0:cb44e2e9ec4c 2314 // example code declare GPIO interface pins
whismanoid 0:cb44e2e9ec4c 2315 // example code declare device instance
whismanoid 3:9055e17e181a 2316 MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC);
whismanoid 3:9055e17e181a 2317 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 2318
whismanoid 1:747f1602abfc 2319 //--------------------------------------------------
whismanoid 3:9055e17e181a 2320 // Option to Datalog Arduino platform analog inputs
whismanoid 3:9055e17e181a 2321 #ifndef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 2322 #define LOG_PLATFORM_AIN 6
whismanoid 3:9055e17e181a 2323 //~ #undef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 2324 #endif
whismanoid 3:9055e17e181a 2325 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 1:747f1602abfc 2326 //#ifndef NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 1:747f1602abfc 2327 //#define NUM_PLATFORM_ANALOG_IN_CHANNELS 6
whismanoid 1:747f1602abfc 2328 //#endif
whismanoid 1:747f1602abfc 2329 const int NUM_PLATFORM_ANALOG_IN_CHANNELS = 6;
whismanoid 1:747f1602abfc 2330 const double adc_full_scale_voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 2331 analogInPin_fullScaleVoltage[0], // 1.2,
whismanoid 10:04022a61b527 2332 analogInPin_fullScaleVoltage[1], // 1.2,
whismanoid 10:04022a61b527 2333 analogInPin_fullScaleVoltage[2], // 1.2,
whismanoid 10:04022a61b527 2334 analogInPin_fullScaleVoltage[3], // 1.2,
whismanoid 10:04022a61b527 2335 analogInPin_fullScaleVoltage[4], // 6.0
whismanoid 10:04022a61b527 2336 analogInPin_fullScaleVoltage[5], // 6.0
whismanoid 0:cb44e2e9ec4c 2337 };
whismanoid 9:45f98573eb6d 2338 // Platform ADC individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 9:45f98573eb6d 2339 typedef enum Platform_AIN_Enable_t {
whismanoid 9:45f98573eb6d 2340 Platform_AIN_Disable = 0,
whismanoid 9:45f98573eb6d 2341 Platform_AIN_Enable_LSB = 1,
whismanoid 9:45f98573eb6d 2342 Platform_AIN_Enable_Volt = 2,
whismanoid 9:45f98573eb6d 2343 } Platform_AIN_Enable_t;
whismanoid 13:184a08909405 2344 uint8_t Platform_Enable_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 9:45f98573eb6d 2345 Platform_AIN_Enable_Volt, // AIN0 2=Volt
whismanoid 9:45f98573eb6d 2346 Platform_AIN_Enable_Volt, // AIN1 2=Volt
whismanoid 9:45f98573eb6d 2347 Platform_AIN_Enable_Volt, // AIN2 2=Volt
whismanoid 9:45f98573eb6d 2348 Platform_AIN_Enable_Volt, // AIN3 2=Volt
whismanoid 9:45f98573eb6d 2349 Platform_AIN_Enable_Volt, // AIN4 2=Volt
whismanoid 9:45f98573eb6d 2350 Platform_AIN_Enable_Volt, // AIN5 2=Volt
whismanoid 9:45f98573eb6d 2351 };
whismanoid 13:184a08909405 2352 #ifndef HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 2353 #define HAS_Platform_AIN_customChannelHeader 1
whismanoid 13:184a08909405 2354 #endif
whismanoid 13:184a08909405 2355 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2356 const char* const Platform_AIN_customChannelHeader_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 2357 "=AIN4", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 2358 "=AIN5", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 2359 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 2360 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 2361 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 2362 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 2363 };
whismanoid 13:184a08909405 2364 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 1:747f1602abfc 2365 //--------------------------------------------------
whismanoid 1:747f1602abfc 2366 // Option to log platform analog inputs as raw LSB code
whismanoid 1:747f1602abfc 2367 #ifndef LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 2368 #define LOG_PLATFORM_ANALOG_IN_LSB 0
whismanoid 1:747f1602abfc 2369 #endif
whismanoid 1:747f1602abfc 2370 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 2371 int Platform_LSB[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 2372 #endif
whismanoid 1:747f1602abfc 2373
whismanoid 1:747f1602abfc 2374 //--------------------------------------------------
whismanoid 1:747f1602abfc 2375 // Option to use platform analog inputs as Voltage
whismanoid 1:747f1602abfc 2376 #ifndef LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 2377 #define LOG_PLATFORM_ANALOG_IN_VOLTS 1
whismanoid 1:747f1602abfc 2378 #endif
whismanoid 1:747f1602abfc 2379 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 2380 double Platform_Voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 2381 #endif
whismanoid 3:9055e17e181a 2382 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 0:cb44e2e9ec4c 2383
whismanoid 10:04022a61b527 2384 //--------------------------------------------------
whismanoid 10:04022a61b527 2385 // Option to use Command forwarding to Auxiliary serial port
whismanoid 10:04022a61b527 2386 // Command forwarding to Auxiliary serial port TX/RX
whismanoid 10:04022a61b527 2387 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial
whismanoid 10:04022a61b527 2388 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial
whismanoid 10:04022a61b527 2389 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 2390 #ifndef USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2391 #define USE_AUX_SERIAL_CMD_FORWARDING 1
whismanoid 10:04022a61b527 2392 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2393 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2394 // Command forwarding to Auxiliary serial port TX/RX #257 -- global parameters
whismanoid 10:04022a61b527 2395 const size_t RX_STRING_BUF_SIZE = 1000;
whismanoid 10:04022a61b527 2396 int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 2397 // transmit command string by AUX TX
whismanoid 10:04022a61b527 2398 #if 0
whismanoid 10:04022a61b527 2399 int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 2400 int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 2401 int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 2402 #endif
whismanoid 10:04022a61b527 2403 // capture received string from AUX RX
whismanoid 10:04022a61b527 2404 Timer g_auxSerialCom_Timer;
whismanoid 10:04022a61b527 2405 int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 2406 int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 2407 int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 2408 int g_auxSerialCom_rx_idle_ms = 500; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 2409 int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 2410 const int aux_serial_cmd_forwarding_rx_eot_not_used = 'x';
whismanoid 10:04022a61b527 2411 int g_auxSerialCom_rx_eot = aux_serial_cmd_forwarding_rx_eot_not_used; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 2412 //~ int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text string?
whismanoid 10:04022a61b527 2413 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2414 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2415 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257
whismanoid 10:04022a61b527 2416 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 2417 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2418 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2419 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2420 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 2421 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2422 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 2423 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2424 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2425 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2426 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2427 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2428 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 2429 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2430 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2431
whismanoid 8:dffee7509bfb 2432 // CODE GENERATOR: example code for ADC: serial port declaration
whismanoid 8:dffee7509bfb 2433 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2434 // Declare the Serial driver
whismanoid 8:dffee7509bfb 2435 // default baud rate settings are 9600 8N1
whismanoid 8:dffee7509bfb 2436 // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
whismanoid 8:dffee7509bfb 2437 // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
whismanoid 8:dffee7509bfb 2438 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2439 #if defined(TARGET_MAX32630)
whismanoid 8:dffee7509bfb 2440 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 2441 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2442 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2443 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 2444 //
whismanoid 8:dffee7509bfb 2445 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2446 Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2447 //Serial J3AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 2448 //Serial BTAUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 2449 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 2450 //
whismanoid 8:dffee7509bfb 2451 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2452 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2453 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2454 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2455 //
whismanoid 8:dffee7509bfb 2456 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2457 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2458 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2459 USBSerial serial;
whismanoid 8:dffee7509bfb 2460 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2461 #elif defined(TARGET_MAX32625MBED)
whismanoid 8:dffee7509bfb 2462 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625MBED: P0_1,P0_0 (Arduino D1,D0)
whismanoid 8:dffee7509bfb 2463 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2464 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625MBED: P3_1,P3_0 (J15-LEDgreen,LEDred)
whismanoid 8:dffee7509bfb 2465 //
whismanoid 8:dffee7509bfb 2466 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2467 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2468 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2469 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2470 //
whismanoid 8:dffee7509bfb 2471 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2472 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2473 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2474 USBSerial serial;
whismanoid 8:dffee7509bfb 2475 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 2476 #elif defined(TARGET_MAX32625PICO)
whismanoid 8:dffee7509bfb 2477 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 2478 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625PICO: P2_1,P2_0 (underside?)
whismanoid 8:dffee7509bfb 2479 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2480 //
whismanoid 8:dffee7509bfb 2481 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2482 Serial AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 2483 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 2484 //
whismanoid 8:dffee7509bfb 2485 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2486 Serial DAPLINKserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_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 22:d6dc8a85f435 2493 //--------------------------------------------------
whismanoid 22:d6dc8a85f435 2494 #elif defined(TARGET_MAX40108DEMOP2U9)
whismanoid 22:d6dc8a85f435 2495 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 2496 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK)
whismanoid 22:d6dc8a85f435 2497 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 2498 //
whismanoid 22:d6dc8a85f435 2499 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial is used as main serial port in MAX40108 Demo board
whismanoid 22:d6dc8a85f435 2500 Serial serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX40108DEMOP2U9: P0_1,P0_0 (J90.1/J90.0 to console)
whismanoid 22:d6dc8a85f435 2501 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 2502 //
whismanoid 22:d6dc8a85f435 2503 // Hardware serial port over DAPLink
whismanoid 22:d6dc8a85f435 2504 // connection to external MAX32625PICO(DAPLINK) needed TX/RX swap in firmware.
whismanoid 22:d6dc8a85f435 2505 // MAX32625PICO(DAPLINK) drives DAPLINK.8, listens on DAPLINK.6.
whismanoid 22:d6dc8a85f435 2506 // See AN6350 MAX32625 Users Guide 7.5.2.3.1 TX and RX Pin Mapping for UART 1 -- Mapping Option B
whismanoid 22:d6dc8a85f435 2507 //Serial DAPLINKserial(UART1_TX,UART1_RX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option A (normal)
whismanoid 22:d6dc8a85f435 2508 Serial DAPLINKserial(UART1_RX,UART1_TX); // tx,rx UART1 MAX40108DEMOP2U9: P2_1,P2_0 (DAPLINK) Mapping Option B (TX/RX-swap)
whismanoid 22:d6dc8a85f435 2509 #define HAS_DAPLINK_SERIAL 1
whismanoid 22:d6dc8a85f435 2510 //
whismanoid 22:d6dc8a85f435 2511 // Serial AUXserial(UART1_TX,UART1_RX); // tx,rx UART2 MAX40108DEMOP2U9: P3_1,P3_0 (unavailable)
whismanoid 22:d6dc8a85f435 2512 // #define HAS_AUX_SERIAL 1
whismanoid 22:d6dc8a85f435 2513 //
whismanoid 22:d6dc8a85f435 2514 // Virtual serial port over USB
whismanoid 22:d6dc8a85f435 2515 // #include "USBSerial.h"
whismanoid 22:d6dc8a85f435 2516 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 22:d6dc8a85f435 2517 //USBSerial serial;
whismanoid 8:dffee7509bfb 2518 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2519 #elif defined(TARGET_MAX32620FTHR)
whismanoid 8:dffee7509bfb 2520 #warning "TARGET_MAX32620FTHR not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 2521 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 2522 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32620FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2523 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2524 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 2525 //
whismanoid 8:dffee7509bfb 2526 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2527 Serial serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2528 //Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2529 Serial AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 2530 //Serial PMOD0AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 2531 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 2532 //
whismanoid 8:dffee7509bfb 2533 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2534 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2535 Serial DAPLINKserial(USBTX, USBRX); // tx,rx MAX32620FTHR: P2_1,P2_0
whismanoid 8:dffee7509bfb 2536 //Serial DAPLINKserial(STDIO_UART_TX, STDIO_UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 2537 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2538 //
whismanoid 8:dffee7509bfb 2539 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2540 // #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2541 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2542 //USBSerial serial; // MAX32620FTHR: USBSerial crash??
whismanoid 8:dffee7509bfb 2543 #warning "TARGET_MAX32620FTHR not previously tested; USBSerial crash?"
whismanoid 8:dffee7509bfb 2544 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2545 #elif defined(TARGET_MAX32600)
whismanoid 8:dffee7509bfb 2546 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 2547 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART2 MAX32625MBED: P1_3,P1_2 (Arduino D3,D2)
whismanoid 8:dffee7509bfb 2548 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART1 MAX32625MBED: P7_3,P7_2 ( ?? )
whismanoid 8:dffee7509bfb 2549 //
whismanoid 8:dffee7509bfb 2550 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2551 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2552 Serial DAPLINKserial(P1_1,P1_0); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 2553 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2554 //
whismanoid 8:dffee7509bfb 2555 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2556 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2557 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2558 USBSerial serial;
whismanoid 8:dffee7509bfb 2559 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2560 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 8:dffee7509bfb 2561 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 2562 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2563 #else
whismanoid 8:dffee7509bfb 2564 #if defined(SERIAL_TX)
whismanoid 8:dffee7509bfb 2565 #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..."
whismanoid 8:dffee7509bfb 2566 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 2567 #elif defined(USBTX)
whismanoid 8:dffee7509bfb 2568 #warning "target not previously tested; guess serial pins are USBTX, USBRX..."
whismanoid 8:dffee7509bfb 2569 Serial serial(USBTX, USBRX); // tx, rx
whismanoid 8:dffee7509bfb 2570 #elif defined(UART_TX)
whismanoid 8:dffee7509bfb 2571 #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..."
whismanoid 8:dffee7509bfb 2572 Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 2573 #else
whismanoid 8:dffee7509bfb 2574 #warning "target not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 2575 #endif
whismanoid 8:dffee7509bfb 2576 #endif
whismanoid 8:dffee7509bfb 2577 //
whismanoid 8:dffee7509bfb 2578 #include "CmdLine.h"
whismanoid 8:dffee7509bfb 2579
whismanoid 8:dffee7509bfb 2580 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 2581 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2582 CmdLine cmdLine_AUXserial(AUXserial, "AUXserial");
whismanoid 10:04022a61b527 2583 uint8_t Datalogger_enable_AUXserial = {
whismanoid 10:04022a61b527 2584 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2585 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 2586 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 2587 false
whismanoid 10:04022a61b527 2588 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2589 true
whismanoid 10:04022a61b527 2590 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2591 };
whismanoid 8:dffee7509bfb 2592 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 2593 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 2594 CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK");
whismanoid 8:dffee7509bfb 2595 uint8_t Datalogger_enable_DAPLINKserial = true;
whismanoid 8:dffee7509bfb 2596 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 2597 CmdLine cmdLine(serial, "serial");
whismanoid 8:dffee7509bfb 2598 uint8_t Datalogger_enable_serial = true;
whismanoid 8:dffee7509bfb 2599 // CODE GENERATOR: example code for ADC: serial port declaration (end)
whismanoid 8:dffee7509bfb 2600
whismanoid 21:ac062a97a71d 2601
whismanoid 21:ac062a97a71d 2602 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 2603 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 2604 #ifndef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 2605 #define USE_DATALOGGER_CommandTable 1
whismanoid 23:c6c652bef4b9 2606 //~ #undef USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 2607 #endif
whismanoid 23:c6c652bef4b9 2608 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 2609 const int COMMAND_TABLE_ROW_MAX = 10;
whismanoid 23:c6c652bef4b9 2610 const int COMMAND_TABLE_COL_MAX = 40;
whismanoid 23:c6c652bef4b9 2611 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 2612 //
whismanoid 23:c6c652bef4b9 2613 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 2614 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 2615 // command_table: list of commands to perform on button press
whismanoid 24:032f3683cb2a 2616 char onButton1_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button1 command table";
whismanoid 23:c6c652bef4b9 2617 char onButton1_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 23:c6c652bef4b9 2618 char onButton1_command_table_02[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 23:c6c652bef4b9 2619 char onButton1_command_table_03[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 23:c6c652bef4b9 2620 char onButton1_command_table_04[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 23:c6c652bef4b9 2621 char onButton1_command_table_05[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 23:c6c652bef4b9 2622 char onButton1_command_table_06[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 23:c6c652bef4b9 2623 char onButton1_command_table_07[COMMAND_TABLE_COL_MAX] = "LR";
whismanoid 23:c6c652bef4b9 2624 char onButton1_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2625 char onButton1_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2626 static char* onButton1_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 2627 onButton1_command_table_00,
whismanoid 23:c6c652bef4b9 2628 onButton1_command_table_01,
whismanoid 23:c6c652bef4b9 2629 onButton1_command_table_02,
whismanoid 23:c6c652bef4b9 2630 onButton1_command_table_03,
whismanoid 23:c6c652bef4b9 2631 onButton1_command_table_04,
whismanoid 23:c6c652bef4b9 2632 onButton1_command_table_05,
whismanoid 23:c6c652bef4b9 2633 onButton1_command_table_06,
whismanoid 23:c6c652bef4b9 2634 onButton1_command_table_07,
whismanoid 23:c6c652bef4b9 2635 onButton1_command_table_08,
whismanoid 23:c6c652bef4b9 2636 onButton1_command_table_09,
whismanoid 23:c6c652bef4b9 2637 };
whismanoid 23:c6c652bef4b9 2638 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 2639 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 2640 // command_table: list of commands to perform on button press
whismanoid 24:032f3683cb2a 2641 char onButton2_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button2 command table";
whismanoid 23:c6c652bef4b9 2642 char onButton2_command_table_01[COMMAND_TABLE_COL_MAX] = "%H91";
whismanoid 23:c6c652bef4b9 2643 char onButton2_command_table_02[COMMAND_TABLE_COL_MAX] = "%H92";
whismanoid 23:c6c652bef4b9 2644 char onButton2_command_table_03[COMMAND_TABLE_COL_MAX] = "%L93";
whismanoid 23:c6c652bef4b9 2645 char onButton2_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2646 char onButton2_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2647 char onButton2_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2648 char onButton2_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2649 char onButton2_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2650 char onButton2_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 23:c6c652bef4b9 2651 static char* onButton2_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 23:c6c652bef4b9 2652 onButton2_command_table_00,
whismanoid 23:c6c652bef4b9 2653 onButton2_command_table_01,
whismanoid 23:c6c652bef4b9 2654 onButton2_command_table_02,
whismanoid 23:c6c652bef4b9 2655 onButton2_command_table_03,
whismanoid 23:c6c652bef4b9 2656 onButton2_command_table_04,
whismanoid 23:c6c652bef4b9 2657 onButton2_command_table_05,
whismanoid 23:c6c652bef4b9 2658 onButton2_command_table_06,
whismanoid 23:c6c652bef4b9 2659 onButton2_command_table_07,
whismanoid 23:c6c652bef4b9 2660 onButton2_command_table_08,
whismanoid 23:c6c652bef4b9 2661 onButton2_command_table_09,
whismanoid 23:c6c652bef4b9 2662 };
whismanoid 23:c6c652bef4b9 2663 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 2664 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 2665 // command_table: list of commands to perform on button press
whismanoid 24:032f3683cb2a 2666 char onButton3_command_table_00[COMMAND_TABLE_COL_MAX] = "# Button3 command table";
whismanoid 24:032f3683cb2a 2667 char onButton3_command_table_01[COMMAND_TABLE_COL_MAX] = "%L91";
whismanoid 24:032f3683cb2a 2668 char onButton3_command_table_02[COMMAND_TABLE_COL_MAX] = "%L92";
whismanoid 24:032f3683cb2a 2669 char onButton3_command_table_03[COMMAND_TABLE_COL_MAX] = "%H93";
whismanoid 24:032f3683cb2a 2670 char onButton3_command_table_04[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 2671 char onButton3_command_table_05[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 2672 char onButton3_command_table_06[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 2673 char onButton3_command_table_07[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 2674 char onButton3_command_table_08[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 2675 char onButton3_command_table_09[COMMAND_TABLE_COL_MAX] = "";
whismanoid 24:032f3683cb2a 2676 static char* onButton3_command_table[COMMAND_TABLE_ROW_MAX] = {
whismanoid 24:032f3683cb2a 2677 onButton3_command_table_00,
whismanoid 24:032f3683cb2a 2678 onButton3_command_table_01,
whismanoid 24:032f3683cb2a 2679 onButton3_command_table_02,
whismanoid 24:032f3683cb2a 2680 onButton3_command_table_03,
whismanoid 24:032f3683cb2a 2681 onButton3_command_table_04,
whismanoid 24:032f3683cb2a 2682 onButton3_command_table_05,
whismanoid 24:032f3683cb2a 2683 onButton3_command_table_06,
whismanoid 24:032f3683cb2a 2684 onButton3_command_table_07,
whismanoid 24:032f3683cb2a 2685 onButton3_command_table_08,
whismanoid 24:032f3683cb2a 2686 onButton3_command_table_09,
whismanoid 24:032f3683cb2a 2687 };
whismanoid 24:032f3683cb2a 2688 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 2689 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 2690 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 2691 #if USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 2692 void Run_command_table(char* command_table[])
whismanoid 23:c6c652bef4b9 2693 {
whismanoid 23:c6c652bef4b9 2694 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 2695 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 2696 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 2697 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 23:c6c652bef4b9 2698 cmdLine.clear();
whismanoid 23:c6c652bef4b9 2699 //~ char* strIndex = command_table[lineIndex];
whismanoid 23:c6c652bef4b9 2700 for (char* strIndex = command_table[lineIndex]; *strIndex != '\0'; strIndex++)
whismanoid 23:c6c652bef4b9 2701 {
whismanoid 23:c6c652bef4b9 2702 cmdLine.append(*strIndex);
whismanoid 23:c6c652bef4b9 2703 }
whismanoid 23:c6c652bef4b9 2704 cmdLine.append('\r'); // append \r invokes onEOLcommandParser to handle command
whismanoid 23:c6c652bef4b9 2705 }
whismanoid 23:c6c652bef4b9 2706 }
whismanoid 23:c6c652bef4b9 2707 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 2708 //--------------------------------------------------
whismanoid 21:ac062a97a71d 2709 // When user presses button BUTTON1, perform actions
whismanoid 21:ac062a97a71d 2710 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 2711 void onButton1FallingEdge(void)
whismanoid 21:ac062a97a71d 2712 {
whismanoid 21:ac062a97a71d 2713 //~ void SelfTest(CmdLine & cmdLine);
whismanoid 21:ac062a97a71d 2714 //~ SelfTest(cmdLine_serial);
whismanoid 22:d6dc8a85f435 2715 //
whismanoid 23:c6c652bef4b9 2716 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 2717 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 2718 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 2719 Run_command_table(onButton1_command_table);
whismanoid 23:c6c652bef4b9 2720 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 2721 }
whismanoid 21:ac062a97a71d 2722 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 2723
whismanoid 21:ac062a97a71d 2724 //--------------------------------------------------
whismanoid 21:ac062a97a71d 2725 // When user presses button BUTTON2, perform actions
whismanoid 21:ac062a97a71d 2726 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 2727 void onButton2FallingEdge(void)
whismanoid 21:ac062a97a71d 2728 {
whismanoid 21:ac062a97a71d 2729 // TBD demo configuration
whismanoid 21:ac062a97a71d 2730 // TODO diagnostic LED
whismanoid 21:ac062a97a71d 2731 // led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 22:d6dc8a85f435 2732 //
whismanoid 23:c6c652bef4b9 2733 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 22:d6dc8a85f435 2734 // command_table: list of commands to perform on button press
whismanoid 22:d6dc8a85f435 2735 // command_table: perform list of commands
whismanoid 23:c6c652bef4b9 2736 Run_command_table(onButton2_command_table);
whismanoid 23:c6c652bef4b9 2737 #endif // USE_DATALOGGER_CommandTable
whismanoid 21:ac062a97a71d 2738 }
whismanoid 21:ac062a97a71d 2739 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 2740
whismanoid 24:032f3683cb2a 2741 //--------------------------------------------------
whismanoid 24:032f3683cb2a 2742 // When user presses button BUTTON2, perform actions
whismanoid 24:032f3683cb2a 2743 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 2744 void onButton3FallingEdge(void)
whismanoid 24:032f3683cb2a 2745 {
whismanoid 24:032f3683cb2a 2746 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 24:032f3683cb2a 2747 // command_table: list of commands to perform on button press
whismanoid 24:032f3683cb2a 2748 // command_table: perform list of commands
whismanoid 24:032f3683cb2a 2749 Run_command_table(onButton3_command_table);
whismanoid 24:032f3683cb2a 2750 #endif // USE_DATALOGGER_CommandTable
whismanoid 24:032f3683cb2a 2751 }
whismanoid 24:032f3683cb2a 2752 #endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 2753
whismanoid 4:d9b05924ad4c 2754 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2755 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2756 inline void print_command_prompt()
whismanoid 4:d9b05924ad4c 2757 {
whismanoid 4:d9b05924ad4c 2758 //~ Serial.println(F(">"));
whismanoid 4:d9b05924ad4c 2759 cmdLine.serial().printf("\r\n> ");
whismanoid 4:d9b05924ad4c 2760 }
whismanoid 4:d9b05924ad4c 2761 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2762
whismanoid 4:d9b05924ad4c 2763 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2764 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2765 void main_menu_status(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 2766 {
whismanoid 4:d9b05924ad4c 2767 cmdLine.serial().printf("\r\nMain menu");
whismanoid 4:d9b05924ad4c 2768 #if APPLICATION_MAX5715 // main_menu_status banner
whismanoid 4:d9b05924ad4c 2769 cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC");
whismanoid 4:d9b05924ad4c 2770 #elif APPLICATION_MAX11131 // main_menu_status banner
whismanoid 4:d9b05924ad4c 2771 cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC");
whismanoid 4:d9b05924ad4c 2772 #elif APPLICATION_MAX5171 // main_menu_status banner
whismanoid 4:d9b05924ad4c 2773 cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC");
whismanoid 4:d9b05924ad4c 2774 #elif APPLICATION_MAX11410 // main_menu_status banner
whismanoid 4:d9b05924ad4c 2775 cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC");
whismanoid 4:d9b05924ad4c 2776 #elif APPLICATION_MAX12345 // main_menu_status banner
whismanoid 4:d9b05924ad4c 2777 cmdLine.serial().printf(" MAX12345");
whismanoid 16:819c5aaf5271 2778 #elif MAX40108_DEMO // main_menu_status banner
whismanoid 17:9397ea3ea7e9 2779 cmdLine.serial().printf(" MAX40108_U%d", MAX40108_DEMO);
whismanoid 4:d9b05924ad4c 2780 #else
whismanoid 4:d9b05924ad4c 2781 //cmdLine.serial().printf(" ");
whismanoid 4:d9b05924ad4c 2782 #endif
whismanoid 4:d9b05924ad4c 2783 //cmdLine.serial().printf(" %s", TARGET_NAME);
whismanoid 4:d9b05924ad4c 2784 if (cmdLine.nameStr())
whismanoid 4:d9b05924ad4c 2785 {
whismanoid 4:d9b05924ad4c 2786 cmdLine.serial().printf(" [%s]", cmdLine.nameStr());
whismanoid 4:d9b05924ad4c 2787 }
whismanoid 4:d9b05924ad4c 2788 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 2789 cmdLine.serial().printf(" [Button1]");
whismanoid 4:d9b05924ad4c 2790 #endif
whismanoid 4:d9b05924ad4c 2791 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 2792 cmdLine.serial().printf(" [Button2]");
whismanoid 24:032f3683cb2a 2793 #endif
whismanoid 24:032f3683cb2a 2794 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 2795 cmdLine.serial().printf(" [Button3]");
whismanoid 4:d9b05924ad4c 2796 #endif
whismanoid 4:d9b05924ad4c 2797 #if HAS_BUTTON1_DEMO
whismanoid 4:d9b05924ad4c 2798 // print BUTTON1 status
whismanoid 4:d9b05924ad4c 2799 cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read());
whismanoid 4:d9b05924ad4c 2800 #endif
whismanoid 4:d9b05924ad4c 2801 #if HAS_BUTTON2_DEMO
whismanoid 24:032f3683cb2a 2802 // print BUTTON2 status
whismanoid 4:d9b05924ad4c 2803 cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read());
whismanoid 4:d9b05924ad4c 2804 #endif
whismanoid 24:032f3683cb2a 2805 #if HAS_BUTTON3_DEMO
whismanoid 24:032f3683cb2a 2806 // print BUTTON3 status
whismanoid 24:032f3683cb2a 2807 cmdLine.serial().printf("\r\n BUTTON3 = %d", button3.read());
whismanoid 24:032f3683cb2a 2808 #endif
whismanoid 4:d9b05924ad4c 2809 cmdLine.serial().printf("\r\n ? -- help");
whismanoid 4:d9b05924ad4c 2810 }
whismanoid 4:d9b05924ad4c 2811 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2812
whismanoid 4:d9b05924ad4c 2813 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2814 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2815 void main_menu_help(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 2816 {
whismanoid 4:d9b05924ad4c 2817 // ? -- help
whismanoid 4:d9b05924ad4c 2818 //~ cmdLine.serial().printf("\r\nMenu:");
whismanoid 10:04022a61b527 2819 //
whismanoid 4:d9b05924ad4c 2820 cmdLine.serial().printf("\r\n # -- lines beginning with # are comments");
whismanoid 10:04022a61b527 2821 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 2822 cmdLine.serial().printf("\r\n ! -- Init");
whismanoid 10:04022a61b527 2823 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 2824 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 2825 cmdLine.serial().printf("\r\n . -- SelfTest");
whismanoid 4:d9b05924ad4c 2826 #endif // USE_SELFTEST
whismanoid 9:45f98573eb6d 2827 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 9:45f98573eb6d 2828 // CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register
whismanoid 9:45f98573eb6d 2829 cmdLine.serial().printf("\r\n * -- read core registers\r\n *regname? -- read register\r\n *regname=regvalue -- write register");
whismanoid 9:45f98573eb6d 2830 // cmdLine.serial().printf("\r\n 01 23 45 67 89 ab cd ef -- write and read raw hex codes");
whismanoid 10:04022a61b527 2831 #endif // USE_STAR_REG_READWRITE
whismanoid 10:04022a61b527 2832 //
whismanoid 10:04022a61b527 2833 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2834 // Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_help
whismanoid 10:04022a61b527 2835 //~ cmdLine.serial().printf("\r\n > -- auxiliary UART port");
whismanoid 10:04022a61b527 2836 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 2837 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2838 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2839 if (cmdLine_AUXserial.nameStr())
whismanoid 10:04022a61b527 2840 {
whismanoid 10:04022a61b527 2841 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_AUXserial.nameStr());
whismanoid 10:04022a61b527 2842 }
whismanoid 10:04022a61b527 2843 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2844 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 2845 if (cmdLine_DAPLINKserial.nameStr())
whismanoid 10:04022a61b527 2846 {
whismanoid 10:04022a61b527 2847 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_DAPLINKserial.nameStr());
whismanoid 10:04022a61b527 2848 }
whismanoid 10:04022a61b527 2849 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2850 # if HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2851 // WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2852 cmdLine.serial().printf("\r\n >xyzzy -- Forward command/data 'xyzzy' to aux TX/RX");
whismanoid 10:04022a61b527 2853 cmdLine.serial().printf("\r\n >>xyzzy -- Forward 'xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 2854 cmdLine.serial().printf("\r\n >>>xyzzy -- Forward '>xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 2855 #if 0
whismanoid 10:04022a61b527 2856 cmdLine.serial().printf("\r\n >tx_wait_echo=%d -- configure TX wait for each character echo", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 2857 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 2858 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 2859 #endif
whismanoid 20:78ef670955d4 2860 #if 1 // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 2861 cmdLine.serial().printf("\r\n >baud=%d message_ms=%d rx_idle_ms=%d rx_max_count=%d rx_eot=%d",
whismanoid 20:78ef670955d4 2862 g_auxSerialCom_baud,
whismanoid 20:78ef670955d4 2863 g_auxSerialCom_message_ms,
whismanoid 20:78ef670955d4 2864 g_auxSerialCom_rx_idle_ms,
whismanoid 20:78ef670955d4 2865 g_auxSerialCom_rx_max_count,
whismanoid 20:78ef670955d4 2866 g_auxSerialCom_rx_eot);
whismanoid 20:78ef670955d4 2867 #else // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 20:78ef670955d4 2868 cmdLine.serial().printf("\r\n >baud=%d -- configure aux TX/RX port", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 2869 cmdLine.serial().printf("\r\n >message_ms=%d -- maximum RX message total response time", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 2870 cmdLine.serial().printf("\r\n >rx_idle_ms=%d -- maximum RX message idle time between characters", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 2871 cmdLine.serial().printf("\r\n >rx_max_count=%d -- maximum RX message total length", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 2872 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 2873 #endif // HAS_AUX_SERIAL_HELP_BRIEF
whismanoid 10:04022a61b527 2874 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2875 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2876 //
whismanoid 4:d9b05924ad4c 2877 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 2878 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 2879 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 2880 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 9:45f98573eb6d 2881 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 9:45f98573eb6d 2882 //
whismanoid 17:9397ea3ea7e9 2883 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible "always-on mode"
whismanoid 4:d9b05924ad4c 2884 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 9:45f98573eb6d 2885 //
whismanoid 17:9397ea3ea7e9 2886 // Datalogger_Trigger = trigger_Timer // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 2887 //~ cmdLine.serial().printf("\r\n LT -- Datalog timer"); // trigger_Timer
whismanoid 17:9397ea3ea7e9 2888 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 2889 //
whismanoid 9:45f98573eb6d 2890 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 2891 //~ cmdLine.serial().printf("\r\n LI -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 2892 // TODO: cmdLine.serial().printf("\r\n LIH3 -- Datalog when input high D3"); // trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 2893 // TODO: cmdLine.serial().printf("\r\n LIL6 -- Datalog when input low D6"); // trigger_PlatformDigitalInput
whismanoid 9:45f98573eb6d 2894 //
whismanoid 17:9397ea3ea7e9 2895 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 9:45f98573eb6d 2896 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 2897 //~ cmdLine.serial().printf("\r\n L$ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2898 cmdLine.serial().printf("\r\n L$regaddr@dataMask=testValue -- Datalog when SPI read of address matches mask"); // trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2899 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 2900 //
whismanoid 17:9397ea3ea7e9 2901 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 2902 cmdLine.serial().printf("\r\n L@ -- configures Datalogger_action_table");
whismanoid 17:9397ea3ea7e9 2903 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 9:45f98573eb6d 2904 //
whismanoid 9:45f98573eb6d 2905 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 2906 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 2907 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 2908 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 2909 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 9:45f98573eb6d 2910 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 9:45f98573eb6d 2911 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 9:45f98573eb6d 2912 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 9:45f98573eb6d 2913 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 9:45f98573eb6d 2914 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 9:45f98573eb6d 2915 //
whismanoid 9:45f98573eb6d 2916 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 2917 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 9:45f98573eb6d 2918 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 9:45f98573eb6d 2919 //
whismanoid 9:45f98573eb6d 2920 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 2921 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 2922 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 9:45f98573eb6d 2923 //
whismanoid 9:45f98573eb6d 2924 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 2925 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 9:45f98573eb6d 2926 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 2927 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 9:45f98573eb6d 2928 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 2929 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 9:45f98573eb6d 2930 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 2931 //
whismanoid 9:45f98573eb6d 2932 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 2933 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 9:45f98573eb6d 2934 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 9:45f98573eb6d 2935 //
whismanoid 9:45f98573eb6d 2936 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 2937 //
whismanoid 9:45f98573eb6d 2938 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 2939 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 2940 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 2941 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 2942 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 9:45f98573eb6d 2943 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 2944 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 9:45f98573eb6d 2945 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 2946 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 2947 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 9:45f98573eb6d 2948 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 2949 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 9:45f98573eb6d 2950 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 2951 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 9:45f98573eb6d 2952 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 2953 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 2954 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 9:45f98573eb6d 2955 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 2956 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 4:d9b05924ad4c 2957 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 8:dffee7509bfb 2958 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 2959 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 2960 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 2961 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 2962 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 2963 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 2964 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 8:dffee7509bfb 2965 //
whismanoid 4:d9b05924ad4c 2966 //cmdLine.serial().print(F("\r\n ! -- Initial Configuration"));
whismanoid 4:d9b05924ad4c 2967 //
whismanoid 4:d9b05924ad4c 2968 // % standardize diagnostic commands
whismanoid 4:d9b05924ad4c 2969 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 2970 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 2971 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 2972 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 2973 // %Ppin df=xx -- pwm output
whismanoid 4:d9b05924ad4c 2974 // %Wpin -- measure high pulsewidth input in usec
whismanoid 4:d9b05924ad4c 2975 // %wpin -- measure low pulsewidth input in usec
whismanoid 4:d9b05924ad4c 2976 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 2977 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 2978 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 2979 // %IW ADDR=? cmd=? data,data,data -- write
whismanoid 4:d9b05924ad4c 2980 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 2981 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 2982 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 2983 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 2984 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 2985 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 2986 // A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 2987 //
whismanoid 23:c6c652bef4b9 2988 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 2989 #if USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 2990 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 2991 // TODO: %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 2992 // TODO: future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 2993 // TODO: future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 2994 // TODO: %B1@ view command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 2995 // TODO: %B1@+ command add new row (if there is room to add) (ignore one space before command)
whismanoid 23:c6c652bef4b9 2996 // TODO: %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 2997 // TODO: %B1@-~~~ clear entire command table
whismanoid 23:c6c652bef4b9 2998 // TODO: %B1@nnn command replace row number nnn (ignore one space before command)
whismanoid 23:c6c652bef4b9 2999 // TODO: %B1@! disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 3000 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 3001 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 23:c6c652bef4b9 3002 cmdLine.serial().printf("\r\n %%B1! trigger Button1; %%B1@ -- view/edit command table");
whismanoid 23:c6c652bef4b9 3003 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3004 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3005 #if HAS_digitalInOuts
whismanoid 4:d9b05924ad4c 3006 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 3007 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 3008 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 3009 cmdLine.serial().printf("\r\n %%Hn {pin:");
whismanoid 4:d9b05924ad4c 3010 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3011 cmdLine.serial().printf("} -- High Output");
whismanoid 4:d9b05924ad4c 3012 cmdLine.serial().printf("\r\n %%Ln {pin:");
whismanoid 4:d9b05924ad4c 3013 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3014 cmdLine.serial().printf("} -- Low Output");
whismanoid 4:d9b05924ad4c 3015 cmdLine.serial().printf("\r\n %%?n {pin:");
whismanoid 4:d9b05924ad4c 3016 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 3017 cmdLine.serial().printf("} -- Input");
whismanoid 4:d9b05924ad4c 3018 #endif
whismanoid 4:d9b05924ad4c 3019
whismanoid 4:d9b05924ad4c 3020 #if HAS_analogIns
whismanoid 4:d9b05924ad4c 3021 // Menu A) analogRead A0..7
whismanoid 4:d9b05924ad4c 3022 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 3023 // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0)
whismanoid 4:d9b05924ad4c 3024 cmdLine.serial().printf("\r\n %%A -- analogRead");
whismanoid 4:d9b05924ad4c 3025 #endif
whismanoid 4:d9b05924ad4c 3026
whismanoid 4:d9b05924ad4c 3027 #if HAS_SPI2_MAX541
whismanoid 4:d9b05924ad4c 3028 // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 4:d9b05924ad4c 3029 cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)");
whismanoid 4:d9b05924ad4c 3030 #endif
whismanoid 4:d9b05924ad4c 3031
whismanoid 4:d9b05924ad4c 3032 #if HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3033 // TODO: support I2C HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3034 // VERIFY: I2C utility commands SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3035 // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz);
whismanoid 4:d9b05924ad4c 3036 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 3037 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 3038 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 3039 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 4:d9b05924ad4c 3040 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 3041 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3042 //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope
whismanoid 4:d9b05924ad4c 3043 cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 4:d9b05924ad4c 3044 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 4:d9b05924ad4c 3045 (g_I2C_SCL_Hz / 1000.));
whismanoid 4:d9b05924ad4c 3046 cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read",
whismanoid 4:d9b05924ad4c 3047 g_I2C_deviceAddress7);
whismanoid 4:d9b05924ad4c 3048 //
whismanoid 4:d9b05924ad4c 3049 #if SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3050 // Menu ^ cmd=?) i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3051 cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data");
whismanoid 4:d9b05924ad4c 3052 // test low-level I2C i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 3053 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3054 //cmdLine.serial().printf(" H) Hunt for attached I2C devices");
whismanoid 4:d9b05924ad4c 3055 cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices");
whismanoid 4:d9b05924ad4c 3056 // cmdLine.serial().printf(" s) search i2c address");
whismanoid 4:d9b05924ad4c 3057 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 3058
whismanoid 4:d9b05924ad4c 3059 #if HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3060 // TODO: support SPI HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3061 // SPI test command S (mosiData)+
whismanoid 4:d9b05924ad4c 3062 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 3063 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 3064 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 3065 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 3066 // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 4:d9b05924ad4c 3067 // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 4:d9b05924ad4c 3068 // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 4:d9b05924ad4c 3069 // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 4:d9b05924ad4c 3070 // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 4:d9b05924ad4c 3071 // mode | POL PHA
whismanoid 4:d9b05924ad4c 3072 // -----+--------
whismanoid 4:d9b05924ad4c 3073 // 0 | 0 0
whismanoid 4:d9b05924ad4c 3074 // 1 | 0 1
whismanoid 4:d9b05924ad4c 3075 // 2 | 1 0
whismanoid 4:d9b05924ad4c 3076 // 3 | 1 1
whismanoid 4:d9b05924ad4c 3077 //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0");
whismanoid 4:d9b05924ad4c 3078 // 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 3079 cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config",
whismanoid 4:d9b05924ad4c 3080 g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.),
whismanoid 4:d9b05924ad4c 3081 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 4:d9b05924ad4c 3082 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0));
whismanoid 4:d9b05924ad4c 3083 cmdLine.serial().printf("\r\n %%SD -- SPI diagnostic messages ");
whismanoid 4:d9b05924ad4c 3084 if (g_MAX11410_device.onSPIprint) {
whismanoid 4:d9b05924ad4c 3085 cmdLine.serial().printf("hide");
whismanoid 4:d9b05924ad4c 3086 }
whismanoid 4:d9b05924ad4c 3087 else {
whismanoid 4:d9b05924ad4c 3088 cmdLine.serial().printf("show");
whismanoid 4:d9b05924ad4c 3089 }
whismanoid 4:d9b05924ad4c 3090 cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes");
whismanoid 4:d9b05924ad4c 3091 // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0
whismanoid 4:d9b05924ad4c 3092 #endif // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 3093 //
whismanoid 4:d9b05924ad4c 3094 // Application-specific commands (help text) here
whismanoid 4:d9b05924ad4c 3095 //
whismanoid 4:d9b05924ad4c 3096 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3097 cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3098 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3099 //
whismanoid 4:d9b05924ad4c 3100
whismanoid 4:d9b05924ad4c 3101 //~ extern void MAX11410_menu_help(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp\n
whismanoid 4:d9b05924ad4c 3102 //~ MAX11410_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 3103 }
whismanoid 4:d9b05924ad4c 3104 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3105
whismanoid 4:d9b05924ad4c 3106 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 15:37c83ec50ea0 3107
whismanoid 15:37c83ec50ea0 3108 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 3109 void pinsMonitor_submenu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 15:37c83ec50ea0 3110 {
whismanoid 15:37c83ec50ea0 3111 // % diagnostic commands submenu
whismanoid 15:37c83ec50ea0 3112 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 3113 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 3114 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 3115 // %A %Apin -- analog input
whismanoid 15:37c83ec50ea0 3116 // %Ppin df=xx -- pwm output
whismanoid 15:37c83ec50ea0 3117 // %Wpin -- measure high pulsewidth input in usec
whismanoid 15:37c83ec50ea0 3118 // %wpin -- measure low pulsewidth input in usec
whismanoid 15:37c83ec50ea0 3119 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 3120 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 3121 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 3122 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 3123 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 3124 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 3125 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 3126 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 3127 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 3128 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 3129 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 3130 //
whismanoid 15:37c83ec50ea0 3131 char strPinIndex[3];
whismanoid 15:37c83ec50ea0 3132 strPinIndex[0] = cmdLine[2];
whismanoid 15:37c83ec50ea0 3133 strPinIndex[1] = cmdLine[3];
whismanoid 15:37c83ec50ea0 3134 strPinIndex[2] = '\0';
whismanoid 15:37c83ec50ea0 3135 int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 15:37c83ec50ea0 3136 //cmdLine.serial().printf(" pinIndex=%d ", pinIndex);
whismanoid 15:37c83ec50ea0 3137 //
whismanoid 15:37c83ec50ea0 3138 // get next character
whismanoid 15:37c83ec50ea0 3139 switch (cmdLine[1])
whismanoid 15:37c83ec50ea0 3140 {
whismanoid 23:c6c652bef4b9 3141 //--------------------------------------------------
whismanoid 23:c6c652bef4b9 3142 #if USE_DATALOGGER_CommandTable // Run_command_table(onButton1_command_table)
whismanoid 23:c6c652bef4b9 3143 // command_table: list of commands to perform on button press
whismanoid 23:c6c652bef4b9 3144 case 'B': case 'b':
whismanoid 23:c6c652bef4b9 3145 {
whismanoid 24:032f3683cb2a 3146 int command_table_button_index = 1;
whismanoid 23:c6c652bef4b9 3147 // %B1 submenu for Button1
whismanoid 23:c6c652bef4b9 3148 // future: %B2 submenu for Button2
whismanoid 23:c6c652bef4b9 3149 // future: %B3 submenu for Button3
whismanoid 23:c6c652bef4b9 3150 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 23:c6c652bef4b9 3151 // cmdLine[2] == '1' selects onButton1_command_table
whismanoid 23:c6c652bef4b9 3152 char** command_table = onButton1_command_table;
whismanoid 23:c6c652bef4b9 3153 #endif
whismanoid 24:032f3683cb2a 3154 switch(cmdLine[2])
whismanoid 24:032f3683cb2a 3155 {
whismanoid 24:032f3683cb2a 3156 default:
whismanoid 24:032f3683cb2a 3157 case '1': case 'A': case 'a': case '!':
whismanoid 24:032f3683cb2a 3158 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3159 command_table_button_index = 1;
whismanoid 24:032f3683cb2a 3160 command_table = onButton1_command_table;
whismanoid 24:032f3683cb2a 3161 #endif
whismanoid 24:032f3683cb2a 3162 break;
whismanoid 24:032f3683cb2a 3163 case '2': case 'B': case 'b': case '@':
whismanoid 23:c6c652bef4b9 3164 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3165 command_table_button_index = 2;
whismanoid 24:032f3683cb2a 3166 command_table = onButton2_command_table;
whismanoid 24:032f3683cb2a 3167 #endif
whismanoid 24:032f3683cb2a 3168 break;
whismanoid 24:032f3683cb2a 3169 case '3': case 'C': case 'c': case '#':
whismanoid 23:c6c652bef4b9 3170 #if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 3171 command_table_button_index = 3;
whismanoid 24:032f3683cb2a 3172 command_table = onButton3_command_table;
whismanoid 24:032f3683cb2a 3173 #endif
whismanoid 24:032f3683cb2a 3174 break;
whismanoid 24:032f3683cb2a 3175 }
whismanoid 24:032f3683cb2a 3176 //
whismanoid 23:c6c652bef4b9 3177 switch(cmdLine[3])
whismanoid 23:c6c652bef4b9 3178 {
whismanoid 23:c6c652bef4b9 3179 case '@':
whismanoid 23:c6c652bef4b9 3180 {
whismanoid 23:c6c652bef4b9 3181 // %B1@ view/edit command table, similar to L@ for action table
whismanoid 23:c6c652bef4b9 3182 int editRowIndex = 0;
whismanoid 23:c6c652bef4b9 3183 int command_table_row_count = 0;
whismanoid 23:c6c652bef4b9 3184 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 3185 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 3186 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 3187 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 3188 }
whismanoid 24:032f3683cb2a 3189 //
whismanoid 24:032f3683cb2a 3190 // ignore extra spaces before the command
whismanoid 24:032f3683cb2a 3191 // find argIndex such that cmdLine[argIndex] is the start of the second word
whismanoid 24:032f3683cb2a 3192 int argIndex;
whismanoid 24:032f3683cb2a 3193 for (argIndex = 5; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 3194 {
whismanoid 24:032f3683cb2a 3195 if (cmdLine[argIndex] == ' ') break;
whismanoid 24:032f3683cb2a 3196 }
whismanoid 24:032f3683cb2a 3197 for (; cmdLine[argIndex] != '\0'; argIndex++)
whismanoid 24:032f3683cb2a 3198 {
whismanoid 24:032f3683cb2a 3199 if (cmdLine[argIndex] != ' ') break;
whismanoid 23:c6c652bef4b9 3200 }
whismanoid 23:c6c652bef4b9 3201 //
whismanoid 23:c6c652bef4b9 3202 // Edit the contents of command_table
whismanoid 23:c6c652bef4b9 3203 switch (cmdLine[4]) // %B1@... -- Edit the contents of command_table
whismanoid 23:c6c652bef4b9 3204 {
whismanoid 23:c6c652bef4b9 3205 case '0': case '1': case '2': case '3': case '4':
whismanoid 23:c6c652bef4b9 3206 case '5': case '6': case '7': case '8': case '9':
whismanoid 24:032f3683cb2a 3207 // %B1@nnn command replace row number nnn
whismanoid 23:c6c652bef4b9 3208 // edit row data
whismanoid 23:c6c652bef4b9 3209 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 3210 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 23:c6c652bef4b9 3211 // get row number to edit from cmdLine[4]
whismanoid 23:c6c652bef4b9 3212 editRowIndex = atoi(cmdLine.str()+4);
whismanoid 24:032f3683cb2a 3213 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 24:032f3683cb2a 3214 // update row
whismanoid 24:032f3683cb2a 3215 cmdLine.serial().printf("\r\n replace row %d with \"%s\"",
whismanoid 24:032f3683cb2a 3216 editRowIndex, cmdLine.str()+argIndex);
whismanoid 24:032f3683cb2a 3217 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 24:032f3683cb2a 3218 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0';
whismanoid 24:032f3683cb2a 3219 }
whismanoid 23:c6c652bef4b9 3220 }
whismanoid 23:c6c652bef4b9 3221 break;
whismanoid 23:c6c652bef4b9 3222 case '+':
whismanoid 24:032f3683cb2a 3223 // %B1@+ command add new row (if there is room to add)
whismanoid 23:c6c652bef4b9 3224 // add a new row at end of table
whismanoid 23:c6c652bef4b9 3225 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 3226 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 23:c6c652bef4b9 3227 editRowIndex = command_table_row_count;
whismanoid 23:c6c652bef4b9 3228 command_table_row_count++;
whismanoid 24:032f3683cb2a 3229 cmdLine.serial().printf("\r\n add new row %d containing \"%s\"",
whismanoid 24:032f3683cb2a 3230 editRowIndex, cmdLine.str()+argIndex);
whismanoid 24:032f3683cb2a 3231 strncpy(command_table[editRowIndex], cmdLine.str()+argIndex, COMMAND_TABLE_COL_MAX-1);
whismanoid 23:c6c652bef4b9 3232 command_table[editRowIndex][COMMAND_TABLE_COL_MAX-1]='\0';
whismanoid 23:c6c652bef4b9 3233 }
whismanoid 23:c6c652bef4b9 3234 break;
whismanoid 23:c6c652bef4b9 3235 case '-':
whismanoid 24:032f3683cb2a 3236 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 23:c6c652bef4b9 3237 // delete row from table
whismanoid 23:c6c652bef4b9 3238 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 3239 // if command_table_row_count == 0 then the table is empty
whismanoid 23:c6c652bef4b9 3240 if ((cmdLine[5] == '~') && (cmdLine[6] == '~') && (cmdLine[7] == '~')) {
whismanoid 23:c6c652bef4b9 3241 // %B1@-~~~ clear entire command table
whismanoid 24:032f3683cb2a 3242 cmdLine.serial().printf("\r\n clear entire command table");
whismanoid 23:c6c652bef4b9 3243 command_table_row_count = 0;
whismanoid 23:c6c652bef4b9 3244 command_table[command_table_row_count][0] = '\0';
whismanoid 23:c6c652bef4b9 3245 break;
whismanoid 23:c6c652bef4b9 3246 }
whismanoid 24:032f3683cb2a 3247 else
whismanoid 23:c6c652bef4b9 3248 {
whismanoid 24:032f3683cb2a 3249 // %B1@-nnn delete row number nnn (if list is not empty)
whismanoid 24:032f3683cb2a 3250 editRowIndex = atoi(cmdLine.str()+5);
whismanoid 24:032f3683cb2a 3251 if ((editRowIndex >= 0) && (editRowIndex < command_table_row_count)) {
whismanoid 24:032f3683cb2a 3252 cmdLine.serial().printf("\r\n delete row %d", editRowIndex);
whismanoid 24:032f3683cb2a 3253 // delete row editRowIndex from Datalogger_action_table
whismanoid 24:032f3683cb2a 3254 for (int i = editRowIndex; i < (command_table_row_count-1); i++)
whismanoid 24:032f3683cb2a 3255 {
whismanoid 24:032f3683cb2a 3256 // copy row i+1 into row i
whismanoid 24:032f3683cb2a 3257 cmdLine.serial().printf("\r\n copy row %d into row %d: \"%s\"",
whismanoid 24:032f3683cb2a 3258 i+1, i, command_table[i+1]);
whismanoid 24:032f3683cb2a 3259 strncpy(command_table[i], command_table[i+1], COMMAND_TABLE_COL_MAX-1);
whismanoid 24:032f3683cb2a 3260 command_table[i][COMMAND_TABLE_COL_MAX-1]='\0';
whismanoid 24:032f3683cb2a 3261 }
whismanoid 24:032f3683cb2a 3262 command_table_row_count--;
whismanoid 24:032f3683cb2a 3263 command_table[command_table_row_count][0] = '\0';
whismanoid 24:032f3683cb2a 3264 }
whismanoid 23:c6c652bef4b9 3265 }
whismanoid 23:c6c652bef4b9 3266 }
whismanoid 23:c6c652bef4b9 3267 break;
whismanoid 23:c6c652bef4b9 3268 case '!':
whismanoid 23:c6c652bef4b9 3269 // pause the entire action table
whismanoid 23:c6c652bef4b9 3270 // TODO: %B1@! disable button response but keep command table contents
whismanoid 23:c6c652bef4b9 3271 //~ Datalogger_action_table_enabled = false;
whismanoid 23:c6c652bef4b9 3272 break;
whismanoid 23:c6c652bef4b9 3273 case '@':
whismanoid 23:c6c652bef4b9 3274 // enable the entire action table
whismanoid 23:c6c652bef4b9 3275 // TODO: %B1@@ enable button response
whismanoid 23:c6c652bef4b9 3276 //~ Datalogger_action_table_enabled = true;
whismanoid 23:c6c652bef4b9 3277 break;
whismanoid 23:c6c652bef4b9 3278 }
whismanoid 23:c6c652bef4b9 3279 //
whismanoid 23:c6c652bef4b9 3280 // Print the contents of command_table
whismanoid 23:c6c652bef4b9 3281 for (int lineIndex = 0; lineIndex < COMMAND_TABLE_ROW_MAX; lineIndex++) {
whismanoid 23:c6c652bef4b9 3282 if (command_table[lineIndex] == NULL) { break; }
whismanoid 23:c6c652bef4b9 3283 if (command_table[lineIndex][0] == '\0') { break; }
whismanoid 24:032f3683cb2a 3284 command_table_row_count = lineIndex+1;
whismanoid 24:032f3683cb2a 3285 cmdLine.serial().printf("\r\n %%B%1d@%d %s",
whismanoid 24:032f3683cb2a 3286 command_table_button_index,
whismanoid 24:032f3683cb2a 3287 lineIndex,
whismanoid 24:032f3683cb2a 3288 command_table[lineIndex]);
whismanoid 23:c6c652bef4b9 3289 }
whismanoid 24:032f3683cb2a 3290 cmdLine.serial().printf("\r\n command_table_row_count = %d",
whismanoid 24:032f3683cb2a 3291 command_table_row_count);
whismanoid 23:c6c652bef4b9 3292 cmdLine.serial().printf("\r\nCommand table editing commands:");
whismanoid 23:c6c652bef4b9 3293 if (command_table_row_count < COMMAND_TABLE_ROW_MAX) {
whismanoid 23:c6c652bef4b9 3294 // if command_table_row_count => COMMAND_TABLE_ROW_MAX then the table is full
whismanoid 24:032f3683cb2a 3295 cmdLine.serial().printf("\r\n %%B%1d@+ command -- add new row %d at end of table",
whismanoid 24:032f3683cb2a 3296 command_table_button_index,
whismanoid 24:032f3683cb2a 3297 command_table_row_count);
whismanoid 23:c6c652bef4b9 3298 }
whismanoid 23:c6c652bef4b9 3299 if (command_table_row_count > 0) {
whismanoid 23:c6c652bef4b9 3300 // if command_table_row_count == 0 then the table is empty
whismanoid 24:032f3683cb2a 3301 cmdLine.serial().printf("\r\n %%B%1d@%d command -- replace row %d",
whismanoid 24:032f3683cb2a 3302 command_table_button_index,
whismanoid 23:c6c652bef4b9 3303 command_table_row_count-1,
whismanoid 23:c6c652bef4b9 3304 command_table_row_count-1);
whismanoid 24:032f3683cb2a 3305 cmdLine.serial().printf("\r\n %%B%1d@-%d -- delete row %d",
whismanoid 24:032f3683cb2a 3306 command_table_button_index,
whismanoid 24:032f3683cb2a 3307 command_table_row_count-1,
whismanoid 24:032f3683cb2a 3308 command_table_row_count-1);
whismanoid 24:032f3683cb2a 3309 cmdLine.serial().printf("\r\n %%B%1d@-~~~ -- delete all rows",
whismanoid 24:032f3683cb2a 3310 command_table_button_index);
whismanoid 24:032f3683cb2a 3311 cmdLine.serial().printf("\r\n %%B%1d@! -- pause entire command table",
whismanoid 24:032f3683cb2a 3312 command_table_button_index);
whismanoid 24:032f3683cb2a 3313 cmdLine.serial().printf("\r\n %%B%1d@@ -- enable command table",
whismanoid 24:032f3683cb2a 3314 command_table_button_index);
whismanoid 23:c6c652bef4b9 3315 }
whismanoid 23:c6c652bef4b9 3316 //
whismanoid 23:c6c652bef4b9 3317 } // case '@' -- %B1@ view/edit command table
whismanoid 23:c6c652bef4b9 3318 break;
whismanoid 23:c6c652bef4b9 3319 case '!':
whismanoid 23:c6c652bef4b9 3320 // TODO: %B1! trigger onButton1FallingEdge() immediately (for test development)
whismanoid 23:c6c652bef4b9 3321 Run_command_table(command_table);
whismanoid 23:c6c652bef4b9 3322 break;
whismanoid 23:c6c652bef4b9 3323 }
whismanoid 23:c6c652bef4b9 3324 }
whismanoid 23:c6c652bef4b9 3325 break;
whismanoid 23:c6c652bef4b9 3326 #endif // USE_DATALOGGER_CommandTable
whismanoid 23:c6c652bef4b9 3327 //--------------------------------------------------
whismanoid 15:37c83ec50ea0 3328 #if HAS_digitalInOuts
whismanoid 15:37c83ec50ea0 3329 case 'H': case 'h':
whismanoid 15:37c83ec50ea0 3330 {
whismanoid 15:37c83ec50ea0 3331 // %Hpin -- digital output high
whismanoid 15:37c83ec50ea0 3332 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 3333 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 3334 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 3335 #else
whismanoid 15:37c83ec50ea0 3336 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 3337 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 3338 digitalInOutPin.write(1);
whismanoid 15:37c83ec50ea0 3339 #endif
whismanoid 15:37c83ec50ea0 3340 cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex);
whismanoid 15:37c83ec50ea0 3341 }
whismanoid 15:37c83ec50ea0 3342 break;
whismanoid 15:37c83ec50ea0 3343 case 'L': case 'l':
whismanoid 15:37c83ec50ea0 3344 {
whismanoid 15:37c83ec50ea0 3345 // %Lpin -- digital output low
whismanoid 15:37c83ec50ea0 3346 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 3347 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 3348 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 3349 #else
whismanoid 15:37c83ec50ea0 3350 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 3351 digitalInOutPin.output();
whismanoid 15:37c83ec50ea0 3352 digitalInOutPin.write(0);
whismanoid 15:37c83ec50ea0 3353 #endif
whismanoid 15:37c83ec50ea0 3354 cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex);
whismanoid 15:37c83ec50ea0 3355 }
whismanoid 15:37c83ec50ea0 3356 break;
whismanoid 15:37c83ec50ea0 3357 case '?':
whismanoid 15:37c83ec50ea0 3358 {
whismanoid 15:37c83ec50ea0 3359 // %?pin -- digital input
whismanoid 15:37c83ec50ea0 3360 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 3361 pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 15:37c83ec50ea0 3362 #else
whismanoid 15:37c83ec50ea0 3363 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 15:37c83ec50ea0 3364 digitalInOutPin.input();
whismanoid 15:37c83ec50ea0 3365 #endif
whismanoid 15:37c83ec50ea0 3366 serial.printf(" digitalInOutPin %d Input ", pinIndex);
whismanoid 15:37c83ec50ea0 3367 #if ARDUINO_STYLE
whismanoid 15:37c83ec50ea0 3368 int value = digitalRead(pinIndex);
whismanoid 15:37c83ec50ea0 3369 #else
whismanoid 15:37c83ec50ea0 3370 int value = digitalInOutPin.read();
whismanoid 15:37c83ec50ea0 3371 #endif
whismanoid 15:37c83ec50ea0 3372 cmdLine.serial().printf("%d ", value);
whismanoid 15:37c83ec50ea0 3373 }
whismanoid 15:37c83ec50ea0 3374 break;
whismanoid 15:37c83ec50ea0 3375 #endif
whismanoid 15:37c83ec50ea0 3376 //
whismanoid 15:37c83ec50ea0 3377 #if HAS_analogIns
whismanoid 15:37c83ec50ea0 3378 case 'A': case 'a':
whismanoid 15:37c83ec50ea0 3379 {
whismanoid 15:37c83ec50ea0 3380 // %A %Apin -- analog input
whismanoid 15:37c83ec50ea0 3381 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 3382 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 15:37c83ec50ea0 3383 for (int pinIndex = 0; pinIndex < 2; pinIndex++)
whismanoid 15:37c83ec50ea0 3384 {
whismanoid 15:37c83ec50ea0 3385 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 3386 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 3387 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 15:37c83ec50ea0 3388 float normValue_0_1 = analogInPin.read();
whismanoid 15:37c83ec50ea0 3389 //
whismanoid 15:37c83ec50ea0 3390 int pinIndexH = pinIndex + 4;
whismanoid 15:37c83ec50ea0 3391 int cPinIndexH = '0' + pinIndexH;
whismanoid 15:37c83ec50ea0 3392 AnalogIn& analogInPinH = find_analogInPin(cPinIndexH);
whismanoid 15:37c83ec50ea0 3393 float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH];
whismanoid 15:37c83ec50ea0 3394 float normValueH_0_1 = analogInPinH.read();
whismanoid 15:37c83ec50ea0 3395 //
whismanoid 15:37c83ec50ea0 3396 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV AIN%c = %7.3f%% = %1.3fV \r\n",
whismanoid 15:37c83ec50ea0 3397 cPinIndex,
whismanoid 15:37c83ec50ea0 3398 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 3399 normValue_0_1 * adc_full_scale_voltage,
whismanoid 15:37c83ec50ea0 3400 cPinIndexH,
whismanoid 15:37c83ec50ea0 3401 normValueH_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 3402 normValueH_0_1 * adc_full_scale_voltageH
whismanoid 15:37c83ec50ea0 3403 );
whismanoid 15:37c83ec50ea0 3404 }
whismanoid 15:37c83ec50ea0 3405 for (int pinIndex = 2; pinIndex < 4; pinIndex++)
whismanoid 15:37c83ec50ea0 3406 {
whismanoid 15:37c83ec50ea0 3407 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 3408 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 3409 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 15:37c83ec50ea0 3410 float normValue_0_1 = analogInPin.read();
whismanoid 15:37c83ec50ea0 3411 //
whismanoid 15:37c83ec50ea0 3412 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 3413 cPinIndex,
whismanoid 15:37c83ec50ea0 3414 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 3415 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 3416 );
whismanoid 15:37c83ec50ea0 3417 }
whismanoid 15:37c83ec50ea0 3418 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 3419 // Platform board uses simple analog inputs
whismanoid 15:37c83ec50ea0 3420 // assume standard Arduino analog inputs A0-A5
whismanoid 15:37c83ec50ea0 3421 for (int pinIndex = 0; pinIndex < 6; pinIndex++)
whismanoid 15:37c83ec50ea0 3422 {
whismanoid 15:37c83ec50ea0 3423 int cPinIndex = '0' + pinIndex;
whismanoid 15:37c83ec50ea0 3424 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 15:37c83ec50ea0 3425 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 15:37c83ec50ea0 3426 float normValue_0_1 = analogInPin.read();
whismanoid 15:37c83ec50ea0 3427 //
whismanoid 15:37c83ec50ea0 3428 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n",
whismanoid 15:37c83ec50ea0 3429 cPinIndex,
whismanoid 15:37c83ec50ea0 3430 normValue_0_1 * 100.0,
whismanoid 15:37c83ec50ea0 3431 normValue_0_1 * adc_full_scale_voltage
whismanoid 15:37c83ec50ea0 3432 );
whismanoid 15:37c83ec50ea0 3433 }
whismanoid 15:37c83ec50ea0 3434 #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 15:37c83ec50ea0 3435 }
whismanoid 15:37c83ec50ea0 3436 break;
whismanoid 15:37c83ec50ea0 3437 #endif
whismanoid 15:37c83ec50ea0 3438 //
whismanoid 15:37c83ec50ea0 3439 #if HAS_SPI2_MAX541
whismanoid 15:37c83ec50ea0 3440 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 3441 {
whismanoid 15:37c83ec50ea0 3442 // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV)
whismanoid 15:37c83ec50ea0 3443 // MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 15:37c83ec50ea0 3444 float voltageV = max541.Get_Voltage();
whismanoid 15:37c83ec50ea0 3445 // if (cmdLine[2] == '+') {
whismanoid 15:37c83ec50ea0 3446 // // %D+
whismanoid 15:37c83ec50ea0 3447 // voltageV = voltageV * 1.25f;
whismanoid 15:37c83ec50ea0 3448 // if (voltageV >= max541.VRef) voltageV = max541.VRef;
whismanoid 15:37c83ec50ea0 3449 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 3450 // }
whismanoid 15:37c83ec50ea0 3451 // else if (cmdLine[2] == '-') {
whismanoid 15:37c83ec50ea0 3452 // // %D-
whismanoid 15:37c83ec50ea0 3453 // voltageV = voltageV * 0.75f;
whismanoid 15:37c83ec50ea0 3454 // if (voltageV < 0.1f) voltageV = 0.1f;
whismanoid 15:37c83ec50ea0 3455 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 3456 // }
whismanoid 15:37c83ec50ea0 3457 if (cmdLine.parse_float("V", voltageV))
whismanoid 15:37c83ec50ea0 3458 {
whismanoid 15:37c83ec50ea0 3459 // %D V=1.234 -- set voltage
whismanoid 15:37c83ec50ea0 3460 max541.Set_Voltage(voltageV);
whismanoid 15:37c83ec50ea0 3461 }
whismanoid 15:37c83ec50ea0 3462 else if (cmdLine.parse_float("TEST", voltageV))
whismanoid 15:37c83ec50ea0 3463 {
whismanoid 15:37c83ec50ea0 3464 // %D TEST=1.234 -- set voltage and compare with AIN0
whismanoid 15:37c83ec50ea0 3465 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 3466 }
whismanoid 15:37c83ec50ea0 3467 else if (cmdLine.parse_float("CAL", voltageV))
whismanoid 15:37c83ec50ea0 3468 {
whismanoid 15:37c83ec50ea0 3469 // %D CAL=1.234 -- calibrate VRef and compare with AIN0
whismanoid 15:37c83ec50ea0 3470
whismanoid 15:37c83ec50ea0 3471 max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
whismanoid 15:37c83ec50ea0 3472 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 3473 const int average_count = 100;
whismanoid 15:37c83ec50ea0 3474 const double average_K = 0.25;
whismanoid 15:37c83ec50ea0 3475 for (int count = 0; count < average_count; count++) {
whismanoid 15:37c83ec50ea0 3476 double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 15:37c83ec50ea0 3477 max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
whismanoid 15:37c83ec50ea0 3478 }
whismanoid 15:37c83ec50ea0 3479 max541.VRef = 2.0 * max541_midscale_V;
whismanoid 15:37c83ec50ea0 3480 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 3481 "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
whismanoid 15:37c83ec50ea0 3482 max541_midscale_V, max541.VRef);
whismanoid 15:37c83ec50ea0 3483 // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
whismanoid 15:37c83ec50ea0 3484 voltageV = 1.0f;
whismanoid 15:37c83ec50ea0 3485 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 15:37c83ec50ea0 3486 }
whismanoid 15:37c83ec50ea0 3487 else {
whismanoid 15:37c83ec50ea0 3488 // %D -- print MAX541 DAC status
whismanoid 15:37c83ec50ea0 3489 cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n",
whismanoid 15:37c83ec50ea0 3490 max541.Get_Code(), max541.Get_Voltage(), max541.VRef);
whismanoid 15:37c83ec50ea0 3491 }
whismanoid 15:37c83ec50ea0 3492 }
whismanoid 15:37c83ec50ea0 3493 break;
whismanoid 15:37c83ec50ea0 3494 #endif
whismanoid 15:37c83ec50ea0 3495
whismanoid 15:37c83ec50ea0 3496 //
whismanoid 15:37c83ec50ea0 3497 #if HAS_I2C // SUPPORT_I2C
whismanoid 15:37c83ec50ea0 3498 case 'I': case 'i':
whismanoid 15:37c83ec50ea0 3499 // %I... -- I2C diagnostics
whismanoid 15:37c83ec50ea0 3500 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 3501 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 3502 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 3503 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 3504 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 3505 // get next character
whismanoid 15:37c83ec50ea0 3506 // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7
whismanoid 15:37c83ec50ea0 3507 cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7);
whismanoid 15:37c83ec50ea0 3508 // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count
whismanoid 15:37c83ec50ea0 3509 g_I2C_read_count = 0; // read count must be reset every command
whismanoid 15:37c83ec50ea0 3510 cmdLine.parse_byte_dec("RD", g_I2C_read_count);
whismanoid 15:37c83ec50ea0 3511 // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress
whismanoid 15:37c83ec50ea0 3512 cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress);
whismanoid 15:37c83ec50ea0 3513 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 3514 {
whismanoid 15:37c83ec50ea0 3515 case 'P': case 'p':
whismanoid 15:37c83ec50ea0 3516 {
whismanoid 15:37c83ec50ea0 3517 // %IP -- I2C probe
whismanoid 15:37c83ec50ea0 3518 HuntAttachedI2CDevices(cmdLine, 0x03, 0x77);
whismanoid 15:37c83ec50ea0 3519 }
whismanoid 15:37c83ec50ea0 3520 break;
whismanoid 15:37c83ec50ea0 3521 case 'C': case 'c':
whismanoid 15:37c83ec50ea0 3522 {
whismanoid 15:37c83ec50ea0 3523 bool isUpdatedI2CConfig = false;
whismanoid 15:37c83ec50ea0 3524 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 15:37c83ec50ea0 3525 // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz
whismanoid 15:37c83ec50ea0 3526 if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz))
whismanoid 15:37c83ec50ea0 3527 {
whismanoid 15:37c83ec50ea0 3528 isUpdatedI2CConfig = true;
whismanoid 15:37c83ec50ea0 3529 // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 3530 if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 3531 {
whismanoid 15:37c83ec50ea0 3532 g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 3533 }
whismanoid 15:37c83ec50ea0 3534 if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz)
whismanoid 15:37c83ec50ea0 3535 {
whismanoid 15:37c83ec50ea0 3536 g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz;
whismanoid 15:37c83ec50ea0 3537 }
whismanoid 15:37c83ec50ea0 3538 }
whismanoid 15:37c83ec50ea0 3539 if (isUpdatedI2CConfig)
whismanoid 15:37c83ec50ea0 3540 {
whismanoid 15:37c83ec50ea0 3541 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 3542 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 3543 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 3544 i2cMaster.start();
whismanoid 15:37c83ec50ea0 3545 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 3546 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 3547 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 3548 "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 15:37c83ec50ea0 3549 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 15:37c83ec50ea0 3550 (g_I2C_SCL_Hz / 1000.));
whismanoid 15:37c83ec50ea0 3551 i2cMaster.start();
whismanoid 15:37c83ec50ea0 3552 i2cMaster.stop();
whismanoid 15:37c83ec50ea0 3553 }
whismanoid 15:37c83ec50ea0 3554 }
whismanoid 15:37c83ec50ea0 3555 break;
whismanoid 15:37c83ec50ea0 3556 case 'W': case 'w':
whismanoid 15:37c83ec50ea0 3557 {
whismanoid 15:37c83ec50ea0 3558 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 3559 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 3560 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 3561 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 15:37c83ec50ea0 3562 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 3563 #define MAX_I2C_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 3564 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 3565 static char mosiData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 3566 static char misoData[MAX_I2C_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 3567 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 3568 MAX_I2C_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 3569 {
whismanoid 15:37c83ec50ea0 3570 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 3571 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 3572 "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->",
whismanoid 15:37c83ec50ea0 3573 g_I2C_deviceAddress7,
whismanoid 15:37c83ec50ea0 3574 (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count);
whismanoid 15:37c83ec50ea0 3575 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 3576 {
whismanoid 15:37c83ec50ea0 3577 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 3578 }
whismanoid 15:37c83ec50ea0 3579 //
whismanoid 15:37c83ec50ea0 3580 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 3581 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 3582 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 3583 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 3584 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 3585 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 3586 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 3587 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 3588 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 3589 // /* 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 3590 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 3591 const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 3592 unsigned int misoLength = 0;
whismanoid 15:37c83ec50ea0 3593 bool repeated = (g_I2C_read_count > 0);
whismanoid 15:37c83ec50ea0 3594 //
whismanoid 15:37c83ec50ea0 3595 int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated);
whismanoid 15:37c83ec50ea0 3596 switch (writeStatus)
whismanoid 15:37c83ec50ea0 3597 {
whismanoid 15:37c83ec50ea0 3598 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 3599 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 3600 default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 3601 writeStatus);
whismanoid 15:37c83ec50ea0 3602 }
whismanoid 15:37c83ec50ea0 3603 if (repeated)
whismanoid 15:37c83ec50ea0 3604 {
whismanoid 15:37c83ec50ea0 3605 int readStatus =
whismanoid 15:37c83ec50ea0 3606 i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false);
whismanoid 15:37c83ec50ea0 3607 switch (readStatus)
whismanoid 15:37c83ec50ea0 3608 {
whismanoid 15:37c83ec50ea0 3609 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 15:37c83ec50ea0 3610 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 15:37c83ec50ea0 3611 default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ",
whismanoid 15:37c83ec50ea0 3612 readStatus);
whismanoid 15:37c83ec50ea0 3613 }
whismanoid 15:37c83ec50ea0 3614 }
whismanoid 15:37c83ec50ea0 3615 //
whismanoid 15:37c83ec50ea0 3616 if (misoLength > 0)
whismanoid 15:37c83ec50ea0 3617 {
whismanoid 15:37c83ec50ea0 3618 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 3619 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 3620 for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count;
whismanoid 15:37c83ec50ea0 3621 byteIndex++)
whismanoid 15:37c83ec50ea0 3622 {
whismanoid 15:37c83ec50ea0 3623 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 3624 }
whismanoid 15:37c83ec50ea0 3625 }
whismanoid 15:37c83ec50ea0 3626 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 3627 }
whismanoid 15:37c83ec50ea0 3628 }
whismanoid 15:37c83ec50ea0 3629 break;
whismanoid 15:37c83ec50ea0 3630 case 'R': case 'r':
whismanoid 15:37c83ec50ea0 3631 {
whismanoid 15:37c83ec50ea0 3632 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 3633 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 3634 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 3635 // %IR ADDR=? RD=? -- read
whismanoid 15:37c83ec50ea0 3636 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 3637 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 3638 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 3639 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 3640 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 3641 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 3642 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 3643 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 3644 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 3645 // /* 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 3646 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 3647 }
whismanoid 15:37c83ec50ea0 3648 break;
whismanoid 15:37c83ec50ea0 3649 case '^':
whismanoid 15:37c83ec50ea0 3650 {
whismanoid 15:37c83ec50ea0 3651 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 15:37c83ec50ea0 3652 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 15:37c83ec50ea0 3653 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 15:37c83ec50ea0 3654 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 15:37c83ec50ea0 3655 // TODO: i2c transfer
whismanoid 15:37c83ec50ea0 3656 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 15:37c83ec50ea0 3657 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 15:37c83ec50ea0 3658 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 15:37c83ec50ea0 3659 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 15:37c83ec50ea0 3660 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 15:37c83ec50ea0 3661 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 15:37c83ec50ea0 3662 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 15:37c83ec50ea0 3663 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 15:37c83ec50ea0 3664 // /* 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 3665 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 15:37c83ec50ea0 3666 }
whismanoid 15:37c83ec50ea0 3667 break;
whismanoid 15:37c83ec50ea0 3668 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 3669 break;
whismanoid 15:37c83ec50ea0 3670 #endif
whismanoid 15:37c83ec50ea0 3671 //
whismanoid 15:37c83ec50ea0 3672 #if HAS_SPI // SUPPORT_SPI
whismanoid 15:37c83ec50ea0 3673 case 'S': case 's':
whismanoid 15:37c83ec50ea0 3674 {
whismanoid 15:37c83ec50ea0 3675 // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 3676 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 3677 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 3678 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 3679 //
whismanoid 15:37c83ec50ea0 3680 // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d
whismanoid 15:37c83ec50ea0 3681 bool isUpdatedSPIConfig = false;
whismanoid 15:37c83ec50ea0 3682 // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2
whismanoid 15:37c83ec50ea0 3683 // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1
whismanoid 15:37c83ec50ea0 3684 if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2))
whismanoid 15:37c83ec50ea0 3685 {
whismanoid 15:37c83ec50ea0 3686 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 3687 }
whismanoid 15:37c83ec50ea0 3688 if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1))
whismanoid 15:37c83ec50ea0 3689 {
whismanoid 15:37c83ec50ea0 3690 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 3691 }
whismanoid 15:37c83ec50ea0 3692 if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1))
whismanoid 15:37c83ec50ea0 3693 {
whismanoid 15:37c83ec50ea0 3694 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 3695 }
whismanoid 15:37c83ec50ea0 3696 // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz
whismanoid 15:37c83ec50ea0 3697 if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz))
whismanoid 15:37c83ec50ea0 3698 {
whismanoid 15:37c83ec50ea0 3699 isUpdatedSPIConfig = true;
whismanoid 15:37c83ec50ea0 3700 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU
whismanoid 15:37c83ec50ea0 3701 if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 3702 {
whismanoid 15:37c83ec50ea0 3703 g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 3704 }
whismanoid 15:37c83ec50ea0 3705 if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz)
whismanoid 15:37c83ec50ea0 3706 {
whismanoid 15:37c83ec50ea0 3707 g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 3708 }
whismanoid 15:37c83ec50ea0 3709 }
whismanoid 15:37c83ec50ea0 3710 // Update SPI configuration
whismanoid 15:37c83ec50ea0 3711 if (isUpdatedSPIConfig)
whismanoid 15:37c83ec50ea0 3712 {
whismanoid 15:37c83ec50ea0 3713 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 3714 spi_cs = g_SPI_cs_state;
whismanoid 15:37c83ec50ea0 3715 spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0
whismanoid 15:37c83ec50ea0 3716 #if APPLICATION_MAX5715
whismanoid 15:37c83ec50ea0 3717 g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 3718 #elif APPLICATION_MAX11131
whismanoid 15:37c83ec50ea0 3719 g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 3720 #elif APPLICATION_MAX5171
whismanoid 15:37c83ec50ea0 3721 g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 3722 #elif APPLICATION_MAX11410
whismanoid 15:37c83ec50ea0 3723 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 3724 #elif APPLICATION_MAX12345
whismanoid 15:37c83ec50ea0 3725 g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 15:37c83ec50ea0 3726 #else
whismanoid 15:37c83ec50ea0 3727 spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 15:37c83ec50ea0 3728 #endif
whismanoid 15:37c83ec50ea0 3729 //
whismanoid 15:37c83ec50ea0 3730 double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz;
whismanoid 15:37c83ec50ea0 3731 int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate
whismanoid 15:37c83ec50ea0 3732 double actual_SCLK_Hz = SystemCoreClock / actual_divisor;
whismanoid 15:37c83ec50ea0 3733 //
whismanoid 15:37c83ec50ea0 3734 // 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 3735 cmdLine.serial().printf(
whismanoid 15:37c83ec50ea0 3736 "\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 3737 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 15:37c83ec50ea0 3738 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0),
whismanoid 15:37c83ec50ea0 3739 g_SPI_cs_state,
whismanoid 15:37c83ec50ea0 3740 g_SPI_SCLK_Hz,
whismanoid 15:37c83ec50ea0 3741 (g_SPI_SCLK_Hz / 1000000.),
whismanoid 15:37c83ec50ea0 3742 ((double)(SystemCoreClock / 1000000.)),
whismanoid 15:37c83ec50ea0 3743 ideal_divisor,
whismanoid 15:37c83ec50ea0 3744 (actual_SCLK_Hz / 1000000.)
whismanoid 15:37c83ec50ea0 3745 );
whismanoid 15:37c83ec50ea0 3746 }
whismanoid 15:37c83ec50ea0 3747 // get next character
whismanoid 15:37c83ec50ea0 3748 switch (cmdLine[2])
whismanoid 15:37c83ec50ea0 3749 {
whismanoid 15:37c83ec50ea0 3750 case 'C': case 's':
whismanoid 15:37c83ec50ea0 3751 // %SC sclk=1Mhz -- SPI configure
whismanoid 15:37c83ec50ea0 3752 break;
whismanoid 15:37c83ec50ea0 3753 case 'D': case 'd':
whismanoid 15:37c83ec50ea0 3754 // %SD -- SPI diagnostic messages enable
whismanoid 15:37c83ec50ea0 3755 if (g_MAX5719_device.onSPIprint) {
whismanoid 15:37c83ec50ea0 3756 g_MAX5719_device.onSPIprint = NULL;
whismanoid 15:37c83ec50ea0 3757 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') != None is false
whismanoid 15:37c83ec50ea0 3758 }
whismanoid 15:37c83ec50ea0 3759 else {
whismanoid 15:37c83ec50ea0 3760 void onSPIprint_handler(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]);
whismanoid 15:37c83ec50ea0 3761 g_MAX5719_device.onSPIprint = onSPIprint_handler;
whismanoid 15:37c83ec50ea0 3762 // no g_MAX5719_device.loop_limit property; device_has_property(Device, 'loop_limit') is false
whismanoid 15:37c83ec50ea0 3763 }
whismanoid 15:37c83ec50ea0 3764 break;
whismanoid 15:37c83ec50ea0 3765 case 'W': case 'R': case 'w': case 'r':
whismanoid 15:37c83ec50ea0 3766 {
whismanoid 15:37c83ec50ea0 3767 // %SW -- write (write and read)
whismanoid 15:37c83ec50ea0 3768 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 15:37c83ec50ea0 3769 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 3770 #define MAX_SPI_BYTE_COUNT 32
whismanoid 15:37c83ec50ea0 3771 size_t byteCount = byteCount;
whismanoid 15:37c83ec50ea0 3772 static char mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 3773 static char misoData[MAX_SPI_BYTE_COUNT];
whismanoid 15:37c83ec50ea0 3774 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 15:37c83ec50ea0 3775 MAX_SPI_BYTE_COUNT))
whismanoid 15:37c83ec50ea0 3776 {
whismanoid 15:37c83ec50ea0 3777 // hex dump mosiData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 3778 cmdLine.serial().printf("\r\nSPI");
whismanoid 15:37c83ec50ea0 3779 if (byteCount > 7) {
whismanoid 15:37c83ec50ea0 3780 cmdLine.serial().printf(" byteCount:%d", byteCount);
whismanoid 15:37c83ec50ea0 3781 }
whismanoid 15:37c83ec50ea0 3782 cmdLine.serial().printf(" MOSI->");
whismanoid 15:37c83ec50ea0 3783 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 15:37c83ec50ea0 3784 {
whismanoid 15:37c83ec50ea0 3785 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 15:37c83ec50ea0 3786 }
whismanoid 15:37c83ec50ea0 3787 spi_cs = 0;
whismanoid 15:37c83ec50ea0 3788 unsigned int numBytesTransferred =
whismanoid 15:37c83ec50ea0 3789 spi.write(mosiData, byteCount, misoData, byteCount);
whismanoid 15:37c83ec50ea0 3790 spi_cs = 1;
whismanoid 15:37c83ec50ea0 3791 // hex dump misoData[0..byteCount-1]
whismanoid 15:37c83ec50ea0 3792 cmdLine.serial().printf(" MISO<-");
whismanoid 15:37c83ec50ea0 3793 for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred;
whismanoid 15:37c83ec50ea0 3794 byteIndex++)
whismanoid 15:37c83ec50ea0 3795 {
whismanoid 15:37c83ec50ea0 3796 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 15:37c83ec50ea0 3797 }
whismanoid 15:37c83ec50ea0 3798 cmdLine.serial().printf(" ");
whismanoid 15:37c83ec50ea0 3799 }
whismanoid 15:37c83ec50ea0 3800 }
whismanoid 15:37c83ec50ea0 3801 break;
whismanoid 15:37c83ec50ea0 3802 } // switch(cmdLine[2])
whismanoid 15:37c83ec50ea0 3803 } // case 'S': // %S... -- SPI diagnostics
whismanoid 15:37c83ec50ea0 3804 break;
whismanoid 15:37c83ec50ea0 3805 #endif
whismanoid 15:37c83ec50ea0 3806 //
whismanoid 15:37c83ec50ea0 3807 // A-Z,a-z,0-9 reserved for application use
whismanoid 15:37c83ec50ea0 3808 } // switch(cmdLine[1])
whismanoid 15:37c83ec50ea0 3809 } // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 15:37c83ec50ea0 3810 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 15:37c83ec50ea0 3811
whismanoid 15:37c83ec50ea0 3812 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3813 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 3814 void main_menu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 3815 {
whismanoid 9:45f98573eb6d 3816 // process command line
whismanoid 9:45f98573eb6d 3817 cmdLine.serial().printf("\r\nCmdLine buf:\"%s\"\r\n", cmdLine.str());
whismanoid 4:d9b05924ad4c 3818
whismanoid 4:d9b05924ad4c 3819 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 3820 // If datalog is free running, halt on any possible received command
whismanoid 17:9397ea3ea7e9 3821 if (Datalogger_Trigger != trigger_Halt) {
whismanoid 4:d9b05924ad4c 3822 Datalogger_Trigger = trigger_Halt;
whismanoid 9:45f98573eb6d 3823 cmdLine.serial().printf("Datalog stopped by USB command input\r\n");
whismanoid 9:45f98573eb6d 3824 cmdLine.serial().printf("Restart datalog by sending LR\r\n");
whismanoid 4:d9b05924ad4c 3825 }
whismanoid 4:d9b05924ad4c 3826 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 3827
whismanoid 4:d9b05924ad4c 3828 // DIAGNOSTIC: print line buffer
whismanoid 4:d9b05924ad4c 3829 //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str());
whismanoid 4:d9b05924ad4c 3830 //
whismanoid 4:d9b05924ad4c 3831 switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 3832 {
whismanoid 4:d9b05924ad4c 3833 case '?':
whismanoid 4:d9b05924ad4c 3834 main_menu_status(cmdLine);
whismanoid 4:d9b05924ad4c 3835 main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 3836 // print command prompt
whismanoid 4:d9b05924ad4c 3837 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 3838 break;
whismanoid 4:d9b05924ad4c 3839 case '\r': case '\n': // ignore blank line
whismanoid 4:d9b05924ad4c 3840 case '\0': // ignore empty line
whismanoid 4:d9b05924ad4c 3841 case '#': // ignore comment line
whismanoid 4:d9b05924ad4c 3842 // # -- lines beginning with # are comments
whismanoid 4:d9b05924ad4c 3843 main_menu_status(cmdLine);
whismanoid 4:d9b05924ad4c 3844 //~ main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 3845 // print command prompt
whismanoid 4:d9b05924ad4c 3846 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 3847 break;
whismanoid 4:d9b05924ad4c 3848 #if ECHO_EOF_ON_EOL
whismanoid 4:d9b05924ad4c 3849 case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file
whismanoid 4:d9b05924ad4c 3850 cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 3851 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 3852 break;
whismanoid 4:d9b05924ad4c 3853 case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file
whismanoid 4:d9b05924ad4c 3854 cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 3855 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 3856 break;
whismanoid 4:d9b05924ad4c 3857 #endif
whismanoid 10:04022a61b527 3858 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 3859 case '!': // device init
whismanoid 10:04022a61b527 3860 {
whismanoid 10:04022a61b527 3861 cmdLine.serial().printf("Init");
whismanoid 10:04022a61b527 3862 // call function Init
whismanoid 10:04022a61b527 3863 uint8_t result = g_MAX11410_device.Init();
whismanoid 10:04022a61b527 3864 // cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 3865 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 3866 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 3867 // in command '!' device init, apply list of custom register writes after init
whismanoid 10:04022a61b527 3868 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 3869 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 10:04022a61b527 3870 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 10:04022a61b527 3871 uint32_t regData = custom_reg_init_data[index];
whismanoid 10:04022a61b527 3872 cmdLine.serial().printf("*%s=0x%06.6x",
whismanoid 10:04022a61b527 3873 g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress),
whismanoid 10:04022a61b527 3874 regData
whismanoid 10:04022a61b527 3875 );
whismanoid 10:04022a61b527 3876 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 10:04022a61b527 3877 }
whismanoid 10:04022a61b527 3878 #endif // USE_CUSTOM_REG_INIT
whismanoid 10:04022a61b527 3879 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 3880 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 3881 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 3882 }
whismanoid 10:04022a61b527 3883 break;
whismanoid 10:04022a61b527 3884 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 3885 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 3886 case '.':
whismanoid 4:d9b05924ad4c 3887 {
whismanoid 4:d9b05924ad4c 3888 // . -- SelfTest
whismanoid 4:d9b05924ad4c 3889 cmdLine.serial().printf("SelfTest()");
whismanoid 4:d9b05924ad4c 3890 SelfTest(cmdLine);
whismanoid 4:d9b05924ad4c 3891 }
whismanoid 4:d9b05924ad4c 3892 break;
whismanoid 4:d9b05924ad4c 3893 #endif // USE_SELFTEST
whismanoid 15:37c83ec50ea0 3894 #if 1 // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 3895 case '%':
whismanoid 4:d9b05924ad4c 3896 {
whismanoid 4:d9b05924ad4c 3897 pinsMonitor_submenu_onEOLcommandParser(cmdLine);
whismanoid 4:d9b05924ad4c 3898 }
whismanoid 4:d9b05924ad4c 3899 break; // case '%'
whismanoid 4:d9b05924ad4c 3900 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 9:45f98573eb6d 3901 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 3902 // reuse the Serial_Tester command *regName=regValue
whismanoid 10:04022a61b527 3903 // CODE GENERATOR: generate * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 3904 case '*':
whismanoid 10:04022a61b527 3905 {
whismanoid 10:04022a61b527 3906 // if buffer starts with a regName:
whismanoid 10:04022a61b527 3907 // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))):
whismanoid 10:04022a61b527 3908 // cmdLine.serial().printf(" scan RegName...\r\n");
whismanoid 10:04022a61b527 3909 }
whismanoid 10:04022a61b527 3910 break;
whismanoid 9:45f98573eb6d 3911 #endif // USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 3912 //
whismanoid 10:04022a61b527 3913 #if 1 // USE_AUX_SERIAL_CMD_FORWARDING && (HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL)
whismanoid 10:04022a61b527 3914 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_onEOLcommandParser
whismanoid 10:04022a61b527 3915 case '>':
whismanoid 10:04022a61b527 3916 {
whismanoid 10:04022a61b527 3917 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 3918 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3919 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 3920 CmdLine& cmdLine_AuxSerial = cmdLine_AUXserial;
whismanoid 10:04022a61b527 3921 Serial& AuxSerial = AUXserial;
whismanoid 10:04022a61b527 3922 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3923 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 3924 CmdLine& cmdLine_AuxSerial = cmdLine_DAPLINKserial;
whismanoid 10:04022a61b527 3925 Serial& AuxSerial = DAPLINKserial;
whismanoid 10:04022a61b527 3926 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3927 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 3928 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3929 //
whismanoid 10:04022a61b527 3930 // >> suppress key=value parsing
whismanoid 10:04022a61b527 3931 bool suppress_parsing = (cmdLine[1] == '>');
whismanoid 10:04022a61b527 3932 if (suppress_parsing == false) {
whismanoid 10:04022a61b527 3933 // int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 3934 if (cmdLine.parse_int_dec("baud", g_auxSerialCom_baud))
whismanoid 10:04022a61b527 3935 {
whismanoid 10:04022a61b527 3936 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- baud rate
whismanoid 10:04022a61b527 3937 cmdLine_AuxSerial.serial().printf("\r\n*** New Baud Rate %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 3938 AuxSerial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 3939 cmdLine_AuxSerial.serial().printf("\r\n*** Baud Rate was set to %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 3940 }
whismanoid 10:04022a61b527 3941 #if 0
whismanoid 10:04022a61b527 3942 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 3943 if (cmdLine.parse_int_dec("tx_wait_echo", g_auxSerialCom_tx_wait_echo))
whismanoid 10:04022a61b527 3944 {
whismanoid 10:04022a61b527 3945 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_wait_echo
whismanoid 10:04022a61b527 3946 //~ cmdLine_AuxSerial.serial().printf("\r\n*** tx_wait_echo was set to %d ***\r\n", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 3947 cmdLine.serial().printf("\r\n tx_wait_echo=%d", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 3948 }
whismanoid 10:04022a61b527 3949 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 3950 if (cmdLine.parse_int_dec("tx_char_delay_ms", g_auxSerialCom_tx_char_delay_ms))
whismanoid 10:04022a61b527 3951 {
whismanoid 10:04022a61b527 3952 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_char_delay_ms
whismanoid 10:04022a61b527 3953 //~ 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 3954 cmdLine.serial().printf("\r\n tx_char_delay_ms=%dms", g_auxSerialCom_tx_char_delay_ms);
whismanoid 10:04022a61b527 3955 }
whismanoid 10:04022a61b527 3956 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 3957 if (cmdLine.parse_int_dec("tx_line_delay_ms", g_auxSerialCom_tx_line_delay_ms))
whismanoid 10:04022a61b527 3958 {
whismanoid 10:04022a61b527 3959 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_line_delay_ms
whismanoid 10:04022a61b527 3960 //~ 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 3961 cmdLine.serial().printf("\r\n tx_line_delay_ms=%dms", g_auxSerialCom_tx_line_delay_ms);
whismanoid 10:04022a61b527 3962 }
whismanoid 10:04022a61b527 3963 #endif
whismanoid 10:04022a61b527 3964 // int g_auxSerialCom_message_ms = 0; //!< capture RX until response timeout?
whismanoid 10:04022a61b527 3965 if (cmdLine.parse_int_dec("message_ms", g_auxSerialCom_message_ms))
whismanoid 10:04022a61b527 3966 {
whismanoid 10:04022a61b527 3967 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 10:04022a61b527 3968 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 3969 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 3970 }
whismanoid 10:04022a61b527 3971 // int g_auxSerialCom_rx_idle_ms = 0; //!< capture RX until idle timeout?
whismanoid 10:04022a61b527 3972 if (cmdLine.parse_int_dec("rx_idle_ms", g_auxSerialCom_rx_idle_ms))
whismanoid 10:04022a61b527 3973 {
whismanoid 10:04022a61b527 3974 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_idle_ms
whismanoid 10:04022a61b527 3975 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_idle_ms was set to %d ***\r\n", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 3976 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 3977 }
whismanoid 10:04022a61b527 3978 // int g_auxSerialCom_rx_max_count = 0; //!< capture RX until max character count?
whismanoid 10:04022a61b527 3979 if (cmdLine.parse_int_dec("rx_max_count", g_auxSerialCom_rx_max_count))
whismanoid 10:04022a61b527 3980 {
whismanoid 10:04022a61b527 3981 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_max_count
whismanoid 10:04022a61b527 3982 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_max_count was set to %d ***\r\n", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 3983 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 3984 }
whismanoid 10:04022a61b527 3985 // int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text char?
whismanoid 10:04022a61b527 3986 if (cmdLine.parse_int_dec("rx_eot", g_auxSerialCom_rx_eot))
whismanoid 10:04022a61b527 3987 {
whismanoid 10:04022a61b527 3988 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_eot
whismanoid 10:04022a61b527 3989 //~ cmdLine_AUXserial.serial().printf("\r\n*** rx_eot was set to %d ***\r\n", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 3990 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 3991 }
whismanoid 10:04022a61b527 3992 }
whismanoid 10:04022a61b527 3993 // Command forwarding to AUX serial TX/RX cmdLine_AuxSerial #257 -- send outgoing_string
whismanoid 10:04022a61b527 3994 char* outgoing_string = (char*)cmdLine.str();
whismanoid 10:04022a61b527 3995 // > use key=value parsing
whismanoid 10:04022a61b527 3996 // >> suppress key=value parsing
whismanoid 10:04022a61b527 3997 if (suppress_parsing) {
whismanoid 10:04022a61b527 3998 cmdLine.serial().printf("\r\n suppress_parsing outgoing_string=\"%s\"", outgoing_string);
whismanoid 10:04022a61b527 3999 outgoing_string++; // skip the first '>'
whismanoid 10:04022a61b527 4000 outgoing_string++; // skip the second '>'
whismanoid 10:04022a61b527 4001 } else {
whismanoid 10:04022a61b527 4002 // TODO: after parsing, key=value pairs should be deleted, but outgoing_string=">xyzzy abc=def"
whismanoid 10:04022a61b527 4003 cmdLine.serial().printf("\r\n after parsing, outgoing_string=\"%s\"", outgoing_string);
whismanoid 10:04022a61b527 4004 outgoing_string++; // skip the first '>'
whismanoid 10:04022a61b527 4005 }
whismanoid 10:04022a61b527 4006 static char rx_string_buf[RX_STRING_BUF_SIZE];
whismanoid 10:04022a61b527 4007 unsigned int rx_string_length = 0;
whismanoid 10:04022a61b527 4008 cmdLine.serial().printf("\r\n >%s\r\n <", outgoing_string);
whismanoid 10:04022a61b527 4009 rx_string_buf[0] = '\0';
whismanoid 10:04022a61b527 4010 rx_string_length = 0;
whismanoid 10:04022a61b527 4011 //
whismanoid 10:04022a61b527 4012 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 4013 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 4014 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 4015 //
whismanoid 10:04022a61b527 4016 // int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 4017 // int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 4018 // int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 4019 // int g_auxSerialCom_rx_idle_ms = 2000; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 4020 // int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 4021 // int g_auxSerialCom_rx_eot = '\r'; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 4022 //~ cmdLine_AuxSerial.serial().printf("\r\n*** TODO forward %s ***\r\n", outgoing_string);
whismanoid 10:04022a61b527 4023 //
whismanoid 10:04022a61b527 4024 // TODO: send whole string or send character-by-character?
whismanoid 10:04022a61b527 4025 cmdLine_AuxSerial.serial().printf("%s", outgoing_string);
whismanoid 10:04022a61b527 4026 cmdLine_AuxSerial.serial().printf("\r\n");
whismanoid 10:04022a61b527 4027 g_auxSerialCom_Timer.start();
whismanoid 10:04022a61b527 4028 g_auxSerialCom_Timer_begin_message_ms = g_auxSerialCom_Timer.read_ms(); // start of message
whismanoid 10:04022a61b527 4029 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 4030 while (rx_string_length < (RX_STRING_BUF_SIZE-1)) {
whismanoid 10:04022a61b527 4031 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_message_ms) > g_auxSerialCom_message_ms) {
whismanoid 10:04022a61b527 4032 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 4033 break;
whismanoid 10:04022a61b527 4034 }
whismanoid 10:04022a61b527 4035 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_rx_idle_ms) > g_auxSerialCom_rx_idle_ms) {
whismanoid 10:04022a61b527 4036 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 4037 break;
whismanoid 10:04022a61b527 4038 }
whismanoid 10:04022a61b527 4039 if (rx_string_length >= g_auxSerialCom_rx_max_count) {
whismanoid 10:04022a61b527 4040 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 4041 break;
whismanoid 10:04022a61b527 4042 }
whismanoid 10:04022a61b527 4043 if (AuxSerial.readable()) {
whismanoid 10:04022a61b527 4044 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 4045 char ch = AuxSerial.getc();
whismanoid 10:04022a61b527 4046 rx_string_buf[rx_string_length++] = ch;
whismanoid 10:04022a61b527 4047 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 10:04022a61b527 4048 cmdLine.serial().printf("%s", &(rx_string_buf[rx_string_length-1]) ); // immediate character echo
whismanoid 10:04022a61b527 4049 if (g_auxSerialCom_rx_eot != aux_serial_cmd_forwarding_rx_eot_not_used) {
whismanoid 10:04022a61b527 4050 if (ch == g_auxSerialCom_rx_eot) {
whismanoid 10:04022a61b527 4051 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 4052 break;
whismanoid 10:04022a61b527 4053 }
whismanoid 10:04022a61b527 4054 }
whismanoid 10:04022a61b527 4055 }
whismanoid 10:04022a61b527 4056 } // end while (rx_string_length < (RX_STRING_BUF_SIZE-1))
whismanoid 10:04022a61b527 4057 #if 1
whismanoid 10:04022a61b527 4058 // print summary. is this needed? we already print aux rx as it is received.
whismanoid 10:04022a61b527 4059 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 10:04022a61b527 4060 cmdLine.serial().printf("\r\n >%s", outgoing_string);
whismanoid 10:04022a61b527 4061 cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 10:04022a61b527 4062 #endif
whismanoid 10:04022a61b527 4063 //
whismanoid 10:04022a61b527 4064 }
whismanoid 10:04022a61b527 4065 break; // case '>'
whismanoid 10:04022a61b527 4066 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 4067 //
whismanoid 4:d9b05924ad4c 4068 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 4069 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 4070 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 4071 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 4072 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible
whismanoid 9:45f98573eb6d 4073 case 'L': case 'l':
whismanoid 4:d9b05924ad4c 4074 {
whismanoid 4:d9b05924ad4c 4075 // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 4076 Datalogger_Trigger = trigger_Halt;
whismanoid 4:d9b05924ad4c 4077 switch (cmdLine[1])
whismanoid 4:d9b05924ad4c 4078 {
whismanoid 17:9397ea3ea7e9 4079 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 4080 case 'T': case 't':
whismanoid 17:9397ea3ea7e9 4081 {
whismanoid 17:9397ea3ea7e9 4082 // timer (configure interval) "intermittent-sleep-mode"
whismanoid 17:9397ea3ea7e9 4083 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 4084 Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 4085 g_timer_interval_counter = 0;
whismanoid 17:9397ea3ea7e9 4086 // TODO: get g_timer_interval_msec from cmdLine
whismanoid 17:9397ea3ea7e9 4087 // g_timer_interval_msec = 500;
whismanoid 17:9397ea3ea7e9 4088 // g_timer_interval_count = 10;
whismanoid 17:9397ea3ea7e9 4089 if (cmdLine.parse_int_dec("count", g_timer_interval_count))
whismanoid 17:9397ea3ea7e9 4090 {
whismanoid 17:9397ea3ea7e9 4091 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 4092 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 4093 cmdLine.serial().printf("\r\n g_timer_interval_count=%d", g_timer_interval_count);
whismanoid 17:9397ea3ea7e9 4094 }
whismanoid 17:9397ea3ea7e9 4095 if (cmdLine.parse_int_dec("base", g_timer_interval_msec))
whismanoid 17:9397ea3ea7e9 4096 {
whismanoid 17:9397ea3ea7e9 4097 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 17:9397ea3ea7e9 4098 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 17:9397ea3ea7e9 4099 cmdLine.serial().printf("\r\n g_timer_interval_msec=%d", g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 4100 }
whismanoid 17:9397ea3ea7e9 4101 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 17:9397ea3ea7e9 4102 }
whismanoid 17:9397ea3ea7e9 4103 break;
whismanoid 17:9397ea3ea7e9 4104 // LIH3 -- Datalog when input high D3
whismanoid 17:9397ea3ea7e9 4105 // LIL6 -- Datalog when input low D6
whismanoid 17:9397ea3ea7e9 4106 case 'I': case 'i':
whismanoid 17:9397ea3ea7e9 4107 {
whismanoid 17:9397ea3ea7e9 4108 // TODO: switch cmdLine[2] configure High or Low, configure input pin
whismanoid 17:9397ea3ea7e9 4109 }
whismanoid 17:9397ea3ea7e9 4110 break;
whismanoid 17:9397ea3ea7e9 4111 #if USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 4112 // L$regaddr@dataMask=testValue -- Datalog when SPI read of address matches mask
whismanoid 17:9397ea3ea7e9 4113 case '$':
whismanoid 17:9397ea3ea7e9 4114 {
whismanoid 17:9397ea3ea7e9 4115 // TODO: scan cmdLine for regAddr, dataMask, testValue
whismanoid 17:9397ea3ea7e9 4116 }
whismanoid 17:9397ea3ea7e9 4117 break;
whismanoid 17:9397ea3ea7e9 4118 #endif // USE_DATALOGGER_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 4119 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 4120 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 4121 case '@':
whismanoid 17:9397ea3ea7e9 4122 {
whismanoid 17:9397ea3ea7e9 4123 // L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 4124 int editRowIndex = 0;
whismanoid 17:9397ea3ea7e9 4125 int edit_action = (int)action_noop;
whismanoid 17:9397ea3ea7e9 4126 int edit_digitalOutPin = 0;
whismanoid 17:9397ea3ea7e9 4127 int edit_condition = (int)condition_always;
whismanoid 17:9397ea3ea7e9 4128 int edit_condition_channel = 0;
whismanoid 17:9397ea3ea7e9 4129 double edit_condition_threshold = 0;
whismanoid 17:9397ea3ea7e9 4130 //
whismanoid 17:9397ea3ea7e9 4131 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 17:9397ea3ea7e9 4132 {
whismanoid 17:9397ea3ea7e9 4133 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 17:9397ea3ea7e9 4134 }
whismanoid 17:9397ea3ea7e9 4135 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 17:9397ea3ea7e9 4136 {
whismanoid 17:9397ea3ea7e9 4137 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 17:9397ea3ea7e9 4138 }
whismanoid 17:9397ea3ea7e9 4139 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 17:9397ea3ea7e9 4140 {
whismanoid 17:9397ea3ea7e9 4141 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 17:9397ea3ea7e9 4142 }
whismanoid 17:9397ea3ea7e9 4143 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 17:9397ea3ea7e9 4144 {
whismanoid 17:9397ea3ea7e9 4145 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 17:9397ea3ea7e9 4146 }
whismanoid 17:9397ea3ea7e9 4147 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 17:9397ea3ea7e9 4148 {
whismanoid 17:9397ea3ea7e9 4149 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 17:9397ea3ea7e9 4150 }
whismanoid 17:9397ea3ea7e9 4151 //
whismanoid 17:9397ea3ea7e9 4152 // Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 4153 switch (cmdLine[2]) // L@... -- Edit the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 4154 {
whismanoid 17:9397ea3ea7e9 4155 // LT%1.0fs -- Datalog timer sleep=%1.3f seconds g_timer_interval_msec
whismanoid 17:9397ea3ea7e9 4156 case '0': case '1': case '2': case '3': case '4':
whismanoid 17:9397ea3ea7e9 4157 case '5': case '6': case '7': case '8': case '9':
whismanoid 17:9397ea3ea7e9 4158 // edit row data
whismanoid 17:9397ea3ea7e9 4159 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 4160 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 4161 // get row number to edit from cmdLine[2]
whismanoid 17:9397ea3ea7e9 4162 editRowIndex = atoi(cmdLine.str()+2);
whismanoid 17:9397ea3ea7e9 4163 // default is no change
whismanoid 17:9397ea3ea7e9 4164 edit_action = Datalogger_action_table[editRowIndex].action;
whismanoid 17:9397ea3ea7e9 4165 edit_digitalOutPin = Datalogger_action_table[editRowIndex].digitalOutPin;
whismanoid 17:9397ea3ea7e9 4166 edit_condition = Datalogger_action_table[editRowIndex].condition;
whismanoid 17:9397ea3ea7e9 4167 edit_condition_channel = Datalogger_action_table[editRowIndex].condition_channel;
whismanoid 17:9397ea3ea7e9 4168 edit_condition_threshold = Datalogger_action_table[editRowIndex].condition_threshold;
whismanoid 17:9397ea3ea7e9 4169 // scan cmdLine[2] for key=value of what fields to change
whismanoid 17:9397ea3ea7e9 4170 if (cmdLine.parse_int_dec("act", edit_action))
whismanoid 17:9397ea3ea7e9 4171 {
whismanoid 17:9397ea3ea7e9 4172 //~ cmdLine.serial().printf("\r\n act=%d", edit_action);
whismanoid 17:9397ea3ea7e9 4173 }
whismanoid 17:9397ea3ea7e9 4174 if (cmdLine.parse_int_dec("pin", edit_digitalOutPin))
whismanoid 17:9397ea3ea7e9 4175 {
whismanoid 17:9397ea3ea7e9 4176 //~ cmdLine.serial().printf("\r\n pin=%d", edit_digitalOutPin);
whismanoid 17:9397ea3ea7e9 4177 }
whismanoid 17:9397ea3ea7e9 4178 if (cmdLine.parse_int_dec("if", edit_condition))
whismanoid 17:9397ea3ea7e9 4179 {
whismanoid 17:9397ea3ea7e9 4180 //~ cmdLine.serial().printf("\r\n if=%d", edit_condition);
whismanoid 17:9397ea3ea7e9 4181 }
whismanoid 17:9397ea3ea7e9 4182 if (cmdLine.parse_int_dec("ch", edit_condition_channel))
whismanoid 17:9397ea3ea7e9 4183 {
whismanoid 17:9397ea3ea7e9 4184 //~ cmdLine.serial().printf("\r\n ch=%d", edit_condition_channel);
whismanoid 17:9397ea3ea7e9 4185 }
whismanoid 17:9397ea3ea7e9 4186 if (cmdLine.parse_double("x", edit_condition_threshold))
whismanoid 17:9397ea3ea7e9 4187 {
whismanoid 17:9397ea3ea7e9 4188 //~ cmdLine.serial().printf("\r\n x=%d", edit_condition_threshold);
whismanoid 17:9397ea3ea7e9 4189 }
whismanoid 17:9397ea3ea7e9 4190 // update row
whismanoid 17:9397ea3ea7e9 4191 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 17:9397ea3ea7e9 4192 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 17:9397ea3ea7e9 4193 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 17:9397ea3ea7e9 4194 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 17:9397ea3ea7e9 4195 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 4196 }
whismanoid 17:9397ea3ea7e9 4197 break;
whismanoid 17:9397ea3ea7e9 4198 case '+':
whismanoid 17:9397ea3ea7e9 4199 // add a new row at end of table
whismanoid 17:9397ea3ea7e9 4200 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 4201 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 4202 editRowIndex = Datalogger_action_table_row_count;
whismanoid 17:9397ea3ea7e9 4203 Datalogger_action_table_row_count++;
whismanoid 17:9397ea3ea7e9 4204 Datalogger_action_table[editRowIndex].action = (action_type_enum_t)edit_action;
whismanoid 17:9397ea3ea7e9 4205 Datalogger_action_table[editRowIndex].digitalOutPin = edit_digitalOutPin;
whismanoid 17:9397ea3ea7e9 4206 Datalogger_action_table[editRowIndex].condition = (action_condition_enum_t)edit_condition;
whismanoid 17:9397ea3ea7e9 4207 Datalogger_action_table[editRowIndex].condition_channel = edit_condition_channel;
whismanoid 17:9397ea3ea7e9 4208 Datalogger_action_table[editRowIndex].condition_threshold = edit_condition_threshold;
whismanoid 17:9397ea3ea7e9 4209 }
whismanoid 17:9397ea3ea7e9 4210 break;
whismanoid 17:9397ea3ea7e9 4211 case '-':
whismanoid 17:9397ea3ea7e9 4212 // delete row from table
whismanoid 17:9397ea3ea7e9 4213 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 4214 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 4215 if ((cmdLine[3] == '~') && (cmdLine[4] == '~') && (cmdLine[5] == '~')) {
whismanoid 17:9397ea3ea7e9 4216 // L@-~~~ -- delete all rows from table
whismanoid 17:9397ea3ea7e9 4217 Datalogger_action_table_row_count = 0;
whismanoid 17:9397ea3ea7e9 4218 break;
whismanoid 17:9397ea3ea7e9 4219 }
whismanoid 17:9397ea3ea7e9 4220 editRowIndex = atoi(cmdLine.str()+3);
whismanoid 17:9397ea3ea7e9 4221 // delete row editRowIndex from Datalogger_action_table
whismanoid 17:9397ea3ea7e9 4222 for (int i = editRowIndex; i < (Datalogger_action_table_row_count-1); i++)
whismanoid 17:9397ea3ea7e9 4223 {
whismanoid 17:9397ea3ea7e9 4224 // copy row i+1 into row i
whismanoid 17:9397ea3ea7e9 4225 Datalogger_action_table[i].action = Datalogger_action_table[i+1].action;
whismanoid 17:9397ea3ea7e9 4226 Datalogger_action_table[i].digitalOutPin = Datalogger_action_table[i+1].digitalOutPin;
whismanoid 17:9397ea3ea7e9 4227 Datalogger_action_table[i].condition = Datalogger_action_table[i+1].condition;
whismanoid 17:9397ea3ea7e9 4228 Datalogger_action_table[i].condition_channel = Datalogger_action_table[i+1].condition_channel;
whismanoid 17:9397ea3ea7e9 4229 Datalogger_action_table[i].condition_threshold = Datalogger_action_table[i+1].condition_threshold;
whismanoid 17:9397ea3ea7e9 4230 }
whismanoid 17:9397ea3ea7e9 4231 Datalogger_action_table_row_count--;
whismanoid 17:9397ea3ea7e9 4232 }
whismanoid 17:9397ea3ea7e9 4233 break;
whismanoid 17:9397ea3ea7e9 4234 case '!':
whismanoid 17:9397ea3ea7e9 4235 // pause the entire action table
whismanoid 17:9397ea3ea7e9 4236 Datalogger_action_table_enabled = false;
whismanoid 17:9397ea3ea7e9 4237 break;
whismanoid 17:9397ea3ea7e9 4238 case '@':
whismanoid 17:9397ea3ea7e9 4239 // enable the entire action table
whismanoid 17:9397ea3ea7e9 4240 Datalogger_action_table_enabled = true;
whismanoid 17:9397ea3ea7e9 4241 break;
whismanoid 17:9397ea3ea7e9 4242 }
whismanoid 17:9397ea3ea7e9 4243 //
whismanoid 17:9397ea3ea7e9 4244 // Print the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 4245 if (Datalogger_action_table_enabled) {
whismanoid 17:9397ea3ea7e9 4246 cmdLine.serial().printf("Action table enabled; L@! to pause");
whismanoid 17:9397ea3ea7e9 4247 }
whismanoid 17:9397ea3ea7e9 4248 else {
whismanoid 17:9397ea3ea7e9 4249 cmdLine.serial().printf("Action table paused; L@@ to enable");
whismanoid 17:9397ea3ea7e9 4250 }
whismanoid 17:9397ea3ea7e9 4251 //~ cmdLine.serial().printf("\r\n Datalogger_action_table_row_count=%d", Datalogger_action_table_row_count);
whismanoid 17:9397ea3ea7e9 4252 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 4253 {
whismanoid 17:9397ea3ea7e9 4254 cmdLine.serial().printf("\r\n L@%d", i);
whismanoid 17:9397ea3ea7e9 4255 cmdLine.serial().printf(" act=%d", Datalogger_action_table[i].action);
whismanoid 17:9397ea3ea7e9 4256 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 4257 {
whismanoid 17:9397ea3ea7e9 4258 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 4259 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 4260 cmdLine.serial().printf(" pin=%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 4261 break;
whismanoid 17:9397ea3ea7e9 4262 default:
whismanoid 17:9397ea3ea7e9 4263 case action_noop:
whismanoid 17:9397ea3ea7e9 4264 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 4265 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 4266 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 4267 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 4268 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 4269 break;
whismanoid 17:9397ea3ea7e9 4270 }
whismanoid 17:9397ea3ea7e9 4271 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 4272 {
whismanoid 17:9397ea3ea7e9 4273 case condition_always:
whismanoid 17:9397ea3ea7e9 4274 break;
whismanoid 17:9397ea3ea7e9 4275 default:
whismanoid 17:9397ea3ea7e9 4276 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 4277 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 4278 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 4279 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 4280 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 4281 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 4282 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 4283 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 4284 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 4285 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 4286 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 4287 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 4288 cmdLine.serial().printf(" if=%d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 4289 cmdLine.serial().printf(" ch=%d", Datalogger_action_table[i].condition_channel);
whismanoid 17:9397ea3ea7e9 4290 cmdLine.serial().printf(" x=%f", Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4291 break;
whismanoid 17:9397ea3ea7e9 4292 }
whismanoid 17:9397ea3ea7e9 4293 cmdLine.serial().printf(" -- ");
whismanoid 17:9397ea3ea7e9 4294 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 4295 {
whismanoid 17:9397ea3ea7e9 4296 case action_noop:
whismanoid 17:9397ea3ea7e9 4297 cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 4298 break;
whismanoid 17:9397ea3ea7e9 4299 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 4300 cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 4301 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 4302 break;
whismanoid 17:9397ea3ea7e9 4303 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 4304 cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 4305 cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 4306 break;
whismanoid 17:9397ea3ea7e9 4307 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 4308 cmdLine.serial().printf("trigger_Halt");
whismanoid 17:9397ea3ea7e9 4309 break;
whismanoid 17:9397ea3ea7e9 4310 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 4311 cmdLine.serial().printf("trigger_FreeRun");
whismanoid 17:9397ea3ea7e9 4312 break;
whismanoid 17:9397ea3ea7e9 4313 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 4314 cmdLine.serial().printf("trigger_Timer");
whismanoid 17:9397ea3ea7e9 4315 // print configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 4316 cmdLine.serial().printf("(%d x %dmsec)", g_timer_interval_count, g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 4317 break;
whismanoid 17:9397ea3ea7e9 4318 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 4319 cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 4320 // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 4321 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 4322 break;
whismanoid 17:9397ea3ea7e9 4323 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 4324 cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 4325 // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 4326 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 4327 break;
whismanoid 17:9397ea3ea7e9 4328 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 4329 //~ cmdLine.serial().printf(" condition %d", Datalogger_action_table[i].condition);
whismanoid 17:9397ea3ea7e9 4330 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 4331 {
whismanoid 17:9397ea3ea7e9 4332 case condition_always:
whismanoid 17:9397ea3ea7e9 4333 cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 4334 break;
whismanoid 17:9397ea3ea7e9 4335 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 4336 cmdLine.serial().printf(" if A%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4337 break;
whismanoid 17:9397ea3ea7e9 4338 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 4339 cmdLine.serial().printf(" if A%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4340 break;
whismanoid 17:9397ea3ea7e9 4341 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 4342 cmdLine.serial().printf(" if A%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4343 break;
whismanoid 17:9397ea3ea7e9 4344 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 4345 cmdLine.serial().printf(" if A%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4346 break;
whismanoid 17:9397ea3ea7e9 4347 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 4348 cmdLine.serial().printf(" if A%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4349 break;
whismanoid 17:9397ea3ea7e9 4350 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 4351 cmdLine.serial().printf(" if A%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4352 break;
whismanoid 17:9397ea3ea7e9 4353 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 4354 cmdLine.serial().printf(" if AIN%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4355 break;
whismanoid 17:9397ea3ea7e9 4356 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 4357 cmdLine.serial().printf(" if AIN%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4358 break;
whismanoid 17:9397ea3ea7e9 4359 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 4360 cmdLine.serial().printf(" if AIN%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4361 break;
whismanoid 17:9397ea3ea7e9 4362 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 4363 cmdLine.serial().printf(" if AIN%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4364 break;
whismanoid 17:9397ea3ea7e9 4365 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 4366 cmdLine.serial().printf(" if AIN%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4367 break;
whismanoid 17:9397ea3ea7e9 4368 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 4369 cmdLine.serial().printf(" if AIN%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4370 break;
whismanoid 17:9397ea3ea7e9 4371 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 4372 } // for ...Datalogger_action_table_row_count // Print the contents of Datalogger_action_table
whismanoid 17:9397ea3ea7e9 4373 cmdLine.serial().printf("\r\nAction table editing commands:");
whismanoid 17:9397ea3ea7e9 4374 if (Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX) {
whismanoid 17:9397ea3ea7e9 4375 // if Datalogger_action_table_row_count => ACTION_TABLE_ROW_MAX then the table is full
whismanoid 17:9397ea3ea7e9 4376 cmdLine.serial().printf("\r\n L@+ act=4 if=1 ch=5 x=12345 -- add new entry at end of table");
whismanoid 17:9397ea3ea7e9 4377 }
whismanoid 17:9397ea3ea7e9 4378 if (Datalogger_action_table_row_count > 0) {
whismanoid 17:9397ea3ea7e9 4379 // if Datalogger_action_table_row_count == 0 then the table is empty
whismanoid 17:9397ea3ea7e9 4380 cmdLine.serial().printf("\r\n L@%d act=4 if=1 ch=5 x=12345 -- edit row %d",
whismanoid 17:9397ea3ea7e9 4381 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 4382 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 4383 cmdLine.serial().printf("\r\n L@-%d -- delete row %d",
whismanoid 17:9397ea3ea7e9 4384 Datalogger_action_table_row_count-1,
whismanoid 17:9397ea3ea7e9 4385 Datalogger_action_table_row_count-1);
whismanoid 17:9397ea3ea7e9 4386 cmdLine.serial().printf("\r\n L@-~~~ -- delete all rows");
whismanoid 17:9397ea3ea7e9 4387 cmdLine.serial().printf("\r\n L@! -- pause entire action table");
whismanoid 17:9397ea3ea7e9 4388 cmdLine.serial().printf("\r\n L@@ -- enable action table");
whismanoid 17:9397ea3ea7e9 4389 }
whismanoid 17:9397ea3ea7e9 4390 //
whismanoid 17:9397ea3ea7e9 4391 } // case L@ -- configures Datalogger_action_table
whismanoid 17:9397ea3ea7e9 4392 break;
whismanoid 17:9397ea3ea7e9 4393 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 4394 // LR -- Datalog free run as fast as possible
whismanoid 4:d9b05924ad4c 4395 case 'R': case 'r':
whismanoid 4:d9b05924ad4c 4396 // free run as fast as possible
whismanoid 8:dffee7509bfb 4397 Datalogger_Trigger = trigger_FreeRun;
whismanoid 8:dffee7509bfb 4398 Datalogger_Need_PrintHeader = true;
whismanoid 4:d9b05924ad4c 4399 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 9:45f98573eb6d 4400 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 4401 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 4402 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 4403 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 4404 case 'S': case 's':
whismanoid 9:45f98573eb6d 4405 {
whismanoid 9:45f98573eb6d 4406 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 4407 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 4408 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 4409 )
whismanoid 9:45f98573eb6d 4410 {
whismanoid 9:45f98573eb6d 4411 // it's me
whismanoid 9:45f98573eb6d 4412 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 4413 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 4414 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 4415 {
whismanoid 9:45f98573eb6d 4416 case 'D': case 'd':
whismanoid 9:45f98573eb6d 4417 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Disable;
whismanoid 9:45f98573eb6d 4418 break;
whismanoid 9:45f98573eb6d 4419 case 'L': case 'l':
whismanoid 9:45f98573eb6d 4420 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 4421 break;
whismanoid 9:45f98573eb6d 4422 case 'V': case 'v':
whismanoid 9:45f98573eb6d 4423 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 4424 break;
whismanoid 9:45f98573eb6d 4425 //
whismanoid 9:45f98573eb6d 4426 //
whismanoid 9:45f98573eb6d 4427 // TODO: MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 4428 case 'C': case 'c':
whismanoid 9:45f98573eb6d 4429 {
whismanoid 9:45f98573eb6d 4430 uint8_t hexValue = 0;
whismanoid 9:45f98573eb6d 4431 hexValue = hexValueOfChar(cmdLine[5]) * 0x10 + hexValueOfChar(cmdLine[6]);
whismanoid 9:45f98573eb6d 4432 switch (cmdLine[4])
whismanoid 9:45f98573eb6d 4433 {
whismanoid 9:45f98573eb6d 4434 //
whismanoid 9:45f98573eb6d 4435 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 4436 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34"));
whismanoid 9:45f98573eb6d 4437 case 'F': case 'f':
whismanoid 9:45f98573eb6d 4438 SPI_AIN_Cfg_v_filter_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 4439 break;
whismanoid 9:45f98573eb6d 4440 //
whismanoid 9:45f98573eb6d 4441 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 4442 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 4443 case 'C': case 'c':
whismanoid 9:45f98573eb6d 4444 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 4445 break;
whismanoid 9:45f98573eb6d 4446 //
whismanoid 9:45f98573eb6d 4447 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 4448 // cmdLine.serial().print(F("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00"));
whismanoid 9:45f98573eb6d 4449 case 'P': case 'p':
whismanoid 9:45f98573eb6d 4450 SPI_AIN_Cfg_v_pga_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 4451 break;
whismanoid 9:45f98573eb6d 4452 //
whismanoid 9:45f98573eb6d 4453 // cmdLine.serial().print(F("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar"));
whismanoid 9:45f98573eb6d 4454 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 4455 case 'U': case 'u':
whismanoid 9:45f98573eb6d 4456 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] | 0x40;
whismanoid 9:45f98573eb6d 4457 break;
whismanoid 9:45f98573eb6d 4458 //
whismanoid 9:45f98573eb6d 4459 // cmdLine.serial().print(F("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar"));
whismanoid 9:45f98573eb6d 4460 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 4461 case 'B': case 'b':
whismanoid 9:45f98573eb6d 4462 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] &~ 0x40;
whismanoid 9:45f98573eb6d 4463 break;
whismanoid 9:45f98573eb6d 4464 }
whismanoid 9:45f98573eb6d 4465 break;
whismanoid 9:45f98573eb6d 4466 }
whismanoid 9:45f98573eb6d 4467 //
whismanoid 9:45f98573eb6d 4468 //
whismanoid 9:45f98573eb6d 4469 }
whismanoid 9:45f98573eb6d 4470 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 4471 } // end for channel_index
whismanoid 9:45f98573eb6d 4472 Datalogger_PrintHeader();
whismanoid 9:45f98573eb6d 4473 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 4474 }
whismanoid 9:45f98573eb6d 4475 break;
whismanoid 9:45f98573eb6d 4476 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 4477 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 4478 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 4479 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 4480 // verb: D for disable, V for Voltage, L for LSB
whismanoid 8:dffee7509bfb 4481 case 'A': case 'a':
whismanoid 9:45f98573eb6d 4482 {
whismanoid 9:45f98573eb6d 4483 // all-channel: loop through all valid channel_index, test cmdLine[2] 'is it me'?
whismanoid 9:45f98573eb6d 4484 // for channel_index loop through 0..NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 9:45f98573eb6d 4485 // if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 4486 // || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 4487 // ) {
whismanoid 9:45f98573eb6d 4488 // // it's me
whismanoid 9:45f98573eb6d 4489 // // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 4490 // // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 4491 // } end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 4492 // } end for channel_index
whismanoid 9:45f98573eb6d 4493 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 4494 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 4495 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 4496 )
whismanoid 9:45f98573eb6d 4497 {
whismanoid 9:45f98573eb6d 4498 // it's me
whismanoid 9:45f98573eb6d 4499 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 4500 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 4501 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 4502 {
whismanoid 9:45f98573eb6d 4503 case 'D': case 'd':
whismanoid 9:45f98573eb6d 4504 Platform_Enable_ch[channel_index] = Platform_AIN_Disable;
whismanoid 9:45f98573eb6d 4505 break;
whismanoid 9:45f98573eb6d 4506 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4507 case 'L': case 'l':
whismanoid 9:45f98573eb6d 4508 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 4509 break;
whismanoid 9:45f98573eb6d 4510 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 4511 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4512 case 'V': case 'v':
whismanoid 9:45f98573eb6d 4513 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 4514 break;
whismanoid 9:45f98573eb6d 4515 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 4516 }
whismanoid 9:45f98573eb6d 4517 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 4518 } // end for channel_index
whismanoid 10:04022a61b527 4519 // Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 4520 if (Datalogger_enable_serial) {
whismanoid 9:45f98573eb6d 4521 Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 4522 }
whismanoid 9:45f98573eb6d 4523 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 4524 if (Datalogger_enable_AUXserial) {
whismanoid 9:45f98573eb6d 4525 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 9:45f98573eb6d 4526 }
whismanoid 9:45f98573eb6d 4527 # endif // HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 4528 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 4529 if (Datalogger_enable_DAPLINKserial) {
whismanoid 9:45f98573eb6d 4530 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 9:45f98573eb6d 4531 }
whismanoid 9:45f98573eb6d 4532 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 4533 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 4534 }
whismanoid 8:dffee7509bfb 4535 break;
whismanoid 9:45f98573eb6d 4536 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 4537 case '>':
whismanoid 9:45f98573eb6d 4538 // L>A -- Datalogger_enable_AUXserial
whismanoid 9:45f98573eb6d 4539 // L>D -- Datalogger_enable_DAPLINKserial
whismanoid 9:45f98573eb6d 4540 // L>S -- Datalogger_enable_serial
whismanoid 9:45f98573eb6d 4541 switch (cmdLine[2])
whismanoid 9:45f98573eb6d 4542 {
whismanoid 9:45f98573eb6d 4543 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 4544 case 'A': case 'a':
whismanoid 9:45f98573eb6d 4545 Datalogger_enable_AUXserial = !Datalogger_enable_AUXserial;
whismanoid 9:45f98573eb6d 4546 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 4547 break;
whismanoid 8:dffee7509bfb 4548 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 4549 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 4550 case 'D': case 'd':
whismanoid 9:45f98573eb6d 4551 Datalogger_enable_DAPLINKserial = !Datalogger_enable_DAPLINKserial;
whismanoid 9:45f98573eb6d 4552 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 4553 break;
whismanoid 8:dffee7509bfb 4554 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 4555 case 'S': case 's':
whismanoid 9:45f98573eb6d 4556 Datalogger_enable_serial = !Datalogger_enable_serial;
whismanoid 9:45f98573eb6d 4557 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 4558 break;
whismanoid 9:45f98573eb6d 4559 }
whismanoid 9:45f98573eb6d 4560 break; // case '>' L>S serial enable toggle
whismanoid 17:9397ea3ea7e9 4561 } // switch (cmdLine[1]) inside case 'L'
whismanoid 4:d9b05924ad4c 4562 }
whismanoid 4:d9b05924ad4c 4563 break; // case 'L'
whismanoid 4:d9b05924ad4c 4564 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 4565 //
whismanoid 4:d9b05924ad4c 4566 // Application-specific commands here
whismanoid 4:d9b05924ad4c 4567 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 4568 //
whismanoid 4:d9b05924ad4c 4569 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 4570 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 4571
whismanoid 4:d9b05924ad4c 4572 //
whismanoid 4:d9b05924ad4c 4573 // TODO1: add new commands here
whismanoid 4:d9b05924ad4c 4574 //
whismanoid 4:d9b05924ad4c 4575 default:
whismanoid 4:d9b05924ad4c 4576 #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 4577 extern bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5715.cpp
whismanoid 4:d9b05924ad4c 4578 if (!MAX5715_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 4579 #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 4580 extern bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11131.cpp
whismanoid 4:d9b05924ad4c 4581 if (!MAX11131_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 4582 #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 4583 extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp
whismanoid 4:d9b05924ad4c 4584 if (!MAX5171_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 4585 #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 4586 extern bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp
whismanoid 4:d9b05924ad4c 4587 if (!MAX11410_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 4588 #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 4589 extern bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX12345.cpp
whismanoid 4:d9b05924ad4c 4590 if (!MAX12345_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 4591 #else
whismanoid 4:d9b05924ad4c 4592 if (0) // not_handled_by_device_submenu
whismanoid 4:d9b05924ad4c 4593 #endif
whismanoid 4:d9b05924ad4c 4594 {
whismanoid 4:d9b05924ad4c 4595 cmdLine.serial().printf("\r\n unknown command ");
whismanoid 4:d9b05924ad4c 4596 //~ cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 4597 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 4598 cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n",
whismanoid 4:d9b05924ad4c 4599 cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 4600 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 4601 }
whismanoid 4:d9b05924ad4c 4602 } // switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 4603 //
whismanoid 4:d9b05924ad4c 4604 // print command prompt
whismanoid 8:dffee7509bfb 4605 // print_command_prompt();
whismanoid 8:dffee7509bfb 4606 cmdLine.serial().printf("\r\n> ");
whismanoid 4:d9b05924ad4c 4607 }
whismanoid 4:d9b05924ad4c 4608 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 4609
whismanoid 4:d9b05924ad4c 4610 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 4611 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 4612 void Datalogger_PrintHeader(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 4613 {
whismanoid 4:d9b05924ad4c 4614 // column header banner for csv data columns
whismanoid 4:d9b05924ad4c 4615 int field_index = 0;
whismanoid 4:d9b05924ad4c 4616 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 4617 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 4618 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 4:d9b05924ad4c 4619 continue;
whismanoid 4:d9b05924ad4c 4620 }
whismanoid 4:d9b05924ad4c 4621 // comma between fields
whismanoid 4:d9b05924ad4c 4622 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 4623 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 4624 }
whismanoid 10:04022a61b527 4625 field_index++;
whismanoid 4:d9b05924ad4c 4626 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 4627 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 4628 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 4:d9b05924ad4c 4629 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 4:d9b05924ad4c 4630 cmdLine.serial().printf("\"AIN%d-%d_BIP", channel_index, channel_index+1);
whismanoid 4:d9b05924ad4c 4631 }
whismanoid 4:d9b05924ad4c 4632 else {
whismanoid 4:d9b05924ad4c 4633 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 4634 }
whismanoid 4:d9b05924ad4c 4635 #else // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 4636 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 4637 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 4638 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_LSB) {
whismanoid 4:d9b05924ad4c 4639 // _LSB column header suffix
whismanoid 13:184a08909405 4640 cmdLine.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 4641 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 4642 cmdLine_DAPLINKserial.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 4643 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 4644 }
whismanoid 10:04022a61b527 4645 else if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_Volt) {
whismanoid 4:d9b05924ad4c 4646 // _V column header suffix
whismanoid 13:184a08909405 4647 cmdLine.serial().printf("_V");
whismanoid 4:d9b05924ad4c 4648 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 4649 cmdLine_DAPLINKserial.serial().printf("_V");
whismanoid 4:d9b05924ad4c 4650 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 4651 }
whismanoid 13:184a08909405 4652 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 4653 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 4654 if (SPI_AIN_customChannelHeader_ch[channel_index] && SPI_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 4655 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 4656 cmdLine.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 4657 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 4658 cmdLine_DAPLINKserial.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 4659 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 4660 } else {
whismanoid 13:184a08909405 4661 // no custom channel name for this channel
whismanoid 13:184a08909405 4662 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 4663 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 4664 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 4665 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 4666 }
whismanoid 13:184a08909405 4667 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 4668 // close quote
whismanoid 13:184a08909405 4669 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 4670 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 4671 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 4672 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 4673 }
whismanoid 4:d9b05924ad4c 4674
whismanoid 4:d9b05924ad4c 4675 #if VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 4676 // PART_ID field: Device ID Validation
whismanoid 4:d9b05924ad4c 4677 cmdLine.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 4678 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 4679 cmdLine_DAPLINKserial.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 4680 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 4681 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 4682 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 4683 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 4684 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 4685 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 4686 continue;
whismanoid 9:45f98573eb6d 4687 }
whismanoid 4:d9b05924ad4c 4688 // comma between fields
whismanoid 4:d9b05924ad4c 4689 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 4690 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 4691 }
whismanoid 9:45f98573eb6d 4692 field_index++;
whismanoid 4:d9b05924ad4c 4693 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 4694 cmdLine.serial().printf("\"A%d", channel_index);
whismanoid 9:45f98573eb6d 4695 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 9:45f98573eb6d 4696 // _LSB column header suffix
whismanoid 13:184a08909405 4697 cmdLine.serial().printf("_LSB");
whismanoid 9:45f98573eb6d 4698 }
whismanoid 9:45f98573eb6d 4699 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 4700 // _V column header suffix
whismanoid 13:184a08909405 4701 cmdLine.serial().printf("_V");
whismanoid 9:45f98573eb6d 4702 }
whismanoid 13:184a08909405 4703 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 4704 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 4705 if (Platform_AIN_customChannelHeader_ch[channel_index] && Platform_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 4706 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 4707 cmdLine.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 4708 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 4709 cmdLine_DAPLINKserial.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 4710 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 4711 } else {
whismanoid 13:184a08909405 4712 // no custom channel name for this channel
whismanoid 13:184a08909405 4713 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 4714 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 4715 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 4716 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 4717 }
whismanoid 13:184a08909405 4718 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 4719 // close quote
whismanoid 13:184a08909405 4720 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 4721 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 4722 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 4723 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 4724 }
whismanoid 4:d9b05924ad4c 4725 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 4:d9b05924ad4c 4726 // end of column header line
whismanoid 4:d9b05924ad4c 4727 cmdLine.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 4728 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 4729 cmdLine_DAPLINKserial.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 4730 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 4731 } // void Datalogger_PrintHeader()
whismanoid 4:d9b05924ad4c 4732
whismanoid 5:aaf8b5f5fda1 4733 //--------------------------------------------------
whismanoid 5:aaf8b5f5fda1 4734 void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 4735 {
whismanoid 5:aaf8b5f5fda1 4736 // CODE GENERATOR: example code: has no member function ScanStandardExternalClock
whismanoid 5:aaf8b5f5fda1 4737 // CODE GENERATOR: example code: has no member function ReadAINcode
whismanoid 5:aaf8b5f5fda1 4738 // CODE GENERATOR: example code: member function Read_All_Voltages
whismanoid 5:aaf8b5f5fda1 4739 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 4740 // Measure ADC channels in sequence from AIN0 to channelNumber_0_9.
whismanoid 5:aaf8b5f5fda1 4741 // @param[in] g_MAX11410_device.channelNumber_0_15: AIN Channel Number
whismanoid 5:aaf8b5f5fda1 4742 // @param[in] g_MAX11410_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
whismanoid 5:aaf8b5f5fda1 4743 // @param[in] g_MAX11410_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
whismanoid 10:04022a61b527 4744 //~ int channelId_0_9 = NUM_DUT_ANALOG_IN_CHANNELS-1+1;
whismanoid 5:aaf8b5f5fda1 4745 //g_MAX11410_device.channelNumber_0_15 = channelId_0_9;
whismanoid 5:aaf8b5f5fda1 4746 //g_MAX11410_device.PowerManagement_0_2 = 0;
whismanoid 5:aaf8b5f5fda1 4747 //g_MAX11410_device.chan_id_0_1 = 1;
whismanoid 5:aaf8b5f5fda1 4748 //----------------------------------------
whismanoid 5:aaf8b5f5fda1 4749 // scan AIN0..AIN9
whismanoid 5:aaf8b5f5fda1 4750 //
whismanoid 10:04022a61b527 4751 #if 1
whismanoid 10:04022a61b527 4752 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 4753 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 4754 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 4755 //
whismanoid 10:04022a61b527 4756 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 4757 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc3); // GP1 = 0
whismanoid 10:04022a61b527 4758 //
whismanoid 10:04022a61b527 4759 int field_index = 0;
whismanoid 10:04022a61b527 4760 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 4761 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 10:04022a61b527 4762 continue;
whismanoid 10:04022a61b527 4763 }
whismanoid 10:04022a61b527 4764 field_index++;
whismanoid 10:04022a61b527 4765 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[channel_index];
whismanoid 10:04022a61b527 4766 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[channel_index];
whismanoid 10:04022a61b527 4767 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[channel_index];
whismanoid 10:04022a61b527 4768 //
whismanoid 10:04022a61b527 4769 // WIP SampleRate_of_FILTER_CONV_START() MAX11410EMC-FW slow ODR 10Sps #262
whismanoid 10:04022a61b527 4770 // adjust the MAX11410.loop_limit value if the sample rate is set to a value slower than 20sps
whismanoid 10:04022a61b527 4771 // SampleRate_of_FILTER_CONV_START(uint8_t FILTER_RegValue, uint8_t CONV_START_RegValue)
whismanoid 10:04022a61b527 4772 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 4773 if (SampleRate < 20.0) {
whismanoid 10:04022a61b527 4774 g_MAX11410_device.loop_limit = 32767; // TODO: is this timeout long enough for the slow output data rates?
whismanoid 10:04022a61b527 4775 }
whismanoid 10:04022a61b527 4776 //
whismanoid 10:04022a61b527 4777 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 4778 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc3); // GP0 = 0
whismanoid 10:04022a61b527 4779 //
whismanoid 10:04022a61b527 4780 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 4781 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 10:04022a61b527 4782 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 10:04022a61b527 4783 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 4784 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = (MAX11410::MAX11410_AINN_SEL_enum_t)(channel_index^1);
whismanoid 10:04022a61b527 4785 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 4786 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 4787 }
whismanoid 10:04022a61b527 4788 else {
whismanoid 10:04022a61b527 4789 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 4790 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = MAX11410::AINN_SEL_1010_GND;
whismanoid 10:04022a61b527 4791 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 4792 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 4793 }
whismanoid 10:04022a61b527 4794 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 4795 //
whismanoid 10:04022a61b527 4796 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 4797 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc4); // GP0 = 1
whismanoid 10:04022a61b527 4798 //
whismanoid 10:04022a61b527 4799 }
whismanoid 10:04022a61b527 4800 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 4801 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc4); // GP1 = 1
whismanoid 10:04022a61b527 4802 #else
whismanoid 5:aaf8b5f5fda1 4803 g_MAX11410_device.Read_All_Voltages();
whismanoid 10:04022a61b527 4804 #endif
whismanoid 10:04022a61b527 4805 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 4806 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 4807 // mbed
whismanoid 5:aaf8b5f5fda1 4808 // Platform board uses simple analog inputs
whismanoid 5:aaf8b5f5fda1 4809 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 5:aaf8b5f5fda1 4810 Platform_LSB[0] = analogIn0.read();
whismanoid 5:aaf8b5f5fda1 4811 Platform_LSB[1] = analogIn1.read();
whismanoid 5:aaf8b5f5fda1 4812 Platform_LSB[2] = analogIn2.read();
whismanoid 5:aaf8b5f5fda1 4813 Platform_LSB[3] = analogIn3.read();
whismanoid 5:aaf8b5f5fda1 4814 Platform_LSB[4] = analogIn4.read();
whismanoid 5:aaf8b5f5fda1 4815 Platform_LSB[5] = analogIn5.read();
whismanoid 10:04022a61b527 4816 #endif
whismanoid 10:04022a61b527 4817 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 5:aaf8b5f5fda1 4818 Platform_Voltage[0] = analogIn0.read() * adc_full_scale_voltage[0];
whismanoid 5:aaf8b5f5fda1 4819 Platform_Voltage[1] = analogIn1.read() * adc_full_scale_voltage[1];
whismanoid 5:aaf8b5f5fda1 4820 Platform_Voltage[2] = analogIn2.read() * adc_full_scale_voltage[2];
whismanoid 5:aaf8b5f5fda1 4821 Platform_Voltage[3] = analogIn3.read() * adc_full_scale_voltage[3];
whismanoid 5:aaf8b5f5fda1 4822 Platform_Voltage[4] = analogIn4.read() * adc_full_scale_voltage[4];
whismanoid 5:aaf8b5f5fda1 4823 Platform_Voltage[5] = analogIn5.read() * adc_full_scale_voltage[5];
whismanoid 5:aaf8b5f5fda1 4824 #endif
whismanoid 5:aaf8b5f5fda1 4825 #endif // defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 4826
whismanoid 5:aaf8b5f5fda1 4827 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 4828 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 4829 const uint32_t part_id_expect = 0x000F02;
whismanoid 5:aaf8b5f5fda1 4830 uint32_t part_id_readback;
whismanoid 5:aaf8b5f5fda1 4831 g_MAX11410_device.RegRead(MAX11410::CMD_r001_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xddd_PART_ID, &part_id_readback);
whismanoid 5:aaf8b5f5fda1 4832 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 4833 } // void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 4834
whismanoid 17:9397ea3ea7e9 4835 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 4836 //--------------------------------------------------
whismanoid 17:9397ea3ea7e9 4837 // TODO: Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 4838 void Datalogger_RunActionTable()
whismanoid 17:9397ea3ea7e9 4839 {
whismanoid 17:9397ea3ea7e9 4840 if (Datalogger_action_table_enabled == false) {
whismanoid 17:9397ea3ea7e9 4841 return;
whismanoid 17:9397ea3ea7e9 4842 }
whismanoid 17:9397ea3ea7e9 4843 // TODO: verbose Datalogger_RunActionTable() emit a csv column ,"Action"
whismanoid 17:9397ea3ea7e9 4844 // TODO: assert Datalogger_action_table_row_count < ACTION_TABLE_ROW_MAX
whismanoid 17:9397ea3ea7e9 4845 // for Datalogger_action_table[0..Datalogger_action_table_row_count]
whismanoid 17:9397ea3ea7e9 4846 for (int i = 0; i < Datalogger_action_table_row_count; i++)
whismanoid 17:9397ea3ea7e9 4847 {
whismanoid 17:9397ea3ea7e9 4848 // skip if Datalogger_action_table[i].action == action_noop
whismanoid 17:9397ea3ea7e9 4849 if (Datalogger_action_table[i].action == action_noop) {
whismanoid 17:9397ea3ea7e9 4850 continue;
whismanoid 17:9397ea3ea7e9 4851 }
whismanoid 17:9397ea3ea7e9 4852 // TODO: test Datalogger_action_table[i].condition "if="
whismanoid 17:9397ea3ea7e9 4853 // TODO: Could the .condition field also distinguish Platform ADC from SPI ADC?
whismanoid 17:9397ea3ea7e9 4854 // That way we keep both sets of ADC channels in separate lists
whismanoid 17:9397ea3ea7e9 4855 // if=0 -- always
whismanoid 17:9397ea3ea7e9 4856 // if=1,2,3,4,5,6 -- Platform_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 4857 // if=7,8,9,10,11,12 -- SPI_AIN_Voltage[ch] > < == >= <= != threshold
whismanoid 17:9397ea3ea7e9 4858 // also, are we comparing code or voltage?
whismanoid 17:9397ea3ea7e9 4859 // TODO: selected Datalogger_action_table[i].condition_channel
whismanoid 17:9397ea3ea7e9 4860 // Datalogger could have both platform ADC and external SPI ADC channels
whismanoid 17:9397ea3ea7e9 4861 // if SPI_ADC_DeviceName
whismanoid 17:9397ea3ea7e9 4862 // NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 4863 // SPI_AIN_Enable_ch[]
whismanoid 17:9397ea3ea7e9 4864 // SPI_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 4865 // SPI_AIN_Voltage[]
whismanoid 17:9397ea3ea7e9 4866 // if LOG_PLATFORM_AIN
whismanoid 17:9397ea3ea7e9 4867 // NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 17:9397ea3ea7e9 4868 // analogInPin_fullScaleVoltage[]
whismanoid 17:9397ea3ea7e9 4869 // Platform_Enable_ch[]
whismanoid 17:9397ea3ea7e9 4870 // Platform_AIN_customChannelHeader_ch[]
whismanoid 17:9397ea3ea7e9 4871 // Platform_Voltage[]
whismanoid 17:9397ea3ea7e9 4872 // TODO: selected Datalogger_action_table[i].condition_threshold
whismanoid 17:9397ea3ea7e9 4873 switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 4874 {
whismanoid 17:9397ea3ea7e9 4875 case condition_always:
whismanoid 17:9397ea3ea7e9 4876 //~ cmdLine.serial().printf(" always");
whismanoid 17:9397ea3ea7e9 4877 break;
whismanoid 17:9397ea3ea7e9 4878 case condition_if_An_gt_threshold:
whismanoid 17:9397ea3ea7e9 4879 //~ cmdLine.serial().printf(" if A%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4880 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 4881 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 4882 continue;
whismanoid 17:9397ea3ea7e9 4883 }
whismanoid 17:9397ea3ea7e9 4884 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 4885 break;
whismanoid 17:9397ea3ea7e9 4886 case condition_if_An_lt_threshold:
whismanoid 17:9397ea3ea7e9 4887 //~ cmdLine.serial().printf(" if A%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4888 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 4889 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 4890 continue;
whismanoid 17:9397ea3ea7e9 4891 }
whismanoid 17:9397ea3ea7e9 4892 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 4893 break;
whismanoid 17:9397ea3ea7e9 4894 case condition_if_An_eq_threshold:
whismanoid 17:9397ea3ea7e9 4895 //~ cmdLine.serial().printf(" if A%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4896 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 4897 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 4898 continue;
whismanoid 17:9397ea3ea7e9 4899 }
whismanoid 17:9397ea3ea7e9 4900 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 4901 break;
whismanoid 17:9397ea3ea7e9 4902 case condition_if_An_ge_threshold:
whismanoid 17:9397ea3ea7e9 4903 //~ cmdLine.serial().printf(" if A%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4904 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 4905 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 4906 continue;
whismanoid 17:9397ea3ea7e9 4907 }
whismanoid 17:9397ea3ea7e9 4908 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 4909 break;
whismanoid 17:9397ea3ea7e9 4910 case condition_if_An_le_threshold:
whismanoid 17:9397ea3ea7e9 4911 //~ cmdLine.serial().printf(" if A%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4912 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 4913 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 4914 continue;
whismanoid 17:9397ea3ea7e9 4915 }
whismanoid 17:9397ea3ea7e9 4916 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 4917 break;
whismanoid 17:9397ea3ea7e9 4918 case condition_if_An_ne_threshold:
whismanoid 17:9397ea3ea7e9 4919 //~ cmdLine.serial().printf(" if A%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4920 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 17:9397ea3ea7e9 4921 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 17:9397ea3ea7e9 4922 if (!(Platform_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 4923 continue;
whismanoid 17:9397ea3ea7e9 4924 }
whismanoid 17:9397ea3ea7e9 4925 break;
whismanoid 17:9397ea3ea7e9 4926 case condition_if_AINn_gt_threshold:
whismanoid 17:9397ea3ea7e9 4927 //~ cmdLine.serial().printf(" if AIN%d > %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4928 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 4929 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] > Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 4930 continue;
whismanoid 17:9397ea3ea7e9 4931 }
whismanoid 17:9397ea3ea7e9 4932 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 4933 break;
whismanoid 17:9397ea3ea7e9 4934 case condition_if_AINn_lt_threshold:
whismanoid 17:9397ea3ea7e9 4935 //~ cmdLine.serial().printf(" if AIN%d < %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4936 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 4937 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] < Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 4938 continue;
whismanoid 17:9397ea3ea7e9 4939 }
whismanoid 17:9397ea3ea7e9 4940 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 4941 break;
whismanoid 17:9397ea3ea7e9 4942 case condition_if_AINn_eq_threshold:
whismanoid 17:9397ea3ea7e9 4943 //~ cmdLine.serial().printf(" if AIN%d == %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4944 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 4945 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] == Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 4946 continue;
whismanoid 17:9397ea3ea7e9 4947 }
whismanoid 17:9397ea3ea7e9 4948 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 4949 break;
whismanoid 17:9397ea3ea7e9 4950 case condition_if_AINn_ge_threshold:
whismanoid 17:9397ea3ea7e9 4951 //~ cmdLine.serial().printf(" if AIN%d >= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4952 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 4953 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] >= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 4954 continue;
whismanoid 17:9397ea3ea7e9 4955 }
whismanoid 17:9397ea3ea7e9 4956 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 4957 break;
whismanoid 17:9397ea3ea7e9 4958 case condition_if_AINn_le_threshold:
whismanoid 17:9397ea3ea7e9 4959 //~ cmdLine.serial().printf(" if AIN%d <= %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4960 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 4961 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] <= Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 4962 continue;
whismanoid 17:9397ea3ea7e9 4963 }
whismanoid 17:9397ea3ea7e9 4964 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 4965 break;
whismanoid 17:9397ea3ea7e9 4966 case condition_if_AINn_ne_threshold:
whismanoid 17:9397ea3ea7e9 4967 //~ cmdLine.serial().printf(" if AIN%d != %f", Datalogger_action_table[i].condition_channel, Datalogger_action_table[i].condition_threshold);
whismanoid 17:9397ea3ea7e9 4968 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 4969 if (!(SPI_AIN_Voltage[Datalogger_action_table[i].condition_channel] != Datalogger_action_table[i].condition_threshold)) {
whismanoid 17:9397ea3ea7e9 4970 continue;
whismanoid 17:9397ea3ea7e9 4971 }
whismanoid 17:9397ea3ea7e9 4972 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 17:9397ea3ea7e9 4973 break;
whismanoid 17:9397ea3ea7e9 4974 } // switch(Datalogger_action_table[i].condition)
whismanoid 17:9397ea3ea7e9 4975 // selected Datalogger_action_table[i].digitalOutPin
whismanoid 17:9397ea3ea7e9 4976 // perform selected Datalogger_action_table[i].action
whismanoid 17:9397ea3ea7e9 4977 switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 4978 {
whismanoid 17:9397ea3ea7e9 4979 case action_noop:
whismanoid 17:9397ea3ea7e9 4980 //~ cmdLine.serial().printf("No_Operation");
whismanoid 17:9397ea3ea7e9 4981 break;
whismanoid 17:9397ea3ea7e9 4982 case action_digitalOutLow:
whismanoid 17:9397ea3ea7e9 4983 {
whismanoid 17:9397ea3ea7e9 4984 //~ cmdLine.serial().printf("digitalOutLow");
whismanoid 17:9397ea3ea7e9 4985 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 4986 // perform action digitalOutLow
whismanoid 17:9397ea3ea7e9 4987 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 4988 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 4989 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 4990 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 4991 #else
whismanoid 17:9397ea3ea7e9 4992 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 4993 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 4994 digitalInOutPin.write(0);
whismanoid 17:9397ea3ea7e9 4995 #endif
whismanoid 17:9397ea3ea7e9 4996 }
whismanoid 17:9397ea3ea7e9 4997 break;
whismanoid 17:9397ea3ea7e9 4998 case action_digitalOutHigh:
whismanoid 17:9397ea3ea7e9 4999 {
whismanoid 17:9397ea3ea7e9 5000 //~ cmdLine.serial().printf("digitalOutHigh");
whismanoid 17:9397ea3ea7e9 5001 //~ cmdLine.serial().printf(" D%d", Datalogger_action_table[i].digitalOutPin);
whismanoid 17:9397ea3ea7e9 5002 // perform action digitalOutHigh
whismanoid 17:9397ea3ea7e9 5003 int pinIndex = Datalogger_action_table[i].digitalOutPin;
whismanoid 17:9397ea3ea7e9 5004 #if ARDUINO_STYLE
whismanoid 17:9397ea3ea7e9 5005 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 5006 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 17:9397ea3ea7e9 5007 #else
whismanoid 17:9397ea3ea7e9 5008 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 17:9397ea3ea7e9 5009 digitalInOutPin.output();
whismanoid 17:9397ea3ea7e9 5010 digitalInOutPin.write(1);
whismanoid 17:9397ea3ea7e9 5011 #endif
whismanoid 17:9397ea3ea7e9 5012 }
whismanoid 17:9397ea3ea7e9 5013 break;
whismanoid 17:9397ea3ea7e9 5014 case action_trigger_Halt:
whismanoid 17:9397ea3ea7e9 5015 //~ cmdLine.serial().printf("trigger_Halt");
whismanoid 17:9397ea3ea7e9 5016 // perform action trigger_Halt
whismanoid 17:9397ea3ea7e9 5017 Datalogger_Trigger = trigger_Halt;
whismanoid 17:9397ea3ea7e9 5018 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 5019 break;
whismanoid 17:9397ea3ea7e9 5020 case action_trigger_FreeRun:
whismanoid 17:9397ea3ea7e9 5021 //~ cmdLine.serial().printf("trigger_FreeRun");
whismanoid 17:9397ea3ea7e9 5022 // perform action trigger_FreeRun
whismanoid 17:9397ea3ea7e9 5023 Datalogger_Trigger = trigger_FreeRun;
whismanoid 17:9397ea3ea7e9 5024 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 5025 break;
whismanoid 17:9397ea3ea7e9 5026 case action_trigger_Timer:
whismanoid 17:9397ea3ea7e9 5027 //~ cmdLine.serial().printf("trigger_Timer");
whismanoid 17:9397ea3ea7e9 5028 //~ // print configuration for trigger_Timer
whismanoid 17:9397ea3ea7e9 5029 //~ cmdLine.serial().printf("(%d x %dmsec)", g_timer_interval_count, g_timer_interval_msec);
whismanoid 17:9397ea3ea7e9 5030 // perform action trigger_Timer
whismanoid 17:9397ea3ea7e9 5031 Datalogger_Trigger = trigger_Timer;
whismanoid 17:9397ea3ea7e9 5032 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 5033 break;
whismanoid 17:9397ea3ea7e9 5034 case action_trigger_PlatformDigitalInput:
whismanoid 17:9397ea3ea7e9 5035 //~ cmdLine.serial().printf("trigger_PlatformDigitalInput");
whismanoid 17:9397ea3ea7e9 5036 //~ // TODO: print configuration for trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 5037 //~ cmdLine.serial().printf("(%d)", g_config_PlatformDigitalInput);
whismanoid 17:9397ea3ea7e9 5038 // TODO: perform action action_trigger_PlatformDigitalInput
whismanoid 17:9397ea3ea7e9 5039 Datalogger_Trigger = trigger_PlatformDigitalInput;
whismanoid 17:9397ea3ea7e9 5040 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 5041 break;
whismanoid 17:9397ea3ea7e9 5042 case action_trigger_SPIDeviceRegRead:
whismanoid 17:9397ea3ea7e9 5043 //~ cmdLine.serial().printf("trigger_SPIDeviceRegRead");
whismanoid 17:9397ea3ea7e9 5044 //~ // TODO: print configuration for trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 5045 //~ cmdLine.serial().printf("(%d)", g_config_SPIDeviceRegRead);
whismanoid 17:9397ea3ea7e9 5046 // TODO: perform action action_trigger_SPIDeviceRegRead
whismanoid 17:9397ea3ea7e9 5047 Datalogger_Trigger = trigger_SPIDeviceRegRead;
whismanoid 17:9397ea3ea7e9 5048 //~ Datalogger_Need_PrintHeader = true;
whismanoid 17:9397ea3ea7e9 5049 break;
whismanoid 17:9397ea3ea7e9 5050 } // switch(Datalogger_action_table[i].action)
whismanoid 17:9397ea3ea7e9 5051 // consider next row of action table
whismanoid 17:9397ea3ea7e9 5052 } // for ...Datalogger_action_table_row_count
whismanoid 17:9397ea3ea7e9 5053 }
whismanoid 17:9397ea3ea7e9 5054 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 5055
whismanoid 5:aaf8b5f5fda1 5056 //--------------------------------------------------
whismanoid 8:dffee7509bfb 5057 void Datalogger_PrintRow(CmdLine& cmdLine)
whismanoid 5:aaf8b5f5fda1 5058 {
whismanoid 5:aaf8b5f5fda1 5059 int field_index = 0;
whismanoid 5:aaf8b5f5fda1 5060 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 5061 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 5062 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 5:aaf8b5f5fda1 5063 continue;
whismanoid 5:aaf8b5f5fda1 5064 }
whismanoid 5:aaf8b5f5fda1 5065 // comma between fields
whismanoid 5:aaf8b5f5fda1 5066 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 5067 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 5068 }
whismanoid 10:04022a61b527 5069 field_index++;
whismanoid 10:04022a61b527 5070 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 10:04022a61b527 5071 cmdLine.serial().printf("%d", g_MAX11410_device.AINcode[channel_index]);
whismanoid 10:04022a61b527 5072 }
whismanoid 10:04022a61b527 5073 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 10:04022a61b527 5074 // TODO: report Voltage instead of LSB
whismanoid 10:04022a61b527 5075 // Serial.print(SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 5076 static char strOutLineBuffer[16];
whismanoid 10:04022a61b527 5077 cmdLine.serial().printf("%6.6f", SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 5078 }
whismanoid 5:aaf8b5f5fda1 5079 }
whismanoid 5:aaf8b5f5fda1 5080 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 5081 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 5082 if (part_id_readback != part_id_expect) {
whismanoid 5:aaf8b5f5fda1 5083 cmdLine.serial().printf(",\"FAIL\"");
whismanoid 9:45f98573eb6d 5084 need_reinit = true;
whismanoid 5:aaf8b5f5fda1 5085 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 5086 g_MAX11410_device.Init();
whismanoid 5:aaf8b5f5fda1 5087 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 5:aaf8b5f5fda1 5088 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 5:aaf8b5f5fda1 5089 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 5:aaf8b5f5fda1 5090 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 5091 }
whismanoid 5:aaf8b5f5fda1 5092 else {
whismanoid 5:aaf8b5f5fda1 5093 cmdLine.serial().printf(",\"OK\"");
whismanoid 5:aaf8b5f5fda1 5094 }
whismanoid 5:aaf8b5f5fda1 5095 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 5096 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 5097 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 5098 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 5099 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 5100 continue;
whismanoid 9:45f98573eb6d 5101 }
whismanoid 5:aaf8b5f5fda1 5102 // comma between fields
whismanoid 5:aaf8b5f5fda1 5103 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 5104 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 5105 }
whismanoid 9:45f98573eb6d 5106 field_index++;
whismanoid 9:45f98573eb6d 5107 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 5:aaf8b5f5fda1 5108 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 5109 cmdLine.serial().printf("%u", Platform_LSB[channel_index]);
whismanoid 9:45f98573eb6d 5110 #endif
whismanoid 9:45f98573eb6d 5111 }
whismanoid 9:45f98573eb6d 5112 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 5113 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 11:2b8adc78618a 5114 // Datalog Volts omit V suffix from numbers #275
whismanoid 11:2b8adc78618a 5115 // because Excel graphs can't handle numbers that have a suffix.
whismanoid 11:2b8adc78618a 5116 cmdLine.serial().printf("%6.6f", Platform_Voltage[channel_index]);
whismanoid 9:45f98573eb6d 5117 #endif
whismanoid 9:45f98573eb6d 5118 }
whismanoid 5:aaf8b5f5fda1 5119 }
whismanoid 5:aaf8b5f5fda1 5120 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 5121 if (need_reinit) {
whismanoid 9:45f98573eb6d 5122 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 5123 if (g_MAX11410_device.Init() == 0) {
whismanoid 9:45f98573eb6d 5124 //~ cmdLine.serial().printf(",\"Init() failed\"");
whismanoid 9:45f98573eb6d 5125 } else {
whismanoid 9:45f98573eb6d 5126 //~ cmdLine.serial().printf(",\"Init() success\"");
whismanoid 9:45f98573eb6d 5127 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 5128 // in Datalogger_PrintRow(), when part_id test fails,
whismanoid 9:45f98573eb6d 5129 // apply list of custom register writes after re-init
whismanoid 9:45f98573eb6d 5130 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 5131 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 9:45f98573eb6d 5132 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 9:45f98573eb6d 5133 uint32_t regData = custom_reg_init_data[index];
whismanoid 9:45f98573eb6d 5134 cmdLine.serial().printf("*%s=0x%06.6x", g_MAX11410_device.RegName(regAddress), regData);
whismanoid 9:45f98573eb6d 5135 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 9:45f98573eb6d 5136 }
whismanoid 9:45f98573eb6d 5137 #endif // USE_CUSTOM_REG_INIT
whismanoid 9:45f98573eb6d 5138 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 9:45f98573eb6d 5139 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 9:45f98573eb6d 5140 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 9:45f98573eb6d 5141 need_reinit = false;
whismanoid 9:45f98573eb6d 5142 }
whismanoid 9:45f98573eb6d 5143 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 5144 need_reinit = false;
whismanoid 9:45f98573eb6d 5145 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 5146 }
whismanoid 5:aaf8b5f5fda1 5147 cmdLine.serial().printf("\r\n");
whismanoid 9:45f98573eb6d 5148 if (need_reinit) {
whismanoid 9:45f98573eb6d 5149 //~ delay(500); // platform_delay_ms 500ms timing delay function
whismanoid 9:45f98573eb6d 5150 }
whismanoid 5:aaf8b5f5fda1 5151 } // void Datalogger_PrintRow()
whismanoid 5:aaf8b5f5fda1 5152
whismanoid 0:cb44e2e9ec4c 5153 // example code main function
whismanoid 0:cb44e2e9ec4c 5154 int main()
whismanoid 0:cb44e2e9ec4c 5155 {
whismanoid 0:cb44e2e9ec4c 5156 // setup: put your setup code here, to run once
whismanoid 4:d9b05924ad4c 5157 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 5158 // Configure serial ports
whismanoid 4:d9b05924ad4c 5159 cmdLine.clear();
whismanoid 4:d9b05924ad4c 5160 //~ cmdLine.serial().printf("\r\n cmdLine.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 5161 cmdLine.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 5162 //~ cmdLine.diagnostic_led_EOF = diagnostic_led_EOF;
whismanoid 4:d9b05924ad4c 5163 /// CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21);
whismanoid 4:d9b05924ad4c 5164 //~ cmdLine.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 5165 //~ cmdLine.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 5166 //~ cmdLine.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 5167 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5168 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 5169 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 5170 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 5171 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 5172 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 5173 # else
whismanoid 10:04022a61b527 5174 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 5175 DAPLINKserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5176 # endif
whismanoid 10:04022a61b527 5177 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 5178 cmdLine_DAPLINKserial.clear();
whismanoid 4:d9b05924ad4c 5179 //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 5180 cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 5181 //~ cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 5182 //~ cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 5183 //~ cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 5184 # endif
whismanoid 6:f6d16658342b 5185 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 5186 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 10:04022a61b527 5187 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 5188 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 5189 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 5190 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 5191 AUXserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 5192 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 6:f6d16658342b 5193 cmdLine_AUXserial.clear();
whismanoid 6:f6d16658342b 5194 //~ cmdLine_AUXserial.serial().printf("\r\n cmdLine_AUXserial.serial().printf test\r\n");
whismanoid 6:f6d16658342b 5195 cmdLine_AUXserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 6:f6d16658342b 5196 //~ cmdLine_AUXserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 6:f6d16658342b 5197 //~ cmdLine_AUXserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 6:f6d16658342b 5198 //~ cmdLine_AUXserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 6:f6d16658342b 5199 # endif // HAS_AUX_SERIAL
whismanoid 4:d9b05924ad4c 5200 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 0:cb44e2e9ec4c 5201
whismanoid 0:cb44e2e9ec4c 5202 // example code: serial port banner message
whismanoid 0:cb44e2e9ec4c 5203 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 5204 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 5205 cmdLine.serial().printf("\r\nDataLogger_MAX11410\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 5206 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 5207 cmdLine.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 5208 # if HAS_DAPLINK_SERIAL
whismanoid 3:9055e17e181a 5209 cmdLine_DAPLINKserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 5210 # endif // HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 5211 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 5212 cmdLine_AUXserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 6:f6d16658342b 5213 # endif // HAS_AUX_SERIAL
whismanoid 3:9055e17e181a 5214 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 5215
whismanoid 1:747f1602abfc 5216 // CODE GENERATOR: get spi properties from device
whismanoid 3:9055e17e181a 5217 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 5218 if (g_SPI_SCLK_Hz > g_MAX11410_device.get_spi_frequency())
whismanoid 3:9055e17e181a 5219 { // Device limits SPI SCLK frequency
whismanoid 3:9055e17e181a 5220 g_SPI_SCLK_Hz = g_MAX11410_device.get_spi_frequency();
whismanoid 3:9055e17e181a 5221 cmdLine.serial().printf("\r\nMAX11410 limits SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 5222
whismanoid 3:9055e17e181a 5223 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 5224 }
whismanoid 3:9055e17e181a 5225 if (g_MAX11410_device.get_spi_frequency() > g_SPI_SCLK_Hz)
whismanoid 3:9055e17e181a 5226 { // Platform limits SPI SCLK frequency
whismanoid 3:9055e17e181a 5227 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 5228 cmdLine.serial().printf("\r\nPlatform limits MAX11410 SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 5229
whismanoid 3:9055e17e181a 5230 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 5231 }
whismanoid 0:cb44e2e9ec4c 5232 // g_SPI_dataMode = g_MAX11410_device.get_spi_dataMode();
whismanoid 3:9055e17e181a 5233 while (g_MAX11410_device.Init() == 0)
whismanoid 3:9055e17e181a 5234 {
whismanoid 3:9055e17e181a 5235 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 5236 cmdLine.serial().printf("\r\nMAX11410 Init failed; retry...\r\n");
whismanoid 3:9055e17e181a 5237
whismanoid 3:9055e17e181a 5238 }
whismanoid 0:cb44e2e9ec4c 5239
whismanoid 0:cb44e2e9ec4c 5240 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 3:9055e17e181a 5241 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 5242 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 3:9055e17e181a 5243 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 3:9055e17e181a 5244 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 3:9055e17e181a 5245 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 5246 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 3:9055e17e181a 5247 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 5248 // CODE GENERATOR: example code: has no member function REF
whismanoid 0:cb44e2e9ec4c 5249 // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line
whismanoid 0:cb44e2e9ec4c 5250 // CODE GENERATOR: ResolutionBits = 24
whismanoid 0:cb44e2e9ec4c 5251 // CODE GENERATOR: FScode = 0xffffff
whismanoid 0:cb44e2e9ec4c 5252 // CODE GENERATOR: NumChannels = 10
whismanoid 0:cb44e2e9ec4c 5253 // CODE GENERATOR: banner before DataLogHelloCppCodeList while(1)
whismanoid 3:9055e17e181a 5254 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 5255 cmdLine.serial().printf("v_filter = 0x%2.2x\r\n", g_MAX11410_device.v_filter);
whismanoid 0:cb44e2e9ec4c 5256
whismanoid 3:9055e17e181a 5257 cmdLine.serial().printf("v_pga = 0x%2.2x\r\n", g_MAX11410_device.v_pga);
whismanoid 0:cb44e2e9ec4c 5258
whismanoid 3:9055e17e181a 5259 cmdLine.serial().printf("v_ctrl = 0x%2.2x\r\n", g_MAX11410_device.v_ctrl);
whismanoid 3:9055e17e181a 5260
whismanoid 3:9055e17e181a 5261 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 5262
whismanoid 3:9055e17e181a 5263 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 5264 Datalogger_Need_PrintHeader = true;
whismanoid 10:04022a61b527 5265
whismanoid 12:2dfc1f2009e0 5266 #if USE_LEDS
whismanoid 12:2dfc1f2009e0 5267 #if defined(TARGET_MAX32630)
whismanoid 12:2dfc1f2009e0 5268 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 5269 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 5270 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 5271 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 5272 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 5273 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 5274 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 5275 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 5276 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 5277 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 5278 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 5279 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 5280 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 5281 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 5282 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 5283 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 19:5ff09c8e9daf 5284 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO) || defined(TARGET_MAX40108DEMOP2U9)
whismanoid 12:2dfc1f2009e0 5285 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 5286 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 5287 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 5288 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 5289 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 5290 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 5291 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 5292 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 5293 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 5294 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 5295 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 5296 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 5297 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 5298 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 5299 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 5300 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 5301 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 12:2dfc1f2009e0 5302 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 5303 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 5304 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 5305 led4 = LED_OFF;
whismanoid 12:2dfc1f2009e0 5306 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 5307 //led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 5308 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 5309 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 5310 led1 = LED_OFF;
whismanoid 12:2dfc1f2009e0 5311 //led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 5312 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 5313 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 5314 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 5315 //led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 5316 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 5317 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 5318 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 5319 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 5320 //
whismanoid 12:2dfc1f2009e0 5321 #endif // target definition
whismanoid 12:2dfc1f2009e0 5322 #endif
whismanoid 12:2dfc1f2009e0 5323
whismanoid 12:2dfc1f2009e0 5324 if (led1.is_connected()) {
whismanoid 12:2dfc1f2009e0 5325 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 5326 }
whismanoid 12:2dfc1f2009e0 5327 if (led2.is_connected()) {
whismanoid 12:2dfc1f2009e0 5328 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 5329 }
whismanoid 12:2dfc1f2009e0 5330 if (led3.is_connected()) {
whismanoid 12:2dfc1f2009e0 5331 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 5332 }
whismanoid 12:2dfc1f2009e0 5333
whismanoid 4:d9b05924ad4c 5334 while(1) { // this code repeats forever
whismanoid 4:d9b05924ad4c 5335 // this code repeats forever
whismanoid 4:d9b05924ad4c 5336
whismanoid 21:ac062a97a71d 5337 #if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 21:ac062a97a71d 5338 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 21:ac062a97a71d 5339 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 21:ac062a97a71d 5340 # if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 5341 static int button1_value_prev = 1;
whismanoid 21:ac062a97a71d 5342 static int button1_value_now = 1;
whismanoid 21:ac062a97a71d 5343 button1_value_prev = button1_value_now;
whismanoid 21:ac062a97a71d 5344 button1_value_now = button1.read();
whismanoid 21:ac062a97a71d 5345 if ((button1_value_prev - button1_value_now) == 1)
whismanoid 21:ac062a97a71d 5346 {
whismanoid 21:ac062a97a71d 5347 // on button1 falling edge (button1 press)
whismanoid 21:ac062a97a71d 5348 onButton1FallingEdge();
whismanoid 21:ac062a97a71d 5349 }
whismanoid 21:ac062a97a71d 5350 # endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 5351 # if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 5352 static int button2_value_prev = 1;
whismanoid 24:032f3683cb2a 5353 static int button2_value_now = 1;
whismanoid 24:032f3683cb2a 5354 button2_value_prev = button2_value_now;
whismanoid 24:032f3683cb2a 5355 button2_value_now = button2.read();
whismanoid 24:032f3683cb2a 5356 if ((button2_value_prev - button2_value_now) == 1)
whismanoid 24:032f3683cb2a 5357 {
whismanoid 24:032f3683cb2a 5358 // on button2 falling edge (button2 press)
whismanoid 24:032f3683cb2a 5359 onButton2FallingEdge();
whismanoid 24:032f3683cb2a 5360 }
whismanoid 24:032f3683cb2a 5361 # endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 5362 # if HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 24:032f3683cb2a 5363 static int button3_value_prev = 1;
whismanoid 24:032f3683cb2a 5364 static int button3_value_now = 1;
whismanoid 24:032f3683cb2a 5365 button3_value_prev = button3_value_now;
whismanoid 24:032f3683cb2a 5366 button3_value_now = button3.read();
whismanoid 24:032f3683cb2a 5367 if ((button3_value_prev - button3_value_now) == 1)
whismanoid 24:032f3683cb2a 5368 {
whismanoid 24:032f3683cb2a 5369 // on button3 falling edge (button3 press)
whismanoid 24:032f3683cb2a 5370 onButton2FallingEdge();
whismanoid 24:032f3683cb2a 5371 }
whismanoid 24:032f3683cb2a 5372 # endif // HAS_BUTTON3_DEMO_INTERRUPT
whismanoid 21:ac062a97a71d 5373 #endif // HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 4:d9b05924ad4c 5374 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 5375 // TODO support CmdLine command menus (like on Serial_Tester); help and usual boilerplate
whismanoid 10:04022a61b527 5376 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 5377 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 5378 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 5379 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 5380 // Accept commands from Auxiliary serial port
whismanoid 6:f6d16658342b 5381 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 5382 if (AUXserial.readable()) {
whismanoid 6:f6d16658342b 5383 cmdLine_AUXserial.append(AUXserial.getc());
whismanoid 6:f6d16658342b 5384 }
whismanoid 6:f6d16658342b 5385 # endif // HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 5386 # if HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 5387 if (DAPLINKserial.readable()) {
whismanoid 6:f6d16658342b 5388 cmdLine_DAPLINKserial.append(DAPLINKserial.getc());
whismanoid 6:f6d16658342b 5389 }
whismanoid 6:f6d16658342b 5390 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 5391 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 5392 if (serial.readable()) {
whismanoid 4:d9b05924ad4c 5393 int c = serial.getc(); // instead of getc() or fgetc()
whismanoid 4:d9b05924ad4c 5394 cmdLine.append(c);
whismanoid 4:d9b05924ad4c 5395 // cmdLine.onEOLcommandParser handler implements menus
whismanoid 4:d9b05924ad4c 5396 } // if (Serial.available())
whismanoid 4:d9b05924ad4c 5397 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 5398
whismanoid 4:d9b05924ad4c 5399 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 5400 // TODO Datalog trigger
whismanoid 4:d9b05924ad4c 5401 if (Datalogger_Trigger == trigger_Halt) {
whismanoid 4:d9b05924ad4c 5402 // halt the datalogger; continue accepting commands
whismanoid 3:9055e17e181a 5403 continue;
whismanoid 3:9055e17e181a 5404 }
whismanoid 4:d9b05924ad4c 5405 if (Datalogger_Trigger == trigger_FreeRun) {
whismanoid 4:d9b05924ad4c 5406 // free run as fast as possible
whismanoid 3:9055e17e181a 5407 }
whismanoid 4:d9b05924ad4c 5408 if (Datalogger_Trigger == trigger_Timer) {
whismanoid 4:d9b05924ad4c 5409 // timer (configure interval)
whismanoid 17:9397ea3ea7e9 5410 // TODO: if Datalogger_Trigger == trigger_Timer sleep(g_timer_interval_msec)
whismanoid 17:9397ea3ea7e9 5411 // sleep(g_timer_interval_msec); // error: too many arguments to function 'void sleep()'
whismanoid 17:9397ea3ea7e9 5412 wait_ms(g_timer_interval_msec); // sleep during delay?
whismanoid 17:9397ea3ea7e9 5413 if (g_timer_interval_counter > 0) {
whismanoid 17:9397ea3ea7e9 5414 g_timer_interval_counter--;
whismanoid 17:9397ea3ea7e9 5415 continue;
whismanoid 17:9397ea3ea7e9 5416 }
whismanoid 17:9397ea3ea7e9 5417 // if time interval not yet reached, continue (continue accepting commands)
whismanoid 17:9397ea3ea7e9 5418 g_timer_interval_counter = g_timer_interval_count;
whismanoid 3:9055e17e181a 5419 }
whismanoid 4:d9b05924ad4c 5420 if (Datalogger_Trigger == trigger_PlatformDigitalInput) {
whismanoid 4:d9b05924ad4c 5421 // platform digital input (configure digital input pin reference)
whismanoid 17:9397ea3ea7e9 5422 // TODO: read selected input pin, test value
whismanoid 17:9397ea3ea7e9 5423 // TODO: if no match, continue (continue accepting commands)
whismanoid 3:9055e17e181a 5424 }
whismanoid 4:d9b05924ad4c 5425 if (Datalogger_Trigger == trigger_SPIDeviceRegRead) {
whismanoid 4:d9b05924ad4c 5426 // SPI device register read (configure regaddr, mask value, match value)
whismanoid 17:9397ea3ea7e9 5427 // TODO: SPI transfer regAddr
whismanoid 17:9397ea3ea7e9 5428 // TODO: apply dataMask, compare with testValue
whismanoid 17:9397ea3ea7e9 5429 // TODO: if no match, continue (continue accepting commands)
whismanoid 4:d9b05924ad4c 5430 }
whismanoid 4:d9b05924ad4c 5431 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 0:cb44e2e9ec4c 5432
whismanoid 8:dffee7509bfb 5433 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 5434 if (Datalogger_Need_PrintHeader) {
whismanoid 8:dffee7509bfb 5435 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 5436 Datalogger_PrintHeader(cmdLine);
whismanoid 8:dffee7509bfb 5437 }
whismanoid 8:dffee7509bfb 5438 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 5439 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 5440 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 5441 }
whismanoid 8:dffee7509bfb 5442 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 5443 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 5444 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 5445 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 5446 }
whismanoid 8:dffee7509bfb 5447 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 5448 Datalogger_Need_PrintHeader = false;
whismanoid 8:dffee7509bfb 5449 }
whismanoid 5:aaf8b5f5fda1 5450 Datalogger_AcquireRow();
whismanoid 17:9397ea3ea7e9 5451 #if USE_DATALOGGER_ActionTable // Datalogger_RunActionTable() supported actions
whismanoid 17:9397ea3ea7e9 5452 // Datalogger_RunActionTable() between Datalogger_AcquireRow() and Datalogger_PrintRow()
whismanoid 17:9397ea3ea7e9 5453 Datalogger_RunActionTable();
whismanoid 17:9397ea3ea7e9 5454 #endif // USE_DATALOGGER_ActionTable Datalogger_RunActionTable() supported actions
whismanoid 0:cb44e2e9ec4c 5455 // wait(3.0);
whismanoid 0:cb44e2e9ec4c 5456 // CODE GENERATOR: print conversion result
whismanoid 0:cb44e2e9ec4c 5457 // Use Arduino Serial Plotter to view output: Tools | Serial Plotter
whismanoid 8:dffee7509bfb 5458 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 5459 Datalogger_PrintRow(cmdLine);
whismanoid 8:dffee7509bfb 5460 }
whismanoid 8:dffee7509bfb 5461 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 5462 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 5463 Datalogger_PrintRow(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 5464 }
whismanoid 8:dffee7509bfb 5465 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 5466 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 5467 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 5468 Datalogger_PrintRow(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 5469 }
whismanoid 8:dffee7509bfb 5470 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:cb44e2e9ec4c 5471
whismanoid 0:cb44e2e9ec4c 5472 } // this code repeats forever
whismanoid 0:cb44e2e9ec4c 5473 }
whismanoid 0:cb44e2e9ec4c 5474 //---------- CODE GENERATOR: end DataLogHelloCppCodeList