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:
Wed Apr 14 01:37:08 2021 -0700
Revision:
16:819c5aaf5271
Parent:
15:37c83ec50ea0
Child:
17:9397ea3ea7e9
MAX40108_u9 banner message

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