Test program running on MAX32625MBED. Control through USB Serial commands using a terminal emulator such as teraterm or putty.

Dependencies:   MaximTinyTester CmdLine MAX5171 USBDevice

Committer:
whismanoid
Date:
Thu Mar 12 23:37:48 2020 +0000
Revision:
22:a14c19b97d0b
Child:
23:abd02fed1ae4
replace main.cpp monster with Test_Main_MAX5171

Who changed what in which revision?

UserRevisionLine numberNew contents of line
whismanoid 22:a14c19b97d0b 1 // /*******************************************************************************
whismanoid 22:a14c19b97d0b 2 // * Copyright (C) 2020 Maxim Integrated Products, Inc., All Rights Reserved.
whismanoid 22:a14c19b97d0b 3 // *
whismanoid 22:a14c19b97d0b 4 // * Permission is hereby granted, free of charge, to any person obtaining a
whismanoid 22:a14c19b97d0b 5 // * copy of this software and associated documentation files (the "Software"),
whismanoid 22:a14c19b97d0b 6 // * to deal in the Software without restriction, including without limitation
whismanoid 22:a14c19b97d0b 7 // * the rights to use, copy, modify, merge, publish, distribute, sublicense,
whismanoid 22:a14c19b97d0b 8 // * and/or sell copies of the Software, and to permit persons to whom the
whismanoid 22:a14c19b97d0b 9 // * Software is furnished to do so, subject to the following conditions:
whismanoid 22:a14c19b97d0b 10 // *
whismanoid 22:a14c19b97d0b 11 // * The above copyright notice and this permission notice shall be included
whismanoid 22:a14c19b97d0b 12 // * in all copies or substantial portions of the Software.
whismanoid 22:a14c19b97d0b 13 // *
whismanoid 22:a14c19b97d0b 14 // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
whismanoid 22:a14c19b97d0b 15 // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
whismanoid 22:a14c19b97d0b 16 // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
whismanoid 22:a14c19b97d0b 17 // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
whismanoid 22:a14c19b97d0b 18 // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
whismanoid 22:a14c19b97d0b 19 // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
whismanoid 22:a14c19b97d0b 20 // * OTHER DEALINGS IN THE SOFTWARE.
whismanoid 22:a14c19b97d0b 21 // *
whismanoid 22:a14c19b97d0b 22 // * Except as contained in this notice, the name of Maxim Integrated
whismanoid 22:a14c19b97d0b 23 // * Products, Inc. shall not be used except as stated in the Maxim Integrated
whismanoid 22:a14c19b97d0b 24 // * Products, Inc. Branding Policy.
whismanoid 22:a14c19b97d0b 25 // *
whismanoid 22:a14c19b97d0b 26 // * The mere transfer of this software does not imply any licenses
whismanoid 22:a14c19b97d0b 27 // * of trade secrets, proprietary technology, copyrights, patents,
whismanoid 22:a14c19b97d0b 28 // * trademarks, maskwork rights, or any other form of intellectual
whismanoid 22:a14c19b97d0b 29 // * property whatsoever. Maxim Integrated Products, Inc. retains all
whismanoid 22:a14c19b97d0b 30 // * ownership rights.
whismanoid 22:a14c19b97d0b 31 // *******************************************************************************
whismanoid 22:a14c19b97d0b 32 // */
whismanoid 22:a14c19b97d0b 33 // example code includes
whismanoid 22:a14c19b97d0b 34 // standard include for target platform -- Platform_Include_Boilerplate
whismanoid 22:a14c19b97d0b 35 #include "mbed.h"
whismanoid 22:a14c19b97d0b 36 // Platforms:
whismanoid 22:a14c19b97d0b 37 // - MAX32625MBED
whismanoid 22:a14c19b97d0b 38 // - supports mbed-os-5.11, requires USBDevice library
whismanoid 22:a14c19b97d0b 39 // - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
whismanoid 22:a14c19b97d0b 40 // - remove max32630fthr library (if present)
whismanoid 22:a14c19b97d0b 41 // - remove MAX32620FTHR library (if present)
whismanoid 22:a14c19b97d0b 42 // - MAX32600MBED
whismanoid 22:a14c19b97d0b 43 // - remove max32630fthr library (if present)
whismanoid 22:a14c19b97d0b 44 // - remove MAX32620FTHR library (if present)
whismanoid 22:a14c19b97d0b 45 // - Windows 10 note: Don't connect HDK until you are ready to load new firmware into the board.
whismanoid 22:a14c19b97d0b 46 // - NUCLEO_F446RE
whismanoid 22:a14c19b97d0b 47 // - remove USBDevice library
whismanoid 22:a14c19b97d0b 48 // - remove max32630fthr library (if present)
whismanoid 22:a14c19b97d0b 49 // - remove MAX32620FTHR library (if present)
whismanoid 22:a14c19b97d0b 50 // - NUCLEO_F401RE
whismanoid 22:a14c19b97d0b 51 // - remove USBDevice library
whismanoid 22:a14c19b97d0b 52 // - remove max32630fthr library (if present)
whismanoid 22:a14c19b97d0b 53 // - remove MAX32620FTHR library (if present)
whismanoid 22:a14c19b97d0b 54 // - MAX32630FTHR
whismanoid 22:a14c19b97d0b 55 // - #include "max32630fthr.h"
whismanoid 22:a14c19b97d0b 56 // - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/
whismanoid 22:a14c19b97d0b 57 // - remove MAX32620FTHR library (if present)
whismanoid 22:a14c19b97d0b 58 // - MAX32620FTHR
whismanoid 22:a14c19b97d0b 59 // - #include "MAX32620FTHR.h"
whismanoid 22:a14c19b97d0b 60 // - remove max32630fthr library (if present)
whismanoid 22:a14c19b97d0b 61 // - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
whismanoid 22:a14c19b97d0b 62 // - not tested yet
whismanoid 22:a14c19b97d0b 63 // - MAX32625PICO
whismanoid 22:a14c19b97d0b 64 // - remove max32630fthr library (if present)
whismanoid 22:a14c19b97d0b 65 // - remove MAX32620FTHR library (if present)
whismanoid 22:a14c19b97d0b 66 // - not tested yet
whismanoid 22:a14c19b97d0b 67 //
whismanoid 22:a14c19b97d0b 68 // end Platform_Include_Boilerplate
whismanoid 22:a14c19b97d0b 69 #include "MAX5171.h"
whismanoid 22:a14c19b97d0b 70 #include "CmdLine.h"
whismanoid 22:a14c19b97d0b 71 #include "MaximTinyTester.h"
whismanoid 22:a14c19b97d0b 72
whismanoid 22:a14c19b97d0b 73 // optional: serial port
whismanoid 22:a14c19b97d0b 74 // note: some platforms such as Nucleo-F446RE do not support the USBSerial library.
whismanoid 22:a14c19b97d0b 75 // In those cases, remove the USBDevice lib from the project and rebuild.
whismanoid 22:a14c19b97d0b 76 #if defined(TARGET_MAX32625MBED)
whismanoid 22:a14c19b97d0b 77 #include "USBSerial.h"
whismanoid 22:a14c19b97d0b 78 USBSerial serial; // virtual serial port over USB (DEV connector)
whismanoid 22:a14c19b97d0b 79 #elif defined(TARGET_MAX32630MBED)
whismanoid 22:a14c19b97d0b 80 #include "USBSerial.h"
whismanoid 22:a14c19b97d0b 81 USBSerial serial; // virtual serial port over USB (DEV connector)
whismanoid 22:a14c19b97d0b 82 #else
whismanoid 22:a14c19b97d0b 83 //#include "USBSerial.h"
whismanoid 22:a14c19b97d0b 84 Serial serial(USBTX, USBRX); // tx, rx
whismanoid 22:a14c19b97d0b 85 #endif
whismanoid 22:a14c19b97d0b 86
whismanoid 22:a14c19b97d0b 87 void on_immediate_0x21(); // Unicode (U+0021) ! EXCLAMATION MARK
whismanoid 22:a14c19b97d0b 88 void on_immediate_0x7b(); // Unicode (U+007B) { LEFT CURLY BRACKET
whismanoid 22:a14c19b97d0b 89 void on_immediate_0x7d(); // Unicode (U+007D) } RIGHT CURLY BRACKET
whismanoid 22:a14c19b97d0b 90
whismanoid 22:a14c19b97d0b 91 #include "CmdLine.h"
whismanoid 22:a14c19b97d0b 92
whismanoid 22:a14c19b97d0b 93 # if HAS_DAPLINK_SERIAL
whismanoid 22:a14c19b97d0b 94 CmdLine cmdLine_DAPLINKserial(DAPLINKserial, "DAPLINK");
whismanoid 22:a14c19b97d0b 95 # endif // HAS_DAPLINK_SERIAL
whismanoid 22:a14c19b97d0b 96 CmdLine cmdLine_serial(serial, "serial");
whismanoid 22:a14c19b97d0b 97
whismanoid 22:a14c19b97d0b 98
whismanoid 22:a14c19b97d0b 99 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 100
whismanoid 22:a14c19b97d0b 101
whismanoid 22:a14c19b97d0b 102 #if defined(TARGET)
whismanoid 22:a14c19b97d0b 103 // TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h
whismanoid 22:a14c19b97d0b 104 // Create a string definition for the TARGET
whismanoid 22:a14c19b97d0b 105 #define STRING_ARG(arg) #arg
whismanoid 22:a14c19b97d0b 106 #define STRING_NAME(name) STRING_ARG(name)
whismanoid 22:a14c19b97d0b 107 #define TARGET_NAME STRING_NAME(TARGET)
whismanoid 22:a14c19b97d0b 108 #elif defined(TARGET_MAX32600)
whismanoid 22:a14c19b97d0b 109 #define TARGET_NAME "MAX32600"
whismanoid 22:a14c19b97d0b 110 #elif defined(TARGET_LPC1768)
whismanoid 22:a14c19b97d0b 111 #define TARGET_NAME "LPC1768"
whismanoid 22:a14c19b97d0b 112 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 22:a14c19b97d0b 113 #define TARGET_NAME "NUCLEO_F446RE"
whismanoid 22:a14c19b97d0b 114 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 22:a14c19b97d0b 115 #define TARGET_NAME "NUCLEO_F401RE"
whismanoid 22:a14c19b97d0b 116 #else
whismanoid 22:a14c19b97d0b 117 #error TARGET NOT DEFINED
whismanoid 22:a14c19b97d0b 118 #endif
whismanoid 22:a14c19b97d0b 119 #if defined(TARGET_MAX32630)
whismanoid 22:a14c19b97d0b 120 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 121 // TARGET=MAX32630FTHR ARM Cortex-M4F 96MHz 2048kB Flash 512kB SRAM
whismanoid 22:a14c19b97d0b 122 // +-------------[microUSB]-------------+
whismanoid 22:a14c19b97d0b 123 // | J1 MAX32630FTHR J2 |
whismanoid 22:a14c19b97d0b 124 // ______ | [ ] RST GND [ ] |
whismanoid 22:a14c19b97d0b 125 // ______ | [ ] 3V3 BAT+[ ] |
whismanoid 22:a14c19b97d0b 126 // ______ | [ ] 1V8 reset SW1 |
whismanoid 22:a14c19b97d0b 127 // ______ | [ ] GND J4 J3 |
whismanoid 22:a14c19b97d0b 128 // analogIn0/4 | [a] AIN_0 1.2Vfs (bat) SYS [ ] | switched BAT+
whismanoid 22:a14c19b97d0b 129 // analogIn1/5 | [a] AIN_1 1.2Vfs PWR [ ] | external pwr btn
whismanoid 22:a14c19b97d0b 130 // analogIn2 | [a] AIN_2 1.2Vfs +5V VBUS [ ] | USB +5V power
whismanoid 22:a14c19b97d0b 131 // analogIn3 | [a] AIN_3 1.2Vfs 1-WIRE P4_0 [d] | D0 dig9
whismanoid 22:a14c19b97d0b 132 // (I2C2.SDA) | [d] P5_7 SDA2 SRN P5_6 [d] | D1 dig8
whismanoid 22:a14c19b97d0b 133 // (I2C2.SCL) | [d] P6_0 SCL2 SDIO3 P5_5 [d] | D2 dig7
whismanoid 22:a14c19b97d0b 134 // D13/SCLK | [s] P5_0 SCLK SDIO2 P5_4 [d] | D3 dig6
whismanoid 22:a14c19b97d0b 135 // D11/MOSI | [s] P5_1 MOSI SSEL P5_3 [d] | D4 dig5
whismanoid 22:a14c19b97d0b 136 // D12/MISO | [s] P5_2 MISO RTS P3_3 [d] | D5 dig4
whismanoid 22:a14c19b97d0b 137 // D10/CS | [s] P3_0 RX CTS P3_2 [d] | D6 dig3
whismanoid 22:a14c19b97d0b 138 // D9 dig0 | [d] P3_1 TX SCL P3_5 [d] | D7 dig2
whismanoid 22:a14c19b97d0b 139 // ______ | [ ] GND SDA P3_4 [d] | D8 dig1
whismanoid 22:a14c19b97d0b 140 // | |
whismanoid 22:a14c19b97d0b 141 // | XIP Flash MAX14690N |
whismanoid 22:a14c19b97d0b 142 // | XIP_SCLK P1_0 SDA2 P5_7 |
whismanoid 22:a14c19b97d0b 143 // | XIP_MOSI P1_1 SCL2 P6_0 |
whismanoid 22:a14c19b97d0b 144 // | XIP_MISO P1_2 PMIC_INIT P3_7 |
whismanoid 22:a14c19b97d0b 145 // | XIP_SSEL P1_3 MPC P2_7 |
whismanoid 22:a14c19b97d0b 146 // | XIP_DIO2 P1_4 MON AIN_0 |
whismanoid 22:a14c19b97d0b 147 // | XIP_DIO3 P1_5 |
whismanoid 22:a14c19b97d0b 148 // | |
whismanoid 22:a14c19b97d0b 149 // | PAN1326B MicroSD LED |
whismanoid 22:a14c19b97d0b 150 // | BT_RX P0_0 SD_SCLK P0_4 r P2_4 |
whismanoid 22:a14c19b97d0b 151 // | BT_TX P0_1 SD_MOSI P0_5 g P2_5 |
whismanoid 22:a14c19b97d0b 152 // | BT_CTS P0_2 SD_MISO P0_6 b P2_6 |
whismanoid 22:a14c19b97d0b 153 // | BT_RTS P0_3 SD_SSEL P0_7 |
whismanoid 22:a14c19b97d0b 154 // | BT_RST P1_6 DETECT P2_2 |
whismanoid 22:a14c19b97d0b 155 // | BT_CLK P1_7 SW2 P2_3 |
whismanoid 22:a14c19b97d0b 156 // +------------------------------------+
whismanoid 22:a14c19b97d0b 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 22:a14c19b97d0b 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 22:a14c19b97d0b 159 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 160 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 161 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 162 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 163 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 164 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 165 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 166 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 22:a14c19b97d0b 167 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 22:a14c19b97d0b 168 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 22:a14c19b97d0b 169 // AIN_10 = x undefined?
whismanoid 22:a14c19b97d0b 170 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 171 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 172 //
whismanoid 22:a14c19b97d0b 173 #include "max32630fthr.h"
whismanoid 22:a14c19b97d0b 174 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 22:a14c19b97d0b 175 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 22:a14c19b97d0b 176 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 22:a14c19b97d0b 177 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 22:a14c19b97d0b 178 // Arduino connector
whismanoid 22:a14c19b97d0b 179 #ifndef A0
whismanoid 22:a14c19b97d0b 180 #define A0 AIN_0
whismanoid 22:a14c19b97d0b 181 #endif
whismanoid 22:a14c19b97d0b 182 #ifndef A1
whismanoid 22:a14c19b97d0b 183 #define A1 AIN_1
whismanoid 22:a14c19b97d0b 184 #endif
whismanoid 22:a14c19b97d0b 185 #ifndef A2
whismanoid 22:a14c19b97d0b 186 #define A2 AIN_2
whismanoid 22:a14c19b97d0b 187 #endif
whismanoid 22:a14c19b97d0b 188 #ifndef A3
whismanoid 22:a14c19b97d0b 189 #define A3 AIN_3
whismanoid 22:a14c19b97d0b 190 #endif
whismanoid 22:a14c19b97d0b 191 #ifndef D0
whismanoid 22:a14c19b97d0b 192 #define D0 P4_0
whismanoid 22:a14c19b97d0b 193 #endif
whismanoid 22:a14c19b97d0b 194 #ifndef D1
whismanoid 22:a14c19b97d0b 195 #define D1 P5_6
whismanoid 22:a14c19b97d0b 196 #endif
whismanoid 22:a14c19b97d0b 197 #ifndef D2
whismanoid 22:a14c19b97d0b 198 #define D2 P5_5
whismanoid 22:a14c19b97d0b 199 #endif
whismanoid 22:a14c19b97d0b 200 #ifndef D3
whismanoid 22:a14c19b97d0b 201 #define D3 P5_4
whismanoid 22:a14c19b97d0b 202 #endif
whismanoid 22:a14c19b97d0b 203 #ifndef D4
whismanoid 22:a14c19b97d0b 204 #define D4 P5_3
whismanoid 22:a14c19b97d0b 205 #endif
whismanoid 22:a14c19b97d0b 206 #ifndef D5
whismanoid 22:a14c19b97d0b 207 #define D5 P3_3
whismanoid 22:a14c19b97d0b 208 #endif
whismanoid 22:a14c19b97d0b 209 #ifndef D6
whismanoid 22:a14c19b97d0b 210 #define D6 P3_2
whismanoid 22:a14c19b97d0b 211 #endif
whismanoid 22:a14c19b97d0b 212 #ifndef D7
whismanoid 22:a14c19b97d0b 213 #define D7 P3_5
whismanoid 22:a14c19b97d0b 214 #endif
whismanoid 22:a14c19b97d0b 215 #ifndef D8
whismanoid 22:a14c19b97d0b 216 #define D8 P3_4
whismanoid 22:a14c19b97d0b 217 #endif
whismanoid 22:a14c19b97d0b 218 #ifndef D9
whismanoid 22:a14c19b97d0b 219 #define D9 P3_1
whismanoid 22:a14c19b97d0b 220 #endif
whismanoid 22:a14c19b97d0b 221 #ifndef D10
whismanoid 22:a14c19b97d0b 222 #define D10 P3_0
whismanoid 22:a14c19b97d0b 223 #endif
whismanoid 22:a14c19b97d0b 224 #ifndef D11
whismanoid 22:a14c19b97d0b 225 #define D11 P5_1
whismanoid 22:a14c19b97d0b 226 #endif
whismanoid 22:a14c19b97d0b 227 #ifndef D12
whismanoid 22:a14c19b97d0b 228 #define D12 P5_2
whismanoid 22:a14c19b97d0b 229 #endif
whismanoid 22:a14c19b97d0b 230 #ifndef D13
whismanoid 22:a14c19b97d0b 231 #define D13 P5_0
whismanoid 22:a14c19b97d0b 232 #endif
whismanoid 22:a14c19b97d0b 233 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 234 #elif defined(TARGET_MAX32625MBED)
whismanoid 22:a14c19b97d0b 235 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 236 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 22:a14c19b97d0b 237 // +-------------------------------------+
whismanoid 22:a14c19b97d0b 238 // | MAX32625MBED Arduino UNO header |
whismanoid 22:a14c19b97d0b 239 // | |
whismanoid 22:a14c19b97d0b 240 // | A5/SCL[ ] | P1_7 dig15
whismanoid 22:a14c19b97d0b 241 // | A4/SDA[ ] | P1_6 dig14
whismanoid 22:a14c19b97d0b 242 // | AREF=N/C[ ] |
whismanoid 22:a14c19b97d0b 243 // | GND[ ] |
whismanoid 22:a14c19b97d0b 244 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 22:a14c19b97d0b 245 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 22:a14c19b97d0b 246 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 22:a14c19b97d0b 247 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 22:a14c19b97d0b 248 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 22:a14c19b97d0b 249 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 22:a14c19b97d0b 250 // | [ ]GND |
whismanoid 22:a14c19b97d0b 251 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 22:a14c19b97d0b 252 // | 6[ ]~| P0_6 dig6
whismanoid 22:a14c19b97d0b 253 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 22:a14c19b97d0b 254 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 22:a14c19b97d0b 255 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 22:a14c19b97d0b 256 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 22:a14c19b97d0b 257 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 22:a14c19b97d0b 258 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 22:a14c19b97d0b 259 // | [ ] [ ] [ ] |
whismanoid 22:a14c19b97d0b 260 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 22:a14c19b97d0b 261 // \_______________________/
whismanoid 22:a14c19b97d0b 262 //
whismanoid 22:a14c19b97d0b 263 // +------------------------+
whismanoid 22:a14c19b97d0b 264 // | |
whismanoid 22:a14c19b97d0b 265 // | MicroSD LED |
whismanoid 22:a14c19b97d0b 266 // | SD_SCLK P2_4 r P3_0 |
whismanoid 22:a14c19b97d0b 267 // | SD_MOSI P2_5 g P3_1 |
whismanoid 22:a14c19b97d0b 268 // | SD_MISO P2_6 b P3_2 |
whismanoid 22:a14c19b97d0b 269 // | SD_SSEL P2_7 y P3_3 |
whismanoid 22:a14c19b97d0b 270 // | |
whismanoid 22:a14c19b97d0b 271 // | DAPLINK BUTTONS |
whismanoid 22:a14c19b97d0b 272 // | TX P2_1 SW3 P2_3 |
whismanoid 22:a14c19b97d0b 273 // | RX P2_0 SW2 P2_2 |
whismanoid 22:a14c19b97d0b 274 // +------------------------+
whismanoid 22:a14c19b97d0b 275 //
whismanoid 22:a14c19b97d0b 276 // AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 277 // AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 278 // AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 279 // AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 280 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 281 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 282 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 283 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 22:a14c19b97d0b 284 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 22:a14c19b97d0b 285 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 22:a14c19b97d0b 286 // AIN_10 = x undefined?
whismanoid 22:a14c19b97d0b 287 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 288 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 289 //
whismanoid 22:a14c19b97d0b 290 //#include "max32625mbed.h" // ?
whismanoid 22:a14c19b97d0b 291 //MAX32625MBED mbed(MAX32625MBED::VIO_3V3); // ?
whismanoid 22:a14c19b97d0b 292 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 22:a14c19b97d0b 293 // MAX32630FTHR board supports only internal VREF = 1.200V at bypass capacitor C15
whismanoid 22:a14c19b97d0b 294 const float ADC_FULL_SCALE_VOLTAGE = 1.200; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 22:a14c19b97d0b 295 // Arduino connector
whismanoid 22:a14c19b97d0b 296 #ifndef A0
whismanoid 22:a14c19b97d0b 297 #define A0 AIN_0
whismanoid 22:a14c19b97d0b 298 #endif
whismanoid 22:a14c19b97d0b 299 #ifndef A1
whismanoid 22:a14c19b97d0b 300 #define A1 AIN_1
whismanoid 22:a14c19b97d0b 301 #endif
whismanoid 22:a14c19b97d0b 302 #ifndef A2
whismanoid 22:a14c19b97d0b 303 #define A2 AIN_2
whismanoid 22:a14c19b97d0b 304 #endif
whismanoid 22:a14c19b97d0b 305 #ifndef A3
whismanoid 22:a14c19b97d0b 306 #define A3 AIN_3
whismanoid 22:a14c19b97d0b 307 #endif
whismanoid 22:a14c19b97d0b 308 #ifndef D0
whismanoid 22:a14c19b97d0b 309 #define D0 P0_0
whismanoid 22:a14c19b97d0b 310 #endif
whismanoid 22:a14c19b97d0b 311 #ifndef D1
whismanoid 22:a14c19b97d0b 312 #define D1 P0_1
whismanoid 22:a14c19b97d0b 313 #endif
whismanoid 22:a14c19b97d0b 314 #ifndef D2
whismanoid 22:a14c19b97d0b 315 #define D2 P0_2
whismanoid 22:a14c19b97d0b 316 #endif
whismanoid 22:a14c19b97d0b 317 #ifndef D3
whismanoid 22:a14c19b97d0b 318 #define D3 P0_3
whismanoid 22:a14c19b97d0b 319 #endif
whismanoid 22:a14c19b97d0b 320 #ifndef D4
whismanoid 22:a14c19b97d0b 321 #define D4 P0_4
whismanoid 22:a14c19b97d0b 322 #endif
whismanoid 22:a14c19b97d0b 323 #ifndef D5
whismanoid 22:a14c19b97d0b 324 #define D5 P0_5
whismanoid 22:a14c19b97d0b 325 #endif
whismanoid 22:a14c19b97d0b 326 #ifndef D6
whismanoid 22:a14c19b97d0b 327 #define D6 P0_6
whismanoid 22:a14c19b97d0b 328 #endif
whismanoid 22:a14c19b97d0b 329 #ifndef D7
whismanoid 22:a14c19b97d0b 330 #define D7 P0_7
whismanoid 22:a14c19b97d0b 331 #endif
whismanoid 22:a14c19b97d0b 332 #ifndef D8
whismanoid 22:a14c19b97d0b 333 #define D8 P1_4
whismanoid 22:a14c19b97d0b 334 #endif
whismanoid 22:a14c19b97d0b 335 #ifndef D9
whismanoid 22:a14c19b97d0b 336 #define D9 P1_5
whismanoid 22:a14c19b97d0b 337 #endif
whismanoid 22:a14c19b97d0b 338 #ifndef D10
whismanoid 22:a14c19b97d0b 339 #define D10 P1_3
whismanoid 22:a14c19b97d0b 340 #endif
whismanoid 22:a14c19b97d0b 341 #ifndef D11
whismanoid 22:a14c19b97d0b 342 #define D11 P1_1
whismanoid 22:a14c19b97d0b 343 #endif
whismanoid 22:a14c19b97d0b 344 #ifndef D12
whismanoid 22:a14c19b97d0b 345 #define D12 P1_2
whismanoid 22:a14c19b97d0b 346 #endif
whismanoid 22:a14c19b97d0b 347 #ifndef D13
whismanoid 22:a14c19b97d0b 348 #define D13 P1_0
whismanoid 22:a14c19b97d0b 349 #endif
whismanoid 22:a14c19b97d0b 350 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 351 #elif defined(TARGET_MAX32600)
whismanoid 22:a14c19b97d0b 352 // target MAX32600
whismanoid 22:a14c19b97d0b 353 //
whismanoid 22:a14c19b97d0b 354 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 22:a14c19b97d0b 355 const float ADC_FULL_SCALE_VOLTAGE = 1.500;
whismanoid 22:a14c19b97d0b 356 //
whismanoid 22:a14c19b97d0b 357 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 358 #elif defined(TARGET_MAX32620FTHR)
whismanoid 22:a14c19b97d0b 359 #warning "TARGET_MAX32620FTHR not previously tested; need to define pins..."
whismanoid 22:a14c19b97d0b 360 #include "MAX32620FTHR.h"
whismanoid 22:a14c19b97d0b 361 // Initialize I/O voltages on MAX32620FTHR board
whismanoid 22:a14c19b97d0b 362 MAX32620FTHR fthr(MAX32620FTHR::VIO_3V3);
whismanoid 22:a14c19b97d0b 363 //#define USE_LEDS 0 ?
whismanoid 22:a14c19b97d0b 364 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 22:a14c19b97d0b 365 #warning "TARGET_MAX32620FTHR not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 22:a14c19b97d0b 366 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 22:a14c19b97d0b 367 //
whismanoid 22:a14c19b97d0b 368 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 369 #elif defined(TARGET_MAX32625PICO)
whismanoid 22:a14c19b97d0b 370 #warning "TARGET_MAX32625PICO not previously tested; need to define pins..."
whismanoid 22:a14c19b97d0b 371 //#define USE_LEDS 0 ?
whismanoid 22:a14c19b97d0b 372 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 1
whismanoid 22:a14c19b97d0b 373 #warning "TARGET_MAX32625PICO not previously tested; need to verify ADC_FULL_SCALE_VOLTAGE..."
whismanoid 22:a14c19b97d0b 374 const float ADC_FULL_SCALE_VOLTAGE = 1.200;
whismanoid 22:a14c19b97d0b 375 //
whismanoid 22:a14c19b97d0b 376 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 377 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 22:a14c19b97d0b 378 // TODO1: target NUCLEO_F446RE
whismanoid 22:a14c19b97d0b 379 //
whismanoid 22:a14c19b97d0b 380 // USER_BUTTON PC13
whismanoid 22:a14c19b97d0b 381 // LED1 is shared with SPI_SCK on NUCLEO_F446RE PA_5, so don't use LED1.
whismanoid 22:a14c19b97d0b 382 #define USE_LEDS 0
whismanoid 22:a14c19b97d0b 383 // SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
whismanoid 22:a14c19b97d0b 384 // Serial serial(SERIAL_TX, SERIAL_RX);
whismanoid 22:a14c19b97d0b 385 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 22:a14c19b97d0b 386 const float ADC_FULL_SCALE_VOLTAGE = 3.300; // TODO: ADC_FULL_SCALE_VOLTAGE Pico?
whismanoid 22:a14c19b97d0b 387 //
whismanoid 22:a14c19b97d0b 388 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 389 #elif defined(TARGET_LPC1768)
whismanoid 22:a14c19b97d0b 390 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 391 // TARGET=LPC1768 ARM Cortex-M3 100 MHz 512kB flash 64kB SRAM
whismanoid 22:a14c19b97d0b 392 // +-------------[microUSB]-------------+
whismanoid 22:a14c19b97d0b 393 // ______ | [ ] GND +3.3V VOUT [ ] | ______
whismanoid 22:a14c19b97d0b 394 // ______ | [ ] 4.5V<VIN<9.0V +5.0V VU [ ] | ______
whismanoid 22:a14c19b97d0b 395 // ______ | [ ] VB USB.IF- [ ] | ______
whismanoid 22:a14c19b97d0b 396 // ______ | [ ] nR USB.IF+ [ ] | ______
whismanoid 22:a14c19b97d0b 397 // digitalInOut0 | [ ] p5 MOSI ETHERNET.RD- [ ] | ______
whismanoid 22:a14c19b97d0b 398 // digitalInOut1 | [ ] p6 MISO ETHERNET.RD+ [ ] | ______
whismanoid 22:a14c19b97d0b 399 // digitalInOut2 | [ ] p7 SCLK ETHERNET.TD- [ ] | ______
whismanoid 22:a14c19b97d0b 400 // digitalInOut3 | [ ] p8 ETHERNET.TD+ [ ] | ______
whismanoid 22:a14c19b97d0b 401 // digitalInOut4 | [ ] p9 TX SDA USB.D- [ ] | ______
whismanoid 22:a14c19b97d0b 402 // digitalInOut5 | [ ] p10 RX SCL USB.D+ [ ] | ______
whismanoid 22:a14c19b97d0b 403 // digitalInOut6 | [ ] p11 MOSI CAN-RD p30 [ ] | digitalInOut13
whismanoid 22:a14c19b97d0b 404 // digitalInOut7 | [ ] p12 MISO CAN-TD p29 [ ] | digitalInOut12
whismanoid 22:a14c19b97d0b 405 // digitalInOut8 | [ ] p13 TX SCLK SDA TX p28 [ ] | digitalInOut11
whismanoid 22:a14c19b97d0b 406 // digitalInOut9 | [ ] p14 RX SCL RX p27 [ ] | digitalInOut10
whismanoid 22:a14c19b97d0b 407 // analogIn0 | [ ] p15 AIN0 3.3Vfs PWM1 p26 [ ] | pwmDriver1
whismanoid 22:a14c19b97d0b 408 // analogIn1 | [ ] p16 AIN1 3.3Vfs PWM2 p25 [ ] | pwmDriver2
whismanoid 22:a14c19b97d0b 409 // analogIn2 | [ ] p17 AIN2 3.3Vfs PWM3 p24 [ ] | pwmDriver3
whismanoid 22:a14c19b97d0b 410 // analogIn3 | [ ] p18 AIN3 AOUT PWM4 p23 [ ] | pwmDriver4
whismanoid 22:a14c19b97d0b 411 // analogIn4 | [ ] p19 AIN4 3.3Vfs PWM5 p22 [ ] | pwmDriver5
whismanoid 22:a14c19b97d0b 412 // analogIn5 | [ ] p20 AIN5 3.3Vfs PWM6 p21 [ ] | pwmDriver6
whismanoid 22:a14c19b97d0b 413 // +------------------------------------+
whismanoid 22:a14c19b97d0b 414 // AIN6 = P0.3 = TGT_SBL_RXD?
whismanoid 22:a14c19b97d0b 415 // AIN7 = P0.2 = TGT_SBL_TXD?
whismanoid 22:a14c19b97d0b 416 //
whismanoid 22:a14c19b97d0b 417 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 418 // LPC1768 board uses VREF = 3.300V +A3,3V thru L1 to bypass capacitor C14
whismanoid 22:a14c19b97d0b 419 #define analogIn4_IS_HIGH_RANGE_OF_analogIn0 0
whismanoid 22:a14c19b97d0b 420 const float ADC_FULL_SCALE_VOLTAGE = 3.300;
whismanoid 22:a14c19b97d0b 421 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 22:a14c19b97d0b 422 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 423 // unknown target
whismanoid 22:a14c19b97d0b 424 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 425 #endif // target definition
whismanoid 22:a14c19b97d0b 426
whismanoid 22:a14c19b97d0b 427
whismanoid 22:a14c19b97d0b 428 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 429 // Option to dedicate SPI port pins
whismanoid 22:a14c19b97d0b 430 //
whismanoid 22:a14c19b97d0b 431 // SPI2_MOSI = P5_1
whismanoid 22:a14c19b97d0b 432 // SPI2_MISO = P5_2
whismanoid 22:a14c19b97d0b 433 // SPI2_SCK = P5_0
whismanoid 22:a14c19b97d0b 434 // On this board I'm using P3_0 as spi_cs
whismanoid 22:a14c19b97d0b 435 // SPI2_SS = P5_3
whismanoid 22:a14c19b97d0b 436 // SPI2_SDIO2 = P5_4
whismanoid 22:a14c19b97d0b 437 // SPI2_SDIO3 = P5_5
whismanoid 22:a14c19b97d0b 438 // SPI2_SRN = P5_6
whismanoid 22:a14c19b97d0b 439 //
whismanoid 22:a14c19b97d0b 440 #ifndef HAS_SPI
whismanoid 22:a14c19b97d0b 441 #define HAS_SPI 1
whismanoid 22:a14c19b97d0b 442 #endif
whismanoid 22:a14c19b97d0b 443 #if HAS_SPI
whismanoid 22:a14c19b97d0b 444 #define SPI_MODE0 0
whismanoid 22:a14c19b97d0b 445 #define SPI_MODE1 1
whismanoid 22:a14c19b97d0b 446 #define SPI_MODE2 2
whismanoid 22:a14c19b97d0b 447 #define SPI_MODE3 3
whismanoid 22:a14c19b97d0b 448 //
whismanoid 22:a14c19b97d0b 449 #if defined(TARGET_MAX32630)
whismanoid 22:a14c19b97d0b 450 // Before setting global variables g_SPI_SCLK_Hz and g_SPI_dataMode,
whismanoid 22:a14c19b97d0b 451 // workaround for TARGET_MAX32630 SPI_MODE2 SPI_MODE3 problem (issue #30)
whismanoid 22:a14c19b97d0b 452 #warning "MAX32630 SPI workaround..."
whismanoid 22:a14c19b97d0b 453 // replace SPI_MODE2 (CPOL=1,CPHA=0) with SPI_MODE1 (CPOL=0,CPHA=1) Falling Edge stable
whismanoid 22:a14c19b97d0b 454 // replace SPI_MODE3 (CPOL=1,CPHA=1) with SPI_MODE0 (CPOL=0,CPHA=0) Rising Edge stable
whismanoid 22:a14c19b97d0b 455 # if ((SPI_dataMode) == (SPI_MODE2))
whismanoid 22:a14c19b97d0b 456 #warning "MAX32630 SPI_MODE2 workaround, changing SPI_dataMode to SPI_MODE1..."
whismanoid 22:a14c19b97d0b 457 // SPI_dataMode SPI_MODE2 // CPOL=1,CPHA=0: Falling Edge stable; SCLK idle High
whismanoid 22:a14c19b97d0b 458 # undef SPI_dataMode
whismanoid 22:a14c19b97d0b 459 # define SPI_dataMode SPI_MODE1 // CPOL=0,CPHA=1: Falling Edge stable; SCLK idle Low
whismanoid 22:a14c19b97d0b 460 # elif ((SPI_dataMode) == (SPI_MODE3))
whismanoid 22:a14c19b97d0b 461 #warning "MAX32630 SPI_MODE3 workaround, changing SPI_dataMode to SPI_MODE0..."
whismanoid 22:a14c19b97d0b 462 // SPI_dataMode SPI_MODE3 // CPOL=1,CPHA=1: Rising Edge stable; SCLK idle High
whismanoid 22:a14c19b97d0b 463 # undef SPI_dataMode
whismanoid 22:a14c19b97d0b 464 # define SPI_dataMode SPI_MODE0 // CPOL=0,CPHA=0: Rising Edge stable; SCLK idle Low
whismanoid 22:a14c19b97d0b 465 # endif // workaround for TARGET_MAX32630 SPI_MODE2 SPI_MODE3 problem
whismanoid 22:a14c19b97d0b 466 // workaround for TARGET_MAX32630 SPI_MODE2 SPI_MODE3 problem (issue #30)
whismanoid 22:a14c19b97d0b 467 // limit SPI SCLK speed to 6MHz or less
whismanoid 22:a14c19b97d0b 468 # if ((SPI_SCLK_Hz) > (6000000))
whismanoid 22:a14c19b97d0b 469 #warning "MAX32630 SPI speed workaround, changing SPI_SCLK_Hz to 6000000 or 6MHz..."
whismanoid 22:a14c19b97d0b 470 # undef SPI_SCLK_Hz
whismanoid 22:a14c19b97d0b 471 # define SPI_SCLK_Hz 6000000 // 6MHz
whismanoid 22:a14c19b97d0b 472 # endif
whismanoid 22:a14c19b97d0b 473 #endif
whismanoid 22:a14c19b97d0b 474 //
whismanoid 22:a14c19b97d0b 475 uint32_t g_SPI_SCLK_Hz = 24000000; // platform limit 24MHz intSPI_SCLK_Platform_Max_MHz * 1000000
whismanoid 22:a14c19b97d0b 476 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency SystemCoreClock F_CPU
whismanoid 22:a14c19b97d0b 477 #if defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 22:a14c19b97d0b 478 // Nucleo SPI frequency isn't working quite as expected...
whismanoid 22:a14c19b97d0b 479 // Looks like STMF4 has an spi clock prescaler (2,4,8,16,32,64,128,256)
whismanoid 22:a14c19b97d0b 480 // so 180MHz->[90.0, 45.0, 22.5, 11.25, 5.625, 2.8125, 1.40625, 0.703125]
whismanoid 22:a14c19b97d0b 481 // %SC SCLK=1MHz sets spi frequency 703.125kHz
whismanoid 22:a14c19b97d0b 482 // %SC SCLK=2MHz sets spi frequency 1.40625MHz
whismanoid 22:a14c19b97d0b 483 // %SC SCLK=3MHz sets spi frequency 2.8125MHz
whismanoid 22:a14c19b97d0b 484 // %SC SCLK=6MHz sets spi frequency 5.625MHz
whismanoid 22:a14c19b97d0b 485 // %SC SCLK=12MHz sets spi frequency 11.25MHz
whismanoid 22:a14c19b97d0b 486 // %SC SCLK=23MHz sets spi frequency 22.5MHz
whismanoid 22:a14c19b97d0b 487 // %SC SCLK=45MHz sets spi frequency 45.0MHz
whismanoid 22:a14c19b97d0b 488 // Don't know why I can't reach spi frequency 90.0MHz, but ok whatever.
whismanoid 22:a14c19b97d0b 489 const uint32_t limit_min_SPI_SCLK_divisor = 2;
whismanoid 22:a14c19b97d0b 490 const uint32_t limit_max_SPI_SCLK_divisor = 256;
whismanoid 22:a14c19b97d0b 491 // not really a divisor, just a powers-of-two prescaler with no intermediate divisors.
whismanoid 22:a14c19b97d0b 492 #else
whismanoid 22:a14c19b97d0b 493 const uint32_t limit_min_SPI_SCLK_divisor = 2;
whismanoid 22:a14c19b97d0b 494 const uint32_t limit_max_SPI_SCLK_divisor = 8191;
whismanoid 22:a14c19b97d0b 495 #endif
whismanoid 22:a14c19b97d0b 496 const uint32_t limit_max_SPI_SCLK_Hz = (SystemCoreClock / limit_min_SPI_SCLK_divisor); // F_CPU / 2; // 8MHz / 2 = 4MHz
whismanoid 22:a14c19b97d0b 497 const uint32_t limit_min_SPI_SCLK_Hz = (SystemCoreClock / limit_max_SPI_SCLK_divisor); // F_CPU / 128; // 8MHz / 128 = 62.5kHz
whismanoid 22:a14c19b97d0b 498 //
whismanoid 22:a14c19b97d0b 499 uint8_t g_SPI_dataMode = SPI_MODE0; // TODO: missing definition SPI_dataMode;
whismanoid 22:a14c19b97d0b 500 uint8_t g_SPI_cs_state = 1;
whismanoid 22:a14c19b97d0b 501 //
whismanoid 22:a14c19b97d0b 502 #endif
whismanoid 22:a14c19b97d0b 503
whismanoid 22:a14c19b97d0b 504
whismanoid 22:a14c19b97d0b 505 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 22:a14c19b97d0b 506 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 507 // Declare the DigitalInOut GPIO pins
whismanoid 22:a14c19b97d0b 508 // Optional digitalInOut support. If there is only one it should be digitalInOut1.
whismanoid 22:a14c19b97d0b 509 // D) Digital High/Low/Input Pin
whismanoid 22:a14c19b97d0b 510 #if defined(TARGET_MAX32630)
whismanoid 22:a14c19b97d0b 511 // +-------------[microUSB]-------------+
whismanoid 22:a14c19b97d0b 512 // | J1 MAX32630FTHR J2 |
whismanoid 22:a14c19b97d0b 513 // | [ ] RST GND [ ] |
whismanoid 22:a14c19b97d0b 514 // | [ ] 3V3 BAT+[ ] |
whismanoid 22:a14c19b97d0b 515 // | [ ] 1V8 reset SW1 |
whismanoid 22:a14c19b97d0b 516 // | [ ] GND J4 J3 |
whismanoid 22:a14c19b97d0b 517 // | [ ] AIN_0 1.2Vfs (bat) SYS [ ] |
whismanoid 22:a14c19b97d0b 518 // | [ ] AIN_1 1.2Vfs PWR [ ] |
whismanoid 22:a14c19b97d0b 519 // | [ ] AIN_2 1.2Vfs +5V VBUS [ ] |
whismanoid 22:a14c19b97d0b 520 // | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9
whismanoid 22:a14c19b97d0b 521 // dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8
whismanoid 22:a14c19b97d0b 522 // dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7
whismanoid 22:a14c19b97d0b 523 // dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6
whismanoid 22:a14c19b97d0b 524 // dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5
whismanoid 22:a14c19b97d0b 525 // dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4
whismanoid 22:a14c19b97d0b 526 // dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3
whismanoid 22:a14c19b97d0b 527 // dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2
whismanoid 22:a14c19b97d0b 528 // | [ ] GND SDA P3_4 [x] | dig1
whismanoid 22:a14c19b97d0b 529 // +------------------------------------+
whismanoid 22:a14c19b97d0b 530 #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15
whismanoid 22:a14c19b97d0b 531 #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12
whismanoid 22:a14c19b97d0b 532 #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11
whismanoid 22:a14c19b97d0b 533 #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10
whismanoid 22:a14c19b97d0b 534 #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9
whismanoid 22:a14c19b97d0b 535 #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8
whismanoid 22:a14c19b97d0b 536 #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7
whismanoid 22:a14c19b97d0b 537 #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6
whismanoid 22:a14c19b97d0b 538 #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5
whismanoid 22:a14c19b97d0b 539 #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4
whismanoid 22:a14c19b97d0b 540 #if HAS_I2C
whismanoid 22:a14c19b97d0b 541 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 22:a14c19b97d0b 542 #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9
whismanoid 22:a14c19b97d0b 543 #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10
whismanoid 22:a14c19b97d0b 544 #else // HAS_I2C
whismanoid 22:a14c19b97d0b 545 #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9
whismanoid 22:a14c19b97d0b 546 #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10
whismanoid 22:a14c19b97d0b 547 #endif // HAS_I2C
whismanoid 22:a14c19b97d0b 548 #if HAS_SPI
whismanoid 22:a14c19b97d0b 549 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 22:a14c19b97d0b 550 #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11
whismanoid 22:a14c19b97d0b 551 #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12
whismanoid 22:a14c19b97d0b 552 #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13
whismanoid 22:a14c19b97d0b 553 #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14
whismanoid 22:a14c19b97d0b 554 #else // HAS_SPI
whismanoid 22:a14c19b97d0b 555 #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11
whismanoid 22:a14c19b97d0b 556 #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12
whismanoid 22:a14c19b97d0b 557 #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13
whismanoid 22:a14c19b97d0b 558 #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14
whismanoid 22:a14c19b97d0b 559 #endif // HAS_SPI
whismanoid 22:a14c19b97d0b 560 #if HAS_digitalInOut0
whismanoid 22:a14c19b97d0b 561 DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15
whismanoid 22:a14c19b97d0b 562 #endif
whismanoid 22:a14c19b97d0b 563 #if HAS_digitalInOut1
whismanoid 22:a14c19b97d0b 564 DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12
whismanoid 22:a14c19b97d0b 565 #endif
whismanoid 22:a14c19b97d0b 566 #if HAS_digitalInOut2
whismanoid 22:a14c19b97d0b 567 DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11
whismanoid 22:a14c19b97d0b 568 #endif
whismanoid 22:a14c19b97d0b 569 #if HAS_digitalInOut3
whismanoid 22:a14c19b97d0b 570 DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10
whismanoid 22:a14c19b97d0b 571 #endif
whismanoid 22:a14c19b97d0b 572 #if HAS_digitalInOut4
whismanoid 22:a14c19b97d0b 573 DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9
whismanoid 22:a14c19b97d0b 574 #endif
whismanoid 22:a14c19b97d0b 575 #if HAS_digitalInOut5
whismanoid 22:a14c19b97d0b 576 DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8
whismanoid 22:a14c19b97d0b 577 #endif
whismanoid 22:a14c19b97d0b 578 #if HAS_digitalInOut6
whismanoid 22:a14c19b97d0b 579 DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7
whismanoid 22:a14c19b97d0b 580 #endif
whismanoid 22:a14c19b97d0b 581 #if HAS_digitalInOut7
whismanoid 22:a14c19b97d0b 582 DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6
whismanoid 22:a14c19b97d0b 583 #endif
whismanoid 22:a14c19b97d0b 584 #if HAS_digitalInOut8
whismanoid 22:a14c19b97d0b 585 DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5
whismanoid 22:a14c19b97d0b 586 #endif
whismanoid 22:a14c19b97d0b 587 #if HAS_digitalInOut9
whismanoid 22:a14c19b97d0b 588 DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4
whismanoid 22:a14c19b97d0b 589 #endif
whismanoid 22:a14c19b97d0b 590 #if HAS_digitalInOut10
whismanoid 22:a14c19b97d0b 591 DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9
whismanoid 22:a14c19b97d0b 592 #endif
whismanoid 22:a14c19b97d0b 593 #if HAS_digitalInOut11
whismanoid 22:a14c19b97d0b 594 DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10
whismanoid 22:a14c19b97d0b 595 #endif
whismanoid 22:a14c19b97d0b 596 #if HAS_digitalInOut12
whismanoid 22:a14c19b97d0b 597 DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11
whismanoid 22:a14c19b97d0b 598 #endif
whismanoid 22:a14c19b97d0b 599 #if HAS_digitalInOut13
whismanoid 22:a14c19b97d0b 600 DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12
whismanoid 22:a14c19b97d0b 601 #endif
whismanoid 22:a14c19b97d0b 602 #if HAS_digitalInOut14
whismanoid 22:a14c19b97d0b 603 DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13
whismanoid 22:a14c19b97d0b 604 #endif
whismanoid 22:a14c19b97d0b 605 #if HAS_digitalInOut15
whismanoid 22:a14c19b97d0b 606 DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14
whismanoid 22:a14c19b97d0b 607 #endif
whismanoid 22:a14c19b97d0b 608 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 609 #elif defined(TARGET_MAX32625MBED)
whismanoid 22:a14c19b97d0b 610 // TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 22:a14c19b97d0b 611 // +-------------------------------------+
whismanoid 22:a14c19b97d0b 612 // | MAX32625MBED Arduino UNO header |
whismanoid 22:a14c19b97d0b 613 // | |
whismanoid 22:a14c19b97d0b 614 // | A5/SCL[ ] | P1_7 dig15
whismanoid 22:a14c19b97d0b 615 // | A4/SDA[ ] | P1_6 dig14
whismanoid 22:a14c19b97d0b 616 // | AREF=N/C[ ] |
whismanoid 22:a14c19b97d0b 617 // | GND[ ] |
whismanoid 22:a14c19b97d0b 618 // | [ ]N/C SCK/13[ ] | P1_0 dig13
whismanoid 22:a14c19b97d0b 619 // | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12
whismanoid 22:a14c19b97d0b 620 // | [ ]RST MOSI/11[ ]~| P1_1 dig11
whismanoid 22:a14c19b97d0b 621 // | [ ]3V3 CS/10[ ]~| P1_3 dig10
whismanoid 22:a14c19b97d0b 622 // | [ ]5V0 9[ ]~| P1_5 dig9
whismanoid 22:a14c19b97d0b 623 // | [ ]GND 8[ ] | P1_4 dig8
whismanoid 22:a14c19b97d0b 624 // | [ ]GND |
whismanoid 22:a14c19b97d0b 625 // | [ ]Vin 7[ ] | P0_7 dig7
whismanoid 22:a14c19b97d0b 626 // | 6[ ]~| P0_6 dig6
whismanoid 22:a14c19b97d0b 627 // AIN_0 | [ ]A0 5[ ]~| P0_5 dig5
whismanoid 22:a14c19b97d0b 628 // AIN_1 | [ ]A1 4[ ] | P0_4 dig4
whismanoid 22:a14c19b97d0b 629 // AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3
whismanoid 22:a14c19b97d0b 630 // AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2
whismanoid 22:a14c19b97d0b 631 // dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1
whismanoid 22:a14c19b97d0b 632 // dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0
whismanoid 22:a14c19b97d0b 633 // | [ ] [ ] [ ] |
whismanoid 22:a14c19b97d0b 634 // | UNO_R3 GND MOSI 5V ____________/
whismanoid 22:a14c19b97d0b 635 // \_______________________/
whismanoid 22:a14c19b97d0b 636 //
whismanoid 22:a14c19b97d0b 637 #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0
whismanoid 22:a14c19b97d0b 638 #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1
whismanoid 22:a14c19b97d0b 639 #if APPLICATION_MAX11131
whismanoid 22:a14c19b97d0b 640 #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn
whismanoid 22:a14c19b97d0b 641 #else
whismanoid 22:a14c19b97d0b 642 #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2
whismanoid 22:a14c19b97d0b 643 #endif
whismanoid 22:a14c19b97d0b 644 #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3
whismanoid 22:a14c19b97d0b 645 #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4
whismanoid 22:a14c19b97d0b 646 #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5
whismanoid 22:a14c19b97d0b 647 #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6
whismanoid 22:a14c19b97d0b 648 #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7
whismanoid 22:a14c19b97d0b 649 #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8
whismanoid 22:a14c19b97d0b 650 #if APPLICATION_MAX11131
whismanoid 22:a14c19b97d0b 651 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut
whismanoid 22:a14c19b97d0b 652 #else
whismanoid 22:a14c19b97d0b 653 #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9
whismanoid 22:a14c19b97d0b 654 #endif
whismanoid 22:a14c19b97d0b 655 #if HAS_SPI
whismanoid 22:a14c19b97d0b 656 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 22:a14c19b97d0b 657 #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 22:a14c19b97d0b 658 #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 22:a14c19b97d0b 659 #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 22:a14c19b97d0b 660 #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 22:a14c19b97d0b 661 #else // HAS_SPI
whismanoid 22:a14c19b97d0b 662 #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 22:a14c19b97d0b 663 #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 22:a14c19b97d0b 664 #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 22:a14c19b97d0b 665 #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 22:a14c19b97d0b 666 #endif // HAS_SPI
whismanoid 22:a14c19b97d0b 667 #if HAS_I2C
whismanoid 22:a14c19b97d0b 668 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 22:a14c19b97d0b 669 #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 22:a14c19b97d0b 670 #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 22:a14c19b97d0b 671 #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 22:a14c19b97d0b 672 #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 22:a14c19b97d0b 673 #else // HAS_I2C
whismanoid 22:a14c19b97d0b 674 #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 22:a14c19b97d0b 675 #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 22:a14c19b97d0b 676 #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 22:a14c19b97d0b 677 #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 22:a14c19b97d0b 678 #endif // HAS_I2C
whismanoid 22:a14c19b97d0b 679 #if HAS_digitalInOut0
whismanoid 22:a14c19b97d0b 680 DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0
whismanoid 22:a14c19b97d0b 681 #endif
whismanoid 22:a14c19b97d0b 682 #if HAS_digitalInOut1
whismanoid 22:a14c19b97d0b 683 DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1
whismanoid 22:a14c19b97d0b 684 #endif
whismanoid 22:a14c19b97d0b 685 #if HAS_digitalInOut2
whismanoid 22:a14c19b97d0b 686 DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2
whismanoid 22:a14c19b97d0b 687 #endif
whismanoid 22:a14c19b97d0b 688 #if HAS_digitalInOut3
whismanoid 22:a14c19b97d0b 689 DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3
whismanoid 22:a14c19b97d0b 690 #endif
whismanoid 22:a14c19b97d0b 691 #if HAS_digitalInOut4
whismanoid 22:a14c19b97d0b 692 DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4
whismanoid 22:a14c19b97d0b 693 #endif
whismanoid 22:a14c19b97d0b 694 #if HAS_digitalInOut5
whismanoid 22:a14c19b97d0b 695 DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5
whismanoid 22:a14c19b97d0b 696 #endif
whismanoid 22:a14c19b97d0b 697 #if HAS_digitalInOut6
whismanoid 22:a14c19b97d0b 698 DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6
whismanoid 22:a14c19b97d0b 699 #endif
whismanoid 22:a14c19b97d0b 700 #if HAS_digitalInOut7
whismanoid 22:a14c19b97d0b 701 DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7
whismanoid 22:a14c19b97d0b 702 #endif
whismanoid 22:a14c19b97d0b 703 #if HAS_digitalInOut8
whismanoid 22:a14c19b97d0b 704 DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8
whismanoid 22:a14c19b97d0b 705 #endif
whismanoid 22:a14c19b97d0b 706 #if HAS_digitalInOut9
whismanoid 22:a14c19b97d0b 707 DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9
whismanoid 22:a14c19b97d0b 708 #endif
whismanoid 22:a14c19b97d0b 709 #if HAS_digitalInOut10
whismanoid 22:a14c19b97d0b 710 DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10
whismanoid 22:a14c19b97d0b 711 #endif
whismanoid 22:a14c19b97d0b 712 #if HAS_digitalInOut11
whismanoid 22:a14c19b97d0b 713 DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11
whismanoid 22:a14c19b97d0b 714 #endif
whismanoid 22:a14c19b97d0b 715 #if HAS_digitalInOut12
whismanoid 22:a14c19b97d0b 716 DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12
whismanoid 22:a14c19b97d0b 717 #endif
whismanoid 22:a14c19b97d0b 718 #if HAS_digitalInOut13
whismanoid 22:a14c19b97d0b 719 DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13
whismanoid 22:a14c19b97d0b 720 #endif
whismanoid 22:a14c19b97d0b 721 #if HAS_digitalInOut14
whismanoid 22:a14c19b97d0b 722 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 22:a14c19b97d0b 723 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 22:a14c19b97d0b 724 DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector)
whismanoid 22:a14c19b97d0b 725 #endif
whismanoid 22:a14c19b97d0b 726 #if HAS_digitalInOut15
whismanoid 22:a14c19b97d0b 727 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 22:a14c19b97d0b 728 DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector)
whismanoid 22:a14c19b97d0b 729 #endif
whismanoid 22:a14c19b97d0b 730 #if HAS_digitalInOut16
whismanoid 22:a14c19b97d0b 731 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 22:a14c19b97d0b 732 // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain
whismanoid 22:a14c19b97d0b 733 // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V
whismanoid 22:a14c19b97d0b 734 DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector)
whismanoid 22:a14c19b97d0b 735 #endif
whismanoid 22:a14c19b97d0b 736 #if HAS_digitalInOut17
whismanoid 22:a14c19b97d0b 737 // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5
whismanoid 22:a14c19b97d0b 738 DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector)
whismanoid 22:a14c19b97d0b 739 #endif
whismanoid 22:a14c19b97d0b 740 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 741 #elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE)
whismanoid 22:a14c19b97d0b 742 #define HAS_digitalInOut0 0 // P0_0 TARGET_MAX32625MBED D0
whismanoid 22:a14c19b97d0b 743 #define HAS_digitalInOut1 0 // P0_1 TARGET_MAX32625MBED D1
whismanoid 22:a14c19b97d0b 744 #if APPLICATION_MAX11131
whismanoid 22:a14c19b97d0b 745 #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn
whismanoid 22:a14c19b97d0b 746 #else
whismanoid 22:a14c19b97d0b 747 #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2
whismanoid 22:a14c19b97d0b 748 #endif
whismanoid 22:a14c19b97d0b 749 #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3
whismanoid 22:a14c19b97d0b 750 #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4
whismanoid 22:a14c19b97d0b 751 #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5
whismanoid 22:a14c19b97d0b 752 #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6
whismanoid 22:a14c19b97d0b 753 #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7
whismanoid 22:a14c19b97d0b 754 #if APPLICATION_MAX5715
whismanoid 22:a14c19b97d0b 755 #define HAS_digitalInOut8 0 // P1_4 TARGET_MAX32625MBED D8 -- MAX5715 CLRb DigitalOut
whismanoid 22:a14c19b97d0b 756 #else
whismanoid 22:a14c19b97d0b 757 #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8
whismanoid 22:a14c19b97d0b 758 #endif
whismanoid 22:a14c19b97d0b 759 #if APPLICATION_MAX5715
whismanoid 22:a14c19b97d0b 760 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX5715 LDACb DigitalOut
whismanoid 22:a14c19b97d0b 761 #elif APPLICATION_MAX11131
whismanoid 22:a14c19b97d0b 762 #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut
whismanoid 22:a14c19b97d0b 763 #else
whismanoid 22:a14c19b97d0b 764 #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9
whismanoid 22:a14c19b97d0b 765 #endif
whismanoid 22:a14c19b97d0b 766 #if HAS_SPI
whismanoid 22:a14c19b97d0b 767 // avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut
whismanoid 22:a14c19b97d0b 768 // Arduino digital pin D10 SPI function is CS/10
whismanoid 22:a14c19b97d0b 769 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 22:a14c19b97d0b 770 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 22:a14c19b97d0b 771 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 22:a14c19b97d0b 772 #define HAS_digitalInOut10 0
whismanoid 22:a14c19b97d0b 773 #define HAS_digitalInOut11 0
whismanoid 22:a14c19b97d0b 774 #define HAS_digitalInOut12 0
whismanoid 22:a14c19b97d0b 775 #define HAS_digitalInOut13 0
whismanoid 22:a14c19b97d0b 776 #else // HAS_SPI
whismanoid 22:a14c19b97d0b 777 #define HAS_digitalInOut10 1
whismanoid 22:a14c19b97d0b 778 #define HAS_digitalInOut11 1
whismanoid 22:a14c19b97d0b 779 #define HAS_digitalInOut12 1
whismanoid 22:a14c19b97d0b 780 #define HAS_digitalInOut13 1
whismanoid 22:a14c19b97d0b 781 #endif // HAS_SPI
whismanoid 22:a14c19b97d0b 782 #if HAS_I2C
whismanoid 22:a14c19b97d0b 783 // avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut
whismanoid 22:a14c19b97d0b 784 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 22:a14c19b97d0b 785 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 22:a14c19b97d0b 786 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 22:a14c19b97d0b 787 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 22:a14c19b97d0b 788 #define HAS_digitalInOut14 0
whismanoid 22:a14c19b97d0b 789 #define HAS_digitalInOut15 0
whismanoid 22:a14c19b97d0b 790 #define HAS_digitalInOut16 0
whismanoid 22:a14c19b97d0b 791 #define HAS_digitalInOut17 0
whismanoid 22:a14c19b97d0b 792 #else // HAS_I2C
whismanoid 22:a14c19b97d0b 793 #define HAS_digitalInOut14 1
whismanoid 22:a14c19b97d0b 794 #define HAS_digitalInOut15 1
whismanoid 22:a14c19b97d0b 795 #define HAS_digitalInOut16 0
whismanoid 22:a14c19b97d0b 796 #define HAS_digitalInOut17 0
whismanoid 22:a14c19b97d0b 797 #endif // HAS_I2C
whismanoid 22:a14c19b97d0b 798 #if HAS_digitalInOut0
whismanoid 22:a14c19b97d0b 799 DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 800 #endif
whismanoid 22:a14c19b97d0b 801 #if HAS_digitalInOut1
whismanoid 22:a14c19b97d0b 802 DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 803 #endif
whismanoid 22:a14c19b97d0b 804 #if HAS_digitalInOut2
whismanoid 22:a14c19b97d0b 805 DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 806 #endif
whismanoid 22:a14c19b97d0b 807 #if HAS_digitalInOut3
whismanoid 22:a14c19b97d0b 808 DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 809 #endif
whismanoid 22:a14c19b97d0b 810 #if HAS_digitalInOut4
whismanoid 22:a14c19b97d0b 811 DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 812 #endif
whismanoid 22:a14c19b97d0b 813 #if HAS_digitalInOut5
whismanoid 22:a14c19b97d0b 814 DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 815 #endif
whismanoid 22:a14c19b97d0b 816 #if HAS_digitalInOut6
whismanoid 22:a14c19b97d0b 817 DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 818 #endif
whismanoid 22:a14c19b97d0b 819 #if HAS_digitalInOut7
whismanoid 22:a14c19b97d0b 820 DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 821 #endif
whismanoid 22:a14c19b97d0b 822 #if HAS_digitalInOut8
whismanoid 22:a14c19b97d0b 823 DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 824 #endif
whismanoid 22:a14c19b97d0b 825 #if HAS_digitalInOut9
whismanoid 22:a14c19b97d0b 826 DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 827 #endif
whismanoid 22:a14c19b97d0b 828 #if HAS_digitalInOut10
whismanoid 22:a14c19b97d0b 829 // Arduino digital pin D10 SPI function is CS/10
whismanoid 22:a14c19b97d0b 830 DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 831 #endif
whismanoid 22:a14c19b97d0b 832 #if HAS_digitalInOut11
whismanoid 22:a14c19b97d0b 833 // Arduino digital pin D11 SPI function is MOSI/11
whismanoid 22:a14c19b97d0b 834 DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 835 #endif
whismanoid 22:a14c19b97d0b 836 #if HAS_digitalInOut12
whismanoid 22:a14c19b97d0b 837 // Arduino digital pin D12 SPI function is MISO/12
whismanoid 22:a14c19b97d0b 838 DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 839 #endif
whismanoid 22:a14c19b97d0b 840 #if HAS_digitalInOut13
whismanoid 22:a14c19b97d0b 841 // Arduino digital pin D13 SPI function is SCK/13
whismanoid 22:a14c19b97d0b 842 DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 843 #endif
whismanoid 22:a14c19b97d0b 844 #if HAS_digitalInOut14
whismanoid 22:a14c19b97d0b 845 // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector)
whismanoid 22:a14c19b97d0b 846 DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 847 #endif
whismanoid 22:a14c19b97d0b 848 #if HAS_digitalInOut15
whismanoid 22:a14c19b97d0b 849 // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector)
whismanoid 22:a14c19b97d0b 850 DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 851 #endif
whismanoid 22:a14c19b97d0b 852 #if HAS_digitalInOut16
whismanoid 22:a14c19b97d0b 853 // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector)
whismanoid 22:a14c19b97d0b 854 DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 855 #endif
whismanoid 22:a14c19b97d0b 856 #if HAS_digitalInOut17
whismanoid 22:a14c19b97d0b 857 // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector)
whismanoid 22:a14c19b97d0b 858 DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 859 #endif
whismanoid 22:a14c19b97d0b 860 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 861 #elif defined(TARGET_LPC1768)
whismanoid 22:a14c19b97d0b 862 #define HAS_digitalInOut0 1
whismanoid 22:a14c19b97d0b 863 #define HAS_digitalInOut1 1
whismanoid 22:a14c19b97d0b 864 #define HAS_digitalInOut2 1
whismanoid 22:a14c19b97d0b 865 #define HAS_digitalInOut3 1
whismanoid 22:a14c19b97d0b 866 #define HAS_digitalInOut4 1
whismanoid 22:a14c19b97d0b 867 #define HAS_digitalInOut5 1
whismanoid 22:a14c19b97d0b 868 #define HAS_digitalInOut6 1
whismanoid 22:a14c19b97d0b 869 #define HAS_digitalInOut7 1
whismanoid 22:a14c19b97d0b 870 #define HAS_digitalInOut8 1
whismanoid 22:a14c19b97d0b 871 #define HAS_digitalInOut9 1
whismanoid 22:a14c19b97d0b 872 // #define HAS_digitalInOut10 1
whismanoid 22:a14c19b97d0b 873 // #define HAS_digitalInOut11 1
whismanoid 22:a14c19b97d0b 874 // #define HAS_digitalInOut12 1
whismanoid 22:a14c19b97d0b 875 // #define HAS_digitalInOut13 1
whismanoid 22:a14c19b97d0b 876 // #define HAS_digitalInOut14 1
whismanoid 22:a14c19b97d0b 877 // #define HAS_digitalInOut15 1
whismanoid 22:a14c19b97d0b 878 #if HAS_digitalInOut0
whismanoid 22:a14c19b97d0b 879 DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3
whismanoid 22:a14c19b97d0b 880 #endif
whismanoid 22:a14c19b97d0b 881 #if HAS_digitalInOut1
whismanoid 22:a14c19b97d0b 882 DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2
whismanoid 22:a14c19b97d0b 883 #endif
whismanoid 22:a14c19b97d0b 884 #if HAS_digitalInOut2
whismanoid 22:a14c19b97d0b 885 DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1
whismanoid 22:a14c19b97d0b 886 #endif
whismanoid 22:a14c19b97d0b 887 #if HAS_digitalInOut3
whismanoid 22:a14c19b97d0b 888 DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0
whismanoid 22:a14c19b97d0b 889 #endif
whismanoid 22:a14c19b97d0b 890 #if HAS_digitalInOut4
whismanoid 22:a14c19b97d0b 891 DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1
whismanoid 22:a14c19b97d0b 892 #endif
whismanoid 22:a14c19b97d0b 893 #if HAS_digitalInOut5
whismanoid 22:a14c19b97d0b 894 DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1
whismanoid 22:a14c19b97d0b 895 #endif
whismanoid 22:a14c19b97d0b 896 #if HAS_digitalInOut6
whismanoid 22:a14c19b97d0b 897 DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1
whismanoid 22:a14c19b97d0b 898 #endif
whismanoid 22:a14c19b97d0b 899 #if HAS_digitalInOut7
whismanoid 22:a14c19b97d0b 900 DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO
whismanoid 22:a14c19b97d0b 901 #endif
whismanoid 22:a14c19b97d0b 902 #if HAS_digitalInOut8
whismanoid 22:a14c19b97d0b 903 DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK
whismanoid 22:a14c19b97d0b 904 #endif
whismanoid 22:a14c19b97d0b 905 #if HAS_digitalInOut9
whismanoid 22:a14c19b97d0b 906 DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL
whismanoid 22:a14c19b97d0b 907 #endif
whismanoid 22:a14c19b97d0b 908 //
whismanoid 22:a14c19b97d0b 909 // these pins support analog input analogIn0 .. analogIn5
whismanoid 22:a14c19b97d0b 910 //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 22:a14c19b97d0b 911 //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 22:a14c19b97d0b 912 //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 22:a14c19b97d0b 913 //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 22:a14c19b97d0b 914 //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 22:a14c19b97d0b 915 //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 22:a14c19b97d0b 916 //
whismanoid 22:a14c19b97d0b 917 // these pins support PWM pwmDriver1 .. pwmDriver6
whismanoid 22:a14c19b97d0b 918 //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0
whismanoid 22:a14c19b97d0b 919 //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1
whismanoid 22:a14c19b97d0b 920 //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2
whismanoid 22:a14c19b97d0b 921 //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3
whismanoid 22:a14c19b97d0b 922 //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1
whismanoid 22:a14c19b97d0b 923 //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK
whismanoid 22:a14c19b97d0b 924 //
whismanoid 22:a14c19b97d0b 925 // these could be additional digitalInOut pins
whismanoid 22:a14c19b97d0b 926 #if HAS_digitalInOut10
whismanoid 22:a14c19b97d0b 927 DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1
whismanoid 22:a14c19b97d0b 928 #endif
whismanoid 22:a14c19b97d0b 929 #if HAS_digitalInOut11
whismanoid 22:a14c19b97d0b 930 DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0
whismanoid 22:a14c19b97d0b 931 #endif
whismanoid 22:a14c19b97d0b 932 #if HAS_digitalInOut12
whismanoid 22:a14c19b97d0b 933 DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1
whismanoid 22:a14c19b97d0b 934 #endif
whismanoid 22:a14c19b97d0b 935 #if HAS_digitalInOut13
whismanoid 22:a14c19b97d0b 936 DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0
whismanoid 22:a14c19b97d0b 937 #endif
whismanoid 22:a14c19b97d0b 938 #if HAS_digitalInOut14
whismanoid 22:a14c19b97d0b 939 DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 940 #endif
whismanoid 22:a14c19b97d0b 941 #if HAS_digitalInOut15
whismanoid 22:a14c19b97d0b 942 DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1);
whismanoid 22:a14c19b97d0b 943 #endif
whismanoid 22:a14c19b97d0b 944 #else
whismanoid 22:a14c19b97d0b 945 // unknown target
whismanoid 22:a14c19b97d0b 946 #endif
whismanoid 22:a14c19b97d0b 947 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 22:a14c19b97d0b 948 #if HAS_digitalInOut0 || HAS_digitalInOut1 \
whismanoid 22:a14c19b97d0b 949 || HAS_digitalInOut2 || HAS_digitalInOut3 \
whismanoid 22:a14c19b97d0b 950 || HAS_digitalInOut4 || HAS_digitalInOut5 \
whismanoid 22:a14c19b97d0b 951 || HAS_digitalInOut6 || HAS_digitalInOut7 \
whismanoid 22:a14c19b97d0b 952 || HAS_digitalInOut8 || HAS_digitalInOut9 \
whismanoid 22:a14c19b97d0b 953 || HAS_digitalInOut10 || HAS_digitalInOut11 \
whismanoid 22:a14c19b97d0b 954 || HAS_digitalInOut12 || HAS_digitalInOut13 \
whismanoid 22:a14c19b97d0b 955 || HAS_digitalInOut14 || HAS_digitalInOut15 \
whismanoid 22:a14c19b97d0b 956 || HAS_digitalInOut16 || HAS_digitalInOut17
whismanoid 22:a14c19b97d0b 957 #define HAS_digitalInOuts 1
whismanoid 22:a14c19b97d0b 958 #endif
whismanoid 22:a14c19b97d0b 959
whismanoid 22:a14c19b97d0b 960 // uncrustify-0.66.1 *INDENT-OFF*
whismanoid 22:a14c19b97d0b 961 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 962 // Declare the AnalogIn driver
whismanoid 22:a14c19b97d0b 963 // Optional analogIn support. If there is only one it should be analogIn1.
whismanoid 22:a14c19b97d0b 964 // A) analog input
whismanoid 22:a14c19b97d0b 965 #if defined(TARGET_MAX32630)
whismanoid 22:a14c19b97d0b 966 #define HAS_analogIn0 1
whismanoid 22:a14c19b97d0b 967 #define HAS_analogIn1 1
whismanoid 22:a14c19b97d0b 968 #define HAS_analogIn2 1
whismanoid 22:a14c19b97d0b 969 #define HAS_analogIn3 1
whismanoid 22:a14c19b97d0b 970 #define HAS_analogIn4 1
whismanoid 22:a14c19b97d0b 971 #define HAS_analogIn5 1
whismanoid 22:a14c19b97d0b 972 #define HAS_analogIn6 1
whismanoid 22:a14c19b97d0b 973 #define HAS_analogIn7 1
whismanoid 22:a14c19b97d0b 974 #define HAS_analogIn8 1
whismanoid 22:a14c19b97d0b 975 #define HAS_analogIn9 1
whismanoid 22:a14c19b97d0b 976 // #define HAS_analogIn10 0
whismanoid 22:a14c19b97d0b 977 // #define HAS_analogIn11 0
whismanoid 22:a14c19b97d0b 978 // #define HAS_analogIn12 0
whismanoid 22:a14c19b97d0b 979 // #define HAS_analogIn13 0
whismanoid 22:a14c19b97d0b 980 // #define HAS_analogIn14 0
whismanoid 22:a14c19b97d0b 981 // #define HAS_analogIn15 0
whismanoid 22:a14c19b97d0b 982 #if HAS_analogIn0
whismanoid 22:a14c19b97d0b 983 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 984 #endif
whismanoid 22:a14c19b97d0b 985 #if HAS_analogIn1
whismanoid 22:a14c19b97d0b 986 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 987 #endif
whismanoid 22:a14c19b97d0b 988 #if HAS_analogIn2
whismanoid 22:a14c19b97d0b 989 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 990 #endif
whismanoid 22:a14c19b97d0b 991 #if HAS_analogIn3
whismanoid 22:a14c19b97d0b 992 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 993 #endif
whismanoid 22:a14c19b97d0b 994 #if HAS_analogIn4
whismanoid 22:a14c19b97d0b 995 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 996 #endif
whismanoid 22:a14c19b97d0b 997 #if HAS_analogIn5
whismanoid 22:a14c19b97d0b 998 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 999 #endif
whismanoid 22:a14c19b97d0b 1000 #if HAS_analogIn6
whismanoid 22:a14c19b97d0b 1001 AnalogIn analogIn6(AIN_6); // TARGET_MAX32630 AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 1002 #endif
whismanoid 22:a14c19b97d0b 1003 #if HAS_analogIn7
whismanoid 22:a14c19b97d0b 1004 AnalogIn analogIn7(AIN_7); // TARGET_MAX32630 AIN_7 = VDD18 fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1005 #endif
whismanoid 22:a14c19b97d0b 1006 #if HAS_analogIn8
whismanoid 22:a14c19b97d0b 1007 AnalogIn analogIn8(AIN_8); // TARGET_MAX32630 AIN_8 = VDD12 fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1008 #endif
whismanoid 22:a14c19b97d0b 1009 #if HAS_analogIn9
whismanoid 22:a14c19b97d0b 1010 AnalogIn analogIn9(AIN_9); // TARGET_MAX32630 AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 22:a14c19b97d0b 1011 #endif
whismanoid 22:a14c19b97d0b 1012 #if HAS_analogIn10
whismanoid 22:a14c19b97d0b 1013 AnalogIn analogIn10(____); // TARGET_MAX32630 AIN_10 = x undefined?
whismanoid 22:a14c19b97d0b 1014 #endif
whismanoid 22:a14c19b97d0b 1015 #if HAS_analogIn11
whismanoid 22:a14c19b97d0b 1016 AnalogIn analogIn11(____); // TARGET_MAX32630 AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 1017 #endif
whismanoid 22:a14c19b97d0b 1018 #if HAS_analogIn12
whismanoid 22:a14c19b97d0b 1019 AnalogIn analogIn12(____); // TARGET_MAX32630 AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 1020 #endif
whismanoid 22:a14c19b97d0b 1021 #if HAS_analogIn13
whismanoid 22:a14c19b97d0b 1022 AnalogIn analogIn13(____);
whismanoid 22:a14c19b97d0b 1023 #endif
whismanoid 22:a14c19b97d0b 1024 #if HAS_analogIn14
whismanoid 22:a14c19b97d0b 1025 AnalogIn analogIn14(____);
whismanoid 22:a14c19b97d0b 1026 #endif
whismanoid 22:a14c19b97d0b 1027 #if HAS_analogIn15
whismanoid 22:a14c19b97d0b 1028 AnalogIn analogIn15(____);
whismanoid 22:a14c19b97d0b 1029 #endif
whismanoid 22:a14c19b97d0b 1030 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1031 #elif defined(TARGET_MAX32625MBED)
whismanoid 22:a14c19b97d0b 1032 #define HAS_analogIn0 1
whismanoid 22:a14c19b97d0b 1033 #define HAS_analogIn1 1
whismanoid 22:a14c19b97d0b 1034 #define HAS_analogIn2 1
whismanoid 22:a14c19b97d0b 1035 #define HAS_analogIn3 1
whismanoid 22:a14c19b97d0b 1036 #define HAS_analogIn4 1
whismanoid 22:a14c19b97d0b 1037 #define HAS_analogIn5 1
whismanoid 22:a14c19b97d0b 1038 #if HAS_analogIn0
whismanoid 22:a14c19b97d0b 1039 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1040 #endif
whismanoid 22:a14c19b97d0b 1041 #if HAS_analogIn1
whismanoid 22:a14c19b97d0b 1042 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1043 #endif
whismanoid 22:a14c19b97d0b 1044 #if HAS_analogIn2
whismanoid 22:a14c19b97d0b 1045 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1046 #endif
whismanoid 22:a14c19b97d0b 1047 #if HAS_analogIn3
whismanoid 22:a14c19b97d0b 1048 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1049 #endif
whismanoid 22:a14c19b97d0b 1050 #if HAS_analogIn4
whismanoid 22:a14c19b97d0b 1051 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 1052 #endif
whismanoid 22:a14c19b97d0b 1053 #if HAS_analogIn5
whismanoid 22:a14c19b97d0b 1054 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 1055 #endif
whismanoid 22:a14c19b97d0b 1056 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1057 #elif defined(TARGET_MAX32620FTHR)
whismanoid 22:a14c19b97d0b 1058 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 22:a14c19b97d0b 1059 #define HAS_analogIn0 1
whismanoid 22:a14c19b97d0b 1060 #define HAS_analogIn1 1
whismanoid 22:a14c19b97d0b 1061 #define HAS_analogIn2 1
whismanoid 22:a14c19b97d0b 1062 #define HAS_analogIn3 1
whismanoid 22:a14c19b97d0b 1063 #define HAS_analogIn4 1
whismanoid 22:a14c19b97d0b 1064 #define HAS_analogIn5 1
whismanoid 22:a14c19b97d0b 1065 #define HAS_analogIn6 1
whismanoid 22:a14c19b97d0b 1066 #define HAS_analogIn7 1
whismanoid 22:a14c19b97d0b 1067 #define HAS_analogIn8 1
whismanoid 22:a14c19b97d0b 1068 #define HAS_analogIn9 1
whismanoid 22:a14c19b97d0b 1069 // #define HAS_analogIn10 0
whismanoid 22:a14c19b97d0b 1070 // #define HAS_analogIn11 0
whismanoid 22:a14c19b97d0b 1071 // #define HAS_analogIn12 0
whismanoid 22:a14c19b97d0b 1072 // #define HAS_analogIn13 0
whismanoid 22:a14c19b97d0b 1073 // #define HAS_analogIn14 0
whismanoid 22:a14c19b97d0b 1074 // #define HAS_analogIn15 0
whismanoid 22:a14c19b97d0b 1075 #if HAS_analogIn0
whismanoid 22:a14c19b97d0b 1076 AnalogIn analogIn0(AIN_0); // TARGET_MAX32620FTHR J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1077 #endif
whismanoid 22:a14c19b97d0b 1078 #if HAS_analogIn1
whismanoid 22:a14c19b97d0b 1079 AnalogIn analogIn1(AIN_1); // TARGET_MAX32620FTHR J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1080 #endif
whismanoid 22:a14c19b97d0b 1081 #if HAS_analogIn2
whismanoid 22:a14c19b97d0b 1082 AnalogIn analogIn2(AIN_2); // TARGET_MAX32620FTHR J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1083 #endif
whismanoid 22:a14c19b97d0b 1084 #if HAS_analogIn3
whismanoid 22:a14c19b97d0b 1085 AnalogIn analogIn3(AIN_3); // TARGET_MAX32620FTHR J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1086 #endif
whismanoid 22:a14c19b97d0b 1087 #if HAS_analogIn4
whismanoid 22:a14c19b97d0b 1088 AnalogIn analogIn4(AIN_4); // TARGET_MAX32620FTHR J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 1089 #endif
whismanoid 22:a14c19b97d0b 1090 #if HAS_analogIn5
whismanoid 22:a14c19b97d0b 1091 AnalogIn analogIn5(AIN_5); // TARGET_MAX32620FTHR J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 1092 #endif
whismanoid 22:a14c19b97d0b 1093 #if HAS_analogIn6
whismanoid 22:a14c19b97d0b 1094 AnalogIn analogIn6(AIN_6); // TARGET_MAX32620FTHR AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 1095 #endif
whismanoid 22:a14c19b97d0b 1096 #if HAS_analogIn7
whismanoid 22:a14c19b97d0b 1097 AnalogIn analogIn7(AIN_7); // TARGET_MAX32620FTHR AIN_7 = VDD18 fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1098 #endif
whismanoid 22:a14c19b97d0b 1099 #if HAS_analogIn8
whismanoid 22:a14c19b97d0b 1100 AnalogIn analogIn8(AIN_8); // TARGET_MAX32620FTHR AIN_8 = VDD12 fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1101 #endif
whismanoid 22:a14c19b97d0b 1102 #if HAS_analogIn9
whismanoid 22:a14c19b97d0b 1103 AnalogIn analogIn9(AIN_9); // TARGET_MAX32620FTHR AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 22:a14c19b97d0b 1104 #endif
whismanoid 22:a14c19b97d0b 1105 #if HAS_analogIn10
whismanoid 22:a14c19b97d0b 1106 AnalogIn analogIn10(____); // TARGET_MAX32620FTHR AIN_10 = x undefined?
whismanoid 22:a14c19b97d0b 1107 #endif
whismanoid 22:a14c19b97d0b 1108 #if HAS_analogIn11
whismanoid 22:a14c19b97d0b 1109 AnalogIn analogIn11(____); // TARGET_MAX32620FTHR AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 1110 #endif
whismanoid 22:a14c19b97d0b 1111 #if HAS_analogIn12
whismanoid 22:a14c19b97d0b 1112 AnalogIn analogIn12(____); // TARGET_MAX32620FTHR AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 1113 #endif
whismanoid 22:a14c19b97d0b 1114 #if HAS_analogIn13
whismanoid 22:a14c19b97d0b 1115 AnalogIn analogIn13(____);
whismanoid 22:a14c19b97d0b 1116 #endif
whismanoid 22:a14c19b97d0b 1117 #if HAS_analogIn14
whismanoid 22:a14c19b97d0b 1118 AnalogIn analogIn14(____);
whismanoid 22:a14c19b97d0b 1119 #endif
whismanoid 22:a14c19b97d0b 1120 #if HAS_analogIn15
whismanoid 22:a14c19b97d0b 1121 AnalogIn analogIn15(____);
whismanoid 22:a14c19b97d0b 1122 #endif
whismanoid 22:a14c19b97d0b 1123 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1124 #elif defined(TARGET_MAX32625PICO)
whismanoid 22:a14c19b97d0b 1125 #warning "TARGET_MAX32625PICO not previously tested; need to verify analogIn0..."
whismanoid 22:a14c19b97d0b 1126 #define HAS_analogIn0 1
whismanoid 22:a14c19b97d0b 1127 #define HAS_analogIn1 1
whismanoid 22:a14c19b97d0b 1128 #define HAS_analogIn2 1
whismanoid 22:a14c19b97d0b 1129 #define HAS_analogIn3 1
whismanoid 22:a14c19b97d0b 1130 #define HAS_analogIn4 1
whismanoid 22:a14c19b97d0b 1131 #define HAS_analogIn5 1
whismanoid 22:a14c19b97d0b 1132 #if HAS_analogIn0
whismanoid 22:a14c19b97d0b 1133 AnalogIn analogIn0(AIN_0); // TARGET_MAX32630 J1.5 AIN_0 = AIN0 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1134 #endif
whismanoid 22:a14c19b97d0b 1135 #if HAS_analogIn1
whismanoid 22:a14c19b97d0b 1136 AnalogIn analogIn1(AIN_1); // TARGET_MAX32630 J1.6 AIN_1 = AIN1 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1137 #endif
whismanoid 22:a14c19b97d0b 1138 #if HAS_analogIn2
whismanoid 22:a14c19b97d0b 1139 AnalogIn analogIn2(AIN_2); // TARGET_MAX32630 J1.7 AIN_2 = AIN2 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1140 #endif
whismanoid 22:a14c19b97d0b 1141 #if HAS_analogIn3
whismanoid 22:a14c19b97d0b 1142 AnalogIn analogIn3(AIN_3); // TARGET_MAX32630 J1.8 AIN_3 = AIN3 pin fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1143 #endif
whismanoid 22:a14c19b97d0b 1144 #if HAS_analogIn4
whismanoid 22:a14c19b97d0b 1145 AnalogIn analogIn4(AIN_4); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 1146 #endif
whismanoid 22:a14c19b97d0b 1147 #if HAS_analogIn5
whismanoid 22:a14c19b97d0b 1148 AnalogIn analogIn5(AIN_5); // TARGET_MAX32630 J1.6 AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 1149 #endif
whismanoid 22:a14c19b97d0b 1150 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1151 #elif defined(TARGET_MAX32600)
whismanoid 22:a14c19b97d0b 1152 #define HAS_analogIn0 1
whismanoid 22:a14c19b97d0b 1153 #define HAS_analogIn1 1
whismanoid 22:a14c19b97d0b 1154 #define HAS_analogIn2 1
whismanoid 22:a14c19b97d0b 1155 #define HAS_analogIn3 1
whismanoid 22:a14c19b97d0b 1156 #define HAS_analogIn4 1
whismanoid 22:a14c19b97d0b 1157 #define HAS_analogIn5 1
whismanoid 22:a14c19b97d0b 1158 #if HAS_analogIn0
whismanoid 22:a14c19b97d0b 1159 AnalogIn analogIn0(A0);
whismanoid 22:a14c19b97d0b 1160 #endif
whismanoid 22:a14c19b97d0b 1161 #if HAS_analogIn1
whismanoid 22:a14c19b97d0b 1162 AnalogIn analogIn1(A1);
whismanoid 22:a14c19b97d0b 1163 #endif
whismanoid 22:a14c19b97d0b 1164 #if HAS_analogIn2
whismanoid 22:a14c19b97d0b 1165 AnalogIn analogIn2(A2);
whismanoid 22:a14c19b97d0b 1166 #endif
whismanoid 22:a14c19b97d0b 1167 #if HAS_analogIn3
whismanoid 22:a14c19b97d0b 1168 AnalogIn analogIn3(A3);
whismanoid 22:a14c19b97d0b 1169 #endif
whismanoid 22:a14c19b97d0b 1170 #if HAS_analogIn4
whismanoid 22:a14c19b97d0b 1171 AnalogIn analogIn4(A4);
whismanoid 22:a14c19b97d0b 1172 #endif
whismanoid 22:a14c19b97d0b 1173 #if HAS_analogIn5
whismanoid 22:a14c19b97d0b 1174 AnalogIn analogIn5(A5);
whismanoid 22:a14c19b97d0b 1175 #endif
whismanoid 22:a14c19b97d0b 1176 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1177 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 22:a14c19b97d0b 1178 #define HAS_analogIn0 1
whismanoid 22:a14c19b97d0b 1179 #define HAS_analogIn1 1
whismanoid 22:a14c19b97d0b 1180 #define HAS_analogIn2 1
whismanoid 22:a14c19b97d0b 1181 #define HAS_analogIn3 1
whismanoid 22:a14c19b97d0b 1182 #define HAS_analogIn4 1
whismanoid 22:a14c19b97d0b 1183 #define HAS_analogIn5 1
whismanoid 22:a14c19b97d0b 1184 #if HAS_analogIn0
whismanoid 22:a14c19b97d0b 1185 AnalogIn analogIn0(A0);
whismanoid 22:a14c19b97d0b 1186 #endif
whismanoid 22:a14c19b97d0b 1187 #if HAS_analogIn1
whismanoid 22:a14c19b97d0b 1188 AnalogIn analogIn1(A1);
whismanoid 22:a14c19b97d0b 1189 #endif
whismanoid 22:a14c19b97d0b 1190 #if HAS_analogIn2
whismanoid 22:a14c19b97d0b 1191 AnalogIn analogIn2(A2);
whismanoid 22:a14c19b97d0b 1192 #endif
whismanoid 22:a14c19b97d0b 1193 #if HAS_analogIn3
whismanoid 22:a14c19b97d0b 1194 AnalogIn analogIn3(A3);
whismanoid 22:a14c19b97d0b 1195 #endif
whismanoid 22:a14c19b97d0b 1196 #if HAS_analogIn4
whismanoid 22:a14c19b97d0b 1197 AnalogIn analogIn4(A4);
whismanoid 22:a14c19b97d0b 1198 #endif
whismanoid 22:a14c19b97d0b 1199 #if HAS_analogIn5
whismanoid 22:a14c19b97d0b 1200 AnalogIn analogIn5(A5);
whismanoid 22:a14c19b97d0b 1201 #endif
whismanoid 22:a14c19b97d0b 1202 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1203 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 22:a14c19b97d0b 1204 #define HAS_analogIn0 1
whismanoid 22:a14c19b97d0b 1205 #define HAS_analogIn1 1
whismanoid 22:a14c19b97d0b 1206 #define HAS_analogIn2 1
whismanoid 22:a14c19b97d0b 1207 #define HAS_analogIn3 1
whismanoid 22:a14c19b97d0b 1208 #define HAS_analogIn4 1
whismanoid 22:a14c19b97d0b 1209 #define HAS_analogIn5 1
whismanoid 22:a14c19b97d0b 1210 #if HAS_analogIn0
whismanoid 22:a14c19b97d0b 1211 AnalogIn analogIn0(A0);
whismanoid 22:a14c19b97d0b 1212 #endif
whismanoid 22:a14c19b97d0b 1213 #if HAS_analogIn1
whismanoid 22:a14c19b97d0b 1214 AnalogIn analogIn1(A1);
whismanoid 22:a14c19b97d0b 1215 #endif
whismanoid 22:a14c19b97d0b 1216 #if HAS_analogIn2
whismanoid 22:a14c19b97d0b 1217 AnalogIn analogIn2(A2);
whismanoid 22:a14c19b97d0b 1218 #endif
whismanoid 22:a14c19b97d0b 1219 #if HAS_analogIn3
whismanoid 22:a14c19b97d0b 1220 AnalogIn analogIn3(A3);
whismanoid 22:a14c19b97d0b 1221 #endif
whismanoid 22:a14c19b97d0b 1222 #if HAS_analogIn4
whismanoid 22:a14c19b97d0b 1223 AnalogIn analogIn4(A4);
whismanoid 22:a14c19b97d0b 1224 #endif
whismanoid 22:a14c19b97d0b 1225 #if HAS_analogIn5
whismanoid 22:a14c19b97d0b 1226 AnalogIn analogIn5(A5);
whismanoid 22:a14c19b97d0b 1227 #endif
whismanoid 22:a14c19b97d0b 1228 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1229 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 22:a14c19b97d0b 1230 #elif defined(TARGET_LPC1768)
whismanoid 22:a14c19b97d0b 1231 #define HAS_analogIn0 1
whismanoid 22:a14c19b97d0b 1232 #define HAS_analogIn1 1
whismanoid 22:a14c19b97d0b 1233 #define HAS_analogIn2 1
whismanoid 22:a14c19b97d0b 1234 #define HAS_analogIn3 1
whismanoid 22:a14c19b97d0b 1235 #define HAS_analogIn4 1
whismanoid 22:a14c19b97d0b 1236 #define HAS_analogIn5 1
whismanoid 22:a14c19b97d0b 1237 // #define HAS_analogIn6 1
whismanoid 22:a14c19b97d0b 1238 // #define HAS_analogIn7 1
whismanoid 22:a14c19b97d0b 1239 // #define HAS_analogIn8 1
whismanoid 22:a14c19b97d0b 1240 // #define HAS_analogIn9 1
whismanoid 22:a14c19b97d0b 1241 // #define HAS_analogIn10 1
whismanoid 22:a14c19b97d0b 1242 // #define HAS_analogIn11 1
whismanoid 22:a14c19b97d0b 1243 // #define HAS_analogIn12 1
whismanoid 22:a14c19b97d0b 1244 // #define HAS_analogIn13 1
whismanoid 22:a14c19b97d0b 1245 // #define HAS_analogIn14 1
whismanoid 22:a14c19b97d0b 1246 // #define HAS_analogIn15 1
whismanoid 22:a14c19b97d0b 1247 #if HAS_analogIn0
whismanoid 22:a14c19b97d0b 1248 AnalogIn analogIn0(p15); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0
whismanoid 22:a14c19b97d0b 1249 #endif
whismanoid 22:a14c19b97d0b 1250 #if HAS_analogIn1
whismanoid 22:a14c19b97d0b 1251 AnalogIn analogIn1(p16); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1
whismanoid 22:a14c19b97d0b 1252 #endif
whismanoid 22:a14c19b97d0b 1253 #if HAS_analogIn2
whismanoid 22:a14c19b97d0b 1254 AnalogIn analogIn2(p17); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3
whismanoid 22:a14c19b97d0b 1255 #endif
whismanoid 22:a14c19b97d0b 1256 #if HAS_analogIn3
whismanoid 22:a14c19b97d0b 1257 AnalogIn analogIn3(p18); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3
whismanoid 22:a14c19b97d0b 1258 #endif
whismanoid 22:a14c19b97d0b 1259 #if HAS_analogIn4
whismanoid 22:a14c19b97d0b 1260 AnalogIn analogIn4(p19); // TARGET_LPC1768 P1.30/VBUS/AD0.4
whismanoid 22:a14c19b97d0b 1261 #endif
whismanoid 22:a14c19b97d0b 1262 #if HAS_analogIn5
whismanoid 22:a14c19b97d0b 1263 AnalogIn analogIn5(p20); // TARGET_LPC1768 P1.31/SCK1/AD0.5
whismanoid 22:a14c19b97d0b 1264 #endif
whismanoid 22:a14c19b97d0b 1265 #if HAS_analogIn6
whismanoid 22:a14c19b97d0b 1266 AnalogIn analogIn6(____);
whismanoid 22:a14c19b97d0b 1267 #endif
whismanoid 22:a14c19b97d0b 1268 #if HAS_analogIn7
whismanoid 22:a14c19b97d0b 1269 AnalogIn analogIn7(____);
whismanoid 22:a14c19b97d0b 1270 #endif
whismanoid 22:a14c19b97d0b 1271 #if HAS_analogIn8
whismanoid 22:a14c19b97d0b 1272 AnalogIn analogIn8(____);
whismanoid 22:a14c19b97d0b 1273 #endif
whismanoid 22:a14c19b97d0b 1274 #if HAS_analogIn9
whismanoid 22:a14c19b97d0b 1275 AnalogIn analogIn9(____);
whismanoid 22:a14c19b97d0b 1276 #endif
whismanoid 22:a14c19b97d0b 1277 #if HAS_analogIn10
whismanoid 22:a14c19b97d0b 1278 AnalogIn analogIn10(____);
whismanoid 22:a14c19b97d0b 1279 #endif
whismanoid 22:a14c19b97d0b 1280 #if HAS_analogIn11
whismanoid 22:a14c19b97d0b 1281 AnalogIn analogIn11(____);
whismanoid 22:a14c19b97d0b 1282 #endif
whismanoid 22:a14c19b97d0b 1283 #if HAS_analogIn12
whismanoid 22:a14c19b97d0b 1284 AnalogIn analogIn12(____);
whismanoid 22:a14c19b97d0b 1285 #endif
whismanoid 22:a14c19b97d0b 1286 #if HAS_analogIn13
whismanoid 22:a14c19b97d0b 1287 AnalogIn analogIn13(____);
whismanoid 22:a14c19b97d0b 1288 #endif
whismanoid 22:a14c19b97d0b 1289 #if HAS_analogIn14
whismanoid 22:a14c19b97d0b 1290 AnalogIn analogIn14(____);
whismanoid 22:a14c19b97d0b 1291 #endif
whismanoid 22:a14c19b97d0b 1292 #if HAS_analogIn15
whismanoid 22:a14c19b97d0b 1293 AnalogIn analogIn15(____);
whismanoid 22:a14c19b97d0b 1294 #endif
whismanoid 22:a14c19b97d0b 1295 #else
whismanoid 22:a14c19b97d0b 1296 // unknown target
whismanoid 22:a14c19b97d0b 1297 #endif
whismanoid 22:a14c19b97d0b 1298 // uncrustify-0.66.1 *INDENT-ON*
whismanoid 22:a14c19b97d0b 1299 #if HAS_analogIn0 || HAS_analogIn1 \
whismanoid 22:a14c19b97d0b 1300 || HAS_analogIn2 || HAS_analogIn3 \
whismanoid 22:a14c19b97d0b 1301 || HAS_analogIn4 || HAS_analogIn5 \
whismanoid 22:a14c19b97d0b 1302 || HAS_analogIn6 || HAS_analogIn7 \
whismanoid 22:a14c19b97d0b 1303 || HAS_analogIn8 || HAS_analogIn9 \
whismanoid 22:a14c19b97d0b 1304 || HAS_analogIn10 || HAS_analogIn11 \
whismanoid 22:a14c19b97d0b 1305 || HAS_analogIn12 || HAS_analogIn13 \
whismanoid 22:a14c19b97d0b 1306 || HAS_analogIn14 || HAS_analogIn15
whismanoid 22:a14c19b97d0b 1307 #define HAS_analogIns 1
whismanoid 22:a14c19b97d0b 1308 #endif
whismanoid 22:a14c19b97d0b 1309
whismanoid 22:a14c19b97d0b 1310 // DigitalInOut pin resource: print the pin index names to serial
whismanoid 22:a14c19b97d0b 1311 #if HAS_digitalInOuts
whismanoid 22:a14c19b97d0b 1312 void list_digitalInOutPins(Stream& serialStream)
whismanoid 22:a14c19b97d0b 1313 {
whismanoid 22:a14c19b97d0b 1314 #if HAS_digitalInOut0
whismanoid 22:a14c19b97d0b 1315 serialStream.printf(" 0");
whismanoid 22:a14c19b97d0b 1316 #endif
whismanoid 22:a14c19b97d0b 1317 #if HAS_digitalInOut1
whismanoid 22:a14c19b97d0b 1318 serialStream.printf(" 1");
whismanoid 22:a14c19b97d0b 1319 #endif
whismanoid 22:a14c19b97d0b 1320 #if HAS_digitalInOut2
whismanoid 22:a14c19b97d0b 1321 serialStream.printf(" 2");
whismanoid 22:a14c19b97d0b 1322 #endif
whismanoid 22:a14c19b97d0b 1323 #if HAS_digitalInOut3
whismanoid 22:a14c19b97d0b 1324 serialStream.printf(" 3");
whismanoid 22:a14c19b97d0b 1325 #endif
whismanoid 22:a14c19b97d0b 1326 #if HAS_digitalInOut4
whismanoid 22:a14c19b97d0b 1327 serialStream.printf(" 4");
whismanoid 22:a14c19b97d0b 1328 #endif
whismanoid 22:a14c19b97d0b 1329 #if HAS_digitalInOut5
whismanoid 22:a14c19b97d0b 1330 serialStream.printf(" 5");
whismanoid 22:a14c19b97d0b 1331 #endif
whismanoid 22:a14c19b97d0b 1332 #if HAS_digitalInOut6
whismanoid 22:a14c19b97d0b 1333 serialStream.printf(" 6");
whismanoid 22:a14c19b97d0b 1334 #endif
whismanoid 22:a14c19b97d0b 1335 #if HAS_digitalInOut7
whismanoid 22:a14c19b97d0b 1336 serialStream.printf(" 7");
whismanoid 22:a14c19b97d0b 1337 #endif
whismanoid 22:a14c19b97d0b 1338 #if HAS_digitalInOut8
whismanoid 22:a14c19b97d0b 1339 serialStream.printf(" 8");
whismanoid 22:a14c19b97d0b 1340 #endif
whismanoid 22:a14c19b97d0b 1341 #if HAS_digitalInOut9
whismanoid 22:a14c19b97d0b 1342 serialStream.printf(" 9");
whismanoid 22:a14c19b97d0b 1343 #endif
whismanoid 22:a14c19b97d0b 1344 #if HAS_digitalInOut10
whismanoid 22:a14c19b97d0b 1345 serialStream.printf(" 10");
whismanoid 22:a14c19b97d0b 1346 #endif
whismanoid 22:a14c19b97d0b 1347 #if HAS_digitalInOut11
whismanoid 22:a14c19b97d0b 1348 serialStream.printf(" 11");
whismanoid 22:a14c19b97d0b 1349 #endif
whismanoid 22:a14c19b97d0b 1350 #if HAS_digitalInOut12
whismanoid 22:a14c19b97d0b 1351 serialStream.printf(" 12");
whismanoid 22:a14c19b97d0b 1352 #endif
whismanoid 22:a14c19b97d0b 1353 #if HAS_digitalInOut13
whismanoid 22:a14c19b97d0b 1354 serialStream.printf(" 13");
whismanoid 22:a14c19b97d0b 1355 #endif
whismanoid 22:a14c19b97d0b 1356 #if HAS_digitalInOut14
whismanoid 22:a14c19b97d0b 1357 serialStream.printf(" 14");
whismanoid 22:a14c19b97d0b 1358 #endif
whismanoid 22:a14c19b97d0b 1359 #if HAS_digitalInOut15
whismanoid 22:a14c19b97d0b 1360 serialStream.printf(" 15");
whismanoid 22:a14c19b97d0b 1361 #endif
whismanoid 22:a14c19b97d0b 1362 #if HAS_digitalInOut16
whismanoid 22:a14c19b97d0b 1363 serialStream.printf(" 16");
whismanoid 22:a14c19b97d0b 1364 #endif
whismanoid 22:a14c19b97d0b 1365 #if HAS_digitalInOut17
whismanoid 22:a14c19b97d0b 1366 serialStream.printf(" 17");
whismanoid 22:a14c19b97d0b 1367 #endif
whismanoid 22:a14c19b97d0b 1368 }
whismanoid 22:a14c19b97d0b 1369 #endif
whismanoid 22:a14c19b97d0b 1370
whismanoid 22:a14c19b97d0b 1371
whismanoid 22:a14c19b97d0b 1372 // DigitalInOut pin resource: search index
whismanoid 22:a14c19b97d0b 1373 #if HAS_digitalInOuts
whismanoid 22:a14c19b97d0b 1374 DigitalInOut& find_digitalInOutPin(int cPinIndex)
whismanoid 22:a14c19b97d0b 1375 {
whismanoid 22:a14c19b97d0b 1376 switch (cPinIndex)
whismanoid 22:a14c19b97d0b 1377 {
whismanoid 22:a14c19b97d0b 1378 default: // default to the first defined digitalInOut pin
whismanoid 22:a14c19b97d0b 1379 #if HAS_digitalInOut0
whismanoid 22:a14c19b97d0b 1380 case '0': case 0x00: return digitalInOut0;
whismanoid 22:a14c19b97d0b 1381 #endif
whismanoid 22:a14c19b97d0b 1382 #if HAS_digitalInOut1
whismanoid 22:a14c19b97d0b 1383 case '1': case 0x01: return digitalInOut1;
whismanoid 22:a14c19b97d0b 1384 #endif
whismanoid 22:a14c19b97d0b 1385 #if HAS_digitalInOut2
whismanoid 22:a14c19b97d0b 1386 case '2': case 0x02: return digitalInOut2;
whismanoid 22:a14c19b97d0b 1387 #endif
whismanoid 22:a14c19b97d0b 1388 #if HAS_digitalInOut3
whismanoid 22:a14c19b97d0b 1389 case '3': case 0x03: return digitalInOut3;
whismanoid 22:a14c19b97d0b 1390 #endif
whismanoid 22:a14c19b97d0b 1391 #if HAS_digitalInOut4
whismanoid 22:a14c19b97d0b 1392 case '4': case 0x04: return digitalInOut4;
whismanoid 22:a14c19b97d0b 1393 #endif
whismanoid 22:a14c19b97d0b 1394 #if HAS_digitalInOut5
whismanoid 22:a14c19b97d0b 1395 case '5': case 0x05: return digitalInOut5;
whismanoid 22:a14c19b97d0b 1396 #endif
whismanoid 22:a14c19b97d0b 1397 #if HAS_digitalInOut6
whismanoid 22:a14c19b97d0b 1398 case '6': case 0x06: return digitalInOut6;
whismanoid 22:a14c19b97d0b 1399 #endif
whismanoid 22:a14c19b97d0b 1400 #if HAS_digitalInOut7
whismanoid 22:a14c19b97d0b 1401 case '7': case 0x07: return digitalInOut7;
whismanoid 22:a14c19b97d0b 1402 #endif
whismanoid 22:a14c19b97d0b 1403 #if HAS_digitalInOut8
whismanoid 22:a14c19b97d0b 1404 case '8': case 0x08: return digitalInOut8;
whismanoid 22:a14c19b97d0b 1405 #endif
whismanoid 22:a14c19b97d0b 1406 #if HAS_digitalInOut9
whismanoid 22:a14c19b97d0b 1407 case '9': case 0x09: return digitalInOut9;
whismanoid 22:a14c19b97d0b 1408 #endif
whismanoid 22:a14c19b97d0b 1409 #if HAS_digitalInOut10
whismanoid 22:a14c19b97d0b 1410 case 'a': case 0x0a: return digitalInOut10;
whismanoid 22:a14c19b97d0b 1411 #endif
whismanoid 22:a14c19b97d0b 1412 #if HAS_digitalInOut11
whismanoid 22:a14c19b97d0b 1413 case 'b': case 0x0b: return digitalInOut11;
whismanoid 22:a14c19b97d0b 1414 #endif
whismanoid 22:a14c19b97d0b 1415 #if HAS_digitalInOut12
whismanoid 22:a14c19b97d0b 1416 case 'c': case 0x0c: return digitalInOut12;
whismanoid 22:a14c19b97d0b 1417 #endif
whismanoid 22:a14c19b97d0b 1418 #if HAS_digitalInOut13
whismanoid 22:a14c19b97d0b 1419 case 'd': case 0x0d: return digitalInOut13;
whismanoid 22:a14c19b97d0b 1420 #endif
whismanoid 22:a14c19b97d0b 1421 #if HAS_digitalInOut14
whismanoid 22:a14c19b97d0b 1422 case 'e': case 0x0e: return digitalInOut14;
whismanoid 22:a14c19b97d0b 1423 #endif
whismanoid 22:a14c19b97d0b 1424 #if HAS_digitalInOut15
whismanoid 22:a14c19b97d0b 1425 case 'f': case 0x0f: return digitalInOut15;
whismanoid 22:a14c19b97d0b 1426 #endif
whismanoid 22:a14c19b97d0b 1427 #if HAS_digitalInOut16
whismanoid 22:a14c19b97d0b 1428 case 'g': case 0x10: return digitalInOut16;
whismanoid 22:a14c19b97d0b 1429 #endif
whismanoid 22:a14c19b97d0b 1430 #if HAS_digitalInOut17
whismanoid 22:a14c19b97d0b 1431 case 'h': case 0x11: return digitalInOut17;
whismanoid 22:a14c19b97d0b 1432 #endif
whismanoid 22:a14c19b97d0b 1433 }
whismanoid 22:a14c19b97d0b 1434 }
whismanoid 22:a14c19b97d0b 1435 #endif
whismanoid 22:a14c19b97d0b 1436
whismanoid 22:a14c19b97d0b 1437
whismanoid 22:a14c19b97d0b 1438 // AnalogIn pin resource: search index
whismanoid 22:a14c19b97d0b 1439 #if HAS_analogIns
whismanoid 22:a14c19b97d0b 1440 AnalogIn& find_analogInPin(int cPinIndex)
whismanoid 22:a14c19b97d0b 1441 {
whismanoid 22:a14c19b97d0b 1442 switch (cPinIndex)
whismanoid 22:a14c19b97d0b 1443 {
whismanoid 22:a14c19b97d0b 1444 default: // default to the first defined analogIn pin
whismanoid 22:a14c19b97d0b 1445 #if HAS_analogIn0
whismanoid 22:a14c19b97d0b 1446 case '0': case 0x00: return analogIn0;
whismanoid 22:a14c19b97d0b 1447 #endif
whismanoid 22:a14c19b97d0b 1448 #if HAS_analogIn1
whismanoid 22:a14c19b97d0b 1449 case '1': case 0x01: return analogIn1;
whismanoid 22:a14c19b97d0b 1450 #endif
whismanoid 22:a14c19b97d0b 1451 #if HAS_analogIn2
whismanoid 22:a14c19b97d0b 1452 case '2': case 0x02: return analogIn2;
whismanoid 22:a14c19b97d0b 1453 #endif
whismanoid 22:a14c19b97d0b 1454 #if HAS_analogIn3
whismanoid 22:a14c19b97d0b 1455 case '3': case 0x03: return analogIn3;
whismanoid 22:a14c19b97d0b 1456 #endif
whismanoid 22:a14c19b97d0b 1457 #if HAS_analogIn4
whismanoid 22:a14c19b97d0b 1458 case '4': case 0x04: return analogIn4;
whismanoid 22:a14c19b97d0b 1459 #endif
whismanoid 22:a14c19b97d0b 1460 #if HAS_analogIn5
whismanoid 22:a14c19b97d0b 1461 case '5': case 0x05: return analogIn5;
whismanoid 22:a14c19b97d0b 1462 #endif
whismanoid 22:a14c19b97d0b 1463 #if HAS_analogIn6
whismanoid 22:a14c19b97d0b 1464 case '6': case 0x06: return analogIn6;
whismanoid 22:a14c19b97d0b 1465 #endif
whismanoid 22:a14c19b97d0b 1466 #if HAS_analogIn7
whismanoid 22:a14c19b97d0b 1467 case '7': case 0x07: return analogIn7;
whismanoid 22:a14c19b97d0b 1468 #endif
whismanoid 22:a14c19b97d0b 1469 #if HAS_analogIn8
whismanoid 22:a14c19b97d0b 1470 case '8': case 0x08: return analogIn8;
whismanoid 22:a14c19b97d0b 1471 #endif
whismanoid 22:a14c19b97d0b 1472 #if HAS_analogIn9
whismanoid 22:a14c19b97d0b 1473 case '9': case 0x09: return analogIn9;
whismanoid 22:a14c19b97d0b 1474 #endif
whismanoid 22:a14c19b97d0b 1475 #if HAS_analogIn10
whismanoid 22:a14c19b97d0b 1476 case 'a': case 0x0a: return analogIn10;
whismanoid 22:a14c19b97d0b 1477 #endif
whismanoid 22:a14c19b97d0b 1478 #if HAS_analogIn11
whismanoid 22:a14c19b97d0b 1479 case 'b': case 0x0b: return analogIn11;
whismanoid 22:a14c19b97d0b 1480 #endif
whismanoid 22:a14c19b97d0b 1481 #if HAS_analogIn12
whismanoid 22:a14c19b97d0b 1482 case 'c': case 0x0c: return analogIn12;
whismanoid 22:a14c19b97d0b 1483 #endif
whismanoid 22:a14c19b97d0b 1484 #if HAS_analogIn13
whismanoid 22:a14c19b97d0b 1485 case 'd': case 0x0d: return analogIn13;
whismanoid 22:a14c19b97d0b 1486 #endif
whismanoid 22:a14c19b97d0b 1487 #if HAS_analogIn14
whismanoid 22:a14c19b97d0b 1488 case 'e': case 0x0e: return analogIn14;
whismanoid 22:a14c19b97d0b 1489 #endif
whismanoid 22:a14c19b97d0b 1490 #if HAS_analogIn15
whismanoid 22:a14c19b97d0b 1491 case 'f': case 0x0f: return analogIn15;
whismanoid 22:a14c19b97d0b 1492 #endif
whismanoid 22:a14c19b97d0b 1493 }
whismanoid 22:a14c19b97d0b 1494 }
whismanoid 22:a14c19b97d0b 1495 #endif
whismanoid 22:a14c19b97d0b 1496
whismanoid 22:a14c19b97d0b 1497 #if HAS_analogIns
whismanoid 22:a14c19b97d0b 1498 const float analogInPin_fullScaleVoltage[] = {
whismanoid 22:a14c19b97d0b 1499 # if defined(TARGET_MAX32630)
whismanoid 22:a14c19b97d0b 1500 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 22:a14c19b97d0b 1501 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 22:a14c19b97d0b 1502 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 22:a14c19b97d0b 1503 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 22:a14c19b97d0b 1504 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 1505 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 1506 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 1507 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1508 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1509 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 22:a14c19b97d0b 1510 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 22:a14c19b97d0b 1511 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 1512 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 1513 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 22:a14c19b97d0b 1514 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 22:a14c19b97d0b 1515 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 22:a14c19b97d0b 1516 # elif defined(TARGET_MAX32620FTHR)
whismanoid 22:a14c19b97d0b 1517 #warning "TARGET_MAX32620FTHR not previously tested; need to verify analogIn0..."
whismanoid 22:a14c19b97d0b 1518 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 22:a14c19b97d0b 1519 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 22:a14c19b97d0b 1520 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 22:a14c19b97d0b 1521 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 22:a14c19b97d0b 1522 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 1523 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 1524 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 1525 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1526 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1527 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 22:a14c19b97d0b 1528 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 22:a14c19b97d0b 1529 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 1530 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 1531 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 22:a14c19b97d0b 1532 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 22:a14c19b97d0b 1533 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 22:a14c19b97d0b 1534 #elif defined(TARGET_MAX32625MBED)
whismanoid 22:a14c19b97d0b 1535 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn0 // fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1536 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn1 // fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1537 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn2 // fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1538 ADC_FULL_SCALE_VOLTAGE * 1.0f, // analogIn3 // fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1539 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 1540 ADC_FULL_SCALE_VOLTAGE * 5.0f, // analogIn4 // AIN_5 = AIN1 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 1541 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn6 // AIN_6 = VDDB / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 1542 ADC_FULL_SCALE_VOLTAGE, // analogIn7 // AIN_7 = VDD18 fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1543 ADC_FULL_SCALE_VOLTAGE, // analogIn8 // AIN_8 = VDD12 fullscale is 1.2V
whismanoid 22:a14c19b97d0b 1544 ADC_FULL_SCALE_VOLTAGE * 2.0f, // analogIn9 // AIN_9 = VRTC / 2.0 fullscale is 2.4V
whismanoid 22:a14c19b97d0b 1545 ADC_FULL_SCALE_VOLTAGE, // analogIn10 // AIN_10 = x undefined?
whismanoid 22:a14c19b97d0b 1546 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn11 // AIN_11 = VDDIO / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 1547 ADC_FULL_SCALE_VOLTAGE * 4.0f, // analogIn12 // AIN_12 = VDDIOH / 4.0 fullscale is 4.8V
whismanoid 22:a14c19b97d0b 1548 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 22:a14c19b97d0b 1549 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 22:a14c19b97d0b 1550 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 22:a14c19b97d0b 1551 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 22:a14c19b97d0b 1552 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 22:a14c19b97d0b 1553 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 22:a14c19b97d0b 1554 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 22:a14c19b97d0b 1555 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 22:a14c19b97d0b 1556 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 22:a14c19b97d0b 1557 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 22:a14c19b97d0b 1558 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 22:a14c19b97d0b 1559 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 22:a14c19b97d0b 1560 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 22:a14c19b97d0b 1561 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 22:a14c19b97d0b 1562 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 22:a14c19b97d0b 1563 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 22:a14c19b97d0b 1564 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 22:a14c19b97d0b 1565 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 22:a14c19b97d0b 1566 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 22:a14c19b97d0b 1567 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 22:a14c19b97d0b 1568 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 22:a14c19b97d0b 1569 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 22:a14c19b97d0b 1570 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 22:a14c19b97d0b 1571 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 22:a14c19b97d0b 1572 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 22:a14c19b97d0b 1573 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 22:a14c19b97d0b 1574 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 22:a14c19b97d0b 1575 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 22:a14c19b97d0b 1576 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 22:a14c19b97d0b 1577 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 22:a14c19b97d0b 1578 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 22:a14c19b97d0b 1579 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 22:a14c19b97d0b 1580 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 22:a14c19b97d0b 1581 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 22:a14c19b97d0b 1582 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 22:a14c19b97d0b 1583 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 22:a14c19b97d0b 1584 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 22:a14c19b97d0b 1585 //#elif defined(TARGET_LPC1768)
whismanoid 22:a14c19b97d0b 1586 #else
whismanoid 22:a14c19b97d0b 1587 // unknown target
whismanoid 22:a14c19b97d0b 1588 ADC_FULL_SCALE_VOLTAGE, // analogIn0
whismanoid 22:a14c19b97d0b 1589 ADC_FULL_SCALE_VOLTAGE, // analogIn1
whismanoid 22:a14c19b97d0b 1590 ADC_FULL_SCALE_VOLTAGE, // analogIn2
whismanoid 22:a14c19b97d0b 1591 ADC_FULL_SCALE_VOLTAGE, // analogIn3
whismanoid 22:a14c19b97d0b 1592 ADC_FULL_SCALE_VOLTAGE, // analogIn4
whismanoid 22:a14c19b97d0b 1593 ADC_FULL_SCALE_VOLTAGE, // analogIn5
whismanoid 22:a14c19b97d0b 1594 ADC_FULL_SCALE_VOLTAGE, // analogIn6
whismanoid 22:a14c19b97d0b 1595 ADC_FULL_SCALE_VOLTAGE, // analogIn7
whismanoid 22:a14c19b97d0b 1596 ADC_FULL_SCALE_VOLTAGE, // analogIn8
whismanoid 22:a14c19b97d0b 1597 ADC_FULL_SCALE_VOLTAGE, // analogIn9
whismanoid 22:a14c19b97d0b 1598 ADC_FULL_SCALE_VOLTAGE, // analogIn10
whismanoid 22:a14c19b97d0b 1599 ADC_FULL_SCALE_VOLTAGE, // analogIn11
whismanoid 22:a14c19b97d0b 1600 ADC_FULL_SCALE_VOLTAGE, // analogIn12
whismanoid 22:a14c19b97d0b 1601 ADC_FULL_SCALE_VOLTAGE, // analogIn13
whismanoid 22:a14c19b97d0b 1602 ADC_FULL_SCALE_VOLTAGE, // analogIn14
whismanoid 22:a14c19b97d0b 1603 ADC_FULL_SCALE_VOLTAGE // analogIn15
whismanoid 22:a14c19b97d0b 1604 # endif
whismanoid 22:a14c19b97d0b 1605 };
whismanoid 22:a14c19b97d0b 1606 #endif
whismanoid 22:a14c19b97d0b 1607
whismanoid 22:a14c19b97d0b 1608
whismanoid 22:a14c19b97d0b 1609
whismanoid 22:a14c19b97d0b 1610
whismanoid 22:a14c19b97d0b 1611 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1612 // Option to use LEDs to show status
whismanoid 22:a14c19b97d0b 1613 #ifndef USE_LEDS
whismanoid 22:a14c19b97d0b 1614 #define USE_LEDS 1
whismanoid 22:a14c19b97d0b 1615 #endif
whismanoid 22:a14c19b97d0b 1616 #if USE_LEDS
whismanoid 22:a14c19b97d0b 1617 #if defined(TARGET_MAX32630)
whismanoid 22:a14c19b97d0b 1618 # define LED_ON 0
whismanoid 22:a14c19b97d0b 1619 # define LED_OFF 1
whismanoid 22:a14c19b97d0b 1620 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1621 #elif defined(TARGET_MAX32625MBED)
whismanoid 22:a14c19b97d0b 1622 # define LED_ON 0
whismanoid 22:a14c19b97d0b 1623 # define LED_OFF 1
whismanoid 22:a14c19b97d0b 1624 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1625 // TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM
whismanoid 22:a14c19b97d0b 1626 #elif defined(TARGET_LPC1768)
whismanoid 22:a14c19b97d0b 1627 # define LED_ON 1
whismanoid 22:a14c19b97d0b 1628 # define LED_OFF 0
whismanoid 22:a14c19b97d0b 1629 #else // not defined(TARGET_LPC1768 etc.)
whismanoid 22:a14c19b97d0b 1630 // USE_LEDS with some platform other than MAX32630, MAX32625MBED, LPC1768
whismanoid 22:a14c19b97d0b 1631 // bugfix for MAX32600MBED LED blink pattern: check if LED_ON/LED_OFF already defined
whismanoid 22:a14c19b97d0b 1632 # ifndef LED_ON
whismanoid 22:a14c19b97d0b 1633 # define LED_ON 0
whismanoid 22:a14c19b97d0b 1634 # endif
whismanoid 22:a14c19b97d0b 1635 # ifndef LED_OFF
whismanoid 22:a14c19b97d0b 1636 # define LED_OFF 1
whismanoid 22:a14c19b97d0b 1637 # endif
whismanoid 22:a14c19b97d0b 1638 //# define LED_ON 1
whismanoid 22:a14c19b97d0b 1639 //# define LED_OFF 0
whismanoid 22:a14c19b97d0b 1640 #endif // target definition
whismanoid 22:a14c19b97d0b 1641 DigitalOut led1(LED1, LED_OFF); // MAX32630FTHR: LED1 = LED_RED
whismanoid 22:a14c19b97d0b 1642 DigitalOut led2(LED2, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN
whismanoid 22:a14c19b97d0b 1643 DigitalOut led3(LED3, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE
whismanoid 22:a14c19b97d0b 1644 DigitalOut led4(LED4, LED_OFF);
whismanoid 22:a14c19b97d0b 1645 #else // USE_LEDS=0
whismanoid 22:a14c19b97d0b 1646 // issue #41 support Nucleo_F446RE
whismanoid 22:a14c19b97d0b 1647 // there are no LED indicators on the board, LED1 interferes with SPI;
whismanoid 22:a14c19b97d0b 1648 // but we still need placeholders led1 led2 led3 led4.
whismanoid 22:a14c19b97d0b 1649 // Declare DigitalOut led1 led2 led3 led4 targeting safe pins.
whismanoid 22:a14c19b97d0b 1650 // PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false
whismanoid 22:a14c19b97d0b 1651 # define LED_ON 0
whismanoid 22:a14c19b97d0b 1652 # define LED_OFF 1
whismanoid 22:a14c19b97d0b 1653 DigitalOut led1(NC, LED_OFF);
whismanoid 22:a14c19b97d0b 1654 DigitalOut led2(NC, LED_OFF);
whismanoid 22:a14c19b97d0b 1655 DigitalOut led3(NC, LED_OFF);
whismanoid 22:a14c19b97d0b 1656 DigitalOut led4(NC, LED_OFF);
whismanoid 22:a14c19b97d0b 1657 #endif // USE_LEDS
whismanoid 22:a14c19b97d0b 1658 #define led1_RFailLED led1
whismanoid 22:a14c19b97d0b 1659 #define led2_GPassLED led2
whismanoid 22:a14c19b97d0b 1660 #define led3_BBusyLED led3
whismanoid 22:a14c19b97d0b 1661
whismanoid 22:a14c19b97d0b 1662 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1663
whismanoid 22:a14c19b97d0b 1664
whismanoid 22:a14c19b97d0b 1665 // example code board support
whismanoid 22:a14c19b97d0b 1666 //MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 22:a14c19b97d0b 1667 //DigitalOut rLED(LED1);
whismanoid 22:a14c19b97d0b 1668 //DigitalOut gLED(LED2);
whismanoid 22:a14c19b97d0b 1669 //DigitalOut bLED(LED3);
whismanoid 22:a14c19b97d0b 1670 //
whismanoid 22:a14c19b97d0b 1671 // Arduino "shield" connector port definitions (MAX32625MBED shown)
whismanoid 22:a14c19b97d0b 1672 #if defined(TARGET_MAX32625MBED)
whismanoid 22:a14c19b97d0b 1673 #define A0 AIN_0
whismanoid 22:a14c19b97d0b 1674 #define A1 AIN_1
whismanoid 22:a14c19b97d0b 1675 #define A2 AIN_2
whismanoid 22:a14c19b97d0b 1676 #define A3 AIN_3
whismanoid 22:a14c19b97d0b 1677 #define D0 P0_0
whismanoid 22:a14c19b97d0b 1678 #define D1 P0_1
whismanoid 22:a14c19b97d0b 1679 #define D2 P0_2
whismanoid 22:a14c19b97d0b 1680 #define D3 P0_3
whismanoid 22:a14c19b97d0b 1681 #define D4 P0_4
whismanoid 22:a14c19b97d0b 1682 #define D5 P0_5
whismanoid 22:a14c19b97d0b 1683 #define D6 P0_6
whismanoid 22:a14c19b97d0b 1684 #define D7 P0_7
whismanoid 22:a14c19b97d0b 1685 #define D8 P1_4
whismanoid 22:a14c19b97d0b 1686 #define D9 P1_5
whismanoid 22:a14c19b97d0b 1687 #define D10 P1_3
whismanoid 22:a14c19b97d0b 1688 #define D11 P1_1
whismanoid 22:a14c19b97d0b 1689 #define D12 P1_2
whismanoid 22:a14c19b97d0b 1690 #define D13 P1_0
whismanoid 22:a14c19b97d0b 1691 #endif
whismanoid 22:a14c19b97d0b 1692
whismanoid 22:a14c19b97d0b 1693 // example code declare SPI interface
whismanoid 22:a14c19b97d0b 1694 #if defined(TARGET_MAX32625MBED)
whismanoid 22:a14c19b97d0b 1695 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 22:a14c19b97d0b 1696 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
whismanoid 22:a14c19b97d0b 1697 #elif defined(TARGET_MAX32600MBED)
whismanoid 22:a14c19b97d0b 1698 SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 22:a14c19b97d0b 1699 DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
whismanoid 22:a14c19b97d0b 1700 #else
whismanoid 22:a14c19b97d0b 1701 SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
whismanoid 22:a14c19b97d0b 1702 DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
whismanoid 22:a14c19b97d0b 1703 #endif
whismanoid 22:a14c19b97d0b 1704
whismanoid 22:a14c19b97d0b 1705 // example code declare GPIO interface pins
whismanoid 22:a14c19b97d0b 1706 // AnalogOut FB_pin(Px_x_PortName_To_Be_Determined); // Analog Input to MAX5171 device
whismanoid 22:a14c19b97d0b 1707 DigitalOut RS_pin(D9); // Digital Configuration Input to MAX5171 device
whismanoid 22:a14c19b97d0b 1708 DigitalOut PDLb_pin(D8); // Digital Configuration Input to MAX5171 device
whismanoid 22:a14c19b97d0b 1709 DigitalOut CLRb_pin(D7); // Digital Configuration Input to MAX5171 device
whismanoid 22:a14c19b97d0b 1710 DigitalOut SHDN_pin(D6); // Digital Configuration Input to MAX5171 device
whismanoid 22:a14c19b97d0b 1711 // AnalogIn OUT_pin(A0); // Analog Output from MAX5171 device
whismanoid 22:a14c19b97d0b 1712 DigitalIn UPO_pin(D5); // Digital General-Purpose Output from MAX5171 device
whismanoid 22:a14c19b97d0b 1713 // example code declare device instance
whismanoid 22:a14c19b97d0b 1714 MAX5171 g_MAX5171_device(spi, spi_cs, RS_pin, PDLb_pin, CLRb_pin, SHDN_pin, UPO_pin, MAX5171::MAX5171_IC);
whismanoid 22:a14c19b97d0b 1715
whismanoid 22:a14c19b97d0b 1716
whismanoid 22:a14c19b97d0b 1717 //----------------------------------------
whismanoid 22:a14c19b97d0b 1718 // Global SPI options
whismanoid 22:a14c19b97d0b 1719 //
whismanoid 22:a14c19b97d0b 1720
whismanoid 22:a14c19b97d0b 1721 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1722 // Optional Diagnostic function to print SPI transactions
whismanoid 22:a14c19b97d0b 1723 #ifndef MAX5171_ONSPIPRINT
whismanoid 22:a14c19b97d0b 1724 #define MAX5171_ONSPIPRINT 1
whismanoid 22:a14c19b97d0b 1725 #endif // MAX5171_ONSPIPRINT
whismanoid 22:a14c19b97d0b 1726
whismanoid 22:a14c19b97d0b 1727 //----------------------------------------
whismanoid 22:a14c19b97d0b 1728 // Global I2C options
whismanoid 22:a14c19b97d0b 1729 //
whismanoid 22:a14c19b97d0b 1730
whismanoid 22:a14c19b97d0b 1731 #define APPLICATION_ArduinoPinsMonitor 1
whismanoid 22:a14c19b97d0b 1732
whismanoid 22:a14c19b97d0b 1733 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1734 // use BUTTON1 trigger some action
whismanoid 22:a14c19b97d0b 1735 #if defined(TARGET_MAX32630)
whismanoid 22:a14c19b97d0b 1736 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 22:a14c19b97d0b 1737 #define HAS_BUTTON2_DEMO 0
whismanoid 22:a14c19b97d0b 1738 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 22:a14c19b97d0b 1739 #elif defined(TARGET_MAX32625PICO)
whismanoid 22:a14c19b97d0b 1740 #warning "TARGET_MAX32625PICO not previously tested; need to define buttons..."
whismanoid 22:a14c19b97d0b 1741 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 22:a14c19b97d0b 1742 #define HAS_BUTTON2_DEMO 0
whismanoid 22:a14c19b97d0b 1743 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 22:a14c19b97d0b 1744 #elif defined(TARGET_MAX32625)
whismanoid 22:a14c19b97d0b 1745 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 22:a14c19b97d0b 1746 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 22:a14c19b97d0b 1747 #elif defined(TARGET_MAX32620FTHR)
whismanoid 22:a14c19b97d0b 1748 #warning "TARGET_MAX32620FTHR not previously tested; need to define buttons..."
whismanoid 22:a14c19b97d0b 1749 #define BUTTON1 SW1
whismanoid 22:a14c19b97d0b 1750 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 22:a14c19b97d0b 1751 #define HAS_BUTTON2_DEMO 0
whismanoid 22:a14c19b97d0b 1752 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 22:a14c19b97d0b 1753 #elif defined(TARGET_NUCLEO_F446RE)
whismanoid 22:a14c19b97d0b 1754 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 22:a14c19b97d0b 1755 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 22:a14c19b97d0b 1756 #elif defined(TARGET_NUCLEO_F401RE)
whismanoid 22:a14c19b97d0b 1757 #define HAS_BUTTON1_DEMO_INTERRUPT 0
whismanoid 22:a14c19b97d0b 1758 #define HAS_BUTTON2_DEMO_INTERRUPT 0
whismanoid 22:a14c19b97d0b 1759 #else
whismanoid 22:a14c19b97d0b 1760 #warning "target not previously tested; need to define buttons..."
whismanoid 22:a14c19b97d0b 1761 #endif
whismanoid 22:a14c19b97d0b 1762 //
whismanoid 22:a14c19b97d0b 1763 #ifndef HAS_BUTTON1_DEMO
whismanoid 22:a14c19b97d0b 1764 #define HAS_BUTTON1_DEMO 0
whismanoid 22:a14c19b97d0b 1765 #endif
whismanoid 22:a14c19b97d0b 1766 #ifndef HAS_BUTTON2_DEMO
whismanoid 22:a14c19b97d0b 1767 #define HAS_BUTTON2_DEMO 0
whismanoid 22:a14c19b97d0b 1768 #endif
whismanoid 22:a14c19b97d0b 1769 //
whismanoid 22:a14c19b97d0b 1770 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 22:a14c19b97d0b 1771 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 22:a14c19b97d0b 1772 #ifndef HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 22:a14c19b97d0b 1773 #define HAS_BUTTON1_DEMO_INTERRUPT_POLLING 1
whismanoid 22:a14c19b97d0b 1774 #endif
whismanoid 22:a14c19b97d0b 1775 //
whismanoid 22:a14c19b97d0b 1776 #ifndef HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 22:a14c19b97d0b 1777 #define HAS_BUTTON1_DEMO_INTERRUPT 1
whismanoid 22:a14c19b97d0b 1778 #endif
whismanoid 22:a14c19b97d0b 1779 #ifndef HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 22:a14c19b97d0b 1780 #define HAS_BUTTON2_DEMO_INTERRUPT 1
whismanoid 22:a14c19b97d0b 1781 #endif
whismanoid 22:a14c19b97d0b 1782 //
whismanoid 22:a14c19b97d0b 1783 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 22:a14c19b97d0b 1784 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 22:a14c19b97d0b 1785 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 22:a14c19b97d0b 1786 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 22:a14c19b97d0b 1787 DigitalIn button1(BUTTON1);
whismanoid 22:a14c19b97d0b 1788 # else
whismanoid 22:a14c19b97d0b 1789 InterruptIn button1(BUTTON1);
whismanoid 22:a14c19b97d0b 1790 # endif
whismanoid 22:a14c19b97d0b 1791 #elif HAS_BUTTON1_DEMO
whismanoid 22:a14c19b97d0b 1792 DigitalIn button1(BUTTON1);
whismanoid 22:a14c19b97d0b 1793 #endif
whismanoid 22:a14c19b97d0b 1794 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 22:a14c19b97d0b 1795 # if HAS_BUTTON1_DEMO_INTERRUPT_POLLING
whismanoid 22:a14c19b97d0b 1796 // avoid runtime error on button1 press [mbed-os-5.11]
whismanoid 22:a14c19b97d0b 1797 // instead of using InterruptIn, use DigitalIn and poll in main while(1)
whismanoid 22:a14c19b97d0b 1798 DigitalIn button2(BUTTON2);
whismanoid 22:a14c19b97d0b 1799 # else
whismanoid 22:a14c19b97d0b 1800 InterruptIn button2(BUTTON2);
whismanoid 22:a14c19b97d0b 1801 # endif
whismanoid 22:a14c19b97d0b 1802 #elif HAS_BUTTON2_DEMO
whismanoid 22:a14c19b97d0b 1803 DigitalIn button2(BUTTON2);
whismanoid 22:a14c19b97d0b 1804 #endif
whismanoid 22:a14c19b97d0b 1805
whismanoid 22:a14c19b97d0b 1806 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1807 // When user presses button BUTTON1, perform self test
whismanoid 22:a14c19b97d0b 1808 #if HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 22:a14c19b97d0b 1809 void onButton1FallingEdge(void)
whismanoid 22:a14c19b97d0b 1810 {
whismanoid 22:a14c19b97d0b 1811 void SelfTest(CmdLine & cmdLine);
whismanoid 22:a14c19b97d0b 1812 SelfTest(cmdLine_serial);
whismanoid 22:a14c19b97d0b 1813 }
whismanoid 22:a14c19b97d0b 1814 #endif // HAS_BUTTON1_DEMO_INTERRUPT
whismanoid 22:a14c19b97d0b 1815
whismanoid 22:a14c19b97d0b 1816 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1817 // When user presses button BUTTON2, perform demo configuration
whismanoid 22:a14c19b97d0b 1818 #if HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 22:a14c19b97d0b 1819 void onButton2FallingEdge(void)
whismanoid 22:a14c19b97d0b 1820 {
whismanoid 22:a14c19b97d0b 1821 // TBD demo configuration
whismanoid 22:a14c19b97d0b 1822 // TODO diagnostic LED
whismanoid 22:a14c19b97d0b 1823 led1 = LED_OFF; led2 = LED_OFF; led3 = LED_ON; // diagnostic rbg led BLUE
whismanoid 22:a14c19b97d0b 1824 }
whismanoid 22:a14c19b97d0b 1825 #endif // HAS_BUTTON2_DEMO_INTERRUPT
whismanoid 22:a14c19b97d0b 1826
whismanoid 22:a14c19b97d0b 1827 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1828 void SelfTest(CmdLine & cmdLine)
whismanoid 22:a14c19b97d0b 1829 {
whismanoid 22:a14c19b97d0b 1830 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1831 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 22:a14c19b97d0b 1832 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 22:a14c19b97d0b 1833 MaximTinyTester tinyTester(cmdLine, analogIn4, analogIn5, analogIn2, analogIn3, analogIn0, analogIn4, led1_RFailLED, led2_GPassLED, led3_BBusyLED);
whismanoid 22:a14c19b97d0b 1834 tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[4]; // board support
whismanoid 22:a14c19b97d0b 1835 tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[5]; // board support
whismanoid 22:a14c19b97d0b 1836 tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support
whismanoid 22:a14c19b97d0b 1837 tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support
whismanoid 22:a14c19b97d0b 1838 tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[0]; // board support
whismanoid 22:a14c19b97d0b 1839 tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[1]; // board support
whismanoid 22:a14c19b97d0b 1840 // low range channels AIN0, AIN1, AIN2, AIN3
whismanoid 22:a14c19b97d0b 1841 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 22:a14c19b97d0b 1842 // Platform board uses simple analog inputs
whismanoid 22:a14c19b97d0b 1843 MaximTinyTester tinyTester(cmdLine, analogIn0, analogIn1, analogIn2, analogIn3, analogIn4, analogIn5, led1_RFailLED, led2_GPassLED, led3_BBusyLED);
whismanoid 22:a14c19b97d0b 1844 tinyTester.analogInPin_fullScaleVoltage[0] = analogInPin_fullScaleVoltage[0]; // board support
whismanoid 22:a14c19b97d0b 1845 tinyTester.analogInPin_fullScaleVoltage[1] = analogInPin_fullScaleVoltage[1]; // board support
whismanoid 22:a14c19b97d0b 1846 tinyTester.analogInPin_fullScaleVoltage[2] = analogInPin_fullScaleVoltage[2]; // board support
whismanoid 22:a14c19b97d0b 1847 tinyTester.analogInPin_fullScaleVoltage[3] = analogInPin_fullScaleVoltage[3]; // board support
whismanoid 22:a14c19b97d0b 1848 tinyTester.analogInPin_fullScaleVoltage[4] = analogInPin_fullScaleVoltage[4]; // board support
whismanoid 22:a14c19b97d0b 1849 tinyTester.analogInPin_fullScaleVoltage[5] = analogInPin_fullScaleVoltage[5]; // board support
whismanoid 22:a14c19b97d0b 1850 #endif
whismanoid 22:a14c19b97d0b 1851 tinyTester.clear();
whismanoid 22:a14c19b97d0b 1852
whismanoid 22:a14c19b97d0b 1853 //
whismanoid 22:a14c19b97d0b 1854 #if INJECT_SELFTEST_FAIL
whismanoid 22:a14c19b97d0b 1855 // Test of the pass/fail report mechanism
whismanoid 22:a14c19b97d0b 1856 tinyTester.FAIL();
whismanoid 22:a14c19b97d0b 1857 cmdLine.serial().print(F("injecting one false failure for test reporting"));
whismanoid 22:a14c19b97d0b 1858 #endif
whismanoid 22:a14c19b97d0b 1859 //
whismanoid 22:a14c19b97d0b 1860 // Report number of pass and number of fail test results
whismanoid 22:a14c19b97d0b 1861 tinyTester.Report_Summary();
whismanoid 22:a14c19b97d0b 1862 }
whismanoid 22:a14c19b97d0b 1863
whismanoid 22:a14c19b97d0b 1864
whismanoid 22:a14c19b97d0b 1865 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1866 inline void print_command_prompt()
whismanoid 22:a14c19b97d0b 1867 {
whismanoid 22:a14c19b97d0b 1868 cmdLine_serial.serial().printf("\r\n> ");
whismanoid 22:a14c19b97d0b 1869
whismanoid 22:a14c19b97d0b 1870 }
whismanoid 22:a14c19b97d0b 1871
whismanoid 22:a14c19b97d0b 1872
whismanoid 22:a14c19b97d0b 1873 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 1874 void pinsMonitor_submenu_onEOLcommandParser(CmdLine& cmdLine)
whismanoid 22:a14c19b97d0b 1875 {
whismanoid 22:a14c19b97d0b 1876 // % diagnostic commands submenu
whismanoid 22:a14c19b97d0b 1877 // %Hpin -- digital output high
whismanoid 22:a14c19b97d0b 1878 // %Lpin -- digital output low
whismanoid 22:a14c19b97d0b 1879 // %?pin -- digital input
whismanoid 22:a14c19b97d0b 1880 // %A %Apin -- analog input
whismanoid 22:a14c19b97d0b 1881 // %Ppin df=xx -- pwm output
whismanoid 22:a14c19b97d0b 1882 // %Wpin -- measure high pulsewidth input in usec
whismanoid 22:a14c19b97d0b 1883 // %wpin -- measure low pulsewidth input in usec
whismanoid 22:a14c19b97d0b 1884 // %I... -- I2C diagnostics
whismanoid 22:a14c19b97d0b 1885 // %IP -- I2C probe
whismanoid 22:a14c19b97d0b 1886 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 22:a14c19b97d0b 1887 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 22:a14c19b97d0b 1888 // %IR ADDR=? RD=? -- read
whismanoid 22:a14c19b97d0b 1889 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 22:a14c19b97d0b 1890 // %S... -- SPI diagnostics
whismanoid 22:a14c19b97d0b 1891 // %SC sclk=1Mhz -- SPI configure
whismanoid 22:a14c19b97d0b 1892 // %SW -- write (write and read)
whismanoid 22:a14c19b97d0b 1893 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 22:a14c19b97d0b 1894 // A-Z,a-z,0-9 reserved for application use
whismanoid 22:a14c19b97d0b 1895 //
whismanoid 22:a14c19b97d0b 1896 char strPinIndex[3];
whismanoid 22:a14c19b97d0b 1897 strPinIndex[0] = cmdLine[2];
whismanoid 22:a14c19b97d0b 1898 strPinIndex[1] = cmdLine[3];
whismanoid 22:a14c19b97d0b 1899 strPinIndex[2] = '\0';
whismanoid 22:a14c19b97d0b 1900 int pinIndex = strtoul(strPinIndex, NULL, 10); // strtol(str, NULL, 10): get decimal value
whismanoid 22:a14c19b97d0b 1901 //cmdLine.serial().printf(" pinIndex=%d ", pinIndex);
whismanoid 22:a14c19b97d0b 1902 //
whismanoid 22:a14c19b97d0b 1903 // get next character
whismanoid 22:a14c19b97d0b 1904 switch (cmdLine[1])
whismanoid 22:a14c19b97d0b 1905 {
whismanoid 22:a14c19b97d0b 1906 #if HAS_digitalInOuts
whismanoid 22:a14c19b97d0b 1907 case 'H': case 'h':
whismanoid 22:a14c19b97d0b 1908 {
whismanoid 22:a14c19b97d0b 1909 // %Hpin -- digital output high
whismanoid 22:a14c19b97d0b 1910 #if ARDUINO_STYLE
whismanoid 22:a14c19b97d0b 1911 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 22:a14c19b97d0b 1912 digitalWrite(pinIndex, HIGH); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 22:a14c19b97d0b 1913 #else
whismanoid 22:a14c19b97d0b 1914 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 22:a14c19b97d0b 1915 digitalInOutPin.output();
whismanoid 22:a14c19b97d0b 1916 digitalInOutPin.write(1);
whismanoid 22:a14c19b97d0b 1917 #endif
whismanoid 22:a14c19b97d0b 1918 cmdLine.serial().printf(" digitalInOutPin %d Output High ", pinIndex);
whismanoid 22:a14c19b97d0b 1919 }
whismanoid 22:a14c19b97d0b 1920 break;
whismanoid 22:a14c19b97d0b 1921 case 'L': case 'l':
whismanoid 22:a14c19b97d0b 1922 {
whismanoid 22:a14c19b97d0b 1923 // %Lpin -- digital output low
whismanoid 22:a14c19b97d0b 1924 #if ARDUINO_STYLE
whismanoid 22:a14c19b97d0b 1925 pinMode(pinIndex, OUTPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 22:a14c19b97d0b 1926 digitalWrite(pinIndex, LOW); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 22:a14c19b97d0b 1927 #else
whismanoid 22:a14c19b97d0b 1928 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 22:a14c19b97d0b 1929 digitalInOutPin.output();
whismanoid 22:a14c19b97d0b 1930 digitalInOutPin.write(0);
whismanoid 22:a14c19b97d0b 1931 #endif
whismanoid 22:a14c19b97d0b 1932 cmdLine.serial().printf(" digitalInOutPin %d Output Low ", pinIndex);
whismanoid 22:a14c19b97d0b 1933 }
whismanoid 22:a14c19b97d0b 1934 break;
whismanoid 22:a14c19b97d0b 1935 case '?':
whismanoid 22:a14c19b97d0b 1936 {
whismanoid 22:a14c19b97d0b 1937 // %?pin -- digital input
whismanoid 22:a14c19b97d0b 1938 #if ARDUINO_STYLE
whismanoid 22:a14c19b97d0b 1939 pinMode(pinIndex, INPUT); // digital pins 0, 1, 2, .. 13, analog input pins A0, A1, .. A5
whismanoid 22:a14c19b97d0b 1940 #else
whismanoid 22:a14c19b97d0b 1941 DigitalInOut& digitalInOutPin = find_digitalInOutPin(pinIndex);
whismanoid 22:a14c19b97d0b 1942 digitalInOutPin.input();
whismanoid 22:a14c19b97d0b 1943 #endif
whismanoid 22:a14c19b97d0b 1944 serial.printf(" digitalInOutPin %d Input ", pinIndex);
whismanoid 22:a14c19b97d0b 1945 #if ARDUINO_STYLE
whismanoid 22:a14c19b97d0b 1946 int value = digitalRead(pinIndex);
whismanoid 22:a14c19b97d0b 1947 #else
whismanoid 22:a14c19b97d0b 1948 int value = digitalInOutPin.read();
whismanoid 22:a14c19b97d0b 1949 #endif
whismanoid 22:a14c19b97d0b 1950 cmdLine.serial().printf("%d ", value);
whismanoid 22:a14c19b97d0b 1951 }
whismanoid 22:a14c19b97d0b 1952 break;
whismanoid 22:a14c19b97d0b 1953 #endif
whismanoid 22:a14c19b97d0b 1954 //
whismanoid 22:a14c19b97d0b 1955 #if HAS_analogIns
whismanoid 22:a14c19b97d0b 1956 case 'A': case 'a':
whismanoid 22:a14c19b97d0b 1957 {
whismanoid 22:a14c19b97d0b 1958 // %A %Apin -- analog input
whismanoid 22:a14c19b97d0b 1959 #if analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 22:a14c19b97d0b 1960 // Platform board uses AIN4,AIN5,.. as high range of AIN0,AIN1,..
whismanoid 22:a14c19b97d0b 1961 for (int pinIndex = 0; pinIndex < 2; pinIndex++)
whismanoid 22:a14c19b97d0b 1962 {
whismanoid 22:a14c19b97d0b 1963 int cPinIndex = '0' + pinIndex;
whismanoid 22:a14c19b97d0b 1964 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 22:a14c19b97d0b 1965 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 22:a14c19b97d0b 1966 float normValue_0_1 = analogInPin.read();
whismanoid 22:a14c19b97d0b 1967 //
whismanoid 22:a14c19b97d0b 1968 int pinIndexH = pinIndex + 4;
whismanoid 22:a14c19b97d0b 1969 int cPinIndexH = '0' + pinIndexH;
whismanoid 22:a14c19b97d0b 1970 AnalogIn& analogInPinH = find_analogInPin(cPinIndexH);
whismanoid 22:a14c19b97d0b 1971 float adc_full_scale_voltageH = analogInPin_fullScaleVoltage[pinIndexH];
whismanoid 22:a14c19b97d0b 1972 float normValueH_0_1 = analogInPinH.read();
whismanoid 22:a14c19b97d0b 1973 //
whismanoid 22:a14c19b97d0b 1974 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV AIN%c = %7.3f%% = %1.3fV \r\n",
whismanoid 22:a14c19b97d0b 1975 cPinIndex,
whismanoid 22:a14c19b97d0b 1976 normValue_0_1 * 100.0,
whismanoid 22:a14c19b97d0b 1977 normValue_0_1 * adc_full_scale_voltage,
whismanoid 22:a14c19b97d0b 1978 cPinIndexH,
whismanoid 22:a14c19b97d0b 1979 normValueH_0_1 * 100.0,
whismanoid 22:a14c19b97d0b 1980 normValueH_0_1 * adc_full_scale_voltageH
whismanoid 22:a14c19b97d0b 1981 );
whismanoid 22:a14c19b97d0b 1982 }
whismanoid 22:a14c19b97d0b 1983 for (int pinIndex = 2; pinIndex < 4; pinIndex++)
whismanoid 22:a14c19b97d0b 1984 {
whismanoid 22:a14c19b97d0b 1985 int cPinIndex = '0' + pinIndex;
whismanoid 22:a14c19b97d0b 1986 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 22:a14c19b97d0b 1987 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 22:a14c19b97d0b 1988 float normValue_0_1 = analogInPin.read();
whismanoid 22:a14c19b97d0b 1989 //
whismanoid 22:a14c19b97d0b 1990 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n",
whismanoid 22:a14c19b97d0b 1991 cPinIndex,
whismanoid 22:a14c19b97d0b 1992 normValue_0_1 * 100.0,
whismanoid 22:a14c19b97d0b 1993 normValue_0_1 * adc_full_scale_voltage
whismanoid 22:a14c19b97d0b 1994 );
whismanoid 22:a14c19b97d0b 1995 }
whismanoid 22:a14c19b97d0b 1996 #else // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 22:a14c19b97d0b 1997 // Platform board uses simple analog inputs
whismanoid 22:a14c19b97d0b 1998 // assume standard Arduino analog inputs A0-A5
whismanoid 22:a14c19b97d0b 1999 for (int pinIndex = 0; pinIndex < 6; pinIndex++)
whismanoid 22:a14c19b97d0b 2000 {
whismanoid 22:a14c19b97d0b 2001 int cPinIndex = '0' + pinIndex;
whismanoid 22:a14c19b97d0b 2002 AnalogIn& analogInPin = find_analogInPin(cPinIndex);
whismanoid 22:a14c19b97d0b 2003 float adc_full_scale_voltage = analogInPin_fullScaleVoltage[pinIndex];
whismanoid 22:a14c19b97d0b 2004 float normValue_0_1 = analogInPin.read();
whismanoid 22:a14c19b97d0b 2005 //
whismanoid 22:a14c19b97d0b 2006 cmdLine.serial().printf("AIN%c = %7.3f%% = %1.3fV\r\n",
whismanoid 22:a14c19b97d0b 2007 cPinIndex,
whismanoid 22:a14c19b97d0b 2008 normValue_0_1 * 100.0,
whismanoid 22:a14c19b97d0b 2009 normValue_0_1 * adc_full_scale_voltage
whismanoid 22:a14c19b97d0b 2010 );
whismanoid 22:a14c19b97d0b 2011 }
whismanoid 22:a14c19b97d0b 2012 #endif // analogIn4_IS_HIGH_RANGE_OF_analogIn0
whismanoid 22:a14c19b97d0b 2013 }
whismanoid 22:a14c19b97d0b 2014 break;
whismanoid 22:a14c19b97d0b 2015 #endif
whismanoid 22:a14c19b97d0b 2016 //
whismanoid 22:a14c19b97d0b 2017 #if HAS_SPI2_MAX541
whismanoid 22:a14c19b97d0b 2018 case 'D': case 'd':
whismanoid 22:a14c19b97d0b 2019 {
whismanoid 22:a14c19b97d0b 2020 // %D -- DAC output MAX541 (SPI2) -- need cmdLine.parse_float(voltageV)
whismanoid 22:a14c19b97d0b 2021 // MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 22:a14c19b97d0b 2022 float voltageV = max541.Get_Voltage();
whismanoid 22:a14c19b97d0b 2023 // if (cmdLine[2] == '+') {
whismanoid 22:a14c19b97d0b 2024 // // %D+
whismanoid 22:a14c19b97d0b 2025 // voltageV = voltageV * 1.25f;
whismanoid 22:a14c19b97d0b 2026 // if (voltageV >= max541.VRef) voltageV = max541.VRef;
whismanoid 22:a14c19b97d0b 2027 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 22:a14c19b97d0b 2028 // }
whismanoid 22:a14c19b97d0b 2029 // else if (cmdLine[2] == '-') {
whismanoid 22:a14c19b97d0b 2030 // // %D-
whismanoid 22:a14c19b97d0b 2031 // voltageV = voltageV * 0.75f;
whismanoid 22:a14c19b97d0b 2032 // if (voltageV < 0.1f) voltageV = 0.1f;
whismanoid 22:a14c19b97d0b 2033 // SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 22:a14c19b97d0b 2034 // }
whismanoid 22:a14c19b97d0b 2035 if (cmdLine.parse_float("V", voltageV))
whismanoid 22:a14c19b97d0b 2036 {
whismanoid 22:a14c19b97d0b 2037 // %D V=1.234 -- set voltage
whismanoid 22:a14c19b97d0b 2038 max541.Set_Voltage(voltageV);
whismanoid 22:a14c19b97d0b 2039 }
whismanoid 22:a14c19b97d0b 2040 else if (cmdLine.parse_float("TEST", voltageV))
whismanoid 22:a14c19b97d0b 2041 {
whismanoid 22:a14c19b97d0b 2042 // %D TEST=1.234 -- set voltage and compare with AIN0
whismanoid 22:a14c19b97d0b 2043 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 22:a14c19b97d0b 2044 }
whismanoid 22:a14c19b97d0b 2045 else if (cmdLine.parse_float("CAL", voltageV))
whismanoid 22:a14c19b97d0b 2046 {
whismanoid 22:a14c19b97d0b 2047 // %D CAL=1.234 -- calibrate VRef and compare with AIN0
whismanoid 22:a14c19b97d0b 2048
whismanoid 22:a14c19b97d0b 2049 max541.Set_Code(0x8000); // we don't know the fullscale voltage yet, so set code to midscale
whismanoid 22:a14c19b97d0b 2050 double max541_midscale_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 2051 const int average_count = 100;
whismanoid 22:a14c19b97d0b 2052 const double average_K = 0.25;
whismanoid 22:a14c19b97d0b 2053 for (int count = 0; count < average_count; count++) {
whismanoid 22:a14c19b97d0b 2054 double measurement_V = analogInPin_fullScaleVoltage[4] * analogIn4.read(); // TARGET_MAX32630 J1.5 AIN_4 = AIN0 / 5.0 fullscale is 6.0V
whismanoid 22:a14c19b97d0b 2055 max541_midscale_V = ((1 - average_K) * max541_midscale_V) + (average_K * measurement_V);
whismanoid 22:a14c19b97d0b 2056 }
whismanoid 22:a14c19b97d0b 2057 max541.VRef = 2.0 * max541_midscale_V;
whismanoid 22:a14c19b97d0b 2058 cmdLine.serial().printf(
whismanoid 22:a14c19b97d0b 2059 "\r\n MAX541 midscale = %1.3fV, so fullscale = %1.3fV",
whismanoid 22:a14c19b97d0b 2060 max541_midscale_V, max541.VRef);
whismanoid 22:a14c19b97d0b 2061 // Detect whether MAX541 is really connected to MAX32625MBED.AIN0/AIN4
whismanoid 22:a14c19b97d0b 2062 voltageV = 1.0f;
whismanoid 22:a14c19b97d0b 2063 SelfTest_MAX541_Voltage(cmdLine, max541, voltageV);
whismanoid 22:a14c19b97d0b 2064 }
whismanoid 22:a14c19b97d0b 2065 else {
whismanoid 22:a14c19b97d0b 2066 // %D -- print MAX541 DAC status
whismanoid 22:a14c19b97d0b 2067 cmdLine.serial().printf("MAX541 code=0x%4.4x = %1.3fV VRef=%1.3fV\r\n",
whismanoid 22:a14c19b97d0b 2068 max541.Get_Code(), max541.Get_Voltage(), max541.VRef);
whismanoid 22:a14c19b97d0b 2069 }
whismanoid 22:a14c19b97d0b 2070 }
whismanoid 22:a14c19b97d0b 2071 break;
whismanoid 22:a14c19b97d0b 2072 #endif
whismanoid 22:a14c19b97d0b 2073
whismanoid 22:a14c19b97d0b 2074 //
whismanoid 22:a14c19b97d0b 2075 #if HAS_I2C // SUPPORT_I2C
whismanoid 22:a14c19b97d0b 2076 case 'I': case 'i':
whismanoid 22:a14c19b97d0b 2077 // %I... -- I2C diagnostics
whismanoid 22:a14c19b97d0b 2078 // %IP -- I2C probe
whismanoid 22:a14c19b97d0b 2079 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 22:a14c19b97d0b 2080 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 22:a14c19b97d0b 2081 // %IR ADDR=? RD=? -- read
whismanoid 22:a14c19b97d0b 2082 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 22:a14c19b97d0b 2083 // get next character
whismanoid 22:a14c19b97d0b 2084 // TODO: parse cmdLine arg (ADDR=\d+)? --> g_I2C_deviceAddress7
whismanoid 22:a14c19b97d0b 2085 cmdLine.parse_byte_hex("ADDR", g_I2C_deviceAddress7);
whismanoid 22:a14c19b97d0b 2086 // TODO: parse cmdLine arg (RD=\d)? --> g_I2C_read_count
whismanoid 22:a14c19b97d0b 2087 g_I2C_read_count = 0; // read count must be reset every command
whismanoid 22:a14c19b97d0b 2088 cmdLine.parse_byte_dec("RD", g_I2C_read_count);
whismanoid 22:a14c19b97d0b 2089 // TODO: parse cmdLine arg (CMD=\d)? --> g_I2C_command_regAddress
whismanoid 22:a14c19b97d0b 2090 cmdLine.parse_byte_hex("CMD", g_I2C_command_regAddress);
whismanoid 22:a14c19b97d0b 2091 switch (cmdLine[2])
whismanoid 22:a14c19b97d0b 2092 {
whismanoid 22:a14c19b97d0b 2093 case 'P': case 'p':
whismanoid 22:a14c19b97d0b 2094 {
whismanoid 22:a14c19b97d0b 2095 // %IP -- I2C probe
whismanoid 22:a14c19b97d0b 2096 HuntAttachedI2CDevices(cmdLine, 0x03, 0x77);
whismanoid 22:a14c19b97d0b 2097 }
whismanoid 22:a14c19b97d0b 2098 break;
whismanoid 22:a14c19b97d0b 2099 case 'C': case 'c':
whismanoid 22:a14c19b97d0b 2100 {
whismanoid 22:a14c19b97d0b 2101 bool isUpdatedI2CConfig = false;
whismanoid 22:a14c19b97d0b 2102 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 22:a14c19b97d0b 2103 // parse cmdLine arg (SCL=\d+(kHZ|MHZ)?)? --> g_I2C_SCL_Hz
whismanoid 22:a14c19b97d0b 2104 if (cmdLine.parse_frequency_Hz("SCL", g_I2C_SCL_Hz))
whismanoid 22:a14c19b97d0b 2105 {
whismanoid 22:a14c19b97d0b 2106 isUpdatedI2CConfig = true;
whismanoid 22:a14c19b97d0b 2107 // TODO1: validate g_I2C_SCL_Hz against system clock frequency F_CPU
whismanoid 22:a14c19b97d0b 2108 if (g_I2C_SCL_Hz > limit_max_I2C_SCL_Hz)
whismanoid 22:a14c19b97d0b 2109 {
whismanoid 22:a14c19b97d0b 2110 g_I2C_SCL_Hz = limit_max_I2C_SCL_Hz;
whismanoid 22:a14c19b97d0b 2111 }
whismanoid 22:a14c19b97d0b 2112 if (g_I2C_SCL_Hz < limit_min_I2C_SCL_Hz)
whismanoid 22:a14c19b97d0b 2113 {
whismanoid 22:a14c19b97d0b 2114 g_I2C_SCL_Hz = limit_min_I2C_SCL_Hz;
whismanoid 22:a14c19b97d0b 2115 }
whismanoid 22:a14c19b97d0b 2116 }
whismanoid 22:a14c19b97d0b 2117 if (isUpdatedI2CConfig)
whismanoid 22:a14c19b97d0b 2118 {
whismanoid 22:a14c19b97d0b 2119 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 22:a14c19b97d0b 2120 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 22:a14c19b97d0b 2121 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 22:a14c19b97d0b 2122 i2cMaster.start();
whismanoid 22:a14c19b97d0b 2123 i2cMaster.stop();
whismanoid 22:a14c19b97d0b 2124 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 22:a14c19b97d0b 2125 cmdLine.serial().printf(
whismanoid 22:a14c19b97d0b 2126 "\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 22:a14c19b97d0b 2127 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 22:a14c19b97d0b 2128 (g_I2C_SCL_Hz / 1000.));
whismanoid 22:a14c19b97d0b 2129 i2cMaster.start();
whismanoid 22:a14c19b97d0b 2130 i2cMaster.stop();
whismanoid 22:a14c19b97d0b 2131 }
whismanoid 22:a14c19b97d0b 2132 }
whismanoid 22:a14c19b97d0b 2133 break;
whismanoid 22:a14c19b97d0b 2134 case 'W': case 'w':
whismanoid 22:a14c19b97d0b 2135 {
whismanoid 22:a14c19b97d0b 2136 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 22:a14c19b97d0b 2137 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 22:a14c19b97d0b 2138 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 22:a14c19b97d0b 2139 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 22:a14c19b97d0b 2140 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 22:a14c19b97d0b 2141 #define MAX_I2C_BYTE_COUNT 32
whismanoid 22:a14c19b97d0b 2142 size_t byteCount = byteCount;
whismanoid 22:a14c19b97d0b 2143 static char mosiData[MAX_I2C_BYTE_COUNT];
whismanoid 22:a14c19b97d0b 2144 static char misoData[MAX_I2C_BYTE_COUNT];
whismanoid 22:a14c19b97d0b 2145 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 22:a14c19b97d0b 2146 MAX_I2C_BYTE_COUNT))
whismanoid 22:a14c19b97d0b 2147 {
whismanoid 22:a14c19b97d0b 2148 // hex dump mosiData[0..byteCount-1]
whismanoid 22:a14c19b97d0b 2149 cmdLine.serial().printf(
whismanoid 22:a14c19b97d0b 2150 "\r\nADDR=0x%2.2x=(0x%2.2x>>1) byteCount:%d RD=%d\r\nI2C MOSI->",
whismanoid 22:a14c19b97d0b 2151 g_I2C_deviceAddress7,
whismanoid 22:a14c19b97d0b 2152 (g_I2C_deviceAddress7 << 1), byteCount, g_I2C_read_count);
whismanoid 22:a14c19b97d0b 2153 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 22:a14c19b97d0b 2154 {
whismanoid 22:a14c19b97d0b 2155 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 22:a14c19b97d0b 2156 }
whismanoid 22:a14c19b97d0b 2157 //
whismanoid 22:a14c19b97d0b 2158 // TODO: i2c transfer
whismanoid 22:a14c19b97d0b 2159 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 22:a14c19b97d0b 2160 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 22:a14c19b97d0b 2161 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 22:a14c19b97d0b 2162 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 22:a14c19b97d0b 2163 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 22:a14c19b97d0b 2164 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 22:a14c19b97d0b 2165 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 22:a14c19b97d0b 2166 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 22:a14c19b97d0b 2167 // /* 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 22:a14c19b97d0b 2168 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 22:a14c19b97d0b 2169 const int addr8bit = g_I2C_deviceAddress7 << 1; // 8bit I2C address, 0x90
whismanoid 22:a14c19b97d0b 2170 unsigned int misoLength = 0;
whismanoid 22:a14c19b97d0b 2171 bool repeated = (g_I2C_read_count > 0);
whismanoid 22:a14c19b97d0b 2172 //
whismanoid 22:a14c19b97d0b 2173 int writeStatus = i2cMaster.write (addr8bit, mosiData, byteCount, repeated);
whismanoid 22:a14c19b97d0b 2174 switch (writeStatus)
whismanoid 22:a14c19b97d0b 2175 {
whismanoid 22:a14c19b97d0b 2176 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 22:a14c19b97d0b 2177 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 22:a14c19b97d0b 2178 default: cmdLine.serial().printf(" {writeStatus 0x%2.2X} ",
whismanoid 22:a14c19b97d0b 2179 writeStatus);
whismanoid 22:a14c19b97d0b 2180 }
whismanoid 22:a14c19b97d0b 2181 if (repeated)
whismanoid 22:a14c19b97d0b 2182 {
whismanoid 22:a14c19b97d0b 2183 int readStatus =
whismanoid 22:a14c19b97d0b 2184 i2cMaster.read (addr8bit, misoData, g_I2C_read_count, false);
whismanoid 22:a14c19b97d0b 2185 switch (readStatus)
whismanoid 22:a14c19b97d0b 2186 {
whismanoid 22:a14c19b97d0b 2187 case 1: cmdLine.serial().printf(" nack "); break;
whismanoid 22:a14c19b97d0b 2188 case 0: cmdLine.serial().printf(" ack "); break;
whismanoid 22:a14c19b97d0b 2189 default: cmdLine.serial().printf(" {readStatus 0x%2.2X} ",
whismanoid 22:a14c19b97d0b 2190 readStatus);
whismanoid 22:a14c19b97d0b 2191 }
whismanoid 22:a14c19b97d0b 2192 }
whismanoid 22:a14c19b97d0b 2193 //
whismanoid 22:a14c19b97d0b 2194 if (misoLength > 0)
whismanoid 22:a14c19b97d0b 2195 {
whismanoid 22:a14c19b97d0b 2196 // hex dump misoData[0..byteCount-1]
whismanoid 22:a14c19b97d0b 2197 cmdLine.serial().printf(" MISO<-");
whismanoid 22:a14c19b97d0b 2198 for (unsigned int byteIndex = 0; byteIndex < g_I2C_read_count;
whismanoid 22:a14c19b97d0b 2199 byteIndex++)
whismanoid 22:a14c19b97d0b 2200 {
whismanoid 22:a14c19b97d0b 2201 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 22:a14c19b97d0b 2202 }
whismanoid 22:a14c19b97d0b 2203 }
whismanoid 22:a14c19b97d0b 2204 cmdLine.serial().printf(" ");
whismanoid 22:a14c19b97d0b 2205 }
whismanoid 22:a14c19b97d0b 2206 }
whismanoid 22:a14c19b97d0b 2207 break;
whismanoid 22:a14c19b97d0b 2208 case 'R': case 'r':
whismanoid 22:a14c19b97d0b 2209 {
whismanoid 22:a14c19b97d0b 2210 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 22:a14c19b97d0b 2211 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 22:a14c19b97d0b 2212 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 22:a14c19b97d0b 2213 // %IR ADDR=? RD=? -- read
whismanoid 22:a14c19b97d0b 2214 // TODO: i2c transfer
whismanoid 22:a14c19b97d0b 2215 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 22:a14c19b97d0b 2216 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 22:a14c19b97d0b 2217 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 22:a14c19b97d0b 2218 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 22:a14c19b97d0b 2219 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 22:a14c19b97d0b 2220 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 22:a14c19b97d0b 2221 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 22:a14c19b97d0b 2222 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 22:a14c19b97d0b 2223 // /* 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 22:a14c19b97d0b 2224 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 22:a14c19b97d0b 2225 }
whismanoid 22:a14c19b97d0b 2226 break;
whismanoid 22:a14c19b97d0b 2227 case '^':
whismanoid 22:a14c19b97d0b 2228 {
whismanoid 22:a14c19b97d0b 2229 // declare in narrower scope: MAX32625MBED I2C i2cMaster(...)
whismanoid 22:a14c19b97d0b 2230 I2C i2cMaster(I2C0_SDA, I2C0_SCL); // sda scl TARGET_MAX32635MBED: P1_6, P1_7 Arduino 10-pin header
whismanoid 22:a14c19b97d0b 2231 i2cMaster.frequency(g_I2C_SCL_Hz);
whismanoid 22:a14c19b97d0b 2232 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 22:a14c19b97d0b 2233 // TODO: i2c transfer
whismanoid 22:a14c19b97d0b 2234 //const int addr7bit = 0x48; // 7 bit I2C address
whismanoid 22:a14c19b97d0b 2235 //const int addr8bit = 0x48 << 1; // 8bit I2C address, 0x90
whismanoid 22:a14c19b97d0b 2236 // /* int */ i2cMaster.read (int addr8bit, char *data, int length, bool repeated=false) // Read from an I2C slave.
whismanoid 22:a14c19b97d0b 2237 // /* int */ i2cMaster.read (int ack) // Read a single byte from the I2C bus.
whismanoid 22:a14c19b97d0b 2238 // /* int */ i2cMaster.write (int addr8bit, const char *data, int length, bool repeated=false) // Write to an I2C slave.
whismanoid 22:a14c19b97d0b 2239 // /* int */ i2cMaster.write (int data) // Write single byte out on the I2C bus.
whismanoid 22:a14c19b97d0b 2240 // /* void */ i2cMaster.start (void) // Creates a start condition on the I2C bus.
whismanoid 22:a14c19b97d0b 2241 // /* void */ i2cMaster.stop (void) // Creates a stop condition on the I2C bus.
whismanoid 22:a14c19b97d0b 2242 // /* 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 22:a14c19b97d0b 2243 // /* void */ i2cMaster.abort_transfer () // Abort the ongoing I2C transfer. More...
whismanoid 22:a14c19b97d0b 2244 }
whismanoid 22:a14c19b97d0b 2245 break;
whismanoid 22:a14c19b97d0b 2246 } // switch(cmdLine[2])
whismanoid 22:a14c19b97d0b 2247 break;
whismanoid 22:a14c19b97d0b 2248 #endif
whismanoid 22:a14c19b97d0b 2249 //
whismanoid 22:a14c19b97d0b 2250 #if HAS_SPI // SUPPORT_SPI
whismanoid 22:a14c19b97d0b 2251 case 'S': case 's':
whismanoid 22:a14c19b97d0b 2252 {
whismanoid 22:a14c19b97d0b 2253 // %S... -- SPI diagnostics
whismanoid 22:a14c19b97d0b 2254 // %SC sclk=1Mhz -- SPI configure
whismanoid 22:a14c19b97d0b 2255 // %SW -- write (write and read)
whismanoid 22:a14c19b97d0b 2256 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 22:a14c19b97d0b 2257 //
whismanoid 22:a14c19b97d0b 2258 // Process arguments SCLK=\d+(kHZ|MHZ) CPOL=\d CPHA=\d
whismanoid 22:a14c19b97d0b 2259 bool isUpdatedSPIConfig = false;
whismanoid 22:a14c19b97d0b 2260 // parse cmdLine arg (CPOL=\d)? --> g_SPI_dataMode | SPI_MODE2
whismanoid 22:a14c19b97d0b 2261 // parse cmdLine arg (CPHA=\d)? --> g_SPI_dataMode | SPI_MODE1
whismanoid 22:a14c19b97d0b 2262 if (cmdLine.parse_flag("CPOL", g_SPI_dataMode, SPI_MODE2))
whismanoid 22:a14c19b97d0b 2263 {
whismanoid 22:a14c19b97d0b 2264 isUpdatedSPIConfig = true;
whismanoid 22:a14c19b97d0b 2265 }
whismanoid 22:a14c19b97d0b 2266 if (cmdLine.parse_flag("CPHA", g_SPI_dataMode, SPI_MODE1))
whismanoid 22:a14c19b97d0b 2267 {
whismanoid 22:a14c19b97d0b 2268 isUpdatedSPIConfig = true;
whismanoid 22:a14c19b97d0b 2269 }
whismanoid 22:a14c19b97d0b 2270 if (cmdLine.parse_flag("CS", g_SPI_cs_state, 1))
whismanoid 22:a14c19b97d0b 2271 {
whismanoid 22:a14c19b97d0b 2272 isUpdatedSPIConfig = true;
whismanoid 22:a14c19b97d0b 2273 }
whismanoid 22:a14c19b97d0b 2274 // parse cmdLine arg (SCLK=\d+(kHZ|MHZ)?)? --> g_SPI_SCLK_Hz
whismanoid 22:a14c19b97d0b 2275 if (cmdLine.parse_frequency_Hz("SCLK", g_SPI_SCLK_Hz))
whismanoid 22:a14c19b97d0b 2276 {
whismanoid 22:a14c19b97d0b 2277 isUpdatedSPIConfig = true;
whismanoid 22:a14c19b97d0b 2278 // TODO1: validate g_SPI_SCLK_Hz against system clock frequency F_CPU
whismanoid 22:a14c19b97d0b 2279 if (g_SPI_SCLK_Hz > limit_max_SPI_SCLK_Hz)
whismanoid 22:a14c19b97d0b 2280 {
whismanoid 22:a14c19b97d0b 2281 g_SPI_SCLK_Hz = limit_max_SPI_SCLK_Hz;
whismanoid 22:a14c19b97d0b 2282 }
whismanoid 22:a14c19b97d0b 2283 if (g_SPI_SCLK_Hz < limit_min_SPI_SCLK_Hz)
whismanoid 22:a14c19b97d0b 2284 {
whismanoid 22:a14c19b97d0b 2285 g_SPI_SCLK_Hz = limit_min_SPI_SCLK_Hz;
whismanoid 22:a14c19b97d0b 2286 }
whismanoid 22:a14c19b97d0b 2287 }
whismanoid 22:a14c19b97d0b 2288 // Update SPI configuration
whismanoid 22:a14c19b97d0b 2289 if (isUpdatedSPIConfig)
whismanoid 22:a14c19b97d0b 2290 {
whismanoid 22:a14c19b97d0b 2291 // %SC sclk=1Mhz -- SPI configure
whismanoid 22:a14c19b97d0b 2292 spi_cs = g_SPI_cs_state;
whismanoid 22:a14c19b97d0b 2293 spi.format(8,g_SPI_dataMode); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0
whismanoid 22:a14c19b97d0b 2294 #if APPLICATION_MAX5715
whismanoid 22:a14c19b97d0b 2295 g_MAX5715_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 22:a14c19b97d0b 2296 #elif APPLICATION_MAX11131
whismanoid 22:a14c19b97d0b 2297 g_MAX11131_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 22:a14c19b97d0b 2298 #elif APPLICATION_MAX5171
whismanoid 22:a14c19b97d0b 2299 g_MAX5171_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 22:a14c19b97d0b 2300 #elif APPLICATION_MAX11410
whismanoid 22:a14c19b97d0b 2301 g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 22:a14c19b97d0b 2302 #elif APPLICATION_MAX12345
whismanoid 22:a14c19b97d0b 2303 g_MAX12345_device.spi_frequency(g_SPI_SCLK_Hz);
whismanoid 22:a14c19b97d0b 2304 #else
whismanoid 22:a14c19b97d0b 2305 spi.frequency(g_SPI_SCLK_Hz); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 22:a14c19b97d0b 2306 #endif
whismanoid 22:a14c19b97d0b 2307 //
whismanoid 22:a14c19b97d0b 2308 double ideal_divisor = ((double)SystemCoreClock) / g_SPI_SCLK_Hz;
whismanoid 22:a14c19b97d0b 2309 int actual_divisor = (int)(ideal_divisor + 0.0); // frequency divisor truncate
whismanoid 22:a14c19b97d0b 2310 double actual_SCLK_Hz = SystemCoreClock / actual_divisor;
whismanoid 22:a14c19b97d0b 2311 //
whismanoid 22:a14c19b97d0b 2312 // 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 22:a14c19b97d0b 2313 cmdLine.serial().printf(
whismanoid 22:a14c19b97d0b 2314 "\r\n %%SC CPOL=%d CPHA=%d CS=%d SCLK=%ld=%1.3fMHz (%1.1fMHz/%1.2f = actual %1.3fMHz) -- SPI config",
whismanoid 22:a14c19b97d0b 2315 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 22:a14c19b97d0b 2316 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0),
whismanoid 22:a14c19b97d0b 2317 g_SPI_cs_state,
whismanoid 22:a14c19b97d0b 2318 g_SPI_SCLK_Hz,
whismanoid 22:a14c19b97d0b 2319 (g_SPI_SCLK_Hz / 1000000.),
whismanoid 22:a14c19b97d0b 2320 ((double)(SystemCoreClock / 1000000.)),
whismanoid 22:a14c19b97d0b 2321 ideal_divisor,
whismanoid 22:a14c19b97d0b 2322 (actual_SCLK_Hz / 1000000.)
whismanoid 22:a14c19b97d0b 2323 );
whismanoid 22:a14c19b97d0b 2324 }
whismanoid 22:a14c19b97d0b 2325 // get next character
whismanoid 22:a14c19b97d0b 2326 switch (cmdLine[2])
whismanoid 22:a14c19b97d0b 2327 {
whismanoid 22:a14c19b97d0b 2328 case 'C': case 's':
whismanoid 22:a14c19b97d0b 2329 // %SC sclk=1Mhz -- SPI configure
whismanoid 22:a14c19b97d0b 2330 break;
whismanoid 22:a14c19b97d0b 2331 case 'D': case 'd':
whismanoid 22:a14c19b97d0b 2332 // %SD -- SPI diagnostic messages enable
whismanoid 22:a14c19b97d0b 2333 if (g_MAX5171_device.onSPIprint) {
whismanoid 22:a14c19b97d0b 2334 g_MAX5171_device.onSPIprint = NULL;
whismanoid 22:a14c19b97d0b 2335 }
whismanoid 22:a14c19b97d0b 2336 else {
whismanoid 22:a14c19b97d0b 2337 void onSPIprint_handler(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]);
whismanoid 22:a14c19b97d0b 2338 g_MAX5171_device.onSPIprint = onSPIprint_handler;
whismanoid 22:a14c19b97d0b 2339 }
whismanoid 22:a14c19b97d0b 2340 break;
whismanoid 22:a14c19b97d0b 2341 case 'W': case 'R': case 'w': case 'r':
whismanoid 22:a14c19b97d0b 2342 {
whismanoid 22:a14c19b97d0b 2343 // %SW -- write (write and read)
whismanoid 22:a14c19b97d0b 2344 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 22:a14c19b97d0b 2345 // parse cmdLine byte list --> int byteCount; int mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 22:a14c19b97d0b 2346 #define MAX_SPI_BYTE_COUNT 32
whismanoid 22:a14c19b97d0b 2347 size_t byteCount = byteCount;
whismanoid 22:a14c19b97d0b 2348 static char mosiData[MAX_SPI_BYTE_COUNT];
whismanoid 22:a14c19b97d0b 2349 static char misoData[MAX_SPI_BYTE_COUNT];
whismanoid 22:a14c19b97d0b 2350 if (cmdLine.parse_byteCount_byteList_hex(byteCount, mosiData,
whismanoid 22:a14c19b97d0b 2351 MAX_SPI_BYTE_COUNT))
whismanoid 22:a14c19b97d0b 2352 {
whismanoid 22:a14c19b97d0b 2353 // hex dump mosiData[0..byteCount-1]
whismanoid 22:a14c19b97d0b 2354 cmdLine.serial().printf("\r\nSPI");
whismanoid 22:a14c19b97d0b 2355 if (byteCount > 7) {
whismanoid 22:a14c19b97d0b 2356 cmdLine.serial().printf(" byteCount:%d", byteCount);
whismanoid 22:a14c19b97d0b 2357 }
whismanoid 22:a14c19b97d0b 2358 cmdLine.serial().printf(" MOSI->");
whismanoid 22:a14c19b97d0b 2359 for (unsigned int byteIndex = 0; byteIndex < byteCount; byteIndex++)
whismanoid 22:a14c19b97d0b 2360 {
whismanoid 22:a14c19b97d0b 2361 cmdLine.serial().printf(" 0x%2.2X", mosiData[byteIndex]);
whismanoid 22:a14c19b97d0b 2362 }
whismanoid 22:a14c19b97d0b 2363 spi_cs = 0;
whismanoid 22:a14c19b97d0b 2364 unsigned int numBytesTransferred =
whismanoid 22:a14c19b97d0b 2365 spi.write(mosiData, byteCount, misoData, byteCount);
whismanoid 22:a14c19b97d0b 2366 spi_cs = 1;
whismanoid 22:a14c19b97d0b 2367 // hex dump misoData[0..byteCount-1]
whismanoid 22:a14c19b97d0b 2368 cmdLine.serial().printf(" MISO<-");
whismanoid 22:a14c19b97d0b 2369 for (unsigned int byteIndex = 0; byteIndex < numBytesTransferred;
whismanoid 22:a14c19b97d0b 2370 byteIndex++)
whismanoid 22:a14c19b97d0b 2371 {
whismanoid 22:a14c19b97d0b 2372 cmdLine.serial().printf(" 0x%2.2X", misoData[byteIndex]);
whismanoid 22:a14c19b97d0b 2373 }
whismanoid 22:a14c19b97d0b 2374 cmdLine.serial().printf(" ");
whismanoid 22:a14c19b97d0b 2375 }
whismanoid 22:a14c19b97d0b 2376 }
whismanoid 22:a14c19b97d0b 2377 break;
whismanoid 22:a14c19b97d0b 2378 } // switch(cmdLine[2])
whismanoid 22:a14c19b97d0b 2379 } // case 'S': // %S... -- SPI diagnostics
whismanoid 22:a14c19b97d0b 2380 break;
whismanoid 22:a14c19b97d0b 2381 #endif
whismanoid 22:a14c19b97d0b 2382 //
whismanoid 22:a14c19b97d0b 2383 // A-Z,a-z,0-9 reserved for application use
whismanoid 22:a14c19b97d0b 2384 } // switch(cmdLine[1])
whismanoid 22:a14c19b97d0b 2385 } // end void pinsMonitor_submenu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 22:a14c19b97d0b 2386
whismanoid 22:a14c19b97d0b 2387
whismanoid 22:a14c19b97d0b 2388 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 2389 void main_menu_status(CmdLine & cmdLine)
whismanoid 22:a14c19b97d0b 2390 {
whismanoid 22:a14c19b97d0b 2391 cmdLine.serial().printf("\r\nMain menu");
whismanoid 22:a14c19b97d0b 2392
whismanoid 22:a14c19b97d0b 2393 cmdLine.serial().printf(" MAX5171 14-bit Force/Sense DAC");
whismanoid 22:a14c19b97d0b 2394
whismanoid 22:a14c19b97d0b 2395 //cmdLine.serial().print(" %s", TARGET_NAME);
whismanoid 22:a14c19b97d0b 2396 if (cmdLine.nameStr())
whismanoid 22:a14c19b97d0b 2397 {
whismanoid 22:a14c19b97d0b 2398 cmdLine.serial().printf(" [%s]", cmdLine.nameStr());
whismanoid 22:a14c19b97d0b 2399
whismanoid 22:a14c19b97d0b 2400 }
whismanoid 22:a14c19b97d0b 2401 cmdLine.serial().printf("\r\n ? -- help");
whismanoid 22:a14c19b97d0b 2402
whismanoid 22:a14c19b97d0b 2403 }
whismanoid 22:a14c19b97d0b 2404
whismanoid 22:a14c19b97d0b 2405
whismanoid 22:a14c19b97d0b 2406 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 2407 void main_menu_help(CmdLine & cmdLine)
whismanoid 22:a14c19b97d0b 2408 {
whismanoid 22:a14c19b97d0b 2409 // ? -- help
whismanoid 22:a14c19b97d0b 2410 //~ cmdLine.serial().print(F("\r\nMenu:"));
whismanoid 22:a14c19b97d0b 2411 cmdLine.serial().printf("\r\n # -- lines beginning with # are comments");
whismanoid 22:a14c19b97d0b 2412
whismanoid 22:a14c19b97d0b 2413 cmdLine.serial().printf("\r\n . -- SelfTest");
whismanoid 22:a14c19b97d0b 2414
whismanoid 22:a14c19b97d0b 2415 //cmdLine.serial().print(F("\r\n ! -- Initial Configuration"));
whismanoid 22:a14c19b97d0b 2416 //
whismanoid 22:a14c19b97d0b 2417 // % standardize diagnostic commands
whismanoid 22:a14c19b97d0b 2418 // %Hpin -- digital output high
whismanoid 22:a14c19b97d0b 2419 // %Lpin -- digital output low
whismanoid 22:a14c19b97d0b 2420 // %?pin -- digital input
whismanoid 22:a14c19b97d0b 2421 // %A %Apin -- analog input
whismanoid 22:a14c19b97d0b 2422 // %Ppin df=xx -- pwm output
whismanoid 22:a14c19b97d0b 2423 // %Wpin -- measure high pulsewidth input in usec
whismanoid 22:a14c19b97d0b 2424 // %wpin -- measure low pulsewidth input in usec
whismanoid 22:a14c19b97d0b 2425 // %I... -- I2C diagnostics
whismanoid 22:a14c19b97d0b 2426 // %IP -- I2C probe
whismanoid 22:a14c19b97d0b 2427 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 22:a14c19b97d0b 2428 // %IW ADDR=? cmd=? data,data,data -- write
whismanoid 22:a14c19b97d0b 2429 // %IR ADDR=? RD=? -- read
whismanoid 22:a14c19b97d0b 2430 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 22:a14c19b97d0b 2431 // %S... -- SPI diagnostics
whismanoid 22:a14c19b97d0b 2432 // %SC sclk=1Mhz -- SPI configure
whismanoid 22:a14c19b97d0b 2433 // %SW -- write (write and read)
whismanoid 22:a14c19b97d0b 2434 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 22:a14c19b97d0b 2435 // A-Z,a-z,0-9 reserved for application use
whismanoid 22:a14c19b97d0b 2436 //
whismanoid 22:a14c19b97d0b 2437 #if HAS_digitalInOuts
whismanoid 22:a14c19b97d0b 2438 // %Hpin -- digital output high
whismanoid 22:a14c19b97d0b 2439 // %Lpin -- digital output low
whismanoid 22:a14c19b97d0b 2440 // %?pin -- digital input
whismanoid 22:a14c19b97d0b 2441 cmdLine.serial().printf("\r\n %%Hn {pin:");
whismanoid 22:a14c19b97d0b 2442 list_digitalInOutPins(cmdLine.serial());
whismanoid 22:a14c19b97d0b 2443 cmdLine.serial().printf("} -- High Output");
whismanoid 22:a14c19b97d0b 2444 cmdLine.serial().printf("\r\n %%Ln {pin:");
whismanoid 22:a14c19b97d0b 2445 list_digitalInOutPins(cmdLine.serial());
whismanoid 22:a14c19b97d0b 2446 cmdLine.serial().printf("} -- Low Output");
whismanoid 22:a14c19b97d0b 2447 cmdLine.serial().printf("\r\n %%?n {pin:");
whismanoid 22:a14c19b97d0b 2448 list_digitalInOutPins(cmdLine.serial());
whismanoid 22:a14c19b97d0b 2449 cmdLine.serial().printf("} -- Input");
whismanoid 22:a14c19b97d0b 2450 #endif
whismanoid 22:a14c19b97d0b 2451
whismanoid 22:a14c19b97d0b 2452 #if HAS_analogIns
whismanoid 22:a14c19b97d0b 2453 // Menu A) analogRead A0..7
whismanoid 22:a14c19b97d0b 2454 // %A %Apin -- analog input
whismanoid 22:a14c19b97d0b 2455 // analogRead(pinIndex) // analog input pins A0, A1, A2, A3, A4, A5; float voltage = analogRead(A0) * (5.0 / 1023.0)
whismanoid 22:a14c19b97d0b 2456 cmdLine.serial().printf("\r\n %%A -- analogRead");
whismanoid 22:a14c19b97d0b 2457 #endif
whismanoid 22:a14c19b97d0b 2458
whismanoid 22:a14c19b97d0b 2459 #if HAS_SPI2_MAX541
whismanoid 22:a14c19b97d0b 2460 // TODO1: MAX541 max541(spi2_max541, spi2_max541_cs);
whismanoid 22:a14c19b97d0b 2461 cmdLine.serial().printf("\r\n %%D -- DAC output MAX541 (SPI2)");
whismanoid 22:a14c19b97d0b 2462 #endif
whismanoid 22:a14c19b97d0b 2463
whismanoid 22:a14c19b97d0b 2464 #if HAS_I2C // SUPPORT_I2C
whismanoid 22:a14c19b97d0b 2465 // TODO: support I2C HAS_I2C // SUPPORT_I2C
whismanoid 22:a14c19b97d0b 2466 // VERIFY: I2C utility commands SUPPORT_I2C
whismanoid 22:a14c19b97d0b 2467 // VERIFY: report g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)) from last Wire_Sr.setClock(I2C_SCL_Hz);
whismanoid 22:a14c19b97d0b 2468 // %I... -- I2C diagnostics
whismanoid 22:a14c19b97d0b 2469 // %IP -- I2C probe
whismanoid 22:a14c19b97d0b 2470 // %IC scl=100khz ADDR=? -- I2C configure
whismanoid 22:a14c19b97d0b 2471 // %IW byte byte ... byte RD=? ADDR=0x -- write
whismanoid 22:a14c19b97d0b 2472 // %IR ADDR=? RD=? -- read
whismanoid 22:a14c19b97d0b 2473 // %I^ cmd=? -- i2c_smbus_read_word_data
whismanoid 22:a14c19b97d0b 2474 //g_I2C_SCL_Hz = (F_CPU / ((TWBR * 2) + 16)); // 'F_CPU' 'TWBR' not declared in this scope
whismanoid 22:a14c19b97d0b 2475 cmdLine.serial().printf("\r\n %%IC ADDR=0x%2.2x=(0x%2.2x>>1) SCL=%d=%1.3fkHz -- I2C config",
whismanoid 22:a14c19b97d0b 2476 g_I2C_deviceAddress7, (g_I2C_deviceAddress7 << 1), g_I2C_SCL_Hz,
whismanoid 22:a14c19b97d0b 2477 (g_I2C_SCL_Hz / 1000.));
whismanoid 22:a14c19b97d0b 2478 cmdLine.serial().printf("\r\n %%IW byte byte ... byte RD=? ADDR=0x%2.2x -- I2C write/read",
whismanoid 22:a14c19b97d0b 2479 g_I2C_deviceAddress7);
whismanoid 22:a14c19b97d0b 2480 //
whismanoid 22:a14c19b97d0b 2481 #if SUPPORT_I2C
whismanoid 22:a14c19b97d0b 2482 // Menu ^ cmd=?) i2c_smbus_read_word_data
whismanoid 22:a14c19b97d0b 2483 cmdLine.serial().printf("\r\n %%I^ cmd=? -- i2c_smbus_read_word_data");
whismanoid 22:a14c19b97d0b 2484 // test low-level I2C i2c_smbus_read_word_data
whismanoid 22:a14c19b97d0b 2485 #endif // SUPPORT_I2C
whismanoid 22:a14c19b97d0b 2486 //cmdLine.serial().printf(" H) Hunt for attached I2C devices");
whismanoid 22:a14c19b97d0b 2487 cmdLine.serial().printf("\r\n %%IP -- I2C Probe for attached devices");
whismanoid 22:a14c19b97d0b 2488 // cmdLine.serial().printf(" s) search i2c address");
whismanoid 22:a14c19b97d0b 2489 #endif // SUPPORT_I2C
whismanoid 22:a14c19b97d0b 2490
whismanoid 22:a14c19b97d0b 2491 #if HAS_SPI // SUPPORT_SPI
whismanoid 22:a14c19b97d0b 2492 // TODO: support SPI HAS_SPI // SUPPORT_SPI
whismanoid 22:a14c19b97d0b 2493 // SPI test command S (mosiData)+
whismanoid 22:a14c19b97d0b 2494 // %S... -- SPI diagnostics
whismanoid 22:a14c19b97d0b 2495 // %SC sclk=1Mhz -- SPI configure
whismanoid 22:a14c19b97d0b 2496 // %SW -- write (write and read)
whismanoid 22:a14c19b97d0b 2497 // %SR -- read (alias for %SW because SPI always write and read)
whismanoid 22:a14c19b97d0b 2498 // spi.format(8,0); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=0 rising edge (initial default)
whismanoid 22:a14c19b97d0b 2499 // spi.format(8,1); // int bits_must_be_8, int mode=0_3 CPOL=0,CPHA=1 falling edge (initial default)
whismanoid 22:a14c19b97d0b 2500 // spi.format(8,2); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=0 falling edge (initial default)
whismanoid 22:a14c19b97d0b 2501 // spi.format(8,3); // int bits_must_be_8, int mode=0_3 CPOL=1,CPHA=1 rising edge (initial default)
whismanoid 22:a14c19b97d0b 2502 // spi.frequency(1000000); // int SCLK_Hz=1000000 = 1MHz (initial default)
whismanoid 22:a14c19b97d0b 2503 // mode | POL PHA
whismanoid 22:a14c19b97d0b 2504 // -----+--------
whismanoid 22:a14c19b97d0b 2505 // 0 | 0 0
whismanoid 22:a14c19b97d0b 2506 // 1 | 0 1
whismanoid 22:a14c19b97d0b 2507 // 2 | 1 0
whismanoid 22:a14c19b97d0b 2508 // 3 | 1 1
whismanoid 22:a14c19b97d0b 2509 //cmdLine.serial().printf(" S) SPI mosi,mosi,...mosi hex bytes SCLK=1000000 CPOL=0 CPHA=0");
whismanoid 22:a14c19b97d0b 2510 // 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 22:a14c19b97d0b 2511 cmdLine.serial().printf("\r\n %%SC SCLK=%ld=%1.3fMHz CPOL=%d CPHA=%d -- SPI config",
whismanoid 22:a14c19b97d0b 2512 g_SPI_SCLK_Hz, (g_SPI_SCLK_Hz / 1000000.),
whismanoid 22:a14c19b97d0b 2513 ((g_SPI_dataMode & SPI_MODE2) ? 1 : 0),
whismanoid 22:a14c19b97d0b 2514 ((g_SPI_dataMode & SPI_MODE1) ? 1 : 0));
whismanoid 22:a14c19b97d0b 2515 cmdLine.serial().printf("\r\n %%SD -- SPI diagnostic messages ");
whismanoid 22:a14c19b97d0b 2516 if (g_MAX5171_device.onSPIprint) {
whismanoid 22:a14c19b97d0b 2517 cmdLine.serial().printf("hide");
whismanoid 22:a14c19b97d0b 2518 }
whismanoid 22:a14c19b97d0b 2519 else {
whismanoid 22:a14c19b97d0b 2520 cmdLine.serial().printf("show");
whismanoid 22:a14c19b97d0b 2521 }
whismanoid 22:a14c19b97d0b 2522 cmdLine.serial().printf("\r\n %%SW mosi,mosi,...mosi -- SPI write hex bytes");
whismanoid 22:a14c19b97d0b 2523 // VERIFY: parse new SPI settings parse_strCommandArgs() SCLK=1000000 CPOL=0 CPHA=0
whismanoid 22:a14c19b97d0b 2524 #endif // SUPPORT_SPI
whismanoid 22:a14c19b97d0b 2525 //
whismanoid 22:a14c19b97d0b 2526 // Application-specific commands (help text) here
whismanoid 22:a14c19b97d0b 2527 //
whismanoid 22:a14c19b97d0b 2528 #if APPLICATION_ArduinoPinsMonitor
whismanoid 22:a14c19b97d0b 2529 cmdLine.serial().printf("\r\n A-Z,a-z,0-9 -- reserved for application use"); // ArduinoPinsMonitor
whismanoid 22:a14c19b97d0b 2530 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 22:a14c19b97d0b 2531 //
whismanoid 22:a14c19b97d0b 2532
whismanoid 22:a14c19b97d0b 2533 extern void MAX5171_menu_help(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp\n
whismanoid 22:a14c19b97d0b 2534 MAX5171_menu_help(cmdLine);
whismanoid 22:a14c19b97d0b 2535 }
whismanoid 22:a14c19b97d0b 2536
whismanoid 22:a14c19b97d0b 2537
whismanoid 22:a14c19b97d0b 2538
whismanoid 22:a14c19b97d0b 2539 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 2540 // main menu command-line parser
whismanoid 22:a14c19b97d0b 2541 // invoked by CmdLine::append(char ch) or CmdLine::idleAppendIfReadable()
whismanoid 22:a14c19b97d0b 2542 void main_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 22:a14c19b97d0b 2543 {
whismanoid 22:a14c19b97d0b 2544 // DIAGNOSTIC: print line buffer
whismanoid 22:a14c19b97d0b 2545 //~ cmdLine.serial().printf("\r\nmain_menu_onEOLcommandParser: ~%s~\r\n", cmdLine.str());
whismanoid 22:a14c19b97d0b 2546 //
whismanoid 22:a14c19b97d0b 2547 switch (cmdLine[0])
whismanoid 22:a14c19b97d0b 2548 {
whismanoid 22:a14c19b97d0b 2549 case '?':
whismanoid 22:a14c19b97d0b 2550 main_menu_status(cmdLine);
whismanoid 22:a14c19b97d0b 2551 main_menu_help(cmdLine);
whismanoid 22:a14c19b97d0b 2552 // print command prompt
whismanoid 22:a14c19b97d0b 2553 //cmdLine.serial().printf("\r\n>");
whismanoid 22:a14c19b97d0b 2554 break;
whismanoid 22:a14c19b97d0b 2555 case '\r': case '\n': // ignore blank line
whismanoid 22:a14c19b97d0b 2556 case '\0': // ignore empty line
whismanoid 22:a14c19b97d0b 2557 case '#': // ignore comment line
whismanoid 22:a14c19b97d0b 2558 // # -- lines beginning with # are comments
whismanoid 22:a14c19b97d0b 2559 main_menu_status(cmdLine);
whismanoid 22:a14c19b97d0b 2560 //~ main_menu_help(cmdLine);
whismanoid 22:a14c19b97d0b 2561 // print command prompt
whismanoid 22:a14c19b97d0b 2562 //cmdLine.serial().printf("\r\n>");
whismanoid 22:a14c19b97d0b 2563 break;
whismanoid 22:a14c19b97d0b 2564 #if ECHO_EOF_ON_EOL
whismanoid 22:a14c19b97d0b 2565 case '\x04': // Unicode (U+0004) EOT END OF TRANSMISSION = CTRL+D as EOF end of file
whismanoid 22:a14c19b97d0b 2566 cmdLine.serial().printf("\x04"); // immediately echo EOF for test scripting
whismanoid 22:a14c19b97d0b 2567 diagnostic_led_EOF();
whismanoid 22:a14c19b97d0b 2568 break;
whismanoid 22:a14c19b97d0b 2569 case '\x1a': // Unicode (U+001A) SUB SUBSTITUTE = CTRL+Z as EOF end of file
whismanoid 22:a14c19b97d0b 2570 cmdLine.serial().printf("\x1a"); // immediately echo EOF for test scripting
whismanoid 22:a14c19b97d0b 2571 diagnostic_led_EOF();
whismanoid 22:a14c19b97d0b 2572 break;
whismanoid 22:a14c19b97d0b 2573 #endif
whismanoid 22:a14c19b97d0b 2574 #if APPLICATION_ArduinoPinsMonitor
whismanoid 22:a14c19b97d0b 2575 case '.':
whismanoid 22:a14c19b97d0b 2576 {
whismanoid 22:a14c19b97d0b 2577 // . -- SelfTest
whismanoid 22:a14c19b97d0b 2578 cmdLine.serial().printf("SelfTest()");
whismanoid 22:a14c19b97d0b 2579 SelfTest(cmdLine);
whismanoid 22:a14c19b97d0b 2580 }
whismanoid 22:a14c19b97d0b 2581 break;
whismanoid 22:a14c19b97d0b 2582 case '%':
whismanoid 22:a14c19b97d0b 2583 {
whismanoid 22:a14c19b97d0b 2584 pinsMonitor_submenu_onEOLcommandParser(cmdLine);
whismanoid 22:a14c19b97d0b 2585 }
whismanoid 22:a14c19b97d0b 2586 break; // case '%'
whismanoid 22:a14c19b97d0b 2587 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 22:a14c19b97d0b 2588 //
whismanoid 22:a14c19b97d0b 2589 // Application-specific commands here
whismanoid 22:a14c19b97d0b 2590 // alphanumeric command codes A-Z,a-z,0-9 reserved for application use
whismanoid 22:a14c19b97d0b 2591 //
whismanoid 22:a14c19b97d0b 2592 #if APPLICATION_ArduinoPinsMonitor
whismanoid 22:a14c19b97d0b 2593 #endif // APPLICATION_ArduinoPinsMonitor
whismanoid 22:a14c19b97d0b 2594
whismanoid 22:a14c19b97d0b 2595 //
whismanoid 22:a14c19b97d0b 2596 // add new commands here
whismanoid 22:a14c19b97d0b 2597 //
whismanoid 22:a14c19b97d0b 2598 default:
whismanoid 22:a14c19b97d0b 2599 extern bool MAX5171_menu_onEOLcommandParser(CmdLine & cmdLine); // defined in Test_Menu_MAX5171.cpp
whismanoid 22:a14c19b97d0b 2600 if (!MAX5171_menu_onEOLcommandParser(cmdLine))
whismanoid 22:a14c19b97d0b 2601 { // not_handled_by_device_submenu
whismanoid 22:a14c19b97d0b 2602 cmdLine.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str());
whismanoid 22:a14c19b97d0b 2603
whismanoid 22:a14c19b97d0b 2604 # if HAS_DAPLINK_SERIAL
whismanoid 22:a14c19b97d0b 2605 cmdLine_DAPLINKserial.serial().printf("\r\n unknown command 0x%2.2x \"%s\"\r\n", cmdLine.str()[0], cmdLine.str());
whismanoid 22:a14c19b97d0b 2606
whismanoid 22:a14c19b97d0b 2607 # endif // HAS_DAPLINK_SERIAL
whismanoid 22:a14c19b97d0b 2608 }
whismanoid 22:a14c19b97d0b 2609 } // switch (cmdLine[0])
whismanoid 22:a14c19b97d0b 2610 //
whismanoid 22:a14c19b97d0b 2611 // print command prompt
whismanoid 22:a14c19b97d0b 2612 cmdLine.serial().printf("\r\nMAX5171 > ");
whismanoid 22:a14c19b97d0b 2613
whismanoid 22:a14c19b97d0b 2614 } // end void main_menu_onEOLcommandParser(CmdLine & cmdLine)
whismanoid 22:a14c19b97d0b 2615
whismanoid 22:a14c19b97d0b 2616 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 2617 #if MAX5171_ONSPIPRINT
whismanoid 22:a14c19b97d0b 2618 // Optional Diagnostic function to print SPI transactions
whismanoid 22:a14c19b97d0b 2619 void onSPIprint_handler(size_t byteCount, uint8_t mosiData[], uint8_t misoData[])
whismanoid 22:a14c19b97d0b 2620 {
whismanoid 22:a14c19b97d0b 2621 cmdLine_serial.serial().printf("\r\nSPI MOSI->");
whismanoid 22:a14c19b97d0b 2622 for (uint8_t index = 0; index < byteCount; index++) {
whismanoid 22:a14c19b97d0b 2623 cmdLine_serial.serial().printf(" 0x%2.2X", mosiData[index]);
whismanoid 22:a14c19b97d0b 2624 }
whismanoid 22:a14c19b97d0b 2625 cmdLine_serial.serial().printf(" MISO<-");
whismanoid 22:a14c19b97d0b 2626 for (uint8_t index = 0; index < byteCount; index++) {
whismanoid 22:a14c19b97d0b 2627 cmdLine_serial.serial().printf(" 0x%2.2X", misoData[index]);
whismanoid 22:a14c19b97d0b 2628 }
whismanoid 22:a14c19b97d0b 2629 cmdLine_serial.serial().printf(" ");
whismanoid 22:a14c19b97d0b 2630 }
whismanoid 22:a14c19b97d0b 2631 #endif // MAX5171_ONSPIPRINT
whismanoid 22:a14c19b97d0b 2632
whismanoid 22:a14c19b97d0b 2633 //--------------------------------------------------
whismanoid 22:a14c19b97d0b 2634 void InitializeConfiguration()
whismanoid 22:a14c19b97d0b 2635 {
whismano