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

Dependencies:   max32625pico CmdLine

Committer:
whismanoid
Date:
Sun Apr 18 22:34:16 2021 -0700
Revision:
18:1235c17b451e
Parent:
17:9397ea3ea7e9
Child:
19:5ff09c8e9daf
support LEDs as digital pins 91 92 93; WIP button as digital pin 90

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