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

Dependencies:   max32625pico CmdLine

Committer:
whismanoid
Date:
Fri Mar 05 08:20:02 2021 +0000
Revision:
14:d4092094dbfe
Parent:
13:184a08909405
Child:
15:37c83ec50ea0
MAX40108 Demo: MAX32625PICO but no USB, for on-board MAX32625 - verified VDDB(USB) can be left unpowered if USB library is not used

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 14:d4092094dbfe 37 #define MAX40108_DEMO 1
whismanoid 14:d4092094dbfe 38 #endif // MAX40108_DEMO
whismanoid 0:cb44e2e9ec4c 39 //---------- CODE GENERATOR: DataLogHelloCppCodeList
whismanoid 0:cb44e2e9ec4c 40 // CODE GENERATOR: example code includes
whismanoid 0:cb44e2e9ec4c 41
whismanoid 0:cb44e2e9ec4c 42 // example code includes
whismanoid 0:cb44e2e9ec4c 43 // standard include for target platform -- Platform_Include_Boilerplate
whismanoid 0:cb44e2e9ec4c 44 #include "mbed.h"
whismanoid 0:cb44e2e9ec4c 45 // Platforms:
whismanoid 0:cb44e2e9ec4c 46 // - MAX32625MBED
whismanoid 0:cb44e2e9ec4c 47 // - supports mbed-os-5.11, requires USBDevice library
whismanoid 0:cb44e2e9ec4c 48 // - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
whismanoid 0:cb44e2e9ec4c 49 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 50 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 51 // - MAX32600MBED
whismanoid 7:949ec8581f5e 52 // - Please note the last supported version is Mbed OS 6.3.
whismanoid 0:cb44e2e9ec4c 53 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 54 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 55 // - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board.
whismanoid 0:cb44e2e9ec4c 56 // - NUCLEO_F446RE
whismanoid 0:cb44e2e9ec4c 57 // - remove USBDevice library
whismanoid 0:cb44e2e9ec4c 58 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 59 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 60 // - NUCLEO_F401RE
whismanoid 0:cb44e2e9ec4c 61 // - remove USBDevice library
whismanoid 0:cb44e2e9ec4c 62 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 63 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 64 // - MAX32630FTHR
whismanoid 0:cb44e2e9ec4c 65 // - #include "max32630fthr.h"
whismanoid 7:949ec8581f5e 66 // - add http://developer.mbed.org/teams/MaximIntegrated/code/max32630fthr/
whismanoid 0:cb44e2e9ec4c 67 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 68 // - MAX32620FTHR
whismanoid 0:cb44e2e9ec4c 69 // - #include "MAX32620FTHR.h"
whismanoid 0:cb44e2e9ec4c 70 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 71 // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
whismanoid 0:cb44e2e9ec4c 72 // - not tested yet
whismanoid 0:cb44e2e9ec4c 73 // - MAX32625PICO
whismanoid 0:cb44e2e9ec4c 74 // - #include "max32625pico.h"
whismanoid 0:cb44e2e9ec4c 75 // - add https://os.mbed.com/users/switches/code/max32625pico/
whismanoid 0:cb44e2e9ec4c 76 // - remove max32630fthr library (if present)
whismanoid 0:cb44e2e9ec4c 77 // - remove MAX32620FTHR library (if present)
whismanoid 0:cb44e2e9ec4c 78 // - not tested yet
whismanoid 0:cb44e2e9ec4c 79 // - see https://os.mbed.com/users/switches/code/max32625pico/
whismanoid 0:cb44e2e9ec4c 80 // - see https://os.mbed.com/users/switches/code/PICO_board_demo/
whismanoid 0:cb44e2e9ec4c 81 // - see https://os.mbed.com/users/switches/code/PICO_USB_I2C_SPI/
whismanoid 0:cb44e2e9ec4c 82 // - see https://os.mbed.com/users/switches/code/SerialInterface/
whismanoid 0:cb44e2e9ec4c 83 // - Note: To load the MAX32625PICO firmware, hold the button while
whismanoid 0:cb44e2e9ec4c 84 // connecting the USB cable, then copy firmware bin file
whismanoid 0:cb44e2e9ec4c 85 // to the MAINTENANCE drive.
whismanoid 0:cb44e2e9ec4c 86 // - see https://os.mbed.com/platforms/MAX32625PICO/
whismanoid 0:cb44e2e9ec4c 87 // - see https://os.mbed.com/teams/MaximIntegrated/wiki/MAX32625PICO-Firmware-Updates
whismanoid 0:cb44e2e9ec4c 88 //
whismanoid 0:cb44e2e9ec4c 89 // end Platform_Include_Boilerplate
whismanoid 0:cb44e2e9ec4c 90
whismanoid 0:cb44e2e9ec4c 91 //--------------------------------------------------
whismanoid 3:9055e17e181a 92 // Option to use SPI connected ADC
whismanoid 3:9055e17e181a 93 #ifndef SPI_ADC_DeviceName
whismanoid 9:45f98573eb6d 94 #define SPI_ADC_DeviceName MAX11410
whismanoid 3:9055e17e181a 95 #undef SPI_ADC_DeviceName
whismanoid 3:9055e17e181a 96 #endif
whismanoid 3:9055e17e181a 97 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 98 #include "MAX11410.h"
whismanoid 3:9055e17e181a 99 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 100
whismanoid 0:cb44e2e9ec4c 101 #if defined(TARGET)
whismanoid 0:cb44e2e9ec4c 102 // TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h
whismanoid 0:cb44e2e9ec4c 103 // Create a string definition for the TARGET
whismanoid 0:cb44e2e9ec4c 104 #define STRING_ARG(arg) #arg
whismanoid 0:cb44e2e9ec4c 105 #define STRING_NAME(name) STRING_ARG(name)
whismanoid 0:cb44e2e9ec4c 106 #define TARGET_NAME STRING_NAME(TARGET)
whismanoid 0:cb44e2e9ec4c 107 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 108 #define TARGET_NAME "MAX32600"
whismanoid 0:cb44e2e9ec4c 109 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 110 #define TARGET_NAME "LPC1768"
whismanoid 0:cb44e2e9ec4c 111 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 112 #define TARGET_NAME "NUCLEO_F446RE"
whismanoid 0:cb44e2e9ec4c 113 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 114 #define TARGET_NAME "NUCLEO_F401RE"
whismanoid 0:cb44e2e9ec4c 115 #else
whismanoid 0:cb44e2e9ec4c 116 #error TARGET NOT DEFINED
whismanoid 0:cb44e2e9ec4c 117 #endif
whismanoid 0:cb44e2e9ec4c 118 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 119 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 120 // TARGET=MAX32630FTHR ARM Cortex-M4F 96MHz 2048kB Flash 512kB SRAM
whismanoid 0:cb44e2e9ec4c 121 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 122 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 123 // ______ | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 124 // ______ | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 125 // ______ | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 126 // ______ | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 127 // analogIn0/4 | [a] AIN_0 1.2Vfs (bat) SYS [ ] | switched BAT+
whismanoid 0:cb44e2e9ec4c 128 // analogIn1/5 | [a] AIN_1 1.2Vfs PWR [ ] | external pwr btn
whismanoid 0:cb44e2e9ec4c 129 // analogIn2 | [a] AIN_2 1.2Vfs +5V VBUS [ ] | USB +5V power
whismanoid 0:cb44e2e9ec4c 130 // analogIn3 | [a] AIN_3 1.2Vfs 1-WIRE P4_0 [d] | D0 dig9
whismanoid 0:cb44e2e9ec4c 131 // (I2C2.SDA) | [d] P5_7 SDA2 SRN P5_6 [d] | D1 dig8
whismanoid 0:cb44e2e9ec4c 132 // (I2C2.SCL) | [d] P6_0 SCL2 SDIO3 P5_5 [d] | D2 dig7
whismanoid 0:cb44e2e9ec4c 133 // D13/SCLK | [s] P5_0 SCLK SDIO2 P5_4 [d] | D3 dig6
whismanoid 0:cb44e2e9ec4c 134 // D11/MOSI | [s] P5_1 MOSI SSEL P5_3 [d] | D4 dig5
whismanoid 0:cb44e2e9ec4c 135 // D12/MISO | [s] P5_2 MISO RTS P3_3 [d] | D5 dig4
whismanoid 0:cb44e2e9ec4c 136 // D10/CS | [s] P3_0 RX CTS P3_2 [d] | D6 dig3
whismanoid 0:cb44e2e9ec4c 137 // D9 dig0 | [d] P3_1 TX SCL P3_5 [d] | D7 dig2
whismanoid 0:cb44e2e9ec4c 138 // ______ | [ ] GND SDA P3_4 [d] | D8 dig1
whismanoid 0:cb44e2e9ec4c 139 // | |
whismanoid 0:cb44e2e9ec4c 140 // | XIP Flash MAX14690N |
whismanoid 0:cb44e2e9ec4c 141 // | XIP_SCLK P1_0 SDA2 P5_7 |
whismanoid 0:cb44e2e9ec4c 142 // | XIP_MOSI P1_1 SCL2 P6_0 |
whismanoid 0:cb44e2e9ec4c 143 // | XIP_MISO P1_2 PMIC_INIT P3_7 |
whismanoid 0:cb44e2e9ec4c 144 // | XIP_SSEL P1_3 MPC P2_7 |
whismanoid 0:cb44e2e9ec4c 145 // | XIP_DIO2 P1_4 MON AIN_0 |
whismanoid 0:cb44e2e9ec4c 146 // | XIP_DIO3 P1_5 |
whismanoid 0:cb44e2e9ec4c 147 // | |
whismanoid 0:cb44e2e9ec4c 148 // | PAN1326B MicroSD LED |
whismanoid 0:cb44e2e9ec4c 149 // | BT_RX P0_0 SD_SCLK P0_4 r P2_4 |
whismanoid 0:cb44e2e9ec4c 150 // | BT_TX P0_1 SD_MOSI P0_5 g P2_5 |
whismanoid 0:cb44e2e9ec4c 151 // | BT_CTS P0_2 SD_MISO P0_6 b P2_6 |
whismanoid 0:cb44e2e9ec4c 152 // | BT_RTS P0_3 SD_SSEL P0_7 |
whismanoid 0:cb44e2e9ec4c 153 // | BT_RST P1_6 DETECT P2_2 |
whismanoid 0:cb44e2e9ec4c 154 // | BT_CLK P1_7 SW2 P2_3 |
whismanoid 0:cb44e2e9ec4c 155 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 156 // 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 157 // 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 158 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 159 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 160 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 161 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 162 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 163 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 164 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 165 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 166 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 167 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 168 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 169 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 170 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 171 //
whismanoid 0:cb44e2e9ec4c 172 #include "max32630fthr.h"
whismanoid 0:cb44e2e9ec4c 173 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 174 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 175 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 176 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 177 // Arduino connector
whismanoid 0:cb44e2e9ec4c 178 #ifndef A0
whismanoid 0:cb44e2e9ec4c 179 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 180 #endif
whismanoid 0:cb44e2e9ec4c 181 #ifndef A1
whismanoid 0:cb44e2e9ec4c 182 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 183 #endif
whismanoid 0:cb44e2e9ec4c 184 #ifndef A2
whismanoid 0:cb44e2e9ec4c 185 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 186 #endif
whismanoid 0:cb44e2e9ec4c 187 #ifndef A3
whismanoid 0:cb44e2e9ec4c 188 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 189 #endif
whismanoid 0:cb44e2e9ec4c 190 #ifndef D0
whismanoid 0:cb44e2e9ec4c 191 #define D0 P4_0
whismanoid 0:cb44e2e9ec4c 192 #endif
whismanoid 0:cb44e2e9ec4c 193 #ifndef D1
whismanoid 0:cb44e2e9ec4c 194 #define D1 P5_6
whismanoid 0:cb44e2e9ec4c 195 #endif
whismanoid 0:cb44e2e9ec4c 196 #ifndef D2
whismanoid 0:cb44e2e9ec4c 197 #define D2 P5_5
whismanoid 0:cb44e2e9ec4c 198 #endif
whismanoid 0:cb44e2e9ec4c 199 #ifndef D3
whismanoid 0:cb44e2e9ec4c 200 #define D3 P5_4
whismanoid 0:cb44e2e9ec4c 201 #endif
whismanoid 0:cb44e2e9ec4c 202 #ifndef D4
whismanoid 0:cb44e2e9ec4c 203 #define D4 P5_3
whismanoid 0:cb44e2e9ec4c 204 #endif
whismanoid 0:cb44e2e9ec4c 205 #ifndef D5
whismanoid 0:cb44e2e9ec4c 206 #define D5 P3_3
whismanoid 0:cb44e2e9ec4c 207 #endif
whismanoid 0:cb44e2e9ec4c 208 #ifndef D6
whismanoid 0:cb44e2e9ec4c 209 #define D6 P3_2
whismanoid 0:cb44e2e9ec4c 210 #endif
whismanoid 0:cb44e2e9ec4c 211 #ifndef D7
whismanoid 0:cb44e2e9ec4c 212 #define D7 P3_5
whismanoid 0:cb44e2e9ec4c 213 #endif
whismanoid 0:cb44e2e9ec4c 214 #ifndef D8
whismanoid 0:cb44e2e9ec4c 215 #define D8 P3_4
whismanoid 0:cb44e2e9ec4c 216 #endif
whismanoid 0:cb44e2e9ec4c 217 #ifndef D9
whismanoid 0:cb44e2e9ec4c 218 #define D9 P3_1
whismanoid 0:cb44e2e9ec4c 219 #endif
whismanoid 0:cb44e2e9ec4c 220 #ifndef D10
whismanoid 0:cb44e2e9ec4c 221 #define D10 P3_0
whismanoid 0:cb44e2e9ec4c 222 #endif
whismanoid 0:cb44e2e9ec4c 223 #ifndef D11
whismanoid 0:cb44e2e9ec4c 224 #define D11 P5_1
whismanoid 0:cb44e2e9ec4c 225 #endif
whismanoid 0:cb44e2e9ec4c 226 #ifndef D12
whismanoid 0:cb44e2e9ec4c 227 #define D12 P5_2
whismanoid 0:cb44e2e9ec4c 228 #endif
whismanoid 0:cb44e2e9ec4c 229 #ifndef D13
whismanoid 0:cb44e2e9ec4c 230 #define D13 P5_0
whismanoid 0:cb44e2e9ec4c 231 #endif
whismanoid 0:cb44e2e9ec4c 232 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 233 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 234 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 235 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 236 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 237 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 238 // | |
whismanoid 0:cb44e2e9ec4c 239 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 240 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 241 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 242 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 243 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 244 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 245 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 246 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 247 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 248 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 249 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 250 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 251 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 252 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 253 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 254 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 255 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 256 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 257 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 258 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 259 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 260 // \_______________________/
whismanoid 0:cb44e2e9ec4c 261 //
whismanoid 0:cb44e2e9ec4c 262 // +------------------------+
whismanoid 0:cb44e2e9ec4c 263 // | |
whismanoid 0:cb44e2e9ec4c 264 // | MicroSD LED |
whismanoid 0:cb44e2e9ec4c 265 // | SD_SCLK P2_4 r P3_0 |
whismanoid 0:cb44e2e9ec4c 266 // | SD_MOSI P2_5 g P3_1 |
whismanoid 0:cb44e2e9ec4c 267 // | SD_MISO P2_6 b P3_2 |
whismanoid 0:cb44e2e9ec4c 268 // | SD_SSEL P2_7 y P3_3 |
whismanoid 0:cb44e2e9ec4c 269 // | |
whismanoid 0:cb44e2e9ec4c 270 // | DAPLINK BUTTONS |
whismanoid 0:cb44e2e9ec4c 271 // | TX P2_1 SW3 P2_3 |
whismanoid 0:cb44e2e9ec4c 272 // | RX P2_0 SW2 P2_2 |
whismanoid 0:cb44e2e9ec4c 273 // +------------------------+
whismanoid 0:cb44e2e9ec4c 274 //
whismanoid 0:cb44e2e9ec4c 275 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 276 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 277 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 278 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 279 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 280 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 281 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 282 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 283 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 284 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 285 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 286 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 287 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 288 //
whismanoid 0:cb44e2e9ec4c 289 //#include "max32625mbed.h" // ?
whismanoid 0:cb44e2e9ec4c 290 //MAX32625MBED mbed(MAX32625MBED::VIO_3V3); // ?
whismanoid 0:cb44e2e9ec4c 291 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 292 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 0:cb44e2e9ec4c 293 const float ADC_FULL_SCALE_VOLTAGE = 1.200; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 294 // Arduino connector
whismanoid 0:cb44e2e9ec4c 295 #ifndef A0
whismanoid 0:cb44e2e9ec4c 296 #define A0 AIN_0
whismanoid 0:cb44e2e9ec4c 297 #endif
whismanoid 0:cb44e2e9ec4c 298 #ifndef A1
whismanoid 0:cb44e2e9ec4c 299 #define A1 AIN_1
whismanoid 0:cb44e2e9ec4c 300 #endif
whismanoid 0:cb44e2e9ec4c 301 #ifndef A2
whismanoid 0:cb44e2e9ec4c 302 #define A2 AIN_2
whismanoid 0:cb44e2e9ec4c 303 #endif
whismanoid 0:cb44e2e9ec4c 304 #ifndef A3
whismanoid 0:cb44e2e9ec4c 305 #define A3 AIN_3
whismanoid 0:cb44e2e9ec4c 306 #endif
whismanoid 0:cb44e2e9ec4c 307 #ifndef D0
whismanoid 0:cb44e2e9ec4c 308 #define D0 P0_0
whismanoid 0:cb44e2e9ec4c 309 #endif
whismanoid 0:cb44e2e9ec4c 310 #ifndef D1
whismanoid 0:cb44e2e9ec4c 311 #define D1 P0_1
whismanoid 0:cb44e2e9ec4c 312 #endif
whismanoid 0:cb44e2e9ec4c 313 #ifndef D2
whismanoid 0:cb44e2e9ec4c 314 #define D2 P0_2
whismanoid 0:cb44e2e9ec4c 315 #endif
whismanoid 0:cb44e2e9ec4c 316 #ifndef D3
whismanoid 0:cb44e2e9ec4c 317 #define D3 P0_3
whismanoid 0:cb44e2e9ec4c 318 #endif
whismanoid 0:cb44e2e9ec4c 319 #ifndef D4
whismanoid 0:cb44e2e9ec4c 320 #define D4 P0_4
whismanoid 0:cb44e2e9ec4c 321 #endif
whismanoid 0:cb44e2e9ec4c 322 #ifndef D5
whismanoid 0:cb44e2e9ec4c 323 #define D5 P0_5
whismanoid 0:cb44e2e9ec4c 324 #endif
whismanoid 0:cb44e2e9ec4c 325 #ifndef D6
whismanoid 0:cb44e2e9ec4c 326 #define D6 P0_6
whismanoid 0:cb44e2e9ec4c 327 #endif
whismanoid 0:cb44e2e9ec4c 328 #ifndef D7
whismanoid 0:cb44e2e9ec4c 329 #define D7 P0_7
whismanoid 0:cb44e2e9ec4c 330 #endif
whismanoid 0:cb44e2e9ec4c 331 #ifndef D8
whismanoid 0:cb44e2e9ec4c 332 #define D8 P1_4
whismanoid 0:cb44e2e9ec4c 333 #endif
whismanoid 0:cb44e2e9ec4c 334 #ifndef D9
whismanoid 0:cb44e2e9ec4c 335 #define D9 P1_5
whismanoid 0:cb44e2e9ec4c 336 #endif
whismanoid 0:cb44e2e9ec4c 337 #ifndef D10
whismanoid 0:cb44e2e9ec4c 338 #define D10 P1_3
whismanoid 0:cb44e2e9ec4c 339 #endif
whismanoid 0:cb44e2e9ec4c 340 #ifndef D11
whismanoid 0:cb44e2e9ec4c 341 #define D11 P1_1
whismanoid 0:cb44e2e9ec4c 342 #endif
whismanoid 0:cb44e2e9ec4c 343 #ifndef D12
whismanoid 0:cb44e2e9ec4c 344 #define D12 P1_2
whismanoid 0:cb44e2e9ec4c 345 #endif
whismanoid 0:cb44e2e9ec4c 346 #ifndef D13
whismanoid 0:cb44e2e9ec4c 347 #define D13 P1_0
whismanoid 0:cb44e2e9ec4c 348 #endif
whismanoid 0:cb44e2e9ec4c 349 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 350 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 351 // target MAX32600
whismanoid 0:cb44e2e9ec4c 352 //
whismanoid 0:cb44e2e9ec4c 353 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 354 const float ADC_FULL_SCALE_VOLTAGE = 1.500;
whismanoid 0:cb44e2e9ec4c 355 //
whismanoid 0:cb44e2e9ec4c 356 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 357 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 358 #warning "TARGET_MAX32620FTHR not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 359 #include "MAX32620FTHR.h"
whismanoid 0:cb44e2e9ec4c 360 // Initialize I/O voltages on MAX32620FTHR board
whismanoid 0:cb44e2e9ec4c 361 MAX32620FTHR fthr(MAX32620FTHR::VIO_3V3);
whismanoid 0:cb44e2e9ec4c 362 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 363 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 364 #warning "TARGET_MAX32620FTHR not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 365 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 366 //
whismanoid 0:cb44e2e9ec4c 367 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 368 #elif defined(TARGET_MAX32625PICO)
whismanoid 0:cb44e2e9ec4c 369 #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 370 #include "max32625pico.h"
whismanoid 0:cb44e2e9ec4c 371 // configure MAX32625PICO VDDIOH mode, and I/O voltages for DIP pins and SWD pins
whismanoid 0:cb44e2e9ec4c 372 MAX32625PICO pico(
whismanoid 13:184a08909405 373 // Select source of higher-voltage logic high supply VDDIOH
whismanoid 0:cb44e2e9ec4c 374 // vddioh_mode_t iohMode
whismanoid 0:cb44e2e9ec4c 375 //~ MAX32625PICO::IOH_OFF, // No connections to VDDIOH
whismanoid 0:cb44e2e9ec4c 376 //~ MAX32625PICO::IOH_DIP_IN, // VDDIOH input from DIP pin 1 (AIN0)
whismanoid 0:cb44e2e9ec4c 377 //~ MAX32625PICO::IOH_SWD_IN, // VDDIOH input from SWD pin 1
whismanoid 0:cb44e2e9ec4c 378 MAX32625PICO::IOH_3V3, // VDDIOH = 3.3V from local supply
whismanoid 0:cb44e2e9ec4c 379 //~ MAX32625PICO::IOH_DIP_OUT, // VDDIOH = 3.3V output to DIP pin 1
whismanoid 0:cb44e2e9ec4c 380 //~ MAX32625PICO::IOH_SWD_OUT, // VDDIOH = 3.3V output to SWD pin 1
whismanoid 0:cb44e2e9ec4c 381 //
whismanoid 13:184a08909405 382 // Digital I/O pin logic high voltage 1.8V or 3.3V
whismanoid 0:cb44e2e9ec4c 383 // vio_t dipVio = MAX32625PICO::VIO_1V8 or MAX32625PICO::VIO_IOH
whismanoid 13:184a08909405 384 MAX32625PICO::VIO_1V8, // 1.8V IO (local)
whismanoid 13:184a08909405 385 //~ MAX32625PICO::VIO_IOH, // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 386 //
whismanoid 13:184a08909405 387 // Software Debug logic high voltage (normally use VIO_IOH)
whismanoid 0:cb44e2e9ec4c 388 // vio_t swdVio
whismanoid 0:cb44e2e9ec4c 389 //~ MAX32625PICO::VIO_1V8 // 1.8V IO (local)
whismanoid 0:cb44e2e9ec4c 390 MAX32625PICO::VIO_IOH // Use VDDIOH (from DIP pin 1, or SWD pin1, or local 3.3V)
whismanoid 0:cb44e2e9ec4c 391 );
whismanoid 0:cb44e2e9ec4c 392 //#define USE_LEDS 0 ?
whismanoid 0:cb44e2e9ec4c 393 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 0:cb44e2e9ec4c 394 #warning "TARGET_MAX32625PICO not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 0:cb44e2e9ec4c 395 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 0:cb44e2e9ec4c 396 //
whismanoid 0:cb44e2e9ec4c 397 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 398 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 399 // TODO1: target NUCLEO_F446RE
whismanoid 0:cb44e2e9ec4c 400 //
whismanoid 0:cb44e2e9ec4c 401 // USER_BUTTON PC13
whismanoid 0:cb44e2e9ec4c 402 // LED1 is shared with SPI_SCK on NUCLEO_F446RE PA_5, so don't use LED1.
whismanoid 0:cb44e2e9ec4c 403 #define USE_LEDS 0
whismanoid 0:cb44e2e9ec4c 404 // SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
whismanoid 0:cb44e2e9ec4c 405 // Serial serial(SERIAL_TX, SERIAL_RX);
whismanoid 0:cb44e2e9ec4c 406 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 407 const float ADC_FULL_SCALE_VOLTAGE = 3.300; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 0:cb44e2e9ec4c 408 //
whismanoid 0:cb44e2e9ec4c 409 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 410 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 411 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 412 // TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM
whismanoid 0:cb44e2e9ec4c 413 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 414 // ______ | [ ] GND +3.3V VOUT [ ] | ______
whismanoid 0:cb44e2e9ec4c 415 // ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | ______
whismanoid 0:cb44e2e9ec4c 416 // ______ | [ ] VB USB.IF- [ ] | ______
whismanoid 0:cb44e2e9ec4c 417 // ______ | [ ] nR USB.IF+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 418 // digitalInOut0 | [ ] p5 MOSI ETHERNET.RD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 419 // digitalInOut1 | [ ] p6 MISO ETHERNET.RD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 420 // digitalInOut2 | [ ] p7 SCLK ETHERNET.TD- [ ] | ______
whismanoid 0:cb44e2e9ec4c 421 // digitalInOut3 | [ ] p8 ETHERNET.TD+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 422 // digitalInOut4 | [ ] p9 TX SDA USB.D- [ ] | ______
whismanoid 0:cb44e2e9ec4c 423 // digitalInOut5 | [ ] p10 RX SCL USB.D+ [ ] | ______
whismanoid 0:cb44e2e9ec4c 424 // digitalInOut6 | [ ] p11 MOSI CAN-RD p30 [ ] | digitalInOut13
whismanoid 0:cb44e2e9ec4c 425 // digitalInOut7 | [ ] p12 MISO CAN-TD p29 [ ] | digitalInOut12
whismanoid 0:cb44e2e9ec4c 426 // digitalInOut8 | [ ] p13 TX SCLK SDA TX p28 [ ] | digitalInOut11
whismanoid 0:cb44e2e9ec4c 427 // digitalInOut9 | [ ] p14 RX SCL RX p27 [ ] | digitalInOut10
whismanoid 0:cb44e2e9ec4c 428 // analogIn0 | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1
whismanoid 0:cb44e2e9ec4c 429 // analogIn1 | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2
whismanoid 0:cb44e2e9ec4c 430 // analogIn2 | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3
whismanoid 0:cb44e2e9ec4c 431 // analogIn3 | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4
whismanoid 0:cb44e2e9ec4c 432 // analogIn4 | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5
whismanoid 0:cb44e2e9ec4c 433 // analogIn5 | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6
whismanoid 0:cb44e2e9ec4c 434 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 435 // AIN6 = P0.3 = TGT_SBL_RXD?
whismanoid 0:cb44e2e9ec4c 436 // AIN7 = P0.2 = TGT_SBL_TXD?
whismanoid 0:cb44e2e9ec4c 437 //
whismanoid 0:cb44e2e9ec4c 438 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 439 // LPC1768 board uses VREF = 3.300V +A3,3V thru L1 to bypass capacitor C14
whismanoid 0:cb44e2e9ec4c 440 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 0:cb44e2e9ec4c 441 const float ADC_FULL_SCALE_VOLTAGE = 3.300;
whismanoid 0:cb44e2e9ec4c 442 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 0:cb44e2e9ec4c 443 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 444 // unknown target
whismanoid 0:cb44e2e9ec4c 445 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 446 #endif // target definition
whismanoid 0:cb44e2e9ec4c 447
whismanoid 0:cb44e2e9ec4c 448
whismanoid 0:cb44e2e9ec4c 449
whismanoid 0:cb44e2e9ec4c 450
whismanoid 0:cb44e2e9ec4c 451 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 452 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 453 // Declare the DigitalInOut GPIO pins
whismanoid 0:cb44e2e9ec4c 454 // Optional digitalInOut support. If there is only one it should be digitalInOut1.
whismanoid 0:cb44e2e9ec4c 455 // D) Digital High/Low/Input Pin
whismanoid 0:cb44e2e9ec4c 456 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 457 // +-------------[microUSB]-------------+
whismanoid 0:cb44e2e9ec4c 458 // | J1 MAX32630FTHR J2 |
whismanoid 0:cb44e2e9ec4c 459 // | [ ] RST GND [ ] |
whismanoid 0:cb44e2e9ec4c 460 // | [ ] 3V3 BAT+[ ] |
whismanoid 0:cb44e2e9ec4c 461 // | [ ] 1V8 reset SW1 |
whismanoid 0:cb44e2e9ec4c 462 // | [ ] GND J4 J3 |
whismanoid 0:cb44e2e9ec4c 463 // | [ ] AIN_0 1.2Vfs (bat) SYS [ ] |
whismanoid 0:cb44e2e9ec4c 464 // | [ ] AIN_1 1.2Vfs PWR [ ] |
whismanoid 0:cb44e2e9ec4c 465 // | [ ] AIN_2 1.2Vfs +5V VBUS [ ] |
whismanoid 0:cb44e2e9ec4c 466 // | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9
whismanoid 0:cb44e2e9ec4c 467 // dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8
whismanoid 0:cb44e2e9ec4c 468 // dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7
whismanoid 0:cb44e2e9ec4c 469 // dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6
whismanoid 0:cb44e2e9ec4c 470 // dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5
whismanoid 0:cb44e2e9ec4c 471 // dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4
whismanoid 0:cb44e2e9ec4c 472 // dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3
whismanoid 0:cb44e2e9ec4c 473 // dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2
whismanoid 0:cb44e2e9ec4c 474 // | [ ] GND SDA P3_4 [x] | dig1
whismanoid 0:cb44e2e9ec4c 475 // +------------------------------------+
whismanoid 0:cb44e2e9ec4c 476 #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 477 #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 478 #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 479 #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 480 #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 481 #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 482 #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 483 #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 484 #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 485 #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 486 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 487 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 488 #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 489 #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 490 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 491 #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 492 #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 493 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 494 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 495 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 496 #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 497 #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 498 #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 499 #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 500 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 501 #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 502 #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 503 #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 504 #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 505 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 506 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 507 DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15
whismanoid 0:cb44e2e9ec4c 508 #endif
whismanoid 0:cb44e2e9ec4c 509 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 510 DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12
whismanoid 0:cb44e2e9ec4c 511 #endif
whismanoid 0:cb44e2e9ec4c 512 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 513 DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11
whismanoid 0:cb44e2e9ec4c 514 #endif
whismanoid 0:cb44e2e9ec4c 515 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 516 DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10
whismanoid 0:cb44e2e9ec4c 517 #endif
whismanoid 0:cb44e2e9ec4c 518 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 519 DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9
whismanoid 0:cb44e2e9ec4c 520 #endif
whismanoid 0:cb44e2e9ec4c 521 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 522 DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8
whismanoid 0:cb44e2e9ec4c 523 #endif
whismanoid 0:cb44e2e9ec4c 524 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 525 DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7
whismanoid 0:cb44e2e9ec4c 526 #endif
whismanoid 0:cb44e2e9ec4c 527 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 528 DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6
whismanoid 0:cb44e2e9ec4c 529 #endif
whismanoid 0:cb44e2e9ec4c 530 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 531 DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5
whismanoid 0:cb44e2e9ec4c 532 #endif
whismanoid 0:cb44e2e9ec4c 533 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 534 DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4
whismanoid 0:cb44e2e9ec4c 535 #endif
whismanoid 0:cb44e2e9ec4c 536 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 537 DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9
whismanoid 0:cb44e2e9ec4c 538 #endif
whismanoid 0:cb44e2e9ec4c 539 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 540 DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10
whismanoid 0:cb44e2e9ec4c 541 #endif
whismanoid 0:cb44e2e9ec4c 542 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 543 DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11
whismanoid 0:cb44e2e9ec4c 544 #endif
whismanoid 0:cb44e2e9ec4c 545 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 546 DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12
whismanoid 0:cb44e2e9ec4c 547 #endif
whismanoid 0:cb44e2e9ec4c 548 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 549 DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13
whismanoid 0:cb44e2e9ec4c 550 #endif
whismanoid 0:cb44e2e9ec4c 551 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 552 DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14
whismanoid 0:cb44e2e9ec4c 553 #endif
whismanoid 0:cb44e2e9ec4c 554 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 555 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 556 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 557 // +-------------------------------------+
whismanoid 0:cb44e2e9ec4c 558 // | MAX32625MBED Arduino UNO header |
whismanoid 0:cb44e2e9ec4c 559 // | |
whismanoid 0:cb44e2e9ec4c 560 // | A5/SCL[ ] | P1_7 dig15
whismanoid 0:cb44e2e9ec4c 561 // | A4/SDA[ ] | P1_6 dig14
whismanoid 0:cb44e2e9ec4c 562 // | AREF=N/C[ ] |
whismanoid 0:cb44e2e9ec4c 563 // | GND[ ] |
whismanoid 0:cb44e2e9ec4c 564 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 0:cb44e2e9ec4c 565 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 0:cb44e2e9ec4c 566 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 0:cb44e2e9ec4c 567 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 0:cb44e2e9ec4c 568 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 0:cb44e2e9ec4c 569 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 0:cb44e2e9ec4c 570 // | [ ]GND |
whismanoid 0:cb44e2e9ec4c 571 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 0:cb44e2e9ec4c 572 // | 6[ ]~| P0_6 dig6
whismanoid 0:cb44e2e9ec4c 573 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 0:cb44e2e9ec4c 574 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 0:cb44e2e9ec4c 575 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 0:cb44e2e9ec4c 576 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 0:cb44e2e9ec4c 577 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 0:cb44e2e9ec4c 578 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 0:cb44e2e9ec4c 579 // | [ ] [ ] [ ] |
whismanoid 0:cb44e2e9ec4c 580 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 0:cb44e2e9ec4c 581 // \_______________________/
whismanoid 0:cb44e2e9ec4c 582 //
whismanoid 0:cb44e2e9ec4c 583 #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 584 #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 585 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 586 #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 587 #else
whismanoid 0:cb44e2e9ec4c 588 #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 589 #endif
whismanoid 0:cb44e2e9ec4c 590 #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 591 #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 592 #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 593 #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 594 #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 595 #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 596 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 597 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 598 #else
whismanoid 0:cb44e2e9ec4c 599 #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 600 #endif
whismanoid 0:cb44e2e9ec4c 601 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 602 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 603 #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 604 #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 605 #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 606 #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 607 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 608 #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 609 #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 610 #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 611 #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 612 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 613 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 614 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 615 #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 616 #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 617 #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 618 #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 619 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 620 #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 621 #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 622 #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 623 #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 624 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 625 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 626 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0
whismanoid 0:cb44e2e9ec4c 627 #endif
whismanoid 0:cb44e2e9ec4c 628 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 629 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1
whismanoid 0:cb44e2e9ec4c 630 #endif
whismanoid 0:cb44e2e9ec4c 631 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 632 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2
whismanoid 0:cb44e2e9ec4c 633 #endif
whismanoid 0:cb44e2e9ec4c 634 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 635 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3
whismanoid 0:cb44e2e9ec4c 636 #endif
whismanoid 0:cb44e2e9ec4c 637 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 638 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4
whismanoid 0:cb44e2e9ec4c 639 #endif
whismanoid 0:cb44e2e9ec4c 640 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 641 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5
whismanoid 0:cb44e2e9ec4c 642 #endif
whismanoid 0:cb44e2e9ec4c 643 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 644 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6
whismanoid 0:cb44e2e9ec4c 645 #endif
whismanoid 0:cb44e2e9ec4c 646 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 647 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7
whismanoid 0:cb44e2e9ec4c 648 #endif
whismanoid 0:cb44e2e9ec4c 649 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 650 DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8
whismanoid 0:cb44e2e9ec4c 651 #endif
whismanoid 0:cb44e2e9ec4c 652 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 653 DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9
whismanoid 0:cb44e2e9ec4c 654 #endif
whismanoid 0:cb44e2e9ec4c 655 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 656 DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 0:cb44e2e9ec4c 657 #endif
whismanoid 0:cb44e2e9ec4c 658 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 659 DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 0:cb44e2e9ec4c 660 #endif
whismanoid 0:cb44e2e9ec4c 661 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 662 DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 0:cb44e2e9ec4c 663 #endif
whismanoid 0:cb44e2e9ec4c 664 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 665 DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 0:cb44e2e9ec4c 666 #endif
whismanoid 0:cb44e2e9ec4c 667 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 668 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 669 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 670 DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 671 #endif
whismanoid 0:cb44e2e9ec4c 672 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 673 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 674 DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 675 #endif
whismanoid 0:cb44e2e9ec4c 676 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 677 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 678 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 0:cb44e2e9ec4c 679 // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V
whismanoid 0:cb44e2e9ec4c 680 DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 681 #endif
whismanoid 0:cb44e2e9ec4c 682 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 683 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 0:cb44e2e9ec4c 684 DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 685 #endif
whismanoid 0:cb44e2e9ec4c 686 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 687 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 688 #define HAS_digitalInOut0 0
whismanoid 0:cb44e2e9ec4c 689 #define HAS_digitalInOut1 0
whismanoid 0:cb44e2e9ec4c 690 #if APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 691 // D2 -- MAX11131 EOC DigitalIn
whismanoid 0:cb44e2e9ec4c 692 #define HAS_digitalInOut2 0
whismanoid 0:cb44e2e9ec4c 693 #else
whismanoid 0:cb44e2e9ec4c 694 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 695 #endif
whismanoid 0:cb44e2e9ec4c 696 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 697 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 698 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 699 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 700 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 701 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 702 // D8 -- MAX5715 CLRb DigitalOut
whismanoid 0:cb44e2e9ec4c 703 #define HAS_digitalInOut8 0
whismanoid 0:cb44e2e9ec4c 704 #else
whismanoid 0:cb44e2e9ec4c 705 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 706 #endif
whismanoid 0:cb44e2e9ec4c 707 #if APPLICATION_MAX5715
whismanoid 0:cb44e2e9ec4c 708 // D9 -- MAX5715 LDACb DigitalOut
whismanoid 0:cb44e2e9ec4c 709 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 710 #elif APPLICATION_MAX11131
whismanoid 0:cb44e2e9ec4c 711 // D9 -- MAX11131 CNVST DigitalOut
whismanoid 0:cb44e2e9ec4c 712 #define HAS_digitalInOut9 0
whismanoid 0:cb44e2e9ec4c 713 #else
whismanoid 0:cb44e2e9ec4c 714 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 715 #endif
whismanoid 0:cb44e2e9ec4c 716 #if HAS_SPI
whismanoid 0:cb44e2e9ec4c 717 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 718 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 719 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 720 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 721 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 722 #define HAS_digitalInOut10 0
whismanoid 0:cb44e2e9ec4c 723 #define HAS_digitalInOut11 0
whismanoid 0:cb44e2e9ec4c 724 #define HAS_digitalInOut12 0
whismanoid 0:cb44e2e9ec4c 725 #define HAS_digitalInOut13 0
whismanoid 0:cb44e2e9ec4c 726 #else // HAS_SPI
whismanoid 0:cb44e2e9ec4c 727 #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 728 #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 729 #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 730 #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 731 #endif // HAS_SPI
whismanoid 0:cb44e2e9ec4c 732 #if HAS_I2C
whismanoid 0:cb44e2e9ec4c 733 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 0:cb44e2e9ec4c 734 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 735 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 736 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 737 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 738 #define HAS_digitalInOut14 0
whismanoid 0:cb44e2e9ec4c 739 #define HAS_digitalInOut15 0
whismanoid 0:cb44e2e9ec4c 740 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 741 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 742 #else // HAS_I2C
whismanoid 0:cb44e2e9ec4c 743 #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 744 #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 745 #define HAS_digitalInOut16 0
whismanoid 0:cb44e2e9ec4c 746 #define HAS_digitalInOut17 0
whismanoid 0:cb44e2e9ec4c 747 #endif // HAS_I2C
whismanoid 0:cb44e2e9ec4c 748 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 749 DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 750 #endif
whismanoid 0:cb44e2e9ec4c 751 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 752 DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 753 #endif
whismanoid 0:cb44e2e9ec4c 754 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 755 DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 756 #endif
whismanoid 0:cb44e2e9ec4c 757 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 758 DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 759 #endif
whismanoid 0:cb44e2e9ec4c 760 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 761 DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 762 #endif
whismanoid 0:cb44e2e9ec4c 763 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 764 DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 765 #endif
whismanoid 0:cb44e2e9ec4c 766 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 767 DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 768 #endif
whismanoid 0:cb44e2e9ec4c 769 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 770 DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 771 #endif
whismanoid 0:cb44e2e9ec4c 772 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 773 DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 774 #endif
whismanoid 0:cb44e2e9ec4c 775 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 776 DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 777 #endif
whismanoid 0:cb44e2e9ec4c 778 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 779 // Arduino digital pin D10 SPI function is CS/10
whismanoid 0:cb44e2e9ec4c 780 DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 781 #endif
whismanoid 0:cb44e2e9ec4c 782 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 783 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 0:cb44e2e9ec4c 784 DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 785 #endif
whismanoid 0:cb44e2e9ec4c 786 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 787 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 0:cb44e2e9ec4c 788 DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 789 #endif
whismanoid 0:cb44e2e9ec4c 790 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 791 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 0:cb44e2e9ec4c 792 DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 793 #endif
whismanoid 0:cb44e2e9ec4c 794 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 795 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 796 DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 797 #endif
whismanoid 0:cb44e2e9ec4c 798 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 799 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 0:cb44e2e9ec4c 800 DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 801 #endif
whismanoid 0:cb44e2e9ec4c 802 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 803 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 804 DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 805 #endif
whismanoid 0:cb44e2e9ec4c 806 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 807 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 0:cb44e2e9ec4c 808 DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 809 #endif
whismanoid 0:cb44e2e9ec4c 810 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 811 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 812 #define HAS_digitalInOut0 1
whismanoid 0:cb44e2e9ec4c 813 #define HAS_digitalInOut1 1
whismanoid 0:cb44e2e9ec4c 814 #define HAS_digitalInOut2 1
whismanoid 0:cb44e2e9ec4c 815 #define HAS_digitalInOut3 1
whismanoid 0:cb44e2e9ec4c 816 #define HAS_digitalInOut4 1
whismanoid 0:cb44e2e9ec4c 817 #define HAS_digitalInOut5 1
whismanoid 0:cb44e2e9ec4c 818 #define HAS_digitalInOut6 1
whismanoid 0:cb44e2e9ec4c 819 #define HAS_digitalInOut7 1
whismanoid 0:cb44e2e9ec4c 820 #define HAS_digitalInOut8 1
whismanoid 0:cb44e2e9ec4c 821 #define HAS_digitalInOut9 1
whismanoid 0:cb44e2e9ec4c 822 // #define HAS_digitalInOut10 1
whismanoid 0:cb44e2e9ec4c 823 // #define HAS_digitalInOut11 1
whismanoid 0:cb44e2e9ec4c 824 // #define HAS_digitalInOut12 1
whismanoid 0:cb44e2e9ec4c 825 // #define HAS_digitalInOut13 1
whismanoid 0:cb44e2e9ec4c 826 // #define HAS_digitalInOut14 1
whismanoid 0:cb44e2e9ec4c 827 // #define HAS_digitalInOut15 1
whismanoid 0:cb44e2e9ec4c 828 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 829 DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3
whismanoid 0:cb44e2e9ec4c 830 #endif
whismanoid 0:cb44e2e9ec4c 831 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 832 DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2
whismanoid 0:cb44e2e9ec4c 833 #endif
whismanoid 0:cb44e2e9ec4c 834 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 835 DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1
whismanoid 0:cb44e2e9ec4c 836 #endif
whismanoid 0:cb44e2e9ec4c 837 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 838 DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0
whismanoid 0:cb44e2e9ec4c 839 #endif
whismanoid 0:cb44e2e9ec4c 840 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 841 DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1
whismanoid 0:cb44e2e9ec4c 842 #endif
whismanoid 0:cb44e2e9ec4c 843 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 844 DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1
whismanoid 0:cb44e2e9ec4c 845 #endif
whismanoid 0:cb44e2e9ec4c 846 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 847 DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1
whismanoid 0:cb44e2e9ec4c 848 #endif
whismanoid 0:cb44e2e9ec4c 849 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 850 DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO
whismanoid 0:cb44e2e9ec4c 851 #endif
whismanoid 0:cb44e2e9ec4c 852 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 853 DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK
whismanoid 0:cb44e2e9ec4c 854 #endif
whismanoid 0:cb44e2e9ec4c 855 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 856 DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL
whismanoid 0:cb44e2e9ec4c 857 #endif
whismanoid 0:cb44e2e9ec4c 858 //
whismanoid 0:cb44e2e9ec4c 859 // these pins support analog input analogIn0 .. analogIn5
whismanoid 0:cb44e2e9ec4c 860 //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 861 //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 862 //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 863 //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 864 //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 865 //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 866 //
whismanoid 0:cb44e2e9ec4c 867 // these pins support PWM pwmDriver1 .. pwmDriver6
whismanoid 0:cb44e2e9ec4c 868 //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0
whismanoid 0:cb44e2e9ec4c 869 //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1
whismanoid 0:cb44e2e9ec4c 870 //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2
whismanoid 0:cb44e2e9ec4c 871 //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3
whismanoid 0:cb44e2e9ec4c 872 //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1
whismanoid 0:cb44e2e9ec4c 873 //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK
whismanoid 0:cb44e2e9ec4c 874 //
whismanoid 0:cb44e2e9ec4c 875 // these could be additional digitalInOut pins
whismanoid 0:cb44e2e9ec4c 876 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 877 DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1
whismanoid 0:cb44e2e9ec4c 878 #endif
whismanoid 0:cb44e2e9ec4c 879 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 880 DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0
whismanoid 0:cb44e2e9ec4c 881 #endif
whismanoid 0:cb44e2e9ec4c 882 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 883 DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1
whismanoid 0:cb44e2e9ec4c 884 #endif
whismanoid 0:cb44e2e9ec4c 885 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 886 DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0
whismanoid 0:cb44e2e9ec4c 887 #endif
whismanoid 0:cb44e2e9ec4c 888 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 889 DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 890 #endif
whismanoid 0:cb44e2e9ec4c 891 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 892 DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1);
whismanoid 0:cb44e2e9ec4c 893 #endif
whismanoid 0:cb44e2e9ec4c 894 #else
whismanoid 0:cb44e2e9ec4c 895 // unknown target
whismanoid 0:cb44e2e9ec4c 896 #endif
whismanoid 0:cb44e2e9ec4c 897 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 898 #if HAS_digitalInOut0 || HAS_digitalInOut1 \
whismanoid 0:cb44e2e9ec4c 899 || HAS_digitalInOut2 || HAS_digitalInOut3 \
whismanoid 0:cb44e2e9ec4c 900 || HAS_digitalInOut4 || HAS_digitalInOut5 \
whismanoid 0:cb44e2e9ec4c 901 || HAS_digitalInOut6 || HAS_digitalInOut7 \
whismanoid 0:cb44e2e9ec4c 902 || HAS_digitalInOut8 || HAS_digitalInOut9 \
whismanoid 0:cb44e2e9ec4c 903 || HAS_digitalInOut10 || HAS_digitalInOut11 \
whismanoid 0:cb44e2e9ec4c 904 || HAS_digitalInOut12 || HAS_digitalInOut13 \
whismanoid 0:cb44e2e9ec4c 905 || HAS_digitalInOut14 || HAS_digitalInOut15 \
whismanoid 0:cb44e2e9ec4c 906 || HAS_digitalInOut16 || HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 907 #define HAS_digitalInOuts 1
whismanoid 0:cb44e2e9ec4c 908 #else
whismanoid 0:cb44e2e9ec4c 909 #warning "Note: There are no digitalInOut resources defined"
whismanoid 0:cb44e2e9ec4c 910 #endif
whismanoid 0:cb44e2e9ec4c 911
whismanoid 0:cb44e2e9ec4c 912 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 0:cb44e2e9ec4c 913 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 914 // Declare the AnalogIn driver
whismanoid 0:cb44e2e9ec4c 915 // Optional analogIn support. If there is only one it should be analogIn1.
whismanoid 0:cb44e2e9ec4c 916 // A) analog input
whismanoid 0:cb44e2e9ec4c 917 #if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 918 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 919 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 920 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 921 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 922 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 923 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 924 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 925 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 926 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 927 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 928 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 929 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 930 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 931 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 932 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 933 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 934 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 935 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 936 #endif
whismanoid 0:cb44e2e9ec4c 937 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 938 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 939 #endif
whismanoid 0:cb44e2e9ec4c 940 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 941 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 942 #endif
whismanoid 0:cb44e2e9ec4c 943 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 944 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 945 #endif
whismanoid 0:cb44e2e9ec4c 946 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 947 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 948 #endif
whismanoid 0:cb44e2e9ec4c 949 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 950 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 951 #endif
whismanoid 0:cb44e2e9ec4c 952 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 953 AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 954 #endif
whismanoid 0:cb44e2e9ec4c 955 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 956 AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 957 #endif
whismanoid 0:cb44e2e9ec4c 958 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 959 AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 960 #endif
whismanoid 0:cb44e2e9ec4c 961 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 962 AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 963 #endif
whismanoid 0:cb44e2e9ec4c 964 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 965 AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 966 #endif
whismanoid 0:cb44e2e9ec4c 967 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 968 AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 969 #endif
whismanoid 0:cb44e2e9ec4c 970 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 971 AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 972 #endif
whismanoid 0:cb44e2e9ec4c 973 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 974 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 975 #endif
whismanoid 0:cb44e2e9ec4c 976 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 977 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 978 #endif
whismanoid 0:cb44e2e9ec4c 979 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 980 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 981 #endif
whismanoid 0:cb44e2e9ec4c 982 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 983 #elif defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 984 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 985 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 986 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 987 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 988 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 989 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 990 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 991 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 992 #endif
whismanoid 0:cb44e2e9ec4c 993 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 994 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 995 #endif
whismanoid 0:cb44e2e9ec4c 996 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 997 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 998 #endif
whismanoid 0:cb44e2e9ec4c 999 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1000 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1001 #endif
whismanoid 0:cb44e2e9ec4c 1002 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1003 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1004 #endif
whismanoid 0:cb44e2e9ec4c 1005 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1006 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1007 #endif
whismanoid 0:cb44e2e9ec4c 1008 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1009 #elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 1010 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1011 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1012 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1013 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1014 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1015 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1016 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1017 #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1018 #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1019 #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1020 #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1021 // #define HAS_analogIn10 0
whismanoid 0:cb44e2e9ec4c 1022 // #define HAS_analogIn11 0
whismanoid 0:cb44e2e9ec4c 1023 // #define HAS_analogIn12 0
whismanoid 0:cb44e2e9ec4c 1024 // #define HAS_analogIn13 0
whismanoid 0:cb44e2e9ec4c 1025 // #define HAS_analogIn14 0
whismanoid 0:cb44e2e9ec4c 1026 // #define HAS_analogIn15 0
whismanoid 0:cb44e2e9ec4c 1027 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1028 AnalogIn analogIn0(AIN_0); // TARGET_MAX32620FTHR J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1029 #endif
whismanoid 0:cb44e2e9ec4c 1030 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1031 AnalogIn analogIn1(AIN_1); // TARGET_MAX32620FTHR J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1032 #endif
whismanoid 0:cb44e2e9ec4c 1033 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1034 AnalogIn analogIn2(AIN_2); // TARGET_MAX32620FTHR J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1035 #endif
whismanoid 0:cb44e2e9ec4c 1036 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1037 AnalogIn analogIn3(AIN_3); // TARGET_MAX32620FTHR J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1038 #endif
whismanoid 0:cb44e2e9ec4c 1039 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1040 AnalogIn analogIn4(AIN_4); // TARGET_MAX32620FTHR J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1041 #endif
whismanoid 0:cb44e2e9ec4c 1042 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1043 AnalogIn analogIn5(AIN_5); // TARGET_MAX32620FTHR J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1044 #endif
whismanoid 0:cb44e2e9ec4c 1045 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1046 AnalogIn analogIn6(AIN_6); // TARGET_MAX32620FTHR AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1047 #endif
whismanoid 0:cb44e2e9ec4c 1048 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1049 AnalogIn analogIn7(AIN_7); // TARGET_MAX32620FTHR AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1050 #endif
whismanoid 0:cb44e2e9ec4c 1051 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1052 AnalogIn analogIn8(AIN_8); // TARGET_MAX32620FTHR AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1053 #endif
whismanoid 0:cb44e2e9ec4c 1054 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1055 AnalogIn analogIn9(AIN_9); // TARGET_MAX32620FTHR AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1056 #endif
whismanoid 0:cb44e2e9ec4c 1057 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1058 AnalogIn analogIn10(____); // TARGET_MAX32620FTHR AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1059 #endif
whismanoid 0:cb44e2e9ec4c 1060 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1061 AnalogIn analogIn11(____); // TARGET_MAX32620FTHR AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1062 #endif
whismanoid 0:cb44e2e9ec4c 1063 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1064 AnalogIn analogIn12(____); // TARGET_MAX32620FTHR AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1065 #endif
whismanoid 0:cb44e2e9ec4c 1066 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1067 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1068 #endif
whismanoid 0:cb44e2e9ec4c 1069 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1070 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1071 #endif
whismanoid 0:cb44e2e9ec4c 1072 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1073 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1074 #endif
whismanoid 0:cb44e2e9ec4c 1075 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1076 #elif defined(TARGET_MAX32625PICO)
whismanoid 0:cb44e2e9ec4c 1077 #warning "TARGET_MAX32625PICO not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1078 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1079 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1080 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1081 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1082 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1083 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1084 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1085 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1086 #endif
whismanoid 0:cb44e2e9ec4c 1087 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1088 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1089 #endif
whismanoid 0:cb44e2e9ec4c 1090 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1091 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1092 #endif
whismanoid 0:cb44e2e9ec4c 1093 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1094 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1095 #endif
whismanoid 0:cb44e2e9ec4c 1096 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1097 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1098 #endif
whismanoid 0:cb44e2e9ec4c 1099 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1100 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1101 #endif
whismanoid 0:cb44e2e9ec4c 1102 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1103 #elif defined(TARGET_MAX32600)
whismanoid 0:cb44e2e9ec4c 1104 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1105 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1106 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1107 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1108 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1109 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1110 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1111 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1112 #endif
whismanoid 0:cb44e2e9ec4c 1113 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1114 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1115 #endif
whismanoid 0:cb44e2e9ec4c 1116 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1117 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1118 #endif
whismanoid 0:cb44e2e9ec4c 1119 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1120 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1121 #endif
whismanoid 0:cb44e2e9ec4c 1122 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1123 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1124 #endif
whismanoid 0:cb44e2e9ec4c 1125 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1126 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1127 #endif
whismanoid 0:cb44e2e9ec4c 1128 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1129 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 1130 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1131 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1132 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1133 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1134 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1135 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1136 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1137 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1138 #endif
whismanoid 0:cb44e2e9ec4c 1139 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1140 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1141 #endif
whismanoid 0:cb44e2e9ec4c 1142 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1143 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1144 #endif
whismanoid 0:cb44e2e9ec4c 1145 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1146 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1147 #endif
whismanoid 0:cb44e2e9ec4c 1148 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1149 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1150 #endif
whismanoid 0:cb44e2e9ec4c 1151 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1152 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1153 #endif
whismanoid 0:cb44e2e9ec4c 1154 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1155 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1156 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1157 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1158 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1159 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1160 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1161 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1162 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1163 AnalogIn analogIn0(A0);
whismanoid 0:cb44e2e9ec4c 1164 #endif
whismanoid 0:cb44e2e9ec4c 1165 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1166 AnalogIn analogIn1(A1);
whismanoid 0:cb44e2e9ec4c 1167 #endif
whismanoid 0:cb44e2e9ec4c 1168 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1169 AnalogIn analogIn2(A2);
whismanoid 0:cb44e2e9ec4c 1170 #endif
whismanoid 0:cb44e2e9ec4c 1171 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1172 AnalogIn analogIn3(A3);
whismanoid 0:cb44e2e9ec4c 1173 #endif
whismanoid 0:cb44e2e9ec4c 1174 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1175 AnalogIn analogIn4(A4);
whismanoid 0:cb44e2e9ec4c 1176 #endif
whismanoid 0:cb44e2e9ec4c 1177 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1178 AnalogIn analogIn5(A5);
whismanoid 0:cb44e2e9ec4c 1179 #endif
whismanoid 0:cb44e2e9ec4c 1180 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1181 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 0:cb44e2e9ec4c 1182 #elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1183 #define HAS_analogIn0 1
whismanoid 0:cb44e2e9ec4c 1184 #define HAS_analogIn1 1
whismanoid 0:cb44e2e9ec4c 1185 #define HAS_analogIn2 1
whismanoid 0:cb44e2e9ec4c 1186 #define HAS_analogIn3 1
whismanoid 0:cb44e2e9ec4c 1187 #define HAS_analogIn4 1
whismanoid 0:cb44e2e9ec4c 1188 #define HAS_analogIn5 1
whismanoid 0:cb44e2e9ec4c 1189 // #define HAS_analogIn6 1
whismanoid 0:cb44e2e9ec4c 1190 // #define HAS_analogIn7 1
whismanoid 0:cb44e2e9ec4c 1191 // #define HAS_analogIn8 1
whismanoid 0:cb44e2e9ec4c 1192 // #define HAS_analogIn9 1
whismanoid 0:cb44e2e9ec4c 1193 // #define HAS_analogIn10 1
whismanoid 0:cb44e2e9ec4c 1194 // #define HAS_analogIn11 1
whismanoid 0:cb44e2e9ec4c 1195 // #define HAS_analogIn12 1
whismanoid 0:cb44e2e9ec4c 1196 // #define HAS_analogIn13 1
whismanoid 0:cb44e2e9ec4c 1197 // #define HAS_analogIn14 1
whismanoid 0:cb44e2e9ec4c 1198 // #define HAS_analogIn15 1
whismanoid 0:cb44e2e9ec4c 1199 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1200 AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 0:cb44e2e9ec4c 1201 #endif
whismanoid 0:cb44e2e9ec4c 1202 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1203 AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 0:cb44e2e9ec4c 1204 #endif
whismanoid 0:cb44e2e9ec4c 1205 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1206 AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 0:cb44e2e9ec4c 1207 #endif
whismanoid 0:cb44e2e9ec4c 1208 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1209 AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 0:cb44e2e9ec4c 1210 #endif
whismanoid 0:cb44e2e9ec4c 1211 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1212 AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 0:cb44e2e9ec4c 1213 #endif
whismanoid 0:cb44e2e9ec4c 1214 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1215 AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 0:cb44e2e9ec4c 1216 #endif
whismanoid 0:cb44e2e9ec4c 1217 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1218 AnalogIn analogIn6(____);
whismanoid 0:cb44e2e9ec4c 1219 #endif
whismanoid 0:cb44e2e9ec4c 1220 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1221 AnalogIn analogIn7(____);
whismanoid 0:cb44e2e9ec4c 1222 #endif
whismanoid 0:cb44e2e9ec4c 1223 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1224 AnalogIn analogIn8(____);
whismanoid 0:cb44e2e9ec4c 1225 #endif
whismanoid 0:cb44e2e9ec4c 1226 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1227 AnalogIn analogIn9(____);
whismanoid 0:cb44e2e9ec4c 1228 #endif
whismanoid 0:cb44e2e9ec4c 1229 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1230 AnalogIn analogIn10(____);
whismanoid 0:cb44e2e9ec4c 1231 #endif
whismanoid 0:cb44e2e9ec4c 1232 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1233 AnalogIn analogIn11(____);
whismanoid 0:cb44e2e9ec4c 1234 #endif
whismanoid 0:cb44e2e9ec4c 1235 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1236 AnalogIn analogIn12(____);
whismanoid 0:cb44e2e9ec4c 1237 #endif
whismanoid 0:cb44e2e9ec4c 1238 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1239 AnalogIn analogIn13(____);
whismanoid 0:cb44e2e9ec4c 1240 #endif
whismanoid 0:cb44e2e9ec4c 1241 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1242 AnalogIn analogIn14(____);
whismanoid 0:cb44e2e9ec4c 1243 #endif
whismanoid 0:cb44e2e9ec4c 1244 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1245 AnalogIn analogIn15(____);
whismanoid 0:cb44e2e9ec4c 1246 #endif
whismanoid 0:cb44e2e9ec4c 1247 #else
whismanoid 0:cb44e2e9ec4c 1248 // unknown target
whismanoid 0:cb44e2e9ec4c 1249 #endif
whismanoid 0:cb44e2e9ec4c 1250 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 0:cb44e2e9ec4c 1251 #if HAS_analogIn0 || HAS_analogIn1 \
whismanoid 0:cb44e2e9ec4c 1252 || HAS_analogIn2 || HAS_analogIn3 \
whismanoid 0:cb44e2e9ec4c 1253 || HAS_analogIn4 || HAS_analogIn5 \
whismanoid 0:cb44e2e9ec4c 1254 || HAS_analogIn6 || HAS_analogIn7 \
whismanoid 0:cb44e2e9ec4c 1255 || HAS_analogIn8 || HAS_analogIn9 \
whismanoid 0:cb44e2e9ec4c 1256 || HAS_analogIn10 || HAS_analogIn11 \
whismanoid 0:cb44e2e9ec4c 1257 || HAS_analogIn12 || HAS_analogIn13 \
whismanoid 0:cb44e2e9ec4c 1258 || HAS_analogIn14 || HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1259 #define HAS_analogIns 1
whismanoid 0:cb44e2e9ec4c 1260 #else
whismanoid 0:cb44e2e9ec4c 1261 #warning "Note: There are no analogIn resources defined"
whismanoid 0:cb44e2e9ec4c 1262 #endif
whismanoid 0:cb44e2e9ec4c 1263
whismanoid 0:cb44e2e9ec4c 1264 // DigitalInOut pin resource: print the pin index names to serial
whismanoid 0:cb44e2e9ec4c 1265 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 1266 void list_digitalInOutPins(Stream& serialStream)
whismanoid 0:cb44e2e9ec4c 1267 {
whismanoid 0:cb44e2e9ec4c 1268 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1269 serialStream.printf(" 0");
whismanoid 0:cb44e2e9ec4c 1270 #endif
whismanoid 0:cb44e2e9ec4c 1271 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1272 serialStream.printf(" 1");
whismanoid 0:cb44e2e9ec4c 1273 #endif
whismanoid 0:cb44e2e9ec4c 1274 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1275 serialStream.printf(" 2");
whismanoid 0:cb44e2e9ec4c 1276 #endif
whismanoid 0:cb44e2e9ec4c 1277 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1278 serialStream.printf(" 3");
whismanoid 0:cb44e2e9ec4c 1279 #endif
whismanoid 0:cb44e2e9ec4c 1280 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1281 serialStream.printf(" 4");
whismanoid 0:cb44e2e9ec4c 1282 #endif
whismanoid 0:cb44e2e9ec4c 1283 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1284 serialStream.printf(" 5");
whismanoid 0:cb44e2e9ec4c 1285 #endif
whismanoid 0:cb44e2e9ec4c 1286 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1287 serialStream.printf(" 6");
whismanoid 0:cb44e2e9ec4c 1288 #endif
whismanoid 0:cb44e2e9ec4c 1289 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1290 serialStream.printf(" 7");
whismanoid 0:cb44e2e9ec4c 1291 #endif
whismanoid 0:cb44e2e9ec4c 1292 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1293 serialStream.printf(" 8");
whismanoid 0:cb44e2e9ec4c 1294 #endif
whismanoid 0:cb44e2e9ec4c 1295 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1296 serialStream.printf(" 9");
whismanoid 0:cb44e2e9ec4c 1297 #endif
whismanoid 0:cb44e2e9ec4c 1298 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1299 serialStream.printf(" 10");
whismanoid 0:cb44e2e9ec4c 1300 #endif
whismanoid 0:cb44e2e9ec4c 1301 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1302 serialStream.printf(" 11");
whismanoid 0:cb44e2e9ec4c 1303 #endif
whismanoid 0:cb44e2e9ec4c 1304 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1305 serialStream.printf(" 12");
whismanoid 0:cb44e2e9ec4c 1306 #endif
whismanoid 0:cb44e2e9ec4c 1307 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1308 serialStream.printf(" 13");
whismanoid 0:cb44e2e9ec4c 1309 #endif
whismanoid 0:cb44e2e9ec4c 1310 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1311 serialStream.printf(" 14");
whismanoid 0:cb44e2e9ec4c 1312 #endif
whismanoid 0:cb44e2e9ec4c 1313 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1314 serialStream.printf(" 15");
whismanoid 0:cb44e2e9ec4c 1315 #endif
whismanoid 0:cb44e2e9ec4c 1316 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1317 serialStream.printf(" 16");
whismanoid 0:cb44e2e9ec4c 1318 #endif
whismanoid 0:cb44e2e9ec4c 1319 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1320 serialStream.printf(" 17");
whismanoid 0:cb44e2e9ec4c 1321 #endif
whismanoid 0:cb44e2e9ec4c 1322 }
whismanoid 0:cb44e2e9ec4c 1323 #endif
whismanoid 0:cb44e2e9ec4c 1324
whismanoid 0:cb44e2e9ec4c 1325
whismanoid 0:cb44e2e9ec4c 1326 // DigitalInOut pin resource: search index
whismanoid 0:cb44e2e9ec4c 1327 #if HAS_digitalInOuts
whismanoid 0:cb44e2e9ec4c 1328 DigitalInOut& find_digitalInOutPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 1329 {
whismanoid 0:cb44e2e9ec4c 1330 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 1331 {
whismanoid 0:cb44e2e9ec4c 1332 default: // default to the first defined digitalInOut pin
whismanoid 0:cb44e2e9ec4c 1333 #if HAS_digitalInOut0
whismanoid 0:cb44e2e9ec4c 1334 case '0': case 0x00: return digitalInOut0;
whismanoid 0:cb44e2e9ec4c 1335 #endif
whismanoid 0:cb44e2e9ec4c 1336 #if HAS_digitalInOut1
whismanoid 0:cb44e2e9ec4c 1337 case '1': case 0x01: return digitalInOut1;
whismanoid 0:cb44e2e9ec4c 1338 #endif
whismanoid 0:cb44e2e9ec4c 1339 #if HAS_digitalInOut2
whismanoid 0:cb44e2e9ec4c 1340 case '2': case 0x02: return digitalInOut2;
whismanoid 0:cb44e2e9ec4c 1341 #endif
whismanoid 0:cb44e2e9ec4c 1342 #if HAS_digitalInOut3
whismanoid 0:cb44e2e9ec4c 1343 case '3': case 0x03: return digitalInOut3;
whismanoid 0:cb44e2e9ec4c 1344 #endif
whismanoid 0:cb44e2e9ec4c 1345 #if HAS_digitalInOut4
whismanoid 0:cb44e2e9ec4c 1346 case '4': case 0x04: return digitalInOut4;
whismanoid 0:cb44e2e9ec4c 1347 #endif
whismanoid 0:cb44e2e9ec4c 1348 #if HAS_digitalInOut5
whismanoid 0:cb44e2e9ec4c 1349 case '5': case 0x05: return digitalInOut5;
whismanoid 0:cb44e2e9ec4c 1350 #endif
whismanoid 0:cb44e2e9ec4c 1351 #if HAS_digitalInOut6
whismanoid 0:cb44e2e9ec4c 1352 case '6': case 0x06: return digitalInOut6;
whismanoid 0:cb44e2e9ec4c 1353 #endif
whismanoid 0:cb44e2e9ec4c 1354 #if HAS_digitalInOut7
whismanoid 0:cb44e2e9ec4c 1355 case '7': case 0x07: return digitalInOut7;
whismanoid 0:cb44e2e9ec4c 1356 #endif
whismanoid 0:cb44e2e9ec4c 1357 #if HAS_digitalInOut8
whismanoid 0:cb44e2e9ec4c 1358 case '8': case 0x08: return digitalInOut8;
whismanoid 0:cb44e2e9ec4c 1359 #endif
whismanoid 0:cb44e2e9ec4c 1360 #if HAS_digitalInOut9
whismanoid 0:cb44e2e9ec4c 1361 case '9': case 0x09: return digitalInOut9;
whismanoid 0:cb44e2e9ec4c 1362 #endif
whismanoid 0:cb44e2e9ec4c 1363 #if HAS_digitalInOut10
whismanoid 0:cb44e2e9ec4c 1364 case 'a': case 0x0a: return digitalInOut10;
whismanoid 0:cb44e2e9ec4c 1365 #endif
whismanoid 0:cb44e2e9ec4c 1366 #if HAS_digitalInOut11
whismanoid 0:cb44e2e9ec4c 1367 case 'b': case 0x0b: return digitalInOut11;
whismanoid 0:cb44e2e9ec4c 1368 #endif
whismanoid 0:cb44e2e9ec4c 1369 #if HAS_digitalInOut12
whismanoid 0:cb44e2e9ec4c 1370 case 'c': case 0x0c: return digitalInOut12;
whismanoid 0:cb44e2e9ec4c 1371 #endif
whismanoid 0:cb44e2e9ec4c 1372 #if HAS_digitalInOut13
whismanoid 0:cb44e2e9ec4c 1373 case 'd': case 0x0d: return digitalInOut13;
whismanoid 0:cb44e2e9ec4c 1374 #endif
whismanoid 0:cb44e2e9ec4c 1375 #if HAS_digitalInOut14
whismanoid 0:cb44e2e9ec4c 1376 case 'e': case 0x0e: return digitalInOut14;
whismanoid 0:cb44e2e9ec4c 1377 #endif
whismanoid 0:cb44e2e9ec4c 1378 #if HAS_digitalInOut15
whismanoid 0:cb44e2e9ec4c 1379 case 'f': case 0x0f: return digitalInOut15;
whismanoid 0:cb44e2e9ec4c 1380 #endif
whismanoid 0:cb44e2e9ec4c 1381 #if HAS_digitalInOut16
whismanoid 0:cb44e2e9ec4c 1382 case 'g': case 0x10: return digitalInOut16;
whismanoid 0:cb44e2e9ec4c 1383 #endif
whismanoid 0:cb44e2e9ec4c 1384 #if HAS_digitalInOut17
whismanoid 0:cb44e2e9ec4c 1385 case 'h': case 0x11: return digitalInOut17;
whismanoid 0:cb44e2e9ec4c 1386 #endif
whismanoid 0:cb44e2e9ec4c 1387 }
whismanoid 0:cb44e2e9ec4c 1388 }
whismanoid 0:cb44e2e9ec4c 1389 #endif
whismanoid 0:cb44e2e9ec4c 1390
whismanoid 0:cb44e2e9ec4c 1391
whismanoid 0:cb44e2e9ec4c 1392 // AnalogIn pin resource: search index
whismanoid 0:cb44e2e9ec4c 1393 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 1394 AnalogIn& find_analogInPin(int cPinIndex)
whismanoid 0:cb44e2e9ec4c 1395 {
whismanoid 0:cb44e2e9ec4c 1396 switch (cPinIndex)
whismanoid 0:cb44e2e9ec4c 1397 {
whismanoid 0:cb44e2e9ec4c 1398 default: // default to the first defined analogIn pin
whismanoid 0:cb44e2e9ec4c 1399 #if HAS_analogIn0
whismanoid 0:cb44e2e9ec4c 1400 case '0': case 0x00: return analogIn0;
whismanoid 0:cb44e2e9ec4c 1401 #endif
whismanoid 0:cb44e2e9ec4c 1402 #if HAS_analogIn1
whismanoid 0:cb44e2e9ec4c 1403 case '1': case 0x01: return analogIn1;
whismanoid 0:cb44e2e9ec4c 1404 #endif
whismanoid 0:cb44e2e9ec4c 1405 #if HAS_analogIn2
whismanoid 0:cb44e2e9ec4c 1406 case '2': case 0x02: return analogIn2;
whismanoid 0:cb44e2e9ec4c 1407 #endif
whismanoid 0:cb44e2e9ec4c 1408 #if HAS_analogIn3
whismanoid 0:cb44e2e9ec4c 1409 case '3': case 0x03: return analogIn3;
whismanoid 0:cb44e2e9ec4c 1410 #endif
whismanoid 0:cb44e2e9ec4c 1411 #if HAS_analogIn4
whismanoid 0:cb44e2e9ec4c 1412 case '4': case 0x04: return analogIn4;
whismanoid 0:cb44e2e9ec4c 1413 #endif
whismanoid 0:cb44e2e9ec4c 1414 #if HAS_analogIn5
whismanoid 0:cb44e2e9ec4c 1415 case '5': case 0x05: return analogIn5;
whismanoid 0:cb44e2e9ec4c 1416 #endif
whismanoid 0:cb44e2e9ec4c 1417 #if HAS_analogIn6
whismanoid 0:cb44e2e9ec4c 1418 case '6': case 0x06: return analogIn6;
whismanoid 0:cb44e2e9ec4c 1419 #endif
whismanoid 0:cb44e2e9ec4c 1420 #if HAS_analogIn7
whismanoid 0:cb44e2e9ec4c 1421 case '7': case 0x07: return analogIn7;
whismanoid 0:cb44e2e9ec4c 1422 #endif
whismanoid 0:cb44e2e9ec4c 1423 #if HAS_analogIn8
whismanoid 0:cb44e2e9ec4c 1424 case '8': case 0x08: return analogIn8;
whismanoid 0:cb44e2e9ec4c 1425 #endif
whismanoid 0:cb44e2e9ec4c 1426 #if HAS_analogIn9
whismanoid 0:cb44e2e9ec4c 1427 case '9': case 0x09: return analogIn9;
whismanoid 0:cb44e2e9ec4c 1428 #endif
whismanoid 0:cb44e2e9ec4c 1429 #if HAS_analogIn10
whismanoid 0:cb44e2e9ec4c 1430 case 'a': case 0x0a: return analogIn10;
whismanoid 0:cb44e2e9ec4c 1431 #endif
whismanoid 0:cb44e2e9ec4c 1432 #if HAS_analogIn11
whismanoid 0:cb44e2e9ec4c 1433 case 'b': case 0x0b: return analogIn11;
whismanoid 0:cb44e2e9ec4c 1434 #endif
whismanoid 0:cb44e2e9ec4c 1435 #if HAS_analogIn12
whismanoid 0:cb44e2e9ec4c 1436 case 'c': case 0x0c: return analogIn12;
whismanoid 0:cb44e2e9ec4c 1437 #endif
whismanoid 0:cb44e2e9ec4c 1438 #if HAS_analogIn13
whismanoid 0:cb44e2e9ec4c 1439 case 'd': case 0x0d: return analogIn13;
whismanoid 0:cb44e2e9ec4c 1440 #endif
whismanoid 0:cb44e2e9ec4c 1441 #if HAS_analogIn14
whismanoid 0:cb44e2e9ec4c 1442 case 'e': case 0x0e: return analogIn14;
whismanoid 0:cb44e2e9ec4c 1443 #endif
whismanoid 0:cb44e2e9ec4c 1444 #if HAS_analogIn15
whismanoid 0:cb44e2e9ec4c 1445 case 'f': case 0x0f: return analogIn15;
whismanoid 0:cb44e2e9ec4c 1446 #endif
whismanoid 0:cb44e2e9ec4c 1447 }
whismanoid 0:cb44e2e9ec4c 1448 }
whismanoid 0:cb44e2e9ec4c 1449 #endif
whismanoid 0:cb44e2e9ec4c 1450
whismanoid 0:cb44e2e9ec4c 1451 #if HAS_analogIns
whismanoid 0:cb44e2e9ec4c 1452 const float analogInPin_fullScaleVoltage[] = {
whismanoid 0:cb44e2e9ec4c 1453 # if defined(TARGET_MAX32630)
whismanoid 0:cb44e2e9ec4c 1454 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1455 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1456 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1457 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1458 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1459 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1460 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1461 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1462 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1463 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1464 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1465 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1466 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1467 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1468 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1469 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1470 # elif defined(TARGET_MAX32620FTHR)
whismanoid 0:cb44e2e9ec4c 1471 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 0:cb44e2e9ec4c 1472 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1473 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1474 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1475 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1476 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1477 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1478 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1479 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1480 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1481 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1482 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1483 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1484 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1485 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1486 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1487 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1488 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO)
whismanoid 0:cb44e2e9ec4c 1489 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1490 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1491 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1492 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1493 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1494 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 0:cb44e2e9ec4c 1495 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1496 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1497 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 0:cb44e2e9ec4c 1498 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 0:cb44e2e9ec4c 1499 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 0:cb44e2e9ec4c 1500 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1501 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 0:cb44e2e9ec4c 1502 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1503 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1504 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1505 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 0:cb44e2e9ec4c 1506 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1507 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1508 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1509 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1510 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1511 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1512 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1513 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1514 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1515 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 1516 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 1517 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 1518 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 1519 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1520 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1521 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1522 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1523 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1524 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1525 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1526 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1527 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1528 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1529 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1530 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1531 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1532 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 1533 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 1534 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 1535 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 1536 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1537 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1538 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1539 //#elif defined(TARGET_LPC1768)
whismanoid 0:cb44e2e9ec4c 1540 #else
whismanoid 0:cb44e2e9ec4c 1541 // unknown target
whismanoid 0:cb44e2e9ec4c 1542 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 0:cb44e2e9ec4c 1543 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 0:cb44e2e9ec4c 1544 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 0:cb44e2e9ec4c 1545 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 0:cb44e2e9ec4c 1546 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 0:cb44e2e9ec4c 1547 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 0:cb44e2e9ec4c 1548 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 0:cb44e2e9ec4c 1549 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 0:cb44e2e9ec4c 1550 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 0:cb44e2e9ec4c 1551 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 0:cb44e2e9ec4c 1552 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 0:cb44e2e9ec4c 1553 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 0:cb44e2e9ec4c 1554 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 0:cb44e2e9ec4c 1555 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 0:cb44e2e9ec4c 1556 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 0:cb44e2e9ec4c 1557 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 0:cb44e2e9ec4c 1558 # endif
whismanoid 0:cb44e2e9ec4c 1559 };
whismanoid 0:cb44e2e9ec4c 1560 #endif
whismanoid 0:cb44e2e9ec4c 1561
whismanoid 0:cb44e2e9ec4c 1562
whismanoid 0:cb44e2e9ec4c 1563
whismanoid 0:cb44e2e9ec4c 1564
whismanoid 0:cb44e2e9ec4c 1565 //--------------------------------------------------
whismanoid 12:2dfc1f2009e0 1566 // Option to use LEDs to show status
whismanoid 12:2dfc1f2009e0 1567 #ifndef USE_LEDS
whismanoid 12:2dfc1f2009e0 1568 #define USE_LEDS 1
whismanoid 12:2dfc1f2009e0 1569 #endif
whismanoid 12:2dfc1f2009e0 1570 #if USE_LEDS
whismanoid 12:2dfc1f2009e0 1571 #if defined(TARGET_MAX32630)
whismanoid 12:2dfc1f2009e0 1572 # define LED_ON 0
whismanoid 12:2dfc1f2009e0 1573 # define LED_OFF 1
whismanoid 12:2dfc1f2009e0 1574 //--------------------------------------------------
whismanoid 12:2dfc1f2009e0 1575 #elif defined(TARGET_MAX32625MBED)
whismanoid 12:2dfc1f2009e0 1576 # define LED_ON 0
whismanoid 12:2dfc1f2009e0 1577 # define LED_OFF 1
whismanoid 12:2dfc1f2009e0 1578 #elif defined(TARGET_MAX32625PICO)
whismanoid 12:2dfc1f2009e0 1579 # define LED_ON 0
whismanoid 12:2dfc1f2009e0 1580 # define LED_OFF 1
whismanoid 12:2dfc1f2009e0 1581 //--------------------------------------------------
whismanoid 12:2dfc1f2009e0 1582 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 12:2dfc1f2009e0 1583 #elif defined(TARGET_LPC1768)
whismanoid 12:2dfc1f2009e0 1584 # define LED_ON 1
whismanoid 12:2dfc1f2009e0 1585 # define LED_OFF 0
whismanoid 12:2dfc1f2009e0 1586 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 12:2dfc1f2009e0 1587 // USE_LEDS with some platform other than MAX32630, MAX32625MBED, LPC1768
whismanoid 12:2dfc1f2009e0 1588 // bugfix for MAX32600MBED LED blink pattern: check if LED_ON/LED_OFF already defined
whismanoid 12:2dfc1f2009e0 1589 # ifndef LED_ON
whismanoid 12:2dfc1f2009e0 1590 # define LED_ON 0
whismanoid 12:2dfc1f2009e0 1591 # endif
whismanoid 12:2dfc1f2009e0 1592 # ifndef LED_OFF
whismanoid 12:2dfc1f2009e0 1593 # define LED_OFF 1
whismanoid 12:2dfc1f2009e0 1594 # endif
whismanoid 12:2dfc1f2009e0 1595 //# define LED_ON 1
whismanoid 12:2dfc1f2009e0 1596 //# define LED_OFF 0
whismanoid 12:2dfc1f2009e0 1597 #endif // target definition
whismanoid 12:2dfc1f2009e0 1598 DigitalOut led1(LED1, LED_OFF); // MAX32630FTHR: LED1 = LED_RED
whismanoid 12:2dfc1f2009e0 1599 DigitalOut led2(LED2, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN
whismanoid 12:2dfc1f2009e0 1600 DigitalOut led3(LED3, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE
whismanoid 12:2dfc1f2009e0 1601 DigitalOut led4(LED4, LED_OFF);
whismanoid 12:2dfc1f2009e0 1602 #else // USE_LEDS=0
whismanoid 12:2dfc1f2009e0 1603 // issue #41 support Nucleo_F446RE
whismanoid 12:2dfc1f2009e0 1604 // there are no LED indicators on the board, LED1 interferes with SPI;
whismanoid 12:2dfc1f2009e0 1605 // but we still need placeholders led1 led2 led3 led4.
whismanoid 12:2dfc1f2009e0 1606 // Declare DigitalOut led1 led2 led3 led4 targeting safe pins.
whismanoid 12:2dfc1f2009e0 1607 // PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false
whismanoid 12:2dfc1f2009e0 1608 # define LED_ON 0
whismanoid 12:2dfc1f2009e0 1609 # define LED_OFF 1
whismanoid 12:2dfc1f2009e0 1610 DigitalOut led1(NC, LED_OFF);
whismanoid 12:2dfc1f2009e0 1611 DigitalOut led2(NC, LED_OFF);
whismanoid 12:2dfc1f2009e0 1612 DigitalOut led3(NC, LED_OFF);
whismanoid 12:2dfc1f2009e0 1613 DigitalOut led4(NC, LED_OFF);
whismanoid 12:2dfc1f2009e0 1614 #endif // USE_LEDS
whismanoid 12:2dfc1f2009e0 1615 #define led1_RFailLED led1
whismanoid 12:2dfc1f2009e0 1616 #define led2_GPassLED led2
whismanoid 12:2dfc1f2009e0 1617 #define led3_BBusyLED led3
whismanoid 12:2dfc1f2009e0 1618
whismanoid 12:2dfc1f2009e0 1619 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 1620 // TODO support CmdLine command menus (like on Serial_Tester)
whismanoid 4:d9b05924ad4c 1621 #ifndef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 1622 #define USE_CMDLINE_MENUS 1
whismanoid 4:d9b05924ad4c 1623 //~ #undef USE_CMDLINE_MENUS
whismanoid 4:d9b05924ad4c 1624 #endif
whismanoid 4:d9b05924ad4c 1625 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 1626 #include "CmdLine.h"
whismanoid 4:d9b05924ad4c 1627 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 1628 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 1629 extern CmdLine cmdLine; // declared later
whismanoid 4:d9b05924ad4c 1630 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 1631
whismanoid 4:d9b05924ad4c 1632 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 1633 // Datalog trigger types
whismanoid 4:d9b05924ad4c 1634 #ifndef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 1635 #define USE_DATALOGGER_TRIGGER 1
whismanoid 4:d9b05924ad4c 1636 //~ #undef USE_DATALOGGER_TRIGGER
whismanoid 4:d9b05924ad4c 1637 #endif
whismanoid 4:d9b05924ad4c 1638 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 1639 typedef enum Datalogger_Trigger_enum_t {
whismanoid 4:d9b05924ad4c 1640 trigger_Halt = 0, //!< halt
whismanoid 4:d9b05924ad4c 1641 trigger_FreeRun = 1, //!< free run as fast as possible
whismanoid 4:d9b05924ad4c 1642 trigger_Timer = 2, //!< timer (configure interval)
whismanoid 4:d9b05924ad4c 1643 trigger_PlatformDigitalInput, //!< platform digital input (configure digital input pin reference)
whismanoid 4:d9b05924ad4c 1644 trigger_SPIDeviceRegRead, //!< SPI device register read (configure regaddr, mask value, match value)
whismanoid 4:d9b05924ad4c 1645 } Datalogger_Trigger_enum_t;
whismanoid 4:d9b05924ad4c 1646 Datalogger_Trigger_enum_t Datalogger_Trigger = trigger_FreeRun;
whismanoid 4:d9b05924ad4c 1647 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 1648
whismanoid 4:d9b05924ad4c 1649 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 1650 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 1651 uint8_t Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 1652 uint8_t need_reinit = true;
whismanoid 8:dffee7509bfb 1653 void Datalogger_PrintHeader(CmdLine& cmdLine);
whismanoid 5:aaf8b5f5fda1 1654 void Datalogger_AcquireRow();
whismanoid 8:dffee7509bfb 1655 void Datalogger_PrintRow(CmdLine& cmdLine);
whismanoid 4:d9b05924ad4c 1656
whismanoid 4:d9b05924ad4c 1657 //--------------------------------------------------
whismanoid 0:cb44e2e9ec4c 1658 // Option to validate SPI link by reading PART_ID register
whismanoid 0:cb44e2e9ec4c 1659 #ifndef VERIFY_PART_ID_IN_LOOP
whismanoid 3:9055e17e181a 1660 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 1661 #define VERIFY_PART_ID_IN_LOOP 1
whismanoid 3:9055e17e181a 1662 #else
whismanoid 0:cb44e2e9ec4c 1663 #define VERIFY_PART_ID_IN_LOOP 0
whismanoid 3:9055e17e181a 1664 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 1665 #endif
whismanoid 0:cb44e2e9ec4c 1666
whismanoid 3:9055e17e181a 1667 //--------------------------------------------------
whismanoid 3:9055e17e181a 1668 #define NUM_DUT_ANALOG_IN_CHANNELS 10
whismanoid 3:9055e17e181a 1669
whismanoid 3:9055e17e181a 1670 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 1671 // MAX11410 individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 3:9055e17e181a 1672 typedef enum SPI_AIN_Enable_t {
whismanoid 10:04022a61b527 1673 SPI_AIN_Disable = 0,
whismanoid 10:04022a61b527 1674 SPI_AIN_Enable_LSB = 1,
whismanoid 10:04022a61b527 1675 SPI_AIN_Enable_Volt = 2,
whismanoid 3:9055e17e181a 1676 } SPI_AIN_Enable_t;
whismanoid 3:9055e17e181a 1677 uint8_t SPI_AIN_Enable_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 1678 SPI_AIN_Enable_LSB, // AIN0 1=LSB
whismanoid 10:04022a61b527 1679 SPI_AIN_Enable_LSB, // AIN1 1=LSB
whismanoid 10:04022a61b527 1680 SPI_AIN_Enable_LSB, // AIN2 1=LSB
whismanoid 10:04022a61b527 1681 SPI_AIN_Enable_LSB, // AIN3 1=LSB
whismanoid 10:04022a61b527 1682 SPI_AIN_Enable_LSB, // AIN4 1=LSB
whismanoid 10:04022a61b527 1683 SPI_AIN_Enable_LSB, // AIN5 1=LSB
whismanoid 10:04022a61b527 1684 SPI_AIN_Enable_LSB, // AIN6 1=LSB
whismanoid 10:04022a61b527 1685 SPI_AIN_Enable_LSB, // AIN7 1=LSB
whismanoid 10:04022a61b527 1686 SPI_AIN_Enable_LSB, // AIN8 1=LSB
whismanoid 10:04022a61b527 1687 SPI_AIN_Enable_LSB, // AIN9 1=LSB
whismanoid 3:9055e17e181a 1688 };
whismanoid 3:9055e17e181a 1689 //
whismanoid 10:04022a61b527 1690 double SPI_AIN_Voltage[NUM_DUT_ANALOG_IN_CHANNELS];
whismanoid 13:184a08909405 1691 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 1692 #ifndef HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 1693 #define HAS_SPI_AIN_customChannelHeader 0
whismanoid 13:184a08909405 1694 #endif
whismanoid 13:184a08909405 1695 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 1696 const char* const SPI_AIN_customChannelHeader_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 1697 "", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 1698 "", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 1699 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 1700 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 1701 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 1702 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 1703 };
whismanoid 13:184a08909405 1704 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 3:9055e17e181a 1705 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 1706 // ---------- Measure_Voltage_custom_props in Measure_Voltage @pre and in class properties ----------
whismanoid 3:9055e17e181a 1707 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 1708 // MAX11410 specific per-channel config register v_filter
whismanoid 3:9055e17e181a 1709 uint8_t SPI_AIN_Cfg_v_filter_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 1710 0x34, // AIN0 @ v_filter=0x34
whismanoid 3:9055e17e181a 1711 0x34, // AIN1 @ v_filter=0x34
whismanoid 3:9055e17e181a 1712 0x34, // AIN2 @ v_filter=0x34
whismanoid 3:9055e17e181a 1713 0x34, // AIN3 @ v_filter=0x34
whismanoid 3:9055e17e181a 1714 0x34, // AIN4 @ v_filter=0x34
whismanoid 3:9055e17e181a 1715 0x34, // AIN5 @ v_filter=0x34
whismanoid 3:9055e17e181a 1716 0x34, // AIN6 @ v_filter=0x34
whismanoid 3:9055e17e181a 1717 0x34, // AIN7 @ v_filter=0x34
whismanoid 3:9055e17e181a 1718 0x34, // AIN8 @ v_filter=0x34
whismanoid 3:9055e17e181a 1719 0x34, // AIN9 @ v_filter=0x34
whismanoid 3:9055e17e181a 1720 };
whismanoid 3:9055e17e181a 1721 //
whismanoid 4:d9b05924ad4c 1722 // MAX11410 specific per-channel config register v_ctrl
whismanoid 3:9055e17e181a 1723 uint8_t SPI_AIN_Cfg_v_ctrl_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 1724 0x42, // AIN0 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 1725 0x42, // AIN1 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 1726 0x42, // AIN2 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 1727 0x42, // AIN3 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 1728 0x42, // AIN4 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 1729 0x42, // AIN5 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 1730 0x42, // AIN6 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 1731 0x42, // AIN7 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 1732 0x42, // AIN8 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 1733 0x42, // AIN9 @ v_ctrl=0x42
whismanoid 3:9055e17e181a 1734 };
whismanoid 3:9055e17e181a 1735 //
whismanoid 4:d9b05924ad4c 1736 // MAX11410 specific per-channel config register v_pga
whismanoid 3:9055e17e181a 1737 uint8_t SPI_AIN_Cfg_v_pga_ch[NUM_DUT_ANALOG_IN_CHANNELS] = {
whismanoid 3:9055e17e181a 1738 0x00, // AIN0 @ v_pga=0x00
whismanoid 3:9055e17e181a 1739 0x00, // AIN1 @ v_pga=0x00
whismanoid 3:9055e17e181a 1740 0x00, // AIN2 @ v_pga=0x00
whismanoid 3:9055e17e181a 1741 0x00, // AIN3 @ v_pga=0x00
whismanoid 3:9055e17e181a 1742 0x00, // AIN4 @ v_pga=0x00
whismanoid 3:9055e17e181a 1743 0x00, // AIN5 @ v_pga=0x00
whismanoid 3:9055e17e181a 1744 0x00, // AIN6 @ v_pga=0x00
whismanoid 3:9055e17e181a 1745 0x00, // AIN7 @ v_pga=0x00
whismanoid 3:9055e17e181a 1746 0x00, // AIN8 @ v_pga=0x00
whismanoid 3:9055e17e181a 1747 0x00, // AIN9 @ v_pga=0x00
whismanoid 3:9055e17e181a 1748 };
whismanoid 3:9055e17e181a 1749 //
whismanoid 3:9055e17e181a 1750 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 1751 // ---------- Measure_Voltage_custom_props ----------
whismanoid 0:cb44e2e9ec4c 1752 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 1753 // filter register configuration in Measure_Voltage and Read_All_Voltages CONV_TYPE_01_Continuous
whismanoid 0:cb44e2e9ec4c 1754 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 1755 //~ const uint8_t custom_v_filter = 0x00; // @ v_filter=0x00 -- LINEF_00_50Hz_60Hz_FIR RATE_0000 | 1.1SPS
whismanoid 0:cb44e2e9ec4c 1756 //~ const uint8_t custom_v_filter = 0x01; // @ v_filter=0x01 -- LINEF_00_50Hz_60Hz_FIR RATE_0001 | 2.1SPS
whismanoid 0:cb44e2e9ec4c 1757 //~ const uint8_t custom_v_filter = 0x02; // @ v_filter=0x02 -- LINEF_00_50Hz_60Hz_FIR RATE_0010 | 4.2SPS
whismanoid 0:cb44e2e9ec4c 1758 //~ const uint8_t custom_v_filter = 0x03; // @ v_filter=0x03 -- LINEF_00_50Hz_60Hz_FIR RATE_0011 | 8.4SPS
whismanoid 0:cb44e2e9ec4c 1759 //~ const uint8_t custom_v_filter = 0x04; // @ v_filter=0x04 -- LINEF_00_50Hz_60Hz_FIR RATE_0100 | 16.8SPS
whismanoid 0:cb44e2e9ec4c 1760 //~ const uint8_t custom_v_filter = 0x10; // @ v_filter=0x10 -- LINEF_01_50Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 1761 //~ const uint8_t custom_v_filter = 0x11; // @ v_filter=0x11 -- LINEF_01_50Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 1762 //~ const uint8_t custom_v_filter = 0x12; // @ v_filter=0x12 -- LINEF_01_50Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 1763 //~ const uint8_t custom_v_filter = 0x13; // @ v_filter=0x13 -- LINEF_01_50Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 1764 //~ const uint8_t custom_v_filter = 0x14; // @ v_filter=0x14 -- LINEF_01_50Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 1765 //~ const uint8_t custom_v_filter = 0x15; // @ v_filter=0x15 -- LINEF_01_50Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 1766 //~ const uint8_t custom_v_filter = 0x20; // @ v_filter=0x20 -- LINEF_10_60Hz_FIR RATE_0000 | 1.3SPS
whismanoid 0:cb44e2e9ec4c 1767 //~ const uint8_t custom_v_filter = 0x21; // @ v_filter=0x21 -- LINEF_10_60Hz_FIR RATE_0001 | 2.7SPS
whismanoid 0:cb44e2e9ec4c 1768 //~ const uint8_t custom_v_filter = 0x22; // @ v_filter=0x22 -- LINEF_10_60Hz_FIR RATE_0010 | 5.3SPS
whismanoid 0:cb44e2e9ec4c 1769 //~ const uint8_t custom_v_filter = 0x23; // @ v_filter=0x23 -- LINEF_10_60Hz_FIR RATE_0011 | 10.7SPS
whismanoid 0:cb44e2e9ec4c 1770 //~ const uint8_t custom_v_filter = 0x24; // @ v_filter=0x24 -- LINEF_10_60Hz_FIR RATE_0100 | 21.3SPS
whismanoid 0:cb44e2e9ec4c 1771 //~ const uint8_t custom_v_filter = 0x25; // @ v_filter=0x25 -- LINEF_10_60Hz_FIR RATE_0101 | 40.0SPS
whismanoid 0:cb44e2e9ec4c 1772 //~ const uint8_t custom_v_filter = 0x30; // @ v_filter=0x30 -- LINEF_11_SINC4 RATE_0000 | 4SPS
whismanoid 0:cb44e2e9ec4c 1773 //~ const uint8_t custom_v_filter = 0x31; // @ v_filter=0x31 -- LINEF_11_SINC4 RATE_0001 | 10SPS
whismanoid 0:cb44e2e9ec4c 1774 //~ const uint8_t custom_v_filter = 0x32; // @ v_filter=0x32 -- LINEF_11_SINC4 RATE_0010 | 20SPS
whismanoid 0:cb44e2e9ec4c 1775 //~ const uint8_t custom_v_filter = 0x33; // @ v_filter=0x33 -- LINEF_11_SINC4 RATE_0011 | 40SPS
whismanoid 0:cb44e2e9ec4c 1776 //~ const uint8_t custom_v_filter = 0x34; // @ v_filter=0x34 --*LINEF_11_SINC4 RATE_0100 | 60SPS
whismanoid 0:cb44e2e9ec4c 1777 //~ const uint8_t custom_v_filter = 0x35; // @ v_filter=0x35 -- LINEF_11_SINC4 RATE_0101 | 120SPS
whismanoid 0:cb44e2e9ec4c 1778 //~ const uint8_t custom_v_filter = 0x36; // @ v_filter=0x36 -- LINEF_11_SINC4 RATE_0110 | 240SPS
whismanoid 0:cb44e2e9ec4c 1779 //~ const uint8_t custom_v_filter = 0x37; // @ v_filter=0x37 -- LINEF_11_SINC4 RATE_0111 | 480SPS
whismanoid 0:cb44e2e9ec4c 1780 //~ const uint8_t custom_v_filter = 0x38; // @ v_filter=0x38 -- LINEF_11_SINC4 RATE_1000 | 960SPS
whismanoid 0:cb44e2e9ec4c 1781 //~ const uint8_t custom_v_filter = 0x39; // @ v_filter=0x39 -- LINEF_11_SINC4 RATE_1001 | 1920SPS
whismanoid 0:cb44e2e9ec4c 1782 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 1783 //
whismanoid 0:cb44e2e9ec4c 1784 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 1785 // pga register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 0:cb44e2e9ec4c 1786 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 1787 //~ const uint8_t custom_v_pga = 0x00; // @ v_pga=0x00 -- 0x00 SIG_PATH_00_BUFFERED
whismanoid 0:cb44e2e9ec4c 1788 //~ const uint8_t custom_v_pga = 0x10; // @ v_pga=0x10 -- 0x10 SIG_PATH_01_BYPASS
whismanoid 0:cb44e2e9ec4c 1789 //~ const uint8_t custom_v_pga = 0x20; // @ v_pga=0x20 -- 0x20 SIG_PATH_10_PGA GAIN_000_1
whismanoid 0:cb44e2e9ec4c 1790 //~ const uint8_t custom_v_pga = 0x21; // @ v_pga=0x21 --*0x21 SIG_PATH_10_PGA GAIN_001_2
whismanoid 0:cb44e2e9ec4c 1791 //~ const uint8_t custom_v_pga = 0x22; // @ v_pga=0x22 -- 0x22 SIG_PATH_10_PGA GAIN_010_4
whismanoid 0:cb44e2e9ec4c 1792 //~ const uint8_t custom_v_pga = 0x23; // @ v_pga=0x23 -- 0x23 SIG_PATH_10_PGA GAIN_011_8
whismanoid 0:cb44e2e9ec4c 1793 //~ const uint8_t custom_v_pga = 0x24; // @ v_pga=0x24 -- 0x24 SIG_PATH_10_PGA GAIN_100_16
whismanoid 0:cb44e2e9ec4c 1794 //~ const uint8_t custom_v_pga = 0x25; // @ v_pga=0x25 -- 0x25 SIG_PATH_10_PGA GAIN_101_32
whismanoid 0:cb44e2e9ec4c 1795 //~ const uint8_t custom_v_pga = 0x26; // @ v_pga=0x26 -- 0x26 SIG_PATH_10_PGA GAIN_110_64
whismanoid 0:cb44e2e9ec4c 1796 //~ const uint8_t custom_v_pga = 0x27; // @ v_pga=0x27 -- 0x27 SIG_PATH_10_PGA GAIN_111_128
whismanoid 0:cb44e2e9ec4c 1797 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 1798 //
whismanoid 0:cb44e2e9ec4c 1799 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 0:cb44e2e9ec4c 1800 // ctrl register configuration in Measure_Voltage and Read_All_Voltages
whismanoid 3:9055e17e181a 1801 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 1802 //~ const uint8_t custom_v_ctrl = 0x40; // @ v_ctrl=0x40 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1
whismanoid 0:cb44e2e9ec4c 1803 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 1804 //~ const uint8_t custom_v_ctrl = 0x58; // @ v_ctrl=0x58 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 1805 //
whismanoid 0:cb44e2e9ec4c 1806 //~ const uint8_t custom_v_ctrl = 0x41; // @ v_ctrl=0x41 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N
whismanoid 0:cb44e2e9ec4c 1807 //~ const uint8_t custom_v_ctrl = 0x45; // @ v_ctrl=0x45 -- 0x40 unipolar, 0x05 REF_SEL_101_REF1P_AGND
whismanoid 0:cb44e2e9ec4c 1808 //~ const uint8_t custom_v_ctrl = 0x59; // @ v_ctrl=0x59 -- 0x40 unipolar, 0x01 REF_SEL_001_REF1P_REF1N, 0x18 refbuf
whismanoid 0:cb44e2e9ec4c 1809 //
whismanoid 0:cb44e2e9ec4c 1810 //~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 1811 //~ const uint8_t custom_v_ctrl = 0x46; // @ v_ctrl=0x46 -- 0x40 unipolar, 0x06 REF_SEL_110_REF2P_AGND
whismanoid 0:cb44e2e9ec4c 1812 //~ const uint8_t custom_v_ctrl = 0x22; // @ v_ctrl=0x22 -- 0x20 bipolar offset binary, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 1813 //~ const uint8_t custom_v_ctrl = 0x02; // @ v_ctrl=0x02 -- 0x00 bipolar 2's complement, 0x02 REF_SEL_010_REF2P_REF2N
whismanoid 0:cb44e2e9ec4c 1814 //
whismanoid 0:cb44e2e9ec4c 1815 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND
whismanoid 0:cb44e2e9ec4c 1816 //~ const uint8_t custom_v_ctrl = 0x47; // @ v_ctrl=0x47 -- 0x40 unipolar, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 1817 //~ const uint8_t custom_v_ctrl = 0x27; // @ v_ctrl=0x27 -- 0x20 bipolar offset binary, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 1818 //~ const uint8_t custom_v_ctrl = 0x07; // @ v_ctrl=0x07 -- 0x00 bipolar 2's complement, 0x07 REF_SEL_111_AVDD_AGND
whismanoid 0:cb44e2e9ec4c 1819 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 0:cb44e2e9ec4c 1820
whismanoid 3:9055e17e181a 1821 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 1822 // example code declare SPI interface (GPIO controlled CS)
whismanoid 0:cb44e2e9ec4c 1823 #if defined(TARGET_MAX32625MBED)
whismanoid 0:cb44e2e9ec4c 1824 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 1825 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 1826 #elif defined(TARGET_MAX32625PICO)
whismanoid 0:cb44e2e9ec4c 1827 #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 0:cb44e2e9ec4c 1828 SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625PICO: pin P0_5 P0_6 P0_4
whismanoid 0:cb44e2e9ec4c 1829 DigitalOut spi_cs(SPI0_SS); // TARGET_MAX32625PICO: pin P0_7
whismanoid 0:cb44e2e9ec4c 1830 #elif defined(TARGET_MAX32600MBED)
whismanoid 0:cb44e2e9ec4c 1831 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 0:cb44e2e9ec4c 1832 DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 1833 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 0:cb44e2e9ec4c 1834 // TODO1: avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 0:cb44e2e9ec4c 1835 // void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
whismanoid 0:cb44e2e9ec4c 1836 //
whismanoid 0:cb44e2e9ec4c 1837 // TODO1: NUCLEO_F446RE SPI not working; CS and MOSI data looks OK but no SCLK clock pulses.
whismanoid 0:cb44e2e9ec4c 1838 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 1839 DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 1840 //
whismanoid 0:cb44e2e9ec4c 1841 #else
whismanoid 3:9055e17e181a 1842 SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 3:9055e17e181a 1843 DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
whismanoid 0:cb44e2e9ec4c 1844 #endif
whismanoid 0:cb44e2e9ec4c 1845
whismanoid 0:cb44e2e9ec4c 1846 // example code declare GPIO interface pins
whismanoid 0:cb44e2e9ec4c 1847 // example code declare device instance
whismanoid 3:9055e17e181a 1848 MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC);
whismanoid 3:9055e17e181a 1849 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 1850
whismanoid 1:747f1602abfc 1851 //--------------------------------------------------
whismanoid 3:9055e17e181a 1852 // Option to Datalog Arduino platform analog inputs
whismanoid 3:9055e17e181a 1853 #ifndef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 1854 #define LOG_PLATFORM_AIN 6
whismanoid 3:9055e17e181a 1855 //~ #undef LOG_PLATFORM_AIN
whismanoid 3:9055e17e181a 1856 #endif
whismanoid 3:9055e17e181a 1857 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 1:747f1602abfc 1858 //#ifndef NUM_PLATFORM_ANALOG_IN_CHANNELS
whismanoid 1:747f1602abfc 1859 //#define NUM_PLATFORM_ANALOG_IN_CHANNELS 6
whismanoid 1:747f1602abfc 1860 //#endif
whismanoid 1:747f1602abfc 1861 const int NUM_PLATFORM_ANALOG_IN_CHANNELS = 6;
whismanoid 1:747f1602abfc 1862 const double adc_full_scale_voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 10:04022a61b527 1863 analogInPin_fullScaleVoltage[0], // 1.2,
whismanoid 10:04022a61b527 1864 analogInPin_fullScaleVoltage[1], // 1.2,
whismanoid 10:04022a61b527 1865 analogInPin_fullScaleVoltage[2], // 1.2,
whismanoid 10:04022a61b527 1866 analogInPin_fullScaleVoltage[3], // 1.2,
whismanoid 10:04022a61b527 1867 analogInPin_fullScaleVoltage[4], // 6.0
whismanoid 10:04022a61b527 1868 analogInPin_fullScaleVoltage[5], // 6.0
whismanoid 0:cb44e2e9ec4c 1869 };
whismanoid 9:45f98573eb6d 1870 // Platform ADC individual channels 1=LSB, 2=Volt, 0=Disabled
whismanoid 9:45f98573eb6d 1871 typedef enum Platform_AIN_Enable_t {
whismanoid 9:45f98573eb6d 1872 Platform_AIN_Disable = 0,
whismanoid 9:45f98573eb6d 1873 Platform_AIN_Enable_LSB = 1,
whismanoid 9:45f98573eb6d 1874 Platform_AIN_Enable_Volt = 2,
whismanoid 9:45f98573eb6d 1875 } Platform_AIN_Enable_t;
whismanoid 13:184a08909405 1876 uint8_t Platform_Enable_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 9:45f98573eb6d 1877 Platform_AIN_Enable_Volt, // AIN0 2=Volt
whismanoid 9:45f98573eb6d 1878 Platform_AIN_Enable_Volt, // AIN1 2=Volt
whismanoid 9:45f98573eb6d 1879 Platform_AIN_Enable_Volt, // AIN2 2=Volt
whismanoid 9:45f98573eb6d 1880 Platform_AIN_Enable_Volt, // AIN3 2=Volt
whismanoid 9:45f98573eb6d 1881 Platform_AIN_Enable_Volt, // AIN4 2=Volt
whismanoid 9:45f98573eb6d 1882 Platform_AIN_Enable_Volt, // AIN5 2=Volt
whismanoid 9:45f98573eb6d 1883 };
whismanoid 13:184a08909405 1884 #ifndef HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 1885 #define HAS_Platform_AIN_customChannelHeader 1
whismanoid 13:184a08909405 1886 #endif
whismanoid 13:184a08909405 1887 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 1888 const char* const Platform_AIN_customChannelHeader_ch[NUM_PLATFORM_ANALOG_IN_CHANNELS] = {
whismanoid 13:184a08909405 1889 "=AIN4", // MAX40108: AIN0_1V0_current_ 0.591202*100/3.34 = 17.70065868263473mA
whismanoid 13:184a08909405 1890 "=AIN5", // MAX40108: AIN1_1V0_voltage
whismanoid 13:184a08909405 1891 "WE", // MAX40108: AIN2_WE
whismanoid 13:184a08909405 1892 "CE", // MAX40108: AIN3_CE
whismanoid 13:184a08909405 1893 "*100/3.34=mA", // MAX40108: AIN4_*100/3.34=mA
whismanoid 13:184a08909405 1894 "CELL_VOLTAGE", // MAX40108: AIN5_CELL_VOLTAGE
whismanoid 13:184a08909405 1895 };
whismanoid 13:184a08909405 1896 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 1:747f1602abfc 1897 //--------------------------------------------------
whismanoid 1:747f1602abfc 1898 // Option to log platform analog inputs as raw LSB code
whismanoid 1:747f1602abfc 1899 #ifndef LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 1900 #define LOG_PLATFORM_ANALOG_IN_LSB 0
whismanoid 1:747f1602abfc 1901 #endif
whismanoid 1:747f1602abfc 1902 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 1:747f1602abfc 1903 int Platform_LSB[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 1904 #endif
whismanoid 1:747f1602abfc 1905
whismanoid 1:747f1602abfc 1906 //--------------------------------------------------
whismanoid 1:747f1602abfc 1907 // Option to use platform analog inputs as Voltage
whismanoid 1:747f1602abfc 1908 #ifndef LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 1909 #define LOG_PLATFORM_ANALOG_IN_VOLTS 1
whismanoid 1:747f1602abfc 1910 #endif
whismanoid 1:747f1602abfc 1911 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 1:747f1602abfc 1912 double Platform_Voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS];
whismanoid 1:747f1602abfc 1913 #endif
whismanoid 3:9055e17e181a 1914 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 0:cb44e2e9ec4c 1915
whismanoid 10:04022a61b527 1916 //--------------------------------------------------
whismanoid 10:04022a61b527 1917 // Option to use Command forwarding to Auxiliary serial port
whismanoid 10:04022a61b527 1918 // Command forwarding to Auxiliary serial port TX/RX
whismanoid 10:04022a61b527 1919 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial
whismanoid 10:04022a61b527 1920 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial
whismanoid 10:04022a61b527 1921 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 1922 #ifndef USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 1923 #define USE_AUX_SERIAL_CMD_FORWARDING 1
whismanoid 10:04022a61b527 1924 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 1925 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 1926 // Command forwarding to Auxiliary serial port TX/RX #257 -- global parameters
whismanoid 10:04022a61b527 1927 const size_t RX_STRING_BUF_SIZE = 1000;
whismanoid 10:04022a61b527 1928 int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 1929 // transmit command string by AUX TX
whismanoid 10:04022a61b527 1930 #if 0
whismanoid 10:04022a61b527 1931 int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 1932 int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 1933 int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 1934 #endif
whismanoid 10:04022a61b527 1935 // capture received string from AUX RX
whismanoid 10:04022a61b527 1936 Timer g_auxSerialCom_Timer;
whismanoid 10:04022a61b527 1937 int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 1938 int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 1939 int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 1940 int g_auxSerialCom_rx_idle_ms = 500; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 1941 int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 1942 const int aux_serial_cmd_forwarding_rx_eot_not_used = 'x';
whismanoid 10:04022a61b527 1943 int g_auxSerialCom_rx_eot = aux_serial_cmd_forwarding_rx_eot_not_used; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 1944 //~ int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text string?
whismanoid 10:04022a61b527 1945 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 1946 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 1947 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257
whismanoid 10:04022a61b527 1948 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 1949 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 1950 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 1951 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 1952 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 1953 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 1954 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 1955 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 1956 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 1957 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 1958 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 1959 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 1960 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 1961 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 1962 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 1963
whismanoid 8:dffee7509bfb 1964 // CODE GENERATOR: example code for ADC: serial port declaration
whismanoid 8:dffee7509bfb 1965 //--------------------------------------------------
whismanoid 8:dffee7509bfb 1966 // Declare the Serial driver
whismanoid 8:dffee7509bfb 1967 // default baud rate settings are 9600 8N1
whismanoid 8:dffee7509bfb 1968 // install device driver from http://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe
whismanoid 8:dffee7509bfb 1969 // see docs https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/getting_started/what_need/
whismanoid 8:dffee7509bfb 1970 //--------------------------------------------------
whismanoid 8:dffee7509bfb 1971 #if defined(TARGET_MAX32630)
whismanoid 8:dffee7509bfb 1972 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 1973 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 1974 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 1975 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 1976 //
whismanoid 8:dffee7509bfb 1977 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 1978 Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32630FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 1979 //Serial J3AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32630FTHR: P5_4,P5_3 (J3.7,J3.8)
whismanoid 8:dffee7509bfb 1980 //Serial BTAUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32630FTHR: P0_1,P0_0 (Bluetooth PAN1326B)
whismanoid 8:dffee7509bfb 1981 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 1982 //
whismanoid 8:dffee7509bfb 1983 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 1984 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 1985 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32630FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 1986 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 1987 //
whismanoid 8:dffee7509bfb 1988 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 1989 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 1990 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 1991 USBSerial serial;
whismanoid 8:dffee7509bfb 1992 //--------------------------------------------------
whismanoid 8:dffee7509bfb 1993 #elif defined(TARGET_MAX32625MBED)
whismanoid 8:dffee7509bfb 1994 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625MBED: P0_1,P0_0 (Arduino D1,D0)
whismanoid 8:dffee7509bfb 1995 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 1996 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625MBED: P3_1,P3_0 (J15-LEDgreen,LEDred)
whismanoid 8:dffee7509bfb 1997 //
whismanoid 8:dffee7509bfb 1998 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 1999 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2000 Serial DAPLINKserial(P2_1,P2_0); // tx,rx UART1 MAX32625MBED: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2001 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2002 //
whismanoid 8:dffee7509bfb 2003 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2004 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2005 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2006 USBSerial serial;
whismanoid 8:dffee7509bfb 2007 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2008 #elif defined(TARGET_MAX32625PICO)
whismanoid 8:dffee7509bfb 2009 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 2010 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32625PICO: P2_1,P2_0 (underside?)
whismanoid 8:dffee7509bfb 2011 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2012 //
whismanoid 14:d4092094dbfe 2013 #if MAX40108_DEMO
whismanoid 14:d4092094dbfe 2014 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial is used as main serial port in MAX40108 Demo board
whismanoid 14:d4092094dbfe 2015 Serial serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 14:d4092094dbfe 2016 // #define HAS_AUX_SERIAL 1
whismanoid 14:d4092094dbfe 2017 //
whismanoid 14:d4092094dbfe 2018 // Hardware serial port over DAPLink
whismanoid 14:d4092094dbfe 2019 Serial DAPLINKserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 14:d4092094dbfe 2020 #define HAS_DAPLINK_SERIAL 1
whismanoid 14:d4092094dbfe 2021 //
whismanoid 14:d4092094dbfe 2022 // Virtual serial port over USB
whismanoid 14:d4092094dbfe 2023 // #include "USBSerial.h"
whismanoid 14:d4092094dbfe 2024 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 14:d4092094dbfe 2025 //USBSerial serial;
whismanoid 14:d4092094dbfe 2026 #else // MAX40108_DEMO
whismanoid 8:dffee7509bfb 2027 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2028 Serial AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32625PICO: P0_1,P0_0 (pin 19/20)
whismanoid 8:dffee7509bfb 2029 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 2030 //
whismanoid 8:dffee7509bfb 2031 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2032 Serial DAPLINKserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32625PICO: P3_1,P3_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2033 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2034 //
whismanoid 8:dffee7509bfb 2035 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2036 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2037 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2038 USBSerial serial;
whismanoid 14:d4092094dbfe 2039 #endif // MAX40108_DEMO
whismanoid 8:dffee7509bfb 2040 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2041 #elif defined(TARGET_MAX32620FTHR)
whismanoid 8:dffee7509bfb 2042 #warning "TARGET_MAX32620FTHR not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 2043 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 2044 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART1 MAX32620FTHR: P2_1,P2_0 (DAPLINK)
whismanoid 8:dffee7509bfb 2045 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2046 //Serial UART3serial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 2047 //
whismanoid 8:dffee7509bfb 2048 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2049 Serial serial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2050 //Serial AUXserial(UART2_TX,UART2_RX); // tx,rx UART2 MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14)
whismanoid 8:dffee7509bfb 2051 Serial AUXserial(UART3_TX,UART3_RX); // tx,rx UART3 MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8)
whismanoid 8:dffee7509bfb 2052 //Serial PMOD0AUXserial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32620FTHR: P0_1,P0_0 (PMOD0.2,PMOD0.3)
whismanoid 8:dffee7509bfb 2053 #define HAS_AUX_SERIAL 1
whismanoid 8:dffee7509bfb 2054 //
whismanoid 8:dffee7509bfb 2055 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2056 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2057 Serial DAPLINKserial(USBTX, USBRX); // tx,rx MAX32620FTHR: P2_1,P2_0
whismanoid 8:dffee7509bfb 2058 //Serial DAPLINKserial(STDIO_UART_TX, STDIO_UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 2059 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2060 //
whismanoid 8:dffee7509bfb 2061 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2062 // #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2063 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2064 //USBSerial serial; // MAX32620FTHR: USBSerial crash??
whismanoid 8:dffee7509bfb 2065 #warning "TARGET_MAX32620FTHR not previously tested; USBSerial crash?"
whismanoid 8:dffee7509bfb 2066 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2067 #elif defined(TARGET_MAX32600)
whismanoid 8:dffee7509bfb 2068 //Serial UART0serial(UART0_TX,UART0_RX); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 2069 //Serial UART1serial(UART1_TX,UART1_RX); // tx,rx UART2 MAX32625MBED: P1_3,P1_2 (Arduino D3,D2)
whismanoid 8:dffee7509bfb 2070 //Serial UART2serial(UART2_TX,UART2_RX); // tx,rx UART1 MAX32625MBED: P7_3,P7_2 ( ?? )
whismanoid 8:dffee7509bfb 2071 //
whismanoid 8:dffee7509bfb 2072 // Hardware serial port over DAPLink
whismanoid 8:dffee7509bfb 2073 // The default baud rate for the DapLink UART is 9600
whismanoid 8:dffee7509bfb 2074 Serial DAPLINKserial(P1_1,P1_0); // tx,rx UART0 MAX32600MBED: P1_1,P1_0 (Arduino D1,D0)(DAPLINK)
whismanoid 8:dffee7509bfb 2075 #define HAS_DAPLINK_SERIAL 1
whismanoid 8:dffee7509bfb 2076 //
whismanoid 8:dffee7509bfb 2077 // Virtual serial port over USB
whismanoid 8:dffee7509bfb 2078 #include "USBSerial.h"
whismanoid 8:dffee7509bfb 2079 // The baud rate does not affect the virtual USBSerial UART.
whismanoid 8:dffee7509bfb 2080 USBSerial serial;
whismanoid 8:dffee7509bfb 2081 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2082 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 8:dffee7509bfb 2083 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 2084 //--------------------------------------------------
whismanoid 8:dffee7509bfb 2085 #else
whismanoid 8:dffee7509bfb 2086 #if defined(SERIAL_TX)
whismanoid 8:dffee7509bfb 2087 #warning "target not previously tested; guess serial pins are SERIAL_TX, SERIAL_RX..."
whismanoid 8:dffee7509bfb 2088 Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx
whismanoid 8:dffee7509bfb 2089 #elif defined(USBTX)
whismanoid 8:dffee7509bfb 2090 #warning "target not previously tested; guess serial pins are USBTX, USBRX..."
whismanoid 8:dffee7509bfb 2091 Serial serial(USBTX, USBRX); // tx, rx
whismanoid 8:dffee7509bfb 2092 #elif defined(UART_TX)
whismanoid 8:dffee7509bfb 2093 #warning "target not previously tested; guess serial pins are UART_TX, UART_RX..."
whismanoid 8:dffee7509bfb 2094 Serial serial(UART_TX, UART_RX); // tx, rx
whismanoid 8:dffee7509bfb 2095 #else
whismanoid 8:dffee7509bfb 2096 #warning "target not previously tested; need to define serial pins..."
whismanoid 8:dffee7509bfb 2097 #endif
whismanoid 8:dffee7509bfb 2098 #endif
whismanoid 8:dffee7509bfb 2099 //
whismanoid 8:dffee7509bfb 2100 #include "CmdLine.h"
whismanoid 8:dffee7509bfb 2101
whismanoid 8:dffee7509bfb 2102 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 2103 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 8:dffee7509bfb 2104 CmdLine cmdLine_AUXserial(AUXserial, "AUXserial");
whismanoid 10:04022a61b527 2105 uint8_t Datalogger_enable_AUXserial = {
whismanoid 10:04022a61b527 2106 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2107 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 2108 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 2109 false
whismanoid 10:04022a61b527 2110 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2111 true
whismanoid 10:04022a61b527 2112 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2113 };
whismanoid 8:dffee7509bfb 2114 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 2115 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 2116 CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK");
whismanoid 8:dffee7509bfb 2117 uint8_t Datalogger_enable_DAPLINKserial = true;
whismanoid 8:dffee7509bfb 2118 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 2119 CmdLine cmdLine(serial, "serial");
whismanoid 8:dffee7509bfb 2120 uint8_t Datalogger_enable_serial = true;
whismanoid 8:dffee7509bfb 2121 // CODE GENERATOR: example code for ADC: serial port declaration (end)
whismanoid 8:dffee7509bfb 2122
whismanoid 4:d9b05924ad4c 2123 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2124 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2125 inline void print_command_prompt()
whismanoid 4:d9b05924ad4c 2126 {
whismanoid 4:d9b05924ad4c 2127 //~ Serial.println(F(">"));
whismanoid 4:d9b05924ad4c 2128 cmdLine.serial().printf("\r\n> ");
whismanoid 4:d9b05924ad4c 2129 }
whismanoid 4:d9b05924ad4c 2130 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2131
whismanoid 4:d9b05924ad4c 2132 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2133 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2134 void main_menu_status(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 2135 {
whismanoid 4:d9b05924ad4c 2136 cmdLine.serial().printf("\r\nMain menu");
whismanoid 4:d9b05924ad4c 2137 #if APPLICATION_MAX5715 // main_menu_status banner
whismanoid 4:d9b05924ad4c 2138 cmdLine.serial().printf(" MAX5715 12-bit 4-ch SPI VOUT DAC");
whismanoid 4:d9b05924ad4c 2139 #elif APPLICATION_MAX11131 // main_menu_status banner
whismanoid 4:d9b05924ad4c 2140 cmdLine.serial().printf(" MAX11131 12-bit 3MSps 16-ch ADC");
whismanoid 4:d9b05924ad4c 2141 #elif APPLICATION_MAX5171 // main_menu_status banner
whismanoid 4:d9b05924ad4c 2142 cmdLine.serial().printf(" MAX5171 14-bit Force/Sense VOUT DAC");
whismanoid 4:d9b05924ad4c 2143 #elif APPLICATION_MAX11410 // main_menu_status banner
whismanoid 4:d9b05924ad4c 2144 cmdLine.serial().printf(" MAX11410 24-bit 1.9ksps Delta-Sigma ADC");
whismanoid 4:d9b05924ad4c 2145 #elif APPLICATION_MAX12345 // main_menu_status banner
whismanoid 4:d9b05924ad4c 2146 cmdLine.serial().printf(" MAX12345");
whismanoid 4:d9b05924ad4c 2147 #else
whismanoid 4:d9b05924ad4c 2148 //cmdLine.serial().printf(" ");
whismanoid 4:d9b05924ad4c 2149 #endif
whismanoid 4:d9b05924ad4c 2150 //cmdLine.serial().printf(" %s", TARGET_NAME);
whismanoid 4:d9b05924ad4c 2151 if (cmdLine.nameStr())
whismanoid 4:d9b05924ad4c 2152 {
whismanoid 4:d9b05924ad4c 2153 cmdLine.serial().printf(" [%s]", cmdLine.nameStr());
whismanoid 4:d9b05924ad4c 2154 }
whismanoid 4:d9b05924ad4c 2155 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 4:d9b05924ad4c 2156 cmdLine.serial().printf(" [Button1=DemoConfig1]");
whismanoid 4:d9b05924ad4c 2157 #endif
whismanoid 4:d9b05924ad4c 2158 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 4:d9b05924ad4c 2159 cmdLine.serial().printf(" [Button2=DemoConfig2]");
whismanoid 4:d9b05924ad4c 2160 #endif
whismanoid 4:d9b05924ad4c 2161 #if HAS_BUTTON1_DEMO
whismanoid 4:d9b05924ad4c 2162 // print BUTTON1 status
whismanoid 4:d9b05924ad4c 2163 cmdLine.serial().printf("\r\n BUTTON1 = %d", button1.read());
whismanoid 4:d9b05924ad4c 2164 #endif
whismanoid 4:d9b05924ad4c 2165 #if HAS_BUTTON2_DEMO
whismanoid 4:d9b05924ad4c 2166 // print BUTTON1 status
whismanoid 4:d9b05924ad4c 2167 cmdLine.serial().printf("\r\n BUTTON2 = %d", button2.read());
whismanoid 4:d9b05924ad4c 2168 #endif
whismanoid 4:d9b05924ad4c 2169 cmdLine.serial().printf("\r\n ? -- help");
whismanoid 4:d9b05924ad4c 2170 }
whismanoid 4:d9b05924ad4c 2171 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2172
whismanoid 4:d9b05924ad4c 2173 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2174 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2175 void main_menu_help(CmdLine & cmdLine)
whismanoid 4:d9b05924ad4c 2176 {
whismanoid 4:d9b05924ad4c 2177 // ? -- help
whismanoid 4:d9b05924ad4c 2178 //~ cmdLine.serial().printf("\r\nMenu:");
whismanoid 10:04022a61b527 2179 //
whismanoid 4:d9b05924ad4c 2180 cmdLine.serial().printf("\r\n # -- lines beginning with # are comments");
whismanoid 10:04022a61b527 2181 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 2182 cmdLine.serial().printf("\r\n ! -- Init");
whismanoid 10:04022a61b527 2183 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 2184 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 2185 cmdLine.serial().printf("\r\n . -- SelfTest");
whismanoid 4:d9b05924ad4c 2186 #endif // USE_SELFTEST
whismanoid 9:45f98573eb6d 2187 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 9:45f98573eb6d 2188 // CODE GENERATOR: help menu if has_register_write_command: *regname? -- read register; *regname=regvalue -- write register
whismanoid 9:45f98573eb6d 2189 cmdLine.serial().printf("\r\n * -- read core registers\r\n *regname? -- read register\r\n *regname=regvalue -- write register");
whismanoid 9:45f98573eb6d 2190 // cmdLine.serial().printf("\r\n 01 23 45 67 89 ab cd ef -- write and read raw hex codes");
whismanoid 10:04022a61b527 2191 #endif // USE_STAR_REG_READWRITE
whismanoid 10:04022a61b527 2192 //
whismanoid 10:04022a61b527 2193 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2194 // Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_help
whismanoid 10:04022a61b527 2195 //~ cmdLine.serial().printf("\r\n > -- auxiliary UART port");
whismanoid 10:04022a61b527 2196 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 2197 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2198 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2199 if (cmdLine_AUXserial.nameStr())
whismanoid 10:04022a61b527 2200 {
whismanoid 10:04022a61b527 2201 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_AUXserial.nameStr());
whismanoid 10:04022a61b527 2202 }
whismanoid 10:04022a61b527 2203 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2204 // Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 2205 if (cmdLine_DAPLINKserial.nameStr())
whismanoid 10:04022a61b527 2206 {
whismanoid 10:04022a61b527 2207 cmdLine.serial().printf("\r\n > -- auxiliary UART port [%s]", cmdLine_DAPLINKserial.nameStr());
whismanoid 10:04022a61b527 2208 }
whismanoid 10:04022a61b527 2209 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2210 # if HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2211 // WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2212 cmdLine.serial().printf("\r\n >xyzzy -- Forward command/data 'xyzzy' to aux TX/RX");
whismanoid 10:04022a61b527 2213 cmdLine.serial().printf("\r\n >>xyzzy -- Forward 'xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 2214 cmdLine.serial().printf("\r\n >>>xyzzy -- Forward '>xyzzy' to aux TX/RX, no key=value parsing");
whismanoid 10:04022a61b527 2215 cmdLine.serial().printf("\r\n >baud=%d -- configure aux TX/RX port", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 2216 #if 0
whismanoid 10:04022a61b527 2217 cmdLine.serial().printf("\r\n >tx_wait_echo=%d -- configure TX wait for each character echo", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 2218 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 2219 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 2220 #endif
whismanoid 10:04022a61b527 2221 cmdLine.serial().printf("\r\n >message_ms=%d -- maximum RX message total response time", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 2222 cmdLine.serial().printf("\r\n >rx_idle_ms=%d -- maximum RX message idle time between characters", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 2223 cmdLine.serial().printf("\r\n >rx_max_count=%d -- maximum RX message total length", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 2224 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 2225 # endif // HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2226 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2227 //
whismanoid 4:d9b05924ad4c 2228 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 2229 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 2230 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 2231 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 9:45f98573eb6d 2232 // cmdLine.serial().print(F("\r\n L -- halt the datalogger; continue accepting commands"));
whismanoid 9:45f98573eb6d 2233 //
whismanoid 4:d9b05924ad4c 2234 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible
whismanoid 4:d9b05924ad4c 2235 cmdLine.serial().printf("\r\n LR -- Datalog free run as fast as possible");
whismanoid 9:45f98573eb6d 2236 //
whismanoid 9:45f98573eb6d 2237 // TODO: Datalogger_Trigger = trigger_Timer // timer (configure interval)
whismanoid 9:45f98573eb6d 2238 // TODO: cmdLine.serial().printf("\r\n L_ -- Datalog _______"); // trigger_Timer
whismanoid 9:45f98573eb6d 2239 //
whismanoid 9:45f98573eb6d 2240 // TODO: Datalogger_Trigger = trigger_PlatformDigitalInput // platform digital input (configure digital input pin reference)
whismanoid 9:45f98573eb6d 2241 // TODO: cmdLine.serial().printf("\r\n L_ -- Datalog _______"); // trigger_PlatformDigitalInput
whismanoid 9:45f98573eb6d 2242 //
whismanoid 9:45f98573eb6d 2243 // TODO: Datalogger_Trigger = trigger_SPIDeviceRegRead // SPI device register read (configure regaddr, mask value, match value)
whismanoid 9:45f98573eb6d 2244 // TODO: cmdLine.serial().printf("\r\n L_ -- Datalog _______"); // trigger_SPIDeviceRegRead
whismanoid 9:45f98573eb6d 2245 //
whismanoid 9:45f98573eb6d 2246 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 2247 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 2248 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 2249 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 2250 cmdLine.serial().printf("\r\n LS-D -- Datalog SPI ADC channel '-'(all) Disable");
whismanoid 9:45f98573eb6d 2251 cmdLine.serial().printf("\r\n LS-V -- Datalog SPI ADC channel '-'(all) Volt");
whismanoid 9:45f98573eb6d 2252 cmdLine.serial().printf("\r\n LS-L -- Datalog SPI ADC channel '-'(all) LSB");
whismanoid 9:45f98573eb6d 2253 cmdLine.serial().printf("\r\n LS2D -- Datalog SPI ADC channel channel 2 Disable");
whismanoid 9:45f98573eb6d 2254 cmdLine.serial().printf("\r\n LS3V -- Datalog SPI ADC channel channel 3 Volt");
whismanoid 9:45f98573eb6d 2255 cmdLine.serial().printf("\r\n LS4L -- Datalog SPI ADC channel channel 4 LSB");
whismanoid 9:45f98573eb6d 2256 //
whismanoid 9:45f98573eb6d 2257 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 2258 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel channel 5 v_filter 0x34"));
whismanoid 9:45f98573eb6d 2259 cmdLine.serial().printf("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34");
whismanoid 9:45f98573eb6d 2260 //
whismanoid 9:45f98573eb6d 2261 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 2262 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 2263 cmdLine.serial().printf("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42");
whismanoid 9:45f98573eb6d 2264 //
whismanoid 9:45f98573eb6d 2265 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 2266 // cmdLine.serial().print(F("\r\n LS5___ -- Datalog SPI ADC channel channel 5 v_ctrl"));
whismanoid 9:45f98573eb6d 2267 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 2268 cmdLine.serial().printf("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar");
whismanoid 9:45f98573eb6d 2269 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 2270 cmdLine.serial().printf("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar");
whismanoid 9:45f98573eb6d 2271 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 2272 //
whismanoid 9:45f98573eb6d 2273 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 2274 // cmdLine.serial().print(F("\r\n LS5CP00 -- Datalog SPI ADC channel channel 5 v_pga 0x00"));
whismanoid 9:45f98573eb6d 2275 cmdLine.serial().printf("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00");
whismanoid 9:45f98573eb6d 2276 //
whismanoid 9:45f98573eb6d 2277 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 2278 //
whismanoid 9:45f98573eb6d 2279 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 2280 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 2281 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 2282 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 2283 cmdLine.serial().printf("\r\n LA-D -- Datalog Platform-AIN all-channel Disable");
whismanoid 9:45f98573eb6d 2284 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 2285 cmdLine.serial().printf("\r\n LA-V -- Datalog Platform-AIN all-channel Volt");
whismanoid 9:45f98573eb6d 2286 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 2287 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 2288 cmdLine.serial().printf("\r\n LA-L -- Datalog Platform-AIN all-channel LSB");
whismanoid 9:45f98573eb6d 2289 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 2290 cmdLine.serial().printf("\r\n LA2D -- Datalog Platform-AIN channel 2 Disable");
whismanoid 9:45f98573eb6d 2291 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 2292 cmdLine.serial().printf("\r\n LA3V -- Datalog Platform-AIN channel 3 Volt");
whismanoid 9:45f98573eb6d 2293 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 2294 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 2295 cmdLine.serial().printf("\r\n LA4L -- Datalog Platform-AIN channel 4 LSB");
whismanoid 9:45f98573eb6d 2296 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 2297 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 4:d9b05924ad4c 2298 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 8:dffee7509bfb 2299 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 2300 cmdLine.serial().printf("\r\n L>A -- Datalogger_enable_AUXserial %s", (Datalogger_enable_AUXserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 2301 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 2302 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 2303 cmdLine.serial().printf("\r\n L>D -- Datalogger_enable_DAPLINKserial %s", (Datalogger_enable_DAPLINKserial?"disable":"enable"));
whismanoid 8:dffee7509bfb 2304 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 2305 cmdLine.serial().printf("\r\n L>S -- Datalogger_enable_serial %s", (Datalogger_enable_serial?"disable":"enable"));
whismanoid 8:dffee7509bfb 2306 //
whismanoid 4:d9b05924ad4c 2307 //cmdLine.serial().print(F("\r\n ! -- Initial Configuration"));
whismanoid 4:d9b05924ad4c 2308 //
whismanoid 4:d9b05924ad4c 2309 // % standardize diagnostic commands
whismanoid 4:d9b05924ad4c 2310 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 2311 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 2312 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 2313 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 2314 // %Ppin df=xx -- pwm output
whismanoid 4:d9b05924ad4c 2315 // %Wpin -- measure high pulsewidth input in usec
whismanoid 4:d9b05924ad4c 2316 // %wpin -- measure low pulsewidth input in usec
whismanoid 4:d9b05924ad4c 2317 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 2318 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 2319 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 2320 // %IW ADDR=? cmd=? data,data,data -- write
whismanoid 4:d9b05924ad4c 2321 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 2322 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 2323 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 2324 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 2325 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 2326 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 2327 // A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 2328 //
whismanoid 4:d9b05924ad4c 2329 #if HAS_digitalInOuts
whismanoid 4:d9b05924ad4c 2330 // %Hpin -- digital output high
whismanoid 4:d9b05924ad4c 2331 // %Lpin -- digital output low
whismanoid 4:d9b05924ad4c 2332 // %?pin -- digital input
whismanoid 4:d9b05924ad4c 2333 cmdLine.serial().printf("\r\n %%Hn {pin:");
whismanoid 4:d9b05924ad4c 2334 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 2335 cmdLine.serial().printf("} -- High Output");
whismanoid 4:d9b05924ad4c 2336 cmdLine.serial().printf("\r\n %%Ln {pin:");
whismanoid 4:d9b05924ad4c 2337 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 2338 cmdLine.serial().printf("} -- Low Output");
whismanoid 4:d9b05924ad4c 2339 cmdLine.serial().printf("\r\n %%?n {pin:");
whismanoid 4:d9b05924ad4c 2340 list_digitalInOutPins(cmdLine.serial());
whismanoid 4:d9b05924ad4c 2341 cmdLine.serial().printf("} -- Input");
whismanoid 4:d9b05924ad4c 2342 #endif
whismanoid 4:d9b05924ad4c 2343
whismanoid 4:d9b05924ad4c 2344 #if HAS_analogIns
whismanoid 4:d9b05924ad4c 2345 // Menu A) analogRead A0..7
whismanoid 4:d9b05924ad4c 2346 // %A %Apin -- analog input
whismanoid 4:d9b05924ad4c 2347 // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0)
whismanoid 4:d9b05924ad4c 2348 cmdLine.serial().printf("\r\n %%A -- analogRead");
whismanoid 4:d9b05924ad4c 2349 #endif
whismanoid 4:d9b05924ad4c 2350
whismanoid 4:d9b05924ad4c 2351 #if HAS_SPI2_MAX541
whismanoid 4:d9b05924ad4c 2352 // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 4:d9b05924ad4c 2353 cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)");
whismanoid 4:d9b05924ad4c 2354 #endif
whismanoid 4:d9b05924ad4c 2355
whismanoid 4:d9b05924ad4c 2356 #if HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 2357 // TODO: support I2C HAS_I2C // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 2358 // VERIFY: I2C utility commands SUPPORT_I2C
whismanoid 4:d9b05924ad4c 2359 // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz);
whismanoid 4:d9b05924ad4c 2360 // %I... -- I2C diagnostics
whismanoid 4:d9b05924ad4c 2361 // %IP -- I2C probe
whismanoid 4:d9b05924ad4c 2362 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 4:d9b05924ad4c 2363 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 4:d9b05924ad4c 2364 // %IR ADDR=? RD=? -- read
whismanoid 4:d9b05924ad4c 2365 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 2366 //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope
whismanoid 4:d9b05924ad4c 2367 cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 4:d9b05924ad4c 2368 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 4:d9b05924ad4c 2369 (g_I2C_SCL_Hz / 1000.));
whismanoid 4:d9b05924ad4c 2370 cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read",
whismanoid 4:d9b05924ad4c 2371 g_I2C_deviceAddress7);
whismanoid 4:d9b05924ad4c 2372 //
whismanoid 4:d9b05924ad4c 2373 #if SUPPORT_I2C
whismanoid 4:d9b05924ad4c 2374 // Menu ^ cmd=?) i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 2375 cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data");
whismanoid 4:d9b05924ad4c 2376 // test low-level I2C i2c_smbus_read_word_data
whismanoid 4:d9b05924ad4c 2377 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 2378 //cmdLine.serial().printf(" H) Hunt for attached I2C devices");
whismanoid 4:d9b05924ad4c 2379 cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices");
whismanoid 4:d9b05924ad4c 2380 // cmdLine.serial().printf(" s) search i2c address");
whismanoid 4:d9b05924ad4c 2381 #endif // SUPPORT_I2C
whismanoid 4:d9b05924ad4c 2382
whismanoid 4:d9b05924ad4c 2383 #if HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 2384 // TODO: support SPI HAS_SPI // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 2385 // SPI test command S (mosiData)+
whismanoid 4:d9b05924ad4c 2386 // %S... -- SPI diagnostics
whismanoid 4:d9b05924ad4c 2387 // %SC sclk=1Mhz -- SPI configure
whismanoid 4:d9b05924ad4c 2388 // %SW -- write (write and read)
whismanoid 4:d9b05924ad4c 2389 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 4:d9b05924ad4c 2390 // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 4:d9b05924ad4c 2391 // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 4:d9b05924ad4c 2392 // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 4:d9b05924ad4c 2393 // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 4:d9b05924ad4c 2394 // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 4:d9b05924ad4c 2395 // mode | POL PHA
whismanoid 4:d9b05924ad4c 2396 // -----+--------
whismanoid 4:d9b05924ad4c 2397 // 0 | 0 0
whismanoid 4:d9b05924ad4c 2398 // 1 | 0 1
whismanoid 4:d9b05924ad4c 2399 // 2 | 1 0
whismanoid 4:d9b05924ad4c 2400 // 3 | 1 1
whismanoid 4:d9b05924ad4c 2401 //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0");
whismanoid 4:d9b05924ad4c 2402 // 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 2403 cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config",
whismanoid 4:d9b05924ad4c 2404 g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.),
whismanoid 4:d9b05924ad4c 2405 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 4:d9b05924ad4c 2406 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0));
whismanoid 4:d9b05924ad4c 2407 cmdLine.serial().printf("\r\n %%SD -- SPI diagnostic messages ");
whismanoid 4:d9b05924ad4c 2408 if (g_MAX11410_device.onSPIprint) {
whismanoid 4:d9b05924ad4c 2409 cmdLine.serial().printf("hide");
whismanoid 4:d9b05924ad4c 2410 }
whismanoid 4:d9b05924ad4c 2411 else {
whismanoid 4:d9b05924ad4c 2412 cmdLine.serial().printf("show");
whismanoid 4:d9b05924ad4c 2413 }
whismanoid 4:d9b05924ad4c 2414 cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes");
whismanoid 4:d9b05924ad4c 2415 // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0
whismanoid 4:d9b05924ad4c 2416 #endif // SUPPORT_SPI
whismanoid 4:d9b05924ad4c 2417 //
whismanoid 4:d9b05924ad4c 2418 // Application-specific commands (help text) here
whismanoid 4:d9b05924ad4c 2419 //
whismanoid 4:d9b05924ad4c 2420 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 2421 cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 2422 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 2423 //
whismanoid 4:d9b05924ad4c 2424
whismanoid 4:d9b05924ad4c 2425 //~ extern void MAX11410_menu_help(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp\n
whismanoid 4:d9b05924ad4c 2426 //~ MAX11410_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 2427 }
whismanoid 4:d9b05924ad4c 2428 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2429
whismanoid 4:d9b05924ad4c 2430 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 2431 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2432 void main_menu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 2433 {
whismanoid 9:45f98573eb6d 2434 // process command line
whismanoid 9:45f98573eb6d 2435 cmdLine.serial().printf("\r\nCmdLine buf:\"%s\"\r\n", cmdLine.str());
whismanoid 4:d9b05924ad4c 2436
whismanoid 4:d9b05924ad4c 2437 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 2438 // If datalog is free running, halt on any possible received command
whismanoid 4:d9b05924ad4c 2439 if (Datalogger_Trigger == trigger_FreeRun) {
whismanoid 4:d9b05924ad4c 2440 Datalogger_Trigger = trigger_Halt;
whismanoid 9:45f98573eb6d 2441 cmdLine.serial().printf("Datalog stopped by USB command input\r\n");
whismanoid 9:45f98573eb6d 2442 cmdLine.serial().printf("Restart datalog by sending LR\r\n");
whismanoid 4:d9b05924ad4c 2443 }
whismanoid 4:d9b05924ad4c 2444 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 2445
whismanoid 4:d9b05924ad4c 2446 // DIAGNOSTIC: print line buffer
whismanoid 4:d9b05924ad4c 2447 //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str());
whismanoid 4:d9b05924ad4c 2448 //
whismanoid 4:d9b05924ad4c 2449 switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 2450 {
whismanoid 4:d9b05924ad4c 2451 case '?':
whismanoid 4:d9b05924ad4c 2452 main_menu_status(cmdLine);
whismanoid 4:d9b05924ad4c 2453 main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 2454 // print command prompt
whismanoid 4:d9b05924ad4c 2455 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 2456 break;
whismanoid 4:d9b05924ad4c 2457 case '\r': case '\n': // ignore blank line
whismanoid 4:d9b05924ad4c 2458 case '\0': // ignore empty line
whismanoid 4:d9b05924ad4c 2459 case '#': // ignore comment line
whismanoid 4:d9b05924ad4c 2460 // # -- lines beginning with # are comments
whismanoid 4:d9b05924ad4c 2461 main_menu_status(cmdLine);
whismanoid 4:d9b05924ad4c 2462 //~ main_menu_help(cmdLine);
whismanoid 4:d9b05924ad4c 2463 // print command prompt
whismanoid 4:d9b05924ad4c 2464 //cmdLine.serial().printf("\r\n>");
whismanoid 4:d9b05924ad4c 2465 break;
whismanoid 4:d9b05924ad4c 2466 #if ECHO_EOF_ON_EOL
whismanoid 4:d9b05924ad4c 2467 case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file
whismanoid 4:d9b05924ad4c 2468 cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 2469 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 2470 break;
whismanoid 4:d9b05924ad4c 2471 case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file
whismanoid 4:d9b05924ad4c 2472 cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting
whismanoid 4:d9b05924ad4c 2473 diagnostic_led_EOF();
whismanoid 4:d9b05924ad4c 2474 break;
whismanoid 4:d9b05924ad4c 2475 #endif
whismanoid 10:04022a61b527 2476 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 2477 case '!': // device init
whismanoid 10:04022a61b527 2478 {
whismanoid 10:04022a61b527 2479 cmdLine.serial().printf("Init");
whismanoid 10:04022a61b527 2480 // call function Init
whismanoid 10:04022a61b527 2481 uint8_t result = g_MAX11410_device.Init();
whismanoid 10:04022a61b527 2482 // cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 2483 cmdLine.serial().printf(" =%d\r\n", result);
whismanoid 10:04022a61b527 2484 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 2485 // in command '!' device init, apply list of custom register writes after init
whismanoid 10:04022a61b527 2486 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 10:04022a61b527 2487 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 10:04022a61b527 2488 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 10:04022a61b527 2489 uint32_t regData = custom_reg_init_data[index];
whismanoid 10:04022a61b527 2490 cmdLine.serial().printf("*%s=0x%06.6x",
whismanoid 10:04022a61b527 2491 g_MAX11410_device.RegName((MAX11410::MAX11410_CMD_enum_t)regAddress),
whismanoid 10:04022a61b527 2492 regData
whismanoid 10:04022a61b527 2493 );
whismanoid 10:04022a61b527 2494 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 10:04022a61b527 2495 }
whismanoid 10:04022a61b527 2496 #endif // USE_CUSTOM_REG_INIT
whismanoid 10:04022a61b527 2497 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 2498 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 2499 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 2500 }
whismanoid 10:04022a61b527 2501 break;
whismanoid 10:04022a61b527 2502 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 2503 #if USE_SELFTEST
whismanoid 4:d9b05924ad4c 2504 case '.':
whismanoid 4:d9b05924ad4c 2505 {
whismanoid 4:d9b05924ad4c 2506 // . -- SelfTest
whismanoid 4:d9b05924ad4c 2507 cmdLine.serial().printf("SelfTest()");
whismanoid 4:d9b05924ad4c 2508 SelfTest(cmdLine);
whismanoid 4:d9b05924ad4c 2509 }
whismanoid 4:d9b05924ad4c 2510 break;
whismanoid 4:d9b05924ad4c 2511 #endif // USE_SELFTEST
whismanoid 4:d9b05924ad4c 2512 #if 0 // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 2513 case '%':
whismanoid 4:d9b05924ad4c 2514 {
whismanoid 4:d9b05924ad4c 2515 pinsMonitor_submenu_onEOLcommandParser(cmdLine);
whismanoid 4:d9b05924ad4c 2516 }
whismanoid 4:d9b05924ad4c 2517 break; // case '%'
whismanoid 4:d9b05924ad4c 2518 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 9:45f98573eb6d 2519 #if USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 2520 // reuse the Serial_Tester command *regName=regValue
whismanoid 10:04022a61b527 2521 // CODE GENERATOR: generate * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 2522 case '*':
whismanoid 10:04022a61b527 2523 {
whismanoid 10:04022a61b527 2524 // if buffer starts with a regName:
whismanoid 10:04022a61b527 2525 // for each reg value (0..n) if(cmdLine.has_keyword(device.regName(r))):
whismanoid 10:04022a61b527 2526 // cmdLine.serial().printf(" scan RegName...\r\n");
whismanoid 10:04022a61b527 2527 }
whismanoid 10:04022a61b527 2528 break;
whismanoid 9:45f98573eb6d 2529 #endif // USE_STAR_REG_READWRITE // * command read/write reg *reg? *reg=value
whismanoid 10:04022a61b527 2530 //
whismanoid 10:04022a61b527 2531 #if 1 // USE_AUX_SERIAL_CMD_FORWARDING && (HAS_AUX_SERIAL || HAS_DAPLINK_SERIAL)
whismanoid 10:04022a61b527 2532 // TODO WIP Command forwarding to Auxiliary serial port TX/RX #257 -- main_menu_onEOLcommandParser
whismanoid 10:04022a61b527 2533 case '>':
whismanoid 10:04022a61b527 2534 {
whismanoid 10:04022a61b527 2535 // prefer cmdLine_AUXserial if available, else cmdLine_DAPLINKserial; else we don't have this feature
whismanoid 10:04022a61b527 2536 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 2537 // TODO WIP Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257
whismanoid 10:04022a61b527 2538 CmdLine& cmdLine_AuxSerial = cmdLine_AUXserial;
whismanoid 10:04022a61b527 2539 Serial& AuxSerial = AUXserial;
whismanoid 10:04022a61b527 2540 # elif HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2541 // TODO WIP Command forwarding to DAPLINK serial TX/RX cmdLine_DAPLINKserial #257
whismanoid 10:04022a61b527 2542 CmdLine& cmdLine_AuxSerial = cmdLine_DAPLINKserial;
whismanoid 10:04022a61b527 2543 Serial& AuxSerial = DAPLINKserial;
whismanoid 10:04022a61b527 2544 # else // neither HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2545 #warning "USE_AUX_SERIAL_CMD_FORWARDING should not be enabled without HAS_AUX_SERIAL or HAS_DAPLINK_SERIAL"
whismanoid 10:04022a61b527 2546 # endif // HAS_AUX_SERIAL HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 2547 //
whismanoid 10:04022a61b527 2548 // >> suppress key=value parsing
whismanoid 10:04022a61b527 2549 bool suppress_parsing = (cmdLine[1] == '>');
whismanoid 10:04022a61b527 2550 if (suppress_parsing == false) {
whismanoid 10:04022a61b527 2551 // int g_auxSerialCom_baud = 9600; //!< baud rate Auxiliary serial port
whismanoid 10:04022a61b527 2552 if (cmdLine.parse_int_dec("baud", g_auxSerialCom_baud))
whismanoid 10:04022a61b527 2553 {
whismanoid 10:04022a61b527 2554 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- baud rate
whismanoid 10:04022a61b527 2555 cmdLine_AuxSerial.serial().printf("\r\n*** New Baud Rate %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 2556 AuxSerial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 2557 cmdLine_AuxSerial.serial().printf("\r\n*** Baud Rate was set to %d ***\r\n", g_auxSerialCom_baud);
whismanoid 10:04022a61b527 2558 }
whismanoid 10:04022a61b527 2559 #if 0
whismanoid 10:04022a61b527 2560 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 2561 if (cmdLine.parse_int_dec("tx_wait_echo", g_auxSerialCom_tx_wait_echo))
whismanoid 10:04022a61b527 2562 {
whismanoid 10:04022a61b527 2563 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_wait_echo
whismanoid 10:04022a61b527 2564 //~ cmdLine_AuxSerial.serial().printf("\r\n*** tx_wait_echo was set to %d ***\r\n", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 2565 cmdLine.serial().printf("\r\n tx_wait_echo=%d", g_auxSerialCom_tx_wait_echo);
whismanoid 10:04022a61b527 2566 }
whismanoid 10:04022a61b527 2567 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 2568 if (cmdLine.parse_int_dec("tx_char_delay_ms", g_auxSerialCom_tx_char_delay_ms))
whismanoid 10:04022a61b527 2569 {
whismanoid 10:04022a61b527 2570 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_char_delay_ms
whismanoid 10:04022a61b527 2571 //~ 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 2572 cmdLine.serial().printf("\r\n tx_char_delay_ms=%dms", g_auxSerialCom_tx_char_delay_ms);
whismanoid 10:04022a61b527 2573 }
whismanoid 10:04022a61b527 2574 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 2575 if (cmdLine.parse_int_dec("tx_line_delay_ms", g_auxSerialCom_tx_line_delay_ms))
whismanoid 10:04022a61b527 2576 {
whismanoid 10:04022a61b527 2577 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- tx_line_delay_ms
whismanoid 10:04022a61b527 2578 //~ 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 2579 cmdLine.serial().printf("\r\n tx_line_delay_ms=%dms", g_auxSerialCom_tx_line_delay_ms);
whismanoid 10:04022a61b527 2580 }
whismanoid 10:04022a61b527 2581 #endif
whismanoid 10:04022a61b527 2582 // int g_auxSerialCom_message_ms = 0; //!< capture RX until response timeout?
whismanoid 10:04022a61b527 2583 if (cmdLine.parse_int_dec("message_ms", g_auxSerialCom_message_ms))
whismanoid 10:04022a61b527 2584 {
whismanoid 10:04022a61b527 2585 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- message_ms
whismanoid 10:04022a61b527 2586 //~ cmdLine_AuxSerial.serial().printf("\r\n*** message_ms was set to %d ***\r\n", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 2587 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 2588 }
whismanoid 10:04022a61b527 2589 // int g_auxSerialCom_rx_idle_ms = 0; //!< capture RX until idle timeout?
whismanoid 10:04022a61b527 2590 if (cmdLine.parse_int_dec("rx_idle_ms", g_auxSerialCom_rx_idle_ms))
whismanoid 10:04022a61b527 2591 {
whismanoid 10:04022a61b527 2592 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_idle_ms
whismanoid 10:04022a61b527 2593 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_idle_ms was set to %d ***\r\n", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 2594 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 2595 }
whismanoid 10:04022a61b527 2596 // int g_auxSerialCom_rx_max_count = 0; //!< capture RX until max character count?
whismanoid 10:04022a61b527 2597 if (cmdLine.parse_int_dec("rx_max_count", g_auxSerialCom_rx_max_count))
whismanoid 10:04022a61b527 2598 {
whismanoid 10:04022a61b527 2599 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_max_count
whismanoid 10:04022a61b527 2600 //~ cmdLine_AuxSerial.serial().printf("\r\n*** rx_max_count was set to %d ***\r\n", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 2601 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 2602 }
whismanoid 10:04022a61b527 2603 // int g_auxSerialCom_rx_eot = 0; //!< capture RX until match end of text char?
whismanoid 10:04022a61b527 2604 if (cmdLine.parse_int_dec("rx_eot", g_auxSerialCom_rx_eot))
whismanoid 10:04022a61b527 2605 {
whismanoid 10:04022a61b527 2606 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- rx_eot
whismanoid 10:04022a61b527 2607 //~ cmdLine_AUXserial.serial().printf("\r\n*** rx_eot was set to %d ***\r\n", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 2608 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 2609 }
whismanoid 10:04022a61b527 2610 }
whismanoid 10:04022a61b527 2611 // Command forwarding to AUX serial TX/RX cmdLine_AuxSerial #257 -- send outgoing_string
whismanoid 10:04022a61b527 2612 char* outgoing_string = (char*)cmdLine.str();
whismanoid 10:04022a61b527 2613 // > use key=value parsing
whismanoid 10:04022a61b527 2614 // >> suppress key=value parsing
whismanoid 10:04022a61b527 2615 if (suppress_parsing) {
whismanoid 10:04022a61b527 2616 cmdLine.serial().printf("\r\n suppress_parsing outgoing_string=\"%s\"", outgoing_string);
whismanoid 10:04022a61b527 2617 outgoing_string++; // skip the first '>'
whismanoid 10:04022a61b527 2618 outgoing_string++; // skip the second '>'
whismanoid 10:04022a61b527 2619 } else {
whismanoid 10:04022a61b527 2620 // TODO: after parsing, key=value pairs should be deleted, but outgoing_string=">xyzzy abc=def"
whismanoid 10:04022a61b527 2621 cmdLine.serial().printf("\r\n after parsing, outgoing_string=\"%s\"", outgoing_string);
whismanoid 10:04022a61b527 2622 outgoing_string++; // skip the first '>'
whismanoid 10:04022a61b527 2623 }
whismanoid 10:04022a61b527 2624 static char rx_string_buf[RX_STRING_BUF_SIZE];
whismanoid 10:04022a61b527 2625 unsigned int rx_string_length = 0;
whismanoid 10:04022a61b527 2626 cmdLine.serial().printf("\r\n >%s\r\n <", outgoing_string);
whismanoid 10:04022a61b527 2627 rx_string_buf[0] = '\0';
whismanoid 10:04022a61b527 2628 rx_string_length = 0;
whismanoid 10:04022a61b527 2629 //
whismanoid 10:04022a61b527 2630 // int g_auxSerialCom_tx_wait_echo = 0; //!< TX wait for each character echo?
whismanoid 10:04022a61b527 2631 // int g_auxSerialCom_tx_char_delay_ms = 0; //!< TX delay after each char?
whismanoid 10:04022a61b527 2632 // int g_auxSerialCom_tx_line_delay_ms = 0; //!< TX delay after each CR/LF?
whismanoid 10:04022a61b527 2633 //
whismanoid 10:04022a61b527 2634 // int g_auxSerialCom_Timer_begin_message_ms = 0; //!< start of message
whismanoid 10:04022a61b527 2635 // int g_auxSerialCom_Timer_begin_rx_idle_ms = 0; //!< recent RX character timestamp
whismanoid 10:04022a61b527 2636 // int g_auxSerialCom_message_ms = 10000; //!< maximum RX message total response time
whismanoid 10:04022a61b527 2637 // int g_auxSerialCom_rx_idle_ms = 2000; //!< maximum RX message idle time between characters
whismanoid 10:04022a61b527 2638 // int g_auxSerialCom_rx_max_count = RX_STRING_BUF_SIZE-1; //!< maximum RX message total length
whismanoid 10:04022a61b527 2639 // int g_auxSerialCom_rx_eot = '\r'; //!< capture RX until match end of text char
whismanoid 10:04022a61b527 2640 //~ cmdLine_AuxSerial.serial().printf("\r\n*** TODO forward %s ***\r\n", outgoing_string);
whismanoid 10:04022a61b527 2641 //
whismanoid 10:04022a61b527 2642 // TODO: send whole string or send character-by-character?
whismanoid 10:04022a61b527 2643 cmdLine_AuxSerial.serial().printf("%s", outgoing_string);
whismanoid 10:04022a61b527 2644 cmdLine_AuxSerial.serial().printf("\r\n");
whismanoid 10:04022a61b527 2645 g_auxSerialCom_Timer.start();
whismanoid 10:04022a61b527 2646 g_auxSerialCom_Timer_begin_message_ms = g_auxSerialCom_Timer.read_ms(); // start of message
whismanoid 10:04022a61b527 2647 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 2648 while (rx_string_length < (RX_STRING_BUF_SIZE-1)) {
whismanoid 10:04022a61b527 2649 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_message_ms) > g_auxSerialCom_message_ms) {
whismanoid 10:04022a61b527 2650 cmdLine.serial().printf("\r\n message_ms timeout %dms", g_auxSerialCom_message_ms);
whismanoid 10:04022a61b527 2651 break;
whismanoid 10:04022a61b527 2652 }
whismanoid 10:04022a61b527 2653 if ((g_auxSerialCom_Timer.read_ms() - g_auxSerialCom_Timer_begin_rx_idle_ms) > g_auxSerialCom_rx_idle_ms) {
whismanoid 10:04022a61b527 2654 cmdLine.serial().printf("\r\n rx_idle_ms timeout %dms", g_auxSerialCom_rx_idle_ms);
whismanoid 10:04022a61b527 2655 break;
whismanoid 10:04022a61b527 2656 }
whismanoid 10:04022a61b527 2657 if (rx_string_length >= g_auxSerialCom_rx_max_count) {
whismanoid 10:04022a61b527 2658 cmdLine.serial().printf("\r\n rx_max_count %d bytes", g_auxSerialCom_rx_max_count);
whismanoid 10:04022a61b527 2659 break;
whismanoid 10:04022a61b527 2660 }
whismanoid 10:04022a61b527 2661 if (AuxSerial.readable()) {
whismanoid 10:04022a61b527 2662 g_auxSerialCom_Timer_begin_rx_idle_ms = g_auxSerialCom_Timer.read_ms(); // recent RX character timestamp
whismanoid 10:04022a61b527 2663 char ch = AuxSerial.getc();
whismanoid 10:04022a61b527 2664 rx_string_buf[rx_string_length++] = ch;
whismanoid 10:04022a61b527 2665 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 10:04022a61b527 2666 cmdLine.serial().printf("%s", &(rx_string_buf[rx_string_length-1]) ); // immediate character echo
whismanoid 10:04022a61b527 2667 if (g_auxSerialCom_rx_eot != aux_serial_cmd_forwarding_rx_eot_not_used) {
whismanoid 10:04022a61b527 2668 if (ch == g_auxSerialCom_rx_eot) {
whismanoid 10:04022a61b527 2669 cmdLine.serial().printf("\r\n rx_eot %d", g_auxSerialCom_rx_eot);
whismanoid 10:04022a61b527 2670 break;
whismanoid 10:04022a61b527 2671 }
whismanoid 10:04022a61b527 2672 }
whismanoid 10:04022a61b527 2673 }
whismanoid 10:04022a61b527 2674 } // end while (rx_string_length < (RX_STRING_BUF_SIZE-1))
whismanoid 10:04022a61b527 2675 #if 1
whismanoid 10:04022a61b527 2676 // print summary. is this needed? we already print aux rx as it is received.
whismanoid 10:04022a61b527 2677 rx_string_buf[rx_string_length] = '\0'; // null terminate buffer
whismanoid 10:04022a61b527 2678 cmdLine.serial().printf("\r\n >%s", outgoing_string);
whismanoid 10:04022a61b527 2679 cmdLine.serial().printf("\r\n <%s\r\n", rx_string_buf);
whismanoid 10:04022a61b527 2680 #endif
whismanoid 10:04022a61b527 2681 //
whismanoid 10:04022a61b527 2682 }
whismanoid 10:04022a61b527 2683 break; // case '>'
whismanoid 10:04022a61b527 2684 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 2685 //
whismanoid 4:d9b05924ad4c 2686 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 2687 // TODO Datalog trigger menu
whismanoid 4:d9b05924ad4c 2688 // set Datalogger_Trigger to trigger_Halt or trigger_FreeRun
whismanoid 4:d9b05924ad4c 2689 // Datalogger_Trigger = trigger_Halt // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 2690 // Datalogger_Trigger = trigger_FreeRun // free run as fast as possible
whismanoid 9:45f98573eb6d 2691 case 'L': case 'l':
whismanoid 4:d9b05924ad4c 2692 {
whismanoid 4:d9b05924ad4c 2693 // halt the datalogger; continue accepting commands
whismanoid 4:d9b05924ad4c 2694 Datalogger_Trigger = trigger_Halt;
whismanoid 4:d9b05924ad4c 2695 switch (cmdLine[1])
whismanoid 4:d9b05924ad4c 2696 {
whismanoid 4:d9b05924ad4c 2697 case 'R': case 'r':
whismanoid 4:d9b05924ad4c 2698 // free run as fast as possible
whismanoid 8:dffee7509bfb 2699 Datalogger_Trigger = trigger_FreeRun;
whismanoid 8:dffee7509bfb 2700 Datalogger_Need_PrintHeader = true;
whismanoid 4:d9b05924ad4c 2701 return; // instead of break; avoid falling through to print_command_prompt();
whismanoid 9:45f98573eb6d 2702 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 2703 // LS<channel ID><verb>: Configure SPI_AIN channels
whismanoid 9:45f98573eb6d 2704 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 2705 // verb: D for disable, V for Voltage, L for LSB
whismanoid 9:45f98573eb6d 2706 case 'S': case 's':
whismanoid 9:45f98573eb6d 2707 {
whismanoid 9:45f98573eb6d 2708 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 2709 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 2710 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 2711 )
whismanoid 9:45f98573eb6d 2712 {
whismanoid 9:45f98573eb6d 2713 // it's me
whismanoid 9:45f98573eb6d 2714 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 2715 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 2716 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 2717 {
whismanoid 9:45f98573eb6d 2718 case 'D': case 'd':
whismanoid 9:45f98573eb6d 2719 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Disable;
whismanoid 9:45f98573eb6d 2720 break;
whismanoid 9:45f98573eb6d 2721 case 'L': case 'l':
whismanoid 9:45f98573eb6d 2722 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 2723 break;
whismanoid 9:45f98573eb6d 2724 case 'V': case 'v':
whismanoid 9:45f98573eb6d 2725 SPI_AIN_Enable_ch[channel_index] = SPI_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 2726 break;
whismanoid 9:45f98573eb6d 2727 //
whismanoid 9:45f98573eb6d 2728 //
whismanoid 9:45f98573eb6d 2729 // TODO: MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 2730 case 'C': case 'c':
whismanoid 9:45f98573eb6d 2731 {
whismanoid 9:45f98573eb6d 2732 uint8_t hexValue = 0;
whismanoid 9:45f98573eb6d 2733 hexValue = hexValueOfChar(cmdLine[5]) * 0x10 + hexValueOfChar(cmdLine[6]);
whismanoid 9:45f98573eb6d 2734 switch (cmdLine[4])
whismanoid 9:45f98573eb6d 2735 {
whismanoid 9:45f98573eb6d 2736 //
whismanoid 9:45f98573eb6d 2737 // MAX11410 verb for configuring SPI_AIN_Cfg_v_filter_ch[channel_index]
whismanoid 9:45f98573eb6d 2738 // cmdLine.serial().print(F("\r\n LS-CF34 -- Datalog SPI ADC channel '-'(all) v_filter 0x34"));
whismanoid 9:45f98573eb6d 2739 case 'F': case 'f':
whismanoid 9:45f98573eb6d 2740 SPI_AIN_Cfg_v_filter_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 2741 break;
whismanoid 9:45f98573eb6d 2742 //
whismanoid 9:45f98573eb6d 2743 // MAX11410 verb for configuring SPI_AIN_Cfg_v_ctrl_ch[channel_index]
whismanoid 9:45f98573eb6d 2744 // cmdLine.serial().print(F("\r\n LS-CC42 -- Datalog SPI ADC channel '-'(all) v_ctrl 0x42"));
whismanoid 9:45f98573eb6d 2745 case 'C': case 'c':
whismanoid 9:45f98573eb6d 2746 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 2747 break;
whismanoid 9:45f98573eb6d 2748 //
whismanoid 9:45f98573eb6d 2749 // MAX11410 verb for configuring SPI_AIN_Cfg_v_pga_ch[channel_index]
whismanoid 9:45f98573eb6d 2750 // cmdLine.serial().print(F("\r\n LS-CP00 -- Datalog SPI ADC channel '-'(all) v_pga 0x00"));
whismanoid 9:45f98573eb6d 2751 case 'P': case 'p':
whismanoid 9:45f98573eb6d 2752 SPI_AIN_Cfg_v_pga_ch[channel_index] = hexValue;
whismanoid 9:45f98573eb6d 2753 break;
whismanoid 9:45f98573eb6d 2754 //
whismanoid 9:45f98573eb6d 2755 // cmdLine.serial().print(F("\r\n LS5CU -- Datalog SPI ADC channel channel 5 v_ctrl Unipolar"));
whismanoid 9:45f98573eb6d 2756 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 2757 case 'U': case 'u':
whismanoid 9:45f98573eb6d 2758 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] | 0x40;
whismanoid 9:45f98573eb6d 2759 break;
whismanoid 9:45f98573eb6d 2760 //
whismanoid 9:45f98573eb6d 2761 // cmdLine.serial().print(F("\r\n LS5CB -- Datalog SPI ADC channel channel 5 v_ctrl Bipolar"));
whismanoid 9:45f98573eb6d 2762 // ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) ? "BIPOLAR" : "Unipolar"
whismanoid 9:45f98573eb6d 2763 case 'B': case 'b':
whismanoid 9:45f98573eb6d 2764 SPI_AIN_Cfg_v_ctrl_ch[channel_index] = SPI_AIN_Cfg_v_ctrl_ch[channel_index] &~ 0x40;
whismanoid 9:45f98573eb6d 2765 break;
whismanoid 9:45f98573eb6d 2766 }
whismanoid 9:45f98573eb6d 2767 break;
whismanoid 9:45f98573eb6d 2768 }
whismanoid 9:45f98573eb6d 2769 //
whismanoid 9:45f98573eb6d 2770 //
whismanoid 9:45f98573eb6d 2771 }
whismanoid 9:45f98573eb6d 2772 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 2773 } // end for channel_index
whismanoid 9:45f98573eb6d 2774 Datalogger_PrintHeader();
whismanoid 9:45f98573eb6d 2775 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 2776 }
whismanoid 9:45f98573eb6d 2777 break;
whismanoid 9:45f98573eb6d 2778 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 2779 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 2780 // LA<channel ID><verb>: Configure Platform_AIN channels
whismanoid 9:45f98573eb6d 2781 // channel ID: 0,1,2,... or - for all channels
whismanoid 9:45f98573eb6d 2782 // verb: D for disable, V for Voltage, L for LSB
whismanoid 8:dffee7509bfb 2783 case 'A': case 'a':
whismanoid 9:45f98573eb6d 2784 {
whismanoid 9:45f98573eb6d 2785 // all-channel: loop through all valid channel_index, test cmdLine[2] 'is it me'?
whismanoid 9:45f98573eb6d 2786 // for channel_index loop through 0..NUM_DUT_ANALOG_IN_CHANNELS
whismanoid 9:45f98573eb6d 2787 // if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 2788 // || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 2789 // ) {
whismanoid 9:45f98573eb6d 2790 // // it's me
whismanoid 9:45f98573eb6d 2791 // // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 2792 // // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 2793 // } end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 2794 // } end for channel_index
whismanoid 9:45f98573eb6d 2795 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 2796 if ((cmdLine[2] == '-' /* all channels */)
whismanoid 9:45f98573eb6d 2797 || (cmdLine[2] == '0'+channel_index)
whismanoid 9:45f98573eb6d 2798 )
whismanoid 9:45f98573eb6d 2799 {
whismanoid 9:45f98573eb6d 2800 // it's me
whismanoid 9:45f98573eb6d 2801 // test cmdLine[3] to determine action
whismanoid 9:45f98573eb6d 2802 // Platform_Enable_ch[channel_index] = Platform_AIN_xxxxx;
whismanoid 9:45f98573eb6d 2803 switch (cmdLine[3])
whismanoid 9:45f98573eb6d 2804 {
whismanoid 9:45f98573eb6d 2805 case 'D': case 'd':
whismanoid 9:45f98573eb6d 2806 Platform_Enable_ch[channel_index] = Platform_AIN_Disable;
whismanoid 9:45f98573eb6d 2807 break;
whismanoid 9:45f98573eb6d 2808 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 2809 case 'L': case 'l':
whismanoid 9:45f98573eb6d 2810 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_LSB;
whismanoid 9:45f98573eb6d 2811 break;
whismanoid 9:45f98573eb6d 2812 #endif // LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 2813 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 2814 case 'V': case 'v':
whismanoid 9:45f98573eb6d 2815 Platform_Enable_ch[channel_index] = Platform_AIN_Enable_Volt;
whismanoid 9:45f98573eb6d 2816 break;
whismanoid 9:45f98573eb6d 2817 #endif // LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 9:45f98573eb6d 2818 }
whismanoid 9:45f98573eb6d 2819 } // end if cmdLine[2] channel_index
whismanoid 9:45f98573eb6d 2820 } // end for channel_index
whismanoid 10:04022a61b527 2821 // Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 2822 if (Datalogger_enable_serial) {
whismanoid 9:45f98573eb6d 2823 Datalogger_PrintHeader(cmdLine);
whismanoid 9:45f98573eb6d 2824 }
whismanoid 9:45f98573eb6d 2825 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 2826 if (Datalogger_enable_AUXserial) {
whismanoid 9:45f98573eb6d 2827 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 9:45f98573eb6d 2828 }
whismanoid 9:45f98573eb6d 2829 # endif // HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 2830 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 2831 if (Datalogger_enable_DAPLINKserial) {
whismanoid 9:45f98573eb6d 2832 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 9:45f98573eb6d 2833 }
whismanoid 9:45f98573eb6d 2834 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 2835 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 2836 }
whismanoid 8:dffee7509bfb 2837 break;
whismanoid 9:45f98573eb6d 2838 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 2839 case '>':
whismanoid 9:45f98573eb6d 2840 // L>A -- Datalogger_enable_AUXserial
whismanoid 9:45f98573eb6d 2841 // L>D -- Datalogger_enable_DAPLINKserial
whismanoid 9:45f98573eb6d 2842 // L>S -- Datalogger_enable_serial
whismanoid 9:45f98573eb6d 2843 switch (cmdLine[2])
whismanoid 9:45f98573eb6d 2844 {
whismanoid 9:45f98573eb6d 2845 # if HAS_AUX_SERIAL
whismanoid 9:45f98573eb6d 2846 case 'A': case 'a':
whismanoid 9:45f98573eb6d 2847 Datalogger_enable_AUXserial = !Datalogger_enable_AUXserial;
whismanoid 9:45f98573eb6d 2848 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 2849 break;
whismanoid 8:dffee7509bfb 2850 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 2851 # if HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 2852 case 'D': case 'd':
whismanoid 9:45f98573eb6d 2853 Datalogger_enable_DAPLINKserial = !Datalogger_enable_DAPLINKserial;
whismanoid 9:45f98573eb6d 2854 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 2855 break;
whismanoid 8:dffee7509bfb 2856 # endif // HAS_DAPLINK_SERIAL
whismanoid 9:45f98573eb6d 2857 case 'S': case 's':
whismanoid 9:45f98573eb6d 2858 Datalogger_enable_serial = !Datalogger_enable_serial;
whismanoid 9:45f98573eb6d 2859 Datalogger_Need_PrintHeader = true;
whismanoid 9:45f98573eb6d 2860 break;
whismanoid 9:45f98573eb6d 2861 }
whismanoid 9:45f98573eb6d 2862 break; // case '>' L>S serial enable toggle
whismanoid 4:d9b05924ad4c 2863 }
whismanoid 4:d9b05924ad4c 2864 }
whismanoid 4:d9b05924ad4c 2865 break; // case 'L'
whismanoid 4:d9b05924ad4c 2866 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 4:d9b05924ad4c 2867 //
whismanoid 4:d9b05924ad4c 2868 // Application-specific commands here
whismanoid 4:d9b05924ad4c 2869 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 4:d9b05924ad4c 2870 //
whismanoid 4:d9b05924ad4c 2871 #if APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 2872 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 4:d9b05924ad4c 2873
whismanoid 4:d9b05924ad4c 2874 //
whismanoid 4:d9b05924ad4c 2875 // TODO1: add new commands here
whismanoid 4:d9b05924ad4c 2876 //
whismanoid 4:d9b05924ad4c 2877 default:
whismanoid 4:d9b05924ad4c 2878 #if APPLICATION_MAX5715 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 2879 extern bool MAX5715_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5715.cpp
whismanoid 4:d9b05924ad4c 2880 if (!MAX5715_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 2881 #elif APPLICATION_MAX11131 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 2882 extern bool MAX11131_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11131.cpp
whismanoid 4:d9b05924ad4c 2883 if (!MAX11131_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 2884 #elif APPLICATION_MAX5171 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 2885 extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp
whismanoid 4:d9b05924ad4c 2886 if (!MAX5171_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 2887 #elif APPLICATION_MAX11410 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 2888 extern bool MAX11410_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX11410.cpp
whismanoid 4:d9b05924ad4c 2889 if (!MAX11410_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 2890 #elif APPLICATION_MAX12345 // main_menu_onEOLcommandParser print command prompt
whismanoid 4:d9b05924ad4c 2891 extern bool MAX12345_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX12345.cpp
whismanoid 4:d9b05924ad4c 2892 if (!MAX12345_menu_onEOLcommandParser(cmdLine))
whismanoid 4:d9b05924ad4c 2893 #else
whismanoid 4:d9b05924ad4c 2894 if (0) // not_handled_by_device_submenu
whismanoid 4:d9b05924ad4c 2895 #endif
whismanoid 4:d9b05924ad4c 2896 {
whismanoid 4:d9b05924ad4c 2897 cmdLine.serial().printf("\r\n unknown command ");
whismanoid 4:d9b05924ad4c 2898 //~ cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 2899 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 2900 cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n",
whismanoid 4:d9b05924ad4c 2901 cmdLine.str()[0], cmdLine.str());
whismanoid 4:d9b05924ad4c 2902 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 2903 }
whismanoid 4:d9b05924ad4c 2904 } // switch (cmdLine[0])
whismanoid 4:d9b05924ad4c 2905 //
whismanoid 4:d9b05924ad4c 2906 // print command prompt
whismanoid 8:dffee7509bfb 2907 // print_command_prompt();
whismanoid 8:dffee7509bfb 2908 cmdLine.serial().printf("\r\n> ");
whismanoid 4:d9b05924ad4c 2909 }
whismanoid 4:d9b05924ad4c 2910 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 2911
whismanoid 4:d9b05924ad4c 2912 //--------------------------------------------------
whismanoid 4:d9b05924ad4c 2913 // print column header banner for csv data columns
whismanoid 8:dffee7509bfb 2914 void Datalogger_PrintHeader(CmdLine& cmdLine)
whismanoid 4:d9b05924ad4c 2915 {
whismanoid 4:d9b05924ad4c 2916 // column header banner for csv data columns
whismanoid 4:d9b05924ad4c 2917 int field_index = 0;
whismanoid 4:d9b05924ad4c 2918 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 2919 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 2920 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 4:d9b05924ad4c 2921 continue;
whismanoid 4:d9b05924ad4c 2922 }
whismanoid 4:d9b05924ad4c 2923 // comma between fields
whismanoid 4:d9b05924ad4c 2924 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 2925 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 2926 }
whismanoid 10:04022a61b527 2927 field_index++;
whismanoid 4:d9b05924ad4c 2928 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 2929 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 2930 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 4:d9b05924ad4c 2931 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 4:d9b05924ad4c 2932 cmdLine.serial().printf("\"AIN%d-%d_BIP", channel_index, channel_index+1);
whismanoid 4:d9b05924ad4c 2933 }
whismanoid 4:d9b05924ad4c 2934 else {
whismanoid 4:d9b05924ad4c 2935 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 2936 }
whismanoid 4:d9b05924ad4c 2937 #else // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 4:d9b05924ad4c 2938 cmdLine.serial().printf("\"AIN%d", channel_index);
whismanoid 4:d9b05924ad4c 2939 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 2940 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_LSB) {
whismanoid 4:d9b05924ad4c 2941 // _LSB column header suffix
whismanoid 13:184a08909405 2942 cmdLine.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 2943 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 2944 cmdLine_DAPLINKserial.serial().printf("_LSB");
whismanoid 4:d9b05924ad4c 2945 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 2946 }
whismanoid 10:04022a61b527 2947 else if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Enable_Volt) {
whismanoid 4:d9b05924ad4c 2948 // _V column header suffix
whismanoid 13:184a08909405 2949 cmdLine.serial().printf("_V");
whismanoid 4:d9b05924ad4c 2950 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 2951 cmdLine_DAPLINKserial.serial().printf("_V");
whismanoid 4:d9b05924ad4c 2952 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 2953 }
whismanoid 13:184a08909405 2954 #if HAS_SPI_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2955 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 2956 if (SPI_AIN_customChannelHeader_ch[channel_index] && SPI_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 2957 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 2958 cmdLine.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 2959 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 2960 cmdLine_DAPLINKserial.serial().printf("_%s", SPI_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 2961 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 2962 } else {
whismanoid 13:184a08909405 2963 // no custom channel name for this channel
whismanoid 13:184a08909405 2964 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 2965 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 2966 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 2967 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 2968 }
whismanoid 13:184a08909405 2969 #endif // HAS_SPI_AIN_customChannelHeader
whismanoid 13:184a08909405 2970 // close quote
whismanoid 13:184a08909405 2971 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 2972 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 2973 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 2974 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 2975 }
whismanoid 4:d9b05924ad4c 2976
whismanoid 4:d9b05924ad4c 2977 #if VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 2978 // PART_ID field: Device ID Validation
whismanoid 4:d9b05924ad4c 2979 cmdLine.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 2980 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 2981 cmdLine_DAPLINKserial.serial().printf(",\"PART_ID\"");
whismanoid 4:d9b05924ad4c 2982 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 2983 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 4:d9b05924ad4c 2984 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 4:d9b05924ad4c 2985 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 2986 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 2987 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 2988 continue;
whismanoid 9:45f98573eb6d 2989 }
whismanoid 4:d9b05924ad4c 2990 // comma between fields
whismanoid 4:d9b05924ad4c 2991 if (field_index > 0) {
whismanoid 4:d9b05924ad4c 2992 cmdLine.serial().printf(",");
whismanoid 4:d9b05924ad4c 2993 }
whismanoid 9:45f98573eb6d 2994 field_index++;
whismanoid 4:d9b05924ad4c 2995 // AIN_index column header prefix
whismanoid 4:d9b05924ad4c 2996 cmdLine.serial().printf("\"A%d", channel_index);
whismanoid 9:45f98573eb6d 2997 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 9:45f98573eb6d 2998 // _LSB column header suffix
whismanoid 13:184a08909405 2999 cmdLine.serial().printf("_LSB");
whismanoid 9:45f98573eb6d 3000 }
whismanoid 9:45f98573eb6d 3001 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 3002 // _V column header suffix
whismanoid 13:184a08909405 3003 cmdLine.serial().printf("_V");
whismanoid 9:45f98573eb6d 3004 }
whismanoid 13:184a08909405 3005 #if HAS_Platform_AIN_customChannelHeader // Optional custom per-channel header suffix
whismanoid 13:184a08909405 3006 // Optional custom per-channel header suffix
whismanoid 13:184a08909405 3007 if (Platform_AIN_customChannelHeader_ch[channel_index] && Platform_AIN_customChannelHeader_ch[channel_index][0]) {
whismanoid 13:184a08909405 3008 // not a null pointer, and not an empty string
whismanoid 13:184a08909405 3009 cmdLine.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 3010 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 3011 cmdLine_DAPLINKserial.serial().printf("_%s", Platform_AIN_customChannelHeader_ch[channel_index]);
whismanoid 13:184a08909405 3012 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 3013 } else {
whismanoid 13:184a08909405 3014 // no custom channel name for this channel
whismanoid 13:184a08909405 3015 //~ cmdLine.serial().printf("~");
whismanoid 13:184a08909405 3016 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 3017 //~ cmdLine_DAPLINKserial.serial().printf("~");
whismanoid 13:184a08909405 3018 # endif // HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 3019 }
whismanoid 13:184a08909405 3020 #endif // HAS_Platform_AIN_customChannelHeader
whismanoid 13:184a08909405 3021 // close quote
whismanoid 13:184a08909405 3022 cmdLine.serial().printf("\"");
whismanoid 13:184a08909405 3023 # if HAS_DAPLINK_SERIAL
whismanoid 13:184a08909405 3024 cmdLine_DAPLINKserial.serial().printf("\"");
whismanoid 13:184a08909405 3025 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 3026 }
whismanoid 4:d9b05924ad4c 3027 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 4:d9b05924ad4c 3028 // end of column header line
whismanoid 4:d9b05924ad4c 3029 cmdLine.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 3030 # if HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 3031 cmdLine_DAPLINKserial.serial().printf("\r\n");
whismanoid 4:d9b05924ad4c 3032 # endif // HAS_DAPLINK_SERIAL
whismanoid 4:d9b05924ad4c 3033 } // void Datalogger_PrintHeader()
whismanoid 4:d9b05924ad4c 3034
whismanoid 5:aaf8b5f5fda1 3035 //--------------------------------------------------
whismanoid 5:aaf8b5f5fda1 3036 void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 3037 {
whismanoid 5:aaf8b5f5fda1 3038 // CODE GENERATOR: example code: has no member function ScanStandardExternalClock
whismanoid 5:aaf8b5f5fda1 3039 // CODE GENERATOR: example code: has no member function ReadAINcode
whismanoid 5:aaf8b5f5fda1 3040 // CODE GENERATOR: example code: member function Read_All_Voltages
whismanoid 5:aaf8b5f5fda1 3041 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 3042 // Measure ADC channels in sequence from AIN0 to channelNumber_0_9.
whismanoid 5:aaf8b5f5fda1 3043 // @param[in] g_MAX11410_device.channelNumber_0_15: AIN Channel Number
whismanoid 5:aaf8b5f5fda1 3044 // @param[in] g_MAX11410_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby
whismanoid 5:aaf8b5f5fda1 3045 // @param[in] g_MAX11410_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID
whismanoid 10:04022a61b527 3046 //~ int channelId_0_9 = NUM_DUT_ANALOG_IN_CHANNELS-1+1;
whismanoid 5:aaf8b5f5fda1 3047 //g_MAX11410_device.channelNumber_0_15 = channelId_0_9;
whismanoid 5:aaf8b5f5fda1 3048 //g_MAX11410_device.PowerManagement_0_2 = 0;
whismanoid 5:aaf8b5f5fda1 3049 //g_MAX11410_device.chan_id_0_1 = 1;
whismanoid 5:aaf8b5f5fda1 3050 //----------------------------------------
whismanoid 5:aaf8b5f5fda1 3051 // scan AIN0..AIN9
whismanoid 5:aaf8b5f5fda1 3052 //
whismanoid 10:04022a61b527 3053 #if 1
whismanoid 10:04022a61b527 3054 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 10:04022a61b527 3055 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 10:04022a61b527 3056 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 10:04022a61b527 3057 //
whismanoid 10:04022a61b527 3058 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 3059 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc3); // GP1 = 0
whismanoid 10:04022a61b527 3060 //
whismanoid 10:04022a61b527 3061 int field_index = 0;
whismanoid 10:04022a61b527 3062 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 3063 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 10:04022a61b527 3064 continue;
whismanoid 10:04022a61b527 3065 }
whismanoid 10:04022a61b527 3066 field_index++;
whismanoid 10:04022a61b527 3067 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[channel_index];
whismanoid 10:04022a61b527 3068 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[channel_index];
whismanoid 10:04022a61b527 3069 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[channel_index];
whismanoid 10:04022a61b527 3070 //
whismanoid 10:04022a61b527 3071 // WIP SampleRate_of_FILTER_CONV_START() MAX11410EMC-FW slow ODR 10Sps #262
whismanoid 10:04022a61b527 3072 // adjust the MAX11410.loop_limit value if the sample rate is set to a value slower than 20sps
whismanoid 10:04022a61b527 3073 // SampleRate_of_FILTER_CONV_START(uint8_t FILTER_RegValue, uint8_t CONV_START_RegValue)
whismanoid 10:04022a61b527 3074 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 3075 if (SampleRate < 20.0) {
whismanoid 10:04022a61b527 3076 g_MAX11410_device.loop_limit = 32767; // TODO: is this timeout long enough for the slow output data rates?
whismanoid 10:04022a61b527 3077 }
whismanoid 10:04022a61b527 3078 //
whismanoid 10:04022a61b527 3079 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 3080 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc3); // GP0 = 0
whismanoid 10:04022a61b527 3081 //
whismanoid 10:04022a61b527 3082 #if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 3083 // MAX11410 v_ctrl bipolar configuration or unipolar?
whismanoid 10:04022a61b527 3084 if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) {
whismanoid 10:04022a61b527 3085 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 3086 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = (MAX11410::MAX11410_AINN_SEL_enum_t)(channel_index^1);
whismanoid 10:04022a61b527 3087 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 3088 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 3089 }
whismanoid 10:04022a61b527 3090 else {
whismanoid 10:04022a61b527 3091 const MAX11410::MAX11410_AINP_SEL_enum_t ainp = (MAX11410::MAX11410_AINP_SEL_enum_t)(channel_index);
whismanoid 10:04022a61b527 3092 const MAX11410::MAX11410_AINN_SEL_enum_t ainn = MAX11410::AINN_SEL_1010_GND;
whismanoid 10:04022a61b527 3093 SPI_AIN_Voltage[channel_index] = g_MAX11410_device.Measure_Voltage(ainp, ainn);
whismanoid 10:04022a61b527 3094 // @post AINcode[ainp]: measurement result LSB code
whismanoid 10:04022a61b527 3095 }
whismanoid 10:04022a61b527 3096 #endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC
whismanoid 10:04022a61b527 3097 //
whismanoid 10:04022a61b527 3098 // diagnostic GPIO pulse on MAX11410 GP0 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 3099 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0100_dddd_xddd_GP0_CTRL, 0xc4); // GP0 = 1
whismanoid 10:04022a61b527 3100 //
whismanoid 10:04022a61b527 3101 }
whismanoid 10:04022a61b527 3102 // diagnostic GPIO pulse on MAX11410 GP1 pin (0xc3 = logic 0, 0xc4 = logic 1)
whismanoid 10:04022a61b527 3103 g_MAX11410_device.RegWrite(MAX11410::CMD_r000_0101_dddd_xddd_GP1_CTRL, 0xc4); // GP1 = 1
whismanoid 10:04022a61b527 3104 #else
whismanoid 5:aaf8b5f5fda1 3105 g_MAX11410_device.Read_All_Voltages();
whismanoid 10:04022a61b527 3106 #endif
whismanoid 10:04022a61b527 3107 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 3108 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 3109 // mbed
whismanoid 5:aaf8b5f5fda1 3110 // Platform board uses simple analog inputs
whismanoid 5:aaf8b5f5fda1 3111 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 5:aaf8b5f5fda1 3112 Platform_LSB[0] = analogIn0.read();
whismanoid 5:aaf8b5f5fda1 3113 Platform_LSB[1] = analogIn1.read();
whismanoid 5:aaf8b5f5fda1 3114 Platform_LSB[2] = analogIn2.read();
whismanoid 5:aaf8b5f5fda1 3115 Platform_LSB[3] = analogIn3.read();
whismanoid 5:aaf8b5f5fda1 3116 Platform_LSB[4] = analogIn4.read();
whismanoid 5:aaf8b5f5fda1 3117 Platform_LSB[5] = analogIn5.read();
whismanoid 10:04022a61b527 3118 #endif
whismanoid 10:04022a61b527 3119 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 5:aaf8b5f5fda1 3120 Platform_Voltage[0] = analogIn0.read() * adc_full_scale_voltage[0];
whismanoid 5:aaf8b5f5fda1 3121 Platform_Voltage[1] = analogIn1.read() * adc_full_scale_voltage[1];
whismanoid 5:aaf8b5f5fda1 3122 Platform_Voltage[2] = analogIn2.read() * adc_full_scale_voltage[2];
whismanoid 5:aaf8b5f5fda1 3123 Platform_Voltage[3] = analogIn3.read() * adc_full_scale_voltage[3];
whismanoid 5:aaf8b5f5fda1 3124 Platform_Voltage[4] = analogIn4.read() * adc_full_scale_voltage[4];
whismanoid 5:aaf8b5f5fda1 3125 Platform_Voltage[5] = analogIn5.read() * adc_full_scale_voltage[5];
whismanoid 5:aaf8b5f5fda1 3126 #endif
whismanoid 5:aaf8b5f5fda1 3127 #endif // defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 5:aaf8b5f5fda1 3128
whismanoid 5:aaf8b5f5fda1 3129 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 3130 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 3131 const uint32_t part_id_expect = 0x000F02;
whismanoid 5:aaf8b5f5fda1 3132 uint32_t part_id_readback;
whismanoid 5:aaf8b5f5fda1 3133 g_MAX11410_device.RegRead(MAX11410::CMD_r001_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xddd_PART_ID, &part_id_readback);
whismanoid 5:aaf8b5f5fda1 3134 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 3135 } // void Datalogger_AcquireRow()
whismanoid 5:aaf8b5f5fda1 3136
whismanoid 5:aaf8b5f5fda1 3137 //--------------------------------------------------
whismanoid 8:dffee7509bfb 3138 void Datalogger_PrintRow(CmdLine& cmdLine)
whismanoid 5:aaf8b5f5fda1 3139 {
whismanoid 5:aaf8b5f5fda1 3140 int field_index = 0;
whismanoid 5:aaf8b5f5fda1 3141 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 3142 for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 10:04022a61b527 3143 if (SPI_AIN_Enable_ch[channel_index] == SPI_AIN_Disable) {
whismanoid 5:aaf8b5f5fda1 3144 continue;
whismanoid 5:aaf8b5f5fda1 3145 }
whismanoid 5:aaf8b5f5fda1 3146 // comma between fields
whismanoid 5:aaf8b5f5fda1 3147 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 3148 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 3149 }
whismanoid 10:04022a61b527 3150 field_index++;
whismanoid 10:04022a61b527 3151 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 10:04022a61b527 3152 cmdLine.serial().printf("%d", g_MAX11410_device.AINcode[channel_index]);
whismanoid 10:04022a61b527 3153 }
whismanoid 10:04022a61b527 3154 if (SPI_AIN_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 10:04022a61b527 3155 // TODO: report Voltage instead of LSB
whismanoid 10:04022a61b527 3156 // Serial.print(SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 3157 static char strOutLineBuffer[16];
whismanoid 10:04022a61b527 3158 cmdLine.serial().printf("%6.6f", SPI_AIN_Voltage[channel_index]);
whismanoid 10:04022a61b527 3159 }
whismanoid 5:aaf8b5f5fda1 3160 }
whismanoid 5:aaf8b5f5fda1 3161 #if VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 3162 // PART_ID field: Device ID Validation
whismanoid 5:aaf8b5f5fda1 3163 if (part_id_readback != part_id_expect) {
whismanoid 5:aaf8b5f5fda1 3164 cmdLine.serial().printf(",\"FAIL\"");
whismanoid 9:45f98573eb6d 3165 need_reinit = true;
whismanoid 5:aaf8b5f5fda1 3166 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 3167 g_MAX11410_device.Init();
whismanoid 5:aaf8b5f5fda1 3168 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 5:aaf8b5f5fda1 3169 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 5:aaf8b5f5fda1 3170 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 5:aaf8b5f5fda1 3171 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 3172 }
whismanoid 5:aaf8b5f5fda1 3173 else {
whismanoid 5:aaf8b5f5fda1 3174 cmdLine.serial().printf(",\"OK\"");
whismanoid 5:aaf8b5f5fda1 3175 }
whismanoid 5:aaf8b5f5fda1 3176 #endif // VERIFY_PART_ID_IN_LOOP
whismanoid 5:aaf8b5f5fda1 3177 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 5:aaf8b5f5fda1 3178 #if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs
whismanoid 9:45f98573eb6d 3179 for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; channel_index++) {
whismanoid 9:45f98573eb6d 3180 if (Platform_Enable_ch[channel_index] == Platform_AIN_Disable) {
whismanoid 9:45f98573eb6d 3181 continue;
whismanoid 9:45f98573eb6d 3182 }
whismanoid 5:aaf8b5f5fda1 3183 // comma between fields
whismanoid 5:aaf8b5f5fda1 3184 if (field_index > 0) {
whismanoid 5:aaf8b5f5fda1 3185 cmdLine.serial().printf(",");
whismanoid 5:aaf8b5f5fda1 3186 }
whismanoid 9:45f98573eb6d 3187 field_index++;
whismanoid 9:45f98573eb6d 3188 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_LSB) {
whismanoid 5:aaf8b5f5fda1 3189 #if LOG_PLATFORM_ANALOG_IN_LSB
whismanoid 9:45f98573eb6d 3190 cmdLine.serial().printf("%u", Platform_LSB[channel_index]);
whismanoid 9:45f98573eb6d 3191 #endif
whismanoid 9:45f98573eb6d 3192 }
whismanoid 9:45f98573eb6d 3193 if (Platform_Enable_ch[channel_index] == Platform_AIN_Enable_Volt) {
whismanoid 9:45f98573eb6d 3194 #if LOG_PLATFORM_ANALOG_IN_VOLTS
whismanoid 11:2b8adc78618a 3195 // Datalog Volts omit V suffix from numbers #275
whismanoid 11:2b8adc78618a 3196 // because Excel graphs can't handle numbers that have a suffix.
whismanoid 11:2b8adc78618a 3197 cmdLine.serial().printf("%6.6f", Platform_Voltage[channel_index]);
whismanoid 9:45f98573eb6d 3198 #endif
whismanoid 9:45f98573eb6d 3199 }
whismanoid 5:aaf8b5f5fda1 3200 }
whismanoid 5:aaf8b5f5fda1 3201 #endif // defined(LOG_PLATFORM_AIN)
whismanoid 9:45f98573eb6d 3202 if (need_reinit) {
whismanoid 9:45f98573eb6d 3203 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 3204 if (g_MAX11410_device.Init() == 0) {
whismanoid 9:45f98573eb6d 3205 //~ cmdLine.serial().printf(",\"Init() failed\"");
whismanoid 9:45f98573eb6d 3206 } else {
whismanoid 9:45f98573eb6d 3207 //~ cmdLine.serial().printf(",\"Init() success\"");
whismanoid 9:45f98573eb6d 3208 #if USE_CUSTOM_REG_INIT // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 3209 // in Datalogger_PrintRow(), when part_id test fails,
whismanoid 9:45f98573eb6d 3210 // apply list of custom register writes after re-init
whismanoid 9:45f98573eb6d 3211 // custom_reg_init_addr[], custom_reg_init_data[], custom_reg_init_count
whismanoid 9:45f98573eb6d 3212 for (unsigned int index = 0; index < custom_reg_init_count; index++) {
whismanoid 9:45f98573eb6d 3213 uint8_t regAddress = custom_reg_init_addr[index];
whismanoid 9:45f98573eb6d 3214 uint32_t regData = custom_reg_init_data[index];
whismanoid 9:45f98573eb6d 3215 cmdLine.serial().printf("*%s=0x%06.6x", g_MAX11410_device.RegName(regAddress), regData);
whismanoid 9:45f98573eb6d 3216 g_MAX11410_device.RegWrite((MAX11410::MAX11410_CMD_enum_t)regAddress, regData);
whismanoid 9:45f98573eb6d 3217 }
whismanoid 9:45f98573eb6d 3218 #endif // USE_CUSTOM_REG_INIT
whismanoid 9:45f98573eb6d 3219 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 9:45f98573eb6d 3220 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 9:45f98573eb6d 3221 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 9:45f98573eb6d 3222 need_reinit = false;
whismanoid 9:45f98573eb6d 3223 }
whismanoid 9:45f98573eb6d 3224 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 3225 need_reinit = false;
whismanoid 9:45f98573eb6d 3226 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 9:45f98573eb6d 3227 }
whismanoid 5:aaf8b5f5fda1 3228 cmdLine.serial().printf("\r\n");
whismanoid 9:45f98573eb6d 3229 if (need_reinit) {
whismanoid 9:45f98573eb6d 3230 //~ delay(500); // platform_delay_ms 500ms timing delay function
whismanoid 9:45f98573eb6d 3231 }
whismanoid 5:aaf8b5f5fda1 3232 } // void Datalogger_PrintRow()
whismanoid 5:aaf8b5f5fda1 3233
whismanoid 0:cb44e2e9ec4c 3234 // example code main function
whismanoid 0:cb44e2e9ec4c 3235 int main()
whismanoid 0:cb44e2e9ec4c 3236 {
whismanoid 0:cb44e2e9ec4c 3237 // setup: put your setup code here, to run once
whismanoid 4:d9b05924ad4c 3238 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3239 // Configure serial ports
whismanoid 4:d9b05924ad4c 3240 cmdLine.clear();
whismanoid 4:d9b05924ad4c 3241 //~ cmdLine.serial().printf("\r\n cmdLine.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 3242 cmdLine.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 3243 //~ cmdLine.diagnostic_led_EOF = diagnostic_led_EOF;
whismanoid 4:d9b05924ad4c 3244 /// CmdLine::set_immediate_handler(char, functionPointer_void_void_on_immediate_0x21);
whismanoid 4:d9b05924ad4c 3245 //~ cmdLine.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 3246 //~ cmdLine.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 3247 //~ cmdLine.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 3248 # if HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3249 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3250 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 3251 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 3252 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 3253 # if HAS_AUX_SERIAL
whismanoid 10:04022a61b527 3254 # else
whismanoid 10:04022a61b527 3255 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 3256 DAPLINKserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 3257 # endif
whismanoid 10:04022a61b527 3258 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 3259 cmdLine_DAPLINKserial.clear();
whismanoid 4:d9b05924ad4c 3260 //~ cmdLine_DAPLINKserial.serial().printf("\r\n cmdLine_DAPLINKserial.serial().printf test\r\n");
whismanoid 4:d9b05924ad4c 3261 cmdLine_DAPLINKserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 4:d9b05924ad4c 3262 //~ cmdLine_DAPLINKserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 4:d9b05924ad4c 3263 //~ cmdLine_DAPLINKserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 4:d9b05924ad4c 3264 //~ cmdLine_DAPLINKserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 4:d9b05924ad4c 3265 # endif
whismanoid 6:f6d16658342b 3266 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 3267 // TX/RX auxiliary UART port cmdLine_AUXserial AUXserial
whismanoid 10:04022a61b527 3268 #if 0 // HARD CRASH -- USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3269 // Command forwarding to AUX serial TX/RX cmdLine_AUXserial #257 -- init aux baud rate g_auxSerialCom_baud
whismanoid 10:04022a61b527 3270 // TODO: if g_auxSerialCom_baud is other than the default 9600 baud,
whismanoid 10:04022a61b527 3271 // then the auxiliary serial port baud rate should be updated.
whismanoid 10:04022a61b527 3272 AUXserial.baud(g_auxSerialCom_baud);
whismanoid 10:04022a61b527 3273 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 6:f6d16658342b 3274 cmdLine_AUXserial.clear();
whismanoid 6:f6d16658342b 3275 //~ cmdLine_AUXserial.serial().printf("\r\n cmdLine_AUXserial.serial().printf test\r\n");
whismanoid 6:f6d16658342b 3276 cmdLine_AUXserial.onEOLcommandParser = main_menu_onEOLcommandParser;
whismanoid 6:f6d16658342b 3277 //~ cmdLine_AUXserial.on_immediate_0x21 = on_immediate_0x21;
whismanoid 6:f6d16658342b 3278 //~ cmdLine_AUXserial.on_immediate_0x7b = on_immediate_0x7b;
whismanoid 6:f6d16658342b 3279 //~ cmdLine_AUXserial.on_immediate_0x7d = on_immediate_0x7d;
whismanoid 6:f6d16658342b 3280 # endif // HAS_AUX_SERIAL
whismanoid 4:d9b05924ad4c 3281 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 0:cb44e2e9ec4c 3282
whismanoid 0:cb44e2e9ec4c 3283 // example code: serial port banner message
whismanoid 0:cb44e2e9ec4c 3284 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 3285 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 3286 cmdLine.serial().printf("\r\nDataLogger_MAX11410\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 3287 #else // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3288 cmdLine.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 3289 # if HAS_DAPLINK_SERIAL
whismanoid 3:9055e17e181a 3290 cmdLine_DAPLINKserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 3:9055e17e181a 3291 # endif // HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 3292 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 3293 cmdLine_AUXserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410
whismanoid 6:f6d16658342b 3294 # endif // HAS_AUX_SERIAL
whismanoid 3:9055e17e181a 3295 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 10:04022a61b527 3296
whismanoid 1:747f1602abfc 3297 // CODE GENERATOR: get spi properties from device
whismanoid 3:9055e17e181a 3298 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 3299 if (g_SPI_SCLK_Hz > g_MAX11410_device.get_spi_frequency())
whismanoid 3:9055e17e181a 3300 { // Device limits SPI SCLK frequency
whismanoid 3:9055e17e181a 3301 g_SPI_SCLK_Hz = g_MAX11410_device.get_spi_frequency();
whismanoid 3:9055e17e181a 3302 cmdLine.serial().printf("\r\nMAX11410 limits SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 3303
whismanoid 3:9055e17e181a 3304 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 3305 }
whismanoid 3:9055e17e181a 3306 if (g_MAX11410_device.get_spi_frequency() > g_SPI_SCLK_Hz)
whismanoid 3:9055e17e181a 3307 { // Platform limits SPI SCLK frequency
whismanoid 3:9055e17e181a 3308 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 3309 cmdLine.serial().printf("\r\nPlatform limits MAX11410 SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz);
whismanoid 3:9055e17e181a 3310
whismanoid 3:9055e17e181a 3311 g_MAX11410_device.Init();
whismanoid 3:9055e17e181a 3312 }
whismanoid 0:cb44e2e9ec4c 3313 // g_SPI_dataMode = g_MAX11410_device.get_spi_dataMode();
whismanoid 3:9055e17e181a 3314 while (g_MAX11410_device.Init() == 0)
whismanoid 3:9055e17e181a 3315 {
whismanoid 3:9055e17e181a 3316 wait(3); // 3000ms timing delay function, platform-specific
whismanoid 3:9055e17e181a 3317 cmdLine.serial().printf("\r\nMAX11410 Init failed; retry...\r\n");
whismanoid 3:9055e17e181a 3318
whismanoid 3:9055e17e181a 3319 }
whismanoid 0:cb44e2e9ec4c 3320
whismanoid 0:cb44e2e9ec4c 3321 // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ----------
whismanoid 3:9055e17e181a 3322 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 3323 g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0];
whismanoid 3:9055e17e181a 3324 g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0];
whismanoid 3:9055e17e181a 3325 g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0];
whismanoid 3:9055e17e181a 3326 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3327 // ---------- CUSTOMIZED from MAX11410_Hello ----------
whismanoid 3:9055e17e181a 3328 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3329 // CODE GENERATOR: example code: has no member function REF
whismanoid 0:cb44e2e9ec4c 3330 // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line
whismanoid 0:cb44e2e9ec4c 3331 // CODE GENERATOR: ResolutionBits = 24
whismanoid 0:cb44e2e9ec4c 3332 // CODE GENERATOR: FScode = 0xffffff
whismanoid 0:cb44e2e9ec4c 3333 // CODE GENERATOR: NumChannels = 10
whismanoid 0:cb44e2e9ec4c 3334 // CODE GENERATOR: banner before DataLogHelloCppCodeList while(1)
whismanoid 3:9055e17e181a 3335 #if defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 3:9055e17e181a 3336 cmdLine.serial().printf("v_filter = 0x%2.2x\r\n", g_MAX11410_device.v_filter);
whismanoid 0:cb44e2e9ec4c 3337
whismanoid 3:9055e17e181a 3338 cmdLine.serial().printf("v_pga = 0x%2.2x\r\n", g_MAX11410_device.v_pga);
whismanoid 0:cb44e2e9ec4c 3339
whismanoid 3:9055e17e181a 3340 cmdLine.serial().printf("v_ctrl = 0x%2.2x\r\n", g_MAX11410_device.v_ctrl);
whismanoid 3:9055e17e181a 3341
whismanoid 3:9055e17e181a 3342 #endif // defined(SPI_ADC_DeviceName) // SPI connected ADC
whismanoid 0:cb44e2e9ec4c 3343
whismanoid 3:9055e17e181a 3344 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 3345 Datalogger_Need_PrintHeader = true;
whismanoid 10:04022a61b527 3346
whismanoid 12:2dfc1f2009e0 3347 #if USE_LEDS
whismanoid 12:2dfc1f2009e0 3348 #if defined(TARGET_MAX32630)
whismanoid 12:2dfc1f2009e0 3349 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 3350 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3351 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 3352 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3353 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 3354 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3355 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 3356 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3357 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 3358 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3359 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 3360 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3361 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 3362 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3363 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 3364 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3365 #elif defined(TARGET_MAX32625MBED) || defined(TARGET_MAX32625PICO)
whismanoid 12:2dfc1f2009e0 3366 led1 = LED_ON; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led RED
whismanoid 12:2dfc1f2009e0 3367 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3368 led1 = LED_OFF; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led GREEN
whismanoid 12:2dfc1f2009e0 3369 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3370 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 12:2dfc1f2009e0 3371 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3372 led1 = LED_ON; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led RED+GREEN+BLUE=WHITE
whismanoid 12:2dfc1f2009e0 3373 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3374 led1 = LED_OFF; led2 = LED_ON; led3 = LED_ON; // diagnostic rbg led GREEN+BLUE=CYAN
whismanoid 12:2dfc1f2009e0 3375 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3376 led1 = LED_ON; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led RED+BLUE=MAGENTA
whismanoid 12:2dfc1f2009e0 3377 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3378 led1 = LED_ON; led2 = LED_ON; led3 = LED_OFF; // diagnostic rbg led RED+GREEN=YELLOW
whismanoid 12:2dfc1f2009e0 3379 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3380 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_OFF; // diagnostic rbg led BLACK
whismanoid 12:2dfc1f2009e0 3381 ThisThread::sleep_for(125); // [since mbed-os-5.10] vs Thread::wait(125);
whismanoid 12:2dfc1f2009e0 3382 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 12:2dfc1f2009e0 3383 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 3384 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 3385 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 3386 led4 = LED_OFF;
whismanoid 12:2dfc1f2009e0 3387 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 3388 //led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 3389 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 3390 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 3391 led1 = LED_OFF;
whismanoid 12:2dfc1f2009e0 3392 //led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 3393 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 3394 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 3395 led2 = LED_OFF;
whismanoid 12:2dfc1f2009e0 3396 //led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 3397 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 3398 ThisThread::sleep_for(75); // [since mbed-os-5.10] vs Thread::wait(75);
whismanoid 12:2dfc1f2009e0 3399 led3 = LED_OFF;
whismanoid 12:2dfc1f2009e0 3400 led4 = LED_ON;
whismanoid 12:2dfc1f2009e0 3401 //
whismanoid 12:2dfc1f2009e0 3402 #endif // target definition
whismanoid 12:2dfc1f2009e0 3403 #endif
whismanoid 12:2dfc1f2009e0 3404
whismanoid 12:2dfc1f2009e0 3405 if (led1.is_connected()) {
whismanoid 12:2dfc1f2009e0 3406 led1 = LED_ON;
whismanoid 12:2dfc1f2009e0 3407 }
whismanoid 12:2dfc1f2009e0 3408 if (led2.is_connected()) {
whismanoid 12:2dfc1f2009e0 3409 led2 = LED_ON;
whismanoid 12:2dfc1f2009e0 3410 }
whismanoid 12:2dfc1f2009e0 3411 if (led3.is_connected()) {
whismanoid 12:2dfc1f2009e0 3412 led3 = LED_ON;
whismanoid 12:2dfc1f2009e0 3413 }
whismanoid 12:2dfc1f2009e0 3414
whismanoid 4:d9b05924ad4c 3415 while(1) { // this code repeats forever
whismanoid 4:d9b05924ad4c 3416 // this code repeats forever
whismanoid 4:d9b05924ad4c 3417
whismanoid 4:d9b05924ad4c 3418 #if USE_CMDLINE_MENUS // support CmdLine command menus
whismanoid 4:d9b05924ad4c 3419 // TODO support CmdLine command menus (like on Serial_Tester); help and usual boilerplate
whismanoid 10:04022a61b527 3420 #if USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3421 // Command forwarding to Auxiliary serial port;
whismanoid 10:04022a61b527 3422 // don't accept commands from Auxiliary serial port
whismanoid 10:04022a61b527 3423 #else // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 10:04022a61b527 3424 // Accept commands from Auxiliary serial port
whismanoid 6:f6d16658342b 3425 # if HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 3426 if (AUXserial.readable()) {
whismanoid 6:f6d16658342b 3427 cmdLine_AUXserial.append(AUXserial.getc());
whismanoid 6:f6d16658342b 3428 }
whismanoid 6:f6d16658342b 3429 # endif // HAS_AUX_SERIAL
whismanoid 6:f6d16658342b 3430 # if HAS_DAPLINK_SERIAL
whismanoid 6:f6d16658342b 3431 if (DAPLINKserial.readable()) {
whismanoid 6:f6d16658342b 3432 cmdLine_DAPLINKserial.append(DAPLINKserial.getc());
whismanoid 6:f6d16658342b 3433 }
whismanoid 6:f6d16658342b 3434 # endif // HAS_DAPLINK_SERIAL
whismanoid 10:04022a61b527 3435 #endif // USE_AUX_SERIAL_CMD_FORWARDING
whismanoid 4:d9b05924ad4c 3436 if (serial.readable()) {
whismanoid 4:d9b05924ad4c 3437 int c = serial.getc(); // instead of getc() or fgetc()
whismanoid 4:d9b05924ad4c 3438 cmdLine.append(c);
whismanoid 4:d9b05924ad4c 3439 // cmdLine.onEOLcommandParser handler implements menus
whismanoid 4:d9b05924ad4c 3440 } // if (Serial.available())
whismanoid 4:d9b05924ad4c 3441 #endif // USE_CMDLINE_MENUS support CmdLine command menus
whismanoid 4:d9b05924ad4c 3442
whismanoid 4:d9b05924ad4c 3443 #if USE_DATALOGGER_TRIGGER // support Datalog trigger
whismanoid 4:d9b05924ad4c 3444 // TODO Datalog trigger
whismanoid 4:d9b05924ad4c 3445 if (Datalogger_Trigger == trigger_Halt) {
whismanoid 4:d9b05924ad4c 3446 // halt the datalogger; continue accepting commands
whismanoid 3:9055e17e181a 3447 continue;
whismanoid 3:9055e17e181a 3448 }
whismanoid 4:d9b05924ad4c 3449 if (Datalogger_Trigger == trigger_FreeRun) {
whismanoid 4:d9b05924ad4c 3450 // free run as fast as possible
whismanoid 3:9055e17e181a 3451 }
whismanoid 4:d9b05924ad4c 3452 if (Datalogger_Trigger == trigger_Timer) {
whismanoid 4:d9b05924ad4c 3453 // timer (configure interval)
whismanoid 3:9055e17e181a 3454 }
whismanoid 4:d9b05924ad4c 3455 if (Datalogger_Trigger == trigger_PlatformDigitalInput) {
whismanoid 4:d9b05924ad4c 3456 // platform digital input (configure digital input pin reference)
whismanoid 3:9055e17e181a 3457 }
whismanoid 4:d9b05924ad4c 3458 if (Datalogger_Trigger == trigger_SPIDeviceRegRead) {
whismanoid 4:d9b05924ad4c 3459 // SPI device register read (configure regaddr, mask value, match value)
whismanoid 4:d9b05924ad4c 3460 }
whismanoid 4:d9b05924ad4c 3461 #endif // USE_DATALOGGER_TRIGGER support Datalog trigger
whismanoid 0:cb44e2e9ec4c 3462
whismanoid 8:dffee7509bfb 3463 // column header banner for csv data columns
whismanoid 8:dffee7509bfb 3464 if (Datalogger_Need_PrintHeader) {
whismanoid 8:dffee7509bfb 3465 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 3466 Datalogger_PrintHeader(cmdLine);
whismanoid 8:dffee7509bfb 3467 }
whismanoid 8:dffee7509bfb 3468 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3469 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 3470 Datalogger_PrintHeader(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 3471 }
whismanoid 8:dffee7509bfb 3472 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3473 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3474 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 3475 Datalogger_PrintHeader(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 3476 }
whismanoid 8:dffee7509bfb 3477 # endif // HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3478 Datalogger_Need_PrintHeader = false;
whismanoid 8:dffee7509bfb 3479 }
whismanoid 5:aaf8b5f5fda1 3480 Datalogger_AcquireRow();
whismanoid 0:cb44e2e9ec4c 3481 // wait(3.0);
whismanoid 0:cb44e2e9ec4c 3482 // CODE GENERATOR: print conversion result
whismanoid 0:cb44e2e9ec4c 3483 // Use Arduino Serial Plotter to view output: Tools | Serial Plotter
whismanoid 8:dffee7509bfb 3484 if (Datalogger_enable_serial) {
whismanoid 8:dffee7509bfb 3485 Datalogger_PrintRow(cmdLine);
whismanoid 8:dffee7509bfb 3486 }
whismanoid 8:dffee7509bfb 3487 # if HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3488 if (Datalogger_enable_AUXserial) {
whismanoid 8:dffee7509bfb 3489 Datalogger_PrintRow(cmdLine_AUXserial);
whismanoid 8:dffee7509bfb 3490 }
whismanoid 8:dffee7509bfb 3491 # endif // HAS_AUX_SERIAL
whismanoid 8:dffee7509bfb 3492 # if HAS_DAPLINK_SERIAL
whismanoid 8:dffee7509bfb 3493 if (Datalogger_enable_DAPLINKserial) {
whismanoid 8:dffee7509bfb 3494 Datalogger_PrintRow(cmdLine_DAPLINKserial);
whismanoid 8:dffee7509bfb 3495 }
whismanoid 8:dffee7509bfb 3496 # endif // HAS_DAPLINK_SERIAL
whismanoid 0:cb44e2e9ec4c 3497
whismanoid 0:cb44e2e9ec4c 3498 } // this code repeats forever
whismanoid 0:cb44e2e9ec4c 3499 }
whismanoid 0:cb44e2e9ec4c 3500 //---------- CODE GENERATOR: end DataLogHelloCppCodeList