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

Dependencies:   max32625pico CmdLine

Committer:
whismanoid
Date:
Fri Apr 23 22:46:43 2021 -0700
Revision:
22:d6dc8a85f435
Parent:
21:ac062a97a71d
Child:
23:c6c652bef4b9
MAX40108DEMOP2U9 DAPLINK TX/RX swap

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